diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar-model.c | 39 | ||||
-rw-r--r-- | calendar/gui/calendar-model.h | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/dialogs/delete-comp.c | 86 | ||||
-rw-r--r-- | calendar/gui/dialogs/delete-comp.h | 29 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 31 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 16 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 16 | ||||
-rw-r--r-- | calendar/gui/event-editor.c | 14 | ||||
-rw-r--r-- | calendar/gui/main.c | 2 |
10 files changed, 176 insertions, 63 deletions
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index 2de745727e..8de4ab2e09 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -1854,33 +1854,6 @@ calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjTy void -calendar_model_delete_task (CalendarModel *model, - gint row) -{ - CalendarModelPrivate *priv; - CalComponent *comp; - const char *uid; - - g_return_if_fail (model != NULL); - g_return_if_fail (IS_CALENDAR_MODEL (model)); - - priv = model->priv; - - g_return_if_fail (row >= 0 && row < priv->objects->len); - - comp = g_array_index (priv->objects, CalComponent *, row); - g_assert (comp != NULL); - - cal_component_get_uid (comp, &uid); - - /* We don't check the return value; FALSE can mean the object was not in - * the server anyways. - */ - cal_client_remove_object (priv->client, uid); -} - - -void calendar_model_mark_task_complete (CalendarModel *model, gint row) { @@ -1904,9 +1877,17 @@ calendar_model_mark_task_complete (CalendarModel *model, } -/* Frees the objects stored in the calendar model */ +/** + * calendar_model_get_component: + * @model: A calendar model. + * @row: Row number of sought calendar component. + * + * Queries a calendar component from a calendar model based on its row number. + * + * Return value: The sought calendar component. + **/ CalComponent * -calendar_model_get_cal_object (CalendarModel *model, +calendar_model_get_component (CalendarModel *model, gint row) { CalendarModelPrivate *priv; diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h index ed04706090..b8c08a5dbc 100644 --- a/calendar/gui/calendar-model.h +++ b/calendar/gui/calendar-model.h @@ -64,10 +64,8 @@ void calendar_model_set_cal_client (CalendarModel *model, void calendar_model_mark_task_complete (CalendarModel *model, gint row); -void calendar_model_delete_task (CalendarModel *model, - gint row); -CalComponent* calendar_model_get_cal_object (CalendarModel *model, +CalComponent* calendar_model_get_component (CalendarModel *model, gint row); /* Whether we use 24 hour format to display the times. */ diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index 9b80e03f95..91720b596b 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -19,6 +19,8 @@ libcal_dialogs_a_SOURCES = \ alarm-notify-dialog.h \ cal-prefs-dialog.c \ cal-prefs-dialog.h \ + delete-comp.c \ + delete-comp.h \ task-editor.c \ task-editor.h diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c new file mode 100644 index 0000000000..d61b26a677 --- /dev/null +++ b/calendar/gui/dialogs/delete-comp.c @@ -0,0 +1,86 @@ +/* Evolution calendar - Delete calendar component dialog + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero <federico@helixcode.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gnome.h> +#include "delete-comp.h" + + + +/** + * delete_component_dialog: + * @comp: A calendar component. + * + * Pops up a dialog box asking the user whether he wants to delete a particular + * calendar component. + * + * Return value: TRUE if the user clicked Yes, FALSE otherwise. + **/ +gboolean +delete_component_dialog (CalComponent *comp) +{ + CalComponentText summary; + CalComponentVType vtype; + char *str; + char *type; + GtkWidget *dialog; + + g_return_val_if_fail (comp != NULL, FALSE); + g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); + + vtype = cal_component_get_vtype (comp); + cal_component_get_summary (comp, &summary); + + switch (vtype) { + case CAL_COMPONENT_EVENT: + type = _("appointment"); + break; + + case CAL_COMPONENT_TODO: + type = _("task"); + break; + + case CAL_COMPONENT_JOURNAL: + type = _("journal entry"); + break; + + default: + g_message ("delete_component_dialog(): Cannot handle object of type %d", vtype); + return FALSE; + } + + if (summary.value) + str = g_strdup_printf (_("Are you sure you want to delete the %s `%s'?"), + type, summary.value); + else + str = g_strdup_printf (_("Are you sure you want to delete this %s?"), type); + + dialog = gnome_question_dialog_modal (str, NULL, NULL); + g_free (str); + + if (gnome_dialog_run (GNOME_DIALOG (dialog)) == GNOME_YES) + return TRUE; + else + return FALSE; +} diff --git a/calendar/gui/dialogs/delete-comp.h b/calendar/gui/dialogs/delete-comp.h new file mode 100644 index 0000000000..6747787fac --- /dev/null +++ b/calendar/gui/dialogs/delete-comp.h @@ -0,0 +1,29 @@ +/* Evolution calendar - Delete calendar component dialog + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero <federico@helixcode.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef DELETE_COMP_H +#define DELETE_COMP_H + +#include <cal-util/cal-component.h> + +gboolean delete_component_dialog (CalComponent *comp); + +#endif diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index de247778a8..850315577a 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -37,6 +37,7 @@ #include <gal/e-table/e-cell-text.h> #include "e-calendar-table.h" #include "calendar-model.h" +#include "dialogs/delete-comp.h" #include "dialogs/task-editor.h" /* Pixmaps. */ @@ -390,14 +391,35 @@ e_calendar_table_on_mark_task_complete (GtkWidget *menuitem, } +/* Deletes a component from the table */ +static void +delete_component (CalendarModel *model, int row) +{ + CalComponent *comp; + + comp = calendar_model_get_component (model, row); + + if (delete_component_dialog (comp)) { + CalClient *client; + const char *uid; + + client = calendar_model_get_cal_client (model); + cal_component_get_uid (comp, &uid); + + /* We don't check the return value; FALSE can mean the object + * was not in the server anyways. + */ + cal_client_remove_object (client, uid); + } +} + static void e_calendar_table_on_delete_task (GtkWidget *menuitem, gpointer data) { ECalendarMenuData *menu_data = (ECalendarMenuData*) data; - calendar_model_delete_task (menu_data->cal_table->model, - menu_data->row); + delete_component (menu_data->cal_table->model, menu_data->row); } @@ -410,7 +432,8 @@ e_calendar_table_on_key_press (ETable *table, ECalendarTable *cal_table) { if (event->keyval == GDK_Delete) { - calendar_model_delete_task (cal_table->model, row); + delete_component (cal_table->model, row); + return TRUE; } return FALSE; @@ -427,7 +450,7 @@ e_calendar_table_open_task (ECalendarTable *cal_table, tedit = task_editor_new (); task_editor_set_cal_client (tedit, calendar_model_get_cal_client (cal_table->model)); - comp = calendar_model_get_cal_object (cal_table->model, row); + comp = calendar_model_get_component (cal_table->model, row); task_editor_set_todo_object (tedit, comp); } diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 06e829c39b..0f22f59a30 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -32,6 +32,7 @@ #include <gnome.h> #include <gdk/gdkx.h> #include <cal-util/timeutil.h> +#include "dialogs/delete-comp.h" #include "comp-util.h" #include "e-day-view.h" #include "e-day-view-time-item.h" @@ -3077,7 +3078,6 @@ e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) { EDayView *day_view; EDayViewEvent *event; - const char *uid; day_view = E_DAY_VIEW (data); @@ -3088,12 +3088,16 @@ e_day_view_on_delete_appointment (GtkWidget *widget, gpointer data) if (day_view->editing_event_day >= 0) e_day_view_stop_editing_event (day_view); - cal_component_get_uid (event->comp, &uid); + if (delete_component_dialog (event->comp)) { + const char *uid; - /* We don't check the return value; FALSE can mean the object was not in - * the server anyways. - */ - cal_client_remove_object (day_view->client, uid); + cal_component_get_uid (event->comp, &uid); + + /* We don't check the return value; FALSE can mean the object + * was not in the server anyways. + */ + cal_client_remove_object (day_view->client, uid); + } } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 6968d5ec81..e6d0546b96 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -31,6 +31,7 @@ #include <gnome.h> #include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gnome-canvas-pixbuf.h> +#include "dialogs/delete-comp.h" #include "calendar-commands.h" #include "comp-util.h" #include "e-week-view.h" @@ -3311,7 +3312,6 @@ e_week_view_on_delete_appointment (GtkWidget *widget, gpointer data) { EWeekView *week_view; EWeekViewEvent *event; - const char *uid; week_view = E_WEEK_VIEW (data); @@ -3321,12 +3321,16 @@ e_week_view_on_delete_appointment (GtkWidget *widget, gpointer data) event = &g_array_index (week_view->events, EWeekViewEvent, week_view->popup_event_num); - cal_component_get_uid (event->comp, &uid); + if (delete_component_dialog (event->comp)) { + const char *uid; - /* We don't check the return value; FALSE can mean the object was not in - * the server anyways. - */ - cal_client_remove_object (week_view->client, uid); + cal_component_get_uid (event->comp, &uid); + + /* We don't check the return value; FALSE can mean the object + * was not in the server anyways. + */ + cal_client_remove_object (week_view->client, uid); + } } diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c index 95ebe40560..139ce84efa 100644 --- a/calendar/gui/event-editor.c +++ b/calendar/gui/event-editor.c @@ -3080,17 +3080,3 @@ make_spin_button (int val, int low, int high) return spin; } - - -/* todo - - get the apply button to work right - - make the properties stuff unglobal - - figure out why alarm units aren't sticking between edits - - closing the dialog window with the wm caused a crash - Gtk-WARNING **: invalid cast from `(unknown)' to `GnomeDialog' - on line 669: gnome_dialog_close (GNOME_DIALOG(dialog->dialog)); - */ diff --git a/calendar/gui/main.c b/calendar/gui/main.c index ecaab4f3b6..f34ac4518f 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -60,7 +60,7 @@ main (int argc, char **argv) { bindtextdomain(PACKAGE, EVOLUTION_LOCALEDIR); textdomain(PACKAGE); - + init_bonobo (&argc, argv); glade_gnome_init (); alarm_init (); |