[gtranslator] Update close button from gedit.



commit 62801ca89ba848efbc8a5b54baa334007766858e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun Mar 13 16:18:32 2011 +0100

    Update close button from gedit.

 src/gtr-close-button.c |   78 +++++++++++++++++++++++------------------------
 src/gtr-close-button.h |   38 +++++++++++++----------
 2 files changed, 59 insertions(+), 57 deletions(-)
---
diff --git a/src/gtr-close-button.c b/src/gtr-close-button.c
index dec3828..e4374ea 100644
--- a/src/gtr-close-button.c
+++ b/src/gtr-close-button.c
@@ -3,47 +3,57 @@
  * This file is part of gtr
  *
  * Copyright (C) 2010 - Paolo Borelli
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * gtr is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * gtr is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, 
- * Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "gtr-close-button.h"
 
-G_DEFINE_TYPE (GtrCloseButton, gtr_close_button, GTK_TYPE_BUTTON)
+struct _GtrCloseButtonClassPrivate
+{
+	GtkCssProvider *css;
+};
+
+G_DEFINE_TYPE_WITH_CODE (GtrCloseButton, gtr_close_button, GTK_TYPE_BUTTON,
+                         g_type_add_class_private (g_define_type_id, sizeof (GtrCloseButtonClassPrivate)))
 
 static void
 gtr_close_button_class_init (GtrCloseButtonClass *klass)
 {
+	static 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"
+		"}";
+
+	klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GTR_TYPE_CLOSE_BUTTON, GtrCloseButtonClassPrivate);
+
+	klass->priv->css = gtk_css_provider_new ();
+	gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
 }
 
 static void
 gtr_close_button_init (GtrCloseButton *button)
 {
+	GtkStyleContext *context;
 	GtkWidget *image;
-	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);
@@ -51,23 +61,11 @@ gtr_close_button_init (GtrCloseButton *button)
 
 	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);
-	}
+	/* make it small */
+	context = gtk_widget_get_style_context (GTK_WIDGET (button));
+	gtk_style_context_add_provider (context,
+	                                GTK_STYLE_PROVIDER (GTR_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
+		                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
 GtkWidget *
diff --git a/src/gtr-close-button.h b/src/gtr-close-button.h
index 088ca66..f053b85 100644
--- a/src/gtr-close-button.h
+++ b/src/gtr-close-button.h
@@ -4,20 +4,19 @@
  *
  * Copyright (C) 2010 - Paolo Borelli
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * gtr is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * gtr is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, 
- * Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #ifndef __GTR_CLOSE_BUTTON_H__
@@ -35,22 +34,27 @@ G_BEGIN_DECLS
 #define GTR_IS_CLOSE_BUTTON_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GTR_TYPE_CLOSE_BUTTON))
 #define GTR_CLOSE_BUTTON_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), GTR_TYPE_CLOSE_BUTTON, GtrCloseButtonClass))
 
-typedef struct _GtrCloseButton	GtrCloseButton;
-typedef struct _GtrCloseButtonClass	GtrCloseButtonClass;
-typedef struct _GtrCloseButtonPrivate	GtrCloseButtonPrivate;
+typedef struct _GtrCloseButton		GtrCloseButton;
+typedef struct _GtrCloseButtonClass		GtrCloseButtonClass;
+typedef struct _GtrCloseButtonClassPrivate	GtrCloseButtonClassPrivate;
 
-struct _GtrCloseButton {
+struct _GtrCloseButton
+{
 	GtkButton parent;
 };
 
-struct _GtrCloseButtonClass {
+struct _GtrCloseButtonClass
+{
 	GtkButtonClass parent_class;
+
+	GtrCloseButtonClassPrivate *priv;
 };
 
 GType		  gtr_close_button_get_type (void) G_GNUC_CONST;
 
-GtkWidget	 *gtr_close_button_new (void);
+GtkWidget	 *gtr_close_button_new      (void);
 
 G_END_DECLS
 
 #endif /* __GTR_CLOSE_BUTTON_H__ */
+/* ex:set ts=8 noet: */



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