diff --git a/lib/appmenu-abstractions.vala b/lib/appmenu-abstractions.vala index bc303155..2e7ed967 100644 --- a/lib/appmenu-abstractions.vala +++ b/lib/appmenu-abstractions.vala @@ -41,9 +41,41 @@ namespace Appmenu { proxy = new DBusMenuRegistrarProxy(); } - protected Backend() + construct { - + try + { + var con = Bus.get_sync(BusType.SESSION); + con.call.begin( + "org.valapanel.AppMenu.Registrar", + "/Registrar", + "org.valapanel.AppMenu.Registrar", + "Reference", + null,null, + DBusCallFlags.NONE, -1); + } + catch(Error e) + { + stderr.printf("%s\n",e.message); + } + } + ~Backend() + { + try + { + var con = Bus.get_sync(BusType.SESSION,null); + con.call.begin( + "org.valapanel.AppMenu.Registrar", + "/Registrar", + "org.valapanel.AppMenu.Registrar", + "UnReference", + null,null, + DBusCallFlags.NO_AUTO_START, -1); + } + catch(Error e) + { + stderr.printf("%s\n",e.message); + } } public signal void active_model_changed(); public abstract void set_active_window_menu(MenuWidget widget); diff --git a/lib/menu-widget.vala b/lib/menu-widget.vala index 3afb03b7..1a0375e8 100644 --- a/lib/menu-widget.vala +++ b/lib/menu-widget.vala @@ -37,6 +37,7 @@ namespace Appmenu private GLib.MenuModel? menubar = null; private Backend backend = new BackendBAMF(); private Gtk.MenuBar mwidget = new Gtk.MenuBar(); + private ulong backend_connector = 0; construct { provider = new Gtk.CssProvider(); @@ -45,7 +46,7 @@ namespace Appmenu context.add_class("-vala-panel-appmenu-core"); unowned Gtk.StyleContext mcontext = mwidget.get_style_context(); Signal.connect(this,"notify",(GLib.Callback)restock,null); - backend.active_model_changed.connect(()=>{ + backend_connector = backend.active_model_changed.connect(()=>{ Timeout.add(50,()=>{ backend.set_active_window_menu(this); return Source.REMOVE; @@ -67,46 +68,11 @@ namespace Appmenu this.add(scroller); scroller.add(mwidget); this.show_all(); - try - { - var con = Bus.get_sync(BusType.SESSION); - con.call.begin( - "org.valapanel.AppMenu.Registrar", - "/Registrar", - "org.valapanel.AppMenu.Registrar", - "Reference", - null,null, - DBusCallFlags.NONE, -1); - - } - catch(Error e) - { - stderr.printf("%s\n",e.message); - } } public MenuWidget() { Object(); } - ~MenuWidget() - { - try - { - var con = Bus.get_sync(BusType.SESSION,null); - con.call.begin( - "org.valapanel.AppMenu.Registrar", - "/Registrar", - "org.valapanel.AppMenu.Registrar", - "UnReference", - null,null, - DBusCallFlags.NO_AUTO_START, -1); - - } - catch(Error e) - { - stderr.printf("%s\n",e.message); - } - } private void restock() { unowned Gtk.StyleContext mcontext = mwidget.get_style_context();