[Xfce4-commits] <parole:bluesabre/gtk3> Remove redundant playlist title code

Sean Davis noreply at xfce.org
Mon Sep 16 04:08:01 CEST 2013


Updating branch refs/heads/bluesabre/gtk3
         to bde5e5b8f297e66b0ee5026f0a6b70574fa521ad (commit)
       from 98b00eedc3a7418b241d6f839f9bf0bfd2dbca12 (commit)

commit bde5e5b8f297e66b0ee5026f0a6b70574fa521ad
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Sep 15 22:07:50 2013 -0400

    Remove redundant playlist title code

 src/gst/parole-gst.c   |    3 ++
 src/parole-medialist.c |   82 ++++++++++++++++++++++++------------------------
 2 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/src/gst/parole-gst.c b/src/gst/parole-gst.c
index 452621e..acb93c5 100644
--- a/src/gst/parole-gst.c
+++ b/src/gst/parole-gst.c
@@ -466,7 +466,10 @@ static void
 parole_gst_set_video_overlay (ParoleGst *gst)
 {
     GstElement *video_sink;
+#if GTK_CHECK_VERSION(3,8,0)
+#else
     gboolean enable_xv;
+#endif
     
     g_object_get (G_OBJECT (gst->priv->playbin),
                   "video-sink", &video_sink,
diff --git a/src/parole-medialist.c b/src/parole-medialist.c
index 28ca38b..afd783b 100644
--- a/src/parole-medialist.c
+++ b/src/parole-medialist.c
@@ -211,6 +211,44 @@ parole_media_list_set_widget_sensitive (ParoleMediaList *list, gboolean sensitiv
     gtk_widget_set_sensitive (GTK_WIDGET (list->priv->clear_button), sensitive);
 }
 
+static void
+parole_media_list_set_playlist_count (ParoleMediaList *list, gint n_items)
+{
+    /* Toggle sensitivity based on playlist count */
+    parole_media_list_set_widget_sensitive (list, n_items != 0);
+    gtk_widget_set_sensitive (list->priv->remove_button, n_items != 0);
+    gtk_widget_set_sensitive (list->priv->clear_button, n_items != 0);
+
+    if ( n_items == 1 )
+    {
+        if (gtk_notebook_get_current_page(GTK_NOTEBOOK(list->priv->playlist_notebook)) == 0)
+        {
+            gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i item)"), n_items));
+        }
+        else
+        {
+            gtk_tree_view_column_set_title (list->priv->disc_col, g_strdup_printf(_("Playlist (%i chapter)"), n_items));
+        }
+    }
+    else
+    {
+        if (gtk_notebook_get_current_page(GTK_NOTEBOOK(list->priv->playlist_notebook)) == 0)
+        {
+            gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i items)"), n_items));
+        }
+        else
+        {
+            gtk_tree_view_column_set_title (list->priv->disc_col, g_strdup_printf(_("Playlist (%i chapters)"), n_items));
+        }
+    }
+    
+    /*
+     * Will emit the signal media_cursor_changed with FALSE because there is no any 
+     * row remaining, so the player can disable click on the play button.
+     */
+    g_signal_emit (G_OBJECT (list), signals [MEDIA_CURSOR_CHANGED], 0, n_items != 0);
+}
+
 /**
  * parole_media_list_add:
  * @ParoleMediaList: a #ParoleMediaList
@@ -270,31 +308,7 @@ parole_media_list_add (ParoleMediaList *list, ParoleFile *file, gboolean disc, g
     else
         nch = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (list->priv->store), NULL); 
     
-    if ( nch == 1 )
-    {
-        gtk_widget_set_sensitive (list->priv->remove_button, TRUE);
-        gtk_widget_set_sensitive (list->priv->clear_button, TRUE);
-        if (gtk_notebook_get_current_page(GTK_NOTEBOOK(list->priv->playlist_notebook)) == 0)
-        {
-            gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i item)"), nch));
-        }
-        else
-        {
-            gtk_tree_view_column_set_title (list->priv->disc_col, g_strdup_printf(_("Playlist (%i chapter)"), nch));
-        }
-    }
-    else
-    {
-        parole_media_list_set_widget_sensitive (list, TRUE);
-        if (gtk_notebook_get_current_page(GTK_NOTEBOOK(list->priv->playlist_notebook)) == 0)
-        {
-            gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i items)"), nch));
-        }
-        else
-        {
-            gtk_tree_view_column_set_title (list->priv->disc_col, g_strdup_printf(_("Playlist (%i chapters)"), nch));
-        }
-    }
+    parole_media_list_set_playlist_count(list, nch);
 }
 
 /**
@@ -977,20 +991,7 @@ parole_media_list_remove_clicked_cb (GtkButton *button, ParoleMediaList *list)
      */
     nch = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (list->priv->store), NULL); 
     
-    if ( nch == 0)
-    {
-        parole_media_list_set_widget_sensitive (list, FALSE);
-        gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i items)"), nch));
-        /*
-         * Will emit the signal media_cursor_changed with FALSE because there is no any 
-         * row remaining, so the player can disable click on the play button.
-         */
-        g_signal_emit (G_OBJECT (list), signals [MEDIA_CURSOR_CHANGED], 0, FALSE);
-    }
-    else if ( nch == 1 )
-        gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i item)"), nch));
-    else
-        gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i items)"), nch));
+    parole_media_list_set_playlist_count(list, nch);
 }
 
 void 
@@ -1213,8 +1214,7 @@ parole_media_list_clear_list (ParoleMediaList *list)
 {
     TRACE("CLEAR START");
     gtk_list_store_clear (GTK_LIST_STORE (list->priv->store));
-    parole_media_list_set_widget_sensitive (list, FALSE);
-    gtk_tree_view_column_set_title (list->priv->col, g_strdup_printf(_("Playlist (%i items)"), 0));
+    parole_media_list_set_playlist_count(list, 0);
     TRACE("CLEAR END");
 }
 


More information about the Xfce4-commits mailing list