diff options
Diffstat (limited to 'lib/tray')
l--------- | lib/tray/gir.py | 1 | ||||
-rw-r--r-- | lib/tray/meson.build | 64 | ||||
-rw-r--r-- | lib/tray/tray.vala | 30 | ||||
-rw-r--r-- | lib/tray/trayItem.vala | 77 |
4 files changed, 140 insertions, 32 deletions
diff --git a/lib/tray/gir.py b/lib/tray/gir.py new file mode 120000 index 0000000..b5b4f1d --- /dev/null +++ b/lib/tray/gir.py @@ -0,0 +1 @@ +../gir.py
\ No newline at end of file diff --git a/lib/tray/meson.build b/lib/tray/meson.build index 421f33d..fbb6672 100644 --- a/lib/tray/meson.build +++ b/lib/tray/meson.build @@ -3,7 +3,7 @@ project( 'vala', 'c', version: run_command('cat', join_paths(meson.project_source_root(), 'version')).stdout().strip(), - meson_version: '>= 0.62.0', + meson_version: '>= 0.63.0', default_options: [ 'warning_level=2', 'werror=false', @@ -18,8 +18,9 @@ assert( version_split = meson.project_version().split('.') api_version = version_split[0] + '.' + version_split[1] -gir = 'AstalTray-' + api_version + '.gir' -typelib = 'AstalTray-' + api_version + '.typelib' +namespace = 'AstalTray' +gir = namespace + '-' + api_version + '.gir' +typelib = namespace + '-' + api_version + '.typelib' config = configure_file( input: 'config.vala.in', @@ -61,7 +62,7 @@ dbusmenu_libs = run_command( check: true, ).stdout().strip() -sources = [config, 'tray.vala', 'watcher.vala', 'trayItem.vala'] +sources = [config] + files('tray.vala', 'watcher.vala', 'trayItem.vala') if get_option('lib') lib = library( @@ -70,23 +71,29 @@ if get_option('lib') dependencies: deps, vala_header: meson.project_name() + '.h', vala_vapi: meson.project_name() + '-' + api_version + '.vapi', - vala_gir: gir, - vala_args: ['--pkg', 'DbusmenuGtk3-0.4', '--pkg', 'Dbusmenu-0.4'], + vala_args: ['--vapi-comments', '--pkg', 'DbusmenuGtk3-0.4', '--pkg', 'Dbusmenu-0.4'], version: meson.project_version(), c_args: dbusmenu_cflags.split(' '), link_args: dbusmenu_libs.split(' '), install: true, - install_dir: [true, true, true, true], + install_dir: true, ) - import('pkgconfig').generate( - lib, - name: meson.project_name(), - filebase: meson.project_name() + '-' + api_version, - version: meson.project_version(), - subdirs: meson.project_name(), - requires: deps, - install_dir: get_option('libdir') / 'pkgconfig', + pkgs = ['--pkg', 'DbusmenuGtk3-0.4', '--pkg', 'Dbusmenu-0.4'] + foreach dep : deps + pkgs += ['--pkg=' + dep.name()] + endforeach + + gir_tgt = custom_target( + gir, + command: [find_program('python3'), files('gir.py'), meson.project_name(), gir] + + pkgs + + sources, + input: sources, + depends: lib, + output: gir, + install: true, + install_dir: get_option('datadir') / 'gir-1.0', ) custom_target( @@ -99,10 +106,35 @@ if get_option('lib') ], input: lib, output: typelib, - depends: lib, + depends: [lib, gir_tgt], install: true, install_dir: get_option('libdir') / 'girepository-1.0', ) + + import('pkgconfig').generate( + lib, + name: meson.project_name(), + filebase: meson.project_name() + '-' + api_version, + version: meson.project_version(), + subdirs: meson.project_name(), + 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 if get_option('cli') diff --git a/lib/tray/tray.vala b/lib/tray/tray.vala index 09b0643..4ea6765 100644 --- a/lib/tray/tray.vala +++ b/lib/tray/tray.vala @@ -2,7 +2,7 @@ namespace AstalTray { [DBus (name="org.kde.StatusNotifierWatcher")] internal interface IWatcher : Object { public abstract string[] RegisteredStatusNotifierItems { owned get; } - public abstract int ProtocolVersion { owned get; } + public abstract int ProtocolVersion { get; } public abstract void RegisterStatusNotifierItem(string service, BusName sender) throws DBusError, IOError; public abstract void RegisterStatusNotifierHost(string service) throws DBusError, IOError; @@ -12,13 +12,19 @@ internal interface IWatcher : Object { public signal void StatusNotifierHostRegistered(); public signal void StatusNotifierHostUnregistered(); } - +/** + * Get the singleton instance of [[email protected]] + */ public Tray get_default() { return Tray.get_default(); } public class Tray : Object { private static Tray? instance; + + /** + * Get the singleton instance of [[email protected]] + */ public static unowned Tray get_default() { if (instance == null) instance = new Tray(); @@ -32,13 +38,22 @@ public class Tray : Object { private HashTable<string, TrayItem> _items = new HashTable<string, TrayItem>(str_hash, str_equal); + /** + * List of currently registered tray items + */ public List<weak TrayItem> items { owned get { return _items.get_values(); }} - public signal void item_added(string service) { + /** + * emitted when a new tray item was added. + */ + public signal void item_added(string item_id) { notify_property("items"); } - public signal void item_removed(string service) { + /** + * emitted when a tray item was removed. + */ + public signal void item_removed(string item_id) { notify_property("items"); } @@ -128,8 +143,11 @@ public class Tray : Object { item_removed(service); } - public TrayItem get_item(string service) { - return _items.get(service); + /** + * gets the TrayItem with the given item-id. + */ + public TrayItem get_item(string item_id) { + return _items.get(item_id); } } } diff --git a/lib/tray/trayItem.vala b/lib/tray/trayItem.vala index d5e8603..16bc05b 100644 --- a/lib/tray/trayItem.vala +++ b/lib/tray/trayItem.vala @@ -57,12 +57,12 @@ public enum Status { [DBus (name="org.kde.StatusNotifierItem")] internal interface IItem : DBusProxy { public abstract string Title { owned get; } - public abstract Category Category { owned get; } - public abstract Status Status { owned get; } + public abstract Category Category { get; } + public abstract Status Status { get; } public abstract Tooltip? ToolTip { owned get; } public abstract string Id { owned get; } public abstract string? IconThemePath { owned get; } - public abstract bool ItemIsMenu { owned get; } + public abstract bool ItemIsMenu { get; } public abstract ObjectPath? Menu { owned get; } public abstract string IconName { owned get; } public abstract Pixmap[] IconPixmap { owned get; } @@ -88,11 +88,23 @@ public class TrayItem : Object { private IItem proxy; private List<ulong> connection_ids; + + /** The Title of the TrayItem */ public string title { owned get { return proxy.Title; } } + + /** The category this item belongs to */ public Category category { get { return proxy.Category; } } + + /** the current status of this item */ public Status status { get { return proxy.Status; } } + + /** the tooltip of this item */ public Tooltip? tooltip { owned get { return proxy.ToolTip; } } - + + /** + * a markup representation of the tooltip. This is basically equvivalent + * to `tooltip.title \n tooltip.description` + */ public string tooltip_markup { owned get { if (proxy.ToolTip == null) @@ -106,10 +118,30 @@ public class TrayItem : Object { } } + /** the id of the item. This id is specified by the tray app.*/ public string id { owned get { return proxy.Id ;} } - public string icon_theme_path { owned get { return proxy.IconThemePath ;} } + + /** + * If set, this only supports the menu, so showing the menu should be prefered + * over calling [[email protected]]. + */ public bool is_menu { get { return proxy.ItemIsMenu ;} } - + + /** + * the icon theme path, where to look for the [[email protected]:icon-name]. + * + * It is recommended to use the [[email protected]:gicon] property, + * which does the icon lookups for you. + */ + public string icon_theme_path { owned get { return proxy.IconThemePath ;} } + + /** + * the name of the icon. This should be looked up in the [[email protected]:icon-theme-path] + * if set or in the currently used icon theme otherwise. + * + * It is recommended to use the [[email protected]:gicon] property, + * which does the icon lookups for you. + */ public string icon_name { owned get { return proxy.Status == Status.NEEDS_ATTENTION @@ -117,17 +149,30 @@ public class TrayItem : Object { : proxy.IconName; } } - + + /** + * a pixbuf containing the icon. + * + * It is recommended to use the [[email protected]:gicon] property, + * which does the icon lookups for you. + */ public Gdk.Pixbuf icon_pixbuf { owned get { return _get_icon_pixbuf(); } } + /** + * contains the items icon. This property is intended to be used with the gicon property + * of the Icon widget and the recommended way to display the icon. + * This property unifies the [[email protected]:icon-name], + * [[email protected]:icon-theme-path] and [[email protected]:icon-pixbuf] properties. + */ public GLib.Icon gicon { get; private set; } + /** the id of the item used to uniquely identify the TrayItems by this lib.*/ public string item_id { get; private set; } public signal void changed(); public signal void ready(); - public TrayItem(string service, string path) { + internal TrayItem(string service, string path) { connection_ids = new List<ulong>(); item_id = service + path; setup_proxy.begin(service, path, (_, res) => setup_proxy.end(res)); @@ -229,7 +274,10 @@ public class TrayItem : Object { } ); } - + + /** + * send an activate request to the tray app. + */ public void activate(int x, int y) { try { proxy.Activate(x, y); @@ -239,6 +287,9 @@ public class TrayItem : Object { } } + /** + * send a secondary activate request to the tray app. + */ public void secondary_activate(int x, int y) { try { proxy.SecondaryActivate(x, y); @@ -248,6 +299,10 @@ public class TrayItem : Object { } } + /** + * send a scroll request to the tray app. + * valid values for the orientation are "horizontal" and "vertical". + */ public void scroll(int delta, string orientation) { try { proxy.Scroll(delta, orientation); @@ -257,7 +312,9 @@ public class TrayItem : Object { } } - + /** + * creates a new Gtk Menu for this item. + */ public Gtk.Menu? create_menu() { if (proxy.Menu == null) return null; |