[totem] Bug 637191 — Port to GtkStyleContext



commit 33f40c087b7a6f416b4bce8549038bf24137aaae
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Dec 13 22:21:30 2010 +0000

    Bug 637191 â?? Port to GtkStyleContext

 browser-plugin/totem-plugin-viewer.c |   33 ++++++++++++++++++++++++---------
 data/Makefile.am                     |    3 ++-
 data/mozilla-viewer.css              |    5 +++++
 src/totem-cell-renderer-video.c      |    2 +-
 src/totem-object.c                   |    9 ++++-----
 5 files changed, 36 insertions(+), 16 deletions(-)
---
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index a50d0b6..76a51da 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -1981,19 +1981,34 @@ totem_embedded_construct (TotemEmbedded *emb,
 
 	/* Try to make controls smaller */
 	{
-        	GtkRcStyle *rcstyle;
+		GtkCssProvider *provider;
+		gchar *css_path;
+		GError *error = NULL;
+
+		css_path = totem_interface_get_full_path ("mozilla-viewer.css");
+		provider = gtk_css_provider_new ();
+		gtk_css_provider_load_from_path (provider, css_path, &error);
+		g_free (css_path);
+
+		if (error != NULL) {
+			/* Error loading the CSS */
+			g_warning ("Couldn't load the CSS file '%s' for the browser plugin. The interface might not be styled correctly.", css_path);
+			g_error_free (error);
+		} else {
+			/* Success! Apply the styling to various widgets */
+			GtkStyleContext *context;
 
-		rcstyle = gtk_rc_style_new ();
-		rcstyle->xthickness = rcstyle->ythickness = 0;
+			context = gtk_widget_get_style_context (emb->pp_button);
+			gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
-		gtk_widget_modify_style (emb->pp_button, rcstyle);
-		
-		child = GTK_WIDGET (gtk_builder_get_object (emb->xml, "time_hscale"));
-		gtk_widget_modify_style (child, rcstyle);
+			context = gtk_widget_get_style_context (GTK_WIDGET (gtk_builder_get_object (emb->xml, "time_hscale")));
+			gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
-		gtk_widget_modify_style (emb->volume, rcstyle);
+			context = gtk_widget_get_style_context (emb->volume);
+			gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+		}
 
-		g_object_unref (rcstyle);
+		g_object_unref (provider);
 	}
 
 	/* Create the cursor before setting the state */
diff --git a/data/Makefile.am b/data/Makefile.am
index 0e3c2c4..068a839 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -28,7 +28,8 @@ stuff_DATA =				\
 	mozilla-viewer.ui		\
 	properties.ui			\
 	uri.ui				\
-	video-list.ui
+	video-list.ui			\
+	mozilla-viewer.css
 EXTRA_DIST += $(stuff_DATA)
 
 # Icons
diff --git a/data/mozilla-viewer.css b/data/mozilla-viewer.css
new file mode 100644
index 0000000..7048a36
--- /dev/null
+++ b/data/mozilla-viewer.css
@@ -0,0 +1,5 @@
+/* Style to attempt to reduce the size of the browser plugin */
+* {
+	padding: 0;
+	margin: 0;
+}
diff --git a/src/totem-cell-renderer-video.c b/src/totem-cell-renderer-video.c
index 4484662..10821b6 100644
--- a/src/totem-cell-renderer-video.c
+++ b/src/totem-cell-renderer-video.c
@@ -411,7 +411,7 @@ totem_cell_renderer_video_render (GtkCellRenderer *cell,
 	if (priv->thumbnail != NULL)
 		pixbuf = priv->thumbnail;
 	else if (priv->use_placeholder == TRUE)
-		pixbuf = gtk_widget_render_icon (widget, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_DIALOG, NULL);
+		pixbuf = gtk_widget_render_icon_pixbuf (widget, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_DIALOG);
 	else
 		pixbuf = NULL;
 
diff --git a/src/totem-object.c b/src/totem-object.c
index fc19606..d5288d0 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -3980,12 +3980,12 @@ char *
 totem_setup_window (TotemObject *totem)
 {
 	GKeyFile *keyfile;
-	int w, h, i;
+	int w, h;
 	gboolean show_sidebar;
 	char *filename, *page_id;
 	GError *err = NULL;
 	GtkWidget *vbox;
-	GdkColor black;
+	GdkRGBA black;
 
 	filename = g_build_filename (totem_dot_dir (), "state.ini", NULL);
 	keyfile = g_key_file_new ();
@@ -4057,9 +4057,8 @@ totem_setup_window (TotemObject *totem)
 
 	/* Set the vbox to be completely black */
 	vbox = GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_bvw_box"));
-	gdk_color_parse ("Black", &black);
-	for (i = 0; i <= GTK_STATE_INSENSITIVE; i++)
-		gtk_widget_modify_bg (vbox, i, &black);
+	gdk_rgba_parse (&black, "Black");
+	gtk_widget_override_background_color (vbox, (GTK_STATE_FLAG_FOCUSED << 1), &black);
 
 	totem_sidebar_setup (totem, show_sidebar, page_id);
 	return page_id;



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