From bac29b1c270adaed8b3fba2f7f074ce01276a564 Mon Sep 17 00:00:00 2001 From: George Lebl Date: Jul 15 2003 17:52:22 +0000 Subject: Fix #97774 by resetting the rlimits back to infinity after we fork the Mon Jul 14 16:44:19 2003 George Lebl * daemon/misc.[ch], daemon/slave.c: Fix #97774 by resetting the rlimits back to infinity after we fork the user session. * config/gdm.conf.in, daemon/gdm.h: The default for AlwaysRestartServer is now again false, since it turns out to be a LOT nicer with buggy X servers (and it turns out quite a lot of people have these). * daemon/slave.c: properly guess the failsafeness of a session and don't re-guess it again * daemon/slave.c: when under the influence of rlimits never ABORT a display since it really could just be that we're hitting stupid limits (definately set way too low). * daemon/slave.c, daemon/server.c, daemon/misc.c: Be extra careful about when to reset signals to avoid races (unlikely though they may be) --- diff --git a/NEWS b/NEWS index d66b667..27d15c4 100644 --- a/NEWS +++ b/NEWS @@ -10,14 +10,19 @@ Ahh news... - Fix DNS lookup stuff in XDMCP for places without DNS. Also cache last result of DNS lookup to cut down traffic during session setup. -- daemon, gdmgreeter and gdmlogin don't link against libgnome and - friends (gdmgreeter still uses canvas). This reduces number of - libs linked by daemon from 46 to 26, for gdmgreeter this goes - from 56 to 32 and for gdmlogin this goes from 52 to 22 +- daemon, gdmgreeter, gdmlogin and gdmchooser don't link against + libgnome and friends (gdmgreeter still uses canvas). This + reduces number of libs linked by daemon from 46 to 26, for + gdmgreeter this goes from 56 to 32 and for gdmlogin this goes + from 52 to 22, and gdmchooser is down to 27 - If a greeter crashes within 10 seconds of display start, try running a different greeter (and telling the user that) +- Fix the chooser so that it actually chooses the host that + you clicked on and not some random one. This also changes + the chooser to use GtkTreeView + - Fix #97774 by resetting the rlimits back after we fork the user session. Also make AlwaysRestartServer default to false again since it was a workaround for this bug. @@ -64,7 +69,7 @@ Ahh news... - Translation updates (Danilo Segan, Serbian team, Metin Amiroff, Christian Rose, Kjartan Maraas, Artur Flinta, Vincent van Adrighem, Valek Filippov, Laurent Dhima, Christophe Merlet, Mohammad DAMT, - Dafydd Harries) + Dafydd Harries, Kang Jeong-Hee, Simos Xenitellis) 2.4.2.96 stuff: diff --git a/configure.in b/configure.in index d4049ab..151fde5 100644 --- a/configure.in +++ b/configure.in @@ -131,6 +131,10 @@ PKG_CHECK_MODULES(GUI, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_R AC_SUBST(GUI_CFLAGS) AC_SUBST(GUI_LIBS) +PKG_CHECK_MODULES(GUIGLADE, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED) +AC_SUBST(GUIGLADE_CFLAGS) +AC_SUBST(GUIGLADE_LIBS) + PKG_CHECK_MODULES(GUING, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED) AC_SUBST(GUING_CFLAGS) AC_SUBST(GUING_LIBS) diff --git a/gui/Makefile.am b/gui/Makefile.am index 8dd1f57..adafa84 100644 --- a/gui/Makefile.am +++ b/gui/Makefile.am @@ -71,9 +71,10 @@ gdmsetup_SOURCES = \ gdmchooser_LDFLAGS = -export-dynamic gdmchooser_LDADD = \ libgdmwm.a \ - $(GUI_LIBS) \ + $(GUIGLADE_LIBS) \ $(X_LIBS) \ $(XDMCP_LIBS) \ + -lpopt \ -lX11 \ $(XINERAMA_LIBS) \ $(X_EXTRA_LIBS) \ diff --git a/gui/gdmchooser-strings.c b/gui/gdmchooser-strings.c index d9c2a01..78cb77a 100644 --- a/gui/gdmchooser-strings.c +++ b/gui/gdmchooser-strings.c @@ -1,7 +1,7 @@ /* * Soubor s přeložitelnými řetězci generovaný programem Glade. - * Přidejte tento soubor do POTFILES.in svého projektu. - * NEPŘEKLÁDEJTE JEJ jako součást své aplikace. + * Přidejte tento soubor do souboru vašeho projektu POTFILES.in. + * NEPŘEKLÁDEJTE JEJ jako součást vaší aplikace. */ gchar *s = N_("GDM Host Chooser"); @@ -15,7 +15,3 @@ gchar *s = N_("Add host: "); gchar *s = N_("*"); gchar *s = N_("Query and add this host to the above list"); gchar *s = N_("Add"); -gchar *s = N_("The main area of this application shows the hosts on the local network that have \"XDMCP\" enabled. This allows users to login remotely to other machines as if they were logged on using the console.\n" - "\n" - "You can rescan the network for new hosts by clicking \"Refresh\". When you have selected a host click \"Connect\" to open a session to that machine."); -gchar *s = N_("Information"); diff --git a/gui/gdmchooser.c b/gui/gdmchooser.c index 6d71ed8..7b282d7 100644 --- a/gui/gdmchooser.c +++ b/gui/gdmchooser.c @@ -56,6 +56,12 @@ static gboolean RUNNING_UNDER_GDM = FALSE; +enum { + CHOOSER_LIST_ICON_COLUMN = 0, + CHOOSER_LIST_LABEL_COLUMN, + CHOOSER_LIST_HOST_COLUMN +}; + typedef struct _GdmChooserHost GdmChooserHost; struct _GdmChooserHost { gchar *name; @@ -63,7 +69,6 @@ struct _GdmChooserHost { struct in_addr ia; GdkPixbuf *picture; gboolean willing; - int pos; }; @@ -154,8 +159,25 @@ static GIOChannel *channel; static GList *hosts = NULL; static GdkPixbuf *defhostimg; static GtkWidget *browser; +static GtkTreeModel *browser_model; static GdmChooserHost *curhost; +static gboolean +find_host_in_list (GdmChooserHost *host, GtkTreeIter *iter) +{ + if (gtk_tree_model_get_iter_first (browser_model, iter)) { + do { + GdmChooserHost *lhost; + gtk_tree_model_get (browser_model, iter, + CHOOSER_LIST_HOST_COLUMN, &lhost, + -1); + if (lhost == host) + return TRUE; + } while (gtk_tree_model_iter_next (browser_model, iter)); + } + return FALSE; +} + static void setup_cursor (GdkCursorType type) { @@ -181,18 +203,6 @@ gdm_chooser_host_dispose (GdmChooserHost *host) g_free (host); } -static gint -gdm_chooser_sort_func (gpointer d1, gpointer d2) -{ - GdmChooserHost *a = d1; - GdmChooserHost *b = d2; - - if (!d1 || !d2) - return 0; - - return strcmp (a->name, b->name); -} - static GdmChooserHost * gdm_chooser_host_alloc (const char *hostname, const char *description, @@ -202,28 +212,14 @@ gdm_chooser_host_alloc (const char *hostname, GdmChooserHost *host; GdkPixbuf *img; gchar *hostimg; - GList *hostl; host = g_new0 (GdmChooserHost, 1); - host->pos = -1; host->name = g_strdup (hostname); host->desc = g_strdup (description); memcpy (&host->ia, ia, sizeof (struct in_addr)); host->willing = willing; - hostl = g_list_find_custom (hosts, - host, - (GCompareFunc) gdm_chooser_sort_func); - /* replace */ - if (hostl != NULL) { - GdmChooserHost *old = hostl->data; - hostl->data = host; - gdm_chooser_host_dispose (old); - } else { - hosts = g_list_insert_sorted (hosts, - host, - (GCompareFunc) gdm_chooser_sort_func); - } + hosts = g_list_prepend (hosts, host); if ( ! willing) return host; @@ -271,22 +267,39 @@ static void gdm_chooser_browser_add_host (GdmChooserHost *host) { if (host->willing) { - /* FIXME: the \n doesn't actually propagate - * since the icon list is a broken piece of horsedung */ - char *temp = g_strconcat (host->name, " \n", - host->desc, NULL); - host->pos = - gnome_icon_list_append_pixbuf (GNOME_ICON_LIST (browser), - host->picture, - NULL /* icon_filename */, - temp); - g_free (temp); + GtkTreeIter iter = {0}; + const char *addr = inet_ntoa (host->ia); + char *label; + + if (strcmp (addr, host->name) == 0) + label = g_strdup_printf ("%s\n%s", + host->name, + host->desc); + else + label = g_strdup_printf ("%s (%s)\n%s", + host->name, + addr, + host->desc); + + gtk_list_store_append (GTK_LIST_STORE (browser_model), &iter); + gtk_list_store_set (GTK_LIST_STORE (browser_model), &iter, + CHOOSER_LIST_ICON_COLUMN, host->picture, + CHOOSER_LIST_LABEL_COLUMN, label, + CHOOSER_LIST_HOST_COLUMN, host, + -1); + g_free (label); if (added_addr != NULL && memcmp (&host->ia, added_addr, sizeof (struct in_addr)) == 0) { - gnome_icon_list_select_icon (GNOME_ICON_LIST (browser), - host->pos); + GtkTreeSelection *selection; + GtkTreePath *path = gtk_tree_model_get_path (browser_model, &iter); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser)); + gtk_tree_selection_select_iter (selection, &iter); + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (browser), + path, NULL, + FALSE, 0.0, 0.0); + gtk_tree_path_free (path); gtk_widget_grab_focus (manage); } g_free (added_host); @@ -608,7 +621,7 @@ gdm_chooser_xdmcp_discover (void) gtk_widget_set_sensitive (GTK_WIDGET (manage), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (rescan), FALSE); - gnome_icon_list_clear (GNOME_ICON_LIST (browser)); + gtk_list_store_clear (GTK_LIST_STORE (browser_model)); gtk_widget_set_sensitive (GTK_WIDGET (browser), FALSE); gtk_label_set_text (GTK_LABEL (status_label), _(scanning_message)); @@ -887,9 +900,16 @@ gdm_chooser_add_host (void) host = gdm_host_known (ia); if (host != NULL) { - if (host->pos >= 0) { - gnome_icon_list_select_icon (GNOME_ICON_LIST (browser), - host->pos); + GtkTreeIter iter = {0}; + if (find_host_in_list (host, &iter)) { + GtkTreeSelection *selection; + GtkTreePath *path = gtk_tree_model_get_path (browser_model, &iter); + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser)); + gtk_tree_selection_select_iter (selection, &iter); + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (browser), + path, NULL, + FALSE, 0.0, 0.0); + gtk_tree_path_free (path); gtk_widget_grab_focus (manage); } else { /* hmm, probably not willing, ping the host then for @@ -1036,43 +1056,29 @@ gdm_chooser_parse_config (void) if (GdmIconMaxHeight < 0) GdmIconMaxHeight = 128; } -static GdmChooserHost * -gdm_nth_willing_host (int n) +static void +host_selected (GtkTreeSelection *selection, gpointer data) { - GList *li; - int i; + GtkTreeModel *tm = NULL; + GtkTreeIter iter = {0}; - i = 0; - for (li = hosts; li != NULL; li = li->next) { - GdmChooserHost *host = li->data; - if (host->willing) { - if (i == n) - return host; - i++; - } - } - return NULL; -} - - -void -gdm_chooser_browser_select (GtkWidget *widget, gint selected, GdkEvent *event) -{ - curhost = gdm_nth_willing_host (selected); - gtk_widget_set_sensitive (manage, TRUE); + curhost = NULL; - if (event != NULL && - event->type == GDK_2BUTTON_PRESS) { - gdm_chooser_manage (NULL, NULL); + if (gtk_tree_selection_get_selected (selection, &tm, &iter)) { + gtk_tree_model_get (tm, &iter, CHOOSER_LIST_HOST_COLUMN, + &curhost, -1); } -} + gtk_widget_set_sensitive (manage, curhost != NULL); +} -void -gdm_chooser_browser_unselect (GtkWidget *widget, gint selected, GdkEvent *event) +static void +row_activated (GtkTreeView *tree_view, + GtkTreePath *path, + GtkTreeViewColumn *column) { - curhost = NULL; - gtk_widget_set_sensitive (manage, FALSE); + if (curhost != NULL) + gdm_chooser_manage (NULL, NULL); } void @@ -1109,12 +1115,14 @@ gdm_chooser_gui_init (void) { int width; int height; + GtkTreeSelection *selection; + GtkTreeViewColumn *column; glade_helper_add_glade_directory (GDM_GLADE_DIR); glade_helper_search_gnome_dirs (FALSE); /* Enable theme */ - if (GdmGtkRC) + if (RUNNING_UNDER_GDM && GdmGtkRC) gtk_rc_parse (GdmGtkRC); /* Load default host image */ @@ -1151,12 +1159,45 @@ gdm_chooser_gui_init (void) GTK_TYPE_ENTRY); browser = glade_helper_get (chooser_app, "chooser_iconlist", - GNOME_TYPE_ICON_LIST); - gnome_icon_list_freeze (GNOME_ICON_LIST (browser)); - gnome_icon_list_set_separators (GNOME_ICON_LIST (browser), " /-_.\n"); - gnome_icon_list_set_icon_width (GNOME_ICON_LIST (browser), GdmIconMaxWidth + 20); - gnome_icon_list_set_icon_border (GNOME_ICON_LIST (browser), 2); - gnome_icon_list_thaw (GNOME_ICON_LIST (browser)); + GTK_TYPE_TREE_VIEW); + + gtk_dialog_set_has_separator (GTK_DIALOG (chooser), FALSE); + + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (browser), TRUE); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser)); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + + g_signal_connect (selection, "changed", + G_CALLBACK (host_selected), + NULL); + g_signal_connect (browser, "row_activated", + G_CALLBACK (row_activated), + NULL); + + browser_model = (GtkTreeModel *)gtk_list_store_new (3, + GDK_TYPE_PIXBUF, + G_TYPE_STRING, + G_TYPE_POINTER); + gtk_tree_view_set_model (GTK_TREE_VIEW (browser), browser_model); + column = gtk_tree_view_column_new_with_attributes + ("Icon", + gtk_cell_renderer_pixbuf_new (), + "pixbuf", CHOOSER_LIST_ICON_COLUMN, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (browser), column); + + column = gtk_tree_view_column_new_with_attributes + ("Hostname", + gtk_cell_renderer_text_new (), + "text", CHOOSER_LIST_LABEL_COLUMN, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (browser), column); + + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser_model), + CHOOSER_LIST_LABEL_COLUMN, + GTK_SORT_ASCENDING); + if ( ! GdmAllowAdd) { GtkWidget *w = glade_helper_get (chooser_app, "add_hbox", diff --git a/gui/gdmchooser.glade b/gui/gdmchooser.glade index 42bc6f9..7c8b461 100644 --- a/gui/gdmchooser.glade +++ b/gui/gdmchooser.glade @@ -2,9 +2,9 @@ - + 6 True GDM Host Chooser GTK_WINDOW_TOPLEVEL @@ -20,7 +20,7 @@ True False - 0 + 6 @@ -152,15 +152,12 @@ False False GTK_JUSTIFY_LEFT - False + True False - 0.5 + 0 0.5 0 0 - - - 0 @@ -179,21 +176,13 @@ GTK_CORNER_TOP_LEFT - + True True - GTK_SELECTION_SINGLE - 78 - 4 - 2 - 2 - False - False - - - - - + False + True + False + True @@ -208,7 +197,7 @@ True False - 0 + 6 @@ -224,8 +213,8 @@ 0 0 - + @@ -288,56 +277,4 @@ - - True - GNOME_MESSAGE_BOX_INFO - The main area of this application shows the hosts on the local network that have "XDMCP" enabled. This allows users to login remotely to other machines as if they were logged on using the console. - -You can rescan the network for new hosts by clicking "Refresh". When you have selected a host click "Connect" to open a session to that machine. - Information - GTK_WIN_POS_NONE - False - False - False - True - False - - - - True - False - 8 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - - - - - 0 - False - True - GTK_PACK_END - - - - - 4 - True - True - - - - diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c index 8538cde..6ffa254 100644 --- a/gui/gdmlogin.c +++ b/gui/gdmlogin.c @@ -3212,6 +3212,7 @@ gdm_login_gui_init (void) GtkTreeViewColumn *column; browser = gtk_tree_view_new (); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (browser), TRUE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (browser), FALSE); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (browser)); diff --git a/gui/gdmsetup.c b/gui/gdmsetup.c index e0f6b71..19b9b20 100644 --- a/gui/gdmsetup.c +++ b/gui/gdmsetup.c @@ -1825,6 +1825,8 @@ setup_graphical_themes (void) char *theme_dir = get_theme_dir (); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (theme_list), TRUE); + selected_theme = ve_config_get_string (ve_config_get (GDM_CONFIG_FILE), GDM_KEY_GRAPHICAL_THEME); diff --git a/gui/greeter/greeter_action_language.c b/gui/greeter/greeter_action_language.c index 8dd02c7..3dce79c 100644 --- a/gui/greeter/greeter_action_language.c +++ b/gui/greeter/greeter_action_language.c @@ -209,6 +209,7 @@ greeter_action_language (GreeterItemInfo *info, gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, FALSE, FALSE, 0); view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lang_model)); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE); /* FIXME: we should handle this better, but things really look * like crap if we aren't always LTR */ gtk_widget_set_direction (view, GTK_TEXT_DIR_LTR); diff --git a/gui/greeter/greeter_canvas_item.c b/gui/greeter/greeter_canvas_item.c index 8f1e069..abdec99 100644 --- a/gui/greeter/greeter_canvas_item.c +++ b/gui/greeter/greeter_canvas_item.c @@ -346,6 +346,7 @@ greeter_item_create_canvas_item (GreeterItemInfo *item) * to it then, depending on the type. Likely userlist is the * only type we support */ list = gtk_tree_view_new (); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (list), TRUE); swin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin), GTK_SHADOW_NONE);