diff options
author | Dan Winship <danw@src.gnome.org> | 2001-06-13 02:04:15 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-06-13 02:04:15 +0800 |
commit | 1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8 (patch) | |
tree | e624d3aa1d8a67817baa750c80c2502f72f59252 | |
parent | 0d6e9d6a8de480714d53636f04847944e23eee77 (diff) | |
download | gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.tar gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.tar.gz gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.tar.bz2 gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.tar.lz gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.tar.xz gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.tar.zst gsoc2013-evolution-1391cd5ced4c2c7e1caab5e0d61b02db83edcbd8.zip |
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
-rw-r--r-- | composer/ChangeLog | 22 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment-bar.c | 14 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.c | 68 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.glade | 142 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.h | 3 | ||||
-rw-r--r-- | composer/e-msg-composer-select-file.c | 58 | ||||
-rw-r--r-- | 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 <danw@ximian.com> + + * 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 <danw@ximian.com> * 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 <sys/stat.h> -#include <gtk/gtkoptionmenu.h> +#include <gtk/gtknotebook.h> +#include <gtk/gtktogglebutton.h> #include <camel/camel.h> #include <gal/widgets/e-unicode.h> #include <libgnomevfs/gnome-vfs-mime.h> @@ -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 @@ <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> - <use_widget_names>False</use_widget_names> <output_main_file>False</output_main_file> - <output_support_files>True</output_support_files> - <output_build_files>True</output_build_files> - <backup_source_files>True</backup_source_files> - <main_source_file>interface.c</main_source_file> - <main_header_file>interface.h</main_header_file> - <handler_source_file>callbacks.c</handler_source_file> - <handler_header_file>callbacks.h</handler_header_file> - <support_source_file>support.c</support_source_file> - <support_header_file>support.h</support_header_file> </project> <widget> <class>GnomeDialog</class> <name>dialog</name> - <cxx_use_heap>True</cxx_use_heap> <title>Attachment properties</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_NONE</position> @@ -41,7 +30,6 @@ <class>GtkVBox</class> <child_name>GnomeDialog:vbox</child_name> <name>dialog-vbox1</name> - <cxx_use_heap>True</cxx_use_heap> <homogeneous>False</homogeneous> <spacing>8</spacing> <child> @@ -51,9 +39,43 @@ </child> <widget> + <class>GtkHButtonBox</class> + <child_name>GnomeDialog:action_area</child_name> + <name>dialog-action_area1</name> + <layout_style>GTK_BUTTONBOX_END</layout_style> + <spacing>8</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkButton</class> + <name>ok_button</name> + <can_default>True</can_default> + <has_default>True</has_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> + </widget> + + <widget> + <class>GtkButton</class> + <name>close_button</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> + </widget> + </widget> + + <widget> <class>GtkTable</class> <name>table1</name> - <cxx_use_heap>True</cxx_use_heap> <rows>4</rows> <columns>2</columns> <homogeneous>False</homogeneous> @@ -68,7 +90,6 @@ <widget> <class>GtkEntry</class> <name>description_entry</name> - <cxx_use_heap>True</cxx_use_heap> <can_focus>True</can_focus> <editable>True</editable> <text_visible>True</text_visible> @@ -93,7 +114,6 @@ <widget> <class>GtkHBox</class> <name>hbox3</name> - <cxx_use_heap>True</cxx_use_heap> <homogeneous>False</homogeneous> <spacing>10</spacing> <child> @@ -115,7 +135,6 @@ <class>GtkEntry</class> <name>file_name_entry</name> <width>290</width> - <cxx_use_heap>True</cxx_use_heap> <can_focus>True</can_focus> <editable>True</editable> <text_visible>True</text_visible> @@ -132,7 +151,6 @@ <widget> <class>GtkEntry</class> <name>mime_type_entry</name> - <cxx_use_heap>True</cxx_use_heap> <sensitive>False</sensitive> <can_focus>True</can_focus> <editable>False</editable> @@ -157,8 +175,7 @@ <widget> <class>GtkLabel</class> - <name>label3</name> - <cxx_use_heap>True</cxx_use_heap> + <name>mime_label</name> <label>MIME type:</label> <justify>GTK_JUSTIFY_LEFT</justify> <wrap>False</wrap> @@ -184,8 +201,7 @@ <widget> <class>GtkLabel</class> - <name>label1</name> - <cxx_use_heap>True</cxx_use_heap> + <name>description_label</name> <label>Description:</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> @@ -211,8 +227,7 @@ <widget> <class>GtkLabel</class> - <name>label2</name> - <cxx_use_heap>True</cxx_use_heap> + <name>filename_label</name> <label>File name:</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> @@ -237,49 +252,20 @@ </widget> <widget> - <class>GtkLabel</class> - <name>label4</name> - <cxx_use_heap>True</cxx_use_heap> - <label>Send as:</label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>False</wrap> - <xalign>1</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <left_attach>0</left_attach> - <right_attach>1</right_attach> - <top_attach>3</top_attach> - <bottom_attach>4</bottom_attach> - <xpad>0</xpad> - <ypad>0</ypad> - <xexpand>False</xexpand> - <yexpand>False</yexpand> - <xshrink>False</xshrink> - <yshrink>False</yshrink> - <xfill>True</xfill> - <yfill>False</yfill> - </child> - </widget> - - <widget> - <class>GtkOptionMenu</class> - <name>disposition_option</name> - <cxx_use_heap>True</cxx_use_heap> + <class>GtkCheckButton</class> + <name>disposition_checkbox</name> <can_focus>True</can_focus> - <items>Attachment -Inline attachment -</items> - <initial_choice>1</initial_choice> + <label>Suggest automatic display of attachment</label> + <active>False</active> + <draw_indicator>True</draw_indicator> <child> - <left_attach>1</left_attach> + <left_attach>0</left_attach> <right_attach>2</right_attach> <top_attach>3</top_attach> <bottom_attach>4</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> - <xexpand>True</xexpand> + <xexpand>False</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> @@ -288,44 +274,6 @@ Inline attachment </child> </widget> </widget> - - <widget> - <class>GtkHButtonBox</class> - <child_name>GnomeDialog:action_area</child_name> - <name>dialog-action_area1</name> - <cxx_use_heap>True</cxx_use_heap> - <layout_style>GTK_BUTTONBOX_END</layout_style> - <spacing>8</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - <pack>GTK_PACK_END</pack> - </child> - - <widget> - <class>GtkButton</class> - <name>ok_button</name> - <cxx_use_heap>True</cxx_use_heap> - <can_default>True</can_default> - <has_default>True</has_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_OK</stock_button> - </widget> - - <widget> - <class>GtkButton</class> - <name>close_button</name> - <cxx_use_heap>True</cxx_use_heap> - <can_default>True</can_default> - <can_focus>True</can_focus> - <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button> - </widget> - </widget> </widget> </widget> 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 <gtk/gtkbox.h> +#include <gtk/gtkcheckbutton.h> #include <gtk/gtkfilesel.h> #include <gtk/gtkmain.h> #include <gtk/gtksignal.h> @@ -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 */ |