Commit 44d9bd95 authored by Paolo Borelli's avatar Paolo Borelli

Remove custom small button class

We should now simply add the "small-button" css class and let adwaita do
its magic
parent 1398794a
......@@ -127,7 +127,6 @@ gedit_NOINST_H_FILES = \
gedit/gedit-recent.h \
gedit/gedit-replace-dialog.h \
gedit/gedit-settings.h \
gedit/gedit-small-button.h \
gedit/gedit-status-menu-button.h \
gedit/gedit-tab-label.h \
gedit/gedit-tab-private.h \
......@@ -202,7 +201,6 @@ gedit_libgedit_c_files = \
gedit/gedit-replace-dialog.c \
gedit/gedit-resources.c \
gedit/gedit-settings.c \
gedit/gedit-small-button.c \
gedit/gedit-statusbar.c \
gedit/gedit-status-menu-button.c \
gedit/gedit-tab.c \
......
......@@ -31,7 +31,6 @@
#include "gedit-multi-notebook.h"
#include "gedit-notebook.h"
#include "gedit-notebook-popup-menu.h"
#include "gedit-small-button.h"
#include "gedit-tab.h"
#include "gedit-tab-private.h"
#include "gedit-utils.h"
......@@ -1582,6 +1581,8 @@ row_create (GtkWidget *row)
{
GeditDocumentsGenericRow *generic_row = (GeditDocumentsGenericRow *)row;
GtkWidget *event_box;
GtkWidget *image;
GIcon *icon;
gedit_debug (DEBUG_PANEL);
......@@ -1599,7 +1600,17 @@ row_create (GtkWidget *row)
gtk_widget_set_halign (generic_row->status_label, GTK_ALIGN_END);
gtk_widget_set_valign (generic_row->status_label, GTK_ALIGN_CENTER);
generic_row->close_button = gedit_close_button_new ();
generic_row->close_button = GTK_WIDGET (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);
gtk_widget_show (image);
g_object_unref (icon);
gtk_container_add (GTK_CONTAINER (generic_row->close_button), image);
gtk_box_pack_start (GTK_BOX (generic_row->box),
generic_row->label, FALSE, FALSE, 0);
......
/*
* gedit-small-button.c
* This file is part of gedit
*
* Copyright (C) 2010 - Paolo Borelli
* Copyright (C) 2011 - Ignacio Casal Quinteiro
*
* gedit is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* gedit 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "gedit-small-button.h"
struct _GeditSmallButtonClassPrivate
{
GtkCssProvider *css;
};
G_DEFINE_TYPE_WITH_CODE (GeditSmallButton, gedit_small_button, GTK_TYPE_BUTTON,
g_type_add_class_private (g_define_type_id, sizeof (GeditSmallButtonClassPrivate)))
static void
gedit_small_button_class_init (GeditSmallButtonClass *klass)
{
static const gchar button_style[] =
"* {\n"
"padding: 0;\n"
"border: 0;\n"
"outline-width: 0;\n"
"}";
klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_SMALL_BUTTON, GeditSmallButtonClassPrivate);
klass->priv->css = gtk_css_provider_new ();
gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
}
static void
gedit_small_button_init (GeditSmallButton *button)
{
GtkStyleContext *context;
/* make it small */
context = gtk_widget_get_style_context (GTK_WIDGET (button));
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (GEDIT_SMALL_BUTTON_GET_CLASS (button)->priv->css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
GtkWidget *
gedit_small_button_new ()
{
return GTK_WIDGET (g_object_new (GEDIT_TYPE_SMALL_BUTTON,
"relief", GTK_RELIEF_NONE,
"focus-on-click", FALSE,
NULL));
}
struct _GeditCloseButtonClassPrivate
{
GtkCssProvider *css;
};
G_DEFINE_TYPE_WITH_CODE (GeditCloseButton, gedit_close_button, GEDIT_TYPE_SMALL_BUTTON,
g_type_add_class_private (g_define_type_id, sizeof (GeditCloseButtonClassPrivate)))
static void
gedit_close_button_class_init (GeditCloseButtonClass *klass)
{
static const gchar button_style[] =
"* {\n"
"padding : 0;\n"
"}";
klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClassPrivate);
klass->priv->css = gtk_css_provider_new ();
gtk_css_provider_load_from_data (klass->priv->css, button_style, -1, NULL);
}
static void
gedit_close_button_init (GeditCloseButton *button)
{
GtkStyleContext *context;
GtkWidget *image;
GIcon *icon;
icon = g_themed_icon_new_with_default_fallbacks ("window-close-symbolic");
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
g_object_unref (icon);
gtk_container_add (GTK_CONTAINER (button), image);
/* remove padding */
context = gtk_widget_get_style_context (GTK_WIDGET (button));
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (GEDIT_CLOSE_BUTTON_GET_CLASS (button)->priv->css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
GtkWidget *
gedit_close_button_new ()
{
return GTK_WIDGET (g_object_new (GEDIT_TYPE_CLOSE_BUTTON,
"relief", GTK_RELIEF_NONE,
"focus-on-click", FALSE,
NULL));
}
/* ex:set ts=8 noet: */
/*
* gedit-small-button.h
* This file is part of gedit
*
* Copyright (C) 2010 - Paolo Borelli
*
* gedit is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* gedit 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __GEDIT_SMALL_BUTTON_H__
#define __GEDIT_SMALL_BUTTON_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GEDIT_TYPE_SMALL_BUTTON (gedit_small_button_get_type ())
#define GEDIT_SMALL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_SMALL_BUTTON, GeditSmallButton))
#define GEDIT_SMALL_BUTTON_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_SMALL_BUTTON, GeditSmallButton const))
#define GEDIT_SMALL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_SMALL_BUTTON, GeditSmallButtonClass))
#define GEDIT_IS_SMALL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_SMALL_BUTTON))
#define GEDIT_IS_SMALL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_SMALL_BUTTON))
#define GEDIT_SMALL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_SMALL_BUTTON, GeditSmallButtonClass))
typedef struct _GeditSmallButton GeditSmallButton;
typedef struct _GeditSmallButtonClass GeditSmallButtonClass;
typedef struct _GeditSmallButtonClassPrivate GeditSmallButtonClassPrivate;
struct _GeditSmallButton
{
GtkButton parent;
};
struct _GeditSmallButtonClass
{
GtkButtonClass parent_class;
GeditSmallButtonClassPrivate *priv;
};
#define GEDIT_TYPE_CLOSE_BUTTON (gedit_close_button_get_type ())
#define GEDIT_CLOSE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButton))
#define GEDIT_CLOSE_BUTTON_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButton const))
#define GEDIT_CLOSE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClass))
#define GEDIT_IS_CLOSE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_CLOSE_BUTTON))
#define GEDIT_IS_CLOSE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_CLOSE_BUTTON))
#define GEDIT_CLOSE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_CLOSE_BUTTON, GeditCloseButtonClass))
typedef struct _GeditCloseButton GeditCloseButton;
typedef struct _GeditCloseButtonClass GeditCloseButtonClass;
typedef struct _GeditCloseButtonClassPrivate GeditCloseButtonClassPrivate;
struct _GeditCloseButton
{
GeditSmallButton parent;
};
struct _GeditCloseButtonClass
{
GeditSmallButtonClass parent_class;
GeditCloseButtonClassPrivate *priv;
};
GType gedit_small_button_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_small_button_new (void);
GType gedit_close_button_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_close_button_new (void);
G_END_DECLS
#endif /* __GEDIT_SMALL_BUTTON_H__ */
/* ex:set ts=8 noet: */
......@@ -56,7 +56,6 @@
#include "gedit-dirs.h"
#include "gedit-status-menu-button.h"
#include "gedit-settings.h"
#include "gedit-small-button.h"
#include "gedit-menu-stack-switcher.h"
#include "gedit-highlight-mode-selector.h"
#include "gedit-open-document-selector.h"
......
......@@ -27,13 +27,24 @@
</packing>
</child>
<child>
<object class="GeditCloseButton" id="close_button">
<object class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="relief">none</property>
<property name="focus-on-click">False</property>
<property name="tooltip_text" translatable="yes">Close Document</property>
<property name="image">close_button_image</property>
<style>
<class name="small-button"/>
<class name="flat"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</template>
<object class="GtkImage" id="close_button_image">
<property name="visible">True</property>
<property name="icon_name">window-close-symbolic</property>
</object>
</interface>
......@@ -247,11 +247,17 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GeditCloseButton" id="bottom_panel_close_button">
<object class="GtkButton" id="bottom_panel_close_button">
<property name="visible">True</property>
<property name="relief">none</property>
<property name="focus-on-click">False</property>
<property name="tooltip-text" translatable="yes">Hide panel</property>
<property name="action_name">win.bottom-panel</property>
<property name="image">close_button_image</property>
<style>
<class name="small-button"/>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......@@ -492,6 +498,10 @@
<property name="visible">True</property>
<property name="icon_name">view-restore-symbolic</property>
</object>
<object class="GtkImage" id="close_button_image">
<property name="visible">True</property>
<property name="icon_name">window-close-symbolic</property>
</object>
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widgets>
......
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