[totem] main: Switch to player when restored session



commit 946955b02d9b45bb6a683a5c2ee3191cef8f2a89
Author: Bastien Nocera <hadess hadess net>
Date:   Tue May 7 10:00:30 2013 +0200

    main: Switch to player when restored session

 src/totem-object.c  |   40 +++++++++++++++++++++-------------------
 src/totem-private.h |    3 +++
 src/totem-session.c |    3 +++
 3 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/src/totem-object.c b/src/totem-object.c
index 66f5767..116e44e 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -574,23 +574,6 @@ totem_object_get_current_time (TotemObject *totem)
        return bacon_video_widget_get_current_time (totem->bvw);
 }
 
-static void
-switch_to_page (Totem      *totem,
-               const char *page)
-{
-       GtkStackTransitionType type;
-
-       if (g_str_equal (page, "player"))
-               type = GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT;
-       else
-               type = GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT;
-
-       /* FIXME should we increase the minimum duration like that? */
-       gtk_stack_set_transition_duration (GTK_STACK (totem->stack), 500);
-       gtk_stack_set_transition_type (GTK_STACK (totem->stack), type);
-       gtk_stack_set_visible_child_name (GTK_STACK (totem->stack), page);
-}
-
 typedef struct {
        TotemObject *totem;
        gchar *uri;
@@ -615,7 +598,7 @@ add_to_playlist_and_play_cb (TotemPlaylist *playlist, GAsyncResult *async_result
                subtitle = NULL;
                totem_playlist_set_current (playlist, end);
                mrl = totem_playlist_get_current_mrl (playlist, &subtitle);
-               switch_to_page (data->totem, "player");
+               totem_object_set_main_page (data->totem, "player", TRUE);
                totem_action_set_mrl_and_play (data->totem, mrl, subtitle);
                g_free (mrl);
                g_free (subtitle);
@@ -790,6 +773,25 @@ totem_object_remove_sidebar_page (TotemObject *totem,
 }
 
 void
+totem_object_set_main_page (TotemObject *totem,
+                           const char  *page_id,
+                           gboolean animate)
+{
+       GtkStackTransitionType type;
+
+       if (!animate)
+               type = GTK_STACK_TRANSITION_TYPE_NONE;
+       else if (g_str_equal (page_id, "player"))
+               type = GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT;
+       else
+               type = GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT;
+
+       /* FIXME should we increase the minimum duration like that? */
+       gtk_stack_set_transition_duration (GTK_STACK (totem->stack), 500);
+       gtk_stack_set_visible_child_full (GTK_STACK (totem->stack), page_id, type);
+}
+
+void
 totem_object_add_main_page (TotemObject *totem,
                            const char  *page_id,
                            GtkWidget   *widget)
@@ -2215,7 +2217,7 @@ back_button_clicked_cb (GtkButton   *button,
                        TotemObject *totem)
 {
        totem_object_action_pause (totem);
-       switch_to_page (totem, "grilo");
+       totem_object_set_main_page (totem, "grilo", TRUE);
 }
 
 static void
diff --git a/src/totem-private.h b/src/totem-private.h
index 8ed75cd..644e141 100644
--- a/src/totem-private.h
+++ b/src/totem-private.h
@@ -190,6 +190,9 @@ void        totem_action_volume_toggle_mute         (TotemObject *totem);
 void   totem_object_add_main_page              (TotemObject *totem,
                                                 const char  *page_id,
                                                 GtkWidget   *widget);
+void   totem_object_set_main_page              (TotemObject *totem,
+                                                const char  *page_id,
+                                                gboolean     animate);
 
 /* Signal emission */
 void   totem_file_opened                       (TotemObject *totem,
diff --git a/src/totem-session.c b/src/totem-session.c
index 5e76479..d703b8b 100644
--- a/src/totem-session.c
+++ b/src/totem-session.c
@@ -80,6 +80,9 @@ totem_session_try_restore (Totem *totem)
        subtitle = NULL;
        mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
 
+       if (mrl != NULL)
+               totem_object_set_main_page (totem, "player", FALSE);
+
        totem_action_set_mrl (totem, mrl, subtitle);
 
        /* We do the seeking after being told that the stream is seekable,


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