[gtranslator] Fix close button style.



commit f8512c84339b0d9157063a6b69efaa7795e4d1f7
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Jan 12 01:24:11 2011 +0100

    Fix close button style.

 src/gtr-close-button.c |   68 ++++++++++++++++++++++++-----------------------
 1 files changed, 35 insertions(+), 33 deletions(-)
---
diff --git a/src/gtr-close-button.c b/src/gtr-close-button.c
index 88966ac..dec3828 100644
--- a/src/gtr-close-button.c
+++ b/src/gtr-close-button.c
@@ -25,56 +25,58 @@
 G_DEFINE_TYPE (GtrCloseButton, gtr_close_button, GTK_TYPE_BUTTON)
 
 static void
-gtr_close_button_style_set (GtkWidget *button,
-			      GtkStyle *previous_style)
-{
-	gint h, w;
-
-	gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (button),
-					   GTK_ICON_SIZE_MENU, &w, &h);
-
-	gtk_widget_set_size_request (button, w + 2, h + 2);
-
-	GTK_WIDGET_CLASS (gtr_close_button_parent_class)->style_set (button, previous_style);
-}
-
-static void
 gtr_close_button_class_init (GtrCloseButtonClass *klass)
 {
-	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
-	widget_class->style_set = gtr_close_button_style_set;
 }
 
 static void
 gtr_close_button_init (GtrCloseButton *button)
 {
-	GtkRcStyle *rcstyle;
 	GtkWidget *image;
-
-	/* make it as small as possible */
-	rcstyle = gtk_rc_style_new ();
-	rcstyle->xthickness = rcstyle->ythickness = 0;
-	gtk_widget_modify_style (GTK_WIDGET (button), rcstyle);
-	g_object_unref (rcstyle);
+	GtkCssProvider *css;
+	GError *error = NULL;
+	const gchar button_style[] =
+		"* {\n"
+		"	-GtkButton-default-border : 0;\n"
+		"	-GtkButton-default-outside-border : 0;\n"
+		"	-GtkButton-inner-border: 0;\n"
+		"	-GtkWidget-focus-line-width : 0;\n"
+		"	-GtkWidget-focus-padding : 0;\n"
+		"	padding: 0;\n"
+		"}";
 
 	image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
-					  GTK_ICON_SIZE_MENU);
+	                                  GTK_ICON_SIZE_MENU);
 	gtk_widget_show (image);
 
 	gtk_container_add (GTK_CONTAINER (button), image);
+
+	/* make it as small as possible */
+	css = gtk_css_provider_new ();
+	if (gtk_css_provider_load_from_data (css, button_style,
+	                                     -1, &error))
+	{
+		GtkStyleContext *context;
+
+		context = gtk_widget_get_style_context (GTK_WIDGET (button));
+		gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css),
+			                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+		g_object_unref (css);
+	}
+	else
+	{
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
 }
 
 GtkWidget *
 gtr_close_button_new ()
 {
-	GtrCloseButton *button;
-
-	button = g_object_new (GTR_TYPE_CLOSE_BUTTON,
-			       "relief", GTK_RELIEF_NONE,
-			       "focus-on-click", FALSE,
-			       NULL);
-
-	return GTK_WIDGET (button);
+	return GTK_WIDGET (g_object_new (GTR_TYPE_CLOSE_BUTTON,
+	                                 "relief", GTK_RELIEF_NONE,
+	                                 "focus-on-click", FALSE,
+	                                 NULL));
 }
 
+/* ex:set ts=8 noet: */



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