aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2003-12-17 08:50:03 +0800
committerHans Petter <hansp@src.gnome.org>2003-12-17 08:50:03 +0800
commita3b04be4f0788104ba7f7e12abff000f573ec439 (patch)
tree6a1aaca5747e0686a0aafdfac325cdafd92a4cc3
parentc13a0defa3f0214e8d78b9f9b16a9c8b2f22ac32 (diff)
downloadgsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.tar
gsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.tar.gz
gsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.tar.bz2
gsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.tar.lz
gsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.tar.xz
gsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.tar.zst
gsoc2013-evolution-a3b04be4f0788104ba7f7e12abff000f573ec439.zip
Use e_source_equal() instead of comparing pointers. This allows user to
2003-12-16 Hans Petter Jansson <hpj@ximian.com> * misc/e-source-option-menu.c (select_source_foreach_menu_item): Use e_source_equal() instead of comparing pointers. This allows user to pass in a source that was obtained from somewhere else. Set the matching internal source as "selected" instead of the one passed in. (select_source): Emit signal only if we found a match. Don't ref/unref anything, since the selected source will always be from our internal list. svn path=/trunk/; revision=23954
-rw-r--r--widgets/ChangeLog10
-rw-r--r--widgets/misc/e-source-option-menu.c22
2 files changed, 24 insertions, 8 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog
index 0cd57d5557..0ee7c01e56 100644
--- a/widgets/ChangeLog
+++ b/widgets/ChangeLog
@@ -1,3 +1,13 @@
+2003-12-16 Hans Petter Jansson <hpj@ximian.com>
+
+ * misc/e-source-option-menu.c (select_source_foreach_menu_item):
+ Use e_source_equal() instead of comparing pointers. This allows user
+ to pass in a source that was obtained from somewhere else. Set the
+ matching internal source as "selected" instead of the one passed in.
+ (select_source): Emit signal only if we found a match. Don't ref/unref
+ anything, since the selected source will always be from our internal
+ list.
+
2003-12-10 Not Zed <NotZed@Ximian.com>
* menus/gal-view-menus.c (remove_instance): NULL out
diff --git a/widgets/misc/e-source-option-menu.c b/widgets/misc/e-source-option-menu.c
index f2b5b4b5cc..fd1fd3de1f 100644
--- a/widgets/misc/e-source-option-menu.c
+++ b/widgets/misc/e-source-option-menu.c
@@ -59,6 +59,8 @@ static uint signals[NUM_SIGNALS] = { 0 };
typedef struct {
ESourceOptionMenu *option_menu;
+ ESource *source;
+ ESource *found_source;
int i;
} ForeachMenuItemData;
@@ -68,8 +70,13 @@ select_source_foreach_menu_item (GtkWidget *menu_item,
{
ESource *source = gtk_object_get_data (GTK_OBJECT (menu_item), MENU_ITEM_SOURCE_DATA_ID);
- if (source == data->option_menu->priv->selected_source)
+ if (data->found_source)
+ return;
+
+ if (source && e_source_equal (source, data->source)) {
+ data->found_source = source;
gtk_option_menu_set_history (GTK_OPTION_MENU (data->option_menu), data->i);
+ }
data->i ++;
}
@@ -80,20 +87,19 @@ select_source (ESourceOptionMenu *menu,
{
ForeachMenuItemData *foreach_data;
- if (menu->priv->selected_source != NULL)
- g_object_unref (menu->priv->selected_source);
- menu->priv->selected_source = source;
-
foreach_data = g_new0 (ForeachMenuItemData, 1);
foreach_data->option_menu = menu;
+ foreach_data->source = source;
gtk_container_foreach (GTK_CONTAINER (GTK_OPTION_MENU (menu)->menu),
(GtkCallback) select_source_foreach_menu_item, foreach_data);
- g_free (foreach_data);
- g_object_ref (source);
+ if (foreach_data->found_source) {
+ menu->priv->selected_source = foreach_data->found_source;
+ g_signal_emit (menu, signals[SOURCE_SELECTED], 0, foreach_data->found_source);
+ }
- g_signal_emit (menu, signals[SOURCE_SELECTED], 0, source);
+ g_free (foreach_data);
}