summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorBrian Cameron <brian.cameron@sun.com>2005-12-25 01:27:13 +0000
committerBrian Cameron <bcameron@src.gnome.org>2005-12-25 01:27:13 +0000
commit5e57744d44ac26b5047397d1eef146617d44871f (patch)
treeb55a7b9b63477f644476880d07c11cd1d7a72c09 /gui
parentbef4ad3555fef9d3dfb5481c61453b8c6faa388d (diff)
downloadgdm-5e57744d44ac26b5047397d1eef146617d44871f.tar.gz
Happy holidays. Some bug fixes.
2005-12-24 Brian Cameron <brian.cameron@sun.com> Happy holidays. Some bug fixes. * daemon/gdm.h, daemon/gdmconfig.c, daemon/slave.c, gui/gdmlogin.c, gui/greeter/greeter_item_timed.c: Fix so that timed/automatic enable is checked and automatic/timed login is only turned on if they are enabled. Fix so greeters restart if timed login is changed in gdmsetup. Fixes bug #324337. * gui/gdmcommon.c, gui/gdmlogin.c, gui/greeter/greeter.c, gui/greeter/greeter_item.c, gui/greeter/greeter_parser.c: Now gdmlogin and gdmcommon use the same character sequences with Welcome/RemoteWelcome messages. Fixes bug #322711. * docs/C/gdm.xml: Document how character sequences work with text labels and Welcome/RemoteWelcome messages. * gui/gdmcommon.[ch], gui/gdmchooser.c, gui/greeter/greeter_canvas_item.c, gui/greeter/greeter_geometry.c: Rename functions so all common functions have prefix gdm_common.
Diffstat (limited to 'gui')
-rw-r--r--gui/gdmchooser.c4
-rw-r--r--gui/gdmcommon.c185
-rw-r--r--gui/gdmcommon.h8
-rw-r--r--gui/gdmlogin.c183
-rw-r--r--gui/greeter/greeter.c36
-rw-r--r--gui/greeter/greeter_canvas_item.c2
-rw-r--r--gui/greeter/greeter_geometry.c4
-rw-r--r--gui/greeter/greeter_item.c190
-rw-r--r--gui/greeter/greeter_item_timed.c17
-rw-r--r--gui/greeter/greeter_parser.c8
10 files changed, 278 insertions, 359 deletions
diff --git a/gui/gdmchooser.c b/gui/gdmchooser.c
index f2514ac2..608ff2a7 100644
--- a/gui/gdmchooser.c
+++ b/gui/gdmchooser.c
@@ -1812,7 +1812,7 @@ gdm_reread_config (int sig, gpointer data)
gdm_config_reload_int (GDM_KEY_BACKGROUND_TYPE)) {
if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
- setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
+ gdm_common_setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
}
return TRUE;
@@ -1969,7 +1969,7 @@ main (int argc, char *argv[])
/* but just in case */
if (RUNNING_UNDER_GDM) {
if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
- setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
+ gdm_common_setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
gdm_common_setup_cursor (GDK_WATCH);
}
diff --git a/gui/gdmcommon.c b/gui/gdmcommon.c
index 5ff093bb..1bdbbb90 100644
--- a/gui/gdmcommon.c
+++ b/gui/gdmcommon.c
@@ -28,6 +28,7 @@
#include <locale.h>
#include <string.h>
#include <syslog.h>
+#include <sys/utsname.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -37,6 +38,8 @@
#include "gdmcomm.h"
#include "gdmconfig.h"
+gint gdm_timed_delay = 0;
+
void
gdm_common_abort (const gchar *format, ...)
{
@@ -305,7 +308,7 @@ gdm_common_select_time_format (void)
/* Not to look too shaby on Xinerama setups */
void
-setup_background_color (gchar *bg_color)
+gdm_common_setup_background_color (gchar *bg_color)
{
GdkColormap *colormap;
GdkColor color;
@@ -338,7 +341,7 @@ setup_background_color (gchar *bg_color)
}
gchar *
-gdm_get_welcomemsg (void)
+gdm_common_get_welcomemsg (void)
{
gchar *welcomemsg;
gchar *tempstr;
@@ -416,7 +419,7 @@ post_display_run (gpointer data)
}
void
-gdm_post_display_launch (void)
+gdm_common_post_display_launch (void)
{
if (! post_display_prog_get_path ())
return;
@@ -424,3 +427,179 @@ gdm_post_display_launch (void)
g_idle_add (post_display_run, NULL);
}
+/*
+ * Returns the string version of the time that the user
+ * will need to free. Requires the user pass in the
+ * the_tm structure to be used. This way the caller
+ * has access to the time data as well.
+ */
+gchar *
+gdm_common_get_clock (struct tm **the_tm)
+{
+ char *str;
+ time_t the_time;
+
+ time (&the_time);
+ *the_tm = localtime (&the_time);
+
+ if (gdm_common_select_time_format ()) {
+ str = ve_strftime (*the_tm, _("%a %b %d, %H:%M"));
+ } else {
+ /* Translators: You should translate time part as
+ %H:%M if your language does not have AM and PM
+ equivalent. Note: %l is a strftime option for
+ 12-hour clock format */
+ str = ve_strftime (*the_tm, _("%a %b %d, %l:%M %p"));
+ }
+
+ return str;
+}
+
+char *
+gdm_common_expand_text (const gchar *text)
+{
+ GString *str;
+ const char *p;
+ gchar *clock, *display;
+ int r, i, n_chars;
+ gboolean underline = FALSE;
+ gchar buf[256];
+ struct utsname name;
+ struct tm *the_tm;
+
+ str = g_string_sized_new (strlen (text));
+
+ p = text;
+ n_chars = g_utf8_strlen (text, -1);
+ i = 0;
+
+ while (i < n_chars)
+ {
+ gunichar ch;
+
+ ch = g_utf8_get_char (p);
+
+ /* Backslash commands */
+ if (ch == '\\')
+ {
+ p = g_utf8_next_char (p);
+ i++;
+ ch = g_utf8_get_char (p);
+
+ if (i >= n_chars || ch == '\0')
+ {
+ g_warning ("Unescaped \\ at end of text\n");
+ goto bail;
+ }
+ else if (ch == 'n')
+ g_string_append_unichar (str, '\n');
+ else
+ g_string_append_unichar (str, ch);
+ }
+ else if (ch == '%')
+ {
+ p = g_utf8_next_char (p);
+ i++;
+ ch = g_utf8_get_char (p);
+
+ if (i >= n_chars || ch == '\0')
+ {
+ g_warning ("Unescaped %% at end of text\n");
+ goto bail;
+ }
+
+ switch (ch)
+ {
+ case '%':
+ g_string_append (str, "%");
+ break;
+ case 'c':
+ clock = gdm_common_get_clock (&the_tm);
+ g_string_append (str, clock);
+ g_free (clock);
+ break;
+ case 'd':
+ display = g_strdup (g_getenv ("DISPLAY"));
+ g_string_append (str, display);
+ break;
+ case 'h':
+ buf[sizeof (buf) - 1] = '\0';
+ r = gethostname (buf, sizeof (buf) - 1);
+ if (r)
+ g_string_append (str, "localhost");
+ else
+ g_string_append (str, buf);
+ break;
+ case 'm':
+ uname (&name);
+ g_string_append (str, name.machine);
+ break;
+ case 'n':
+ uname (&name);
+ g_string_append (str, name.nodename);
+ break;
+ case 'o':
+ buf[sizeof (buf) - 1] = '\0';
+ r = getdomainname (buf, sizeof (buf) - 1);
+ if (r)
+ g_string_append (str, "localdomain");
+ else
+ g_string_append (str, buf);
+ break;
+ case 'r':
+ uname (&name);
+ g_string_append (str, name.release);
+ break;
+ case 's':
+ uname (&name);
+ g_string_append (str, name.sysname);
+ break;
+ case 't':
+ g_string_append_printf (str, "%d", gdm_timed_delay);
+ if (gdm_timed_delay != 1)
+ g_string_append (str, _(" seconds"));
+ else
+ g_string_append (str, _(" second"));
+ break;
+ case 'u':
+ g_string_append (str, ve_sure_string (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)));
+ break;
+ default:
+ if (ch < 127)
+ g_warning ("unknown escape code %%%c in text\n", (char)ch);
+ else
+ g_warning ("unknown escape code %%(U%x) in text\n", (int)ch);
+ }
+ }
+ else if (ch == '_')
+ {
+ /*
+ * Could be true if an underscore was put right before a special
+ * character like % or /
+ */
+ if (underline == FALSE) {
+ underline = TRUE;
+ g_string_append (str, "<u>");
+ }
+ }
+ else
+ {
+ g_string_append_unichar (str, ch);
+ if (underline)
+ {
+ underline = FALSE;
+ g_string_append (str, "</u>");
+ }
+ }
+ p = g_utf8_next_char (p);
+ i++;
+ }
+
+ bail:
+
+ if (underline)
+ g_string_append (str, "</u>");
+
+ return g_string_free (str, FALSE);
+}
+
diff --git a/gui/gdmcommon.h b/gui/gdmcommon.h
index b620ca20..32bc503c 100644
--- a/gui/gdmcommon.h
+++ b/gui/gdmcommon.h
@@ -55,8 +55,10 @@ GdkPixbuf *gdm_common_get_face (const char *filename,
guint max_height);
gchar* gdm_common_get_config_file (void);
gboolean gdm_common_select_time_format (void);
-void setup_background_color (gchar *bg_color);
-gchar* gdm_get_welcomemsg (void);
-void gdm_post_display_launch (void);
+void gdm_common_setup_background_color (gchar *bg_color);
+gchar* gdm_common_get_welcomemsg (void);
+void gdm_common_post_display_launch (void);
+gchar* gdm_common_expand_text (const gchar *text);
+gchar* gdm_common_get_clock (struct tm **the_tm);
#endif /* GDM_COMMON_H */
diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c
index 377a7934..be10a956 100644
--- a/gui/gdmlogin.c
+++ b/gui/gdmlogin.c
@@ -41,7 +41,6 @@
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <pwd.h>
-#include <sys/utsname.h>
#if HAVE_PAM
#include <security/pam_appl.h>
@@ -128,7 +127,6 @@ static const gchar *curlang = NULL;
static gchar *curuser = NULL;
static gchar *session = NULL;
static gchar *language = NULL;
-static gint curdelay = 0;
static gint savesess = GTK_RESPONSE_NO;
static gint savelang = GTK_RESPONSE_NO;
@@ -161,6 +159,7 @@ extern GHashTable *sessnames;
extern gchar *default_session;
extern const gchar *current_session;
extern gboolean session_dir_whacked_out;
+extern gint gdm_timed_delay;
static void login_window_resize (gboolean force);
@@ -413,35 +412,31 @@ back_prog_stop (void)
}
}
-
/*
* Timed Login: Timer
*/
-
static gboolean
gdm_timer (gpointer data)
{
- curdelay --;
- if ( curdelay <= 0 ) {
+ if (gdm_timed_delay <= 0) {
/* timed interruption */
printf ("%c%c%c\n", STX, BEL, GDM_INTERRUPT_TIMED_LOGIN);
fflush (stdout);
} else {
gchar *autologin_msg;
- if (curdelay > 1)
- autologin_msg = g_strdup_printf (
- _("User %s will login in %d seconds"),
- gdm_config_get_string (GDM_KEY_TIMED_LOGIN), curdelay);
- else
- autologin_msg = g_strdup_printf (
- _("User %s will login in %d second"),
- gdm_config_get_string (GDM_KEY_TIMED_LOGIN), curdelay);
+ /* Note that this message is not handled the same way as in
+ * the greeter, we don't parse it through the enriched text.
+ */
+ autologin_msg = gdm_common_expand_text (
+ _("User %u will login in %t"));
gtk_label_set_text (GTK_LABEL (auto_timed_msg), autologin_msg);
gtk_widget_show (GTK_WIDGET (auto_timed_msg));
g_free (autologin_msg);
login_window_resize (FALSE /* force */);
}
+
+ gdm_timed_delay--;
return TRUE;
}
@@ -455,10 +450,10 @@ gdm_timer_up_delay (GSignalInvocationHint *ihint,
const GValue *param_values,
gpointer data)
{
- if (curdelay < 30)
- curdelay = 30;
- if (curdelay < gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY))
- curdelay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
+ if (gdm_timed_delay < 30)
+ gdm_timed_delay = 30;
+ if (gdm_timed_delay < gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY))
+ gdm_timed_delay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
return TRUE;
}
@@ -637,104 +632,6 @@ set_screen_to_pos (int x, int y)
}
}
-
-/* I *really* need to rewrite this */
-static gchar *
-gdm_parse_enriched_string (const char *pre, const gchar *s, const char *post)
-{
- gchar hostbuf[1023] = "";
- gchar *hostname, *display;
- struct utsname name;
- GString *str;
-
- if (s == NULL)
- return (NULL);
-
- hostbuf[sizeof (hostbuf) - 1] = '\0';
- if (gethostname (hostbuf, sizeof (hostbuf) - 1) < 0)
- hostname = g_strdup ("GNOME");
- else
- hostname = g_strdup (hostbuf);
-
- display = g_strdup (g_getenv ("DISPLAY"));
-
- uname (&name);
-
- if (strlen (s) > 2048) {
- char *buffer;
- syslog (LOG_ERR, _("%s: String too long!"), "gdm_parse_enriched_string");
- g_free (display);
- buffer = g_strdup_printf (_("%sWelcome to %s%s"),
- pre, name.nodename, post);
- g_free (hostname);
- return buffer;
- }
-
- str = g_string_new (pre);
-
- while (s[0] != '\0') {
- /* Backslash commands */
- if (s[0] == '\\' && s[1] != '\0') {
- char cmd = s[1];
- s++;
- switch (cmd) {
- case 'n':
- g_string_append_c (str, '\n');
- break;
- default:
- g_string_append_c (str, cmd);
- }
- /* Percent commands */
- } else if (s[0] == '%' && s[1] != 0) {
- char cmd = s[1];
- s++;
-
- switch (cmd) {
- case 'h':
- g_string_append (str, hostname);
- break;
-
- case 'n':
- g_string_append (str, name.nodename);
- break;
-
- case 'd':
- g_string_append (str, ve_sure_string (display));
- break;
-
- case 's':
- g_string_append (str, name.sysname);
- break;
-
- case 'r':
- g_string_append (str, name.release);
- break;
-
- case 'm':
- g_string_append (str, name.machine);
- break;
-
- case '%':
- g_string_append_c (str, '%');
- break;
-
- default:
- break;
- };
- } else {
- g_string_append_c (str, *s);
- }
- s++;
- }
-
- g_string_append (str, post);
-
- g_free (display);
- g_free (hostname);
-
- return g_string_free (str, FALSE);
-}
-
static void
gdm_run_gdmconfig (GtkWidget *w, gpointer data)
{
@@ -2049,11 +1946,11 @@ gdm_login_ctrl_handler (GIOChannel *source, GIOCondition cond, gint fd)
*/
if (timed_handler_id == 0 &&
+ gdm_config_get_bool (GDM_KEY_TIMED_LOGIN_ENABLE) &&
! ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)) &&
gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY) > 0) {
- curdelay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
- timed_handler_id = g_timeout_add (1000,
- gdm_timer, NULL);
+ gdm_timed_delay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
+ timed_handler_id = g_timeout_add (1000, gdm_timer, NULL);
}
printf ("%c\n", STX);
fflush (stdout);
@@ -2336,29 +2233,16 @@ create_handle (void)
}
static gboolean
-update_clock (gpointer data)
+update_clock (void)
{
- struct tm *the_tm;
- char *str;
- time_t the_time;
- gint time_til_next_min;
+ struct tm *the_tm;
+ gchar *str;
+ gint time_til_next_min;
if (clock_label == NULL)
return FALSE;
- time (&the_time);
- the_tm = localtime (&the_time);
-
- if (gdm_common_select_time_format ()) {
- str = ve_strftime (the_tm, _("%a %b %d, %H:%M"));
- } else {
- /* Translators: You should translate time part as
- %H:%M if your language does not have AM and PM
- equivalent. Note: %l is a strftime option for
- 12-hour clock format */
- str = ve_strftime (the_tm, _("%a %b %d, %l:%M %p"));
- }
-
+ str = gdm_common_get_clock (&the_tm);
gtk_label_set_text (GTK_LABEL (clock_label), str);
g_free (str);
@@ -2367,7 +2251,6 @@ update_clock (gpointer data)
time_til_next_min = (time_til_next_min>=0?time_til_next_min:0);
g_timeout_add (time_til_next_min*1000, update_clock, NULL);
-
return FALSE;
}
@@ -2477,11 +2360,14 @@ static void
gdm_set_welcomemsg (void)
{
gchar *greeting;
- gchar *welcomemsg = gdm_get_welcomemsg ();
+ gchar *welcomemsg = gdm_common_get_welcomemsg ();
+ gchar *fullwelcomemsg = g_strdup_printf (
+ "<big><big><big>%s</big></big></big>", welcomemsg);
- greeting = gdm_parse_enriched_string ("<big><big><big>", welcomemsg,
- "</big></big></big>");
+ greeting = gdm_common_expand_text (fullwelcomemsg);
gtk_label_set_markup (GTK_LABEL (welcome), greeting);
+
+ g_free (fullwelcomemsg);
g_free (welcomemsg);
g_free (greeting);
}
@@ -2682,7 +2568,7 @@ gdm_login_gui_init (void)
G_CALLBACK (gtk_widget_destroyed),
&clock_label);
- update_clock (NULL);
+ update_clock ();
if (browser_ok && gdm_config_get_bool (GDM_KEY_BROWSER))
rows = 2;
@@ -3151,11 +3037,11 @@ setup_background (void)
/* Load background color */
} else if (bg_type != GDM_BACKGROUND_NONE &&
bg_type != GDM_BACKGROUND_IMAGE) {
- setup_background_color (bg_color);
+ gdm_common_setup_background_color (bg_color);
/* Load default background */
} else {
gchar *blank_color = g_strdup ("#000000");
- setup_background_color (blank_color);
+ gdm_common_setup_background_color (blank_color);
}
}
@@ -3195,7 +3081,9 @@ else
gdm_config_reload_string (GDM_KEY_INFO_MSG_FONT) ||
gdm_config_reload_string (GDM_KEY_INCLUDE) ||
gdm_config_reload_string (GDM_KEY_EXCLUDE) ||
+ gdm_config_reload_string (GDM_KEY_TIMED_LOGIN) ||
gdm_config_reload_int (GDM_KEY_XINERAMA_SCREEN) ||
+ gdm_config_reload_int (GDM_KEY_TIMED_LOGIN_DELAY) ||
gdm_config_reload_bool (GDM_KEY_SYSTEM_MENU) ||
gdm_config_reload_bool (GDM_KEY_BROWSER) ||
gdm_config_reload_bool (GDM_KEY_INCLUDE_ALL) ||
@@ -3228,7 +3116,7 @@ else
gdm_config_reload_bool (GDM_KEY_SOUND_ON_LOGIN);
gdm_config_reload_string (GDM_KEY_SOUND_ON_LOGIN_FILE);
gdm_config_reload_string (GDM_KEY_USE_24_CLOCK);
- update_clock (NULL);
+ update_clock ();
if (gdm_config_reload_string (GDM_KEY_LOGO)) {
GdkPixbuf *pb;
@@ -3547,7 +3435,8 @@ main (int argc, char *argv[])
/* if in timed mode, delay timeout on keyboard or menu
* activity */
- if ( ! ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN))) {
+ if (gdm_config_get_bool (GDM_KEY_TIMED_LOGIN_ENABLE) &&
+ ! ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN))) {
sid = g_signal_lookup ("activate",
GTK_TYPE_MENU_ITEM);
g_signal_add_emission_hook (sid,
@@ -3689,7 +3578,7 @@ main (int argc, char *argv[])
/* Only setup the cursor now since it will be a WATCH from before */
gdm_common_setup_cursor (GDK_LEFT_PTR);
- gdm_post_display_launch ();
+ gdm_common_post_display_launch ();
gtk_main ();
gdm_kill_thingies ();
diff --git a/gui/greeter/greeter.c b/gui/greeter/greeter.c
index b608152d..0ab212d9 100644
--- a/gui/greeter/greeter.c
+++ b/gui/greeter/greeter.c
@@ -64,9 +64,7 @@ gboolean DOING_GDM_DEVELOPMENT = FALSE;
GtkWidget *window;
GtkWidget *canvas;
-gboolean GDM_IS_LOCAL = FALSE;
-
-gint greeter_current_delay = 0;
+gboolean GDM_IS_LOCAL = FALSE;
static gboolean ignore_buttons = FALSE;
/* FIXME: hack */
@@ -74,6 +72,7 @@ GreeterItemInfo *welcome_string_info = NULL;
extern gboolean session_dir_whacked_out;
extern gboolean require_quarter;
+extern gint gdm_timed_delay;
gboolean greeter_probably_login_prompt = FALSE;
@@ -701,7 +700,7 @@ verify_gdm_version (void)
static void
gdm_set_welcomemsg (void)
{
- char *welcomemsg = gdm_get_welcomemsg ();
+ char *welcomemsg = gdm_common_get_welcomemsg ();
if (welcome_string_info->data.text.orig_text != NULL)
g_free (welcome_string_info->data.text.orig_text);
@@ -721,27 +720,28 @@ greeter_reread_config (int sig, gpointer data)
gdm_config_reload_string (GDM_KEY_GRAPHICAL_THEME_DIR) ||
gdm_config_reload_string (GDM_KEY_GTKRC) ||
gdm_config_reload_string (GDM_KEY_GTK_THEME) ||
- gdm_config_reload_int (GDM_KEY_XINERAMA_SCREEN) ||
- gdm_config_reload_bool (GDM_KEY_ENTRY_CIRCLES) ||
- gdm_config_reload_bool (GDM_KEY_ENTRY_INVISIBLE) ||
- gdm_config_reload_bool (GDM_KEY_SHOW_XTERM_FAILSAFE) ||
- gdm_config_reload_bool (GDM_KEY_SHOW_GNOME_FAILSAFE) ||
- gdm_config_reload_bool (GDM_KEY_INCLUDE_ALL) ||
gdm_config_reload_string (GDM_KEY_INCLUDE) ||
gdm_config_reload_string (GDM_KEY_EXCLUDE) ||
gdm_config_reload_string (GDM_KEY_SESSION_DESKTOP_DIR) ||
gdm_config_reload_string (GDM_KEY_LOCALE_FILE) ||
- gdm_config_reload_bool (GDM_KEY_SYSTEM_MENU) ||
gdm_config_reload_string (GDM_KEY_HALT) ||
gdm_config_reload_string (GDM_KEY_REBOOT) ||
gdm_config_reload_string (GDM_KEY_SUSPEND) ||
gdm_config_reload_string (GDM_KEY_CONFIGURATOR) ||
gdm_config_reload_string (GDM_KEY_INFO_MSG_FILE) ||
gdm_config_reload_string (GDM_KEY_INFO_MSG_FONT) ||
+ gdm_config_reload_string (GDM_KEY_TIMED_LOGIN) ||
+ gdm_config_reload_int (GDM_KEY_XINERAMA_SCREEN) ||
+ gdm_config_reload_int (GDM_KEY_TIMED_LOGIN_DELAY) ||
+ gdm_config_reload_bool (GDM_KEY_ENTRY_CIRCLES) ||
+ gdm_config_reload_bool (GDM_KEY_ENTRY_INVISIBLE) ||
+ gdm_config_reload_bool (GDM_KEY_SHOW_XTERM_FAILSAFE) ||
+ gdm_config_reload_bool (GDM_KEY_SHOW_GNOME_FAILSAFE) ||
+ gdm_config_reload_bool (GDM_KEY_INCLUDE_ALL) ||
+ gdm_config_reload_bool (GDM_KEY_SYSTEM_MENU) ||
gdm_config_reload_bool (GDM_KEY_CONFIG_AVAILABLE) ||
gdm_config_reload_bool (GDM_KEY_CHOOSER_BUTTON) ||
- gdm_config_reload_bool (GDM_KEY_TIMED_LOGIN_ENABLE) ||
- gdm_config_reload_int (GDM_KEY_TIMED_LOGIN_DELAY)) {
+ gdm_config_reload_bool (GDM_KEY_TIMED_LOGIN_ENABLE)) {
/* Set busy cursor */
gdm_common_setup_cursor (GDK_WATCH);
@@ -982,7 +982,7 @@ main (int argc, char *argv[])
if (ve_string_empty (bg_color)) {
bg_color = gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR);
}
- setup_background_color (bg_color);
+ gdm_common_setup_background_color (bg_color);
greeter_session_init ();
ve_signal_add (SIGHUP, greeter_reread_config, NULL);
@@ -1050,6 +1050,12 @@ main (int argc, char *argv[])
gdm_wm_screen.height);
gtk_container_add (GTK_CONTAINER (window), canvas);
+ /*
+ * Initialize the value with the default value so the first time it
+ * is displayed it doesn't show as 0.
+ */
+ gdm_timed_delay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
+
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))
@@ -1321,7 +1327,7 @@ main (int argc, char *argv[])
gdm_config_get_string (GDM_KEY_INFO_MSG_FONT));
gdm_common_setup_cursor (GDK_LEFT_PTR);
- gdm_post_display_launch ();
+ gdm_common_post_display_launch ();
gtk_main ();
return 0;
diff --git a/gui/greeter/greeter_canvas_item.c b/gui/greeter/greeter_canvas_item.c
index 558930d6..8f31e295 100644
--- a/gui/greeter/greeter_canvas_item.c
+++ b/gui/greeter/greeter_canvas_item.c
@@ -297,7 +297,7 @@ greeter_item_create_canvas_item (GreeterItemInfo *item)
NULL);
break;
case GREETER_ITEM_TYPE_LABEL:
- text = greeter_item_expand_text (item->data.text.orig_text);
+ text = gdm_common_expand_text (item->data.text.orig_text);
/* Justification is taken from the anchor */
if (item->anchor == GTK_ANCHOR_NORTH_WEST ||
diff --git a/gui/greeter/greeter_geometry.c b/gui/greeter/greeter_geometry.c
index aa89192c..81325564 100644
--- a/gui/greeter/greeter_geometry.c
+++ b/gui/greeter/greeter_geometry.c
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <librsvg/rsvg.h>
+#include "gdmcommon.h"
#include "gdmwm.h"
#include "greeter_geometry.h"
#include "greeter_canvas_item.h"
@@ -517,8 +518,7 @@ greeter_item_size_request (GreeterItemInfo *item,
* You can go about your business.
* Move Along
*/
- text = greeter_item_expand_text (item->data.text.orig_text);
-
+ text = gdm_common_expand_text (item->data.text.orig_text);
if (set_width > 0)
max_width = set_width;
diff --git a/gui/greeter/greeter_item.c b/gui/greeter/greeter_item.c
index 6c32cd8c..a9d0c6c5 100644
--- a/gui/greeter/greeter_item.c
+++ b/gui/greeter/greeter_item.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
-#include <sys/utsname.h>
#include "gdm.h"
#include "gdmconfig.h"
@@ -34,8 +33,6 @@
#include "greeter_item.h"
#include "greeter_configuration.h"
-extern gint greeter_current_delay;
-
GreeterItemInfo *
greeter_item_info_new (GreeterItemInfo *parent,
GreeterItemType type)
@@ -135,7 +132,7 @@ greeter_item_update_text (GreeterItemInfo *info)
GNOME_IS_CANVAS_TEXT (info->item) &&
GREETER_ITEM_TYPE_IS_TEXT (info))
{
- text = greeter_item_expand_text (info->data.text.orig_text);
+ text = gdm_common_expand_text (info->data.text.orig_text);
g_object_set (G_OBJECT (info->item),
"markup", text,
@@ -146,157 +143,6 @@ greeter_item_update_text (GreeterItemInfo *info)
}
-
-static char *
-get_clock (void)
-{
- struct tm *the_tm;
- char *str;
- time_t the_time;
-
- time (&the_time);
- the_tm = localtime (&the_time);
-
- if (gdm_common_select_time_format ())
- {
- str = ve_strftime (the_tm, _("%a %b %d, %H:%M"));
- }
- else
- {
- /* Translators: You should translate time part as
- %H:%M if your language does not have AM and PM
- equivalent. Note: %l is a strftime option for
- 12-hour clock format */
-
- str = ve_strftime (the_tm, _("%a %b %d, %l:%M %p"));
- }
-
- return str;
-}
-
-
-char *
-greeter_item_expand_text (const char *text)
-{
- GString *str;
- const char *p;
- char *clock;
- int r, i, n_chars;
- gboolean underline = FALSE;
- char buf[256];
- struct utsname name;
-
- str = g_string_sized_new (strlen (text));
-
- p = text;
- n_chars = g_utf8_strlen (text, -1);
- i = 0;
-
- while (i < n_chars)
- {
- gunichar ch;
-
- ch = g_utf8_get_char (p);
-
- /* Backslash commands */
- if (ch == '\\')
- {
- p = g_utf8_next_char (p);
- i++;
- ch = g_utf8_get_char (p);
-
- if (i >= n_chars || ch == '\0')
- {
- g_warning ("Unescaped \\ at end of text\n");
- goto bail;
- }
- else if (ch == 'n')
- g_string_append_unichar (str, '\n');
- else
- g_string_append_unichar (str, ch);
- }
- else if (ch == '%')
- {
- p = g_utf8_next_char (p);
- i++;
- ch = g_utf8_get_char (p);
-
- if (i >= n_chars || ch == '\0')
- {
- g_warning ("Unescaped %% at end of text\n");
- goto bail;
- }
-
- switch (ch)
- {
- case '%':
- g_string_append (str, "%");
- break;
- case 'n':
- uname (&name);
- g_string_append (str, name.nodename);
- break;
- case 'h':
- buf[sizeof (buf) - 1] = '\0';
- r = gethostname (buf, sizeof (buf) - 1);
- if (r)
- g_string_append (str, "localhost");
- else
- g_string_append (str, buf);
- break;
- case 'o':
- buf[sizeof (buf) - 1] = '\0';
- r = getdomainname (buf, sizeof (buf) - 1);
- if (r)
- g_string_append (str, "localdomain");
- else
- g_string_append (str, buf);
- break;
- case 'd':
- g_string_append_printf (str, "%d",
- greeter_current_delay);
- break;
- case 's':
- g_string_append (str, ve_sure_string (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)));
- break;
- case 'c':
- clock = get_clock ();
- g_string_append (str, clock);
- g_free (clock);
- break;
- default:
- if (ch < 127)
- g_warning ("unknown escape code %%%c in text\n", (char)ch);
- else
- g_warning ("unknown escape code %%(U%x) in text\n", (int)ch);
- }
- }
- else if (ch == '_')
- {
- underline = TRUE;
- g_string_append (str, "<u>");
- }
- else
- {
- g_string_append_unichar (str, ch);
- if (underline)
- {
- underline = FALSE;
- g_string_append (str, "</u>");
- }
- }
- p = g_utf8_next_char (p);
- i++;
- }
-
- bail:
-
- if (underline)
- g_string_append (str, "</u>");
-
- return g_string_free (str, FALSE);
-}
-
gboolean
greeter_item_is_visible (GreeterItemInfo *info)
{
@@ -320,10 +166,10 @@ greeter_item_is_visible (GreeterItemInfo *info)
! (info->show_modes & GREETER_ITEM_SHOW_CONSOLE_FLEXI))
return FALSE;
if ( ! GDM_IS_LOCAL && GDM_FLEXI_SERVER &&
- ! (info->show_modes & GREETER_ITEM_SHOW_REMOTE_FLEXI))
+ ! (info->show_modes & GREETER_ITEM_SHOW_REMOTE_FLEXI))
return FALSE;
if ( ! GDM_IS_LOCAL && ! GDM_FLEXI_SERVER &&
- ! (info->show_modes & GREETER_ITEM_SHOW_REMOTE))
+ ! (info->show_modes & GREETER_ITEM_SHOW_REMOTE))
return FALSE;
sysmenu = gdm_config_get_bool (GDM_KEY_SYSTEM_MENU);
@@ -331,39 +177,39 @@ greeter_item_is_visible (GreeterItemInfo *info)
if (( ! gdm_config_get_bool (GDM_KEY_CONFIG_AVAILABLE) ||
! sysmenu ||
! gdm_working_command_exists (GDM_KEY_CONFIGURATOR)) &&
- info->show_type != NULL &&
- strcmp (info->show_type, "config") == 0)
+ (info->show_type != NULL &&
+ strcmp (info->show_type, "config") == 0))
return FALSE;
if (( ! gdm_config_get_bool (GDM_KEY_CHOOSER_BUTTON) || ! sysmenu) &&
- info->show_type != NULL &&
- strcmp (info->show_type, "chooser") == 0)
+ (info->show_type != NULL &&
+ strcmp (info->show_type, "chooser") == 0))
return FALSE;
- if ( ! sysmenu &&
- info->show_type != NULL &&
+ if ( ! sysmenu && info->show_type != NULL &&
strcmp (info->show_type, "system") == 0)
return FALSE;
if (( ! sysmenu ||
! gdm_working_command_exists (gdm_config_get_string (GDM_KEY_HALT))) &&
- info->show_type != NULL &&
- strcmp (info->show_type, "halt") == 0)
+ (info->show_type != NULL &&
+ strcmp (info->show_type, "halt") == 0))
return FALSE;
if (( ! sysmenu ||
! gdm_working_command_exists (gdm_config_get_string (GDM_KEY_REBOOT))) &&
- info->show_type != NULL &&
- strcmp (info->show_type, "reboot") == 0)
+ (info->show_type != NULL &&
+ strcmp (info->show_type, "reboot") == 0))
return FALSE;
if (( ! sysmenu ||
! gdm_working_command_exists (gdm_config_get_string (GDM_KEY_SUSPEND))) &&
- info->show_type != NULL &&
- strcmp (info->show_type, "suspend") == 0)
+ (info->show_type != NULL &&
+ strcmp (info->show_type, "suspend") == 0))
return FALSE;
- if (ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)) &&
- info->show_type != NULL &&
- strcmp (info->show_type, "timed") == 0)
+ if (( ! gdm_config_get_bool (GDM_KEY_TIMED_LOGIN_ENABLE) ||
+ ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN))) &&
+ (info->show_type != NULL &&
+ strcmp (info->show_type, "timed") == 0))
return FALSE;
return TRUE;
diff --git a/gui/greeter/greeter_item_timed.c b/gui/greeter/greeter_item_timed.c
index 024f5ff5..c24b24f6 100644
--- a/gui/greeter/greeter_item_timed.c
+++ b/gui/greeter/greeter_item_timed.c
@@ -28,7 +28,7 @@
#include "greeter_configuration.h"
#include "greeter_item_timed.h"
-extern gint greeter_current_delay;
+extern gint gdm_timed_delay;
static guint timed_handler_id = 0;
@@ -52,8 +52,8 @@ static gboolean
gdm_timer (gpointer data)
{
greeter_item_timed_update ();
- greeter_current_delay --;
- if ( greeter_current_delay <= 0 )
+ gdm_timed_delay--;
+ if (gdm_timed_delay <= 0)
{
/* timed interruption */
printf ("%c%c%c\n", STX, BEL, GDM_INTERRUPT_TIMED_LOGIN);
@@ -75,10 +75,10 @@ gdm_timer_up_delay (GSignalInvocationHint *ihint,
{
int timeddelay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
- if (greeter_current_delay < 30)
- greeter_current_delay = 30;
- if (greeter_current_delay < timeddelay)
- greeter_current_delay = timeddelay;
+ if (gdm_timed_delay < 30)
+ gdm_timed_delay = 30;
+ if (gdm_timed_delay < timeddelay)
+ gdm_timed_delay = timeddelay;
return TRUE;
}
@@ -126,10 +126,11 @@ greeter_item_timed_start (void)
int timeddelay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
if (timed_handler_id == 0 &&
+ gdm_config_get_bool (GDM_KEY_TIMED_LOGIN_ENABLE) &&
! ve_string_empty (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)) &&
timeddelay > 0)
{
- greeter_current_delay = timeddelay;
+ gdm_timed_delay = timeddelay;
timed_handler_id = g_timeout_add (1000, gdm_timer, NULL);
}
}
diff --git a/gui/greeter/greeter_parser.c b/gui/greeter/greeter_parser.c
index 5b5fea4c..8c4b92dc 100644
--- a/gui/greeter/greeter_parser.c
+++ b/gui/greeter/greeter_parser.c
@@ -1103,11 +1103,7 @@ parse_stock (xmlNodePtr node,
else if (g_ascii_strcasecmp ((char *) prop, "timed-label") == 0)
{
g_free (*translated_text);
- *translated_text = g_strdup (ngettext ("User %s will login in %d "
- "second",
- "User %s will login in %d "
- "seconds",
- 1));
+ *translated_text = g_strdup (_("User %u will login in %t"));
}
else if (g_ascii_strcasecmp ((char *) prop, "welcome-label") == 0)
{
@@ -1115,7 +1111,7 @@ parse_stock (xmlNodePtr node,
welcome_string_info = info;
g_free (*translated_text);
- *translated_text = gdm_get_welcomemsg ();
+ *translated_text = gdm_common_get_welcomemsg ();
}
/* FIXME: is this actually needed? */
else if (g_ascii_strcasecmp ((char *) prop, "username-label") == 0)