[snappy] ui: ony show subtitle toggle if subtitles available



commit 90edfd7a3ffd0ff4df0e2f27a205a27db83244d2
Author: Luis de Bethencourt <luis debethencourt com>
Date:   Fri Dec 14 13:51:37 2012 -0500

    ui: ony show subtitle toggle if subtitles available

 src/gst_engine.c     |    9 +++++++++
 src/user_interface.c |   19 +++++++++++++++++--
 src/user_interface.h |    1 +
 3 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/gst_engine.c b/src/gst_engine.c
index 049bdc3..b1208a8 100644
--- a/src/gst_engine.c
+++ b/src/gst_engine.c
@@ -477,6 +477,8 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
       GST_DEBUG ("State changed");
       gst_message_parse_state_changed (msg, &old, &new, &pending);
       if (new == GST_STATE_PLAYING) {
+        gint streams;
+
         /* If loading file */
         if (!engine->has_started) {
           gint64 position;
@@ -492,6 +494,13 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
           else
             g_print ("Secret mode. Not saving uri in history.\n");
 
+          g_object_get (G_OBJECT (engine->player), "n-text", &streams, NULL);
+          if (streams > 0) {
+            ui->subtitles_available = TRUE;
+          } else {
+            ui->subtitles_available = FALSE;
+          }
+
           interface_update_controls (ui);
           engine->has_started = TRUE;
         }
diff --git a/src/user_interface.c b/src/user_interface.c
index ddb822e..e035cf8 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -687,7 +687,7 @@ load_controls (UserInterface * ui)
     g_error_free (error);
     error = NULL;
   }
-  // clutter_actor_add_child (ui->info_box, ui->subtitle_toggle);
+  clutter_actor_hide (ui->subtitle_toggle);
   clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (ui->info_box_layout), ui->subtitle_toggle, FALSE,       /* expand */
       FALSE,                    /* x-fill */
       FALSE,                    /* y-fill */
@@ -886,6 +886,13 @@ show_controls (UserInterface * ui, gboolean vis)
   else if (vis == TRUE && ui->controls_showing == FALSE) {
     ui->controls_showing = TRUE;
 
+    if (ui->subtitles_available) {
+      clutter_actor_show (ui->subtitle_toggle);
+    } else {
+      clutter_actor_hide (ui->subtitle_toggle);
+    }
+
+    update_controls_size (ui);
     progress_update_seekbar (ui);
     progress_update_text (ui);
     clutter_stage_show_cursor (CLUTTER_STAGE (ui->stage));
@@ -949,6 +956,7 @@ update_controls_size (UserInterface * ui)
   gchar *font_name;
   gfloat ctl_width, ctl_height;
   gfloat icon_size;
+  gfloat control_box_width;
 
   // g_print ("Updating controls size for stage: %ux%u\n", ui->stage_width,
   //     ui->stage_height);
@@ -964,8 +972,14 @@ update_controls_size (UserInterface * ui)
 
   icon_size = ctl_height * PLAY_TOGGLE_RATIO;
 
+  if (ui->subtitles_available) {
+    control_box_width = ctl_width + ((ctl_width / BG_W) * SHADOW_RIGHT) + (icon_size * 0.72f);
+  } else {
+    control_box_width = ctl_width + ((ctl_width / BG_W) * SHADOW_RIGHT);
+  }
+
   clutter_actor_set_size (CLUTTER_ACTOR (ui->control_box),
-      ctl_width + ((ctl_width / BG_W) * SHADOW_RIGHT) + (icon_size * 0.72f),
+      control_box_width,
       ctl_height + ((ctl_height / BG_H) * SHADOW_BOTTOM));
 
   clutter_actor_set_size (ui->control_play_toggle, icon_size, icon_size);
@@ -1047,6 +1061,7 @@ interface_init (UserInterface * ui)
   ui->volume_high_png = NULL;
 
   ui->subtitle_toggle_png = NULL;
+  ui->subtitles_available = FALSE;
   ui->video_stream_toggle_png = NULL;
   ui->audio_stream_toggle_png = NULL;
 
diff --git a/src/user_interface.h b/src/user_interface.h
index 6278273..3c8266b 100644
--- a/src/user_interface.h
+++ b/src/user_interface.h
@@ -79,6 +79,7 @@ struct _UserInterface
 {
   gboolean controls_showing, keep_showing_controls;
   gboolean blind, fullscreen, hide, penalty_box_active, tags;
+  gboolean subtitles_available;
 
   gint title_length, controls_timeout, progress_id;
   guint media_width, media_height;



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