* Dim the "Move to" icon and menu entry when a message is
[modest] / src / gnome / modest-msg-view-window.c
index 2b5c155..68fe792 100644 (file)
@@ -57,6 +57,8 @@ struct _ModestMsgViewWindowPrivate {
        GtkWidget   *toolbar;
        GtkWidget   *menubar;
        GtkWidget   *msg_view;
+
+       gchar *msg_uid;
 };
 
 #define MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
@@ -123,6 +125,23 @@ modest_msg_view_window_get_type (void)
 }
 
 static void
+save_state (ModestWindow *self)
+{
+       modest_widget_memory_save (modest_runtime_get_conf (),
+                                  G_OBJECT(self), 
+                                  MODEST_CONF_MSG_VIEW_WINDOW_KEY);
+}
+
+
+static void
+restore_settings (ModestWindow *self)
+{
+       modest_widget_memory_restore (modest_runtime_get_conf (),
+                                     G_OBJECT(self), 
+                                     MODEST_CONF_MSG_VIEW_WINDOW_KEY);
+}
+
+static void
 modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
 {
        GObjectClass *gobject_class;
@@ -132,6 +151,9 @@ modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
        gobject_class->finalize = modest_msg_view_window_finalize;
 
        g_type_class_add_private (gobject_class, sizeof(ModestMsgViewWindowPrivate));
+
+       ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
+       modest_window_class->save_state_func = save_state;
 }
 
 static void
@@ -140,24 +162,10 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj)
        ModestMsgViewWindowPrivate *priv;
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
 
-       priv->toolbar       = NULL;
-       priv->menubar       = NULL;
-       priv->msg_view      = NULL;
-}
-
-static void
-save_settings (ModestMsgViewWindow *self)
-{
-       modest_widget_memory_save (modest_runtime_get_conf (),
-                                   G_OBJECT(self), "modest-msg-view-window");
-}
-
-
-static void
-restore_settings (ModestMsgViewWindow *self)
-{
-       modest_widget_memory_restore (modest_runtime_get_conf (),
-                                     G_OBJECT(self), "modest-msg-view-window");
+       priv->toolbar  = NULL;
+       priv->menubar  = NULL;
+       priv->msg_view = NULL;
+       priv->msg_uid  = NULL;
 }
 
 
@@ -190,7 +198,16 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
 
 static void
 modest_msg_view_window_finalize (GObject *obj)
-{      
+{
+       ModestMsgViewWindowPrivate *priv;
+
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
+
+       if (priv->msg_uid) {
+               g_free (priv->msg_uid);
+               msg_uid = NULL;
+       }
+
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -199,13 +216,15 @@ modest_msg_view_window_finalize (GObject *obj)
 static gboolean
 on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
 {
-       save_settings (self);
+       modest_window_save_state (MODEST_WINDOW(self));
        return FALSE;
 }
 
 
 ModestWindow *
-modest_msg_view_window_new (TnyMsg *msg, const gchar *account)
+modest_msg_view_window_new_for_attachment (TnyMsg *msg, 
+                           const gchar *modest_account_name, 
+                           const gchar *msg_uid)
 {
        GObject *obj;
        ModestMsgViewWindowPrivate *priv;
@@ -221,6 +240,8 @@ modest_msg_view_window_new (TnyMsg *msg, const gchar *account)
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
        parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
 
+       priv->msg_uid = g_strdup (msg_uid);
+
        modest_window_set_active_account (MODEST_WINDOW(obj), account);
        
        parent_priv->ui_manager = gtk_ui_manager_new();
@@ -258,7 +279,7 @@ modest_msg_view_window_new (TnyMsg *msg, const gchar *account)
 
        /* Init window */
        init_window (MODEST_MSG_VIEW_WINDOW(obj), msg);
-       restore_settings (MODEST_MSG_VIEW_WINDOW(obj));
+       restore_settings (MODEST_WINDOW(obj));
 
        header = tny_msg_get_header (msg);
        if (header)
@@ -291,18 +312,41 @@ modest_msg_view_window_get_message (ModestMsgViewWindow *self)
        return modest_msg_view_get_message (MODEST_MSG_VIEW(msg_view));
 }
 
+const gchar*
+modest_msg_view_window_get_message_uid (ModestMsgViewWindow *self)
+{
+       TnyMsg *msg;
+       TnyHeader *header;
+       const gchar *retval = NULL;
+
+       msg = modest_msg_view_window_get_message (self);
+
+       if (!msg)
+               return NULL;
+
+       header = tny_msg_get_header (msg);
+       if (header) {
+               retval = tny_header_get_uid (header);
+               g_object_unref (header);
+       }
+       g_object_unref (msg);
+
+       return retval;
+}
+
 ModestWindow*   
 modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
-                                             const gchar *account, 
+                                             const gchar *modest_account_name, 
+                                             const gchar *msg_uid,
                                              GtkTreeModel *model, 
-                                             GtkTreeIter iter)
+                                             GtkTreeRowReference *row_reference)
 {
        /* Currently we simply redirect to new constructor. It should store a
           reference to the header list model, to enable next/prev message
           actions */
        g_message ("partially implemented %s", __FUNCTION__);
 
-       return modest_msg_view_window_new (msg, account);
+       return modest_msg_view_window_new_for_attachment (msg, account);
 }
 
 
@@ -319,3 +363,20 @@ modest_msg_view_window_select_previous_message (ModestMsgViewWindow *window)
        g_message ("not implemented %s", __FUNCTION__);
        return FALSE;
 }
+
+void
+modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart *mime_part)
+{
+       g_message ("not implemented %s", __FUNCTION__);
+}
+
+void
+modest_msg_view_window_save_attachments (ModestMsgViewWindow *window, GList *mime_parts)
+{
+       g_message ("not implemented %s", __FUNCTION__);
+}
+void
+modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, GList *mime_parts)
+{
+       g_message ("not implemented %s", __FUNCTION__);
+}