[totem] main: Migrate aspect ratio submenu



commit 8ff9c0d1dd058d60696eed6a778e2750ac02fac1
Author: Bastien Nocera <hadess hadess net>
Date:   Thu May 9 17:08:20 2013 +0200

    main: Migrate aspect ratio submenu

 data/totem.ui      |   86 +++++++++++++++++++--------------------------------
 src/totem-menu.c   |   29 +++++++++++++----
 src/totem-object.c |    6 ++--
 3 files changed, 57 insertions(+), 64 deletions(-)
---
diff --git a/data/totem.ui b/data/totem.ui
index 5ee6a29..d2f6ccd 100644
--- a/data/totem.ui
+++ b/data/totem.ui
@@ -64,6 +64,38 @@
        <section>
                <section id="screenshot-placeholder"/>
        </section>
+       <section>
+               <submenu>
+                       <attribute name="label">_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>
+       </section>
 </menu>
 
 <menu id="gomenu">
@@ -206,53 +238,6 @@
          </child>
 
          <child>
-            <object class="GtkRadioAction" id="aspect-ratio-auto">
-               <property 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</property>
-              <property name="tooltip" translatable="yes">Sets automatic aspect ratio</property>
-              <!-- BVW_RATIO_AUTO -->
-              <property name="value">0</property>
-              <property name="current-value">0</property>
-               <signal name="changed" handler="aspect_ratio_changed_callback"/>
-            </object>
-         </child>
-         <child>
-            <object class="GtkRadioAction" id="aspect-ratio-square">
-               <property name="label" translatable="yes">Square</property>
-               <property name="tooltip" translatable="yes">Sets square aspect ratio</property>
-              <!-- BVW_RATIO_SQUARE -->
-              <property name="group">aspect-ratio-auto</property>
-               <property name="value">1</property>
-            </object>
-         </child>
-         <child>
-            <object class="GtkRadioAction" id="aspect-ratio-fbt">
-               <property name="label" translatable="yes">4∶3 (TV)</property>
-               <property name="tooltip" translatable="yes">Sets 4∶3 (TV) aspect ratio</property>
-              <!-- BVW_RATIO_FOURBYTHREE -->
-              <property name="group">aspect-ratio-auto</property>
-               <property name="value">2</property>
-            </object>
-         </child>
-         <child>
-            <object class="GtkRadioAction" id="aspect-ratio-anamorphic">
-               <property name="label" translatable="yes">16∶9 (Widescreen)</property>
-               <property name="tooltip" translatable="yes">Sets 16∶9 (widescreen) aspect ratio</property>
-              <!-- BVW_RATIO_ANAMORPHIC -->
-              <property name="group">aspect-ratio-auto</property>
-               <property name="value">3</property>
-            </object>
-         </child>
-         <child>
-            <object class="GtkRadioAction" id="aspect-ratio-dvb">
-               <property name="label" translatable="yes">2.11∶1 (DVB)</property>
-               <property name="tooltip" translatable="yes">Sets 2.11∶1 (DVB) aspect ratio</property>
-              <!-- BVW_RATIO_DVB -->
-              <property name="group">aspect-ratio-auto</property>
-               <property name="value">4</property>
-            </object>
-         </child>
-
-         <child>
             <object class="GtkAction" id="subtitles-menu">
                <property name="label" translatable="yes">S_ubtitles</property>
                <property name="hide-if-empty">False</property>
@@ -299,13 +284,6 @@
          <menu name="view" action="view-menu">
             <menuitem name="zoom-toggle" action="zoom-toggle"/>
             <separator/>
-            <menu name="aspect-ratio" action="aspect-ratio-menu">
-               <menuitem name="aspect-ratio-auto" action="aspect-ratio-auto"/>
-               <menuitem name="aspect-ratio-square" action="aspect-ratio-square"/>
-               <menuitem name="aspect-ratio-fbt" action="aspect-ratio-fbt"/>
-               <menuitem name="aspect-ratio-anamorphic" action="aspect-ratio-anamorphic"/>
-               <menuitem name="aspect-ratio-dvb" action="aspect-ratio-dvb"/>
-            </menu>
             <menuitem name="next-angle" action="next-angle"/>
             <separator/>
             <menu name="subtitles" action="subtitles-menu">
diff --git a/src/totem-menu.c b/src/totem-menu.c
index d361066..ddbc929 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -54,7 +54,6 @@ G_MODULE_EXPORT void skip_backwards_action_callback (GtkAction *action, Totem *t
 G_MODULE_EXPORT void volume_up_action_callback (GtkAction *action, Totem *totem);
 G_MODULE_EXPORT void volume_down_action_callback (GtkAction *action, Totem *totem);
 G_MODULE_EXPORT void show_sidebar_action_callback (GtkToggleAction *action, Totem *totem);
-G_MODULE_EXPORT void aspect_ratio_changed_callback (GtkRadioAction *action, GtkRadioAction *current, Totem 
*totem);
 G_MODULE_EXPORT void select_subtitle_action_callback (GtkAction *action, Totem *totem);
 G_MODULE_EXPORT void clear_playlist_action_callback (GtkAction *action, Totem *totem);
 
@@ -96,6 +95,27 @@ fullscreen_change_state (GSimpleAction *action,
 }
 
 static void
+aspect_ratio_change_state (GSimpleAction *action,
+                          GVariant      *value,
+                          gpointer       user_data)
+{
+       BvwAspectRatio ratio;
+
+       ratio = g_variant_get_int32 (value);
+       bacon_video_widget_set_aspect_ratio (TOTEM_OBJECT (user_data)->bvw, ratio);
+
+       g_simple_action_set_state (action, value);
+}
+
+static void
+aspect_ratio_action_cb (GSimpleAction *action,
+                       GVariant      *parameter,
+                       gpointer       user_data)
+{
+       g_action_change_state (G_ACTION (action), parameter);
+}
+
+static void
 shuffle_change_state (GSimpleAction *action,
                      GVariant      *value,
                      gpointer       user_data)
@@ -198,6 +218,7 @@ static GActionEntry app_entries[] = {
        { "dvd-audio-menu", dvd_audio_menu_action_cb, NULL, NULL, NULL },
        { "dvd-angle-menu", dvd_angle_menu_action_cb, NULL, NULL, NULL },
        { "dvd-chapter-menu", dvd_chapter_menu_action_cb, NULL, NULL, NULL },
+       { "aspect-ratio", aspect_ratio_action_cb, "i", "0", aspect_ratio_change_state },
        { "preferences", preferences_action_cb, NULL, NULL, NULL },
        { "shuffle", toggle_action_cb, NULL, "false", shuffle_change_state },
        { "repeat", toggle_action_cb, NULL, "false", repeat_change_state },
@@ -579,12 +600,6 @@ show_sidebar_action_callback (GtkToggleAction *action, Totem *totem)
 }
 
 void
-aspect_ratio_changed_callback (GtkRadioAction *action, GtkRadioAction *current, Totem *totem)
-{
-       bacon_video_widget_set_aspect_ratio (totem->bvw, gtk_radio_action_get_current_value (current));
-}
-
-void
 clear_playlist_action_callback (GtkAction *action, Totem *totem)
 {
        totem_playlist_clear (totem->playlist);
diff --git a/src/totem-object.c b/src/totem-object.c
index e999e92..e4e1f66 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -1996,7 +1996,7 @@ totem_action_volume_toggle_mute (TotemObject *totem)
 static void
 totem_action_toggle_aspect_ratio (TotemObject *totem)
 {
-       GtkAction *action;
+       GAction *action;
        int tmp;
 
        tmp = bacon_video_widget_get_aspect_ratio (totem->bvw);
@@ -2004,8 +2004,8 @@ totem_action_toggle_aspect_ratio (TotemObject *totem)
        if (tmp > BVW_RATIO_DVB)
                tmp = BVW_RATIO_AUTO;
 
-       action = gtk_action_group_get_action (totem->main_action_group, "aspect-ratio-auto");
-       gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), tmp);
+       action = g_action_map_lookup_action (G_ACTION_MAP (totem), "aspect-ratio");
+       g_action_change_state (action, g_variant_new ("i", tmp));
 }
 
 void


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