On showing a calendar event in view, emit a signal to handle it in upper layers
authorJosé Dapena Paz <jdapena@igalia.com>
Thu, 17 Dec 2009 16:29:29 +0000 (17:29 +0100)
committerJosé Dapena Paz <jdapena@igalia.com>
Mon, 18 Jan 2010 15:49:56 +0000 (16:49 +0100)
src/widgets/modest-gtkhtml-msg-view.c
src/widgets/modest-msg-view.c
src/widgets/modest-msg-view.h

index 9941c1e..35810e4 100644 (file)
@@ -261,6 +261,8 @@ struct _ModestGtkhtmlMsgViewPrivate {
        GtkWidget   *calendar_box;
        GtkWidget   *calendar_icon;
 #endif
+       GtkWidget   *calendar_actions_box;
+       GtkWidget   *calendar_actions_container;
 
        /* internal adjustments for set_scroll_adjustments */
        GtkAdjustment *hadj;
@@ -1250,6 +1252,7 @@ modest_gtkhtml_msg_view_init (ModestGtkhtmlMsgView *obj)
                                                                   
                gtk_widget_hide_all (priv->priority_box);
        }
+       priv->calendar_actions_box = NULL;
        priv->calendar_icon = gtk_image_new ();
        gtk_image_set_from_icon_name (GTK_IMAGE (priv->calendar_icon), MODEST_HEADER_ICON_CALENDAR, GTK_ICON_SIZE_MENU);
        gtk_misc_set_alignment (GTK_MISC (priv->calendar_icon), 0.0, 0.5);
@@ -1279,6 +1282,9 @@ modest_gtkhtml_msg_view_init (ModestGtkhtmlMsgView *obj)
                g_free (att_label);
        }
 
+       priv->calendar_actions_container = gtk_vbox_new (FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (priv->headers_box), priv->calendar_actions_container, FALSE, FALSE, 0);
+
 #ifndef MODEST_TOOLKIT_HILDON2
        separator = gtk_hseparator_new ();
        gtk_box_pack_start (GTK_BOX(priv->headers_box), separator, FALSE, FALSE, 0);
@@ -2793,9 +2799,19 @@ set_calendar (ModestGtkhtmlMsgView *self, TnyHeader *header, TnyMsg *msg)
        g_return_if_fail (MODEST_IS_GTKHTML_MSG_VIEW (self));
        priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE (self);
 
+       if (priv->calendar_actions_box) {
+               gtk_widget_destroy (priv->calendar_actions_box);
+               priv->calendar_actions_box = NULL;
+       }
+
        calendar_part = modest_tny_msg_find_calendar (TNY_MSG (msg));
 
        if (calendar_part) {
+               priv->calendar_actions_box = gtk_vbox_new (FALSE, 0);
+               gtk_widget_show (priv->calendar_actions_box);
+               gtk_box_pack_start (GTK_BOX (priv->calendar_actions_container), priv->calendar_actions_box, FALSE, FALSE, 0);
+               gtk_widget_show (priv->calendar_actions_container);
+               g_signal_emit_by_name (G_OBJECT (self), "handle-calendar", calendar_part, priv->calendar_actions_box);
                gtk_widget_show_all  (priv->calendar_box);
                g_object_unref (calendar_part);
        } else {
index ebbbfd0..aeabe12 100644 (file)
@@ -40,6 +40,7 @@ enum {
        FETCH_IMAGE_SIGNAL,
        SHOW_DETAILS_SIGNAL,
        LIMIT_ERROR_SIGNAL,
+       HANDLE_CALENDAR_SIGNAL,
        LAST_SIGNAL
 };
 static guint signals[LAST_SIGNAL] = {0};
@@ -207,6 +208,14 @@ modest_msg_view_base_init (gpointer g_class)
                                      g_cclosure_marshal_VOID__VOID,
                                      G_TYPE_NONE, 0);
                
+               signals[HANDLE_CALENDAR_SIGNAL] =
+                       g_signal_new ("handle_calendar",
+                                     MODEST_TYPE_MSG_VIEW,
+                                     G_SIGNAL_RUN_FIRST,
+                                     G_STRUCT_OFFSET(ModestMsgViewIface, handle_calendar),
+                                     NULL, NULL,
+                                     modest_marshal_VOID__OBJECT_OBJECT,
+                                     G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
                initialized = TRUE;
        }
 }
index 0ee8b1c..c81be1b 100644 (file)
@@ -88,6 +88,7 @@ struct _ModestMsgViewIface {
        void (*request_fetch_images_func) (ModestMsgView *msgview);
        gboolean (*has_blocked_external_images_func) (ModestMsgView *msgview);
        void (*limit_error)        (ModestMsgView *msgview);
+       void (*handle_calendar)    (ModestMsgView *msgview, TnyMimePart *calendar_part, GtkContainer *container);
 };