[gtksourceview/wip/chergert/gsv-gtk4: 21/172] gutter: modernize GtkSourceGutterRendererPixbuf
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4: 21/172] gutter: modernize GtkSourceGutterRendererPixbuf
- Date: Thu, 14 May 2020 02:03:21 +0000 (UTC)
commit bc94a7092428092dba70fdad5bb06ed99c9405e3
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 8 20:39:33 2020 -0800
gutter: modernize GtkSourceGutterRendererPixbuf
- Use G_DECLARE_ macros
- Use get_instance_private
- Fix spacing style for multi-line functions
gtksourceview/gtksourceautocleanups.h | 1 -
gtksourceview/gtksourcegutterrendererpixbuf.c | 52 +++++++++++++++----------
gtksourceview/gtksourcegutterrendererpixbuf.h | 55 ++++++++-------------------
3 files changed, 46 insertions(+), 62 deletions(-)
---
diff --git a/gtksourceview/gtksourceautocleanups.h b/gtksourceview/gtksourceautocleanups.h
index 4a7c827a..c1a35a70 100644
--- a/gtksourceview/gtksourceautocleanups.h
+++ b/gtksourceview/gtksourceautocleanups.h
@@ -28,7 +28,6 @@ G_BEGIN_DECLS
#ifndef __GI_SCANNER__
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceGutterRendererPixbuf, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceGutterRendererText, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceLanguage, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceLanguageManager, g_object_unref)
diff --git a/gtksourceview/gtksourcegutterrendererpixbuf.c b/gtksourceview/gtksourcegutterrendererpixbuf.c
index 8fcbbc55..43f5ee9d 100644
--- a/gtksourceview/gtksourcegutterrendererpixbuf.c
+++ b/gtksourceview/gtksourcegutterrendererpixbuf.c
@@ -33,10 +33,10 @@
* #GtkSourceGutter.
*/
-struct _GtkSourceGutterRendererPixbufPrivate
+typedef struct
{
GtkSourcePixbufHelper *helper;
-};
+} GtkSourceGutterRendererPixbufPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceGutterRendererPixbuf, gtk_source_gutter_renderer_pixbuf,
GTK_SOURCE_TYPE_GUTTER_RENDERER)
@@ -88,6 +88,7 @@ gutter_renderer_pixbuf_draw (GtkSourceGutterRenderer *renderer,
GtkSourceGutterRendererState state)
{
GtkSourceGutterRendererPixbuf *pix = GTK_SOURCE_GUTTER_RENDERER_PIXBUF (renderer);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(pix);
gint width;
gint height;
gfloat xalign;
@@ -114,7 +115,7 @@ gutter_renderer_pixbuf_draw (GtkSourceGutterRenderer *renderer,
view = gtk_source_gutter_renderer_get_view (renderer);
- pixbuf = gtk_source_pixbuf_helper_render (pix->priv->helper,
+ pixbuf = gtk_source_pixbuf_helper_render (priv->helper,
GTK_WIDGET (view),
cell_area->width);
@@ -192,8 +193,9 @@ static void
gtk_source_gutter_renderer_pixbuf_finalize (GObject *object)
{
GtkSourceGutterRendererPixbuf *renderer = GTK_SOURCE_GUTTER_RENDERER_PIXBUF (object);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
- gtk_source_pixbuf_helper_free (renderer->priv->helper);
+ gtk_source_pixbuf_helper_free (priv->helper);
G_OBJECT_CLASS (gtk_source_gutter_renderer_pixbuf_parent_class)->finalize (object);
}
@@ -202,8 +204,9 @@ static void
set_pixbuf (GtkSourceGutterRendererPixbuf *renderer,
GdkPixbuf *pixbuf)
{
- gtk_source_pixbuf_helper_set_pixbuf (renderer->priv->helper,
- pixbuf);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
+
+ gtk_source_pixbuf_helper_set_pixbuf (priv->helper, pixbuf);
g_object_notify (G_OBJECT (renderer), "pixbuf");
@@ -214,8 +217,9 @@ static void
set_gicon (GtkSourceGutterRendererPixbuf *renderer,
GIcon *icon)
{
- gtk_source_pixbuf_helper_set_gicon (renderer->priv->helper,
- icon);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
+
+ gtk_source_pixbuf_helper_set_gicon (priv->helper, icon);
g_object_notify (G_OBJECT (renderer), "gicon");
@@ -226,8 +230,9 @@ static void
set_icon_name (GtkSourceGutterRendererPixbuf *renderer,
const gchar *icon_name)
{
- gtk_source_pixbuf_helper_set_icon_name (renderer->priv->helper,
- icon_name);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
+
+ gtk_source_pixbuf_helper_set_icon_name (priv->helper, icon_name);
g_object_notify (G_OBJECT (renderer), "icon-name");
@@ -268,23 +273,22 @@ gtk_source_gutter_renderer_pixbuf_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GtkSourceGutterRendererPixbuf *renderer;
-
- renderer = GTK_SOURCE_GUTTER_RENDERER_PIXBUF (object);
+ GtkSourceGutterRendererPixbuf *renderer = GTK_SOURCE_GUTTER_RENDERER_PIXBUF (object);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
switch (prop_id)
{
case PROP_PIXBUF:
g_value_set_object (value,
- gtk_source_pixbuf_helper_get_pixbuf (renderer->priv->helper));
+ gtk_source_pixbuf_helper_get_pixbuf (priv->helper));
break;
case PROP_ICON_NAME:
g_value_set_string (value,
- gtk_source_pixbuf_helper_get_icon_name (renderer->priv->helper));
+ gtk_source_pixbuf_helper_get_icon_name (priv->helper));
break;
case PROP_GICON:
g_value_set_object (value,
- gtk_source_pixbuf_helper_get_gicon (renderer->priv->helper));
+ gtk_source_pixbuf_helper_get_gicon (priv->helper));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -333,9 +337,9 @@ gtk_source_gutter_renderer_pixbuf_class_init (GtkSourceGutterRendererPixbufClass
static void
gtk_source_gutter_renderer_pixbuf_init (GtkSourceGutterRendererPixbuf *self)
{
- self->priv = gtk_source_gutter_renderer_pixbuf_get_instance_private (self);
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(self);
- self->priv->helper = gtk_source_pixbuf_helper_new ();
+ priv->helper = gtk_source_pixbuf_helper_new ();
}
/**
@@ -380,9 +384,11 @@ gtk_source_gutter_renderer_pixbuf_set_pixbuf (GtkSourceGutterRendererPixbuf *ren
GdkPixbuf *
gtk_source_gutter_renderer_pixbuf_get_pixbuf (GtkSourceGutterRendererPixbuf *renderer)
{
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
+
g_return_val_if_fail (GTK_SOURCE_IS_GUTTER_RENDERER_PIXBUF (renderer), NULL);
- return gtk_source_pixbuf_helper_get_pixbuf (renderer->priv->helper);
+ return gtk_source_pixbuf_helper_get_pixbuf (priv->helper);
}
/**
@@ -412,9 +418,11 @@ gtk_source_gutter_renderer_pixbuf_set_gicon (GtkSourceGutterRendererPixbuf *rend
GIcon *
gtk_source_gutter_renderer_pixbuf_get_gicon (GtkSourceGutterRendererPixbuf *renderer)
{
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
+
g_return_val_if_fail (GTK_SOURCE_IS_GUTTER_RENDERER_PIXBUF (renderer), NULL);
- return gtk_source_pixbuf_helper_get_gicon (renderer->priv->helper);
+ return gtk_source_pixbuf_helper_get_gicon (priv->helper);
}
/**
@@ -434,7 +442,9 @@ gtk_source_gutter_renderer_pixbuf_set_icon_name (GtkSourceGutterRendererPixbuf *
const gchar *
gtk_source_gutter_renderer_pixbuf_get_icon_name (GtkSourceGutterRendererPixbuf *renderer)
{
+ GtkSourceGutterRendererPixbufPrivate *priv = gtk_source_gutter_renderer_pixbuf_get_instance_private
(renderer);
+
g_return_val_if_fail (GTK_SOURCE_IS_GUTTER_RENDERER_PIXBUF (renderer), NULL);
- return gtk_source_pixbuf_helper_get_icon_name (renderer->priv->helper);
+ return gtk_source_pixbuf_helper_get_icon_name (priv->helper);
}
diff --git a/gtksourceview/gtksourcegutterrendererpixbuf.h b/gtksourceview/gtksourcegutterrendererpixbuf.h
index b34f4dda..a506edf7 100644
--- a/gtksourceview/gtksourcegutterrendererpixbuf.h
+++ b/gtksourceview/gtksourcegutterrendererpixbuf.h
@@ -29,60 +29,35 @@
G_BEGIN_DECLS
-#define GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF (gtk_source_gutter_renderer_pixbuf_get_type
())
-#define GTK_SOURCE_GUTTER_RENDERER_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF, GtkSourceGutterRendererPixbuf))
-#define GTK_SOURCE_GUTTER_RENDERER_PIXBUF_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF, GtkSourceGutterRendererPixbuf const))
-#define GTK_SOURCE_GUTTER_RENDERER_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF, GtkSourceGutterRendererPixbufClass))
-#define GTK_SOURCE_IS_GUTTER_RENDERER_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF))
-#define GTK_SOURCE_IS_GUTTER_RENDERER_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF))
-#define GTK_SOURCE_GUTTER_RENDERER_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF, GtkSourceGutterRendererPixbufClass))
+#define GTK_SOURCE_TYPE_GUTTER_RENDERER_PIXBUF (gtk_source_gutter_renderer_pixbuf_get_type())
-typedef struct _GtkSourceGutterRendererPixbufClass GtkSourceGutterRendererPixbufClass;
-typedef struct _GtkSourceGutterRendererPixbufPrivate GtkSourceGutterRendererPixbufPrivate;
-
-struct _GtkSourceGutterRendererPixbuf
-{
- /*< private >*/
- GtkSourceGutterRenderer parent;
-
- GtkSourceGutterRendererPixbufPrivate *priv;
-
- /*< public >*/
-};
+GTK_SOURCE_AVAILABLE_IN_ALL
+G_DECLARE_DERIVABLE_TYPE (GtkSourceGutterRendererPixbuf, gtk_source_gutter_renderer_pixbuf, GTK_SOURCE,
GUTTER_RENDERER_PIXBUF, GtkSourceGutterRenderer)
struct _GtkSourceGutterRendererPixbufClass
{
- /*< private >*/
GtkSourceGutterRendererClass parent_class;
- gpointer padding[10];
+ /*< private >*/
+ gpointer _reserved[10];
};
GTK_SOURCE_AVAILABLE_IN_ALL
-GType gtk_source_gutter_renderer_pixbuf_get_type (void) G_GNUC_CONST;
-
-GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourceGutterRenderer *gtk_source_gutter_renderer_pixbuf_new (void);
-
+GtkSourceGutterRenderer *gtk_source_gutter_renderer_pixbuf_new (void);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_gutter_renderer_pixbuf_set_pixbuf (GtkSourceGutterRendererPixbuf *renderer,
- GdkPixbuf *pixbuf);
-
+void gtk_source_gutter_renderer_pixbuf_set_pixbuf (GtkSourceGutterRendererPixbuf
*renderer,
+ GdkPixbuf
*pixbuf);
GTK_SOURCE_AVAILABLE_IN_ALL
-GdkPixbuf *gtk_source_gutter_renderer_pixbuf_get_pixbuf (GtkSourceGutterRendererPixbuf *renderer);
-
+GdkPixbuf *gtk_source_gutter_renderer_pixbuf_get_pixbuf (GtkSourceGutterRendererPixbuf
*renderer);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_gutter_renderer_pixbuf_set_gicon (GtkSourceGutterRendererPixbuf *renderer,
- GIcon *icon);
-
+void gtk_source_gutter_renderer_pixbuf_set_gicon (GtkSourceGutterRendererPixbuf
*renderer,
+ GIcon
*icon);
GTK_SOURCE_AVAILABLE_IN_ALL
-GIcon *gtk_source_gutter_renderer_pixbuf_get_gicon (GtkSourceGutterRendererPixbuf *renderer);
-
+GIcon *gtk_source_gutter_renderer_pixbuf_get_gicon (GtkSourceGutterRendererPixbuf
*renderer);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_gutter_renderer_pixbuf_set_icon_name (GtkSourceGutterRendererPixbuf *renderer,
- const gchar *icon_name);
-
+void gtk_source_gutter_renderer_pixbuf_set_icon_name (GtkSourceGutterRendererPixbuf
*renderer,
+ const gchar
*icon_name);
GTK_SOURCE_AVAILABLE_IN_ALL
-const gchar *gtk_source_gutter_renderer_pixbuf_get_icon_name (GtkSourceGutterRendererPixbuf *renderer);
+const gchar *gtk_source_gutter_renderer_pixbuf_get_icon_name (GtkSourceGutterRendererPixbuf
*renderer);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]