Avoid addressbook buttons expanding if field grows.
[modest] / src / hildon2 / modest-msg-edit-window.c
index c127898..945562b 100644 (file)
@@ -738,6 +738,9 @@ connect_signals (ModestMsgEditWindow *obj)
        g_signal_connect_swapped (G_OBJECT (priv->bcc_field), "open-addressbook", 
                                  G_CALLBACK (modest_msg_edit_window_open_addressbook), obj);
 
+       g_signal_connect (G_OBJECT (priv->send_button), "clicked",
+                         G_CALLBACK (modest_ui_actions_on_send), obj);
+
        g_signal_connect (G_OBJECT (priv->from_field), "value-changed",
                          G_CALLBACK (from_field_changed), obj);
 
@@ -1549,9 +1552,6 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
        priv->font_face_toolitem = tool_item;
 
        /* Set expand and homogeneous for remaining items */
-       tool_item = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarSend");
-       gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
-       gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
        tool_item = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ActionsBold");
        gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
        gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
@@ -2636,7 +2636,6 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window,
                        g_object_unref (att_list);
                        return;
                }
-               
        } else {
                g_object_ref (att_list);
        }
@@ -2707,7 +2706,7 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window,
        g_object_unref (att_list);
 
        /* if the last attachment has been removed, focus the Subject: field */
-       if (!modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view))) 
+       if (!modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)))
                gtk_widget_grab_focus (priv->subject_field);
 }
 
@@ -2898,7 +2897,7 @@ modest_msg_edit_window_open_addressbook (ModestMsgEditWindow *window,
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
 
        if (editor == NULL) {
-               GtkWidget *view_focus;
+               GtkWidget *view_focus, *parent;
                view_focus = gtk_window_get_focus (GTK_WINDOW (window));
 
                /* This code should be kept in sync with ModestRecptEditor. The
@@ -2907,24 +2906,15 @@ modest_msg_edit_window_open_addressbook (ModestMsgEditWindow *window,
                   hbox recpt editor inherits from, we'll need to go up in the 
                   hierarchy to know if the text view is part of the recpt editor
                   or if it's a different text entry */
-
-               if (gtk_widget_get_parent (view_focus)) {
-                       GtkWidget *first_parent;
-
-                       first_parent = gtk_widget_get_parent (view_focus);
-                       if (gtk_widget_get_parent (first_parent) && 
-                           MODEST_IS_RECPT_EDITOR (gtk_widget_get_parent (first_parent))) {
-                               editor = MODEST_RECPT_EDITOR (gtk_widget_get_parent (first_parent));
-                       }
-               }
+               parent = gtk_widget_get_parent (view_focus);
+               if (parent && MODEST_IS_RECPT_EDITOR (parent))
+                       editor = MODEST_RECPT_EDITOR (parent);
 
                if (editor == NULL)
                        editor = MODEST_RECPT_EDITOR (priv->to_field);
-
        }
 
-       modest_address_book_select_addresses (editor);
-
+       modest_address_book_select_addresses (editor, GTK_WINDOW (window));
 }
 
 void
@@ -3027,8 +3017,12 @@ modest_msg_edit_window_set_file_format (ModestMsgEditWindow *window,
 
        gtk_widget_set_no_show_all (GTK_WIDGET (parent_priv->toolbar), TRUE);
 
-       if (file_format == MODEST_FILE_FORMAT_PLAIN_TEXT) {
-               if (parent_priv->toolbar) gtk_widget_hide (parent_priv->toolbar);
+       if (parent_priv->toolbar) {
+               if (file_format == MODEST_FILE_FORMAT_PLAIN_TEXT) {
+                       gtk_widget_hide (parent_priv->toolbar);
+               } else {
+                       gtk_widget_show (parent_priv->toolbar);
+               }
        }
 
        if (current_format != file_format) {
@@ -3540,28 +3534,33 @@ body_insert_text (GtkTextBuffer *buffer,
 {
        GtkTextIter end_iter;
        gint offset;
+       glong utf8_len;
 
        gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (buffer), &end_iter);
 
        offset = gtk_text_iter_get_offset (&end_iter);
+       utf8_len = g_utf8_strlen (text, len);
 
-       if (offset + len > MAX_BODY_LENGTH) {
+       if (offset + utf8_len > MAX_BODY_LENGTH) {
                g_signal_stop_emission_by_name (G_OBJECT (buffer), "insert-text");
                if (offset < MAX_BODY_LENGTH)
                {
                        gchar *result;
+                       gchar *utf8_end;
+
+                       utf8_end = g_utf8_offset_to_pointer (text, MAX_BODY_LENGTH - offset);
 
                        /* Prevent endless recursion */
-                       result = g_strndup (text, MAX_BODY_LENGTH - offset);
+                       result = g_strndup (text, utf8_end - text);
                        g_signal_handlers_block_by_func (G_OBJECT (buffer), G_CALLBACK (body_insert_text), window);
                        g_signal_emit_by_name (G_OBJECT (buffer), "insert-text", location,
-                                              (gpointer) result, (gpointer) MAX_BODY_LENGTH - offset,
+                                              (gpointer) result, (gpointer) (utf8_end - text),
                                               (gpointer) window);
                        g_signal_handlers_unblock_by_func (G_OBJECT (buffer), G_CALLBACK (body_insert_text), window);
                }
 
        }
-       if (offset + len > MAX_BODY_LENGTH) {
+       if (offset + utf8_len > MAX_BODY_LENGTH) {
                hildon_banner_show_information (GTK_WIDGET (window), NULL, 
                                                _CS("ckdg_ib_maximum_characters_reached"));
        }
@@ -4181,6 +4180,9 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window)
        g_signal_connect (G_OBJECT (html_toggle), "toggled", G_CALLBACK (on_format_toggle), &helper);
        g_signal_connect (G_OBJECT (text_toggle), "toggled", G_CALLBACK (on_format_toggle), &helper);
 
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+                                    GTK_WINDOW (dialog), GTK_WINDOW (window));
+
        /* Save settings if the user clicked on done */
        if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
                TnyHeaderFlags flags;
@@ -4273,7 +4275,7 @@ setup_menu (ModestMsgEditWindow *self)
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_attach_inlineimage"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_insert_image),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_set_style));
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("TODO: add attachment"), NULL,
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_editor_add_attachment"), NULL,
                                           APP_MENU_CALLBACK (modest_msg_edit_window_add_attachment_clicked),
                                           NULL);
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
@@ -4305,7 +4307,7 @@ _create_addressbook_box (GtkSizeGroup *title_size_group, GtkSizeGroup *value_siz
 
        box = gtk_hbox_new (FALSE, 0);
 
-       align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+       align = gtk_alignment_new (0.0, 0.0, 1.0, 0.0);
        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 0, MODEST_MARGIN_DEFAULT);
 
        abook_button = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT);