protected void Initialize(bool registerCommonServices) { // Set the process name so system process listings and commands are pretty PlatformHacks.TrySetProcessName(Application.InternalName); Application.Initialize(); InitializeGtk(); Gtk.Window.DefaultIconName = default_icon_name; ThreadAssist.InitializeMainThread(); Gdk.Global.ProgramClass = Application.InternalName; GLib.Global.ApplicationName = "Banshee"; if (ApplicationContext.Debugging) { GLib.Log.SetLogHandler("Gtk", GLib.LogLevelFlags.Critical, GLib.Log.PrintTraceLogFunction); } ServiceManager.ServiceStarted += OnServiceStarted; // Register specific services this client will care about if (registerCommonServices) { Banshee.Gui.CommonServices.Register(); } OnRegisterServices(); Application.ShutdownPromptHandler = OnShutdownPrompt; Application.TimeoutHandler = RunTimeout; Application.IdleHandler = RunIdle; Application.IdleTimeoutRemoveHandler = IdleTimeoutRemove; // Start the core boot process Application.PushClient(this); Application.Run(); if (!Banshee.Configuration.DefaultApplicationHelper.NeverAsk && Banshee.Configuration.DefaultApplicationHelper.HaveHelper) { Application.ClientStarted += delegate { Banshee.Gui.Dialogs.DefaultApplicationHelperDialog.RunIfAppropriate(); }; } Log.Notify += OnLogNotify; }
public Client(string[] args) { Log.Information("Starting Synapse"); try { PlatformHacks.SetProcessName("synapse"); } catch (Exception ex) { Console.WriteLine("[WARNING] Failed to set process name: " + ex.Message); } GLib.Global.ProgramName = "Synapse"; Gtk.Application.Init(); m_App = new QApplication(args); m_App.QuitOnLastWindowClosed = false; m_App.ApplicationName = "Synapse"; m_App.ApplicationVersion = "0.1"; InitQtWebKit.InitSmoke(); m_ResourceFileEngineHandler = new ResourceFileEngineHandler(); m_AvatarFileEngineHandler = new AvatarFileEngineHandler(); Application.Initialize(this); if (Application.Debugging) { QtTraceListener listener = new QtTraceListener(); listener.TraceOutputOptions = TraceOptions.Callstack; Debug.Listeners.Add(listener); Debug.Listeners.Add(new ConsoleTraceListener()); Debug.WriteLine("Debug Mode On"); } AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException; if (!Application.CommandLine.Contains("disable-dbus")) { try { NDesk.DBus.BusG.Init(); } catch (Exception ex) { Console.Error.WriteLine("Failed to initialize DBUS: " + ex); } } else { Console.WriteLine("DBus disabled by request."); } // XXX: I dont like all of these being here. ServiceManager.RegisterService <Synapse.Xmpp.Services.XmppService>(); ServiceManager.RegisterService <Synapse.Xmpp.Services.AccountService>(); ServiceManager.RegisterService <Synapse.QtClient.OctyService>(); ServiceManager.RegisterService <Synapse.Xmpp.Services.ShoutService>(); ServiceManager.RegisterService <Synapse.Xmpp.Services.GeoService>(); ServiceManager.RegisterService <GuiService>(); QWebSettings.GlobalSettings().SetAttribute(QWebSettings.WebAttribute.DeveloperExtrasEnabled, true); QWebSettings.GlobalSettings().SetAttribute(QWebSettings.WebAttribute.PluginsEnabled, true); if (Application.CommandLine.Contains("uninstalled")) { ConversationWidget.ThemesDirectory = Path.Combine(Environment.CurrentDirectory, "themes"); } else { ConversationWidget.ThemesDirectory = Path.Combine(Paths.InstalledApplicationData, "themes"); } Application.Run(); QApplication.Invoke(delegate { /* Create the UI */ Gui.MainWindow = new MainWindow(); Gui.TrayIcon = new TrayIcon(m_App); Gui.TabbedChatsWindow = new TabbedChatsWindow(); OnStarted(); Gui.TrayIcon.Show(); Gui.MainWindow.Show(); }); QApplication.Exec(); }