3
// GNOME Do is the legal property of its developers. Please refer to the
4
// COPYRIGHT file distributed with this source distribution.
6
// This program is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program. If not, see <http://www.gnu.org/licenses/>.
21
using System.Threading;
22
using System.Diagnostics;
23
using System.Collections.Generic;
35
static XKeybinder keybinder;
36
static Controller controller;
37
static UniverseManager universe_manager;
39
public static CorePreferences Preferences { get; private set; }
40
public static CoreKeybindings Keybindings { get; private set; }
42
internal static void Main (string [] args)
44
Catalog.Init ("gnome-do", AssemblyInfo.LocaleDirectory);
45
Gtk.Application.Init ();
48
// We are conservative with the log at first.
49
Log.DisplayLevel = LogLevel.Error;
50
if (CorePreferences.PeekDebug)
51
Log.DisplayLevel = LogLevel.Debug;
53
PluginManager.Initialize ();
54
Services.System.EnsureSingleApplicationInstance ();
56
Preferences = new CorePreferences ();
58
Keybindings = new CoreKeybindings ();
60
// Now we can set the preferred log level.
61
if (Preferences.QuietStart)
62
Log.DisplayLevel = LogLevel.Error;
63
// Check for debug again in case QuietStart is also set.
64
if (Preferences.Debug)
65
Log.DisplayLevel = LogLevel.Debug;
68
Util.SetProcessName ("gnome-do");
69
} catch (Exception e) {
70
Log.Error ("Failed to set process name: {0}", e.Message);
73
Controller.Initialize ();
74
UniverseManager.Initialize ();
76
keybinder = new XKeybinder ();
79
if (!Preferences.QuietStart)
82
Gtk.Application.Run ();
84
RelevanceProvider.Serialize (RelevanceProvider.DefaultProvider);
88
public static Controller Controller {
90
if (controller == null)
91
controller = new Controller ();
96
public static UniverseManager UniverseManager {
98
if (universe_manager == null)
99
universe_manager = new UniverseManager ();
100
return universe_manager;
104
static void SummonKeyCb (object sender, PreferencesChangedEventArgs e)
107
if (e.OldValue != null)
108
keybinder.Unbind (e.OldValue as string);
109
keybinder.Bind (Keybindings.GetKeybinding ("SummonKey"), OnActivate);
110
} catch (Exception ex) {
111
Log.Error ("Could not bind summon key: {0}", ex.Message);
112
Log.Debug (ex.StackTrace);
117
static void SetupKeybindings ()
120
keybinder.Bind (Keybindings.GetKeybinding ("SummonKey"), OnActivate);
121
} catch (Exception e) {
122
Log.Error ("Could not bind summon key: {0}", e.Message);
123
Log.Debug (e.StackTrace);
126
// Watch preferences for changes to the keybinding so we
127
// can change the binding when the user reassigns it.
128
Keybindings.RegisterNotification ("SummonKey", SummonKeyCb);
131
static void OnActivate (object sender, EventArgs e)
133
controller.Summon ();