2007-04-15 Sergio Villar Senin <svillar@igalia.com>
[modest] / src / maemo / modest-main-window.c
index ae3e1f6..e3c120f 100644 (file)
  */
 
 #include <hildon-widgets/hildon-window.h>
+#include <hildon-widgets/hildon-note.h>
 
 #include <glib/gi18n.h>
 #include <gtk/gtktreeviewcolumn.h>
 #include <tny-account-store-view.h>
 #include <modest-runtime.h>
+#include <string.h>
 
 #include <widgets/modest-main-window.h>
 #include <widgets/modest-msg-edit-window.h>
 #include <widgets/modest-account-view-window.h>
 
+#include "modest-platform.h"
 #include "modest-widget-memory.h"
 #include "modest-window-priv.h"
 #include "modest-main-window-ui.h"
 #include "modest-account-mgr.h"
 #include "modest-conf.h"
-
+#include <modest-maemo-utils.h>
 #include "modest-tny-platform-factory.h"
 #include "modest-tny-msg.h"
 #include "modest-mail-operation.h"
 static void modest_main_window_class_init    (ModestMainWindowClass *klass);
 static void modest_main_window_init          (ModestMainWindow *obj);
 static void modest_main_window_finalize      (GObject *obj);
+static gboolean modest_main_window_window_state_event (GtkWidget *widget, 
+                                                          GdkEventWindowState *event, 
+                                                          gpointer userdata);
 
 static void connect_signals (ModestMainWindow *self);
 static void restore_sizes (ModestMainWindow *self);
 static void save_sizes (ModestMainWindow *self);
 
+static void modest_main_window_show_toolbar   (ModestWindow *window,
+                                              gboolean show_toolbar);
+
 /* list my signals */
 enum {
        /* MY_SIGNAL_1, */
@@ -69,14 +78,14 @@ typedef struct _ModestMainWindowPrivate ModestMainWindowPrivate;
 struct _ModestMainWindowPrivate {
        GtkWidget *msg_paned;
        GtkWidget *main_paned;
+       GtkWidget *main_vbox;
        GtkWidget *progress_bar;
 
        ModestHeaderView *header_view;
        ModestFolderView *folder_view;
 
+       ModestMainWindowStyle style;
 };
-
-
 #define MODEST_MAIN_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
                                                 MODEST_TYPE_MAIN_WINDOW, \
                                                 ModestMainWindowPrivate))
@@ -84,12 +93,13 @@ struct _ModestMainWindowPrivate {
 typedef struct _GetMsgAsyncHelper {
        ModestMainWindowPrivate *main_window_private;
        guint action;
-       ModestMailOperationReplyType reply_type;
-       ModestMailOperationForwardType forward_type;
+       ModestTnyMsgReplyType reply_type;
+       ModestTnyMsgForwardType forward_type;
        gchar *from;
        TnyIterator *iter;
 } GetMsgAsyncHelper;
 
+
 /* globals */
 static GtkWindowClass *parent_class = NULL;
 
@@ -125,13 +135,49 @@ modest_main_window_class_init (ModestMainWindowClass *klass)
 {
        GObjectClass *gobject_class;
        gobject_class = (GObjectClass*) klass;
+       ModestWindowClass *modest_window_class;
+
+       modest_window_class = (ModestWindowClass *) klass;
 
        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = modest_main_window_finalize;
 
+       modest_window_class->show_toolbar_func = modest_main_window_show_toolbar;
+
        g_type_class_add_private (gobject_class, sizeof(ModestMainWindowPrivate));
 }
 
+
+static void
+on_key_changed (ModestConf* conf, const gchar *key, ModestConfEvent event, ModestMainWindow *win)
+{
+       TnyAccount *account;
+       
+       if (!key || strcmp (key, MODEST_CONF_DEVICE_NAME) != 0)
+               return; /* wrong key */
+       
+       /* ok, the device name changed; thus, we have to update the
+        * local folder account name*/
+       account =
+               modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store(),
+                                                                    MODEST_LOCAL_FOLDERS_ACCOUNT_ID,
+                                                                    TNY_ACCOUNT_TYPE_STORE);
+       if (!account) {
+               g_printerr ("modest: could not get account\n");
+               return;
+       }
+
+       if (event == MODEST_CONF_EVENT_KEY_UNSET) 
+               tny_account_set_name (account, MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME);
+       else {
+               gchar *device_name = modest_conf_get_string (modest_runtime_get_conf(),
+                                                            MODEST_CONF_DEVICE_NAME, NULL);
+               tny_account_set_name (account, device_name);
+               g_free (device_name);
+       }
+       g_object_unref (G_OBJECT(account));     
+}
+
 static void
 modest_main_window_init (ModestMainWindow *obj)
 {
@@ -141,8 +187,10 @@ modest_main_window_init (ModestMainWindow *obj)
 
        priv->msg_paned    = NULL;
        priv->main_paned   = NULL;      
+       priv->main_vbox    = NULL;
        priv->header_view  = NULL;
        priv->folder_view  = NULL;
+       priv->style  = MODEST_MAIN_WINDOW_STYLE_SPLIT;
 
        /* progress bar */
        priv->progress_bar = gtk_progress_bar_new ();
@@ -157,7 +205,6 @@ modest_main_window_finalize (GObject *obj)
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
-
 GtkWidget*
 modest_main_window_get_child_widget (ModestMainWindow *self,
                                     ModestWidgetType widget_type)
@@ -195,12 +242,12 @@ restore_sizes (ModestMainWindow *self)
 
        conf = modest_runtime_get_conf ();
        
-       modest_widget_memory_restore (conf,G_OBJECT(self),
-                                     "modest-main-window");
        modest_widget_memory_restore (conf, G_OBJECT(priv->main_paned),
                                      "modest-main-paned");
        modest_widget_memory_restore (conf, G_OBJECT(priv->header_view),
                                      "header-view");
+       modest_widget_memory_restore (conf, G_OBJECT(self), 
+                                     "modest-main-window");
 }
 
 
@@ -247,83 +294,12 @@ on_delete_event (GtkWidget *widget, GdkEvent  *event, ModestMainWindow *self)
        return FALSE;
 }
 
-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 GtkWidget*
-get_toolbar (ModestMainWindow *self)
-{
-       GtkWidget   *toolbar, *progress_box, *progress_alignment;
-       GtkToolItem *progress_item;
-       ModestWindowPrivate *parent_priv;
-       ModestMainWindowPrivate *priv;
-       GtkWidget   *stop_icon;
-       
-       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
-       priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
-       
-       /* Toolbar */
-       toolbar       = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
-
-       gtk_progress_bar_set_text (GTK_PROGRESS_BAR(priv->progress_bar), "Connecting...");
-
-       progress_box        = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
-       progress_alignment  = gtk_alignment_new (0.5, 0.5, 1, 0);
-       
-       gtk_container_add  (GTK_CONTAINER(progress_alignment), priv->progress_bar);
-       gtk_box_pack_start (GTK_BOX(progress_box), progress_alignment, TRUE, TRUE, 0);
-       
-       progress_item  = gtk_tool_item_new ();
-       gtk_container_add (GTK_CONTAINER(progress_item), progress_box);
-       gtk_tool_item_set_homogeneous (progress_item, FALSE);
-       gtk_tool_item_set_expand(progress_item, TRUE);
-       
-       gtk_toolbar_insert (GTK_TOOLBAR(toolbar), progress_item,
-                           gtk_toolbar_get_n_items(GTK_TOOLBAR(toolbar)));
-
-       stop_icon = gtk_image_new_from_icon_name("qgn_toolb_gene_stop", GTK_ICON_SIZE_BUTTON);
-       gtk_toolbar_insert (GTK_TOOLBAR(toolbar), gtk_tool_button_new(stop_icon, NULL),
-                           gtk_toolbar_get_n_items(GTK_TOOLBAR(toolbar)));
-
-
-       gtk_widget_show_all (toolbar);
-       return toolbar;
-}
-
-
-static void
-on_destroy (GtkWidget *widget, GdkEvent  *event, ModestMainWindow *self)
-{
-       gtk_main_quit();
-}
-
 static void
 connect_signals (ModestMainWindow *self)
 {      
        ModestWindowPrivate *parent_priv;
        ModestMainWindowPrivate *priv;
+       GtkWidget *menu;
        
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
        parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
@@ -331,31 +307,46 @@ connect_signals (ModestMainWindow *self)
        /* folder view */
        g_signal_connect (G_OBJECT(priv->folder_view), "folder_selection_changed",
                          G_CALLBACK(modest_ui_actions_on_folder_selection_changed), self);
-//     g_signal_connect (G_OBJECT(self->folder_view), "button-press-event",
-//                       G_CALLBACK (on_folder_view_button_press_event),self);
-//     g_signal_connect (self->folder_view,"popup-menu",
-//                       G_CALLBACK (on_folder_view_button_press_event),self);
+
+       menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/FolderViewContextMenu");
+       gtk_widget_tap_and_hold_setup (GTK_WIDGET (priv->folder_view), menu, NULL, 0);
 
        /* header view */
-       g_signal_connect (G_OBJECT(priv->header_view), "status_update",
-                         G_CALLBACK(modest_ui_actions_on_header_status_update), self);
+/*     g_signal_connect (G_OBJECT(priv->header_view), "status_update", */
+/*                       G_CALLBACK(modest_ui_actions_on_header_status_update), self); */
        g_signal_connect (G_OBJECT(priv->header_view), "header_selected",
                          G_CALLBACK(modest_ui_actions_on_header_selected), self);
        g_signal_connect (G_OBJECT(priv->header_view), "header_activated",
                          G_CALLBACK(modest_ui_actions_on_header_activated), self);
        g_signal_connect (G_OBJECT(priv->header_view), "item_not_found",
                          G_CALLBACK(modest_ui_actions_on_item_not_found), self);
-//     g_signal_connect (G_OBJECT(self->header_view), "button-press-event",
-//                       G_CALLBACK (on_header_view_button_press_event), self);
-//     g_signal_connect (G_OBJECT(self->header_view),"popup-menu",0
-//                       G_CALLBACK (on_header_view_button_press_event), self);
 
        /* window */
-       g_signal_connect (G_OBJECT(self), "destroy", G_CALLBACK(on_destroy), NULL);
+       g_signal_connect (G_OBJECT(self), "delete-event", G_CALLBACK(on_delete_event), self);
+       g_signal_connect (G_OBJECT (self), "window-state-event",
+                         G_CALLBACK (modest_main_window_window_state_event),
+                         NULL);
+
+
+       
+       /* modest_maemo_utils_get_device_name will probably change
+        * MODEST_CONF_DEVICE_NAME. If that happens, we update the local folders
+        * account name in the callback
+        */
+       g_signal_connect (G_OBJECT(modest_runtime_get_conf()), "key_changed",
+                         G_CALLBACK(on_key_changed), self);
+       
        g_signal_connect (G_OBJECT(self), "delete-event", G_CALLBACK(on_delete_event), self);
 }
 
 
+gboolean
+sync_accounts_cb (ModestMainWindow *win)
+{
+       modest_ui_actions_on_send_receive (NULL, MODEST_WINDOW(win));
+       return FALSE;
+}
+
 
 ModestWindow*
 modest_main_window_new (void)
@@ -363,11 +354,13 @@ modest_main_window_new (void)
        ModestMainWindow *self; 
        ModestMainWindowPrivate *priv;
        ModestWindowPrivate *parent_priv;
-       GtkWidget *main_vbox;
        GtkWidget *header_win, *folder_win;
        GtkActionGroup *action_group;
        GError *error = NULL;
-       TnyFolderStoreQuery     *query;
+       TnyFolderStoreQuery *query;
+       GdkPixbuf *window_icon;
+       ModestConf *conf;
+       GtkAction *action;
 
        self  = MODEST_MAIN_WINDOW(g_object_new(MODEST_TYPE_MAIN_WINDOW, NULL));
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
@@ -375,18 +368,25 @@ modest_main_window_new (void)
 
        parent_priv->ui_manager = gtk_ui_manager_new();
        action_group = gtk_action_group_new ("ModestMainWindowActions");
+       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
 
        /* Add common actions */
        gtk_action_group_add_actions (action_group,
                                      modest_action_entries,
                                      G_N_ELEMENTS (modest_action_entries),
                                      self);
-       
+
+       gtk_action_group_add_toggle_actions (action_group,
+                                            modest_toggle_action_entries,
+                                            G_N_ELEMENTS (modest_toggle_action_entries),
+                                            self);
+
        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-main-window-ui.xml", &error);
+       gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager,
+                                        MODEST_UIDIR "modest-main-window-ui.xml", &error);
        if (error != NULL) {
                g_warning ("Could not merge modest-ui.xml: %s", error->message);
                g_error_free (error);
@@ -397,12 +397,17 @@ modest_main_window_new (void)
        gtk_window_add_accel_group (GTK_WINDOW (self), 
                                    gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
 
-       /* add the toolbar */
-       parent_priv->toolbar = get_toolbar(self);
-       hildon_window_add_toolbar (HILDON_WINDOW (self), GTK_TOOLBAR (parent_priv->toolbar));
-
-       /* Menubar */
-       parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
+       /* Menubar. Update the state of some toggles */
+       parent_priv->menubar = modest_maemo_utils_menubar_to_menu (parent_priv->ui_manager);
+       conf = modest_runtime_get_conf ();
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, 
+                                           "/MenuBar/ViewMenu/ViewShowToolbarMainMenu/ViewShowToolbarNormalScreenMenu");
+       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                     modest_conf_get_bool (conf, MODEST_CONF_SHOW_TOOLBAR, NULL));
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, 
+                                           "/MenuBar/ViewMenu/ViewShowToolbarMainMenu/ViewShowToolbarFullScreenMenu");
+       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                     modest_conf_get_bool (conf, MODEST_CONF_SHOW_TOOLBAR_FULLSCREEN, NULL));
        hildon_window_set_menu (HILDON_WINDOW (self), GTK_MENU (parent_priv->menubar));
 
        /* folder view */
@@ -412,17 +417,18 @@ modest_main_window_new (void)
        priv->folder_view = MODEST_FOLDER_VIEW(modest_folder_view_new (query));
        if (!priv->folder_view)
                g_printerr ("modest: cannot instantiate folder view\n");        
-       g_object_unref (G_OBJECT (query));
-       
+       g_object_unref (G_OBJECT (query));      
+       modest_maemo_utils_get_device_name ();
+
        /* header view */
        priv->header_view  =
                MODEST_HEADER_VIEW(modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS));
        if (!priv->header_view)
                g_printerr ("modest: cannot instantiate header view\n");
-       
+       modest_header_view_set_style (priv->header_view, MODEST_HEADER_VIEW_STYLE_TWOLINES);
        
        folder_win = wrapped_in_scrolled_window (GTK_WIDGET(priv->folder_view), FALSE);
-       header_win = wrapped_in_scrolled_window (GTK_WIDGET(priv->header_view), FALSE);                    
+       header_win = wrapped_in_scrolled_window (GTK_WIDGET(priv->header_view), FALSE);
 
        /* paned */
        priv->main_paned = gtk_hpaned_new ();
@@ -432,19 +438,15 @@ modest_main_window_new (void)
        gtk_tree_view_columns_autosize (GTK_TREE_VIEW(priv->header_view));
 
        /* putting it all together... */
-       main_vbox = gtk_vbox_new (FALSE, 6);
-       gtk_box_pack_start (GTK_BOX(main_vbox), priv->main_paned, TRUE, TRUE,0);
+       priv->main_vbox = gtk_vbox_new (FALSE, 6);
+       gtk_box_pack_start (GTK_BOX(priv->main_vbox), priv->main_paned, TRUE, TRUE,0);
 
-       gtk_container_add (GTK_CONTAINER(self), main_vbox);
-       restore_sizes (MODEST_MAIN_WINDOW(self));       
-
-       gtk_window_set_title (GTK_WINDOW(self), _("Modest"));
-       gtk_window_set_icon_from_file (GTK_WINDOW(self), MODEST_APP_ICON, NULL);
-       
-       gtk_widget_show_all (main_vbox);
+       gtk_container_add (GTK_CONTAINER(self), priv->main_vbox);
+       restore_sizes (MODEST_MAIN_WINDOW(self));
 
-       g_signal_connect (G_OBJECT(self), "delete-event",
-                         G_CALLBACK(on_delete_event), self);
+       /* Set window icon */
+       window_icon = modest_platform_get_icon (MODEST_APP_ICON);
+       gtk_window_set_icon (GTK_WINDOW (self), window_icon);
 
        /* Connect signals */
        connect_signals (self);
@@ -452,7 +454,159 @@ modest_main_window_new (void)
        /* Set account store */
        tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
                                                  TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+       g_idle_add ((GSourceFunc)sync_accounts_cb, self);
+       /* do send & receive when we are idle */        
 
-       tny_device_force_online (modest_runtime_get_device());
+       g_message ("online? %s",
+                  tny_device_is_online (modest_runtime_get_device()) ? "yes" : "no");
+               
        return MODEST_WINDOW(self);
 }
+
+gboolean 
+modest_main_window_close_all (ModestMainWindow *self)
+{
+       GtkWidget *note;
+       GtkResponseType response;
+
+       /* Create the confirmation dialog MSG-NOT308 */
+       note = hildon_note_new_confirmation_add_buttons (GTK_WINDOW (self),
+                                                        _("emev_nc_close_windows"),
+                                                        _("mcen_db_yes"), GTK_RESPONSE_YES,
+                                                        _("mcen_db_no"), GTK_RESPONSE_NO,
+                                                        NULL);
+
+       response = gtk_dialog_run (GTK_DIALOG (note));
+       gtk_widget_destroy (GTK_WIDGET (note));
+
+       if (response == GTK_RESPONSE_YES)
+               return TRUE;
+       else
+               return FALSE;
+}
+
+void 
+modest_main_window_set_style (ModestMainWindow *self, 
+                             ModestMainWindowStyle style)
+{
+       ModestMainWindowPrivate *priv;
+       GtkWidget *scrolled_win;
+
+       g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
+
+       priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+       /* no change -> nothing to do */
+       if (priv->style == style)
+               return;
+
+       priv->style = style;
+       scrolled_win = gtk_widget_get_parent (GTK_WIDGET (priv->header_view));
+
+       switch (style) {
+       case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
+               /* Remove main paned */
+               g_object_ref (priv->main_paned);
+               gtk_container_remove (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
+
+               /* Reparent header view with scrolled window */
+               gtk_widget_reparent (scrolled_win, priv->main_vbox);
+               break;
+       case MODEST_MAIN_WINDOW_STYLE_SPLIT:
+               /* Remove header view */
+               g_object_ref (scrolled_win);
+               gtk_container_remove (GTK_CONTAINER (priv->main_vbox), scrolled_win);
+
+               /* Reparent the main paned */
+               gtk_paned_add2 (GTK_PANED (priv->main_paned), scrolled_win);
+               gtk_container_add (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
+               break;
+       default:
+               g_return_if_reached ();
+       }
+
+       /* Show changes */
+       gtk_widget_show_all (GTK_WIDGET (priv->main_vbox));
+}
+
+ModestMainWindowStyle
+modest_main_window_get_style (ModestMainWindow *self)
+{
+       ModestMainWindowPrivate *priv;
+
+       g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (self), -1);
+
+       priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+       return priv->style;
+}
+
+static gboolean
+modest_main_window_window_state_event (GtkWidget *widget, GdkEventWindowState *event, gpointer userdata)
+{
+       if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
+               ModestWindowPrivate *parent_priv;
+               ModestWindowMgr *mgr;
+               gboolean is_fullscreen;
+               GtkAction *fs_toggle_action;
+               gboolean active;
+               
+               mgr = modest_runtime_get_window_mgr ();
+               
+               is_fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
+
+               parent_priv = MODEST_WINDOW_GET_PRIVATE (widget);
+               
+               fs_toggle_action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewToggleFullscreenMenu");
+               active = (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (fs_toggle_action)))?1:0;
+               if (is_fullscreen != active) {
+                       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (fs_toggle_action), is_fullscreen);
+               }
+       }
+
+       return FALSE;
+
+}
+
+static void
+set_homogeneous (GtkWidget *widget,
+                gpointer data)
+{
+       gtk_tool_item_set_expand (GTK_TOOL_ITEM (widget), TRUE);
+       gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (widget), TRUE);
+}
+
+static void 
+modest_main_window_show_toolbar (ModestWindow *self,
+                                gboolean show_toolbar)
+{
+       ModestWindowPrivate *parent_priv;
+       GtkWidget *reply_button = NULL, *menu = NULL;
+       
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+       if (!parent_priv->toolbar && show_toolbar) {
+               parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, 
+                                                                 "/ToolBar");
+
+               /* Set homogeneous toolbar */
+               gtk_container_foreach (GTK_CONTAINER (parent_priv->toolbar), 
+                                      set_homogeneous, NULL);
+
+               /* Add to window */
+               hildon_window_add_toolbar (HILDON_WINDOW (self), 
+                                          GTK_TOOLBAR (parent_priv->toolbar));
+
+               /* Set reply button tap and hold menu */
+               reply_button = gtk_ui_manager_get_widget (parent_priv->ui_manager, 
+                                                         "/ToolBar/ToolbarMessageReply");
+               menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, 
+                                                 "/ToolbarReplyContextMenu");
+               gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0);
+       }
+
+
+       if (show_toolbar)
+               gtk_widget_show (GTK_WIDGET (parent_priv->toolbar));
+       else
+               gtk_widget_hide (GTK_WIDGET (parent_priv->toolbar));
+}