[totem] main: Remove GtkUIManager usage



commit 40d4b61b75f0ccd8f1e3577f43d6849a187e8f6c
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 30 19:47:27 2014 +0200

    main: Remove GtkUIManager usage
    
    Plenty of deprecated code gone.

 data/totem.ui       |   33 ---------------------------
 src/totem-menu.c    |   61 ++++++++++++++++++++++++--------------------------
 src/totem-menu.h    |    2 -
 src/totem-object.c  |   61 ++++++++++++++++++++++----------------------------
 src/totem-private.h |   12 +---------
 src/totem.c         |   17 --------------
 6 files changed, 57 insertions(+), 129 deletions(-)
---
diff --git a/data/totem.ui b/data/totem.ui
index f9bde01..a1e621e 100644
--- a/data/totem.ui
+++ b/data/totem.ui
@@ -161,39 +161,6 @@
        </section>
 </menu>
 
-<object class="GtkUIManager" id="totem-ui-manager">
-   <child>
-      <object class="GtkActionGroup" id="main-action-group">
-         <child>
-            <object class="GtkAction" id="play">
-               <property name="label" translatable="yes">Play / P_ause</property>
-               <property name="tooltip" translatable="yes">Play or pause the movie</property>
-               <signal name="activate" handler="play_action_callback"/>
-            </object>
-            <accelerator key="space" modifiers="GDK_CONTROL_MASK"/>
-         </child>
-
-         <child>
-            <object class="GtkAction" id="next-chapter">
-               <property name="label" translatable="yes">_Next Chapter/Movie</property>
-               <property name="tooltip" translatable="yes">Next chapter or movie</property>
-               <signal name="activate" handler="next_chapter_action_callback"/>
-            </object>
-            <accelerator key="Right" modifiers="GDK_MOD1_MASK"/>
-         </child>
-         <child>
-            <object class="GtkAction" id="previous-chapter">
-               <property name="label" translatable="yes">_Previous Chapter/Movie</property>
-               <property name="tooltip" translatable="yes">Previous chapter or movie</property>
-               <signal name="activate" handler="previous_chapter_action_callback"/>
-            </object>
-            <accelerator key="Left" modifiers="GDK_MOD1_MASK"/>
-         </child>
-
-      </object>
-   </child>
-</object>
-
 <object class="GtkAdjustment" id="tmw_seek_adjustment">
   <property name="lower">0</property>
   <property name="upper">0</property>
diff --git a/src/totem-menu.c b/src/totem-menu.c
index af78389..d17a6d0 100644
--- a/src/totem-menu.c
+++ b/src/totem-menu.c
@@ -37,11 +37,6 @@
 
 #include "totem-profile.h"
 
-/* Callback functions for GtkBuilder */
-G_MODULE_EXPORT void play_action_callback (GtkAction *action, Totem *totem);
-G_MODULE_EXPORT void next_chapter_action_callback (GtkAction *action, Totem *totem);
-G_MODULE_EXPORT void previous_chapter_action_callback (GtkAction *action, Totem *totem);
-
 static void
 open_action_cb (GSimpleAction *action,
                GVariant      *parameter,
@@ -248,6 +243,30 @@ select_subtitle_action_cb (GSimpleAction *action,
                                               TOTEM_PLAYLIST_DIALOG_PLAYING);
 }
 
+static void
+play_action_cb (GSimpleAction *action,
+               GVariant      *parameter,
+               gpointer       user_data)
+{
+       totem_object_play_pause (TOTEM_OBJECT (user_data));
+}
+
+static void
+next_chapter_action_cb (GSimpleAction *action,
+                       GVariant      *parameter,
+                       gpointer       user_data)
+{
+       TOTEM_PROFILE (totem_object_seek_next (TOTEM_OBJECT (user_data)));
+}
+
+static void
+previous_chapter_action_cb (GSimpleAction *action,
+                           GVariant      *parameter,
+                           gpointer       user_data)
+{
+       TOTEM_PROFILE (totem_object_seek_previous (TOTEM_OBJECT (user_data)));
+}
+
 static GActionEntry app_entries[] = {
        /* Main app menu */
        { "open", open_action_cb, NULL, NULL, NULL },
@@ -273,6 +292,11 @@ static GActionEntry app_entries[] = {
        { "zoom", toggle_action_cb, NULL, "false", zoom_action_change_state },
        { "next-angle", next_angle_action_cb, NULL, NULL, NULL },
        { "eject", eject_action_cb, NULL, NULL, NULL },
+
+       /* Navigation popup */
+       { "play", play_action_cb, NULL, NULL, NULL },
+       { "next-chapter", next_chapter_action_cb, NULL, NULL, NULL },
+       { "previous-chapter", previous_chapter_action_cb, NULL, NULL, NULL },
 };
 
 void
@@ -498,30 +522,3 @@ totem_sublang_exit (Totem *totem)
        g_list_free_full (totem->subtitles_list, g_free);
        g_list_free_full (totem->languages_list, g_free);
 }
-
-void
-play_action_callback (GtkAction *action, Totem *totem)
-{
-       totem_object_play_pause (totem);
-}
-
-void
-next_chapter_action_callback (GtkAction *action, Totem *totem)
-{
-       TOTEM_PROFILE (totem_object_seek_next (totem));
-}
-
-void
-previous_chapter_action_callback (GtkAction *action, Totem *totem)
-{
-       TOTEM_PROFILE (totem_object_seek_previous (totem));
-}
-
-void
-totem_ui_manager_setup (Totem *totem)
-{
-       totem->main_action_group = GTK_ACTION_GROUP (gtk_builder_get_object (totem->xml, 
"main-action-group"));
-
-       totem->ui_manager = GTK_UI_MANAGER (gtk_builder_get_object (totem->xml, "totem-ui-manager"));
-}
-
diff --git a/src/totem-menu.h b/src/totem-menu.h
index d9fb1fd..939c11a 100644
--- a/src/totem-menu.h
+++ b/src/totem-menu.h
@@ -29,8 +29,6 @@ G_BEGIN_DECLS
 
 void totem_app_menu_setup (Totem *totem);
 
-void totem_ui_manager_setup (Totem *totem);
-
 void totem_sublang_update (Totem *totem);
 void totem_sublang_exit (Totem *totem);
 
diff --git a/src/totem-object.c b/src/totem-object.c
index 15143a1..7f8709f 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -62,7 +62,6 @@
 #include "totem-interface.h"
 #include "totem-preferences.h"
 #include "totem-session.h"
-#include "totem-rtl-helpers.h"
 #include "totem-main-toolbar.h"
 
 #define WANT_MIME_TYPES 1
@@ -1298,9 +1297,8 @@ main_window_destroy_cb (GtkWidget *widget, GdkEvent *event, TotemObject *totem)
 static void
 play_pause_set_label (TotemObject *totem, TotemStates state)
 {
-       GtkAction *action;
+       GtkWidget *image;
        const char *id, *tip;
-       GSList *l, *proxies;
 
        if (state == totem->state)
                return;
@@ -1313,7 +1311,7 @@ play_pause_set_label (TotemObject *totem, TotemStates state)
                totem_playlist_set_playing (totem->playlist, TOTEM_PLAYLIST_STATUS_PLAYING);
                break;
        case STATE_PAUSED:
-               id = totem_get_rtl_icon_name ("media-playback-start");
+               id = "media-playback-start";
                tip = N_("Play");
                totem_playlist_set_playing (totem->playlist, TOTEM_PLAYLIST_STATUS_PAUSED);
                break;
@@ -1322,7 +1320,7 @@ play_pause_set_label (TotemObject *totem, TotemStates state)
                                           0, 0);
                bacon_time_label_set_time (totem->time_rem_label,
                                           0, 0);
-               id = totem_get_rtl_icon_name ("media-playback-start");
+               id = "media-playback-start";
                totem_playlist_set_playing (totem->playlist, TOTEM_PLAYLIST_STATUS_NONE);
                tip = N_("Play");
                break;
@@ -1331,16 +1329,9 @@ play_pause_set_label (TotemObject *totem, TotemStates state)
                return;
        }
 
-       action = gtk_action_group_get_action (totem->main_action_group, "play");
-       g_object_set (G_OBJECT (action),
-                       "tooltip", _(tip),
-                       "icon-name", id, NULL);
-
-       proxies = gtk_action_get_proxies (action);
-       for (l = proxies; l != NULL; l = l->next) {
-               atk_object_set_name (gtk_widget_get_accessible (l->data),
-                               _(tip));
-       }
+       gtk_widget_set_tooltip_text (totem->play_button, _(tip));
+       image = gtk_button_get_image (GTK_BUTTON (totem->play_button));
+       gtk_image_set_from_icon_name (GTK_IMAGE (image), id, GTK_ICON_SIZE_MENU);
 
        totem->state = state;
 
@@ -1777,15 +1768,15 @@ totem_object_set_mrl (TotemObject *totem,
                play_pause_set_label (totem, STATE_STOPPED);
 
                /* Play/Pause */
-               totem_object_set_sensitivity ("play", FALSE);
+               totem_object_set_sensitivity2 ("play", FALSE);
 
                /* Volume */
                totem_controls_set_sensitivity ("volume_button", FALSE);
                totem->volume_sensitive = FALSE;
 
                /* Control popup */
-               totem_object_set_sensitivity ("next-chapter", FALSE);
-               totem_object_set_sensitivity ("previous-chapter", FALSE);
+               totem_object_set_sensitivity2 ("next-chapter", FALSE);
+               totem_object_set_sensitivity2 ("previous-chapter", FALSE);
 
                /* Subtitle selection */
                totem_object_set_sensitivity2 ("select-subtitle", FALSE);
@@ -1819,7 +1810,7 @@ totem_object_set_mrl (TotemObject *totem,
                totem->mrl = g_strdup (mrl);
 
                /* Play/Pause */
-               totem_object_set_sensitivity ("play", TRUE);
+               totem_object_set_sensitivity2 ("play", TRUE);
 
                /* Volume */
                caps = bacon_video_widget_can_set_volume (totem->bvw);
@@ -3455,13 +3446,13 @@ update_buttons (TotemObject *totem)
        has_item = bacon_video_widget_has_previous_track (totem->bvw) ||
                totem_playlist_has_previous_mrl (totem->playlist) ||
                totem_playlist_get_repeat (totem->playlist);
-       totem_object_set_sensitivity ("previous-chapter", has_item);
+       totem_object_set_sensitivity2 ("previous-chapter", has_item);
 
        /* Next */
        has_item = bacon_video_widget_has_next_track (totem->bvw) ||
                totem_playlist_has_next_mrl (totem->playlist) ||
                totem_playlist_get_repeat (totem->playlist);
-       totem_object_set_sensitivity ("next-chapter", has_item);
+       totem_object_set_sensitivity2 ("next-chapter", has_item);
 }
 
 void
@@ -3589,27 +3580,25 @@ update_add_button_visibility (GObject     *gobject,
 static GtkWidget *
 create_control_button (TotemObject *totem,
                       const gchar *action_name,
+                      const gchar *icon_name,
                       const gchar *tooltip_text)
 {
        GtkWidget *button, *image;
-       GtkAction *action;
 
        button = gtk_button_new ();
-       image = gtk_image_new ();
+       g_object_set (G_OBJECT (button), "action-name", action_name, NULL);
+       image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
        gtk_button_set_image (GTK_BUTTON (button), image);
        gtk_widget_set_valign (GTK_WIDGET (button), GTK_ALIGN_CENTER);
        gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
-       if (g_str_equal (action_name, "play")) {
+       if (g_str_equal (action_name, "app.play")) {
                g_object_set (G_OBJECT (image),
                              "margin-start", 16,
                              "margin-end", 16,
                              NULL);
+               totem->play_button = button;
        }
 
-       action = gtk_action_group_get_action (totem->main_action_group,
-                                             action_name);
-       gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
-
        gtk_button_set_label (GTK_BUTTON (button), NULL);
        gtk_widget_set_tooltip_text (button, tooltip_text);
        atk_object_set_name (gtk_widget_get_accessible (button), tooltip_text);
@@ -3634,19 +3623,23 @@ totem_callback_connect (TotemObject *totem)
 
        /* Controls */
        box = g_object_get_data (totem->controls, "controls_box");
+       gtk_widget_insert_action_group (GTK_WIDGET (box), "app", G_ACTION_GROUP (totem));
 
        /* Previous */
-       item = create_control_button (totem, "previous-chapter",
+       item = create_control_button (totem, "app.previous-chapter",
+                                     "media-skip-backward",
                                      _("Previous Chapter/Movie"));
        gtk_box_pack_start (box, item, FALSE, FALSE, 0);
 
        /* Play/Pause */
-       item = create_control_button (totem, "play",
+       item = create_control_button (totem, "app.play",
+                                     "media-playback-start",
                                      _("Play / Pause"));
        gtk_box_pack_start (box, item, FALSE, FALSE, 0);
 
        /* Next */
-       item = create_control_button (totem, "next-chapter",
+       item = create_control_button (totem, "app.next-chapter",
+                                     "media-skip-forward",
                                      _("Next Chapter/Movie"));
        gtk_box_pack_start (box, item, FALSE, FALSE, 0);
 
@@ -3714,9 +3707,9 @@ totem_callback_connect (TotemObject *totem)
        gtk_widget_add_events (totem->win, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
 
        /* Set sensitivity of the toolbar buttons */
-       totem_object_set_sensitivity ("play", FALSE);
-       totem_object_set_sensitivity ("next-chapter", FALSE);
-       totem_object_set_sensitivity ("previous-chapter", FALSE);
+       totem_object_set_sensitivity2 ("play", FALSE);
+       totem_object_set_sensitivity2 ("next-chapter", FALSE);
+       totem_object_set_sensitivity2 ("previous-chapter", FALSE);
 
        /* Volume */
        g_signal_connect (G_OBJECT (totem->bvw), "notify::volume",
diff --git a/src/totem-private.h b/src/totem-private.h
index a3dd2e2..ac2ec7f 100644
--- a/src/totem-private.h
+++ b/src/totem-private.h
@@ -48,13 +48,6 @@
        }
 #define totem_controls_set_sensitivity(name, state) gtk_widget_set_sensitive (g_object_get_data 
(totem->controls, name), state)
 
-#define totem_object_set_sensitivity(name, state)                                      \
-       {                                                                               \
-               GtkAction *__action;                                                    \
-               __action = gtk_action_group_get_action (totem->main_action_group, name);\
-               gtk_action_set_sensitive (__action, state);                             \
-       }
-
 #define totem_object_set_sensitivity2(name, state)                                     \
        {                                                                               \
                GAction *__action;                                                      \
@@ -88,6 +81,7 @@ struct _TotemObject {
        GtkWidget *grilo;
 
        GObject *controls;
+       GtkWidget *play_button;
        BaconTimeLabel *time_label;
        BaconTimeLabel *time_rem_label;
        GtkWidget *header;
@@ -96,10 +90,6 @@ struct _TotemObject {
        GtkWidget *fullscreen_header;
        GtkWidget *fullscreen_gear_button;
 
-       /* UI manager */
-       GtkActionGroup *main_action_group;
-       GtkUIManager *ui_manager;
-
        /* Plugins */
        GtkWidget *plugins;
        TotemPluginsEngine *engine;
diff --git a/src/totem.c b/src/totem.c
index 828071b..8c4df1e 100644
--- a/src/totem.c
+++ b/src/totem.c
@@ -48,7 +48,6 @@
 #include "totem-uri.h"
 #include "totem-preferences.h"
 #include "totem-session.h"
-#include "totem-rtl-helpers.h"
 
 static gboolean startup_called = FALSE;
 
@@ -70,17 +69,6 @@ debug_handler (const char *log_domain,
 }
 
 static void
-set_rtl_icon_name (Totem *totem,
-                  const char *widget_name,
-                  const char *icon_name)
-{
-       GtkAction *action;
-
-       action = GTK_ACTION (gtk_builder_get_object (totem->xml, widget_name));
-       gtk_action_set_icon_name (action, totem_get_rtl_icon_name (icon_name));
-}
-
-static void
 app_init (Totem *totem, char **argv)
 {
        GtkSettings *gtk_settings;
@@ -99,15 +87,10 @@ app_init (Totem *totem, char **argv)
        if (totem->xml == NULL)
                totem_object_exit (NULL);
 
-       set_rtl_icon_name (totem, "play", "media-playback-start");
-       set_rtl_icon_name (totem, "next-chapter", "media-skip-forward");
-       set_rtl_icon_name (totem, "previous-chapter", "media-skip-backward");
-
        totem->win = GTK_WIDGET (gtk_builder_get_object (totem->xml, "totem_main_window"));
 
        /* Menubar */
        totem->stack = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_main_stack"));
-       totem_ui_manager_setup (totem);
 
        /* The sidebar */
        playlist_widget_setup (totem);


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