diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-03-02 17:48:14 +0100 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-03-02 17:48:14 +0100 |
commit | ec208dcc25e90d10d983cd16a2b5ea34bac51c05 (patch) | |
tree | f0343a3051ae214a61fe560a193c89ca3aadfe57 /src | |
parent | 538ab3dee6461ac9340172d6d8f198870415c0b6 (diff) | |
download | abrt-ec208dcc25e90d10d983cd16a2b5ea34bac51c05.tar.gz abrt-ec208dcc25e90d10d983cd16a2b5ea34bac51c05.tar.xz abrt-ec208dcc25e90d10d983cd16a2b5ea34bac51c05.zip |
gui-wizard-gtk: highlight the search result
Diffstat (limited to 'src')
-rw-r--r-- | src/gui-wizard-gtk/wizard.c | 33 | ||||
-rw-r--r-- | src/gui-wizard-gtk/wizard.glade | 47 |
2 files changed, 30 insertions, 50 deletions
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 77699480..27692925 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -788,20 +788,41 @@ static gint next_page_no(gint current_page_no, gpointer data) } + static gboolean highlight_search(gpointer user_data) { GtkEntry *entry = GTK_ENTRY(user_data); - g_print("searching: %s\n", gtk_entry_get_text(entry)); - //returning will make gtk to remove this event + GtkTextBuffer *buffer = gtk_text_view_get_buffer(g_tv_backtrace); + GtkTextIter start_find; + GtkTextIter end_find; + GtkTextIter start_match; + GtkTextIter end_match; + int offset = 0; + + gtk_text_buffer_get_start_iter(buffer, &start_find); + gtk_text_buffer_get_end_iter(buffer, &end_find); + gtk_text_buffer_remove_tag_by_name(buffer, "search_result_bg", &start_find, &end_find); + VERB1 log("searching: %s\n", gtk_entry_get_text(entry)); + while(gtk_text_iter_forward_search(&start_find, gtk_entry_get_text(entry), + GTK_TEXT_SEARCH_TEXT_ONLY, &start_match, + &end_match, NULL)) + { + gtk_text_buffer_apply_tag_by_name(buffer, "search_result_bg", + &start_match, &end_match); + offset = gtk_text_iter_get_offset(&end_match); + gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset); + } + + //returning false will make glib to remove this event return false; } static void search_timeout(GtkEntry *entry) { - /* this little hack makes the search start after 500 milisec after + /* this little hack makes the search start searching after 500 milisec after * user stops writing into entry box * if this part is removed, then the search will be started on every - * char written into the entry + * change of the search entry */ if(g_timeout != 0) g_source_remove(g_timeout); @@ -953,12 +974,10 @@ void create_assistant() g_signal_connect(g_tb_approve_bt, "toggled", G_CALLBACK(on_bt_approve_toggle), NULL); g_signal_connect(g_btn_refresh, "clicked", G_CALLBACK(on_btn_refresh_clicked), NULL); - /* init search */ + /* init searching */ GtkTextBuffer *backtrace_buf = gtk_text_view_get_buffer(g_tv_backtrace); /* found items background */ gtk_text_buffer_create_tag(backtrace_buf, "search_result_bg", "background", "red", NULL); - /* current position */ - gtk_text_buffer_create_tag(backtrace_buf, "current_pos_bg", "background", "yellow", NULL); g_signal_connect(g_search_entry_bt, "changed", G_CALLBACK(search_timeout), NULL); gtk_assistant_set_page_complete(g_assistant, diff --git a/src/gui-wizard-gtk/wizard.glade b/src/gui-wizard-gtk/wizard.glade index 9dde4316..0db515d2 100644 --- a/src/gui-wizard-gtk/wizard.glade +++ b/src/gui-wizard-gtk/wizard.glade @@ -322,53 +322,14 @@ <property name="visible">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkHBox" id="hbox2"> + <object class="GtkEntry" id="entry_search_bt"> <property name="visible">True</property> - <child> - <object class="GtkEntry" id="entry_search_bt"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="secondary_icon_stock">gtk-find</property> - </object> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="vbox2"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkArrow" id="arrow1"> - <property name="visible">True</property> - <property name="arrow_type">up</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkArrow" id="arrow2"> - <property name="visible">True</property> - <property name="arrow_type">down</property> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="secondary_icon_stock">gtk-find</property> </object> <packing> <property name="expand">False</property> - <property name="fill">False</property> <property name="position">0</property> </packing> </child> |