Commit 35049a4c authored by Ray Strode's avatar Ray Strode

Merge branch 'wip/nielsdg/add-private-deprecated' into 'master'

Get rid of most `g_type_class_add_private` occurrences (and use G_DECLARE_..._TYPE)

See merge request !55
parents 6a7c8e95 1744dcc9
Pipeline #47774 failed with stage
in 2 minutes and 9 seconds
......@@ -33,10 +33,10 @@
#include "gdm-address.h"
#include "gdm-chooser-host.h"
#define GDM_CHOOSER_HOST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_CHOOSER_HOST, GdmChooserHostPrivate))
struct GdmChooserHostPrivate
struct _GdmChooserHost
{
GObject parent;
GdmAddress *address;
char *description;
GdmChooserHostKind kind;
......@@ -62,7 +62,7 @@ gdm_chooser_host_get_address (GdmChooserHost *host)
{
g_return_val_if_fail (GDM_IS_CHOOSER_HOST (host), NULL);
return host->priv->address;
return host->address;
}
G_CONST_RETURN char *
......@@ -70,7 +70,7 @@ gdm_chooser_host_get_description (GdmChooserHost *host)
{
g_return_val_if_fail (GDM_IS_CHOOSER_HOST (host), NULL);
return host->priv->description;
return host->description;
}
GdmChooserHostKind
......@@ -78,7 +78,7 @@ gdm_chooser_host_get_kind (GdmChooserHost *host)
{
g_return_val_if_fail (GDM_IS_CHOOSER_HOST (host), 0);
return host->priv->kind;
return host->kind;
}
gboolean
......@@ -86,37 +86,37 @@ gdm_chooser_host_get_willing (GdmChooserHost *host)
{
g_return_val_if_fail (GDM_IS_CHOOSER_HOST (host), FALSE);
return host->priv->willing;
return host->willing;
}
static void
_gdm_chooser_host_set_address (GdmChooserHost *host,
GdmAddress *address)
{
if (host->priv->address != NULL) {
gdm_address_free (host->priv->address);
if (host->address != NULL) {
gdm_address_free (host->address);
}
g_assert (address != NULL);
gdm_address_debug (address);
host->priv->address = gdm_address_copy (address);
host->address = gdm_address_copy (address);
}
static void
_gdm_chooser_host_set_description (GdmChooserHost *host,
const char *description)
{
g_free (host->priv->description);
host->priv->description = g_strdup (description);
g_free (host->description);
host->description = g_strdup (description);
}
static void
_gdm_chooser_host_set_kind (GdmChooserHost *host,
int kind)
{
if (host->priv->kind != kind) {
host->priv->kind = kind;
if (host->kind != kind) {
host->kind = kind;
}
}
......@@ -124,8 +124,8 @@ static void
_gdm_chooser_host_set_willing (GdmChooserHost *host,
gboolean willing)
{
if (host->priv->willing != willing) {
host->priv->willing = willing;
if (host->willing != willing) {
host->willing = willing;
}
}
......@@ -170,16 +170,16 @@ gdm_chooser_host_get_property (GObject *object,
switch (param_id) {
case PROP_ADDRESS:
g_value_set_boxed (value, host->priv->address);
g_value_set_boxed (value, host->address);
break;
case PROP_DESCRIPTION:
g_value_set_string (value, host->priv->description);
g_value_set_string (value, host->description);
break;
case PROP_KIND:
g_value_set_int (value, host->priv->kind);
g_value_set_int (value, host->kind);
break;
case PROP_WILLING:
g_value_set_boolean (value, host->priv->willing);
g_value_set_boolean (value, host->willing);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
......@@ -228,15 +228,11 @@ gdm_chooser_host_class_init (GdmChooserHostClass *klass)
"willing",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GdmChooserHostPrivate));
}
static void
gdm_chooser_host_init (GdmChooserHost *widget)
{
widget->priv = GDM_CHOOSER_HOST_GET_PRIVATE (widget);
}
static void
......@@ -249,10 +245,8 @@ gdm_chooser_host_finalize (GObject *object)
host = GDM_CHOOSER_HOST (object);
g_return_if_fail (host->priv != NULL);
g_free (host->priv->description);
gdm_address_free (host->priv->address);
g_free (host->description);
gdm_address_free (host->address);
G_OBJECT_CLASS (gdm_chooser_host_parent_class)->finalize (object);
}
......@@ -25,12 +25,8 @@
G_BEGIN_DECLS
#define GDM_TYPE_CHOOSER_HOST (gdm_chooser_host_get_type ())
#define GDM_CHOOSER_HOST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_CHOOSER_HOST, GdmChooserHost))
#define GDM_CHOOSER_HOST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_CHOOSER_HOST, GdmChooserHostClass))
#define GDM_IS_CHOOSER_HOST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_CHOOSER_HOST))
#define GDM_IS_CHOOSER_HOST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_CHOOSER_HOST))
#define GDM_CHOOSER_HOST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_CHOOSER_HOST, GdmChooserHostClass))
#define GDM_TYPE_CHOOSER_HOST (gdm_chooser_host_get_type ())
G_DECLARE_FINAL_TYPE (GdmChooserHost, gdm_chooser_host, GDM, CHOOSER_HOST, GObject)
typedef enum {
GDM_CHOOSER_HOST_KIND_XDMCP = 1 << 0,
......@@ -38,21 +34,6 @@ typedef enum {
#define GDM_CHOOSER_HOST_KIND_MASK_ALL (GDM_CHOOSER_HOST_KIND_XDMCP)
typedef struct GdmChooserHostPrivate GdmChooserHostPrivate;
typedef struct
{
GObject parent;
GdmChooserHostPrivate *priv;
} GdmChooserHost;
typedef struct
{
GObjectClass parent_class;
} GdmChooserHostClass;
GType gdm_chooser_host_get_type (void) G_GNUC_CONST;
G_CONST_RETURN char *gdm_chooser_host_get_description (GdmChooserHost *chooser_host);
GdmAddress * gdm_chooser_host_get_address (GdmChooserHost *chooser_host);
gboolean gdm_chooser_host_get_willing (GdmChooserHost *chooser_host);
......
......@@ -34,10 +34,10 @@
#include "gdm-host-chooser-dialog.h"
#define GDM_CHOOSER_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_CHOOSER_SESSION, GdmChooserSessionPrivate))
struct GdmChooserSessionPrivate
struct _GdmChooserSession
{
GObject parent;
GdmClient *client;
GdmRemoteGreeter *remote_greeter;
GdmChooser *chooser;
......@@ -175,7 +175,7 @@ on_dialog_response (GtkDialog *dialog,
/* FIXME: fall back to numerical address? */
if (hostname != NULL) {
g_debug ("GdmChooserSession: Selected hostname '%s'", hostname);
gdm_chooser_call_select_hostname_sync (session->priv->chooser,
gdm_chooser_call_select_hostname_sync (session->chooser,
hostname,
NULL,
&error);
......@@ -188,7 +188,7 @@ on_dialog_response (GtkDialog *dialog,
}
}
gdm_remote_greeter_call_disconnect_sync (session->priv->remote_greeter,
gdm_remote_greeter_call_disconnect_sync (session->remote_greeter,
NULL,
&error);
if (error != NULL) {
......@@ -202,17 +202,17 @@ gdm_chooser_session_start (GdmChooserSession *session,
{
g_return_val_if_fail (GDM_IS_CHOOSER_SESSION (session), FALSE);
session->priv->remote_greeter = gdm_client_get_remote_greeter_sync (session->priv->client,
session->remote_greeter = gdm_client_get_remote_greeter_sync (session->client,
NULL,
error);
if (session->priv->remote_greeter == NULL) {
if (session->remote_greeter == NULL) {
return FALSE;
}
session->priv->chooser = gdm_client_get_chooser_sync (session->priv->client,
session->chooser = gdm_client_get_chooser_sync (session->client,
NULL,
error);
if (session->priv->chooser == NULL) {
if (session->chooser == NULL) {
return FALSE;
}
......@@ -220,12 +220,12 @@ gdm_chooser_session_start (GdmChooserSession *session,
start_window_manager (session);
/* Only support XDMCP on remote choosers */
session->priv->chooser_dialog = gdm_host_chooser_dialog_new (GDM_CHOOSER_HOST_KIND_XDMCP);
g_signal_connect (session->priv->chooser_dialog,
session->chooser_dialog = gdm_host_chooser_dialog_new (GDM_CHOOSER_HOST_KIND_XDMCP);
g_signal_connect (session->chooser_dialog,
"response",
G_CALLBACK (on_dialog_response),
session);
gtk_widget_show (session->priv->chooser_dialog);
gtk_widget_show (session->chooser_dialog);
return TRUE;
}
......@@ -295,17 +295,12 @@ gdm_chooser_session_class_init (GdmChooserSessionClass *klass)
object_class->constructor = gdm_chooser_session_constructor;
object_class->dispose = gdm_chooser_session_dispose;
object_class->finalize = gdm_chooser_session_finalize;
g_type_class_add_private (klass, sizeof (GdmChooserSessionPrivate));
}
static void
gdm_chooser_session_init (GdmChooserSession *session)
{
session->priv = GDM_CHOOSER_SESSION_GET_PRIVATE (session);
session->priv->client = gdm_client_new ();
session->client = gdm_client_new ();
}
static void
......@@ -318,11 +313,11 @@ gdm_chooser_session_finalize (GObject *object)
chooser_session = GDM_CHOOSER_SESSION (object);
g_return_if_fail (chooser_session->priv != NULL);
g_return_if_fail (chooser_session != NULL);
g_clear_object (&chooser_session->priv->chooser);
g_clear_object (&chooser_session->priv->remote_greeter);
g_clear_object (&chooser_session->priv->client);
g_clear_object (&chooser_session->chooser);
g_clear_object (&chooser_session->remote_greeter);
g_clear_object (&chooser_session->client);
G_OBJECT_CLASS (gdm_chooser_session_parent_class)->finalize (object);
}
......
......@@ -25,27 +25,8 @@
G_BEGIN_DECLS
#define GDM_TYPE_CHOOSER_SESSION (gdm_chooser_session_get_type ())
#define GDM_CHOOSER_SESSION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_CHOOSER_SESSION, GdmChooserSession))
#define GDM_CHOOSER_SESSION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_CHOOSER_SESSION, GdmChooserSessionClass))
#define GDM_IS_CHOOSER_SESSION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_CHOOSER_SESSION))
#define GDM_IS_CHOOSER_SESSION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_CHOOSER_SESSION))
#define GDM_CHOOSER_SESSION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_CHOOSER_SESSION, GdmChooserSessionClass))
typedef struct GdmChooserSessionPrivate GdmChooserSessionPrivate;
typedef struct
{
GObject parent;
GdmChooserSessionPrivate *priv;
} GdmChooserSession;
typedef struct
{
GObjectClass parent_class;
} GdmChooserSessionClass;
GType gdm_chooser_session_get_type (void);
#define GDM_TYPE_CHOOSER_SESSION (gdm_chooser_session_get_type ())
G_DECLARE_FINAL_TYPE (GdmChooserSession, gdm_chooser_session, GDM, CHOOSER_SESSION, GObject)
GdmChooserSession * gdm_chooser_session_new (void);
......
......@@ -33,10 +33,10 @@
#include "gdm-host-chooser-dialog.h"
#include "gdm-host-chooser-widget.h"
#define GDM_HOST_CHOOSER_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_HOST_CHOOSER_DIALOG, GdmHostChooserDialogPrivate))
struct GdmHostChooserDialogPrivate
struct _GdmHostChooserDialog
{
GtkDialog parent;
GtkWidget *chooser_widget;
int kind_mask;
};
......@@ -48,7 +48,6 @@ enum {
static void gdm_host_chooser_dialog_class_init (GdmHostChooserDialogClass *klass);
static void gdm_host_chooser_dialog_init (GdmHostChooserDialog *host_chooser_dialog);
static void gdm_host_chooser_dialog_finalize (GObject *object);
G_DEFINE_TYPE (GdmHostChooserDialog, gdm_host_chooser_dialog, GTK_TYPE_DIALOG)
......@@ -59,7 +58,7 @@ gdm_host_chooser_dialog_get_host (GdmHostChooserDialog *dialog)
g_return_val_if_fail (GDM_IS_HOST_CHOOSER_DIALOG (dialog), NULL);
host = gdm_host_chooser_widget_get_host (GDM_HOST_CHOOSER_WIDGET (dialog->priv->chooser_widget));
host = gdm_host_chooser_widget_get_host (GDM_HOST_CHOOSER_WIDGET (dialog->chooser_widget));
return host;
}
......@@ -68,8 +67,8 @@ static void
_gdm_host_chooser_dialog_set_kind_mask (GdmHostChooserDialog *dialog,
int kind_mask)
{
if (dialog->priv->kind_mask != kind_mask) {
dialog->priv->kind_mask = kind_mask;
if (dialog->kind_mask != kind_mask) {
dialog->kind_mask = kind_mask;
}
}
......@@ -112,7 +111,7 @@ on_response (GdmHostChooserDialog *dialog,
{
switch (response_id) {
case GTK_RESPONSE_APPLY:
gdm_host_chooser_widget_refresh (GDM_HOST_CHOOSER_WIDGET (dialog->priv->chooser_widget));
gdm_host_chooser_widget_refresh (GDM_HOST_CHOOSER_WIDGET (dialog->chooser_widget));
g_signal_stop_emission_by_name (dialog, "response");
break;
default:
......@@ -132,9 +131,9 @@ gdm_host_chooser_dialog_constructor (GType type,
construct_properties));
dialog->priv->chooser_widget = gdm_host_chooser_widget_new (dialog->priv->kind_mask);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), dialog->priv->chooser_widget, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (dialog->priv->chooser_widget), 5);
dialog->chooser_widget = gdm_host_chooser_widget_new (dialog->kind_mask);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), dialog->chooser_widget, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (dialog->chooser_widget), 5);
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
_("_Refresh"), GTK_RESPONSE_APPLY,
......@@ -174,7 +173,6 @@ gdm_host_chooser_dialog_class_init (GdmHostChooserDialogClass *klass)
object_class->set_property = gdm_host_chooser_dialog_set_property;
object_class->constructor = gdm_host_chooser_dialog_constructor;
object_class->dispose = gdm_host_chooser_dialog_dispose;
object_class->finalize = gdm_host_chooser_dialog_finalize;
g_object_class_install_property (object_class,
PROP_KIND_MASK,
......@@ -185,29 +183,11 @@ gdm_host_chooser_dialog_class_init (GdmHostChooserDialogClass *klass)
G_MAXINT,
0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GdmHostChooserDialogPrivate));
}
static void
gdm_host_chooser_dialog_init (GdmHostChooserDialog *dialog)
{
dialog->priv = GDM_HOST_CHOOSER_DIALOG_GET_PRIVATE (dialog);
}
static void
gdm_host_chooser_dialog_finalize (GObject *object)
{
GdmHostChooserDialog *host_chooser_dialog;
g_return_if_fail (object != NULL);
g_return_if_fail (GDM_IS_HOST_CHOOSER_DIALOG (object));
host_chooser_dialog = GDM_HOST_CHOOSER_DIALOG (object);
g_return_if_fail (host_chooser_dialog->priv != NULL);
G_OBJECT_CLASS (gdm_host_chooser_dialog_parent_class)->finalize (object);
}
GtkWidget *
......
......@@ -28,26 +28,7 @@
G_BEGIN_DECLS
#define GDM_TYPE_HOST_CHOOSER_DIALOG (gdm_host_chooser_dialog_get_type ())
#define GDM_HOST_CHOOSER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_HOST_CHOOSER_DIALOG, GdmHostChooserDialog))
#define GDM_HOST_CHOOSER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_HOST_CHOOSER_DIALOG, GdmHostChooserDialogClass))
#define GDM_IS_HOST_CHOOSER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_HOST_CHOOSER_DIALOG))
#define GDM_IS_HOST_CHOOSER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_HOST_CHOOSER_DIALOG))
#define GDM_HOST_CHOOSER_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_HOST_CHOOSER_DIALOG, GdmHostChooserDialogClass))
typedef struct GdmHostChooserDialogPrivate GdmHostChooserDialogPrivate;
typedef struct
{
GtkDialog parent;
GdmHostChooserDialogPrivate *priv;
} GdmHostChooserDialog;
typedef struct
{
GtkDialogClass parent_class;
} GdmHostChooserDialogClass;
GType gdm_host_chooser_dialog_get_type (void);
G_DECLARE_FINAL_TYPE (GdmHostChooserDialog, gdm_host_chooser_dialog, GDM, HOST_CHOOSER_DIALOG, GtkDialog)
GtkWidget * gdm_host_chooser_dialog_new (int kind_mask);
void gdm_host_chooser_dialog_set_kind_mask (GdmHostChooserDialog *dialog,
......
This diff is collapsed.
......@@ -27,30 +27,9 @@
G_BEGIN_DECLS
#define GDM_TYPE_HOST_CHOOSER_WIDGET (gdm_host_chooser_widget_get_type ())
#define GDM_HOST_CHOOSER_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_HOST_CHOOSER_WIDGET, GdmHostChooserWidget))
#define GDM_HOST_CHOOSER_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_HOST_CHOOSER_WIDGET, GdmHostChooserWidgetClass))
#define GDM_IS_HOST_CHOOSER_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_HOST_CHOOSER_WIDGET))
#define GDM_IS_HOST_CHOOSER_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_HOST_CHOOSER_WIDGET))
#define GDM_HOST_CHOOSER_WIDGET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_HOST_CHOOSER_WIDGET, GdmHostChooserWidgetClass))
#define GDM_TYPE_HOST_CHOOSER_WIDGET (gdm_host_chooser_widget_get_type ())
G_DECLARE_FINAL_TYPE (GdmHostChooserWidget, gdm_host_chooser_widget, GDM, HOST_CHOOSER_WIDGET, GtkBox)
typedef struct GdmHostChooserWidgetPrivate GdmHostChooserWidgetPrivate;
typedef struct
{
GtkVBox parent;
GdmHostChooserWidgetPrivate *priv;
} GdmHostChooserWidget;
typedef struct
{
GtkVBoxClass parent_class;
/* signals */
void (* host_activated) (GdmHostChooserWidget *widget);
} GdmHostChooserWidgetClass;
GType gdm_host_chooser_widget_get_type (void);
GtkWidget * gdm_host_chooser_widget_new (int kind_mask);
void gdm_host_chooser_widget_set_kind_mask (GdmHostChooserWidget *widget,
......
......@@ -35,13 +35,6 @@
#include "gdm-settings-backend.h"
#define GDM_SETTINGS_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS_BACKEND, GdmSettingsBackendPrivate))
struct GdmSettingsBackendPrivate
{
gpointer dummy;
};
enum {
VALUE_CHANGED,
LAST_SIGNAL
......@@ -156,27 +149,17 @@ gdm_settings_backend_class_init (GdmSettingsBackendClass *klass)
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (GdmSettingsBackendPrivate));
}
static void
gdm_settings_backend_init (GdmSettingsBackend *settings_backend)
{
settings_backend->priv = GDM_SETTINGS_BACKEND_GET_PRIVATE (settings_backend);
}
static void
gdm_settings_backend_finalize (GObject *object)
{
GdmSettingsBackend *settings_backend;
g_return_if_fail (object != NULL);
g_return_if_fail (GDM_IS_SETTINGS_BACKEND (object));
settings_backend = GDM_SETTINGS_BACKEND (object);
g_return_if_fail (settings_backend->priv != NULL);
G_OBJECT_CLASS (gdm_settings_backend_parent_class)->finalize (object);
}
......@@ -26,22 +26,10 @@
G_BEGIN_DECLS
#define GDM_TYPE_SETTINGS_BACKEND (gdm_settings_backend_get_type ())
#define GDM_SETTINGS_BACKEND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_SETTINGS_BACKEND, GdmSettingsBackend))
#define GDM_SETTINGS_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_SETTINGS_BACKEND, GdmSettingsBackendClass))
#define GDM_IS_SETTINGS_BACKEND(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_SETTINGS_BACKEND))
#define GDM_IS_SETTINGS_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_SETTINGS_BACKEND))
#define GDM_SETTINGS_BACKEND_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_SETTINGS_BACKEND, GdmSettingsBackendClass))
#define GDM_TYPE_SETTINGS_BACKEND (gdm_settings_backend_get_type ())
G_DECLARE_DERIVABLE_TYPE (GdmSettingsBackend, gdm_settings_backend, GDM, SETTINGS_BACKEND, GObject)
typedef struct GdmSettingsBackendPrivate GdmSettingsBackendPrivate;
typedef struct
{
GObject parent;
GdmSettingsBackendPrivate *priv;
} GdmSettingsBackend;
typedef struct
struct _GdmSettingsBackendClass
{
GObjectClass parent_class;
......@@ -60,7 +48,7 @@ typedef struct
const char *key,
const char *old_value,
const char **new_value);
} GdmSettingsBackendClass;
};
typedef enum
{
......@@ -71,7 +59,6 @@ typedef enum
#define GDM_SETTINGS_BACKEND_ERROR gdm_settings_backend_error_quark ()
GQuark gdm_settings_backend_error_quark (void);
GType gdm_settings_backend_get_type (void);
gboolean gdm_settings_backend_get_value (GdmSettingsBackend *settings_backend,
const char *key,
......
......@@ -36,10 +36,10 @@
#include "gdm-settings-desktop-backend.h"
#define GDM_SETTINGS_DESKTOP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SETTINGS_DESKTOP_BACKEND, GdmSettingsDesktopBackendPrivate))
struct GdmSettingsDesktopBackendPrivate
struct _GdmSettingsDesktopBackend
{
GdmSettingsBackend parent;
char *filename;
GKeyFile *key_file;
gboolean dirty;
......@@ -65,26 +65,24 @@ _gdm_settings_desktop_backend_set_file_name (GdmSettingsDesktopBackend *backend,
GError *error;
char *contents;
backend->priv = GDM_SETTINGS_DESKTOP_BACKEND_GET_PRIVATE (backend);
g_free (backend->priv->filename);
backend->priv->filename = g_strdup (filename);
g_free (backend->filename);
backend->filename = g_strdup (filename);
backend->priv->key_file = g_key_file_new ();
backend->key_file = g_key_file_new ();
error = NULL;
res = g_key_file_load_from_file (backend->priv->key_file,
backend->priv->filename,
res = g_key_file_load_from_file (backend->key_file,
backend->filename,
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
&error);
if (! res) {
g_warning ("Unable to load file '%s': %s", backend->priv->filename, error->message);
g_warning ("Unable to load file '%s': %s", backend->filename, error->message);
}
contents = g_key_file_to_data (backend->priv->key_file, NULL, NULL);
contents = g_key_file_to_data (backend->key_file, NULL, NULL);
if (contents != NULL) {
g_debug ("GdmSettings: %s is:\n%s\n", backend->priv->filename, contents);
g_debug ("GdmSettings: %s is:\n%s\n", backend->filename, contents);
g_free (contents);
}
......@@ -122,7 +120,7 @@ gdm_settings_desktop_backend_get_property (GObject *object,
switch (prop_id) {
case PROP_FILENAME:
g_value_set_string (value, self->priv->filename);
g_value_set_string (value, self->filename);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -249,7 +247,7 @@ gdm_settings_desktop_backend_get_value (GdmSettingsBackend *backend,
/*g_debug ("Getting key: %s %s %s", g, k, l);*/
local_error = NULL;
val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->key_file,
g,
k,
&local_error);
......@@ -279,14 +277,14 @@ save_settings (GdmSettingsDesktopBackend *backend)
char *contents;
gsize length;
if (! backend->priv->dirty) {
if (! backend->dirty) {
return;
}
g_debug ("Saving settings to %s", backend->priv->filename);
g_debug ("Saving settings to %s", backend->filename);
local_error = NULL;
contents = g_key_file_to_data (backend->priv->key_file, &length, &local_error);
contents = g_key_file_to_data (backend->key_file, &length, &local_error);
if (local_error != NULL) {
g_warning ("Unable to save settings: %s", local_error->message);
g_error_free (local_error);
......@@ -294,7 +292,7 @@ save_settings (GdmSettingsDesktopBackend *backend)
}
local_error = NULL;
g_file_set_contents (backend->priv->filename,
g_file_set_contents (backend->filename,
contents,
length,
&local_error);
......@@ -307,30 +305,30 @@ save_settings (GdmSettingsDesktopBackend *backend)
g_free (contents);
backend->priv->dirty = FALSE;
backend->dirty = FALSE;
}
static gboolean
save_settings_timer (GdmSettingsDesktopBackend *backend)
{
save_settings (backend);
backend->priv->save_id = 0;
backend->save_id = 0;
return FALSE;
}
static void
queue_save (GdmSettingsDesktopBackend *backend)
{
if (! backend->priv->dirty) {
if (! backend->dirty) {
return;
}
if (backend->priv->save_id != 0) {
if (backend->save_id != 0) {
/* already pending */
return;
}
backend->priv->save_id = g_timeout_add_seconds (5, (GSourceFunc)save_settings_timer, backend);
backend->save_id = g_timeout_add_seconds (5, (GSourceFunc)save_settings_timer, backend);
}
static gboolean
......@@ -355,7 +353,7 @@ gdm_settings_desktop_backend_set_value (GdmSettingsBackend *backend,
}
local_error = NULL;
old_val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
old_val = g_key_file_get_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->key_file,
g,
k,
&local_error);
......@@ -365,12 +363,12 @@ gdm_settings_desktop_backend_set_value (GdmSettingsBackend *backend,
/*g_debug ("Setting key: %s %s %s", g, k, l);*/
local_error = NULL;
g_key_file_set_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->key_file,
g_key_file_set_value (GDM_SETTINGS_DESKTOP_BACKEND (backend)->key_file,
g,
k,
value);
GDM_SETTINGS_DESKTOP_BACKEND (backend)->priv->dirty = TRUE;
GDM_SETTINGS_DESKTOP_BACKEND (backend)->dirty = TRUE;
queue_save (GDM_SETTINGS_DESKTOP_BACKEND (backend));
gdm_settings_backend_value_changed (backend, key, old_val, value);
......@@ -393,8 +391,6 @@ gdm_settings_desktop_backend_class_init (GdmSettingsDesktopBackendClass *klass)
backend_class->get_value = gdm_settings_desktop_backend_get_value;
backend_class->set_value = gdm_settings_desktop_backend_set_value;
g_type_class_add_private (klass, sizeof (GdmSettingsDesktopBackendPrivate));
g_object_class_install_property (object_class,