[gdm/wip/nielsdg/add-private-deprecated: 2/20] settings: use G_DECLARE_FINAL_TYPE
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/wip/nielsdg/add-private-deprecated: 2/20] settings: use G_DECLARE_FINAL_TYPE
- Date: Sun, 23 Dec 2018 18:51:24 +0000 (UTC)
commit ffdef9716e6a169a844ff761f6537eca1360eb63
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Dec 23 11:46:17 2018 +0100
settings: use G_DECLARE_FINAL_TYPE
Note that we need to remove the signal vfunc in GdmSettingsClass, so
make sure to change the `g_signal_new("value-changed", ...)`, to cope
with that.
It also immediately gets rid of the deprecated
`g_type_class_add_private()`.
common/gdm-settings.c | 32 ++++++++++++++------------------
common/gdm-settings.h | 27 ++-------------------------
2 files changed, 16 insertions(+), 43 deletions(-)
---
diff --git a/common/gdm-settings.c b/common/gdm-settings.c
index cebbef25..e6f46ec3 100644
--- a/common/gdm-settings.c
+++ b/common/gdm-settings.c
@@ -39,11 +39,11 @@
#include "gdm-settings-desktop-backend.h"
-#define GDM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS,
GdmSettingsPrivate))
-
-struct GdmSettingsPrivate
+struct _GdmSettings
{
- GList *backends;
+ GObject parent;
+
+ GList *backends;
};
enum {
@@ -87,7 +87,7 @@ gdm_settings_get_value (GdmSettings *settings,
local_error = NULL;
- for (l = settings->priv->backends; l; l = g_list_next (l)) {
+ for (l = settings->backends; l; l = g_list_next (l)) {
GdmSettingsBackend *backend = l->data;
if (local_error) {
@@ -126,7 +126,7 @@ gdm_settings_set_value (GdmSettings *settings,
local_error = NULL;
- for (l = settings->priv->backends; l; l = g_list_next (l)) {
+ for (l = settings->backends; l; l = g_list_next (l)) {
GdmSettingsBackend *backend = l->data;
if (local_error) {
@@ -160,7 +160,7 @@ gdm_settings_class_init (GdmSettingsClass *klass)
g_signal_new ("value-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdmSettingsClass, value_changed),
+ 0,
NULL,
NULL,
g_cclosure_marshal_generic,
@@ -169,8 +169,6 @@ gdm_settings_class_init (GdmSettingsClass *klass)
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
-
- g_type_class_add_private (klass, sizeof (GdmSettingsPrivate));
}
static void
@@ -192,17 +190,15 @@ gdm_settings_init (GdmSettings *settings)
GList *l;
GdmSettingsBackend *backend;
- settings->priv = GDM_SETTINGS_GET_PRIVATE (settings);
-
backend = gdm_settings_desktop_backend_new (GDM_CUSTOM_CONF);
if (backend)
- settings->priv->backends = g_list_prepend (NULL, backend);
+ settings->backends = g_list_prepend (NULL, backend);
backend = gdm_settings_desktop_backend_new (GDM_RUNTIME_CONF);
if (backend)
- settings->priv->backends = g_list_prepend (settings->priv->backends, backend);
+ settings->backends = g_list_prepend (settings->backends, backend);
- for (l = settings->priv->backends; l; l = g_list_next (l)) {
+ for (l = settings->backends; l; l = g_list_next (l)) {
backend = l->data;
g_signal_connect (backend,
@@ -222,11 +218,11 @@ gdm_settings_finalize (GObject *object)
settings = GDM_SETTINGS (object);
- g_return_if_fail (settings->priv != NULL);
+ g_return_if_fail (settings != NULL);
- g_list_foreach (settings->priv->backends, (GFunc) g_object_unref, NULL);
- g_list_free (settings->priv->backends);
- settings->priv->backends = NULL;
+ g_list_foreach (settings->backends, (GFunc) g_object_unref, NULL);
+ g_list_free (settings->backends);
+ settings->backends = NULL;
settings_object = NULL;
diff --git a/common/gdm-settings.h b/common/gdm-settings.h
index 7ffb4aab..786868a9 100644
--- a/common/gdm-settings.h
+++ b/common/gdm-settings.h
@@ -26,30 +26,8 @@
G_BEGIN_DECLS
-#define GDM_TYPE_SETTINGS (gdm_settings_get_type ())
-#define GDM_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_SETTINGS, GdmSettings))
-#define GDM_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_SETTINGS, GdmSettingsClass))
-#define GDM_IS_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_SETTINGS))
-#define GDM_IS_SETTINGS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_SETTINGS))
-#define GDM_SETTINGS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_SETTINGS, GdmSettingsClass))
-
-typedef struct GdmSettingsPrivate GdmSettingsPrivate;
-
-typedef struct
-{
- GObject parent;
- GdmSettingsPrivate *priv;
-} GdmSettings;
-
-typedef struct
-{
- GObjectClass parent_class;
-
- void (* value_changed) (GdmSettings *settings,
- const char *key,
- const char *old_value,
- const char **new_value);
-} GdmSettingsClass;
+#define GDM_TYPE_SETTINGS (gdm_settings_get_type ())
+G_DECLARE_FINAL_TYPE (GdmSettings, gdm_settings, GDM, SETTINGS, GObject)
typedef enum
{
@@ -60,7 +38,6 @@ typedef enum
#define GDM_SETTINGS_ERROR gdm_settings_error_quark ()
GQuark gdm_settings_error_quark (void);
-GType gdm_settings_get_type (void);
GdmSettings * gdm_settings_new (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]