diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-12-14 04:14:26 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-12-14 04:14:26 +0800 |
commit | d103ae62e11c1180f665e242dc0fac1fa0d0f016 (patch) | |
tree | 82cacf4de1735708bad7e120f009c56dce209a73 | |
parent | fe2f7a99bb470fd7136e8f8fa5a82c5cefdfaf7a (diff) | |
download | gsoc2013-evolution-d103ae62e11c1180f665e242dc0fac1fa0d0f016.tar.gz gsoc2013-evolution-d103ae62e11c1180f665e242dc0fac1fa0d0f016.tar.zst gsoc2013-evolution-d103ae62e11c1180f665e242dc0fac1fa0d0f016.zip |
Attach to the parent widget's destroy signal - when that gets destroyed,
001-12-11 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment.c (e_msg_composer_attachment_edit):
Attach to the parent widget's destroy signal - when that gets
destroyed, we need to cancel the editor dialog too. Also connect
to our parent window's "hide" signal so that when the composer
gets hidden (ie, it's being sent), we also close the dialogs.
* e-msg-composer.c (init): Default composer->enable_autosave to
TRUE.
svn path=/trunk/; revision=15016
-rw-r--r-- | composer/ChangeLog | 16 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment-bar.c | 139 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.c | 57 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 18 |
4 files changed, 127 insertions, 103 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 577eb84dc6..a3aeabc391 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,5 +1,16 @@ 2001-12-11 Jeffrey Stedfast <fejj@ximian.com> + * e-msg-composer-attachment.c (e_msg_composer_attachment_edit): + Attach to the parent widget's destroy signal - when that gets + destroyed, we need to cancel the editor dialog too. Also connect + to our parent window's "hide" signal so that when the composer + gets hidden (ie, it's being sent), we also close the dialogs. + + * e-msg-composer.c (init): Default composer->enable_autosave to + TRUE. + +2001-12-11 Jeffrey Stedfast <fejj@ximian.com> + * e-msg-composer-select-file.c (confirm): If multiple-selection is enabled but nothing is slected, fall back to using the filename in the entry box as the "selected" file. @@ -52,6 +63,11 @@ * e-msg-composer.c (drag_data_received): Allow drag & drop for vcards. +2001-11-30 Jeffrey Stedfast <fejj@ximian.com> + + * e-msg-composer.c (setup_ui): Change the FileSend tooltip the be + the same as the FileSendLater tooltip if we are in offline mode. + 2001-11-14 Larry Ewing <lewing@ximian.com> * e-msg-composer.c (create_composer): popup failure dialog if we diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index 16c68bf910..59e872d64c 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -91,11 +91,11 @@ static gchar * size_to_string (gulong size) { gchar *size_string; - + /* FIXME: The following should probably go into a separate module, as we might have to do the same thing in other places as well. Also, I am not sure this will be OK for all the languages. */ - + if (size < 1e3L) { if (size == 1) size_string = g_strdup (_("1 byte")); @@ -104,7 +104,7 @@ size_to_string (gulong size) (guint) size); } else { gdouble displayed_size; - + if (size < 1e6L) { displayed_size = (gdouble) size / 1.0e3; size_string = g_strdup_printf (_("%.1fK"), @@ -119,7 +119,7 @@ size_to_string (gulong size) displayed_size); } } - + return size_string; } @@ -130,11 +130,13 @@ free_attachment_list (EMsgComposerAttachmentBar *bar) { EMsgComposerAttachmentBarPrivate *priv; GList *p; - + priv = bar->priv; - + for (p = priv->attachments; p != NULL; p = p->next) gtk_object_unref (GTK_OBJECT (p->data)); + + priv->attachments = NULL; } static void @@ -203,9 +205,9 @@ remove_attachment (EMsgComposerAttachmentBar *bar, bar->priv->attachments = g_list_remove (bar->priv->attachments, attachment); bar->priv->num_attachments--; - + gtk_object_unref (GTK_OBJECT (attachment)); - + gtk_signal_emit (GTK_OBJECT (bar), signals[CHANGED]); } @@ -218,7 +220,7 @@ pixbuf_for_mime_type (const char *mime_type) const char *icon_name; char *filename = NULL; GdkPixbuf *pixbuf; - + icon_name = gnome_vfs_mime_get_value (mime_type, "icon-filename"); if (icon_name) { if (*icon_name == '/') { @@ -256,14 +258,14 @@ update (EMsgComposerAttachmentBar *bar) EMsgComposerAttachmentBarPrivate *priv; EIconList *icon_list; GList *p; - + priv = bar->priv; icon_list = E_ICON_LIST (bar); - + e_icon_list_freeze (icon_list); - + e_icon_list_clear (icon_list); - + /* FIXME could be faster, but we don't care. */ for (p = priv->attachments; p != NULL; p = p->next) { EMsgComposerAttachment *attachment; @@ -382,7 +384,7 @@ update (EMsgComposerAttachmentBar *bar) g_free (desc); g_free (label); } - + e_icon_list_thaw (icon_list); } @@ -394,13 +396,13 @@ remove_selected (EMsgComposerAttachmentBar *bar) GList *attachment_list; GList *p; gint num; - + icon_list = E_ICON_LIST (bar); - + /* Weee! I am especially proud of this piece of cheesy code: it is truly awful. But unless one attaches a huge number of files, it will not be as greedy as intended. FIXME of course. */ - + attachment_list = NULL; p = e_icon_list_get_selection (icon_list); for (; p != NULL; p = p->next) { @@ -409,12 +411,12 @@ remove_selected (EMsgComposerAttachmentBar *bar) (g_list_nth (bar->priv->attachments, num)->data); attachment_list = g_list_prepend (attachment_list, attachment); } - + for (p = attachment_list; p != NULL; p = p->next) remove_attachment (bar, E_MSG_COMPOSER_ATTACHMENT (p->data)); - + g_list_free (attachment_list); - + update (bar); } @@ -425,13 +427,13 @@ edit_selected (EMsgComposerAttachmentBar *bar) EMsgComposerAttachment *attachment; GList *selection; gint num; - + icon_list = E_ICON_LIST (bar); - + selection = e_icon_list_get_selection (icon_list); num = GPOINTER_TO_INT (selection->data); attachment = g_list_nth (bar->priv->attachments, num)->data; - + e_msg_composer_attachment_edit (attachment, GTK_WIDGET (bar)); } @@ -468,7 +470,7 @@ add_cb (GtkWidget *widget, gpointer data) { g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (data)); - + add_from_user (E_MSG_COMPOSER_ATTACHMENT_BAR (data)); } @@ -477,9 +479,9 @@ properties_cb (GtkWidget *widget, gpointer data) { EMsgComposerAttachmentBar *bar; - + g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (data)); - + bar = E_MSG_COMPOSER_ATTACHMENT_BAR (data); edit_selected (data); } @@ -489,9 +491,9 @@ remove_cb (GtkWidget *widget, gpointer data) { EMsgComposerAttachmentBar *bar; - + g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (data)); - + bar = E_MSG_COMPOSER_ATTACHMENT_BAR (data); remove_selected (bar); } @@ -511,12 +513,12 @@ static GtkWidget * get_icon_context_menu (EMsgComposerAttachmentBar *bar) { EMsgComposerAttachmentBarPrivate *priv; - + priv = bar->priv; if (priv->icon_context_menu == NULL) priv->icon_context_menu = gnome_popup_menu_new (icon_context_menu_info); - + return priv->icon_context_menu; } @@ -526,7 +528,7 @@ popup_icon_context_menu (EMsgComposerAttachmentBar *bar, GdkEventButton *event) { GtkWidget *menu; - + menu = get_icon_context_menu (bar); gnome_popup_menu_do_popup (menu, NULL, NULL, event, bar); } @@ -542,11 +544,11 @@ static GtkWidget * get_context_menu (EMsgComposerAttachmentBar *bar) { EMsgComposerAttachmentBarPrivate *priv; - + priv = bar->priv; if (priv->context_menu == NULL) priv->context_menu = gnome_popup_menu_new (context_menu_info); - + return priv->context_menu; } @@ -555,7 +557,7 @@ popup_context_menu (EMsgComposerAttachmentBar *bar, GdkEventButton *event) { GtkWidget *menu; - + menu = get_context_menu (bar); gnome_popup_menu_do_popup (menu, NULL, NULL, event, bar); } @@ -567,11 +569,11 @@ static void destroy (GtkObject *object) { EMsgComposerAttachmentBar *bar; - + bar = E_MSG_COMPOSER_ATTACHMENT_BAR (object); - + free_attachment_list (bar); - + if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -586,24 +588,23 @@ button_press_event (GtkWidget *widget, EMsgComposerAttachmentBar *bar; EIconList *icon_list; gint icon_number; - + bar = E_MSG_COMPOSER_ATTACHMENT_BAR (widget); icon_list = E_ICON_LIST (widget); - + if (event->button != 3) return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); - - icon_number = e_icon_list_get_icon_at (icon_list, - event->x, event->y); - + + icon_number = e_icon_list_get_icon_at (icon_list, event->x, event->y); + if (icon_number >= 0) { e_icon_list_select_icon (icon_list, icon_number); popup_icon_context_menu (bar, icon_number, event); } else { popup_context_menu (bar, event); } - + return TRUE; } @@ -616,19 +617,19 @@ class_init (EMsgComposerAttachmentBarClass *class) GtkObjectClass *object_class; GtkWidgetClass *widget_class; EIconListClass *icon_list_class; - + object_class = GTK_OBJECT_CLASS (class); widget_class = GTK_WIDGET_CLASS (class); icon_list_class = E_ICON_LIST_CLASS (class); - + parent_class = gtk_type_class (e_icon_list_get_type ()); - + object_class->destroy = destroy; - + widget_class->button_press_event = button_press_event; - + /* Setup signals. */ - + signals[CHANGED] = gtk_signal_new ("changed", GTK_RUN_LAST, @@ -637,7 +638,7 @@ class_init (EMsgComposerAttachmentBarClass *class) changed), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); - + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } @@ -647,21 +648,21 @@ init (EMsgComposerAttachmentBar *bar) EMsgComposerAttachmentBarPrivate *priv; guint icon_size, icon_height; GdkFont *font; - + priv = g_new (EMsgComposerAttachmentBarPrivate, 1); - + priv->attachments = NULL; priv->context_menu = NULL; priv->icon_context_menu = NULL; - + priv->num_attachments = 0; - + bar->priv = priv; - + /* FIXME partly hardcoded. We should compute height from the font, and allow at least 2 lines for every item. */ icon_size = ICON_WIDTH + ICON_SPACING + ICON_BORDER + ICON_TEXT_SPACING; - + font = GTK_WIDGET (bar)->style->font; icon_height = icon_size + ((font->ascent + font->descent) * 2); icon_size += 24; @@ -674,7 +675,7 @@ GtkType e_msg_composer_attachment_bar_get_type (void) { static GtkType type = 0; - + if (type == 0) { static const GtkTypeInfo info = { "EMsgComposerAttachmentBar", @@ -686,10 +687,10 @@ e_msg_composer_attachment_bar_get_type (void) /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; - + type = gtk_type_unique (e_icon_list_get_type (), &info); } - + return type; } @@ -698,25 +699,25 @@ e_msg_composer_attachment_bar_new (GtkAdjustment *adj) { EMsgComposerAttachmentBar *new; EIconList *icon_list; - + gdk_rgb_init (); gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); new = gtk_type_new (e_msg_composer_attachment_bar_get_type ()); gtk_widget_pop_visual (); gtk_widget_pop_colormap (); - + icon_list = E_ICON_LIST (new); - + e_icon_list_construct (icon_list, ICON_WIDTH, 0); - + e_icon_list_set_separators (icon_list, ICON_SEPARATORS); e_icon_list_set_row_spacing (icon_list, ICON_ROW_SPACING); e_icon_list_set_col_spacing (icon_list, ICON_COL_SPACING); e_icon_list_set_icon_border (icon_list, ICON_BORDER); e_icon_list_set_text_spacing (icon_list, ICON_TEXT_SPACING); e_icon_list_set_selection_mode (icon_list, GTK_SELECTION_MULTIPLE); - + return GTK_WIDGET (new); } @@ -773,7 +774,7 @@ e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, { EMsgComposerAttachmentBarPrivate *priv; GList *p; - + g_return_if_fail (bar != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); g_return_if_fail (multipart != NULL); @@ -795,7 +796,7 @@ e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *ba { g_return_val_if_fail (bar != NULL, 0); g_return_val_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar), 0); - + return bar->priv->num_attachments; } @@ -805,7 +806,7 @@ e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name) { g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); - + if (file_name == NULL) add_from_user (bar); else @@ -817,6 +818,6 @@ e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar, CamelMimePart *part) { g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); - + add_from_mime_part (bar, part); } diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 8304fb445f..046ab1bfdd 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* e-msg-composer-attachment.c * - * Copyright (C) 1999 Ximian, Inc. + * Copyright (C) 1999,2001 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -185,6 +185,7 @@ e_msg_composer_attachment_new (const char *file_name, file_name, g_strerror (errno)); return NULL; } + wrapper = camel_data_wrapper_new (); camel_data_wrapper_construct_from_stream (wrapper, stream); camel_object_unref (CAMEL_OBJECT (stream)); @@ -323,49 +324,47 @@ connect_widget (GladeXML *gui, } static void -close_cb (GtkWidget *widget, - gpointer data) +close_cb (GtkWidget *widget, gpointer data) { EMsgComposerAttachment *attachment; DialogData *dialog_data; - + dialog_data = (DialogData *) data; attachment = dialog_data->attachment; - + gtk_widget_destroy (glade_xml_get_widget (attachment->editor_gui, "dialog")); gtk_object_unref (GTK_OBJECT (attachment->editor_gui)); attachment->editor_gui = NULL; - + destroy_dialog_data (dialog_data); } static void -ok_cb (GtkWidget *widget, - gpointer data) +ok_cb (GtkWidget *widget, gpointer data) { DialogData *dialog_data; EMsgComposerAttachment *attachment; - gchar *str; + char *str; dialog_data = (DialogData *) data; attachment = dialog_data->attachment; - + str = e_utf8_gtk_entry_get_text (dialog_data->file_name_entry); camel_mime_part_set_filename (attachment->body, str); g_free (str); - + str = e_utf8_gtk_entry_get_text (dialog_data->description_entry); camel_mime_part_set_description (attachment->body, str); g_free (str); - + str = e_utf8_gtk_entry_get_text (dialog_data->mime_type_entry); camel_mime_part_set_content_type (attachment->body, str); camel_data_wrapper_set_mime_type ( camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body)), str); g_free (str); - + switch (gtk_toggle_button_get_active (dialog_data->disposition_checkbox)) { case 0: camel_mime_part_set_disposition (attachment->body, "attachment"); @@ -377,7 +376,7 @@ ok_cb (GtkWidget *widget, /* Hmmmm? */ break; } - + changed (attachment); close_cb (widget, data); } @@ -388,7 +387,7 @@ file_name_focus_out_cb (GtkWidget *widget, gpointer data) { DialogData *dialog_data; - + dialog_data = (DialogData *) data; update_mime_type (dialog_data); } @@ -400,32 +399,32 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, { DialogData *dialog_data; GladeXML *editor_gui; - + g_return_if_fail (attachment != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT (attachment)); - + if (attachment->editor_gui != NULL) { GtkWidget *window; - + window = glade_xml_get_widget (attachment->editor_gui, "dialog"); gdk_window_show (window->window); return; } - + editor_gui = glade_xml_new (E_GLADEDIR "/e-msg-composer-attachment.glade", NULL); if (editor_gui == NULL) { g_warning ("Cannot load `e-msg-composer-attachment.glade'"); return; } - + attachment->editor_gui = editor_gui; - + gtk_window_set_transient_for (GTK_WINDOW (glade_xml_get_widget (editor_gui, "dialog")), GTK_WINDOW (gtk_widget_get_toplevel (parent))); - + dialog_data = g_new (DialogData, 1); dialog_data->attachment = attachment; dialog_data->dialog = glade_xml_get_widget (editor_gui, "dialog"); @@ -437,12 +436,12 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, 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; char *type; const char *disposition; - + set_entry (editor_gui, "file_name_entry", camel_mime_part_get_filename (attachment->body)); set_entry (editor_gui, "description_entry", @@ -451,15 +450,19 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, type = header_content_type_simple (content_type); set_entry (editor_gui, "mime_type_entry", type); g_free (type); - + disposition = camel_mime_part_get_disposition (attachment->body); 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); connect_widget (editor_gui, "close_button", "clicked", close_cb, dialog_data); - + connect_widget (editor_gui, "file_name_entry", "focus_out_event", file_name_focus_out_cb, dialog_data); + + gtk_signal_connect (GTK_OBJECT (parent), "destroy", close_cb, dialog_data); + gtk_signal_connect (GTK_OBJECT (gtk_widget_get_toplevel (parent)), "hide", + close_cb, dialog_data); } diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index b81dd7aac1..605c587664 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -347,7 +347,7 @@ build_message (EMsgComposer *composer) if (composer->send_html) { clear_current_images (composer); - + data = get_text (composer->persist_stream_interface, "text/html"); if (!data) { /* The component has probably died */ @@ -401,7 +401,7 @@ build_message (EMsgComposer *composer) add_inlined_images (composer, html_with_images); clear_current_images (composer); - + current = CAMEL_DATA_WRAPPER (html_with_images); } else current = CAMEL_DATA_WRAPPER (body); @@ -415,7 +415,7 @@ build_message (EMsgComposer *composer) camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), "multipart/alternative"); } - + /* Generate a random boundary. */ camel_multipart_set_boundary (multipart, NULL); @@ -431,16 +431,16 @@ build_message (EMsgComposer *composer) if (composer->is_alternative) { int i; - + for (i = camel_multipart_get_number (multipart); i > 1; i--) { part = camel_multipart_get_part (multipart, i - 1); camel_medium_remove_header (CAMEL_MEDIUM (part), "Content-Disposition"); } } - + current = CAMEL_DATA_WRAPPER (multipart); } - + if (composer->pgp_sign || composer->pgp_encrypt) { part = camel_mime_part_new (); camel_medium_set_content_object (CAMEL_MEDIUM (part), current); @@ -462,6 +462,8 @@ build_message (EMsgComposer *composer) camel_internet_address_get (from, 0, NULL, &pgpid); } + printf ("build_message(): pgpid = '%s'\n", pgpid); + mail_crypto_pgp_mime_part_sign (&part, pgpid, CAMEL_CIPHER_HASH_SHA1, &ex); if (from) @@ -1108,7 +1110,7 @@ autosave_save_draft (EMsgComposer *composer) CamelMimeMessage *message; CamelStream *stream; char *file; - gint fd; + int fd; gboolean success = TRUE; fd = composer->autosave_fd; @@ -2270,6 +2272,8 @@ init (EMsgComposer *composer) composer->has_changed = FALSE; composer->charset = NULL; + + composer->enable_autosave = TRUE; composer->autosave_file = NULL; composer->autosave_fd = -1; } |