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>
This commit is contained in:
Florian Müllner 2022-02-09 18:14:04 +01:00 committed by Marge Bot
parent e3a3f79200
commit 17719352f3
4 changed files with 266 additions and 227 deletions

View File

@ -90,14 +90,19 @@ struct _ShellApp
enum { enum {
PROP_0, PROP_0,
PROP_STATE, PROP_STATE,
PROP_BUSY, PROP_BUSY,
PROP_ID, PROP_ID,
PROP_ACTION_GROUP, PROP_ACTION_GROUP,
PROP_ICON, PROP_ICON,
PROP_APP_INFO PROP_APP_INFO,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
enum { enum {
WINDOWS_CHANGED, WINDOWS_CHANGED,
LAST_SIGNAL LAST_SIGNAL
@ -212,7 +217,7 @@ on_window_icon_changed (GObject *object,
if (!app->fallback_icon) if (!app->fallback_icon)
app->fallback_icon = g_themed_icon_new ("application-x-executable"); 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); g_assert (app->running_state->muxer);
gtk_action_muxer_insert (app->running_state->muxer, "win", actions); 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); _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 static void
@ -1053,7 +1058,7 @@ busy_changed_cb (GObject *object,
g_assert (SHELL_IS_APP (app)); 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 static void
@ -1076,7 +1081,7 @@ get_application_proxy (GObject *source,
G_CALLBACK (busy_changed_cb), G_CALLBACK (busy_changed_cb),
app); app);
if (shell_org_gtk_application_get_busy (proxy)) 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 && if (app->running_state != NULL &&
@ -1178,7 +1183,7 @@ _shell_app_remove_window (ShellApp *app,
/* Select a new icon from a different window. */ /* Select a new icon from a different window. */
g_clear_object (&app->fallback_icon); 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); 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 * The high-level state of the application, effectively whether it's
* running or not, or transitioning between those states. * running or not, or transitioning between those states.
*/ */
g_object_class_install_property (gobject_class, props[PROP_STATE] =
PROP_STATE,
g_param_spec_enum ("state", g_param_spec_enum ("state",
"State", "State",
"Application state", "Application state",
SHELL_TYPE_APP_STATE, SHELL_TYPE_APP_STATE,
SHELL_APP_STATE_STOPPED, SHELL_APP_STATE_STOPPED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellApp:busy: * ShellApp:busy:
* *
* Whether the application has marked itself as busy. * Whether the application has marked itself as busy.
*/ */
g_object_class_install_property (gobject_class, props[PROP_BUSY] =
PROP_BUSY,
g_param_spec_boolean ("busy", g_param_spec_boolean ("busy",
"Busy", "Busy",
"Busy state", "Busy state",
FALSE, FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellApp:id: * ShellApp:id:
@ -1709,26 +1712,24 @@ shell_app_class_init(ShellAppClass *klass)
* The id of this application (a desktop filename, or a special string * The id of this application (a desktop filename, or a special string
* like window:0xabcd1234) * like window:0xabcd1234)
*/ */
g_object_class_install_property (gobject_class, props[PROP_ID] =
PROP_ID,
g_param_spec_string ("id", g_param_spec_string ("id",
"Application id", "Application id",
"The desktop file id of this ShellApp", "The desktop file id of this ShellApp",
NULL, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellApp:icon: * ShellApp:icon:
* *
* The #GIcon representing this ShellApp * The #GIcon representing this ShellApp
*/ */
g_object_class_install_property (gobject_class, props[PROP_ICON] =
PROP_ICON,
g_param_spec_object ("icon", g_param_spec_object ("icon",
"GIcon", "GIcon",
"The GIcon representing this app", "The GIcon representing this app",
G_TYPE_ICON, G_TYPE_ICON,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellApp:action-group: * ShellApp:action-group:
@ -1736,24 +1737,24 @@ shell_app_class_init(ShellAppClass *klass)
* The #GDBusActionGroup associated with this ShellApp, if any. See the * The #GDBusActionGroup associated with this ShellApp, if any. See the
* documentation of #GApplication and #GActionGroup for details. * documentation of #GApplication and #GActionGroup for details.
*/ */
g_object_class_install_property (gobject_class, props[PROP_ACTION_GROUP] =
PROP_ACTION_GROUP,
g_param_spec_object ("action-group", g_param_spec_object ("action-group",
"Application Action Group", "Application Action Group",
"The action group exported by the remote application", "The action group exported by the remote application",
G_TYPE_ACTION_GROUP, G_TYPE_ACTION_GROUP,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellApp:app-info: * ShellApp:app-info:
* *
* The #GDesktopAppInfo associated with this ShellApp, if any. * The #GDesktopAppInfo associated with this ShellApp, if any.
*/ */
g_object_class_install_property (gobject_class, props[PROP_APP_INFO] =
PROP_APP_INFO,
g_param_spec_object ("app-info", g_param_spec_object ("app-info",
"DesktopAppInfo", "DesktopAppInfo",
"The DesktopAppInfo associated with this app", "The DesktopAppInfo associated with this app",
G_TYPE_DESKTOP_APP_INFO, G_TYPE_DESKTOP_APP_INFO,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, props);
} }

View File

@ -109,8 +109,12 @@ enum {
PROP_FRAME_TIMESTAMPS, PROP_FRAME_TIMESTAMPS,
PROP_FRAME_FINISH_TIMESTAMP, PROP_FRAME_FINISH_TIMESTAMP,
PROP_SWITCHEROO_CONTROL, PROP_SWITCHEROO_CONTROL,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
/* Signals */ /* Signals */
enum enum
{ {
@ -144,7 +148,7 @@ got_switcheroo_control_gpus_property_cb (GObject *source_object,
global = user_data; global = user_data;
g_dbus_proxy_set_cached_property (global->switcheroo_control, "GPUs", gpus); 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 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); 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")) 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; return;
} }
/* Delay property notification until we have all the properties gathered */ /* 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_debug ("switcheroo-control vanished");
g_clear_object (&global->switcheroo_control); 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 static void
@ -488,145 +492,140 @@ shell_global_class_init (ShellGlobalClass *klass)
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
g_object_class_install_property (gobject_class, props[PROP_SESSION_MODE] =
PROP_SESSION_MODE,
g_param_spec_string ("session-mode", g_param_spec_string ("session-mode",
"Session Mode", "Session Mode",
"The session mode to use", "The session mode to use",
"user", "user",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class, props[PROP_SCREEN_WIDTH] =
PROP_SCREEN_WIDTH,
g_param_spec_int ("screen-width", g_param_spec_int ("screen-width",
"Screen Width", "Screen Width",
"Screen width, in pixels", "Screen width, in pixels",
0, G_MAXINT, 1, 0, G_MAXINT, 1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class, props[PROP_SCREEN_HEIGHT] =
PROP_SCREEN_HEIGHT,
g_param_spec_int ("screen-height", g_param_spec_int ("screen-height",
"Screen Height", "Screen Height",
"Screen height, in pixels", "Screen height, in pixels",
0, G_MAXINT, 1, 0, G_MAXINT, 1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_BACKEND, props[PROP_BACKEND] =
g_param_spec_object ("backend", g_param_spec_object ("backend",
"Backend", "Backend",
"MetaBackend object", "MetaBackend object",
META_TYPE_BACKEND, META_TYPE_BACKEND,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_CONTEXT, props[PROP_CONTEXT] =
g_param_spec_object ("context", g_param_spec_object ("context",
"Context", "Context",
"MetaContext object", "MetaContext object",
META_TYPE_CONTEXT, META_TYPE_CONTEXT,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_DISPLAY, props[PROP_DISPLAY] =
g_param_spec_object ("display", g_param_spec_object ("display",
"Display", "Display",
"Metacity display object for the shell", "Metacity display object for the shell",
META_TYPE_DISPLAY, META_TYPE_DISPLAY,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class, props[PROP_WORKSPACE_MANAGER] =
PROP_WORKSPACE_MANAGER,
g_param_spec_object ("workspace-manager", g_param_spec_object ("workspace-manager",
"Workspace manager", "Workspace manager",
"Workspace manager", "Workspace manager",
META_TYPE_WORKSPACE_MANAGER, META_TYPE_WORKSPACE_MANAGER,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class, props[PROP_STAGE] =
PROP_STAGE,
g_param_spec_object ("stage", g_param_spec_object ("stage",
"Stage", "Stage",
"Stage holding the desktop scene graph", "Stage holding the desktop scene graph",
CLUTTER_TYPE_ACTOR, CLUTTER_TYPE_ACTOR,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_WINDOW_GROUP, props[PROP_WINDOW_GROUP] =
g_param_spec_object ("window-group", g_param_spec_object ("window-group",
"Window Group", "Window Group",
"Actor holding window actors", "Actor holding window actors",
CLUTTER_TYPE_ACTOR, CLUTTER_TYPE_ACTOR,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class, props[PROP_TOP_WINDOW_GROUP] =
PROP_TOP_WINDOW_GROUP,
g_param_spec_object ("top-window-group", g_param_spec_object ("top-window-group",
"Top Window Group", "Top Window Group",
"Actor holding override-redirect windows", "Actor holding override-redirect windows",
CLUTTER_TYPE_ACTOR, CLUTTER_TYPE_ACTOR,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class, props[PROP_WINDOW_MANAGER] =
PROP_WINDOW_MANAGER,
g_param_spec_object ("window-manager", g_param_spec_object ("window-manager",
"Window Manager", "Window Manager",
"Window management interface", "Window management interface",
SHELL_TYPE_WM, SHELL_TYPE_WM,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_SETTINGS, props[PROP_SETTINGS] =
g_param_spec_object ("settings", g_param_spec_object ("settings",
"Settings", "Settings",
"GSettings instance for gnome-shell configuration", "GSettings instance for gnome-shell configuration",
G_TYPE_SETTINGS, G_TYPE_SETTINGS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_DATADIR, props[PROP_DATADIR] =
g_param_spec_string ("datadir", g_param_spec_string ("datadir",
"Data directory", "Data directory",
"Directory containing gnome-shell data files", "Directory containing gnome-shell data files",
NULL, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_IMAGEDIR, props[PROP_IMAGEDIR] =
g_param_spec_string ("imagedir", g_param_spec_string ("imagedir",
"Image directory", "Image directory",
"Directory containing gnome-shell image files", "Directory containing gnome-shell image files",
NULL, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_USERDATADIR, props[PROP_USERDATADIR] =
g_param_spec_string ("userdatadir", g_param_spec_string ("userdatadir",
"User data directory", "User data directory",
"Directory containing gnome-shell user data", "Directory containing gnome-shell user data",
NULL, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_FOCUS_MANAGER, props[PROP_FOCUS_MANAGER] =
g_param_spec_object ("focus-manager", g_param_spec_object ("focus-manager",
"Focus manager", "Focus manager",
"The shell's StFocusManager", "The shell's StFocusManager",
ST_TYPE_FOCUS_MANAGER, ST_TYPE_FOCUS_MANAGER,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_FRAME_TIMESTAMPS, props[PROP_FRAME_TIMESTAMPS] =
g_param_spec_boolean ("frame-timestamps", g_param_spec_boolean ("frame-timestamps",
"Frame Timestamps", "Frame Timestamps",
"Whether to log frame timestamps in the performance log", "Whether to log frame timestamps in the performance log",
FALSE, FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_FRAME_FINISH_TIMESTAMP, props[PROP_FRAME_FINISH_TIMESTAMP] =
g_param_spec_boolean ("frame-finish-timestamp", g_param_spec_boolean ("frame-finish-timestamp",
"Frame Finish Timestamps", "Frame Finish Timestamps",
"Whether at the end of a frame to call glFinish and log paintCompletedTimestamp", "Whether at the end of a frame to call glFinish and log paintCompletedTimestamp",
FALSE, FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gobject_class,
PROP_SWITCHEROO_CONTROL, props[PROP_SWITCHEROO_CONTROL] =
g_param_spec_object ("switcheroo-control", g_param_spec_object ("switcheroo-control",
"switcheroo-control", "switcheroo-control",
"D-Bus Proxy for switcheroo-control daemon", "D-Bus Proxy for switcheroo-control daemon",
G_TYPE_DBUS_PROXY, G_TYPE_DBUS_PROXY,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 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); 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 static void
@ -867,7 +866,7 @@ global_stage_notify_height (GObject *gobject,
{ {
ShellGlobal *global = SHELL_GLOBAL (data); 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 static gboolean

View File

@ -65,6 +65,17 @@ struct _ShellKeyringPrompt
enum { enum {
PROP_0, 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_TITLE,
PROP_MESSAGE, PROP_MESSAGE,
PROP_DESCRIPTION, PROP_DESCRIPTION,
@ -75,15 +86,11 @@ enum {
PROP_PASSWORD_STRENGTH, PROP_PASSWORD_STRENGTH,
PROP_CALLER_WINDOW, PROP_CALLER_WINDOW,
PROP_CONTINUE_LABEL, PROP_CONTINUE_LABEL,
PROP_CANCEL_LABEL, PROP_CANCEL_LABEL
PROP_PASSWORD_VISIBLE,
PROP_CONFIRM_VISIBLE,
PROP_WARNING_VISIBLE,
PROP_CHOICE_VISIBLE,
PROP_PASSWORD_ACTOR,
PROP_CONFIRM_ACTOR
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
static void shell_keyring_prompt_iface (GcrPromptIface *iface); static void shell_keyring_prompt_iface (GcrPromptIface *iface);
G_DEFINE_TYPE_WITH_CODE (ShellKeyringPrompt, shell_keyring_prompt, G_TYPE_OBJECT, 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) if (!self->warning)
self->warning = g_strdup (""); self->warning = g_strdup ("");
g_object_notify (obj, "warning"); g_object_notify (obj, "warning");
g_object_notify (obj, "warning-visible"); g_object_notify_by_pspec (obj, props[PROP_WARNING_VISIBLE]);
break; break;
case PROP_CHOICE_LABEL: case PROP_CHOICE_LABEL:
g_free (self->choice_label); g_free (self->choice_label);
@ -171,7 +178,7 @@ shell_keyring_prompt_set_property (GObject *obj,
if (!self->choice_label) if (!self->choice_label)
self->choice_label = g_strdup (""); self->choice_label = g_strdup ("");
g_object_notify (obj, "choice-label"); g_object_notify (obj, "choice-label");
g_object_notify (obj, "choice-visible"); g_object_notify_by_pspec (obj, props[PROP_CHOICE_VISIBLE]);
break; break;
case PROP_CHOICE_CHOSEN: case PROP_CHOICE_CHOSEN:
self->choice_chosen = g_value_get_boolean (value); self->choice_chosen = g_value_get_boolean (value);
@ -180,7 +187,7 @@ shell_keyring_prompt_set_property (GObject *obj,
case PROP_PASSWORD_NEW: case PROP_PASSWORD_NEW:
self->password_new = g_value_get_boolean (value); self->password_new = g_value_get_boolean (value);
g_object_notify (obj, "password-new"); g_object_notify (obj, "password-new");
g_object_notify (obj, "confirm-visible"); g_object_notify_by_pspec (obj, props[PROP_CONFIRM_VISIBLE]);
break; break;
case PROP_CALLER_WINDOW: case PROP_CALLER_WINDOW:
/* ignored */ /* ignored */
@ -345,54 +352,74 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
* *
* Whether the password entry is visible or not. * Whether the password entry is visible or not.
*/ */
g_object_class_install_property (gobject_class, PROP_PASSWORD_VISIBLE, props[PROP_PASSWORD_VISIBLE] =
g_param_spec_boolean ("password-visible", "Password visible", "Password field is visible", g_param_spec_boolean ("password-visible",
FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); "Password visible",
"Password field is visible",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellKeyringPrompt:confirm-visible: * ShellKeyringPrompt:confirm-visible:
* *
* Whether the password confirm entry is visible or not. * Whether the password confirm entry is visible or not.
*/ */
g_object_class_install_property (gobject_class, PROP_CONFIRM_VISIBLE, props[PROP_CONFIRM_VISIBLE] =
g_param_spec_boolean ("confirm-visible", "Confirm visible", "Confirm field is visible", g_param_spec_boolean ("confirm-visible",
FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); "Confirm visible",
"Confirm field is visible",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellKeyringPrompt:warning-visible: * ShellKeyringPrompt:warning-visible:
* *
* Whether the warning label is visible or not. * Whether the warning label is visible or not.
*/ */
g_object_class_install_property (gobject_class, PROP_WARNING_VISIBLE, props[PROP_WARNING_VISIBLE] =
g_param_spec_boolean ("warning-visible", "Warning visible", "Warning is visible", g_param_spec_boolean ("warning-visible",
FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); "Warning visible",
"Warning is visible",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellKeyringPrompt:choice-visible: * ShellKeyringPrompt:choice-visible:
* *
* Whether the choice check box is visible or not. * Whether the choice check box is visible or not.
*/ */
g_object_class_install_property (gobject_class, PROP_CHOICE_VISIBLE, props[PROP_CHOICE_VISIBLE] =
g_param_spec_boolean ("choice-visible", "Choice visible", "Choice is visible", g_param_spec_boolean ("choice-visible",
FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); "Choice visible",
"Choice is visible",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellKeyringPrompt:password-actor: * ShellKeyringPrompt:password-actor:
* *
* Text field for password * Text field for password
*/ */
g_object_class_install_property (gobject_class, PROP_PASSWORD_ACTOR, props[PROP_PASSWORD_ACTOR] =
g_param_spec_object ("password-actor", "Password actor", "Text field for password", g_param_spec_object ("password-actor",
CLUTTER_TYPE_TEXT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); "Password actor",
"Text field for password",
CLUTTER_TYPE_TEXT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
/** /**
* ShellKeyringPrompt:confirm-actor: * ShellKeyringPrompt:confirm-actor:
* *
* Text field for confirmation password * Text field for confirmation password
*/ */
g_object_class_install_property (gobject_class, PROP_CONFIRM_ACTOR, props[PROP_CONFIRM_ACTOR] =
g_param_spec_object ("confirm-actor", "Confirm actor", "Text field for confirming password", g_param_spec_object ("confirm-actor",
CLUTTER_TYPE_TEXT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); "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), signals[SIGNAL_SHOW_PASSWORD] = g_signal_new ("show-password", G_TYPE_FROM_CLASS (klass),
0, 0, NULL, NULL, 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 (SHELL_IS_KEYRING_PROMPT (self));
g_return_if_fail (password_actor == NULL || CLUTTER_IS_TEXT (password_actor)); g_return_if_fail (password_actor == NULL || CLUTTER_IS_TEXT (password_actor));
if (self->password_actor == password_actor)
return;
if (password_actor) if (password_actor)
{ {
buffer = shell_secure_text_buffer_new (); buffer = shell_secure_text_buffer_new ();
@ -661,7 +691,7 @@ shell_keyring_prompt_set_password_actor (ShellKeyringPrompt *self,
} }
self->password_actor = password_actor; 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 (SHELL_IS_KEYRING_PROMPT (self));
g_return_if_fail (confirm_actor == NULL || CLUTTER_IS_TEXT (confirm_actor)); g_return_if_fail (confirm_actor == NULL || CLUTTER_IS_TEXT (confirm_actor));
if (self->confirm_actor == confirm_actor)
return;
if (confirm_actor) if (confirm_actor)
{ {
buffer = shell_secure_text_buffer_new (); buffer = shell_secure_text_buffer_new ();
@ -691,7 +724,7 @@ shell_keyring_prompt_set_confirm_actor (ShellKeyringPrompt *self,
if (self->confirm_actor) if (self->confirm_actor)
g_object_unref (self->confirm_actor); g_object_unref (self->confirm_actor);
self->confirm_actor = 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]);
} }
/** /**

View File

@ -48,9 +48,14 @@ G_DEFINE_TYPE (ShellWindowTracker, shell_window_tracker, G_TYPE_OBJECT);
enum { enum {
PROP_0, PROP_0,
PROP_FOCUS_APP
PROP_FOCUS_APP,
N_PROPS
}; };
static GParamSpec *props[N_PROPS] = { NULL, };
enum { enum {
STARTUP_SEQUENCE_CHANGED, STARTUP_SEQUENCE_CHANGED,
TRACKED_WINDOWS_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->get_property = shell_window_tracker_get_property;
gobject_class->finalize = shell_window_tracker_finalize; gobject_class->finalize = shell_window_tracker_finalize;
g_object_class_install_property (gobject_class, props[PROP_FOCUS_APP] =
PROP_FOCUS_APP,
g_param_spec_object ("focus-app", g_param_spec_object ("focus-app",
"Focus App", "Focus App",
"Focused application", "Focused application",
SHELL_TYPE_APP, SHELL_TYPE_APP,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 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", signals[STARTUP_SEQUENCE_CHANGED] = g_signal_new ("startup-sequence-changed",
SHELL_TYPE_WINDOW_TRACKER, SHELL_TYPE_WINDOW_TRACKER,
@ -731,7 +737,7 @@ set_focus_app (ShellWindowTracker *tracker,
if (tracker->focus_app != NULL) if (tracker->focus_app != NULL)
g_object_ref (tracker->focus_app); 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 static void