2011-11-07 13:46:58 -06:00
|
|
|
/*
|
2011-11-07 16:52:18 -06:00
|
|
|
* pluma-close-button.c
|
|
|
|
* This file is part of pluma
|
2011-11-07 13:46:58 -06:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-18 19:54:49 -06:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-11-07 13:46:58 -06:00
|
|
|
*/
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
#include "pluma-close-button.h"
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
G_DEFINE_TYPE (PlumaCloseButton, pluma_close_button, GTK_TYPE_BUTTON)
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
static void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_close_button_style_set (GtkWidget *button,
|
2011-11-07 13:46:58 -06:00
|
|
|
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);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
GTK_WIDGET_CLASS (pluma_close_button_parent_class)->style_set (button, previous_style);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_close_button_class_init (PlumaCloseButtonClass *klass)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
widget_class->style_set = pluma_close_button_style_set;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_close_button_init (PlumaCloseButton *button)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
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 *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_close_button_new ()
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
PlumaCloseButton *button;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
button = g_object_new (PLUMA_TYPE_CLOSE_BUTTON,
|
2011-11-07 13:46:58 -06:00
|
|
|
"relief", GTK_RELIEF_NONE,
|
|
|
|
"focus-on-click", FALSE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return GTK_WIDGET (button);
|
|
|
|
}
|
|
|
|
|