[glade/tintou/more-g-declare: 9/21] gladeui: Use G_DECLARE_DERIVABLE_TYPE for GladeCellRendererIcon
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade/tintou/more-g-declare: 9/21] gladeui: Use G_DECLARE_DERIVABLE_TYPE for GladeCellRendererIcon
- Date: Tue, 20 Aug 2019 18:58:44 +0000 (UTC)
commit 138dcbccd177d6f5e077c8bfa94a32d381839ac3
Author: Corentin Noël <corentin noel collabora com>
Date: Fri Aug 16 16:48:39 2019 +0200
gladeui: Use G_DECLARE_DERIVABLE_TYPE for GladeCellRendererIcon
gladeui/glade-cell-renderer-icon.c | 46 +++++++++++++++++++++++---------------
gladeui/glade-cell-renderer-icon.h | 21 ++---------------
2 files changed, 30 insertions(+), 37 deletions(-)
---
diff --git a/gladeui/glade-cell-renderer-icon.c b/gladeui/glade-cell-renderer-icon.c
index 9811a9bd..e874bd83 100644
--- a/gladeui/glade-cell-renderer-icon.c
+++ b/gladeui/glade-cell-renderer-icon.c
@@ -39,11 +39,11 @@ static gboolean glade_cell_renderer_icon_activate (GtkCellRenderer *cell,
const GdkRectangle *cell_area,
GtkCellRendererState flags);
-struct _GladeCellRendererIconPrivate
+typedef struct _GladeCellRendererIconPrivate
{
guint active : 1;
guint activatable : 1;
-};
+} GladeCellRendererIconPrivate;
enum
{
@@ -69,10 +69,10 @@ G_DEFINE_TYPE_WITH_PRIVATE (GladeCellRendererIcon,
static void glade_cell_renderer_icon_init (GladeCellRendererIcon *cellicon)
{
- cellicon->priv = glade_cell_renderer_icon_get_instance_private (cellicon);
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (cellicon);
- cellicon->priv->activatable = TRUE;
- cellicon->priv->active = FALSE;
+ priv->activatable = TRUE;
+ priv->active = FALSE;
g_object_set (G_OBJECT (cellicon), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
NULL);
@@ -121,14 +121,15 @@ glade_cell_renderer_icon_get_property (GObject *object,
GParamSpec *pspec)
{
GladeCellRendererIcon *cellicon = GLADE_CELL_RENDERER_ICON (object);
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (cellicon);
switch (param_id)
{
case PROP_ACTIVE:
- g_value_set_boolean (value, cellicon->priv->active);
+ g_value_set_boolean (value, priv->active);
break;
case PROP_ACTIVATABLE:
- g_value_set_boolean (value, cellicon->priv->activatable);
+ g_value_set_boolean (value, priv->activatable);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -144,14 +145,15 @@ glade_cell_renderer_icon_set_property (GObject *object,
GParamSpec *pspec)
{
GladeCellRendererIcon *cellicon = GLADE_CELL_RENDERER_ICON (object);
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (cellicon);
switch (param_id)
{
case PROP_ACTIVE:
- cellicon->priv->active = g_value_get_boolean (value);
+ priv->active = g_value_get_boolean (value);
break;
case PROP_ACTIVATABLE:
- cellicon->priv->activatable = g_value_get_boolean (value);
+ priv->activatable = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -174,10 +176,10 @@ glade_cell_renderer_icon_activate (GtkCellRenderer *cell,
const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
- GladeCellRendererIcon *cellicon;
+ GladeCellRendererIcon *cellicon = GLADE_CELL_RENDERER_ICON (cell);
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (cellicon);
- cellicon = GLADE_CELL_RENDERER_ICON (cell);
- if (cellicon->priv->activatable)
+ if (priv->activatable)
{
g_signal_emit (cell, icon_cell_signals[ACTIVATE], 0, path);
return TRUE;
@@ -189,20 +191,24 @@ glade_cell_renderer_icon_activate (GtkCellRenderer *cell,
gboolean
glade_cell_renderer_icon_get_active (GladeCellRendererIcon *icon)
{
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (icon);
+
g_return_val_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon), FALSE);
- return icon->priv->active;
+ return priv->active;
}
void
glade_cell_renderer_icon_set_active (GladeCellRendererIcon *icon,
gboolean setting)
{
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (icon);
+
g_return_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon));
- if (icon->priv->active != setting)
+ if (priv->active != setting)
{
- icon->priv->active = setting ? TRUE : FALSE;
+ priv->active = setting ? TRUE : FALSE;
g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_ACTIVE]);
}
}
@@ -210,20 +216,24 @@ glade_cell_renderer_icon_set_active (GladeCellRendererIcon *icon,
gboolean
glade_cell_renderer_icon_get_activatable (GladeCellRendererIcon *icon)
{
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (icon);
+
g_return_val_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon), FALSE);
- return icon->priv->activatable;
+ return priv->activatable;
}
void
glade_cell_renderer_icon_set_activatable (GladeCellRendererIcon *icon,
gboolean setting)
{
+ GladeCellRendererIconPrivate *priv = glade_cell_renderer_icon_get_instance_private (icon);
+
g_return_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon));
- if (icon->priv->activatable != setting)
+ if (priv->activatable != setting)
{
- icon->priv->activatable = setting ? TRUE : FALSE;
+ priv->activatable = setting ? TRUE : FALSE;
g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_ACTIVATABLE]);
}
}
diff --git a/gladeui/glade-cell-renderer-icon.h b/gladeui/glade-cell-renderer-icon.h
index 3bb3fb44..e7fbad9a 100644
--- a/gladeui/glade-cell-renderer-icon.h
+++ b/gladeui/glade-cell-renderer-icon.h
@@ -27,24 +27,8 @@
G_BEGIN_DECLS
-
-#define GLADE_TYPE_CELL_RENDERER_ICON (glade_cell_renderer_icon_get_type ())
-#define GLADE_CELL_RENDERER_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GLADE_TYPE_CELL_RENDERER_ICON, GladeCellRendererIcon))
-#define GLADE_CELL_RENDERER_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GLADE_TYPE_CELL_RENDERER_ICON, GladeCellRendererIconClass))
-#define GLADE_IS_CELL_RENDERER_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GLADE_TYPE_CELL_RENDERER_ICON))
-#define GLADE_IS_CELL_RENDERER_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GLADE_TYPE_CELL_RENDERER_ICON))
-#define GLADE_CELL_RENDERER_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GLADE_TYPE_CELL_RENDERER_ICON, GladeCellRendererIconClass))
-
-typedef struct _GladeCellRendererIcon GladeCellRendererIcon;
-typedef struct _GladeCellRendererIconClass GladeCellRendererIconClass;
-typedef struct _GladeCellRendererIconPrivate GladeCellRendererIconPrivate;
-
-struct _GladeCellRendererIcon
-{
- GtkCellRendererPixbuf parent;
-
- GladeCellRendererIconPrivate *priv;
-};
+#define GLADE_TYPE_CELL_RENDERER_ICON glade_cell_renderer_icon_get_type ()
+G_DECLARE_DERIVABLE_TYPE (GladeCellRendererIcon, glade_cell_renderer_icon, GLADE, CELL_RENDERER_ICON,
GtkCellRendererPixbuf)
struct _GladeCellRendererIconClass
{
@@ -54,7 +38,6 @@ struct _GladeCellRendererIconClass
const gchar *path);
};
-GType glade_cell_renderer_icon_get_type (void) G_GNUC_CONST;
GtkCellRenderer *glade_cell_renderer_icon_new (void);
gboolean glade_cell_renderer_icon_get_active (GladeCellRendererIcon *icon);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]