diff options
-rw-r--r-- | lib/tray/meson.build | 50 | ||||
-rw-r--r-- | lib/tray/trayItem.vala | 84 |
2 files changed, 53 insertions, 81 deletions
diff --git a/lib/tray/meson.build b/lib/tray/meson.build index fbb6672..cb7ab30 100644 --- a/lib/tray/meson.build +++ b/lib/tray/meson.build @@ -39,29 +39,9 @@ deps = [ dependency('gio-2.0'), dependency('json-glib-1.0'), dependency('gdk-pixbuf-2.0'), - dependency('gtk+-3.0'), + dependency('appmenu-glib-translator') ] -dbusmenu_cflags = run_command( - find_program('pkg-config', required: true), - '--cflags', 'dbusmenu-gtk3-0.4', - 'gobject-introspection-1.0', - 'gobject-2.0', - 'glib-2.0', - capture: true, - check: true, -).stdout().strip() - -dbusmenu_libs = run_command( - find_program('pkg-config', required: true), - '--libs', 'dbusmenu-gtk3-0.4', - 'gobject-introspection-1.0', - 'gobject-2.0', - 'glib-2.0', - capture: true, - check: true, -).stdout().strip() - sources = [config] + files('tray.vala', 'watcher.vala', 'trayItem.vala') if get_option('lib') @@ -71,15 +51,13 @@ if get_option('lib') dependencies: deps, vala_header: meson.project_name() + '.h', vala_vapi: meson.project_name() + '-' + api_version + '.vapi', - vala_args: ['--vapi-comments', '--pkg', 'DbusmenuGtk3-0.4', '--pkg', 'Dbusmenu-0.4'], + vala_args: ['--vapi-comments'], version: meson.project_version(), - c_args: dbusmenu_cflags.split(' '), - link_args: dbusmenu_libs.split(' '), install: true, - install_dir: true, + install_dir: [true, true, true], ) - pkgs = ['--pkg', 'DbusmenuGtk3-0.4', '--pkg', 'Dbusmenu-0.4'] + pkgs = [] foreach dep : deps pkgs += ['--pkg=' + dep.name()] endforeach @@ -120,31 +98,13 @@ if get_option('lib') requires: deps, install_dir: get_option('libdir') / 'pkgconfig', ) - # - # custom_target( - # typelib, - # command: [ - # find_program('g-ir-compiler'), - # '--output', '@OUTPUT@', - # '--shared-library', get_option('prefix') / get_option('libdir') / '@PLAINNAME@', - # meson.current_build_dir() / gir, - # ], - # input: lib, - # output: typelib, - # depends: lib, - # install: true, - # install_dir: get_option('libdir') / 'girepository-1.0', - # ) -endif + endif if get_option('cli') executable( meson.project_name(), ['cli.vala', sources], dependencies: deps, - vala_args: ['--pkg', 'DbusmenuGtk3-0.4', '--pkg', 'Dbusmenu-0.4'], - c_args: dbusmenu_cflags.split(' '), - link_args: dbusmenu_libs.split(' '), install: true, ) endif diff --git a/lib/tray/trayItem.vala b/lib/tray/trayItem.vala index db0e6d4..57f7a23 100644 --- a/lib/tray/trayItem.vala +++ b/lib/tray/trayItem.vala @@ -1,4 +1,3 @@ -using DbusmenuGtk; namespace AstalTray { public struct Pixmap { @@ -169,6 +168,22 @@ public class TrayItem : Object { /** the id of the item used to uniquely identify the TrayItems by this lib.*/ public string item_id { get; private set; } + private DBusMenu.Importer menu_importer; + + public MenuModel menu_model { + owned get { + if (menu_importer == null) return null; + return menu_importer.model; + } + } + + public ActionGroup action_group { + owned get { + if (menu_importer == null) return null; + return menu_importer.action_group; + } + } + public signal void changed(); public signal void ready(); @@ -197,6 +212,14 @@ public class TrayItem : Object { } }); + if(proxy.Menu != null) { + this.menu_importer = new DBusMenu.Importer(proxy.get_name_owner(), proxy.Menu); + this.menu_importer.notify["model"].connect(() => { + notify_property("menu-model"); + notify_property("action-group"); + }); + } + update_gicon(); ready(); @@ -217,17 +240,18 @@ public class TrayItem : Object { private void update_gicon() { if(icon_name != null && icon_name != "") { if(icon_theme_path != null && icon_theme_path != "") { - - Gtk.IconTheme icon_theme = new Gtk.IconTheme(); - string[] paths = {icon_theme_path}; - icon_theme.set_search_path(paths); - - int size = icon_theme.get_icon_sizes(icon_name)[0]; - Gtk.IconInfo icon_info = icon_theme.lookup_icon( - icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE); - - if (icon_info != null) - gicon = new GLib.FileIcon(GLib.File.new_for_path(icon_info.get_filename())); + //TODO: icon loopkup + + // Gtk.IconTheme icon_theme = new Gtk.IconTheme(); + // string[] paths = {icon_theme_path}; + // icon_theme.set_search_path(paths); + // + // int size = icon_theme.get_icon_sizes(icon_name)[0]; + // Gtk.IconInfo icon_info = icon_theme.lookup_icon( + // icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE); + // + // if (icon_info != null) + // gicon = new GLib.FileIcon(GLib.File.new_for_path(icon_info.get_filename())); } else { gicon = new GLib.ThemedIcon(icon_name); } @@ -312,18 +336,6 @@ public class TrayItem : Object { } } - /** - * creates a new Gtk Menu for this item. - */ - public Gtk.Menu? create_menu() { - if (proxy.Menu == null) - return null; - - return new DbusmenuGtk.Menu( - proxy.get_name_owner(), - proxy.Menu); - } - private Gdk.Pixbuf? _get_icon_pixbuf() { Pixmap[] pixmaps = proxy.Status == Status.NEEDS_ATTENTION ? proxy.AttentionIconPixmap @@ -351,18 +363,18 @@ public class TrayItem : Object { if (icon_name == "" || icon_name == null) return null; - - Gtk.IconTheme icon_theme = new Gtk.IconTheme(); - string[] paths = {theme_path}; - icon_theme.set_search_path(paths); - - int size = icon_theme.get_icon_sizes(icon_name)[0]; - Gtk.IconInfo icon_info = icon_theme.lookup_icon( - icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE); - - if (icon_info != null) - return icon_info.load_icon(); - + // + // Gtk.IconTheme icon_theme = new Gtk.IconTheme(); + // string[] paths = {theme_path}; + // icon_theme.set_search_path(paths); + // + // int size = icon_theme.get_icon_sizes(icon_name)[0]; + // Gtk.IconInfo icon_info = icon_theme.lookup_icon( + // icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE); + // + // if (icon_info != null) + // return icon_info.load_icon(); + // return null; } |