]> spindle.queued.net Git - midori/commitdiff
Show inline find while typing in an overlay
authorChristian Dywan <christian@twotoasts.de>
Sun, 18 Mar 2012 13:06:13 +0000 (14:06 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sun, 18 Mar 2012 13:06:13 +0000 (14:06 +0100)
midori/midori-view.c
toolbars/midori-findbar.c
toolbars/midori-findbar.h

index 670a35926d9f1b155c56a31933cb0e8d2d9d8ce1..63b8f93dc574bc7d06fa5aded896b14d1a348ff1 100644 (file)
@@ -15,6 +15,7 @@
 #include "midori-searchaction.h"
 #include "midori-platform.h"
 #include "midori-core.h"
+#include "midori-findbar.h"
 
 #include "marshal.h"
 
@@ -116,6 +117,7 @@ struct _MidoriView
     #if GTK_CHECK_VERSION (3, 2, 0)
     GtkWidget* overlay;
     GtkWidget* overlay_label;
+    GtkWidget* overlay_find;
     #endif
 };
 
@@ -2044,7 +2046,12 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view,
         && !webkit_web_view_can_paste_clipboard (web_view))
     {
         gchar* text = character ? g_strdup_printf ("%c", character) : NULL;
+        #if GTK_CHECK_VERSION(3, 2, 0)
+        midori_findbar_search_text (MIDORI_FINDBAR (view->overlay_find),
+            (GtkWidget*)view, TRUE, katze_str_non_null (text));
+        #else
         g_signal_emit (view, signals[SEARCH_TEXT], 0, TRUE, text ? text : "");
+        #endif
         g_free (text);
         return TRUE;
     }
@@ -3174,10 +3181,17 @@ midori_view_init (MidoriView* view)
     gtk_container_add (GTK_CONTAINER (view->overlay), view->scrolled_window);
     gtk_box_pack_start (GTK_BOX (view), view->overlay, TRUE, TRUE, 0);
 
+    /* Overlays must be created before showing GtkOverlay as of GTK+ 3.2 */
     view->overlay_label = gtk_label_new (NULL);
     gtk_widget_set_halign (view->overlay_label, GTK_ALIGN_START);
     gtk_widget_set_valign (view->overlay_label, GTK_ALIGN_END);
     gtk_overlay_add_overlay (GTK_OVERLAY (view->overlay), view->overlay_label);
+    view->overlay_find = g_object_new (MIDORI_TYPE_FINDBAR, NULL);
+    gtk_widget_set_halign (view->overlay_find, GTK_ALIGN_END);
+    gtk_widget_set_valign (view->overlay_find, GTK_ALIGN_START);
+    gtk_overlay_add_overlay (GTK_OVERLAY (view->overlay),
+                             view->overlay_find);
+    gtk_widget_set_no_show_all (view->overlay_find, TRUE);
     #else
     gtk_box_pack_start (GTK_BOX (view), view->scrolled_window, TRUE, TRUE, 0);
     #endif
index 122489dcb2e096401e19a3e5a5979cf07b081cd6..22ab5da40a331e0955e1d4b225453736d203f6ee 100644 (file)
@@ -253,6 +253,7 @@ midori_findbar_init (MidoriFindbar* findbar)
     #endif
     gtk_toolbar_set_icon_size (GTK_TOOLBAR (findbar), GTK_ICON_SIZE_MENU);
     gtk_toolbar_set_style (GTK_TOOLBAR (findbar), GTK_TOOLBAR_BOTH_HORIZ);
+    gtk_toolbar_set_show_arrow (GTK_TOOLBAR (findbar), FALSE);
     g_signal_connect (findbar, "key-press-event",
         G_CALLBACK (midori_findbar_find_key_press_event_cb), NULL);
 
@@ -336,7 +337,7 @@ void
 midori_findbar_search_text (MidoriFindbar* findbar,
                             GtkWidget*     view,
                             gboolean       found,
-                            gchar*         typing)
+                            const gchar*   typing)
 {
     const gchar* text;
     gboolean case_sensitive;
index e5871732f0d91e4344d3f2d9cea5a7ea9f95d941..5f1a54c54a6c0c5b20f081d29a233c9258305d15 100644 (file)
@@ -55,7 +55,7 @@ void
 midori_findbar_search_text            (MidoriFindbar* findbar,
                                        GtkWidget*     view,
                                        gboolean       found,
-                                       gchar*         typing);
+                                       const gchar*   typing);
 
 void
 midori_findbar_set_close_button_left  (MidoriFindbar* findbar,