Updated Spanish translation
[anjuta.git] / libanjuta / anjuta-close-button.c
blob3aa738b9effa7901580548702e2345cc18b940c7
1 /*
2 * anjuta-close-button.c
4 * Copyright (C) 2010 - Paolo Borelli
5 * Copyright (C) 2011 - Ignacio Casal Quinteiro
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "anjuta-close-button.h"
24 struct _AnjutaCloseButtonClassPrivate
26 GtkCssProvider *css;
29 G_DEFINE_TYPE_WITH_CODE (AnjutaCloseButton, anjuta_close_button, GTK_TYPE_BUTTON,
30 g_type_add_class_private (g_define_type_id, sizeof (AnjutaCloseButtonClassPrivate)))
32 static void
33 anjuta_close_button_class_init (AnjutaCloseButtonClass *klass)
35 static const gchar button_style[] =
36 "* {\n"
37 "padding: 0px;\n"
38 "}";
40 klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, ANJUTA_TYPE_CLOSE_BUTTON, AnjutaCloseButtonClassPrivate);
42 klass->priv->css = gtk_css_provider_new ();
43 gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
46 static void
47 anjuta_close_button_init (AnjutaCloseButton *button)
49 GtkStyleContext *context;
50 GtkWidget *image;
51 GIcon *icon;
53 icon = g_themed_icon_new_with_default_fallbacks ("window-close-symbolic");
54 image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
55 gtk_widget_show (image);
56 g_object_unref (icon);
58 gtk_container_add (GTK_CONTAINER (button), image);
60 /* make it small */
61 context = gtk_widget_get_style_context (GTK_WIDGET (button));
62 gtk_style_context_add_provider (context,
63 GTK_STYLE_PROVIDER (ANJUTA_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
64 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
67 GtkWidget *
68 anjuta_close_button_new ()
70 return GTK_WIDGET (g_object_new (ANJUTA_TYPE_CLOSE_BUTTON,
71 "relief", GTK_RELIEF_NONE,
72 "focus-on-click", FALSE,
73 NULL));
76 /* ex:set ts=8 noet: */