talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit c56ee766b98962cf019fea4f362de5235d603fec
parent 854d9907ae7f17594267b5b3942211cfa754a205
Author: Colin Leroy <colin@colino.net>
Date:   Mon, 19 May 2008 16:41:32 +0000

2008-05-19 [colin]	3.4.0cvs54

	* src/prefs_filtering_action.c
	* src/prefs_matcher.c
	* src/common/tags.c
	* src/common/tags.h
	* src/gtk/combobox.c
	* src/gtk/combobox.h
		Patch by Pawel: disabled Tags menus in filtering dialogs

Diffstat:
MChangeLog | 10++++++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/common/tags.c | 4++++
Msrc/common/tags.h | 1+
Msrc/gtk/combobox.c | 40++++++++++++++++++++++++++++++++++++++++
Msrc/gtk/combobox.h | 3+++
Msrc/prefs_filtering_action.c | 16+++++++++++++---
Msrc/prefs_matcher.c | 31+++++++++++++++++++++++--------
9 files changed, 96 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,13 @@ +2008-05-19 [colin] 3.4.0cvs54 + + * src/prefs_filtering_action.c + * src/prefs_matcher.c + * src/common/tags.c + * src/common/tags.h + * src/gtk/combobox.c + * src/gtk/combobox.h + Patch by Pawel: disabled Tags menus in filtering dialogs + 2008-05-19 [colin] 3.4.0cvs53 * src/prefs_account.c diff --git a/PATCHSETS b/PATCHSETS @@ -3349,3 +3349,4 @@ ( cvs diff -u -r 1.13.2.34 -r 1.13.2.35 src/common/plugin.c; cvs diff -u -r 1.1.4.100 -r 1.1.4.101 src/etpan/imap-thread.c; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/etpan/nntp-thread.c; cvs diff -u -r 1.1.4.44 -r 1.1.4.45 src/gtk/gtksctree.c; ) > 3.4.0cvs51.patchset ( cvs diff -u -r 1.274.2.241 -r 1.274.2.242 src/mainwindow.c; ) > 3.4.0cvs52.patchset ( cvs diff -u -r 1.105.2.131 -r 1.105.2.132 src/prefs_account.c; ) > 3.4.0cvs53.patchset +( cvs diff -u -r 1.1.4.50 -r 1.1.4.51 src/prefs_filtering_action.c; cvs diff -u -r 1.43.2.72 -r 1.43.2.73 src/prefs_matcher.c; cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/common/tags.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/common/tags.h; cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/gtk/combobox.c; cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/gtk/combobox.h; ) > 3.4.0cvs54.patchset diff --git a/configure.ac b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=4 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=53 +EXTRA_VERSION=54 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/tags.c b/src/common/tags.c @@ -240,3 +240,7 @@ GSList *tags_get_list(void) return data.list; } +guint tags_get_size(void) +{ + return g_hash_table_size(tags_table); +} diff --git a/src/common/tags.h b/src/common/tags.h @@ -30,5 +30,6 @@ void tags_update_tag(gint id, const gchar *tag); const gchar *tags_get_tag(gint id); gint tags_get_id_for_str(const gchar *str); GSList *tags_get_list(void); +guint tags_get_size(void); #endif diff --git a/src/gtk/combobox.c b/src/gtk/combobox.c @@ -191,3 +191,43 @@ gboolean combobox_set_value_from_arrow_key(GtkComboBox *combobox, /* return TRUE if value could be set */ return valid; } + +static void store_set_sensitive(GtkTreeModel *model, GtkTreeIter *iter, + const gboolean sensitive) +{ + if(GTK_IS_LIST_STORE(model)) { + gtk_list_store_set(GTK_LIST_STORE(model), iter, + COMBOBOX_SENS, sensitive, + -1); + } else { + gtk_tree_store_set(GTK_TREE_STORE(model), iter, + COMBOBOX_SENS, sensitive, + -1); + } +} + +void combobox_set_sensitive(GtkComboBox *combobox, const guint index, + const gboolean sensitive) +{ + GtkTreeModel *model; + GtkTreeIter iter, child; + guint i; + + if((model = gtk_combo_box_get_model(combobox)) == NULL) + return; + + gtk_tree_model_get_iter_first(model, &iter); + for(i=0; i<index; i++) { + if(gtk_tree_model_iter_next(model, &iter) == FALSE) + return; + } + + store_set_sensitive(model, &iter, sensitive); + + if(gtk_tree_model_iter_children(model, &child, &iter) == FALSE) + return; + + do { + store_set_sensitive(model, &child, sensitive); + } while (gtk_tree_model_iter_next(model, &child) == TRUE); +} diff --git a/src/gtk/combobox.h b/src/gtk/combobox.h @@ -65,5 +65,8 @@ void combobox_set_popdown_strings(GtkComboBox *combobox, GList *list); gboolean combobox_set_value_from_arrow_key(GtkComboBox *combobox, guint keyval); +void combobox_set_sensitive (GtkComboBox *combobox, + const guint index, + const gboolean sensitive); #endif /* __COMBOBOX_H__ */ diff --git a/src/prefs_filtering_action.c b/src/prefs_filtering_action.c @@ -190,6 +190,7 @@ static struct { enum { ACTION_COMBO_TEXT, ACTION_COMBO_DATA, + ACTION_COMBO_SENS, N_ACTION_COMBO }; @@ -205,7 +206,8 @@ static GtkTreeModel *prefs_filtering_action_create_model(void) gchar *curr_menu = NULL; gint i; - store = gtk_tree_store_new(N_ACTION_COMBO, G_TYPE_STRING, G_TYPE_INT); + store = gtk_tree_store_new(N_ACTION_COMBO, G_TYPE_STRING, G_TYPE_INT, + G_TYPE_BOOLEAN); for (i = 0; action_menu[i].menu || action_menu[i].text; i++) { @@ -215,6 +217,7 @@ static GtkTreeModel *prefs_filtering_action_create_model(void) gtk_tree_store_set(store, &iter, ACTION_COMBO_TEXT, gettext(action_menu[i].menu), + ACTION_COMBO_SENS, TRUE, -1); curr_menu = action_menu[i].menu; } @@ -223,6 +226,7 @@ static GtkTreeModel *prefs_filtering_action_create_model(void) gtk_tree_store_set(store, &iter2, ACTION_COMBO_TEXT, gettext(action_menu[i].text), ACTION_COMBO_DATA, action_menu[i].action, + ACTION_COMBO_SENS, TRUE, -1); } else { curr_menu = NULL; @@ -231,6 +235,7 @@ static GtkTreeModel *prefs_filtering_action_create_model(void) gtk_tree_store_set(store, &iter, ACTION_COMBO_TEXT, gettext(action_menu[i].text), ACTION_COMBO_DATA, action_menu[i].action, + ACTION_COMBO_SENS, TRUE, -1); } } @@ -244,8 +249,9 @@ static void cell_is_sensitive(GtkCellLayout *cell_layout, GtkTreeIter *iter, gpointer data) { - gboolean sensitive = !gtk_tree_model_iter_has_child (tree_model, iter); - g_object_set (cell, "sensitive", sensitive, NULL); + if(gtk_tree_model_iter_has_child (tree_model, iter)) { + g_object_set (cell, "sensitive", FALSE, NULL); + } } /*! @@ -442,6 +448,7 @@ static void prefs_filtering_action_create(void) gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(action_combo), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(action_combo), renderer, "text", ACTION_COMBO_TEXT, + "sensitive", ACTION_COMBO_SENS, NULL); gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(action_combo), renderer, cell_is_sensitive, NULL, NULL); @@ -683,6 +690,9 @@ static void prefs_filtering_action_set_dialog(GSList *action_list) } prefs_filtering_action_reset_dialog(); + + combobox_set_sensitive(GTK_COMBO_BOX(filtering_action.action_combo), 9, + (tags_get_size() > 0) ? TRUE : FALSE); } /*! diff --git a/src/prefs_matcher.c b/src/prefs_matcher.c @@ -50,6 +50,7 @@ #include "matcher_parser.h" #include "colorlabel.h" +#include "tags.h" static void prefs_matcher_addressbook_select(void); static void prefs_matcher_test_info(GtkWidget *widget, GtkWidget *parent); @@ -514,6 +515,8 @@ static void prefs_matcher_create(void) static GdkGeometry geometry; GtkSizeGroup *size_group; + GtkListStore *store; + GtkTreeIter iter; debug_print("Creating matcher configuration window...\n"); @@ -581,14 +584,23 @@ static void prefs_matcher_create(void) gtk_table_attach(GTK_TABLE(table), criteria_label, 0, 1, 0, 1, GTK_FILL, GTK_SHRINK, 2, 2); - criteria_combo = combobox_text_new(FALSE, _("All messages"), _("Header"), - _("Age"), _("Phrase"), _("Flags"), - _("Color labels"), _("Thread"), - _("Score"), _("Size"), - _("Partially downloaded"), - _("Address book"), _("Tags"), - _("External program test"), - NULL); + criteria_combo = gtkut_sc_combobox_create(NULL, FALSE); + store = GTK_LIST_STORE(gtk_combo_box_get_model( + GTK_COMBO_BOX(criteria_combo))); + COMBOBOX_ADD(store, _("All messages"), 0); + COMBOBOX_ADD(store, _("Header"), 1); + COMBOBOX_ADD(store, _("Age"), 2); + COMBOBOX_ADD(store, _("Phrase"), 3); + COMBOBOX_ADD(store, _("Flags"), 4); + COMBOBOX_ADD(store, _("Color labels"), 5); + COMBOBOX_ADD(store, _("Thread"), 6); + COMBOBOX_ADD(store, _("Score"), 7); + COMBOBOX_ADD(store, _("Size"), 8); + COMBOBOX_ADD(store, _("Partially downloaded"), 9); + COMBOBOX_ADD(store, _("Address book"), 10); + COMBOBOX_ADD(store, _("Tags"), 11); + COMBOBOX_ADD(store, _("External program test"), 12); + gtk_widget_set_size_request(criteria_combo, 150, -1); gtk_combo_box_set_active(GTK_COMBO_BOX(criteria_combo), MATCH_ALL); gtk_table_attach(GTK_TABLE(table), criteria_combo, 1, 2, 0, 1, @@ -894,6 +906,9 @@ static void prefs_matcher_set_dialog(MatcherList *matchers) gtk_combo_box_set_active(GTK_COMBO_BOX(matcher.bool_op_combo), bool_op); prefs_matcher_reset_condition(); + + combobox_set_sensitive(GTK_COMBO_BOX(matcher.criteria_combo), MATCH_TAGS, + (tags_get_size() > 0) ? TRUE : FALSE); } /*!