public override bool Initialize(IPluginHost host) { pluginHost = host; // mimmic behavior of other ubuntu apps hideMenuInApp = Environment.GetEnvironmentVariable("APPMENU_DISPLAY_BOTH") != "1"; try { DBusBackgroundWorker.Start(); gtkInitDoneEvent = new AutoResetEvent(false); DBusBackgroundWorker.InvokeGtkThread(() => GtkDBusInit()); if (!gtkInitDoneEvent.WaitOne(1000)) { throw new TimeoutException("Timed out waiting for GTK thread."); } if (!gtkInitOk) { throw new Exception("GTK init failed."); } 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 (gtkInitOk) { 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); activateWorkaroundTimer = new System.Windows.Forms.Timer(); activateWorkaroundTimer.Interval = 100; activateWorkaroundTimer.Tick += OnActivateWorkaroundTimerTick; var threadStarted = false; try { DBusBackgroundWorker.Start(); threadStarted = true; DBusBackgroundWorker.InvokeGtkThread(() => GtkDBusInit()); pluginHost.MainWindow.Activated += MainWindow_Activated; pluginHost.MainWindow.Resize += MainWindow_Resize; } catch (Exception ex) { Debug.Fail(ex.ToString()); if (threadStarted) { Terminate(); } return(false); } return(true); }