From 8bf6b2775468e604c275e1a0990729f4a328e02a Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 16 Jun 2004 06:58:21 +0000 Subject: fix a path leak and maek the code more structured. 2004-06-16 Not Zed * e-source-selector.c (cell_toggled_callback): fix a path leak and maek the code more structured. (e_source_selector_set_toggle_selection): set the mode on whether you can toggle the currnet selection or not. (cell_toggled_callback): implement set_toggle_selection behaviour. svn path=/trunk/; revision=26361 --- widgets/misc/ChangeLog | 8 ++++++++ widgets/misc/e-source-selector.c | 30 +++++++++++++++++++++++------- widgets/misc/e-source-selector.h | 2 ++ 3 files changed, 33 insertions(+), 7 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 9d6e8d266f..11ba7c99fd 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,11 @@ +2004-06-16 Not Zed + + * e-source-selector.c (cell_toggled_callback): fix a path leak and + maek the code more structured. + (e_source_selector_set_toggle_selection): set the mode on whether + you can toggle the currnet selection or not. + (cell_toggled_callback): implement set_toggle_selection behaviour. + 2004-06-03 William Jon McCann * e-error.c (e_error_newv): Add HIG border width for dialog window. diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c index 2f85b5d534..28da3314b4 100644 --- a/widgets/misc/e-source-selector.c +++ b/widgets/misc/e-source-selector.c @@ -34,6 +34,7 @@ #include #include #include +#include #define PARENT_TYPE gtk_tree_view_get_type () static GtkTreeViewClass *parent_class = NULL; @@ -50,8 +51,8 @@ struct _ESourceSelectorPrivate { int rebuild_model_idle_id; gboolean toggled_last; - gboolean checkboxes_shown; + gboolean toggle_selection; }; typedef struct { @@ -496,12 +497,11 @@ cell_toggled_callback (GtkCellRendererToggle *renderer, } gtk_tree_model_get (model, &iter, 0, &data, -1); - if (E_IS_SOURCE_GROUP (data)) { - gtk_tree_path_free (path); - } else { + if (!E_IS_SOURCE_GROUP (data)) { source = E_SOURCE (data); - if (e_source_selector_peek_primary_selection (selector) != source) { + if (e_source_selector_peek_primary_selection (selector) != source + || selector->priv->toggle_selection) { if (source_is_selected (selector, source)) unselect_source (selector, source); else @@ -511,10 +511,10 @@ cell_toggled_callback (GtkCellRendererToggle *renderer, gtk_tree_model_row_changed (model, path, &iter); g_signal_emit (selector, signals[SELECTION_CHANGED], 0); - - gtk_tree_path_free (path); } } + + gtk_tree_path_free (path); g_object_unref (data); } @@ -886,6 +886,22 @@ e_source_selector_selection_shown (ESourceSelector *selector) return selector->priv->checkboxes_shown; } +/** + * e_source_selector_set_toggle_selection: + * @selector: + * @state: + * + * Set the source selectr behaviour, whether you can toggle the + * current selection or not. + **/ +void +e_source_selector_set_toggle_selection(ESourceSelector *selector, gboolean state) +{ + g_return_if_fail (E_IS_SOURCE_SELECTOR (selector)); + + selector->priv->toggle_selection = state; +} + /** * e_source_selector_select_source: * @selector: An ESourceSelector widget diff --git a/widgets/misc/e-source-selector.h b/widgets/misc/e-source-selector.h index 8d3540866d..0b65d9443a 100644 --- a/widgets/misc/e-source-selector.h +++ b/widgets/misc/e-source-selector.h @@ -72,6 +72,8 @@ void e_source_selector_show_selection (ESourceSelector *selector, gboolean show); gboolean e_source_selector_selection_shown (ESourceSelector *selector); +void e_source_selector_set_toggle_selection(ESourceSelector *selector, gboolean state); + ESource *e_source_selector_peek_primary_selection (ESourceSelector *selector); void e_source_selector_set_primary_selection (ESourceSelector *selector, ESource *source); -- cgit