[gedit] status-menu-button: use G_DECLARE macros
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] status-menu-button: use G_DECLARE macros
- Date: Mon, 20 Apr 2015 20:49:53 +0000 (UTC)
commit a17c5e7593c74428ea19513986f2838cae2080a1
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Apr 20 22:49:07 2015 +0200
status-menu-button: use G_DECLARE macros
gedit/gedit-status-menu-button.c | 39 +++++++++++++++++++++----------------
gedit/gedit-status-menu-button.h | 29 +--------------------------
2 files changed, 24 insertions(+), 44 deletions(-)
---
diff --git a/gedit/gedit-status-menu-button.c b/gedit/gedit-status-menu-button.c
index 8b58743..f48a960 100644
--- a/gedit/gedit-status-menu-button.c
+++ b/gedit/gedit-status-menu-button.c
@@ -20,15 +20,17 @@
#include "gedit-status-menu-button.h"
-struct _GeditStatusMenuButtonPrivate
+struct _GeditStatusMenuButton
{
+ GtkMenuButton parent_instance;
+
GtkWidget *label;
};
-struct _GeditStatusMenuButtonClassPrivate
+typedef struct
{
GtkCssProvider *css;
-};
+} GeditStatusMenuButtonClassPrivate;
/* Properties */
enum
@@ -40,7 +42,6 @@ enum
G_DEFINE_TYPE_WITH_CODE (GeditStatusMenuButton,
gedit_status_menu_button,
GTK_TYPE_MENU_BUTTON,
- G_ADD_PRIVATE (GeditStatusMenuButton)
g_type_add_class_private (g_define_type_id, sizeof
(GeditStatusMenuButtonClassPrivate)))
static void
@@ -84,8 +85,6 @@ gedit_status_menu_button_set_property (GObject *object,
static void
gedit_status_menu_button_class_init (GeditStatusMenuButtonClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
static const gchar style[] =
"* {\n"
"-GtkButton-default-border : 0;\n"
@@ -96,6 +95,10 @@ gedit_status_menu_button_class_init (GeditStatusMenuButtonClass *klass)
"padding: 1px 8px 2px 4px;\n"
"}";
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GeditStatusMenuButtonClassPrivate *class_priv;
+
object_class->get_property = gedit_status_menu_button_get_property;
object_class->set_property = gedit_status_menu_button_set_property;
@@ -104,27 +107,29 @@ gedit_status_menu_button_class_init (GeditStatusMenuButtonClass *klass)
/* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/gedit/ui/gedit-status-menu-button.ui");
- gtk_widget_class_bind_template_child_internal_private (widget_class, GeditStatusMenuButton, label);
+ gtk_widget_class_bind_template_child_internal (widget_class, GeditStatusMenuButton, label);
- klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_STATUS_MENU_BUTTON,
GeditStatusMenuButtonClassPrivate);
-
- klass->priv->css = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (klass->priv->css, style, -1, NULL);
+ /* Store the CSS provider in the class private data so it is shared among all instances */
+ class_priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_STATUS_MENU_BUTTON,
GeditStatusMenuButtonClassPrivate);
+ class_priv->css = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (class_priv->css, style, -1, NULL);
}
static void
gedit_status_menu_button_init (GeditStatusMenuButton *self)
{
GtkStyleContext *context;
-
- self->priv = gedit_status_menu_button_get_instance_private (self);
+ GeditStatusMenuButtonClassPrivate *class_priv;
gtk_widget_init_template (GTK_WIDGET (self));
/* make it as small as possible */
context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ class_priv = G_TYPE_CLASS_GET_PRIVATE (G_TYPE_INSTANCE_GET_CLASS (self,
GEDIT_TYPE_STATUS_MENU_BUTTON, GeditStatusMenuButtonClass),
+ GEDIT_TYPE_STATUS_MENU_BUTTON,
+ GeditStatusMenuButtonClassPrivate);
gtk_style_context_add_provider (context,
- GTK_STYLE_PROVIDER (GEDIT_STATUS_MENU_BUTTON_GET_CLASS
(self)->priv->css),
+ GTK_STYLE_PROVIDER (class_priv->css),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
@@ -143,15 +148,15 @@ gedit_status_menu_button_new (void)
void
gedit_status_menu_button_set_label (GeditStatusMenuButton *button,
- const gchar *label)
+ const gchar *label)
{
- gtk_label_set_markup (GTK_LABEL (button->priv->label), label);
+ gtk_label_set_markup (GTK_LABEL (button->label), label);
}
const gchar *
gedit_status_menu_button_get_label (GeditStatusMenuButton *button)
{
- return gtk_label_get_label (GTK_LABEL (button->priv->label));
+ return gtk_label_get_label (GTK_LABEL (button->label));
}
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-status-menu-button.h b/gedit/gedit-status-menu-button.h
index 5c1a20c..cde6961 100644
--- a/gedit/gedit-status-menu-button.h
+++ b/gedit/gedit-status-menu-button.h
@@ -25,34 +25,9 @@
G_BEGIN_DECLS
-#define GEDIT_TYPE_STATUS_MENU_BUTTON (gedit_status_menu_button_get_type ())
-#define GEDIT_STATUS_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GEDIT_TYPE_STATUS_MENU_BUTTON, GeditStatusMenuButton))
-#define GEDIT_STATUS_MENU_BUTTON_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GEDIT_TYPE_STATUS_MENU_BUTTON, GeditStatusMenuButton const))
-#define GEDIT_STATUS_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GEDIT_TYPE_STATUS_MENU_BUTTON, GeditStatusMenuButtonClass))
-#define GEDIT_IS_STATUS_MENU_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GEDIT_TYPE_STATUS_MENU_BUTTON))
-#define GEDIT_IS_STATUS_MENU_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GEDIT_TYPE_STATUS_MENU_BUTTON))
-#define GEDIT_STATUS_MENU_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GEDIT_TYPE_STATUS_MENU_BUTTON, GeditStatusMenuButtonClass))
+#define GEDIT_TYPE_STATUS_MENU_BUTTON (gedit_status_menu_button_get_type ())
-typedef struct _GeditStatusMenuButton GeditStatusMenuButton;
-typedef struct _GeditStatusMenuButtonPrivate GeditStatusMenuButtonPrivate;
-typedef struct _GeditStatusMenuButtonClass GeditStatusMenuButtonClass;
-typedef struct _GeditStatusMenuButtonClassPrivate GeditStatusMenuButtonClassPrivate;
-
-struct _GeditStatusMenuButton
-{
- GtkMenuButton parent;
-
- GeditStatusMenuButtonPrivate *priv;
-};
-
-struct _GeditStatusMenuButtonClass
-{
- GtkMenuButtonClass parent_class;
-
- GeditStatusMenuButtonClassPrivate *priv;
-};
-
-GType gedit_status_menu_button_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (GeditStatusMenuButton, gedit_status_menu_button, GEDIT, STATUS_MENU_BUTTON,
GtkMenuButton)
GtkWidget *gedit_status_menu_button_new (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]