Inheritance: Gtk.Window
Exemple #1
0
        public IndicateManager(MainWindow mainWindow,
                               ChatViewManager chatViewManager)
        {
            Trace.Call(mainWindow, chatViewManager);

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

            MainWindow = mainWindow;
            ChatViewManager = chatViewManager;
            #if INDICATE_SHARP
            Indicators = new Dictionary<ChatView, Indicator>();
            #elif MESSAGING_MENU_SHARP
            Sources = new Dictionary<ChatView, string>();
            #endif
            HighlightEventHandlers = new Dictionary
                <ChatView,
                 MessageTextViewMessageHighlightedEventHandler>();

            try {
                Init();
            } catch (Exception ex) {
            #if LOG4NET
                Logger.Error("IndicateManager(): initialization failed: ", ex);
            #endif
            }
        }
Exemple #2
0
        public NotifyManager(MainWindow mainWindow,
                               ChatViewManager chatViewManager)
        {
            Trace.Call(mainWindow, chatViewManager);

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

            MainWindow = mainWindow;
            ChatViewManager = chatViewManager;
            Notifications = new Dictionary<ChatView, Notification>();
            HighlightEventHandlers = new Dictionary
                <ChatView,
                 MessageTextViewMessageHighlightedEventHandler>();

            try {
                Init();
            } catch (Exception ex) {
            #if LOG4NET
                Logger.Error("NotifyManager(): initialization failed: ", ex);
            #endif
            }
        }
Exemple #3
0
        public StatusIconManager(MainWindow mainWindow, ChatViewManager chatViewManager)
        {
            if (mainWindow == null) {
                throw new ArgumentNullException("mainWindow");
            }
            if (chatViewManager == null) {
                throw new ArgumentNullException("chatViewManager");
            }

            f_MainWindow               = mainWindow;
            f_MainWindow.FocusInEvent += OnMainWindowFocusInEvent;
            f_MainWindow.Minimized    += delegate {
                CheckMainWindowState();
            };
            f_MainWindow.Unminimized  += delegate {
                CheckMainWindowState();
            };
            f_MainWindow.Hidden       += delegate {
                CheckMainWindowState();
            };
            f_MainWindow.Shown        += delegate {
                CheckMainWindowState();
            };

            f_ChatViewManager              = chatViewManager;
            f_ChatViewManager.ChatAdded   += OnChatViewManagerChatAdded;
            f_ChatViewManager.ChatRemoved += OnChatViewManagerChatRemoved;
        }
Exemple #4
0
        public static void Init(string[] args, string engine)
        {
            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;
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

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

            InitSignalHandlers();
            InitGtk(args);

            //_SplashScreenWindow = new SplashScreenWindow();

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

            _MainWindow = new MainWindow();

            if (((string[]) FrontendConfig["Engines/Engines"]).Length == 0) {
                InitLocalEngine();
                ConnectEngineToGUI();
            } else {
                // there are remote engines defined, means we have to ask
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                try {
                    ShowEngineManagerDialog(engine);
                } catch (ArgumentException ex) {
                    if (ex.ParamName == "value") {
                        Console.WriteLine(ex.Message);
                        System.Environment.Exit(1);
                    }
                    throw;
                }
            }

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

            if (IsMacOSX) {
                ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) {
                    Quit();
                    e.Handled = true;
                };

                ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) {
                    MainWindow.Deiconify();
                    MainWindow.Visible = true;
                    e.Handled = true;
                };

                ApplicationEvents.OpenUrls += delegate(object sender, ApplicationUrlEventArgs e) {
                    e.Handled = true;
                    if (e.Urls == null || e.Urls.Count == 0) {
                        return;
                    }
                    foreach (var url in e.Urls) {
                        try {
                            OpenChatLink(new Uri(url));
                        } catch (Exception ex) {
            #if LOG4NET
                            _Logger.Error("ApplicationEvents.OpenUrls() Exception", ex);
            #endif
                        }
                    }
                };
            }

            InGtkApplicationRun = true;
            Gtk.Application.Run();
            InGtkApplicationRun = false;
            #if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
            #endif
        }
Exemple #5
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

            Gtk.Application.Init(Name, ref args);
            #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 (((string[]) FrontendConfig["Engines/Engines"]).Length == 0) {
                InitLocalEngine();
                ConnectEngineToGUI();
            } else {
                // there are remote engines defined, means we have to ask
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                ShowEngineManagerDialog();
            }

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

            Gtk.Application.Run();
            #if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
            #endif
        }
Exemple #6
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
        }
Exemple #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

            InitGtk(args);

            //_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 (((string[]) FrontendConfig["Engines/Engines"]).Length == 0) {
                InitLocalEngine();
                ConnectEngineToGUI();
            } else {
                // there are remote engines defined, means we have to ask
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                ShowEngineManagerDialog();
            }

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

            Gtk.Application.Run();
            #if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
            #endif
        }
Exemple #8
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

            InitGtk(args);

            //_SplashScreenWindow = new SplashScreenWindow();

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

            _MainWindow = new MainWindow();

            if (((string[]) FrontendConfig["Engines/Engines"]).Length == 0) {
                InitLocalEngine();
                ConnectEngineToGUI();
            } else {
                // there are remote engines defined, means we have to ask
                string engine = null;
                for (int i = 0; i < args.Length; i++) {
                    var arg = args[i];
                    switch (arg) {
                        case "-e":
                        case "--engine":
                            if (args.Length >=  i + 1) {
                                engine = args[i + 1];
                            }
                            break;
                    }
                }
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                try {
                    ShowEngineManagerDialog(engine);
                } catch (ArgumentException ex) {
                    if (ex.ParamName == "value") {
                        Console.WriteLine(ex.Message);
                        System.Environment.Exit(1);
                    }
                    throw;
                }
            }

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

            Gtk.Application.Run();
            #if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
            #endif
        }