aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/save-calendar
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@novell.com>2004-10-21 09:17:24 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2004-10-21 09:17:24 +0800
commit9349ecf81c58237e1d8744e5d2d62901949a0569 (patch)
tree0c2b785ea3d2104fc1e090ac816e46a27c15afcb /plugins/save-calendar
parent458b72a844f8c86edf904367307217b231f773fe (diff)
downloadgsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.tar
gsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.tar.gz
gsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.tar.bz2
gsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.tar.lz
gsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.tar.xz
gsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.tar.zst
gsoc2013-evolution-9349ecf81c58237e1d8744e5d2d62901949a0569.zip
new plugin for saving a calendar to disk.
2004-10-21 Rodrigo Moya <rodrigo@novell.com> * save-calendar.c: new plugin for saving a calendar to disk. svn path=/trunk/; revision=27661
Diffstat (limited to 'plugins/save-calendar')
-rw-r--r--plugins/save-calendar/ChangeLog3
-rw-r--r--plugins/save-calendar/Makefile.am11
-rw-r--r--plugins/save-calendar/org-gnome-save-calendar.eplug.in14
-rw-r--r--plugins/save-calendar/save-calendar.c126
4 files changed, 154 insertions, 0 deletions
diff --git a/plugins/save-calendar/ChangeLog b/plugins/save-calendar/ChangeLog
new file mode 100644
index 0000000000..a98c1f8365
--- /dev/null
+++ b/plugins/save-calendar/ChangeLog
@@ -0,0 +1,3 @@
+2004-10-21 Rodrigo Moya <rodrigo@novell.com>
+
+ * save-calendar.c: new plugin for saving a calendar to disk. \ No newline at end of file
diff --git a/plugins/save-calendar/Makefile.am b/plugins/save-calendar/Makefile.am
new file mode 100644
index 0000000000..ed29da9d18
--- /dev/null
+++ b/plugins/save-calendar/Makefile.am
@@ -0,0 +1,11 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ $(EVOLUTION_CALENDAR_CFLAGS)
+
+@EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-save-calendar.eplug
+plugin_LTLIBRARIES = liborg-gnome-save-calendar.la
+
+liborg_gnome_save_calendar_la_SOURCES = save-calendar.c
+liborg_gnome_save_calendar_la_LDFLAGS = -module -avoid-version
diff --git a/plugins/save-calendar/org-gnome-save-calendar.eplug.in b/plugins/save-calendar/org-gnome-save-calendar.eplug.in
new file mode 100644
index 0000000000..4fd8816bf4
--- /dev/null
+++ b/plugins/save-calendar/org-gnome-save-calendar.eplug.in
@@ -0,0 +1,14 @@
+<e-plugin-list>
+ <e-plugin id="org.gnome.evolution.save_calendar" type="shlib" name="Save Selected Calendar or Tasks List" description="Saves selected calendar or tasks list to disk"
+ location="@PLUGINDIR@/liborg-gnome-save-calendar.so">
+
+ <hook class="org.gnome.evolution.calendar.popup:1.0">
+ <menu id="org.gnome.evolution.tasks.source.popup" target="source">
+ <item type="item" path="25.save_tasks" label="Save Tasks List to _Disk" icon="stock_check-filled" activate="org_gnome_save_tasks"/>
+ </menu>
+ <menu id="org.gnome.evolution.calendar.source.popup" target="source">
+ <item type="item" path="25.save_calendar" label="Save Calendar to _Disk" icon="stock_check-filled" activate="org_gnome_save_calendar"/>
+ </menu>
+ </hook>
+ </e-plugin>
+</e-plugin-list> \ No newline at end of file
diff --git a/plugins/save-calendar/save-calendar.c b/plugins/save-calendar/save-calendar.c
new file mode 100644
index 0000000000..4ecb5df968
--- /dev/null
+++ b/plugins/save-calendar/save-calendar.c
@@ -0,0 +1,126 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors: Rodrigo Moya <jpr@novell.com>
+ *
+ * Copyright 2004 Novell, Inc. (www.novell.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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+/* This is prototype code only, this may, or may not, use undocumented
+ * unstable or private internal function calls. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#ifdef USE_GTKFILECHOOSER
+# include <gtk/gtkfilechooser.h>
+# include <gtk/gtkfilechooserdialog.h>
+#else
+# include <gtk/gtkfilesel.h>
+#endif
+#include <gtk/gtkstock.h>
+#include <libedataserver/e-source.h>
+#include <libedataserverui/e-source-selector.h>
+#include <libecal/e-cal.h>
+#include <calendar/gui/e-cal-popup.h>
+
+void org_gnome_save_calendar (EPlugin *ep, ECalPopupTargetSource *target);
+void org_gnome_save_tasks (EPlugin *ep, ECalPopupTargetSource *target);
+
+static void
+do_save_calendar (EPlugin *ep, ECalPopupTargetSource *target, ECalSourceType type)
+{
+ ESource *primary_source;
+ char *dest_uri;
+ ECal *source_client, *dest_client;
+ GtkWidget *dialog;
+
+ primary_source = e_source_selector_peek_primary_selection (target->selector);
+
+ /* ask the user for destination file */
+#ifdef USE_GTKFILECHOOSER
+ dialog = gtk_file_chooser_dialog_new (_("Select destination file"),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+#else
+ dialog = gtk_file_selection_new (_("Select destination file"));
+#endif
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+#ifdef USE_GTKFILECHOOSER
+ dest_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
+#else
+ dest_uri = g_strdup (gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)));
+#endif
+ gtk_widget_destroy (dialog);
+ if (!dest_uri)
+ return;
+
+ /* open source client */
+ source_client = e_cal_new (primary_source, type);
+ if (!e_cal_open (source_client, TRUE, NULL)) {
+ g_object_unref (source_client);
+ g_free (dest_uri);
+ return;
+ }
+
+ /* open destination client */
+ dest_client = e_cal_new_from_uri (dest_uri, type);
+ if (e_cal_open (dest_client, FALSE, NULL)) {
+ GList *objects;
+
+ if (e_cal_get_object_list (source_client, "#t", &objects, NULL)) {
+ while (objects != NULL) {
+ icalcomponent *icalcomp = objects->data;
+
+ /* FIXME: deal with additions/modifications */
+ e_cal_create_object (dest_client, icalcomp, NULL, NULL);
+
+ /* remove item from the list */
+ objects = g_list_remove (objects, icalcomp);
+ icalcomponent_free (icalcomp);
+ }
+ }
+ }
+
+ /* terminate */
+ g_object_unref (source_client);
+ g_object_unref (dest_client);
+ g_free (dest_uri);
+}
+
+void
+org_gnome_save_calendar (EPlugin *ep, ECalPopupTargetSource *target)
+{
+ do_save_calendar (ep, target, E_CAL_SOURCE_TYPE_EVENT);
+}
+
+void
+org_gnome_save_tasks (EPlugin *ep, ECalPopupTargetSource *target)
+{
+ do_save_calendar (ep, target, E_CAL_SOURCE_TYPE_TODO);
+}