diff options
author | Wu Xiaotian <[email protected]> | 2018-11-19 14:12:59 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-11-26 13:02:53 +0100 |
commit | 6b7875b9714d5872f80b6b4012f24fb8f548aca2 (patch) | |
tree | bf3ba2f47a359ecad1281604cb869fbfe1200a05 /mate-session | |
parent | bdec713320b7487c429bd4415fdde55cf48cb44b (diff) | |
download | mate-session-manager-6b7875b9714d5872f80b6b4012f24fb8f548aca2.tar.bz2 mate-session-manager-6b7875b9714d5872f80b6b4012f24fb8f548aca2.tar.xz |
Avoid compile warning for g_type_class_add_private
- capplet/gsm-app-dialog.c
- capplet/gsm-app-dialog.h
- capplet/gsm-properties-dialog.c
- capplet/gsm-properties-dialog.h
- capplet/gsp-app-manager.c
- capplet/gsp-app-manager.h
- capplet/gsp-app.c
- capplet/gsp-app.h
- mate-session/gsm-app.c
- mate-session/gsm-app.h
- mate-session/gsm-autostart-app.c
- mate-session/gsm-autostart-app.h
- mate-session/gsm-client.c
- mate-session/gsm-client.h
- mate-session/gsm-consolekit.c
- mate-session/gsm-consolekit.h
- mate-session/gsm-dbus-client.c
- mate-session/gsm-dbus-client.h
- mate-session/gsm-inhibit-dialog.c
- mate-session/gsm-inhibit-dialog.h
- mate-session/gsm-inhibitor.c
- mate-session/gsm-inhibitor.h
- mate-session/gsm-logout-dialog.c
- mate-session/gsm-logout-dialog.h
- mate-session/gsm-store.c
- mate-session/gsm-store.h
- mate-session/gsm-systemd.c
- mate-session/gsm-systemd.h
- mate-session/gsm-xsmp-client.c
- mate-session/gsm-xsmp-client.h
- mate-session/gsm-xsmp-server.c
- mate-session/gsm-xsmp-server.h
Diffstat (limited to 'mate-session')
24 files changed, 1031 insertions, 1053 deletions
diff --git a/mate-session/gsm-app.c b/mate-session/gsm-app.c index 55c2911..7d693b8 100644 --- a/mate-session/gsm-app.c +++ b/mate-session/gsm-app.c @@ -29,17 +29,13 @@ #include "gsm-app.h" #include "gsm-app-glue.h" -#define GSM_APP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_APP, GsmAppPrivate)) - -struct _GsmAppPrivate -{ +typedef struct { char *id; char *app_id; int phase; char *startup_id; DBusGConnection *connection; -}; - +} GsmAppPrivate; enum { EXITED, @@ -60,7 +56,7 @@ enum { LAST_PROP }; -G_DEFINE_TYPE (GsmApp, gsm_app, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GsmApp, gsm_app, G_TYPE_OBJECT) GQuark gsm_app_error_quark (void) @@ -92,10 +88,13 @@ static gboolean register_app (GsmApp *app) { GError *error; + GsmAppPrivate *priv; error = NULL; - app->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (app->priv->connection == NULL) { + priv = gsm_app_get_instance_private (app); + + priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (priv->connection == NULL) { if (error != NULL) { g_critical ("error getting session bus: %s", error->message); g_error_free (error); @@ -103,7 +102,7 @@ register_app (GsmApp *app) return FALSE; } - dbus_g_connection_register_g_object (app->priv->connection, app->priv->id, G_OBJECT (app)); + dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (app)); return TRUE; } @@ -115,13 +114,15 @@ gsm_app_constructor (GType type, { GsmApp *app; gboolean res; + GsmAppPrivate *priv; app = GSM_APP (G_OBJECT_CLASS (gsm_app_parent_class)->constructor (type, n_construct_properties, construct_properties)); + priv = gsm_app_get_instance_private (app); - g_free (app->priv->id); - app->priv->id = g_strdup_printf ("/org/gnome/SessionManager/App%u", get_next_app_serial ()); + g_free (priv->id); + priv->id = g_strdup_printf ("/org/gnome/SessionManager/App%u", get_next_app_serial ()); res = register_app (app); if (! res) { @@ -134,27 +135,32 @@ gsm_app_constructor (GType type, static void gsm_app_init (GsmApp *app) { - app->priv = GSM_APP_GET_PRIVATE (app); } static void gsm_app_set_phase (GsmApp *app, int phase) { + GsmAppPrivate *priv; g_return_if_fail (GSM_IS_APP (app)); - app->priv->phase = phase; + priv = gsm_app_get_instance_private (app); + + priv->phase = phase; } static void gsm_app_set_id (GsmApp *app, const char *id) { + GsmAppPrivate *priv; g_return_if_fail (GSM_IS_APP (app)); - g_free (app->priv->id); + priv = gsm_app_get_instance_private (app); + + g_free (priv->id); - app->priv->id = g_strdup (id); + priv->id = g_strdup (id); g_object_notify (G_OBJECT (app), "id"); } @@ -162,11 +168,14 @@ static void gsm_app_set_startup_id (GsmApp *app, const char *startup_id) { + GsmAppPrivate *priv; g_return_if_fail (GSM_IS_APP (app)); - g_free (app->priv->startup_id); + priv = gsm_app_get_instance_private (app); - app->priv->startup_id = g_strdup (startup_id); + g_free (priv->startup_id); + + priv->startup_id = g_strdup (startup_id); g_object_notify (G_OBJECT (app), "startup-id"); } @@ -200,17 +209,20 @@ gsm_app_get_property (GObject *object, GValue *value, GParamSpec *pspec) { + GsmAppPrivate *priv; GsmApp *app = GSM_APP (object); + priv = gsm_app_get_instance_private (app); + switch (prop_id) { case PROP_STARTUP_ID: - g_value_set_string (value, app->priv->startup_id); + g_value_set_string (value, priv->startup_id); break; case PROP_ID: - g_value_set_string (value, app->priv->id); + g_value_set_string (value, priv->id); break; case PROP_PHASE: - g_value_set_int (value, app->priv->phase); + g_value_set_int (value, priv->phase); break; default: break; @@ -220,13 +232,16 @@ gsm_app_get_property (GObject *object, static void gsm_app_dispose (GObject *object) { + GsmAppPrivate *priv; GsmApp *app = GSM_APP (object); - g_free (app->priv->startup_id); - app->priv->startup_id = NULL; + priv = gsm_app_get_instance_private (app); - g_free (app->priv->id); - app->priv->id = NULL; + g_free (priv->startup_id); + priv->startup_id = NULL; + + g_free (priv->id); + priv->id = NULL; G_OBJECT_CLASS (gsm_app_parent_class)->dispose (object); } @@ -301,14 +316,16 @@ gsm_app_class_init (GsmAppClass *klass) G_TYPE_NONE, 0); - g_type_class_add_private (klass, sizeof (GsmAppPrivate)); dbus_g_object_type_install_info (GSM_TYPE_APP, &dbus_glib_gsm_app_object_info); } const char * gsm_app_peek_id (GsmApp *app) { - return app->priv->id; + GsmAppPrivate *priv; + priv = gsm_app_get_instance_private (app); + + return priv->id; } const char * @@ -320,7 +337,10 @@ gsm_app_peek_app_id (GsmApp *app) const char * gsm_app_peek_startup_id (GsmApp *app) { - return app->priv->startup_id; + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + return priv->startup_id; } /** @@ -334,9 +354,12 @@ gsm_app_peek_startup_id (GsmApp *app) GsmManagerPhase gsm_app_peek_phase (GsmApp *app) { + GsmAppPrivate *priv; g_return_val_if_fail (GSM_IS_APP (app), GSM_MANAGER_PHASE_APPLICATION); - return app->priv->phase; + priv = gsm_app_get_instance_private (app); + + return priv->phase; } gboolean @@ -414,7 +437,10 @@ gboolean gsm_app_start (GsmApp *app, GError **error) { - g_debug ("Starting app: %s", app->priv->id); + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + g_debug ("Starting app: %s", priv->id); return GSM_APP_GET_CLASS (app)->impl_start (app, error); } @@ -423,7 +449,11 @@ gboolean gsm_app_restart (GsmApp *app, GError **error) { - g_debug ("Re-starting app: %s", app->priv->id); + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + + g_debug ("Re-starting app: %s", priv->id); return GSM_APP_GET_CLASS (app)->impl_restart (app, error); } @@ -486,8 +516,11 @@ gsm_app_get_startup_id (GsmApp *app, char **id, GError **error) { + GsmAppPrivate *priv; g_return_val_if_fail (GSM_IS_APP (app), FALSE); - *id = g_strdup (app->priv->startup_id); + + priv = gsm_app_get_instance_private (app); + *id = g_strdup (priv->startup_id); return TRUE; } @@ -496,7 +529,10 @@ gsm_app_get_phase (GsmApp *app, guint *phase, GError **error) { + GsmAppPrivate *priv; g_return_val_if_fail (GSM_IS_APP (app), FALSE); - *phase = app->priv->phase; + + priv = gsm_app_get_instance_private (app); + *phase = priv->phase; return TRUE; } diff --git a/mate-session/gsm-app.h b/mate-session/gsm-app.h index a1adaa3..a535fc5 100644 --- a/mate-session/gsm-app.h +++ b/mate-session/gsm-app.h @@ -30,26 +30,10 @@ #include "gsm-manager.h" #include "gsm-client.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_APP (gsm_app_get_type ()) -#define GSM_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_APP, GsmApp)) -#define GSM_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_APP, GsmAppClass)) -#define GSM_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_APP)) -#define GSM_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_APP)) -#define GSM_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_APP, GsmAppClass)) - -typedef struct _GsmApp GsmApp; -typedef struct _GsmAppClass GsmAppClass; -typedef struct _GsmAppPrivate GsmAppPrivate; - -struct _GsmApp -{ - GObject parent; - GsmAppPrivate *priv; -}; +G_DECLARE_DERIVABLE_TYPE (GsmApp, gsm_app, GSM, APP, GObject) struct _GsmAppClass { @@ -131,8 +115,6 @@ gboolean gsm_app_get_phase (GsmApp *app, guint *phase, GError **error); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_APP_H__ */ diff --git a/mate-session/gsm-autostart-app.c b/mate-session/gsm-autostart-app.c index 11ac4f4..aac072c 100644 --- a/mate-session/gsm-autostart-app.c +++ b/mate-session/gsm-autostart-app.c @@ -56,7 +56,7 @@ enum { #define GSM_SESSION_CLIENT_DBUS_INTERFACE "org.mate.SessionClient" -struct _GsmAutostartAppPrivate { +typedef struct { char *desktop_filename; char *desktop_id; char *startup_id; @@ -78,7 +78,7 @@ struct _GsmAutostartAppPrivate { DBusGProxy *proxy; DBusGProxyCall *proxy_call; -}; +} GsmAutostartAppPrivate; enum { CONDITION_CHANGED, @@ -92,19 +92,19 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -#define GSM_AUTOSTART_APP_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSM_TYPE_AUTOSTART_APP, GsmAutostartAppPrivate)) - -G_DEFINE_TYPE (GsmAutostartApp, gsm_autostart_app, GSM_TYPE_APP) +G_DEFINE_TYPE_WITH_PRIVATE (GsmAutostartApp, gsm_autostart_app, GSM_TYPE_APP) static void gsm_autostart_app_init (GsmAutostartApp *app) { - app->priv = GSM_AUTOSTART_APP_GET_PRIVATE (app); + GsmAutostartAppPrivate *priv; - app->priv->pid = -1; - app->priv->condition_monitor = NULL; - app->priv->condition = FALSE; - app->priv->autostart_delay = -1; + priv = gsm_autostart_app_get_instance_private (app); + + priv->pid = -1; + priv->condition_monitor = NULL; + priv->condition = FALSE; + priv->autostart_delay = -1; } static gboolean @@ -112,7 +112,7 @@ is_disabled (GsmApp *app) { GsmAutostartAppPrivate *priv; - priv = GSM_AUTOSTART_APP (app)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); /* GSM_AUTOSTART_APP_ENABLED_KEY key, used by old mate-session */ if (egg_desktop_file_has_key (priv->desktop_file, @@ -196,7 +196,7 @@ if_exists_condition_cb (GFileMonitor *monitor, GsmAutostartAppPrivate *priv; gboolean condition = FALSE; - priv = GSM_AUTOSTART_APP (app)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); switch (event) { case G_FILE_MONITOR_EVENT_CREATED: @@ -227,7 +227,7 @@ unless_exists_condition_cb (GFileMonitor *monitor, GsmAutostartAppPrivate *priv; gboolean condition = FALSE; - priv = GSM_AUTOSTART_APP (app)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); switch (event) { case G_FILE_MONITOR_EVENT_CREATED: @@ -261,7 +261,7 @@ gsettings_condition_cb (GSettings *settings, app = GSM_APP (user_data); - priv = GSM_AUTOSTART_APP (app)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); condition = g_settings_get_boolean (settings, key); @@ -286,9 +286,12 @@ setup_gsettings_condition_monitor (GsmAutostartApp *app, char **elems; gboolean retval = FALSE; char *signal; + GsmAutostartAppPrivate *priv; elems = g_strsplit (key, " ", 2); + priv = gsm_autostart_app_get_instance_private (app); + if (elems == NULL) goto out; @@ -312,7 +315,7 @@ setup_gsettings_condition_monitor (GsmAutostartApp *app, retval = g_settings_get_boolean (settings, elems[1]); - app->priv->condition_settings = settings; + priv->condition_settings = settings; out: g_strfreev (elems); @@ -327,17 +330,20 @@ setup_condition_monitor (GsmAutostartApp *app) char *key; gboolean res; gboolean UNUSED_VARIABLE disabled; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); - if (app->priv->condition_monitor != NULL) { - g_file_monitor_cancel (app->priv->condition_monitor); + if (priv->condition_monitor != NULL) { + g_file_monitor_cancel (priv->condition_monitor); } - if (app->priv->condition_settings != NULL) { - g_object_unref (app->priv->condition_settings); - app->priv->condition_settings = NULL; + if (priv->condition_settings != NULL) { + g_object_unref (priv->condition_settings); + priv->condition_settings = NULL; } - if (app->priv->condition_string == NULL) { + if (priv->condition_string == NULL) { return; } @@ -347,7 +353,7 @@ setup_condition_monitor (GsmAutostartApp *app) } key = NULL; - res = parse_condition_string (app->priv->condition_string, &kind, &key); + res = parse_condition_string (priv->condition_string, &kind, &key); if (! res) { g_free (key); return; @@ -366,9 +372,9 @@ setup_condition_monitor (GsmAutostartApp *app) disabled = !g_file_test (file_path, G_FILE_TEST_EXISTS); file = g_file_new_for_path (file_path); - app->priv->condition_monitor = g_file_monitor_file (file, 0, NULL, NULL); + priv->condition_monitor = g_file_monitor_file (file, 0, NULL, NULL); - g_signal_connect (app->priv->condition_monitor, "changed", + g_signal_connect (priv->condition_monitor, "changed", G_CALLBACK (if_exists_condition_cb), app); @@ -383,9 +389,9 @@ setup_condition_monitor (GsmAutostartApp *app) disabled = g_file_test (file_path, G_FILE_TEST_EXISTS); file = g_file_new_for_path (file_path); - app->priv->condition_monitor = g_file_monitor_file (file, 0, NULL, NULL); + priv->condition_monitor = g_file_monitor_file (file, 0, NULL, NULL); - g_signal_connect (app->priv->condition_monitor, "changed", + g_signal_connect (priv->condition_monitor, "changed", G_CALLBACK (unless_exists_condition_cb), app); @@ -412,12 +418,15 @@ load_desktop_file (GsmAutostartApp *app) char *phase_str; int phase; gboolean res; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); - if (app->priv->desktop_file == NULL) { + if (priv->desktop_file == NULL) { return FALSE; } - phase_str = egg_desktop_file_get_string (app->priv->desktop_file, + phase_str = egg_desktop_file_get_string (priv->desktop_file, GSM_AUTOSTART_APP_PHASE_KEY, NULL); if (phase_str != NULL) { @@ -438,20 +447,20 @@ load_desktop_file (GsmAutostartApp *app) phase = GSM_MANAGER_PHASE_APPLICATION; } - dbus_name = egg_desktop_file_get_string (app->priv->desktop_file, + dbus_name = egg_desktop_file_get_string (priv->desktop_file, GSM_AUTOSTART_APP_DBUS_NAME_KEY, NULL); if (dbus_name != NULL) { - app->priv->launch_type = AUTOSTART_LAUNCH_ACTIVATE; + priv->launch_type = AUTOSTART_LAUNCH_ACTIVATE; } else { - app->priv->launch_type = AUTOSTART_LAUNCH_SPAWN; + priv->launch_type = AUTOSTART_LAUNCH_SPAWN; } /* this must only be done on first load */ - switch (app->priv->launch_type) { + switch (priv->launch_type) { case AUTOSTART_LAUNCH_SPAWN: startup_id = - egg_desktop_file_get_string (app->priv->desktop_file, + egg_desktop_file_get_string (priv->desktop_file, GSM_AUTOSTART_APP_STARTUP_ID_KEY, NULL); @@ -466,32 +475,32 @@ load_desktop_file (GsmAutostartApp *app) g_assert_not_reached (); } - res = egg_desktop_file_has_key (app->priv->desktop_file, + res = egg_desktop_file_has_key (priv->desktop_file, GSM_AUTOSTART_APP_AUTORESTART_KEY, NULL); if (res) { - app->priv->autorestart = egg_desktop_file_get_boolean (app->priv->desktop_file, - GSM_AUTOSTART_APP_AUTORESTART_KEY, - NULL); + priv->autorestart = egg_desktop_file_get_boolean (priv->desktop_file, + GSM_AUTOSTART_APP_AUTORESTART_KEY, + NULL); } else { - app->priv->autorestart = FALSE; + priv->autorestart = FALSE; } - g_free (app->priv->condition_string); - app->priv->condition_string = egg_desktop_file_get_string (app->priv->desktop_file, - "AutostartCondition", - NULL); + g_free (priv->condition_string); + priv->condition_string = egg_desktop_file_get_string (priv->desktop_file, + "AutostartCondition", + NULL); setup_condition_monitor (app); if (phase == GSM_MANAGER_PHASE_APPLICATION) { /* Only accept an autostart delay for the application phase */ - app->priv->autostart_delay = egg_desktop_file_get_integer (app->priv->desktop_file, - GSM_AUTOSTART_APP_DELAY_KEY, - NULL); - if (app->priv->autostart_delay < 0) { - g_warning ("Invalid autostart delay of %d for %s", app->priv->autostart_delay, + priv->autostart_delay = egg_desktop_file_get_integer (priv->desktop_file, + GSM_AUTOSTART_APP_DELAY_KEY, + NULL); + if (priv->autostart_delay < 0) { + g_warning ("Invalid autostart delay of %d for %s", priv->autostart_delay, gsm_app_peek_id (GSM_APP (app))); - app->priv->autostart_delay = -1; + priv->autostart_delay = -1; } } @@ -511,22 +520,25 @@ gsm_autostart_app_set_desktop_filename (GsmAutostartApp *app, const char *desktop_filename) { GError *error; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); - if (app->priv->desktop_file != NULL) { - egg_desktop_file_free (app->priv->desktop_file); - app->priv->desktop_file = NULL; - g_free (app->priv->desktop_id); + if (priv->desktop_file != NULL) { + egg_desktop_file_free (priv->desktop_file); + priv->desktop_file = NULL; + g_free (priv->desktop_id); } if (desktop_filename == NULL) { return; } - app->priv->desktop_id = g_path_get_basename (desktop_filename); + priv->desktop_id = g_path_get_basename (desktop_filename); error = NULL; - app->priv->desktop_file = egg_desktop_file_new (desktop_filename, &error); - if (app->priv->desktop_file == NULL) { + priv->desktop_file = egg_desktop_file_new (desktop_filename, &error); + if (priv->desktop_file == NULL) { g_warning ("Could not parse desktop file %s: %s", desktop_filename, error->message); @@ -562,13 +574,15 @@ gsm_autostart_app_get_property (GObject *object, GParamSpec *pspec) { GsmAutostartApp *self; + GsmAutostartAppPrivate *priv; self = GSM_AUTOSTART_APP (object); + priv = gsm_autostart_app_get_instance_private (self); switch (prop_id) { case PROP_DESKTOP_FILENAME: - if (self->priv->desktop_file != NULL) { - g_value_set_string (value, egg_desktop_file_get_source (self->priv->desktop_file)); + if (priv->desktop_file != NULL) { + g_value_set_string (value, egg_desktop_file_get_source (priv->desktop_file)); } else { g_value_set_string (value, NULL); } @@ -584,7 +598,7 @@ gsm_autostart_app_dispose (GObject *object) { GsmAutostartAppPrivate *priv; - priv = GSM_AUTOSTART_APP (object)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(object)); if (priv->startup_id) { g_free (priv->startup_id); @@ -639,7 +653,7 @@ is_running (GsmApp *app) GsmAutostartAppPrivate *priv; gboolean is; - priv = GSM_AUTOSTART_APP (app)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); /* is running if pid is still valid or * or a client is connected @@ -653,13 +667,13 @@ is_running (GsmApp *app) static gboolean is_conditionally_disabled (GsmApp *app) { - GsmAutostartAppPrivate *priv; gboolean res; gboolean disabled; char *key; guint kind; + GsmAutostartAppPrivate *priv; - priv = GSM_AUTOSTART_APP (app)->priv; + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); /* Check AutostartCondition */ if (priv->condition_string == NULL) { @@ -716,6 +730,9 @@ app_exited (GPid pid, int status, GsmAutostartApp *app) { + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); g_debug ("GsmAutostartApp: (pid:%d) done (%s:%d)", (int) pid, WIFEXITED (status) ? "status" @@ -725,9 +742,9 @@ app_exited (GPid pid, : WIFSIGNALED (status) ? WTERMSIG (status) : -1); - g_spawn_close_pid (app->priv->pid); - app->priv->pid = -1; - app->priv->child_watch_id = 0; + g_spawn_close_pid (priv->pid); + priv->pid = -1; + priv->child_watch_id = 0; if (WIFEXITED (status)) { gsm_app_exited (GSM_APP (app)); @@ -768,8 +785,11 @@ autostart_app_stop_spawn (GsmAutostartApp *app, GError **error) { int res; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); - if (app->priv->pid < 1) { + if (priv->pid < 1) { g_set_error (error, GSM_APP_ERROR, GSM_APP_ERROR_STOP, @@ -777,7 +797,7 @@ autostart_app_stop_spawn (GsmAutostartApp *app, return FALSE; } - res = _signal_pid (app->priv->pid, SIGTERM); + res = _signal_pid (priv->pid, SIGTERM); if (res != 0) { g_set_error (error, GSM_APP_ERROR, @@ -803,12 +823,14 @@ gsm_autostart_app_stop (GsmApp *app, { GsmAutostartApp *aapp; gboolean ret; + GsmAutostartAppPrivate *priv; aapp = GSM_AUTOSTART_APP (app); - g_return_val_if_fail (aapp->priv->desktop_file != NULL, FALSE); + priv = gsm_autostart_app_get_instance_private (aapp); + g_return_val_if_fail (priv->desktop_file != NULL, FALSE); - switch (aapp->priv->launch_type) { + switch (priv->launch_type) { case AUTOSTART_LAUNCH_SPAWN: ret = autostart_app_stop_spawn (aapp, error); break; @@ -832,43 +854,45 @@ autostart_app_start_spawn (GsmAutostartApp *app, GError *local_error; const char *startup_id; char *command; + GsmAutostartAppPrivate *priv; startup_id = gsm_app_peek_startup_id (GSM_APP (app)); g_assert (startup_id != NULL); + priv = gsm_autostart_app_get_instance_private (app); env[0] = g_strdup_printf ("DESKTOP_AUTOSTART_ID=%s", startup_id); local_error = NULL; - command = egg_desktop_file_parse_exec (app->priv->desktop_file, + command = egg_desktop_file_parse_exec (priv->desktop_file, NULL, &local_error); if (command == NULL) { g_warning ("Unable to parse command from '%s': %s", - egg_desktop_file_get_source (app->priv->desktop_file), + egg_desktop_file_get_source (priv->desktop_file), local_error->message); g_error_free (local_error); } - g_debug ("GsmAutostartApp: starting %s: command=%s startup-id=%s", app->priv->desktop_id, command, startup_id); + g_debug ("GsmAutostartApp: starting %s: command=%s startup-id=%s", priv->desktop_id, command, startup_id); g_free (command); - g_free (app->priv->startup_id); + g_free (priv->startup_id); local_error = NULL; - success = egg_desktop_file_launch (app->priv->desktop_file, + success = egg_desktop_file_launch (priv->desktop_file, NULL, &local_error, EGG_DESKTOP_FILE_LAUNCH_PUTENV, env, EGG_DESKTOP_FILE_LAUNCH_FLAGS, G_SPAWN_DO_NOT_REAP_CHILD, - EGG_DESKTOP_FILE_LAUNCH_RETURN_PID, &app->priv->pid, - EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID, &app->priv->startup_id, + EGG_DESKTOP_FILE_LAUNCH_RETURN_PID, &priv->pid, + EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID, &priv->startup_id, NULL); g_free (env[0]); if (success) { - g_debug ("GsmAutostartApp: started pid:%d", app->priv->pid); - app->priv->child_watch_id = g_child_watch_add (app->priv->pid, - (GChildWatchFunc)app_exited, - app); + g_debug ("GsmAutostartApp: started pid:%d", priv->pid); + priv->child_watch_id = g_child_watch_add (priv->pid, + (GChildWatchFunc)app_exited, + app); } else { g_set_error (error, GSM_APP_ERROR, @@ -887,19 +911,22 @@ start_notify (DBusGProxy *proxy, { gboolean res; GError *error; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); error = NULL; res = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - app->priv->proxy_call = NULL; + priv->proxy_call = NULL; if (! res) { g_warning ("GsmAutostartApp: Error starting application: %s", error->message); g_error_free (error); } else { - g_debug ("GsmAutostartApp: Started application %s", app->priv->desktop_id); + g_debug ("GsmAutostartApp: Started application %s", priv->desktop_id); } } @@ -912,6 +939,9 @@ autostart_app_start_activate (GsmAutostartApp *app, char *arguments; DBusGConnection *bus; GError *local_error; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (app); local_error = NULL; bus = dbus_g_bus_get (DBUS_BUS_SESSION, &local_error); @@ -926,7 +956,7 @@ autostart_app_start_activate (GsmAutostartApp *app, name = gsm_app_peek_startup_id (GSM_APP (app)); g_assert (name != NULL); - path = egg_desktop_file_get_string (app->priv->desktop_file, + path = egg_desktop_file_get_string (priv->desktop_file, GSM_AUTOSTART_APP_DBUS_PATH_KEY, NULL); if (path == NULL) { @@ -934,15 +964,15 @@ autostart_app_start_activate (GsmAutostartApp *app, path = g_strdup ("/"); } - arguments = egg_desktop_file_get_string (app->priv->desktop_file, + arguments = egg_desktop_file_get_string (priv->desktop_file, GSM_AUTOSTART_APP_DBUS_ARGS_KEY, NULL); - app->priv->proxy = dbus_g_proxy_new_for_name (bus, - name, - path, - GSM_SESSION_CLIENT_DBUS_INTERFACE); - if (app->priv->proxy == NULL) { + priv->proxy = dbus_g_proxy_new_for_name (bus, + name, + path, + GSM_SESSION_CLIENT_DBUS_INTERFACE); + if (priv->proxy == NULL) { g_set_error (error, GSM_APP_ERROR, GSM_APP_ERROR_START, @@ -950,16 +980,16 @@ autostart_app_start_activate (GsmAutostartApp *app, return FALSE; } - app->priv->proxy_call = dbus_g_proxy_begin_call (app->priv->proxy, - "Start", - (DBusGProxyCallNotify)start_notify, - app, - NULL, - G_TYPE_STRING, arguments, - G_TYPE_INVALID); - if (app->priv->proxy_call == NULL) { - g_object_unref (app->priv->proxy); - app->priv->proxy = NULL; + priv->proxy_call = dbus_g_proxy_begin_call (priv->proxy, + "Start", + (DBusGProxyCallNotify)start_notify, + app, + NULL, + G_TYPE_STRING, arguments, + G_TYPE_INVALID); + if (priv->proxy_call == NULL) { + g_object_unref (priv->proxy); + priv->proxy = NULL; g_set_error (error, GSM_APP_ERROR, GSM_APP_ERROR_START, @@ -976,12 +1006,14 @@ gsm_autostart_app_start (GsmApp *app, { GsmAutostartApp *aapp; gboolean ret; + GsmAutostartAppPrivate *priv; aapp = GSM_AUTOSTART_APP (app); + priv = gsm_autostart_app_get_instance_private (aapp); - g_return_val_if_fail (aapp->priv->desktop_file != NULL, FALSE); + g_return_val_if_fail (priv->desktop_file != NULL, FALSE); - switch (aapp->priv->launch_type) { + switch (priv->launch_type) { case AUTOSTART_LAUNCH_SPAWN: ret = autostart_app_start_spawn (aapp, error); break; @@ -1028,16 +1060,19 @@ gsm_autostart_app_provides (GsmApp *app, gsize len; gsize i; GsmAutostartApp *aapp; + GsmAutostartAppPrivate *priv; + g_return_val_if_fail (GSM_IS_APP (app), FALSE); aapp = GSM_AUTOSTART_APP (app); + priv = gsm_autostart_app_get_instance_private (aapp); - if (aapp->priv->desktop_file == NULL) { + if (priv->desktop_file == NULL) { return FALSE; } - provides = egg_desktop_file_get_string_list (aapp->priv->desktop_file, + provides = egg_desktop_file_get_string_list (priv->desktop_file, GSM_AUTOSTART_APP_PROVIDES_KEY, &len, NULL); if (!provides) { @@ -1060,17 +1095,19 @@ gsm_autostart_app_has_autostart_condition (GsmApp *app, const char *condition) { GsmAutostartApp *aapp; + GsmAutostartAppPrivate *priv; g_return_val_if_fail (GSM_IS_APP (app), FALSE); g_return_val_if_fail (condition != NULL, FALSE); aapp = GSM_AUTOSTART_APP (app); + priv = gsm_autostart_app_get_instance_private (aapp); - if (aapp->priv->condition_string == NULL) { + if (priv->condition_string == NULL) { return FALSE; } - if (strcmp (aapp->priv->condition_string, condition) == 0) { + if (strcmp (priv->condition_string, condition) == 0) { return TRUE; } @@ -1082,18 +1119,21 @@ gsm_autostart_app_get_autorestart (GsmApp *app) { gboolean res; gboolean autorestart; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); - if (GSM_AUTOSTART_APP (app)->priv->desktop_file == NULL) { + if (priv->desktop_file == NULL) { return FALSE; } autorestart = FALSE; - res = egg_desktop_file_has_key (GSM_AUTOSTART_APP (app)->priv->desktop_file, + res = egg_desktop_file_has_key (priv->desktop_file, GSM_AUTOSTART_APP_AUTORESTART_KEY, NULL); if (res) { - autorestart = egg_desktop_file_get_boolean (GSM_AUTOSTART_APP (app)->priv->desktop_file, + autorestart = egg_desktop_file_get_boolean (priv->desktop_file, GSM_AUTOSTART_APP_AUTORESTART_KEY, NULL); } @@ -1106,12 +1146,15 @@ gsm_autostart_app_get_app_id (GsmApp *app) { const char *location; const char *slash; + GsmAutostartAppPrivate *priv; + + priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app)); - if (GSM_AUTOSTART_APP (app)->priv->desktop_file == NULL) { + if (priv->desktop_file == NULL) { return NULL; } - location = egg_desktop_file_get_source (GSM_AUTOSTART_APP (app)->priv->desktop_file); + location = egg_desktop_file_get_source (priv->desktop_file); slash = strrchr (location, '/'); if (slash != NULL) { @@ -1124,9 +1167,12 @@ gsm_autostart_app_get_app_id (GsmApp *app) static int gsm_autostart_app_peek_autostart_delay (GsmApp *app) { + GsmAutostartAppPrivate *priv; GsmAutostartApp *aapp = GSM_AUTOSTART_APP (app); - return aapp->priv->autostart_delay; + priv = gsm_autostart_app_get_instance_private (aapp); + + return priv->autostart_delay; } static GObject * @@ -1188,8 +1234,6 @@ gsm_autostart_app_class_init (GsmAutostartAppClass *klass) G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - g_type_class_add_private (object_class, sizeof (GsmAutostartAppPrivate)); } GsmApp * diff --git a/mate-session/gsm-autostart-app.h b/mate-session/gsm-autostart-app.h index 4c45338..ff92fca 100644 --- a/mate-session/gsm-autostart-app.h +++ b/mate-session/gsm-autostart-app.h @@ -26,27 +26,10 @@ #include <X11/SM/SMlib.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_AUTOSTART_APP (gsm_autostart_app_get_type ()) -#define GSM_AUTOSTART_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_AUTOSTART_APP, GsmAutostartApp)) -#define GSM_AUTOSTART_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_AUTOSTART_APP, GsmAutostartAppClass)) -#define GSM_IS_AUTOSTART_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_AUTOSTART_APP)) -#define GSM_IS_AUTOSTART_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_AUTOSTART_APP)) -#define GSM_AUTOSTART_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_AUTOSTART_APP, GsmAutostartAppClass)) - -typedef struct _GsmAutostartApp GsmAutostartApp; -typedef struct _GsmAutostartAppClass GsmAutostartAppClass; -typedef struct _GsmAutostartAppPrivate GsmAutostartAppPrivate; - -struct _GsmAutostartApp -{ - GsmApp parent; - - GsmAutostartAppPrivate *priv; -}; +G_DECLARE_DERIVABLE_TYPE (GsmAutostartApp, gsm_autostart_app, GSM, AUTOSTART_APP, GsmApp) struct _GsmAutostartAppClass { @@ -72,8 +55,6 @@ GsmApp *gsm_autostart_app_new (const char *desktop_file); #define GSM_AUTOSTART_APP_DISCARD_KEY "X-MATE-Autostart-discard-exec" #define GSM_AUTOSTART_APP_DELAY_KEY "X-MATE-Autostart-Delay" -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_AUTOSTART_APP_H__ */ diff --git a/mate-session/gsm-client.c b/mate-session/gsm-client.c index 2909d99..13c6169 100644 --- a/mate-session/gsm-client.c +++ b/mate-session/gsm-client.c @@ -31,16 +31,14 @@ static guint32 client_serial = 1; -#define GSM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_CLIENT, GsmClientPrivate)) - -struct GsmClientPrivate -{ +typedef struct { + GObject parent; char *id; char *startup_id; char *app_id; guint status; DBusGConnection *connection; -}; +} GsmClientPrivate; enum { PROP_0, @@ -58,7 +56,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_ABSTRACT_TYPE (GsmClient, gsm_client, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsmClient, gsm_client, G_TYPE_OBJECT) GQuark gsm_client_error_quark (void) @@ -111,10 +109,12 @@ static gboolean register_client (GsmClient *client) { GError *error; + GsmClientPrivate *priv; error = NULL; - client->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (client->priv->connection == NULL) { + priv = gsm_client_get_instance_private (client); + priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (priv->connection == NULL) { if (error != NULL) { g_critical ("error getting session bus: %s", error->message); g_error_free (error); @@ -122,7 +122,7 @@ register_client (GsmClient *client) return FALSE; } - dbus_g_connection_register_g_object (client->priv->connection, client->priv->id, G_OBJECT (client)); + dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (client)); return TRUE; } @@ -134,13 +134,14 @@ gsm_client_constructor (GType type, { GsmClient *client; gboolean res; + GsmClientPrivate *priv; client = GSM_CLIENT (G_OBJECT_CLASS (gsm_client_parent_class)->constructor (type, n_construct_properties, construct_properties)); - - g_free (client->priv->id); - client->priv->id = g_strdup_printf ("/org/gnome/SessionManager/Client%u", get_next_client_serial ()); + priv = gsm_client_get_instance_private (client); + g_free (priv->id); + priv->id = g_strdup_printf ("/org/gnome/SessionManager/Client%u", get_next_client_serial ()); res = register_client (client); if (! res) { @@ -153,24 +154,25 @@ gsm_client_constructor (GType type, static void gsm_client_init (GsmClient *client) { - client->priv = GSM_CLIENT_GET_PRIVATE (client); } static void gsm_client_finalize (GObject *object) { GsmClient *client; + GsmClientPrivate *priv; g_return_if_fail (object != NULL); g_return_if_fail (GSM_IS_CLIENT (object)); client = GSM_CLIENT (object); + priv = gsm_client_get_instance_private (client); - g_return_if_fail (client->priv != NULL); + g_return_if_fail (priv != NULL); - g_free (client->priv->id); - g_free (client->priv->startup_id); - g_free (client->priv->app_id); + g_free (priv->id); + g_free (priv->startup_id); + g_free (priv->app_id); G_OBJECT_CLASS (gsm_client_parent_class)->finalize (object); } @@ -179,9 +181,12 @@ void gsm_client_set_status (GsmClient *client, guint status) { + GsmClientPrivate *priv; g_return_if_fail (GSM_IS_CLIENT (client)); - if (client->priv->status != status) { - client->priv->status = status; + + priv = gsm_client_get_instance_private (client); + if (priv->status != status) { + priv->status = status; g_object_notify (G_OBJECT (client), "status"); } } @@ -190,14 +195,17 @@ static void gsm_client_set_startup_id (GsmClient *client, const char *startup_id) { + GsmClientPrivate *priv; g_return_if_fail (GSM_IS_CLIENT (client)); - g_free (client->priv->startup_id); + priv = gsm_client_get_instance_private (client); + + g_free (priv->startup_id); if (startup_id != NULL) { - client->priv->startup_id = g_strdup (startup_id); + priv->startup_id = g_strdup (startup_id); } else { - client->priv->startup_id = g_strdup (""); + priv->startup_id = g_strdup (""); } g_object_notify (G_OBJECT (client), "startup-id"); } @@ -206,14 +214,17 @@ void gsm_client_set_app_id (GsmClient *client, const char *app_id) { + GsmClientPrivate *priv; g_return_if_fail (GSM_IS_CLIENT (client)); - g_free (client->priv->app_id); + priv = gsm_client_get_instance_private (client); + + g_free (priv->app_id); if (app_id != NULL) { - client->priv->app_id = g_strdup (app_id); + priv->app_id = g_strdup (app_id); } else { - client->priv->app_id = g_strdup (""); + priv->app_id = g_strdup (""); } g_object_notify (G_OBJECT (client), "app-id"); } @@ -251,18 +262,20 @@ gsm_client_get_property (GObject *object, GParamSpec *pspec) { GsmClient *self; + GsmClientPrivate *priv; self = GSM_CLIENT (object); + priv = gsm_client_get_instance_private (self); switch (prop_id) { case PROP_STARTUP_ID: - g_value_set_string (value, self->priv->startup_id); + g_value_set_string (value, priv->startup_id); break; case PROP_APP_ID: - g_value_set_string (value, self->priv->app_id); + g_value_set_string (value, priv->app_id); break; case PROP_STATUS: - g_value_set_uint (value, self->priv->status); + g_value_set_uint (value, priv->status); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -285,13 +298,15 @@ static void gsm_client_dispose (GObject *object) { GsmClient *client; + GsmClientPrivate *priv; g_return_if_fail (object != NULL); g_return_if_fail (GSM_IS_CLIENT (object)); client = GSM_CLIENT (object); + priv = gsm_client_get_instance_private (client); - g_debug ("GsmClient: disposing %s", client->priv->id); + g_debug ("GsmClient: disposing %s", priv->id); G_OBJECT_CLASS (gsm_client_parent_class)->dispose (object); } @@ -352,17 +367,18 @@ gsm_client_class_init (GsmClientClass *klass) GSM_CLIENT_UNREGISTERED, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - g_type_class_add_private (klass, sizeof (GsmClientPrivate)); - dbus_g_object_type_install_info (GSM_TYPE_CLIENT, &dbus_glib_gsm_client_object_info); } const char * gsm_client_peek_id (GsmClient *client) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), NULL); - return client->priv->id; + priv = gsm_client_get_instance_private (client); + + return priv->id; } /** @@ -378,25 +394,34 @@ gsm_client_peek_id (GsmClient *client) const char * gsm_client_peek_app_id (GsmClient *client) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), NULL); - return client->priv->app_id; + priv = gsm_client_get_instance_private (client); + + return priv->app_id; } const char * gsm_client_peek_startup_id (GsmClient *client) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), NULL); - return client->priv->startup_id; + priv = gsm_client_get_instance_private (client); + + return priv->startup_id; } guint gsm_client_peek_status (GsmClient *client) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), GSM_CLIENT_UNREGISTERED); - return client->priv->status; + priv = gsm_client_get_instance_private (client); + + return priv->status; } guint @@ -412,9 +437,12 @@ gsm_client_get_startup_id (GsmClient *client, char **id, GError **error) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - *id = g_strdup (client->priv->startup_id); + priv = gsm_client_get_instance_private (client); + + *id = g_strdup (priv->startup_id); return TRUE; } @@ -424,9 +452,12 @@ gsm_client_get_app_id (GsmClient *client, char **id, GError **error) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - *id = g_strdup (client->priv->app_id); + priv = gsm_client_get_instance_private (client); + + *id = g_strdup (priv->app_id); return TRUE; } @@ -448,9 +479,12 @@ gsm_client_get_status (GsmClient *client, guint *status, GError **error) { + GsmClientPrivate *priv; g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE); - *status = client->priv->status; + priv = gsm_client_get_instance_private (client); + + *status = priv->status; return TRUE; } diff --git a/mate-session/gsm-client.h b/mate-session/gsm-client.h index 91e9cba..b623742 100644 --- a/mate-session/gsm-client.h +++ b/mate-session/gsm-client.h @@ -26,21 +26,10 @@ #include <glib-object.h> #include <sys/types.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_CLIENT (gsm_client_get_type ()) -#define GSM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_CLIENT, GsmClient)) -#define GSM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_CLIENT, GsmClientClass)) -#define GSM_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_CLIENT)) -#define GSM_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_CLIENT)) -#define GSM_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_CLIENT, GsmClientClass)) - -typedef struct _GsmClient GsmClient; -typedef struct _GsmClientClass GsmClientClass; - -typedef struct GsmClientPrivate GsmClientPrivate; +G_DECLARE_DERIVABLE_TYPE (GsmClient, gsm_client, GSM, CLIENT, GObject) typedef enum { GSM_CLIENT_UNREGISTERED = 0, @@ -62,12 +51,6 @@ typedef enum { GSM_CLIENT_END_SESSION_FLAG_LAST = 1 << 2 } GsmClientEndSessionFlag; -struct _GsmClient -{ - GObject parent; - GsmClientPrivate *priv; -}; - struct _GsmClientClass { GObjectClass parent_class; @@ -110,7 +93,6 @@ typedef enum GType gsm_client_error_get_type (void); GQuark gsm_client_error_quark (void); - GType gsm_client_get_type (void) G_GNUC_CONST; const char *gsm_client_peek_id (GsmClient *client); @@ -168,8 +150,6 @@ void gsm_client_end_session_response (GsmClient *client, gboolean cancel, const char *reason); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_CLIENT_H__ */ diff --git a/mate-session/gsm-consolekit.c b/mate-session/gsm-consolekit.c index 5f39358..31dbb70 100644 --- a/mate-session/gsm-consolekit.c +++ b/mate-session/gsm-consolekit.c @@ -43,16 +43,13 @@ #define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat" #define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session" -#define GSM_CONSOLEKIT_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_CONSOLEKIT, GsmConsolekitPrivate)) - -struct _GsmConsolekitPrivate +typedef struct { DBusGConnection *dbus_connection; DBusGProxy *bus_proxy; DBusGProxy *ck_proxy; guint32 is_connected : 1; -}; +} GsmConsolekitPrivate; enum { PROP_0, @@ -83,7 +80,7 @@ static void gsm_consolekit_on_name_owner_changed (DBusGProxy *bus_pro const char *new_owner, GsmConsolekit *manager); -G_DEFINE_TYPE (GsmConsolekit, gsm_consolekit, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_PRIVATE (GsmConsolekit, gsm_consolekit, G_TYPE_OBJECT); static void gsm_consolekit_get_property (GObject *object, @@ -92,11 +89,14 @@ gsm_consolekit_get_property (GObject *object, GParamSpec *pspec) { GsmConsolekit *manager = GSM_CONSOLEKIT (object); + GsmConsolekitPrivate *priv; + + priv = gsm_consolekit_get_instance_private (manager); switch (prop_id) { case PROP_IS_CONNECTED: g_value_set_boolean (value, - manager->priv->is_connected); + priv->is_connected); break; default: @@ -148,7 +148,6 @@ gsm_consolekit_class_init (GsmConsolekitClass *manager_class) G_TYPE_NONE, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER); - g_type_class_add_private (manager_class, sizeof (GsmConsolekitPrivate)); } static DBusHandlerResult @@ -177,64 +176,66 @@ gsm_consolekit_ensure_ck_connection (GsmConsolekit *manager, { GError *connection_error; gboolean is_connected; + GsmConsolekitPrivate *priv; connection_error = NULL; + priv = gsm_consolekit_get_instance_private (manager); - if (manager->priv->dbus_connection == NULL) { + if (priv->dbus_connection == NULL) { DBusConnection *connection; - manager->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, - &connection_error); + priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, + &connection_error); - if (manager->priv->dbus_connection == NULL) { + if (priv->dbus_connection == NULL) { g_propagate_error (error, connection_error); is_connected = FALSE; goto out; } - connection = dbus_g_connection_get_connection (manager->priv->dbus_connection); + connection = dbus_g_connection_get_connection (priv->dbus_connection); dbus_connection_set_exit_on_disconnect (connection, FALSE); dbus_connection_add_filter (connection, gsm_consolekit_dbus_filter, manager, NULL); } - if (manager->priv->bus_proxy == NULL) { - manager->priv->bus_proxy = - dbus_g_proxy_new_for_name_owner (manager->priv->dbus_connection, + if (priv->bus_proxy == NULL) { + priv->bus_proxy = + dbus_g_proxy_new_for_name_owner (priv->dbus_connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, &connection_error); - if (manager->priv->bus_proxy == NULL) { + if (priv->bus_proxy == NULL) { g_propagate_error (error, connection_error); is_connected = FALSE; goto out; } - dbus_g_proxy_add_signal (manager->priv->bus_proxy, + dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (manager->priv->bus_proxy, + dbus_g_proxy_connect_signal (priv->bus_proxy, "NameOwnerChanged", G_CALLBACK (gsm_consolekit_on_name_owner_changed), manager, NULL); } - if (manager->priv->ck_proxy == NULL) { - manager->priv->ck_proxy = - dbus_g_proxy_new_for_name_owner (manager->priv->dbus_connection, + if (priv->ck_proxy == NULL) { + priv->ck_proxy = + dbus_g_proxy_new_for_name_owner (priv->dbus_connection, "org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", &connection_error); - if (manager->priv->ck_proxy == NULL) { + if (priv->ck_proxy == NULL) { g_propagate_error (error, connection_error); is_connected = FALSE; goto out; @@ -244,26 +245,26 @@ gsm_consolekit_ensure_ck_connection (GsmConsolekit *manager, is_connected = TRUE; out: - if (manager->priv->is_connected != is_connected) { - manager->priv->is_connected = is_connected; + if (priv->is_connected != is_connected) { + priv->is_connected = is_connected; g_object_notify (G_OBJECT (manager), "is-connected"); } if (!is_connected) { - if (manager->priv->dbus_connection == NULL) { - if (manager->priv->bus_proxy != NULL) { - g_object_unref (manager->priv->bus_proxy); - manager->priv->bus_proxy = NULL; + if (priv->dbus_connection == NULL) { + if (priv->bus_proxy != NULL) { + g_object_unref (priv->bus_proxy); + priv->bus_proxy = NULL; } - if (manager->priv->ck_proxy != NULL) { - g_object_unref (manager->priv->ck_proxy); - manager->priv->ck_proxy = NULL; + if (priv->ck_proxy != NULL) { + g_object_unref (priv->ck_proxy); + priv->ck_proxy = NULL; } - } else if (manager->priv->bus_proxy == NULL) { - if (manager->priv->ck_proxy != NULL) { - g_object_unref (manager->priv->ck_proxy); - manager->priv->ck_proxy = NULL; + } else if (priv->bus_proxy == NULL) { + if (priv->ck_proxy != NULL) { + g_object_unref (priv->ck_proxy); + priv->ck_proxy = NULL; } } } @@ -278,13 +279,17 @@ gsm_consolekit_on_name_owner_changed (DBusGProxy *bus_proxy, const char *new_owner, GsmConsolekit *manager) { + GsmConsolekitPrivate *priv; + if (name != NULL && strcmp (name, "org.freedesktop.ConsoleKit") != 0) { return; } - if (manager->priv->ck_proxy != NULL) { - g_object_unref (manager->priv->ck_proxy); - manager->priv->ck_proxy = NULL; + priv = gsm_consolekit_get_instance_private (manager); + + if (priv->ck_proxy != NULL) { + g_object_unref (priv->ck_proxy); + priv->ck_proxy = NULL; } gsm_consolekit_ensure_ck_connection (manager, NULL); @@ -295,8 +300,6 @@ gsm_consolekit_init (GsmConsolekit *manager) { GError *error; - manager->priv = GSM_CONSOLEKIT_GET_PRIVATE (manager); - error = NULL; if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { @@ -309,25 +312,28 @@ gsm_consolekit_init (GsmConsolekit *manager) static void gsm_consolekit_free_dbus (GsmConsolekit *manager) { - if (manager->priv->bus_proxy != NULL) { - g_object_unref (manager->priv->bus_proxy); - manager->priv->bus_proxy = NULL; + GsmConsolekitPrivate *priv; + + priv = gsm_consolekit_get_instance_private (manager); + if (priv->bus_proxy != NULL) { + g_object_unref (priv->bus_proxy); + priv->bus_proxy = NULL; } - if (manager->priv->ck_proxy != NULL) { - g_object_unref (manager->priv->ck_proxy); - manager->priv->ck_proxy = NULL; + if (priv->ck_proxy != NULL) { + g_object_unref (priv->ck_proxy); + priv->ck_proxy = NULL; } - if (manager->priv->dbus_connection != NULL) { + if (priv->dbus_connection != NULL) { DBusConnection *connection; - connection = dbus_g_connection_get_connection (manager->priv->dbus_connection); + connection = dbus_g_connection_get_connection (priv->dbus_connection); dbus_connection_remove_filter (connection, gsm_consolekit_dbus_filter, manager); - dbus_g_connection_unref (manager->priv->dbus_connection); - manager->priv->dbus_connection = NULL; + dbus_g_connection_unref (priv->dbus_connection); + priv->dbus_connection = NULL; } } @@ -421,8 +427,10 @@ gsm_consolekit_attempt_restart (GsmConsolekit *manager) { gboolean res; GError *error; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -432,7 +440,7 @@ gsm_consolekit_attempt_restart (GsmConsolekit *manager) return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "Restart", INT_MAX, &error, @@ -453,8 +461,10 @@ gsm_consolekit_attempt_stop (GsmConsolekit *manager) { gboolean res; GError *error; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -464,7 +474,7 @@ gsm_consolekit_attempt_stop (GsmConsolekit *manager) return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "Stop", INT_MAX, &error, @@ -485,8 +495,10 @@ gsm_consolekit_attempt_suspend (GsmConsolekit *manager) { gboolean res; GError *error; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -495,7 +507,7 @@ gsm_consolekit_attempt_suspend (GsmConsolekit *manager) return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "Suspend", INT_MAX, &error, @@ -514,8 +526,10 @@ gsm_consolekit_attempt_hibernate (GsmConsolekit *manager) { gboolean res; GError *error; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -524,7 +538,7 @@ gsm_consolekit_attempt_hibernate (GsmConsolekit *manager) return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "Hibernate", INT_MAX, &error, @@ -678,8 +692,10 @@ gsm_consolekit_set_session_idle (GsmConsolekit *manager, DBusMessage *reply; DBusError dbus_error; DBusMessageIter iter; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -689,7 +705,7 @@ gsm_consolekit_set_session_idle (GsmConsolekit *manager, } session_id = NULL; - res = get_current_session_id (dbus_g_connection_get_connection (manager->priv->dbus_connection), + res = get_current_session_id (dbus_g_connection_get_connection (priv->dbus_connection), &session_id); if (!res) { goto out; @@ -711,7 +727,7 @@ gsm_consolekit_set_session_idle (GsmConsolekit *manager, /* FIXME: use async? */ dbus_error_init (&dbus_error); - reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (manager->priv->dbus_connection), + reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (priv->dbus_connection), message, -1, &dbus_error); @@ -785,8 +801,10 @@ gsm_consolekit_can_switch_user (GsmConsolekit *manager) GError *error; char *seat_id; gboolean ret; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -795,13 +813,13 @@ gsm_consolekit_can_switch_user (GsmConsolekit *manager) return FALSE; } - seat_id = get_current_seat_id (dbus_g_connection_get_connection (manager->priv->dbus_connection)); + seat_id = get_current_seat_id (dbus_g_connection_get_connection (priv->dbus_connection)); if (seat_id == NULL || seat_id[0] == '\0') { g_debug ("seat id is not set; can't switch sessions"); return FALSE; } - ret = seat_can_activate_sessions (dbus_g_connection_get_connection (manager->priv->dbus_connection), + ret = seat_can_activate_sessions (dbus_g_connection_get_connection (priv->dbus_connection), seat_id); g_free (seat_id); @@ -834,8 +852,10 @@ gsm_consolekit_can_restart (GsmConsolekit *manager) gboolean res; gboolean can_restart; GError *error; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -844,7 +864,7 @@ gsm_consolekit_can_restart (GsmConsolekit *manager) return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "CanRestart", INT_MAX, &error, @@ -867,8 +887,10 @@ gsm_consolekit_can_stop (GsmConsolekit *manager) gboolean res; gboolean can_stop; GError *error; + GsmConsolekitPrivate *priv; error = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -877,7 +899,7 @@ gsm_consolekit_can_stop (GsmConsolekit *manager) return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "CanStop", INT_MAX, &error, @@ -902,6 +924,9 @@ gsm_consolekit_can_suspend (GsmConsolekit *manager) gboolean can_suspend; gchar *retval; GError *error = NULL; + GsmConsolekitPrivate *priv; + + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -910,7 +935,7 @@ gsm_consolekit_can_suspend (GsmConsolekit *manager) return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "CanSuspend", INT_MAX, &error, @@ -939,6 +964,9 @@ gsm_consolekit_can_hibernate (GsmConsolekit *manager) gboolean can_hibernate; gchar *retval; GError *error = NULL; + GsmConsolekitPrivate *priv; + + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &error)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -947,7 +975,7 @@ gsm_consolekit_can_hibernate (GsmConsolekit *manager) return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->ck_proxy, + res = dbus_g_proxy_call_with_timeout (priv->ck_proxy, "CanHibernate", INT_MAX, &error, @@ -981,10 +1009,12 @@ gsm_consolekit_get_current_session_type (GsmConsolekit *manager) gchar *ret; DBusMessageIter iter; const char *value; + GsmConsolekitPrivate *priv; session_id = NULL; ret = NULL; gerror = NULL; + priv = gsm_consolekit_get_instance_private (manager); if (!gsm_consolekit_ensure_ck_connection (manager, &gerror)) { g_warning ("Could not connect to ConsoleKit: %s", @@ -993,7 +1023,7 @@ gsm_consolekit_get_current_session_type (GsmConsolekit *manager) goto out; } - connection = dbus_g_connection_get_connection (manager->priv->dbus_connection); + connection = dbus_g_connection_get_connection (priv->dbus_connection); if (!get_current_session_id (connection, &session_id)) { goto out; } diff --git a/mate-session/gsm-consolekit.h b/mate-session/gsm-consolekit.h index 3dbb4f8..6cffd5b 100644 --- a/mate-session/gsm-consolekit.h +++ b/mate-session/gsm-consolekit.h @@ -27,29 +27,14 @@ #include <glib.h> #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_CONSOLEKIT (gsm_consolekit_get_type ()) -#define GSM_CONSOLEKIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_CONSOLEKIT, GsmConsolekit)) -#define GSM_CONSOLEKIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_CONSOLEKIT, GsmConsolekitClass)) -#define GSM_IS_CONSOLEKIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_CONSOLEKIT)) -#define GSM_IS_CONSOLEKIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_CONSOLEKIT)) -#define GSM_CONSOLEKIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSM_TYPE_CONSOLEKIT, GsmConsolekitClass)) #define GSM_CONSOLEKIT_ERROR (gsm_consolekit_error_quark ()) -typedef struct _GsmConsolekit GsmConsolekit; -typedef struct _GsmConsolekitClass GsmConsolekitClass; -typedef struct _GsmConsolekitPrivate GsmConsolekitPrivate; -typedef enum _GsmConsolekitError GsmConsolekitError; - -struct _GsmConsolekit -{ - GObject parent; +G_DECLARE_DERIVABLE_TYPE (GsmConsolekit, gsm_consolekit, GSM, CONSOLEKIT, GObject) - GsmConsolekitPrivate *priv; -}; +typedef enum _GsmConsolekitError GsmConsolekitError; struct _GsmConsolekitClass { @@ -71,7 +56,7 @@ enum _GsmConsolekitError { #define GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW "LoginWindow" -GType gsm_consolekit_get_type (void); +GType gsm_consolekit_get_type (void) G_GNUC_CONST; GQuark gsm_consolekit_error_quark (void); @@ -106,8 +91,6 @@ gchar *gsm_consolekit_get_current_session_type (GsmConsolekit *manager GsmConsolekit *gsm_get_consolekit (void); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_CONSOLEKIT_H__ */ diff --git a/mate-session/gsm-dbus-client.c b/mate-session/gsm-dbus-client.c index 3b33170..eba098c 100644 --- a/mate-session/gsm-dbus-client.c +++ b/mate-session/gsm-dbus-client.c @@ -38,13 +38,12 @@ #include "gsm-manager.h" #include "gsm-util.h" -#define GSM_DBUS_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_DBUS_CLIENT, GsmDBusClientPrivate)) - #define SM_DBUS_NAME "org.gnome.SessionManager" #define SM_DBUS_CLIENT_PRIVATE_INTERFACE "org.gnome.SessionManager.ClientPrivate" -struct GsmDBusClientPrivate +struct _GsmDBusClient { + GsmClient parent; char *bus_name; GPid caller_pid; GsmClientRestartStyle restart_style_hint; @@ -98,9 +97,9 @@ setup_connection (GsmDBusClient *client) dbus_error_init (&error); - if (client->priv->connection == NULL) { - client->priv->connection = dbus_bus_get (DBUS_BUS_SESSION, &error); - if (client->priv->connection == NULL) { + if (client->connection == NULL) { + client->connection = dbus_bus_get (DBUS_BUS_SESSION, &error); + if (client->connection == NULL) { if (dbus_error_is_set (&error)) { g_debug ("GsmDbusClient: Couldn't connect to session bus: %s", error.message); @@ -109,8 +108,8 @@ setup_connection (GsmDBusClient *client) return FALSE; } - dbus_connection_setup_with_g_main (client->priv->connection, NULL); - dbus_connection_set_exit_on_disconnect (client->priv->connection, FALSE); + dbus_connection_setup_with_g_main (client->connection, NULL); + dbus_connection_set_exit_on_disconnect (client->connection, FALSE); } return TRUE; @@ -160,7 +159,7 @@ handle_end_session_response (GsmDBusClient *client, g_warning ("Invalid method call: %s", error.message); dbus_error_free (&error); } - raise_error (client->priv->connection, + raise_error (client->connection, message, DBUS_ERROR_FAILED, "There is a syntax error in the invocation of the method EndSessionResponse"); @@ -172,10 +171,10 @@ handle_end_session_response (GsmDBusClient *client, /* make sure it is from our client */ sender = dbus_message_get_sender (message); if (sender == NULL - || IS_STRING_EMPTY (client->priv->bus_name) - || strcmp (sender, client->priv->bus_name) != 0) { + || IS_STRING_EMPTY (client->bus_name) + || strcmp (sender, client->bus_name) != 0) { - raise_error (client->priv->connection, + raise_error (client->connection, message, DBUS_ERROR_FAILED, "Caller not recognized as the client"); @@ -191,7 +190,7 @@ handle_end_session_response (GsmDBusClient *client, is_ok, FALSE, FALSE, reason); - if (! dbus_connection_send (client->priv->connection, reply, NULL)) { + if (! dbus_connection_send (client->connection, reply, NULL)) { g_error ("No memory"); } @@ -247,7 +246,7 @@ gsm_dbus_client_constructor (GType type, } /* Object path is already registered by base class */ - dbus_connection_add_filter (client->priv->connection, client_dbus_filter_function, client, NULL); + dbus_connection_add_filter (client->connection, client_dbus_filter_function, client, NULL); return G_OBJECT (client); } @@ -255,7 +254,6 @@ gsm_dbus_client_constructor (GType type, static void gsm_dbus_client_init (GsmDBusClient *client) { - client->priv = GSM_DBUS_CLIENT_GET_PRIVATE (client); } /* adapted from PolicyKit */ @@ -335,12 +333,12 @@ gsm_dbus_client_set_bus_name (GsmDBusClient *client, g_return_if_fail (GSM_IS_DBUS_CLIENT (client)); - g_free (client->priv->bus_name); + g_free (client->bus_name); - client->priv->bus_name = g_strdup (bus_name); + client->bus_name = g_strdup (bus_name); g_object_notify (G_OBJECT (client), "bus-name"); - if (client->priv->bus_name != NULL) { + if (client->bus_name != NULL) { gboolean res; res = get_caller_info (client, bus_name, &uid, &pid); @@ -350,7 +348,7 @@ gsm_dbus_client_set_bus_name (GsmDBusClient *client, } else { pid = 0; } - client->priv->caller_pid = pid; + client->caller_pid = pid; } const char * @@ -358,7 +356,7 @@ gsm_dbus_client_get_bus_name (GsmDBusClient *client) { g_return_val_if_fail (GSM_IS_DBUS_CLIENT (client), NULL); - return client->priv->bus_name; + return client->bus_name; } static void @@ -393,7 +391,7 @@ gsm_dbus_client_get_property (GObject *object, switch (prop_id) { case PROP_BUS_NAME: - g_value_set_string (value, self->priv->bus_name); + g_value_set_string (value, self->bus_name); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -406,7 +404,7 @@ gsm_dbus_client_finalize (GObject *object) { GsmDBusClient *client = (GsmDBusClient *) object; - g_free (client->priv->bus_name); + g_free (client->bus_name); G_OBJECT_CLASS (gsm_dbus_client_parent_class)->finalize (object); } @@ -441,11 +439,11 @@ dbus_client_stop (GsmClient *client, if (message == NULL) { goto out; } - if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) { + if (!dbus_message_set_destination (message, dbus_client->bus_name)) { goto out; } - if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) { + if (!dbus_connection_send (dbus_client->connection, message, NULL)) { goto out; } @@ -469,13 +467,13 @@ dbus_client_get_app_name (GsmClient *client) static GsmClientRestartStyle dbus_client_get_restart_style_hint (GsmClient *client) { - return (GSM_DBUS_CLIENT (client)->priv->restart_style_hint); + return (GSM_DBUS_CLIENT (client)->restart_style_hint); } static guint dbus_client_get_unix_process_id (GsmClient *client) { - return (GSM_DBUS_CLIENT (client)->priv->caller_pid); + return (GSM_DBUS_CLIENT (client)->caller_pid); } static gboolean @@ -490,7 +488,7 @@ dbus_client_query_end_session (GsmClient *client, ret = FALSE; - if (dbus_client->priv->bus_name == NULL) { + if (dbus_client->bus_name == NULL) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -498,7 +496,7 @@ dbus_client_query_end_session (GsmClient *client, return FALSE; } - g_debug ("GsmDBusClient: sending QueryEndSession signal to %s", dbus_client->priv->bus_name); + g_debug ("GsmDBusClient: sending QueryEndSession signal to %s", dbus_client->bus_name); /* unicast the signal to only the registered bus name */ message = dbus_message_new_signal (gsm_client_peek_id (client), @@ -511,7 +509,7 @@ dbus_client_query_end_session (GsmClient *client, "Unable to send QueryEndSession message"); goto out; } - if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) { + if (!dbus_message_set_destination (message, dbus_client->bus_name)) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -522,7 +520,7 @@ dbus_client_query_end_session (GsmClient *client, dbus_message_iter_init_append (message, &iter); dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags); - if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) { + if (!dbus_connection_send (dbus_client->connection, message, NULL)) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -563,7 +561,7 @@ dbus_client_end_session (GsmClient *client, "Unable to send EndSession message"); goto out; } - if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) { + if (!dbus_message_set_destination (message, dbus_client->bus_name)) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -574,7 +572,7 @@ dbus_client_end_session (GsmClient *client, dbus_message_iter_init_append (message, &iter); dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags); - if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) { + if (!dbus_connection_send (dbus_client->connection, message, NULL)) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -610,7 +608,7 @@ dbus_client_cancel_end_session (GsmClient *client, "Unable to send CancelEndSession message"); goto out; } - if (!dbus_message_set_destination (message, dbus_client->priv->bus_name)) { + if (!dbus_message_set_destination (message, dbus_client->bus_name)) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -618,7 +616,7 @@ dbus_client_cancel_end_session (GsmClient *client, goto out; } - if (!dbus_connection_send (dbus_client->priv->connection, message, NULL)) { + if (!dbus_connection_send (dbus_client->connection, message, NULL)) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -646,7 +644,7 @@ gsm_dbus_client_dispose (GObject *object) client = GSM_DBUS_CLIENT (object); - dbus_connection_remove_filter (client->priv->connection, client_dbus_filter_function, client); + dbus_connection_remove_filter (client->connection, client_dbus_filter_function, client); G_OBJECT_CLASS (gsm_dbus_client_parent_class)->dispose (object); } @@ -679,8 +677,6 @@ gsm_dbus_client_class_init (GsmDBusClientClass *klass) "bus-name", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_type_class_add_private (klass, sizeof (GsmDBusClientPrivate)); } GsmClient * diff --git a/mate-session/gsm-dbus-client.h b/mate-session/gsm-dbus-client.h index 4b9dc7a..a1007cc 100644 --- a/mate-session/gsm-dbus-client.h +++ b/mate-session/gsm-dbus-client.h @@ -23,32 +23,10 @@ #include "gsm-client.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_DBUS_CLIENT (gsm_dbus_client_get_type ()) -#define GSM_DBUS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_DBUS_CLIENT, GsmDBusClient)) -#define GSM_DBUS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_DBUS_CLIENT, GsmDBusClientClass)) -#define GSM_IS_DBUS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_DBUS_CLIENT)) -#define GSM_IS_DBUS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_DBUS_CLIENT)) -#define GSM_DBUS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_DBUS_CLIENT, GsmDBusClientClass)) - -typedef struct _GsmDBusClient GsmDBusClient; -typedef struct _GsmDBusClientClass GsmDBusClientClass; - -typedef struct GsmDBusClientPrivate GsmDBusClientPrivate; - -struct _GsmDBusClient -{ - GsmClient parent; - GsmDBusClientPrivate *priv; -}; - -struct _GsmDBusClientClass -{ - GsmClientClass parent_class; -}; +G_DECLARE_FINAL_TYPE (GsmDBusClient, gsm_dbus_client, GSM, DBUS_CLIENT, GsmClient) typedef enum { @@ -64,14 +42,10 @@ GType gsm_dbus_client_error_get_type (void); GQuark gsm_dbus_client_error_quark (void); -GType gsm_dbus_client_get_type (void) G_GNUC_CONST; - GsmClient * gsm_dbus_client_new (const char *startup_id, const char *bus_name); const char * gsm_dbus_client_get_bus_name (GsmDBusClient *client); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_DBUS_CLIENT_H__ */ diff --git a/mate-session/gsm-inhibit-dialog.c b/mate-session/gsm-inhibit-dialog.c index 1ea58ed..7c6ec97 100644 --- a/mate-session/gsm-inhibit-dialog.c +++ b/mate-session/gsm-inhibit-dialog.c @@ -43,8 +43,6 @@ #include <X11/extensions/Xrender.h> #endif -#define GSM_INHIBIT_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_INHIBIT_DIALOG, GsmInhibitDialogPrivate)) - #define GTKBUILDER_FILE "gsm-inhibit-dialog.ui" #ifndef DEFAULT_ICON_SIZE @@ -57,8 +55,9 @@ #define DIALOG_RESPONSE_LOCK_SCREEN 1 -struct GsmInhibitDialogPrivate +struct _GsmInhibitDialog { + GtkDialog parent; GtkBuilder *xml; int action; gboolean is_done; @@ -108,7 +107,7 @@ on_response (GsmInhibitDialog *dialog, gint response_id) { - if (dialog->priv->is_done) { + if (dialog->is_done) { g_signal_stop_emission_by_name (dialog, "response"); return; } @@ -119,7 +118,7 @@ on_response (GsmInhibitDialog *dialog, lock_screen (dialog); break; default: - dialog->priv->is_done = TRUE; + dialog->is_done = TRUE; break; } } @@ -128,7 +127,7 @@ static void gsm_inhibit_dialog_set_action (GsmInhibitDialog *dialog, int action) { - dialog->priv->action = action; + dialog->action = action; } static gboolean @@ -142,7 +141,7 @@ find_inhibitor (GsmInhibitDialog *dialog, g_assert (GSM_IS_INHIBIT_DIALOG (dialog)); found_item = FALSE; - model = GTK_TREE_MODEL (dialog->priv->list_store); + model = GTK_TREE_MODEL (dialog->list_store); if (!gtk_tree_model_get_iter_first (model, iter)) { return FALSE; @@ -479,7 +478,7 @@ add_inhibitor (GsmInhibitDialog *dialog, xid = gsm_inhibitor_peek_toplevel_xid (inhibitor); g_debug ("GsmInhibitDialog: inhibitor has XID %u", xid); - if (xid > 0 && dialog->priv->have_xrender) { + if (xid > 0 && dialog->have_xrender) { pixbuf = get_pixbuf_for_window (gdkdisplay, xid, DEFAULT_SNAPSHOT_SIZE, DEFAULT_SNAPSHOT_SIZE); if (pixbuf == NULL) { g_debug ("GsmInhibitDialog: unable to read pixbuf from %u", xid); @@ -567,7 +566,7 @@ add_inhibitor (GsmInhibitDialog *dialog, client_id = gsm_inhibitor_peek_client_id (inhibitor); if (! IS_STRING_EMPTY (client_id)) { GsmClient *client; - client = GSM_CLIENT (gsm_store_lookup (dialog->priv->clients, client_id)); + client = GSM_CLIENT (gsm_store_lookup (dialog->clients, client_id)); if (client != NULL) { freeme = gsm_client_get_app_name (client); name = freeme; @@ -592,7 +591,7 @@ add_inhibitor (GsmInhibitDialog *dialog, NULL); } - gtk_list_store_insert_with_values (dialog->priv->list_store, + gtk_list_store_insert_with_values (dialog->list_store, NULL, 0, INHIBIT_IMAGE_COLUMN, pixbuf, INHIBIT_NAME_COLUMN, name, @@ -628,7 +627,7 @@ update_dialog_text (GsmInhibitDialog *dialog) const char *header_text; GtkWidget *widget; - if (model_has_one_entry (GTK_TREE_MODEL (dialog->priv->list_store))) { + if (model_has_one_entry (GTK_TREE_MODEL (dialog->list_store))) { g_debug ("Found one entry in model"); header_text = _("A program is still running:"); description_text = _("Waiting for the program to finish. Interrupting the program may cause you to lose work."); @@ -638,7 +637,7 @@ update_dialog_text (GsmInhibitDialog *dialog) description_text = _("Waiting for programs to finish. Interrupting these programs may cause you to lose work."); } - widget = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml, + widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "header-label")); if (widget != NULL) { char *markup; @@ -647,7 +646,7 @@ update_dialog_text (GsmInhibitDialog *dialog) g_free (markup); } - widget = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml, + widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "description-label")); if (widget != NULL) { gtk_label_set_text (GTK_LABEL (widget), description_text); @@ -664,7 +663,7 @@ on_store_inhibitor_added (GsmStore *store, g_debug ("GsmInhibitDialog: inhibitor added: %s", id); - if (dialog->priv->is_done) { + if (dialog->is_done) { return; } @@ -687,18 +686,18 @@ on_store_inhibitor_removed (GsmStore *store, g_debug ("GsmInhibitDialog: inhibitor removed: %s", id); - if (dialog->priv->is_done) { + if (dialog->is_done) { return; } /* Remove from model */ if (find_inhibitor (dialog, id, &iter)) { - gtk_list_store_remove (dialog->priv->list_store, &iter); + gtk_list_store_remove (dialog->list_store, &iter); update_dialog_text (dialog); } /* if there are no inhibitors left then trigger response */ - if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->priv->list_store), &iter)) { + if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->list_store), &iter)) { gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); } } @@ -713,28 +712,28 @@ gsm_inhibit_dialog_set_inhibitor_store (GsmInhibitDialog *dialog, g_object_ref (store); } - if (dialog->priv->inhibitors != NULL) { - g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors, + if (dialog->inhibitors != NULL) { + g_signal_handlers_disconnect_by_func (dialog->inhibitors, on_store_inhibitor_added, dialog); - g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors, + g_signal_handlers_disconnect_by_func (dialog->inhibitors, on_store_inhibitor_removed, dialog); - g_object_unref (dialog->priv->inhibitors); + g_object_unref (dialog->inhibitors); } g_debug ("GsmInhibitDialog: setting store %p", store); - dialog->priv->inhibitors = store; + dialog->inhibitors = store; - if (dialog->priv->inhibitors != NULL) { - g_signal_connect (dialog->priv->inhibitors, + if (dialog->inhibitors != NULL) { + g_signal_connect (dialog->inhibitors, "added", G_CALLBACK (on_store_inhibitor_added), dialog); - g_signal_connect (dialog->priv->inhibitors, + g_signal_connect (dialog->inhibitors, "removed", G_CALLBACK (on_store_inhibitor_removed), dialog); @@ -751,11 +750,11 @@ gsm_inhibit_dialog_set_client_store (GsmInhibitDialog *dialog, g_object_ref (store); } - if (dialog->priv->clients != NULL) { - g_object_unref (dialog->priv->clients); + if (dialog->clients != NULL) { + g_object_unref (dialog->clients); } - dialog->priv->clients = store; + dialog->clients = store; } static void @@ -792,13 +791,13 @@ gsm_inhibit_dialog_get_property (GObject *object, switch (prop_id) { case PROP_ACTION: - g_value_set_int (value, dialog->priv->action); + g_value_set_int (value, dialog->action); break; case PROP_INHIBITOR_STORE: - g_value_set_object (value, dialog->priv->inhibitors); + g_value_set_object (value, dialog->inhibitors); break; case PROP_CLIENT_STORE: - g_value_set_object (value, dialog->priv->clients); + g_value_set_object (value, dialog->clients); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -849,7 +848,7 @@ add_to_model (const char *id, static void populate_model (GsmInhibitDialog *dialog) { - gsm_store_foreach_remove (dialog->priv->inhibitors, + gsm_store_foreach_remove (dialog->inhibitors, (GsmStoreFunc)add_to_model, dialog); update_dialog_text (dialog); @@ -863,7 +862,7 @@ setup_dialog (GsmInhibitDialog *dialog) GtkTreeViewColumn *column; GtkCellRenderer *renderer; - switch (dialog->priv->action) { + switch (dialog->action) { case GSM_LOGOUT_ACTION_SWITCH_USER: button_text = _("Switch User Anyway"); break; @@ -901,17 +900,17 @@ setup_dialog (GsmInhibitDialog *dialog) G_CALLBACK (on_response), dialog); - dialog->priv->list_store = gtk_list_store_new (NUMBER_OF_COLUMNS, - GDK_TYPE_PIXBUF, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING); + dialog->list_store = gtk_list_store_new (NUMBER_OF_COLUMNS, + GDK_TYPE_PIXBUF, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); - treeview = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml, + treeview = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "inhibitors-treeview")); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), - GTK_TREE_MODEL (dialog->priv->list_store)); + GTK_TREE_MODEL (dialog->list_store)); /* IMAGE COLUMN */ renderer = gtk_cell_renderer_pixbuf_new (); @@ -953,25 +952,25 @@ gsm_inhibit_dialog_constructor (GType type, GdkDisplay *gdkdisplay; #endif /* HAVE_XRENDER */ dialog = GSM_INHIBIT_DIALOG (G_OBJECT_CLASS (gsm_inhibit_dialog_parent_class)->constructor (type, - n_construct_properties, - construct_properties)); + n_construct_properties, + construct_properties)); #ifdef HAVE_XRENDER gdkdisplay = gdk_display_get_default (); gdk_x11_display_error_trap_push (gdkdisplay); - if (XRenderQueryExtension (GDK_DISPLAY_XDISPLAY (gdkdisplay), &dialog->priv->xrender_event_base, &dialog->priv->xrender_error_base)) { + if (XRenderQueryExtension (GDK_DISPLAY_XDISPLAY (gdkdisplay), &dialog->xrender_event_base, &dialog->xrender_error_base)) { g_debug ("GsmInhibitDialog: Initialized XRender extension"); - dialog->priv->have_xrender = TRUE; + dialog->have_xrender = TRUE; } else { g_debug ("GsmInhibitDialog: Unable to initialize XRender extension"); - dialog->priv->have_xrender = FALSE; + dialog->have_xrender = FALSE; } gdk_display_sync (gdkdisplay); gdk_x11_display_error_trap_pop_ignored (gdkdisplay); #endif /* HAVE_XRENDER */ /* FIXME: turn this on when it is ready */ - dialog->priv->have_xrender = FALSE; + dialog->have_xrender = FALSE; setup_dialog (dialog); @@ -992,26 +991,26 @@ gsm_inhibit_dialog_dispose (GObject *object) g_debug ("GsmInhibitDialog: dispose called"); - if (dialog->priv->list_store != NULL) { - g_object_unref (dialog->priv->list_store); - dialog->priv->list_store = NULL; + if (dialog->list_store != NULL) { + g_object_unref (dialog->list_store); + dialog->list_store = NULL; } - if (dialog->priv->inhibitors != NULL) { - g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors, + if (dialog->inhibitors != NULL) { + g_signal_handlers_disconnect_by_func (dialog->inhibitors, on_store_inhibitor_added, dialog); - g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors, + g_signal_handlers_disconnect_by_func (dialog->inhibitors, on_store_inhibitor_removed, dialog); - g_object_unref (dialog->priv->inhibitors); - dialog->priv->inhibitors = NULL; + g_object_unref (dialog->inhibitors); + dialog->inhibitors = NULL; } - if (dialog->priv->xml != NULL) { - g_object_unref (dialog->priv->xml); - dialog->priv->xml = NULL; + if (dialog->xml != NULL) { + g_object_unref (dialog->xml); + dialog->xml = NULL; } G_OBJECT_CLASS (gsm_inhibit_dialog_parent_class)->dispose (object); @@ -1051,8 +1050,6 @@ gsm_inhibit_dialog_class_init (GsmInhibitDialogClass *klass) NULL, GSM_TYPE_STORE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_type_class_add_private (klass, sizeof (GsmInhibitDialogPrivate)); } static void @@ -1062,13 +1059,11 @@ gsm_inhibit_dialog_init (GsmInhibitDialog *dialog) GtkWidget *widget; GError *error; - dialog->priv = GSM_INHIBIT_DIALOG_GET_PRIVATE (dialog); - - dialog->priv->xml = gtk_builder_new (); - gtk_builder_set_translation_domain (dialog->priv->xml, GETTEXT_PACKAGE); + dialog->xml = gtk_builder_new (); + gtk_builder_set_translation_domain (dialog->xml, GETTEXT_PACKAGE); error = NULL; - if (!gtk_builder_add_from_file (dialog->priv->xml, + if (!gtk_builder_add_from_file (dialog->xml, GTKBUILDER_DIR "/" GTKBUILDER_FILE, &error)) { if (error) { @@ -1081,7 +1076,7 @@ gsm_inhibit_dialog_init (GsmInhibitDialog *dialog) } content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - widget = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml, + widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "main-box")); gtk_container_add (GTK_CONTAINER (content_area), widget); @@ -1103,7 +1098,7 @@ gsm_inhibit_dialog_finalize (GObject *object) dialog = GSM_INHIBIT_DIALOG (object); - g_return_if_fail (dialog->priv != NULL); + g_return_if_fail (dialog != NULL); g_debug ("GsmInhibitDialog: finalizing"); diff --git a/mate-session/gsm-inhibit-dialog.h b/mate-session/gsm-inhibit-dialog.h index c48dc90..89c7121 100644 --- a/mate-session/gsm-inhibit-dialog.h +++ b/mate-session/gsm-inhibit-dialog.h @@ -26,18 +26,10 @@ #include "gsm-store.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_INHIBIT_DIALOG (gsm_inhibit_dialog_get_type ()) -#define GSM_INHIBIT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_INHIBIT_DIALOG, GsmInhibitDialog)) -#define GSM_INHIBIT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_INHIBIT_DIALOG, GsmInhibitDialogClass)) -#define GSM_IS_INHIBIT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_INHIBIT_DIALOG)) -#define GSM_IS_INHIBIT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_INHIBIT_DIALOG)) -#define GSM_INHIBIT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_INHIBIT_DIALOG, GsmInhibitDialogClass)) - -typedef struct GsmInhibitDialogPrivate GsmInhibitDialogPrivate; +G_DECLARE_FINAL_TYPE (GsmInhibitDialog, gsm_inhibit_dialog, GSM, INHIBIT_DIALOG, GtkDialog) typedef enum { @@ -49,26 +41,11 @@ typedef enum GSM_LOGOUT_ACTION_SLEEP } GsmLogoutAction; -typedef struct -{ - GtkDialog parent; - GsmInhibitDialogPrivate *priv; -} GsmInhibitDialog; - -typedef struct -{ - GtkDialogClass parent_class; -} GsmInhibitDialogClass; - -GType gsm_inhibit_dialog_get_type (void); - GtkWidget * gsm_inhibit_dialog_new (GsmStore *inhibitors, GsmStore *clients, int action); GtkTreeModel * gsm_inhibit_dialog_get_model (GsmInhibitDialog *dialog); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_INHIBIT_DIALOG_H */ diff --git a/mate-session/gsm-inhibitor.c b/mate-session/gsm-inhibitor.c index 6f4e229..6129ddb 100644 --- a/mate-session/gsm-inhibitor.c +++ b/mate-session/gsm-inhibitor.c @@ -34,10 +34,9 @@ static guint32 inhibitor_serial = 1; -#define GSM_INHIBITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_INHIBITOR, GsmInhibitorPrivate)) - -struct GsmInhibitorPrivate +struct _GsmInhibitor { + GObject parent; char *id; char *bus_name; char *app_id; @@ -115,8 +114,8 @@ register_inhibitor (GsmInhibitor *inhibitor) GError *error; error = NULL; - inhibitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (inhibitor->priv->connection == NULL) { + inhibitor->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + if (inhibitor->connection == NULL) { if (error != NULL) { g_critical ("error getting session bus: %s", error->message); g_error_free (error); @@ -124,7 +123,7 @@ register_inhibitor (GsmInhibitor *inhibitor) return FALSE; } - dbus_g_connection_register_g_object (inhibitor->priv->connection, inhibitor->priv->id, G_OBJECT (inhibitor)); + dbus_g_connection_register_g_object (inhibitor->connection, inhibitor->id, G_OBJECT (inhibitor)); return TRUE; } @@ -141,8 +140,8 @@ gsm_inhibitor_constructor (GType type, n_construct_properties, construct_properties)); - g_free (inhibitor->priv->id); - inhibitor->priv->id = g_strdup_printf ("/org/gnome/SessionManager/Inhibitor%u", get_next_inhibitor_serial ()); + g_free (inhibitor->id); + inhibitor->id = g_strdup_printf ("/org/gnome/SessionManager/Inhibitor%u", get_next_inhibitor_serial ()); res = register_inhibitor (inhibitor); if (! res) { g_warning ("Unable to register inhibitor with session bus"); @@ -154,7 +153,6 @@ gsm_inhibitor_constructor (GType type, static void gsm_inhibitor_init (GsmInhibitor *inhibitor) { - inhibitor->priv = GSM_INHIBITOR_GET_PRIVATE (inhibitor); } static void @@ -163,12 +161,12 @@ gsm_inhibitor_set_bus_name (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - g_free (inhibitor->priv->bus_name); + g_free (inhibitor->bus_name); if (bus_name != NULL) { - inhibitor->priv->bus_name = g_strdup (bus_name); + inhibitor->bus_name = g_strdup (bus_name); } else { - inhibitor->priv->bus_name = g_strdup (""); + inhibitor->bus_name = g_strdup (""); } g_object_notify (G_OBJECT (inhibitor), "bus-name"); } @@ -179,9 +177,9 @@ gsm_inhibitor_set_app_id (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - g_free (inhibitor->priv->app_id); + g_free (inhibitor->app_id); - inhibitor->priv->app_id = g_strdup (app_id); + inhibitor->app_id = g_strdup (app_id); g_object_notify (G_OBJECT (inhibitor), "app-id"); } @@ -191,14 +189,14 @@ gsm_inhibitor_set_client_id (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - g_free (inhibitor->priv->client_id); + g_free (inhibitor->client_id); g_debug ("GsmInhibitor: setting client-id = %s", client_id); if (client_id != NULL) { - inhibitor->priv->client_id = g_strdup (client_id); + inhibitor->client_id = g_strdup (client_id); } else { - inhibitor->priv->client_id = g_strdup (""); + inhibitor->client_id = g_strdup (""); } g_object_notify (G_OBJECT (inhibitor), "client-id"); } @@ -209,12 +207,12 @@ gsm_inhibitor_set_reason (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - g_free (inhibitor->priv->reason); + g_free (inhibitor->reason); if (reason != NULL) { - inhibitor->priv->reason = g_strdup (reason); + inhibitor->reason = g_strdup (reason); } else { - inhibitor->priv->reason = g_strdup (""); + inhibitor->reason = g_strdup (""); } g_object_notify (G_OBJECT (inhibitor), "reason"); } @@ -225,8 +223,8 @@ gsm_inhibitor_set_cookie (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - if (inhibitor->priv->cookie != cookie) { - inhibitor->priv->cookie = cookie; + if (inhibitor->cookie != cookie) { + inhibitor->cookie = cookie; g_object_notify (G_OBJECT (inhibitor), "cookie"); } } @@ -237,8 +235,8 @@ gsm_inhibitor_set_flags (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - if (inhibitor->priv->flags != flags) { - inhibitor->priv->flags = flags; + if (inhibitor->flags != flags) { + inhibitor->flags = flags; g_object_notify (G_OBJECT (inhibitor), "flags"); } } @@ -249,8 +247,8 @@ gsm_inhibitor_set_toplevel_xid (GsmInhibitor *inhibitor, { g_return_if_fail (GSM_IS_INHIBITOR (inhibitor)); - if (inhibitor->priv->toplevel_xid != xid) { - inhibitor->priv->toplevel_xid = xid; + if (inhibitor->toplevel_xid != xid) { + inhibitor->toplevel_xid = xid; g_object_notify (G_OBJECT (inhibitor), "toplevel-xid"); } } @@ -260,7 +258,7 @@ gsm_inhibitor_peek_bus_name (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL); - return inhibitor->priv->bus_name; + return inhibitor->bus_name; } gboolean @@ -270,8 +268,8 @@ gsm_inhibitor_get_app_id (GsmInhibitor *inhibitor, { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - if (inhibitor->priv->app_id != NULL) { - *id = g_strdup (inhibitor->priv->app_id); + if (inhibitor->app_id != NULL) { + *id = g_strdup (inhibitor->app_id); } else { *id = g_strdup (""); } @@ -287,7 +285,7 @@ gsm_inhibitor_get_client_id (GsmInhibitor *inhibitor, g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); /* object paths are not allowed to be NULL or blank */ - if (IS_STRING_EMPTY (inhibitor->priv->client_id)) { + if (IS_STRING_EMPTY (inhibitor->client_id)) { g_set_error (error, GSM_INHIBITOR_ERROR, GSM_INHIBITOR_ERROR_NOT_SET, @@ -295,7 +293,7 @@ gsm_inhibitor_get_client_id (GsmInhibitor *inhibitor, return FALSE; } - *id = g_strdup (inhibitor->priv->client_id); + *id = g_strdup (inhibitor->client_id); g_debug ("GsmInhibitor: getting client-id = '%s'", *id); @@ -309,8 +307,8 @@ gsm_inhibitor_get_reason (GsmInhibitor *inhibitor, { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - if (inhibitor->priv->reason != NULL) { - *reason = g_strdup (inhibitor->priv->reason); + if (inhibitor->reason != NULL) { + *reason = g_strdup (inhibitor->reason); } else { *reason = g_strdup (""); } @@ -325,7 +323,7 @@ gsm_inhibitor_get_flags (GsmInhibitor *inhibitor, { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - *flags = inhibitor->priv->flags; + *flags = inhibitor->flags; return TRUE; } @@ -337,7 +335,7 @@ gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor, { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE); - *xid = inhibitor->priv->toplevel_xid; + *xid = inhibitor->toplevel_xid; return TRUE; } @@ -347,7 +345,7 @@ gsm_inhibitor_peek_id (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL); - return inhibitor->priv->id; + return inhibitor->id; } const char * @@ -355,7 +353,7 @@ gsm_inhibitor_peek_app_id (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL); - return inhibitor->priv->app_id; + return inhibitor->app_id; } const char * @@ -363,7 +361,7 @@ gsm_inhibitor_peek_client_id (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL); - return inhibitor->priv->client_id; + return inhibitor->client_id; } const char * @@ -371,7 +369,7 @@ gsm_inhibitor_peek_reason (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL); - return inhibitor->priv->reason; + return inhibitor->reason; } guint @@ -379,7 +377,7 @@ gsm_inhibitor_peek_flags (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0); - return inhibitor->priv->flags; + return inhibitor->flags; } guint @@ -387,7 +385,7 @@ gsm_inhibitor_peek_toplevel_xid (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0); - return inhibitor->priv->toplevel_xid; + return inhibitor->toplevel_xid; } guint @@ -395,7 +393,7 @@ gsm_inhibitor_peek_cookie (GsmInhibitor *inhibitor) { g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0); - return inhibitor->priv->cookie; + return inhibitor->cookie; } static void @@ -448,25 +446,25 @@ gsm_inhibitor_get_property (GObject *object, switch (prop_id) { case PROP_BUS_NAME: - g_value_set_string (value, self->priv->bus_name); + g_value_set_string (value, self->bus_name); break; case PROP_APP_ID: - g_value_set_string (value, self->priv->app_id); + g_value_set_string (value, self->app_id); break; case PROP_CLIENT_ID: - g_value_set_string (value, self->priv->client_id); + g_value_set_string (value, self->client_id); break; case PROP_REASON: - g_value_set_string (value, self->priv->reason); + g_value_set_string (value, self->reason); break; case PROP_FLAGS: - g_value_set_uint (value, self->priv->flags); + g_value_set_uint (value, self->flags); break; case PROP_COOKIE: - g_value_set_uint (value, self->priv->cookie); + g_value_set_uint (value, self->cookie); break; case PROP_TOPLEVEL_XID: - g_value_set_uint (value, self->priv->toplevel_xid); + g_value_set_uint (value, self->toplevel_xid); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -479,11 +477,11 @@ gsm_inhibitor_finalize (GObject *object) { GsmInhibitor *inhibitor = (GsmInhibitor *) object; - g_free (inhibitor->priv->id); - g_free (inhibitor->priv->bus_name); - g_free (inhibitor->priv->app_id); - g_free (inhibitor->priv->client_id); - g_free (inhibitor->priv->reason); + g_free (inhibitor->id); + g_free (inhibitor->bus_name); + g_free (inhibitor->app_id); + g_free (inhibitor->client_id); + g_free (inhibitor->reason); G_OBJECT_CLASS (gsm_inhibitor_parent_class)->finalize (object); } @@ -556,7 +554,6 @@ gsm_inhibitor_class_init (GsmInhibitorClass *klass) dbus_g_object_type_install_info (GSM_TYPE_INHIBITOR, &dbus_glib_gsm_inhibitor_object_info); dbus_g_error_domain_register (GSM_INHIBITOR_ERROR, NULL, GSM_INHIBITOR_TYPE_ERROR); - g_type_class_add_private (klass, sizeof (GsmInhibitorPrivate)); } GsmInhibitor * diff --git a/mate-session/gsm-inhibitor.h b/mate-session/gsm-inhibitor.h index 66aba28..653f717 100644 --- a/mate-session/gsm-inhibitor.h +++ b/mate-session/gsm-inhibitor.h @@ -24,32 +24,12 @@ #include <glib-object.h> #include <sys/types.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_INHIBITOR (gsm_inhibitor_get_type ()) -#define GSM_INHIBITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_INHIBITOR, GsmInhibitor)) -#define GSM_INHIBITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_INHIBITOR, GsmInhibitorClass)) -#define GSM_IS_INHIBITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_INHIBITOR)) -#define GSM_IS_INHIBITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_INHIBITOR)) -#define GSM_INHIBITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_INHIBITOR, GsmInhibitorClass)) - -typedef struct _GsmInhibitor GsmInhibitor; -typedef struct _GsmInhibitorClass GsmInhibitorClass; - -typedef struct GsmInhibitorPrivate GsmInhibitorPrivate; - -struct _GsmInhibitor -{ - GObject parent; - GsmInhibitorPrivate *priv; -}; - -struct _GsmInhibitorClass -{ - GObjectClass parent_class; -}; +#define GSM_INHIBITOR_ERROR (gsm_inhibitor_error_quark ()) +#define GSM_INHIBITOR_TYPE_ERROR (gsm_inhibitor_error_get_type ()) +G_DECLARE_FINAL_TYPE (GsmInhibitor, gsm_inhibitor, GSM, INHIBITOR, GObject) typedef enum { GSM_INHIBITOR_FLAG_LOGOUT = 1 << 0, @@ -65,14 +45,10 @@ typedef enum GSM_INHIBITOR_NUM_ERRORS } GsmInhibitorError; -#define GSM_INHIBITOR_ERROR gsm_inhibitor_error_quark () GType gsm_inhibitor_error_get_type (void); -#define GSM_INHIBITOR_TYPE_ERROR (gsm_inhibitor_error_get_type ()) GQuark gsm_inhibitor_error_quark (void); -GType gsm_inhibitor_get_type (void) G_GNUC_CONST; - GsmInhibitor * gsm_inhibitor_new (const char *app_id, guint toplevel_xid, guint flags, @@ -112,9 +88,6 @@ gboolean gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor, guint *xid, GError **error); - -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_INHIBITOR_H__ */ diff --git a/mate-session/gsm-logout-dialog.c b/mate-session/gsm-logout-dialog.c index 3183036..0b5741c 100644 --- a/mate-session/gsm-logout-dialog.c +++ b/mate-session/gsm-logout-dialog.c @@ -34,9 +34,6 @@ #include "gsm-consolekit.h" #include "mdm.h" -#define GSM_LOGOUT_DIALOG_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_LOGOUT_DIALOG, GsmLogoutDialogPrivate)) - #define GSM_ICON_LOGOUT "system-log-out" #define GSM_ICON_SHUTDOWN "system-shutdown" @@ -51,8 +48,9 @@ typedef enum { GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN } GsmDialogLogoutType; -struct _GsmLogoutDialogPrivate +struct _GsmLogoutDialog { + GtkMessageDialog parent; GsmDialogLogoutType type; #ifdef HAVE_SYSTEMD GsmSystemd *systemd; @@ -133,32 +131,28 @@ gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass) g_object_class_override_property (gobject_class, PROP_MESSAGE_TYPE, "message-type"); - - g_type_class_add_private (klass, sizeof (GsmLogoutDialogPrivate)); } static void gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog) { - logout_dialog->priv = GSM_LOGOUT_DIALOG_GET_PRIVATE (logout_dialog); - - logout_dialog->priv->timeout_id = 0; - logout_dialog->priv->timeout = 0; - logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL; + logout_dialog->timeout_id = 0; + logout_dialog->timeout = 0; + logout_dialog->default_response = GTK_RESPONSE_CANCEL; - GtkStyleContext *context; - context = gtk_widget_get_style_context (GTK_WIDGET (logout_dialog)); - gtk_style_context_add_class (context, "logout-dialog"); + GtkStyleContext *context; + context = gtk_widget_get_style_context (GTK_WIDGET (logout_dialog)); + gtk_style_context_add_class (context, "logout-dialog"); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE); gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE); gtk_window_stick (GTK_WINDOW (logout_dialog)); #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) - logout_dialog->priv->systemd = gsm_get_systemd (); + logout_dialog->systemd = gsm_get_systemd (); else #endif - logout_dialog->priv->consolekit = gsm_get_consolekit (); + logout_dialog->consolekit = gsm_get_consolekit (); g_signal_connect (logout_dialog, "destroy", @@ -175,20 +169,20 @@ static void gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog, gpointer data) { - if (logout_dialog->priv->timeout_id != 0) { - g_source_remove (logout_dialog->priv->timeout_id); - logout_dialog->priv->timeout_id = 0; + if (logout_dialog->timeout_id != 0) { + g_source_remove (logout_dialog->timeout_id); + logout_dialog->timeout_id = 0; } #ifdef HAVE_SYSTEMD - if (logout_dialog->priv->systemd) { - g_object_unref (logout_dialog->priv->systemd); - logout_dialog->priv->systemd = NULL; + if (logout_dialog->systemd) { + g_object_unref (logout_dialog->systemd); + logout_dialog->systemd = NULL; } #endif - if (logout_dialog->priv->consolekit) { - g_object_unref (logout_dialog->priv->consolekit); - logout_dialog->priv->consolekit = NULL; + if (logout_dialog->consolekit) { + g_object_unref (logout_dialog->consolekit); + logout_dialog->consolekit = NULL; } current_dialog = NULL; @@ -201,10 +195,10 @@ gsm_logout_supports_system_suspend (GsmLogoutDialog *logout_dialog) ret = FALSE; #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) - ret = gsm_systemd_can_suspend (logout_dialog->priv->systemd); + ret = gsm_systemd_can_suspend (logout_dialog->systemd); else #endif - ret = gsm_consolekit_can_suspend (logout_dialog->priv->consolekit); + ret = gsm_consolekit_can_suspend (logout_dialog->consolekit); return ret; } @@ -215,10 +209,10 @@ gsm_logout_supports_system_hibernate (GsmLogoutDialog *logout_dialog) ret = FALSE; #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) - ret = gsm_systemd_can_hibernate (logout_dialog->priv->systemd); + ret = gsm_systemd_can_hibernate (logout_dialog->systemd); else #endif - ret = gsm_consolekit_can_hibernate (logout_dialog->priv->consolekit); + ret = gsm_consolekit_can_hibernate (logout_dialog->consolekit); return ret; } @@ -237,10 +231,10 @@ gsm_logout_supports_switch_user (GsmLogoutDialog *logout_dialog) if (!locked) { #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) - ret = gsm_systemd_can_switch_user (logout_dialog->priv->systemd); + ret = gsm_systemd_can_switch_user (logout_dialog->systemd); else #endif - ret = gsm_consolekit_can_switch_user (logout_dialog->priv->consolekit); + ret = gsm_consolekit_can_switch_user (logout_dialog->consolekit); } return ret; @@ -253,10 +247,10 @@ gsm_logout_supports_reboot (GsmLogoutDialog *logout_dialog) #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) - ret = gsm_systemd_can_restart (logout_dialog->priv->systemd); + ret = gsm_systemd_can_restart (logout_dialog->systemd); else #endif - ret = gsm_consolekit_can_restart (logout_dialog->priv->consolekit); + ret = gsm_consolekit_can_restart (logout_dialog->consolekit); if (!ret) { ret = mdm_supports_logout_action (MDM_LOGOUT_ACTION_REBOOT); } @@ -271,10 +265,10 @@ gsm_logout_supports_shutdown (GsmLogoutDialog *logout_dialog) #ifdef HAVE_SYSTEMD if (LOGIND_RUNNING()) - ret = gsm_systemd_can_stop (logout_dialog->priv->systemd); + ret = gsm_systemd_can_stop (logout_dialog->systemd); else #endif - ret = gsm_consolekit_can_stop (logout_dialog->priv->consolekit); + ret = gsm_consolekit_can_stop (logout_dialog->consolekit); if (!ret) { ret = mdm_supports_logout_action (MDM_LOGOUT_ACTION_SHUTDOWN); @@ -300,20 +294,20 @@ gsm_logout_dialog_timeout (gpointer data) logout_dialog = (GsmLogoutDialog *) data; - if (!logout_dialog->priv->timeout) { + if (!logout_dialog->timeout) { gtk_dialog_response (GTK_DIALOG (logout_dialog), - logout_dialog->priv->default_response); + logout_dialog->default_response); return FALSE; } - switch (logout_dialog->priv->type) { + switch (logout_dialog->type) { case GSM_DIALOG_LOGOUT_TYPE_LOGOUT: seconds_warning = ngettext ("You will be automatically logged " "out in %d second", "You will be automatically logged " "out in %d seconds", - logout_dialog->priv->timeout); + logout_dialog->timeout); break; case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: @@ -321,13 +315,13 @@ gsm_logout_dialog_timeout (gpointer data) "shut down in %d second", "This system will be automatically " "shut down in %d seconds", - logout_dialog->priv->timeout); + logout_dialog->timeout); break; default: g_assert_not_reached (); } - seconds_warning = g_strdup_printf (seconds_warning, logout_dialog->priv->timeout); + seconds_warning = g_strdup_printf (seconds_warning, logout_dialog->timeout); if (session_type == NULL) { #ifdef HAVE_SYSTEMD @@ -370,16 +364,16 @@ gsm_logout_dialog_timeout (gpointer data) secondary_text = g_strdup (seconds_warning); } - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), - logout_dialog->priv->timeout / 60.0); - gtk_progress_bar_set_text (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->progressbar), + logout_dialog->timeout / 60.0); + gtk_progress_bar_set_text (GTK_PROGRESS_BAR (logout_dialog->progressbar), seconds_warning); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog), secondary_text, NULL); - logout_dialog->priv->timeout--; + logout_dialog->timeout--; g_free (secondary_text); g_free (seconds_warning); @@ -394,22 +388,22 @@ gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog) settings = g_settings_new (SESSION_SCHEMA); - logout_dialog->priv->timeout = g_settings_get_int (settings, KEY_LOGOUT_TIMEOUT); + logout_dialog->timeout = g_settings_get_int (settings, KEY_LOGOUT_TIMEOUT); - if (logout_dialog->priv->timeout > 0) { + if (logout_dialog->timeout > 0) { /* Sets the secondary text */ gsm_logout_dialog_timeout (logout_dialog); - if (logout_dialog->priv->timeout_id != 0) { - g_source_remove (logout_dialog->priv->timeout_id); + if (logout_dialog->timeout_id != 0) { + g_source_remove (logout_dialog->timeout_id); } - logout_dialog->priv->timeout_id = g_timeout_add (1000, - gsm_logout_dialog_timeout, - logout_dialog); + logout_dialog->timeout_id = g_timeout_add (1000, + gsm_logout_dialog_timeout, + logout_dialog); } else { - gtk_widget_hide (logout_dialog->priv->progressbar); + gtk_widget_hide (logout_dialog->progressbar); } g_object_unref (settings); @@ -435,7 +429,7 @@ gsm_get_dialog (GsmDialogLogoutType type, gtk_window_set_title (GTK_WINDOW (logout_dialog), ""); - logout_dialog->priv->type = type; + logout_dialog->type = type; icon_name = NULL; primary_text = NULL; @@ -445,7 +439,7 @@ gsm_get_dialog (GsmDialogLogoutType type, icon_name = GSM_ICON_LOGOUT; primary_text = _("Log out of this system now?"); - logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT; + logout_dialog->default_response = GSM_LOGOUT_RESPONSE_LOGOUT; if (gsm_logout_supports_switch_user (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), @@ -466,7 +460,7 @@ gsm_get_dialog (GsmDialogLogoutType type, icon_name = GSM_ICON_SHUTDOWN; primary_text = _("Shut down this system now?"); - logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN; + logout_dialog->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN; if (gsm_logout_supports_system_suspend (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), @@ -501,11 +495,11 @@ gsm_get_dialog (GsmDialogLogoutType type, } hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - logout_dialog->priv->progressbar = gtk_progress_bar_new (); - gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), TRUE); - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), 1.0); + logout_dialog->progressbar = gtk_progress_bar_new (); + gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (logout_dialog->progressbar), TRUE); + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->progressbar), 1.0); gtk_box_pack_start (GTK_BOX (hbox), - logout_dialog->priv->progressbar, + logout_dialog->progressbar, TRUE, TRUE, 12); gtk_widget_show_all (hbox); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (logout_dialog))), hbox); @@ -515,7 +509,7 @@ gsm_get_dialog (GsmDialogLogoutType type, gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (logout_dialog), primary_text); gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog), - logout_dialog->priv->default_response); + logout_dialog->default_response); gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen); diff --git a/mate-session/gsm-logout-dialog.h b/mate-session/gsm-logout-dialog.h index dcde2cb..2166521 100644 --- a/mate-session/gsm-logout-dialog.h +++ b/mate-session/gsm-logout-dialog.h @@ -26,9 +26,10 @@ #include <gtk/gtk.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS + +#define GSM_TYPE_LOGOUT_DIALOG (gsm_logout_dialog_get_type ()) +G_DECLARE_FINAL_TYPE (GsmLogoutDialog, gsm_logout_dialog, GSM, LOGOUT_DIALOG, GtkMessageDialog) enum { @@ -40,38 +41,11 @@ enum GSM_LOGOUT_RESPONSE_SLEEP }; -#define GSM_TYPE_LOGOUT_DIALOG (gsm_logout_dialog_get_type ()) -#define GSM_LOGOUT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_LOGOUT_DIALOG, GsmLogoutDialog)) -#define GSM_LOGOUT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_LOGOUT_DIALOG, GsmLogoutDialogClass)) -#define GSM_IS_LOGOUT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_LOGOUT_DIALOG)) -#define GSM_IS_LOGOUT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_LOGOUT_DIALOG)) -#define GSM_LOGOUT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_LOGOUT_DIALOG, GsmLogoutDialogClass)) - -typedef struct _GsmLogoutDialog GsmLogoutDialog; -typedef struct _GsmLogoutDialogClass GsmLogoutDialogClass; -typedef struct _GsmLogoutDialogPrivate GsmLogoutDialogPrivate; - -struct _GsmLogoutDialog -{ - GtkMessageDialog parent; - - GsmLogoutDialogPrivate *priv; -}; - -struct _GsmLogoutDialogClass -{ - GtkMessageDialogClass parent_class; -}; - -GType gsm_logout_dialog_get_type (void) G_GNUC_CONST; - GtkWidget *gsm_get_logout_dialog (GdkScreen *screen, guint32 activate_time); GtkWidget *gsm_get_shutdown_dialog (GdkScreen *screen, guint32 activate_time); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_LOGOUT_DIALOG_H__ */ diff --git a/mate-session/gsm-store.c b/mate-session/gsm-store.c index 2d1721f..e715e73 100644 --- a/mate-session/gsm-store.c +++ b/mate-session/gsm-store.c @@ -32,13 +32,11 @@ #include "gsm-store.h" -#define GSM_STORE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_STORE, GsmStorePrivate)) - -struct GsmStorePrivate +typedef struct { GHashTable *objects; gboolean locked; -}; +} GsmStorePrivate; enum { ADDED, @@ -57,7 +55,7 @@ static void gsm_store_class_init (GsmStoreClass *klass); static void gsm_store_init (GsmStore *store); static void gsm_store_finalize (GObject *object); -G_DEFINE_TYPE (GsmStore, gsm_store, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GsmStore, gsm_store, G_TYPE_OBJECT) GQuark gsm_store_error_quark (void) @@ -73,7 +71,9 @@ gsm_store_error_quark (void) guint gsm_store_size (GsmStore *store) { - return g_hash_table_size (store->priv->objects); + GsmStorePrivate *priv; + priv = gsm_store_get_instance_private (store); + return g_hash_table_size (priv->objects); } gboolean @@ -83,10 +83,12 @@ gsm_store_remove (GsmStore *store, GObject *found; gboolean removed; char *id_copy; + GsmStorePrivate *priv; g_return_val_if_fail (store != NULL, FALSE); - found = g_hash_table_lookup (store->priv->objects, id); + priv = gsm_store_get_instance_private (store); + found = g_hash_table_lookup (priv->objects, id); if (found == NULL) { return FALSE; } @@ -95,7 +97,7 @@ gsm_store_remove (GsmStore *store, g_object_ref (found); - removed = g_hash_table_remove (store->priv->objects, id_copy); + removed = g_hash_table_remove (priv->objects, id_copy); g_assert (removed); g_signal_emit (store, signals [REMOVED], 0, id_copy); @@ -113,8 +115,10 @@ gsm_store_foreach (GsmStore *store, { g_return_if_fail (store != NULL); g_return_if_fail (func != NULL); + GsmStorePrivate *priv; + priv = gsm_store_get_instance_private (store); - g_hash_table_find (store->priv->objects, + g_hash_table_find (priv->objects, (GHRFunc)func, user_data); } @@ -125,11 +129,13 @@ gsm_store_find (GsmStore *store, gpointer user_data) { GObject *object; + GsmStorePrivate *priv; g_return_val_if_fail (store != NULL, NULL); g_return_val_if_fail (predicate != NULL, NULL); + priv = gsm_store_get_instance_private (store); - object = g_hash_table_find (store->priv->objects, + object = g_hash_table_find (priv->objects, (GHRFunc)predicate, user_data); return object; @@ -140,11 +146,13 @@ gsm_store_lookup (GsmStore *store, const char *id) { GObject *object; + GsmStorePrivate *priv; g_return_val_if_fail (store != NULL, NULL); g_return_val_if_fail (id != NULL, NULL); + priv = gsm_store_get_instance_private (store); - object = g_hash_table_lookup (store->priv->objects, id); + object = g_hash_table_lookup (priv->objects, id); return object; } @@ -180,16 +188,18 @@ gsm_store_foreach_remove (GsmStore *store, { guint ret; WrapperData data; + GsmStorePrivate *priv; g_return_val_if_fail (store != NULL, 0); g_return_val_if_fail (func != NULL, 0); + priv = gsm_store_get_instance_private (store); data.store = store; data.user_data = user_data; data.func = func; data.removed = NULL; - ret = g_hash_table_foreach_remove (store->priv->objects, + ret = g_hash_table_foreach_remove (priv->objects, (GHRFunc)foreach_remove_wrapper, &data); @@ -231,19 +241,22 @@ gsm_store_add (GsmStore *store, const char *id, GObject *object) { + GsmStorePrivate *priv; g_return_val_if_fail (store != NULL, FALSE); g_return_val_if_fail (id != NULL, FALSE); g_return_val_if_fail (object != NULL, FALSE); + priv = gsm_store_get_instance_private (store); + /* If we're locked, we don't accept any new session objects. */ - if (store->priv->locked) { + if (priv->locked) { return FALSE; } g_debug ("GsmStore: Adding object id %s to store", id); - g_hash_table_insert (store->priv->objects, + g_hash_table_insert (priv->objects, g_strdup (id), g_object_ref (object)); @@ -256,17 +269,21 @@ void gsm_store_set_locked (GsmStore *store, gboolean locked) { + GsmStorePrivate *priv; g_return_if_fail (GSM_IS_STORE (store)); + priv = gsm_store_get_instance_private (store); - store->priv->locked = locked; + priv->locked = locked; } gboolean gsm_store_get_locked (GsmStore *store) { + GsmStorePrivate *priv; g_return_val_if_fail (GSM_IS_STORE (store), FALSE); + priv = gsm_store_get_instance_private (store); - return store->priv->locked; + return priv->locked; } static void @@ -296,12 +313,14 @@ gsm_store_get_property (GObject *object, GParamSpec *pspec) { GsmStore *self; + GsmStorePrivate *priv; self = GSM_STORE (object); + priv = gsm_store_get_instance_private (self); switch (prop_id) { case PROP_LOCKED: - g_value_set_boolean (value, self->priv->locked); + g_value_set_boolean (value, priv->locked); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -361,8 +380,6 @@ gsm_store_class_init (GsmStoreClass *klass) NULL, FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_type_class_add_private (klass, sizeof (GsmStorePrivate)); } static void @@ -375,28 +392,30 @@ _destroy_object (GObject *object) static void gsm_store_init (GsmStore *store) { + GsmStorePrivate *priv; + priv = gsm_store_get_instance_private (store); - store->priv = GSM_STORE_GET_PRIVATE (store); - - store->priv->objects = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - (GDestroyNotify) _destroy_object); + priv->objects = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + (GDestroyNotify) _destroy_object); } static void gsm_store_finalize (GObject *object) { GsmStore *store; + GsmStorePrivate *priv; g_return_if_fail (object != NULL); g_return_if_fail (GSM_IS_STORE (object)); store = GSM_STORE (object); + priv = gsm_store_get_instance_private (store); - g_return_if_fail (store->priv != NULL); + g_return_if_fail (priv != NULL); - g_hash_table_destroy (store->priv->objects); + g_hash_table_destroy (priv->objects); G_OBJECT_CLASS (gsm_store_parent_class)->finalize (object); } diff --git a/mate-session/gsm-store.h b/mate-session/gsm-store.h index c7b1c85..5a7f408 100644 --- a/mate-session/gsm-store.h +++ b/mate-session/gsm-store.h @@ -24,26 +24,12 @@ #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_STORE (gsm_store_get_type ()) -#define GSM_STORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_STORE, GsmStore)) -#define GSM_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_STORE, GsmStoreClass)) -#define GSM_IS_STORE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_STORE)) -#define GSM_IS_STORE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_STORE)) -#define GSM_STORE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_STORE, GsmStoreClass)) +G_DECLARE_DERIVABLE_TYPE (GsmStore, gsm_store, GSM, STORE, GObject) -typedef struct GsmStorePrivate GsmStorePrivate; - -typedef struct -{ - GObject parent; - GsmStorePrivate *priv; -} GsmStore; - -typedef struct +struct _GsmStoreClass { GObjectClass parent_class; @@ -51,7 +37,7 @@ typedef struct const char *id); void (* removed) (GsmStore *store, const char *id); -} GsmStoreClass; +}; typedef enum { @@ -65,7 +51,7 @@ typedef gboolean (*GsmStoreFunc) (const char *id, gpointer user_data); GQuark gsm_store_error_quark (void); -GType gsm_store_get_type (void); +GType gsm_store_get_type (void) G_GNUC_CONST; GsmStore * gsm_store_new (void); @@ -93,9 +79,6 @@ GObject * gsm_store_find (GsmStore *store, GObject * gsm_store_lookup (GsmStore *store, const char *id); - -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_STORE_H */ diff --git a/mate-session/gsm-systemd.c b/mate-session/gsm-systemd.c index 3ef6e48..5eafaed 100644 --- a/mate-session/gsm-systemd.c +++ b/mate-session/gsm-systemd.c @@ -44,16 +44,13 @@ #define SD_SEAT_INTERFACE "org.freedesktop.login1.Seat" #define SD_SESSION_INTERFACE "org.freedesktop.login1.Session" -#define GSM_SYSTEMD_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_SYSTEMD, GsmSystemdPrivate)) - -struct _GsmSystemdPrivate +typedef struct { DBusGConnection *dbus_connection; DBusGProxy *bus_proxy; DBusGProxy *sd_proxy; guint32 is_connected : 1; -}; +} GsmSystemdPrivate; enum { PROP_0, @@ -84,7 +81,7 @@ static void gsm_systemd_on_name_owner_changed (DBusGProxy *bus_proxy, const char *new_owner, GsmSystemd *manager); -G_DEFINE_TYPE (GsmSystemd, gsm_systemd, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_PRIVATE (GsmSystemd, gsm_systemd, G_TYPE_OBJECT); static void gsm_systemd_get_property (GObject *object, @@ -92,12 +89,15 @@ gsm_systemd_get_property (GObject *object, GValue *value, GParamSpec *pspec) { + GsmSystemdPrivate *priv; GsmSystemd *manager = GSM_SYSTEMD (object); + priv = gsm_systemd_get_instance_private (manager); + switch (prop_id) { case PROP_IS_CONNECTED: g_value_set_boolean (value, - manager->priv->is_connected); + priv->is_connected); break; default: @@ -148,8 +148,6 @@ gsm_systemd_class_init (GsmSystemdClass *manager_class) gsm_marshal_VOID__BOOLEAN_BOOLEAN_POINTER, G_TYPE_NONE, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER); - - g_type_class_add_private (manager_class, sizeof (GsmSystemdPrivate)); } static DBusHandlerResult @@ -177,64 +175,67 @@ gsm_systemd_ensure_sd_connection (GsmSystemd *manager, { GError *connection_error; gboolean is_connected; + GsmSystemdPrivate *priv; connection_error = NULL; - if (manager->priv->dbus_connection == NULL) { + priv = gsm_systemd_get_instance_private (manager); + + if (priv->dbus_connection == NULL) { DBusConnection *connection; - manager->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, - &connection_error); + priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, + &connection_error); - if (manager->priv->dbus_connection == NULL) { + if (priv->dbus_connection == NULL) { g_propagate_error (error, connection_error); is_connected = FALSE; goto out; } - connection = dbus_g_connection_get_connection (manager->priv->dbus_connection); + connection = dbus_g_connection_get_connection (priv->dbus_connection); dbus_connection_set_exit_on_disconnect (connection, FALSE); dbus_connection_add_filter (connection, gsm_systemd_dbus_filter, manager, NULL); } - if (manager->priv->bus_proxy == NULL) { - manager->priv->bus_proxy = - dbus_g_proxy_new_for_name_owner (manager->priv->dbus_connection, + if (priv->bus_proxy == NULL) { + priv->bus_proxy = + dbus_g_proxy_new_for_name_owner (priv->dbus_connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, &connection_error); - if (manager->priv->bus_proxy == NULL) { + if (priv->bus_proxy == NULL) { g_propagate_error (error, connection_error); is_connected = FALSE; goto out; } - dbus_g_proxy_add_signal (manager->priv->bus_proxy, + dbus_g_proxy_add_signal (priv->bus_proxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (manager->priv->bus_proxy, + dbus_g_proxy_connect_signal (priv->bus_proxy, "NameOwnerChanged", G_CALLBACK (gsm_systemd_on_name_owner_changed), manager, NULL); } - if (manager->priv->sd_proxy == NULL) { - manager->priv->sd_proxy = - dbus_g_proxy_new_for_name_owner (manager->priv->dbus_connection, + if (priv->sd_proxy == NULL) { + priv->sd_proxy = + dbus_g_proxy_new_for_name_owner (priv->dbus_connection, SD_NAME, SD_PATH, SD_INTERFACE, &connection_error); - if (manager->priv->sd_proxy == NULL) { + if (priv->sd_proxy == NULL) { g_propagate_error (error, connection_error); is_connected = FALSE; goto out; @@ -244,26 +245,26 @@ gsm_systemd_ensure_sd_connection (GsmSystemd *manager, is_connected = TRUE; out: - if (manager->priv->is_connected != is_connected) { - manager->priv->is_connected = is_connected; + if (priv->is_connected != is_connected) { + priv->is_connected = is_connected; g_object_notify (G_OBJECT (manager), "is-connected"); } if (!is_connected) { - if (manager->priv->dbus_connection == NULL) { - if (manager->priv->bus_proxy != NULL) { - g_object_unref (manager->priv->bus_proxy); - manager->priv->bus_proxy = NULL; + if (priv->dbus_connection == NULL) { + if (priv->bus_proxy != NULL) { + g_object_unref (priv->bus_proxy); + priv->bus_proxy = NULL; } - if (manager->priv->sd_proxy != NULL) { - g_object_unref (manager->priv->sd_proxy); - manager->priv->sd_proxy = NULL; + if (priv->sd_proxy != NULL) { + g_object_unref (priv->sd_proxy); + priv->sd_proxy = NULL; } - } else if (manager->priv->bus_proxy == NULL) { - if (manager->priv->sd_proxy != NULL) { - g_object_unref (manager->priv->sd_proxy); - manager->priv->sd_proxy = NULL; + } else if (priv->bus_proxy == NULL) { + if (priv->sd_proxy != NULL) { + g_object_unref (priv->sd_proxy); + priv->sd_proxy = NULL; } } } @@ -278,13 +279,16 @@ gsm_systemd_on_name_owner_changed (DBusGProxy *bus_proxy, const char *new_owner, GsmSystemd *manager) { + GsmSystemdPrivate *priv; + + priv = gsm_systemd_get_instance_private (manager); if (name != NULL && g_strcmp0 (name, SD_NAME) != 0) { return; } - if (manager->priv->sd_proxy != NULL) { - g_object_unref (manager->priv->sd_proxy); - manager->priv->sd_proxy = NULL; + if (priv->sd_proxy != NULL) { + g_object_unref (priv->sd_proxy); + priv->sd_proxy = NULL; } gsm_systemd_ensure_sd_connection (manager, NULL); @@ -295,8 +299,6 @@ gsm_systemd_init (GsmSystemd *manager) { GError *error; - manager->priv = GSM_SYSTEMD_GET_PRIVATE (manager); - error = NULL; if (!gsm_systemd_ensure_sd_connection (manager, &error)) { @@ -309,25 +311,28 @@ gsm_systemd_init (GsmSystemd *manager) static void gsm_systemd_free_dbus (GsmSystemd *manager) { - if (manager->priv->bus_proxy != NULL) { - g_object_unref (manager->priv->bus_proxy); - manager->priv->bus_proxy = NULL; + GsmSystemdPrivate *priv; + + priv = gsm_systemd_get_instance_private (manager); + if (priv->bus_proxy != NULL) { + g_object_unref (priv->bus_proxy); + priv->bus_proxy = NULL; } - if (manager->priv->sd_proxy != NULL) { - g_object_unref (manager->priv->sd_proxy); - manager->priv->sd_proxy = NULL; + if (priv->sd_proxy != NULL) { + g_object_unref (priv->sd_proxy); + priv->sd_proxy = NULL; } - if (manager->priv->dbus_connection != NULL) { + if (priv->dbus_connection != NULL) { DBusConnection *connection; - connection = dbus_g_connection_get_connection (manager->priv->dbus_connection); + connection = dbus_g_connection_get_connection (priv->dbus_connection); dbus_connection_remove_filter (connection, gsm_systemd_dbus_filter, manager); - dbus_g_connection_unref (manager->priv->dbus_connection); - manager->priv->dbus_connection = NULL; + dbus_g_connection_unref (priv->dbus_connection); + priv->dbus_connection = NULL; } } @@ -421,8 +426,10 @@ gsm_systemd_attempt_restart (GsmSystemd *manager) { gboolean res; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", @@ -432,7 +439,7 @@ gsm_systemd_attempt_restart (GsmSystemd *manager) return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, "Reboot", INT_MAX, &error, @@ -454,8 +461,10 @@ gsm_systemd_attempt_stop (GsmSystemd *manager) { gboolean res; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", @@ -465,7 +474,7 @@ gsm_systemd_attempt_stop (GsmSystemd *manager) return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, "PowerOff", INT_MAX, &error, @@ -552,8 +561,10 @@ gsm_systemd_set_session_idle (GsmSystemd *manager, DBusMessage *reply; DBusError dbus_error; DBusMessageIter iter; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", @@ -562,7 +573,7 @@ gsm_systemd_set_session_idle (GsmSystemd *manager, return; } - gsm_systemd_get_session_path (dbus_g_connection_get_connection (manager->priv->dbus_connection), &session_path); + gsm_systemd_get_session_path (dbus_g_connection_get_connection (priv->dbus_connection), &session_path); g_return_if_fail (session_path != NULL); @@ -581,7 +592,7 @@ gsm_systemd_set_session_idle (GsmSystemd *manager, /* FIXME: use async? */ dbus_error_init (&dbus_error); - reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (manager->priv->dbus_connection), + reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (priv->dbus_connection), message, -1, &dbus_error); @@ -638,8 +649,8 @@ gboolean gsm_systemd_get_restart_privileges (GsmSystemd *manager) { g_signal_emit (G_OBJECT (manager), - signals [PRIVILEGES_COMPLETED], - 0, TRUE, TRUE, NULL); + signals [PRIVILEGES_COMPLETED], + 0, TRUE, TRUE, NULL); return TRUE; } @@ -648,8 +659,8 @@ gboolean gsm_systemd_get_stop_privileges (GsmSystemd *manager) { g_signal_emit (G_OBJECT (manager), - signals [PRIVILEGES_COMPLETED], - 0, TRUE, TRUE, NULL); + signals [PRIVILEGES_COMPLETED], + 0, TRUE, TRUE, NULL); return TRUE; } @@ -661,8 +672,10 @@ gsm_systemd_can_restart (GsmSystemd *manager) gchar *value; gboolean can_restart; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", @@ -671,7 +684,7 @@ gsm_systemd_can_restart (GsmSystemd *manager) return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, "CanReboot", INT_MAX, &error, @@ -698,8 +711,10 @@ gsm_systemd_can_stop (GsmSystemd *manager) gchar *value; gboolean can_stop; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", @@ -708,7 +723,7 @@ gsm_systemd_can_stop (GsmSystemd *manager) return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, "CanPowerOff", INT_MAX, &error, @@ -736,26 +751,28 @@ gsm_systemd_can_hibernate (GsmSystemd *manager) gchar *value; gboolean can_hibernate; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", - error->message); + error->message); g_error_free (error); return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, - "CanHibernate", - INT_MAX, - &error, - G_TYPE_INVALID, - G_TYPE_STRING, &value, - G_TYPE_INVALID); + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, + "CanHibernate", + INT_MAX, + &error, + G_TYPE_INVALID, + G_TYPE_STRING, &value, + G_TYPE_INVALID); if (res == FALSE) { g_warning ("Could not make DBUS call: %s", - error->message); + error->message); g_error_free (error); return FALSE; } @@ -773,26 +790,28 @@ gsm_systemd_can_suspend (GsmSystemd *manager) gchar *value; gboolean can_suspend; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", - error->message); + error->message); g_error_free (error); return FALSE; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, - "CanSuspend", - INT_MAX, - &error, - G_TYPE_INVALID, - G_TYPE_STRING, &value, - G_TYPE_INVALID); + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, + "CanSuspend", + INT_MAX, + &error, + G_TYPE_INVALID, + G_TYPE_STRING, &value, + G_TYPE_INVALID); if (res == FALSE) { g_warning ("Could not make DBUS call: %s", - error->message); + error->message); g_error_free (error); return FALSE; } @@ -808,26 +827,28 @@ gsm_systemd_attempt_hibernate (GsmSystemd *manager) { gboolean res; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", - error->message); + error->message); g_error_free (error); return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, - "Hibernate", - INT_MAX, - &error, + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, + "Hibernate", + INT_MAX, + &error, G_TYPE_BOOLEAN, TRUE, /* interactive */ - G_TYPE_INVALID, - G_TYPE_INVALID); + G_TYPE_INVALID, + G_TYPE_INVALID); if (res == FALSE) { g_warning ("Could not make DBUS call: %s", - error->message); + error->message); g_error_free (error); return; } @@ -839,26 +860,28 @@ gsm_systemd_attempt_suspend (GsmSystemd *manager) { gboolean res; GError *error; + GsmSystemdPrivate *priv; error = NULL; + priv = gsm_systemd_get_instance_private (manager); if (!gsm_systemd_ensure_sd_connection (manager, &error)) { g_warning ("Could not connect to Systemd: %s", - error->message); + error->message); g_error_free (error); return; } - res = dbus_g_proxy_call_with_timeout (manager->priv->sd_proxy, - "Suspend", - INT_MAX, - &error, + res = dbus_g_proxy_call_with_timeout (priv->sd_proxy, + "Suspend", + INT_MAX, + &error, G_TYPE_BOOLEAN, TRUE, /* interactive */ G_TYPE_INVALID, - G_TYPE_INVALID); + G_TYPE_INVALID); if (res == FALSE) { g_warning ("Could not make DBUS call: %s", - error->message); + error->message); g_error_free (error); return; } diff --git a/mate-session/gsm-systemd.h b/mate-session/gsm-systemd.h index e0e21c4..5d6b654 100644 --- a/mate-session/gsm-systemd.h +++ b/mate-session/gsm-systemd.h @@ -27,32 +27,15 @@ #include <glib.h> #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_SYSTEMD (gsm_systemd_get_type ()) -#define GSM_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_SYSTEMD, GsmSystemd)) -#define GSM_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_SYSTEMD, GsmSystemdClass)) -#define GSM_IS_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_SYSTEMD)) -#define GSM_IS_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_SYSTEMD)) -#define GSM_SYSTEMD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSM_TYPE_SYSTEMD, GsmSystemdClass)) #define GSM_SYSTEMD_ERROR (gsm_systemd_error_quark ()) +G_DECLARE_DERIVABLE_TYPE (GsmSystemd, gsm_systemd, GSM, SYSTEMD, GObject) #define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0) - -typedef struct _GsmSystemd GsmSystemd; -typedef struct _GsmSystemdClass GsmSystemdClass; -typedef struct _GsmSystemdPrivate GsmSystemdPrivate; typedef enum _GsmSystemdError GsmSystemdError; -struct _GsmSystemd -{ - GObject parent; - - GsmSystemdPrivate *priv; -}; - struct _GsmSystemdClass { GObjectClass parent_class; @@ -73,7 +56,7 @@ enum _GsmSystemdError { #define GSM_SYSTEMD_SESSION_TYPE_LOGIN_WINDOW "greeter" -GType gsm_systemd_get_type (void); +GType gsm_systemd_get_type (void) G_GNUC_CONST; GQuark gsm_systemd_error_quark (void); @@ -108,8 +91,6 @@ gchar *gsm_systemd_get_current_session_type (GsmSystemd *manager); GsmSystemd *gsm_get_systemd (void); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_SYSTEMD_H__ */ diff --git a/mate-session/gsm-xsmp-client.c b/mate-session/gsm-xsmp-client.c index 9c61497..5e15744 100644 --- a/mate-session/gsm-xsmp-client.c +++ b/mate-session/gsm-xsmp-client.c @@ -40,11 +40,8 @@ #define GsmDesktopFile "_GSM_DesktopFile" -#define GSM_XSMP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_XSMP_CLIENT, GsmXSMPClientPrivate)) - -struct GsmXSMPClientPrivate -{ - +typedef struct { + GsmClient parent; SmsConn conn; IceConn ice_connection; @@ -57,7 +54,7 @@ struct GsmXSMPClientPrivate int current_save_yourself; int next_save_yourself; guint next_save_yourself_allow_interact : 1; -}; +} GsmXSMPClientPrivate; enum { PROP_0, @@ -72,7 +69,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GsmXSMPClient, gsm_xsmp_client, GSM_TYPE_CLIENT) +G_DEFINE_TYPE_WITH_PRIVATE (GsmXSMPClient, gsm_xsmp_client, GSM_TYPE_CLIENT) static gboolean client_iochannel_watch (GIOChannel *channel, @@ -80,15 +77,18 @@ client_iochannel_watch (GIOChannel *channel, GsmXSMPClient *client) { gboolean keep_going; + GsmXSMPClientPrivate *priv; g_object_ref (client); - switch (IceProcessMessages (client->priv->ice_connection, NULL, NULL)) { + priv = gsm_xsmp_client_get_instance_private (client); + + switch (IceProcessMessages (priv->ice_connection, NULL, NULL)) { case IceProcessMessagesSuccess: keep_going = TRUE; break; case IceProcessMessagesIOError: - g_debug ("GsmXSMPClient: IceProcessMessagesIOError on '%s'", client->priv->description); + g_debug ("GsmXSMPClient: IceProcessMessagesIOError on '%s'", priv->description); gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FAILED); /* Emitting "disconnected" will eventually cause * IceCloseConnection() to be called. @@ -99,8 +99,8 @@ client_iochannel_watch (GIOChannel *channel, case IceProcessMessagesConnectionClosed: g_debug ("GsmXSMPClient: IceProcessMessagesConnectionClosed on '%s'", - client->priv->description); - client->priv->ice_connection = NULL; + priv->description); + priv->ice_connection = NULL; keep_going = FALSE; break; @@ -119,9 +119,12 @@ find_property (GsmXSMPClient *client, { SmProp *prop; int i; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (client); - for (i = 0; i < client->priv->props->len; i++) { - prop = client->priv->props->pdata[i]; + for (i = 0; i < priv->props->len; i++) { + prop = priv->props->pdata[i]; if (!strcmp (prop->name, name)) { if (index) { @@ -139,21 +142,23 @@ set_description (GsmXSMPClient *client) { SmProp *prop; const char *id; + GsmXSMPClientPrivate *priv; + priv = gsm_xsmp_client_get_instance_private (client); prop = find_property (client, SmProgram, NULL); id = gsm_client_peek_startup_id (GSM_CLIENT (client)); - g_free (client->priv->description); + g_free (priv->description); if (prop) { - client->priv->description = g_strdup_printf ("%p [%.*s %s]", - client, - prop->vals[0].length, - (char *)prop->vals[0].value, - id); + priv->description = g_strdup_printf ("%p [%.*s %s]", + client, + prop->vals[0].length, + (char *)prop->vals[0].value, + id); } else if (id != NULL) { - client->priv->description = g_strdup_printf ("%p [%s]", client, id); + priv->description = g_strdup_printf ("%p [%s]", client, id); } else { - client->priv->description = g_strdup_printf ("%p", client); + priv->description = g_strdup_printf ("%p", client); } } @@ -162,21 +167,23 @@ setup_connection (GsmXSMPClient *client) { GIOChannel *channel; int fd; + GsmXSMPClientPrivate *priv; + priv = gsm_xsmp_client_get_instance_private (client); g_debug ("GsmXSMPClient: Setting up new connection"); - fd = IceConnectionNumber (client->priv->ice_connection); + fd = IceConnectionNumber (priv->ice_connection); fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC); channel = g_io_channel_unix_new (fd); - client->priv->watch_id = g_io_add_watch (channel, - G_IO_IN | G_IO_ERR, - (GIOFunc)client_iochannel_watch, - client); + priv->watch_id = g_io_add_watch (channel, + G_IO_IN | G_IO_ERR, + (GIOFunc)client_iochannel_watch, + client); g_io_channel_unref (channel); set_description (client); - g_debug ("GsmXSMPClient: New client '%s'", client->priv->description); + g_debug ("GsmXSMPClient: New client '%s'", priv->description); } static GObject * @@ -197,12 +204,14 @@ gsm_xsmp_client_constructor (GType type, static void gsm_xsmp_client_init (GsmXSMPClient *client) { - client->priv = GSM_XSMP_CLIENT_GET_PRIVATE (client); + GsmXSMPClientPrivate *priv; - client->priv->props = g_ptr_array_new (); - client->priv->current_save_yourself = -1; - client->priv->next_save_yourself = -1; - client->priv->next_save_yourself_allow_interact = FALSE; + priv = gsm_xsmp_client_get_instance_private (client); + + priv->props = g_ptr_array_new (); + priv->current_save_yourself = -1; + priv->next_save_yourself = -1; + priv->next_save_yourself_allow_interact = FALSE; } @@ -212,6 +221,9 @@ delete_property (GsmXSMPClient *client, { int index; SmProp *prop; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (client); prop = find_property (client, name, &index); if (!prop) { @@ -231,7 +243,7 @@ delete_property (GsmXSMPClient *client, } #endif - g_ptr_array_remove_index_fast (client->priv->props, index); + g_ptr_array_remove_index_fast (priv->props, index); SmFreeProperty (prop); } @@ -274,14 +286,17 @@ set_properties_callback (SmsConn conn, int num_props, SmProp **props) { - GsmXSMPClient *client = manager_data; int i; + GsmXSMPClientPrivate *priv; + GsmXSMPClient *client = manager_data; + + priv = gsm_xsmp_client_get_instance_private (client); - g_debug ("GsmXSMPClient: Set properties from client '%s'", client->priv->description); + g_debug ("GsmXSMPClient: Set properties from client '%s'", priv->description); for (i = 0; i < num_props; i++) { delete_property (client, props[i]->name); - g_ptr_array_add (client->priv->props, props[i]); + g_ptr_array_add (priv->props, props[i]); debug_print_property (props[i]); @@ -299,10 +314,13 @@ delete_properties_callback (SmsConn conn, int num_props, char **prop_names) { - GsmXSMPClient *client = manager_data; int i; + GsmXSMPClientPrivate *priv; + GsmXSMPClient *client = manager_data; + + priv = gsm_xsmp_client_get_instance_private (client); - g_debug ("GsmXSMPClient: Delete properties from '%s'", client->priv->description); + g_debug ("GsmXSMPClient: Delete properties from '%s'", priv->description); for (i = 0; i < num_props; i++) { delete_property (client, prop_names[i]); @@ -317,13 +335,16 @@ static void get_properties_callback (SmsConn conn, SmPointer manager_data) { + GsmXSMPClientPrivate *priv; GsmXSMPClient *client = manager_data; - g_debug ("GsmXSMPClient: Get properties request from '%s'", client->priv->description); + priv = gsm_xsmp_client_get_instance_private (client); + + g_debug ("GsmXSMPClient: Get properties request from '%s'", priv->description); SmsReturnProperties (conn, - client->priv->props->len, - (SmProp **)client->priv->props->pdata); + priv->props->len, + (SmProp **)priv->props->pdata); } static char * @@ -404,30 +425,33 @@ do_save_yourself (GsmXSMPClient *client, int save_type, gboolean allow_interact) { - g_assert (client->priv->conn != NULL); + GsmXSMPClientPrivate *priv; - if (client->priv->next_save_yourself != -1) { + priv = gsm_xsmp_client_get_instance_private (client); + g_assert (priv->conn != NULL); + + if (priv->next_save_yourself != -1) { /* Either we're currently doing a shutdown and there's a checkpoint * queued after it, or vice versa. Either way, the new SaveYourself * is redundant. */ g_debug ("GsmXSMPClient: skipping redundant SaveYourself for '%s'", - client->priv->description); - } else if (client->priv->current_save_yourself != -1) { + priv->description); + } else if (priv->current_save_yourself != -1) { g_debug ("GsmXSMPClient: queuing new SaveYourself for '%s'", - client->priv->description); - client->priv->next_save_yourself = save_type; - client->priv->next_save_yourself_allow_interact = allow_interact; + priv->description); + priv->next_save_yourself = save_type; + priv->next_save_yourself_allow_interact = allow_interact; } else { - client->priv->current_save_yourself = save_type; + priv->current_save_yourself = save_type; /* make sure we don't have anything queued */ - client->priv->next_save_yourself = -1; - client->priv->next_save_yourself_allow_interact = FALSE; + priv->next_save_yourself = -1; + priv->next_save_yourself_allow_interact = FALSE; switch (save_type) { case SmSaveLocal: /* Save state */ - SmsSaveYourself (client->priv->conn, + SmsSaveYourself (priv->conn, SmSaveLocal, FALSE, SmInteractStyleNone, @@ -437,13 +461,13 @@ do_save_yourself (GsmXSMPClient *client, default: /* Logout */ if (!allow_interact) { - SmsSaveYourself (client->priv->conn, + SmsSaveYourself (priv->conn, save_type, /* save type */ TRUE, /* shutdown */ SmInteractStyleNone, /* interact style */ TRUE); /* fast */ } else { - SmsSaveYourself (client->priv->conn, + SmsSaveYourself (priv->conn, save_type, /* save type */ TRUE, /* shutdown */ SmInteractStyleAny, /* interact style */ @@ -457,32 +481,38 @@ do_save_yourself (GsmXSMPClient *client, static void xsmp_save_yourself_phase2 (GsmClient *client) { - GsmXSMPClient *xsmp = (GsmXSMPClient *) client; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client)); - g_debug ("GsmXSMPClient: xsmp_save_yourself_phase2 ('%s')", xsmp->priv->description); + g_debug ("GsmXSMPClient: xsmp_save_yourself_phase2 ('%s')", priv->description); - SmsSaveYourselfPhase2 (xsmp->priv->conn); + SmsSaveYourselfPhase2 (priv->conn); } static void xsmp_interact (GsmClient *client) { - GsmXSMPClient *xsmp = (GsmXSMPClient *) client; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client)); - g_debug ("GsmXSMPClient: xsmp_interact ('%s')", xsmp->priv->description); + g_debug ("GsmXSMPClient: xsmp_interact ('%s')", priv->description); - SmsInteract (xsmp->priv->conn); + SmsInteract (priv->conn); } static gboolean xsmp_cancel_end_session (GsmClient *client, GError **error) { - GsmXSMPClient *xsmp = (GsmXSMPClient *) client; + GsmXSMPClientPrivate *priv; - g_debug ("GsmXSMPClient: xsmp_cancel_end_session ('%s')", xsmp->priv->description); + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client)); - if (xsmp->priv->conn == NULL) { + g_debug ("GsmXSMPClient: xsmp_cancel_end_session ('%s')", priv->description); + + if (priv->conn == NULL) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -490,12 +520,12 @@ xsmp_cancel_end_session (GsmClient *client, return FALSE; } - SmsShutdownCancelled (xsmp->priv->conn); + SmsShutdownCancelled (priv->conn); /* reset the state */ - xsmp->priv->current_save_yourself = -1; - xsmp->priv->next_save_yourself = -1; - xsmp->priv->next_save_yourself_allow_interact = FALSE; + priv->current_save_yourself = -1; + priv->next_save_yourself = -1; + priv->next_save_yourself_allow_interact = FALSE; return TRUE; } @@ -523,9 +553,9 @@ get_desktop_file_path (GsmXSMPClient *client) * try to find the desktop file from its program name */ prop = find_property (client, SmProgram, NULL); - if (!prop) { - goto out; - } + if (!prop) { + goto out; + } program_name = prop->vals[0].value; @@ -563,7 +593,7 @@ set_desktop_file_keys_from_client (GsmClient *client, * properties. But it could still be that SmProgram is not set. */ name = _("Remembered Application"); - } + } comment = g_strdup_printf ("Client %s which was automatically saved", gsm_client_peek_startup_id (client)); @@ -700,11 +730,13 @@ static gboolean xsmp_stop (GsmClient *client, GError **error) { - GsmXSMPClient *xsmp = (GsmXSMPClient *) client; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client)); - g_debug ("GsmXSMPClient: xsmp_stop ('%s')", xsmp->priv->description); + g_debug ("GsmXSMPClient: xsmp_stop ('%s')", priv->description); - if (xsmp->priv->conn == NULL) { + if (priv->conn == NULL) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -712,7 +744,7 @@ xsmp_stop (GsmClient *client, return FALSE; } - SmsDie (xsmp->priv->conn); + SmsDie (priv->conn); return TRUE; } @@ -724,8 +756,11 @@ xsmp_query_end_session (GsmClient *client, { gboolean allow_interact; int save_type; + GsmXSMPClientPrivate *priv; - if (GSM_XSMP_CLIENT (client)->priv->conn == NULL) { + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client)); + + if (priv->conn == NULL) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -752,8 +787,11 @@ xsmp_end_session (GsmClient *client, GError **error) { gboolean phase2; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client)); - if (GSM_XSMP_CLIENT (client)->priv->conn == NULL) { + if (priv->conn == NULL) { g_set_error (error, GSM_CLIENT_ERROR, GSM_CLIENT_ERROR_NOT_REGISTERED, @@ -794,7 +832,7 @@ xsmp_get_app_name (GsmClient *client) prop = find_property (GSM_XSMP_CLIENT (client), SmProgram, NULL); if (prop) { - name = prop_to_command (prop); + name = prop_to_command (prop); } return name; @@ -804,7 +842,10 @@ static void gsm_client_set_ice_connection (GsmXSMPClient *client, gpointer conn) { - client->priv->ice_connection = conn; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (client); + priv->ice_connection = conn; } static void @@ -833,13 +874,13 @@ gsm_xsmp_client_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GsmXSMPClient *self; + GsmXSMPClientPrivate *priv; - self = GSM_XSMP_CLIENT (object); + priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(object)); switch (prop_id) { case PROP_ICE_CONNECTION: - g_value_set_pointer (value, self->priv->ice_connection); + g_value_set_pointer (value, priv->ice_connection); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -850,31 +891,39 @@ gsm_xsmp_client_get_property (GObject *object, static void gsm_xsmp_client_disconnect (GsmXSMPClient *client) { - if (client->priv->watch_id > 0) { - g_source_remove (client->priv->watch_id); + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (client); + if (priv->watch_id > 0) { + g_source_remove (priv->watch_id); } - if (client->priv->conn != NULL) { - SmsCleanUp (client->priv->conn); + if (priv->conn != NULL) { + SmsCleanUp (priv->conn); } - if (client->priv->ice_connection != NULL) { - IceSetShutdownNegotiation (client->priv->ice_connection, FALSE); - IceCloseConnection (client->priv->ice_connection); + if (priv->ice_connection != NULL) { + IceSetShutdownNegotiation (priv->ice_connection, FALSE); + IceCloseConnection (priv->ice_connection); } } static void gsm_xsmp_client_finalize (GObject *object) { - GsmXSMPClient *client = (GsmXSMPClient *) object; + GsmXSMPClientPrivate *priv; + GsmXSMPClient *client; + + client = GSM_XSMP_CLIENT(object); + + priv = gsm_xsmp_client_get_instance_private (client); - g_debug ("GsmXSMPClient: xsmp_finalize (%s)", client->priv->description); + g_debug ("GsmXSMPClient: xsmp_finalize (%s)", priv->description); gsm_xsmp_client_disconnect (client); - g_free (client->priv->description); - g_ptr_array_foreach (client->priv->props, (GFunc)SmFreeProperty, NULL); - g_ptr_array_free (client->priv->props, TRUE); + g_free (priv->description); + g_ptr_array_foreach (priv->props, (GFunc)SmFreeProperty, NULL); + g_ptr_array_free (priv->props, TRUE); G_OBJECT_CLASS (gsm_xsmp_client_parent_class)->finalize (object); } @@ -1026,8 +1075,6 @@ gsm_xsmp_client_class_init (GsmXSMPClientClass *klass) "ice-connection", "ice-connection", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (klass, sizeof (GsmXSMPClientPrivate)); } GsmClient * @@ -1047,12 +1094,15 @@ register_client_callback (SmsConn conn, SmPointer manager_data, char *previous_id) { - GsmXSMPClient *client = manager_data; gboolean handled; char *id; + GsmXSMPClientPrivate *priv; + + GsmXSMPClient *client = manager_data; + priv = gsm_xsmp_client_get_instance_private (client); g_debug ("GsmXSMPClient: Client '%s' received RegisterClient(%s)", - client->priv->description, + priv->description, previous_id ? previous_id : "NULL"); @@ -1083,7 +1133,7 @@ register_client_callback (SmsConn conn, set_description (client); - g_debug ("GsmXSMPClient: Sending RegisterClientReply to '%s'", client->priv->description); + g_debug ("GsmXSMPClient: Sending RegisterClientReply to '%s'", priv->description); SmsRegisterClientReply (conn, id); @@ -1091,7 +1141,7 @@ register_client_callback (SmsConn conn, /* Send the initial SaveYourself. */ g_debug ("GsmXSMPClient: Sending initial SaveYourself"); SmsSaveYourself (conn, SmSaveLocal, False, SmInteractStyleNone, False); - client->priv->current_save_yourself = SmSaveLocal; + priv->current_save_yourself = SmSaveLocal; } gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_REGISTERED); @@ -1112,10 +1162,13 @@ save_yourself_request_callback (SmsConn conn, Bool fast, Bool global) { + GsmXSMPClientPrivate *priv; GsmXSMPClient *client = manager_data; + priv = gsm_xsmp_client_get_instance_private (client); + g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfRequest(%s, %s, %s, %s, %s)", - client->priv->description, + priv->description, save_type == SmSaveLocal ? "SmSaveLocal" : save_type == SmSaveGlobal ? "SmSaveGlobal" : "SmSaveBoth", shutdown ? "Shutdown" : "!Shutdown", @@ -1169,12 +1222,15 @@ static void save_yourself_phase2_request_callback (SmsConn conn, SmPointer manager_data) { + GsmXSMPClientPrivate *priv; GsmXSMPClient *client = manager_data; + priv = gsm_xsmp_client_get_instance_private (client); + g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfPhase2Request", - client->priv->description); + priv->description); - client->priv->current_save_yourself = -1; + priv->current_save_yourself = -1; /* this is a valid response to SaveYourself and therefore may be a response to a QES or ES */ @@ -1188,14 +1244,17 @@ interact_request_callback (SmsConn conn, SmPointer manager_data, int dialog_type) { + GsmXSMPClientPrivate *priv; GsmXSMPClient *client = manager_data; + + priv = gsm_xsmp_client_get_instance_private (client); #if 0 gboolean res; GError *error; #endif g_debug ("GsmXSMPClient: Client '%s' received InteractRequest(%s)", - client->priv->description, + priv->description, dialog_type == SmDialogNormal ? "Dialog" : "Errors"); gsm_client_end_session_response (GSM_CLIENT (client), @@ -1223,10 +1282,13 @@ interact_done_callback (SmsConn conn, SmPointer manager_data, Bool cancel_shutdown) { + GsmXSMPClientPrivate *priv; GsmXSMPClient *client = manager_data; + priv = gsm_xsmp_client_get_instance_private (client); + g_debug ("GsmXSMPClient: Client '%s' received InteractDone(cancel_shutdown = %s)", - client->priv->description, + priv->description, cancel_shutdown ? "True" : "False"); gsm_client_end_session_response (GSM_CLIENT (client), @@ -1239,16 +1301,19 @@ save_yourself_done_callback (SmsConn conn, SmPointer manager_data, Bool success) { + GsmXSMPClientPrivate *priv; GsmXSMPClient *client = manager_data; + priv = gsm_xsmp_client_get_instance_private (client); + g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfDone(success = %s)", - client->priv->description, + priv->description, success ? "True" : "False"); - if (client->priv->current_save_yourself != -1) { - SmsSaveComplete (client->priv->conn); - client->priv->current_save_yourself = -1; - } + if (priv->current_save_yourself != -1) { + SmsSaveComplete (priv->conn); + priv->current_save_yourself = -1; + } /* If success is false then the application couldn't save data. Nothing * the session manager can do about, though. FIXME: we could display a @@ -1257,12 +1322,12 @@ save_yourself_done_callback (SmsConn conn, TRUE, FALSE, FALSE, NULL); - if (client->priv->next_save_yourself) { - int save_type = client->priv->next_save_yourself; - gboolean allow_interact = client->priv->next_save_yourself_allow_interact; + if (priv->next_save_yourself) { + int save_type = priv->next_save_yourself; + gboolean allow_interact = priv->next_save_yourself_allow_interact; - client->priv->next_save_yourself = -1; - client->priv->next_save_yourself_allow_interact = -1; + priv->next_save_yourself = -1; + priv->next_save_yourself_allow_interact = -1; do_save_yourself (client, save_type, allow_interact); } } @@ -1273,10 +1338,13 @@ close_connection_callback (SmsConn conn, int count, char **reason_msgs) { - GsmXSMPClient *client = manager_data; int i; + GsmXSMPClientPrivate *priv; + GsmXSMPClient *client = manager_data; - g_debug ("GsmXSMPClient: Client '%s' received CloseConnection", client->priv->description); + priv = gsm_xsmp_client_get_instance_private (client); + + g_debug ("GsmXSMPClient: Client '%s' received CloseConnection", priv->description); for (i = 0; i < count; i++) { g_debug ("GsmXSMPClient: close reason: '%s'", reason_msgs[i]); } @@ -1292,9 +1360,12 @@ gsm_xsmp_client_connect (GsmXSMPClient *client, unsigned long *mask_ret, SmsCallbacks *callbacks_ret) { - client->priv->conn = conn; + GsmXSMPClientPrivate *priv; + + priv = gsm_xsmp_client_get_instance_private (client); + priv->conn = conn; - g_debug ("GsmXSMPClient: Initializing client %s", client->priv->description); + g_debug ("GsmXSMPClient: Initializing client %s", priv->description); *mask_ret = 0; diff --git a/mate-session/gsm-xsmp-client.h b/mate-session/gsm-xsmp-client.h index f14ab61..0078d64 100644 --- a/mate-session/gsm-xsmp-client.h +++ b/mate-session/gsm-xsmp-client.h @@ -25,27 +25,10 @@ #include <X11/SM/SMlib.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS -#define GSM_TYPE_XSMP_CLIENT (gsm_xsmp_client_get_type ()) -#define GSM_XSMP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_XSMP_CLIENT, GsmXSMPClient)) -#define GSM_XSMP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_XSMP_CLIENT, GsmXSMPClientClass)) -#define GSM_IS_XSMP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_XSMP_CLIENT)) -#define GSM_IS_XSMP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_XSMP_CLIENT)) -#define GSM_XSMP_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_XSMP_CLIENT, GsmXSMPClientClass)) - -typedef struct _GsmXSMPClient GsmXSMPClient; -typedef struct _GsmXSMPClientClass GsmXSMPClientClass; - -typedef struct GsmXSMPClientPrivate GsmXSMPClientPrivate; - -struct _GsmXSMPClient -{ - GsmClient parent; - GsmXSMPClientPrivate *priv; -}; +#define GSM_TYPE_XSMP_CLIENT (gsm_xsmp_client_get_type ()) +G_DECLARE_DERIVABLE_TYPE (GsmXSMPClient, gsm_xsmp_client, GSM, XSMP_CLIENT, GsmClient) struct _GsmXSMPClientClass { @@ -86,8 +69,6 @@ void gsm_xsmp_client_save_yourself_phase2 (GsmXSMPClient *client); void gsm_xsmp_client_interact (GsmXSMPClient *client); void gsm_xsmp_client_shutdown_cancelled (GsmXSMPClient *client); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_XSMP_CLIENT_H__ */ diff --git a/mate-session/gsm-xsmp-server.c b/mate-session/gsm-xsmp-server.c index 83ec21f..293ed7a 100644 --- a/mate-session/gsm-xsmp-server.c +++ b/mate-session/gsm-xsmp-server.c @@ -61,10 +61,9 @@ #define GSM_ICE_MAGIC_COOKIE_AUTH_NAME "MIT-MAGIC-COOKIE-1" #define GSM_ICE_MAGIC_COOKIE_LEN 16 -#define GSM_XSMP_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_XSMP_SERVER, GsmXsmpServerPrivate)) - -struct GsmXsmpServerPrivate +struct _GsmXsmpServer { + GObject parent; GsmStore *client_store; IceListenObj *xsmp_sockets; @@ -229,14 +228,14 @@ gsm_xsmp_server_start (GsmXsmpServer *server) GIOChannel *channel; int i; - for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) { + for (i = 0; i < server->num_local_xsmp_sockets; i++) { GsmIceConnectionData *data; data = g_new0 (GsmIceConnectionData, 1); data->server = server; - data->listener = server->priv->xsmp_sockets[i]; + data->listener = server->xsmp_sockets[i]; - channel = g_io_channel_unix_new (IceGetListenConnectionNumber (server->priv->xsmp_sockets[i])); + channel = g_io_channel_unix_new (IceGetListenConnectionNumber (server->xsmp_sockets[i])); g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, G_IO_IN | G_IO_HUP | G_IO_ERR, @@ -257,11 +256,11 @@ gsm_xsmp_server_set_client_store (GsmXsmpServer *xsmp_server, g_object_ref (store); } - if (xsmp_server->priv->client_store != NULL) { - g_object_unref (xsmp_server->priv->client_store); + if (xsmp_server->client_store != NULL) { + g_object_unref (xsmp_server->client_store); } - xsmp_server->priv->client_store = store; + xsmp_server->client_store = store; } static void @@ -296,7 +295,7 @@ gsm_xsmp_server_get_property (GObject *object, switch (prop_id) { case PROP_CLIENT_STORE: - g_value_set_object (value, self->priv->client_store); + g_value_set_object (value, self->client_store); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -319,7 +318,7 @@ accept_xsmp_connection (SmsConn sms_conn, GsmIceConnectionWatch *data; /* FIXME: what about during shutdown but before gsm_xsmp_shutdown? */ - if (server->priv->xsmp_sockets == NULL) { + if (server->xsmp_sockets == NULL) { g_debug ("GsmXsmpServer: In shutdown, rejecting new client"); *failure_reason_ret = strdup (_("Refusing new client connection because the session is currently being shut down\n")); @@ -334,7 +333,7 @@ accept_xsmp_connection (SmsConn sms_conn, client = gsm_xsmp_client_new (ice_conn); - gsm_store_add (server->priv->client_store, gsm_client_peek_id (client), G_OBJECT (client)); + gsm_store_add (server->client_store, gsm_client_peek_id (client), G_OBJECT (client)); /* the store will own the ref */ g_object_unref (client); @@ -448,9 +447,9 @@ update_iceauthority (GsmXsmpServer *server, return FALSE; } - our_network_ids = g_malloc (server->priv->num_local_xsmp_sockets * sizeof (char *)); - for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) { - our_network_ids[i] = IceGetListenConnectionString (server->priv->xsmp_sockets[i]); + our_network_ids = g_malloc (server->num_local_xsmp_sockets * sizeof (char *)); + for (i = 0; i < server->num_local_xsmp_sockets; i++) { + our_network_ids[i] = IceGetListenConnectionString (server->xsmp_sockets[i]); } entries = NULL; @@ -469,13 +468,13 @@ update_iceauthority (GsmXsmpServer *server, continue; } - for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) { + for (i = 0; i < server->num_local_xsmp_sockets; i++) { if (!strcmp (auth_entry->network_id, our_network_ids[i])) { IceFreeAuthFileEntry (auth_entry); break; } } - if (i != server->priv->num_local_xsmp_sockets) { + if (i != server->num_local_xsmp_sockets) { continue; } @@ -503,7 +502,7 @@ update_iceauthority (GsmXsmpServer *server, } if (adding) { - for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) { + for (i = 0; i < server->num_local_xsmp_sockets; i++) { entries = g_slist_append (entries, auth_entry_new ("ICE", our_network_ids[i])); entries = g_slist_prepend (entries, @@ -523,7 +522,7 @@ update_iceauthority (GsmXsmpServer *server, cleanup: IceUnlockAuthFile (filename); - for (i = 0; i < server->priv->num_local_xsmp_sockets; i++) { + for (i = 0; i < server->num_local_xsmp_sockets; i++) { free (our_network_ids[i]); } g_free (our_network_ids); @@ -579,8 +578,8 @@ setup_listener (GsmXsmpServer *server) */ saved_umask = umask (0); umask (saved_umask); - res = IceListenForConnections (&server->priv->num_xsmp_sockets, - &server->priv->xsmp_sockets, + res = IceListenForConnections (&server->num_xsmp_sockets, + &server->xsmp_sockets, sizeof (error), error); if (! res) { @@ -592,28 +591,28 @@ setup_listener (GsmXsmpServer *server) /* Find the local sockets in the returned socket list and move them * to the start of the list. */ - for (i = server->priv->num_local_xsmp_sockets = 0; i < server->priv->num_xsmp_sockets; i++) { - char *id = IceGetListenConnectionString (server->priv->xsmp_sockets[i]); + for (i = server->num_local_xsmp_sockets = 0; i < server->num_xsmp_sockets; i++) { + char *id = IceGetListenConnectionString (server->xsmp_sockets[i]); if (!strncmp (id, "local/", sizeof ("local/") - 1) || !strncmp (id, "unix/", sizeof ("unix/") - 1)) { - if (i > server->priv->num_local_xsmp_sockets) { + if (i > server->num_local_xsmp_sockets) { IceListenObj tmp; - tmp = server->priv->xsmp_sockets[i]; - server->priv->xsmp_sockets[i] = server->priv->xsmp_sockets[server->priv->num_local_xsmp_sockets]; - server->priv->xsmp_sockets[server->priv->num_local_xsmp_sockets] = tmp; + tmp = server->xsmp_sockets[i]; + server->xsmp_sockets[i] = server->xsmp_sockets[server->num_local_xsmp_sockets]; + server->xsmp_sockets[server->num_local_xsmp_sockets] = tmp; } - server->priv->num_local_xsmp_sockets++; + server->num_local_xsmp_sockets++; } free (id); } - if (server->priv->num_local_xsmp_sockets == 0) { + if (server->num_local_xsmp_sockets == 0) { gsm_util_init_error (TRUE, "IceListenForConnections did not return a local listener!"); } #ifdef HAVE_XTRANS - if (server->priv->num_local_xsmp_sockets != server->priv->num_xsmp_sockets) { + if (server->num_local_xsmp_sockets != server->num_xsmp_sockets) { /* Xtrans was apparently compiled with support for some * non-local transport besides TCP (which we disabled above); we * won't create IO watches on those extra sockets, so @@ -624,10 +623,10 @@ setup_listener (GsmXsmpServer *server) * stop it, the fix is to add additional _IceTransNoListen() * calls above. */ - network_id_list = IceComposeNetworkIdList (server->priv->num_xsmp_sockets - server->priv->num_local_xsmp_sockets, - server->priv->xsmp_sockets + server->priv->num_local_xsmp_sockets); + network_id_list = IceComposeNetworkIdList (server->num_xsmp_sockets - server->num_local_xsmp_sockets, + server->xsmp_sockets + server->num_local_xsmp_sockets); g_warning ("IceListenForConnections returned %d non-local listeners: %s", - server->priv->num_xsmp_sockets - server->priv->num_local_xsmp_sockets, + server->num_xsmp_sockets - server->num_local_xsmp_sockets, network_id_list); free (network_id_list); } @@ -641,8 +640,8 @@ setup_listener (GsmXsmpServer *server) IceAuthFileName ()); } - network_id_list = IceComposeNetworkIdList (server->priv->num_local_xsmp_sockets, - server->priv->xsmp_sockets); + network_id_list = IceComposeNetworkIdList (server->num_local_xsmp_sockets, + server->xsmp_sockets); gsm_util_setenv ("SESSION_MANAGER", network_id_list); g_debug ("GsmXsmpServer: SESSION_MANAGER=%s\n", network_id_list); @@ -681,15 +680,11 @@ gsm_xsmp_server_class_init (GsmXsmpServerClass *klass) NULL, GSM_TYPE_STORE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_type_class_add_private (klass, sizeof (GsmXsmpServerPrivate)); } static void gsm_xsmp_server_init (GsmXsmpServer *xsmp_server) { - xsmp_server->priv = GSM_XSMP_SERVER_GET_PRIVATE (xsmp_server); - } static void @@ -702,13 +697,11 @@ gsm_xsmp_server_finalize (GObject *object) xsmp_server = GSM_XSMP_SERVER (object); - g_return_if_fail (xsmp_server->priv != NULL); - - IceFreeListenObjs (xsmp_server->priv->num_xsmp_sockets, - xsmp_server->priv->xsmp_sockets); + IceFreeListenObjs (xsmp_server->num_xsmp_sockets, + xsmp_server->xsmp_sockets); - if (xsmp_server->priv->client_store != NULL) { - g_object_unref (xsmp_server->priv->client_store); + if (xsmp_server->client_store != NULL) { + g_object_unref (xsmp_server->client_store); } G_OBJECT_CLASS (gsm_xsmp_server_parent_class)->finalize (object); diff --git a/mate-session/gsm-xsmp-server.h b/mate-session/gsm-xsmp-server.h index 3c4998a..29f72db 100644 --- a/mate-session/gsm-xsmp-server.h +++ b/mate-session/gsm-xsmp-server.h @@ -26,37 +26,14 @@ #include "gsm-store.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define GSM_TYPE_XSMP_SERVER (gsm_xsmp_server_get_type ()) -#define GSM_XSMP_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSM_TYPE_XSMP_SERVER, GsmXsmpServer)) -#define GSM_XSMP_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSM_TYPE_XSMP_SERVER, GsmXsmpServerClass)) -#define GSM_IS_XSMP_SERVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSM_TYPE_XSMP_SERVER)) -#define GSM_IS_XSMP_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSM_TYPE_XSMP_SERVER)) -#define GSM_XSMP_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSM_TYPE_XSMP_SERVER, GsmXsmpServerClass)) - -typedef struct GsmXsmpServerPrivate GsmXsmpServerPrivate; - -typedef struct -{ - GObject parent; - GsmXsmpServerPrivate *priv; -} GsmXsmpServer; - -typedef struct -{ - GObjectClass parent_class; -} GsmXsmpServerClass; - -GType gsm_xsmp_server_get_type (void); +G_DECLARE_FINAL_TYPE (GsmXsmpServer, gsm_xsmp_server, GSM, XSMP_SERVER, GObject) GsmXsmpServer * gsm_xsmp_server_new (GsmStore *client_store); void gsm_xsmp_server_start (GsmXsmpServer *server); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __GSM_XSMP_SERVER_H */ |