aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorDavid Trowbridge <trowbrds@cs.colorado.edu>2004-11-04 12:36:49 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-11-04 12:36:49 +0800
commitd243a742b2a008858ec130521161090dba667106 (patch)
tree520be041618de58f519bb62981412f4f768be371 /calendar
parent5b69bc3cd86bdb62cf4383a21d21e08faa48e8ea (diff)
downloadgsoc2013-evolution-d243a742b2a008858ec130521161090dba667106.tar.gz
gsoc2013-evolution-d243a742b2a008858ec130521161090dba667106.tar.zst
gsoc2013-evolution-d243a742b2a008858ec130521161090dba667106.zip
added EConfig subclass for calendars initialize plugin hooks on component
2004-11-03 David Trowbridge <trowbrds@cs.colorado.edu> * gui/e-cal-config.c: added EConfig subclass for calendars * gui/calendar-component.c, gui/tasks-component.c: initialize plugin hooks on component startup. * gui/dialogs/calendar-setup.c: Converted to use EConfig svn path=/trunk/; revision=27832
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog7
-rw-r--r--calendar/gui/Makefile.am7
-rw-r--r--calendar/gui/dialogs/Makefile.am1
-rw-r--r--calendar/gui/dialogs/calendar-setup.c1106
-rw-r--r--calendar/gui/dialogs/calendar-setup.h39
-rw-r--r--calendar/gui/e-cal-config.c190
-rw-r--r--calendar/gui/e-cal-config.h83
-rw-r--r--calendar/gui/main.c3
8 files changed, 659 insertions, 777 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 10add4b2dc..1e213c6157 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,10 @@
+2004-11-03 David Trowbridge <trowbrds@cs.colorado.edu>
+
+ * gui/e-cal-config.c: added EConfig subclass for calendars
+ * gui/calendar-component.c, gui/tasks-component.c: initialize
+ plugin hooks on component startup.
+ * gui/dialogs/calendar-setup.c: Converted to use EConfig
+
2004-11-04 Li Yuan <li.yuan@sun.com>
Fixes #6767
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index c2d282cc4c..fecdaa5cbc 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -59,6 +59,11 @@ SUBDIRS = alarm-notify dialogs
component_LTLIBRARIES = libevolution-calendar.la
+ecalendarincludedir = $(privincludedir)/calendar/gui
+
+ecalendarinclude_HEADERS = \
+ e-cal-config.h
+
INCLUDES = \
-DG_LOG_DOMAIN=\"calendar-gui\" \
-I$(top_builddir)/shell \
@@ -115,6 +120,8 @@ libevolution_calendar_la_SOURCES = \
e-alarm-list.h \
e-cal-component-preview.c \
e-cal-component-preview.h \
+ e-cal-config.c \
+ e-cal-config.h \
e-cal-menu.c \
e-cal-menu.h \
e-cal-model-calendar.h \
diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am
index 68d071fdd7..1247ce0a44 100644
--- a/calendar/gui/dialogs/Makefile.am
+++ b/calendar/gui/dialogs/Makefile.am
@@ -89,7 +89,6 @@ glade_DATA = \
alarm-dialog.glade \
alarm-list-dialog.glade \
cal-prefs-dialog.glade \
- calendar-setup.glade \
e-delegate-dialog.glade \
event-page.glade \
meeting-page.glade \
diff --git a/calendar/gui/dialogs/calendar-setup.c b/calendar/gui/dialogs/calendar-setup.c
index 01b63b9c1d..1996cc6db1 100644
--- a/calendar/gui/dialogs/calendar-setup.c
+++ b/calendar/gui/dialogs/calendar-setup.c
@@ -1,12 +1,12 @@
-/* Evolution calendar - Calendar properties dialogs
+/*
+ * Authors: David Trowbridge <trowbrds@cs.colorado.edu>
*
- * Copyright (C) 2003 Novell, Inc.
- *
- * Author: Hans Petter Jansson <hpj@ximian.com>
+ * Copyright (C) 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.
+ * 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
@@ -15,879 +15,461 @@
*
* 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.
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <string.h>
-#include <bonobo/bonobo-i18n.h>
-#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkbox.h>
#include <gtk/gtkdialog.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkmessagedialog.h>
-#include <gtk/gtkoptionmenu.h>
-#include <libgnome/libgnome.h>
-#include <libgnomeui/gnome-druid.h>
-#include <libgnomeui/gnome-druid-page.h>
-#include <libgnomeui/gnome-color-picker.h>
-#include <glade/glade.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtkvbox.h>
+
+#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
-#include <libecal/e-cal.h>
-#include <e-util/e-dialog-utils.h>
-#include <e-util/e-url.h>
-#include <e-util/e-icon-factory.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnomeui/libgnomeui.h>
+
#include "calendar-setup.h"
+#include "../e-cal-config.h"
-#define GLADE_FILE_NAME "calendar-setup.glade"
+typedef struct _CalendarSourceDialog CalendarSourceDialog;
-typedef struct
-{
- GladeXML *gui_xml;
+struct _CalendarSourceDialog {
+ ECalConfig *config; /* the config manager */
- /* Main widgets */
- GtkWidget *window;
- GtkWidget *druid;
+ GtkWidget *window;
- /* Source selection */
- ESourceList *source_list;
- GtkWidget *group_optionmenu;
+ /* Source selection (creation only) */
+ ESourceList *source_list;
+ GSList *menu_source_groups;
+ GtkWidget *group_optionmenu;
- /* ESource we're currently editing (if any) */
- ESource *source;
+ /* ESource we're currently editing */
+ ESource *source;
+ /* The original source in edit mode. Also used to flag when we are in edit mode. */
+ ESource *original_source;
- /* Source group we're creating/editing source in */
+ /* Source group we're creating/editing a source in */
ESourceGroup *source_group;
-
- /* General page fields */
- GtkWidget *name_entry;
- GtkWidget *source_color;
-
- /* Location page fields */
- GtkWidget *uri_entry;
- GtkWidget *refresh_spin;
-
- /* sensitive blocks */
- GtkWidget *uri_label;
- GtkWidget *uri_hbox;
- GtkWidget *refresh_label;
- GtkWidget *refresh_hbox;
- GtkWidget *refresh_optionmenu;
- GtkWidget *add_button;
-}
-SourceDialog;
-
-static gchar *
-print_uri_noproto (EUri *uri)
-{
- gchar *uri_noproto;
-
- if (uri->port != 0)
- uri_noproto = g_strdup_printf (
- "%s%s%s%s%s%s%s:%d%s%s%s",
- uri->user ? uri->user : "",
- uri->authmech ? ";auth=" : "",
- uri->authmech ? uri->authmech : "",
- uri->passwd ? ":" : "",
- uri->passwd ? uri->passwd : "",
- uri->user ? "@" : "",
- uri->host ? uri->host : "",
- uri->port,
- uri->path ? uri->path : "",
- uri->query ? "?" : "",
- uri->query ? uri->query : "");
- else
- uri_noproto = g_strdup_printf (
- "%s%s%s%s%s%s%s%s%s%s",
- uri->user ? uri->user : "",
- uri->authmech ? ";auth=" : "",
- uri->authmech ? uri->authmech : "",
- uri->passwd ? ":" : "",
- uri->passwd ? uri->passwd : "",
- uri->user ? "@" : "",
- uri->host ? uri->host : "",
- uri->path ? uri->path : "",
- uri->query ? "?" : "",
- uri->query ? uri->query : "");
-
- return uri_noproto;
-}
+};
static gboolean
-source_group_is_remote (ESourceGroup *group)
+eccp_check_complete (EConfig *ec, const char *pageid, void *data)
{
- EUri *uri;
- gboolean is_remote = FALSE;
-
- if (!group)
- return FALSE;
-
- uri = e_uri_new (e_source_group_peek_base_uri (group));
- if (!uri)
- return FALSE;
-
- if (uri->protocol && uri->protocol [0] && strcmp (uri->protocol, "file"))
- is_remote = TRUE;
-
- e_uri_free (uri);
- return is_remote;
-}
-
-static gboolean
-source_is_remote (ESource *source)
-{
- gchar *uri_str;
- EUri *uri;
- gboolean is_remote = FALSE;
-
- uri_str = e_source_get_uri (source);
- if (!uri_str)
- return FALSE;
-
- uri = e_uri_new (uri_str);
- g_free (uri_str);
-
- if (!uri)
- return FALSE;
+ CalendarSourceDialog *sdialog = data;
+ gboolean valid = TRUE;
+ const char *tmp;
+ ESource *source;
- if (uri->protocol && uri->protocol [0] && strcmp (uri->protocol, "file"))
- is_remote = TRUE;
+ tmp = e_source_peek_name (sdialog->source);
+ valid = tmp && tmp[0] && ((source = e_source_group_peek_source_by_name (sdialog->source_group, tmp)) == NULL || source == sdialog->original_source);
- e_uri_free (uri);
- return is_remote;
+ return valid;
}
-static gboolean
-validate_remote_uri (const gchar *source_location, gboolean interactive, GtkWidget *parent)
+static void
+colorpicker_set_color (GnomeColorPicker *color, guint32 rgb)
{
- EUri *uri;
-
- if (!source_location || !strlen (source_location)) {
- if (interactive)
- e_notice (parent, GTK_MESSAGE_ERROR,
- _("You must specify a location to get the calendar from."));
- return FALSE;
- }
-
- uri = e_uri_new (source_location);
- if (!uri) {
- if (interactive)
- e_notice (parent, GTK_MESSAGE_ERROR,
- _("The source location '%s' is not well-formed."),
- source_location);
- return FALSE;
- }
-
- /* Make sure we're in agreement with the protocol. Note that EUri sets it
- * to 'file' if none was specified in the input URI. We don't want to
- * silently translate an explicit file:// into http:// though. */
- if (uri->protocol &&
- strcmp (uri->protocol, "http") &&
- strcmp (uri->protocol, "webcal")) {
- e_uri_free (uri);
-
- if (interactive)
- e_notice (parent, GTK_MESSAGE_ERROR,
- _("The source location '%s' is not a webcal source."),
- source_location);
- return FALSE;
- }
-
- e_uri_free (uri);
- return TRUE;
+ gnome_color_picker_set_i8 (color, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff);
}
-static gboolean
-source_group_is_mutable (ESourceGroup *source_group)
+static guint32
+colorpicker_get_color (GnomeColorPicker *color)
{
- gboolean mutable;
-
- if (!source_group)
- return FALSE;
-
- mutable = !e_source_group_get_readonly (source_group);
-
- if (mutable) {
- const char *uri = e_source_group_peek_base_uri (source_group);
-
- if (g_str_has_prefix (uri, "groupwise://") || g_str_has_prefix (uri, "exchange://"))
- mutable = FALSE;
-
- }
-
- return mutable;
-}
+ guint8 r, g, b, a;
+ guint32 rgb = 0;
-static int
-source_group_menu_add_groups (GtkMenuShell *menu_shell, SourceDialog *source_dialog)
-{
- ESourceList *source_list = source_dialog->source_list;
- GSList *groups, *sl;
- int index=-1, i=0;
-
-
- if (source_list == NULL)
- return index;
-
- groups = e_source_list_peek_groups (source_list);
- for (sl = groups; sl; sl = g_slist_next (sl)) {
- GtkWidget *menu_item;
- ESourceGroup *group = sl->data;
-
- menu_item = gtk_menu_item_new_with_label (e_source_group_peek_name (group));
- gtk_widget_show (menu_item);
-
- if (!source_group_is_mutable (group))
- gtk_widget_set_sensitive(menu_item, FALSE);
-
- if (source_dialog->source_group
- && !strcmp (e_source_group_peek_uid (source_dialog->source_group), e_source_group_peek_uid (group)))
- index = i;
-
- gtk_menu_shell_append (menu_shell, menu_item);
- i++;
- }
+ gnome_color_picker_get_i8 (color, &r, &g, &b, &a);
- if (!source_dialog->source_group && groups) {
- source_dialog->source_group = groups->data;
- return -1;
- }
+ rgb = r;
+ rgb <<= 8;
+ rgb |= g;
+ rgb <<= 8;
+ rgb |= b;
- return index;
+ return rgb;
}
-static ESource *
-create_new_source_with_group (GtkWindow *parent,
- ESourceGroup *group,
- const char *source_name,
- const char *source_location,
- ECalSourceType source_type)
+static void
+eccp_commit (EConfig *ec, GSList *items, void *data)
{
- ESource *source;
- ECal *cal;
-
- if (e_source_group_peek_source_by_name (group, source_name)) {
- e_notice (parent, GTK_MESSAGE_ERROR,
- _("Source with name '%s' already exists in the selected group"),
- source_name);
- return NULL;
- }
-
- if (source_group_is_remote (group)) {
- EUri *uri;
- gchar *relative_uri;
-
- /* Remote source */
-
- if (!source_location || !strlen (source_location)) {
- e_notice (parent, GTK_MESSAGE_ERROR,
- _("The group '%s' is remote. You must specify a location "
- "to get the calendar from"),
- e_source_group_peek_name (group));
- return NULL;
- }
-
- if (!validate_remote_uri (source_location, TRUE, GTK_WIDGET (parent)))
- return NULL;
+ CalendarSourceDialog *sdialog = data;
+ xmlNodePtr xml;
- /* Our relative_uri is everything but protocol, which is supplied by parent group */
- uri = e_uri_new (source_location);
- relative_uri = print_uri_noproto (uri);
- e_uri_free (uri);
+ if (sdialog->original_source) {
+ guint32 color;
- /* Create source */
- source = e_source_new (source_name, relative_uri);
+ xml = xmlNewNode (NULL, "dummy");
+ e_source_dump_to_xml_node (sdialog->source, xml);
+ e_source_update_from_xml_node (sdialog->original_source, xml->children, NULL);
+ xmlFreeNode (xml);
- g_free (relative_uri);
+ e_source_get_color (sdialog->source, &color);
+ e_source_set_color (sdialog->original_source, color);
} else {
- /* Local source */
- source = e_source_new (source_name, source_name);
- e_source_set_relative_uri (source, e_source_peek_uid (source));
- }
-
- e_source_group_add_source (group, source, -1);
-
- /* create the calendar in the backend */
- cal = e_cal_new (source, source_type);
- if (!e_cal_open (cal, FALSE, NULL)) {
- e_source_group_remove_source (group, source);
- g_object_unref (source);
- source = NULL;
+ e_source_group_add_source (sdialog->source_group, sdialog->source, -1);
+ e_source_list_sync (sdialog->source_list, NULL);
}
-
- g_object_unref (cal);
-
- return source;
}
static void
-source_dialog_destroy (SourceDialog *source_dialog)
+eccp_free (EConfig *ec, GSList *items, void *data)
{
- g_object_unref (source_dialog->gui_xml);
+ CalendarSourceDialog *sdialog = data;
- if (source_dialog->source)
- g_object_unref (source_dialog->source);
+ g_slist_free (items);
- g_free (source_dialog);
-}
-
-static gboolean
-remote_page_verify (SourceDialog *source_dialog)
-{
- const gchar *uri;
-
- uri = gtk_entry_get_text (GTK_ENTRY (source_dialog->uri_entry));
- if (!uri || !uri [0])
- return FALSE;
-
- if (!validate_remote_uri (uri, FALSE, NULL))
- return FALSE;
-
- return TRUE;
+ g_object_unref (sdialog->source);
+ if (sdialog->original_source)
+ g_object_unref (sdialog->original_source);
+ if (sdialog->source_list)
+ g_object_unref (sdialog->source_list);
+ g_slist_free (sdialog->menu_source_groups);
+ g_free (sdialog);
}
static void
-general_entry_modified (SourceDialog *source_dialog)
+eccp_type_changed (GtkComboBox *dropdown, CalendarSourceDialog *sdialog)
{
- const char *text = gtk_entry_get_text (GTK_ENTRY (source_dialog->name_entry));
- gboolean sensitive = text && *text != '\0';
-
- sensitive = sensitive && (source_dialog->source_group != NULL);
-
- if (source_group_is_remote (source_dialog->source_group) && source_group_is_mutable (source_dialog->source_group)) {
- sensitive = sensitive && remote_page_verify (source_dialog);
- }
-
- gtk_widget_set_sensitive (source_dialog->add_button, sensitive);
-}
-
-static void
-general_update_dialog (SourceDialog *source_dialog)
-{
- gboolean remote = FALSE;
- gboolean mutable = source_group_is_mutable (source_dialog->source_group);
-
- if (source_dialog->source && e_source_get_readonly (source_dialog->source))
- gtk_widget_set_sensitive (glade_xml_get_widget (source_dialog->gui_xml, "settings-table"), FALSE);
+ int id = gtk_combo_box_get_active (dropdown);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- /* These are calendar specific so make sure we have them */
- if (source_dialog->uri_entry)
- g_signal_handlers_block_matched (source_dialog->uri_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
+ model = gtk_combo_box_get_model (dropdown);
+ if (id == -1 || !gtk_tree_model_iter_nth_child (model, &iter, NULL, id))
+ return;
- remote = (source_dialog->source && source_is_remote (source_dialog->source))
- || source_group_is_remote (source_dialog->source_group);
+ /* TODO: when we change the group type, we lose all of the pre-filled dialog info */
+ gtk_tree_model_get (model, &iter, 1, &sdialog->source_group, -1);
+ /* HACK: doesn't work if you don't do this */
+ e_source_set_absolute_uri (sdialog->source, NULL);
+ e_source_set_group (sdialog->source, sdialog->source_group);
- if (!remote) {
- if (source_dialog->uri_entry)
- gtk_entry_set_text (GTK_ENTRY (source_dialog->uri_entry), "");
- if (source_dialog->refresh_spin)
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (source_dialog->refresh_spin), 30);
- }
-
- general_entry_modified (source_dialog);
-
- if (source_dialog->uri_hbox)
- gtk_widget_set_sensitive (source_dialog->uri_hbox, remote && mutable);
- if (source_dialog->uri_label)
- gtk_widget_set_sensitive (source_dialog->uri_label, remote && mutable);
- if (source_dialog->refresh_label)
- gtk_widget_set_sensitive (source_dialog->refresh_label, remote && mutable);
- if (source_dialog->refresh_hbox)
- gtk_widget_set_sensitive (source_dialog->refresh_hbox, remote && mutable);
-
- if (source_dialog->uri_entry)
- g_signal_handlers_unblock_matched (source_dialog->uri_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
-}
+ e_source_set_relative_uri (sdialog->source, "");
-static void
-colorpicker_set_color (GnomeColorPicker *color, guint32 rgb)
-{
- gnome_color_picker_set_i8 (color, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff);
+ e_config_target_changed ((EConfig *) sdialog->config, E_CONFIG_TARGET_CHANGED_REBUILD);
}
-static guint32
-colorpicker_get_color (GnomeColorPicker *color)
+static GtkWidget *
+eccp_get_source_type (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *old, void *data)
{
- guint8 r, g, b, a;
- guint32 rgb = 0;
-
- gnome_color_picker_get_i8 (color, &r, &g, &b, &a);
-
- rgb = r;
- rgb <<= 8;
- rgb |= g;
- rgb <<= 8;
- rgb |= b;
-
- return rgb;
-}
-
-static char *
-get_refresh_minutes (SourceDialog *source_dialog)
-{
- int setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (source_dialog->refresh_spin));
-
- if (source_dialog->refresh_optionmenu)
- switch (gtk_option_menu_get_history (GTK_OPTION_MENU (source_dialog->refresh_optionmenu))){
- case 0: /* minutes */
- break;
- case 1: /* hours */
- setting *= 60;
- break;
- case 2: /* days */
- setting *= 1440;
- break;
- case 3: /* weeks wtf? why so long */
- setting *= 10080;
- break;
- default:
- g_warning ("Time unit out of range");
- break;
- }
-
- return g_strdup_printf ("%d", setting);
-}
-
-static void
-set_refresh_time (SourceDialog *source_dialog) {
- int time;
- int item_num = 0;
-
- const char *refresh_str = e_source_get_property (source_dialog->source, "refresh");
- time = refresh_str ? atoi (refresh_str) : 30;
-
- if (source_dialog->refresh_optionmenu) {
- if (time && !(time % 10080)) {
- /* weeks */
- item_num = 3;
- time /= 10080;
- } else if (time && !(time % 1440)) {
- /* days */
- item_num = 2;
- time /= 1440;
- } else if (time && !(time % 60)) {
- /* days */
- item_num = 1;
- time /= 60;
+ static GtkWidget *label, *type;
+ int row;
+ CalendarSourceDialog *sdialog = data;
+ ECalConfigTargetSource *t = (ECalConfigTargetSource *) ec->target;
+ ESource *source = t->source;
+ ESourceGroup *group = e_source_peek_group (source);
+ char *markup;
+
+ if (old)
+ gtk_widget_destroy (label);
+
+ row = ((GtkTable *)parent)->nrows;
+
+ if (sdialog->original_source) {
+ label = gtk_label_new (_("Type:"));
+
+ type = gtk_label_new ("");
+ gtk_widget_show (type);
+ markup = g_strdup_printf ("<span weight=\"bold\">%s</span>", e_source_group_peek_name (group));
+ gtk_label_set_markup (GTK_LABEL (type), markup);
+ gtk_misc_set_alignment (GTK_MISC (type), 0.0, 0.5);
+ g_free (markup);
+ gtk_table_attach (GTK_TABLE (parent), type, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ } else {
+ GtkCellRenderer *cell;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GSList *l;
+ int active = 0, i = 0;
+
+ label = gtk_label_new_with_mnemonic(_("_Type:"));
+
+ type = gtk_combo_box_new ();
+ cell = gtk_cell_renderer_text_new ();
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ for (l = sdialog->menu_source_groups; l; l = g_slist_next (l)) {
+ ESourceGroup *group = l->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, e_source_group_peek_name (group), 1, group, -1);
+ if (sdialog->source_group == group)
+ active = i;
+ i++;
}
- gtk_option_menu_set_history (GTK_OPTION_MENU (source_dialog->refresh_optionmenu), item_num);
+ gtk_cell_layout_pack_start ((GtkCellLayout *) type, cell, TRUE);
+ gtk_cell_layout_set_attributes ((GtkCellLayout *) type, cell, "text", 0, NULL);
+ gtk_combo_box_set_model ((GtkComboBox *) type, (GtkTreeModel *) store);
+ gtk_combo_box_set_active ((GtkComboBox *) type, active);
+ g_signal_connect (type, "changed", G_CALLBACK (eccp_type_changed), sdialog);
+ gtk_widget_show (type);
+ gtk_table_attach (GTK_TABLE (parent), type, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), type);
}
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (source_dialog->refresh_spin), time);
- return;
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
+
+ return type;
}
static void
-source_to_dialog (SourceDialog *source_dialog)
+name_changed (GtkEntry *entry, ECalConfigTargetSource *t)
{
- ESource *source = source_dialog->source;
- gboolean remote = FALSE;
-
- g_signal_handlers_block_matched (source_dialog->name_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
-
- /* These are calendar specific so make sure we have them */
- if (source_dialog->uri_entry)
- g_signal_handlers_block_matched (source_dialog->uri_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
- if (source_dialog->refresh_spin)
- g_signal_handlers_block_matched (source_dialog->refresh_spin, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
-
- gtk_entry_set_text (GTK_ENTRY (source_dialog->name_entry), source ? e_source_peek_name (source) : "");
-
- if (source && source_is_remote (source)) {
- gchar *uri_str;
-
- remote = TRUE;
-
- uri_str = e_source_get_uri (source);
- gtk_entry_set_text (GTK_ENTRY (source_dialog->uri_entry), uri_str);
- g_free (uri_str);
-
- set_refresh_time (source_dialog);
- } else {
- if (source_dialog->uri_entry)
- gtk_entry_set_text (GTK_ENTRY (source_dialog->uri_entry), "");
- if (source_dialog->refresh_spin)
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (source_dialog->refresh_spin), 30);
- }
-
- general_update_dialog (source_dialog);
-
- g_signal_handlers_unblock_matched (source_dialog->name_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
- if (source_dialog->uri_entry)
- g_signal_handlers_unblock_matched (source_dialog->uri_entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
- if (source_dialog->refresh_spin)
- g_signal_handlers_unblock_matched (source_dialog->refresh_spin, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, source_dialog);
- if (source_dialog->source_color) {
- static guint32 assigned_colors[] = {
- 0xBECEDD, /* 190 206 221 Blue */
- 0xE2F0EF, /* 226 240 239 Light Blue */
- 0xC6E2B7, /* 198 226 183 Green */
- 0xE2F0D3, /* 226 240 211 Light Green */
- 0xE2D4B7, /* 226 212 183 Khaki */
- 0xEAEAC1, /* 234 234 193 Light Khaki */
- 0xF0B8B7, /* 240 184 183 Pink */
- 0xFED4D3, /* 254 212 211 Light Pink */
- 0xE2C6E1, /* 226 198 225 Purple */
- 0xF0E2EF /* 240 226 239 Light Purple */
- };
- GRand *rand = g_rand_new ();
- guint32 color;
-
- color = assigned_colors[g_rand_int_range (rand, 0, 9)];
- g_rand_free (rand);
-
- if (source_dialog->source)
- e_source_get_color (source_dialog->source, &color);
- else
- /* FIXME */;
-
- colorpicker_set_color (GNOME_COLOR_PICKER (source_dialog->source_color), color);
- }
+ ESource *source = t->source;
+ e_source_set_name (source, gtk_entry_get_text (GTK_ENTRY (entry)));
}
-static void
-dialog_to_source (SourceDialog *source_dialog)
+static GtkWidget *
+eccp_get_source_name (EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data)
{
- ESource *source = source_dialog->source;
+ static GtkWidget *label, *entry;
+ int row;
+ ECalConfigTargetSource *t = (ECalConfigTargetSource *) ec->target;
+ ESource *source = t->source;
- g_return_if_fail (source != NULL);
+ if (old)
+ gtk_widget_destroy (label);
- e_source_set_name (source, gtk_entry_get_text (GTK_ENTRY (source_dialog->name_entry)));
- if (source_is_remote (source)) {
- EUri *uri;
- gchar *relative_uri;
- gchar *refresh_str;
+ row = ((GtkTable*)parent)->nrows;
- /* Our relative_uri is everything but protocol, which is supplied by parent group */
- uri = e_uri_new (gtk_entry_get_text (GTK_ENTRY (source_dialog->uri_entry)));
- if (!uri) {
- g_warning ("Invalid remote URI!");
- return;
- }
+ label = gtk_label_new_with_mnemonic (_("_Name:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
- relative_uri = print_uri_noproto (uri);
- e_source_set_relative_uri (source, relative_uri);
- g_free (relative_uri);
- e_uri_free (uri);
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+ gtk_table_attach (GTK_TABLE (parent), entry, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+ g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (name_changed), (gpointer) t);
- refresh_str = get_refresh_minutes (source_dialog);
- e_source_set_property (source, "refresh", refresh_str);
- g_free (refresh_str);
- }
-
- if (source_dialog->source_color)
- e_source_set_color (source,
- colorpicker_get_color (GNOME_COLOR_PICKER (source_dialog->source_color)));
-}
+ if (source)
+ gtk_entry_set_text (GTK_ENTRY (entry), e_source_peek_name (source));
-static void
-dialog_hide_unused_options (SourceDialog *source_dialog)
-{
- ESource *source = source_dialog->source;
-
- if (source && (!source_is_remote (source) || !source_group_is_mutable (source_dialog->source_group))) {
- if (source_dialog->uri_hbox)
- gtk_widget_hide (source_dialog->uri_hbox);
- if (source_dialog->uri_label)
- gtk_widget_hide (source_dialog->uri_label);
- if (source_dialog->refresh_label)
- gtk_widget_hide (source_dialog->refresh_label);
- if (source_dialog->refresh_hbox)
- gtk_widget_hide (source_dialog->refresh_hbox);
- }
+ return entry;
}
static void
-source_group_changed_sensitive (SourceDialog *source_dialog)
+color_changed (GnomeColorPicker *picker, guint r, guint g, guint b, guint a, ECalConfigTargetSource *t)
{
- source_dialog->source_group =
- g_slist_nth (e_source_list_peek_groups (source_dialog->source_list),
- gtk_option_menu_get_history (GTK_OPTION_MENU (source_dialog->group_optionmenu)))->data;
-
- general_update_dialog (source_dialog);
+ ESource *source = t->source;
+ e_source_set_color (source, colorpicker_get_color (picker));
}
-static gboolean
-key_press_event (GtkWidget *widget, GdkEventKey *event)
+static GtkWidget *
+eccp_get_source_color (EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data)
{
- if (event->keyval == GDK_Escape) {
- gtk_widget_destroy (widget);
- return TRUE;
- }
+ CalendarSourceDialog *sdialog = data;
+ static GtkWidget *label, *picker;
+ int row;
+ ECalConfigTargetSource *t = (ECalConfigTargetSource *) ec->target;
+ ESource *source = t->source;
+
+ static guint32 assigned_colors[] = {
+ 0xBECEDD, /* 190 206 221 Blue */
+ 0xE2F0EF, /* 226 240 239 Light Blue */
+ 0xC6E2B7, /* 198 226 183 Green */
+ 0xE2F0D3, /* 226 240 211 Light Green */
+ 0xE2D4B7, /* 226 212 183 Khaki */
+ 0xEAEAC1, /* 234 234 193 Light Khaki */
+ 0xF0B8B7, /* 240 184 183 Pink */
+ 0xFED4D3, /* 254 212 211 Light Pink */
+ 0xE2C6E1, /* 226 198 225 Purple */
+ 0xF0E2EF /* 240 226 239 Light Purple */
+ };
+ GRand *rand = g_rand_new ();
+ guint32 color;
+
+ if (old)
+ gtk_widget_destroy (label);
+
+ row = ((GtkTable*)parent)->nrows;
+
+ color = assigned_colors[g_rand_int_range (rand, 0, 9)];
+ g_rand_free (rand);
+
+ label = gtk_label_new_with_mnemonic (_("C_olor:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0);
+
+ picker = gnome_color_picker_new ();
+ gtk_widget_show (picker);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), picker);
+ gtk_table_attach (GTK_TABLE (parent), picker, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ g_signal_connect (G_OBJECT (picker), "color-set", G_CALLBACK (color_changed), t);
+
+ if (sdialog->original_source)
+ e_source_get_color (sdialog->original_source, &color);
+ else
+ /* since we don't have an original source here, we want to set
+ * the initial color */
+ e_source_set_color (sdialog->source, color);
- return FALSE;
-}
+ colorpicker_set_color (GNOME_COLOR_PICKER (picker), color);
-static void
-new_calendar_cancel (SourceDialog *source_dialog)
-{
- gtk_widget_destroy (source_dialog->window);
-}
-
-static void
-new_calendar_add (SourceDialog *source_dialog)
-{
- source_dialog->source =
- create_new_source_with_group (GTK_WINDOW (source_dialog->window), source_dialog->source_group,
- gtk_entry_get_text (GTK_ENTRY (source_dialog->name_entry)),
- gtk_entry_get_text (GTK_ENTRY (source_dialog->uri_entry)),
- E_CAL_SOURCE_TYPE_EVENT);
- dialog_to_source (source_dialog);
-
- gtk_widget_destroy (source_dialog->window);
+ return picker;
}
-static void
-edit_calendar_finish (SourceDialog *source_dialog)
-{
- dialog_to_source (source_dialog);
- gtk_widget_destroy (source_dialog->window);
-}
-
-gboolean
-calendar_setup_edit_calendar (GtkWindow *parent, ESource *source)
+static ECalConfigItem eccp_items[] = {
+ { E_CONFIG_BOOK, "", NULL },
+ { E_CONFIG_PAGE, "00.general", N_("General") },
+ { E_CONFIG_SECTION_TABLE, "00.general/00.source", N_("Calendar") },
+ { E_CONFIG_ITEM_TABLE, "00.general/00.source/00.type", NULL, eccp_get_source_type },
+ { E_CONFIG_ITEM_TABLE, "00.general/00.source/10.name", NULL, eccp_get_source_name },
+ { E_CONFIG_ITEM_TABLE, "00.general/00.source/20.color", NULL, eccp_get_source_color },
+ { 0 },
+};
+
+static ECalConfigItem ectp_items[] = {
+ { E_CONFIG_BOOK, "", NULL },
+ { E_CONFIG_PAGE, "00.general", N_("General") },
+ { E_CONFIG_SECTION_TABLE, "00.general/00.source", N_("Tasks List") },
+ { E_CONFIG_ITEM_TABLE, "00.general/00.source/00.type", NULL, eccp_get_source_type },
+ { E_CONFIG_ITEM_TABLE, "00.general/00.source/10.name", NULL, eccp_get_source_name },
+ { E_CONFIG_ITEM_TABLE, "00.general/00.source/20.color", NULL, eccp_get_source_color },
+ { 0 },
+};
+
+/**
+ * calendar_setup_edit_calendar:
+ * @parent: parent window for dialog (current unused)
+ * @source: the ESource corresponding to the calendar
+ *
+ * Show calendar properties for @source.
+ **/
+void
+calendar_setup_edit_calendar (struct _GtkWindow *parent, ESource *source)
{
- SourceDialog *source_dialog = g_new0 (SourceDialog, 1);
- int index;
- GList *icon_list;
-
- source_dialog->gui_xml = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, "add-calendar-window", NULL);
- if (!source_dialog->gui_xml) {
- g_warning (G_STRLOC ": Cannot load Glade file.");
- g_free (source_dialog);
- return FALSE;
- }
+ CalendarSourceDialog *sdialog = g_new0 (CalendarSourceDialog, 1);
+ char *xml;
+ ECalConfig *ec;
+ int i;
+ GSList *items = NULL;
+ ECalConfigTargetSource *target;
- source_dialog->window = glade_xml_get_widget (source_dialog->gui_xml, "add-calendar-window");
if (source) {
- gtk_window_set_title (GTK_WINDOW (source_dialog->window), "Calendar Properties");
- source_dialog->source = source;
- source_dialog->source_group = e_source_peek_group (source);
- g_object_ref (source);
- }
-
- g_signal_connect (source_dialog->window, "key-press-event", G_CALLBACK (key_press_event), NULL);
-
- source_dialog->name_entry = glade_xml_get_widget (source_dialog->gui_xml, "name-entry");
- g_signal_connect_swapped (source_dialog->name_entry, "changed",
- G_CALLBACK (general_entry_modified), source_dialog);
- source_dialog->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/calendar/sources");
-
- source_dialog->group_optionmenu =
- glade_xml_get_widget (source_dialog->gui_xml, "group-optionmenu");
- if (!GTK_IS_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (source_dialog->group_optionmenu)))) {
- GtkWidget *menu = gtk_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (source_dialog->group_optionmenu), menu);
- gtk_widget_show (menu);
- }
- gtk_widget_set_sensitive (source_dialog->group_optionmenu, source == NULL);
-
- /* NOTE: This assumes that we have sources. If they don't exist, they're set up
- * on startup of the calendar component. */
- index = source_group_menu_add_groups (GTK_MENU_SHELL (gtk_option_menu_get_menu (
- GTK_OPTION_MENU (source_dialog->group_optionmenu))), source_dialog);
- gtk_option_menu_set_history (GTK_OPTION_MENU (source_dialog->group_optionmenu), index);
-
- g_signal_connect_swapped (source_dialog->group_optionmenu, "changed",
- G_CALLBACK (source_group_changed_sensitive), source_dialog);
- source_dialog->uri_entry = glade_xml_get_widget (source_dialog->gui_xml, "uri-entry");
- source_dialog->uri_label = glade_xml_get_widget (source_dialog->gui_xml, "uri-label");
- source_dialog->uri_hbox = glade_xml_get_widget (source_dialog->gui_xml, "uri-hbox");
-
- g_signal_connect_swapped (source_dialog->uri_entry, "changed",
- G_CALLBACK (general_entry_modified), source_dialog);
-
- source_dialog->refresh_spin = glade_xml_get_widget (source_dialog->gui_xml, "refresh-spin");
- source_dialog->refresh_optionmenu = glade_xml_get_widget (source_dialog->gui_xml, "refresh-optionmenu");
- source_dialog->refresh_label = glade_xml_get_widget (source_dialog->gui_xml, "refresh-label");
- source_dialog->refresh_hbox = glade_xml_get_widget (source_dialog->gui_xml, "refresh-hbox");
+ guint32 color;
- g_signal_connect_swapped (glade_xml_get_widget (source_dialog->gui_xml, "cancel-button"), "clicked",
- G_CALLBACK (new_calendar_cancel), source_dialog);
+ sdialog->original_source = source;
+ g_object_ref (source);
+ sdialog->source_group = e_source_peek_group (source);
+ xml = e_source_to_standalone_xml (source);
+ sdialog->source = e_source_new_from_standalone_xml (xml);
+ g_free (xml);
- source_dialog->add_button = glade_xml_get_widget (source_dialog->gui_xml, "add-button");
- gtk_widget_set_sensitive (source_dialog->add_button, FALSE);
+ e_source_get_color (source, &color);
+ e_source_set_color (sdialog->source, color);
+ } else {
+ GConfClient *gconf;
+ GSList *l;
- if (source) {
- gtk_button_set_use_stock (GTK_BUTTON (source_dialog->add_button), TRUE);
- gtk_button_set_label (GTK_BUTTON (source_dialog->add_button), GTK_STOCK_OK);
+ sdialog->source = e_source_new ("", "");
+ gconf = gconf_client_get_default ();
+ sdialog->source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/calendar/sources");
+ l = e_source_list_peek_groups (sdialog->source_list);
+ sdialog->menu_source_groups = g_slist_copy(l);
- g_signal_connect_swapped (source_dialog->add_button, "clicked",
- G_CALLBACK (edit_calendar_finish), source_dialog);
- } else {
- g_signal_connect_swapped (source_dialog->add_button, "clicked",
- G_CALLBACK (new_calendar_add), source_dialog);
+ sdialog->source_group = (ESourceGroup *)sdialog->menu_source_groups->data;
+ g_object_unref (gconf);
}
- source_dialog->source_color = glade_xml_get_widget (source_dialog->gui_xml, "source-color");
-
- g_object_weak_ref (G_OBJECT (source_dialog->window),
- (GWeakNotify) source_dialog_destroy, source_dialog);
-
- source_to_dialog (source_dialog);
-
- gtk_window_set_type_hint (GTK_WINDOW (source_dialog->window), GDK_WINDOW_TYPE_HINT_DIALOG);
- gtk_window_set_modal (GTK_WINDOW (source_dialog->window), TRUE);
-
- icon_list = e_icon_factory_get_icon_list ("stock_calendar");
- if (icon_list) {
- gtk_window_set_icon_list (GTK_WINDOW (source_dialog->window), icon_list);
- g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
- g_list_free (icon_list);
- }
+ /* HACK: doesn't work if you don't do this */
+ e_source_set_absolute_uri (sdialog->source, NULL);
+ e_source_set_group (sdialog->source, sdialog->source_group);
- dialog_hide_unused_options (source_dialog);
- gtk_widget_show (source_dialog->window);
- return TRUE;
-}
+ sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties");
+ for (i = 0; eccp_items[i].path; i++)
+ items = g_slist_prepend (items, &eccp_items[i]);
+ e_config_add_items ((EConfig *) ec, items, eccp_commit, NULL, eccp_free, sdialog);
+ e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog);
-static void
-new_task_list_cancel (SourceDialog *source_dialog)
-{
- gtk_widget_destroy (source_dialog->window);
-}
+ target = e_cal_config_target_new_source (ec, sdialog->source);
+ e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
-static void
-new_task_list_add (SourceDialog *source_dialog)
-{
- source_dialog->source =
- create_new_source_with_group (GTK_WINDOW (source_dialog->window), source_dialog->source_group,
- gtk_entry_get_text (GTK_ENTRY (source_dialog->name_entry)),
- gtk_entry_get_text (GTK_ENTRY (source_dialog->uri_entry)),
- E_CAL_SOURCE_TYPE_TODO);
- dialog_to_source (source_dialog);
-
- gtk_widget_destroy (source_dialog->window);
-}
+ sdialog->window = e_config_create_window ((EConfig *)ec, NULL, _("Calendar Properties"));
-gboolean
-calendar_setup_new_calendar (GtkWindow *parent)
-{
- return calendar_setup_edit_calendar (parent, NULL);
+ /* forces initial validation */
+ if (!sdialog->original_source)
+ e_config_target_changed ((EConfig *)ec, E_CONFIG_TARGET_CHANGED_STATE);
+
+ return;
}
-static void
-edit_task_list_finish (SourceDialog *source_dialog)
+void
+calendar_setup_new_calendar (struct _GtkWindow *parent)
{
- dialog_to_source (source_dialog);
- gtk_widget_destroy (source_dialog->window);
+ calendar_setup_edit_calendar (parent, NULL);
}
-gboolean
-calendar_setup_edit_task_list (GtkWindow *parent, ESource *source)
+void
+calendar_setup_edit_task_list (struct _GtkWindow *parent, ESource *source)
{
- SourceDialog *source_dialog = g_new0 (SourceDialog, 1);
- int index;
- GList *icon_list;
-
- source_dialog->gui_xml = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, "add-task-list-window", NULL);
- if (!source_dialog->gui_xml) {
- g_warning (G_STRLOC ": Cannot load Glade file.");
- g_free (source_dialog);
- return FALSE;
- }
+ CalendarSourceDialog *sdialog = g_new0 (CalendarSourceDialog, 1);
+ char *xml;
+ ECalConfig *ec;
+ int i;
+ GSList *items = NULL;
+ ECalConfigTargetSource *target;
- source_dialog->window = glade_xml_get_widget (source_dialog->gui_xml, "add-task-list-window");
if (source) {
- gtk_window_set_title (GTK_WINDOW (source_dialog->window), "Task List Properties");
- source_dialog->source = source;
- source_dialog->source_group = e_source_peek_group (source);
+ guint32 color;
+
+ sdialog->original_source = source;
g_object_ref (source);
- }
+ sdialog->source_group = e_source_peek_group (source);
+ xml = e_source_to_standalone_xml (source);
+ sdialog->source = e_source_new_from_standalone_xml (xml);
+ g_free (xml);
- g_signal_connect (source_dialog->window, "key-press-event", G_CALLBACK (key_press_event), NULL);
+ e_source_get_color (source, &color);
+ e_source_set_color (sdialog->source, color);
+ } else {
+ GConfClient *gconf;
+ GSList *l;
- source_dialog->name_entry = glade_xml_get_widget (source_dialog->gui_xml, "name-entry");
- g_signal_connect_swapped (source_dialog->name_entry, "changed",
- G_CALLBACK (general_entry_modified), source_dialog);
- source_dialog->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/tasks/sources");
+ sdialog->source = e_source_new ("", "");
+ gconf = gconf_client_get_default ();
+ sdialog->source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/tasks/sources");
+ l = e_source_list_peek_groups (sdialog->source_list);
+ sdialog->menu_source_groups = g_slist_copy(l);
- source_dialog->group_optionmenu =
- glade_xml_get_widget (source_dialog->gui_xml, "group-optionmenu");
- if (!GTK_IS_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (source_dialog->group_optionmenu)))) {
- GtkWidget *menu = gtk_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (source_dialog->group_optionmenu), menu);
- gtk_widget_show (menu);
+ sdialog->source_group = (ESourceGroup *)sdialog->menu_source_groups->data;
+ g_object_unref (gconf);
}
- gtk_widget_set_sensitive (source_dialog->group_optionmenu, source == NULL);
-
- /* NOTE: This assumes that we have sources. If they don't exist, they're set up
- * on startup of the calendar component. */
- index = source_group_menu_add_groups (GTK_MENU_SHELL (gtk_option_menu_get_menu (
- GTK_OPTION_MENU (source_dialog->group_optionmenu))), source_dialog);
- gtk_option_menu_set_history (GTK_OPTION_MENU (source_dialog->group_optionmenu), index);
-
- g_signal_connect_swapped (source_dialog->group_optionmenu, "changed",
- G_CALLBACK (source_group_changed_sensitive), source_dialog);
- source_dialog->uri_entry = glade_xml_get_widget (source_dialog->gui_xml, "uri-entry");
- source_dialog->uri_label = glade_xml_get_widget (source_dialog->gui_xml, "uri-label");
- source_dialog->uri_hbox = glade_xml_get_widget (source_dialog->gui_xml, "uri-hbox");
+ /* HACK: doesn't work if you don't do this */
+ e_source_set_absolute_uri (sdialog->source, NULL);
+ e_source_set_group (sdialog->source, sdialog->source_group);
- g_signal_connect_swapped (source_dialog->uri_entry, "changed",
- G_CALLBACK (general_entry_modified), source_dialog);
+ sdialog->config = ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.calendarProperties");
+ for (i = 0; ectp_items[i].path; i++)
+ items = g_slist_prepend (items, &ectp_items[i]);
+ e_config_add_items ((EConfig *) ec, items, eccp_commit, NULL, eccp_free, sdialog);
+ e_config_add_page_check ((EConfig *) ec, NULL, eccp_check_complete, sdialog);
- source_dialog->refresh_spin = glade_xml_get_widget (source_dialog->gui_xml, "refresh-spin");
- source_dialog->refresh_optionmenu = glade_xml_get_widget (source_dialog->gui_xml, "refresh-optionmenu");
- source_dialog->refresh_label = glade_xml_get_widget (source_dialog->gui_xml, "refresh-label");
- source_dialog->refresh_hbox = glade_xml_get_widget (source_dialog->gui_xml, "refresh-hbox");
+ target = e_cal_config_target_new_source (ec, sdialog->source);
+ e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
- g_signal_connect_swapped (glade_xml_get_widget (source_dialog->gui_xml, "cancel-button"), "clicked",
- G_CALLBACK (new_task_list_cancel), source_dialog);
+ sdialog->window = e_config_create_window ((EConfig *)ec, NULL, _("Task List Properties"));
- source_dialog->add_button = glade_xml_get_widget (source_dialog->gui_xml, "add-button");
- gtk_widget_set_sensitive (source_dialog->add_button, FALSE);
-
- if (source) {
- gtk_button_set_use_stock (GTK_BUTTON (source_dialog->add_button), TRUE);
- gtk_button_set_label (GTK_BUTTON (source_dialog->add_button), GTK_STOCK_OK);
+ /* forces initial validation */
+ if (!sdialog->original_source)
+ e_config_target_changed ((EConfig *)ec, E_CONFIG_TARGET_CHANGED_STATE);
- g_signal_connect_swapped (source_dialog->add_button, "clicked",
- G_CALLBACK (edit_task_list_finish), source_dialog);
- } else {
- g_signal_connect_swapped (source_dialog->add_button, "clicked",
- G_CALLBACK (new_task_list_add), source_dialog);
- }
-
- g_object_weak_ref (G_OBJECT (source_dialog->window),
- (GWeakNotify) source_dialog_destroy, source_dialog);
-
- source_dialog->source_color = glade_xml_get_widget (source_dialog->gui_xml, "source-color");
-
- source_to_dialog (source_dialog);
-
- gtk_window_set_type_hint (GTK_WINDOW (source_dialog->window), GDK_WINDOW_TYPE_HINT_DIALOG);
- gtk_window_set_modal (GTK_WINDOW (source_dialog->window), TRUE);
-
- icon_list = e_icon_factory_get_icon_list ("stock_task");
- if (icon_list) {
- gtk_window_set_icon_list (GTK_WINDOW (source_dialog->window), icon_list);
- g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
- g_list_free (icon_list);
- }
-
- dialog_hide_unused_options (source_dialog);
- gtk_widget_show (source_dialog->window);
- return TRUE;
+ return;
}
-gboolean
-calendar_setup_new_task_list (GtkWindow *parent)
+void
+calendar_setup_new_task_list (struct _GtkWindow *parent)
{
- return calendar_setup_edit_task_list (parent, NULL);
+ calendar_setup_edit_task_list (parent, NULL);
}
-
diff --git a/calendar/gui/dialogs/calendar-setup.h b/calendar/gui/dialogs/calendar-setup.h
index c60afdf0e5..f0e1a04ceb 100644
--- a/calendar/gui/dialogs/calendar-setup.h
+++ b/calendar/gui/dialogs/calendar-setup.h
@@ -1,12 +1,12 @@
-/* Evolution calendar - Calendar properties dialogs.
+/*
+ * Authors: David Trowbridge <trowbrds@cs.colorado.edu>
*
- * Copyright (C) 2004 Novell, Inc.
- *
- * Author: Hans Petter Jansson <hpj@ximian.com>
+ * Copyright (C) 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.
+ * 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
@@ -15,18 +15,29 @@
*
* 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.
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
*/
-#ifndef CALENDAR_CONFIG_H
-#define CALENDAR_CONFIG_H
+#ifndef __CALENDAR_SETUP_H__
+#define __CALENDAR_SETUP_H__
-#include <gtk/gtkwindow.h>
+struct _GtkWindow;
+struct _ESource;
-gboolean calendar_setup_new_calendar (GtkWindow *parent);
-gboolean calendar_setup_edit_calendar (GtkWindow *parent, ESource *source);
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif
-gboolean calendar_setup_new_task_list (GtkWindow *parent);
-gboolean calendar_setup_edit_task_list (GtkWindow *parent, ESource *source);
+void calendar_setup_edit_calendar (struct _GtkWindow *parent, struct _ESource *source);
+void calendar_setup_new_calendar (struct _GtkWindow *parent);
+void calendar_setup_edit_task_list (struct _GtkWindow *parent, struct _ESource *source);
+void calendar_setup_new_task_list (struct _GtkWindow *parent);
+
+#ifdef __cplusplus
+}
#endif
+
+#endif /* __CALENDAR_SETUP_H__ */
diff --git a/calendar/gui/e-cal-config.c b/calendar/gui/e-cal-config.c
new file mode 100644
index 0000000000..65c1d8c2b6
--- /dev/null
+++ b/calendar/gui/e-cal-config.c
@@ -0,0 +1,190 @@
+/*
+ * Authors: David Trowbridge <trowbrds@cs.colorado.edu>
+ *
+ * Copyright (C) 2004 Novell, Inc (www.novell.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 <gtk/gtkwidget.h>
+#include "e-cal-config.h"
+
+static GObjectClass *ecp_parent_class;
+static GObjectClass *ecph_parent_class;
+
+struct _ECalConfigPrivate {
+ ulong source_changed_id;
+};
+
+#define _PRIVATE(o) (g_type_instance_get_private ((GTypeInstance *)o, e_cal_config_get_type ()))
+
+static void
+ecp_init (GObject *o)
+{
+}
+
+static void
+ecp_target_free (EConfig *ec, EConfigTarget *t)
+{
+ struct _ECalConfigPrivate *p = _PRIVATE (ec);
+
+ if (ec->target == t) {
+ switch (t->type) {
+ case EC_CONFIG_TARGET_SOURCE: {
+ ECalConfigTargetSource *s = (ECalConfigTargetSource *)t;
+
+ if (p->source_changed_id) {
+ g_signal_handler_disconnect (s->source, p->source_changed_id);
+ p->source_changed_id = NULL;
+ }
+ break; }
+ }
+ }
+
+ switch (t->type) {
+ case EC_CONFIG_TARGET_SOURCE: {
+ ECalConfigTargetSource *s = (ECalConfigTargetSource *)t;
+ if (s->source)
+ g_object_unref (s->source);
+ break; }
+ }
+
+ ((EConfigClass *) ecp_parent_class)->target_free (ec, t);
+}
+
+static void
+ecp_source_changed (struct _ESource *source, EConfig *ec)
+{
+ e_config_target_changed (ec, E_CONFIG_TARGET_CHANGED_STATE);
+}
+
+static void
+ecp_set_target (EConfig *ec, EConfigTarget *t)
+{
+ struct _ECalConfigPrivate *p = _PRIVATE(ec);
+
+ ((EConfigClass *)ecp_parent_class)->set_target(ec, t);
+
+ if (t) {
+ switch (t->type) {
+ case EC_CONFIG_TARGET_SOURCE: {
+ ECalConfigTargetSource *s = (ECalConfigTargetSource *)t;
+
+ p->source_changed_id = g_signal_connect (s->source, "changed", G_CALLBACK (ecp_source_changed), ec);
+ break; }
+ }
+ }
+}
+
+static void
+ecp_class_init (GObjectClass *klass)
+{
+ ((EConfigClass *)klass)->set_target = ecp_set_target;
+ ((EConfigClass *)klass)->target_free = ecp_target_free;
+
+ g_type_class_add_private (klass, sizeof (struct _ECalConfigPrivate));
+}
+
+GType
+e_cal_config_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (ECalConfigClass),
+ NULL, NULL,
+ (GClassInitFunc) ecp_class_init,
+ NULL, NULL,
+ sizeof (ECalConfig), 0,
+ (GInstanceInitFunc) ecp_init
+ };
+
+ ecp_parent_class = g_type_class_ref (e_config_get_type ());
+ type = g_type_register_static (e_config_get_type (), "ECalConfig", &info, 0);
+ }
+
+ return type;
+}
+
+ECalConfig *
+e_cal_config_new (int type, const char *menuid)
+{
+ ECalConfig *ecp = g_object_new (e_cal_config_get_type(), 0);
+ e_config_construct (&ecp->config, type, menuid);
+ return ecp;
+}
+
+ECalConfigTargetSource *
+e_cal_config_target_new_source (ECalConfig *ecp, struct _ESource *source)
+{
+ ECalConfigTargetSource *t = e_config_target_new (&ecp->config, EC_CONFIG_TARGET_SOURCE, sizeof (*t));
+
+ t->source = source;
+ g_object_ref (source);
+
+ return t;
+}
+
+static const EConfigHookTargetMask ecph_no_masks[] = {
+ { 0 }
+};
+
+static const EConfigHookTargetMap ecph_targets[] = {
+ { "source", EC_CONFIG_TARGET_SOURCE, ecph_no_masks },
+ { 0 },
+};
+
+static void
+ecph_class_init (EPluginHookClass *klass)
+{
+ int i;
+
+ klass->id = "org.gnome.evolution.calendar.config:1.0";
+
+ for (i = 0; ecph_targets[i].type; i++) {
+ g_print ("adding hook target '%s'\n", ecph_targets[i].type);
+ e_config_hook_class_add_target_map ((EConfigHookClass *)klass, &ecph_targets[i]);
+ }
+
+ ((EConfigHookClass *)klass)->config_class = g_type_class_ref (e_cal_config_get_type ());
+}
+
+GType
+e_cal_config_hook_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (ECalConfigHookClass),
+ NULL, NULL,
+ (GClassInitFunc) ecph_class_init,
+ NULL, NULL,
+ sizeof (ECalConfigHook), 0,
+ (GInstanceInitFunc) NULL
+ };
+
+ ecph_parent_class = g_type_class_ref (e_config_hook_get_type ());
+ type = g_type_register_static (e_config_hook_get_type (), "ECalConfigHook", &info, 0);
+ }
+
+ return type;
+}
diff --git a/calendar/gui/e-cal-config.h b/calendar/gui/e-cal-config.h
new file mode 100644
index 0000000000..93086dd8ce
--- /dev/null
+++ b/calendar/gui/e-cal-config.h
@@ -0,0 +1,83 @@
+/*
+ * Authors: David Trowbridge <trowbrds@cs.colorado.edu>
+ *
+ * Copyright (C) 2004 Novell, Inc (www.novell.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 __E_CAL_CONFIG_H__
+#define __E_CAL_CONFIG_H__
+
+#include <glib-object.h>
+
+#include "e-util/e-config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif
+
+typedef struct _ECalConfig ECalConfig;
+typedef struct _ECalConfigClass ECalConfigClass;
+
+struct _ECalConfig {
+ EConfig config;
+};
+
+struct _ECalConfigClass {
+ EConfigClass config_class;
+};
+
+enum _e_cal_config_target_t {
+ EC_CONFIG_TARGET_SOURCE,
+};
+
+typedef struct _ECalConfigTargetSource ECalConfigTargetSource;
+
+struct _ECalConfigTargetSource {
+ EConfigTarget target;
+
+ struct _ESource *source;
+};
+
+typedef struct _EConfigItem ECalConfigItem;
+
+GType e_cal_config_get_type (void);
+ECalConfig *e_cal_config_new (int type, const char *menuid);
+
+ECalConfigTargetSource *e_cal_config_target_new_source (ECalConfig *ecp, struct _ESource *source);
+
+/* ********************************************************************** */
+
+typedef struct _ECalConfigHook ECalConfigHook;
+typedef struct _ECalConfigHookClass ECalConfigHookClass;
+
+struct _ECalConfigHook {
+ EConfigHook hook;
+};
+
+struct _ECalConfigHookClass {
+ EConfigHookClass hook_class;
+};
+
+GType e_cal_config_hook_get_type (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 6a189fc8d2..e3afeab6ac 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -45,6 +45,8 @@
#include "tasks-control.h"
#include "tasks-component.h"
+#include <e-util/e-plugin.h>
+#include "e-cal-config.h"
#define FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_Factory:" BASE_VERSION
@@ -143,6 +145,7 @@ initialize (void)
/* Initialize plugin system */
e_plugin_hook_register_type (e_cal_popup_hook_get_type());
e_plugin_hook_register_type (e_cal_menu_hook_get_type());
+ e_plugin_hook_register_type (e_cal_config_hook_get_type ());
}