[gimp] app: Make alt+[number] switch tabs in single-window mode



commit 110b3daa973c9ad53ee6f1a60d59d67f2da0ba7b
Author: Mukund Sivaraman <muks banu com>
Date:   Wed Apr 6 11:52:10 2011 +0530

    app: Make alt+[number] switch tabs in single-window mode

 app/display/gimpimagewindow.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 6cf554d..50f98de 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -19,6 +19,7 @@
 
 #include <gegl.h>
 #include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "libgimpmath/gimpmath.h"
 #include "libgimpwidgets/gimpwidgets.h"
@@ -162,6 +163,9 @@ static void      gimp_image_window_switch_page         (GtkNotebook         *not
                                                         gpointer             page,
                                                         gint                 page_num,
                                                         GimpImageWindow     *window);
+static gboolean  gimp_image_window_key_pressed         (GtkWidget           *widget,
+                                                        GdkEventKey         *event,
+                                                        gpointer             user_data);
 static void      gimp_image_window_page_removed        (GtkNotebook         *notebook,
                                                         GtkWidget           *widget,
                                                         gint                 page_num,
@@ -344,6 +348,9 @@ gimp_image_window_constructed (GObject *object)
   g_signal_connect (private->notebook, "switch-page",
                     G_CALLBACK (gimp_image_window_switch_page),
                     window);
+  g_signal_connect (private->notebook, "key-press-event",
+                    G_CALLBACK (gimp_image_window_key_pressed),
+                    window);
   g_signal_connect (private->notebook, "page-removed",
                     G_CALLBACK (gimp_image_window_page_removed),
                     window);
@@ -1252,6 +1259,30 @@ gimp_image_window_switch_page (GtkNotebook     *notebook,
   gimp_ui_manager_update (private->menubar_manager, active_display);
 }
 
+static gboolean
+gimp_image_window_key_pressed (GtkWidget           *widget,
+                               GdkEventKey         *event,
+                               gpointer             user_data)
+{
+  if (event->state & GDK_MOD1_MASK)
+    {
+      if ((event->keyval >= GDK_KEY_0) &&
+          (event->keyval <= GDK_KEY_9))
+        {
+          guint tab = (event->keyval - GDK_KEY_0) - 1;
+          gint n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (widget));
+
+          if (tab < n)
+            {
+              gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), tab);
+              return TRUE;
+            }
+        }
+    }
+
+  return FALSE;
+}
+
 static void
 gimp_image_window_page_removed (GtkNotebook     *notebook,
                                 GtkWidget       *widget,



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