static void
midori_view_search_text_cb (GtkWidget* view,
gboolean found,
+ gchar* typing,
MidoriBrowser* browser)
{
const gchar* text;
gboolean case_sensitive;
gboolean highlight;
+ if (typing)
+ {
+ gint position = -1;
+
+ gtk_widget_show (browser->find);
+ gtk_window_set_focus (GTK_WINDOW (browser), browser->find_text);
+ gtk_editable_insert_text (GTK_EDITABLE (browser->find_text), typing, -1, &position);
+ gtk_editable_set_position (GTK_EDITABLE (browser->find_text), -1);
+ }
if (GTK_WIDGET_VISIBLE (browser->find))
{
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (browser->find_text),
MIDORI_TYPE_VIEW,
MIDORI_TYPE_NEW_VIEW);
+ /**
+ * MidoriView::search-text:
+ * @view: the object on which the signal is emitted
+ * @found: whether the search was successful
+ * @typing: whether the search was initiated by typing
+ *
+ * Emitted when a search is performed. Either manually
+ * invoked or automatically by typing. The value of typing
+ * is actually the text the user typed.
+ *
+ * Note that in 0.1.3 the argument @typing was introduced.
+ */
signals[SEARCH_TEXT] = g_signal_new (
"search-text",
G_TYPE_FROM_CLASS (class),
0,
0,
NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
+ midori_cclosure_marshal_VOID__BOOLEAN_STRING,
+ G_TYPE_NONE, 2,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING);
signals[ADD_BOOKMARK] = g_signal_new (
"add-bookmark",
return FALSE;
}
+static gboolean
+gtk_widget_key_press_event_cb (WebKitWebView* web_view,
+ GdkEventKey* event,
+ MidoriView* view)
+{
+ guint character = gdk_unicode_to_keyval (event->keyval);
+
+ if (!webkit_web_view_can_cut_clipboard (web_view)
+ && !webkit_web_view_can_paste_clipboard (web_view))
+ {
+ gchar* text = g_strdup_printf ("%c", character);
+
+ g_signal_emit (view, signals[SEARCH_TEXT], 0,
+ webkit_web_view_search_text (web_view,
+ text, FALSE, TRUE, TRUE), text);
+ g_free (text);
+ }
+
+ return FALSE;
+}
+
static gboolean
gtk_widget_scroll_event_cb (WebKitWebView* web_view,
GdkEventScroll* event,
webkit_web_view_hovering_over_link_cb, view,
"signal::button-press-event",
gtk_widget_button_press_event_cb, view,
+ "signal::key-press-event",
+ gtk_widget_key_press_event_cb, view,
"signal::scroll-event",
gtk_widget_scroll_event_cb, view,
"signal::populate-popup",
g_signal_emit (view, signals[SEARCH_TEXT], 0,
webkit_web_view_search_text (WEBKIT_WEB_VIEW (view->web_view),
- text, case_sensitive, forward, TRUE));
+ text, case_sensitive, forward, TRUE), NULL);
}
/**