2008-05-22 [colin] 3.4.0cvs63
authorColin Leroy <colin@colino.net>
Thu, 22 May 2008 15:42:19 +0000 (15:42 +0000)
committerColin Leroy <colin@colino.net>
Thu, 22 May 2008 15:42:19 +0000 (15:42 +0000)
* src/prefs_filtering_action.c
* src/gtk/combobox.c
* src/gtk/combobox.h
Fix reselecting of Tags actions in
filtering actions dialog

ChangeLog
PATCHSETS
configure.ac
src/gtk/combobox.c
src/gtk/combobox.h
src/prefs_filtering_action.c

index ac6a10e..290e25e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-22 [colin]     3.4.0cvs63
+
+       * src/prefs_filtering_action.c
+       * src/gtk/combobox.c
+       * src/gtk/combobox.h
+               Fix reselecting of Tags actions in
+               filtering actions dialog
+
 2008-05-22 [colin]     3.4.0cvs62
 
        * src/Makefile.am
index de15071..dae8e15 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.59.2.68 -r 1.59.2.69 src/prefs_filtering.c;  ) > 3.4.0cvs60.patchset
 ( cvs diff -u -r 1.36.2.140 -r 1.36.2.141 src/common/utils.c;  ) > 3.4.0cvs61.patchset
 ( cvs diff -u -r 1.155.2.85 -r 1.155.2.86 src/Makefile.am;  cvs diff -u -r 1.30.2.50 -r 1.30.2.51 src/prefs_toolbar.c;  cvs diff -u -r 1.25.2.55 -r 1.25.2.56 src/stock_pixmap.c;  cvs diff -u -r 1.18.2.34 -r 1.18.2.35 src/stock_pixmap.h;  cvs diff -u -r 1.43.2.99 -r 1.43.2.100 src/toolbar.c;  diff -u /dev/null src/pixmaps/delete_btn.xpm;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/pixmaps/insert_file.xpm;  diff -u /dev/null src/pixmaps/mail_reply_to_list.xpm;  ) > 3.4.0cvs62.patchset
+( cvs diff -u -r 1.1.4.51 -r 1.1.4.52 src/prefs_filtering_action.c;  cvs diff -u -r 1.1.2.13 -r 1.1.2.14 src/gtk/combobox.c;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/gtk/combobox.h;  ) > 3.4.0cvs63.patchset
index 8a8a466..3d89baa 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=62
+EXTRA_VERSION=63
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 55f6a31..ce96836 100644 (file)
@@ -31,6 +31,7 @@
 typedef struct _combobox_sel_by_data_ctx {
        GtkComboBox *combobox;
        gint data;
+       const gchar *cdata;
 } ComboboxSelCtx;
 
 GtkWidget *combobox_text_new(const gboolean with_entry, const gchar *text, ...)
@@ -92,6 +93,45 @@ void combobox_select_by_data(GtkComboBox *combobox, gint data)
        g_free(ctx);
 }
 
+static gboolean _select_by_text_func(GtkTreeModel *model,      GtkTreePath *path,
+               GtkTreeIter *iter, ComboboxSelCtx *ctx)
+{
+       GtkComboBox *combobox = ctx->combobox;
+       const gchar *data = ctx->cdata;
+       const gchar *curdata;
+
+       gtk_tree_model_get (GTK_TREE_MODEL(model), iter, 0, &curdata, -1);
+       if (!g_utf8_collate(data, curdata)) {
+               gtk_combo_box_set_active_iter(combobox, iter);
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+void combobox_select_by_text(GtkComboBox *combobox, const gchar *data)
+{
+       GtkTreeModel *model;
+       ComboboxSelCtx *ctx = NULL;
+       GtkComboBoxClass *class;
+
+       g_return_if_fail(combobox != NULL);
+       class = GTK_COMBO_BOX_GET_CLASS (combobox);
+
+       /* we can do that only with gtk_combo_box_next_text() combo boxes */
+       g_return_if_fail(class->get_active_text != NULL);
+
+       model = gtk_combo_box_get_model(combobox);
+
+       ctx = g_new(ComboboxSelCtx,
+                       sizeof(ComboboxSelCtx));
+       ctx->combobox = combobox;
+       ctx->cdata = data;
+
+       gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc)_select_by_text_func, ctx);
+       g_free(ctx);
+}
+
 gint combobox_get_active_data(GtkComboBox *combobox)
 {
        GtkTreeModel *model;
index 6aedcc6..ca6faf8 100644 (file)
@@ -56,7 +56,9 @@ enum {
 GtkWidget *combobox_text_new(const gboolean with_entry, const gchar *text, ...);
 
 void combobox_select_by_data   (GtkComboBox            *combobox,
-                                gint            data);
+                                gint                    data);
+void combobox_select_by_text   (GtkComboBox            *combobox,
+                                const gchar            *data);
 
 gint combobox_get_active_data  (GtkComboBox            *combobox);
 
index 037b429..2c157af 100644 (file)
@@ -1609,6 +1609,25 @@ static gboolean prefs_filtering_actions_selected
                        gtk_entry_set_text(GTK_ENTRY(filtering_action.header_entry), "");
                combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
                                     ACTION_ADD_TO_ADDRESSBOOK);
+               break;
+       case MATCHACTION_SET_TAG:
+               combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
+                                    ACTION_SET_TAG);
+               combobox_select_by_text(GTK_COMBO_BOX(filtering_action.tags_combo),
+                                       action->destination);
+               break;
+       case MATCHACTION_UNSET_TAG:
+               combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
+                                    ACTION_UNSET_TAG);
+               combobox_select_by_text(GTK_COMBO_BOX(filtering_action.tags_combo),
+                                       action->destination);
+               break;
+       case MATCHACTION_CLEAR_TAGS:
+               combobox_select_by_data(GTK_COMBO_BOX(filtering_action.action_combo),
+                                    ACTION_CLEAR_TAGS);
+               break;
+       default:
+               g_warning("unhandled case !\n");
        }
        if (action->destination)
                gtk_entry_set_text(GTK_ENTRY(filtering_action.dest_entry), action->destination);