* src/widgets/modest-header-view.c:
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 20 Feb 2008 11:07:32 +0000 (11:07 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 20 Feb 2008 11:07:32 +0000 (11:07 +0000)
        * Set the fixed height from font in text cell renderers.
* src/widgets/modest-header-view-render.c:
        * Avoid using pango markup as pango parsing is expensive.
          Instead of this use cell renderer properties to set the
          default fonts.
        * We set the properties now using freeze and thaw, for avoiding
          preparing the font as many times as properties we have.
* src/modest-ui-actions.c:
        * Show proper information banner on opening a drafts message.
* src/maemo/modest-msg-edit-window.c:
        * Delay show all just until all the window is ready to be shown.
          This should reduce expensive redraws and relocations.
* src/maemo/modest-msg-view-window.c:
        * Also delay show all until all the window is ready to be shown.

pmo-trunk-r4206

src/maemo/modest-msg-edit-window.c
src/maemo/modest-msg-view-window.c
src/modest-ui-actions.c
src/widgets/modest-hbox-cell-renderer.c
src/widgets/modest-header-view-render.c
src/widgets/modest-header-view.c

index 418638b..309390e 100644 (file)
@@ -1555,7 +1555,6 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
        g_object_unref (menu_rules_group);
        g_object_unref (toolbar_rules_group);
        g_object_unref (clipboard_rules_group);
        g_object_unref (menu_rules_group);
        g_object_unref (toolbar_rules_group);
        g_object_unref (clipboard_rules_group);
-       gtk_widget_show_all (GTK_WIDGET (obj));
        modest_msg_edit_window_clipboard_owner_change (NULL, NULL, MODEST_MSG_EDIT_WINDOW (obj));
 
        set_msg (MODEST_MSG_EDIT_WINDOW (obj), msg, preserve_is_rich);
        modest_msg_edit_window_clipboard_owner_change (NULL, NULL, MODEST_MSG_EDIT_WINDOW (obj));
 
        set_msg (MODEST_MSG_EDIT_WINDOW (obj), msg, preserve_is_rich);
index c758c0d..78bf0e5 100644 (file)
@@ -726,8 +726,8 @@ select_next_valid_row (GtkTreeModel *model,
 /* TODO: This should be in _init(), with the parameters as properties. */
 static void
 modest_msg_view_window_construct (ModestMsgViewWindow *self, 
 /* TODO: This should be in _init(), with the parameters as properties. */
 static void
 modest_msg_view_window_construct (ModestMsgViewWindow *self, 
-                           const gchar *modest_account_name,
-                           const gchar *msg_uid)
+                                 const gchar *modest_account_name,
+                                 const gchar *msg_uid)
 {
        GObject *obj = NULL;
        ModestMsgViewWindowPrivate *priv = NULL;
 {
        GObject *obj = NULL;
        ModestMsgViewWindowPrivate *priv = NULL;
@@ -826,7 +826,6 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
        /* Init the clipboard actions dim status */
        modest_msg_view_grab_focus(MODEST_MSG_VIEW (priv->msg_view));
 
        /* Init the clipboard actions dim status */
        modest_msg_view_grab_focus(MODEST_MSG_VIEW (priv->msg_view));
 
-       gtk_widget_show_all (GTK_WIDGET (obj));
        update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
 
 
        update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
 
 
@@ -948,6 +947,8 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg,
        update_window_title (window);
        modest_msg_view_window_update_priority (window);
 
        update_window_title (window);
        modest_msg_view_window_update_priority (window);
 
+       gtk_widget_show_all (GTK_WIDGET (window));
+
 
        return MODEST_WINDOW(window);
 }
 
        return MODEST_WINDOW(window);
 }
@@ -971,6 +972,8 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg,
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
        update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
 
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
        update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
 
+       gtk_widget_show_all (GTK_WIDGET (obj));
+
        /* Check dimming rules */
        modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (obj));
        modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (obj));
        /* Check dimming rules */
        modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (obj));
        modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (obj));
index 9778bc4..46fb8e3 100644 (file)
@@ -807,6 +807,28 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op,
        return TRUE;
 }
 
        return TRUE;
 }
 
+typedef struct {
+       guint idle_handler;
+       gchar *message;
+       GtkWidget *banner;
+} OpenMsgBannerInfo;
+
+gboolean
+open_msg_banner_idle (gpointer userdata)
+{
+       OpenMsgBannerInfo *banner_info = (OpenMsgBannerInfo *) userdata;
+
+       gdk_threads_enter ();
+       banner_info->idle_handler = 0;
+       banner_info->banner = modest_platform_animation_banner (NULL, NULL, banner_info->message);
+       g_object_ref (banner_info->banner);
+       
+       gdk_threads_leave ();
+
+       return FALSE;
+       
+}
+
 static void
 open_msg_cb (ModestMailOperation *mail_op, 
             TnyHeader *header,  
 static void
 open_msg_cb (ModestMailOperation *mail_op, 
             TnyHeader *header,  
@@ -822,12 +844,13 @@ open_msg_cb (ModestMailOperation *mail_op,
        gchar *account = NULL;
        TnyFolder *folder;
        gboolean open_in_editor = FALSE;
        gchar *account = NULL;
        TnyFolder *folder;
        gboolean open_in_editor = FALSE;
+       OpenMsgBannerInfo *banner_info = (OpenMsgBannerInfo *) user_data;
        
        /* Do nothing if there was any problem with the mail
           operation. The error will be shown by the error_handler of
           the mail operation */
        if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg))
        
        /* Do nothing if there was any problem with the mail
           operation. The error will be shown by the error_handler of
           the mail operation */
        if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg))
-               return;
+               goto banner_cleanup;
 
        parent_win = (ModestWindow *) modest_mail_operation_get_source (mail_op);
        folder = tny_header_get_folder (header);
 
        parent_win = (ModestWindow *) modest_mail_operation_get_source (mail_op);
        folder = tny_header_get_folder (header);
@@ -908,9 +931,6 @@ open_msg_cb (ModestMailOperation *mail_op,
                win = modest_msg_edit_window_new (msg, account, TRUE);
 
 
                win = modest_msg_edit_window_new (msg, account, TRUE);
 
 
-               /* Show banner */
-               modest_platform_information_banner_with_timeout
-                       (NULL, NULL, _("mail_ib_opening_draft_message"), 1200);
 
        } else {
                gchar *uid = modest_tny_folder_get_header_unique_id (header);
 
        } else {
                gchar *uid = modest_tny_folder_get_header_unique_id (header);
@@ -965,6 +985,20 @@ cleanup:
        g_free(account);
        g_object_unref (parent_win);
        g_object_unref (folder);
        g_free(account);
        g_object_unref (parent_win);
        g_object_unref (folder);
+banner_cleanup:
+       if (banner_info) {
+               g_free (banner_info->message);
+               if (banner_info->idle_handler > 0) {
+                       g_source_remove (banner_info->idle_handler);
+                       banner_info->idle_handler = 0;
+               }
+               if (banner_info->banner != NULL) {
+                       gtk_widget_destroy (banner_info->banner);
+                       g_object_unref (banner_info->banner);
+                       banner_info->banner = NULL;
+               }
+               g_slice_free (OpenMsgBannerInfo, banner_info);
+       }
 }
 
 void
 }
 
 void
@@ -1041,6 +1075,8 @@ open_msgs_performer(gboolean canceled,
        ModestTransportStoreProtocol proto;
        TnyList *not_opened_headers;
        TnyConnectionStatus status;
        ModestTransportStoreProtocol proto;
        TnyList *not_opened_headers;
        TnyConnectionStatus status;
+       gboolean show_open_draft = FALSE;
+       OpenMsgBannerInfo *banner_info = NULL;
 
        not_opened_headers = TNY_LIST (user_data);
 
 
        not_opened_headers = TNY_LIST (user_data);
 
@@ -1072,6 +1108,19 @@ open_msgs_performer(gboolean canceled,
                        g_object_unref (header);
                        g_object_unref (iter);
                } else {
                        g_object_unref (header);
                        g_object_unref (iter);
                } else {
+                       TnyHeader *header;
+                       TnyFolder *folder;
+                       TnyIterator *iter;
+                       TnyFolderType folder_type;
+
+                       iter = tny_list_create_iterator (not_opened_headers);
+                       header = TNY_HEADER (tny_iterator_get_current (iter));
+                       folder = tny_header_get_folder (header);
+                       folder_type = modest_tny_folder_get_local_or_mmc_folder_type (folder);
+                       show_open_draft = (folder_type == TNY_FOLDER_TYPE_DRAFTS);
+                       g_object_unref (folder);
+                       g_object_unref (header);
+                       g_object_unref (iter);
                        error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
                }
        } else {
                        error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
                }
        } else {
@@ -1085,11 +1134,18 @@ open_msgs_performer(gboolean canceled,
                                                               error_msg, g_free);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                         mail_op);
                                                               error_msg, g_free);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                         mail_op);
-               
+
+       if (show_open_draft) {
+               banner_info = g_slice_new (OpenMsgBannerInfo);
+               banner_info->message = g_strdup (_("mail_ib_opening_draft_message"));
+               banner_info->banner = NULL;
+               banner_info->idle_handler = g_timeout_add (500, open_msg_banner_idle, banner_info);
+       }
+
        modest_mail_operation_get_msgs_full (mail_op,
                                             not_opened_headers,
                                             open_msg_cb,
        modest_mail_operation_get_msgs_full (mail_op,
                                             not_opened_headers,
                                             open_msg_cb,
-                                            NULL,
+                                            banner_info,
                                             NULL);
 
        /* Frees */
                                             NULL);
 
        /* Frees */
index 49c984d..568ea8e 100644 (file)
@@ -316,7 +316,6 @@ modest_hbox_cell_renderer_render       (GtkCellRenderer       *cell,
                                GtkRequisition child_req;
                                gint child_xpad, child_ypad;
                                GdkRectangle child_expose_area;
                                GtkRequisition child_req;
                                gint child_xpad, child_ypad;
                                GdkRectangle child_expose_area;
-
                                gtk_cell_renderer_get_size (child, widget, NULL, NULL, NULL, &(child_req.width), &(child_req.height));
                                g_object_get (child, "xpad", &child_xpad, "ypad", &child_ypad, NULL);
 
                                gtk_cell_renderer_get_size (child, widget, NULL, NULL, NULL, &(child_req.width), &(child_req.height));
                                g_object_get (child, "xpad", &child_xpad, "ypad", &child_ypad, NULL);
 
index 6cc8e9a..df8f9a0 100644 (file)
 #include <modest-platform.h>
 #include <string.h>
 
 #include <modest-platform.h>
 #include <string.h>
 
+typedef enum {
+       RENDER_CELL_STYLE_DEFAULT=0,
+       RENDER_CELL_STYLE_GREY
+} RenderCellStyle;
 
 static const gchar *
 get_status_string (ModestTnySendQueueStatus status)
 
 static const gchar *
 get_status_string (ModestTnySendQueueStatus status)
@@ -120,6 +124,36 @@ set_common_flags (GtkCellRenderer *renderer, TnyHeaderFlags flags)
                      NULL);    
 }
 
                      NULL);    
 }
 
+static void
+set_cell_text (GtkCellRenderer *renderer, 
+              const gchar *text, 
+              TnyHeaderFlags flags,
+              RenderCellStyle style)
+{
+       PangoWeight weight;
+       gboolean strikethrough;
+
+       weight =  (flags & TNY_HEADER_FLAG_SEEN) ? PANGO_WEIGHT_NORMAL: PANGO_WEIGHT_ULTRABOLD;
+       strikethrough = (flags & TNY_HEADER_FLAG_DELETED) ?  TRUE:FALSE;
+       g_object_freeze_notify (G_OBJECT (renderer));
+       g_object_set (G_OBJECT (renderer), "text", text, NULL);
+       if (!(flags & TNY_HEADER_FLAG_SEEN))
+               g_object_set (G_OBJECT (renderer), "weight", PANGO_WEIGHT_ULTRABOLD, NULL);
+       if (flags & TNY_HEADER_FLAG_DELETED)
+               g_object_set (G_OBJECT (renderer), "strikethrough", TRUE, NULL);
+       switch (style) {
+       case RENDER_CELL_STYLE_GREY:
+               g_object_set (G_OBJECT (renderer), 
+                             "foreground", "#666666",
+                             "scale", PANGO_SCALE_SMALL,
+                             NULL);
+               break;
+       case RENDER_CELL_STYLE_DEFAULT:
+               break;
+       }
+       g_object_thaw_notify (G_OBJECT (renderer));
+}
+
 
 void
 _modest_header_view_msgtype_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
 
 void
 _modest_header_view_msgtype_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
@@ -187,10 +221,8 @@ _modest_header_view_date_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer
                            date_col, &date,
                            -1);
        
                            date_col, &date,
                            -1);
        
-       g_object_set (G_OBJECT(renderer), "text", modest_text_utils_get_display_date (date),
-                     NULL);    
-
-       set_common_flags (renderer, flags);
+       set_cell_text (renderer, modest_text_utils_get_display_date (date),
+                      flags, RENDER_CELL_STYLE_DEFAULT);
 }
 
 void
 }
 
 void
@@ -215,13 +247,8 @@ _modest_header_view_sender_receiver_cell_data  (GtkTreeViewColumn *column,
                            -1);
        
        modest_text_utils_get_display_address (address); /* string is changed in-place */
                            -1);
        
        modest_text_utils_get_display_address (address); /* string is changed in-place */
-       g_object_set (G_OBJECT(renderer),
-                     "text",
-                     address,
-                     NULL);
+       set_cell_text (renderer, address, flags, RENDER_CELL_STYLE_DEFAULT);
        g_free (address);
        g_free (address);
-
-       set_common_flags (renderer, flags);
 }
 /*
  * this for both incoming and outgoing mail, depending on the the user_data
 }
 /*
  * this for both incoming and outgoing mail, depending on the the user_data
@@ -239,14 +266,12 @@ _modest_header_view_compact_header_cell_data  (GtkTreeViewColumn *column,  GtkCe
        TnyHeaderFlags flags = 0;
        gchar *address = NULL;
        gchar *subject = NULL;
        TnyHeaderFlags flags = 0;
        gchar *address = NULL;
        gchar *subject = NULL;
-       gchar *header = NULL;
        time_t date;
        
        GtkCellRenderer *recipient_cell, *date_or_status_cell, *subject_cell,
                *attach_cell, *priority_cell,
                *recipient_box, *subject_box = NULL;
        TnyHeader *msg_header = NULL;
        time_t date;
        
        GtkCellRenderer *recipient_cell, *date_or_status_cell, *subject_cell,
                *attach_cell, *priority_cell,
                *recipient_box, *subject_box = NULL;
        TnyHeader *msg_header = NULL;
-       gchar *display_date = NULL, *tmp_date = NULL;
        TnyHeaderFlags prio = 0;
 
 
        TnyHeaderFlags prio = 0;
 
 
@@ -296,31 +321,14 @@ _modest_header_view_compact_header_cell_data  (GtkTreeViewColumn *column,  GtkCe
                      get_pixbuf_for_flag (prio), 
                      NULL);
 
                      get_pixbuf_for_flag (prio), 
                      NULL);
 
-       if (subject && strlen (subject)) {
-               gchar* escaped_subject = g_markup_escape_text (subject, -1);
-               g_object_set (G_OBJECT (subject_cell), "markup",
-                             escaped_subject, NULL);
-               g_free (escaped_subject);
-       } else {
-               g_object_set (G_OBJECT (subject_cell), "markup",
-                             _("mail_va_no_subject"), NULL);
-       }
-
+       set_cell_text (subject_cell, (subject && subject[0] != 0)?subject:_("mail_va_no_subject"), 
+                      flags, RENDER_CELL_STYLE_DEFAULT);
        g_free (subject);
        g_free (subject);
-       set_common_flags (subject_cell, flags);
 
        /* FIXME: we hardcode the color to #666666; instead we should use SecondaryTextColour from the
         * theme (gtkrc file) */
        modest_text_utils_get_display_address (address); /* changed in-place */
 
        /* FIXME: we hardcode the color to #666666; instead we should use SecondaryTextColour from the
         * theme (gtkrc file) */
        modest_text_utils_get_display_address (address); /* changed in-place */
-       header = g_markup_printf_escaped ("<span size='small' foreground='#666666'>%s</span>",
-                                         address);
-       g_free (address);
-       g_object_set (G_OBJECT (recipient_cell),
-                     "markup", header,
-                     NULL);
-       g_free (header);
-       header = NULL;
-       set_common_flags (recipient_cell, flags);
+       set_cell_text (recipient_cell, address, flags, RENDER_CELL_STYLE_GREY);
        
        if (header_mode == MODEST_HEADER_VIEW_COMPACT_HEADER_MODE_OUTBOX) {
                ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
        
        if (header_mode == MODEST_HEADER_VIEW_COMPACT_HEADER_MODE_OUTBOX) {
                ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
@@ -333,28 +341,14 @@ _modest_header_view_compact_header_cell_data  (GtkTreeViewColumn *column,  GtkCe
                }
                
                status_str = get_status_string (status);
                }
                
                status_str = get_status_string (status);
-               display_date = g_strdup_printf("<span size='small' foreground='#666666'>%s</span>", status_str);
-               g_object_set (G_OBJECT (date_or_status_cell),
-                             "markup", display_date,
-                             NULL);
-               g_free (display_date);
-               display_date = NULL;
+               set_cell_text (date_or_status_cell, status_str, flags, RENDER_CELL_STYLE_GREY);
        } else {                
        } else {                
-               display_date = g_strdup_printf ("<span size='small' foreground='#666666'>%s</span>",
-                                               date ? modest_text_utils_get_display_date (date) : "");
-               g_object_set (G_OBJECT (date_or_status_cell),
-                             "markup", display_date,
-                             NULL);
-               g_free (tmp_date);
-               tmp_date = NULL;
-               g_free (display_date);
-               display_date = NULL;
+               set_cell_text (date_or_status_cell, date ? modest_text_utils_get_display_date (date) : "",
+                              flags, RENDER_CELL_STYLE_GREY);
        }
        
        if (msg_header != NULL)
                g_object_unref (msg_header);
        }
        
        if (msg_header != NULL)
                g_object_unref (msg_header);
-               
-       set_common_flags (date_or_status_cell, flags);
 }
 
 
 }
 
 
@@ -374,8 +368,7 @@ _modest_header_view_size_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer
        
        size_str = modest_text_utils_get_display_size (size);
        
        
        size_str = modest_text_utils_get_display_size (size);
        
-       g_object_set (G_OBJECT(renderer), "text", size_str, NULL);
-       set_common_flags (renderer, flags);
+       set_cell_text (renderer, size_str, flags, RENDER_CELL_STYLE_DEFAULT);
 
        g_free (size_str);
  }
 
        g_free (size_str);
  }
@@ -398,8 +391,7 @@ _modest_header_view_status_cell_data  (GtkTreeViewColumn *column,  GtkCellRender
        else           
               status_str = g_strdup(_("mcen_li_outbox_waiting"));
        
        else           
               status_str = g_strdup(_("mcen_li_outbox_waiting"));
        
-       g_object_set (G_OBJECT(renderer), "text", status_str, NULL);
-       set_common_flags (renderer, flags);
+       set_cell_text (renderer, status_str, flags, RENDER_CELL_STYLE_DEFAULT);
 
        g_free (status_str);
  }
 
        g_free (status_str);
  }
index 0d93336..9e04043 100644 (file)
@@ -389,12 +389,15 @@ modest_header_view_set_columns (ModestHeaderView *self, const GList *columns, Tn
        g_object_set (G_OBJECT (renderer_subject),
                      "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 1.0,
                      NULL);
        g_object_set (G_OBJECT (renderer_subject),
                      "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 1.0,
                      NULL);
+       gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer_subject), 1);
        g_object_set (G_OBJECT (renderer_recpt),
                      "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 0.0,
                      NULL);
        g_object_set (G_OBJECT (renderer_recpt),
                      "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 0.0,
                      NULL);
+       gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer_recpt), 1);
        g_object_set(G_OBJECT(renderer_compact_date_or_status),
                     "xalign", 1.0, "yalign", 0.0,
                     NULL);
        g_object_set(G_OBJECT(renderer_compact_date_or_status),
                     "xalign", 1.0, "yalign", 0.0,
                     NULL);
+       gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer_compact_date_or_status), 1);
        g_object_set (G_OBJECT (renderer_priority),
                      "yalign", 1.0, NULL);
        g_object_set (G_OBJECT (renderer_attach),
        g_object_set (G_OBJECT (renderer_priority),
                      "yalign", 1.0, NULL);
        g_object_set (G_OBJECT (renderer_attach),