104
105
public void Initialize ()
107
if (Do.Preferences.Theme == "Docky") {
108
string message = Catalog.GetString (
109
"<b>Docky is no longer a Do theme!</b>\n" +
110
"It is now available as a stand-alone application. " +
111
"Your GNOME Do theme has been reset to Classic. " +
112
"Please feel free to change it in Preferences."
115
Gtk.MessageDialog md = new Gtk.MessageDialog (null, Gtk.DialogFlags.DestroyWithParent,
116
Gtk.MessageType.Info, Gtk.ButtonsType.Ok, true, message);
117
md.Response += (o, args) => md.Destroy ();
119
Do.Preferences.Theme = "Classic";
106
122
SetTheme (Do.Preferences.Theme);
107
123
Do.Preferences.ThemeChanged += OnThemeChanged;
108
124
Screen.Default.CompositedChanged += OnCompositingChanged;
110
126
// Register Shortcuts
111
// TODO: Localize the text here.
112
// Previous shortcuts
113
Do.Keybindings.RegisterShortcut (
114
new Shortcut ("SummonKey",
115
Catalog.GetString ("Summon GNOME Do"),
116
OnSummonKeyPressEvent),
118
Do.Keybindings.RegisterShortcut (
119
new Shortcut ("TextModeKey",
120
Catalog.GetString ("Enter text mode"),
121
OnTextModePressEvent),
124
Do.Keybindings.RegisterShortcut (
125
new Shortcut ("CopyKey",
126
Catalog.GetString ("Copy Text"),
129
Do.Keybindings.RegisterShortcut (
130
new Shortcut ("PasteKey",
131
Catalog.GetString ("Paste Text"),
134
Do.Keybindings.RegisterShortcut (
135
new Shortcut ("AlternateEscapeKey",
136
Catalog.GetString ("Alternate Escape"),
137
OnEscapeKeyPressEvent));
138
Do.Keybindings.RegisterShortcut (
139
new Shortcut ("AlternateActivateKey",
140
Catalog.GetString ("Alternate Activate"),
141
OnActivateKeyPressEvent));
142
Do.Keybindings.RegisterShortcut (
143
new Shortcut ("AlternateDeleteKey",
144
Catalog.GetString ("Alternate Delete"),
145
OnDeleteKeyPressEvent));
146
Do.Keybindings.RegisterShortcut (
147
new Shortcut ("ShiftTabKey",
148
Catalog.GetString ("Previous Pane"),
149
OnShiftTabKeyPressEvent),
151
Do.Keybindings.RegisterShortcut (
152
new Shortcut ("TabKey",
153
Catalog.GetString ("Next Pane"),
156
Do.Keybindings.RegisterShortcut (
157
new Shortcut ("UpKey",
158
Catalog.GetString ("Previous Result"),
161
Do.Keybindings.RegisterShortcut (
162
new Shortcut ("DownKey",
163
Catalog.GetString ("Next Result"),
164
OnDownKeyPressEvent),
166
Do.Keybindings.RegisterShortcut (
167
new Shortcut ("HomeKey",
168
Catalog.GetString ("First Result"),
169
OnHomeKeyPressEvent),
171
Do.Keybindings.RegisterShortcut (
172
new Shortcut ("EndKey",
173
Catalog.GetString ("Last Result"),
176
Do.Keybindings.RegisterShortcut (
177
new Shortcut ("PageUpKey",
178
Catalog.GetString ("Previous 5 Results"),
179
OnPageUpKeyPressEvent),
181
Do.Keybindings.RegisterShortcut (
182
new Shortcut ("PageDownKey",
183
Catalog.GetString ("Next 5 Results"),
184
OnPageDownKeyPressEvent),
186
Do.Keybindings.RegisterShortcut (
187
new Shortcut ("LeftKey",
188
Catalog.GetString ("Step out of Item"),
189
OnLeftKeyPressEvent),
191
Do.Keybindings.RegisterShortcut (
192
new Shortcut ("RightKey",
193
Catalog.GetString ("Browse Into Item"),
194
OnRightKeyPressEvent),
196
Do.Keybindings.RegisterShortcut (
197
new Shortcut ("CommaKey",
198
Catalog.GetString ("Multiple selection"),
199
OnSelectionKeyPressEvent),
130
void SetupKeybindings ()
132
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon Do"), "<Super>space",
133
OnSummonKeyPressEvent, true));
135
// this keybinding is disabled by default - note the empty keybinding
136
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Summon in Text Mode"), "",
137
OnTextModeSummonKeyPressEvent, true));
139
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Enter Text Mode"), "period",
140
OnTextModePressEvent));
142
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Clear"), "Escape",
143
OnClearKeyPressEvent));
145
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Copy to Clipboard"), "<Control>c",
147
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Paste from Clipboard"), "<Control>v",
150
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Pane"), "<Shift>Tab",
151
OnPreviousPanePressEvent));
152
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Pane"), "Tab",
153
OnNextPanePressEvent));
155
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous Item"), "Up",
156
OnPreviousItemPressEvent));
157
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next Item"), "Down",
158
OnNextItemPressEvent));
160
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("First Item"), "Home",
161
OnFirstItemPressEvent));
162
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Last Item"), "End",
163
OnLastItemPressEvent));
165
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Previous 5 Results"), "Page_Up",
166
OnNextItemPagePressEvent));
167
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Next 5 Results"), "Page_Down",
168
OnPreviousItemPagePressEvent));
170
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Out of Item"), "Left",
171
OnStepOutItemPressEvent));
172
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Step Into Item"), "Right",
173
OnStepInItemPressEvent));
175
Services.Keybinder.RegisterKeyBinding (new KeyBinding (Catalog.GetString ("Select Multiple Items"), "comma",
176
OnSelectionKeyPressEvent));
203
179
void OnSummoned ()
483
462
#region KeyPress Handling
485
Key IfVertical (Key ifKey, Key elseKey)
487
return Orientation == ControlOrientation.Vertical ? ifKey : elseKey;
490
Key UpKey { get { return IfVertical (Key.Up, Key.Left); } }
491
Key DownKey { get { return IfVertical (Key.Down, Key.Right); } }
492
Key LeftKey { get { return IfVertical (Key.Left, Key.Up); } }
493
Key RightKey { get { return IfVertical (Key.Right, Key.Down); } }
495
464
private void KeyPressWrap (EventKey evnt)
497
466
Key key = (Key) evnt.KeyValue;
500
// Currently - only hardcoded are enter keys, escape and delete/backspace
501
if (key == Key.Escape) {
502
OnEscapeKeyPressEvent (evnt);
503
} else if (key == Key.Return ||
468
// Currently - only hardcoded are enter keys and delete/backspace
469
if (key == Key.Return ||
504
470
key == Key.ISO_Enter ||
505
471
key == Key.KP_Enter) {
506
472
OnActivateKeyPressEvent (evnt);
507
473
} else if (key == Key.Delete ||
508
474
key == Key.BackSpace) {
509
475
OnDeleteKeyPressEvent (evnt);
476
} else if (Services.Keybinder.Bindings.Any (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt))) {
511
477
// User set keybindings
512
Shortcut sc = Do.Keybindings.GetShortcutByKeycode (KeyEventToString (evnt));
478
Services.Keybinder.Bindings.First (k => k.KeyString == Services.Keybinder.KeyEventToString (evnt)).Callback (evnt);
517
480
OnInputKeyPressEvent (evnt);
715
689
SearchController.Cursor++;
718
void OnHomeKeyPressEvent (EventKey evnt)
692
void OnFirstItemPressEvent (EventKey evnt)
720
694
im_context.Reset ();
721
695
SearchController.Cursor = 0;
724
void OnEndKeyPressEvent (EventKey evnt)
698
void OnLastItemPressEvent (EventKey evnt)
726
700
im_context.Reset ();
727
701
SearchController.Cursor = SearchController.Results.Count - 1;
730
void OnPageUpKeyPressEvent (EventKey evnt)
704
void OnNextItemPagePressEvent (EventKey evnt)
732
706
im_context.Reset ();
733
707
SearchController.Cursor -= 5;
736
void OnPageDownKeyPressEvent (EventKey evnt)
710
void OnPreviousItemPagePressEvent (EventKey evnt)
738
712
im_context.Reset ();
739
713
SearchController.Cursor += 5;
743
/// Converts a keypress into a human readable string for comparing
744
/// against values in GConf.
746
/// <param name="evnt">
747
/// A <see cref="EventKey"/>
750
/// A <see cref="System.String"/> in the form "<Modifier>key"
752
string KeyEventToString (EventKey evnt) {
753
string modifier = "";
754
if ((evnt.State & ModifierType.ControlMask) != 0) {
755
modifier += "<Control>";
757
if ((evnt.State & ModifierType.SuperMask) != 0) {
758
modifier += "<Super>";
760
if ((evnt.State & ModifierType.Mod1Mask) != 0) {
763
return modifier + evnt.Key.ToString ();