]> spindle.queued.net Git - midori/commitdiff
Open or focus Inline Find on activation, close it with Escape
authorNick Schermer <nick@xfce.org>
Sat, 24 Jan 2009 14:34:31 +0000 (15:34 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 24 Jan 2009 14:34:31 +0000 (15:34 +0100)
midori/midori-browser.c

index 4fc00dc8a7b74b455721128b8e7fef396a61cae7..cddf94472fd726d08753afbd4467ee730ff270c8 100644 (file)
@@ -1486,24 +1486,15 @@ static void
 _action_find_activate (GtkAction*     action,
                        MidoriBrowser* browser)
 {
-    GtkWidget* view;
-
-    if (GTK_WIDGET_VISIBLE (browser->find))
-    {
-        view = midori_browser_get_current_tab (browser);
-        midori_view_unmark_text_matches (MIDORI_VIEW (view));
-        gtk_toggle_tool_button_set_active (
-            GTK_TOGGLE_TOOL_BUTTON (browser->find_highlight), FALSE);
-        gtk_widget_hide (browser->find);
-    }
-    else
+    if (!GTK_WIDGET_VISIBLE (browser->find))
     {
         gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
                                             GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_FIND);
         gtk_entry_set_text (GTK_ENTRY (browser->find_text), "");
         gtk_widget_show (browser->find);
-        gtk_widget_grab_focus (GTK_WIDGET (browser->find_text));
     }
+
+    gtk_widget_grab_focus (GTK_WIDGET (browser->find_text));
 }
 
 static void
@@ -1550,6 +1541,19 @@ _find_highlight_toggled (GtkToggleToolButton* toolitem,
     midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
 }
 
+static gboolean
+midori_browser_find_key_press_event_cb (GtkWidget*   toolbar,
+                                        GdkEventKey* event)
+{
+    if (event->keyval == GDK_Escape)
+    {
+        gtk_widget_hide (toolbar);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
 static void
 midori_browser_find_button_close_clicked_cb (GtkWidget*     widget,
                                              MidoriBrowser* browser)
@@ -4185,6 +4189,8 @@ midori_browser_init (MidoriBrowser* browser)
     gtk_widget_set_name (browser->find, "MidoriFindbar");
     gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->find), GTK_ICON_SIZE_MENU);
     gtk_toolbar_set_style (GTK_TOOLBAR (browser->find), GTK_TOOLBAR_BOTH_HORIZ);
+    g_signal_connect (browser->find, "key-press-event",
+                      G_CALLBACK (midori_browser_find_key_press_event_cb), NULL);
     toolitem = gtk_tool_item_new ();
     gtk_container_set_border_width (GTK_CONTAINER (toolitem), 6);
     gtk_container_add (GTK_CONTAINER (toolitem),