diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2003-11-24 07:26:12 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2003-11-24 07:26:12 +0800 |
commit | e0cc63b07902740a58e399dd07c91a9a5a1c52bb (patch) | |
tree | a35e9c6196e40c41e10c9b603c370e8b5457b9d7 /calendar | |
parent | 515d9aaeb26d164dacc3fe0450b3b51fa1c04054 (diff) | |
download | gsoc2013-evolution-e0cc63b07902740a58e399dd07c91a9a5a1c52bb.tar.gz gsoc2013-evolution-e0cc63b07902740a58e399dd07c91a9a5a1c52bb.tar.zst gsoc2013-evolution-e0cc63b07902740a58e399dd07c91a9a5a1c52bb.zip |
fixed copyright notices.
2003-11-23 Rodrigo Moya <rodrigo@ximian.com>
* gui/dialogs/new-calendar.[ch]: fixed copyright notices.
* gui/dialogs/copy-source-dialog.[ch]: implementation of the
Copy command for sources.
* gui/dialogs/Makefile.am: added new files.
* gui/calendar-component.c (fill_popup_menu_cb, copy_calendar_cb):
added Copy command.
* gui/tasks-component.c (fill_popup_menu_cb, copy_task_list_cb):
added Copy command.
svn path=/trunk/; revision=23471
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 15 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 19 | ||||
-rw-r--r-- | calendar/gui/dialogs/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/dialogs/copy-source-dialog.c | 155 | ||||
-rw-r--r-- | calendar/gui/dialogs/copy-source-dialog.h | 29 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-calendar.c | 6 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-calendar.h | 6 | ||||
-rw-r--r-- | calendar/gui/tasks-component.c | 21 |
8 files changed, 244 insertions, 9 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 033816c4ea..0a00ace82f 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,18 @@ +2003-11-23 Rodrigo Moya <rodrigo@ximian.com> + + * gui/dialogs/new-calendar.[ch]: fixed copyright notices. + + * gui/dialogs/copy-source-dialog.[ch]: implementation of the + Copy command for sources. + + * gui/dialogs/Makefile.am: added new files. + + * gui/calendar-component.c (fill_popup_menu_cb, copy_calendar_cb): + added Copy command. + + * gui/tasks-component.c (fill_popup_menu_cb, copy_task_list_cb): + added Copy command. + 2003-11-23 Ross Burton <ross@burtonini.com> * gui/alarm-notify/GNOME_Evolution_Calendar_AlarmNotify.server.in.in: diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 97e6b2654b..0968b9372f 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -39,6 +39,7 @@ #include "comp-util.h" #include "dialogs/new-calendar.h" #include "dialogs/comp-editor.h" +#include "dialogs/copy-source-dialog.h" #include "dialogs/event-editor.h" #include "widgets/misc/e-source-selector.h" @@ -327,6 +328,21 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, } static void +copy_calendar_cb (GtkWidget *widget, CalendarComponent *comp) +{ + ESource *selected_source; + CalendarComponentPrivate *priv; + + priv = comp->priv; + + selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selected_source) + return; + + copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, CALOBJ_TYPE_EVENT); +} + +static void delete_calendar_cb (GtkWidget *widget, CalendarComponent *comp) { ESource *selected_source; @@ -406,8 +422,9 @@ fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, CalendarComponent TRUE : FALSE; add_popup_menu_item (menu, _("New Calendar"), GTK_STOCK_NEW, G_CALLBACK (new_calendar_cb), comp, TRUE); - add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_calendar_cb), comp, sensitive); + add_popup_menu_item (menu, _("Copy"), NULL, G_CALLBACK (copy_calendar_cb), comp, sensitive); add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_calendar_cb), comp, sensitive); + add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_calendar_cb), comp, sensitive); } static void diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index 9eb68fb350..ebf5fcf236 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -46,6 +46,8 @@ libcal_dialogs_la_SOURCES = \ comp-editor-page.h \ comp-editor-util.c \ comp-editor-util.h \ + copy-source-dialog.c \ + copy-source-dialog.h \ delete-comp.c \ delete-comp.h \ delete-error.c \ diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c new file mode 100644 index 0000000000..39daf0c597 --- /dev/null +++ b/calendar/gui/dialogs/copy-source-dialog.c @@ -0,0 +1,155 @@ +/* Evolution calendar - Copy source dialog + * + * Copyright (C) 2003 Novell, Inc. + * + * Author: Rodrigo Moya <rodrigo@ximian.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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. + */ + +#include <gtk/gtkdialog.h> +#include <gtk/gtkstock.h> +#include <widgets/misc/e-source-selector.h> +#include "copy-source-dialog.h" + +typedef struct { + GtkWidget *dialog; + GtkWidget *selector; + ESourceList *source_list; + GConfClient *conf_client; + ESource *orig_source; + CalObjType obj_type; +} CopySourceDialogData; + +static void +primary_selection_changed_cb (ESourceSelector *selector, CopySourceDialogData *csdd) +{ + ESource *source; + + source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (csdd->selector)); + if (source) { + if (source != csdd->orig_source) + gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, TRUE); + else + gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, FALSE); + } else + gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, FALSE); +} + +static gboolean +copy_source (CopySourceDialogData *csdd) +{ + char *uri; + ESource *dest_source; + ECal *source_client, *dest_client; + GList *obj_list = NULL; + gboolean result = FALSE; + + dest_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (csdd->selector)); + if (!dest_source) + return FALSE; + + /* open the source */ + uri = e_source_get_uri (csdd->orig_source); + source_client = e_cal_new (uri, csdd->obj_type); + g_free (uri); + if (!e_cal_open (source_client, TRUE, NULL)) { + g_object_unref (source_client); + g_warning (G_STRLOC ": Could not open source"); + return FALSE; + } + + /* open the destination */ + uri = e_source_get_uri (dest_source); + dest_client = e_cal_new (uri, csdd->obj_type); + g_free (uri); + if (!e_cal_open (dest_client, FALSE, NULL)) { + g_object_unref (dest_client); + g_object_unref (source_client); + g_warning (G_STRLOC ": Could not open destination"); + return FALSE; + } + + if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) { + GList *l; + const char *uid; + icalcomponent *icalcomp; + + for (l = obj_list; l != NULL; l = l->next) { + /* FIXME: process recurrences */ + /* FIXME: process errors */ + if (e_cal_get_object (dest_client, icalcomponent_get_uid (l->data), NULL, + &icalcomp, NULL)) { + e_cal_modify_modify_object (dest_client, icalcomp, CALOBJ_MOD_ALL, NULL); + } else { + e_cal_create_object (dest_client, icalcomp, &uid, NULL); + g_free ((gpointer) uid); + } + } + + e_cal_free_object_list (obj_list); + } + + return result; +} + +/** + * copy_source_dialog + * + * Implements the Copy command for sources, allowing the user to select a target + * source to copy to. + */ +gboolean +copy_source_dialog (GtkWindow *parent, ESource *source, CalObjType obj_type) +{ + CopySourceDialogData csdd; + gboolean result = FALSE; + const char *gconf_key; + + g_return_val_if_fail (E_IS_SOURCE (source), FALSE); + + if (obj_type == CALOBJ_TYPE_EVENT) + gconf_key = "/apps/evolution/calendar/sources"; + else if (obj_type == CALOBJ_TYPE_TODO) + gconf_key = "/apps/evolution/tasks/sources"; + else + return FALSE; + + csdd.orig_source = source; + csdd.obj_type = obj_type; + + /* create the dialog */ + csdd.dialog = gtk_dialog_new_with_buttons (_("Copy"), parent, 0, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd.dialog), GTK_RESPONSE_OK, FALSE); + + csdd.conf_client = gconf_client_get_default (); + csdd.source_list = e_source_list_new_for_gconf (csdd.conf_client, gconf_key); + csdd.selector = e_source_selector_new (csdd.source_list); + g_signal_connect (G_OBJECT (csdd.selector), "primary_selection_changed", + G_CALLBACK (primary_selection_changed_cb), &csdd); + + if (gtk_dialog_run (GTK_DIALOG (csdd.dialog)) == GTK_RESPONSE_OK) { + result = copy_source (&csdd); + } + + /* free memory */ + g_object_unref (csdd.conf_client); + g_object_unref (csdd.source_list); + gtk_widget_destroy (csdd.dialog); + + return result; +} diff --git a/calendar/gui/dialogs/copy-source-dialog.h b/calendar/gui/dialogs/copy-source-dialog.h new file mode 100644 index 0000000000..d87d841afe --- /dev/null +++ b/calendar/gui/dialogs/copy-source-dialog.h @@ -0,0 +1,29 @@ +/* Evolution calendar - Copy source dialog + * + * Copyright (C) 2003 Novell, Inc. + * + * Author: Rodrigo Moya <rodrigo@ximian.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 COPY_SOURCE_DIALOG_H +#define COPY_SOURCE_DIALOG_H + +#include <gtk/gtkwindow.h> +#include <e-util/e-source.h> + +gboolean copy_source_dialog (GtkWindow *parent, ESource *source); + +#endif diff --git a/calendar/gui/dialogs/new-calendar.c b/calendar/gui/dialogs/new-calendar.c index 520f1bc2de..4010339a2a 100644 --- a/calendar/gui/dialogs/new-calendar.c +++ b/calendar/gui/dialogs/new-calendar.c @@ -1,8 +1,8 @@ -/* Evolution calendar - Send calendar component dialog +/* Evolution calendar - New calendar dialog * - * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2003 Novell, Inc. * - * Author: JP Rosevear <jpr@ximian.com> + * Author: Rodrigo Moya <rodrigo@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public diff --git a/calendar/gui/dialogs/new-calendar.h b/calendar/gui/dialogs/new-calendar.h index 9890f9e1f8..86c819796e 100644 --- a/calendar/gui/dialogs/new-calendar.h +++ b/calendar/gui/dialogs/new-calendar.h @@ -1,8 +1,8 @@ -/* Evolution calendar - Send calendar component dialog +/* Evolution calendar - New calendar dialog * - * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2003 Novell, Inc. * - * Author: JP Rosevear <jpr@ximian.com> + * Author: Rodrigo Moya <rodrigo@ximian.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 95ebd55304..59dcb14337 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -40,6 +40,7 @@ #include "comp-util.h" #include "calendar-config.h" #include "dialogs/comp-editor.h" +#include "dialogs/copy-source-dialog.h" #include "dialogs/task-editor.h" #include "widgets/misc/e-source-selector.h" @@ -298,6 +299,21 @@ add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap, } static void +copy_task_list_cb (GtkWidget *widget, TasksComponent *comp) +{ + ESource *selected_source; + TasksComponentPrivate *priv; + + priv = comp->priv; + + selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->source_selector)); + if (!selected_source) + return; + + copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget), selected_source, CALOBJ_TYPE_TODO); +} + +static void delete_task_list_cb (GtkWidget *widget, TasksComponent *comp) { ESource *selected_source; @@ -377,10 +393,11 @@ fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, TasksComponent *co add_popup_menu_item (menu, _("New Task List"), GTK_STOCK_NEW, G_CALLBACK (new_task_list_cb), component, TRUE); - add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_task_list_cb), - component, sensitive); + add_popup_menu_item (menu, _("Copy"), NULL, G_CALLBACK (copy_task_list_cb), component, sensitive); add_popup_menu_item (menu, _("Rename"), NULL, G_CALLBACK (rename_task_list_cb), component, sensitive); + add_popup_menu_item (menu, _("Delete"), GTK_STOCK_DELETE, G_CALLBACK (delete_task_list_cb), + component, sensitive); } static void |