From 19fa2fa8848b7da923b3b978f2e2d3f2aa6f2b62 Mon Sep 17 00:00:00 2001
From: c4pp4
Date: Sun, 29 May 2022 03:00:40 +0200
Subject: [PATCH 1/1] Add a traditional menubar

Signed-off-by: c4pp4
---
 po/POTFILES.in                                |   1 +
 src/grilo.gresource.xml                       |   3 +
 src/menus-traditional.ui                      | 179 ++++++++++++++++++
 .../open-directory/totem-open-directory.c     |   1 +
 .../properties/totem-movie-properties.c       |   4 +
 src/plugins/rotation/totem-rotation.c         |   3 +
 src/plugins/save-file/totem-save-file.c       |   1 +
 .../screenshot/totem-screenshot-plugin.c      |   3 +
 src/plugins/skipto/totem-skipto-plugin.c      |   1 +
 .../totem-variable-rate-plugin.c              |   2 +
 src/totem-menu.c                              |  13 +-
 src/totem-object.c                            |  30 ++-
 12 files changed, 228 insertions(+), 13 deletions(-)
 create mode 100644 src/menus-traditional.ui

diff --git a/po/POTFILES.in b/po/POTFILES.in
index d73eefd..1cb5873 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,6 +12,7 @@ src/backend/bacon-video-widget.c
 src/backend/bacon-video-widget-gst-missing-plugins.c
 src/gst/totem-time-helpers.c
 src/grilo.ui
+src/menus-traditional.ui
 src/totem.c
 src/totem-gallery-thumbnailer.c
 src/totem-grilo.c
diff --git a/src/grilo.gresource.xml b/src/grilo.gresource.xml
index 2186e86..c605738 100644
--- a/src/grilo.gresource.xml
+++ b/src/grilo.gresource.xml
@@ -6,4 +6,7 @@
     <file compressed="true">grilo.ui</file>
     <file compressed="true">totem-grilo.conf</file>
   </gresource>
+  <gresource prefix="/org/gnome/Totem">
+    <file alias="gtk/menus-traditional.ui" compressed="true" preprocess="xml-stripblanks">menus-traditional.ui</file>
+  </gresource>
 </gresources>
diff --git a/src/menus-traditional.ui b/src/menus-traditional.ui
new file mode 100644
index 0000000..8bab2f9
--- /dev/null
+++ b/src/menus-traditional.ui
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+
+  <menu id="menubar">
+    <submenu>
+      <attribute name="label" translatable="yes">_Movie</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">Add _Local Video…</attribute>
+          <attribute name="action">app.open</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;O</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">Add _Web Video…</attribute>
+          <attribute name="action">app.open-location</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;L</attribute>
+        </item>
+      </section>
+      <section>
+        <section id="opendirectory-placeholder"/>
+        <section id="save-placeholder"/>
+      </section>
+      <section>
+        <section id="properties-placeholder"/>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Play / Pause</attribute>
+          <attribute name="action">app.play</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;space</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Eject</attribute>
+          <attribute name="action">app.eject</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;E</attribute>
+        </item>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Quit</attribute>
+          <attribute name="action">app.quit</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;Q</attribute>
+        </item>
+      </section>
+    </submenu>
+
+    <submenu>
+      <attribute name="label" translatable="yes">_Edit</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Repeat</attribute>
+          <attribute name="action">app.repeat</attribute>
+        </item>
+      </section>
+      <section>
+        <section id="screenshot-placeholder"/>
+      </section>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">Prefere_nces</attribute>
+          <attribute name="action">app.preferences</attribute>
+        </item>
+      </section>
+    </submenu>
+
+    <submenu>
+      <attribute name="label" translatable="yes">_View</attribute>
+      <section>
+        <submenu>
+          <attribute name="label" translatable="yes">_Aspect Ratio</attribute>
+          <section>
+            <item>
+              <attribute name="label" translatable="yes" comments="Translators: an entry in the 'Aspect Ratio' menu, used to choose the displayed aspect ratio of a video" context="Aspect ratio">Auto</attribute>
+              <attribute name="action">app.aspect-ratio</attribute>
+              <attribute name="target" type="i">0</attribute>
+            </item>
+            <item>
+              <attribute name="label" translatable="yes" comments="Translators: an entry in the 'Aspect Ratio' menu, used to choose the displayed aspect ratio of a video" context="Aspect ratio">Square</attribute>
+              <attribute name="action">app.aspect-ratio</attribute>
+              <attribute name="target" type="i">1</attribute>
+            </item>
+            <item>
+              <attribute name="label" translatable="yes" comments="Translators: an entry in the 'Aspect Ratio' menu, used to choose the displayed aspect ratio of a video" context="Aspect ratio">4∶3 (TV)</attribute>
+              <attribute name="action">app.aspect-ratio</attribute>
+              <attribute name="target" type="i">2</attribute>
+            </item>
+            <item>
+              <attribute name="label" translatable="yes" comments="Translators: an entry in the 'Aspect Ratio' menu, used to choose the displayed aspect ratio of a video" context="Aspect ratio">16∶9 (Widescreen)</attribute>
+              <attribute name="action">app.aspect-ratio</attribute>
+              <attribute name="target" type="i">3</attribute>
+            </item>
+            <item>
+              <attribute name="label" translatable="yes" comments="Translators: an entry in the 'Aspect Ratio' menu, used to choose the displayed aspect ratio of a video" context="Aspect ratio">2.11∶1 (DVB)</attribute>
+              <attribute name="action">app.aspect-ratio</attribute>
+              <attribute name="target" type="i">4</attribute>
+            </item>
+          </section>
+        </submenu>
+        <item>
+          <attribute name="label" translatable="yes">Zoom In</attribute>
+          <attribute name="action">app.zoom</attribute>
+        </item>
+        <section id="rotation-placeholder"/>
+        <item>
+          <attribute name="label" translatable="yes">Switch An_gles</attribute>
+          <attribute name="action">app.next-angle</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;G</attribute>
+        </item>
+        <submenu>
+          <attribute name="label" translatable="yes">Speed</attribute>
+          <section id="variable-rate-placeholder"/>
+        </submenu>
+      </section>
+      <section>
+        <submenu>
+          <attribute name="label" translatable="yes">_Languages</attribute>
+          <section id="languages-placeholder"/>
+        </submenu>
+        <submenu>
+          <attribute name="label" translatable="yes">S_ubtitles</attribute>
+          <section>
+            <item>
+              <attribute name="label" translatable="yes">_Select Text Subtitles…</attribute>
+              <attribute name="action">app.select-subtitle</attribute>
+            </item>
+            <section id="subtitle-download-placeholder"/>
+            <section id="subtitles-placeholder"/>
+          </section>
+        </submenu>
+      </section>
+    </submenu>
+
+    <submenu>
+      <attribute name="label" translatable="yes">_Go</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_DVD Menu</attribute>
+          <attribute name="action">app.dvd-root-menu</attribute>
+          <attribute name="accel">&lt;Ctrl&gt;M</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Title Menu</attribute>
+          <attribute name="action">app.dvd-title-menu</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">A_udio Menu</attribute>
+          <attribute name="action">app.dvd-audio-menu</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Angle Menu</attribute>
+          <attribute name="action">app.dvd-angle-menu</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Chapter Menu</attribute>
+          <attribute name="action">app.dvd-chapter-menu</attribute>
+        </item>
+      </section>
+      <section>
+        <section id="skipto-placeholder"/>
+      </section>
+    </submenu>
+
+    <submenu>
+      <attribute name="label" translatable="yes">_Help</attribute>
+      <section>
+        <item>
+          <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+          <attribute name="action">app.shortcuts</attribute>
+        </item>
+        <item>
+          <attribute name="label" translatable="yes">_Help</attribute>
+          <attribute name="action">app.help</attribute>
+          <attribute name="accel">F1</attribute>
+        </item>
+      </section>
+    </submenu>
+  </menu>
+
+</interface>
diff --git a/src/plugins/open-directory/totem-open-directory.c b/src/plugins/open-directory/totem-open-directory.c
index 1c0883d..eb03ffd 100644
--- a/src/plugins/open-directory/totem-open-directory.c
+++ b/src/plugins/open-directory/totem-open-directory.c
@@ -184,6 +184,7 @@ impl_activate (PeasActivatable *plugin)
 	menu = totem_object_get_menu_section (pi->totem, "opendirectory-placeholder");
 	item = g_menu_item_new (_("Open Containing Folder"), "app.open-dir");
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (gtk_application_get_menu_by_id (GTK_APPLICATION (pi->totem), "opendirectory-placeholder")), item);
 
 	mrl = totem_object_get_current_mrl (pi->totem);
 	totem_open_directory_file_opened (pi->totem, mrl, pi);
diff --git a/src/plugins/properties/totem-movie-properties.c b/src/plugins/properties/totem-movie-properties.c
index 8850cd4..f8d9f54 100644
--- a/src/plugins/properties/totem-movie-properties.c
+++ b/src/plugins/properties/totem-movie-properties.c
@@ -214,6 +214,7 @@ totem_movie_properties_plugin_file_opened (TotemObject *totem,
 		(BACON_VIDEO_WIDGET_PROPERTIES (plugin->props), bvw);
 	g_object_unref (bvw);
 	gtk_widget_set_sensitive (plugin->props, TRUE);
+	g_simple_action_set_enabled (G_SIMPLE_ACTION (plugin->props_action), TRUE);
 }
 
 static void
@@ -224,6 +225,7 @@ totem_movie_properties_plugin_file_closed (TotemObject *totem,
         bacon_video_widget_properties_reset
 		(BACON_VIDEO_WIDGET_PROPERTIES (plugin->props));
 	gtk_widget_set_sensitive (plugin->props, FALSE);
+	g_simple_action_set_enabled (G_SIMPLE_ACTION (plugin->props_action), FALSE);
 }
 
 static void
@@ -297,12 +299,14 @@ impl_activate (PeasActivatable *plugin)
 	gtk_application_set_accels_for_action (GTK_APPLICATION (totem),
 					       "app.properties",
 					       accels);
+	g_simple_action_set_enabled (G_SIMPLE_ACTION (pi->props_action), FALSE);
 
 	/* Install the menu */
 	menu = totem_object_get_menu_section (totem, "properties-placeholder");
 	item = g_menu_item_new (_("_Properties"), "app.properties");
 	g_menu_item_set_attribute (item, "accel", "s", "<Primary>p");
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (gtk_application_get_menu_by_id (GTK_APPLICATION (totem), "properties-placeholder")), item);
 	g_object_unref (item);
 
 	g_signal_connect (G_OBJECT (totem),
diff --git a/src/plugins/rotation/totem-rotation.c b/src/plugins/rotation/totem-rotation.c
index 743c903..082959f 100644
--- a/src/plugins/rotation/totem-rotation.c
+++ b/src/plugins/rotation/totem-rotation.c
@@ -233,6 +233,7 @@ impl_activate (PeasActivatable *plugin)
 
 	/* add UI */
 	menu = totem_object_get_menu_section (pi->totem, "rotation-placeholder");
+	GMenu *menu_trad = gtk_application_get_menu_by_id (GTK_APPLICATION (pi->totem), "rotation-placeholder");
 
 	pi->rotate_left_action = g_simple_action_new ("rotate-left", NULL);
 	g_signal_connect (G_OBJECT (pi->rotate_left_action), "activate",
@@ -255,10 +256,12 @@ impl_activate (PeasActivatable *plugin)
 	item = g_menu_item_new (_("_Rotate ↷"), "app.rotate-right");
 	g_menu_item_set_attribute (item, "accel", "s", "<Primary>R");
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (menu_trad), item);
 
 	item = g_menu_item_new (_("Rotate ↶"), "app.rotate-left");
 	g_menu_item_set_attribute (item, "accel", "s", "<Primary><Shift>R");
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (menu_trad), item);
 
 	mrl = totem_object_get_current_mrl (pi->totem);
 	update_state (pi, mrl);
diff --git a/src/plugins/save-file/totem-save-file.c b/src/plugins/save-file/totem-save-file.c
index e9e08e5..fd21659 100644
--- a/src/plugins/save-file/totem-save-file.c
+++ b/src/plugins/save-file/totem-save-file.c
@@ -453,6 +453,7 @@ impl_activate (PeasActivatable *plugin)
 	item = g_menu_item_new (_("Make Available Offline"), "app.save-as");
 	g_menu_item_set_attribute (item, "accel", "s", "<Primary>s");
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (gtk_application_get_menu_by_id (GTK_APPLICATION (pi->totem), "save-placeholder")), item);
 
 	mrl = totem_object_get_current_mrl (pi->totem);
 	totem_save_file_file_opened (pi->totem, mrl, pi);
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c b/src/plugins/screenshot/totem-screenshot-plugin.c
index a63860e..160f16a 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -318,16 +318,19 @@ impl_activate (PeasActivatable *plugin)
 
 	/* Install the menu */
 	menu = totem_object_get_menu_section (pi->totem, "screenshot-placeholder");
+	GMenu *menu_trad = gtk_application_get_menu_by_id (GTK_APPLICATION (pi->totem), "screenshot-placeholder");
 	item = g_menu_item_new (_("Take _Screenshot"), "app.take-screenshot");
 	g_menu_item_set_attribute (item, "accel", "s", "<Primary><Alt>s");
 	g_menu_item_set_attribute_value (item, "hidden-when",
 					 g_variant_new_string ("action-disabled"));
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (menu_trad), item);
 	g_object_unref (item);
 	item = g_menu_item_new (_("Create Screenshot _Gallery…"), "app.take-gallery");
 	g_menu_item_set_attribute_value (item, "hidden-when",
 					 g_variant_new_string ("action-disabled"));
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (menu_trad), item);
 	g_object_unref (item);
 
 	/* Set up a GSettings watch for lockdown keys */
diff --git a/src/plugins/skipto/totem-skipto-plugin.c b/src/plugins/skipto/totem-skipto-plugin.c
index 582a885..86bfee2 100644
--- a/src/plugins/skipto/totem-skipto-plugin.c
+++ b/src/plugins/skipto/totem-skipto-plugin.c
@@ -198,6 +198,7 @@ impl_activate (PeasActivatable *plugin)
 	item = g_menu_item_new (_("_Skip To…"), "app.skip-to");
 	g_menu_item_set_attribute (item, "accel", "s", "<Primary>k");
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (gtk_application_get_menu_by_id (GTK_APPLICATION (pi->totem), "skipto-placeholder")), item);
 
 	totem_skipto_update_from_state (pi->totem, pi);
 }
diff --git a/src/plugins/variable-rate/totem-variable-rate-plugin.c b/src/plugins/variable-rate/totem-variable-rate-plugin.c
index 6d88a05..bf507a7 100644
--- a/src/plugins/variable-rate/totem-variable-rate-plugin.c
+++ b/src/plugins/variable-rate/totem-variable-rate-plugin.c
@@ -234,6 +234,7 @@ impl_activate (PeasActivatable *plugin)
 
 	/* Create the submenu */
 	menu = totem_object_get_menu_section (pi->totem, "variable-rate-placeholder");
+	GMenu *menu_trad = gtk_application_get_menu_by_id (GTK_APPLICATION (pi->totem), "variable-rate-placeholder");
 	for (i = 0; i < NUM_RATES; i++) {
 		char *target;
 
@@ -241,6 +242,7 @@ impl_activate (PeasActivatable *plugin)
 		item = g_menu_item_new (g_dpgettext2 (NULL, "playback rate", rates[i].label), target);
 		g_free (target);
 		g_menu_append_item (G_MENU (menu), item);
+		g_menu_append_item (G_MENU (menu_trad), item);
 	}
 }
 
diff --git a/src/totem-menu.c b/src/totem-menu.c
index 143d01c..e6a2443 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -567,6 +567,7 @@ bvw_lang_info_to_menu_labels (GList        *langs,
 
 static void
 add_lang_item (GMenu      *menu,
+	       GMenu      *menu_trad,
 	       const char *label,
 	       const char *action,
 	       int         target)
@@ -576,10 +577,12 @@ add_lang_item (GMenu      *menu,
 	item = g_menu_item_new (label, NULL);
 	g_menu_item_set_action_and_target_value (item, action, g_variant_new_int32 (target));
 	g_menu_append_item (G_MENU (menu), item);
+	g_menu_append_item (G_MENU (menu_trad), item);
 }
 
 static void
 add_lang_action (GMenu *menu,
+	         GMenu *menu_trad,
 		 const char *action,
 		 const char *label,
 		 int         id)
@@ -587,11 +590,12 @@ add_lang_action (GMenu *menu,
 	g_autofree char *escaped_label = NULL;
 
 	escaped_label = escape_label_for_menu (label);
-	add_lang_item (menu, escaped_label, action, id);
+	add_lang_item (menu, menu_trad, escaped_label, action, id);
 }
 
 static void
 create_lang_actions (GMenu        *menu,
+		     GMenu        *menu_trad,
 		     const char   *action,
 		     GList        *list,
 		     BvwTrackType  track_type)
@@ -602,7 +606,7 @@ create_lang_actions (GMenu        *menu,
 
 	for (l = ui_list; l != NULL; l = l->next) {
 		MenuItem *item = l->data;
-		add_lang_action (menu, action, item->label, item->id);
+		add_lang_action (menu, menu_trad, action, item->label, item->id);
 	}
 
 	g_list_free_full (ui_list, (GDestroyNotify) free_menu_item);
@@ -620,7 +624,8 @@ totem_languages_update (Totem *totem, GList *list)
 	if (list != NULL) {
 		GMenu *menu;
 		menu = totem_object_get_menu_section (totem, "languages-placeholder");
-		create_lang_actions (menu, "app.set-language", list, BVW_TRACK_TYPE_AUDIO);
+		GMenu *menu_trad = gtk_application_get_menu_by_id (GTK_APPLICATION (totem), "languages-placeholder");
+		create_lang_actions (menu, menu_trad, "app.set-language", list, BVW_TRACK_TYPE_AUDIO);
 	}
 
 	action = g_action_map_lookup_action (G_ACTION_MAP (totem), "set-language");
@@ -642,7 +647,8 @@ totem_subtitles_update (Totem *totem, GList *list)
 	if (list != NULL) {
 		GMenu *menu;
 		menu = totem_object_get_menu_section (totem, "subtitles-placeholder");
-		create_lang_actions (menu, "app.set-subtitle", list, BVW_TRACK_TYPE_SUBTITLE);
+		GMenu *menu_trad = gtk_application_get_menu_by_id (GTK_APPLICATION (totem), "subtitles-placeholder");
+		create_lang_actions (menu, menu_trad, "app.set-subtitle", list, BVW_TRACK_TYPE_SUBTITLE);
 	}
 
 	action = g_action_map_lookup_action (G_ACTION_MAP (totem), "set-subtitle");
diff --git a/src/totem-object.c b/src/totem-object.c
index 45f2b97..a927068 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -669,17 +669,10 @@ totem_object_get_menu_section (TotemObject *totem,
  * related actions. Note that menu items with specific target
  * will not have the associated action removed.
  **/
-void
-totem_object_empty_menu_section (TotemObject *totem,
-				 const char  *id)
+static void
+totem_object_remove_item (TotemObject *totem,
+		          GMenu       *menu)
 {
-	GMenu *menu;
-
-	g_return_if_fail (TOTEM_IS_OBJECT (totem));
-
-	menu = G_MENU (gtk_builder_get_object (totem->xml, id));
-	g_return_if_fail (menu != NULL);
-
 	while (g_menu_model_get_n_items (G_MENU_MODEL (menu)) > 0) {
 		const char *action;
 		g_menu_model_get_item_attribute (G_MENU_MODEL (menu), 0, G_MENU_ATTRIBUTE_ACTION, "s", &action);
@@ -698,6 +691,23 @@ totem_object_empty_menu_section (TotemObject *totem,
 	}
 }
 
+void
+totem_object_empty_menu_section (TotemObject *totem,
+				 const char  *id)
+{
+	GMenu *menu;
+
+	g_return_if_fail (TOTEM_IS_OBJECT (totem));
+
+	menu = G_MENU (gtk_builder_get_object (totem->xml, id));
+	g_return_if_fail (menu != NULL);
+	GMenu *menu_trad = gtk_application_get_menu_by_id (GTK_APPLICATION (totem), id);
+	g_return_if_fail (menu_trad != NULL);
+
+	totem_object_remove_item (totem, menu);
+	totem_object_remove_item (totem, menu_trad);
+}
+
 /**
  * totem_object_get_video_widget:
  * @totem: a #TotemObject
-- 
2.35.1

