[totem/wip/hadess/remove-app-menu: 4/5] main: Remove app menu



commit 66c122d8c2122f830c46ccab179526b4ef11a5bd
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 4 12:29:05 2019 +0100

    main: Remove app menu
    
    Move items from the app menu to a menu button in the main window. This
    new hamburger menu will show in the content navigation/selection view
    and include the same items that were available in the app menu.
    
    As we do not want 2 hamburger menus in the player view, duplicate the
    preferences and keyboard shortcuts menu items in the player menu.
    
    See:
    https://gitlab.gnome.org/GNOME/Initiatives/wikis/App-Menu-Retirement
    
    Closes: #265

 data/totem.ui       | 10 ++++++++++
 src/totem-menu.c    |  4 ----
 src/totem-object.c  | 17 ++++++++++++++++-
 src/totem-private.h |  1 +
 4 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/data/totem.ui b/data/totem.ui
index f63dcc533..eafdc8633 100644
--- a/data/totem.ui
+++ b/data/totem.ui
@@ -107,6 +107,16 @@
                        </section>
                </submenu>
        </section>
+       <section>
+               <item>
+                       <attribute name="label" translatable="yes">Prefere_nces</attribute>
+                       <attribute name="action">app.preferences</attribute>
+               </item>
+               <item>
+                       <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+                       <attribute name="action">app.shortcuts</attribute>
+               </item>
+       </section>
        <section>
                <section id="properties-placeholder"/>
        </section>
diff --git a/src/totem-menu.c b/src/totem-menu.c
index cc7cbedb9..fd86ef62b 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -341,7 +341,6 @@ totem_app_actions_setup (Totem *totem)
 void
 totem_app_menu_setup (Totem *totem)
 {
-       GMenuModel *appmenu;
        char *accels[] = { NULL, NULL };
        const char * const shortcuts_accels[] = {
                "<Ctrl>H",
@@ -350,9 +349,6 @@ totem_app_menu_setup (Totem *totem)
                NULL
        };
 
-       appmenu = (GMenuModel *)gtk_builder_get_object (totem->xml, "appmenu");
-       gtk_application_set_app_menu (GTK_APPLICATION (totem), appmenu);
-
        /* FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=700085 */
        accels[0] = "<Primary>G";
        gtk_application_set_accels_for_action (GTK_APPLICATION (totem), "app.next-angle", (const char * const 
*) accels);
diff --git a/src/totem-object.c b/src/totem-object.c
index b475dc026..ac26a16a8 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -1014,6 +1014,7 @@ totem_object_set_main_page (TotemObject *totem,
                gtk_widget_show (totem->fullscreen_button);
                gtk_widget_show (totem->gear_button);
                gtk_widget_hide (totem->add_button);
+               gtk_widget_hide (totem->main_menu_button);
                bacon_video_widget_show_popup (totem->bvw);
        } else if (g_strcmp0 (page_id, "grilo") == 0) {
                totem_grilo_start (TOTEM_GRILO (totem->grilo));
@@ -1032,6 +1033,7 @@ totem_object_set_main_page (TotemObject *totem,
                g_clear_pointer (&totem->search_string, g_free);
                g_clear_pointer (&totem->player_title, g_free);
                g_clear_object (&totem->custom_title);
+               gtk_widget_show (totem->main_menu_button);
                gtk_widget_hide (totem->fullscreen_button);
                gtk_widget_hide (totem->gear_button);
                if (totem_grilo_get_current_page (TOTEM_GRILO (totem->grilo)) == TOTEM_GRILO_PAGE_RECENT)
@@ -3802,7 +3804,20 @@ totem_callback_connect (TotemObject *totem)
        gtk_widget_set_size_request (GTK_WIDGET (popover), 175, -1);
        g_signal_connect (G_OBJECT (item), "toggled",
                          G_CALLBACK (popup_menu_shown_cb), totem);
-       /* Cog wheel */
+
+       /* Main menu */
+       item = totem->main_menu_button = totem_interface_create_header_button (totem->header,
+                                                                              gtk_menu_button_new (),
+                                                                              "open-menu-symbolic",
+                                                                              GTK_PACK_END);
+       gtk_container_child_set (GTK_CONTAINER (totem->header), totem->main_menu_button,
+                                "position", 0,
+                                NULL);
+       menu = (GMenuModel *) gtk_builder_get_object (totem->xml, "appmenu");
+       gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (item), menu);
+       gtk_widget_show (item);
+
+       /* Player menu */
        item = totem->gear_button = totem_interface_create_header_button (totem->header,
                                                                          gtk_menu_button_new (),
                                                                          "open-menu-symbolic",
diff --git a/src/totem-private.h b/src/totem-private.h
index 76942b140..2eee4d886 100644
--- a/src/totem-private.h
+++ b/src/totem-private.h
@@ -139,6 +139,7 @@ struct _TotemObject {
        GtkWidget *fullscreen_button;
        GtkWidget *gear_button;
        GtkWidget *add_button;
+       GtkWidget *main_menu_button;
 
        char *player_title;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]