diff options
author | raveit65 <[email protected]> | 2016-06-11 18:03:09 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-06-11 21:09:24 +0200 |
commit | f15b90f66bdc562b62837d1389e92608439f6b30 (patch) | |
tree | 22f72e152ee8d62f076d81815552f962f028a4c9 /src/terminal-close-button.c | |
parent | c6fba6db82e8f427bb573f36578b99f12d6968f9 (diff) | |
download | mate-terminal-f15b90f66bdc562b62837d1389e92608439f6b30.tar.bz2 mate-terminal-f15b90f66bdc562b62837d1389e92608439f6b30.tar.xz |
Borrow pluma-close-button class and use it.
This is a subclass of GtkButton special theming for the close button.
taken from:
https://git.gnome.org/browse/gnome-terminal/commit/src?h=gnome-3-8&id=c3a3e06
https://git.gnome.org/browse/gnome-terminal/diff/src/terminal-close-button.c?h=gnome-3-8&id=2bff4b6
Diffstat (limited to 'src/terminal-close-button.c')
-rw-r--r-- | src/terminal-close-button.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/terminal-close-button.c b/src/terminal-close-button.c new file mode 100644 index 0000000..8a1f777 --- /dev/null +++ b/src/terminal-close-button.c @@ -0,0 +1,74 @@ +/* + * terminal-close-button.c + * + * Copyright © 2010 - Paolo Borelli + * Copyright © 2011 - Ignacio Casal Quinteiro + * Copyright © 2016 - Wolfgang Ulbrich + * + * Mate-terminal 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 3 of the License, or + * (at your option) any later version. + * + * Mate-terminal 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, see <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include "terminal-close-button.h" + +struct _TerminalCloseButtonClassPrivate { + GtkCssProvider *css; +}; + +G_DEFINE_TYPE_WITH_CODE (TerminalCloseButton, terminal_close_button, GTK_TYPE_BUTTON, + g_type_add_class_private (g_define_type_id, sizeof (TerminalCloseButtonClassPrivate))) + +static void +terminal_close_button_class_init (TerminalCloseButtonClass *klass) +{ + static const gchar button_style[] = + "* {\n" + "padding: 0;\n" + "}"; + + klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, TERMINAL_TYPE_CLOSE_BUTTON, TerminalCloseButtonClassPrivate); + + klass->priv->css = gtk_css_provider_new (); + gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL); +} + +static void +terminal_close_button_init (TerminalCloseButton *button) +{ + GtkWidget *image; + GtkStyleContext *context; + + gtk_widget_set_name (GTK_WIDGET (button), "mate-terminal-tab-close-button"); + + image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU); + gtk_widget_show (image); + + gtk_container_add (GTK_CONTAINER (button), image); + + context = gtk_widget_get_style_context (GTK_WIDGET (button)); + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (TERMINAL_CLOSE_BUTTON_GET_CLASS (button)->priv->css), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +} + +GtkWidget * +terminal_close_button_new () +{ + return GTK_WIDGET (g_object_new (TERMINAL_TYPE_CLOSE_BUTTON, + "relief", GTK_RELIEF_NONE, + "focus-on-click", FALSE, + NULL)); +} + |