[tomboy/mac-keybindings: 2/2] Initial cut at mac-like keybindings



commit fc2f34ca940335cb99a95c8d8ce06005be7e2a2a
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Tue Sep 8 08:12:05 2009 -0700

    Initial cut at mac-like keybindings

 Tomboy/Addins/FixedWidth/FixedWidthMenuItem.cs     |    2 +-
 .../InsertTimestamp/InsertTimestampNoteAddin.cs    |    2 +-
 Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs    |    2 +-
 Tomboy/Addins/Underline/UnderlineMenuItem.cs       |    2 +-
 Tomboy/GnomeApplication.cs                         |    4 +
 Tomboy/MacApplication.cs                           |    5 +-
 Tomboy/NativeApplication.cs                        |    2 +
 Tomboy/NoteEditor.cs                               |    2 +-
 Tomboy/NoteTag.cs                                  |    4 +-
 Tomboy/NoteWindow.cs                               |   60 ++++++++++----------
 Tomboy/RecentChanges.cs                            |    6 +-
 Tomboy/Watchers.cs                                 |    2 +-
 Tomboy/WindowsApplication.cs                       |    4 +
 13 files changed, 55 insertions(+), 42 deletions(-)
---
diff --git a/Tomboy/Addins/FixedWidth/FixedWidthMenuItem.cs b/Tomboy/Addins/FixedWidth/FixedWidthMenuItem.cs
index ae6ba26..d10f215 100644
--- a/Tomboy/Addins/FixedWidth/FixedWidthMenuItem.cs
+++ b/Tomboy/Addins/FixedWidth/FixedWidthMenuItem.cs
@@ -19,7 +19,7 @@ namespace Tomboy.FixedWidth
 			Addin = addin;
 			Addin.Window.TextMenu.Shown += MenuShown;
 			AddAccelerator ("activate", Addin.Window.AccelGroup,
-                                (uint) Gdk.Key.t, Gdk.ModifierType.ControlMask,
+                                (uint) Gdk.Key.t, Services.NativeApplication.ControlModifier,
                                 Gtk.AccelFlags.Visible);
 
 			ShowAll();
diff --git a/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs b/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
index 461b434..b68791f 100644
--- a/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
+++ b/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
@@ -29,7 +29,7 @@ namespace Tomboy.InsertTimestamp {
 				Catalog.GetString ("Insert Timestamp"));
 			item.Activated += OnMenuItemActivated;
 			item.AddAccelerator ("activate", Window.AccelGroup,
-				(uint) Gdk.Key.d, Gdk.ModifierType.ControlMask,
+				(uint) Gdk.Key.d, Services.NativeApplication.ControlModifier,
 				Gtk.AccelFlags.Visible);
 			item.Show ();
 			AddPluginMenuItem (item);
diff --git a/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs b/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs
index 160288a..4bc2e71 100644
--- a/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs
+++ b/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs
@@ -53,7 +53,7 @@ namespace Tomboy.PrintNotes
 			item.Image = new Gtk.Image (Gtk.Stock.Print, Gtk.IconSize.Menu);
 			item.Activated += PrintButtonClicked;
 			item.AddAccelerator ("activate", Window.AccelGroup,
-				(uint) Gdk.Key.p, Gdk.ModifierType.ControlMask,
+				(uint) Gdk.Key.p, Services.NativeApplication.ControlModifier,
 				Gtk.AccelFlags.Visible);
 			item.Show ();
 			AddPluginMenuItem (item);
diff --git a/Tomboy/Addins/Underline/UnderlineMenuItem.cs b/Tomboy/Addins/Underline/UnderlineMenuItem.cs
index 066e521..397a8a7 100644
--- a/Tomboy/Addins/Underline/UnderlineMenuItem.cs
+++ b/Tomboy/Addins/Underline/UnderlineMenuItem.cs
@@ -17,7 +17,7 @@ namespace Tomboy.Underline
 			Addin = addin;
 			Addin.Window.TextMenu.Shown += MenuShown;
 			AddAccelerator ("activate", Addin.Window.AccelGroup,
-				(uint) Gdk.Key.u, Gdk.ModifierType.ControlMask,
+				(uint) Gdk.Key.u, Services.NativeApplication.ControlModifier,
 				Gtk.AccelFlags.Visible);
 
 			ShowAll();
diff --git a/Tomboy/GnomeApplication.cs b/Tomboy/GnomeApplication.cs
index 5c1a655..912ddfe 100644
--- a/Tomboy/GnomeApplication.cs
+++ b/Tomboy/GnomeApplication.cs
@@ -191,5 +191,9 @@ namespace Tomboy
 				                     ".tomboy");
 			}
 		}
+		
+		public Gdk.ModifierType ControlModifier {
+			get { return Gdk.ModifierType.ControlMask; }
+		}
 	}
 }
diff --git a/Tomboy/MacApplication.cs b/Tomboy/MacApplication.cs
index b8a6c4a..430e829 100644
--- a/Tomboy/MacApplication.cs
+++ b/Tomboy/MacApplication.cs
@@ -224,7 +224,6 @@ namespace Tomboy
 			mainMenu.Show ();
 			IgeMacMenu.MenuBar = mainMenu;
 			WindowMenuManager.UpdateWindowMenu ();
-
 			Gtk.MenuItem about_item = uiManager.GetWidget ("/MainWindowMenubar/HelpMenu/ShowAbout") as Gtk.MenuItem;
 			Gtk.MenuItem prefs_item = uiManager.GetWidget ("/MainWindowMenubar/EditMenu/ShowPreferences") as Gtk.MenuItem;
 			Gtk.MenuItem quit_item  = uiManager.GetWidget ("/MainWindowMenubar/FileMenu/QuitTomboy") as Gtk.MenuItem;
@@ -286,6 +285,10 @@ namespace Tomboy
 		{
 			OpenUrl ("http://library.gnome.org/users/tomboy/0.12/";, screen);
 		}
+		
+		public Gdk.ModifierType ControlModifier {
+			get { return Gdk.ModifierType.MetaMask; }
+		}
 
 		#endregion
 	}
diff --git a/Tomboy/NativeApplication.cs b/Tomboy/NativeApplication.cs
index 6a9dca9..aba0426 100644
--- a/Tomboy/NativeApplication.cs
+++ b/Tomboy/NativeApplication.cs
@@ -31,5 +31,7 @@ namespace Tomboy
 		void OpenUrl (string url, Gdk.Screen screen);
 
 		void DisplayHelp (string help_uri, Gdk.Screen screen);
+		
+		Gdk.ModifierType ControlModifier { get; }
 	}
 }
diff --git a/Tomboy/NoteEditor.cs b/Tomboy/NoteEditor.cs
index fd78e16..bb482a0 100644
--- a/Tomboy/NoteEditor.cs
+++ b/Tomboy/NoteEditor.cs
@@ -188,7 +188,7 @@ namespace Tomboy
 			case Gdk.Key.KP_Enter:
 			case Gdk.Key.Return:
 				// Allow opening notes with Ctrl + Enter
-				if (args.Event.State != Gdk.ModifierType.ControlMask) {
+				if (args.Event.State != Services.NativeApplication.ControlModifier) {
 					if ((int) (args.Event.State & Gdk.ModifierType.ShiftMask) != 0) {
 						ret_value = ((NoteBuffer) Buffer).AddNewline (true);
 					} else {
diff --git a/Tomboy/NoteTag.cs b/Tomboy/NoteTag.cs
index 1baf4aa..e64ff55 100644
--- a/Tomboy/NoteTag.cs
+++ b/Tomboy/NoteTag.cs
@@ -216,7 +216,7 @@ namespace Tomboy
 
 				/* Don't activate if Shift or Control is pressed */
 				if ((int) (button_ev.State & (Gdk.ModifierType.ShiftMask |
-				                              Gdk.ModifierType.ControlMask)) != 0)
+				                              Services.NativeApplication.ControlModifier)) != 0)
 					return false;
 
 				// Prevent activation when selecting links with the mouse
@@ -245,7 +245,7 @@ namespace Tomboy
 				Gdk.EventKey key_ev = new Gdk.EventKey (ev.Handle);
 
 				// Control-Enter activates the link at point...
-				if ((int) (key_ev.State & Gdk.ModifierType.ControlMask) == 0)
+				if ((int) (key_ev.State & Services.NativeApplication.ControlModifier) == 0)
 					return false;
 
 				if (key_ev.Key != Gdk.Key.Return &&
diff --git a/Tomboy/NoteWindow.cs b/Tomboy/NoteWindow.cs
index 890f07e..ecaedb1 100644
--- a/Tomboy/NoteWindow.cs
+++ b/Tomboy/NoteWindow.cs
@@ -61,7 +61,7 @@ namespace Tomboy
 			find_item.AddAccelerator ("activate",
 			                          accel_group,
 			                          (uint) Gdk.Key.f,
-			                          Gdk.ModifierType.ControlMask,
+			                          Services.NativeApplication.ControlModifier,
 			                          Gtk.AccelFlags.Visible);
 			find_item.Show ();
 			text_menu.Append (find_item);
@@ -121,7 +121,7 @@ namespace Tomboy
 			if (!using_emacs)
 				global_keys.AddAccelerator (new EventHandler (CloseWindowHandler),
 				                            (uint) Gdk.Key.w,
-				                            Gdk.ModifierType.ControlMask,
+				                            Services.NativeApplication.ControlModifier,
 				                            Gtk.AccelFlags.Visible);
 
 			// Escape has been moved to be handled by a KeyPress Handler so that
@@ -130,19 +130,19 @@ namespace Tomboy
 			// Close all windows on current Desktop (Ctrl-Q)
 			global_keys.AddAccelerator (new EventHandler (CloseAllWindowsHandler),
 			                            (uint) Gdk.Key.q,
-			                            Gdk.ModifierType.ControlMask,
+			                            Services.NativeApplication.ControlModifier,
 			                            Gtk.AccelFlags.Visible);
 
 			// Find Next (Ctrl-G)
 			global_keys.AddAccelerator (new EventHandler (FindNextActivate),
 			                            (uint) Gdk.Key.g,
-			                            Gdk.ModifierType.ControlMask,
+			                            Services.NativeApplication.ControlModifier,
 			                            Gtk.AccelFlags.Visible);
 
 			// Find Previous (Ctrl-Shift-G)
 			global_keys.AddAccelerator (new EventHandler (FindPreviousActivate),
 			                            (uint) Gdk.Key.g,
-			                            (Gdk.ModifierType.ControlMask |
+			                            (Services.NativeApplication.ControlModifier |
 			                             Gdk.ModifierType.ShiftMask),
 			                            Gtk.AccelFlags.Visible);
 
@@ -156,7 +156,7 @@ namespace Tomboy
 			if (!using_emacs)
 				global_keys.AddAccelerator (new EventHandler (CreateNewNote),
 				                            (uint) Gdk.Key.n,
-				                            Gdk.ModifierType.ControlMask,
+				                            Services.NativeApplication.ControlModifier,
 				                            Gtk.AccelFlags.Visible);
 
 			// Have Esc key close the find bar or note window
@@ -165,7 +165,7 @@ namespace Tomboy
 			// Increase Indent
 			global_keys.AddAccelerator (new EventHandler (ChangeDepthRightHandler),
 			                            (uint) Gdk.Key.Right,
-			                            Gdk.ModifierType.Mod1Mask,
+			                            Gdk.ModifierType.Mod5Mask,
 			                            Gtk.AccelFlags.Visible);
 
 			// Decrease Indent
@@ -352,7 +352,7 @@ namespace Tomboy
 			search.AddAccelerator ("activate",
 			                       accel_group,
 			                       (uint) Gdk.Key.f,
-			                       (Gdk.ModifierType.ControlMask |
+			                       (Services.NativeApplication.ControlModifier |
 			                        Gdk.ModifierType.ShiftMask),
 			                       Gtk.AccelFlags.Visible);
 			search.Show ();
@@ -365,7 +365,7 @@ namespace Tomboy
 			link.AddAccelerator ("activate",
 			                     accel_group,
 			                     (uint) Gdk.Key.l,
-			                     Gdk.ModifierType.ControlMask,
+			                     Services.NativeApplication.ControlModifier,
 			                     Gtk.AccelFlags.Visible);
 			link.Show ();
 
@@ -398,7 +398,7 @@ namespace Tomboy
 			close_all.AddAccelerator ("activate",
 			                          accel_group,
 			                          (uint) Gdk.Key.q,
-			                          Gdk.ModifierType.ControlMask,
+			                          Services.NativeApplication.ControlModifier,
 			                          Gtk.AccelFlags.Visible);
 			close_all.Show ();
 
@@ -409,7 +409,7 @@ namespace Tomboy
 			close_window.AddAccelerator ("activate",
 			                             accel_group,
 			                             (uint) Gdk.Key.w,
-			                             Gdk.ModifierType.ControlMask,
+			                             Services.NativeApplication.ControlModifier,
 			                             Gtk.AccelFlags.Visible);
 			close_window.Show ();
 
@@ -440,7 +440,7 @@ namespace Tomboy
 			search.AddAccelerator ("clicked",
 			                       accel_group,
 			                       (uint) Gdk.Key.f,
-			                       (Gdk.ModifierType.ControlMask |
+			                       (Services.NativeApplication.ControlModifier |
 			                        Gdk.ModifierType.ShiftMask),
 			                       Gtk.AccelFlags.Visible);
 			search.ShowAll ();
@@ -459,7 +459,7 @@ namespace Tomboy
 			link_button.AddAccelerator ("clicked",
 			                            accel_group,
 			                            (uint) Gdk.Key.l,
-			                            Gdk.ModifierType.ControlMask,
+			                            Services.NativeApplication.ControlModifier,
 			                            Gtk.AccelFlags.Visible);
 			link_button.ShowAll ();
 			tb.Insert (link_button, -1);
@@ -565,7 +565,7 @@ namespace Tomboy
 			find.AddAccelerator ("activate",
 			                     accel_group,
 			                     (uint) Gdk.Key.f,
-			                     Gdk.ModifierType.ControlMask,
+			                     Services.NativeApplication.ControlModifier,
 			                     Gtk.AccelFlags.Visible);
 			find.Show ();
 
@@ -578,7 +578,7 @@ namespace Tomboy
 			find_next.AddAccelerator ("activate",
 			                          accel_group,
 			                          (uint) Gdk.Key.g,
-			                          Gdk.ModifierType.ControlMask,
+			                          Services.NativeApplication.ControlModifier,
 			                          Gtk.AccelFlags.Visible);
 			find_next.Show ();
 
@@ -591,7 +591,7 @@ namespace Tomboy
 			find_previous.AddAccelerator ("activate",
 			                              accel_group,
 			                              (uint) Gdk.Key.g,
-			                              (Gdk.ModifierType.ControlMask |
+			                              (Services.NativeApplication.ControlModifier |
 			                               Gdk.ModifierType.ShiftMask),
 			                              Gtk.AccelFlags.Visible);
 			find_previous.Show ();
@@ -1230,7 +1230,7 @@ namespace Tomboy
 				undo.AddAccelerator ("activate",
 				                     accel_group,
 				                     (uint) Gdk.Key.z,
-				                     Gdk.ModifierType.ControlMask,
+				                     Services.NativeApplication.ControlModifier,
 				                     Gtk.AccelFlags.Visible);
 				undo.Show ();
 				Append (undo);
@@ -1240,7 +1240,7 @@ namespace Tomboy
 				redo.AddAccelerator ("activate",
 				                     accel_group,
 				                     (uint) Gdk.Key.z,
-				                     (Gdk.ModifierType.ControlMask |
+				                     (Services.NativeApplication.ControlModifier |
 				                      Gdk.ModifierType.ShiftMask),
 				                     Gtk.AccelFlags.Visible);
 				redo.Show ();
@@ -1263,7 +1263,7 @@ namespace Tomboy
 			bold.AddAccelerator ("activate",
 			                     accel_group,
 			                     (uint) Gdk.Key.b,
-			                     Gdk.ModifierType.ControlMask,
+			                     Services.NativeApplication.ControlModifier,
 			                     Gtk.AccelFlags.Visible);
 
 			italic = new Gtk.CheckMenuItem ("<i>" +
@@ -1275,7 +1275,7 @@ namespace Tomboy
 			italic.AddAccelerator ("activate",
 			                       accel_group,
 			                       (uint) Gdk.Key.i,
-			                       Gdk.ModifierType.ControlMask,
+			                       Services.NativeApplication.ControlModifier,
 			                       Gtk.AccelFlags.Visible);
 
 			strikeout = new Gtk.CheckMenuItem ("<s>" +
@@ -1287,7 +1287,7 @@ namespace Tomboy
 			strikeout.AddAccelerator ("activate",
 			                          accel_group,
 			                          (uint) Gdk.Key.s,
-			                          Gdk.ModifierType.ControlMask,
+			                          Services.NativeApplication.ControlModifier,
 			                          Gtk.AccelFlags.Visible);
 
 			highlight = new Gtk.CheckMenuItem ("<span background='yellow'>" +
@@ -1299,7 +1299,7 @@ namespace Tomboy
 			highlight.AddAccelerator ("activate",
 			                          accel_group,
 			                          (uint) Gdk.Key.h,
-			                          Gdk.ModifierType.ControlMask,
+			                          Services.NativeApplication.ControlModifier,
 			                          Gtk.AccelFlags.Visible);
 
 			Gtk.SeparatorMenuItem spacer1 = new Gtk.SeparatorMenuItem ();
@@ -1313,12 +1313,12 @@ namespace Tomboy
 			normal.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.Key_0,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			normal.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.KP_0,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			normal.Activated += FontSizeActivated;
 
@@ -1353,17 +1353,17 @@ namespace Tomboy
 			increase_font.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.plus,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			increase_font.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.KP_Add,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			increase_font.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.equal,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			increase_font.Activated += IncreaseFontClicked;
 
@@ -1371,17 +1371,17 @@ namespace Tomboy
 			decrease_font.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.minus,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			decrease_font.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.KP_Subtract,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			decrease_font.AddAccelerator ("activate",
 						accel_group,
 						(uint) Gdk.Key.underscore,
-						Gdk.ModifierType.ControlMask,
+						Services.NativeApplication.ControlModifier,
 						Gtk.AccelFlags.Visible);
 			decrease_font.Activated += DecreaseFontClicked;
 
diff --git a/Tomboy/RecentChanges.cs b/Tomboy/RecentChanges.cs
index 58823cf..042b0d8 100644
--- a/Tomboy/RecentChanges.cs
+++ b/Tomboy/RecentChanges.cs
@@ -738,7 +738,7 @@ namespace Tomboy
 			switch (args.Event.Type) {
 			case Gdk.EventType.TwoButtonPress:
 				if (args.Event.Button != 1 || (args.Event.State &
-						(Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask)) != 0) {
+						(Services.NativeApplication.ControlModifier | Gdk.ModifierType.ShiftMask)) != 0) {
 					break;
 				}
 
@@ -762,7 +762,7 @@ namespace Tomboy
 				}
 
 				if (tree.Selection.PathIsSelected (path) && (args.Event.State &
-						(Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask)) == 0) {
+						(Services.NativeApplication.ControlModifier | Gdk.ModifierType.ShiftMask)) == 0) {
 					if (column != null && args.Event.Button == 1) {
 						Gtk.CellRenderer renderer = column.CellRenderers [0];
 						Gdk.Rectangle background_area = tree.GetBackgroundArea (path, column);
@@ -818,7 +818,7 @@ namespace Tomboy
 		void OnTreeViewButtonReleased (object sender, Gtk.ButtonReleaseEventArgs args)
 		{
 			if (!Gtk.Drag.CheckThreshold (tree, clickX, clickY, (int)args.Event.X, (int)args.Event.Y) &&
-					((args.Event.State & (Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask)) == 0) &&
+					((args.Event.State & (Services.NativeApplication.ControlModifier | Gdk.ModifierType.ShiftMask)) == 0) &&
 					tree.Selection.CountSelectedRows () > 1) {
 
 				Gtk.TreePath path;
diff --git a/Tomboy/Watchers.cs b/Tomboy/Watchers.cs
index adfdfa3..1bd5326 100644
--- a/Tomboy/Watchers.cs
+++ b/Tomboy/Watchers.cs
@@ -1063,7 +1063,7 @@ namespace Tomboy
 
 			// Don't show hand if Shift or Control is pressed
 			bool avoid_hand = (pointer_mask & (Gdk.ModifierType.ShiftMask |
-			                                   Gdk.ModifierType.ControlMask)) != 0;
+			                                   Services.NativeApplication.ControlModifier)) != 0;
 
 			if (hovering != hovering_on_link) {
 				hovering_on_link = hovering;
diff --git a/Tomboy/WindowsApplication.cs b/Tomboy/WindowsApplication.cs
index 4bbb27b..ae056b5 100644
--- a/Tomboy/WindowsApplication.cs
+++ b/Tomboy/WindowsApplication.cs
@@ -121,6 +121,10 @@ namespace Tomboy
 		{
 			OpenUrl ("http://library.gnome.org/users/tomboy/0.12/";, screen);
 		}
+		
+		public Gdk.ModifierType ControlModifier {
+			get { return Gdk.ModifierType.ControlMask; }
+		}
 
 		#endregion
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]