X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhildon2%2Fmodest-msg-edit-window.c;h=6ea289d25eef084ca9f6a3e820b37f86ba6c3074;hb=8d4844a81a6d20c97f8916fd6a6a0e384d995ded;hp=511eb0c5d372ea3388e65d0e58bbb8b0572b1afd;hpb=a7be4d9c27d5a6074f3a1701b12bcc2c45887022;p=modest diff --git a/src/hildon2/modest-msg-edit-window.c b/src/hildon2/modest-msg-edit-window.c index 511eb0c..6ea289d 100644 --- a/src/hildon2/modest-msg-edit-window.c +++ b/src/hildon2/modest-msg-edit-window.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -78,12 +78,12 @@ #endif #include #include "modest-maemo-utils.h" +#include #define DEFAULT_FONT_SIZE 3 #define DEFAULT_FONT 2 #define DEFAULT_SIZE_BUTTON_FONT_FAMILY "Sans" -#define DEFAULT_SIZE_COMBOBOX_WIDTH 80 #define DEFAULT_MAIN_VBOX_SPACING 6 #define SUBJECT_MAX_LENGTH 1000 #define IMAGE_MAX_WIDTH 560 @@ -455,8 +455,6 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj) } -/* FIXME: this is a dup from the one in gtk/ */ - /** * @result: A ModestPairList, which must be freed with modest_pair_list_free(). */ @@ -723,7 +721,7 @@ connect_signals (ModestMsgEditWindow *obj) static void init_window (ModestMsgEditWindow *obj) { - GtkWidget *from_caption, *to_caption, *subject_caption; + GtkWidget *to_caption, *subject_caption; GtkWidget *main_vbox; ModestMsgEditWindowPrivate *priv; GtkActionGroup *action_group; @@ -731,13 +729,15 @@ init_window (ModestMsgEditWindow *obj) GdkPixbuf *window_icon = NULL; GError *error = NULL; - GtkSizeGroup *size_group; + GtkSizeGroup *title_size_group; + GtkSizeGroup *value_size_group; GtkWidget *subject_box; GtkWidget *attachment_icon; GtkWidget *window_box; #if (GTK_MINOR_VERSION >= 10) GdkAtom deserialize_type; #endif + priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj); parent_priv = MODEST_WINDOW_GET_PRIVATE (obj); @@ -789,12 +789,17 @@ init_window (ModestMsgEditWindow *obj) parent_priv->menubar = NULL; - size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + title_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + value_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - /* Note: This ModestPairList* must exist for as long as the combo - * that uses it, because the ModestComboBox uses the ID opaquely, + /* Note: This ModestPairList* must exist for as long as the picker + * that uses it, because the ModestSelectorPicker uses the ID opaquely, * so it can't know how to manage its memory. */ - priv->from_field = modest_combo_box_new (NULL, g_str_equal); + priv->from_field = modest_selector_picker_new (MODEST_EDITABLE_SIZE, + HILDON_BUTTON_ARRANGEMENT_HORIZONTAL, + NULL, g_str_equal); + modest_maemo_utils_set_hbutton_layout (title_size_group, value_size_group, + _("mail_va_from"), priv->from_field); priv->to_field = modest_recpt_editor_new (); priv->cc_field = modest_recpt_editor_new (); @@ -802,7 +807,8 @@ init_window (ModestMsgEditWindow *obj) subject_box = gtk_hbox_new (FALSE, 0); priv->priority_icon = gtk_image_new (); gtk_box_pack_start (GTK_BOX (subject_box), priv->priority_icon, FALSE, FALSE, 0); - priv->subject_field = gtk_entry_new_with_max_length (SUBJECT_MAX_LENGTH); + priv->subject_field = hildon_entry_new (MODEST_EDITABLE_SIZE); + gtk_entry_set_max_length (GTK_ENTRY (priv->subject_field) ,SUBJECT_MAX_LENGTH); g_object_set (G_OBJECT (priv->subject_field), "truncate-multiline", TRUE, NULL); hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->subject_field), HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP); @@ -811,7 +817,7 @@ init_window (ModestMsgEditWindow *obj) GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (priv->add_attachment_button), GTK_CAN_FOCUS); gtk_button_set_relief (GTK_BUTTON (priv->add_attachment_button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (priv->add_attachment_button), FALSE); - gtk_button_set_alignment (GTK_BUTTON (priv->add_attachment_button), 1.0, 1.0); + gtk_button_set_alignment (GTK_BUTTON (priv->add_attachment_button), 1.0, 0.5); attachment_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_ATTACH, GTK_ICON_SIZE_BUTTON); gtk_container_add (GTK_CONTAINER (priv->add_attachment_button), attachment_icon); gtk_box_pack_start (GTK_BOX (subject_box), priv->add_attachment_button, FALSE, FALSE, 0); @@ -819,23 +825,24 @@ init_window (ModestMsgEditWindow *obj) priv->header_box = gtk_vbox_new (FALSE, 0); - from_caption = hildon_caption_new (size_group, _("mail_va_from"), priv->from_field, NULL, 0); - to_caption = hildon_caption_new (size_group, _("mail_va_to"), priv->to_field, NULL, 0); - priv->cc_caption = hildon_caption_new (size_group, _("mail_va_cc"), priv->cc_field, NULL, 0); - priv->bcc_caption = hildon_caption_new (size_group, _("mail_va_hotfix1"), priv->bcc_field, NULL, 0); - subject_caption = hildon_caption_new (size_group, _("mail_va_subject"), subject_box, NULL, 0); - priv->attachments_caption = hildon_caption_new (size_group, _("mail_va_attachment"), priv->attachments_view, NULL, 0); - g_object_unref (size_group); - - size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - modest_recpt_editor_set_field_size_group (MODEST_RECPT_EDITOR (priv->to_field), size_group); - modest_recpt_editor_set_field_size_group (MODEST_RECPT_EDITOR (priv->cc_field), size_group); - modest_recpt_editor_set_field_size_group (MODEST_RECPT_EDITOR (priv->bcc_field), size_group); - gtk_size_group_add_widget (size_group, priv->subject_field); - gtk_size_group_add_widget (size_group, priv->attachments_view); - g_object_unref (size_group); - - gtk_box_pack_start (GTK_BOX (priv->header_box), from_caption, FALSE, FALSE, 0); + to_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group, + _("mail_va_to"), priv->to_field); + priv->cc_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group, + _("mail_va_cc"), priv->cc_field); + priv->bcc_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group, + _("mail_va_hotfix1"), priv->bcc_field); + subject_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group, + _("mail_va_subject"), subject_box); + priv->attachments_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group, + _("mail_va_attachment"), + priv->attachments_view); + /* modest_recpt_editor_set_field_size_group (MODEST_RECPT_EDITOR (priv->to_field), value_size_group); */ + /* modest_recpt_editor_set_field_size_group (MODEST_RECPT_EDITOR (priv->cc_field), value_size_group); */ + /* modest_recpt_editor_set_field_size_group (MODEST_RECPT_EDITOR (priv->bcc_field), value_size_group); */ + g_object_unref (title_size_group); + g_object_unref (value_size_group); + + gtk_box_pack_start (GTK_BOX (priv->header_box), priv->from_field, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->header_box), to_caption, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->header_box), priv->cc_caption, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->header_box), priv->bcc_caption, FALSE, FALSE, 0); @@ -969,7 +976,7 @@ modest_msg_edit_window_finalize (GObject *obj) g_object_unref (priv->attachments); g_object_unref (priv->images); - /* This had to stay alive for as long as the combobox that used it: */ + /* This had to stay alive for as long as the picker that used it: */ modest_pair_list_free (priv->from_field_protos); G_OBJECT_CLASS(parent_class)->finalize (obj); @@ -1000,6 +1007,8 @@ pixbuf_from_stream (TnyStream *stream, const gchar *mime_type, guint64 *stream_s readed = tny_stream_read (TNY_STREAM (stream), (char *) read_buffer, 128); size += readed; if (!gdk_pixbuf_loader_write (loader, read_buffer, readed, &error)) { + if (error) + g_error_free (error); break; } } @@ -1233,10 +1242,6 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) gtk_widget_grab_focus (priv->msg_body); } - /* TODO: lower priority, select in the From: combo to the - value that comes from msg <- not sure, should it be - allowed? */ - DEBUG_BUFFER (WP_TEXT_BUFFER (priv->text_buffer)); gtk_text_buffer_get_start_iter (priv->text_buffer, &iter); @@ -1492,8 +1497,13 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre parent_priv->menubar = modest_maemo_utils_get_manager_menubar_as_menu (parent_priv->ui_manager, "/MenuBar"); hildon_window_set_menu (HILDON_WINDOW (obj), GTK_MENU (parent_priv->menubar)); priv->from_field_protos = get_transports (); - modest_combo_box_set_pair_list (MODEST_COMBO_BOX (priv->from_field), priv->from_field_protos); - modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->from_field), (gpointer) account_name); + modest_selector_picker_set_pair_list (MODEST_SELECTOR_PICKER (priv->from_field), priv->from_field_protos); + modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) account_name); + hildon_button_set_title (HILDON_BUTTON (priv->from_field), + _("mail_va_from")); + hildon_button_set_value (HILDON_BUTTON (priv->from_field), + hildon_touch_selector_get_current_text + (HILDON_TOUCH_SELECTOR (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (priv->from_field))))); modest_msg_edit_window_setup_toolbar (MODEST_MSG_EDIT_WINDOW (obj)); hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar)); @@ -1608,7 +1618,7 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (edit_window); - account_name = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); + account_name = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field)); g_return_val_if_fail (account_name, NULL); @@ -1893,6 +1903,7 @@ modest_msg_edit_window_set_format_state (ModestMsgEditWindow *self, text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), self); + g_free (buffer_format); g_free (current_format); /* Check dimming rules */ @@ -2160,7 +2171,7 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) modest_maemo_utils_setup_images_filechooser (GTK_FILE_CHOOSER (dialog)); modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), - GTK_WINDOW (dialog)); + GTK_WINDOW (dialog), GTK_WINDOW (window)); response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { @@ -2238,6 +2249,7 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window) insert_mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (priv->text_buffer)); gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (priv->text_buffer), &position, insert_mark); wp_text_buffer_insert_image (WP_TEXT_BUFFER (priv->text_buffer), &position, g_strdup (tny_mime_part_get_content_id (mime_part)), pixbuf); + g_object_unref (pixbuf); } tny_list_prepend (priv->images, (GObject *) mime_part); @@ -2274,7 +2286,7 @@ modest_msg_edit_window_offer_attach_file (ModestMsgEditWindow *window) dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_window_set_title (GTK_WINDOW (dialog), _("mcen_ti_select_attachment_title")); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); - modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog)); + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), GTK_WINDOW (window)); response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { @@ -2853,7 +2865,7 @@ modest_msg_edit_window_select_font (ModestMsgEditWindow *window) dialog = hildon_font_selection_dialog_new (GTK_WINDOW (window), NULL); modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), - GTK_WINDOW(dialog)); + GTK_WINDOW(dialog), GTK_WINDOW (window)); /* First we get the currently selected font information */ wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), &oldfmt, TRUE); @@ -2890,7 +2902,7 @@ modest_msg_edit_window_select_font (ModestMsgEditWindow *window) NULL); modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), - GTK_WINDOW (dialog)); + GTK_WINDOW (dialog), GTK_WINDOW (window)); gtk_widget_show_all (dialog); priv->font_dialog = dialog; response = gtk_dialog_run (GTK_DIALOG (dialog)); @@ -3144,7 +3156,7 @@ modest_msg_edit_window_is_modified (ModestMsgEditWindow *editor) return TRUE; if (gtk_text_buffer_get_modified (priv->text_buffer)) return TRUE; - account_name = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); + account_name = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field)); if (!priv->original_account_name || strcmp(account_name, priv->original_account_name)) { return TRUE; } @@ -3544,8 +3556,12 @@ modest_msg_edit_window_set_draft (ModestMsgEditWindow *window, priv->msg_uid = NULL; } priv->msg_uid = modest_tny_folder_get_header_unique_id (header); - if (GTK_WIDGET_REALIZED (window)) - modest_window_mgr_register_window (mgr, MODEST_WINDOW (window)); + if (GTK_WIDGET_REALIZED (window)) { + if (!modest_window_mgr_register_window (mgr, MODEST_WINDOW (window), NULL)) { + gtk_widget_destroy (GTK_WIDGET (window)); + return; + } + } } priv->draft_msg = draft; @@ -3560,7 +3576,7 @@ text_buffer_apply_tag (GtkTextBuffer *buffer, GtkTextTag *tag, ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (userdata); gchar *tag_name; - if (tag == NULL+13) return; + if (tag == NULL) return; g_object_get (G_OBJECT (tag), "name", &tag_name, NULL); if ((tag_name != NULL) && (g_str_has_prefix (tag_name, "image-tag-replace-"))) { replace_with_images (window, priv->images);