Ejemplo n.º 1
0
        /// <summary>
        /// Initalize Gtk and DBus stuff
        /// </summary>
        private void GtkDBusInit()
        {
            /* setup StatusIcon */

            statusIcon          = new Gtk.StatusIcon();
            statusIcon.IconName = "keepass2-locked";
#if DEBUG
            statusIcon.File = Path.GetFullPath("Resources/icons/hicolor/16x16/apps/keepass2-locked.png");
#endif
            statusIcon.Tooltip = PwDefs.ProductName;

            statusIconMenu = new Gtk.Menu();

            var trayContextMenu = pluginHost.MainWindow.TrayContextMenu;
            // make copy of item list to prevent list changed exception when iterating
            var menuItems =
                new System.Windows.Forms.ToolStripItem[trayContextMenu.Items.Count];
            trayContextMenu.Items.CopyTo(menuItems, 0);
            trayContextMenu.ItemAdded += (sender, e) =>
                                         DBusBackgroundWorker.InvokeGtkThread
                                             (() => ConvertAndAddMenuItem(e.Item, statusIconMenu));

            foreach (System.Windows.Forms.ToolStripItem item in menuItems)
            {
                ConvertAndAddMenuItem(item, statusIconMenu);
            }

            statusIcon.PopupMenu += OnPopupMenu;
            statusIcon.Activate  += (sender, e) => {
                DBusBackgroundWorker.InvokeWinformsThread
                    (() => pluginHost.MainWindow.EnsureVisibleForegroundWindow(true, true));
            };
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     if (statusItem != null) {
         statusItem.Dispose();
     }
     statusItem = null;
     menu = null;
 }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (statusItem != null)
     {
         statusItem.Dispose();
     }
     statusItem = null;
     menu       = null;
 }
Ejemplo n.º 4
0
        public void ApplyConfig(UserConfig userConfig)
        {
            Trace.Call(userConfig);

            if (userConfig == null)
            {
                throw new ArgumentNullException("userConfig");
            }

            string modeStr = (string)userConfig["Interface/Notification/NotificationAreaIconMode"];

            f_NotificationAreaIconMode = (NotificationAreaIconMode)Enum.Parse(
                typeof(NotificationAreaIconMode),
                modeStr
                );

            // initialize status icon for the first time
            if (f_NotificationAreaIconMode != NotificationAreaIconMode.Never &&
                f_StatusIcon == null)
            {
                f_StatusIcon = new Gtk.StatusIcon();
                if (Frontend.HasSystemIconTheme)
                {
                    f_StatusIcon.IconName = Frontend.IconName;
                }
                else
                {
                    f_StatusIcon.Pixbuf = Frontend.LoadIcon(
                        Frontend.IconName, 256, "icon_256x256.png"
                        );
                }
                f_StatusIcon.Activate  += OnStatusIconActivated;
                f_StatusIcon.PopupMenu += OnStatusIconPopupMenu;
                f_StatusIcon.Tooltip    = "Smuxi";
            }
            if (f_NotificationAreaIconMode == NotificationAreaIconMode.Never &&
                !f_MainWindow.Visible)
            {
                // force window unhide as the user would not be able to bring
                // it back without a notification icon!
                f_MainWindow.Visible = true;
            }

            CheckMainWindowState();
        }
Ejemplo n.º 5
0
 public void InitializeBackend(object frontend)
 {
     statusItem = new Gtk.StatusIcon();
 }
Ejemplo n.º 6
0
 public void InitializeBackend(object frontend, ApplicationContext context)
 {
     statusItem = new Gtk.StatusIcon();
 }
Ejemplo n.º 7
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            Assembly asm = Assembly.GetAssembly(typeof(Frontend));
            AssemblyName asm_name = asm.GetName(false);
            AssemblyProductAttribute pr = (AssemblyProductAttribute)asm.
                GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];
            _Version = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

            #if LOG4NET
            _Logger.Info(_VersionString + " starting");
            #endif

            #if GTK_SHARP_2_8 || GTK_SHARP_2_10
            if (!GLib.Thread.Supported) {
                GLib.Thread.Init();
            }
            _UIThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
            #else
            // with GTK# 2.8 we can do this better, see above
            // GTK# 2.7.1 for MS .NET doesn't support that though.
            if (Type.GetType("Mono.Runtime") == null) {
                // when we don't run on Mono, we need to initialize glib ourself
                GLib.Thread.Init();
            }
            #endif

            string appDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string localeDir = Path.Combine(appDir, "locale");
            if (!Directory.Exists(localeDir)) {
                localeDir = Path.Combine(Defines.InstallPrefix, "share");
                localeDir = Path.Combine(localeDir, "locale");
            }

            LibraryCatalog.Init("smuxi-frontend-gnome", localeDir);
            #if LOG4NET
            _Logger.Debug("Using locale data from: " + localeDir);
            #endif

            #if UI_GNOME
            _Program = new GNOME.Program(Name, Version.ToString(), GNOME.Modules.UI, args);
            #elif UI_GTK
            Gtk.Application.Init(Name, args);
            #endif
            #if GTK_SHARP_2_10
            GLib.ExceptionManager.UnhandledException += _OnUnhandledException;
            #endif
            //_SplashScreenWindow = new SplashScreenWindow();

            _FrontendConfig = new FrontendConfig(UIName);
            // loading and setting defaults
            _FrontendConfig.Load();
            _FrontendConfig.Save();

            Gtk.Window.DefaultIcon = new Gdk.Pixbuf(null, "icon.svg");

            _MainWindow = new MainWindow();

            #if GTK_SHARP_2_10
            _StatusIcon = new Gtk.StatusIcon();
            _StatusIcon.Visible = false;
            _StatusIcon.Pixbuf = new Gdk.Pixbuf(null, "icon.svg");
            _StatusIcon.Activate += delegate {
                try {
                    if (_StatusIcon.Blinking) {
                        _MainWindow.Present();
                        return;
                    }
                    _MainWindow.Visible = !_MainWindow.Visible;
                } catch (Exception ex) {
                    ShowException(ex);
                }
            };
            _StatusIcon.PopupMenu += OnStatusIconPopupMenu;
            _StatusIcon.Tooltip = "Smuxi";
            #endif

            if (String.IsNullOrEmpty((string) FrontendConfig["Engines/Default"])) {
                InitLocalEngine();
                ConnectEngineToGUI();
            } else {
                // there is a default engine set, means we want a remote engine
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                ShowEngineManagerDialog();
            }

            if (_SplashScreenWindow != null) {
                _SplashScreenWindow.Destroy();
            }

            #if UI_GNOME
            _Program.Run();
            #if LOG4NET
            _Logger.Warn("_Program.Run() returned!");
            #endif
            #elif UI_GTK
            Gtk.Application.Run();
            #if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
            #endif
            #endif
        }
Ejemplo n.º 8
0
 public void InitializeBackend(object frontend, ApplicationContext context)
 {
     this.context = context;
     statusItem   = new Gtk.StatusIcon();
 }
Ejemplo n.º 9
0
        public void ApplyConfig(UserConfig userConfig)
        {
            Trace.Call(userConfig);

            if (userConfig == null) {
                throw new ArgumentNullException("userConfig");
            }

            string modeStr = (string) userConfig["Interface/Notification/NotificationAreaIconMode"];
            f_NotificationAreaIconMode = (NotificationAreaIconMode) Enum.Parse(
                typeof(NotificationAreaIconMode),
                modeStr
            );

            // initialize status icon for the first time
            if (f_NotificationAreaIconMode != NotificationAreaIconMode.Never &&
                f_StatusIcon == null) {
                f_StatusIcon = new Gtk.StatusIcon();
                f_StatusIcon.Pixbuf = new Gdk.Pixbuf(null, "icon.svg");
                f_StatusIcon.Activate += OnStatusIconActivated;
                f_StatusIcon.PopupMenu += OnStatusIconPopupMenu;
                f_StatusIcon.Tooltip = "Smuxi";
            }
            if (f_NotificationAreaIconMode == NotificationAreaIconMode.Never &&
                !f_MainWindow.Visible) {
                // force window unhide as the user would not be able to bring
                // it back without a notification icon!
                f_MainWindow.Visible = true;
            }

            CheckMainWindowState();
        }
Ejemplo n.º 10
0
 public void InitializeBackend(object frontend)
 {
     statusItem = new Gtk.StatusIcon();
 }