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=2bff4b6master-1.22
parent
c6fba6db82
commit
f15b90f66b
|
@ -23,6 +23,8 @@ mate_terminal_SOURCES= \
|
||||||
terminal-accels.h \
|
terminal-accels.h \
|
||||||
terminal-app.c \
|
terminal-app.c \
|
||||||
terminal-app.h \
|
terminal-app.h \
|
||||||
|
terminal-close-button.h \
|
||||||
|
terminal-close-button.c \
|
||||||
terminal-debug.c \
|
terminal-debug.c \
|
||||||
terminal-debug.h \
|
terminal-debug.h \
|
||||||
terminal-encoding.c \
|
terminal-encoding.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));
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* terminal-close-button.h
|
||||||
|
*
|
||||||
|
* Copyright © 2010 - Paolo Borelli
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TERMINAL_CLOSE_BUTTON_H__
|
||||||
|
#define __TERMINAL_CLOSE_BUTTON_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define TERMINAL_TYPE_CLOSE_BUTTON (terminal_close_button_get_type ())
|
||||||
|
#define TERMINAL_CLOSE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_CLOSE_BUTTON, TerminalCloseButton))
|
||||||
|
#define TERMINAL_CLOSE_BUTTON_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_CLOSE_BUTTON, TerminalCloseButton const))
|
||||||
|
#define TERMINAL_CLOSE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_CLOSE_BUTTON, TerminalCloseButtonClass))
|
||||||
|
#define TERMINAL_IS_CLOSE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_CLOSE_BUTTON))
|
||||||
|
#define TERMINAL_IS_CLOSE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_CLOSE_BUTTON))
|
||||||
|
#define TERMINAL_CLOSE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_CLOSE_BUTTON, TerminalCloseButtonClass))
|
||||||
|
|
||||||
|
typedef struct _TerminalCloseButton TerminalCloseButton;
|
||||||
|
typedef struct _TerminalCloseButtonPrivate TerminalCloseButtonPrivate;
|
||||||
|
typedef struct _TerminalCloseButtonClass TerminalCloseButtonClass;
|
||||||
|
typedef struct _TerminalCloseButtonClassPrivate TerminalCloseButtonClassPrivate;
|
||||||
|
|
||||||
|
struct _TerminalCloseButton
|
||||||
|
{
|
||||||
|
GtkButton parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _TerminalCloseButtonClass
|
||||||
|
{
|
||||||
|
GtkButtonClass parent_class;
|
||||||
|
|
||||||
|
TerminalCloseButtonClassPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType terminal_close_button_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GtkWidget *terminal_close_button_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __TERMINAL_CLOSE_BUTTON_H__ */
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "terminal-intl.h"
|
#include "terminal-intl.h"
|
||||||
#include "terminal-tab-label.h"
|
#include "terminal-tab-label.h"
|
||||||
|
#include "terminal-close-button.h"
|
||||||
|
|
||||||
#define TERMINAL_TAB_LABEL_GET_PRIVATE(tab_label)(G_TYPE_INSTANCE_GET_PRIVATE ((tab_label), TERMINAL_TYPE_TAB_LABEL, TerminalTabLabelPrivate))
|
#define TERMINAL_TAB_LABEL_GET_PRIVATE(tab_label)(G_TYPE_INSTANCE_GET_PRIVATE ((tab_label), TERMINAL_TYPE_TAB_LABEL, TerminalTabLabelPrivate))
|
||||||
|
|
||||||
|
@ -91,22 +92,6 @@ terminal_tab_label_parent_set (GtkWidget *widget,
|
||||||
parent_set (widget, old_parent);
|
parent_set (widget, old_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
terminal_tab_label_style_set (GtkWidget *widget,
|
|
||||||
GtkStyle *previous_style)
|
|
||||||
{
|
|
||||||
TerminalTabLabel *tab_label = TERMINAL_TAB_LABEL (widget);
|
|
||||||
TerminalTabLabelPrivate *priv = tab_label->priv;
|
|
||||||
void (* style_set) (GtkWidget *, GtkStyle *) = GTK_WIDGET_CLASS (terminal_tab_label_parent_class)->style_set;
|
|
||||||
int h, w;
|
|
||||||
|
|
||||||
if (style_set)
|
|
||||||
style_set (widget, previous_style);
|
|
||||||
|
|
||||||
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
|
|
||||||
gtk_widget_set_size_request (priv->close_button, w + 2, h + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
terminal_tab_label_init (TerminalTabLabel *tab_label)
|
terminal_tab_label_init (TerminalTabLabel *tab_label)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +106,7 @@ terminal_tab_label_constructor (GType type,
|
||||||
GObject *object;
|
GObject *object;
|
||||||
TerminalTabLabel *tab_label;
|
TerminalTabLabel *tab_label;
|
||||||
TerminalTabLabelPrivate *priv;
|
TerminalTabLabelPrivate *priv;
|
||||||
GtkWidget *hbox, *label, *close_button, *image;
|
GtkWidget *hbox, *label, *close_button;
|
||||||
|
|
||||||
object = G_OBJECT_CLASS (terminal_tab_label_parent_class)->constructor
|
object = G_OBJECT_CLASS (terminal_tab_label_parent_class)->constructor
|
||||||
(type, n_construct_properties, construct_params);
|
(type, n_construct_properties, construct_params);
|
||||||
|
@ -148,15 +133,9 @@ terminal_tab_label_constructor (GType type,
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||||
|
|
||||||
priv->close_button = close_button = gtk_button_new ();
|
priv->close_button = close_button = terminal_close_button_new ();
|
||||||
gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
|
|
||||||
gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
|
|
||||||
gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
|
|
||||||
gtk_widget_set_name (close_button, "mate-terminal-tab-close-button");
|
|
||||||
gtk_widget_set_tooltip_text (close_button, _("Close tab"));
|
gtk_widget_set_tooltip_text (close_button, _("Close tab"));
|
||||||
|
|
||||||
image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU);
|
|
||||||
gtk_container_add (GTK_CONTAINER (close_button), image);
|
|
||||||
gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
|
gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
sync_tab_label (priv->screen, NULL, label);
|
sync_tab_label (priv->screen, NULL, label);
|
||||||
|
@ -210,7 +189,6 @@ terminal_tab_label_class_init (TerminalTabLabelClass *klass)
|
||||||
gobject_class->set_property = terminal_tab_label_set_property;
|
gobject_class->set_property = terminal_tab_label_set_property;
|
||||||
|
|
||||||
widget_class->parent_set = terminal_tab_label_parent_set;
|
widget_class->parent_set = terminal_tab_label_parent_set;
|
||||||
widget_class->style_set = terminal_tab_label_style_set;
|
|
||||||
|
|
||||||
signals[CLOSE_BUTTON_CLICKED] =
|
signals[CLOSE_BUTTON_CLICKED] =
|
||||||
g_signal_new (I_("close-button-clicked"),
|
g_signal_new (I_("close-button-clicked"),
|
||||||
|
|
|
@ -2131,16 +2131,6 @@ terminal_window_class_init (TerminalWindowClass *klass)
|
||||||
widget_class->screen_changed = terminal_window_screen_changed;
|
widget_class->screen_changed = terminal_window_screen_changed;
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (TerminalWindowPrivate));
|
g_type_class_add_private (object_class, sizeof (TerminalWindowPrivate));
|
||||||
|
|
||||||
gtk_rc_parse_string ("style \"mate-terminal-tab-close-button-style\"\n"
|
|
||||||
"{\n"
|
|
||||||
"GtkWidget::focus-padding = 0\n"
|
|
||||||
"GtkWidget::focus-line-width = 0\n"
|
|
||||||
"xthickness = 0\n"
|
|
||||||
"ythickness = 0\n"
|
|
||||||
"}\n"
|
|
||||||
"widget \"*.mate-terminal-tab-close-button\" style \"mate-terminal-tab-close-button-style\"");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue