Migrated hildon2 to text-utils dgettext macros
[modest] / src / hildon2 / modest-msg-edit-window.c
index da939cd..18b1680 100644 (file)
@@ -267,6 +267,7 @@ struct _ModestMsgEditWindowPrivate {
        GtkWidget   *font_dialog;
 
        GtkWidget   *pannable;
+       guint        correct_scroll_idle;
        guint        scroll_drag_timeout_id;
        gdouble      last_upper;
 
@@ -419,6 +420,7 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj)
        priv->sent = FALSE;
 
        priv->scroll_drag_timeout_id = 0;
+       priv->correct_scroll_idle = 0;
        priv->last_upper = 0.0;
 
        priv->font_dialog = NULL;
@@ -493,21 +495,19 @@ scroll_drag_timeout (gpointer userdata)
        return FALSE;
 }
 
-static void
-correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focused)
+static gboolean 
+correct_scroll_without_drag_check_idle (gpointer userdata)
 {
+       ModestMsgEditWindow *w = (ModestMsgEditWindow *) userdata;
        ModestMsgEditWindowPrivate *priv;
-       GtkTextMark *insert;
        GtkTextIter iter;
        GdkRectangle rectangle;
        gdouble new_value;
        gint offset;
+       GtkTextMark *insert;
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
-
-       if (only_if_focused && !gtk_widget_is_focus (priv->msg_body))
-               return;
-
+       
        insert = gtk_text_buffer_get_insert (priv->text_buffer);
        gtk_text_buffer_get_iter_at_mark (priv->text_buffer, &iter, insert);
 
@@ -517,6 +517,27 @@ correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focu
        new_value = (offset + rectangle.y);
 
        hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (priv->pannable), -1, new_value);
+
+       priv->correct_scroll_idle = 0;
+       return FALSE;
+}
+
+static void
+correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focused)
+{
+       ModestMsgEditWindowPrivate *priv;
+
+       priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
+
+       if (only_if_focused && !gtk_widget_is_focus (priv->msg_body))
+               return;
+
+       if (priv->correct_scroll_idle > 0) {
+               return;
+       }
+
+       priv->correct_scroll_idle = g_idle_add ((GSourceFunc) correct_scroll_without_drag_check_idle,
+                                               (gpointer) w);
 }
 
 static void
@@ -773,20 +794,21 @@ init_window (ModestMsgEditWindow *obj)
        
        to_caption = modest_maemo_utils_create_captioned_with_size_type 
                (title_size_group, value_size_group,
-                _("mail_va_to"), priv->to_field,
+                _("mail_va_to"), FALSE, priv->to_field,
                 HILDON_SIZE_AUTO_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
        priv->cc_caption = modest_maemo_utils_create_captioned_with_size_type 
                (title_size_group, value_size_group,
-                _("mail_va_cc"), priv->cc_field,
+                _("mail_va_cc"), FALSE, priv->cc_field,
                 HILDON_SIZE_AUTO_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
        priv->bcc_caption = modest_maemo_utils_create_captioned_with_size_type
                (title_size_group, value_size_group,
-                _("mail_va_hotfix1"), priv->bcc_field,
+                _("mail_va_hotfix1"), FALSE, priv->bcc_field,
                 HILDON_SIZE_AUTO_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
        subject_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
-                                                              _("mail_va_subject"), subject_box);
+                                                              _("mail_va_subject"), FALSE, subject_box);
        priv->attachments_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group, value_size_group,
                                                                                        _("mail_va_attachment"), 
+                                                                                       FALSE,
                                                                                        priv->attachments_view,
                                                                                        HILDON_SIZE_AUTO_WIDTH |
                                                                                        HILDON_SIZE_AUTO_HEIGHT);
@@ -836,6 +858,8 @@ init_window (ModestMsgEditWindow *obj)
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->frame, TRUE, TRUE, 0);
 
        hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (priv->pannable), main_vbox);
+       gtk_container_set_focus_vadjustment (GTK_CONTAINER (main_vbox), 
+                                            hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (priv->pannable)));
        gtk_widget_show_all (GTK_WIDGET(priv->pannable));
        
        window_box = gtk_vbox_new (FALSE, 0);
@@ -912,6 +936,10 @@ modest_msg_edit_window_finalize (GObject *obj)
                g_object_unref (priv->outbox_msg);
                priv->outbox_msg = NULL;
        }
+       if (priv->correct_scroll_idle > 0) {
+               g_source_remove (priv->correct_scroll_idle);
+               priv->correct_scroll_idle = 0;
+       }
        if (priv->scroll_drag_timeout_id > 0) {
                g_source_remove (priv->scroll_drag_timeout_id);
                priv->scroll_drag_timeout_id = 0;
@@ -2173,31 +2201,32 @@ modest_msg_edit_window_insert_image (ModestMsgEditWindow *window)
 
                        mime_part = tny_platform_factory_new_mime_part
                                (modest_runtime_get_platform_factory ());
-                               
+
                        TnyStream *stream = create_stream_for_uri (uri);
 
                        if (stream == NULL) {
 
-                               modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed"));
-                               
+                               modest_platform_information_banner (NULL, NULL, 
+                                                                   _FM("sfil_ib_opening_not_allowed"));
+
                                g_object_unref (mime_part);
                                gnome_vfs_file_info_unref (info);
                                continue;
                        }
 
                        tny_mime_part_construct (mime_part, stream, mime_type, "base64");
-                       
+
                        content_id = g_strdup_printf ("%d", priv->next_cid);
                        tny_mime_part_set_content_id (mime_part, content_id);
                        g_free (content_id);
                        priv->next_cid++;
-                       
+
                        basename = g_path_get_basename (filename);
                        tny_mime_part_set_filename (mime_part, basename);
                        g_free (basename);
 
                        pixbuf = pixbuf_from_stream (stream, mime_type, &stream_size);
-                       
+
                        if (pixbuf != NULL) {
                                priv->images_size += stream_size;
                                priv->images_count ++;
@@ -2349,7 +2378,7 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window,
                        size = info->size;
                        if (size > allowed_size) {
                                modest_platform_information_banner (NULL, NULL, 
-                                                                   dgettext("hildon-fm", "sfil_ib_opening_not_allowed"));
+                                                                   _FM("sfil_ib_opening_not_allowed"));
                                return 0;
                        }
                } else
@@ -2359,7 +2388,7 @@ modest_msg_edit_window_attach_file_one (ModestMsgEditWindow *window,
                
                if (stream == NULL) {
 
-                       modest_platform_information_banner (NULL, NULL, dgettext("hildon-fm", "sfil_ib_opening_not_allowed"));
+                       modest_platform_information_banner (NULL, NULL, _FM("sfil_ib_opening_not_allowed"));
 
                        g_object_unref (mime_part);
                        gnome_vfs_file_info_unref (info);
@@ -3284,8 +3313,7 @@ subject_field_insert_text (GtkEditable *editable,
 
        if (result_len + old_length > 1000) {
                hildon_banner_show_information (GTK_WIDGET (window), NULL, 
-                                               dgettext("hildon-common-strings",
-                                                        "ckdg_ib_maximum_characters_reached"));
+                                               _CS("ckdg_ib_maximum_characters_reached"));
        }
        g_string_free (result, TRUE);
 }
@@ -3391,7 +3419,7 @@ modest_msg_edit_window_find_toolbar_search (GtkWidget *widget,
                g_free (priv->last_search);
                priv->last_search = NULL;
                /* Information banner about empty search */
-               hildon_banner_show_information (NULL, NULL, dgettext ("hildon-common-strings", "ecdg_ib_find_rep_enter_text"));
+               hildon_banner_show_information (NULL, NULL, _CS("ecdg_ib_find_rep_enter_text"));
                return;
        }
 
@@ -3407,14 +3435,14 @@ modest_msg_edit_window_find_toolbar_search (GtkWidget *widget,
                result = gtk_text_iter_forward_search_insensitive (&selection_end, current_search, 
                                                                   &match_start, &match_end);
                if (!result)
-                       hildon_banner_show_information (NULL, NULL, dgettext ("hildon-libs", "ckct_ib_find_search_complete"));
+                       hildon_banner_show_information (NULL, NULL, _HL("ckct_ib_find_search_complete"));
        } else {
                GtkTextIter buffer_start;
                gtk_text_buffer_get_start_iter (priv->text_buffer, &buffer_start);
                result = gtk_text_iter_forward_search_insensitive (&buffer_start, current_search, 
                                                                   &match_start, &match_end);
                if (!result)
-                       hildon_banner_show_information (NULL, NULL, dgettext ("hildon-libs", "ckct_ib_find_no_matches"));
+                       hildon_banner_show_information (NULL, NULL, _HL("ckct_ib_find_no_matches"));
        }
 
        /* Mark as selected the string found in search */
@@ -3727,7 +3755,7 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window)
        gtk_box_pack_start (GTK_BOX (priority_hbox), high_toggle, TRUE, TRUE, 0);
        gtk_widget_show_all (priority_hbox);
        captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
-                                                        _("mcen_me_editor_message_priority"), priority_hbox);
+                                                        _("mcen_me_editor_message_priority"), FALSE, priority_hbox);
        gtk_widget_show (captioned);
        gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, 0);
 
@@ -3747,7 +3775,7 @@ modest_msg_edit_window_show_msg_settings_dialog (ModestMsgEditWindow *window)
        gtk_box_pack_start (GTK_BOX (format_hbox), text_toggle, TRUE, TRUE, 0);
        gtk_widget_show_all (format_hbox);
        captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
-                                                        _("mcen_me_editor_format"), format_hbox);
+                                                        _("mcen_me_editor_format"), FALSE, format_hbox);
        gtk_widget_show (captioned);
        gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, 0);