summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2004-05-06 17:00:04 +0000
committerGeorge Lebl <jirka@src.gnome.org>2004-05-06 17:00:04 +0000
commit636909afe52850e6866d4b42aa136322196eb777 (patch)
tree28d8ea19e801c64e9e661d6af9b9421cd35042fc /gui
parentabda44e5dc3c484587a777cca3f116d71137e501 (diff)
downloadgdm-636909afe52850e6866d4b42aa136322196eb777.tar.gz
Apply and heavily massage a patch from Muktha to add font setting to the
Thu May 06 09:59:48 2004 George Lebl <jirka@5z.com> * gui/misc.[ch], gui/gdmlogin.c, gui/gdmsetup.c, gui/gdmchooser.c, gui/greeter/greeter.c: Apply and heavily massage a patch from Muktha to add font setting to the theming and finally fix #125070 hopefully * daemon/misc.c: our gethostent should strip the ::ffff: since it's confusing to rest of gdm and X in particular apparently, so whack it from the hostname so that it doesn't get into the display name. Should fix #133246 * gui/gdmlogin.c, gui/greeter/greeter_item_pam.c: fix #123958 by having an empty message clear the message string rather then append an empty string. Evil, but it fixes the bug. PAM is one large bug in fact, and would require a rather large flywatter to fix, based on a patch from Frederic Crozat
Diffstat (limited to 'gui')
-rw-r--r--gui/Makefile.am6
-rw-r--r--gui/gdmchooser.c9
-rw-r--r--gui/gdmlogin.c23
-rw-r--r--gui/gdmsetup.c10
-rw-r--r--gui/greeter/greeter.c9
-rw-r--r--gui/greeter/greeter_item_pam.c4
-rw-r--r--gui/misc.c75
-rw-r--r--gui/misc.h2
8 files changed, 94 insertions, 44 deletions
diff --git a/gui/Makefile.am b/gui/Makefile.am
index 7bbad936..39563ffd 100644
--- a/gui/Makefile.am
+++ b/gui/Makefile.am
@@ -57,6 +57,8 @@ libgdmwm_a_SOURCES = \
libgdmcommon_a_SOURCES = \
gdmlanguages.c \
gdmlanguages.h \
+ misc.c \
+ misc.h \
gdmcommon.c \
gdmcommon.h
@@ -66,9 +68,7 @@ gdmchooser_SOURCES = \
misc.h
gdmlogin_SOURCES = \
- gdmlogin.c \
- misc.c \
- misc.h
+ gdmlogin.c
gdmsetup_SOURCES = \
gdmsetup.c \
diff --git a/gui/gdmchooser.c b/gui/gdmchooser.c
index 2b6f7002..dd1bd73a 100644
--- a/gui/gdmchooser.c
+++ b/gui/gdmchooser.c
@@ -1702,14 +1702,7 @@ gdm_chooser_gui_init (void)
theme_name = GdmGtkTheme;
if ( ! ve_string_empty (theme_name)) {
- gchar *theme_dir = gtk_rc_get_theme_dir ();
- char *theme = g_strdup_printf ("%s/%s/gtk-2.0/gtkrc", theme_dir, theme_name);
- g_free (theme_dir);
-
- if( ! ve_string_empty (theme))
- gtk_rc_parse (theme);
-
- g_free (theme);
+ gdm_set_theme (theme_name);
}
}
diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c
index c696f00a..f7be7bfe 100644
--- a/gui/gdmlogin.c
+++ b/gui/gdmlogin.c
@@ -628,16 +628,16 @@ gdm_login_suspend_handler (void)
static void
gdm_theme_handler (GtkWidget *widget, gpointer data)
{
- char *theme_name;
+ const char *theme_name = (const char *)data;
- theme_name = g_strdup((char *)data);
printf ("%c%c%c%s\n", STX, BEL, GDM_INTERRUPT_THEME, theme_name);
fflush (stdout);
- gtk_settings_set_string_property (gtk_settings_get_default (),
- "gtk-theme-name", theme_name, "gdm");
- g_free (theme_name);
+ gdm_set_theme (theme_name);
+
+ login_window_resize (FALSE);
+ gdm_wm_center_window (GTK_WINDOW (login));
}
static void
@@ -1938,7 +1938,9 @@ gdm_login_ctrl_handler (GIOChannel *source, GIOCondition cond, gint fd)
/* HAAAAAAACK. Sometimes pam sends many many messages, SO
* we try to collect them until the next prompt or reset or
* whatnot */
- if ( ! replace_msg) {
+ if ( ! replace_msg &&
+ /* empty message is for clearing */
+ ! ve_string_empty (buf)) {
const char *oldtext;
oldtext = gtk_label_get_text (GTK_LABEL (msg));
if ( ! ve_string_empty (oldtext)) {
@@ -2656,14 +2658,7 @@ gdm_login_gui_init (void)
gtk_rc_parse (GdmGtkRC);
if ( ! ve_string_empty (theme_name)) {
- gchar *theme_dir = gtk_rc_get_theme_dir ();
- char *theme = g_strdup_printf ("%s/%s/gtk-2.0/gtkrc", theme_dir, theme_name);
- g_free (theme_dir);
-
- if( ! ve_string_empty (theme))
- gtk_rc_parse (theme);
-
- g_free (theme);
+ gdm_set_theme (theme_name);
}
login = gtk_window_new (GTK_WINDOW_TOPLEVEL);
diff --git a/gui/gdmsetup.c b/gui/gdmsetup.c
index d63c9e6e..01cd7da0 100644
--- a/gui/gdmsetup.c
+++ b/gui/gdmsetup.c
@@ -2691,15 +2691,7 @@ main (int argc, char *argv[])
}
if ( ! ve_string_empty (theme_name)) {
- char *theme_dir = gtk_rc_get_theme_dir ();
- /* If we are running under gdm parse the GDM gtkRC */
- gtkrc = g_strdup_printf ("%s/%s/gtk-2.0/gtkrc", theme_dir,
- theme_name);
- g_free (theme_dir);
-
- if ( ! ve_string_empty (gtkrc))
- gtk_rc_parse (gtkrc);
- g_free (gtkrc);
+ gdm_set_theme (theme_name);
}
/* evil, but oh well */
diff --git a/gui/greeter/greeter.c b/gui/greeter/greeter.c
index ba1131cc..22fedf18 100644
--- a/gui/greeter/greeter.c
+++ b/gui/greeter/greeter.c
@@ -1054,14 +1054,7 @@ main (int argc, char *argv[])
gdm_gtk_theme = GdmGtkTheme;
if ( ! ve_string_empty (gdm_gtk_theme)) {
- gchar *theme_gtk_dir = gtk_rc_get_theme_dir ();
- char *theme = g_strdup_printf ("%s/%s/gtk-2.0/gtkrc", theme_gtk_dir, gdm_gtk_theme);
- g_free (theme_gtk_dir);
-
- if( ! ve_string_empty (theme))
- gtk_rc_parse (theme);
-
- g_free (theme);
+ gdm_set_theme (gdm_gtk_theme);
}
gdm_wm_screen_init (GdmXineramaScreen);
diff --git a/gui/greeter/greeter_item_pam.c b/gui/greeter/greeter_item_pam.c
index 79494122..223762b0 100644
--- a/gui/greeter/greeter_item_pam.c
+++ b/gui/greeter/greeter_item_pam.c
@@ -218,7 +218,9 @@ greeter_item_pam_message (const char *message)
/* HAAAAAAACK. Sometimes pam sends many many messages, SO
* we try to collect them until the next prompt or reset or
* whatnot */
- if (!replace_msg)
+ if ( ! replace_msg &&
+ /* empty message is for clearing */
+ ! ve_string_empty (message))
{
g_object_get (G_OBJECT (message_info->item),
"text", &oldtext,
diff --git a/gui/misc.c b/gui/misc.c
index 2ea89e29..922a1b73 100644
--- a/gui/misc.c
+++ b/gui/misc.c
@@ -23,6 +23,79 @@
#include "misc.h"
-/* For now empty */
+#define INDEX_FILE1 "index.theme"
+#define INDEX_FILE2 "index.theme.disabled"
+
+static char *
+gdm_get_font (const char *theme_name)
+{
+ char *font_name;
+ char *theme_dir;
+ char *file_name;
+ char buf[512];
+ GtkStyle *style;
+ FILE *fp;
+
+ style = gtk_widget_get_default_style ();
+ font_name = pango_font_description_to_string (style->font_desc);
+
+ theme_dir = gtk_rc_get_theme_dir ();
+ file_name = g_build_filename (theme_dir, theme_name, INDEX_FILE1, NULL);
+ if ( ! g_file_test (file_name, G_FILE_TEST_EXISTS)) {
+ g_free (file_name);
+ file_name = g_build_filename (theme_dir, theme_name, INDEX_FILE2, NULL);
+ if ( ! g_file_test (file_name, G_FILE_TEST_EXISTS)) {
+ g_free (theme_dir);
+ g_free (file_name);
+ return font_name;
+ }
+ }
+ g_free (theme_dir);
+
+ /*
+ * FIXME: this is evil!
+ */
+ fp = fopen (file_name, "r");
+ if (fp != NULL) {
+ while (fgets (buf, 512, fp) != NULL) {
+ if (strncmp ("ApplicationFont", buf, 15) == 0) {
+ char *tmp_name;
+ tmp_name = strchr (buf, '=');
+
+ if (tmp_name != NULL) {
+ g_free (font_name);
+ font_name = strdup (tmp_name + 1);
+ }
+
+ fclose (fp);
+ g_free (file_name);
+ return font_name;
+ }
+ }
+ fclose (fp);
+ }
+ g_free (file_name);
+ return font_name;
+}
+
+/* perhaps needs to do something like:
+ login_window_resize (FALSE);
+ gdm_wm_center_window (GTK_WINDOW (login));
+ after calling if doing during runtime
+ */
+void
+gdm_set_theme (const char *theme_name)
+{
+ char *font_name;
+ GtkSettings *settings = gtk_settings_get_default ();
+
+ font_name = gdm_get_font (theme_name);
+
+ gtk_settings_set_string_property (settings,
+ "gtk-theme-name", theme_name, "gdm");
+ gtk_settings_set_string_property (settings,
+ "gtk-font-name", font_name, "gdm");
+ g_free (font_name);
+}
/* EOF */
diff --git a/gui/misc.h b/gui/misc.h
index 054e0983..55d61c70 100644
--- a/gui/misc.h
+++ b/gui/misc.h
@@ -19,6 +19,8 @@
#ifndef MISC_H
#define MISC_H
+void gdm_set_theme (const char *theme_name);
+
#endif /* MISC_H */
/* EOF */