From 1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 12 Jun 2001 18:04:15 +0000 Subject: Replace the disposition option menu with a checkbox. * e-msg-composer-attachment.glade: Replace the disposition option menu with a checkbox. * e-msg-composer-select-file.c (e_msg_composer_select_file_attachment): New function to select a file to attach. Adds a "suggest inline disposition" checkbox. * e-msg-composer-attachment.c (e_msg_composer_attachment_new): Add a disposition argument rather than always defaulting to "attachment". (struct _DialogData, ok_cb, e_msg_composer_attachment_edit): Update for optionmenu->checkbox change for disposition. * e-msg-composer-attachment-bar.c (add_from_file): Add a disposition argument. (add_from_user): Use e_msg_composer_select_file_attachment, pass chosen disposition to add_from_file. (e_msg_composer_attachment_bar_attach): Pass "attachment" to add_from_file for the disposition. svn path=/trunk/; revision=10200 --- composer/ChangeLog | 22 +++++ composer/e-msg-composer-attachment-bar.c | 14 +-- composer/e-msg-composer-attachment.c | 68 +++++---------- composer/e-msg-composer-attachment.glade | 142 ++++++++++--------------------- composer/e-msg-composer-attachment.h | 3 +- composer/e-msg-composer-select-file.c | 58 +++++++++++-- composer/e-msg-composer-select-file.h | 3 + 7 files changed, 153 insertions(+), 157 deletions(-) diff --git a/composer/ChangeLog b/composer/ChangeLog index ae1a797b4b..f197d85d07 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,25 @@ +2001-06-12 Dan Winship + + * e-msg-composer-attachment.glade: Replace the disposition option + menu with a checkbox. + + * e-msg-composer-select-file.c + (e_msg_composer_select_file_attachment): New function to select a + file to attach. Adds a "suggest inline disposition" checkbox. + + * e-msg-composer-attachment.c (e_msg_composer_attachment_new): Add + a disposition argument rather than always defaulting to + "attachment". + (struct _DialogData, ok_cb, e_msg_composer_attachment_edit): + Update for optionmenu->checkbox change for disposition. + + * e-msg-composer-attachment-bar.c (add_from_file): Add a + disposition argument. + (add_from_user): Use e_msg_composer_select_file_attachment, pass + chosen disposition to add_from_file. + (e_msg_composer_attachment_bar_attach): Pass "attachment" to + add_from_file for the disposition. + 2001-06-11 Dan Winship * e-msg-composer.c (best_charset): Fix again... don't leave diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index b039a1f7a8..2c0f42f9ed 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -168,9 +168,10 @@ add_from_mime_part (EMsgComposerAttachmentBar *bar, static void add_from_file (EMsgComposerAttachmentBar *bar, - const gchar *file_name) + const gchar *file_name, + const gchar *disposition) { - add_common (bar, e_msg_composer_attachment_new (file_name)); + add_common (bar, e_msg_composer_attachment_new (file_name, disposition)); } static void @@ -420,12 +421,15 @@ add_from_user (EMsgComposerAttachmentBar *bar) { EMsgComposer *composer; char *file_name; + gboolean is_inline = FALSE; composer = E_MSG_COMPOSER (gtk_widget_get_toplevel (GTK_WIDGET (bar))); - file_name = e_msg_composer_select_file (composer, _("Attach a file")); + file_name = e_msg_composer_select_file_attachment (composer, &is_inline); + if (!file_name) + return; - add_from_file (bar, file_name); + add_from_file (bar, file_name, is_inline ? "inline" : "attachment"); g_free (file_name); } @@ -800,7 +804,7 @@ e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, if (file_name == NULL) add_from_user (bar); else - add_from_file (bar, file_name); + add_from_file (bar, file_name, "attachment"); } void diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 203bd7d59d..b473e48ab5 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -29,7 +29,8 @@ #include -#include +#include +#include #include #include #include @@ -140,12 +141,14 @@ e_msg_composer_attachment_get_type (void) /** * e_msg_composer_attachment_new: - * @file_name: - * - * Return value: + * @file_name: filename to attach + * @disposition: Content-Disposition of the attachment + * + * Return value: the new attachment, or %NULL on error **/ EMsgComposerAttachment * -e_msg_composer_attachment_new (const gchar *file_name) +e_msg_composer_attachment_new (const gchar *file_name, + const gchar *disposition) { EMsgComposerAttachment *new; CamelMimePart *part; @@ -181,7 +184,7 @@ e_msg_composer_attachment_new (const gchar *file_name) camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper); camel_object_unref (CAMEL_OBJECT (wrapper)); - camel_mime_part_set_disposition (part, "attachment"); + camel_mime_part_set_disposition (part, disposition); if (strchr (file_name, '/')) camel_mime_part_set_filename (part, strrchr (file_name, '/') + 1); else @@ -233,7 +236,7 @@ struct _DialogData { GtkEntry *file_name_entry; GtkEntry *description_entry; GtkEntry *mime_type_entry; - GtkOptionMenu *disposition_option; + GtkToggleButton *disposition_checkbox; EMsgComposerAttachment *attachment; }; typedef struct _DialogData DialogData; @@ -312,27 +315,6 @@ close_cb (GtkWidget *widget, destroy_dialog_data (dialog_data); } -/* Why was this never part of GTK? */ -static int -option_menu_get_history (GtkOptionMenu *menu) -{ - GtkWidget *active; - - g_return_val_if_fail (menu != NULL, -1); - g_return_val_if_fail (GTK_IS_OPTION_MENU (menu), -1); - - if (menu->menu) { - active = gtk_menu_get_active (GTK_MENU (menu->menu)); - - if (active) - return g_list_index (GTK_MENU_SHELL (menu->menu)->children, - active); - else - return -1; - } else - return -1; -} - static void ok_cb (GtkWidget *widget, gpointer data) @@ -340,7 +322,6 @@ ok_cb (GtkWidget *widget, DialogData *dialog_data; EMsgComposerAttachment *attachment; gchar *str; - int option; dialog_data = (DialogData *) data; attachment = dialog_data->attachment; @@ -360,8 +341,7 @@ ok_cb (GtkWidget *widget, camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body)), str); g_free (str); - option = option_menu_get_history (dialog_data->disposition_option); - switch (option) { + switch (gtk_toggle_button_get_active (dialog_data->disposition_checkbox)) { case 0: camel_mime_part_set_disposition (attachment->body, "attachment"); break; @@ -424,18 +404,14 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, dialog_data = g_new (DialogData, 1); dialog_data->attachment = attachment; dialog_data->dialog = glade_xml_get_widget (editor_gui, "dialog"); - dialog_data->file_name_entry = GTK_ENTRY (glade_xml_get_widget - (editor_gui, - "file_name_entry")); - dialog_data->description_entry = GTK_ENTRY (glade_xml_get_widget - (editor_gui, - "description_entry")); - dialog_data->mime_type_entry = GTK_ENTRY (glade_xml_get_widget - (editor_gui, - "mime_type_entry")); - dialog_data->disposition_option = GTK_OPTION_MENU (glade_xml_get_widget - (editor_gui, - "disposition_option")); + dialog_data->file_name_entry = GTK_ENTRY ( + glade_xml_get_widget (editor_gui, "file_name_entry")); + dialog_data->description_entry = GTK_ENTRY ( + glade_xml_get_widget (editor_gui, "description_entry")); + dialog_data->mime_type_entry = GTK_ENTRY ( + glade_xml_get_widget (editor_gui, "mime_type_entry")); + dialog_data->disposition_checkbox = GTK_TOGGLE_BUTTON ( + glade_xml_get_widget (editor_gui, "disposition_checkbox")); if (attachment != NULL) { CamelContentType *content_type; @@ -452,10 +428,8 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, g_free (type); disposition = camel_mime_part_get_disposition (attachment->body); - if (disposition && !g_strcasecmp (disposition, "inline")) - gtk_option_menu_set_history (dialog_data->disposition_option, 1); - else - gtk_option_menu_set_history (dialog_data->disposition_option, 0); + gtk_toggle_button_set_active (dialog_data->disposition_checkbox, + disposition && !g_strcasecmp (disposition, "inline")); } connect_widget (editor_gui, "ok_button", "clicked", ok_cb, dialog_data); diff --git a/composer/e-msg-composer-attachment.glade b/composer/e-msg-composer-attachment.glade index 4679a0d8e0..5b585e2d5c 100644 --- a/composer/e-msg-composer-attachment.glade +++ b/composer/e-msg-composer-attachment.glade @@ -10,23 +10,12 @@ C True True - False False - True - True - True - interface.c - interface.h - callbacks.c - callbacks.h - support.c - support.h GnomeDialog dialog - True Attachment properties GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -41,7 +30,6 @@ GtkVBox GnomeDialog:vbox dialog-vbox1 - True False 8 @@ -50,10 +38,44 @@ True + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + ok_button + True + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + close_button + True + True + GNOME_STOCK_BUTTON_CANCEL + + + GtkTable table1 - True 4 2 False @@ -68,7 +90,6 @@ GtkEntry description_entry - True True True True @@ -93,7 +114,6 @@ GtkHBox hbox3 - True False 10 @@ -115,7 +135,6 @@ GtkEntry file_name_entry 290 - True True True True @@ -132,7 +151,6 @@ GtkEntry mime_type_entry - True False True False @@ -157,8 +175,7 @@ GtkLabel - label3 - True + mime_label GTK_JUSTIFY_LEFT False @@ -184,8 +201,7 @@ GtkLabel - label1 - True + description_label GTK_JUSTIFY_CENTER False @@ -211,8 +227,7 @@ GtkLabel - label2 - True + filename_label GTK_JUSTIFY_CENTER False @@ -237,49 +252,20 @@ - GtkLabel - label4 - True - - GTK_JUSTIFY_LEFT - False - 1 - 0.5 - 0 - 0 - - 0 - 1 - 3 - 4 - 0 - 0 - False - False - False - False - True - False - - - - - GtkOptionMenu - disposition_option - True + GtkCheckButton + disposition_checkbox True - Attachment -Inline attachment - - 1 + + False + True - 1 + 0 2 3 4 0 0 - True + False False False False @@ -288,44 +274,6 @@ Inline attachment - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - True - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - ok_button - True - True - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - close_button - True - True - True - GNOME_STOCK_BUTTON_CLOSE - - diff --git a/composer/e-msg-composer-attachment.h b/composer/e-msg-composer-attachment.h index 7be3c9d595..381f347380 100644 --- a/composer/e-msg-composer-attachment.h +++ b/composer/e-msg-composer-attachment.h @@ -62,7 +62,8 @@ struct _EMsgComposerAttachmentClass { GtkType e_msg_composer_attachment_get_type (void); -EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name); +EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name, + const gchar *disposition); EMsgComposerAttachment *e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part); void e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, GtkWidget *parent); diff --git a/composer/e-msg-composer-select-file.c b/composer/e-msg-composer-select-file.c index c575a6d4ad..338b96aaa4 100644 --- a/composer/e-msg-composer-select-file.c +++ b/composer/e-msg-composer-select-file.c @@ -21,6 +21,8 @@ * Author: Ettore Perazzoli */ +#include +#include #include #include #include @@ -29,6 +31,7 @@ struct _FileSelectionInfo { GtkWidget *widget; + GtkToggleButton *inline_checkbox; char *selected_file; }; typedef struct _FileSelectionInfo FileSelectionInfo; @@ -103,11 +106,13 @@ create_file_selection (EMsgComposer *composer) GtkWidget *widget; GtkWidget *ok_button; GtkWidget *cancel_button; + GtkWidget *inline_checkbox; + GtkWidget *box; char *path; info = g_new (FileSelectionInfo, 1); - widget = gtk_file_selection_new (NULL); + widget = gtk_file_selection_new (NULL); path = g_strdup_printf ("%s/", g_get_home_dir ()); gtk_file_selection_set_filename (GTK_FILE_SELECTION (widget), path); g_free (path); @@ -123,8 +128,13 @@ create_file_selection (EMsgComposer *composer) gtk_signal_connect (GTK_OBJECT (widget), "delete_event", GTK_SIGNAL_FUNC (delete_event_cb), info); - info->widget = widget; - info->selected_file = NULL; + inline_checkbox = gtk_check_button_new_with_label (_("Suggest automatic display of attachment")); + box = gtk_widget_get_ancestor (GTK_FILE_SELECTION (widget)->selection_entry, GTK_TYPE_BOX); + gtk_box_pack_end (GTK_BOX (box), inline_checkbox, FALSE, FALSE, 4); + + info->widget = widget; + info->selected_file = NULL; + info->inline_checkbox = GTK_TOGGLE_BUTTON (inline_checkbox); return info; } @@ -141,14 +151,14 @@ file_selection_info_destroy_notify (void *data) } -char * -e_msg_composer_select_file (EMsgComposer *composer, - const char *title) +static char * +select_file_internal (EMsgComposer *composer, + const char *title, + gboolean *inline_p) { FileSelectionInfo *info; char *retval; - g_return_val_if_fail (composer != NULL, NULL); g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); info = gtk_object_get_data (GTK_OBJECT (composer), @@ -165,6 +175,10 @@ e_msg_composer_select_file (EMsgComposer *composer, return NULL; /* Busy! */ gtk_window_set_title (GTK_WINDOW (info->widget), title); + if (inline_p) + gtk_widget_show (GTK_WIDGET (info->inline_checkbox)); + else + gtk_widget_hide (GTK_WIDGET (info->inline_checkbox)); gtk_widget_show (info->widget); GDK_THREADS_ENTER(); @@ -174,5 +188,35 @@ e_msg_composer_select_file (EMsgComposer *composer, retval = info->selected_file; info->selected_file = NULL; + if (inline_p) { + *inline_p = gtk_toggle_button_get_active (info->inline_checkbox); + gtk_toggle_button_set_active (info->inline_checkbox, FALSE); + } + return retval; } + +/** + * e_msg_composer_select_file: + * @composer: a composer + * @title: the title for the file selection dialog box + * + * This pops up a file selection dialog box with the given title + * and allows the user to select a file. + * + * Return value: the selected filename, or %NULL if the user + * cancelled. + **/ +char * +e_msg_composer_select_file (EMsgComposer *composer, + const char *title) +{ + return select_file_internal (composer, title, NULL); +} + +char * +e_msg_composer_select_file_attachment (EMsgComposer *composer, + gboolean *inline_p) +{ + return select_file_internal (composer, _("Attach a file"), inline_p); +} diff --git a/composer/e-msg-composer-select-file.h b/composer/e-msg-composer-select-file.h index 2f89bd58b4..316426b40b 100644 --- a/composer/e-msg-composer-select-file.h +++ b/composer/e-msg-composer-select-file.h @@ -29,4 +29,7 @@ char *e_msg_composer_select_file (EMsgComposer *composer, const char *title); +char *e_msg_composer_select_file_attachment (EMsgComposer *composer, + gboolean *inline_p); + #endif /* E_MSG_COMPOSER_SELECT_FILE_H */ -- cgit v1.2.3