summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cameron <brian.cameron@sun.com>2006-10-30 18:14:49 +0000
committerBrian Cameron <bcameron@src.gnome.org>2006-10-30 18:14:49 +0000
commita6865f4468460545f14784c8b7063ebbffbb2100 (patch)
treea91481d2dd6cbbb43794aff85ee5aebc9baec22f
parent48320ec6774f9cb010631e636871ce5f167a093d (diff)
downloadgdm-a6865f4468460545f14784c8b7063ebbffbb2100.tar.gz
Add new QUERY_CUSTOM_CMD_LABELS and QUERY_CUSTOM_CMD_NO_RESTART_STATUS
2006-10-30 Brian Cameron <brian.cameron@sun.com> * config/gdm.conf.in, daemon/gdm.c, daemon/gdm.h, daemon/gdmconfig.c, docs/C/gdm.xml, gui/gdmlogin.c, gui/greeter/greeter.c, gui/greeter/greeter_item.c, gui/greeter/greeter_configuration.h, gui/greeter/greeter_system.c: Add new QUERY_CUSTOM_CMD_LABELS and QUERY_CUSTOM_CMD_NO_RESTART_STATUS commands and the new CustomCommandIsPersistent[0-9]
-rw-r--r--ChangeLog14
-rw-r--r--config/gdm.conf.in64
-rw-r--r--daemon/gdm.c172
-rw-r--r--daemon/gdm.h34
-rw-r--r--daemon/gdmconfig.c108
-rw-r--r--docs/C/gdm.xml82
-rw-r--r--docs/es/gdm.xml44
-rw-r--r--docs/uk/gdm.xml44
-rw-r--r--gui/gdmlogin.c55
-rw-r--r--gui/greeter/greeter.c99
-rw-r--r--gui/greeter/greeter_configuration.h4
-rw-r--r--gui/greeter/greeter_item.c17
-rw-r--r--gui/greeter/greeter_system.c55
13 files changed, 534 insertions, 258 deletions
diff --git a/ChangeLog b/ChangeLog
index a2700df7..aa044fd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
-2006-10-25 Lukasz Zalewski <lukas@dcs.qmul.ac.uk>
+2006-10-30 Brian Cameron <brian.cameron@sun.com>
+
+ * config/gdm.conf.in, daemon/gdm.c, daemon/gdm.h,
+ daemon/gdmconfig.c, docs/C/gdm.xml, gui/gdmlogin.c,
+ gui/greeter/greeter.c, gui/greeter/greeter_item.c,
+ gui/greeter/greeter_configuration.h,
+ gui/greeter/greeter_system.c: Add new QUERY_CUSTOM_CMD_LABELS
+ and QUERY_CUSTOM_CMD_NO_RESTART_STATUS commands and the
+ new CustomCommandIsPersistent[0-9]
+
+2006-10-29 Lukasz Zalewski <lukas@dcs.qmul.ac.uk>
Fixes enhancement request #358114.
* daemon/gdmconfig.c: Added variables & functions used to read/store
@@ -32,7 +42,7 @@
query beforehand)
* gui/greeter/greeter_system.c: Updated macros and several functions
to accomodate new CustomCommand functionality
-
+
2006-10-26 Brian Cameron <brian.cameron@sun.com>
* gui/gdmcommon.c, gui/greeter/greeter.c: Never die if
diff --git a/config/gdm.conf.in b/config/gdm.conf.in
index eb44a8b5..5037aaf3 100644
--- a/config/gdm.conf.in
+++ b/config/gdm.conf.in
@@ -1,26 +1,25 @@
# GDM Configuration file.
#
-# This file should not be updated by hand. Since GDM 2.13.0.4,
-# configuration choices in the /etc/X11/gdm/gdm.conf-custom file will
-# override the default values specified in this file (installation
-# locations of the configuration files may vary for different distros).
-# This defaults.conf file may be overwritten on upgrade, so to ensure
-# that your configuration choices are not lost, please make sure that
-# your changes are made only the the custom.conf file.
-#
-# If you were using an older version of GDM, your system may have the
-# the older gdm.conf configuration file on the system. If so, then this
-# file is used instead of the custom.conf file for backwards support.
-# If you make changes to the custom.conf file and they seem to not be
-# taking effect, this is likely the problem. Consider migrating your
-# configuration to the new custom.conf file and removing the gdm.conf
+# This file should not be updated by hand. Since GDM 2.13.0.4, configuration
+# choices in the /etc/X11/gdm/gdm.conf-custom file will override the default
+# values specified in this file (installation locations of the configuration
+# files may vary for different distros). This defaults.conf file may be
+# overwritten on upgrade, so to ensure that your configuration choices are not
+# lost, please make sure that your changes are made only the the custom.conf
# file.
#
+# If you were using an older version of GDM, your system may have the the older
+# gdm.conf configuration file on the system. If so, then this file is used
+# instead of the custom.conf file for backwards support. If you make changes
+# to the custom.conf file and they seem to not be taking effect, this is likely
+# the problem. Consider migrating your configuration to the new custom.conf
+# file and removing the gdm.conf file.
+#
# You can use the gdmsetup program to graphically edit the gdm.conf-custom
# file. Note that gdmsetup does not support every option in this file, just
-# the most common ones that users want to change. If you feel that
-# gdmsetup should support additional configuration options, please file a
-# bug report at http://bugzilla.gnome.org/.
+# the most common ones that users want to change. If you feel that gdmsetup
+# should support additional configuration options, please file a bug report at
+# http://bugzilla.gnome.org/.
#
# If you hand-edit the GDM configuration, you should run the following command
# to get the GDM daemon to recognize the change. Any running GDM GUI programs
@@ -600,17 +599,18 @@ chooser=true
[customcommand]
# This section allows you specify up to 10 custom commands. Each of the
-# commands can be defined by the six parameters listed below. In each of the
+# commands can be defined by the seven parameters listed below. In each of the
# descriptions of the parameters N can take on any values between 0 and 9,
# i.e. CustomCommand0=,CustomCommand1=,...,CustomCommand9=. The numbers
# can have gaps as long as they fit within predefined set of 10, and their
# placement order within this section and with respect to each other is
# not important.
#
-# CustomCommandN, CustomCommandTextN, CustomCommandLabelN,
-# CustomCommandLRLabelN, CustomCommandTooltipN, and CustomCommandNoRestartN
-# must all be defined for a given integer N, where N can be a number from
-# 0-9.
+# CustomCommandN, CustomCommandTextN, CustomCommandLabelN,
+# CustomCommandLRLabelN, CustomCommandTooltipN, CustomCommandIsPersistentN
+# and CustomCommandNoRestartN should all be defined for a given integer N,
+# where N can be a number from 0-9 (if not the default values will be
+# assigned except CustomCommandN for which no default exists).
# Custom command to run. Multiple commands may be specified separated by
# semicolons. GDM will use the first valid command. Examples:
@@ -626,15 +626,16 @@ chooser=true
#CustomCommandTextN=
# Custom command label that will appear as stock label on buttons/menu items.
+# This option can't contain any semicolon characters (i.e. ";").
# Examples:
# _Windoze, or
# _Update Me
#CustomCommandLabelN=
-# Custom command label that will appear as stock label on radio buttons/lista
-# items. Examples:
-# Restart into _Windoze, or
-# Perform system _Update
+# Custom command label that will appear as stock label on radio buttons/list
+# items. The underscore indicates the mnemonic used with this item. Examples:
+# Restart into _Windoze
+# Perform system _Update
#CustomCommandLRLabelN=
# Custom command tooltip. Examples
@@ -642,10 +643,19 @@ chooser=true
# Updates the computer software to the most recent version(s)
#CustomCommandTooltipN=
+# Custom command persistence option. Setting it to true will allow this
+# command to appear outside the login manager, e.g. on the desktop through
+# Log Out/Shut Down dialogs. The default value is false.
+#CustomCommandIsPersistentN=
+
# Custom command gdm/system restart option. Setting it to true will not
# restart gdm after command execution. The default commands (reboot, shut
# down) all reboot the system by default which is why the default setting
# is true.
+# In addition when corresponding CustomCommandIsPersistentN option is set to
+# true, setting CustomCommandNoRestartN to false will place CustomCommandN
+# in the Shut Down dialog set of actions, setting it to true will place
+# CustomCommandN in the Log Out dialog set of actions.
#CustomCommandNoRestartN=
#
# Example layout for more than one command:
@@ -654,6 +664,7 @@ chooser=true
#CustomCommandLabel0=
#CustomCommandLRLabel0=
#CustomCommandTooltip0=
+#CustomCommandIsPersistent0=
#CustomCommandNoRestart0=
#
#CustomCommand1=
@@ -661,6 +672,7 @@ chooser=true
#CustomCommandLabel1=
#CustomCommandLRLabel1=
#CustomCommandTooltip1=
+#CustomCommandIsPersistent1=
#CustomCommandNoRestart1=
#
# and so on
diff --git a/daemon/gdm.c b/daemon/gdm.c
index 33823963..10cd91e9 100644
--- a/daemon/gdm.c
+++ b/daemon/gdm.c
@@ -714,10 +714,10 @@ static void
custom_cmd (long cmd_id)
{
if (cmd_id < 0 || cmd_id >= GDM_CUSTOM_COMMAND_MAX) {
- /* We are just feeling very paranoid */
- gdm_error (_("custom_cmd: Custom command index %ld outside permitted range [0,%d)"),
- cmd_id, GDM_CUSTOM_COMMAND_MAX);
- return;
+ /* We are just feeling very paranoid */
+ gdm_error (_("custom_cmd: Custom command index %ld outside permitted range [0,%d)"),
+ cmd_id, GDM_CUSTOM_COMMAND_MAX);
+ return;
}
gchar * key_string = g_strdup_printf (_("%s%ld="), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, cmd_id);
@@ -725,7 +725,7 @@ custom_cmd (long cmd_id)
custom_cmd_no_restart (cmd_id);
else
custom_cmd_restart (cmd_id);
-
+
g_free(key_string);
}
@@ -747,7 +747,7 @@ custom_cmd_restart (long cmd_id)
argv = ve_split (gdm_get_value_string (key_string));
g_free(key_string);
if (argv != NULL && argv[0] != NULL)
- VE_IGNORE_EINTR (execv (argv[0], argv));
+ VE_IGNORE_EINTR (execv (argv[0], argv));
g_strfreev (argv);
@@ -769,32 +769,32 @@ custom_cmd_no_restart (long cmd_id)
return;
}
else if (pid == 0) {
- /* child */
- char **argv;
- gchar * key_string = g_strdup_printf (_("%s%ld="), GDM_KEY_CUSTOM_CMD_TEMPLATE, cmd_id);
- argv = ve_split (gdm_get_value_string (key_string));
- g_free(key_string);
- if (argv != NULL && argv[0] != NULL)
- VE_IGNORE_EINTR (execv (argv[0], argv));
+ /* child */
+ char **argv;
+ gchar * key_string = g_strdup_printf (_("%s%ld="), GDM_KEY_CUSTOM_CMD_TEMPLATE, cmd_id);
+ argv = ve_split (gdm_get_value_string (key_string));
+ g_free(key_string);
+ if (argv != NULL && argv[0] != NULL)
+ VE_IGNORE_EINTR (execv (argv[0], argv));
- g_strfreev (argv);
-
- gdm_error (_("%s: Execution of custom command failed: %s"),
- "gdm_child_action", strerror (errno));
-
- _exit (0);
+ g_strfreev (argv);
+
+ gdm_error (_("%s: Execution of custom command failed: %s"),
+ "gdm_child_action", strerror (errno));
+
+ _exit (0);
}
else {
- /* parent */
- gint exitstatus = 0, status;
- pid_t p_stat = waitpid (1, &exitstatus, WNOHANG);
- if(p_stat > 0){
- if G_LIKELY (WIFEXITED (exitstatus)){
- status = WEXITSTATUS (exitstatus);
- gdm_debug (_("custom_cmd: child %d returned %d"), p_stat, status);
- }
- return;
- }
+ /* parent */
+ gint exitstatus = 0, status;
+ pid_t p_stat = waitpid (1, &exitstatus, WNOHANG);
+ if (p_stat > 0) {
+ if G_LIKELY (WIFEXITED (exitstatus)){
+ status = WEXITSTATUS (exitstatus);
+ gdm_debug (_("custom_cmd: child %d returned %d"), p_stat, status);
+ }
+ return;
+ }
}
}
@@ -1173,7 +1173,7 @@ gdm_do_logout_action (GdmLogoutAction logout_action)
check for the range of values */
if (logout_action >= GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST &&
logout_action <= GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST)
- custom_cmd (logout_action - GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST);
+ custom_cmd (logout_action - GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST);
break;
}
}
@@ -2979,6 +2979,8 @@ handle_dynamic_server (GdmConnection *conn, int type, gchar *key)
static void
gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
{
+ gint i;
+
gdm_debug ("Handling user message: '%s'", msg);
if (gdm_connection_get_message_count (conn) > GDM_SUP_MAX_MESSAGES) {
@@ -3372,23 +3374,109 @@ gdm_handle_user_message (GdmConnection *conn, const gchar *msg, gpointer data)
sep = ";";
}
- register int i = 0;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- gchar *key_string = NULL;
- key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
- if (sysmenu && disp->attached &&
- ! ve_string_empty (gdm_get_value_string (key_string))) {
- g_string_append_printf (msg, "%s%s%d", sep, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD_TEMPLATE, i);
- if (logout_action == (GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST + i))
- g_string_append (msg, "!");
- sep = ";";
- }
- g_free(key_string);
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar *key_string = NULL;
+ key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ if (sysmenu && disp->attached &&
+ ! ve_string_empty (gdm_get_value_string (key_string))) {
+ g_free (key_string);
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i);
+ if (gdm_get_value_bool (key_string)) {
+ g_string_append_printf (msg, "%s%s%d", sep, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD_TEMPLATE, i);
+ if (logout_action == (GDM_LOGOUT_ACTION_CUSTOM_CMD_FIRST + i))
+ g_string_append (msg, "!");
+ sep = ";";
+ }
+ }
+ g_free(key_string);
}
g_string_append (msg, "\n");
gdm_connection_write (conn, msg->str);
g_string_free (msg, TRUE);
+ } else if (strcmp (msg, GDM_SUP_QUERY_CUSTOM_CMD_LABELS) == 0) {
+ GdmDisplay *disp;
+ GString *msg;
+ const gchar *sep = " ";
+ gboolean sysmenu;
+
+ disp = gdm_connection_get_display (conn);
+ sysmenu = gdm_get_value_bool_per_display (disp->name, GDM_KEY_SYSTEM_MENU);
+
+ /* Only allow locally authenticated connections */
+ if ( ! GDM_CONN_AUTHENTICATED (conn) ||
+ disp == NULL) {
+ gdm_info (_("%s request denied: "
+ "Not authenticated"), "QUERY_LOGOUT_ACTION");
+ gdm_connection_write (conn,
+ "ERROR 100 Not authenticated\n");
+ return;
+ }
+
+ msg = g_string_new ("OK");
+
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar *key_string = NULL;
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ if (sysmenu && disp->attached &&
+ ! ve_string_empty (gdm_get_value_string (key_string))) {
+ g_free (key_string);
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i);
+ if (gdm_get_value_bool (key_string)) {
+ g_free (key_string);
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
+ g_string_append_printf (msg, "%s%s", sep, gdm_get_value_string (key_string));
+ sep = ";";
+ }
+ }
+ g_free(key_string);
+ }
+
+ g_string_append (msg, "\n");
+ gdm_connection_write (conn, msg->str);
+ g_string_free (msg, TRUE);
+ } else if (strcmp (msg, GDM_SUP_QUERY_CUSTOM_CMD_NO_RESTART_STATUS) == 0) {
+ GdmDisplay *disp;
+ GString *msg;
+ gboolean sysmenu;
+
+ disp = gdm_connection_get_display (conn);
+ sysmenu = gdm_get_value_bool_per_display (disp->name, GDM_KEY_SYSTEM_MENU);
+
+ /* Only allow locally authenticated connections */
+ if ( ! GDM_CONN_AUTHENTICATED (conn) ||
+ disp == NULL) {
+ gdm_info (_("%s request denied: "
+ "Not authenticated"), "QUERY_LOGOUT_ACTION");
+ gdm_connection_write (conn,
+ "ERROR 100 Not authenticated\n");
+ return;
+ }
+
+ msg = g_string_new ("OK ");
+
+ unsigned long no_restart_status_flag = 0; /* we can store up-to 32 commands this way */
+
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar *key_string = NULL;
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ if (sysmenu && disp->attached &&
+ ! ve_string_empty (gdm_get_value_string (key_string))) {
+ g_free (key_string);
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i);
+ if (gdm_get_value_bool (key_string)) {
+ g_free (key_string);
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, i);
+ if(gdm_get_value_bool (key_string))
+ no_restart_status_flag |= (1 << i);
+ }
+ }
+ g_free(key_string);
+ }
+
+ g_string_append_printf (msg, "%ld\n", no_restart_status_flag);
+ gdm_connection_write (conn, msg->str);
+ g_string_free (msg, TRUE);
} else if (strncmp (msg, GDM_SUP_SET_LOGOUT_ACTION " ",
strlen (GDM_SUP_SET_LOGOUT_ACTION " ")) == 0) {
const gchar *action =
diff --git a/daemon/gdm.h b/daemon/gdm.h
index 21a311df..765e2aff 100644
--- a/daemon/gdm.h
+++ b/daemon/gdm.h
@@ -241,6 +241,7 @@ enum {
#define GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE "customcommand/CustomCommandText"
#define GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE "customcommand/CustomCommandTooltip"
#define GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE "customcommand/CustomCommandNoRestart"
+#define GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE "customcommand/CustomCommandIsPersistent"
#define GDM_KEY_ROOT_PATH "daemon/RootPath=/sbin:/usr/sbin:" GDM_USER_PATH
#define GDM_KEY_SERV_AUTHDIR "daemon/ServAuthDir=" AUTHDIR
#define GDM_KEY_SESSION_DESKTOP_DIR "daemon/SessionDesktopDir=/etc/X11/sessions/:" DMCONFDIR "/Sessions/:" DATADIR "/gdm/BuiltInSessions/:" DATADIR "/xsessions/"
@@ -452,6 +453,7 @@ struct _GdmCustomCmd {
gchar *command_text; /* warning dialog text */
gchar *command_tooltip; /* tooltip string */
gboolean command_no_restart; /* no restart flag */
+ gboolean command_is_persistent; /* persistence flag */
};
#define GDM_CUSTOM_COMMAND_MAX 10 /* maximum number of supported custom commands */
@@ -1177,6 +1179,38 @@ void gdm_final_cleanup (void);
* 200 = Too many messages
* 999 = Unknown error
*/
+#define GDM_SUP_QUERY_CUSTOM_CMD_LABELS "QUERY_CUSTOM_CMD_LABELS" /* None */
+/* QUERY_CUSTOM_CMD_LABELS: Query labels belonging to exported custom commands
+ * Only supported on connections that passed
+ * AUTH_LOCAL.
+ * Supported since: 2.5.90.0
+ * Answers:
+ * OK <label1>;<label2>;...
+ * Where labelX is one of the labels belonging to CUSTOM_CMDX (where X in [0,GDM_CUSTOM_COMMAND_MAX)).
+ * An empty list can also be returned if none of the custom commands are
+ * exported outside login manager (no CustomCommandIsPersistent options are set to true).
+ * ERROR <err number> <english error description>
+ * 0 = Not implemented
+ * 100 = Not authenticated
+ * 200 = Too many messages
+ * 999 = Unknown error
+ */
+#define GDM_SUP_QUERY_CUSTOM_CMD_NO_RESTART_STATUS "QUERY_CUSTOM_CMD_NO_RESTART_STATUS" /* None */
+/* QUERY_CUSTOM_CMD_NO_RESTART_STATUS: Query NoRestart config options for each of custom commands
+ * Only supported on connections that passed
+ * AUTH_LOCAL.
+ * Supported since: 2.5.90.0
+ * Answers:
+ * OK <status>
+ * Where each bit of the status represents NoRestart value for each of the custom commands.
+ * bit on (1): NoRestart = true,
+ * bit off (0): NoRestart = false.
+ * ERROR <err number> <english error description>
+ * 0 = Not implemented
+ * 100 = Not authenticated
+ * 200 = Too many messages
+ * 999 = Unknown error
+ */
#define GDM_SUP_SET_LOGOUT_ACTION "SET_LOGOUT_ACTION" /* <action> */
/* SET_LOGOUT_ACTION: Tell the daemon to halt/restart/suspend after
* slave process exits. Only supported on
diff --git a/daemon/gdmconfig.c b/daemon/gdmconfig.c
index 0aefacac..6a179dbe 100644
--- a/daemon/gdmconfig.c
+++ b/daemon/gdmconfig.c
@@ -345,6 +345,8 @@ is_key (const gchar *key1, const gchar *key2)
static void
gdm_config_init (void)
{
+ gint i;
+
type_hash = g_hash_table_new (g_str_hash, g_str_equal);
val_hash = g_hash_table_new (g_str_hash, g_str_equal);
realkey_hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -509,33 +511,36 @@ gdm_config_init (void)
/* custom command string values */
GdmCustomCommands = g_new0 (GdmCustomCmd, GDM_CUSTOM_COMMAND_MAX);
- register int i = 0;
gchar *key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- /* For each possible custom command */
- key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
- GdmCustomCommands[i].command = NULL;
- gdm_config_add_hash (key_string, &GdmCustomCommands[i].command, &string_type);
-
- key_string = g_strdup_printf (_("%s%d=_Custom%d"), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i, i);
- GdmCustomCommands[i].command_label = NULL;
- gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_label, &string_type);
-
- key_string = g_strdup_printf (_("%s%d=Execute _custom command %d"), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i, i);
- GdmCustomCommands[i].command_lr_label = NULL;
- gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_lr_label, &string_type);
-
- key_string = g_strdup_printf (_("%s%d=Are you sure?"), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
- GdmCustomCommands[i].command_text = NULL;
- gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_text, &string_type);
-
- key_string = g_strdup_printf (_("%s%d=Execute custom command %d"), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i, i);
- GdmCustomCommands[i].command_tooltip = NULL;
- gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_tooltip, &string_type);
-
- key_string = g_strdup_printf (_("%s%d=false"), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, i);
- GdmCustomCommands[i].command_no_restart = FALSE;
- gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_no_restart, &bool_type);
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ /* For each possible custom command */
+ key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ GdmCustomCommands[i].command = NULL;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command, &string_type);
+
+ key_string = g_strdup_printf (_("%s%d=Custom_%d"), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i, i);
+ GdmCustomCommands[i].command_label = NULL;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_label, &string_type);
+
+ key_string = g_strdup_printf (_("%s%d=Execute custom command _%d"), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i, i);
+ GdmCustomCommands[i].command_lr_label = NULL;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_lr_label, &string_type);
+
+ key_string = g_strdup_printf (_("%s%d=Are you sure?"), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
+ GdmCustomCommands[i].command_text = NULL;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_text, &string_type);
+
+ key_string = g_strdup_printf (_("%s%d=Execute custom command %d"), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i, i);
+ GdmCustomCommands[i].command_tooltip = NULL;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_tooltip, &string_type);
+
+ key_string = g_strdup_printf (_("%s%d=false"), GDM_KEY_CUSTOM_CMD_NO_RESTART_TEMPLATE, i);
+ GdmCustomCommands[i].command_no_restart = FALSE;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_no_restart, &bool_type);
+
+ key_string = g_strdup_printf(_("%s%d=false"), GDM_KEY_CUSTOM_CMD_IS_PERSISTENT_TEMPLATE, i);
+ GdmCustomCommands[i].command_is_persistent = FALSE;
+ gdm_config_add_hash (key_string, &GdmCustomCommands[i].command_is_persistent, &bool_type);
}
/* int values */
@@ -1059,6 +1064,7 @@ _gdm_set_value_string (gchar *key, gchar *value_in, gboolean doing_update)
gchar *setting_copy = NULL;
gchar *temp_string;
gchar *value;
+ gint i;
if (! ve_string_empty (value_in))
value = value_in;
@@ -1191,23 +1197,21 @@ _gdm_set_value_string (gchar *key, gchar *value_in, gboolean doing_update)
/* All others */
} else {
- register int i = 0;
- gchar * key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- /* For each possible custom command */
- key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
- if(is_key (key, key_string)) {
- if (value != NULL)
- *setting = ve_get_first_working_command (value, FALSE);
- else
- *setting = NULL;
-
- break;
- }
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = NULL;
+ /* For each possible custom command */
+ key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ if(is_key (key, key_string)) {
+ if (value != NULL)
+ *setting = ve_get_first_working_command (value, FALSE);
+ else
+ *setting = NULL;
+
+ break;
+ }
+ g_free(key_string);
}
- g_free(key_string);
-
if (value != NULL)
*setting = g_strdup (value);
else {
@@ -1242,18 +1246,18 @@ _gdm_set_value_string (gchar *key, gchar *value_in, gboolean doing_update)
else if (is_key (key, GDM_KEY_TIMED_LOGIN))
notify_displays_string (GDM_NOTIFY_TIMED_LOGIN, *setting);
- register int i = 0;
- gchar * key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- /* For each possible custom command */
- key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
- if (is_key (key, key_string)) {
- g_free(key_string);
- key_string = g_strdup_printf (_("%s%d"), GDM_NOTIFY_CUSTOM_CMD_TEMPLATE, i);
- notify_displays_string (key_string, *setting);
- }
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = NULL;
+ /* For each possible custom command */
+ key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ if (is_key (key, key_string)) {
+ g_free(key_string);
+ key_string = g_strdup_printf (_("%s%d"), GDM_NOTIFY_CUSTOM_CMD_TEMPLATE, i);
+ notify_displays_string (key_string, *setting);
+ break;
+ }
+ g_free(key_string);
}
- g_free(key_string);
}
if (setting_copy != NULL)
diff --git a/docs/C/gdm.xml b/docs/C/gdm.xml
index 9deeedcf..b36a3fd0 100644
--- a/docs/C/gdm.xml
+++ b/docs/C/gdm.xml
@@ -3999,6 +3999,23 @@ gdm:.my.domain
</varlistentry>
<varlistentry>
+ <term>CustomCommandIsPersistent[0-9]</term>
+ <listitem>
+ <synopsis>CustomCommandIsPersistent[0-9]=</synopsis>
+ <para>
+ Specifies if <filename>n-th</filename> &quot;Custom
+ Command&quot; will appear outside the login manager, for
+ example on the desktop through the Log Out/Shut Down dialogs.
+ If not specified the default value is &quot;false&quot;. This
+ option is only valid if corresponding
+ <filename>CustomCommand</filename> is defined. [0-9] represents
+ <filename>CustomCommand</filename> suffix and can be an integer
+ between 0 and 9.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>CustomCommandLabel[0-9]</term>
<listitem>
<synopsis>CustomCommandLabel[0-9]=</synopsis>
@@ -4006,10 +4023,11 @@ gdm:.my.domain
Specifies the stock label that will be displayed on the
<filename>n-th</filename> &quot;Custom Command&quot;
buttons and menu items. If not specified the default value is
- &quot;_Custom[0-9]&quot;. This option is only valid if
+ &quot;Custom_[0-9]&quot;. This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
[0-9] represents <filename>CustomCommand</filename> suffix
- and can be an integer between 0 and 9.
+ and can be an integer between 0 and 9. This option can't contain
+ any semicolon characters (i.e. &quot;;&quot;).
</para>
</listitem>
</varlistentry>
@@ -4022,7 +4040,7 @@ gdm:.my.domain
Specifies the stock label that will be displayed on the
<filename>n-th</filename> &quot;Custom Command&quot;
list items and radio buttons. If not specified the default
- value is &quot;Execute _custom command [0-9]&quot;. This
+ value is &quot;Execute custom command _[0-9]&quot;. This
option is only valid if corresponding
<filename>CustomCommand</filename> is defined. [0-9]
represents <filename>CustomCommand</filename> suffix and
@@ -4042,7 +4060,14 @@ gdm:.my.domain
&quot;false&quot;. This option is only valid if corresponding
<filename>CustomCommand</filename> is defined. [0-9]
represents <filename>CustomCommand</filename> suffix and
- can be an integer between 0 and 9.
+ can be an integer between 0 and 9. In addition when
+ corresponding <filename>CustomCommandIsPersistent</filename>
+ is set to true, setting CustomCommandNoRestart to false will
+ place corresponding <filename>CustomCommand</filename> in the
+ Shut Down dialog set of actions, setting it to true will place
+ corresponding
+ <filename>CustomCommand</filename> in the Log Out dialog set of
+ actions.
</para>
</listitem>
</varlistentry>
@@ -4796,6 +4821,50 @@ Answers:
</screen>
</sect3>
+ <sect3 id="querycustomcmdlabels">
+ <title>QUERY_CUSTOM_CMD_LABELS</title>
+<screen>
+ QUERY_CUSTOM_CMD_LABELS: Query labels belonging to exported custom
+ commands Only supported on connections that
+ passed AUTH_LOCAL.
+ Supported since: 2.5.90.0
+ Answers:
+ OK &lt;label1&gt;;&lt;label2&gt;;...
+ Where labelX is one of the labels belonging to CUSTOM_CMDX
+ (where X in [0,GDM_CUSTOM_COMMAND_MAX)). An empty list can
+ also be returned if none of the custom commands are exported
+ outside login manager (no CustomCommandIsPersistent options
+ are set to true).
+ ERROR &lt;err number&gt; &lt;english error description&gt;
+ 0 = Not implemented
+ 100 = Not authenticated
+ 200 = Too many messages
+ 999 = Unknown error
+</screen>
+ </sect3>
+
+ <sect3 id="querycustomcmdnorestartstatus">
+ <title>QUERY_CUSTOM_CMD_NO_RESTART_STATUS</title>
+<screen>
+QUERY_CUSTOM_CMD_NO_RESTART_STATUS: Query NoRestart config options
+ for each of custom commands Only
+ supported on connections that
+ passed AUTH_LOCAL.
+Supported since: 2.5.90.0
+Answers:
+ OK &lt;status&gt;
+ Where each bit of the status represents NoRestart value for
+ each of the custom commands.
+ bit on (1): NoRestart = true,
+ bit off (0): NoRestart = false.
+ ERROR &lt;err number&gt; &lt;english error description&gt;
+ 0 = Not implemented
+ 100 = Not authenticated
+ 200 = Too many messages
+ 999 = Unknown error
+</screen>
+ </sect3>
+
<sect3 id="queryvt">
<title>QUERY_VT</title>
<screen>
@@ -6530,7 +6599,7 @@ homogeneous=&quot;bool&quot;&gt;
<filename>config</filename>, _(&quot;_Configure&quot;
</para>
<para>
- <filename>custom_cmd[0-9]</filename>, _(&quot;_Custom[0-9]&quot;
+ <filename>custom_cmd[0-9]</filename>, _(&quot;Custom_[0-9]&quot;
</para>
<para>
<filename>disconnect</filename>, _(&quot;D_isconnect&quot;
@@ -7084,6 +7153,7 @@ Hosts=appserverone,appservertwo
CustomCommandLRLabel0=Reboot into _Windoze
CustomCommandText0=Are you sure you want to restart the computer into Windoze?
CustomCommandTooltip0=Restarts the computer into Windoze
+ CustomCommandIsPersistent0=true
</screen>
CustomCommand0 specifies two commands separated by a semicolon:
@@ -7122,6 +7192,7 @@ Hosts=appserverone,appservertwo
CustomCommandLRLabel0=Reboot into _Windoze
CustomCommandText0=Are you sure you want to restart the computer into Windoze?
CustomCommandTooltip0=Restarts the computer into Windoze
+ CustomCommandIsPersistent0=true
CustomCommand1=/sbin/updatesystem;/usr/local/sbin/updatesystem
CustomCommandLabel1=_Update Me
@@ -7142,6 +7213,7 @@ Hosts=appserverone,appservertwo
CustomCommandLRLabel0=Reboot into _Windoze
CustomCommandText0=Are you sure you want to restart the computer into Windoze?
CustomCommandTooltip0=Restarts the computer into Windoze
+ CustomCommandIsPersistent0=true
CustomCommand1=/sbin/updatesystem;/usr/local/sbin/updatesystem
CustomCommandLabel1=_Update Me
diff --git a/docs/es/gdm.xml b/docs/es/gdm.xml
index 36f09d41..587c2b34 100644
--- a/docs/es/gdm.xml
+++ b/docs/es/gdm.xml
@@ -2506,8 +2506,8 @@ PostSession/
<para>
You can create up to 10 different commands. Gaps between command
numbers are allowed and their relative positioning within the
- section is not important as long as they conform to the permitted
- range of [0-9].
+ section and with respect to each other is not important as long as
+ they conform to the permitted range of [0-9].
</para>
@@ -2520,11 +2520,14 @@ PostSession/
<synopsis>CustomCommand[0-9]=</synopsis>
<para>
Full path and arguments to command to be executed when user
- selects n-th "Custom Command" from the Actions menu.
- This can be a ';' separated list of commands to try. If the
- value is empty or missing, then the custom command is not
- available. By default this value is not enabled, so to enable
- "Custom Command" it must be set to a nonempty value.
+ selects <filename>n-th</filename> "Custom Command"
+ from the Actions menu. This can be a ';' separated list of
+ commands to try. If the value is empty or missing, then the
+ custom command is not available. By default this value is not
+ enabled, so to enable "Custom Command" it must be
+ set to a nonempty value. [0-9] represents the
+ <filename>CustomCommand</filename> suffix and can be an
+ integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2539,6 +2542,8 @@ PostSession/
buttons and menu items. If not specified the default value is
"_Custom[0-9]". This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
+ [0-9] represents <filename>CustomCommand</filename> suffix
+ and can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2553,7 +2558,9 @@ PostSession/
list items and radio buttons. If not specified the default
value is "Execute _custom command [0-9]". This
option is only valid if corresponding
- <filename>CustomCommand</filename> is defined.
+ <filename>CustomCommand</filename> is defined. [0-9]
+ represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2567,7 +2574,9 @@ PostSession/
<filename>n-th</filename> "Custom Command"
has been executed. If not specified the default value is
"false". This option is only valid if corresponding
- <filename>CustomCommand</filename> is defined.
+ <filename>CustomCommand</filename> is defined. [0-9]
+ represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2583,6 +2592,8 @@ PostSession/
item has been activated. If not specified the default value is
"Are you sure?". This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
+ [0-9] represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2597,6 +2608,8 @@ PostSession/
entries. If not specified the default value is "Execute
custom command [0-9]". This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
+ [0-9] represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -4597,6 +4610,19 @@ homogeneous="bool"&gt;
directory as the theme <filename>.xml</filename> file in
<filename>&lt;share&gt;/gdm/themes/&lt;theme_name&gt;</filename>.
</para>
+
+ <para>
+ Note that alternative image file can be specified using the altfile[n]
+ property. GDM will use the last valid image filename specified.
+ For example:
+<screen>
+&lt;normal file="picture.png" altfile1="distribution-blah-image.png" altfile2="distribution-foo-image.png"/&gt;
+</screen>
+ If <filename>distribution-foo-image.png</filename> is a valid image
+ filename it will be used. Otherwise distribution-blah-image.png will
+ be used if valid.
+ </para>
+
</sect3>
<sect3 id="listcoloronodes">
diff --git a/docs/uk/gdm.xml b/docs/uk/gdm.xml
index 1a2e58c9..d6e57d74 100644
--- a/docs/uk/gdm.xml
+++ b/docs/uk/gdm.xml
@@ -2597,8 +2597,8 @@ gdm:.my.domain
<para>
You can create up to 10 different commands. Gaps between command
numbers are allowed and their relative positioning within the
- section is not important as long as they conform to the permitted
- range of [0-9].
+ section and with respect to each other is not important as long as
+ they conform to the permitted range of [0-9].
</para>
@@ -2611,11 +2611,14 @@ gdm:.my.domain
<synopsis>CustomCommand[0-9]=</synopsis>
<para>
Full path and arguments to command to be executed when user
- selects n-th "Custom Command" from the Actions menu.
- This can be a ';' separated list of commands to try. If the
- value is empty or missing, then the custom command is not
- available. By default this value is not enabled, so to enable
- "Custom Command" it must be set to a nonempty value.
+ selects <filename>n-th</filename> "Custom Command"
+ from the Actions menu. This can be a ';' separated list of
+ commands to try. If the value is empty or missing, then the
+ custom command is not available. By default this value is not
+ enabled, so to enable "Custom Command" it must be
+ set to a nonempty value. [0-9] represents the
+ <filename>CustomCommand</filename> suffix and can be an
+ integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2630,6 +2633,8 @@ gdm:.my.domain
buttons and menu items. If not specified the default value is
"_Custom[0-9]". This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
+ [0-9] represents <filename>CustomCommand</filename> suffix
+ and can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2644,7 +2649,9 @@ gdm:.my.domain
list items and radio buttons. If not specified the default
value is "Execute _custom command [0-9]". This
option is only valid if corresponding
- <filename>CustomCommand</filename> is defined.
+ <filename>CustomCommand</filename> is defined. [0-9]
+ represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2658,7 +2665,9 @@ gdm:.my.domain
<filename>n-th</filename> "Custom Command"
has been executed. If not specified the default value is
"false". This option is only valid if corresponding
- <filename>CustomCommand</filename> is defined.
+ <filename>CustomCommand</filename> is defined. [0-9]
+ represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2674,6 +2683,8 @@ gdm:.my.domain
item has been activated. If not specified the default value is
"Are you sure?". This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
+ [0-9] represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -2688,6 +2699,8 @@ gdm:.my.domain
entries. If not specified the default value is "Execute
custom command [0-9]". This option is only valid if
corresponding <filename>CustomCommand</filename> is defined.
+ [0-9] represents <filename>CustomCommand</filename> suffix and
+ can be an integer between 0 and 9.
</para>
</listitem>
</varlistentry>
@@ -4697,6 +4710,19 @@ homogeneous="bool"&gt;
</para>
<para>Зауважте, що відносні назви шляхів мають бути у тому самому каталозі, що й <filename>.xml</filename> файл теми у <filename>&lt;share&gt;/gdm/themes/&lt;theme_name&gt;</filename>.</para>
+
+ <para>
+ Note that alternative image file can be specified using the altfile[n]
+ property. GDM will use the last valid image filename specified.
+ For example:
+<screen>
+&lt;normal file="picture.png" altfile1="distribution-blah-image.png" altfile2="distribution-foo-image.png"/&gt;
+</screen>
+ If <filename>distribution-foo-image.png</filename> is a valid image
+ filename it will be used. Otherwise distribution-blah-image.png will
+ be used if valid.
+ </para>
+
</sect3>
<sect3 id="listcoloronodes">
diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c
index 89b19d9f..391d9e19 100644
--- a/gui/gdmlogin.c
+++ b/gui/gdmlogin.c
@@ -670,18 +670,19 @@ gdm_login_restart_handler (void)
}
static void
-gdm_custom_cmd_handler (GtkWidget *widget, gint *cmd_id)
+gdm_custom_cmd_handler (GtkWidget *widget, gpointer data)
{
- if (cmd_id) {
- gchar * key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, *cmd_id);
- if (gdm_wm_warn_dialog (
- gdm_config_get_string (key_string) , "", GTK_STOCK_OK, NULL, TRUE) == GTK_RESPONSE_YES) {
-
- printf ("%c%c%c%d\n", STX, BEL, GDM_INTERRUPT_CUSTOM_CMD, *cmd_id);
- fflush (stdout);
- }
-
- g_free (key_string);
+ if (data) {
+ int *cmd_id = (int*)data;
+ gchar * key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, *cmd_id);
+ if (gdm_wm_warn_dialog (
+ gdm_config_get_string (key_string) , "", GTK_STOCK_OK, NULL, TRUE) == GTK_RESPONSE_YES) {
+
+ printf ("%c%c%c%d\n", STX, BEL, GDM_INTERRUPT_CUSTOM_CMD, *cmd_id);
+ fflush (stdout);
+ }
+
+ g_free (key_string);
}
}
@@ -2274,7 +2275,7 @@ gdm_login_gui_init (void)
GtkWidget *stack, *hline1, *hline2, *handle;
GtkWidget *bbox = NULL;
GtkWidget /**help_button,*/ *button_box;
- gint rows;
+ gint rows, i;
GdkPixbuf *pb;
GtkWidget *frame;
int lw, lh;
@@ -2394,9 +2395,8 @@ gdm_login_gui_init (void)
got_anything = TRUE;
}
- register int i = 0;
- gchar * key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = NULL;
key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
if (gdm_working_command_exists (gdm_config_get_string (key_string))) {
gint * cmd_index = g_new0(gint, 1);
@@ -2410,8 +2410,8 @@ gdm_login_gui_init (void)
gtk_widget_show (GTK_WIDGET (item));
got_anything = TRUE;
}
+ g_free (key_string);
}
- g_free (key_string);
if (gdm_working_command_exists (gdm_config_get_string (GDM_KEY_HALT))) {
item = gtk_menu_item_new_with_mnemonic (_("Shut _Down"));
@@ -2975,6 +2975,8 @@ enum {
static void
gdm_read_config (void)
{
+ gint i;
+
/* Read config data in bulk */
gdmcomm_comm_bulk_start ();
@@ -3010,10 +3012,9 @@ gdm_read_config (void)
gdm_config_get_string (GDM_KEY_USE_24_CLOCK);
gdm_config_get_string (GDM_KEY_WELCOME);
- /* String keys for custom commands */
- register int i = 0;
- gchar * key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ /* String keys for custom commands */
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = NULL;
key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
gdm_config_get_string (key_string);
@@ -3028,8 +3029,9 @@ gdm_read_config (void)
key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
gdm_config_get_string (key_string);
+
+ g_free (key_string);
}
- g_free (key_string);
gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE);
gdm_config_get_int (GDM_KEY_BACKGROUND_PROGRAM_INITIAL_DELAY);
@@ -3081,6 +3083,8 @@ static gboolean
gdm_reread_config (int sig, gpointer data)
{
gboolean resize = FALSE;
+ gboolean custom_changed = FALSE;
+ gint i;
/* Read config data in bulk */
gdmcomm_comm_bulk_start ();
@@ -3160,10 +3164,8 @@ gdm_reread_config (int sig, gpointer data)
}
/* Keys for custom commands */
- register int i = 0;
- gboolean custom_changed = FALSE;
- gchar *key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar *key_string = NULL;
key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
if(gdm_config_reload_string (key_string))
custom_changed = TRUE;
@@ -3183,8 +3185,9 @@ gdm_reread_config (int sig, gpointer data)
key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
if(gdm_config_reload_string (key_string))
custom_changed = TRUE;
+
+ g_free (key_string);
}
- g_free (key_string);
if(custom_changed){
/* Set busy cursor */
diff --git a/gui/greeter/greeter.c b/gui/greeter/greeter.c
index 495534df..4ed3355a 100644
--- a/gui/greeter/greeter.c
+++ b/gui/greeter/greeter.c
@@ -719,6 +719,8 @@ gdm_set_welcomemsg (void)
static void
gdm_read_config (void)
{
+ gint i;
+
/* Read config data in bulk */
gdmcomm_comm_bulk_start ();
@@ -778,9 +780,8 @@ gdm_read_config (void)
gdm_config_get_bool (GDM_KEY_ADD_GTK_MODULES);
/* Keys for custom commands */
- register int i = 0;
- gchar * key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = NULL;
key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
gdm_config_get_string (key_string);
@@ -795,9 +796,9 @@ gdm_read_config (void)
key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
gdm_config_get_string (key_string);
- }
- g_free (key_string);
+ g_free (key_string);
+ }
/* Keys not to include in reread_config */
gdm_config_get_string (GDM_KEY_SESSION_DESKTOP_DIR);
@@ -810,6 +811,9 @@ gdm_read_config (void)
static gboolean
greeter_reread_config (int sig, gpointer data)
{
+ gint i;
+ gboolean custom_changed = FALSE;
+
/* Read config data in bulk */
gdmcomm_comm_bulk_start ();
@@ -869,41 +873,39 @@ greeter_reread_config (int sig, gpointer data)
_exit (DISPLAY_RESTARTGREETER);
}
- register int i = 0;
- gboolean custom_changed = FALSE;
- gchar *key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
- if (gdm_config_reload_string (key_string))
- custom_changed = TRUE;
-
- key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
- if (gdm_config_reload_string (key_string))
- custom_changed = TRUE;
-
- key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i);
- if (gdm_config_reload_string (key_string))
- custom_changed = TRUE;
-
- key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
- if (gdm_config_reload_string (key_string))
- custom_changed = TRUE;
-
- key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
- if (gdm_config_reload_string (key_string))
- custom_changed = TRUE;
- }
-
- g_free (key_string);
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar *key_string = NULL;
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ if (gdm_config_reload_string (key_string))
+ custom_changed = TRUE;
+
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
+ if (gdm_config_reload_string (key_string))
+ custom_changed = TRUE;
+
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_LR_LABEL_TEMPLATE, i);
+ if (gdm_config_reload_string (key_string))
+ custom_changed = TRUE;
+
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, i);
+ if (gdm_config_reload_string (key_string))
+ custom_changed = TRUE;
+
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TOOLTIP_TEMPLATE, i);
+ if (gdm_config_reload_string (key_string))
+ custom_changed = TRUE;
+ g_free (key_string);
+ }
+
if(custom_changed){
- /* Set busy cursor */
- gdm_common_setup_cursor (GDK_WATCH);
-
- gdm_wm_save_wm_order ();
- gdmcomm_comm_bulk_stop ();
-
- _exit (DISPLAY_RESTARTGREETER);
+ /* Set busy cursor */
+ gdm_common_setup_cursor (GDK_WATCH);
+
+ gdm_wm_save_wm_order ();
+ gdmcomm_comm_bulk_stop ();
+
+ _exit (DISPLAY_RESTARTGREETER);
}
gdm_config_reload_string (GDM_KEY_SOUND_PROGRAM);
@@ -1088,6 +1090,7 @@ main (int argc, char *argv[])
const char *gdm_gtk_theme;
guint sid;
int r;
+ gint i;
if (g_getenv ("DOING_GDM_DEVELOPMENT") != NULL)
DOING_GDM_DEVELOPMENT = TRUE;
@@ -1226,17 +1229,17 @@ main (int argc, char *argv[])
GdmConfiguratorFound = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_CONFIGURATOR));
GdmCustomCmdsFound = g_new0 (gboolean, GDM_CUSTOM_COMMAND_MAX);
- register int i = 0;
- gchar * key_string = NULL;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- /* For each possible custom command */
- key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
- GdmCustomCmdsFound[i] = gdm_working_command_exists (gdm_config_get_string (key_string));
- if (GdmCustomCmdsFound[i])
- GdmAnyCustomCmdsFound = TRUE;
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = NULL;
+ /* For each possible custom command */
+ key_string = g_strdup_printf(_("%s%d="), GDM_KEY_CUSTOM_CMD_TEMPLATE, i);
+ GdmCustomCmdsFound[i] = gdm_working_command_exists (gdm_config_get_string (key_string));
+ if (GdmCustomCmdsFound[i])
+ GdmAnyCustomCmdsFound = TRUE;
+
+ g_free (key_string);
}
- g_free (key_string);
-
+
if (g_getenv ("GDM_THEME") != NULL)
gdm_graphical_theme = g_strdup (g_getenv ("GDM_THEME"));
else if (gdm_config_get_bool (GDM_KEY_GRAPHICAL_THEME_RAND))
diff --git a/gui/greeter/greeter_configuration.h b/gui/greeter/greeter_configuration.h
index 51ab82fe..d4dabaf9 100644
--- a/gui/greeter/greeter_configuration.h
+++ b/gui/greeter/greeter_configuration.h
@@ -29,10 +29,6 @@ extern gboolean GdmConfigAvailable;
extern gboolean GdmChooserButton;
extern gchar *GdmHalt;
extern gchar *GdmReboot;
-extern gchar *GdmCustomCmdText;
-extern gchar *GdmCustomCmdLabel;
-extern gchar *GdmCustomCmdLRLabel;
-extern gchar *GdmCustomCmdTooltip;
extern gchar *GdmSuspend;
extern gchar *GdmConfigurator;
extern gboolean GdmHaltFound;
diff --git a/gui/greeter/greeter_item.c b/gui/greeter/greeter_item.c
index 0fa14a3c..61794c38 100644
--- a/gui/greeter/greeter_item.c
+++ b/gui/greeter/greeter_item.c
@@ -157,9 +157,8 @@ greeter_item_is_visible (GreeterItemInfo *info)
static gboolean checked = FALSE;
static gboolean GDM_IS_LOCAL = FALSE;
static gboolean GDM_FLEXI_SERVER = FALSE;
- gboolean sysmenu = FALSE;
- gchar *key_string = NULL;
- int i = 0;
+ gboolean sysmenu = FALSE;
+ gint i = 0;
if ( ! checked)
{
@@ -213,16 +212,16 @@ greeter_item_is_visible (GreeterItemInfo *info)
strcmp (info->show_type, "suspend") == 0))
return FALSE;
- for (i=0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- key_string = g_strdup_printf (_("custom_cmd%d"), i);
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gchar * key_string = g_strdup_printf (_("custom_cmd%d"), i);
if (( ! sysmenu || ! GdmCustomCmdsFound[i]) &&
- (info->show_type != NULL &&
- strcmp (info->show_type, key_string) == 0)) {
+ (info->show_type != NULL &&
+ strcmp (info->show_type, key_string) == 0)) {
g_free (key_string);
return FALSE;
- }
+ }
+ g_free (key_string);
}
- g_free (key_string);
if (( ! gdm_config_get_bool (GDM_KEY_TIMED_LOGIN_ENABLE) ||
ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)) ||
diff --git a/gui/greeter/greeter_system.c b/gui/greeter/greeter_system.c
index 07c2e5d8..eb6d1329 100644
--- a/gui/greeter/greeter_system.c
+++ b/gui/greeter/greeter_system.c
@@ -81,9 +81,10 @@ query_greeter_restart_handler (void)
}
static void
-query_greeter_custom_cmd_handler (GtkWidget *widget, gint *cmd_id)
+query_greeter_custom_cmd_handler (GtkWidget *widget, gpointer data)
{
- if (cmd_id) {
+ if (data) {
+ gint *cmd_id = (gint*)data;
gchar * key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_TEXT_TEMPLATE, *cmd_id);
if (gdm_wm_warn_dialog (gdm_config_get_string (key_string) , "",
GTK_STOCK_OK, NULL, TRUE) == GTK_RESPONSE_YES) {
@@ -171,6 +172,7 @@ void
greeter_system_append_system_menu (GtkWidget *menu)
{
GtkWidget *w, *sep;
+ gint i = 0;
/* should never be allowed by the UI */
if ( ! gdm_config_get_bool (GDM_KEY_SYSTEM_MENU) ||
@@ -214,20 +216,19 @@ greeter_system_append_system_menu (GtkWidget *menu)
}
if (GdmAnyCustomCmdsFound) {
- register int i = 0;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
if (GdmCustomCmdsFound[i]){
- gint * cmd_index = g_new0(gint, 1);
- *cmd_index = i;
- gchar * key_string = NULL;
- key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
- w = gtk_menu_item_new_with_mnemonic (gdm_config_get_string(key_string));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
- gtk_widget_show (GTK_WIDGET (w));
- g_signal_connect (G_OBJECT (w), "activate",
- G_CALLBACK (query_greeter_custom_cmd_handler),
- cmd_index);
- g_free (key_string);
+ gint * cmd_index = g_new0(gint, 1);
+ *cmd_index = i;
+ gchar * key_string = NULL;
+ key_string = g_strdup_printf (_("%s%d="), GDM_KEY_CUSTOM_CMD_LABEL_TEMPLATE, i);
+ w = gtk_menu_item_new_with_mnemonic (gdm_config_get_string(key_string));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
+ gtk_widget_show (GTK_WIDGET (w));
+ g_signal_connect (G_OBJECT (w), "activate",
+ G_CALLBACK (query_greeter_custom_cmd_handler),
+ cmd_index);
+ g_free (key_string);
}
}
}
@@ -283,7 +284,8 @@ greeter_system_handler (GreeterItemInfo *info,
GtkWidget *config_radio = NULL;
GtkWidget *chooser_radio = NULL;
gchar *s;
- int ret, i;
+ int ret;
+ gint i;
GSList *radio_group = NULL;
static GtkTooltips *tooltips = NULL;
@@ -492,7 +494,9 @@ greeter_system_handler (GreeterItemInfo *info,
void
greeter_item_system_setup (void)
-{
+{
+ gint i;
+
greeter_item_register_action_callback ("reboot_button",
(ActionFunc)query_greeter_restart_handler,
NULL);
@@ -512,14 +516,13 @@ greeter_item_system_setup (void)
(ActionFunc)greeter_chooser_handler,
NULL);
- register int i = 0;
- for (; i < GDM_CUSTOM_COMMAND_MAX; i++) {
- gint * cmd_index = g_new0(gint, 1);
- *cmd_index = i;
- gchar * key_string = g_strdup_printf (_("custom_cmd_button%d"), i);
- greeter_item_register_action_callback (key_string,
- (ActionFunc)query_greeter_custom_cmd_handler,
- cmd_index);
- g_free (key_string);
+ for (i = 0; i < GDM_CUSTOM_COMMAND_MAX; i++) {
+ gint * cmd_index = g_new0(gint, 1);
+ *cmd_index = i;
+ gchar * key_string = g_strdup_printf (_("custom_cmd_button%d"), i);
+ greeter_item_register_action_callback (key_string,
+ (ActionFunc)query_greeter_custom_cmd_handler,
+ cmd_index);
+ g_free (key_string);
}
}