From 2a2ac8396f60f586fe6aa94da39a865de5fa81d3 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 19 Mar 1998 02:32:03 +0000 Subject: [PATCH] 1998-03-18 Federico Mena Quintero * gprop.c (perm_group_new): (perm_owner_new): Fill the combo lists with users and groups, respectively. --- gnome/ChangeLog | 4 ++++ gnome/gprop.c | 52 +++++++++++++++++++++++++++++++++++++++++++++---- gnome/gscreen.c | 2 +- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 8871f056f..720e5d19d 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,5 +1,9 @@ 1998-03-18 Federico Mena Quintero + * gprop.c (perm_group_new): + (perm_owner_new): Fill the combo lists with users and groups, + respectively. + * gprop.h: New files gprop.[ch]. These create the property pages for desktop entries. diff --git a/gnome/gprop.c b/gnome/gprop.c index 57563d469..c4717b0b2 100644 --- a/gnome/gprop.c +++ b/gnome/gprop.c @@ -5,6 +5,9 @@ * Author: Federico Mena */ +#include +#include +#include #include #include "gprop.h" @@ -235,10 +238,31 @@ perm_owner_new (char *owner) { GtkWidget *gentry; GtkWidget *entry; - - /* FIXME: this should be a nice pull-down list of user names, as in achown.c */ + GtkWidget *list; + struct passwd *passwd; + int i, sel; gentry = gnome_entry_new ("gprop_perm_owner"); + + list = GTK_COMBO (gentry)->list; + + /* We can't use 0 as the intial element because the gnome entry may already + * have loaded some history from a file. + */ + + i = g_list_length (GTK_LIST (list)->children); + sel = i; + + gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, ""); + + for (setpwent (); (passwd = getpwent ()) != NULL; i++) { + gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, passwd->pw_name); + if (strcmp (passwd->pw_name, owner) == 0) + sel = i; + } + + gtk_list_select_item (GTK_LIST (list), sel); + entry = gnome_entry_gtk_entry (GNOME_ENTRY (gentry)); gtk_entry_set_text (GTK_ENTRY (entry), owner); @@ -250,10 +274,30 @@ perm_group_new (char *group) { GtkWidget *gentry; GtkWidget *entry; - - /* FIXME: this should be a nice pull-down list of group names, as in achown.c */ + GtkWidget *list; + struct group *grp; + int i, sel; gentry = gnome_entry_new ("gprop_perm_group"); + gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, ""); + + list = GTK_COMBO (gentry)->list; + + /* We can't use 0 as the intial element because the gnome entry may already + * have loaded some history from a file. + */ + + i = g_list_length (GTK_LIST (list)->children); + sel = i; + + for (setgrent (); (grp = getgrent ()) != NULL; i++) { + gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, grp->gr_name); + if (strcmp (grp->gr_name, group) == 0) + sel = i; + } + + gtk_list_select_item (GTK_LIST (list), sel); + entry = gnome_entry_gtk_entry (GNOME_ENTRY (gentry)); gtk_entry_set_text (GTK_ENTRY (entry), group); diff --git a/gnome/gscreen.c b/gnome/gscreen.c index 8bcbc6304..f502932c7 100644 --- a/gnome/gscreen.c +++ b/gnome/gscreen.c @@ -483,7 +483,7 @@ test_it (void) gtk_widget_show (window); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gpp = gprop_perm_new (0, "yomero", "migrupo"); + gpp = gprop_perm_new (0, "yomero", "gnome"); gtk_container_add (GTK_CONTAINER (window), gpp->top); gtk_widget_show (gpp->top); gtk_widget_show (window);