diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar-component.c | 57 | ||||
-rw-r--r-- | calendar/gui/tasks-component.c | 59 |
2 files changed, 47 insertions, 69 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 428d211d07..1b0f3b479e 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -257,42 +257,36 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, static void delete_calendar_cb (GtkWidget *widget, CalendarComponent *comp) { - GSList *selection, *l; + ESource *selected_source; CalendarComponentPrivate *priv; + GtkWidget *dialog; priv = comp->priv; - selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (priv->source_selector)); - if (!selection) + selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selected_source) return; - for (l = selection; l; l = l->next) { - GtkWidget *dialog; - ESource *selected_source = l->data; - - /* create the confirmation dialog */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW (gtk_widget_get_toplevel (widget)), - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Calendar '%s' will be removed. Are you sure you want to continue?"), - e_source_peek_name (selected_source)); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) { - if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->source_selector), - selected_source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), - selected_source); - - e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); - - /* FIXME: remove the calendar.ics file and the directory */ - } + /* create the confirmation dialog */ + dialog = gtk_message_dialog_new ( + GTK_WINDOW (gtk_widget_get_toplevel (widget)), + GTK_DIALOG_MODAL, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("Calendar '%s' will be removed. Are you sure you want to continue?"), + e_source_peek_name (selected_source)); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) { + if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->source_selector), + selected_source)) + e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), + selected_source); + + e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); - gtk_widget_destroy (dialog); + /* FIXME: remove the calendar.ics file and the directory */ } - e_source_selector_free_selection (selection); + gtk_widget_destroy (dialog); } static void @@ -304,19 +298,16 @@ new_calendar_cb (GtkWidget *widget, CalendarComponent *comp) 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) + selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selected_source) 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, @@ -332,8 +323,6 @@ rename_calendar_cb (GtkWidget *widget, CalendarComponent *comp) 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 diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 46e67cc536..e1603893e2 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -228,42 +228,36 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, static void delete_task_list_cb (GtkWidget *widget, TasksComponent *comp) { - GSList *selection, *l; + ESource *selected_source; TasksComponentPrivate *priv; + GtkWidget *dialog; priv = comp->priv; - selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (priv->source_selector)); - if (!selection) + selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selected_source) return; - for (l = selection; l; l = l->next) { - GtkWidget *dialog; - ESource *selected_source = l->data; - - /* create the confirmation dialog */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW (gtk_widget_get_toplevel (widget)), - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("Task List '%s' will be removed. Are you sure you want to continue?"), - e_source_peek_name (selected_source)); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) { - if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->source_selector), - selected_source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), - selected_source); - - e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); - - /* FIXME: remove the tasks.ics file and the directory */ - } - - gtk_widget_destroy (dialog); + /* create the confirmation dialog */ + dialog = gtk_message_dialog_new ( + GTK_WINDOW (gtk_widget_get_toplevel (widget)), + GTK_DIALOG_MODAL, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("Task List '%s' will be removed. Are you sure you want to continue?"), + e_source_peek_name (selected_source)); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) { + if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->source_selector), + selected_source)) + e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), + selected_source); + + e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); + + /* FIXME: remove the tasks.ics file and the directory */ } - e_source_selector_free_selection (selection); + gtk_widget_destroy (dialog); } static void @@ -274,19 +268,16 @@ new_task_list_cb (GtkWidget *widget, TasksComponent *component) static void rename_task_list_cb (GtkWidget *widget, TasksComponent *comp) { - GSList *selection; TasksComponentPrivate *priv; ESource *selected_source; GtkWidget *dialog, *entry; priv = comp->priv; - selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (priv->source_selector)); - if (!selection) + selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selected_source) 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, @@ -302,8 +293,6 @@ rename_task_list_cb (GtkWidget *widget, TasksComponent *comp) 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 |