summaryrefslogtreecommitdiff
path: root/pluma/pluma-close-button.c
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-07 19:52:18 -0300
committerPerberos <[email protected]>2011-11-07 19:52:18 -0300
commit5ded9cba8563f336939400303d6a841d5089b107 (patch)
treec5676588cff26ba37e12369fe4de24b54e9f6682 /pluma/pluma-close-button.c
parentf00b3a11a199f9f85a4d46a600f9d14179b37dbf (diff)
downloadpluma-5ded9cba8563f336939400303d6a841d5089b107.tar.bz2
pluma-5ded9cba8563f336939400303d6a841d5089b107.tar.xz
renaming from gedit to pluma
Diffstat (limited to 'pluma/pluma-close-button.c')
-rwxr-xr-xpluma/pluma-close-button.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/pluma/pluma-close-button.c b/pluma/pluma-close-button.c
new file mode 100755
index 00000000..0213d4d1
--- /dev/null
+++ b/pluma/pluma-close-button.c
@@ -0,0 +1,80 @@
+/*
+ * pluma-close-button.c
+ * This file is part of pluma
+ *
+ * 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.
+ *
+ * This program 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.
+ *
+ * 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.
+ */
+
+#include "pluma-close-button.h"
+
+G_DEFINE_TYPE (PlumaCloseButton, pluma_close_button, GTK_TYPE_BUTTON)
+
+static void
+pluma_close_button_style_set (GtkWidget *button,
+ GtkStyle *previous_style)
+{
+ gint h, w;
+
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (button),
+ GTK_ICON_SIZE_MENU, &w, &h);
+
+ gtk_widget_set_size_request (button, w + 2, h + 2);
+
+ GTK_WIDGET_CLASS (pluma_close_button_parent_class)->style_set (button, previous_style);
+}
+
+static void
+pluma_close_button_class_init (PlumaCloseButtonClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->style_set = pluma_close_button_style_set;
+}
+
+static void
+pluma_close_button_init (PlumaCloseButton *button)
+{
+ GtkRcStyle *rcstyle;
+ GtkWidget *image;
+
+ /* make it as small as possible */
+ rcstyle = gtk_rc_style_new ();
+ rcstyle->xthickness = rcstyle->ythickness = 0;
+ gtk_widget_modify_style (GTK_WIDGET (button), rcstyle);
+ g_object_unref (rcstyle);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image);
+
+ gtk_container_add (GTK_CONTAINER (button), image);
+}
+
+GtkWidget *
+pluma_close_button_new ()
+{
+ PlumaCloseButton *button;
+
+ button = g_object_new (PLUMA_TYPE_CLOSE_BUTTON,
+ "relief", GTK_RELIEF_NONE,
+ "focus-on-click", FALSE,
+ NULL);
+
+ return GTK_WIDGET (button);
+}
+