[gnome-shell] shell: Use g_object_notify_by_pspec() where possible
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] shell: Use g_object_notify_by_pspec() where possible
- Date: Thu, 10 Feb 2022 13:14:06 +0000 (UTC)
commit 17719352f36200345017124fc259449d52c18a14
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 9 18:14:04 2022 +0100
shell: Use g_object_notify_by_pspec() where possible
It's slightly more efficient not having to do property lookups. While
that is unlikely to be a concern for the properties in question, it's
still good practice and makes the code base a bit more consistent.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2168>
src/shell-app.c | 103 ++++++++--------
src/shell-global.c | 287 ++++++++++++++++++++++-----------------------
src/shell-keyring-prompt.c | 93 ++++++++++-----
src/shell-window-tracker.c | 24 ++--
4 files changed, 273 insertions(+), 234 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 8790dba0fe..43b0980205 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -90,14 +90,19 @@ struct _ShellApp
enum {
PROP_0,
+
PROP_STATE,
PROP_BUSY,
PROP_ID,
PROP_ACTION_GROUP,
PROP_ICON,
- PROP_APP_INFO
+ PROP_APP_INFO,
+
+ N_PROPS
};
+static GParamSpec *props[N_PROPS] = { NULL, };
+
enum {
WINDOWS_CHANGED,
LAST_SIGNAL
@@ -212,7 +217,7 @@ on_window_icon_changed (GObject *object,
if (!app->fallback_icon)
app->fallback_icon = g_themed_icon_new ("application-x-executable");
- g_object_notify (G_OBJECT (app), "icon");
+ g_object_notify_by_pspec (G_OBJECT (app), props[PROP_ICON]);
}
/**
@@ -511,7 +516,7 @@ shell_app_update_window_actions (ShellApp *app, MetaWindow *window)
g_assert (app->running_state->muxer);
gtk_action_muxer_insert (app->running_state->muxer, "win", actions);
- g_object_notify (G_OBJECT (app), "action-group");
+ g_object_notify_by_pspec (G_OBJECT (app), props[PROP_ACTION_GROUP]);
}
}
@@ -963,7 +968,7 @@ shell_app_state_transition (ShellApp *app,
_shell_app_system_notify_app_state_changed (shell_app_system_get_default (), app);
- g_object_notify (G_OBJECT (app), "state");
+ g_object_notify_by_pspec (G_OBJECT (app), props[PROP_STATE]);
}
static void
@@ -1053,7 +1058,7 @@ busy_changed_cb (GObject *object,
g_assert (SHELL_IS_APP (app));
- g_object_notify (G_OBJECT (app), "busy");
+ g_object_notify_by_pspec (G_OBJECT (app), props[PROP_BUSY]);
}
static void
@@ -1076,7 +1081,7 @@ get_application_proxy (GObject *source,
G_CALLBACK (busy_changed_cb),
app);
if (shell_org_gtk_application_get_busy (proxy))
- g_object_notify (G_OBJECT (app), "busy");
+ g_object_notify_by_pspec (G_OBJECT (app), props[PROP_BUSY]);
}
if (app->running_state != NULL &&
@@ -1178,7 +1183,7 @@ _shell_app_remove_window (ShellApp *app,
/* Select a new icon from a different window. */
g_clear_object (&app->fallback_icon);
- g_object_notify (G_OBJECT (app), "icon");
+ g_object_notify_by_pspec (G_OBJECT (app), props[PROP_ICON]);
}
g_object_unref (window);
@@ -1681,27 +1686,25 @@ shell_app_class_init(ShellAppClass *klass)
* The high-level state of the application, effectively whether it's
* running or not, or transitioning between those states.
*/
- g_object_class_install_property (gobject_class,
- PROP_STATE,
- g_param_spec_enum ("state",
- "State",
- "Application state",
- SHELL_TYPE_APP_STATE,
- SHELL_APP_STATE_STOPPED,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_STATE] =
+ g_param_spec_enum ("state",
+ "State",
+ "Application state",
+ SHELL_TYPE_APP_STATE,
+ SHELL_APP_STATE_STOPPED,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellApp:busy:
*
* Whether the application has marked itself as busy.
*/
- g_object_class_install_property (gobject_class,
- PROP_BUSY,
- g_param_spec_boolean ("busy",
- "Busy",
- "Busy state",
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_BUSY] =
+ g_param_spec_boolean ("busy",
+ "Busy",
+ "Busy state",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellApp:id:
@@ -1709,26 +1712,24 @@ shell_app_class_init(ShellAppClass *klass)
* The id of this application (a desktop filename, or a special string
* like window:0xabcd1234)
*/
- g_object_class_install_property (gobject_class,
- PROP_ID,
- g_param_spec_string ("id",
- "Application id",
- "The desktop file id of this ShellApp",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_ID] =
+ g_param_spec_string ("id",
+ "Application id",
+ "The desktop file id of this ShellApp",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellApp:icon:
*
* The #GIcon representing this ShellApp
*/
- g_object_class_install_property (gobject_class,
- PROP_ICON,
- g_param_spec_object ("icon",
- "GIcon",
- "The GIcon representing this app",
- G_TYPE_ICON,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_ICON] =
+ g_param_spec_object ("icon",
+ "GIcon",
+ "The GIcon representing this app",
+ G_TYPE_ICON,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellApp:action-group:
@@ -1736,24 +1737,24 @@ shell_app_class_init(ShellAppClass *klass)
* The #GDBusActionGroup associated with this ShellApp, if any. See the
* documentation of #GApplication and #GActionGroup for details.
*/
- g_object_class_install_property (gobject_class,
- PROP_ACTION_GROUP,
- g_param_spec_object ("action-group",
- "Application Action Group",
- "The action group exported by the remote
application",
- G_TYPE_ACTION_GROUP,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_ACTION_GROUP] =
+ g_param_spec_object ("action-group",
+ "Application Action Group",
+ "The action group exported by the remote application",
+ G_TYPE_ACTION_GROUP,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
/**
* ShellApp:app-info:
*
* The #GDesktopAppInfo associated with this ShellApp, if any.
*/
- g_object_class_install_property (gobject_class,
- PROP_APP_INFO,
- g_param_spec_object ("app-info",
- "DesktopAppInfo",
- "The DesktopAppInfo associated with this app",
- G_TYPE_DESKTOP_APP_INFO,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
-
+ props[PROP_APP_INFO] =
+ g_param_spec_object ("app-info",
+ "DesktopAppInfo",
+ "The DesktopAppInfo associated with this app",
+ G_TYPE_DESKTOP_APP_INFO,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class, N_PROPS, props);
}
diff --git a/src/shell-global.c b/src/shell-global.c
index ac8edb1e5b..23551790ce 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -109,8 +109,12 @@ enum {
PROP_FRAME_TIMESTAMPS,
PROP_FRAME_FINISH_TIMESTAMP,
PROP_SWITCHEROO_CONTROL,
+
+ N_PROPS
};
+static GParamSpec *props[N_PROPS] = { NULL, };
+
/* Signals */
enum
{
@@ -144,7 +148,7 @@ got_switcheroo_control_gpus_property_cb (GObject *source_object,
global = user_data;
g_dbus_proxy_set_cached_property (global->switcheroo_control, "GPUs", gpus);
- g_object_notify (G_OBJECT (global), "switcheroo-control");
+ g_object_notify_by_pspec (G_OBJECT (global), props[PROP_SWITCHEROO_CONTROL]);
}
static void
@@ -173,7 +177,7 @@ switcheroo_control_ready_cb (GObject *source_object,
cached_props = g_dbus_proxy_get_cached_property_names (global->switcheroo_control);
if (cached_props != NULL && g_strv_contains ((const gchar * const *) cached_props, "GPUs"))
{
- g_object_notify (G_OBJECT (global), "switcheroo-control");
+ g_object_notify_by_pspec (G_OBJECT (global), props[PROP_SWITCHEROO_CONTROL]);
return;
}
/* Delay property notification until we have all the properties gathered */
@@ -330,7 +334,7 @@ switcheroo_vanished_cb (GDBusConnection *connection,
g_debug ("switcheroo-control vanished");
g_clear_object (&global->switcheroo_control);
- g_object_notify (G_OBJECT (global), "switcheroo-control");
+ g_object_notify_by_pspec (G_OBJECT (global), props[PROP_SWITCHEROO_CONTROL]);
}
static void
@@ -488,145 +492,140 @@ shell_global_class_init (ShellGlobalClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
- g_object_class_install_property (gobject_class,
- PROP_SESSION_MODE,
- g_param_spec_string ("session-mode",
- "Session Mode",
- "The session mode to use",
- "user",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_SCREEN_WIDTH,
- g_param_spec_int ("screen-width",
- "Screen Width",
- "Screen width, in pixels",
- 0, G_MAXINT, 1,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_SCREEN_HEIGHT,
- g_param_spec_int ("screen-height",
- "Screen Height",
- "Screen height, in pixels",
- 0, G_MAXINT, 1,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_BACKEND,
- g_param_spec_object ("backend",
- "Backend",
- "MetaBackend object",
- META_TYPE_BACKEND,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_CONTEXT,
- g_param_spec_object ("context",
- "Context",
- "MetaContext object",
- META_TYPE_CONTEXT,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_DISPLAY,
- g_param_spec_object ("display",
- "Display",
- "Metacity display object for the shell",
- META_TYPE_DISPLAY,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_WORKSPACE_MANAGER,
- g_param_spec_object ("workspace-manager",
- "Workspace manager",
- "Workspace manager",
- META_TYPE_WORKSPACE_MANAGER,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_STAGE,
- g_param_spec_object ("stage",
- "Stage",
- "Stage holding the desktop scene graph",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_WINDOW_GROUP,
- g_param_spec_object ("window-group",
- "Window Group",
- "Actor holding window actors",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_TOP_WINDOW_GROUP,
- g_param_spec_object ("top-window-group",
- "Top Window Group",
- "Actor holding override-redirect windows",
- CLUTTER_TYPE_ACTOR,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class,
- PROP_WINDOW_MANAGER,
- g_param_spec_object ("window-manager",
- "Window Manager",
- "Window management interface",
- SHELL_TYPE_WM,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_SETTINGS,
- g_param_spec_object ("settings",
- "Settings",
- "GSettings instance for gnome-shell configuration",
- G_TYPE_SETTINGS,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_DATADIR,
- g_param_spec_string ("datadir",
- "Data directory",
- "Directory containing gnome-shell data files",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_IMAGEDIR,
- g_param_spec_string ("imagedir",
- "Image directory",
- "Directory containing gnome-shell image files",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_USERDATADIR,
- g_param_spec_string ("userdatadir",
- "User data directory",
- "Directory containing gnome-shell user data",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_FOCUS_MANAGER,
- g_param_spec_object ("focus-manager",
- "Focus manager",
- "The shell's StFocusManager",
- ST_TYPE_FOCUS_MANAGER,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_FRAME_TIMESTAMPS,
- g_param_spec_boolean ("frame-timestamps",
- "Frame Timestamps",
- "Whether to log frame timestamps in the performance
log",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_FRAME_FINISH_TIMESTAMP,
- g_param_spec_boolean ("frame-finish-timestamp",
- "Frame Finish Timestamps",
- "Whether at the end of a frame to call glFinish and
log paintCompletedTimestamp",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class,
- PROP_SWITCHEROO_CONTROL,
- g_param_spec_object ("switcheroo-control",
- "switcheroo-control",
- "D-Bus Proxy for switcheroo-control daemon",
- G_TYPE_DBUS_PROXY,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_SESSION_MODE] =
+ g_param_spec_string ("session-mode",
+ "Session Mode",
+ "The session mode to use",
+ "user",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_SCREEN_WIDTH] =
+ g_param_spec_int ("screen-width",
+ "Screen Width",
+ "Screen width, in pixels",
+ 0, G_MAXINT, 1,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_SCREEN_HEIGHT] =
+ g_param_spec_int ("screen-height",
+ "Screen Height",
+ "Screen height, in pixels",
+ 0, G_MAXINT, 1,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_BACKEND] =
+ g_param_spec_object ("backend",
+ "Backend",
+ "MetaBackend object",
+ META_TYPE_BACKEND,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_CONTEXT] =
+ g_param_spec_object ("context",
+ "Context",
+ "MetaContext object",
+ META_TYPE_CONTEXT,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_DISPLAY] =
+ g_param_spec_object ("display",
+ "Display",
+ "Metacity display object for the shell",
+ META_TYPE_DISPLAY,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_WORKSPACE_MANAGER] =
+ g_param_spec_object ("workspace-manager",
+ "Workspace manager",
+ "Workspace manager",
+ META_TYPE_WORKSPACE_MANAGER,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_STAGE] =
+ g_param_spec_object ("stage",
+ "Stage",
+ "Stage holding the desktop scene graph",
+ CLUTTER_TYPE_ACTOR,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_WINDOW_GROUP] =
+ g_param_spec_object ("window-group",
+ "Window Group",
+ "Actor holding window actors",
+ CLUTTER_TYPE_ACTOR,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_TOP_WINDOW_GROUP] =
+ g_param_spec_object ("top-window-group",
+ "Top Window Group",
+ "Actor holding override-redirect windows",
+ CLUTTER_TYPE_ACTOR,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_WINDOW_MANAGER] =
+ g_param_spec_object ("window-manager",
+ "Window Manager",
+ "Window management interface",
+ SHELL_TYPE_WM,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_SETTINGS] =
+ g_param_spec_object ("settings",
+ "Settings",
+ "GSettings instance for gnome-shell configuration",
+ G_TYPE_SETTINGS,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_DATADIR] =
+ g_param_spec_string ("datadir",
+ "Data directory",
+ "Directory containing gnome-shell data files",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_IMAGEDIR] =
+ g_param_spec_string ("imagedir",
+ "Image directory",
+ "Directory containing gnome-shell image files",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_USERDATADIR] =
+ g_param_spec_string ("userdatadir",
+ "User data directory",
+ "Directory containing gnome-shell user data",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_FOCUS_MANAGER] =
+ g_param_spec_object ("focus-manager",
+ "Focus manager",
+ "The shell's StFocusManager",
+ ST_TYPE_FOCUS_MANAGER,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_FRAME_TIMESTAMPS] =
+ g_param_spec_boolean ("frame-timestamps",
+ "Frame Timestamps",
+ "Whether to log frame timestamps in the performance log",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_FRAME_FINISH_TIMESTAMP] =
+ g_param_spec_boolean ("frame-finish-timestamp",
+ "Frame Finish Timestamps",
+ "Whether at the end of a frame to call glFinish and log paintCompletedTimestamp",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ props[PROP_SWITCHEROO_CONTROL] =
+ g_param_spec_object ("switcheroo-control",
+ "switcheroo-control",
+ "D-Bus Proxy for switcheroo-control daemon",
+ G_TYPE_DBUS_PROXY,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class, N_PROPS, props);
}
/*
@@ -857,7 +856,7 @@ global_stage_notify_width (GObject *gobject,
{
ShellGlobal *global = SHELL_GLOBAL (data);
- g_object_notify (G_OBJECT (global), "screen-width");
+ g_object_notify_by_pspec (G_OBJECT (global), props[PROP_SCREEN_WIDTH]);
}
static void
@@ -867,7 +866,7 @@ global_stage_notify_height (GObject *gobject,
{
ShellGlobal *global = SHELL_GLOBAL (data);
- g_object_notify (G_OBJECT (global), "screen-height");
+ g_object_notify_by_pspec (G_OBJECT (global), props[PROP_SCREEN_HEIGHT]);
}
static gboolean
diff --git a/src/shell-keyring-prompt.c b/src/shell-keyring-prompt.c
index ccf3ffb05b..f25d9f8470 100644
--- a/src/shell-keyring-prompt.c
+++ b/src/shell-keyring-prompt.c
@@ -65,6 +65,17 @@ struct _ShellKeyringPrompt
enum {
PROP_0,
+
+ PROP_PASSWORD_VISIBLE,
+ PROP_CONFIRM_VISIBLE,
+ PROP_WARNING_VISIBLE,
+ PROP_CHOICE_VISIBLE,
+ PROP_PASSWORD_ACTOR,
+ PROP_CONFIRM_ACTOR,
+
+ N_PROPS,
+
+ /* GcrPrompt */
PROP_TITLE,
PROP_MESSAGE,
PROP_DESCRIPTION,
@@ -75,15 +86,11 @@ enum {
PROP_PASSWORD_STRENGTH,
PROP_CALLER_WINDOW,
PROP_CONTINUE_LABEL,
- PROP_CANCEL_LABEL,
- PROP_PASSWORD_VISIBLE,
- PROP_CONFIRM_VISIBLE,
- PROP_WARNING_VISIBLE,
- PROP_CHOICE_VISIBLE,
- PROP_PASSWORD_ACTOR,
- PROP_CONFIRM_ACTOR
+ PROP_CANCEL_LABEL
};
+static GParamSpec *props[N_PROPS] = { NULL, };
+
static void shell_keyring_prompt_iface (GcrPromptIface *iface);
G_DEFINE_TYPE_WITH_CODE (ShellKeyringPrompt, shell_keyring_prompt, G_TYPE_OBJECT,
@@ -163,7 +170,7 @@ shell_keyring_prompt_set_property (GObject *obj,
if (!self->warning)
self->warning = g_strdup ("");
g_object_notify (obj, "warning");
- g_object_notify (obj, "warning-visible");
+ g_object_notify_by_pspec (obj, props[PROP_WARNING_VISIBLE]);
break;
case PROP_CHOICE_LABEL:
g_free (self->choice_label);
@@ -171,7 +178,7 @@ shell_keyring_prompt_set_property (GObject *obj,
if (!self->choice_label)
self->choice_label = g_strdup ("");
g_object_notify (obj, "choice-label");
- g_object_notify (obj, "choice-visible");
+ g_object_notify_by_pspec (obj, props[PROP_CHOICE_VISIBLE]);
break;
case PROP_CHOICE_CHOSEN:
self->choice_chosen = g_value_get_boolean (value);
@@ -180,7 +187,7 @@ shell_keyring_prompt_set_property (GObject *obj,
case PROP_PASSWORD_NEW:
self->password_new = g_value_get_boolean (value);
g_object_notify (obj, "password-new");
- g_object_notify (obj, "confirm-visible");
+ g_object_notify_by_pspec (obj, props[PROP_CONFIRM_VISIBLE]);
break;
case PROP_CALLER_WINDOW:
/* ignored */
@@ -345,54 +352,74 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
*
* Whether the password entry is visible or not.
*/
- g_object_class_install_property (gobject_class, PROP_PASSWORD_VISIBLE,
- g_param_spec_boolean ("password-visible", "Password visible", "Password field is visible",
- FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_PASSWORD_VISIBLE] =
+ g_param_spec_boolean ("password-visible",
+ "Password visible",
+ "Password field is visible",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellKeyringPrompt:confirm-visible:
*
* Whether the password confirm entry is visible or not.
*/
- g_object_class_install_property (gobject_class, PROP_CONFIRM_VISIBLE,
- g_param_spec_boolean ("confirm-visible", "Confirm visible", "Confirm field is visible",
- FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_CONFIRM_VISIBLE] =
+ g_param_spec_boolean ("confirm-visible",
+ "Confirm visible",
+ "Confirm field is visible",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellKeyringPrompt:warning-visible:
*
* Whether the warning label is visible or not.
*/
- g_object_class_install_property (gobject_class, PROP_WARNING_VISIBLE,
- g_param_spec_boolean ("warning-visible", "Warning visible", "Warning is visible",
- FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_WARNING_VISIBLE] =
+ g_param_spec_boolean ("warning-visible",
+ "Warning visible",
+ "Warning is visible",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellKeyringPrompt:choice-visible:
*
* Whether the choice check box is visible or not.
*/
- g_object_class_install_property (gobject_class, PROP_CHOICE_VISIBLE,
- g_param_spec_boolean ("choice-visible", "Choice visible", "Choice is visible",
- FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_CHOICE_VISIBLE] =
+ g_param_spec_boolean ("choice-visible",
+ "Choice visible",
+ "Choice is visible",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/**
* ShellKeyringPrompt:password-actor:
*
* Text field for password
*/
- g_object_class_install_property (gobject_class, PROP_PASSWORD_ACTOR,
- g_param_spec_object ("password-actor", "Password actor", "Text field for password",
- CLUTTER_TYPE_TEXT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ props[PROP_PASSWORD_ACTOR] =
+ g_param_spec_object ("password-actor",
+ "Password actor",
+ "Text field for password",
+ CLUTTER_TYPE_TEXT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
/**
* ShellKeyringPrompt:confirm-actor:
*
* Text field for confirmation password
*/
- g_object_class_install_property (gobject_class, PROP_CONFIRM_ACTOR,
- g_param_spec_object ("confirm-actor", "Confirm actor", "Text field for confirming password",
- CLUTTER_TYPE_TEXT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ props[PROP_CONFIRM_ACTOR] =
+ g_param_spec_object ("confirm-actor",
+ "Confirm actor",
+ "Text field for confirming password",
+ CLUTTER_TYPE_TEXT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class, N_PROPS, props);
signals[SIGNAL_SHOW_PASSWORD] = g_signal_new ("show-password", G_TYPE_FROM_CLASS (klass),
0, 0, NULL, NULL,
@@ -645,6 +672,9 @@ shell_keyring_prompt_set_password_actor (ShellKeyringPrompt *self,
g_return_if_fail (SHELL_IS_KEYRING_PROMPT (self));
g_return_if_fail (password_actor == NULL || CLUTTER_IS_TEXT (password_actor));
+ if (self->password_actor == password_actor)
+ return;
+
if (password_actor)
{
buffer = shell_secure_text_buffer_new ();
@@ -661,7 +691,7 @@ shell_keyring_prompt_set_password_actor (ShellKeyringPrompt *self,
}
self->password_actor = password_actor;
- g_object_notify (G_OBJECT (self), "password-actor");
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_PASSWORD_ACTOR]);
}
/**
@@ -680,6 +710,9 @@ shell_keyring_prompt_set_confirm_actor (ShellKeyringPrompt *self,
g_return_if_fail (SHELL_IS_KEYRING_PROMPT (self));
g_return_if_fail (confirm_actor == NULL || CLUTTER_IS_TEXT (confirm_actor));
+ if (self->confirm_actor == confirm_actor)
+ return;
+
if (confirm_actor)
{
buffer = shell_secure_text_buffer_new ();
@@ -691,7 +724,7 @@ shell_keyring_prompt_set_confirm_actor (ShellKeyringPrompt *self,
if (self->confirm_actor)
g_object_unref (self->confirm_actor);
self->confirm_actor = confirm_actor;
- g_object_notify (G_OBJECT (self), "confirm-actor");
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CONFIRM_ACTOR]);
}
/**
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index a8c85edc73..8c3de6f32a 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -48,9 +48,14 @@ G_DEFINE_TYPE (ShellWindowTracker, shell_window_tracker, G_TYPE_OBJECT);
enum {
PROP_0,
- PROP_FOCUS_APP
+
+ PROP_FOCUS_APP,
+
+ N_PROPS
};
+static GParamSpec *props[N_PROPS] = { NULL, };
+
enum {
STARTUP_SEQUENCE_CHANGED,
TRACKED_WINDOWS_CHANGED,
@@ -97,13 +102,14 @@ shell_window_tracker_class_init (ShellWindowTrackerClass *klass)
gobject_class->get_property = shell_window_tracker_get_property;
gobject_class->finalize = shell_window_tracker_finalize;
- g_object_class_install_property (gobject_class,
- PROP_FOCUS_APP,
- g_param_spec_object ("focus-app",
- "Focus App",
- "Focused application",
- SHELL_TYPE_APP,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ props[PROP_FOCUS_APP] =
+ g_param_spec_object ("focus-app",
+ "Focus App",
+ "Focused application",
+ SHELL_TYPE_APP,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class, N_PROPS, props);
signals[STARTUP_SEQUENCE_CHANGED] = g_signal_new ("startup-sequence-changed",
SHELL_TYPE_WINDOW_TRACKER,
@@ -731,7 +737,7 @@ set_focus_app (ShellWindowTracker *tracker,
if (tracker->focus_app != NULL)
g_object_ref (tracker->focus_app);
- g_object_notify (G_OBJECT (tracker), "focus-app");
+ g_object_notify_by_pspec (G_OBJECT (tracker), props[PROP_FOCUS_APP]);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]