예제 #1
0
        public override bool Initialize(IPluginHost host)
        {
            pluginHost = host;

            // mimmic behavior of other ubuntu apps
            hideMenuInApp =
                Environment.GetEnvironmentVariable("APPMENU_DISPLAY_BOTH") != "1";
            bool threadStarted = false;

            try {
                DBusBackgroundWorker.Request();
                threadStarted = true;
                DBusBackgroundWorker.InvokeGtkThread((Action)GtkDBusInit).Wait();

                if (hideMenuInApp)
                {
                    pluginHost.MainWindow.MainMenu.Visible = false;
                }
                pluginHost.MainWindow.Activated   += MainWindow_Activated;
                GlobalWindowManager.WindowAdded   += GlobalWindowManager_WindowAdded;
                GlobalWindowManager.WindowRemoved += GlobalWindowManager_WindowRemoved;
            } catch (Exception ex) {
                Debug.Fail(ex.ToString());
                if (threadStarted)
                {
                    Terminate();
                }
                return(false);
            }
            return(true);
        }
예제 #2
0
        public override bool Initialize(IPluginHost host)
        {
            pluginHost             = host;
            updateUITimer          = new System.Windows.Forms.Timer();
            updateUITimer.Interval = 500;
            updateUITimer.Tick    += On_updateUITimer_Tick;
            finishInitDelaytimer   = new System.Windows.Forms.Timer();

            var threadStarted = false;

            try {
                DBusBackgroundWorker.Request();
                threadStarted = true;
                DBusBackgroundWorker.InvokeGtkThread((Action)GtkDBusInit).Wait();
                pluginHost.MainWindow.UIStateUpdated += On_MainWindow_UIStateUpdated;
            } catch (Exception ex) {
                Debug.Fail(ex.ToString());
                if (threadStarted)
                {
                    Terminate();
                }
                return(false);
            }
            return(true);
        }
        public override bool Initialize(IPluginHost host)
        {
            pluginHost = host;

            // purposely break the winforms tray icon so it is not displayed
            var mainWindowType = pluginHost.MainWindow.GetType();
            var ntfTrayField   = mainWindowType.GetField("m_ntfTray",
                                                         BindingFlags.Instance | BindingFlags.NonPublic);
            var ntfField = ntfTrayField.FieldType.GetField("m_ntf",
                                                           BindingFlags.Instance | BindingFlags.NonPublic);

            ntfField.SetValue(ntfTrayField.GetValue(pluginHost.MainWindow), null);

            var threadStarted = false;

            try {
                DBusBackgroundWorker.Request();
                threadStarted = true;
                DBusBackgroundWorker.InvokeGtkThread((Action)GtkDBusInit).Wait();
            } catch (Exception ex) {
                MessageService.ShowWarning(
                    "KeebuntuStatusNotifier plugin failed to start.",
                    ex.ToString());
                if (threadStarted)
                {
                    Terminate();
                }
                return(false);
            }
            return(true);
        }
예제 #4
0
 void ShowErrorMessage()
 {
     DBusBackgroundWorker.Request();
     DBusBackgroundWorker.InvokeGtkThread(() => {
         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();
         }
     }).Wait();
     DBusBackgroundWorker.Release();
 }
예제 #5
0
        public override bool Initialize(IPluginHost host)
        {
            pluginHost = host;

            // purposely break the winforms tray icon so it is not displayed
            var mainWindowType = pluginHost.MainWindow.GetType();
            var ntfTrayField   = mainWindowType.GetField("m_ntfTray",
                                                         BindingFlags.Instance | BindingFlags.NonPublic);
            var ntfField = ntfTrayField.FieldType.GetField("m_ntf",
                                                           BindingFlags.Instance | BindingFlags.NonPublic);

            ntfField.SetValue(ntfTrayField.GetValue(pluginHost.MainWindow), null);

            activateWorkaroundTimer          = new System.Windows.Forms.Timer();
            activateWorkaroundTimer.Interval = 100;
            activateWorkaroundTimer.Tick    += OnActivateWorkaroundTimerTick;

            var threadStarted = false;

            try {
                DBusBackgroundWorker.Request();
                threadStarted = true;
                DBusBackgroundWorker.InvokeGtkThread((Action)GtkDBusInit).Wait();

                pluginHost.MainWindow.Activated += MainWindow_Activated;
                pluginHost.MainWindow.Resize    += MainWindow_Resize;
            } catch (Exception ex) {
                MessageService.ShowWarning(
                    "KeebuntuAppIndicator plugin failed to start.",
                    ex.ToString());
                if (threadStarted)
                {
                    Terminate();
                }
                return(false);
            }
            return(true);
        }