From 0892f485f96e827f9869656c2daa6ed8a165b15f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Jun 2011 16:34:22 +0200 Subject: track specific items proxying nicely --- src/specific-items-manager.vala | 71 +++++++++++++++++++++++++++++++++++ src/track-specific-items-manager.vala | 71 ----------------------------------- 2 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 src/specific-items-manager.vala delete mode 100644 src/track-specific-items-manager.vala (limited to 'src') diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala new file mode 100644 index 0000000..3fa7663 --- /dev/null +++ b/src/specific-items-manager.vala @@ -0,0 +1,71 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Dbusmenu; +using Gee; + +public class SpecificItemsManager : GLib.Object +{ + private PlayerController owner {get; set;} + private string dbus_path; + private Dbusmenu.Client client; + private Gee.ArrayList proxy_items; + + public SpecificItemsManager (PlayerController controller, string path) + { + this.proxy_items = new ArrayList(); + this.owner = controller; + this.dbus_path = path; + this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); + this.client.root_changed.connect (on_root_changed); + } + + private void on_root_changed (GLib.Object newroot) + { + Dbusmenu.Menuitem root = this.client.get_root(); + root.child_added.connect (on_child_added); + root.child_removed.connect (on_child_removed); + + // Fetch what children are there already. + GLib.List children = root.get_children().copy(); + + debug ("on_root_changed - size of children list : %i", + (int)children.length()); + foreach (void* child in children) { + unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child; + Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item); + proxy_items.add (proxy); + debug ("Proxy item of label = %s added to collection", + item.property_get (MENUITEM_PROP_LABEL)); + this.owner.root_menu.child_add_position (proxy, + this.owner.menu_offset + 3); + } + } + + private void on_child_added (GLib.Object child, uint position) + { + debug ("On child added Specific root node"); + } + + private void on_child_removed (GLib.Object child) + { + debug ("On child removed Specific root node"); + } + +} diff --git a/src/track-specific-items-manager.vala b/src/track-specific-items-manager.vala deleted file mode 100644 index 67b8bbf..0000000 --- a/src/track-specific-items-manager.vala +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright 2011 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -using Dbusmenu; -using Gee; - -public class SpecificItemsManager : GLib.Object -{ - private PlayerController owner {get; set;} - private string dbus_path; - private Dbusmenu.Client client; - private Gee.ArrayList proxy_items; - - public SpecificItemsManager (PlayerController controller, string path) - { - this.proxy_items = new ArrayList(); - this.owner = controller; - this.dbus_path = path; - this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); - this.client.root_changed.connect (on_root_changed); - } - - private void on_root_changed (GLib.Object newroot) - { - Dbusmenu.Menuitem root = this.client.get_root(); - root.child_added.connect (on_child_added); - root.child_removed.connect (on_child_removed); - - // Fetch what children are there already. - GLib.List children = root.get_children().copy(); - - debug ("on_root_changed - size of children list : %i", - (int)children.length()); - foreach (void* child in children) { - Dbusmenu.Menuitem* item = (Dbusmenu.Menuitem*)child; - Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(*item); - proxy_items.add (proxy); - debug ("Proxy item of label = %s added to collection", - item->property_get (MENUITEM_PROP_LABEL)); - this.owner.root_menu.child_add_position (proxy.menu_item, - this.owner.menu_offset + 3); - } - } - - private void on_child_added (GLib.Object child, uint position) - { - debug ("On child added Specific root node"); - } - - private void on_child_removed (GLib.Object child) - { - debug ("On child removed Specific root node"); - } - -} -- cgit v1.2.3