diff options
author | Milan Crha <mcrha@redhat.com> | 2011-08-26 20:22:58 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-09-14 20:08:57 +0800 |
commit | bc03bf534a55275bd7e5de99e0c0b612d33c25d7 (patch) | |
tree | 1083d6d6d91b59d87208b175a40b890d6e36e113 /calendar/gui/dialogs/recurrence-page.c | |
parent | 1fcec870ae72635a85a9b377c5e62f4b764d5354 (diff) | |
download | gsoc2013-evolution-bc03bf534a55275bd7e5de99e0c0b612d33c25d7.tar.gz gsoc2013-evolution-bc03bf534a55275bd7e5de99e0c0b612d33c25d7.tar.zst gsoc2013-evolution-bc03bf534a55275bd7e5de99e0c0b612d33c25d7.zip |
Changing source in CompEditor blocks UI
Diffstat (limited to 'calendar/gui/dialogs/recurrence-page.c')
-rw-r--r-- | calendar/gui/dialogs/recurrence-page.c | 128 |
1 files changed, 96 insertions, 32 deletions
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index c22138f6b9..fa18e0d9f1 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -588,22 +588,15 @@ sensitize_recur_widgets (RecurrencePage *rpage) } static void -sensitize_buttons (RecurrencePage *rpage) +update_with_readonly (RecurrencePage *rpage, gboolean read_only) { RecurrencePagePrivate *priv = rpage->priv; CompEditor *editor; CompEditorFlags flags; - gboolean read_only, sensitize = TRUE; gint selected_rows; - icalcomponent *icalcomp; - ECalClient *client; - const gchar *uid; - - if (priv->comp == NULL) - return; + gboolean sensitize = TRUE; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage)); - client = comp_editor_get_client (editor); flags = comp_editor_get_flags (editor); if (flags & COMP_EDITOR_MEETING) @@ -612,39 +605,110 @@ sensitize_buttons (RecurrencePage *rpage) selected_rows = gtk_tree_selection_count_selected_rows ( gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->exception_list))); - read_only = e_client_is_readonly (E_CLIENT (client)); + if (!read_only) + sensitize_recur_widgets (rpage); + else + gtk_widget_set_sensitive (priv->params, FALSE); - if (!read_only) { - e_cal_component_get_uid (priv->comp, &uid); + gtk_widget_set_sensitive (priv->recurs, !read_only && sensitize); + gtk_widget_set_sensitive (priv->exception_add, !read_only && e_cal_component_has_recurrences (priv->comp) && sensitize); + gtk_widget_set_sensitive (priv->exception_modify, !read_only && selected_rows > 0 && sensitize); + gtk_widget_set_sensitive (priv->exception_delete, !read_only && selected_rows > 0 && sensitize); +} - if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR) && e_cal_client_get_object_sync (client, uid, NULL, &icalcomp, NULL, NULL)) { - read_only = TRUE; - icalcomponent_free (icalcomp); +static void +rpage_get_objects_for_uid_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + ECalClient *client = E_CAL_CLIENT (source_object); + RecurrencePage *rpage = user_data; + GSList *ecalcomps = NULL; + GError *error = NULL; + + if (result && !e_cal_client_get_objects_for_uid_finish (client, result, &ecalcomps, &error)) { + ecalcomps = NULL; + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + return; } + } - if (!read_only) { - GSList *list = NULL; + update_with_readonly (rpage, g_slist_length (ecalcomps) > 1); - /* see if we have detached instances */ - if (e_cal_client_get_objects_for_uid_sync (client, uid, &list, NULL, NULL)) { - if (list && g_slist_length (list) > 1) - read_only = TRUE; + g_slist_foreach (ecalcomps, (GFunc) g_object_unref, NULL); + g_slist_free (ecalcomps); +} - g_slist_foreach (list, (GFunc) g_object_unref, NULL); - g_slist_free (list); - } +static void +rpage_get_object_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) +{ + ECalClient *client = E_CAL_CLIENT (source_object); + RecurrencePage *rpage = user_data; + icalcomponent *icalcomp = NULL; + const gchar *uid = NULL; + GError *error = NULL; + + if (result && !e_cal_client_get_object_finish (client, result, &icalcomp, &error)) { + icalcomp = NULL; + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + return; } } - if (!read_only) - sensitize_recur_widgets (rpage); - else - gtk_widget_set_sensitive (priv->params, FALSE); + if (icalcomp) { + icalcomponent_free (icalcomp); + update_with_readonly (rpage, TRUE); + return; + } - gtk_widget_set_sensitive (priv->recurs, !read_only && sensitize); - gtk_widget_set_sensitive (priv->exception_add, !read_only && e_cal_component_has_recurrences (priv->comp) && sensitize); - gtk_widget_set_sensitive (priv->exception_modify, !read_only && selected_rows > 0 && sensitize); - gtk_widget_set_sensitive (priv->exception_delete, !read_only && selected_rows > 0 && sensitize); + if (rpage->priv->comp) + e_cal_component_get_uid (rpage->priv->comp, &uid); + + if (!uid || !*uid) { + update_with_readonly (rpage, FALSE); + return; + } + + /* see if we have detached instances */ + e_cal_client_get_objects_for_uid (client, uid, rpage->priv->cancellable, rpage_get_objects_for_uid_cb, rpage); +} + +static void +sensitize_buttons (RecurrencePage *rpage) +{ + RecurrencePagePrivate *priv = rpage->priv; + CompEditor *editor; + ECalClient *client; + const gchar *uid; + + if (priv->comp == NULL) + return; + + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage)); + client = comp_editor_get_client (editor); + + if (e_client_is_readonly (E_CLIENT (client))) { + update_with_readonly (rpage, TRUE); + return; + } + + if (priv->cancellable) { + g_cancellable_cancel (priv->cancellable); + g_object_unref (priv->cancellable); + } + priv->cancellable = g_cancellable_new (); + + e_cal_component_get_uid (priv->comp, &uid); + if (!uid || !*uid) { + update_with_readonly (rpage, FALSE); + return; + } + + if (e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR)) { + e_cal_client_get_object (client, uid, NULL, priv->cancellable, rpage_get_object_cb, rpage); + } else { + rpage_get_object_cb (G_OBJECT (client), NULL, rpage); + } } #if 0 |