aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2013-08-29 17:00:26 +0800
committerLAN-TW <lantw44@gmail.com>2013-08-29 17:00:26 +0800
commit85a2b3484e59f1f44464a2d5101f34cd32b866fa (patch)
tree3ee5b66e12fdb21d4989b4e331201e1cc8e008f9
parent779200f4c5c50e6a64841c77db98e721a638652d (diff)
downloadgsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.tar
gsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.tar.gz
gsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.tar.bz2
gsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.tar.lz
gsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.tar.xz
gsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.tar.zst
gsoc2013-evolution-85a2b3484e59f1f44464a2d5101f34cd32b866fa.zip
Add widgets and object data to support archive creation
-rw-r--r--e-util/e-attachment-store.c66
1 files changed, 57 insertions, 9 deletions
diff --git a/e-util/e-attachment-store.c b/e-util/e-attachment-store.c
index a0794d9e04..7b4f8c902a 100644
--- a/e-util/e-attachment-store.c
+++ b/e-util/e-attachment-store.c
@@ -444,32 +444,49 @@ update_preview_cb (GtkFileChooser *file_chooser,
g_object_unref (pixbuf);
}
+#define LOAD_RESPONSE_ATTACH 1
+
void
e_attachment_store_run_load_dialog (EAttachmentStore *store,
GtkWindow *parent)
{
GtkFileChooser *file_chooser;
GtkWidget *dialog;
- GtkWidget *option;
+
+ GtkBox *extra_box;
+ GtkWidget *extra_box_widget;
+ GtkWidget *option_display;
+
+ GtkBox *option_format_box;
+ GtkWidget *option_format_box_widget;
+ GtkWidget *option_format_label;
+ GtkWidget *option_format_combo;
+
GtkImage *preview;
+
GSList *files, *iter;
const gchar *disposition;
gboolean active;
gint response;
+ GSettings *settings;
+ AutoarPref *arpref;
+ int format, filter;
+
g_return_if_fail (E_IS_ATTACHMENT_STORE (store));
g_return_if_fail (GTK_IS_WINDOW (parent));
dialog = gtk_file_chooser_dialog_new (
_("Add Attachment"), parent,
GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("A_ttach"), GTK_RESPONSE_OK, NULL);
+ _("_Open"), GTK_RESPONSE_OK,
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("A_ttach"), LOAD_RESPONSE_ATTACH, NULL);
file_chooser = GTK_FILE_CHOOSER (dialog);
gtk_file_chooser_set_local_only (file_chooser, FALSE);
gtk_file_chooser_set_select_multiple (file_chooser, TRUE);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), LOAD_RESPONSE_ATTACH);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "mail-attachment");
preview = GTK_IMAGE (gtk_image_new ());
@@ -480,20 +497,44 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
file_chooser, "update-preview",
G_CALLBACK (update_preview_cb), preview);
- option = gtk_check_button_new_with_mnemonic (
+ extra_box_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ extra_box = GTK_BOX (extra_box_widget);
+
+ option_display = gtk_check_button_new_with_mnemonic (
_("_Suggest automatic display of attachment"));
- gtk_file_chooser_set_extra_widget (file_chooser, option);
- gtk_widget_show (option);
+ gtk_box_pack_start (extra_box, option_display, FALSE, FALSE, 0);
+
+ option_format_box_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ option_format_box = GTK_BOX (option_format_box_widget);
+ gtk_box_pack_start (extra_box, option_format_box_widget, FALSE, FALSE, 0);
+
+ settings = g_settings_new (AUTOAR_PREF_DEFAULT_GSCHEMA_ID);
+ arpref = autoar_pref_new_with_gsettings (settings);
+
+ option_format_label = gtk_label_new (
+ _("Archive selected directories using this format: "));
+ option_format_combo = autoar_gtk_format_filter_simple_new (
+ autoar_pref_get_default_format (arpref),
+ autoar_pref_get_default_filter (arpref));
+ gtk_box_pack_start (option_format_box, option_format_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (option_format_box, option_format_combo, FALSE, FALSE, 0);
+
+ gtk_file_chooser_set_extra_widget (file_chooser, extra_box_widget);
+ gtk_widget_show_all (extra_box_widget);
response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response != GTK_RESPONSE_OK)
+ if (response != GTK_RESPONSE_OK && response != LOAD_RESPONSE_ATTACH)
goto exit;
files = gtk_file_chooser_get_files (file_chooser);
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (option));
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (option_display));
disposition = active ? "inline" : "attachment";
+ autoar_gtk_format_filter_simple_get (option_format_combo, &format, &filter);
+ autoar_pref_set_default_format (arpref, format);
+ autoar_pref_set_default_filter (arpref, filter);
+
for (iter = files; iter != NULL; iter = g_slist_next (iter)) {
EAttachment *attachment;
GFile *file = iter->data;
@@ -502,6 +543,10 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
e_attachment_set_file (attachment, file);
e_attachment_set_disposition (attachment, disposition);
e_attachment_store_add_attachment (store, attachment);
+
+ g_object_set_data_full (G_OBJECT (attachment),
+ "autoar-pref", g_object_ref (arpref), g_object_unref);
+
e_attachment_load_async (
attachment, (GAsyncReadyCallback)
e_attachment_load_handle_error, parent);
@@ -513,6 +558,9 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store,
exit:
gtk_widget_destroy (dialog);
+ g_object_unref (settings);
+ g_object_unref (arpref);
+
}
GFile *