Example #1
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
        }
Example #2
0
        public static void Init(string engine)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";
            Trace.Call(engine);

            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;

            // this always calls abort() :(((
            //StflApi.stfl_error_action("print");

            #if LOG4NET
            _Logger.Info(_VersionString + " starting");
            #endif
            _MainWindow = new MainWindow();

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

            if (_FrontendConfig.IsCleanConfig) {
                // first start assistant
            } else {
                if (String.IsNullOrEmpty(engine) || engine == "local") {
                    InitLocalEngine();
                } else {
                    InitRemoteEngine(engine);
                }
            }

            while (true) {
                // wait maximum for 500ms, to force a refresh even when
                // not hitting a key
                _MainWindow.Run(500);
            }
            #if LOG4NET
               _Logger.Warn("_MainWindow.Run() returned!");
            #endif
        }
Example #3
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";
            Trace.Call(args);

            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;

            //STFL.error_action("print");

            #if LOG4NET
            _Logger.Info(_VersionString + " starting");
            #endif
            _MainWindow = new MainWindow();

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

            if (_FrontendConfig.IsCleanConfig) {
                // first start assistant
            } else {
                if (((string)FrontendConfig["Engines/Default"]).Length == 0) {
                    InitLocalEngine();
                } else {
                    // there is a default engine set, means we want a remote engine
                    //new EngineManagerDialog();
                    InitLocalEngine();
                }
            }

            while (true) {
                // wait maximum for 500ms, to force a refresh even when
                // not hitting a key
                _MainWindow.Run(500);
            }
            #if LOG4NET
               _Logger.Warn("_MainWindow.Run() returned!");
            #endif
        }
Example #4
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
        }
Example #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
        }
Example #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

            // We don't want to put any XP/Vista users by using the dull ugly
            // unthemed interface.  Application.EnableVisualStyles() should be
            // called before any form is displayed.
            Application.EnableVisualStyles();

            _SplashScreenWindow = new SplashScreenWindow();

            _MainWindow = new MainWindow();
            // HACK: force creation of window handle, else the engine will have problems adding stuff
            IntPtr handle = _MainWindow.Handle;

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

            if (_FrontendConfig.IsCleanConfig) {
                /*TODO: Create and show first run wizard*/
            } else {
                if (((string)FrontendConfig["Engines/Default"]).Length == 0) {
                    InitLocalEngine();
                } else {
                    // there is a default engine set, means we want a remote engine
                    /*TODO: Create and show Engine Manager Dialog*/

                    // HACK: for now always use local engine
                    InitLocalEngine();
                }
            }
            // TODO: Kill the SplashScreen Window
            _SplashScreenWindow.Close();

             /*TODO: Set the main message loop*/
            Application.Run(_MainWindow);
            #if LOG4NET
            _Logger.Warn("Application.Run() returned!");
            #endif
        }
Example #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
            Application.Init(false);

            _MainWindow = new MainWindow();

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

            if (_FrontendConfig.IsCleanConfig) {
            } else {
                if (((string)FrontendConfig["Engines/Default"]).Length == 0) {
                    InitLocalEngine();
                } else {
                    // there is a default engine set, means we want a remote engine
                    //new EngineManagerDialog();
                    InitLocalEngine();
                }
            }

            Application.Timeout = 100;
            Application.Iteration += delegate {
                Application.Refresh ();
            };

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

            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
        }
Example #9
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
        }
Example #10
0
        private void StartApplication(object sender, StartupEventArgs e)
        {
            #if LOG4NET

            log4net.Config.BasicConfigurator.Configure();

            #endif

            // Splash screen should be shown as soon as the application begins

            Window ss = StartSplashScreen();

            // Now we can continue to initialize the application as needed

            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 = String.Format("{0} - {1} frontend {2}", pr.Product, UIName, Version);

            }

            #if LOG4NET

            _Logger.Info(VersionString + " starting");

            #endif

            FrontendConfig = new FrontendConfig(UIName);

            // loading and setting defaults

            FrontendConfig.Load();

            FrontendConfig.Save();

            if (FrontendConfig.IsCleanConfig)
            {

                ss.Close();

                RunInitWizard();

            }
            else
            {

                if (((string)FrontendConfig["Engines/Default"]).Length == 0)
                {

                    //InitLocalEngine();

                }
                else
                {

                    // there is a default engine set, means we want a remote engine

                    ss.Close();

                    RunEngineManagerDialog();

                }

            }

            // Now that everything is setup, we can destroy the splash screen

            // and start the application

            ss.Close();
        }