* Fixes NB#92686, migrate the main window menus to the 1,5 specs
[modest] / src / hildon2 / modest-main-window.c
index 1c284fb..2d0c8a4 100644 (file)
@@ -77,10 +77,6 @@ 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 modest_main_window_disconnect_signals (ModestWindow *self);
@@ -166,7 +162,7 @@ static void      on_folder_selection_changed (ModestFolderView *folder_view,
                                              TnyFolderStore *folder_store, 
                                              gboolean selected,
                                              ModestMainWindow *main_window);
-                                               
+
 static void set_at_least_one_account_visible(ModestMainWindow *self);
 
 static void on_updating_msg_list (ModestHeaderView *header_view,
@@ -203,7 +199,7 @@ struct _ModestMainWindowPrivate {
        GtkWidget   *refresh_toolitem;
        ModestToolBarModes current_toolbar_mode;
 
-       /* Merge ids used to add/remove accounts to the ViewMenu*/
+       /* Merge ids used to add/remove accounts to the Accounts Menu*/
        GByteArray *merge_ids;
        GtkActionGroup *view_additions_group;
 
@@ -269,7 +265,6 @@ static const GtkActionEntry modest_folder_view_action_entries [] = {
        { "FolderViewCSMRenameFolder", NULL, N_("mcen_me_user_renamefolder"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_rename_folder) },
        { "FolderViewCSMPasteMsgs", NULL, N_("mcen_me_inbox_paste"), NULL, NULL,  G_CALLBACK (modest_ui_actions_on_paste)},
        { "FolderViewCSMDeleteFolder", NULL, N_("mcen_me_inbox_delete"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_delete_folder) },
-       { "FolderViewCSMSearchMessages", NULL, N_("mcen_me_inbox_search"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_search_messages) },
        { "FolderViewCSMHelp", NULL, N_("mcen_me_inbox_help"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_csm_help) },
 };
 
@@ -553,7 +548,7 @@ tap_and_hold_query_cb (GtkWidget *widget, GdkEvent *event)
 
 static void
 update_menus (ModestMainWindow* self)
-{      
+{
        GSList *account_names, *iter, *accounts;
        ModestMainWindowPrivate *priv;
        ModestWindowPrivate *parent_priv;
@@ -645,10 +640,10 @@ update_menus (ModestMainWindow* self)
        /* Create a new action group */
        default_account = modest_account_mgr_get_default_account (mgr);
        active_account_name = modest_window_get_active_account (MODEST_WINDOW (self));
-       
+
        if (!active_account_name) 
                modest_window_set_active_account (MODEST_WINDOW (self), default_account);
-       
+
        priv->view_additions_group = gtk_action_group_new (MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS);
        radio_group = NULL;
        for (i = 0; i < num_accounts; i++) {
@@ -661,7 +656,7 @@ update_menus (ModestMainWindow* self)
                        continue;
                }
                account_name = modest_account_settings_get_account_name (settings);
-       
+
                if (default_account && account_name && 
                    !(strcmp (default_account, account_name) == 0)) {
                        display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_default"), 
@@ -671,8 +666,8 @@ update_menus (ModestMainWindow* self)
                                                        modest_account_settings_get_display_name (settings));
                }
 
-               
-               
+
+
                /* Create action and add it to the action group. The
                   action name must be the account name, this way we
                   could know in the handlers the account to show */
@@ -707,7 +702,7 @@ update_menus (ModestMainWindow* self)
                        priv->merge_ids = g_byte_array_append (priv->merge_ids, &merge_id, 1);
                        gtk_ui_manager_add_ui (parent_priv->ui_manager,
                                               merge_id,
-                                              "/MenuBar/ViewMenu/ViewMenuAdditions",
+                                              "/MenuBar/AccountsMenu/AccountsMenuAdditions",
                                               item_name,
                                               account_name,
                                               GTK_UI_MANAGER_MENUITEM,
@@ -794,10 +789,10 @@ update_menus (ModestMainWindow* self)
 
                /* Get the item of the view menu */
                item_name = g_strconcat (account_name, "Menu", NULL);
-               path = g_strconcat ("/MenuBar/ViewMenu/ViewMenuAdditions/", item_name, NULL);
+               path = g_strconcat ("/MenuBar/AccountsMenu/AccountsMenuAdditions/", item_name, NULL);
                item = gtk_ui_manager_get_widget (parent_priv->ui_manager, path);
                g_free(path);
-               
+
                if (item) {
                        GtkWidget *child = gtk_bin_get_child (GTK_BIN (item));
                        if (GTK_IS_LABEL (child)) {
@@ -810,7 +805,7 @@ update_menus (ModestMainWindow* self)
                                gtk_label_set_ellipsize (GTK_LABEL (child),  PANGO_ELLIPSIZE_END);
                        }
                }
-                       
+
                /* Get the item of the tools menu */
                path = g_strconcat("/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsMenuAdditions/", item_name, NULL);
                item = gtk_ui_manager_get_widget (parent_priv->ui_manager, path);
@@ -1005,12 +1000,8 @@ connect_signals (ModestMainWindow *self)
                modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(priv->header_view), "tap-and-hold",
                                           G_CALLBACK(_header_view_csm_menu_activated),
                                           self);
-       
+
        /* window */
-       priv->sighandlers = 
-               modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (self), "window-state-event",
-                                          G_CALLBACK (modest_main_window_window_state_event),
-                                          NULL);
        /* we don't register this in sighandlers, as it should be run after disconnecting all signals,
         * in destroy stage */
        g_signal_connect (G_OBJECT (self), "destroy", G_CALLBACK (on_window_destroy), NULL);
@@ -1181,8 +1172,6 @@ modest_main_window_new (void)
        GtkActionGroup *action_group = NULL;
        GError *error = NULL;
        HildonProgram *app;
-       ModestConf *conf = NULL;
-       GtkAction *action = NULL;
        GdkPixbuf *window_icon;
        ShowHelper *helper;
        
@@ -1216,11 +1205,6 @@ modest_main_window_new (void)
                                      self);
 
        gtk_action_group_add_toggle_actions (action_group,
-                                            modest_toggle_action_entries,
-                                            G_N_ELEMENTS (modest_toggle_action_entries),
-                                            self);
-
-       gtk_action_group_add_toggle_actions (action_group,
                                             modest_main_window_toggle_action_entries,
                                             G_N_ELEMENTS (modest_main_window_toggle_action_entries),
                                             self);
@@ -1259,11 +1243,6 @@ modest_main_window_new (void)
 
        /* Menubar. Update the state of some toggles */
        parent_priv->menubar = modest_maemo_utils_get_manager_menubar_as_menu (parent_priv->ui_manager, "/MenuBar");
-       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_MAIN_WINDOW_SHOW_TOOLBAR, NULL));
        hildon_window_set_menu (HILDON_WINDOW (self), GTK_MENU (parent_priv->menubar));
        gtk_widget_show (parent_priv->menubar);
 
@@ -1513,37 +1492,6 @@ toolbar_resize (ModestMainWindow *self)
                
 }
 
-
-
-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);
-               }
-
-               toolbar_resize (MODEST_MAIN_WINDOW (widget));
-       }
-
-       return FALSE;
-
-}
-
 static void 
 modest_main_window_show_toolbar (ModestWindow *self,
                                 gboolean show_toolbar)
@@ -2080,19 +2028,19 @@ modest_main_window_notify_send_receive_completed (ModestMainWindow *self)
        GtkAction *action = NULL;
        GtkWidget *widget = NULL;
        ModestMainWindowPrivate *priv = NULL;
-               
+
        g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
 
        priv->send_receive_in_progress  = FALSE;
 
-        action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu");        
+        action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu");
        gtk_action_set_sensitive (action, TRUE);
 /*         action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveCancelSendingMenu");    */
 /*     gtk_action_set_sensitive (action, TRUE); */
-        widget = modest_window_get_action_widget (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsMenuAdditions");      
+        widget = modest_window_get_action_widget (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsMenuAdditions");
        gtk_widget_set_sensitive (widget, TRUE);
-} 
+}
 
 
 static void