aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/main_filter_toolbar.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2012-05-05 15:09:19 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2012-05-05 15:09:19 +0000
commit7afb363eab3c033f04dd34430117e014617afd36 (patch)
treec1d7cd5c25c5f2d95edf99252cd69b45e225b2be /ui/gtk/main_filter_toolbar.c
parent24f5265620124211ab52c843422d4a8a6093589b (diff)
Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6892 :
Sort the recent filters list by "most recently used" (that is, put the most recently used filter at the head of the list). svn path=/trunk/; revision=42439
Diffstat (limited to 'ui/gtk/main_filter_toolbar.c')
-rw-r--r--ui/gtk/main_filter_toolbar.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/ui/gtk/main_filter_toolbar.c b/ui/gtk/main_filter_toolbar.c
index 7be04e3d16..8ac2e9a46d 100644
--- a/ui/gtk/main_filter_toolbar.c
+++ b/ui/gtk/main_filter_toolbar.c
@@ -300,7 +300,7 @@ dfilter_entry_match(GtkWidget *filter_cm, char *s, int *index)
*index = i;
return FALSE;
}
- do{
+ do {
i++;
gtk_tree_model_get_value (model, &iter, 0, &value);
filter_str = g_value_get_string (&value);
@@ -345,14 +345,14 @@ dfilter_recent_combo_write_all(FILE *rf) {
if (!gtk_tree_model_get_iter_first (model, &iter))
return;
- do{
+ do {
gtk_tree_model_get_value (model, &iter, 0, &value);
filter_str = g_value_get_string (&value);
if(filter_str)
fprintf (rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", filter_str);
g_value_unset (&value);
- }while (gtk_tree_model_iter_next (model, &iter)&& (max_count++ < prefs.gui_recent_df_entries_max));
+ } while (gtk_tree_model_iter_next (model, &iter)&& (max_count++ < prefs.gui_recent_df_entries_max));
}
@@ -397,10 +397,20 @@ main_filter_packets(capture_file *cf, const gchar *dftext, gboolean force)
if (cf_status == CF_OK && strlen(s) > 0) {
int index;
- if(!dfilter_entry_match(filter_cm,s, &index)) {
+ if(!dfilter_entry_match(filter_cm,s, &index) || index != 0) {
+
+ /* If the filter is already there but not the first entry, remove it */
+ if (index > 0) {
+ gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(filter_cm), index);
+ index--;
+ }
+
+ /* Add the filter (at the head of the list) */
gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(filter_cm), s);
index++;
}
+
+ /* If we have too many entries, remove some */
while ((guint)index >= prefs.gui_recent_df_entries_max) {
gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(filter_cm), index);
index--;