[totem] Use Pango attributes instead of boldify and italicise functions



commit af11b1a7338d87bb5707490e332e7fd41547ff3f
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Jul 26 18:59:38 2009 +0100

    Use Pango attributes instead of boldify and italicise functions

 data/plugins.ui                                    |   12 +++
 data/properties.ui                                 |   51 +++++++++++
 data/totem.ui                                      |   23 +++++-
 .../properties/bacon-video-widget-properties.c     |   14 +---
 src/plugins/totem-plugin-manager.c                 |   13 ---
 src/totem-interface.c                              |   92 --------------------
 src/totem-interface.h                              |    4 -
 src/totem-preferences.c                            |    9 --
 8 files changed, 87 insertions(+), 131 deletions(-)
---
diff --git a/data/plugins.ui b/data/plugins.ui
index 5550adb..01a7a1c 100644
--- a/data/plugins.ui
+++ b/data/plugins.ui
@@ -124,6 +124,9 @@
     		  <property name="width_chars">-1</property>
     		  <property name="single_line_mode">False</property>
     		  <property name="angle">0</property>
+    		  <attributes>
+		    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                  </attributes>
     		</object>
     		<packing>
     		  <property name="padding">0</property>
@@ -188,6 +191,9 @@
     		  <property name="width_chars">-1</property>
     		  <property name="single_line_mode">False</property>
     		  <property name="angle">0</property>
+    		  <attributes>
+		    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                  </attributes>
     		</object>
     		<packing>
     		  <property name="padding">0</property>
@@ -252,6 +258,9 @@
     		  <property name="width_chars">-1</property>
     		  <property name="single_line_mode">False</property>
     		  <property name="angle">0</property>
+    		  <attributes>
+		    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                  </attributes>
     		</object>
     		<packing>
     		  <property name="padding">0</property>
@@ -316,6 +325,9 @@
     		  <property name="width_chars">-1</property>
     		  <property name="single_line_mode">False</property>
     		  <property name="angle">0</property>
+    		  <attributes>
+		    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                  </attributes>
     		</object>
     		<packing>
     		  <property name="padding">0</property>
diff --git a/data/properties.ui b/data/properties.ui
index cc2f396..291edf0 100644
--- a/data/properties.ui
+++ b/data/properties.ui
@@ -32,6 +32,9 @@
 	  <property name="width_chars">-1</property>
 	  <property name="single_line_mode">False</property>
 	  <property name="angle">0</property>
+	  <attributes>
+	    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+	  </attributes>
 	</object>
 	<packing>
 	  <property name="padding">0</property>
@@ -81,6 +84,9 @@
 		  <accessibility>
 		    <relation target="title" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -112,6 +118,9 @@
 		  <accessibility>
 		    <relation target="artist" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -143,6 +152,9 @@
 		  <accessibility>
 		    <relation target="duration" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -174,6 +186,9 @@
 		  <accessibility>
 		    <relation target="year" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -205,6 +220,9 @@
 		  <accessibility>
 		    <relation target="album" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -396,6 +414,9 @@
 		  <accessibility>
 		    <relation target="comment" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -478,6 +499,9 @@
 	  <property name="width_chars">-1</property>
 	  <property name="single_line_mode">False</property>
 	  <property name="angle">0</property>
+	  <attributes>
+	    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+	  </attributes>
 	</object>
 	<packing>
 	  <property name="padding">0</property>
@@ -527,6 +551,9 @@
 		  <accessibility>
 		    <relation target="dimensions" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -558,6 +585,9 @@
 		  <accessibility>
 		    <relation target="vcodec" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -589,6 +619,9 @@
 		  <accessibility>
 		    <relation target="framerate" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -620,6 +653,9 @@
 		  <accessibility>
 		    <relation target="video_bitrate" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -798,6 +834,9 @@
 	  <property name="width_chars">-1</property>
 	  <property name="single_line_mode">False</property>
 	  <property name="angle">0</property>
+	  <attributes>
+	    <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+	  </attributes>
 	</object>
 	<packing>
 	  <property name="padding">0</property>
@@ -847,6 +886,9 @@
 		  <accessibility>
 		    <relation target="samplerate" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -910,6 +952,9 @@
 		  <accessibility>
 		    <relation target="audio_bitrate" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -973,6 +1018,9 @@
 		  <accessibility>
 		    <relation target="acodec" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
@@ -1036,6 +1084,9 @@
 		  <accessibility>
 		    <relation target="channels" type="label-for"/>
 		  </accessibility>
+		  <attributes>
+	            <attribute name="style" value="PANGO_STYLE_ITALIC"/>
+	          </attributes>
 		</object>
 		<packing>
 		  <property name="left_attach">0</property>
diff --git a/data/totem.ui b/data/totem.ui
index f643f1b..eed2a82 100644
--- a/data/totem.ui
+++ b/data/totem.ui
@@ -755,6 +755,9 @@
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
 		      <property name="angle">0</property>
+		      <attributes>
+		        <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                      </attributes>
 		    </object>
 		    <packing>
 		      <property name="padding">0</property>
@@ -825,6 +828,9 @@
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
 		      <property name="angle">0</property>
+		      <attributes>
+		        <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                      </attributes>
 		    </object>
 		    <packing>
 		      <property name="padding">0</property>
@@ -937,6 +943,9 @@
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
 		      <property name="angle">0</property>
+		      <attributes>
+		        <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                      </attributes>
 		    </object>
 		    <packing>
 		      <property name="padding">0</property>
@@ -1157,6 +1166,9 @@
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
 		      <property name="angle">0</property>
+		      <attributes>
+		        <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                      </attributes>
 		    </object>
 		    <packing>
 		      <property name="padding">0</property>
@@ -1262,6 +1274,9 @@
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
 		      <property name="angle">0</property>
+		      <attributes>
+		        <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                      </attributes>
 		    </object>
 		    <packing>
 		      <property name="padding">0</property>
@@ -1410,7 +1425,7 @@
 				    <object class="GtkCellRendererText" id="renderer1"/>
 				    <attributes>
 				      <attribute name="text">0</attribute>
-			      	    </attributes>
+				    </attributes>
 				  </child>
 				</object>
 				<packing>
@@ -1474,6 +1489,9 @@
 			  <property name="width_chars">-1</property>
 			  <property name="single_line_mode">False</property>
 			  <property name="angle">0</property>
+			  <attributes>
+		            <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                          </attributes>
 			</object>
 			<packing>
 			  <property name="padding">0</property>
@@ -1825,6 +1843,9 @@
 			  <property name="width_chars">-1</property>
 			  <property name="single_line_mode">False</property>
 			  <property name="angle">0</property>
+			  <attributes>
+		            <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                          </attributes>
 			</object>
 			<packing>
 			  <property name="padding">0</property>
diff --git a/src/plugins/properties/bacon-video-widget-properties.c b/src/plugins/properties/bacon-video-widget-properties.c
index 8f3f9c2..79ed37e 100644
--- a/src/plugins/properties/bacon-video-widget-properties.c
+++ b/src/plugins/properties/bacon-video-widget-properties.c
@@ -280,11 +280,6 @@ bacon_video_widget_properties_new (void)
 			"dimensions_label", "vcodec_label", "framerate_label",
 			"vbitrate_label", "abitrate_label", "acodec_label",
 			"samplerate_label", "channels_label" };
-	const char *bold_labels[] = {
-		"bvwp_general_label",
-		"bvwp_video_label",
-		"bvwp_audio_label"
-	};
 	guint i;
 
 	xml = totem_interface_load ("properties.ui", TRUE, NULL, NULL);
@@ -303,13 +298,8 @@ bacon_video_widget_properties_new (void)
 
 	group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
-	for (i = 0; i < G_N_ELEMENTS (labels); i++) {
-		gtk_size_group_add_widget (group,
-					   GTK_WIDGET (gtk_builder_get_object (xml, labels[i])));
-		totem_interface_italicise_label (xml, labels[i]);
-	}
-	for (i = 0; i < G_N_ELEMENTS (bold_labels); i++)
-		totem_interface_boldify_label (xml, bold_labels[i]);
+	for (i = 0; i < G_N_ELEMENTS (labels); i++)
+		gtk_size_group_add_widget (group, GTK_WIDGET (gtk_builder_get_object (xml, labels[i])));
 
 	g_object_unref (group);
 
diff --git a/src/plugins/totem-plugin-manager.c b/src/plugins/totem-plugin-manager.c
index 87d32f4..5ae6faf 100644
--- a/src/plugins/totem-plugin-manager.c
+++ b/src/plugins/totem-plugin-manager.c
@@ -60,10 +60,6 @@ struct _TotemPluginManagerPrivate
 	GtkTreeModel	*plugin_model;
 
 	GtkWidget	*configure_button;
-	GtkWidget	*site_label;
-	GtkWidget	*copyright_label;
-	GtkWidget	*authors_label;
-	GtkWidget	*description_label;
 	GtkWidget	*header_hbox;
 	GtkWidget	*plugin_icon;
 	GtkWidget	*site_text;
@@ -503,15 +499,6 @@ totem_plugin_manager_init (TotemPluginManager *pm)
 	pm->priv->header_hbox = GTK_WIDGET (gtk_builder_get_object (xml, "header_hbox"));
 	pm->priv->plugin_title = GTK_WIDGET (gtk_builder_get_object (xml, "plugin_title"));
 
-	pm->priv->site_label = GTK_WIDGET (gtk_builder_get_object (xml, "site_label"));
-	totem_interface_boldify_label (xml, "site_label");
-	pm->priv->copyright_label = GTK_WIDGET (gtk_builder_get_object (xml, "copyright_label"));
-	totem_interface_boldify_label (xml, "copyright_label");
-	pm->priv->authors_label = GTK_WIDGET (gtk_builder_get_object (xml, "authors_label"));
-	totem_interface_boldify_label (xml, "authors_label");
-	pm->priv->description_label = GTK_WIDGET (gtk_builder_get_object (xml, "description_label"));
-	totem_interface_boldify_label (xml, "description_label");
-
 	pm->priv->plugin_icon = GTK_WIDGET (gtk_builder_get_object (xml, "plugin_icon"));
 	pm->priv->site_text = GTK_WIDGET (gtk_builder_get_object (xml, "site_text"));
 	pm->priv->copyright_text = GTK_WIDGET (gtk_builder_get_object (xml, "copyright_text"));
diff --git a/src/totem-interface.c b/src/totem-interface.c
index 6c4ddd8..5cd5a80 100644
--- a/src/totem-interface.c
+++ b/src/totem-interface.c
@@ -372,95 +372,3 @@ totem_interface_get_license (void)
 			  NULL);
 }
 
-/**
- * totem_interface_boldify_label:
- * @builder: a #GtkBuilder
- * @name: the label name
- *
- * Makes the text of the @name label bold.
- *
- * This should be used instead of putting the Pango markup directly into a #GtkBuilder
- * UI file so that translators don't have to translate text formatting markup unnecessarily.
- *
- * This function can only be used if the entire text of a label is to be made bold.
- **/
-void
-totem_interface_boldify_label (GtkBuilder *builder, const char *name)
-{
-	GtkLabel *widget;
-	gchar *str_final;
-
-	widget = GTK_LABEL (gtk_builder_get_object (builder, name));
-
-	if (widget == NULL) {
-		g_warning ("widget '%s' not found", name);
-		return;
-	}
-
-	/* this way is probably better, but for some reason doesn't work with
-	 * labels with mnemonics.
-
-	static PangoAttrList *pattrlist = NULL;
-
-	if (pattrlist == NULL) {
-		PangoAttribute *attr;
-
-		pattrlist = pango_attr_list_new ();
-		attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
-		attr->start_index = 0;
-		attr->end_index = G_MAXINT;
-		pango_attr_list_insert (pattrlist, attr);
-	}
-	gtk_label_set_attributes (widget, pattrlist);*/
-
-	str_final = g_strdup_printf ("<b>%s</b>", gtk_label_get_label (widget));
-	gtk_label_set_markup_with_mnemonic (widget, str_final);
-	g_free (str_final);
-}
-
-/**
- * totem_interface_italicise_label:
- * @builder: a #GtkBuilder
- * @name: the label name
- *
- * Makes the text of the @name label italic.
- *
- * This should be used instead of putting the Pango markup directly into a #GtkBuilder
- * UI file so that translators don't have to translate text formatting markup unnecessarily.
- *
- * This function can only be used if the entire text of a label is to be made italic.
- **/
-void
-totem_interface_italicise_label (GtkBuilder *builder, const char *name)
-{
-	GtkLabel *widget;
-	gchar *str_final;
-
-	widget = GTK_LABEL (gtk_builder_get_object (builder, name));
-
-	if (widget == NULL) {
-		g_warning ("widget '%s' not found", name);
-		return;
-	}
-
-	/* this way is probably better, but for some reason doesn't work with
-	 * labels with mnemonics.
-
-	static PangoAttrList *pattrlist = NULL;
-
-	if (pattrlist == NULL) {
-		PangoAttribute *attr;
-
-		pattrlist = pango_attr_list_new ();
-		attr = pango_attr_style_new (PANGO_STYLE_ITALIC);
-		attr->start_index = 0;
-		attr->end_index = G_MAXINT;
-		pango_attr_list_insert (pattrlist, attr);
-	}
-	gtk_label_set_attributes (widget, pattrlist);*/
-
-	str_final = g_strdup_printf ("<i>%s</i>", gtk_label_get_label (widget));
-	gtk_label_set_markup_with_mnemonic (widget, str_final);
-	g_free (str_final);
-}
-
diff --git a/src/totem-interface.h b/src/totem-interface.h
index d10128a..a87e94a 100644
--- a/src/totem-interface.h
+++ b/src/totem-interface.h
@@ -53,10 +53,6 @@ void		 totem_interface_error_with_link (const char *title,
 void		 totem_interface_set_transient_for (GtkWindow *window,
 						    GtkWindow *parent);
 char *		 totem_interface_get_license	(void);
-void		 totem_interface_boldify_label	(GtkBuilder *builder,
-						 const char *name);
-void		 totem_interface_italicise_label(GtkBuilder *builder,
-						 const char *name);
 
 G_END_DECLS
 
diff --git a/src/totem-preferences.c b/src/totem-preferences.c
index 03b7c85..fd37e6a 100644
--- a/src/totem-preferences.c
+++ b/src/totem-preferences.c
@@ -545,15 +545,6 @@ totem_setup_preferences (Totem *totem)
 	item = gtk_builder_get_object (totem->xml, "totem_preferences_window");
 	gtk_widget_destroy (GTK_WIDGET (item));
 
-	/* Boldify some labels */
-	totem_interface_boldify_label (totem->xml, "tpw_playback_label");
-	totem_interface_boldify_label (totem->xml, "tpw_network_label");
-	totem_interface_boldify_label (totem->xml, "tpw_text_subtitles_label");
-	totem_interface_boldify_label (totem->xml, "tpw_display_label");
-	totem_interface_boldify_label (totem->xml, "tpw_visuals_label");
-	totem_interface_boldify_label (totem->xml, "tpw_color_balance_label");
-	totem_interface_boldify_label (totem->xml, "tpw_audio_output_label");
-
 	g_signal_connect (G_OBJECT (totem->prefs), "response",
 			G_CALLBACK (gtk_widget_hide), NULL);
 	g_signal_connect (G_OBJECT (totem->prefs), "delete-event",



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