* src/maemo/modest-main-window-ui.h:
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 13 Dec 2007 09:03:25 +0000 (09:03 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 13 Dec 2007 09:03:25 +0000 (09:03 +0000)
        * Add shortcut for "new email" in message view.
* src/maemo/modest-maemo-utils.[ch]:
        * New method ..._get_manager_menubar_as_menu. This converts
          a GtkMenuBar obtained from ui manager to a GtkMenu as
          expected in hildon_window_set_menu (). Using this instead
          of popup menus in ui manager fixes the shortcuts
          (fixes NB#75525).
* src/maemo/modest-msg-edit-window.c,
  src/maemo/modest-msg-view-window.c,
  src/maemo/modest-main-window.c:
        * Remove menubar_to_menu, as this is now a common method in
         modest_maemo_utils. Use the new method.
* src/maemo/ui/modest-main-window.xml,
  src/maemo/ui/modest-msg-edit-window.xml,
  src/maemo/ui/modest-msg-view-window.xml:
        * Use again menubars.

pmo-trunk-r3908

src/maemo/modest-maemo-utils.c
src/maemo/modest-maemo-utils.h
src/maemo/modest-main-window-ui.h
src/maemo/modest-main-window.c
src/maemo/modest-msg-edit-window.c
src/maemo/modest-msg-view-window.c
src/maemo/ui/modest-main-window-ui.xml
src/maemo/ui/modest-msg-edit-window-ui.xml
src/maemo/ui/modest-msg-view-window-ui.xml
src/widgets/modest-msg-edit-window-ui.h

index 196d686..19ba8ef 100644 (file)
@@ -264,3 +264,26 @@ modest_maemo_open_mcc_mapping_file (void)
        return result;
 }
 
+GtkWidget *
+modest_maemo_utils_get_manager_menubar_as_menu (GtkUIManager *manager,
+                                               const gchar *item_name)
+{
+       GtkWidget *new_menu;
+       GtkWidget *menubar;
+       GList *children, *iter;
+
+       menubar = gtk_ui_manager_get_widget (manager, item_name);
+       new_menu = gtk_menu_new ();
+
+       children = gtk_container_get_children (GTK_CONTAINER (menubar));
+       for (iter = children; iter != NULL; iter = g_list_next (iter)) {
+               GtkWidget *menu;
+
+               menu = GTK_WIDGET (iter->data);
+               gtk_widget_reparent (menu, new_menu);
+       }
+       
+       g_list_free (children);
+
+       return new_menu;
+}
index 80229da..d8ce63d 100644 (file)
@@ -111,4 +111,16 @@ osso_context_t* modest_maemo_utils_get_osso_context (void);
  */
 void modest_maemo_utils_set_osso_context (osso_context_t *osso_context);
 
+/**
+ * modest_maemo_utils_get_manager_menubar_as_menu:
+ * @manager: a #GtkUIManager
+ * @item_name: a string
+ *
+ * obtains the node with name @item_name in @manager (which happens to be a menubar) as a
+ * #GtkMenu.
+ *
+ * Returns: a #GtkMenu
+ */
+GtkWidget *modest_maemo_utils_get_manager_menubar_as_menu (GtkUIManager *manager, const gchar *item_name);
+
 #endif /*__MODEST_MAEMO_UTILS_H__*/
index 9bbc353..7e8cc74 100644 (file)
@@ -58,7 +58,7 @@ static const GtkActionEntry modest_action_entries [] = {
        /* Email */
        { "EmailNew", NULL, N_("mcen_me_inbox_new") }, /* submenu */
        { "EmailNewMessage",  NULL,  N_("mcen_me_inbox_message"),      "<CTRL>N", NULL,   G_CALLBACK (modest_ui_actions_on_new_msg) },
-       { "EmailNewDefault", NULL, N_("mcen_me_viewer_newemail"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_new_msg) },
+       { "EmailNewDefault", NULL, N_("mcen_me_viewer_newemail"), "<CTRL>N", NULL, G_CALLBACK (modest_ui_actions_on_new_msg) },
        { "EmailNewFolder",   NULL,  N_("mcen_me_inbox_folder"),       NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_new_folder) },
        { "EmailOpen",        NULL,  N_("mcen_me_inbox_open"),          "<CTRL>O", NULL,   G_CALLBACK (modest_ui_actions_on_open) },
        { "EmailReply",       NULL,  N_("mcen_me_inbox_reply"),         "<CTRL>R",      NULL,   G_CALLBACK (modest_ui_actions_on_reply) },
index 8350c5e..614fe61 100644 (file)
@@ -1169,7 +1169,7 @@ modest_main_window_new (void)
                                    gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
 
        /* Menubar. Update the state of some toggles */
-       parent_priv->menubar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar");
+       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");
index 5ba8351..3b0a566 100644 (file)
@@ -562,17 +562,6 @@ connect_signals (ModestMsgEditWindow *obj)
 
 }
 
-static GtkWidget *
-menubar_to_menu (GtkUIManager *ui_manager)
-{
-       GtkWidget *main_menu;
-
-       /* Get the menubar from the UI manager */
-       main_menu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
-
-       return main_menu;
-}
-
 static void
 init_window (ModestMsgEditWindow *obj)
 {
@@ -1302,7 +1291,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
        parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
 
        /* Menubar. Update the state of some toggles */
-       parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
+       parent_priv->menubar = modest_maemo_utils_get_manager_menubar_as_menu (parent_priv->ui_manager, "/MenuBar");
        hildon_window_set_menu (HILDON_WINDOW (obj), GTK_MENU (parent_priv->menubar));
        priv->from_field_protos = get_transports ();
        modest_combo_box_set_pair_list (MODEST_COMBO_BOX (priv->from_field), priv->from_field_protos);
index 893f2c1..ddb972f 100644 (file)
@@ -534,17 +534,6 @@ set_toolbar_mode (ModestMsgViewWindow *self,
 }
 
 
-static GtkWidget *
-menubar_to_menu (GtkUIManager *ui_manager)
-{
-       GtkWidget *main_menu;
-
-       /* Get the menubar from the UI manager */
-       main_menu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
-
-       return main_menu;
-}
-
 static void
 init_window (ModestMsgViewWindow *obj)
 {
@@ -752,7 +741,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
        priv->msg_uid = g_strdup (msg_uid);
 
        /* Menubar */
-       parent_priv->menubar = menubar_to_menu (parent_priv->ui_manager);
+       parent_priv->menubar = modest_maemo_utils_get_manager_menubar_as_menu (parent_priv->ui_manager, "/MenuBar");
        hildon_window_set_menu    (HILDON_WINDOW(obj), GTK_MENU(parent_priv->menubar));
        gtk_widget_show (parent_priv->menubar);
        parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new();
index e1eef55..a17612d 100644 (file)
@@ -30,7 +30,7 @@
 
 <ui>
 
-  <popup name="MenuBar">
+  <menubar name="MenuBar">
     
     <menu name="EmailMenu" action="Email">
       <menu name="EmailNewMainMenu" action="EmailNew">
       <menuitem name="CloseWindowMenu"     action="CloseWindow"/>
       <menuitem name="CloseAllWindowsMenu" action="CloseAllWindows"/>
     </menu>
-  </popup>
+  </menubar>
 
   <toolbar name="ToolBar">
     <toolitem action="ToolbarMessageNew"/> 
index 4ba8bd3..1386fba 100644 (file)
@@ -30,7 +30,7 @@
 
 <ui>
 
-  <popup name="MenuBar">
+  <menubar name="MenuBar">
 
     <menu name="EmailMenu" action="Email">
       <menuitem name="SendMenu" action="ActionsSend"/>
       <menuitem name="CloseWindowMenu" action="CloseWindow"/>
       <menuitem name="CloseAllWindowsMenu" action="CloseAllWindows"/>
     </menu>
-
-  </popup>
+  </menubar>
 
   <toolbar name="ToolBar">
     <toolitem action="ToolbarSend"/>
index 54cd9e8..120cc13 100644 (file)
@@ -30,8 +30,7 @@
 
 <ui>
 
-  <popup name="MenuBar">
-
+  <menubar name="MenuBar">
     <menu name="MessageMenu" action="Email">
       <menuitem name="MessageReplyMenu" action="EmailReply"/>
       <menuitem name="MessageReplyAllMenu" action="EmailReplyAll"/>
@@ -94,7 +93,7 @@
       <menuitem name="CloseWindowMenu"     action="CloseWindow"/>
       <menuitem name="CloseAllWindowsMenu"     action="CloseAllWindows"/>
     </menu>
-  </popup>
+  </menubar>
 
   <toolbar name="ToolBar">
     <toolitem action="ToolbarMessageReply"/> 
index bed7cca..22e0372 100644 (file)
@@ -38,7 +38,6 @@
 G_BEGIN_DECLS
 
 static const GtkActionEntry modest_msg_edit_action_entries [] = {
-
        /* Toplevel menus */
        { "Email", NULL, N_("mcen_me_inbox_email") , NULL, NULL, G_CALLBACK (modest_ui_actions_on_email_menu_activated) },
        { "View", NULL, N_("mcen_me_inbox_view") , NULL, NULL, G_CALLBACK (modest_ui_actions_on_view_menu_activated)},