diff options
Diffstat (limited to 'calendar/gui/dialogs/event-page.c')
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index c943825c84..99a49f33a6 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -29,12 +29,14 @@ #include <gtk/gtksignal.h> #include <gtk/gtktextview.h> #include <gtk/gtktogglebutton.h> +#include <gtk/gtkmessagedialog.h> #include <libgnome/gnome-i18n.h> #include <glade/glade.h> #include <gal/widgets/e-categories.h> #include "e-util/e-categories-config.h" #include "e-util/e-dialog-widgets.h" #include "widgets/misc/e-dateedit.h" +#include "widgets/misc/e-source-option-menu.h" #include <libecal/e-cal-time-util.h> #include "../calendar-config.h" #include "../e-timezone-entry.h" @@ -74,6 +76,8 @@ struct _EventPagePrivate { GtkWidget *categories_btn; GtkWidget *categories; + GtkWidget *source_selector; + gboolean updating; /* This is TRUE if both the start & end timezone are the same. If the @@ -417,6 +421,7 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) ECalComponentDateTime start_date, end_date; const char *location; const char *categories; + ESource *source; GSList *l; g_return_if_fail (page->client != NULL); @@ -512,6 +517,10 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) e_cal_component_get_categories (comp, &categories); e_dialog_editable_set (priv->categories, categories); + /* Source */ + source = e_cal_get_source (page->client); + e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), source); + priv->updating = FALSE; } @@ -749,6 +758,8 @@ get_widgets (EventPage *epage) priv->categories_btn = GW ("categories-button"); priv->categories = GW ("categories"); + priv->source_selector = GW ("source"); + #undef GW return (priv->summary @@ -1189,6 +1200,40 @@ field_changed_cb (GtkWidget *widget, gpointer data) comp_editor_page_notify_changed (COMP_EDITOR_PAGE (epage)); } +static void +source_changed_cb (GtkWidget *widget, ESource *source, gpointer data) +{ + EventPage *epage; + EventPagePrivate *priv; + + epage = EVENT_PAGE (data); + priv = epage->priv; + + if (!priv->updating) { + ECal *client; + + client = e_cal_new (source, CALOBJ_TYPE_EVENT); + if (!client || !e_cal_open (client, FALSE, NULL)) { + GtkWidget *dialog; + + if (client) + g_object_unref (client); + + e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), + e_cal_get_source (COMP_EDITOR_PAGE (epage)->client)); + + dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, + _("Unable to open the calendar '%s'."), + e_source_peek_name (source)); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } else { + comp_editor_page_notify_client_changed (COMP_EDITOR_PAGE (epage), client); + } + } +} + /* Hooks the widget signals */ static gboolean init_widgets (EventPage *epage) @@ -1277,6 +1322,8 @@ init_widgets (EventPage *epage) epage); g_signal_connect((priv->categories), "changed", G_CALLBACK (field_changed_cb), epage); + g_signal_connect((priv->source_selector), "source_selected", + G_CALLBACK (source_changed_cb), epage); /* Set the default timezone, so the timezone entry may be hidden. */ location = calendar_config_get_timezone (); @@ -1369,3 +1416,22 @@ make_timezone_entry (void) gtk_widget_show (w); return w; } + +GtkWidget *event_page_create_source_option_menu (void); + +GtkWidget * +event_page_create_source_option_menu (void) +{ + GtkWidget *menu; + GConfClient *gconf_client; + ESourceList *source_list; + + gconf_client = gconf_client_get_default (); + source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/calendar/sources"); + + menu = e_source_option_menu_new (source_list); + g_object_unref (source_list); + + gtk_widget_show (menu); + return menu; +} |