From 9abc95aaec8f886749f95fdbec050c08c42ee14e Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 22 May 2008 15:42:19 +0000 Subject: [PATCH] 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 --- ChangeLog | 8 ++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/gtk/combobox.c | 40 ++++++++++++++++++++++++++++++++++++ src/gtk/combobox.h | 4 +++- src/prefs_filtering_action.c | 19 +++++++++++++++++ 6 files changed, 72 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac6a10e1c..290e25e15 100644 --- 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 diff --git a/PATCHSETS b/PATCHSETS index de150713a..dae8e1579 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3358,3 +3358,4 @@ ( 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 diff --git a/configure.ac b/configure.ac index 8a8a46640..3d89baace 100644 --- a/configure.ac +++ b/configure.ac @@ -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= diff --git a/src/gtk/combobox.c b/src/gtk/combobox.c index 55f6a3181..ce9683631 100644 --- a/src/gtk/combobox.c +++ b/src/gtk/combobox.c @@ -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; diff --git a/src/gtk/combobox.h b/src/gtk/combobox.h index 6aedcc615..ca6faf809 100644 --- a/src/gtk/combobox.h +++ b/src/gtk/combobox.h @@ -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); diff --git a/src/prefs_filtering_action.c b/src/prefs_filtering_action.c index 037b429f2..2c157afcd 100644 --- a/src/prefs_filtering_action.c +++ b/src/prefs_filtering_action.c @@ -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); -- 2.25.1