コード例 #1
0
 public override void Terminate()
 {
     pluginHost.MainWindow.Activated += MainWindow_Activated;
     pluginHost.MainWindow.Resize    -= MainWindow_Resize;
     aboutToShowSignal.RemoveDelegate((EventHandler)OnAppIndicatorMenuShown);
     appIndicatorMenu.Shown -= OnAppIndicatorMenuShown;
     try {
         DBusBackgroundWorker.Stop();
     } catch (Exception ex) {
         Debug.Fail(ex.ToString());
     }
 }
コード例 #2
0
 public override void Terminate()
 {
     try {
         pluginHost.MainWindow.Activated   -= MainWindow_Activated;
         GlobalWindowManager.WindowAdded   -= GlobalWindowManager_WindowAdded;
         GlobalWindowManager.WindowRemoved -= GlobalWindowManager_WindowRemoved;
         DBusBackgroundWorker.InvokeWinformsThread(() => {
             pluginHost.MainWindow.MainMenu.Visible = true;
         });
         DBusBackgroundWorker.Stop();
     } catch (Exception ex) {
         Debug.Fail(ex.ToString());
     }
 }
コード例 #3
0
        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();
                }
            }
        }