Updated Spanish translation
[empathy-mirror.git] / src / gedit-close-button.c
blob6a9021aeb352271f19ab970da6474554c2d44636
1 /*
2 * gedit-close-button.c
3 * This file is part of gedit
5 * Copyright (C) 2010 - Paolo Borelli
6 * Copyright (C) 2011 - Ignacio Casal Quinteiro
8 * gedit is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * gedit is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "gedit-close-button.h"
25 struct _GeditCloseButtonClassPrivate
27 GtkCssProvider *css;
30 G_DEFINE_TYPE_WITH_CODE (GeditCloseButton, gedit_close_button, GTK_TYPE_BUTTON,
31 g_type_add_class_private (g_define_type_id, sizeof (GeditCloseButtonClassPrivate)))
33 static void
34 gedit_close_button_class_init (GeditCloseButtonClass *klass)
36 static const gchar button_style[] =
37 "* {\n"
38 "-GtkButton-default-border : 0;\n"
39 "-GtkButton-default-outside-border : 0;\n"
40 "-GtkButton-inner-border: 0;\n"
41 "-GtkWidget-focus-line-width : 0;\n"
42 "-GtkWidget-focus-padding : 0;\n"
43 "padding: 0;\n"
44 "}";
46 klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClassPrivate);
48 klass->priv->css = gtk_css_provider_new ();
49 gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
52 static void
53 gedit_close_button_init (GeditCloseButton *button)
55 GtkStyleContext *context;
56 GtkWidget *image;
58 image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
59 GTK_ICON_SIZE_MENU);
60 gtk_widget_show (image);
62 gtk_container_add (GTK_CONTAINER (button), image);
64 /* make it small */
65 context = gtk_widget_get_style_context (GTK_WIDGET (button));
66 gtk_style_context_add_provider (context,
67 GTK_STYLE_PROVIDER (GEDIT_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
68 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
71 GtkWidget *
72 gedit_close_button_new ()
74 return GTK_WIDGET (g_object_new (GEDIT_TYPE_CLOSE_BUTTON,
75 "relief", GTK_RELIEF_NONE,
76 "focus-on-click", FALSE,
77 NULL));
80 /* ex:set ts=8 noet: */