[Xfce4-commits] <parole:bluesabre/gtk3> Improve list-count label behavior (hidden when list is empty) and make it translateable

Simon Steinbeiss noreply at xfce.org
Sun Aug 11 15:16:20 CEST 2013


Updating branch refs/heads/bluesabre/gtk3
         to 2df6d9e8564b531f760e8d43ecd5318272f5fdd5 (commit)
       from f2e0b4a1ae4c865d28207c3ac48614f1ca8f2738 (commit)

commit 2df6d9e8564b531f760e8d43ecd5318272f5fdd5
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Feb 22 11:58:15 2013 +0100

    Improve list-count label behavior (hidden when list is empty) and make it translateable

 src/parole-medialist.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/parole-medialist.c b/src/parole-medialist.c
index 53bf4f6..df65065 100644
--- a/src/parole-medialist.c
+++ b/src/parole-medialist.c
@@ -255,7 +255,6 @@ parole_media_list_add (ParoleMediaList *list, ParoleFile *file, gboolean disc, g
     GtkTreeRowReference *row;
     GtkTreeIter iter;
     gint nch;
-    gchar *n_items_text = "Playlist empty";
     
     if (disc)
         list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (list->priv->disc_view)));
@@ -299,12 +298,16 @@ parole_media_list_add (ParoleMediaList *list, ParoleFile *file, gboolean disc, g
     {
 	gtk_widget_set_sensitive (list->priv->remove_button, TRUE);
 	gtk_widget_set_sensitive (list->priv->clear_button, TRUE);
+	gtk_label_set_text (GTK_LABEL(list->priv->n_items),g_strdup_printf (_("%i item"),nch));
     }
     else
+    {
 	parole_media_list_set_widget_sensitive (list, TRUE);
-    if ( nch != 0 )
-	n_items_text = g_strdup_printf ("%i items",nch);
-    gtk_label_set_text (GTK_LABEL(list->priv->n_items),n_items_text);
+	gtk_label_set_text (GTK_LABEL(list->priv->n_items),g_strdup_printf (_("%i items"),nch));
+    }
+    gtk_widget_show (list->priv->n_items);
+    if ( nch == 0 )
+	    gtk_widget_hide (list->priv->n_items);
 }
 
 /**
@@ -973,15 +976,18 @@ parole_media_list_remove_clicked_cb (GtkButton *button, ParoleMediaList *list)
     if ( nch == 0)
     {
 	parole_media_list_set_widget_sensitive (list, FALSE);
-	gtk_label_set_text (GTK_LABEL(list->priv->n_items),"Playlist empty");
+	gtk_label_set_text (GTK_LABEL(list->priv->n_items),_("Playlist empty"));
+	gtk_widget_hide (list->priv->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, FALSE);
     }
-    
-    gtk_label_set_text (GTK_LABEL(list->priv->n_items),g_strdup_printf ("%i items",nch));
+    else if ( nch == 1 )
+	gtk_label_set_text (GTK_LABEL(list->priv->n_items),g_strdup_printf (_("%i item"),nch));
+    else
+	gtk_label_set_text (GTK_LABEL(list->priv->n_items),g_strdup_printf (_("%i items"),nch));
 }
 
 /**
@@ -1114,7 +1120,8 @@ 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_label_set_text (GTK_LABEL(list->priv->n_items),"Playlist empty");
+    gtk_label_set_text (GTK_LABEL(list->priv->n_items),_("Playlist empty"));
+    gtk_widget_hide (list->priv->n_items);
     TRACE("CLEAR END");
 }
 


More information about the Xfce4-commits mailing list