diff options
Diffstat (limited to 'calendar/gui/e-memo-list-selector.c')
-rw-r--r-- | calendar/gui/e-memo-list-selector.c | 168 |
1 files changed, 90 insertions, 78 deletions
diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c index a1cc8a7e30..8952a67258 100644 --- a/calendar/gui/e-memo-list-selector.c +++ b/calendar/gui/e-memo-list-selector.c @@ -49,27 +49,31 @@ static gboolean memo_list_selector_update_single_object (ECalClient *client, icalcomponent *icalcomp) { - gchar *uid = NULL; - icalcomponent *tmp_icalcomp; + gchar *uid; + icalcomponent *tmp_icalcomp = NULL; + gboolean success; uid = (gchar *) icalcomponent_get_uid (icalcomp); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) { + e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, NULL); + + if (tmp_icalcomp != NULL) { icalcomponent_free (tmp_icalcomp); return e_cal_client_modify_object_sync ( client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL); } - if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL)) - return FALSE; + success = e_cal_client_create_object_sync ( + client, icalcomp, &uid, NULL, NULL); - if (uid) + if (uid != NULL) { icalcomponent_set_uid (icalcomp, uid); + g_free (uid); + } - g_free (uid); - - return TRUE; + return success; } static gboolean @@ -184,13 +188,23 @@ memo_list_selector_process_data (ESourceSelector *selector, if (old_uid == NULL) old_uid = g_strdup (uid); - if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, &error)) { + success = e_cal_client_get_object_sync ( + client, uid, NULL, &tmp_icalcomp, NULL, &error); + + /* Sanity check. */ + g_return_val_if_fail ( + (success && (error == NULL)) || + (!success && (error != NULL)), FALSE); + + if (success) { icalcomponent_free (tmp_icalcomp); - success = TRUE; goto exit; } - if (error != NULL && !g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) { + if (g_error_matches (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) + g_clear_error (&error); + + if (error != NULL) { g_message ( "Failed to search the object in destination " "task list: %s", error->message); @@ -198,9 +212,6 @@ memo_list_selector_process_data (ESourceSelector *selector, goto exit; } - if (error) - g_error_free (error); - success = memo_list_selector_update_objects (client, icalcomp); if (!success || action != GDK_ACTION_MOVE) @@ -222,8 +233,7 @@ exit: return success; } -struct DropData -{ +struct DropData { ESourceSelector *selector; GdkDragAction action; GSList *list; @@ -290,71 +300,24 @@ exit: } static void -memo_list_selector_constructed (GObject *object) -{ - ESourceSelector *selector; - ESourceRegistry *registry; - ESource *source; - - selector = E_SOURCE_SELECTOR (object); - registry = e_source_selector_get_registry (selector); - source = e_source_registry_ref_default_memo_list (registry); - e_source_selector_set_primary_selection (selector, source); - g_object_unref (source); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_memo_list_selector_parent_class)-> - constructed (object); -} - -static gboolean -memo_list_selector_data_dropped (ESourceSelector *selector, - GtkSelectionData *selection_data, - ESource *destination, - GdkDragAction action, - guint info) -{ - struct DropData *dd; - - dd = g_new0 (struct DropData, 1); - dd->selector = g_object_ref (selector); - dd->action = action; - dd->list = cal_comp_selection_get_string_list (selection_data); - - e_client_selector_get_client ( - E_CLIENT_SELECTOR (selector), destination, NULL, - client_connect_for_drop_cb, dd); - - return TRUE; -} - -EShellView * -e_memo_list_selector_get_shell_view (EMemoListSelector *memo_list_selector) -{ - g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (memo_list_selector), NULL); - - return memo_list_selector->priv->shell_view; -} - -static void -e_memo_list_selector_set_shell_view (EMemoListSelector *memo_list_selector, - EShellView *shell_view) +memo_list_selector_set_shell_view (EMemoListSelector *selector, + EShellView *shell_view) { g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_return_if_fail (memo_list_selector->priv->shell_view == NULL); + g_return_if_fail (selector->priv->shell_view == NULL); - memo_list_selector->priv->shell_view = g_object_ref (shell_view); + selector->priv->shell_view = g_object_ref (shell_view); } static void memo_list_selector_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_SHELL_VIEW: - e_memo_list_selector_set_shell_view ( + memo_list_selector_set_shell_view ( E_MEMO_LIST_SELECTOR (object), g_value_get_object (value)); return; @@ -365,15 +328,16 @@ memo_list_selector_set_property (GObject *object, static void memo_list_selector_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { switch (property_id) { case PROP_SHELL_VIEW: g_value_set_object ( value, - e_memo_list_selector_get_shell_view (E_MEMO_LIST_SELECTOR (object))); + e_memo_list_selector_get_shell_view ( + E_MEMO_LIST_SELECTOR (object))); return; } @@ -389,11 +353,50 @@ memo_list_selector_dispose (GObject *object) g_clear_object (&priv->shell_view); - /* Chain up to the parent' s dispose() method. */ + /* Chain up to the parent's dispose() method. */ G_OBJECT_CLASS (e_memo_list_selector_parent_class)->dispose (object); } static void +memo_list_selector_constructed (GObject *object) +{ + ESourceSelector *selector; + ESourceRegistry *registry; + ESource *source; + + selector = E_SOURCE_SELECTOR (object); + registry = e_source_selector_get_registry (selector); + source = e_source_registry_ref_default_memo_list (registry); + e_source_selector_set_primary_selection (selector, source); + g_object_unref (source); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (e_memo_list_selector_parent_class)-> + constructed (object); +} + +static gboolean +memo_list_selector_data_dropped (ESourceSelector *selector, + GtkSelectionData *selection_data, + ESource *destination, + GdkDragAction action, + guint info) +{ + struct DropData *dd; + + dd = g_new0 (struct DropData, 1); + dd->selector = g_object_ref (selector); + dd->action = action; + dd->list = cal_comp_selection_get_string_list (selection_data); + + e_client_selector_get_client ( + E_CLIENT_SELECTOR (selector), destination, NULL, + client_connect_for_drop_cb, dd); + + return TRUE; +} + +static void e_memo_list_selector_class_init (EMemoListSelectorClass *class) { GObjectClass *object_class; @@ -437,7 +440,7 @@ e_memo_list_selector_init (EMemoListSelector *selector) GtkWidget * e_memo_list_selector_new (EClientCache *client_cache, - EShellView *shell_view) + EShellView *shell_view) { ESourceRegistry *registry; GtkWidget *widget; @@ -458,3 +461,12 @@ e_memo_list_selector_new (EClientCache *client_cache, return widget; } + +EShellView * +e_memo_list_selector_get_shell_view (EMemoListSelector *selector) +{ + g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (selector), NULL); + + return selector->priv->shell_view; +} + |