Use dist_doc_DATA for documentation text files
[anjuta.git] / libanjuta / anjuta-close-button.c
blobff8f7871bd738b263e894be7109c7794a2a30e5b
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 "-GtkButton-default-border : 0;\n"
38 "-GtkButton-default-outside-border : 0;\n"
39 "-GtkButton-inner-border: 0;\n"
40 "-GtkWidget-focus-line-width : 0;\n"
41 "-GtkWidget-focus-padding : 0;\n"
42 "padding: 0;\n"
43 "}";
45 klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, ANJUTA_TYPE_CLOSE_BUTTON, AnjutaCloseButtonClassPrivate);
47 klass->priv->css = gtk_css_provider_new ();
48 gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
51 static void
52 anjuta_close_button_init (AnjutaCloseButton *button)
54 GtkStyleContext *context;
55 GtkWidget *image;
56 GIcon *icon;
58 icon = g_themed_icon_new_with_default_fallbacks ("window-close-symbolic");
59 image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
60 gtk_widget_show (image);
61 g_object_unref (icon);
63 gtk_container_add (GTK_CONTAINER (button), image);
65 /* make it small */
66 context = gtk_widget_get_style_context (GTK_WIDGET (button));
67 gtk_style_context_add_provider (context,
68 GTK_STYLE_PROVIDER (ANJUTA_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
69 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
72 GtkWidget *
73 anjuta_close_button_new ()
75 return GTK_WIDGET (g_object_new (ANJUTA_TYPE_CLOSE_BUTTON,
76 "relief", GTK_RELIEF_NONE,
77 "focus-on-click", FALSE,
78 NULL));
81 /* ex:set ts=8 noet: */