[gnome-system-tools] Fix/add GConf options for hiding system users and root



commit 75b2947e8fec105704f0bcb3699da0568153c02a
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Sat Dec 5 17:37:58 2009 +0100

    Fix/add GConf options for hiding system users and root
    
    "showall" option only applies to users now: system groups are only shown, since they are the most interesting ones. Add an option to hide the root account, which is turned of by default.

 gnome-system-tools.schemas.in |   13 ++++++++++++-
 src/users/users-table.c       |   18 ++++++++++++++----
 src/users/users-tool.c        |   16 +++++++---------
 src/users/users-tool.h        |    1 +
 4 files changed, 34 insertions(+), 14 deletions(-)
---
diff --git a/gnome-system-tools.schemas.in b/gnome-system-tools.schemas.in
index bf03098..a48e304 100644
--- a/gnome-system-tools.schemas.in
+++ b/gnome-system-tools.schemas.in
@@ -8,7 +8,18 @@
       <type>bool</type>
       <default>false</default>
       <locale name="C">
-        <short>Whether the users-admin tool should show all users and groups or not</short>
+        <short>Whether the users-admin tool should show system users in the users list</short>
+        <long></long>
+      </locale>
+    </schema>
+    <schema>
+      <key>/schemas/apps/gnome-system-tools/users/showroot</key>
+      <applyto>/apps/gnome-system-tools/users/showroot</applyto>
+      <owner>gnome</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+        <short>Whether the users-admin tool should show the root user in the users list</short>
         <long></long>
       </locale>
     </schema>
diff --git a/src/users/users-table.c b/src/users/users-table.c
index 73dbc1a..998afd7 100644
--- a/src/users/users-table.c
+++ b/src/users/users-table.c
@@ -68,15 +68,25 @@ static gboolean
 users_model_filter (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
 {
 	GstUsersTool *tool = (GstUsersTool *) data;
+	OobsUser *user;
 	gint uid;
+	gboolean show;
 
 	gtk_tree_model_get (model, iter,
 			    COL_USER_ID, &uid,
+	                    COL_USER_OBJECT, &user,
 			    -1);
-	return (tool->showall ||
-		(uid == 0 ||
-		 (uid >= tool->minimum_uid &&
-		  uid <= tool->maximum_uid)));
+
+	if (user == NULL)
+		return FALSE;
+
+	show = (tool->showall
+	        || (oobs_user_is_root (user) && tool->showroot)
+	        || (uid >= tool->minimum_uid && uid <= tool->maximum_uid));
+
+	g_object_unref (user);
+
+	return show;
 }
 
 static GtkTreeModel*
diff --git a/src/users/users-tool.c b/src/users/users-tool.c
index 310d407..8d6d2ef 100644
--- a/src/users/users-tool.c
+++ b/src/users/users-tool.c
@@ -54,26 +54,21 @@ gst_users_tool_class_init (GstUsersToolClass *class)
 }
 
 static void
-on_showall_changed (GConfClient *client,
+on_option_changed (GConfClient *client,
 		    guint        conn_id,
 		    GConfEntry  *entry,
 		    gpointer     data)
 {
 	GstTool *tool = GST_TOOL (data);
-	GConfValue *value;
 	GtkWidget *widget;
 	GtkTreeModel *model;
 
-	value = gconf_entry_get_value (entry);
-	GST_USERS_TOOL (tool)->showall = gconf_value_get_bool (value);
+	GST_USERS_TOOL (tool)->showall = gst_conf_get_boolean (GST_TOOL (tool), "showall");
+	GST_USERS_TOOL (tool)->showroot = gst_conf_get_boolean (GST_TOOL (tool), "showroot");
 
 	widget = gst_dialog_get_widget (tool->main_dialog, "users_table");
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
 	gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
-	
-	widget = gst_dialog_get_widget (tool->main_dialog, "groups_table");
-	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-	gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model));
 }
 
 static void
@@ -105,9 +100,12 @@ gst_users_tool_constructor (GType                  type,
 
 	tool = GST_TOOL (object);
 	GST_USERS_TOOL (tool)->showall = gst_conf_get_boolean (GST_TOOL (tool), "showall");
+	GST_USERS_TOOL (tool)->showroot = gst_conf_get_boolean (GST_TOOL (tool), "showroot");
 
 	gst_conf_add_notify (GST_TOOL (tool), "showall",
-			     on_showall_changed, tool);
+			     on_option_changed, tool);
+	gst_conf_add_notify (GST_TOOL (tool), "showroot",
+			     on_option_changed, tool);
 
 	return object;
 }
diff --git a/src/users/users-tool.h b/src/users/users-tool.h
index 68046a7..d08f144 100644
--- a/src/users/users-tool.h
+++ b/src/users/users-tool.h
@@ -52,6 +52,7 @@ struct _GstUsersTool {
 	gint maximum_gid;
 
 	gboolean showall;
+	gboolean showroot;
 };
 
 struct _GstUsersToolClass {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]