Added implementation of loading method in ModestMailHeaderView interface
authorJose Dapena Paz <jdapena@igalia.com>
Mon, 30 Mar 2009 08:42:16 +0000 (08:42 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 30 Mar 2009 08:42:16 +0000 (08:42 +0000)
and specific classes, to hide the details button in compact header on
loading.

pmo-trunk-r8461

src/widgets/modest-compact-mail-header-view.c
src/widgets/modest-compact-mail-header-view.h
src/widgets/modest-expander-mail-header-view.c
src/widgets/modest-expander-mail-header-view.h
src/widgets/modest-mail-header-view.c
src/widgets/modest-mail-header-view.h

index 851377c..e826aa8 100644 (file)
@@ -56,6 +56,7 @@ struct _ModestCompactMailHeaderViewPriv
        GtkWidget    *fromto_contents;
        GtkWidget    *priority_icon;
        GtkWidget    *details_label;
+       GtkWidget    *details_button;
        GtkWidget    *date_label;
        GtkWidget    *subject_label;
 
@@ -67,6 +68,8 @@ struct _ModestCompactMailHeaderViewPriv
        TnyHeader    *header;
        TnyHeaderFlags priority_flags;
 
+       gboolean     is_loading;
+
        time_t       date_to_show;
        ModestDatetimeFormatter *datetime_formatter;
 };
@@ -94,6 +97,10 @@ static TnyHeaderFlags modest_compact_mail_header_view_get_priority_default (Mode
 static void modest_compact_mail_header_view_set_priority (ModestMailHeaderView *self, TnyHeaderFlags flags);
 static void modest_compact_mail_header_view_set_priority_default (ModestMailHeaderView *headers_view,
                                                                   TnyHeaderFlags flags);
+static gboolean modest_compact_mail_header_view_get_loading (ModestMailHeaderView *headers_view);
+static gboolean modest_compact_mail_header_view_get_loading_default (ModestMailHeaderView *headers_view);
+static void modest_compact_mail_header_view_set_loading (ModestMailHeaderView *headers_view, gboolean is_loading);
+static void modest_compact_mail_header_view_set_loading_default (ModestMailHeaderView *headers_view, gboolean is_loading);
 static const GtkWidget *modest_compact_mail_header_view_add_custom_header (ModestMailHeaderView *self,
                                                                            const gchar *label,
                                                                            GtkWidget *custom_widget,
@@ -326,7 +333,6 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
        ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)instance;
        ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
        GtkWidget *first_hbox, *second_hbox, *vbox, *main_vbox;
-       GtkWidget *details_button;
        PangoAttrList *attr_list;
        GtkWidget *main_align;
 
@@ -351,15 +357,15 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
        gtk_label_set_attributes (GTK_LABEL (priv->subject_label), attr_list);
        pango_attr_list_unref (attr_list);
 
-       details_button = gtk_button_new ();
+       priv->details_button = gtk_button_new ();
        priv->details_label = gtk_label_new (_("mcen_ti_message_properties"));
        gtk_misc_set_alignment (GTK_MISC (priv->details_label), 1.0, 0.5);
-       gtk_container_add (GTK_CONTAINER (details_button), priv->details_label);
-       gtk_button_set_relief (GTK_BUTTON (details_button), GTK_RELIEF_NONE);
+       gtk_container_add (GTK_CONTAINER (priv->details_button), priv->details_label);
+       gtk_button_set_relief (GTK_BUTTON (priv->details_button), GTK_RELIEF_NONE);
 
        gtk_box_pack_end (GTK_BOX (priv->subject_box), priv->subject_label, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (first_hbox), priv->subject_box, TRUE, TRUE, 0);
-       gtk_box_pack_start (GTK_BOX (first_hbox), details_button, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (first_hbox), priv->details_button, FALSE, FALSE, 0);
 
        second_hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_DOUBLE);
 
@@ -386,7 +392,7 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
 
        g_signal_connect (G_OBJECT (self), "notify::style", G_CALLBACK (on_notify_style), (gpointer) self);
 
-       g_signal_connect (G_OBJECT (details_button), "clicked", G_CALLBACK (on_details_button_clicked), instance);
+       g_signal_connect (G_OBJECT (priv->details_button), "clicked", G_CALLBACK (on_details_button_clicked), instance);
 
        priv->datetime_formatter = modest_datetime_formatter_new ();
        g_signal_connect (G_OBJECT (priv->datetime_formatter), "format-changed", 
@@ -408,6 +414,7 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
 
        priv->is_outgoing = FALSE;
        priv->is_draft = FALSE;
+       priv->is_loading = FALSE;
 
        return;
 }
@@ -460,6 +467,8 @@ modest_mail_header_view_init (gpointer g, gpointer iface_data)
 
        klass->get_priority = modest_compact_mail_header_view_get_priority;
        klass->set_priority = modest_compact_mail_header_view_set_priority;
+       klass->get_loading = modest_compact_mail_header_view_get_loading;
+       klass->set_loading = modest_compact_mail_header_view_set_loading;
        klass->add_custom_header = modest_compact_mail_header_view_add_custom_header;
 
        return;
@@ -477,6 +486,8 @@ modest_compact_mail_header_view_class_init (ModestCompactMailHeaderViewClass *kl
        klass->clear_func = modest_compact_mail_header_view_clear_default;
        klass->set_priority_func = modest_compact_mail_header_view_set_priority_default;
        klass->get_priority_func = modest_compact_mail_header_view_get_priority_default;
+       klass->set_loading_func = modest_compact_mail_header_view_set_loading_default;
+       klass->get_loading_func = modest_compact_mail_header_view_get_loading_default;
        klass->add_custom_header_func = modest_compact_mail_header_view_add_custom_header_default;
        object_class->finalize = modest_compact_mail_header_view_finalize;
 
@@ -584,6 +595,45 @@ modest_compact_mail_header_view_set_priority_default (ModestMailHeaderView *head
        }
 }
 
+static gboolean
+modest_compact_mail_header_view_get_loading (ModestMailHeaderView *headers_view)
+{
+       return MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->get_loading_func (headers_view);
+}
+
+static gboolean
+modest_compact_mail_header_view_get_loading_default (ModestMailHeaderView *headers_view)
+{
+       ModestCompactMailHeaderViewPriv *priv;
+
+       g_return_val_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (headers_view), FALSE);
+       priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
+
+       return priv->is_loading;
+}
+
+static void
+modest_compact_mail_header_view_set_loading (ModestMailHeaderView *headers_view, gboolean is_loading)
+{
+       MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->set_loading_func (headers_view, is_loading);
+}
+
+static void
+modest_compact_mail_header_view_set_loading_default (ModestMailHeaderView *headers_view, gboolean is_loading)
+{
+       ModestCompactMailHeaderViewPriv *priv;
+
+       g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (headers_view));
+       priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
+
+       priv->is_loading = is_loading;
+       if (is_loading) {
+               gtk_widget_hide (priv->details_button);
+       } else {
+               gtk_widget_show (priv->details_button);
+       }
+}
+
 static void 
 on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata)
 {
index a357a53..9b77668 100644 (file)
@@ -63,6 +63,8 @@ struct _ModestCompactMailHeaderViewClass
        void (*clear_func) (TnyHeaderView *self);
        void (*set_priority_func) (ModestMailHeaderView *self, TnyHeaderFlags flags);
        TnyHeaderFlags (*get_priority_func) (ModestMailHeaderView *self);
+       void (*set_loading_func) (ModestMailHeaderView *self, gboolean is_loading);
+       gboolean (*get_loading_func) (ModestMailHeaderView *self);
        const GtkWidget * (*add_custom_header_func) (ModestMailHeaderView *self,
                                                     const gchar *label,
                                                     GtkWidget *custom_widget,
index d5258ff..41e0238 100644 (file)
@@ -56,6 +56,7 @@ struct _ModestExpanderMailHeaderViewPriv
        GtkSizeGroup *labels_size_group;
        gboolean     is_outgoing;
        gboolean     is_draft;
+       gboolean     is_loading;
        TnyHeader    *header;
        TnyHeaderFlags priority_flags;
        ModestDatetimeFormatter *datetime_formatter;
@@ -84,6 +85,10 @@ 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_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,
@@ -481,6 +486,8 @@ modest_expander_mail_header_view_instance_init (GTypeInstance *instance, gpointe
        priv->is_outgoing = FALSE;
        priv->is_draft = FALSE;
 
+       priv->is_loading = FALSE;
+
        return;
 }
 
@@ -529,6 +536,8 @@ 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->add_custom_header = modest_expander_mail_header_view_add_custom_header;
 
        return;
@@ -546,6 +555,8 @@ 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->add_custom_header_func = modest_expander_mail_header_view_add_custom_header_default;
 
        object_class->finalize = modest_expander_mail_header_view_finalize;
@@ -654,3 +665,37 @@ modest_expander_mail_header_view_set_priority_default (ModestMailHeaderView *hea
                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;
+}
index 0bdd712..87288c1 100644 (file)
@@ -63,6 +63,8 @@ struct _ModestExpanderMailHeaderViewClass
        void (*clear_func) (TnyHeaderView *self);
        void (*set_priority_func) (ModestMailHeaderView *self, TnyHeaderFlags flags);
        TnyHeaderFlags (*get_priority_func) (ModestMailHeaderView *self);
+       void (*set_loading_func) (ModestMailHeaderView *self, gboolean is_loading);
+       gboolean (*get_loading_func) (ModestMailHeaderView *self);
        const GtkWidget *(*add_custom_header_func) (ModestMailHeaderView *self,
                                                    const gchar *label,
                                                    GtkWidget *custom_widget,
index 7efb1dc..c9a8977 100644 (file)
@@ -51,6 +51,18 @@ modest_mail_header_view_set_priority (ModestMailHeaderView *self, TnyHeaderFlags
        MODEST_MAIL_HEADER_VIEW_GET_IFACE (self)->set_priority (self, flags);
 }
 
+gboolean
+modest_mail_header_view_get_loading (ModestMailHeaderView *self)
+{
+       return MODEST_MAIL_HEADER_VIEW_GET_IFACE (self)->get_loading (self);
+}
+
+void
+modest_mail_header_view_set_loading (ModestMailHeaderView *self, gboolean is_loading)
+{
+       MODEST_MAIL_HEADER_VIEW_GET_IFACE (self)->set_loading (self, is_loading);
+}
+
 const GtkWidget *
 modest_mail_header_view_add_custom_header (ModestMailHeaderView *self,
                                           const gchar *label,
index 32aa9f2..9b50a8c 100644 (file)
@@ -54,6 +54,8 @@ struct _ModestMailHeaderViewIface {
                                               GtkWidget *custom_widget,
                                               gboolean with_expander,
                                               gboolean start);
+       void (*set_loading) (ModestMailHeaderView *self, gboolean is_loading);
+       gboolean (*get_loading) (ModestMailHeaderView *self);
        
        /* signals */
        void (*show_details) (ModestMailHeaderView *msgview,
@@ -80,6 +82,8 @@ const GtkWidget *modest_mail_header_view_add_custom_header (ModestMailHeaderView
                                                            GtkWidget *custom_widget,
                                                            gboolean with_expander,
                                                            gboolean start);
+void modest_mail_header_view_set_loading (ModestMailHeaderView *self, gboolean is_loading);
+gboolean modest_mail_header_view_get_loading (ModestMailHeaderView *self);
 
 
 G_END_DECLS