diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar-component.c | 43 | ||||
-rw-r--r-- | calendar/gui/tasks-component.c | 41 |
2 files changed, 80 insertions, 4 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 74d87ec3fe..428d211d07 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -237,9 +237,9 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, item = gtk_image_menu_item_new_with_label (label); /* load the image */ - image = gtk_image_new_from_file (pixmap); + image = gtk_image_new_from_stock (pixmap, GTK_ICON_SIZE_MENU); if (!image) - image = gtk_image_new_from_stock (pixmap, GTK_ICON_SIZE_MENU); + image = gtk_image_new_from_file (pixmap); if (image) gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); @@ -296,17 +296,52 @@ delete_calendar_cb (GtkWidget *widget, CalendarComponent *comp) } static void -new_calendar_cb (GtkWidget *widget, ESourceSelector *selector) +new_calendar_cb (GtkWidget *widget, CalendarComponent *comp) { new_calendar_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget))); } static void +rename_calendar_cb (GtkWidget *widget, CalendarComponent *comp) +{ + GSList *selection; + CalendarComponentPrivate *priv; + ESource *selected_source; + GtkWidget *dialog, *entry; + + priv = comp->priv; + + selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selection) + return; + + selected_source = selection->data; + + /* create the dialog to prompt the user for the new name */ + dialog = gtk_message_dialog_new (gtk_widget_get_toplevel (widget), + GTK_DIALOG_MODAL, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_OK_CANCEL, + _("Rename this calendar to")); + entry = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (entry), e_source_peek_name (selected_source)); + gtk_widget_show (entry); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), entry, TRUE, FALSE, 6); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) + e_source_set_name (selected_source, gtk_entry_get_text (GTK_ENTRY (entry))); + + gtk_widget_destroy (dialog); + + e_source_selector_free_selection (selection); +} + +static void fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, CalendarComponent *comp) { add_popup_menu_item (menu, _("New Calendar"), NULL, G_CALLBACK (new_calendar_cb), comp); add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_calendar_cb), comp); - add_popup_menu_item (menu, _("Rename"), NULL, NULL, NULL); + add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_calendar_cb), comp); } static void diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 58448dc646..f79ddfd3a8 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -199,6 +199,44 @@ get_default_task (ECal *ecal) /* 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_stock (pixmap, GTK_ICON_SIZE_MENU); + if (!image) + image = gtk_image_new_from_file (pixmap); + + 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_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); +} + +static void +new_task_list_cb (GtkWidget *widget, TasksComponent *component) +{ +} + +static void +fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, TasksComponent *component) +{ + add_popup_menu (menu, _("New Task List"), GTK_STOCK_NEW, G_CALLBACK (new_task_list_cb), component); +} + +static void source_selection_changed_cb (ESourceSelector *selector, TasksComponent *component) { update_uris_for_selection (component); @@ -337,6 +375,9 @@ impl_createControls (PortableServer_Servant servant, g_signal_connect_object (priv->source_selector, "primary_selection_changed", G_CALLBACK (primary_source_selection_changed_cb), G_OBJECT (component), 0); + g_signal_connect_object (priv->source_selector, "fill_popup_menu", + G_CALLBACK (fill_popup_menu_cb), + G_OBJECT (component), 0); /* Load the selection from the last run */ update_selection (component); |