diff options
author | Alessandro Bono <alessandro.bono369@gmail.com> | 2022-08-30 16:51:50 +0200 |
---|---|---|
committer | Ray Strode <halfline@gmail.com> | 2022-09-27 16:57:29 +0000 |
commit | efacc03c0fb30fd2a6caf07f86b98b5594624ffd (patch) | |
tree | 6c6745ac5918dd7fa450a1d18ab17c188dba6329 | |
parent | 771593305c6612c7274aa116efb12e227dd591a3 (diff) | |
download | gdm-efacc03c0fb30fd2a6caf07f86b98b5594624ffd.tar.gz |
gdm-display-store: Use G_DECLARE_FINAL_TYPE
-rw-r--r-- | daemon/gdm-display-store.c | 38 | ||||
-rw-r--r-- | daemon/gdm-display-store.h | 27 |
2 files changed, 19 insertions, 46 deletions
diff --git a/daemon/gdm-display-store.c b/daemon/gdm-display-store.c index 7df69d9b..587e9795 100644 --- a/daemon/gdm-display-store.c +++ b/daemon/gdm-display-store.c @@ -33,8 +33,9 @@ #include "gdm-display-store.h" #include "gdm-display.h" -struct GdmDisplayStorePrivate +struct _GdmDisplayStore { + GObject parent; GHashTable *displays; }; @@ -56,7 +57,7 @@ static void gdm_display_store_class_init (GdmDisplayStoreClass *klass); static void gdm_display_store_init (GdmDisplayStore *display_store); static void gdm_display_store_finalize (GObject *object); -G_DEFINE_TYPE_WITH_PRIVATE (GdmDisplayStore, gdm_display_store, G_TYPE_OBJECT) +G_DEFINE_TYPE (GdmDisplayStore, gdm_display_store, G_TYPE_OBJECT) static StoredDisplay * stored_display_new (GdmDisplayStore *store, @@ -102,7 +103,7 @@ gdm_display_store_clear (GdmDisplayStore *store) { g_return_if_fail (store != NULL); g_debug ("GdmDisplayStore: Clearing display store"); - g_hash_table_remove_all (store->priv->displays); + g_hash_table_remove_all (store->displays); } static gboolean @@ -167,7 +168,7 @@ gdm_display_store_foreach (GdmDisplayStore *store, closure.predicate = func; closure.user_data = user_data; - g_hash_table_foreach (store->priv->displays, + g_hash_table_foreach (store->displays, (GHFunc) foreach_func, &closure); } @@ -181,7 +182,7 @@ gdm_display_store_lookup (GdmDisplayStore *store, g_return_val_if_fail (store != NULL, NULL); g_return_val_if_fail (id != NULL, NULL); - stored_display = g_hash_table_lookup (store->priv->displays, + stored_display = g_hash_table_lookup (store->displays, id); if (stored_display == NULL) { return NULL; @@ -204,7 +205,7 @@ gdm_display_store_find (GdmDisplayStore *store, closure.predicate = predicate; closure.user_data = user_data; - stored_display = g_hash_table_find (store->priv->displays, + stored_display = g_hash_table_find (store->displays, (GHRFunc) find_func, &closure); @@ -229,7 +230,7 @@ gdm_display_store_foreach_remove (GdmDisplayStore *store, closure.predicate = func; closure.user_data = user_data; - ret = g_hash_table_foreach_remove (store->priv->displays, + ret = g_hash_table_foreach_remove (store->displays, (GHRFunc) find_func, &closure); return ret; @@ -250,7 +251,7 @@ gdm_display_store_add (GdmDisplayStore *store, g_debug ("GdmDisplayStore: Adding display %s to store", id); stored_display = stored_display_new (store, display); - g_hash_table_insert (store->priv->displays, + g_hash_table_insert (store->displays, id, stored_display); @@ -271,7 +272,7 @@ gdm_display_store_class_init (GdmDisplayStoreClass *klass) g_signal_new ("display-added", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdmDisplayStoreClass, display_added), + 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, @@ -281,7 +282,7 @@ gdm_display_store_class_init (GdmDisplayStoreClass *klass) g_signal_new ("display-removed", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdmDisplayStoreClass, display_removed), + 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, @@ -292,14 +293,11 @@ gdm_display_store_class_init (GdmDisplayStoreClass *klass) static void gdm_display_store_init (GdmDisplayStore *store) { - - store->priv = gdm_display_store_get_instance_private (store); - - store->priv->displays = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - (GDestroyNotify) - stored_display_free); + store->displays = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + (GDestroyNotify) + stored_display_free); } static void @@ -312,9 +310,7 @@ gdm_display_store_finalize (GObject *object) store = GDM_DISPLAY_STORE (object); - g_return_if_fail (store->priv != NULL); - - g_hash_table_destroy (store->priv->displays); + g_hash_table_destroy (store->displays); G_OBJECT_CLASS (gdm_display_store_parent_class)->finalize (object); } diff --git a/daemon/gdm-display-store.h b/daemon/gdm-display-store.h index 0aff8ee2..8cb13500 100644 --- a/daemon/gdm-display-store.h +++ b/daemon/gdm-display-store.h @@ -27,30 +27,8 @@ G_BEGIN_DECLS -#define GDM_TYPE_DISPLAY_STORE (gdm_display_store_get_type ()) -#define GDM_DISPLAY_STORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_DISPLAY_STORE, GdmDisplayStore)) -#define GDM_DISPLAY_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_DISPLAY_STORE, GdmDisplayStoreClass)) -#define GDM_IS_DISPLAY_STORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_DISPLAY_STORE)) -#define GDM_IS_DISPLAY_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_DISPLAY_STORE)) -#define GDM_DISPLAY_STORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_DISPLAY_STORE, GdmDisplayStoreClass)) - -typedef struct GdmDisplayStorePrivate GdmDisplayStorePrivate; - -typedef struct -{ - GObject parent; - GdmDisplayStorePrivate *priv; -} GdmDisplayStore; - -typedef struct -{ - GObjectClass parent_class; - - void (* display_added) (GdmDisplayStore *display_store, - const char *id); - void (* display_removed) (GdmDisplayStore *display_store, - GdmDisplay *display); -} GdmDisplayStoreClass; +#define GDM_TYPE_DISPLAY_STORE (gdm_display_store_get_type ()) +G_DECLARE_FINAL_TYPE (GdmDisplayStore, gdm_display_store, GDM, DISPLAY_STORE, GObject) typedef enum { @@ -64,7 +42,6 @@ typedef gboolean (*GdmDisplayStoreFunc) (const char *id, gpointer user_data); GQuark gdm_display_store_error_quark (void); -GType gdm_display_store_get_type (void); GdmDisplayStore * gdm_display_store_new (void); |