SF.net SVN: geany: [1021] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Nov 23 12:23:36 UTC 2006


Revision: 1021
          http://svn.sourceforge.net/geany/?rev=1021&view=rev
Author:   ntrel
Date:     2006-11-23 04:23:36 -0800 (Thu, 23 Nov 2006)

Log Message:
-----------
Add switching to a notebook tab number using Alt-1 to Alt-9; Alt-0
switches to the last tab.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keybindings.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-23 11:42:10 UTC (rev 1020)
+++ trunk/ChangeLog	2006-11-23 12:23:36 UTC (rev 1021)
@@ -4,6 +4,9 @@
    data/filetypes.*:
    Only use [a-zA-Z0-9] chars for default wordchars, to avoid problems
    with word matching when using Find & Replace functions.
+ * src/keybindings.c:
+   Add switching to a notebook tab number using Alt-1 to Alt-9; Alt-0
+   switches to the last tab.
 
 
 2006-11-22  Frank Lanitz  <frank at frank.uvena.de>

Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c	2006-11-23 11:42:10 UTC (rev 1020)
+++ trunk/src/keybindings.c	2006-11-23 12:23:36 UTC (rev 1021)
@@ -41,7 +41,9 @@
 #endif
 
 
+const gboolean swap_alt_tab_order = FALSE;
 
+
 /* simple convenience function to allocate and fill the struct */
 static binding *fill(KBCallback func, guint key, GdkModifierType mod, const gchar *name,
 		const gchar *label);
@@ -373,11 +375,35 @@
 }
 
 
+static gboolean check_fixed_kb(GdkEventKey *event)
+{
+	// check alt-0 to alt-9 for setting current notebook page
+	if (event->state & GDK_MOD1_MASK && event->keyval >= GDK_0 && event->keyval <= GDK_9)
+	{
+		gint page = event->keyval - GDK_0 - 1;
+		gint npages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
+
+		// alt-0 is for the rightmost tab
+		if (event->keyval == GDK_0)
+			page = npages - 1;
+		// invert the order if tabs are added on the other side
+		if (swap_alt_tab_order && ! app->tab_order_ltr)
+			page = (npages - 1) - page;
+
+		gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), page);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+
 /* central keypress event handler, almost all keypress events go to this function */
 gboolean keybindings_got_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {
 	guint i, k;
 
+	if (check_fixed_kb(event)) return TRUE;
+
 	for (i = 0; i < GEANY_MAX_KEYS; i++)
 	{
 		// ugly hack to get around that CTRL+Shift+r results in 'R' not 'r'


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list