diff options
author | yetist <[email protected]> | 2018-11-12 23:06:26 +0800 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-11-26 12:58:58 +0100 |
commit | 6934f934da478bb23fc85cf83d8ba5d620ec7995 (patch) | |
tree | 426cf700dd00a74a5f188ed82e8d3bfb28a0bbe0 /egg | |
parent | 582bcbad9587c34247689947f098647977545ba1 (diff) | |
download | mate-session-manager-6934f934da478bb23fc85cf83d8ba5d620ec7995.tar.bz2 mate-session-manager-6934f934da478bb23fc85cf83d8ba5d620ec7995.tar.xz |
Avoid compile warning for g_type_class_add_private
Fixes the issue with GLib >= 2.58, list of modified files:
- egg/eggsmclient.c
- egg/eggsmclient.h
Diffstat (limited to 'egg')
-rw-r--r-- | egg/eggsmclient.c | 89 | ||||
-rw-r--r-- | egg/eggsmclient.h | 24 |
2 files changed, 46 insertions, 67 deletions
diff --git a/egg/eggsmclient.c b/egg/eggsmclient.c index 0cc3818..2d278df 100644 --- a/egg/eggsmclient.c +++ b/egg/eggsmclient.c @@ -26,9 +26,9 @@ #include "eggsmclient-private.h" static void egg_sm_client_debug_handler (const char *log_domain, - GLogLevelFlags log_level, - const char *message, - gpointer user_data); + GLogLevelFlags log_level, + const char *message, + gpointer user_data); enum { SAVE_STATE, @@ -40,13 +40,11 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -struct _EggSMClientPrivate { +typedef struct { GKeyFile *state_file; -}; - -#define EGG_SM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_SM_CLIENT, EggSMClientPrivate)) +}EggSMClientPrivate; -G_DEFINE_TYPE (EggSMClient, egg_sm_client, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (EggSMClient, egg_sm_client, G_TYPE_OBJECT) static EggSMClient *global_client; static EggSMClientMode global_client_mode = EGG_SM_CLIENT_MODE_NORMAL; @@ -62,8 +60,6 @@ egg_sm_client_class_init (EggSMClientClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (EggSMClientPrivate)); - /** * EggSMClient::save_state: * @client: the client @@ -182,9 +178,9 @@ static char *sm_config_prefix = NULL; static gboolean sm_client_post_parse_func (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) + GOptionGroup *group, + gpointer data, + GError **error) { EggSMClient *client = egg_sm_client_get (); @@ -246,12 +242,12 @@ egg_sm_client_get_option_group (void) /* Use our own debug handler for the "EggSMClient" domain. */ g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - egg_sm_client_debug_handler, NULL); + egg_sm_client_debug_handler, NULL); group = g_option_group_new ("sm-client", - _("Session management options:"), - _("Show session management options"), - NULL, NULL); + _("Session management options:"), + _("Show session management options"), + NULL, NULL); g_option_group_add_entries (group, entries); g_option_group_set_parse_hooks (group, NULL, sm_client_post_parse_func); @@ -316,36 +312,36 @@ EggSMClient * egg_sm_client_get (void) { if (!global_client) + { + if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED && + !sm_client_disable) { - if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED && - !sm_client_disable) - { #if defined (GDK_WINDOWING_WIN32) - global_client = egg_sm_client_win32_new (); + global_client = egg_sm_client_win32_new (); #elif defined (GDK_WINDOWING_QUARTZ) - global_client = egg_sm_client_osx_new (); + global_client = egg_sm_client_osx_new (); #else - /* If both D-Bus and XSMP are compiled in, try XSMP first - * (since it supports state saving) and fall back to D-Bus - * if XSMP isn't available. - */ + /* If both D-Bus and XSMP are compiled in, try XSMP first + * (since it supports state saving) and fall back to D-Bus + * if XSMP isn't available. + */ # ifdef EGG_SM_CLIENT_BACKEND_XSMP - global_client = egg_sm_client_xsmp_new (); + global_client = egg_sm_client_xsmp_new (); # endif # ifdef EGG_SM_CLIENT_BACKEND_DBUS - if (!global_client) - global_client = egg_sm_client_dbus_new (); + if (!global_client) + global_client = egg_sm_client_dbus_new (); # endif #endif - } - - /* Fallback: create a dummy client, so that callers don't have - * to worry about a %NULL return value. - */ - if (!global_client) - global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL); } + /* Fallback: create a dummy client, so that callers don't have + * to worry about a %NULL return value. + */ + if (!global_client) + global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL); + } + return global_client; } @@ -390,7 +386,8 @@ egg_sm_client_is_resumed (EggSMClient *client) GKeyFile * egg_sm_client_get_state_file (EggSMClient *client) { - EggSMClientPrivate *priv = EGG_SM_CLIENT_GET_PRIVATE (client); + EggSMClientPrivate *priv = egg_sm_client_get_instance_private (client); + char *state_file_path; GError *err = NULL; @@ -410,7 +407,7 @@ egg_sm_client_get_state_file (EggSMClient *client) if (!g_key_file_load_from_file (priv->state_file, state_file_path, 0, &err)) { g_warning ("Could not load SM state file '%s': %s", - sm_client_state_file, err->message); + sm_client_state_file, err->message); g_clear_error (&err); g_key_file_free (priv->state_file); priv->state_file = NULL; @@ -435,8 +432,8 @@ egg_sm_client_get_state_file (EggSMClient *client) **/ void egg_sm_client_set_restart_command (EggSMClient *client, - int argc, - const char **argv) + int argc, + const char **argv) { g_return_if_fail (EGG_IS_SM_CLIENT (client)); @@ -464,7 +461,7 @@ egg_sm_client_set_restart_command (EggSMClient *client, **/ void egg_sm_client_will_quit (EggSMClient *client, - gboolean will_quit) + gboolean will_quit) { g_return_if_fail (EGG_IS_SM_CLIENT (client)); @@ -490,7 +487,7 @@ egg_sm_client_will_quit (EggSMClient *client, **/ gboolean egg_sm_client_end_session (EggSMClientEndStyle style, - gboolean request_confirmation) + gboolean request_confirmation) { EggSMClient *client = egg_sm_client_get (); @@ -499,7 +496,7 @@ egg_sm_client_end_session (EggSMClientEndStyle style, if (EGG_SM_CLIENT_GET_CLASS (client)->end_session) { return EGG_SM_CLIENT_GET_CLASS (client)->end_session (client, style, - request_confirmation); + request_confirmation); } else return FALSE; @@ -575,9 +572,9 @@ egg_sm_client_quit (EggSMClient *client) static void egg_sm_client_debug_handler (const char *log_domain, - GLogLevelFlags log_level, - const char *message, - gpointer user_data) + GLogLevelFlags log_level, + const char *message, + gpointer user_data) { static int debug = -1; diff --git a/egg/eggsmclient.h b/egg/eggsmclient.h index 124f325..1721bfd 100644 --- a/egg/eggsmclient.h +++ b/egg/eggsmclient.h @@ -22,20 +22,10 @@ #include <glib-object.h> -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define EGG_TYPE_SM_CLIENT (egg_sm_client_get_type ()) -#define EGG_SM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT, EggSMClient)) -#define EGG_SM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT, EggSMClientClass)) -#define EGG_IS_SM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT)) -#define EGG_IS_SM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT)) -#define EGG_SM_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT, EggSMClientClass)) - -typedef struct _EggSMClient EggSMClient; -typedef struct _EggSMClientClass EggSMClientClass; -typedef struct _EggSMClientPrivate EggSMClientPrivate; +G_DECLARE_DERIVABLE_TYPE (EggSMClient, egg_sm_client, EGG, SM_CLIENT, GObject) typedef enum { EGG_SM_CLIENT_END_SESSION_DEFAULT, @@ -50,12 +40,6 @@ typedef enum { EGG_SM_CLIENT_MODE_NORMAL } EggSMClientMode; -struct _EggSMClient -{ - GObject parent; - -}; - struct _EggSMClientClass { GObjectClass parent_class; @@ -113,8 +97,6 @@ void egg_sm_client_will_quit (EggSMClient *client, gboolean egg_sm_client_end_session (EggSMClientEndStyle style, gboolean request_confirmation); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __EGG_SM_CLIENT_H__ */ |