[totem-pl-parser/wip/hadess/add-ignored-extensions: 1/4] plparser: Remove g_type_class_add_private() usage



commit 019cb6a7d0fe45c9569b58ce90a1ad9aeb7968d1
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Nov 12 11:29:30 2019 +0100

    plparser: Remove g_type_class_add_private() usage
    
    Obsoleted since glib 2.58

 plparse/totem-pl-parser.c   | 12 ++++--------
 plparse/totem-pl-playlist.c | 23 +++++++++--------------
 2 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index e63a191..49dd406 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -327,8 +327,6 @@ totem_pl_parser_class_init (TotemPlParserClass *klass)
 
        totem_pl_parser_parent_class = g_type_class_peek_parent (klass);
 
-       g_type_class_add_private (klass, sizeof (TotemPlParserPrivate));
-
        object_class->finalize = totem_pl_parser_finalize;
        object_class->set_property = totem_pl_parser_set_property;
        object_class->get_property = totem_pl_parser_get_property;
@@ -1278,7 +1276,7 @@ totem_pl_parser_read_ini_line_string (char **lines, const char *key)
 static void
 totem_pl_parser_init (TotemPlParser *parser)
 {
-       parser->priv = G_TYPE_INSTANCE_GET_PRIVATE (parser, TOTEM_TYPE_PL_PARSER, TotemPlParserPrivate);
+       parser->priv = g_new0 (TotemPlParserPrivate, 1);
        parser->priv->main_thread = g_thread_self ();
        g_mutex_init (&parser->priv->ignore_mutex);
        parser->priv->ignore_schemes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@@ -1289,16 +1287,14 @@ totem_pl_parser_init (TotemPlParser *parser)
 static void
 totem_pl_parser_finalize (GObject *object)
 {
-       TotemPlParserPrivate *priv = TOTEM_PL_PARSER (object)->priv;
-
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (priv != NULL);
+       TotemPlParser *parser = TOTEM_PL_PARSER (object);
+       TotemPlParserPrivate *priv = parser->priv;
 
        g_clear_pointer (&priv->ignore_schemes, g_hash_table_destroy);
        g_clear_pointer (&priv->ignore_mimetypes, g_hash_table_destroy);
        g_clear_pointer (&priv->ignore_globs, g_hash_table_destroy);
-
        g_mutex_clear (&priv->ignore_mutex);
+       g_clear_pointer (&parser->priv, g_free);
 
        G_OBJECT_CLASS (totem_pl_parser_parent_class)->finalize (object);
 }
diff --git a/plparse/totem-pl-playlist.c b/plparse/totem-pl-playlist.c
index 61e5d46..a81ff85 100644
--- a/plparse/totem-pl-playlist.c
+++ b/plparse/totem-pl-playlist.c
@@ -51,13 +51,10 @@ struct TotemPlPlaylistPrivate {
         GList *items;
 };
 
-#define TOTEM_PL_PLAYLIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TOTEM_TYPE_PL_PLAYLIST, 
TotemPlPlaylistPrivate))
-
 static void totem_pl_playlist_finalize (GObject *object);
 
-
-G_DEFINE_TYPE (TotemPlPlaylist, totem_pl_playlist, G_TYPE_OBJECT)
-
+G_DEFINE_TYPE_WITH_CODE (TotemPlPlaylist, totem_pl_playlist, G_TYPE_OBJECT,
+                        G_ADD_PRIVATE (TotemPlPlaylist))
 
 static void
 totem_pl_playlist_class_init (TotemPlPlaylistClass *klass)
@@ -65,8 +62,6 @@ totem_pl_playlist_class_init (TotemPlPlaylistClass *klass)
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
         object_class->finalize = totem_pl_playlist_finalize;
-
-        g_type_class_add_private (klass, sizeof (TotemPlPlaylistPrivate));
 }
 
 static void
@@ -79,7 +74,7 @@ totem_pl_playlist_finalize (GObject *object)
 {
         TotemPlPlaylistPrivate *priv;
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (object);
+        priv = totem_pl_playlist_get_instance_private (TOTEM_PL_PLAYLIST (object));
 
         g_list_foreach (priv->items, (GFunc) g_hash_table_destroy, NULL);
         g_list_free (priv->items);
@@ -115,7 +110,7 @@ totem_pl_playlist_size (TotemPlPlaylist *playlist)
 
         g_return_val_if_fail (TOTEM_IS_PL_PLAYLIST (playlist), 0);
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (playlist);
+        priv = totem_pl_playlist_get_instance_private (playlist);
 
         return g_list_length (priv->items);
 }
@@ -148,7 +143,7 @@ totem_pl_playlist_prepend (TotemPlPlaylist     *playlist,
         g_return_if_fail (TOTEM_IS_PL_PLAYLIST (playlist));
         g_return_if_fail (iter != NULL);
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (playlist);
+        priv = totem_pl_playlist_get_instance_private (playlist);
 
         item = create_playlist_item ();
         priv->items = g_list_prepend (priv->items, item);
@@ -177,7 +172,7 @@ totem_pl_playlist_append (TotemPlPlaylist     *playlist,
         g_return_if_fail (TOTEM_IS_PL_PLAYLIST (playlist));
         g_return_if_fail (iter != NULL);
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (playlist);
+        priv = totem_pl_playlist_get_instance_private (playlist);
 
         item = create_playlist_item ();
 
@@ -214,7 +209,7 @@ totem_pl_playlist_insert (TotemPlPlaylist     *playlist,
         g_return_if_fail (TOTEM_IS_PL_PLAYLIST (playlist));
         g_return_if_fail (iter != NULL);
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (playlist);
+        priv = totem_pl_playlist_get_instance_private (playlist);
 
         item = create_playlist_item ();
         priv->items = g_list_insert (priv->items, item, position);
@@ -237,7 +232,7 @@ check_iter (TotemPlPlaylist     *playlist,
                 return FALSE;
         }
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (playlist);
+        priv = totem_pl_playlist_get_instance_private (playlist);
 
         if (g_list_position (priv->items, iter->data2) == -1) {
                 return FALSE;
@@ -264,7 +259,7 @@ totem_pl_playlist_iter_first (TotemPlPlaylist     *playlist,
         g_return_val_if_fail (TOTEM_IS_PL_PLAYLIST (playlist), FALSE);
         g_return_val_if_fail (iter != NULL, FALSE);
 
-        priv = TOTEM_PL_PLAYLIST_GET_PRIVATE (playlist);
+        priv = totem_pl_playlist_get_instance_private (playlist);
 
         if (!priv->items) {
                 /* Empty playlist */


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