From 011d83d44b61cc6079eebff6a5905e5f87f56bbe Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Wed, 2 Jan 2019 17:56:09 +0100 Subject: [PATCH] Fix g_type_class_add_private is deprecated --- src/gst/parole-gst.c | 9 +- src/misc/parole-file.c | 132 +++++++++++------------ src/misc/parole-file.h | 6 +- src/misc/parole-stream.c | 197 ++++++++++++++++------------------- src/misc/parole-stream.h | 10 +- src/parole-button.c | 9 +- src/parole-conf-dialog.c | 9 +- src/parole-disc.c | 9 +- src/parole-medialist.c | 9 +- src/parole-player.c | 8 +- src/parole-plugin-player.c | 11 +- src/parole-plugins-manager.c | 9 +- 12 files changed, 180 insertions(+), 238 deletions(-) diff --git a/src/gst/parole-gst.c b/src/gst/parole-gst.c index d05e786..7cc63eb 100644 --- a/src/gst/parole-gst.c +++ b/src/gst/parole-gst.c @@ -58,9 +58,6 @@ #define HIDE_WINDOW_CURSOR_TIMEOUT 3.0f -#define PAROLE_GST_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_GST, ParoleGstPrivate)) - static void parole_gst_play_file_internal(ParoleGst *gst); static void parole_gst_change_state(ParoleGst *gst, @@ -165,7 +162,7 @@ static gpointer parole_gst_object = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE(ParoleGst, parole_gst, GTK_TYPE_WIDGET) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleGst, parole_gst, GTK_TYPE_WIDGET) static void parole_gst_finalize(GObject *object) { @@ -2125,13 +2122,11 @@ parole_gst_class_init(ParoleGstClass *klass) { NULL, NULL, TRUE, G_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (ParoleGstPrivate)); } static void parole_gst_init(ParoleGst *gst) { - gst->priv = PAROLE_GST_GET_PRIVATE(gst); + gst->priv = parole_gst_get_instance_private(gst); gst->priv->state = GST_STATE_VOID_PENDING; gst->priv->target = GST_STATE_VOID_PENDING; diff --git a/src/misc/parole-file.c b/src/misc/parole-file.c index cf1163a..f3bf06f 100644 --- a/src/misc/parole-file.c +++ b/src/misc/parole-file.c @@ -37,10 +37,6 @@ #include "src/misc/parole-file.h" -#define PAROLE_FILE_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_FILE, ParoleFilePrivate)) - -typedef struct _ParoleFilePrivate ParoleFilePrivate; struct _ParoleFilePrivate { gchar *filename; @@ -63,33 +59,31 @@ enum { PROP_DVD_CHAPTER }; -G_DEFINE_TYPE(ParoleFile, parole_file, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleFile, parole_file, G_TYPE_OBJECT) static void parole_file_finalize(GObject *object) { ParoleFile *file; - ParoleFilePrivate *priv; file = PAROLE_FILE(object); - priv = PAROLE_FILE_GET_PRIVATE(file); - if ( priv->filename ) - g_free(priv->filename); + if ( file->priv->filename ) + g_free(file->priv->filename); - if ( priv->uri ) - g_free(priv->uri); + if ( file->priv->uri ) + g_free(file->priv->uri); - if ( priv->display_name ) - g_free(priv->display_name); + if ( file->priv->display_name ) + g_free(file->priv->display_name); - if ( priv->content_type ) - g_free(priv->content_type); + if ( file->priv->content_type ) + g_free(file->priv->content_type); - if ( priv->directory ) - g_free(priv->directory); + if ( file->priv->directory ) + g_free(file->priv->directory); - if ( priv->custom_subtitles ) - g_free(priv->custom_subtitles); + if ( file->priv->custom_subtitles ) + g_free(file->priv->custom_subtitles); G_OBJECT_CLASS(parole_file_parent_class)->finalize(object); } @@ -101,19 +95,19 @@ parole_file_set_property(GObject *object, guint prop_id, const GValue *value, GP switch (prop_id) { case PROP_PATH: - PAROLE_FILE_GET_PRIVATE(file)->filename = g_value_dup_string(value); + file->priv->filename = g_value_dup_string(value); break; case PROP_DISPLAY_NAME: - PAROLE_FILE_GET_PRIVATE(file)->display_name = g_value_dup_string(value); + file->priv->display_name = g_value_dup_string(value); break; case PROP_DIRECTORY: - PAROLE_FILE_GET_PRIVATE(file)->directory = g_value_dup_string(value); + file->priv->directory = g_value_dup_string(value); break; case PROP_CUSTOM_SUBTITLES: - PAROLE_FILE_GET_PRIVATE(file)->custom_subtitles = g_value_dup_string(value); + file->priv->custom_subtitles = g_value_dup_string(value); break; case PROP_DVD_CHAPTER: - PAROLE_FILE_GET_PRIVATE(file)->dvd_chapter = g_value_get_int(value); + file->priv->dvd_chapter = g_value_get_int(value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -129,25 +123,25 @@ parole_file_get_property(GObject *object, guint prop_id, GValue *value, GParamSp switch (prop_id) { case PROP_PATH: - g_value_set_string(value, PAROLE_FILE_GET_PRIVATE(file)->filename); + g_value_set_string(value, file->priv->filename); break; case PROP_URI: - g_value_set_string(value, PAROLE_FILE_GET_PRIVATE(file)->filename); + g_value_set_string(value, file->priv->filename); break; case PROP_CONTENT_TYPE: - g_value_set_string(value, PAROLE_FILE_GET_PRIVATE(file)->content_type); + g_value_set_string(value, file->priv->content_type); break; case PROP_DISPLAY_NAME: - g_value_set_string(value, PAROLE_FILE_GET_PRIVATE(file)->display_name); + g_value_set_string(value, file->priv->display_name); break; case PROP_DIRECTORY: - g_value_set_string(value, PAROLE_FILE_GET_PRIVATE(file)->directory); + g_value_set_string(value, file->priv->directory); break; case PROP_CUSTOM_SUBTITLES: - g_value_set_string(value, PAROLE_FILE_GET_PRIVATE(file)->custom_subtitles); + g_value_set_string(value, file->priv->custom_subtitles); break; case PROP_DVD_CHAPTER: - g_value_set_int(value, PAROLE_FILE_GET_PRIVATE(file)->dvd_chapter); + g_value_set_int(value, file->priv->dvd_chapter); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -160,35 +154,33 @@ parole_file_constructed(GObject *object) { GFile *gfile; GFileInfo *info; ParoleFile *file; - ParoleFilePrivate *priv; GError *error = NULL; gchar *filename; file = PAROLE_FILE(object); - priv = PAROLE_FILE_GET_PRIVATE(file); - filename = g_strdup(priv->filename); + filename = g_strdup(file->priv->filename); if ( g_str_has_prefix(filename, "cdda") ) { - priv->directory = NULL; - priv->uri = g_strdup(filename); - priv->content_type = g_strdup("cdda"); + file->priv->directory = NULL; + file->priv->uri = g_strdup(filename); + file->priv->content_type = g_strdup("cdda"); g_free(filename); return; } if ( g_str_has_prefix(filename, "dvd") ) { - priv->directory = NULL; - priv->uri = g_strdup("dvd:/"); - priv->content_type = g_strdup("dvd"); + file->priv->directory = NULL; + file->priv->uri = g_strdup("dvd:/"); + file->priv->content_type = g_strdup("dvd"); g_free(filename); return; } g_free(filename); - gfile = g_file_new_for_commandline_arg(priv->filename); + gfile = g_file_new_for_commandline_arg(file->priv->filename); info = g_file_query_info(gfile, "standard::*,", @@ -197,16 +189,16 @@ parole_file_constructed(GObject *object) { &error); - priv->directory = g_file_get_path(g_file_get_parent(gfile)); + file->priv->directory = g_file_get_path(g_file_get_parent(gfile)); if ( error ) { if (G_LIKELY(error->code == G_IO_ERROR_NOT_SUPPORTED)) { g_error_free(error); - if (!priv->display_name) - priv->display_name = g_file_get_basename(gfile); + if (!file->priv->display_name) + file->priv->display_name = g_file_get_basename(gfile); } else { - if (!priv->display_name) - priv->display_name = g_strdup(priv->filename); + if (!file->priv->display_name) + file->priv->display_name = g_strdup(file->priv->filename); g_warning("Unable to read file info %s", error->message); } goto out; @@ -218,7 +210,7 @@ parole_file_constructed(GObject *object) { gchar *title; gchar *title_s; - tag_file = taglib_file_new(priv->filename); + tag_file = taglib_file_new(file->priv->filename); if ( tag_file ) { tag = taglib_file_tag(tag_file); @@ -228,7 +220,7 @@ parole_file_constructed(GObject *object) { if ( title ) { title_s = g_strstrip(title); if ( strlen(title_s) ) { - priv->display_name = g_strdup(title_s); + file->priv->display_name = g_strdup(title_s); } } @@ -239,15 +231,15 @@ parole_file_constructed(GObject *object) { } #endif - if (!priv->display_name) - priv->display_name = g_strdup(g_file_info_get_display_name(info)); + if (!file->priv->display_name) + file->priv->display_name = g_strdup(g_file_info_get_display_name(info)); - priv->content_type = g_strdup(g_file_info_get_content_type(info)); + file->priv->content_type = g_strdup(g_file_info_get_content_type(info)); g_object_unref(info); out: - priv->uri = g_file_get_uri(gfile); + file->priv->uri = g_file_get_uri(gfile); g_object_unref(gfile); } @@ -372,23 +364,19 @@ parole_file_class_init(ParoleFileClass *klass) { -1, G_PARAM_CONSTRUCT_ONLY| G_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (ParoleFilePrivate)); } static void parole_file_init(ParoleFile *file) { - ParoleFilePrivate *priv; - - priv = PAROLE_FILE_GET_PRIVATE(file); - - priv->filename = NULL; - priv->display_name = NULL; - priv->uri = NULL; - priv->content_type = NULL; - priv->directory = NULL; - priv->custom_subtitles = NULL; - priv->dvd_chapter = 0; + file->priv = parole_file_get_instance_private(file); + + file->priv->filename = NULL; + file->priv->display_name = NULL; + file->priv->uri = NULL; + file->priv->content_type = NULL; + file->priv->directory = NULL; + file->priv->custom_subtitles = NULL; + file->priv->dvd_chapter = 0; } /** @@ -496,7 +484,7 @@ const gchar * parole_file_get_file_name(const ParoleFile *file) { g_return_val_if_fail(PAROLE_IS_FILE(file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->filename; + return file->priv->filename; } /** @@ -513,7 +501,7 @@ const gchar * parole_file_get_display_name(const ParoleFile *file) { g_return_val_if_fail(PAROLE_IS_FILE(file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->display_name; + return file->priv->display_name; } /** @@ -530,7 +518,7 @@ const gchar * parole_file_get_uri(const ParoleFile *file) { g_return_val_if_fail(PAROLE_IS_FILE(file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->uri; + return file->priv->uri; } /** @@ -547,7 +535,7 @@ const gchar * parole_file_get_content_type(const ParoleFile *file) { g_return_val_if_fail(PAROLE_IS_FILE(file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->content_type; + return file->priv->content_type; } /** @@ -564,7 +552,7 @@ const gchar * parole_file_get_directory(const ParoleFile *file) { g_return_val_if_fail(PAROLE_IS_FILE(file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->directory; + return file->priv->directory; } /** @@ -581,7 +569,7 @@ const gchar * parole_file_get_custom_subtitles(const ParoleFile *file) { g_return_val_if_fail(PAROLE_IS_FILE(file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->custom_subtitles; + return file->priv->custom_subtitles; } /** @@ -622,7 +610,7 @@ gint parole_file_get_dvd_chapter(const ParoleFile *file) { // g_return_val_if_fail (PAROLE_IS_FILE (file), NULL); - return PAROLE_FILE_GET_PRIVATE (file)->dvd_chapter; + return file->priv->dvd_chapter; } /** diff --git a/src/misc/parole-file.h b/src/misc/parole-file.h index 0f57785..a6fe0eb 100644 --- a/src/misc/parole-file.h +++ b/src/misc/parole-file.h @@ -35,8 +35,9 @@ G_BEGIN_DECLS #define PAROLE_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_FILE, ParoleFile)) #define PAROLE_IS_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_FILE)) -typedef struct _ParoleFile ParoleFile; -typedef struct _ParoleFileClass ParoleFileClass; +typedef struct _ParoleFile ParoleFile; +typedef struct _ParoleFileClass ParoleFileClass; +typedef struct _ParoleFilePrivate ParoleFilePrivate; /** * ParoleFile: @@ -47,6 +48,7 @@ typedef struct _ParoleFileClass ParoleFileClass; */ struct _ParoleFile { GObject parent; + ParoleFilePrivate *priv; }; struct _ParoleFileClass { diff --git a/src/misc/parole-stream.c b/src/misc/parole-stream.c index 60b2ebd..57c8818 100644 --- a/src/misc/parole-stream.c +++ b/src/misc/parole-stream.c @@ -35,9 +35,6 @@ #include "src/misc/parole-stream.h" -#define PAROLE_STREAM_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_STREAM, ParoleStreamPrivate)) - #define PAROLE_STREAM_FREE_STR_PROP(str) \ if ( str ) \ g_free(str); \ @@ -47,8 +44,6 @@ PAROLE_STREAM_FREE_STR_PROP(str); \ str = g_value_dup_string(value); \ -typedef struct _ParoleStreamPrivate ParoleStreamPrivate; - struct _ParoleStreamPrivate { /*Properties*/ gchar *uri; @@ -107,7 +102,7 @@ enum { PROP_IMAGE_URI }; -G_DEFINE_TYPE(ParoleStream, parole_stream, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleStream, parole_stream, G_TYPE_OBJECT) static void parole_stream_get_media_type_from_uri(ParoleStream *stream, const gchar *uri) { @@ -148,90 +143,86 @@ static void parole_stream_set_property(GObject *object, switch (prop_id) { case PROP_URI: { - ParoleStreamPrivate *priv; - priv = PAROLE_STREAM_GET_PRIVATE(stream); - priv->uri = g_value_dup_string(value); - parole_stream_get_media_type_from_uri(stream, priv->uri); + stream->priv->uri = g_value_dup_string(value); + parole_stream_get_media_type_from_uri(stream, stream->priv->uri); break; } case PROP_IMAGE_URI: { - PAROLE_STREAM_GET_PRIVATE(stream)->image_uri = g_value_dup_string(value); + stream->priv->image_uri = g_value_dup_string(value); break; } case PROP_SUBTITLES: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->subtitles, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->subtitles, value); break; case PROP_LIVE: { - ParoleStreamPrivate *priv; gboolean maybe_remote; - priv = PAROLE_STREAM_GET_PRIVATE(stream); - maybe_remote = priv->media_type == PAROLE_MEDIA_TYPE_REMOTE || - priv->media_type == PAROLE_MEDIA_TYPE_UNKNOWN; - priv->live = g_value_get_boolean(value) && maybe_remote; + maybe_remote = stream->priv->media_type == PAROLE_MEDIA_TYPE_REMOTE || + stream->priv->media_type == PAROLE_MEDIA_TYPE_UNKNOWN; + stream->priv->live = g_value_get_boolean(value) && maybe_remote; break; } case PROP_MEDIA_TYPE: - PAROLE_STREAM_GET_PRIVATE(stream)->media_type = g_value_get_enum(value); + stream->priv->media_type = g_value_get_enum(value); break; case PROP_HAS_AUDIO: - PAROLE_STREAM_GET_PRIVATE(stream)->has_audio = g_value_get_boolean(value); + stream->priv->has_audio = g_value_get_boolean(value); break; case PROP_HAS_VIDEO: - PAROLE_STREAM_GET_PRIVATE(stream)->has_video = g_value_get_boolean(value); + stream->priv->has_video = g_value_get_boolean(value); break; case PROP_SEEKABLE: - PAROLE_STREAM_GET_PRIVATE(stream)->seekable = g_value_get_boolean(value); + stream->priv->seekable = g_value_get_boolean(value); break; case PROP_DISP_PAR_D: - PAROLE_STREAM_GET_PRIVATE(stream)->disp_par_d = g_value_get_uint(value); + stream->priv->disp_par_d = g_value_get_uint(value); break; case PROP_DISP_PAR_N: - PAROLE_STREAM_GET_PRIVATE(stream)->disp_par_n = g_value_get_uint(value); + stream->priv->disp_par_n = g_value_get_uint(value); break; case PROP_TRACKS: - PAROLE_STREAM_GET_PRIVATE(stream)->tracks = g_value_get_uint(value); + stream->priv->tracks = g_value_get_uint(value); break; case PROP_TRACK: - PAROLE_STREAM_GET_PRIVATE(stream)->track = g_value_get_uint(value); + stream->priv->track = g_value_get_uint(value); break; case PROP_TAG_AVAILABLE: - PAROLE_STREAM_GET_PRIVATE(stream)->tag_available = g_value_get_boolean(value); + stream->priv->tag_available = g_value_get_boolean(value); break; case PROP_DURATION: - PAROLE_STREAM_GET_PRIVATE(stream)->duration = g_value_get_int64(value); + stream->priv->duration = g_value_get_int64(value); break; case PROP_ABSOLUTE_DURATION: - PAROLE_STREAM_GET_PRIVATE(stream)->absolute_duration = g_value_get_int64(value); + stream->priv->absolute_duration = g_value_get_int64(value); break; case PROP_VIDEO_HEIGHT: - PAROLE_STREAM_GET_PRIVATE(stream)->video_h = g_value_get_int(value); + stream->priv->video_h = g_value_get_int(value); break; case PROP_VIDEO_WIDTH: - PAROLE_STREAM_GET_PRIVATE(stream)->video_w = g_value_get_int(value); + stream->priv->video_w = g_value_get_int(value); break; case PROP_TITLE: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->title, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->title, value); break; case PROP_ARTIST: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->artist, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->artist, value); break; case PROP_YEAR: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->year, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->year, value); break; case PROP_ALBUM: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->album, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->album, value); break; case PROP_COMMENT: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->comment, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->comment, value); break; case PROP_GENRE: - PAROLE_STREAM_DUP_GVALUE_STRING(PAROLE_STREAM_GET_PRIVATE(stream)->genre, value); + PAROLE_STREAM_DUP_GVALUE_STRING(stream->priv->genre, value); break; case PROP_BITRATE: - PAROLE_STREAM_GET_PRIVATE(stream)->bitrate = g_value_get_uint(value); + stream->priv->bitrate = g_value_get_uint(value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -248,76 +239,76 @@ static void parole_stream_get_property(GObject *object, switch (prop_id) { case PROP_URI: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->uri); + g_value_set_string(value, stream->priv->uri); break; case PROP_IMAGE_URI: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->image_uri); + g_value_set_string(value, stream->priv->image_uri); break; case PROP_SUBTITLES: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->subtitles); + g_value_set_string(value, stream->priv->subtitles); break; case PROP_LIVE: - g_value_set_boolean(value, PAROLE_STREAM_GET_PRIVATE(stream)->live); + g_value_set_boolean(value, stream->priv->live); break; case PROP_MEDIA_TYPE: - g_value_set_enum(value, PAROLE_STREAM_GET_PRIVATE(stream)->media_type); + g_value_set_enum(value, stream->priv->media_type); break; case PROP_HAS_AUDIO: - g_value_set_boolean(value, PAROLE_STREAM_GET_PRIVATE(stream)->has_audio); + g_value_set_boolean(value, stream->priv->has_audio); break; case PROP_HAS_VIDEO: - g_value_set_boolean(value, PAROLE_STREAM_GET_PRIVATE(stream)->has_video); + g_value_set_boolean(value, stream->priv->has_video); break; case PROP_SEEKABLE: - g_value_set_boolean(value, PAROLE_STREAM_GET_PRIVATE(stream)->seekable); + g_value_set_boolean(value, stream->priv->seekable); break; case PROP_DISP_PAR_D: - g_value_set_uint(value, PAROLE_STREAM_GET_PRIVATE(stream)->disp_par_d); + g_value_set_uint(value, stream->priv->disp_par_d); break; case PROP_DISP_PAR_N: - g_value_set_uint(value, PAROLE_STREAM_GET_PRIVATE(stream)->disp_par_n); + g_value_set_uint(value, stream->priv->disp_par_n); break; case PROP_DURATION: - g_value_set_int64(value, PAROLE_STREAM_GET_PRIVATE(stream)->duration); + g_value_set_int64(value, stream->priv->duration); break; case PROP_TRACKS: - g_value_set_uint(value, PAROLE_STREAM_GET_PRIVATE(stream)->tracks); + g_value_set_uint(value, stream->priv->tracks); break; case PROP_TRACK: - g_value_set_uint(value, PAROLE_STREAM_GET_PRIVATE(stream)->track); + g_value_set_uint(value, stream->priv->track); break; case PROP_TAG_AVAILABLE: - g_value_set_double(value, PAROLE_STREAM_GET_PRIVATE(stream)->tag_available); + g_value_set_double(value, stream->priv->tag_available); break; case PROP_ABSOLUTE_DURATION: - g_value_set_int64(value, PAROLE_STREAM_GET_PRIVATE(stream)->absolute_duration); + g_value_set_int64(value, stream->priv->absolute_duration); break; case PROP_VIDEO_HEIGHT: - g_value_set_int(value, PAROLE_STREAM_GET_PRIVATE(stream)->video_h); + g_value_set_int(value, stream->priv->video_h); break; case PROP_VIDEO_WIDTH: - g_value_set_int(value, PAROLE_STREAM_GET_PRIVATE(stream)->video_w); + g_value_set_int(value, stream->priv->video_w); break; case PROP_TITLE: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->title); + g_value_set_string(value, stream->priv->title); break; case PROP_ARTIST: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->artist); + g_value_set_string(value, stream->priv->artist); break; case PROP_YEAR: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->year); + g_value_set_string(value, stream->priv->year); break; case PROP_ALBUM: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->album); + g_value_set_string(value, stream->priv->album); break; case PROP_COMMENT: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->comment); + g_value_set_string(value, stream->priv->comment); break; case PROP_GENRE: - g_value_set_string(value, PAROLE_STREAM_GET_PRIVATE(stream)->genre); + g_value_set_string(value, stream->priv->genre); break; case PROP_BITRATE: - g_value_set_uint(value, PAROLE_STREAM_GET_PRIVATE(stream)->bitrate); + g_value_set_uint(value, stream->priv->bitrate); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -354,24 +345,24 @@ parole_stream_set_image(GObject *object, GdkPixbuf *pixbuf) { stream = PAROLE_STREAM(object); - if ( PAROLE_STREAM_GET_PRIVATE (stream)->image ) - g_object_unref(G_OBJECT(PAROLE_STREAM_GET_PRIVATE(stream)->image)); + if ( stream->priv->image ) + g_object_unref(G_OBJECT(stream->priv->image)); if (pixbuf) { - PAROLE_STREAM_GET_PRIVATE(stream)->image = gdk_pixbuf_copy(pixbuf); + stream->priv->image = gdk_pixbuf_copy(pixbuf); /* Create a jpeg of the artwork for other components to easily access */ fid = g_file_open_tmp("parole-art-XXXXXX.jpg", &filename, NULL); close(fid); gdk_pixbuf_save(pixbuf, filename, "jpeg", NULL, "quality", "100", NULL); - PAROLE_STREAM_GET_PRIVATE(stream)->previous_image = g_strdup(filename); - PAROLE_STREAM_GET_PRIVATE(stream)->image_uri = g_strdup_printf("file://%s", filename); + stream->priv->previous_image = g_strdup(filename); + stream->priv->image_uri = g_strdup_printf("file://%s", filename); g_free(filename); } else { - PAROLE_STREAM_GET_PRIVATE(stream)->image = NULL; - PAROLE_STREAM_GET_PRIVATE(stream)->previous_image = NULL; - PAROLE_STREAM_GET_PRIVATE(stream)->image_uri = g_strdup_printf("file://%s/no-cover.png", PIXMAPS_DIR); + stream->priv->image = NULL; + stream->priv->previous_image = NULL; + stream->priv->image_uri = g_strdup_printf("file://%s/no-cover.png", PIXMAPS_DIR); } } @@ -392,8 +383,8 @@ parole_stream_get_image(GObject *object) { stream = PAROLE_STREAM(object); - if (PAROLE_STREAM_GET_PRIVATE (stream)->image) - pixbuf = gdk_pixbuf_copy(GDK_PIXBUF(PAROLE_STREAM_GET_PRIVATE(stream)->image)); + if (stream->priv->image) + pixbuf = gdk_pixbuf_copy(GDK_PIXBUF(stream->priv->image)); else pixbuf = NULL; @@ -782,12 +773,12 @@ parole_stream_class_init(ParoleStreamClass *klass) { 0, 2147483647, 0, G_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (ParoleStreamPrivate)); } static void parole_stream_init(ParoleStream *stream) { + stream->priv = parole_stream_get_instance_private(stream); + parole_stream_init_properties(stream); } @@ -799,40 +790,36 @@ parole_stream_new(void) { } void parole_stream_init_properties(ParoleStream *stream) { - ParoleStreamPrivate *priv; - - priv = PAROLE_STREAM_GET_PRIVATE(stream); - - priv->live = FALSE; - priv->seekable = FALSE; - priv->has_audio = FALSE; - priv->has_video = FALSE; - priv->absolute_duration = 0; - priv->duration = 0; - priv->tag_available = FALSE; - priv->media_type = PAROLE_MEDIA_TYPE_UNKNOWN; - priv->video_h = 0; - priv->video_w = 0; - priv->tracks = 1; - priv->track = 1; - priv->disp_par_n = 1; - priv->disp_par_d = 1; - priv->bitrate = 0; - - PAROLE_STREAM_FREE_STR_PROP(priv->title); - PAROLE_STREAM_FREE_STR_PROP(priv->uri); - PAROLE_STREAM_FREE_STR_PROP(priv->subtitles); - PAROLE_STREAM_FREE_STR_PROP(priv->artist); - PAROLE_STREAM_FREE_STR_PROP(priv->year); - PAROLE_STREAM_FREE_STR_PROP(priv->album); - PAROLE_STREAM_FREE_STR_PROP(priv->comment); - PAROLE_STREAM_FREE_STR_PROP(priv->genre); - PAROLE_STREAM_FREE_STR_PROP(priv->image_uri); + stream->priv->live = FALSE; + stream->priv->seekable = FALSE; + stream->priv->has_audio = FALSE; + stream->priv->has_video = FALSE; + stream->priv->absolute_duration = 0; + stream->priv->duration = 0; + stream->priv->tag_available = FALSE; + stream->priv->media_type = PAROLE_MEDIA_TYPE_UNKNOWN; + stream->priv->video_h = 0; + stream->priv->video_w = 0; + stream->priv->tracks = 1; + stream->priv->track = 1; + stream->priv->disp_par_n = 1; + stream->priv->disp_par_d = 1; + stream->priv->bitrate = 0; + + PAROLE_STREAM_FREE_STR_PROP(stream->priv->title); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->uri); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->subtitles); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->artist); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->year); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->album); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->comment); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->genre); + PAROLE_STREAM_FREE_STR_PROP(stream->priv->image_uri); /* Remove the previous image if it exists */ - if (PAROLE_STREAM_GET_PRIVATE(stream)->previous_image) { - if (g_remove (PAROLE_STREAM_GET_PRIVATE (stream)->previous_image) != 0) + if (stream->priv->previous_image) { + if (g_remove (stream->priv->previous_image) != 0) g_warning("Failed to remove temporary artwork"); } - PAROLE_STREAM_GET_PRIVATE(stream)->previous_image = NULL; + stream->priv->previous_image = NULL; } diff --git a/src/misc/parole-stream.h b/src/misc/parole-stream.h index ae946c0..4dd7f94 100644 --- a/src/misc/parole-stream.h +++ b/src/misc/parole-stream.h @@ -90,15 +90,17 @@ typedef enum { * * Since: 0.2 */ -typedef struct _ParoleStream ParoleStream; -typedef struct _ParoleStreamClass ParoleStreamClass; +typedef struct _ParoleStream ParoleStream; +typedef struct _ParoleStreamClass ParoleStreamClass; +typedef struct _ParoleStreamPrivate ParoleStreamPrivate; struct _ParoleStream { - GObject parent; + GObject parent; + ParoleStreamPrivate *priv; }; struct _ParoleStreamClass { - GObjectClass parent_class; + GObjectClass parent_class; }; GType parole_stream_get_type (void) G_GNUC_CONST; diff --git a/src/parole-button.c b/src/parole-button.c index 0333de2..5c2d47c 100644 --- a/src/parole-button.c +++ b/src/parole-button.c @@ -54,9 +54,6 @@ static void parole_button_finalize(GObject *object); -#define PAROLE_BUTTON_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_BUTTON, ParoleButtonPrivate)) - static struct { ParoleButtonKey key; guint key_code; @@ -76,7 +73,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE(ParoleButton, parole_button, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleButton, parole_button, G_TYPE_OBJECT) /** * parole_button_get_key: @@ -251,8 +248,6 @@ parole_button_class_init(ParoleButtonClass *klass) { G_TYPE_NONE, 1, ENUM_GTYPE_BUTTON_KEY); object_class->finalize = parole_button_finalize; - - g_type_class_add_private (klass, sizeof (ParoleButtonPrivate)); } /** @@ -263,7 +258,7 @@ parole_button_class_init(ParoleButtonClass *klass) { **/ static void parole_button_init(ParoleButton *button) { - button->priv = PAROLE_BUTTON_GET_PRIVATE(button); + button->priv = parole_button_get_instance_private(button); button->priv->screen = NULL; button->priv->window = NULL; diff --git a/src/parole-conf-dialog.c b/src/parole-conf-dialog.c index ab40b54..c54dcb2 100644 --- a/src/parole-conf-dialog.c +++ b/src/parole-conf-dialog.c @@ -86,9 +86,6 @@ void reset_color_clicked_cb(GtkButton *button, * End of GtkBuilder callbacks */ -#define PAROLE_CONF_DIALOG_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_CONF_DIALOG, ParoleConfDialogPrivate)) - struct ParoleConfDialogPrivate { ParoleConf *conf; @@ -107,7 +104,7 @@ struct ParoleConfDialogPrivate { GtkWidget *saturation; }; -G_DEFINE_TYPE(ParoleConfDialog, parole_conf_dialog, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleConfDialog, parole_conf_dialog, G_TYPE_OBJECT) /* Destroy the dialog */ static void @@ -256,14 +253,12 @@ parole_conf_dialog_class_init(ParoleConfDialogClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); object_class->finalize = parole_conf_dialog_finalize; - - g_type_class_add_private (klass, sizeof (ParoleConfDialogPrivate)); } /* Initialize the dialog */ static void parole_conf_dialog_init(ParoleConfDialog *self) { - self->priv = PAROLE_CONF_DIALOG_GET_PRIVATE(self); + self->priv = parole_conf_dialog_get_instance_private(self); self->priv->conf = parole_conf_new(); self->priv->vis_plugins = parole_vis_get_plugins(); diff --git a/src/parole-disc.c b/src/parole-disc.c index 303aa78..c85a3c4 100644 --- a/src/parole-disc.c +++ b/src/parole-disc.c @@ -50,9 +50,6 @@ static void parole_disc_finalize(GObject *object); -#define PAROLE_DISC_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_DISC, ParoleDiscPrivate)) - struct ParoleDiscPrivate { GVolumeMonitor *monitor; GPtrArray *array; @@ -70,7 +67,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE(ParoleDisc, parole_disc, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleDisc, parole_disc, G_TYPE_OBJECT) typedef struct { GtkWidget *mi; @@ -484,8 +481,6 @@ parole_disc_class_init(ParoleDiscClass *klass) { G_TYPE_NONE, 1, G_TYPE_STRING); object_class->finalize = parole_disc_finalize; - - g_type_class_add_private (klass, sizeof (ParoleDiscPrivate)); } /** @@ -498,7 +493,7 @@ static void parole_disc_init(ParoleDisc *disc) { GtkBuilder *builder; - disc->priv = PAROLE_DISC_GET_PRIVATE(disc); + disc->priv = parole_disc_get_instance_private(disc); builder = parole_builder_get_main_interface(); diff --git a/src/parole-medialist.c b/src/parole-medialist.c index 9d62859..0aae3ac 100644 --- a/src/parole-medialist.c +++ b/src/parole-medialist.c @@ -157,9 +157,6 @@ gboolean parole_media_list_query_tooltip(GtkWidget *widget, * End of GtkBuilder callbacks */ -#define PAROLE_MEDIA_LIST_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_MEDIA_LIST, ParoleMediaListPrivate)) - struct ParoleMediaListPrivate { DBusGConnection *bus; ParoleConf *conf; @@ -198,7 +195,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE(ParoleMediaList, parole_media_list, GTK_TYPE_BOX) +G_DEFINE_TYPE_WITH_PRIVATE(ParoleMediaList, parole_media_list, GTK_TYPE_BOX) static void parole_media_list_set_widget_sensitive(ParoleMediaList *list, gboolean sensitive) { @@ -1366,8 +1363,6 @@ parole_media_list_class_init(ParoleMediaListClass *klass) { g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - g_type_class_add_private (klass, sizeof (ParoleMediaListPrivate)); - parole_media_list_dbus_class_init(klass); } @@ -1498,7 +1493,7 @@ parole_media_list_init(ParoleMediaList *list) { GtkWidget *box; media_list = list; - list->priv = PAROLE_MEDIA_LIST_GET_PRIVATE(list); + list->priv = parole_media_list_get_instance_private(list); list->priv->bus = parole_g_session_bus_get(); diff --git a/src/parole-player.c b/src/parole-player.c index 97e9983..29715be 100644 --- a/src/parole-player.c +++ b/src/parole-player.c @@ -332,8 +332,6 @@ static GtkTargetEntry target_entry[] = { /* * End of GtkBuilder Callbacks */ -#define PAROLE_PLAYER_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_PLAYER, ParolePlayerPrivate)) struct ParolePlayerPrivate { DBusGConnection *bus; @@ -464,7 +462,7 @@ enum { PROP_CLIENT_ID }; -G_DEFINE_TYPE(ParolePlayer, parole_player, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParolePlayer, parole_player, G_TYPE_OBJECT) void parole_show_about(GtkWidget *widget, ParolePlayer *player) { parole_about(GTK_WINDOW(player->priv->window)); @@ -2513,8 +2511,6 @@ parole_player_class_init(ParolePlayerClass *klass) { NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); - g_type_class_add_private (klass, sizeof (ParolePlayerPrivate)); - parole_player_dbus_class_init(klass); } @@ -3108,7 +3104,7 @@ parole_player_init(ParolePlayer *player) { g_setenv("PULSE_PROP_media.role", "video", TRUE); - player->priv = PAROLE_PLAYER_GET_PRIVATE(player); + player->priv = parole_player_get_instance_private(player); player->priv->client_id = NULL; player->priv->sm_client = NULL; diff --git a/src/parole-plugin-player.c b/src/parole-plugin-player.c index 953b001..33e18a7 100644 --- a/src/parole-plugin-player.c +++ b/src/parole-plugin-player.c @@ -43,9 +43,6 @@ static void parole_plugin_player_iface_init(ParoleProviderPlayerIface *iface); static void parole_plugin_player_finalize(GObject *object); -#define PAROLE_PLUGIN_PLAYER_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_PLUGIN_PLAYER, ParolePluginPlayerPrivate)) - struct ParolePluginPlayerPrivate { GtkWidget *gst; GtkWidget *box; @@ -59,7 +56,9 @@ struct ParolePluginPlayerPrivate { }; G_DEFINE_TYPE_WITH_CODE(ParolePluginPlayer, parole_plugin_player, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(PAROLE_TYPE_PROVIDER_PLAYER, parole_plugin_player_iface_init)) + G_ADD_PRIVATE(ParolePluginPlayer) + G_IMPLEMENT_INTERFACE(PAROLE_TYPE_PROVIDER_PLAYER, + parole_plugin_player_iface_init)) static void parole_plugin_player_send_message(const gchar *message) { @@ -285,14 +284,12 @@ parole_plugin_player_class_init(ParolePluginPlayerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); object_class->finalize = parole_plugin_player_finalize; - - g_type_class_add_private (klass, sizeof (ParolePluginPlayerPrivate)); } static void parole_plugin_player_init(ParolePluginPlayer *player) { GtkWidget *window; - player->priv = PAROLE_PLUGIN_PLAYER_GET_PRIVATE(player); + player->priv = parole_plugin_player_get_instance_private(player); player->priv->gst = parole_gst_get(); diff --git a/src/parole-plugins-manager.c b/src/parole-plugins-manager.c index 6122fb5..125cb5f 100644 --- a/src/parole-plugins-manager.c +++ b/src/parole-plugins-manager.c @@ -95,9 +95,6 @@ static void parole_plugins_manager_set_property(GObject *object, const GValue *value, GParamSpec *pspec); -#define PAROLE_PLUGINS_MANAGER_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE((o), PAROLE_TYPE_PLUGINS_MANAGER, ParolePluginsManagerPrivate)) - struct ParolePluginsManagerPrivate { GtkWidget *list_nt; GtkWidget *main_window; @@ -111,7 +108,7 @@ struct ParolePluginsManagerPrivate { static gpointer parole_plugins_manager_object = NULL; -G_DEFINE_TYPE(ParolePluginsManager, parole_plugins_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE(ParolePluginsManager, parole_plugins_manager, G_TYPE_OBJECT) enum { COL_ACTIVE, @@ -550,15 +547,13 @@ parole_plugins_manager_class_init(ParolePluginsManagerClass *klass) { TRUE, G_PARAM_CONSTRUCT_ONLY| G_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (ParolePluginsManagerPrivate)); } static void parole_plugins_manager_init(ParolePluginsManager *manager) { GtkBuilder *builder; - manager->priv = PAROLE_PLUGINS_MANAGER_GET_PRIVATE(manager); + manager->priv = parole_plugins_manager_get_instance_private(manager); manager->priv->array = g_ptr_array_new(); -- 2.20.1