Пример #1
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
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                ShowEngineManagerDialog();
            }

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

            Gtk.Application.Run();
#if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
#endif
        }
Пример #2
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
        }