diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-01-20 03:41:02 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-06-03 11:00:41 +0800 |
commit | cb1220aff2c8c78246432229b875b7de6d44de84 (patch) | |
tree | 0e6648380a86e86325c62729c7ad637ce6437248 | |
parent | 8b03b8a20cd20c343979dea3013a05600ad2f6ec (diff) | |
download | gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.tar gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.tar.gz gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.tar.bz2 gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.tar.lz gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.tar.xz gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.tar.zst gsoc2013-evolution-cb1220aff2c8c78246432229b875b7de6d44de84.zip |
Add 'cal-config-local' module.
Registers the "On This Computer" backend in ECalSourceConfig widgets.
Replaces the 'calendar-file' plugin.
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | modules/Makefile.am | 1 | ||||
-rw-r--r-- | modules/cal-config-local/Makefile.am | 26 | ||||
-rw-r--r-- | modules/cal-config-local/e-source-local.c | 203 | ||||
-rw-r--r-- | modules/cal-config-local/e-source-local.h | 69 | ||||
-rw-r--r-- | modules/cal-config-local/evolution-cal-config-local.c | 306 | ||||
-rw-r--r-- | plugins/calendar-file/Makefile.am | 27 | ||||
-rw-r--r-- | plugins/calendar-file/calendar-file.c | 249 | ||||
-rw-r--r-- | plugins/calendar-file/org-gnome-calendar-file.eplug.xml | 22 |
9 files changed, 607 insertions, 300 deletions
diff --git a/configure.ac b/configure.ac index c62401c7f7..dacd541d91 100644 --- a/configure.ac +++ b/configure.ac @@ -1298,7 +1298,7 @@ AC_ARG_ENABLE([plugins], [enable_plugins="$enableval"],[enable_plugins=all]) dnl Add any new plugins here -plugins_base_always="calendar-file calendar-http itip-formatter default-source mark-all-read publish-calendar caldav imap-features google-account-setup" +plugins_base_always="calendar-http itip-formatter default-source mark-all-read publish-calendar caldav imap-features google-account-setup" plugins_base="$plugins_base_always" dist_plugins_base="$plugins_base_always calendar-weather" @@ -1637,6 +1637,7 @@ modules/book-config-google/Makefile modules/book-config-ldap/Makefile modules/book-config-local/Makefile modules/book-config-webdav/Makefile +modules/cal-config-local/Makefile modules/composer-autosave/Makefile modules/mailto-handler/Makefile modules/mdn/Makefile @@ -1654,7 +1655,6 @@ plugins/attachment-reminder/Makefile plugins/audio-inline/Makefile plugins/bbdb/Makefile plugins/caldav/Makefile -plugins/calendar-file/Makefile plugins/calendar-http/Makefile plugins/calendar-weather/Makefile plugins/dbx-import/Makefile diff --git a/modules/Makefile.am b/modules/Makefile.am index ff6888ed75..043c53d1ce 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -24,6 +24,7 @@ SUBDIRS = \ $(CONFIG_LDAP_DIR) \ book-config-local \ book-config-webdav \ + cal-config-local \ composer-autosave \ mailto-handler \ mdn \ diff --git a/modules/cal-config-local/Makefile.am b/modules/cal-config-local/Makefile.am new file mode 100644 index 0000000000..3cd8f6d18a --- /dev/null +++ b/modules/cal-config-local/Makefile.am @@ -0,0 +1,26 @@ +module_LTLIBRARIES = module-cal-config-local.la + +module_cal_config_local_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/widgets \ + -DG_LOG_DOMAIN=\"evolution-cal-config-local\" \ + $(EVOLUTION_DATA_SERVER_CFLAGS) \ + $(GNOME_PLATFORM_CFLAGS) + +module_cal_config_local_la_SOURCES = \ + evolution-cal-config-local.c \ + e-source-local.c \ + e-source-local.h + +module_cal_config_local_la_LIBADD = \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/calendar/gui/libevolution-calendar.la \ + $(EVOLUTION_DATA_SERVER_LIBS) \ + $(GNOME_PLATFORM_LIBS) + +module_cal_config_local_la_LDFLAGS = \ + -module -avoid-version $(NO_UNDEFINED) + +-include $(top_srcdir)/git.mk diff --git a/modules/cal-config-local/e-source-local.c b/modules/cal-config-local/e-source-local.c new file mode 100644 index 0000000000..6877cf0d27 --- /dev/null +++ b/modules/cal-config-local/e-source-local.c @@ -0,0 +1,203 @@ +/* + * e-source-local.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +#include "e-source-local.h" + +#define E_SOURCE_LOCAL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_SOURCE_LOCAL, ESourceLocalPrivate)) + +struct _ESourceLocalPrivate { + GMutex *property_lock; + GFile *custom_file; +}; + +enum { + PROP_0, + PROP_CUSTOM_FILE +}; + +G_DEFINE_DYNAMIC_TYPE ( + ESourceLocal, + e_source_local, + E_TYPE_SOURCE_EXTENSION) + +static void +source_local_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CUSTOM_FILE: + e_source_local_set_custom_file ( + E_SOURCE_LOCAL (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +source_local_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_CUSTOM_FILE: + g_value_take_object ( + value, + e_source_local_dup_custom_file ( + E_SOURCE_LOCAL (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +source_local_dispose (GObject *object) +{ + ESourceLocalPrivate *priv; + + priv = E_SOURCE_LOCAL_GET_PRIVATE (object); + + if (priv->custom_file != NULL) { + g_object_unref (priv->custom_file); + priv->custom_file = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (e_source_local_parent_class)->dispose (object); +} + +static void +source_local_finalize (GObject *object) +{ + ESourceLocalPrivate *priv; + + priv = E_SOURCE_LOCAL_GET_PRIVATE (object); + + g_mutex_free (priv->property_lock); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (e_source_local_parent_class)->finalize (object); +} + +static void +e_source_local_class_init (ESourceLocalClass *class) +{ + GObjectClass *object_class; + ESourceExtensionClass *extension_class; + + g_type_class_add_private (class, sizeof (ESourceLocalPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = source_local_set_property; + object_class->get_property = source_local_get_property; + object_class->dispose = source_local_dispose; + object_class->finalize = source_local_finalize; + + extension_class = E_SOURCE_EXTENSION_CLASS (class); + extension_class->name = E_SOURCE_EXTENSION_LOCAL_BACKEND; + + g_object_class_install_property ( + object_class, + PROP_CUSTOM_FILE, + g_param_spec_object ( + "custom-file", + "Custom File", + "Custom iCalendar file", + G_TYPE_FILE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + E_SOURCE_PARAM_SETTING)); +} + +static void +e_source_local_class_finalize (ESourceLocalClass *class) +{ +} + +static void +e_source_local_init (ESourceLocal *extension) +{ + extension->priv = E_SOURCE_LOCAL_GET_PRIVATE (extension); + extension->priv->property_lock = g_mutex_new (); +} + +void +e_source_local_type_register (GTypeModule *type_module) +{ + /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration + * function, so we have to wrap it with a public function in + * order to register types from a separate compilation unit. */ + e_source_local_register_type (type_module); +} + +GFile * +e_source_local_get_custom_file (ESourceLocal *extension) +{ + g_return_val_if_fail (E_IS_SOURCE_LOCAL (extension), NULL); + + return extension->priv->custom_file; +} + +GFile * +e_source_local_dup_custom_file (ESourceLocal *extension) +{ + GFile *protected; + GFile *duplicate; + + g_return_val_if_fail (E_IS_SOURCE_LOCAL (extension), NULL); + + g_mutex_lock (extension->priv->property_lock); + + protected = e_source_local_get_custom_file (extension); + duplicate = (protected != NULL) ? g_file_dup (protected) : NULL; + + g_mutex_unlock (extension->priv->property_lock); + + return duplicate; +} + +void +e_source_local_set_custom_file (ESourceLocal *extension, + GFile *custom_file) +{ + g_return_if_fail (E_IS_SOURCE_LOCAL (extension)); + + if (custom_file != NULL) { + g_return_if_fail (G_IS_FILE (custom_file)); + g_object_ref (custom_file); + } + + g_mutex_lock (extension->priv->property_lock); + + if (extension->priv->custom_file != NULL) + g_object_unref (extension->priv->custom_file); + + extension->priv->custom_file = custom_file; + + g_mutex_unlock (extension->priv->property_lock); + + g_object_notify (G_OBJECT (extension), "custom-file"); +} + diff --git a/modules/cal-config-local/e-source-local.h b/modules/cal-config-local/e-source-local.h new file mode 100644 index 0000000000..7eed749966 --- /dev/null +++ b/modules/cal-config-local/e-source-local.h @@ -0,0 +1,69 @@ +/* + * e-source-local.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +#ifndef E_SOURCE_LOCAL_H +#define E_SOURCE_LOCAL_H + +#include <libedataserver/e-source-extension.h> + +/* Standard GObject macros */ +#define E_TYPE_SOURCE_LOCAL \ + (e_source_local_get_type ()) +#define E_SOURCE_LOCAL(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_SOURCE_LOCAL, ESourceLocal)) +#define E_SOURCE_LOCAL_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_SOURCE_LOCAL, ESourceLocalClass)) +#define E_IS_SOURCE_LOCAL(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_SOURCE_LOCAL)) +#define E_IS_SOURCE_LOCAL_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_SOURCE_LOCAL)) +#define E_SOURCE_LOCAL_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_SOURCE_LOCAL, ESourceLocalClass)) + +#define E_SOURCE_EXTENSION_LOCAL_BACKEND "Local Backend" + +G_BEGIN_DECLS + +typedef struct _ESourceLocal ESourceLocal; +typedef struct _ESourceLocalClass ESourceLocalClass; +typedef struct _ESourceLocalPrivate ESourceLocalPrivate; + +struct _ESourceLocal { + ESourceExtension parent; + ESourceLocalPrivate *priv; +}; + +struct _ESourceLocalClass { + ESourceExtensionClass parent_class; +}; + +GType e_source_local_get_type (void); +void e_source_local_type_register (GTypeModule *type_module); +GFile * e_source_local_get_custom_file (ESourceLocal *extension); +GFile * e_source_local_dup_custom_file (ESourceLocal *extension); +void e_source_local_set_custom_file (ESourceLocal *extension, + GFile *custom_file); + +G_END_DECLS + +#endif /* E_SOURCE_LOCAL_H */ diff --git a/modules/cal-config-local/evolution-cal-config-local.c b/modules/cal-config-local/evolution-cal-config-local.c new file mode 100644 index 0000000000..ab83f8c68c --- /dev/null +++ b/modules/cal-config-local/evolution-cal-config-local.c @@ -0,0 +1,306 @@ +/* + * evolution-cal-config-local.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +#include <config.h> +#include <glib/gi18n-lib.h> + +#include <libebackend/e-extension.h> + +#include <misc/e-source-config-backend.h> +#include <calendar/gui/e-cal-source-config.h> + +#include "e-source-local.h" + +typedef ESourceConfigBackend ECalConfigLocal; +typedef ESourceConfigBackendClass ECalConfigLocalClass; + +typedef struct _Context Context; + +struct _Context { + GtkWidget *custom_file_checkbox; + GtkWidget *custom_file_chooser; + GtkWidget *writable_checkbox; +}; + +/* Module Entry Points */ +void e_module_load (GTypeModule *type_module); +void e_module_unload (GTypeModule *type_module); + +/* Forward Declarations */ +GType e_cal_config_local_get_type (void); + +G_DEFINE_DYNAMIC_TYPE ( + ECalConfigLocal, + e_cal_config_local, + E_TYPE_SOURCE_CONFIG_BACKEND) + +static void +cal_config_local_context_free (Context *context) +{ + g_object_unref (context->custom_file_checkbox); + g_object_unref (context->custom_file_chooser); + g_object_unref (context->writable_checkbox); + + g_slice_free (Context, context); +} + +static gboolean +cal_config_local_active_to_custom_file (GBinding *binding, + const GValue *source_value, + GValue *target_value, + gpointer user_data) +{ + Context *context = user_data; + GtkFileChooser *file_chooser; + GFile *file = NULL; + + file_chooser = GTK_FILE_CHOOSER (context->custom_file_chooser); + + if (g_value_get_boolean (source_value)) + file = gtk_file_chooser_get_file (file_chooser); + + g_value_take_object (target_value, file); + + return TRUE; +} + +static gboolean +cal_config_local_custom_file_to_active (GBinding *binding, + const GValue *source_value, + GValue *target_value, + gpointer user_data) +{ + Context *context = user_data; + GtkFileChooser *file_chooser; + GFile *file; + gboolean success; + + file_chooser = GTK_FILE_CHOOSER (context->custom_file_chooser); + + file = g_value_get_object (source_value); + + if (file == NULL) { + g_value_set_boolean (target_value, FALSE); + return TRUE; + } + + success = gtk_file_chooser_set_file (file_chooser, file, NULL); + g_value_set_boolean (target_value, success); + + return success; +} + +static void +cal_config_local_file_set_cb (GtkFileChooserButton *button, + GtkWidget *custom_file_checkbox) +{ + /* This will update ESourceLocal:custom-file. */ + g_object_notify (G_OBJECT (custom_file_checkbox), "active"); +} + +static void +cal_config_local_insert_widgets (ESourceConfigBackend *backend, + ESource *scratch_source) +{ + ESourceConfig *config; + ESource *builtin_source; + ESourceRegistry *registry; + ESourceExtension *extension; + GtkFileFilter *filter; + GtkWidget *container; + GtkWidget *widget; + Context *context; + gboolean source_is_builtin = FALSE; + const gchar *extension_name; + const gchar *uid; + gchar *markup; + + uid = e_source_get_uid (scratch_source); + config = e_source_config_backend_get_config (backend); + registry = e_source_config_get_registry (config); + + /* The built-in sources can't use a custom file. */ + + builtin_source = e_source_registry_ref_builtin_calendar (registry); + source_is_builtin |= e_source_equal (scratch_source, builtin_source); + g_object_unref (builtin_source); + + builtin_source = e_source_registry_ref_builtin_memo_list (registry); + source_is_builtin |= e_source_equal (scratch_source, builtin_source); + g_object_unref (builtin_source); + + builtin_source = e_source_registry_ref_builtin_task_list (registry); + source_is_builtin |= e_source_equal (scratch_source, builtin_source); + g_object_unref (builtin_source); + + if (source_is_builtin) + return; + + context = g_slice_new (Context); + + g_object_set_data_full ( + G_OBJECT (backend), uid, context, + (GDestroyNotify) cal_config_local_context_free); + + widget = gtk_check_button_new_with_label ( + _("Use an existing iCalendar (ics) file")); + e_source_config_insert_widget ( + config, scratch_source, NULL, widget); + context->custom_file_checkbox = g_object_ref (widget); + gtk_widget_show (widget); + + g_signal_connect_swapped ( + widget, "toggled", + G_CALLBACK (e_source_config_resize_window), config); + + container = e_source_config_get_page (config, scratch_source); + + /* Put some extra padding above and below the header. */ + widget = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); + gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 12, 6, 0, 0); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + gtk_widget_show (widget); + + g_object_bind_property ( + context->custom_file_checkbox, "active", + widget, "visible", + G_BINDING_SYNC_CREATE); + + container = widget; + + markup = g_markup_printf_escaped ("<b>%s</b>", _("iCalendar File")); + widget = gtk_label_new (markup); + gtk_label_set_use_markup (GTK_LABEL (widget), TRUE); + gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); + gtk_container_add (GTK_CONTAINER (container), widget); + gtk_widget_show (widget); + g_free (markup); + + filter = gtk_file_filter_new (); + gtk_file_filter_add_mime_type (filter, "text/calendar"); + + widget = gtk_file_chooser_button_new ( + _("Choose an iCalendar file"), GTK_FILE_CHOOSER_ACTION_OPEN); + gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (widget), filter); + e_source_config_insert_widget ( + config, scratch_source, _("File:"), widget); + context->custom_file_chooser = g_object_ref (widget); + gtk_widget_show (widget); + + g_signal_connect ( + widget, "file-set", + G_CALLBACK (cal_config_local_file_set_cb), + context->custom_file_checkbox); + + g_object_bind_property ( + context->custom_file_checkbox, "active", + widget, "visible", + G_BINDING_SYNC_CREATE); + + widget = gtk_check_button_new_with_label ( + _("Allow Evolution to update the file")); + e_source_config_insert_widget ( + config, scratch_source, NULL, widget); + context->writable_checkbox = g_object_ref (widget); + gtk_widget_show (widget); + + g_object_bind_property ( + context->custom_file_checkbox, "active", + widget, "visible", + G_BINDING_SYNC_CREATE); + + extension_name = E_SOURCE_EXTENSION_LOCAL_BACKEND; + extension = e_source_get_extension (scratch_source, extension_name); + + g_object_bind_property_full ( + extension, "custom-file", + context->custom_file_checkbox, "active", + G_BINDING_BIDIRECTIONAL | + G_BINDING_SYNC_CREATE, + cal_config_local_custom_file_to_active, + cal_config_local_active_to_custom_file, + context, (GDestroyNotify) NULL); +} + +static gboolean +cal_config_local_check_complete (ESourceConfigBackend *backend, + ESource *scratch_source) +{ + ESourceLocal *extension; + GtkToggleButton *toggle_button; + Context *context; + GFile *file; + const gchar *extension_name; + const gchar *uid; + gboolean active; + + uid = e_source_get_uid (scratch_source); + context = g_object_get_data (G_OBJECT (backend), uid); + + /* This function might get called before we install a + * context for this ESource, in which case just return. */ + if (context == NULL) + return FALSE; + + extension_name = E_SOURCE_EXTENSION_LOCAL_BACKEND; + extension = e_source_get_extension (scratch_source, extension_name); + + file = e_source_local_get_custom_file (extension); + + toggle_button = GTK_TOGGLE_BUTTON (context->custom_file_checkbox); + active = gtk_toggle_button_get_active (toggle_button); + + /* If toggle button is active we need a valid file. */ + return !active || (file != NULL); +} + +static void +e_cal_config_local_class_init (ESourceConfigBackendClass *class) +{ + EExtensionClass *extension_class; + + extension_class = E_EXTENSION_CLASS (class); + extension_class->extensible_type = E_TYPE_CAL_SOURCE_CONFIG; + + class->parent_uid = "local-stub"; + class->backend_name = "local"; + class->insert_widgets = cal_config_local_insert_widgets; + class->check_complete = cal_config_local_check_complete; +} + +static void +e_cal_config_local_class_finalize (ESourceConfigBackendClass *class) +{ +} + +static void +e_cal_config_local_init (ESourceConfigBackend *backend) +{ +} + +G_MODULE_EXPORT void +e_module_load (GTypeModule *type_module) +{ + e_source_local_type_register (type_module); + e_cal_config_local_register_type (type_module); +} + +G_MODULE_EXPORT void +e_module_unload (GTypeModule *type_module) +{ +} diff --git a/plugins/calendar-file/Makefile.am b/plugins/calendar-file/Makefile.am deleted file mode 100644 index c36053f550..0000000000 --- a/plugins/calendar-file/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -@EVO_PLUGIN_RULE@ - -plugin_DATA = org-gnome-calendar-file.eplug - -plugin_LTLIBRARIES = liborg-gnome-calendar-file.la - -liborg_gnome_calendar_file_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - $(EVOLUTION_DATA_SERVER_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) - -liborg_gnome_calendar_file_la_SOURCES = calendar-file.c - -liborg_gnome_calendar_file_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) - -liborg_gnome_calendar_file_la_LIBADD = \ - $(top_builddir)/e-util/libeutil.la \ - $(EVOLUTION_DATA_SERVER_LIBS) \ - $(GNOME_PLATFORM_LIBS) - -EXTRA_DIST = org-gnome-calendar-file.eplug.xml - -BUILT_SOURCES = $(plugin_DATA) -CLEANFILES = $(BUILT_SOURCES) - --include $(top_srcdir)/git.mk diff --git a/plugins/calendar-file/calendar-file.c b/plugins/calendar-file/calendar-file.c deleted file mode 100644 index 32ba96aa8a..0000000000 --- a/plugins/calendar-file/calendar-file.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <e-util/e-config.h> -#include <e-util/e-plugin-util.h> -#include <calendar/gui/e-cal-config.h> -#include <libedataserver/e-source.h> -#include <glib/gi18n.h> -#include <string.h> - -gint e_plugin_lib_enable (EPlugin *ep, gint enable); - -gint -e_plugin_lib_enable (EPlugin *ep, - gint enable) -{ - return 0; -} - -static void -location_changed (GtkFileChooserButton *widget, - ESource *source) -{ - gchar *filename; - - g_return_if_fail (widget != NULL); - g_return_if_fail (source != NULL); - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); - e_source_set_property ( - source, "custom-file", - (filename && *filename) ? filename : NULL); - g_free (filename); -} - -static void -maincheck_toggled (GtkToggleButton *check, - ESource *source) -{ - GtkWidget *w; - gboolean enabled = gtk_toggle_button_get_active (check); - - w = g_object_get_data (G_OBJECT (check), "child"); - gtk_widget_set_sensitive (w, enabled); - - /* used with source = NULL to enable widgets only */ - if (!source) - return; - - if (enabled) { - gchar *file; - - w = g_object_get_data (G_OBJECT (check), "file-chooser"); - file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w)); - e_source_set_property (source, "custom-file", (file && *file) ? file : NULL); - g_free (file); - } else { - e_source_set_property (source, "custom-file", NULL); - } -} - -static void -refresh_type_changed (GtkComboBox *refresh_type, - ESource *source) -{ - GtkWidget *refresh_hbox; - gint active = gtk_combo_box_get_active (refresh_type); - gchar buff[2] = {0}; - - refresh_hbox = g_object_get_data (G_OBJECT (refresh_type), "refresh-hbox"); - - if (active < 0 || active > 2) - active = 0; - - if (active == 2) { - gtk_widget_show (refresh_hbox); - } else { - gtk_widget_hide (refresh_hbox); - } - - buff[0] = '0' + active; - e_source_set_property (source, "refresh-type", buff); -} - -GtkWidget *e_calendar_file_customs (EPlugin *epl, EConfigHookItemFactoryData *data); - -GtkWidget * -e_calendar_file_customs (EPlugin *epl, - EConfigHookItemFactoryData *data) -{ - ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target; - ESource *source = t->source; - const gchar *relative_uri, *value; - guint n_rows; - GtkWidget *w1, *w2, *box1, *box2, *mainbox, *maincheck; - - if (!e_plugin_util_is_source_proto (source, "local")) - return NULL; - - relative_uri = e_source_peek_relative_uri (source); - if (relative_uri && g_str_equal (relative_uri, "system")) - return NULL; - - e_source_set_relative_uri (source, e_source_get_uid (source)); - - mainbox = gtk_vbox_new (FALSE, 2); - g_object_get (data->parent, "n-rows", &n_rows, NULL); - gtk_table_attach ( - GTK_TABLE (data->parent), mainbox, - 1, 2, n_rows, n_rows + 1, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - maincheck = gtk_check_button_new_with_mnemonic (_("C_ustomize options")); - gtk_box_pack_start ((GtkBox *) mainbox, maincheck, TRUE, TRUE, 2); - - box1 = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start ((GtkBox *) mainbox, box1, TRUE, TRUE, 2); - - g_object_set_data ((GObject*)maincheck, "child", box1); - - /* left-most space, the first one */ - w1 = gtk_label_new (""); - gtk_box_pack_start ((GtkBox *) box1, w1, FALSE, TRUE, 8); - - box2 = gtk_vbox_new (FALSE, 2); - gtk_box_pack_start ((GtkBox *) box1, box2, TRUE, TRUE, 2); - - box1 = box2; - box2 = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start ((GtkBox *) box1, box2, TRUE, TRUE, 2); - - w1 = gtk_label_new_with_mnemonic (_("F_ilename:")); - gtk_misc_set_alignment (GTK_MISC (w1), 0.0, 0.5); - gtk_box_pack_start ((GtkBox *) box2, w1, FALSE, TRUE, 2); - - w2 = gtk_file_chooser_button_new ( - _("Choose calendar file"), GTK_FILE_CHOOSER_ACTION_OPEN); - gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (w2), TRUE); - gtk_label_set_mnemonic_widget (GTK_LABEL (w1), w2); - gtk_box_pack_start ((GtkBox *) box2, w2, TRUE, TRUE, 2); - - g_object_set_data (G_OBJECT (maincheck), "file-chooser", w2); - - value = e_source_get_property (source, "custom-file"); - if (value && *value) { - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (w2), value); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (maincheck), TRUE); - } else { - gchar *file = NULL; - const gchar *file_name = NULL; - - switch (t->source_type) { - case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: - file_name = "calendar.ics"; - break; - case E_CAL_CLIENT_SOURCE_TYPE_TASKS: - file_name = "tasks.ics"; - break; - case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: - file_name = "journal.ics"; - break; - case E_CAL_CLIENT_SOURCE_TYPE_LAST: - break; - } - - file = g_build_filename (g_get_home_dir (), file_name, NULL); - if (file && *file) - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (w2), file); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (maincheck), FALSE); - g_free (file); - } - maincheck_toggled (GTK_TOGGLE_BUTTON (maincheck), NULL); - - g_signal_connect ( - w2, "file-set", - G_CALLBACK (location_changed), source); - g_signal_connect ( - maincheck, "toggled", - G_CALLBACK (maincheck_toggled), source); - - box2 = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start ((GtkBox *) box1, box2, FALSE, TRUE, 2); - - w1 = gtk_label_new_with_mnemonic (_("Re_fresh:")); - gtk_misc_set_alignment (GTK_MISC (w1), 0.0, 0.5); - gtk_box_pack_start ((GtkBox *) box2, w1, FALSE, TRUE, 2); - - w2 = gtk_combo_box_text_new (); - /* Translators: This is one setting for when to refresh a memo/calendar/tasks list */ - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w2), _("On open")); - /* Translators: This is one setting for when to refresh a memo/calendar/tasks list */ - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w2), _("On file change")); - /* Translators: This is one setting for when to refresh a memo/calendar/tasks list */ - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w2), _("Periodically")); - gtk_label_set_mnemonic_widget (GTK_LABEL (w1), w2); - gtk_box_pack_start ((GtkBox *) box2, w2, FALSE, TRUE, 2); - - value = e_source_get_property (source, "refresh-type"); - gtk_combo_box_set_active ( - (GtkComboBox *) w2, - (value && *value && !value[1] && value[0] >= '0' && - value[0] <= '2') ? value[0] - '0' : 0); - - w1 = w2; - w2 = e_plugin_util_add_refresh (NULL, NULL, source, "refresh"); - gtk_box_pack_start (GTK_BOX (box2), w2, FALSE, TRUE, 0); - - g_object_set_data (G_OBJECT (w1), "refresh-hbox", w2); - - g_signal_connect ( - w1, "changed", - G_CALLBACK (refresh_type_changed), source); - - w2 = e_plugin_util_add_check ( - NULL, _("Force read _only"), source, - "custom-file-readonly", "1", NULL); - gtk_box_pack_start ((GtkBox *) box1, w2, TRUE, TRUE, 2); - - gtk_widget_show_all (mainbox); - - /* w1 is a refresh-type combobox, and it hides widgets, - * thus should be called after show_all call */ - refresh_type_changed (GTK_COMBO_BOX (w1), source); - - return mainbox; -} diff --git a/plugins/calendar-file/org-gnome-calendar-file.eplug.xml b/plugins/calendar-file/org-gnome-calendar-file.eplug.xml deleted file mode 100644 index a9c6379636..0000000000 --- a/plugins/calendar-file/org-gnome-calendar-file.eplug.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0"?> -<e-plugin-list> - <e-plugin - type="shlib" - location="@PLUGINDIR@/liborg-gnome-calendar-file@SOEXT@" - id="org.gnome.evolution.calendar.file" - _name="Local Calendars" - system_plugin="true"> - <author name="JP Rosevear" email="jpr@novell.com"/> - <_description>Add local calendars to Evolution.</_description> - <hook class="org.gnome.evolution.calendar.config:1.0"> - <group - target="source" - id="org.gnome.evolution.calendar.calendarProperties"> - <item - type="item_table" - path="00.general/00.source/99.file_customs" - factory="e_calendar_file_customs"/> - </group> - </hook> - </e-plugin> -</e-plugin-list> |