diff options
author | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-10-10 18:50:18 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-10-10 18:50:18 +0800 |
commit | 56a166bb42bd55216a489c0b850ddd6bca2a3cd5 (patch) | |
tree | 3f87cf07fd6098ab2700c56d71d97686c5e5bc71 /widgets/misc/e-attachment-store.c | |
parent | 8fd93c9042bb30e53ce88303f8a0789a6ca688eb (diff) | |
parent | 6d5db4c7cd468d424ea8628344c5a1bba6fc3d7c (diff) | |
download | gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.tar gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.tar.gz gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.tar.bz2 gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.tar.lz gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.tar.xz gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.tar.zst gsoc2013-evolution-56a166bb42bd55216a489c0b850ddd6bca2a3cd5.zip |
Merge branch 'master' into wip/gsettings
Diffstat (limited to 'widgets/misc/e-attachment-store.c')
-rw-r--r-- | widgets/misc/e-attachment-store.c | 141 |
1 files changed, 8 insertions, 133 deletions
diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c index 691fd518b8..8c808d9731 100644 --- a/widgets/misc/e-attachment-store.c +++ b/widgets/misc/e-attachment-store.c @@ -34,14 +34,12 @@ struct _EAttachmentStorePrivate { GHashTable *attachment_index; - gchar *current_folder_uri; guint ignore_row_changed : 1; }; enum { PROP_0, - PROP_CURRENT_FOLDER_URI, PROP_NUM_ATTACHMENTS, PROP_NUM_LOADING, PROP_TOTAL_SIZE @@ -53,36 +51,12 @@ G_DEFINE_TYPE ( GTK_TYPE_LIST_STORE) static void -attachment_store_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_CURRENT_FOLDER_URI: - e_attachment_store_set_current_folder_uri ( - E_ATTACHMENT_STORE (object), - g_value_get_string (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void attachment_store_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { switch (property_id) { - case PROP_CURRENT_FOLDER_URI: - g_value_set_string ( - value, - e_attachment_store_get_current_folder_uri ( - E_ATTACHMENT_STORE (object))); - return; - case PROP_NUM_ATTACHMENTS: g_value_set_uint ( value, @@ -126,28 +100,11 @@ attachment_store_finalize (GObject *object) g_hash_table_destroy (priv->attachment_index); - g_free (priv->current_folder_uri); - /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (e_attachment_store_parent_class)->finalize (object); } static void -attachment_store_constructed (GObject *object) -{ - GConfBridge *bridge; - const gchar *key; - - bridge = gconf_bridge_get (); - - key = "/apps/evolution/shell/file_chooser_folder"; - gconf_bridge_bind_property (bridge, key, object, "current-folder-uri"); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_attachment_store_parent_class)->constructed (object); -} - -static void e_attachment_store_class_init (EAttachmentStoreClass *class) { GObjectClass *object_class; @@ -155,22 +112,9 @@ e_attachment_store_class_init (EAttachmentStoreClass *class) g_type_class_add_private (class, sizeof (EAttachmentStorePrivate)); object_class = G_OBJECT_CLASS (class); - object_class->set_property = attachment_store_set_property; object_class->get_property = attachment_store_get_property; object_class->dispose = attachment_store_dispose; object_class->finalize = attachment_store_finalize; - object_class->constructed = attachment_store_constructed; - - g_object_class_install_property ( - object_class, - PROP_CURRENT_FOLDER_URI, - g_param_spec_string ( - "current-folder-uri", - "Current Folder URI", - NULL, - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, @@ -409,34 +353,6 @@ e_attachment_store_get_attachments (EAttachmentStore *store) return g_list_reverse (list); } -const gchar * -e_attachment_store_get_current_folder_uri (EAttachmentStore *store) -{ - g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL); - - return store->priv->current_folder_uri; -} - -void -e_attachment_store_set_current_folder_uri (EAttachmentStore *store, - const gchar *current_folder_uri) -{ - gchar *allocated; - - g_return_if_fail (E_IS_ATTACHMENT_STORE (store)); - - if (current_folder_uri == NULL) { - const gchar *home_dir = g_get_home_dir (); - allocated = g_filename_to_uri (home_dir, NULL, NULL); - } else - allocated = g_strdup (current_folder_uri); - - g_free (store->priv->current_folder_uri); - store->priv->current_folder_uri = allocated; - - g_object_notify (G_OBJECT (store), "current-folder-uri"); -} - guint e_attachment_store_get_num_attachments (EAttachmentStore *store) { @@ -493,41 +409,6 @@ e_attachment_store_get_total_size (EAttachmentStore *store) return total_size; } -gint -e_attachment_store_run_file_chooser_dialog (EAttachmentStore *store, - GtkWidget *dialog) -{ - GtkFileChooser *file_chooser; - gint response = GTK_RESPONSE_NONE; - const gchar *current_uri; - gboolean update_folder; - - g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), response); - g_return_val_if_fail (GTK_IS_FILE_CHOOSER_DIALOG (dialog), response); - - file_chooser = GTK_FILE_CHOOSER (dialog); - current_uri = e_attachment_store_get_current_folder_uri (store); - gtk_file_chooser_set_current_folder_uri (file_chooser, current_uri); - - response = gtk_dialog_run (GTK_DIALOG (dialog)); - - update_folder = - (response == GTK_RESPONSE_ACCEPT) || - (response == GTK_RESPONSE_OK) || - (response == GTK_RESPONSE_YES) || - (response == GTK_RESPONSE_APPLY); - - if (update_folder) { - gchar *uri; - - uri = gtk_file_chooser_get_current_folder_uri (file_chooser); - e_attachment_store_set_current_folder_uri (store, uri); - g_free (uri); - } - - return response; -} - void e_attachment_store_run_load_dialog (EAttachmentStore *store, GtkWindow *parent) @@ -560,7 +441,7 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store, gtk_file_chooser_set_extra_widget (file_chooser, option); gtk_widget_show (option); - response = e_attachment_store_run_file_chooser_dialog (store, dialog); + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response != GTK_RESPONSE_OK) goto exit; @@ -643,7 +524,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store, gtk_file_chooser_set_current_name (file_chooser, name); } - response = e_attachment_store_run_file_chooser_dialog (store, dialog); + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_OK) destination = gtk_file_chooser_get_file (file_chooser); @@ -773,10 +654,8 @@ attachment_store_get_uris_save_cb (EAttachment *attachment, if (error == NULL) g_simple_async_result_set_op_res_gpointer (simple, uris, NULL); - else { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + else + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); @@ -996,10 +875,8 @@ attachment_store_load_ready_cb (EAttachment *attachment, if (error == NULL) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + else + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); @@ -1277,21 +1154,19 @@ attachment_store_save_cb (EAttachment *attachment, save_context->error = NULL; simple = save_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); attachment_store_save_context_free (save_context); - g_error_free (error); return; } if (error != NULL) { simple = save_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); attachment_store_save_context_free (save_context); - g_error_free (error); return; } |