From e75b8144322b4b7c9a731ba8ff467962229c1701 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 18 Mar 2012 14:06:13 +0100 Subject: [PATCH] Show inline find while typing in an overlay --- midori/midori-view.c | 14 ++++++++++++++ toolbars/midori-findbar.c | 3 ++- toolbars/midori-findbar.h | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/midori/midori-view.c b/midori/midori-view.c index 670a3592..63b8f93d 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -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 diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c index 122489dc..22ab5da4 100644 --- a/toolbars/midori-findbar.c +++ b/toolbars/midori-findbar.c @@ -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; diff --git a/toolbars/midori-findbar.h b/toolbars/midori-findbar.h index e5871732..5f1a54c5 100644 --- a/toolbars/midori-findbar.h +++ b/toolbars/midori-findbar.h @@ -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, -- 2.39.5