void GtkDBusInit() { /* setup ApplicationMenu */ dbusMenu = new MenuStripDBusMenu(pluginHost.MainWindow.MainMenu); emptyDBusMenu = new MenuStripDBusMenu(new MenuStrip()); var sessionBus = Bus.Session; #if DEBUG const string dbusBusPath = "/org/freedesktop/DBus"; const string dbusBusName = "org.freedesktop.DBus"; var dbusObjectPath = new ObjectPath(dbusBusPath); var dbusService = sessionBus.GetObject <org.freedesktop.DBus.IBus>(dbusBusName, dbusObjectPath); dbusService.NameAcquired += (name) => Console.WriteLine("NameAcquired: " + name); #endif const string registrarBusPath = "/com/canonical/AppMenu/Registrar"; const string registratBusName = "com.canonical.AppMenu.Registrar"; var registrarObjectPath = new ObjectPath(registrarBusPath); unityPanelServiceBus = sessionBus.GetObject <com.canonical.AppMenu.Registrar.IRegistrar>(registratBusName, registrarObjectPath); mainFormXid = GetWindowXid(pluginHost.MainWindow); mainFormObjectPath = new ObjectPath(string.Format(menuPath, mainFormXid)); sessionBus.Register(mainFormObjectPath, dbusMenu); try { unityPanelServiceBus.RegisterWindow((uint)mainFormXid.ToInt32(), mainFormObjectPath); } catch (Exception) { if (!pluginHost.CustomConfig.GetBool(keebuntuAppMenuWarningSeenId, false)) { Task.Run((Action)ShowErrorMessage); } DBusBackgroundWorker.InvokeWinformsThread(() => Terminate()); } }
void GtkDBusInit() { /* setup ApplicationMenu */ dbusMenu = new MenuStripDBusMenu(pluginHost.MainWindow.MainMenu); emptyDBusMenu = new MenuStripDBusMenu(new MenuStrip()); var sessionBus = Bus.Session; #if DEBUG const string dbusBusPath = "/org/freedesktop/DBus"; const string dbusBusName = "org.freedesktop.DBus"; var dbusObjectPath = new ObjectPath(dbusBusPath); var dbusService = sessionBus.GetObject <org.freedesktop.DBus.IBus>(dbusBusName, dbusObjectPath); dbusService.NameAcquired += (name) => Console.WriteLine("NameAcquired: " + name); #endif const string registrarBusPath = "/com/canonical/AppMenu/Registrar"; const string registratBusName = "com.canonical.AppMenu.Registrar"; var registrarObjectPath = new ObjectPath(registrarBusPath); unityPanelServiceBus = sessionBus.GetObject <com.canonical.AppMenu.Registrar.IRegistrar>(registratBusName, registrarObjectPath); mainFormXid = GetWindowXid(pluginHost.MainWindow); mainFormObjectPath = new ObjectPath(string.Format(menuPath, mainFormXid)); sessionBus.Register(mainFormObjectPath, dbusMenu); try { unityPanelServiceBus.RegisterWindow((uint)mainFormXid.ToInt32(), mainFormObjectPath); gtkInitOk = true; gtkInitDoneEvent.Set(); } catch (Exception) { gtkInitDoneEvent.Set(); if (!pluginHost.CustomConfig.GetBool(keebuntuAppMenuWarningSeenId, false)) { using (var dialog = new Gtk.Dialog()) { dialog.BorderWidth = 6; dialog.Resizable = false; dialog.HasSeparator = false; var message = "<span weight=\"bold\"size=\"larger\">" + "Could not register KeebuntuAppMenu with Unity panel service." + "</span>\n\n" + "This plugin only works with Ubuntu Unity desktop." + " If you do not use Unity, you should uninstall the KeebuntuAppMenu plugin." + "\n"; var label = new Gtk.Label(message); label.UseMarkup = true; label.Wrap = true; label.Yalign = 0; var icon = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Dialog); icon.Yalign = 0; var contentBox = new Gtk.HBox(); contentBox.Spacing = 12; contentBox.BorderWidth = 6; contentBox.PackStart(icon); contentBox.PackEnd(label); dialog.VBox.PackStart(contentBox); dialog.AddButton("Don't show this again", Gtk.ResponseType.Accept); dialog.AddButton("OK", Gtk.ResponseType.Ok); dialog.DefaultResponse = Gtk.ResponseType.Ok; dialog.Response += (o, args) => { dialog.Destroy(); if (args.ResponseId == Gtk.ResponseType.Accept) { pluginHost.CustomConfig.SetBool(keebuntuAppMenuWarningSeenId, true); } }; dialog.ShowAll(); dialog.KeepAbove = true; dialog.Run(); } DBusBackgroundWorker.Stop(); } } }