From 7b8da87e1785d12a1c72cabec20c0015fdde0e40 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Mon, 1 Dec 2003 02:55:47 +0000 Subject: Add NONE:POINTER. * e-util-marshal.list: Add NONE:POINTER. * test-source-option-menu.c (source_selected_callback): New callback to test the "source_selected" signal. (on_idle_create_widget): Connect. * e-source-option-menu.c: Add "source_selected" signal. (select_source): Assume source != NULL and emit "source_selected". svn path=/trunk/; revision=23512 --- widgets/misc/ChangeLog | 11 ++++++++++ widgets/misc/e-source-option-menu.c | 37 ++++++++++++++++++++++++++-------- widgets/misc/e-util-marshal.list | 1 + widgets/misc/test-source-option-menu.c | 10 +++++++++ 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 15a2bee117..9caa036471 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,14 @@ +2003-11-30 Ettore Perazzoli + + * e-util-marshal.list: Add NONE:POINTER. + + * test-source-option-menu.c (source_selected_callback): New + callback to test the "source_selected" signal. + (on_idle_create_widget): Connect. + + * e-source-option-menu.c: Add "source_selected" signal. + (select_source): Assume source != NULL and emit "source_selected". + 2003-11-30 Ettore Perazzoli * test-source-option-menu.c: New test. diff --git a/widgets/misc/e-source-option-menu.c b/widgets/misc/e-source-option-menu.c index 3904a20dba..f2b5b4b5cc 100644 --- a/widgets/misc/e-source-option-menu.c +++ b/widgets/misc/e-source-option-menu.c @@ -24,6 +24,8 @@ #include "e-source-option-menu.h" +#include "e-util-marshal.h" + #include #include @@ -45,6 +47,14 @@ struct _ESourceOptionMenuPrivate { }; +enum { + SOURCE_SELECTED, + NUM_SIGNALS +}; + +static uint signals[NUM_SIGNALS] = { 0 }; + + /* Selecting a source. */ typedef struct { @@ -68,21 +78,22 @@ static void select_source (ESourceOptionMenu *menu, ESource *source) { + ForeachMenuItemData *foreach_data; + if (menu->priv->selected_source != NULL) g_object_unref (menu->priv->selected_source); menu->priv->selected_source = source; - if (source != NULL) { - ForeachMenuItemData *foreach_data = g_new0 (ForeachMenuItemData, 1); + foreach_data = g_new0 (ForeachMenuItemData, 1); + foreach_data->option_menu = menu; - foreach_data->option_menu = menu; + gtk_container_foreach (GTK_CONTAINER (GTK_OPTION_MENU (menu)->menu), + (GtkCallback) select_source_foreach_menu_item, foreach_data); - 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); - g_free (foreach_data); - g_object_ref (source); - } + g_signal_emit (menu, signals[SOURCE_SELECTED], 0, source); } @@ -223,6 +234,16 @@ class_init (ESourceOptionMenuClass *class) object_class->finalize = impl_finalize; parent_class = g_type_class_peek_parent (class); + + signals[SOURCE_SELECTED] = + g_signal_new ("source_selected", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ESourceOptionMenuClass, source_selected), + NULL, NULL, + e_util_marshal_VOID__POINTER, + G_TYPE_NONE, 1, + G_TYPE_POINTER); } static void diff --git a/widgets/misc/e-util-marshal.list b/widgets/misc/e-util-marshal.list index f5d8f046b7..0cb9a24afe 100644 --- a/widgets/misc/e-util-marshal.list +++ b/widgets/misc/e-util-marshal.list @@ -1,2 +1,3 @@ NONE:NONE NONE:INT +NONE:POINTER diff --git a/widgets/misc/test-source-option-menu.c b/widgets/misc/test-source-option-menu.c index 91a7941e29..a473c0f972 100644 --- a/widgets/misc/test-source-option-menu.c +++ b/widgets/misc/test-source-option-menu.c @@ -33,6 +33,15 @@ #include +static void +source_selected_callback (ESourceOptionMenu *menu, + ESource *source, + void *unused_data) +{ + g_print ("source selected: \"%s\"\n", e_source_peek_name (source)); +} + + static int on_idle_create_widget (const char *gconf_path) { @@ -46,6 +55,7 @@ on_idle_create_widget (const char *gconf_path) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); option_menu = e_source_option_menu_new (source_list); + g_signal_connect (option_menu, "source_selected", G_CALLBACK (source_selected_callback), NULL); gtk_container_add (GTK_CONTAINER (window), option_menu); gtk_widget_show_all (window); -- cgit gstreamer0.10-removal'>gstreamer0.10-removal FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)
aboutsummaryrefslogtreecommitdiffstats
Commit message (Expand)AuthorAgeFilesLines