aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/comp-editor.c
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2003-12-18 10:41:53 +0800
committerHans Petter <hansp@src.gnome.org>2003-12-18 10:41:53 +0800
commite4a68478f7fed9fdf32feae4cca56fb1f4b71411 (patch)
treeccaf59a8b1d95a3be46e9241248185f490592535 /calendar/gui/dialogs/comp-editor.c
parent919563751e1cce6a0aa42f6ec8bd02f84ec7d67c (diff)
downloadgsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.gz
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.bz2
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.lz
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.xz
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.zst
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.zip
Add the concept of a source client, where the object lives currently. The
2003-12-17 Hans Petter Jansson <hpj@ximian.com> * gui/dialogs/comp-editor.c: Add the concept of a source client, where the object lives currently. The plain client is where it will be stored. (comp_editor_finalize): If we have a source client, disconnect from and unref it. (save_comp): Check if the object is being moved, and if so, remove it from the source client, and make the target client the new source. (comp_editor_append_page): Connect to client_changed signal. (real_set_e_cal): Change an old gtk_signal_disconnect_by_data() to the GLib equivalent, and don't cast ECal to GtkObject. If the source client is not set, make it equivalent to the target client. (page_client_changed_cb): Implement. Handles a client change. * gui/dialogs/comp-editor-page.c (comp_editor_page_class_init): Add a new signal, "client_changed", that notifies that the ECal client was changed from one of the editor pages. (comp_editor_page_set_e_cal): Fix two bugs in this function; if the same client is set twice, its ref count could drop to 0. Additionally, it was unreffing the new client instead of the old one. (comp_editor_page_notify_client_changed): Implement. * gui/dialogs/event-page.c (event_page_fill_widgets): Fill in the source menu. (get_widgets): Get the source menu. (source_changed_cb): Implement. Try to open a client for the new source, and if successful, notify of the change. Show a dialog on failure, and revert to last selected source. (init_widgets): Connect to source menu. (event_page_create_source_option_menu): Implement Glade helper. * gui/dialogs/task-page.c (task_page_fill_widgets): Fill in the source menu. (get_widgets): Get the source menu. (source_changed_cb): Implement, similar to the event page, but for tasks. (init_widgets): Connect to source menu. (task_page_construct): Fix a message booboo. (task_page_create_source_option_menu): Implement Glade helper. * gui/dialogs/event-page.glade: Add source menu widget. * gui/dialogs/task-page.glade: Add source menu widget. svn path=/trunk/; revision=23974
Diffstat (limited to 'calendar/gui/dialogs/comp-editor.c')
-rw-r--r--calendar/gui/dialogs/comp-editor.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index cd270eb423..4e4a9da7c2 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -56,6 +56,9 @@ struct _CompEditorPrivate {
/* Client to use */
ECal *client;
+ /* Source client (where comp lives currently) */
+ ECal *source_client;
+
/* Calendar object/uid we are editing; this is an internal copy */
ECalComponent *comp;
@@ -100,6 +103,7 @@ static void close_dialog (CompEditor *editor);
static void page_changed_cb (GtkObject *obj, gpointer data);
static void page_summary_changed_cb (GtkObject *obj, const char *summary, gpointer data);
static void page_dates_changed_cb (GtkObject *obj, CompEditorPageDates *dates, gpointer data);
+static void page_client_changed_cb (GtkObject *obj, ECal *client, gpointer data);
static void obj_updated_cb (ECal *client, const char *uid, gpointer data);
static void obj_removed_cb (ECal *client, const char *uid, gpointer data);
@@ -268,6 +272,12 @@ comp_editor_finalize (GObject *object)
priv->client = NULL;
}
+ if (priv->source_client) {
+ g_signal_handlers_disconnect_matched (priv->source_client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, editor);
+ g_object_unref (priv->source_client);
+ priv->source_client = NULL;
+ }
+
/* We want to destroy the pages after the widgets get destroyed,
since they have lots of signal handlers connected to the widgets
with the pages as the data. */
@@ -296,6 +306,7 @@ save_comp (CompEditor *editor)
GList *l;
gboolean result;
GError *error = NULL;
+ const char *orig_uid;
priv = editor->priv;
@@ -322,6 +333,8 @@ save_comp (CompEditor *editor)
priv->updating = TRUE;
+ e_cal_component_get_uid (priv->comp, &orig_uid);
+
if (!cal_comp_is_on_server (priv->comp, priv->client)) {
result = e_cal_create_object (priv->client, e_cal_component_get_icalcomponent (priv->comp), NULL, &error);
} else {
@@ -343,6 +356,23 @@ save_comp (CompEditor *editor)
return FALSE;
} else {
+ if (priv->source_client &&
+ !e_source_equal (e_cal_get_source (priv->client),
+ e_cal_get_source (priv->source_client)) &&
+ cal_comp_is_on_server (priv->comp, priv->source_client)) {
+ /* Comp found a new home. Remove it from old one. */
+ e_cal_remove_object (priv->source_client, orig_uid, NULL);
+
+ /* Let priv->source_client point to new home, so we can move it
+ * again this session. */
+ g_signal_handlers_disconnect_matched (priv->source_client, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, editor);
+ g_object_unref (priv->source_client);
+
+ priv->source_client = priv->client;
+ g_object_ref (priv->source_client);
+ }
+
priv->changed = FALSE;
}
@@ -654,6 +684,8 @@ comp_editor_append_page (CompEditor *editor,
G_CALLBACK (page_summary_changed_cb), editor);
g_signal_connect(page, "dates_changed",
G_CALLBACK (page_dates_changed_cb), editor);
+ g_signal_connect(page, "client_changed",
+ G_CALLBACK (page_client_changed_cb), editor);
/* Listen for when the page is mapped/unmapped so we can
install/uninstall the appropriate GtkAccelGroup. */
@@ -938,13 +970,20 @@ real_set_e_cal (CompEditor *editor, ECal *client)
}
if (priv->client) {
- gtk_signal_disconnect_by_data (GTK_OBJECT (priv->client),
- editor);
+ g_signal_handlers_disconnect_matched (G_OBJECT (priv->client),
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL,
+ editor);
g_object_unref (priv->client);
}
priv->client = client;
+ if (!priv->source_client) {
+ priv->source_client = client;
+ g_object_ref (client);
+ }
+
/* Pass the client to any pages that need it. */
for (elem = priv->pages; elem; elem = elem->next)
comp_editor_page_set_e_cal (elem->data, client);
@@ -1430,6 +1469,18 @@ page_dates_changed_cb (GtkObject *obj,
}
static void
+page_client_changed_cb (GtkObject *obj, ECal *client, gpointer data)
+{
+ CompEditor *editor = COMP_EDITOR (data);
+ CompEditorPrivate *priv;
+
+ priv = editor->priv;
+
+ priv->changed = TRUE;
+ comp_editor_set_e_cal (editor, client);
+}
+
+static void
obj_updated_cb (ECal *client, const char *uid, gpointer data)
{
CompEditor *editor = COMP_EDITOR (data);