widgets: Remove close button CSS

It works without this extra CSS (in adwaita at least).
parent f436efd4
......@@ -36,8 +36,6 @@ gnome_terminal_server_SOURCES = \
terminal-accels.h \
terminal-app.c \
terminal-app.h \
terminal-close-button.h \
terminal-close-button.c \
terminal-debug.c \
terminal-debug.h \
terminal-defines.h \
......@@ -46,6 +44,8 @@ gnome_terminal_server_SOURCES = \
terminal-encoding.h \
terminal-gdbus.c \
terminal-gdbus.h \
terminal-icon-button.h \
terminal-icon-button.c \
terminal-info-bar.c \
terminal-info-bar.h \
terminal-intl.h \
......
/*
* terminal-close-button.c
* terminal-icon-button.c
*
* Copyright © 2010 - Paolo Borelli
* Copyright © 2011 - Ignacio Casal Quinteiro
......@@ -18,63 +18,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "config.h"
#include "terminal-close-button.h"
#include "terminal-icon-button.h"
#include "terminal-libgsystem.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)
GtkWidget *
terminal_icon_button_new (const char *gicon_name)
{
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, TERMINAL_TYPE_CLOSE_BUTTON, TerminalCloseButtonClassPrivate);
GtkWidget *button, *image;
gs_unref_object GIcon *icon;
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;
gs_unref_object GIcon *icon;
button = (GtkWidget *) g_object_new (GTK_TYPE_BUTTON,
"relief", GTK_RELIEF_NONE,
"focus-on-click", FALSE,
NULL);
icon = g_themed_icon_new_with_default_fallbacks ("window-close-symbolic");
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
icon = g_themed_icon_new_with_default_fallbacks (gicon_name);
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (button), image);
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);
return button;
}
GtkWidget *
terminal_close_button_new (void)
{
return GTK_WIDGET (g_object_new (TERMINAL_TYPE_CLOSE_BUTTON,
"relief", GTK_RELIEF_NONE,
"focus-on-click", FALSE,
NULL));
return terminal_icon_button_new ("window-close-symbolic");
}
/* ex:set ts=8 noet: */
......@@ -17,43 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TERMINAL_CLOSE_BUTTON_H__
#define __TERMINAL_CLOSE_BUTTON_H__
#ifndef __TERMINAL_ICON_BUTTON_H__
#define __TERMINAL_ICON_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))
GtkWidget *terminal_icon_button_new (const char *gicon_name);
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);
GtkWidget *terminal_close_button_new (void);
G_END_DECLS
#endif /* __TERMINAL_CLOSE_BUTTON_H__ */
/* ex:set ts=8 noet: */
#endif /* __TERMINAL_ICON_BUTTON_H__ */
......@@ -24,7 +24,7 @@
#include "terminal-intl.h"
#include "terminal-tab-label.h"
#include "terminal-close-button.h"
#include "terminal-icon-button.h"
#include "terminal-window.h"
#define TERMINAL_TAB_LABEL_GET_PRIVATE(tab_label)(G_TYPE_INSTANCE_GET_PRIVATE ((tab_label), TERMINAL_TYPE_TAB_LABEL, TerminalTabLabelPrivate))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment