Added the function that quotes emails
[modest] / src / widgets / modest-expander-mail-header-view.c
index dcb4f0c..c6a3aef 100644 (file)
 
 #include <string.h>
 #include <gtk/gtk.h>
+#include <modest-defs.h>
 #include <modest-text-utils.h>
 #include <modest-expander-mail-header-view.h>
 #include <modest-tny-folder.h>
 #include <modest-recpt-view.h>
+#include <modest-icon-names.h>
+#include <modest-datetime-formatter.h>
 
 static GObjectClass *parent_class = NULL;
 
@@ -53,8 +56,10 @@ struct _ModestExpanderMailHeaderViewPriv
        GtkSizeGroup *labels_size_group;
        gboolean     is_outgoing;
        gboolean     is_draft;
+       gboolean     is_loading;
        TnyHeader    *header;
        TnyHeaderFlags priority_flags;
+       ModestDatetimeFormatter *datetime_formatter;
 };
 
 #define MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_PRIVATE(o)        \
@@ -80,6 +85,12 @@ static TnyHeaderFlags modest_expander_mail_header_view_get_priority_default (Mod
 static void modest_expander_mail_header_view_set_priority (ModestMailHeaderView *self, TnyHeaderFlags flags);
 static void modest_expander_mail_header_view_set_priority_default (ModestMailHeaderView *headers_view,
                                                                   TnyHeaderFlags flags);
+static gboolean modest_expander_mail_header_view_get_loading (ModestMailHeaderView *headers_view);
+static gboolean modest_expander_mail_header_view_get_loading_default (ModestMailHeaderView *headers_view);
+static void modest_expander_mail_header_view_set_branding (ModestMailHeaderView *headers_view, const gchar *brand_name, const GdkPixbuf *brand_icon);
+static void modest_expander_mail_header_view_set_branding_default (ModestMailHeaderView *headers_view, const gchar *brand_name, const GdkPixbuf *brand_icon);
+static void modest_expander_mail_header_view_set_loading (ModestMailHeaderView *headers_view, gboolean is_loading);
+static void modest_expander_mail_header_view_set_loading_default (ModestMailHeaderView *headers_view, gboolean is_loading);
 static const GtkWidget *modest_expander_mail_header_view_add_custom_header (ModestMailHeaderView *self,
                                                                            const gchar *label,
                                                                            GtkWidget *custom_widget,
@@ -103,16 +114,16 @@ static void expander_activate (GtkWidget *expander, ModestExpanderMailHeaderView
 static void
 add_date_time_header (ModestExpanderMailHeaderView *mail_header, const gchar *name, time_t date)
 {
-       const guint BUF_SIZE = 64; 
-       gchar date_buf [BUF_SIZE];
-       gchar time_buf [BUF_SIZE];
+       const gchar *date_buf;
+       const gchar *time_buf;
 
        ModestExpanderMailHeaderViewPriv *priv = MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_PRIVATE (mail_header);
        GtkWidget *hbox, *date_hbox, *time_hbox;
        GtkWidget *label;
 
-       modest_text_utils_strftime (date_buf, BUF_SIZE, "%x", date);
-       modest_text_utils_strftime (time_buf, BUF_SIZE, "%X", date);
+       date_buf = modest_datetime_formatter_format_date (priv->datetime_formatter, date);
+       time_buf = modest_datetime_formatter_format_time (priv->datetime_formatter, date);
+
 
        hbox = gtk_hbox_new (FALSE, 48);
        date_hbox = gtk_hbox_new (FALSE, 12);
@@ -442,6 +453,8 @@ modest_expander_mail_header_view_instance_init (GTypeInstance *instance, gpointe
 
        priv->header = NULL;
 
+       priv->datetime_formatter = modest_datetime_formatter_new ();
+
        priv->expander = gtk_expander_new (NULL);
        priv->main_vbox = gtk_vbox_new (FALSE, 1);
        gtk_box_pack_start (GTK_BOX (instance), priv->expander, FALSE, FALSE, 0);
@@ -475,6 +488,8 @@ modest_expander_mail_header_view_instance_init (GTypeInstance *instance, gpointe
        priv->is_outgoing = FALSE;
        priv->is_draft = FALSE;
 
+       priv->is_loading = FALSE;
+
        return;
 }
 
@@ -484,6 +499,11 @@ modest_expander_mail_header_view_finalize (GObject *object)
        ModestExpanderMailHeaderView *self = (ModestExpanderMailHeaderView *)object;    
        ModestExpanderMailHeaderViewPriv *priv = MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_PRIVATE (self);
 
+       if (priv->datetime_formatter) {
+               g_object_unref (priv->datetime_formatter);
+               priv->datetime_formatter = NULL;
+       }
+
        if (G_LIKELY (priv->header))
                g_object_unref (G_OBJECT (priv->header));
        priv->header = NULL;
@@ -518,6 +538,9 @@ modest_mail_header_view_init (gpointer g, gpointer iface_data)
 
        klass->get_priority = modest_expander_mail_header_view_get_priority;
        klass->set_priority = modest_expander_mail_header_view_set_priority;
+       klass->get_loading = modest_expander_mail_header_view_get_loading;
+       klass->set_loading = modest_expander_mail_header_view_set_loading;
+       klass->set_branding = modest_expander_mail_header_view_set_branding;
        klass->add_custom_header = modest_expander_mail_header_view_add_custom_header;
 
        return;
@@ -535,6 +558,9 @@ modest_expander_mail_header_view_class_init (ModestExpanderMailHeaderViewClass *
        klass->clear_func = modest_expander_mail_header_view_clear_default;
        klass->set_priority_func = modest_expander_mail_header_view_set_priority_default;
        klass->get_priority_func = modest_expander_mail_header_view_get_priority_default;
+       klass->set_loading_func = modest_expander_mail_header_view_set_loading_default;
+       klass->get_loading_func = modest_expander_mail_header_view_get_loading_default;
+       klass->set_branding_func = modest_expander_mail_header_view_set_branding_default;
        klass->add_custom_header_func = modest_expander_mail_header_view_add_custom_header_default;
 
        object_class->finalize = modest_expander_mail_header_view_finalize;
@@ -634,12 +660,61 @@ modest_expander_mail_header_view_set_priority_default (ModestMailHeaderView *hea
                        priv->priority_icon = NULL;
                }
        } else if (priv->priority_flags == TNY_HEADER_FLAG_HIGH_PRIORITY) {
-               priv->priority_icon = gtk_image_new_from_icon_name ("qgn_list_messaging_high", GTK_ICON_SIZE_MENU);
+               priv->priority_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_HIGH, GTK_ICON_SIZE_MENU);
                gtk_box_pack_start (GTK_BOX (priv->subject_box), priv->priority_icon, FALSE, FALSE, 0);
                gtk_widget_show (priv->priority_icon);
        } else if (priv->priority_flags == TNY_HEADER_FLAG_LOW_PRIORITY) {
-               priv->priority_icon = gtk_image_new_from_icon_name ("qgn_list_messaging_low", GTK_ICON_SIZE_MENU);
+               priv->priority_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_LOW, GTK_ICON_SIZE_MENU);
                gtk_box_pack_start (GTK_BOX (priv->subject_box), priv->priority_icon, FALSE, FALSE, 0);
                gtk_widget_show (priv->priority_icon);
        }
 }
+
+static gboolean
+modest_expander_mail_header_view_get_loading (ModestMailHeaderView *headers_view)
+{
+       return MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->get_loading_func (headers_view);
+}
+
+static gboolean
+modest_expander_mail_header_view_get_loading_default (ModestMailHeaderView *headers_view)
+{
+       ModestExpanderMailHeaderViewPriv *priv;
+
+       g_return_val_if_fail (MODEST_IS_EXPANDER_MAIL_HEADER_VIEW (headers_view), FALSE);
+       priv = MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
+
+       return priv->is_loading;
+}
+
+static void
+modest_expander_mail_header_view_set_loading (ModestMailHeaderView *headers_view, gboolean is_loading)
+{
+       MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->set_loading_func (headers_view, is_loading);
+}
+
+static void
+modest_expander_mail_header_view_set_loading_default (ModestMailHeaderView *headers_view, gboolean is_loading)
+{
+       ModestExpanderMailHeaderViewPriv *priv;
+
+       g_return_if_fail (MODEST_IS_EXPANDER_MAIL_HEADER_VIEW (headers_view));
+       priv = MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
+
+       priv->is_loading = is_loading;
+}
+
+static void
+modest_expander_mail_header_view_set_branding (ModestMailHeaderView *headers_view, const gchar *brand_name, const GdkPixbuf *brand_icon)
+{
+       MODEST_EXPANDER_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->set_branding_func (headers_view, brand_name, brand_icon);
+}
+
+static void
+modest_expander_mail_header_view_set_branding_default (ModestMailHeaderView *headers_view, const gchar *brand_name, const GdkPixbuf *brand_icon)
+{
+       g_return_if_fail (MODEST_IS_EXPANDER_MAIL_HEADER_VIEW (headers_view));
+
+       /* Empty implementation */
+       return;
+}