diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-02-21 22:54:46 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-02-21 22:54:51 +0800 |
commit | 6b33a26fa16179fce84a6243ede3f2d226ce4718 (patch) | |
tree | 853c3a2e2e05b044fe993f66e3007fe6687c04e4 /src/gedit-close-button.c | |
parent | 7490e07615a360c73cf204f6023298785eefe183 (diff) | |
download | gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.tar gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.tar.gz gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.tar.bz2 gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.tar.lz gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.tar.xz gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.tar.zst gsoc2013-empathy-6b33a26fa16179fce84a6243ede3f2d226ce4718.zip |
add gedit-close-button
This file is a bare copy from gedit.
Diffstat (limited to 'src/gedit-close-button.c')
-rw-r--r-- | src/gedit-close-button.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/gedit-close-button.c b/src/gedit-close-button.c new file mode 100644 index 000000000..6a9021aeb --- /dev/null +++ b/src/gedit-close-button.c @@ -0,0 +1,80 @@ +/* + * gedit-close-button.c + * This file is part of gedit + * + * Copyright (C) 2010 - Paolo Borelli + * Copyright (C) 2011 - Ignacio Casal Quinteiro + * + * gedit 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. + * + * gedit 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 + * Lesser General Public License for more details. + * + * 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 "gedit-close-button.h" + +struct _GeditCloseButtonClassPrivate +{ + GtkCssProvider *css; +}; + +G_DEFINE_TYPE_WITH_CODE (GeditCloseButton, gedit_close_button, GTK_TYPE_BUTTON, + g_type_add_class_private (g_define_type_id, sizeof (GeditCloseButtonClassPrivate))) + +static void +gedit_close_button_class_init (GeditCloseButtonClass *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, GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClassPrivate); + + klass->priv->css = gtk_css_provider_new (); + gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL); +} + +static void +gedit_close_button_init (GeditCloseButton *button) +{ + GtkStyleContext *context; + GtkWidget *image; + + image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, + GTK_ICON_SIZE_MENU); + gtk_widget_show (image); + + gtk_container_add (GTK_CONTAINER (button), image); + + /* make it small */ + context = gtk_widget_get_style_context (GTK_WIDGET (button)); + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (GEDIT_CLOSE_BUTTON_GET_CLASS (button)->priv->css), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +} + +GtkWidget * +gedit_close_button_new () +{ + return GTK_WIDGET (g_object_new (GEDIT_TYPE_CLOSE_BUTTON, + "relief", GTK_RELIEF_NONE, + "focus-on-click", FALSE, + NULL)); +} + +/* ex:set ts=8 noet: */ |