Skip to content

Commit

Permalink
Lib: move registrar reference to backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Feb 16, 2018
1 parent 0173b7c commit f5c6e07
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 38 deletions.
36 changes: 34 additions & 2 deletions lib/appmenu-abstractions.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 2 additions & 36 deletions lib/menu-widget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit f5c6e07

Please sign in to comment.