[sushi] Replace usage of deprecated g_type_class_add_private()



commit 6f0648c2473a705a0d61380e4ebcb584387a060a
Author: Martin Blanchard <tchaik gmx com>
Date:   Mon Sep 3 18:32:33 2018 -0700

    Replace usage of deprecated g_type_class_add_private()
    
    Stop declaring privates with g_type_class_add_private() and use the
    G_DECLARE_FINAL_TYPE() / G_DEFINE_TYPE_WITH_PRIVATE() pair.

 src/libsushi/sushi-font-widget.c | 12 +++++++++---
 src/libsushi/sushi-font-widget.h | 27 ++++-----------------------
 2 files changed, 13 insertions(+), 26 deletions(-)
---
diff --git a/src/libsushi/sushi-font-widget.c b/src/libsushi/sushi-font-widget.c
index 104cf53..e3213a0 100644
--- a/src/libsushi/sushi-font-widget.c
+++ b/src/libsushi/sushi-font-widget.c
@@ -42,7 +42,7 @@ enum {
   NUM_SIGNALS
 };
 
-struct _SushiFontWidgetPrivate {
+typedef struct {
   gchar *uri;
   gint face_index;
 
@@ -57,12 +57,19 @@ struct _SushiFontWidgetPrivate {
   gchar *sample_string;
 
   gchar *font_name;
+} SushiFontWidgetPrivate;
+
+struct _SushiFontWidget {
+  GtkDrawingArea parent_instance;
+
+  SushiFontWidgetPrivate *priv;
 };
 
 static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
 static guint signals[NUM_SIGNALS] = { 0, };
 
-G_DEFINE_TYPE (SushiFontWidget, sushi_font_widget, GTK_TYPE_DRAWING_AREA);
+G_DEFINE_TYPE_WITH_PRIVATE (SushiFontWidget, sushi_font_widget,
+                            GTK_TYPE_DRAWING_AREA)
 
 #define SURFACE_SIZE 4
 #define SECTION_SPACING 16
@@ -826,7 +833,6 @@ sushi_font_widget_class_init (SushiFontWidgetClass *klass)
                   G_TYPE_NONE, 1, G_TYPE_STRING);
 
   g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
-  g_type_class_add_private (klass, sizeof (SushiFontWidgetPrivate));
 }
 
 SushiFontWidget *
diff --git a/src/libsushi/sushi-font-widget.h b/src/libsushi/sushi-font-widget.h
index 9f1bac1..9c7b556 100644
--- a/src/libsushi/sushi-font-widget.h
+++ b/src/libsushi/sushi-font-widget.h
@@ -33,30 +33,11 @@
 
 G_BEGIN_DECLS
 
-#define SUSHI_TYPE_FONT_WIDGET            (sushi_font_widget_get_type ())
-#define SUSHI_FONT_WIDGET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SUSHI_TYPE_FONT_WIDGET, 
SushiFontWidget))
-#define SUSHI_IS_FONT_WIDGET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SUSHI_TYPE_FONT_WIDGET))
-#define SUSHI_FONT_WIDGET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  SUSHI_TYPE_FONT_WIDGET, 
SushiFontWidgetClass))
-#define SUSHI_IS_FONT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  SUSHI_TYPE_FONT_WIDGET))
-#define SUSHI_FONT_WIDGET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  SUSHI_TYPE_FONT_WIDGET, 
SushiFontWidgetClass))
+#define SUSHI_TYPE_FONT_WIDGET (sushi_font_widget_get_type ())
 
-typedef struct _SushiFontWidget          SushiFontWidget;
-typedef struct _SushiFontWidgetPrivate   SushiFontWidgetPrivate;
-typedef struct _SushiFontWidgetClass     SushiFontWidgetClass;
-
-struct _SushiFontWidget
-{
-  GtkDrawingArea parent_instance;
-
-  SushiFontWidgetPrivate *priv;
-};
-
-struct _SushiFontWidgetClass
-{
-  GtkDrawingAreaClass parent_class;
-};
-
-GType    sushi_font_widget_get_type     (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (SushiFontWidget, sushi_font_widget,
+                      SUSHI, FONT_WIDGET,
+                      GtkDrawingArea)
 
 SushiFontWidget *sushi_font_widget_new (const gchar *uri, gint face_index);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]