Commit 636909af authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

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
parent abda44e5
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
Tue May 04 09:47:21 2004 George Lebl <jirka@5z.com>
* daemon/display.c: Don't whack the socket_conn on display_manage
......
......@@ -1473,9 +1473,6 @@ fillout_hostent (struct hostent *he_, struct in_addr *ia, const char *name)
he->addrs = NULL;
he->addr_count = 0;
/* Sometimes if we can't look things up, we could end
up with a dot in the name field which would screw
us up. Weird but apparently possible */
#ifdef ENABLE_IPV6
if (res != NULL && res->ai_canonname != NULL) {
he->hostname = g_strdup (res->ai_canonname);
......@@ -1525,7 +1522,16 @@ fillout_hostent (struct hostent *he_, struct in_addr *ia, const char *name)
res = res->ai_next;
}
/* We don't want the ::ffff: that could arise here */
if (he->hostname != NULL &&
strncmp (he->hostname, "::ffff:", 7) == 0) {
strcpy (he->hostname, he->hostname + 7);
}
#else
/* Sometimes if we can't look things up, we could end
up with a dot in the name field which would screw
us up. Weird but apparently possible */
if (he_ != NULL &&
he_->h_name != NULL &&
he_->h_name[0] != '\0' &&
......
......@@ -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 \
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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,
......
......@@ -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 */
......@@ -19,6 +19,8 @@
#ifndef MISC_H
#define MISC_H
void gdm_set_theme (const char *theme_name);
#endif /* MISC_H */
/* EOF */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment