Search inline directly when preedit text changes
This commit is contained in:
parent
61e51ea1d2
commit
cd69cdedb9
2 changed files with 31 additions and 9 deletions
|
@ -97,22 +97,29 @@ midori_findbar_case_sensitive (MidoriFindbar* findbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_findbar_find (MidoriFindbar* findbar,
|
midori_findbar_find_text (MidoriFindbar* findbar,
|
||||||
gboolean forward)
|
const gchar* text,
|
||||||
|
gboolean forward)
|
||||||
{
|
{
|
||||||
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
|
MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
|
||||||
const gchar* text;
|
|
||||||
gboolean case_sensitive;
|
gboolean case_sensitive;
|
||||||
GtkWidget* view;
|
GtkWidget* view;
|
||||||
|
|
||||||
if (!(view = midori_browser_get_current_tab (browser)))
|
if (!(view = midori_browser_get_current_tab (browser)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
|
|
||||||
case_sensitive = midori_findbar_case_sensitive (findbar);
|
case_sensitive = midori_findbar_case_sensitive (findbar);
|
||||||
midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
|
midori_view_search_text (MIDORI_VIEW (view), text, case_sensitive, forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
midori_findbar_find (MidoriFindbar* findbar,
|
||||||
|
gboolean forward)
|
||||||
|
{
|
||||||
|
const gchar* text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
|
||||||
|
midori_findbar_find_text (findbar, text, forward);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_findbar_invoke (MidoriFindbar* findbar)
|
midori_findbar_invoke (MidoriFindbar* findbar)
|
||||||
{
|
{
|
||||||
|
@ -161,20 +168,28 @@ midori_findbar_button_close_clicked_cb (GtkWidget* widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_findbar_text_changed_cb (GtkWidget* entry,
|
midori_findbar_preedit_changed_cb (GtkWidget* entry,
|
||||||
MidoriFindbar* findbar)
|
const gchar* preedit,
|
||||||
|
MidoriFindbar* findbar)
|
||||||
{
|
{
|
||||||
if (findbar->find_typing)
|
if (findbar->find_typing)
|
||||||
{
|
{
|
||||||
MidoriBrowser* browser = midori_browser_get_for_widget (entry);
|
MidoriBrowser* browser = midori_browser_get_for_widget (entry);
|
||||||
GtkWidget* view = midori_browser_get_current_tab (browser);
|
GtkWidget* view = midori_browser_get_current_tab (browser);
|
||||||
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
||||||
midori_view_unmark_text_matches (MIDORI_VIEW (view));
|
midori_view_unmark_text_matches (MIDORI_VIEW (view));
|
||||||
if (g_utf8_strlen (text, -1) > 1)
|
if (g_utf8_strlen (preedit, -1) > 1)
|
||||||
midori_findbar_find (findbar, TRUE);
|
midori_findbar_find_text (findbar, preedit, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_findbar_text_changed_cb (GtkWidget* entry,
|
||||||
|
MidoriFindbar* findbar)
|
||||||
|
{
|
||||||
|
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
|
midori_findbar_preedit_changed_cb (entry, text, findbar);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
midori_findbar_text_focus_out_event_cb (GtkWidget* entry,
|
midori_findbar_text_focus_out_event_cb (GtkWidget* entry,
|
||||||
GdkEventFocus* event,
|
GdkEventFocus* event,
|
||||||
|
@ -227,6 +242,8 @@ midori_findbar_init (MidoriFindbar* findbar)
|
||||||
G_CALLBACK (midori_findbar_entry_clear_icon_released_cb), NULL);
|
G_CALLBACK (midori_findbar_entry_clear_icon_released_cb), NULL);
|
||||||
g_signal_connect (findbar->find_text, "activate",
|
g_signal_connect (findbar->find_text, "activate",
|
||||||
G_CALLBACK (midori_findbar_next_activate_cb), findbar);
|
G_CALLBACK (midori_findbar_next_activate_cb), findbar);
|
||||||
|
g_signal_connect (findbar->find_text, "preedit-changed",
|
||||||
|
G_CALLBACK (midori_findbar_preedit_changed_cb), findbar);
|
||||||
g_signal_connect (findbar->find_text, "changed",
|
g_signal_connect (findbar->find_text, "changed",
|
||||||
G_CALLBACK (midori_findbar_text_changed_cb), findbar);
|
G_CALLBACK (midori_findbar_text_changed_cb), findbar);
|
||||||
g_signal_connect (findbar->find_text, "focus-out-event",
|
g_signal_connect (findbar->find_text, "focus-out-event",
|
||||||
|
|
|
@ -42,6 +42,11 @@ void
|
||||||
midori_findbar_find (MidoriFindbar* findbar,
|
midori_findbar_find (MidoriFindbar* findbar,
|
||||||
gboolean forward);
|
gboolean forward);
|
||||||
|
|
||||||
|
void
|
||||||
|
midori_findbar_find_text (MidoriFindbar* findbar,
|
||||||
|
const gchar* text,
|
||||||
|
gboolean forward);
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_findbar_set_can_find (MidoriFindbar* findbar,
|
midori_findbar_set_can_find (MidoriFindbar* findbar,
|
||||||
gboolean can_find);
|
gboolean can_find);
|
||||||
|
|
Loading…
Reference in a new issue