Skip to content

Commit

Permalink
Merge pull request #9 from equeim/work
Browse files Browse the repository at this point in the history
Work
  • Loading branch information
equeim authored Dec 1, 2024
2 parents 7192d34 + 171bd26 commit e9d5afb
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 24 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:

jobs:
build-debian:
runs-on: ubuntu-latest
container: "debian:12"

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends --assume-yes install gcc meson valac libxfce4panel-2.0-dev libasound2-dev gettext
- name: Build
run: |
meson setup build
meson compile -C build -v
build-tumbleweed:
strategy:
fail-fast: false
matrix:
with-419: [ true, false ]

runs-on: ubuntu-latest
container: "opensuse/tumbleweed:latest"

steps:
- uses: actions/checkout@v4

- name: Add XFCE 4.19 repo
if: matrix.with-419
run: |
zypper ar -p 90 https://download.opensuse.org/repositories/X11:/xfce:/4.19/openSUSE_Tumbleweed/X11:xfce:4.19.repo
- name: Install dependencies
run: |
zypper --non-interactive --gpg-auto-import-keys in --no-recommends --details gcc meson vala xfce4-panel-devel alsa-devel gettext
- name: Build
run: |
meson setup build
meson compile -C build -v
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Simple ALSA volume control for xfce4-panel

### Building
```sh
# meson build -Dgtk3=true
meson build
ninja -C build
ninja -C build install
meson setup build
meson compile -C build
meson install -C build
```
13 changes: 12 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ add_project_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), la
add_project_arguments('-DPACKAGE_NAME="@0@"'.format(meson.project_name()), language : 'c')
add_project_arguments('-DLOCALEDIR="@0@"'.format(join_paths(get_option('prefix'), get_option('localedir'))), language : 'c')

# Suppress GCC warning about unused variables in generated code
add_project_arguments('-Wno-unused-variable', language: 'c')
add_project_arguments('-Wno-unused-value', language: 'c')
add_project_arguments('-Wno-unused-but-set-variable', language: 'c')

libxfce4panel_dep = dependency('libxfce4panel-2.0', version : '>= 4.13.0')
message(libxfce4panel_dep.version())
if libxfce4panel_dep.version().version_compare('>= 4.19.0')
add_project_arguments('--define=XFCE_420', language : 'vala')
endif

dependencies = [dependency('alsa'),
dependency('gtk+-3.0', version : '>= 3.20.0'),
dependency('libxfce4panel-2.0', version : '>= 4.13.0'),
libxfce4panel_dep,
meson.get_compiler('vala').find_library('config', dirs : vapi_dir)]

shared_library('alsa',
Expand Down
56 changes: 38 additions & 18 deletions src/vapi/libxfce4panel-2.0.vapi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* libxfce4panel-2.0.vapi generated by vapigen, do not modify. */
/* libxfce4panel-2.0.vapi generated by vapigen-0.56, do not modify. */

[CCode (cprefix = "Xfce", gir_namespace = "libxfce4panel", gir_version = "2.0", lower_case_cprefix = "xfce_")]
[CCode (cprefix = "Xfce", gir_namespace = "Libxfce4panel", gir_version = "2.0", lower_case_cprefix = "xfce_")]
namespace Xfce {
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", type_id = "xfce_arrow_button_get_type ()")]
public class ArrowButton : Gtk.ToggleButton, Atk.Implementor, Gtk.Actionable, Gtk.Activatable, Gtk.Buildable {
Expand All @@ -18,28 +18,31 @@ namespace Xfce {
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", type_id = "xfce_panel_image_get_type ()")]
public class PanelImage : Gtk.Widget, Atk.Implementor, Gtk.Buildable {
[CCode (has_construct_function = false, type = "GtkWidget*")]
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public PanelImage ();
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public void clear ();
[CCode (has_construct_function = false, type = "GtkWidget*")]
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public PanelImage.from_pixbuf (Gdk.Pixbuf? pixbuf);
[CCode (has_construct_function = false, type = "GtkWidget*")]
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public PanelImage.from_source (string? source);
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public int get_size ();
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public void set_from_pixbuf (Gdk.Pixbuf? pixbuf);
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public void set_from_source (string? source);
[Version (since = "4.8")]
[Version (deprecated = true, deprecated_since = "4.18.1", since = "4.8")]
public void set_size (int size);
[NoAccessorMethod]
[Version (deprecated = true, deprecated_since = "4.18.1")]
public Gdk.Pixbuf pixbuf { owned get; set; }
[Version (deprecated = true, deprecated_since = "4.18.1")]
public int size { get; set; }
[NoAccessorMethod]
[Version (deprecated = true, deprecated_since = "4.18.1")]
public string source { owned get; set; }
}
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", type_id = "xfce_panel_plugin_get_type ()")]
Expand Down Expand Up @@ -77,9 +80,15 @@ namespace Xfce {
[Version (since = "4.10")]
public bool get_small ();
public string lookup_rc_file ();
public void menu_destroy ();
public void menu_insert_item (Gtk.MenuItem item);
public void menu_show_about ();
public void menu_show_configure ();
[Version (since = "4.17.2")]
public void popup_menu (Gtk.Menu menu, Gtk.Widget? widget, Gdk.Event? trigger_event);
[Version (since = "4.19.0")]
public void popup_window (Gtk.Window window, Gtk.Widget? widget);
[Version (deprecated = true, deprecated_since = "4.17.2")]
public static void position_menu (Gtk.Menu menu, out int x, out int y, bool push_in, void* panel_plugin);
public void position_widget (Gtk.Widget menu_widget, Gtk.Widget? attach_widget, out int x, out int y);
public void register_menu (Gtk.Menu menu);
Expand All @@ -96,6 +105,9 @@ namespace Xfce {
public string[] arguments { get; construct; }
[Version (since = "4.8")]
public string comment { get; construct; }
[NoAccessorMethod]
[Version (since = "4.14")]
public bool dark_mode { get; set; }
public string display_name { get; construct; }
public bool expand { get; set; }
[Version (since = "4.14")]
Expand Down Expand Up @@ -140,8 +152,10 @@ namespace Xfce {
public abstract bool get_show_about ();
public abstract bool get_show_configure ();
public abstract int get_unique_id ();
public abstract bool remote_event (string name, GLib.Value value, uint handle);
public abstract void removed ();
public abstract void save ();
public abstract void set_dark_mode (bool dark_mode);
public abstract void set_icon_size (int icon_size);
public abstract void set_locked (bool locked);
public abstract void set_mode (Xfce.PanelPluginMode mode);
Expand All @@ -163,14 +177,13 @@ namespace Xfce {
public enum PanelPluginProviderPropType {
SET_SIZE,
SET_ICON_SIZE,
SET_DARK_MODE,
SET_MODE,
SET_SCREEN_POSITION,
SET_BACKGROUND_ALPHA,
SET_NROWS,
SET_LOCKED,
SET_SENSITIVE,
SET_BACKGROUND_COLOR,
SET_BACKGROUND_IMAGE,
ACTION_REMOVED,
ACTION_SAVE,
ACTION_QUIT,
Expand All @@ -179,7 +192,11 @@ namespace Xfce {
ACTION_SHOW_CONFIGURE,
ACTION_SHOW_ABOUT,
ACTION_ASK_REMOVE,
SET_OPACITY
SET_OPACITY,
SET_BACKGROUND_COLOR,
SET_BACKGROUND_IMAGE,
SET_MONITOR,
SET_GEOMETRY
}
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", cprefix = "PROVIDER_SIGNAL_", has_type_id = false)]
public enum PanelPluginProviderSignal {
Expand Down Expand Up @@ -238,19 +255,19 @@ namespace Xfce {
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", cname = "LIBXFCE4PANEL_MINOR_VERSION")]
[Version (since = "4.8")]
public const int MINOR_VERSION;
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", cname = "XFCE_PANEL_PLUGIN_ICON_PADDING")]
[Version (since = "4.19.6")]
public const int PANEL_PLUGIN_ICON_PADDING;
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", cname = "LIBXFCE4PANEL_VERSION")]
[Version (since = "4.8")]
public const string VERSION;
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", cname = "xfce_allow_panel_customization")]
[Version (deprecated = true, deprecated_since = "4.8")]
public const bool allow_panel_customization;
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h", cname = "libxfce4panel_check_version")]
[Version (since = "4.8")]
public static unowned string check_version (uint required_major, uint required_minor, uint required_micro);
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h")]
public static Gtk.Widget panel_create_button ();
public static unowned Gtk.Widget panel_create_button ();
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h")]
public static Gtk.Widget panel_create_toggle_button ();
public static unowned Gtk.Widget panel_create_toggle_button ();
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h")]
[Version (since = "4.8")]
public static unowned string panel_get_channel_name ();
Expand All @@ -260,4 +277,7 @@ namespace Xfce {
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h")]
[Version (since = "4.10")]
public static Gdk.Pixbuf panel_pixbuf_from_source_at_size (string source, Gtk.IconTheme? icon_theme, int dest_width, int dest_height);
[CCode (cheader_filename = "libxfce4panel/libxfce4panel.h")]
[Version (since = "4.17.4")]
public static void panel_set_image_from_source (Gtk.Image image, string source, Gtk.IconTheme? icon_theme, int size, int scale);
}
15 changes: 14 additions & 1 deletion src/volumebutton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ namespace AlsaPlugin {
volume_popup = new VolumePopup(plugin);
volume_popup.show.connect(() => {
this.active = true;
#if !XFCE_420
position_popup();
#endif
});
volume_popup.hide.connect(() => { this.active = false; });

plugin.small = true;
plugin.size_changed.connect((size) => {
update();
#if !XFCE_420
position_popup();
#endif
return true;
});

plugin.mode_changed.connect((mode) => {
stdout.printf("mode_changed called.\n");
stdout.printf("mode_changed called.\n");
update();
#if !XFCE_420
position_popup();
#endif
});

alsa.state_changed.connect(update);
Expand Down Expand Up @@ -100,6 +106,7 @@ namespace AlsaPlugin {
}
}

#if !XFCE_420
private void position_popup() {
if (volume_popup.visible) {
int x = 0;
Expand All @@ -108,14 +115,20 @@ namespace AlsaPlugin {
volume_popup.move(x, y);
}
}
#endif

bool on_button_press_event(Gdk.EventButton event) {
if (event.type == Gdk.EventType.BUTTON_PRESS) {
switch (event.button) {
case 1:
{
if (alsa.configured) {
#if XFCE_420
plugin.popup_window(volume_popup, null);
#else
volume_popup.show_all();
#endif

}
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions src/volumepopup.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ namespace AlsaPlugin {
private Plugin plugin;
private Gtk.Box scale_container;
private Gtk.Scale scale;
#if !XFCE_420
private Gdk.Seat seat = null;
#endif

public VolumePopup(Plugin plugin) {
#if XFCE_420
Object(type: Gtk.WindowType.TOPLEVEL);
#else
Object(type: Gtk.WindowType.POPUP);
#endif
this.plugin = plugin;

var frame = new Gtk.Frame(null);
Expand All @@ -38,6 +44,8 @@ namespace AlsaPlugin {

setup_scale();

frame.show_all();

alsa.state_changed.connect(() => {
scale.set_value(alsa.volume);
});
Expand All @@ -46,12 +54,14 @@ namespace AlsaPlugin {
reset_scale();
});

#if !XFCE_420
show.connect(on_show);
hide.connect(on_hide);
button_press_event.connect(on_button_press_event);
grab_broken_event.connect(on_grab_broken_event);
grab_notify.connect(on_grab_notify);
key_release_event.connect(on_key_release_event);
#endif
}

private void setup_scale() {
Expand All @@ -73,8 +83,10 @@ namespace AlsaPlugin {
scale_container.remove(scale);
scale = null;
setup_scale();
scale.show();
}

#if !XFCE_420
private void on_show() {
if (seat != null) {
seat.ungrab();
Expand Down Expand Up @@ -138,5 +150,6 @@ namespace AlsaPlugin {
}
return false;
}
#endif
}
}

0 comments on commit e9d5afb

Please sign in to comment.