From: Jose Dapena Paz Date: Thu, 13 Dec 2007 09:03:25 +0000 (+0000) Subject: * src/maemo/modest-main-window-ui.h: X-Git-Tag: git_migration_finished~1930 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=de2d9a7e88e25c2b3128cdc69a27c334cb9635ea * src/maemo/modest-main-window-ui.h: * 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 --- diff --git a/src/maemo/modest-maemo-utils.c b/src/maemo/modest-maemo-utils.c index 196d686..19ba8ef 100644 --- a/src/maemo/modest-maemo-utils.c +++ b/src/maemo/modest-maemo-utils.c @@ -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; +} diff --git a/src/maemo/modest-maemo-utils.h b/src/maemo/modest-maemo-utils.h index 80229da..d8ce63d 100644 --- a/src/maemo/modest-maemo-utils.h +++ b/src/maemo/modest-maemo-utils.h @@ -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__*/ diff --git a/src/maemo/modest-main-window-ui.h b/src/maemo/modest-main-window-ui.h index 9bbc353..7e8cc74 100644 --- a/src/maemo/modest-main-window-ui.h +++ b/src/maemo/modest-main-window-ui.h @@ -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"), "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"), "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"), "O", NULL, G_CALLBACK (modest_ui_actions_on_open) }, { "EmailReply", NULL, N_("mcen_me_inbox_reply"), "R", NULL, G_CALLBACK (modest_ui_actions_on_reply) }, diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 8350c5e..614fe61 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -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"); diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 5ba8351..3b0a566 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -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); diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 893f2c1..ddb972f 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -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(); diff --git a/src/maemo/ui/modest-main-window-ui.xml b/src/maemo/ui/modest-main-window-ui.xml index e1eef55..a17612d 100644 --- a/src/maemo/ui/modest-main-window-ui.xml +++ b/src/maemo/ui/modest-main-window-ui.xml @@ -30,7 +30,7 @@ - + @@ -100,7 +100,7 @@ - + diff --git a/src/maemo/ui/modest-msg-edit-window-ui.xml b/src/maemo/ui/modest-msg-edit-window-ui.xml index 4ba8bd3..1386fba 100644 --- a/src/maemo/ui/modest-msg-edit-window-ui.xml +++ b/src/maemo/ui/modest-msg-edit-window-ui.xml @@ -30,7 +30,7 @@ - + @@ -104,8 +104,7 @@ - - + diff --git a/src/maemo/ui/modest-msg-view-window-ui.xml b/src/maemo/ui/modest-msg-view-window-ui.xml index 54cd9e8..120cc13 100644 --- a/src/maemo/ui/modest-msg-view-window-ui.xml +++ b/src/maemo/ui/modest-msg-view-window-ui.xml @@ -30,8 +30,7 @@ - - + @@ -94,7 +93,7 @@ - + diff --git a/src/widgets/modest-msg-edit-window-ui.h b/src/widgets/modest-msg-edit-window-ui.h index bed7cca..22e0372 100644 --- a/src/widgets/modest-msg-edit-window-ui.h +++ b/src/widgets/modest-msg-edit-window-ui.h @@ -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)},