[totem/wip/hadess/totem-object-cleanups] main: Simplify TotemObjectClass declaration




commit f1da2e45aa85178d08fbda9a22c44e3b60a8b84f
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Apr 7 14:29:53 2022 +0200

    main: Simplify TotemObjectClass declaration

 src/totem-object.c | 18 ++++++------------
 src/totem.h        | 30 +++---------------------------
 2 files changed, 9 insertions(+), 39 deletions(-)
---
diff --git a/src/totem-object.c b/src/totem-object.c
index 02fe7a709..071968212 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -461,8 +461,7 @@ totem_object_class_init (TotemObjectClass *klass)
                g_signal_new ("file-opened",
                                G_TYPE_FROM_CLASS (object_class),
                                G_SIGNAL_RUN_LAST,
-                               G_STRUCT_OFFSET (TotemObjectClass, file_opened),
-                               NULL, NULL,
+                               0, NULL, NULL,
                                g_cclosure_marshal_VOID__STRING,
                                G_TYPE_NONE, 1, G_TYPE_STRING);
 
@@ -477,8 +476,7 @@ totem_object_class_init (TotemObjectClass *klass)
                g_signal_new ("file-has-played",
                                G_TYPE_FROM_CLASS (object_class),
                                G_SIGNAL_RUN_LAST,
-                               G_STRUCT_OFFSET (TotemObjectClass, file_has_played),
-                               NULL, NULL,
+                               0, NULL, NULL,
                                g_cclosure_marshal_VOID__STRING,
                                G_TYPE_NONE, 1, G_TYPE_STRING);
 
@@ -492,8 +490,7 @@ totem_object_class_init (TotemObjectClass *klass)
                g_signal_new ("file-closed",
                                G_TYPE_FROM_CLASS (object_class),
                                G_SIGNAL_RUN_LAST,
-                               G_STRUCT_OFFSET (TotemObjectClass, file_closed),
-                               NULL, NULL,
+                               0, NULL, NULL,
                                g_cclosure_marshal_VOID__VOID,
                                G_TYPE_NONE, 0, G_TYPE_NONE);
 
@@ -512,8 +509,7 @@ totem_object_class_init (TotemObjectClass *klass)
                g_signal_new ("metadata-updated",
                                G_TYPE_FROM_CLASS (object_class),
                                G_SIGNAL_RUN_LAST,
-                               G_STRUCT_OFFSET (TotemObjectClass, metadata_updated),
-                               NULL, NULL,
+                               0, NULL, NULL,
                                g_cclosure_marshal_generic,
                                G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
 
@@ -531,8 +527,7 @@ totem_object_class_init (TotemObjectClass *klass)
                g_signal_new ("get-user-agent",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (TotemObjectClass, get_user_agent),
-                             accumulator_first_non_null_wins, NULL,
+                             0, accumulator_first_non_null_wins, NULL,
                              g_cclosure_marshal_generic,
                              G_TYPE_STRING, 1, G_TYPE_STRING);
 
@@ -550,8 +545,7 @@ totem_object_class_init (TotemObjectClass *klass)
                g_signal_new ("get-text-subtitle",
                              G_TYPE_FROM_CLASS (object_class),
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (TotemObjectClass, get_text_subtitle),
-                             accumulator_first_non_null_wins, NULL,
+                             0, accumulator_first_non_null_wins, NULL,
                              g_cclosure_marshal_generic,
                              G_TYPE_STRING, 1, G_TYPE_STRING);
 
diff --git a/src/totem.h b/src/totem.h
index ec0cd9edc..0f95a32f4 100644
--- a/src/totem.h
+++ b/src/totem.h
@@ -121,44 +121,20 @@ GQuark totem_remote_setting_quark (void);
 #define TOTEM_TYPE_REMOTE_SETTING      (totem_remote_setting_get_type())
 #define TOTEM_REMOTE_SETTING           totem_remote_setting_quark ()
 
-#define TOTEM_TYPE_OBJECT              (totem_object_get_type ())
-#define TOTEM_OBJECT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), totem_object_get_type (), 
TotemObject))
-#define TOTEM_OBJECT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), totem_object_get_type (), 
TotemObjectClass))
-#define TOTEM_IS_OBJECT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE (obj, totem_object_get_type ()))
-#define TOTEM_IS_OBJECT_CLASS(klass)   (G_CHECK_INSTANCE_GET_CLASS ((klass), totem_object_get_type ()))
-
 /**
  * Totem:
  *
  * The #Totem object is a handy synonym for #TotemObject, and the two can be used interchangably.
  **/
+typedef struct _TotemObject Totem;
 
 /**
  * TotemObject:
  *
  * All the fields in the #TotemObject structure are private and should never be accessed directly.
  **/
-typedef struct _TotemObject Totem;
-typedef struct _TotemObject TotemObject;
-
-typedef struct {
-       GtkApplicationClass parent_class;
-
-       void (*file_opened)                     (TotemObject *totem, const char *mrl);
-       void (*file_closed)                     (TotemObject *totem);
-       void (*file_has_played)                 (TotemObject *totem, const char *mrl);
-       void (*metadata_updated)                (TotemObject *totem,
-                                                const char *artist,
-                                                const char *title,
-                                                const char *album,
-                                                guint track_num);
-       char * (*get_user_agent)                (TotemObject *totem,
-                                                const char  *mrl);
-       char * (*get_text_subtitle)             (TotemObject *totem,
-                                                const char  *mrl);
-} TotemObjectClass;
-
-GType  totem_object_get_type                   (void);
+#define TOTEM_TYPE_OBJECT              (totem_object_get_type ())
+G_DECLARE_FINAL_TYPE(TotemObject, totem_object, TOTEM, OBJECT, GtkApplication)
 
 void   totem_object_exit                       (TotemObject *totem) G_GNUC_NORETURN;
 void   totem_object_play                       (TotemObject *totem);


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