[gnome-font-viewer] Replace usage of deprecated g_type_class_add_private()



commit 9447578b68fa2ab695e13a2321993f8efa3260fd
Author: Martin Blanchard <tchaik gmx com>
Date:   Thu Jul 19 22:20:44 2018 +0100

    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/font-model.c | 14 ++++++++++----
 src/font-model.h | 19 +++++--------------
 src/font-view.c  | 20 +++++++++-----------
 3 files changed, 24 insertions(+), 29 deletions(-)
---
diff --git a/src/font-model.c b/src/font-model.c
index 99b1f0e..3492223 100644
--- a/src/font-model.c
+++ b/src/font-model.c
@@ -43,7 +43,7 @@
 #include "font-utils.h"
 #include "sushi-font-loader.h"
 
-struct _FontViewModelPrivate {
+typedef struct {
     /* list of fonts in fontconfig database */
     FcFontSet *font_list;
     GMutex font_list_mutex;
@@ -56,6 +56,13 @@ struct _FontViewModelPrivate {
     gint scale_factor;
     guint font_list_idle_id;
     guint fontconfig_update_id;
+} FontViewModelPrivate;
+
+struct _FontViewModel
+{
+  GtkListStore parent_instance;
+
+  FontViewModelPrivate *priv;
 };
 
 enum {
@@ -65,7 +72,8 @@ enum {
 
 static guint signals[NUM_SIGNALS] = { 0, };
 
-G_DEFINE_TYPE (FontViewModel, font_view_model, GTK_TYPE_LIST_STORE);
+G_DEFINE_TYPE_WITH_PRIVATE (FontViewModel, font_view_model,
+                            GTK_TYPE_LIST_STORE)
 
 #define ATTRIBUTES_FOR_CREATING_THUMBNAIL \
     G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"," \
@@ -651,8 +659,6 @@ font_view_model_class_init (FontViewModelClass *klass)
                       G_SIGNAL_RUN_FIRST,
                       0, NULL, NULL, NULL,
                       G_TYPE_NONE, 0);
-
-    g_type_class_add_private (klass, sizeof (FontViewModelPrivate));
 }
 
 GtkTreeModel *
diff --git a/src/font-model.h b/src/font-model.h
index c8021fe..2082c4e 100644
--- a/src/font-model.h
+++ b/src/font-model.h
@@ -39,23 +39,14 @@ typedef enum {
   NUM_COLUMNS
 } FontViewModelColumns;
 
-typedef struct _FontViewModelPrivate FontViewModelPrivate;
+#define FONT_VIEW_TYPE_MODEL (font_view_model_get_type ())
 
-#define FONT_VIEW_TYPE_MODEL font_view_model_get_type()
-#define FONT_VIEW_MODEL(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_VIEW_TYPE_MODEL, FontViewModel))
-
-typedef struct {
-  GtkListStore parent;
-
-  FontViewModelPrivate *priv;
-} FontViewModel;
-
-typedef struct {
-  GtkListStoreClass parent_class;
-} FontViewModelClass;
+G_DECLARE_FINAL_TYPE (FontViewModel, font_view_model,
+                      FONT_VIEW, MODEL,
+                      GtkListStore)
 
 GType font_view_model_get_type (void);
+
 GtkTreeModel * font_view_model_new (void);
 
 gboolean font_view_model_get_iter_for_face (FontViewModel *self,
diff --git a/src/font-view.c b/src/font-view.c
index ec3cd23..e01d225 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -41,13 +41,14 @@
 #include "font-model.h"
 #include "sushi-font-widget.h"
 
-#define FONT_VIEW_TYPE_APPLICATION font_view_application_get_type()
-#define FONT_VIEW_APPLICATION(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_VIEW_TYPE_APPLICATION, FontViewApplication))
-
+#define FONT_VIEW_TYPE_APPLICATION (font_view_application_get_type ())
 #define FONT_VIEW_ICON_NAME "org.gnome.font-viewer"
 
-typedef struct {
+G_DECLARE_FINAL_TYPE (FontViewApplication, sushi_font_widget,
+                      FONT_VIEW, APPLICATION,
+                      GtkApplication)
+
+struct _FontViewApplication {
     GtkApplication parent;
 
     GtkWidget *main_window;
@@ -72,11 +73,7 @@ typedef struct {
     GtkTreeModel *filter_model;
 
     GFile *font_file;
-} FontViewApplication;
-
-typedef struct {
-    GtkApplicationClass parent_class;
-} FontViewApplicationClass;
+};
 
 static gboolean
 _print_version_and_exit (const gchar *option_name,
@@ -96,7 +93,8 @@ static const GOptionEntry goption_options[] =
     { NULL }
 };
 
-G_DEFINE_TYPE (FontViewApplication, font_view_application, GTK_TYPE_APPLICATION);
+G_DEFINE_TYPE (FontViewApplication, font_view_application,
+               GTK_TYPE_APPLICATION)
 
 static void font_view_application_do_overview (FontViewApplication *self);
 static void ensure_window (FontViewApplication *self);


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