From c6fb640109eadb091cb867ad6930811ce9c501e6 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Tue, 28 Oct 2003 18:42:09 +0000 Subject: connect to "fill_popup_menu" on the ESourceSelector. 2003-10-28 Rodrigo Moya * gui/calendar-component.c (impl_createControls): connect to "fill_popup_menu" on the ESourceSelector. (fill_popup_menu_callback): add popup menu items here. (add_popup_menu_item): new function to add items to the popup menu. svn path=/trunk/; revision=23107 --- calendar/ChangeLog | 8 ++++++++ calendar/gui/calendar-component.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index dc031d1bca..75873a6d39 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,11 @@ +2003-10-28 Rodrigo Moya + + * gui/calendar-component.c (impl_createControls): connect to + "fill_popup_menu" on the ESourceSelector. + (fill_popup_menu_callback): add popup menu items here. + (add_popup_menu_item): new function to add items to the + popup menu. + 2003-10-28 Rodrigo Moya * gui/e-cal-view.c: no need to keep the timezone here, it is diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index eec39adad6..82332073ad 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -118,6 +118,39 @@ update_uris_for_selection (ESourceSelector *selector, CalendarComponent *calenda } /* Callbacks. */ +static void +add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, + GCallback callback, gpointer user_data) +{ + GtkWidget *item, *image; + + if (pixmap) { + item = gtk_image_menu_item_new_with_label (label); + + /* load the image */ + image = gtk_image_new_from_file (pixmap); + if (!image) + image = gtk_image_new_from_stock (pixmap, GTK_ICON_SIZE_MENU); + + if (image) + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); + } else { + item = gtk_menu_item_new_with_label (label); + } + + if (callback) + g_signal_connect (G_OBJECT (item), "activate", callback, user_data); + + gtk_menu_append (menu, item); + gtk_widget_show (item); +} + +static void +fill_popup_menu_callback (ESourceSelector *selector, GtkMenu *menu, CalendarComponent *comp) +{ + add_popup_menu_item (menu, _("_New Calendar"), NULL, NULL, selector); +} + static void source_selection_changed_callback (ESourceSelector *selector, CalendarComponent *calendar_component) @@ -254,6 +287,9 @@ impl_createControls (PortableServer_Servant servant, g_signal_connect_object (selector, "primary_selection_changed", G_CALLBACK (primary_source_selection_changed_callback), G_OBJECT (calendar_component), 0); + g_signal_connect_object (selector, "fill_popup_menu", + G_CALLBACK (fill_popup_menu_callback), + G_OBJECT (calendar_component), 0); update_uris_for_selection (E_SOURCE_SELECTOR (selector), calendar_component); -- cgit