* implement TODO item i001:
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Wed, 7 Feb 2007 11:20:38 +0000 (11:20 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Wed, 7 Feb 2007 11:20:38 +0000 (11:20 +0000)
  - message view widget for gtk/maemo, activated
    with double-clicking header

pmo-trunk-r794

TODO
src/gtk/modest-msg-view-window.c
src/gtk/ui/modest-msg-view-window-ui.xml
src/maemo/Makefile.am
src/maemo/modest-msg-view-window.c [new file with mode: 0644]
src/maemo/ui/modest-msg-view-window-ui.xml [new file with mode: 0644]
src/modest-ui-actions.h
src/modest-ui.c

diff --git a/TODO b/TODO
index 2b0df41..65fb723 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 todo
 ----
-i001: add a message view window; it's quite different from the edit view,
-      as it is readonly, and will use the html-view instead of text-view
 i002: message view and message edit window should know what account they apply to;
       thus, the 'From:' information and TransportAccount can be decided
 i003: when creating a new message, the information should be set according to i002
@@ -27,7 +25,8 @@ i018: make d&d work
 done
 ----
 i016:: add 'make default' to the account editor
-
+i001: add a message view window; it's quite different from the edit view,
+      as it is readonly, and will use the html-view instead of text-view
 
 later
 -----
index e80f700..9abff56 100644 (file)
@@ -138,7 +138,7 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
        parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
 
-       priv->msg_view = modest_msg_view_new (NULL);
+       priv->msg_view = modest_msg_view_new (msg);
        main_vbox = gtk_vbox_new  (FALSE, 6);
        
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->menubar, FALSE, FALSE, 0);
@@ -196,7 +196,7 @@ modest_msg_view_window_new (TnyMsg *msg)
        gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-view-window-ui.xml",
                                         &error);
        if (error) {
-               g_printerr ("modest: could not merge modest-edit-msg-window-ui.xml: %s\n", error->message);
+               g_printerr ("modest: could not merge modest-msg-view-window-ui.xml: %s\n", error->message);
                g_error_free (error);
                error = NULL;
        }
@@ -219,8 +219,7 @@ modest_msg_view_window_new (TnyMsg *msg)
        gtk_window_set_title (GTK_WINDOW(obj), "Modest");
        gtk_window_set_icon_from_file (GTK_WINDOW(obj), MODEST_APP_ICON, NULL);
 
-       g_signal_connect (G_OBJECT(obj), "delete-event",
-                         G_CALLBACK(on_delete_event), obj);
+       g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj);
 
        return (ModestWindow *) (obj);
 }
index a41a32b..e0a75a4 100644 (file)
     </menu>
 
     <menu name="ActionsMenu" action="Actions">
-      <menuitem name="ActionsNewMenu" action="ActionsNew"/>
       <menuitem name="ActionsReplyMenu" action="ActionsReply"/>
+      <menuitem name="ActionsReplyAllMenu" action="ActionsReplyAll"/>
       <menuitem name="ActionsForwardMenu" action="ActionsForward"/>
-      <menuitem name="ActionsBounceMenu" action="ActionsBounce"/>
       <separator/>
       <menuitem name="ActionsFolderNewMenu" action="ActionsFolderNew"/>
       <menuitem name="ActionsFolderDeleteMenu" action="ActionsFolderDelete"/>
@@ -57,8 +56,6 @@
   </menubar>
 
   <toolbar name="ToolBar">
-    <toolitem action="ActionsNew"/>
-    <separator/>
     <toolitem action="ActionsReply"/>
     <toolitem action="ActionsReplyAll"/>
     <toolitem action="ActionsForward"/>
index d9dc019..54a5500 100644 (file)
@@ -51,7 +51,8 @@ libmodest_ui_la_SOURCES=              \
        modest-store-widget.c         \
        modest-store-widget.h         \
        modest-transport-widget.c     \
-       modest-transport-widget.h     
+       modest-transport-widget.h     \
+        modest-msg-view-window.c       
 
 
 LDADD = \
@@ -66,7 +67,8 @@ pixmap_DATA = $(PIXMAP_FILES)
 
 UI_FILES=\
        ui/modest-ui.xml \
-       ui/modest-edit-msg-window-ui.xml
+       ui/modest-edit-msg-window-ui.xml \
+       ui/modest-msg-view-window-ui.xml
 
 uidir = $(datadir)/modest/ui
 ui_DATA = $(UI_FILES)
diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c
new file mode 100644 (file)
index 0000000..2a23c84
--- /dev/null
@@ -0,0 +1,255 @@
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <glib/gi18n.h>
+#include <string.h>
+#include <tny-account-store.h>
+#include <tny-simple-list.h>
+#include <modest-tny-msg.h>
+#include <modest-msg-view-window.h>
+#include <modest-main-window-ui.h>
+#include <modest-widget-memory.h>
+#include <modest-runtime.h>
+#include <modest-window-priv.h>
+
+static void  modest_msg_view_window_class_init   (ModestMsgViewWindowClass *klass);
+static void  modest_msg_view_window_init         (ModestMsgViewWindow *obj);
+static void  modest_msg_view_window_finalize     (GObject *obj);
+
+/* list my signals */
+enum {
+       /* MY_SIGNAL_1, */
+       /* MY_SIGNAL_2, */
+       LAST_SIGNAL
+};
+
+typedef struct _ModestMsgViewWindowPrivate ModestMsgViewWindowPrivate;
+struct _ModestMsgViewWindowPrivate {
+
+       GtkWidget   *toolbar;
+       GtkWidget   *menubar;
+       GtkWidget   *msg_view;
+};
+
+#define MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+                                                    MODEST_TYPE_MSG_VIEW_WINDOW, \
+                                                    ModestMsgViewWindowPrivate))
+/* globals */
+static GtkWindowClass *parent_class = NULL;
+
+/* uncomment the following if you have defined any signals */
+/* static guint signals[LAST_SIGNAL] = {0}; */
+
+GType
+modest_msg_view_window_get_type (void)
+{
+       static GType my_type = 0;
+       if (!my_type) {
+               static const GTypeInfo my_info = {
+                       sizeof(ModestMsgViewWindowClass),
+                       NULL,           /* base init */
+                       NULL,           /* base finalize */
+                       (GClassInitFunc) modest_msg_view_window_class_init,
+                       NULL,           /* class finalize */
+                       NULL,           /* class data */
+                       sizeof(ModestMsgViewWindow),
+                       1,              /* n_preallocs */
+                       (GInstanceInitFunc) modest_msg_view_window_init,
+                       NULL
+               };
+               my_type = g_type_register_static (MODEST_TYPE_WINDOW,
+                                                 "ModestMsgViewWindow",
+                                                 &my_info, 0);
+       }
+       return my_type;
+}
+
+static void
+modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
+{
+       GObjectClass *gobject_class;
+       gobject_class = (GObjectClass*) klass;
+
+       parent_class            = g_type_class_peek_parent (klass);
+       gobject_class->finalize = modest_msg_view_window_finalize;
+
+       g_type_class_add_private (gobject_class, sizeof(ModestMsgViewWindowPrivate));
+}
+
+static void
+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");
+}
+
+
+
+static GtkWidget *
+menubar_to_menu (GtkUIManager *ui_manager)
+{
+       GtkWidget *main_menu;
+       GtkWidget *menubar;
+       GList *iter;
+
+       /* Create new main menu */
+       main_menu = gtk_menu_new();
+
+       /* Get the menubar from the UI manager */
+       menubar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
+
+       iter = gtk_container_get_children (GTK_CONTAINER (menubar));
+       while (iter) {
+               GtkWidget *menu;
+
+               menu = GTK_WIDGET (iter->data);
+               gtk_widget_reparent(menu, main_menu);
+
+               iter = g_list_next (iter);
+       }
+       return main_menu;
+}
+
+
+static void
+init_window (ModestMsgViewWindow *obj, TnyMsg *msg)
+{
+       GtkWidget *main_vbox;
+       ModestMsgViewWindowPrivate *priv;
+       ModestWindowPrivate *parent_priv;
+       
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
+
+       priv->msg_view = modest_msg_view_new (msg);
+       main_vbox = gtk_vbox_new  (FALSE, 6);
+
+       /* Toolbar / Menubar */
+       
+       parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
+       gtk_widget_show_all (GTK_WIDGET(parent_priv->menubar));
+       hildon_window_set_menu    (HILDON_WINDOW(obj), GTK_MENU(parent_priv->menubar));
+
+       parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
+       gtk_widget_show_all (GTK_WIDGET(parent_priv->toolbar));
+       hildon_window_add_toolbar (HILDON_WINDOW(obj), GTK_TOOLBAR(parent_priv->toolbar));
+
+       gtk_box_pack_start (GTK_BOX(main_vbox), priv->msg_view, TRUE, TRUE, 6);
+       gtk_container_add   (GTK_CONTAINER(obj), main_vbox);
+       
+       gtk_widget_show_all (GTK_WIDGET(main_vbox));
+}      
+
+
+static void
+modest_msg_view_window_finalize (GObject *obj)
+{
+       G_OBJECT_CLASS(parent_class)->finalize (obj);
+}
+
+
+
+static gboolean
+on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgViewWindow *self)
+{
+       save_settings (self);
+       return FALSE;
+}
+
+
+
+ModestWindow *
+modest_msg_view_window_new (TnyMsg *msg)
+{
+       GObject *obj;
+       ModestMsgViewWindowPrivate *priv;
+       ModestWindowPrivate *parent_priv;
+       GtkActionGroup *action_group;
+       GError *error = NULL;
+
+       g_return_val_if_fail (msg, NULL);
+       
+       obj = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL);
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
+       
+       parent_priv->ui_manager = gtk_ui_manager_new();
+       action_group = gtk_action_group_new ("ModestMsgViewWindowActions");
+
+       /* Add common actions */
+       gtk_action_group_add_actions (action_group,
+                                     modest_action_entries,
+                                     G_N_ELEMENTS (modest_action_entries),
+                                     obj);
+       gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0);
+       g_object_unref (action_group);
+
+       /* Load the UI definition */
+       gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-view-window-ui.xml",
+                                        &error);
+       if (error) {
+               g_printerr ("modest: could not merge modest-msg-view-window-ui.xml: %s\n", error->message);
+               g_error_free (error);
+               error = NULL;
+       }
+       /* ****** */
+
+       /* Add accelerators */
+       gtk_window_add_accel_group (GTK_WINDOW (obj), 
+                                   gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
+       
+       /* Init window */
+       init_window (MODEST_MSG_VIEW_WINDOW(obj), msg);
+       restore_settings (MODEST_MSG_VIEW_WINDOW(obj));
+       
+       gtk_window_set_title (GTK_WINDOW(obj), "Modest");
+       gtk_window_set_icon_from_file (GTK_WINDOW(obj), MODEST_APP_ICON, NULL);
+
+       g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj);
+
+       return (ModestWindow *) (obj);
+}
diff --git a/src/maemo/ui/modest-msg-view-window-ui.xml b/src/maemo/ui/modest-msg-view-window-ui.xml
new file mode 100644 (file)
index 0000000..2495c5e
--- /dev/null
@@ -0,0 +1,57 @@
+<!--
+ * Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<ui>
+
+  <menubar name="MenuBar">
+       
+    <menu name="EditMenu" action="Edit">
+      <menuitem name="EditUndoMenu" action="EditUndo"/>
+      <separator/>
+      <menuitem name="EditCutMenu" action="EditCut"/>
+      <menuitem name="EditCopyMenu" action="EditCopy"/>
+      <menuitem name="EditPasteMenu" action="EditPaste"/>
+      <separator/>
+      <menuitem name="EditSelectMenu" action="EditSelect"/>
+      <menuitem name="EditMoveToMenu" action="EditMoveTo"/>
+    </menu> 
+
+   <menu name="CloseMenu" action="Close">
+      <menuitem name="CloseWindowMenu"     action="CloseWindow"/>
+    </menu>
+  </menubar>
+
+  <toolbar name="ToolBar">
+    <toolitem action="ToolbarMessageReply"/> 
+    <toolitem action="ToolbarMessageReplyAll"/>
+    <toolitem action="ToolbarMessageForward"/> 
+  </toolbar>
+
+  </ui>
index afe204d..8247bf1 100644 (file)
@@ -60,6 +60,9 @@ void   _modest_ui_actions_toggle_view      (GtkWidget *widget, ModestMainWindow *
 void     _modest_ui_actions_on_header_selected          (ModestHeaderView *folder_view, 
                                                         TnyHeader *header,
                                                         ModestMainWindow *main_window);
+void     _modest_ui_actions_on_header_activated         (ModestHeaderView *folder_view, 
+                                                        TnyHeader *header,
+                                                        ModestMainWindow *main_window);
 
 void     _modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
                                                         TnyFolder *folder, 
index 6aaea80..7ae7610 100644 (file)
@@ -344,6 +344,9 @@ connect_signals (ModestUI *self)
        g_signal_connect (G_OBJECT(header_view), "header_selected",
                          G_CALLBACK(_modest_ui_actions_on_header_selected), 
                          priv->main_window);
+       g_signal_connect (G_OBJECT(header_view), "header_activated",
+                         G_CALLBACK(_modest_ui_actions_on_header_activated), 
+                         priv->main_window);
        g_signal_connect (G_OBJECT(header_view), "item_not_found",
                          G_CALLBACK(_modest_ui_actions_on_item_not_found), 
                          priv->main_window);
@@ -806,6 +809,49 @@ _modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
        g_object_unref (G_OBJECT (folder));
 }
 
+
+
+void 
+_modest_ui_actions_on_header_activated (ModestHeaderView *folder_view, 
+                                       TnyHeader *header,
+                                       ModestMainWindow *main_window)
+{
+       ModestWindow *win;
+       TnyFolder *folder = NULL;
+       TnyMsg    *msg    = NULL;
+       
+       if (!header)
+               return;
+
+       folder = tny_header_get_folder (header);
+       if (!folder) {
+               g_printerr ("modest: cannot get folder for header\n");
+               goto cleanup;
+       }
+
+       /* FIXME: make async?; check error  */
+       msg = tny_folder_get_msg (folder, header, NULL);
+       if (!msg) {
+               g_printerr ("modest: cannot get msg for header\n");
+               goto cleanup;
+       }
+
+       win = modest_msg_view_window_new (msg);
+       gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (main_window));
+
+       gtk_widget_show_all (GTK_WIDGET(win));
+       
+cleanup:
+       if (folder)
+               g_object_unref (G_OBJECT (folder));
+       if (msg)
+               g_object_unref (G_OBJECT (folder));
+}
+
+
+
+
+
 void 
 _modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
                                               TnyFolder *folder,