public static void Quit() { Trace.Call(); // only save windows size when we are not in the engine manager dialog if (_MainWindow.Visible) { // save window size int width, heigth; if (_MainWindow.IsMaximized) { width = -1; heigth = -1; } else { _MainWindow.GetSize(out width, out heigth); } _FrontendConfig[Frontend.UIName + "/Interface/Width"] = width; _FrontendConfig[Frontend.UIName + "/Interface/Heigth"] = heigth; int x, y; _MainWindow.GetPosition(out x, out y); _FrontendConfig[Frontend.UIName + "/Interface/XPosition"] = x; _FrontendConfig[Frontend.UIName + "/Interface/YPosition"] = y; _FrontendConfig.Save(); } if (_FrontendManager != null) { if (IsLocalEngine) { try { // dispose (possibly flush) all protocol managers / chats lock (Session.ProtocolManagers) { foreach (var protocolManager in Session.ProtocolManagers) { protocolManager.Dispose(); } } } catch (Exception ex) { #if LOG4NET _Logger.Error("Quit(): Exception", ex); #endif } } DisconnectEngineFromGUI(); } #if LOG4NET // HACK: workaround log4net deadlock issue. Not sure if it has any // effect though, see: https://www.smuxi.org/issues/show/876 log4net.Core.LoggerManager.Shutdown(); #endif Gtk.Application.Quit(); Environment.Exit(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(); _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: Set the main message loop*/ Application.Run(_MainWindow); #if LOG4NET _Logger.Warn("Application.Run() returned!"); #endif }
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; _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(); if (_FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] == null) { _FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] = "#000000"; } _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); } }
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 }
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 }
public static void Quit() { Trace.Call(); // only save windows size when we are not in the engine manager dialog if (_MainWindow.Visible) { // save window size int width, heigth; if (_MainWindow.IsMaximized) { width = -1; heigth = -1; } else { _MainWindow.GetSize(out width, out heigth); } _FrontendConfig[Frontend.UIName + "/Interface/Width"] = width; _FrontendConfig[Frontend.UIName + "/Interface/Heigth"] = heigth; int x, y; _MainWindow.GetPosition(out x, out y); _FrontendConfig[Frontend.UIName + "/Interface/XPosition"] = x; _FrontendConfig[Frontend.UIName + "/Interface/YPosition"] = y; _FrontendConfig.Save(); } if (_FrontendManager != null) { DisconnectEngineFromGUI(); } Gtk.Application.Quit(); Environment.Exit(0); }
public static void Quit() { Trace.Call(); // only save windows size when we are not in the engine manager dialog if (_MainWindow != null && _MainWindow.Visible) { // save window size int width, heigth; if (_MainWindow.IsMaximized) { width = -1; heigth = -1; } else { _MainWindow.GetSize(out width, out heigth); } _FrontendConfig[Frontend.UIName + "/Interface/Width"] = width; _FrontendConfig[Frontend.UIName + "/Interface/Heigth"] = heigth; int x, y; _MainWindow.GetPosition(out x, out y); _FrontendConfig[Frontend.UIName + "/Interface/XPosition"] = x; _FrontendConfig[Frontend.UIName + "/Interface/YPosition"] = y; _FrontendConfig.Save(); } if (_FrontendManager != null) { if (IsLocalEngine) { try { // shutdown session (flush message buffers) Session.Shutdown(); } catch (Exception ex) { #if LOG4NET _Logger.Error("Quit(): Exception", ex); #endif } } // sync last seen message of current chat var currentChatView = _MainWindow.ChatViewManager.CurrentChatView; if (!UseLowBandwidthMode && currentChatView != null) { currentChatView.UpdateLastSeenMessage(); } // OPT: switch to Smuxi chat so switch page events are not // triggered when each chat gets removed _MainWindow.ChatViewManager.CurrentChatNumber = 0; DisconnectEngineFromGUI(); } #if LOG4NET // HACK: workaround log4net deadlock issue. Not sure if it has any // effect though, see: https://www.smuxi.org/issues/show/876 log4net.Core.LoggerManager.Shutdown(); #endif if (IsGtkInitialized && InGtkApplicationRun) { Gtk.Application.Quit(); } Environment.Exit(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 }
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(); }
protected virtual void OnApply(object sender, EventArgs e) { Trace.Call(sender, e); string engine = f_NameWidget.EngineNameEntry.Text; if (f_EngineName == null) { // check if an engine wit that name exists already string[] engines = (string[])f_Config["Engines/Engines"]; foreach (string oldEngine in engines) { if (engine == oldEngine) { Gtk.MessageDialog md = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, _("An engine with this name already exists! Please specify a different one.")); md.Run(); md.Destroy(); // jump back to the name page // HACK: assistant API is buggy here, the "Apply" button // will trigger a next page signal, thus we have to jump // to one page before the name page :( CurrentPage = f_NamePage - 1; return; } } string[] newEngines; if (engines.Length == 0) { // there was no existing engines newEngines = new string[] { engine }; } else { newEngines = new string[engines.Length + 1]; engines.CopyTo(newEngines, 0); newEngines[engines.Length] = engine; } if (engines.Length == 1) { f_Config["Engines/Default"] = engine; } f_Config["Engines/Engines"] = newEngines; } if (f_NameWidget.MakeDefaultEngineCheckButton.Active) { f_Config["Engines/Default"] = engine; } f_Config["Engines/" + engine + "/Username"] = f_CredentialsWidget.UsernameEntry.Text.Trim(); f_Config["Engines/" + engine + "/Password"] = f_CredentialsWidget.PasswordEntry.Text.Trim(); f_Config["Engines/" + engine + "/Hostname"] = f_ConnectionWidget.HostEntry.Text.Trim(); f_Config["Engines/" + engine + "/Port"] = f_ConnectionWidget.PortSpinButton.ValueAsInt; f_Config["Engines/" + engine + "/UseSshTunnel"] = f_ConnectionWidget.UseSshTunnelCheckButton.Active; f_Config["Engines/" + engine + "/SshUsername"] = f_CredentialsWidget.SshUsernameEntry.Text.Trim(); if (f_CredentialsWidget.SshPasswordVBox.Visible) { f_Config["Engines/" + engine + "/SshPassword"] = f_CredentialsWidget.SshPasswordEntry.Text; } f_Config["Engines/" + engine + "/SshKeyfile"] = f_CredentialsWidget.SshKeyfileChooserButton.Filename ?? String.Empty; f_Config["Engines/" + engine + "/SshHostname"] = f_ConnectionWidget.SshHostEntry.Text.Trim(); f_Config["Engines/" + engine + "/SshPort"] = f_ConnectionWidget.SshPortSpinButton.ValueAsInt; // HACK: we don't really support any other channels/formatters (yet) f_Config["Engines/" + engine + "/Channel"] = "TCP"; f_Config["Engines/" + engine + "/Formatter"] = "binary"; f_Config.Save(); }