[totem/gnome-2-32] Add plural strings in the "Skip to" dialogue



commit 7d985d9822f741b1d794e781154f9cf53dde598c
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Aug 9 23:18:41 2010 +0100

    Add plural strings in the "Skip to" dialogue

 src/plugins/skipto/skipto.ui      |    6 +++---
 src/plugins/skipto/totem-skipto.c |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/skipto/skipto.ui b/src/plugins/skipto/skipto.ui
index 199c7f9..6fb59d2 100644
--- a/src/plugins/skipto/skipto.ui
+++ b/src/plugins/skipto/skipto.ui
@@ -56,6 +56,7 @@
               <property name="page-increment">10</property>
               <property name="page-size">0</property>
               <property name="value">0</property>
+              <signal name="value-changed" handler="tstw_adjustment_value_changed_cb"/>
 	    </object>
 	    <object class="TotemTimeEntry" id="tstw_skip_time_entry">
 	      <property name="climb_rate">1</property>
@@ -73,18 +74,17 @@
 	  <child>
 	    <object class="GtkLabel" id="tstw_seconds_label">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">seconds</property>
+	      <property name="label"></property><!-- This is set in code -->
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
+	      <property name="wrap">True</property>
 	      <property name="selectable">False</property>
 	      <property name="xalign">0.5</property>
 	      <property name="yalign">0.5</property>
 	      <property name="xpad">0</property>
 	      <property name="ypad">0</property>
 	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-	      <property name="width_chars">-1</property>
 	      <property name="single_line_mode">False</property>
 	      <property name="angle">0</property>
 	    </object>
diff --git a/src/plugins/skipto/totem-skipto.c b/src/plugins/skipto/totem-skipto.c
index 93e2f43..62b5478 100644
--- a/src/plugins/skipto/totem-skipto.c
+++ b/src/plugins/skipto/totem-skipto.c
@@ -46,10 +46,12 @@ static void totem_skipto_dispose	(GObject *object);
 
 /* Callback functions for GtkBuilder */
 G_MODULE_EXPORT void time_entry_activate_cb (GtkEntry *entry, TotemSkipto *skipto);
+G_MODULE_EXPORT void tstw_adjustment_value_changed_cb (GtkAdjustment *adjustment, TotemSkipto *skipto);
 
 struct TotemSkiptoPrivate {
 	GtkBuilder *xml;
 	GtkWidget *time_entry;
+	GtkLabel *seconds_label;
 	gint64 time;
 	Totem *totem;
 };
@@ -148,6 +150,14 @@ time_entry_activate_cb (GtkEntry *entry, TotemSkipto *skipto)
 	gtk_dialog_response (GTK_DIALOG (skipto), GTK_RESPONSE_OK);
 }
 
+void
+tstw_adjustment_value_changed_cb (GtkAdjustment *adjustment, TotemSkipto *skipto)
+{
+	/* Update the "seconds" label so that it always has the correct singular/plural form */
+	/* Translators: label for the seconds selector in the "Skip to" dialogue */
+	gtk_label_set_label (skipto->priv->seconds_label, ngettext ("second", "seconds", (int) gtk_adjustment_get_value (adjustment)));
+}
+
 GtkWidget *
 totem_skipto_new (TotemSkiptoPlugin *plugin)
 {
@@ -167,6 +177,15 @@ totem_skipto_new (TotemSkiptoPlugin *plugin)
 	}
 	skipto->priv->time_entry = GTK_WIDGET (gtk_builder_get_object
 		(skipto->priv->xml, "tstw_skip_time_entry"));
+	skipto->priv->seconds_label = GTK_LABEL (gtk_builder_get_object
+		(skipto->priv->xml, "tstw_seconds_label"));
+
+	/* Fix the label width at the maximum necessary for the plural labels, to prevent it changing size when we change the spinner value */
+	gtk_label_set_width_chars (skipto->priv->seconds_label, MAX (strlen (_("second")), strlen (_("seconds"))));
+
+	/* Set the initial "seconds" label */
+	tstw_adjustment_value_changed_cb (GTK_ADJUSTMENT (gtk_builder_get_object
+		(skipto->priv->xml, "tstw_skip_adjustment")), skipto);
 
 	gtk_window_set_title (GTK_WINDOW (skipto), _("Skip to"));
 	gtk_dialog_set_has_separator (GTK_DIALOG (skipto), FALSE);



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