gimp r26204 - in trunk: . plug-ins/help-browser



Author: neo
Date: Wed Jul 16 15:20:49 2008
New Revision: 26204
URL: http://svn.gnome.org/viewvc/gimp?rev=26204&view=rev

Log:
2008-07-16  Sven Neumann  <sven gimp org>

	* plug-ins/help-browser/dialog.c: also start the search when the
	slash key is pressed. Added a "find-again" feature bound to 
Ctrl-G.



Modified:
   trunk/ChangeLog
   trunk/plug-ins/help-browser/dialog.c

Modified: trunk/plug-ins/help-browser/dialog.c
==============================================================================
--- trunk/plug-ins/help-browser/dialog.c	(original)
+++ trunk/plug-ins/help-browser/dialog.c	Wed Jul 16 15:20:49 2008
@@ -88,6 +88,8 @@
                                            gpointer           data);
 static void       find_callback           (GtkAction         *action,
                                            gpointer           data);
+static void       find_again_callback     (GtkAction         *action,
+                                           gpointer           data);
 static void       copy_location_callback  (GtkAction         *action,
                                            gpointer           data);
 static void       show_index_callback     (GtkAction         *action,
@@ -117,6 +119,8 @@
                                            GdkEventButton    *event);
 static gboolean   view_button_press       (GtkWidget         *widget,
                                            GdkEventButton    *event);
+static gboolean   view_key_press          (GtkWidget         *widget,
+                                           GdkEventKey       *event);
 
 static void       title_changed           (GtkWidget         *view,
                                            WebKitWebFrame    *frame,
@@ -291,6 +295,9 @@
   g_signal_connect (view, "button-press-event",
                     G_CALLBACK (view_button_press),
                     NULL);
+  g_signal_connect (view, "key-press-event",
+                    G_CALLBACK (view_key_press),
+                    NULL);
 
 #if HAVE_WEBKIT_ZOOM_API
   webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (view), data.zoom);
@@ -578,11 +585,6 @@
       G_CALLBACK (home_callback)
     },
     {
-      "find", GTK_STOCK_FIND,
-      NULL, "<control>F", N_("Find text in current page"),
-      G_CALLBACK (find_callback)
-    },
-    {
       "copy-location", GTK_STOCK_COPY,
       N_("C_opy location"), "",
       N_("Copy the location of this page to the clipboard"),
@@ -599,6 +601,16 @@
       G_CALLBACK (zoom_out_callback)
     },
     {
+      "find", GTK_STOCK_FIND,
+      NULL, "<control>F", N_("Find text in current page"),
+      G_CALLBACK (find_callback)
+    },
+    {
+      "find-again", NULL,
+      N_("Find _Again"), "<control>G", NULL,
+      G_CALLBACK (find_again_callback)
+    },
+    {
       "close", GTK_STOCK_CLOSE,
       NULL, "<control>W", NULL,
       G_CALLBACK (close_callback)
@@ -681,9 +693,11 @@
                                      "    <menuitem action=\"stop\" />"
                                      "    <separator />"
                                      "    <menuitem action=\"home\" />"
-                                     "    <menuitem action=\"find\" />"
                                      "    <menuitem action=\"copy-location\" />"
                                      "    <menuitem action=\"show-index\" />"
+                                     "    <separator />"
+                                     "    <menuitem action=\"find\" />"
+                                     "    <menuitem action=\"find-again\" />"
 #ifdef HAVE_WEBKIT_ZOOM_API
                                      "    <separator />"
                                      "    <menuitem action=\"zoom-in\" />"
@@ -756,10 +770,23 @@
 find_callback (GtkAction *action,
                gpointer   data)
 {
+  GtkWidget *entry = g_object_get_data (G_OBJECT (searchbar), "entry");
+
   gtk_widget_show (searchbar);
-  gtk_widget_grab_focus (g_object_get_data (G_OBJECT (searchbar), "entry"));
+  gtk_widget_grab_focus (entry);
 }
 
+static void
+find_again_callback (GtkAction *action,
+                     gpointer   data)
+{
+  GtkWidget *entry = g_object_get_data (G_OBJECT (searchbar), "entry");
+
+  gtk_widget_show (searchbar);
+  gtk_widget_grab_focus (entry);
+
+  search (gtk_entry_get_text (GTK_ENTRY (entry)), TRUE);
+}
 
 static void
 copy_location_callback (GtkAction *action,
@@ -1035,6 +1062,24 @@
   return FALSE;
 }
 
+static gboolean
+view_key_press (GtkWidget   *widget,
+                GdkEventKey *event)
+{
+  if (event->keyval == GDK_slash)
+    {
+      GtkAction *action;
+
+      action = gtk_ui_manager_get_action (ui_manager,
+                                          "/ui/help-browser-popup/find");
+      gtk_action_activate (action);
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 title_changed (GtkWidget      *view,
                WebKitWebFrame *frame,
@@ -1157,6 +1202,8 @@
   if (event->keyval == GDK_Escape)
     {
       gtk_widget_hide (searchbar);
+      webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
+
       return TRUE;
     }
 
@@ -1190,4 +1237,5 @@
 search_close_clicked (GtkWidget *button)
 {
   gtk_widget_hide (searchbar);
+  webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
 }



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