gnome-utils r7897 - in trunk/baobab: . data src



Author: marzocca
Date: Thu May  1 20:53:57 2008
New Revision: 7897
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=7897&view=rev

Log:
Continuing migration to Gio

Modified:
   trunk/baobab/ChangeLog
   trunk/baobab/data/baobab.schemas.in
   trunk/baobab/src/baobab-prefs.c
   trunk/baobab/src/baobab-prefs.h
   trunk/baobab/src/baobab-utils.c
   trunk/baobab/src/baobab.c
   trunk/baobab/src/baobab.h

Modified: trunk/baobab/data/baobab.schemas.in
==============================================================================
--- trunk/baobab/data/baobab.schemas.in	(original)
+++ trunk/baobab/data/baobab.schemas.in	Thu May  1 20:53:57 2008
@@ -38,16 +38,17 @@
       </locale>
     </schema>
     
+    
     <schema>
-      <key>/schemas/apps/baobab/properties/noscan</key>
-      <applyto>/apps/baobab/properties/noscan</applyto>
+      <key>/schemas/apps/baobab/properties/skip_scan_uri_list</key>
+      <applyto>/apps/baobab/properties/skip_scan_uri_list</applyto>
       <owner>baobab</owner>
       <type>list</type>
       <list_type>string</list_type>
       <default>[]</default>
       <locale name="C">
-	<short>Exluded partitions</short>
-	<long>A list of partitions to be excluded from scanning.</long>
+	<short>Exluded partitions uris</short>
+	<long>A list of uri for partitions to be excluded from scanning.</long>
       </locale>
     </schema>
     

Modified: trunk/baobab/src/baobab-prefs.c
==============================================================================
--- trunk/baobab/src/baobab-prefs.c	(original)
+++ trunk/baobab/src/baobab-prefs.c	Thu May  1 20:53:57 2008
@@ -63,15 +63,15 @@
 	      GConfEntry *entry,
 	      gpointer user_data)
 {
-	GSList *dirs;
+	GSList *uris;
 
-	dirs = 	gconf_client_get_list (client,
+	uris = 	gconf_client_get_list (client,
 				       PROPS_SCAN_KEY,
 				       GCONF_VALUE_STRING,
 				       NULL);
-	baobab_set_excluded_dirs (dirs);
-	g_slist_foreach (dirs, (GFunc) g_free, NULL);
-	g_slist_free (dirs);
+	baobab_set_excluded_locations (uris);
+	g_slist_foreach (uris, (GFunc) g_free, NULL);
+	g_slist_free (uris);
 
 	baobab_get_filesystem (&g_fs);
 	set_label_scan (&g_fs);
@@ -145,10 +145,11 @@
 	mdl = gtk_list_store_new (TOT_COLUMNS,
 				  G_TYPE_BOOLEAN,	/* checkbox */
 				  G_TYPE_STRING,	/* device */
-				  G_TYPE_STRING,	/* mount point */
+				  G_TYPE_STRING,	/*mount point display */
+				  G_TYPE_STRING,	/* mount point uri */
 				  G_TYPE_STRING,	/* fs type */
 				  G_TYPE_STRING,	/* fs size */
-				  G_TYPE_STRING		/* fs used */
+				  G_TYPE_STRING		/* fs avail */
 				  );
 
 	return mdl;
@@ -185,8 +186,8 @@
 	cell = gtk_cell_renderer_text_new ();
 	col = gtk_tree_view_column_new_with_attributes (_("Mount Point"),
 							cell, "markup",
-							COL_MOUNT, "text",
-							COL_MOUNT, NULL);
+							COL_MOUNT_D, "text",
+							COL_MOUNT_D, NULL);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (tvw), col);
 
 	/* third text column */
@@ -270,22 +271,30 @@
 	     
 	     	glibtop_fsusage fsusage;
 		gchar * total, *avail;
+		GFile	*file;
+		gchar	*uri;
+		
 		glibtop_get_fsusage (&fsusage, mountentry->mountdir);
 		fstotal = fsusage.blocks * fsusage.block_size;
 		fsavail = fsusage.bfree * fsusage.block_size;
 		total = g_format_size_for_display(fstotal);
 		avail = g_format_size_for_display(fsavail);
+		file = g_file_new_for_path (mountentry->mountdir);
+		uri = g_file_get_uri (file);
 		gtk_list_store_append (model_props, &iter);
 			gtk_list_store_set (model_props, &iter,
 					    COL_CHECK, TRUE,
-					    COL_DEVICE, mountentry->devname, 
-					    COL_MOUNT, mountentry->mountdir, 
+					    COL_DEVICE, mountentry->devname,
+					    COL_MOUNT_D, mountentry->mountdir, 
+					    COL_MOUNT, uri, 
 					    COL_TYPE, mountentry->type,
 					    COL_FS_SIZE, total,
 					    COL_FS_AVAIL, avail,
 					    -1);
 		g_free(total);
 		g_free(avail);
+		g_free(uri);
+		g_object_unref(file);
 	}
 
 	g_free (mountentry_tofree);

Modified: trunk/baobab/src/baobab-prefs.h
==============================================================================
--- trunk/baobab/src/baobab-prefs.h	(original)
+++ trunk/baobab/src/baobab-prefs.h	Thu May  1 20:53:57 2008
@@ -28,6 +28,7 @@
 {
 	COL_CHECK,
 	COL_DEVICE,
+	COL_MOUNT_D,
 	COL_MOUNT,
 	COL_TYPE,
 	COL_FS_SIZE,

Modified: trunk/baobab/src/baobab-utils.c
==============================================================================
--- trunk/baobab/src/baobab-utils.c	(original)
+++ trunk/baobab/src/baobab-utils.c	Thu May  1 20:53:57 2008
@@ -52,10 +52,15 @@
 	mountentries = glibtop_get_mountlist (&mountlist, FALSE);
 
 	for (i = 0; i < mountlist.number; ++i) {
+		GFile	*file;
 		glibtop_fsusage fsusage;
+		
+		file = g_file_new_for_path(mountentries[i].mountdir);	
 
-		if (baobab_is_excluded_dir (mountentries[i].mountdir))
+		if (baobab_is_excluded_location (file)){
+			g_object_unref(file);
 			continue;
+			}
 
 		glibtop_get_fsusage (&fsusage, mountentries[i].mountdir);
 
@@ -63,6 +68,8 @@
 		fs->total += fsusage.blocks * fsusage.block_size;
 		fs->avail += fsusage.bfree * fsusage.block_size;
 		fs->used += (fsusage.blocks - fsusage.bfree) * fsusage.block_size;
+		g_object_unref(file);
+
 	}
 
 	g_free (mountentries);

Modified: trunk/baobab/src/baobab.c
==============================================================================
--- trunk/baobab/src/baobab.c	(original)
+++ trunk/baobab/src/baobab.c	Thu May  1 20:53:57 2008
@@ -65,21 +65,15 @@
 
 
 static gboolean
-scan_is_local (const gchar *uri_dir)
+scan_is_local (GFile	*file)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult res;
-	gboolean ret;
-
-	info = gnome_vfs_file_info_new ();
-	res = gnome_vfs_get_file_info (uri_dir,
-				       info, GNOME_VFS_FILE_INFO_DEFAULT);
-
-	ret = ((res == GNOME_VFS_OK) &&
-	       (info->flags & GNOME_VFS_FILE_FLAGS_LOCAL));
-
-	gnome_vfs_file_info_unref (info);
-
+	gchar	*uri_scheme;
+	gboolean	ret=FALSE;
+	
+	uri_scheme = g_file_get_uri_scheme (file);
+	if (g_ascii_strcasecmp(uri_scheme,"file") == 0) ret= TRUE;
+	
+	g_free (uri_scheme);
 	return ret;
 }
 
@@ -124,7 +118,7 @@
 	iterstack = g_queue_new ();
 
 	/* check if the file system is local or remote */
-	baobab.is_local = scan_is_local (dir);
+	baobab.is_local = scan_is_local (file);
 	ck_allocated = glade_xml_get_widget (baobab.main_xml, "ck_allocated");
 	if (!baobab.is_local) {
 		gtk_toggle_button_set_active ((GtkToggleButton *)
@@ -441,46 +435,52 @@
 	g_free (escaped_str);
 }
 
-static gint
-list_find (gconstpointer a, gconstpointer b)
-{
-	gchar *str_a, *str_b;
-	gint ret;
-
-	str_a = gnome_vfs_format_uri_for_display (a);
-	str_b = gnome_vfs_format_uri_for_display (b);
-
-	ret = strcmp (str_a, str_b);
-
-	g_free (str_a);
-	g_free (str_b);
-
-	return ret;
-}
 
 void
-baobab_set_excluded_dirs (GSList *excluded_dirs)
+baobab_set_excluded_locations (GSList *excluded_uris)
 {
 	GSList *l;
 
-	g_slist_foreach (baobab.excluded_dirs, (GFunc) g_free, NULL);
-	g_slist_free (baobab.excluded_dirs);
+	g_slist_foreach (baobab.excluded_locations, (GFunc) g_object_unref, NULL);
+	g_slist_free (baobab.excluded_locations);
+	baobab.excluded_locations = NULL;
+	for (l = excluded_uris; l != NULL; l = l->next) {
+		baobab.excluded_locations = g_slist_prepend (baobab.excluded_locations,
+						g_file_new_for_uri (l->data));
+	}
 
-	for (l = excluded_dirs; l != NULL; l = l->next) {
-		baobab.excluded_dirs = g_slist_prepend (baobab.excluded_dirs,
-							g_strdup (l->data));
+}
+
+gboolean
+baobab_is_excluded_location (GFile *file)
+{
+	gboolean ret = FALSE;
+	GSList	*l;
+	
+	for (l=baobab.excluded_locations; l != NULL; l = l->next) {	
+		if (g_file_equal(l->data, file))
+			ret = TRUE;
 	}
+	
+	return ret;
 }
 
 gboolean
-baobab_is_excluded_dir (const gchar *dir)
+baobab_is_excluded_dir (const gchar *uri)
 {
-	g_return_val_if_fail (dir != NULL, FALSE);
+	gboolean ret = FALSE;
+	GFile	*file;
 
-	return (baobab.excluded_dirs &&
-		(g_slist_find_custom (baobab.excluded_dirs, dir, list_find) != NULL));
+	g_return_val_if_fail (uri != NULL, FALSE);
+	file = g_file_new_for_uri (uri);
+	ret = baobab_is_excluded_location (file);
+	g_object_unref (file);
+	return ret;
 }
 
+
+
+
 void
 set_toolbar_visible (gboolean visible)
 {
@@ -636,9 +636,8 @@
 static void
 baobab_init (void)
 {
-	GnomeVFSResult result;
-	GnomeVFSVolumeMonitor *volmonitor;
-
+	GSList	*uri_list, *l;
+	
 	/* Load Glade */
 	baobab.main_xml = glade_xml_new (BAOBAB_GLADE_FILE,
 					 "baobab_window", NULL);
@@ -659,21 +658,37 @@
 				 NULL, NULL, NULL);
 	gconf_client_notify_add (baobab.gconf_client, SYSTEM_TOOLBAR_STYLE, baobab_toolbar_style,
 				 NULL, NULL, NULL);				 
-	baobab.excluded_dirs = gconf_client_get_list (baobab.gconf_client,
+	uri_list = gconf_client_get_list (baobab.gconf_client,
 						      PROPS_SCAN_KEY,
 						      GCONF_VALUE_STRING,
 						      NULL);
+	
+	baobab_set_excluded_locations(uri_list);
+
+	g_slist_foreach (uri_list, (GFunc) g_free, NULL);
+	g_slist_free (uri_list);
 
 	/* Verify if gconf wrongly contains root dir exclusion, and remove it from gconf. */
-	if (baobab_is_excluded_dir ("/")) {
-		baobab.excluded_dirs = g_slist_delete_link (baobab.excluded_dirs, 
-						g_slist_find_custom (baobab.excluded_dirs, 
-							"/", list_find));
+	if (baobab_is_excluded_dir ("file:///")) {
+		GFile 	*file;
+		
+		file = g_file_new_for_uri ("file:///");
+
+		baobab.excluded_locations = g_slist_delete_link (baobab.excluded_locations, 
+						g_slist_find (baobab.excluded_locations, 
+							file));
+		g_object_unref (file);
+		for (l = baobab.excluded_locations; l != NULL; l = l->next) {
+			uri_list = g_slist_prepend (uri_list, g_file_get_uri(l->data));
+		}
+		
 		gconf_client_set_list (baobab.gconf_client,
 				       PROPS_SCAN_KEY,
 				       GCONF_VALUE_STRING, 
-				       baobab.excluded_dirs,
+				       uri_list,
 				       NULL);
+		g_slist_foreach (uri_list, (GFunc) g_free, NULL);
+		g_slist_free (uri_list);
 	}
 
 	baobab.bbEnableHomeMonitor = gconf_client_get_bool (baobab.gconf_client,
@@ -727,8 +742,8 @@
 
 	g_free (baobab.selected_path);
 
-	g_slist_foreach (baobab.excluded_dirs, (GFunc) g_free, NULL);
-	g_slist_free (baobab.excluded_dirs);
+	g_slist_foreach (baobab.excluded_locations, (GFunc) g_object_unref, NULL);
+	g_slist_free (baobab.excluded_locations);
 
 	if (baobab.gconf_client)
 		g_object_unref (baobab.gconf_client);

Modified: trunk/baobab/src/baobab.h
==============================================================================
--- trunk/baobab/src/baobab.h	(original)
+++ trunk/baobab/src/baobab.h	Thu May  1 20:53:57 2008
@@ -42,7 +42,7 @@
 #define BAOBAB_KEY_DIR "/apps/baobab"
 #define BAOBAB_TOOLBAR_VISIBLE_KEY	BAOBAB_KEY_DIR "/ui/toolbar_visible"
 #define BAOBAB_STATUSBAR_VISIBLE_KEY	BAOBAB_KEY_DIR "/ui/statusbar_visible"
-#define PROPS_SCAN_KEY			BAOBAB_KEY_DIR "/properties/noscan"
+#define PROPS_SCAN_KEY			BAOBAB_KEY_DIR "/properties/skip_scan_uri_list"
 #define PROPS_ENABLE_HOME_MONITOR	BAOBAB_KEY_DIR "/properties/enable_home_monitor"
 #define SYSTEM_TOOLBAR_STYLE		"/desktop/gnome/interface/toolbar_style"
 
@@ -58,7 +58,7 @@
 	GtkTreeStore *model;
 	gboolean STOP_SCANNING;
 	gboolean CONTENTS_CHANGED_DELAYED;
-	GSList *excluded_dirs;
+	GSList *excluded_locations;
 	gboolean bbEnableHomeMonitor;
 	gchar *label_scan;
 	gboolean show_allocated;
@@ -97,8 +97,9 @@
 void baobab_stop_scan (void);
 void fill_model (struct chan_data *);
 void first_row (void);
-gboolean baobab_is_excluded_dir (const gchar *);
-void baobab_set_excluded_dirs (GSList *);
+gboolean baobab_is_excluded_location (GFile *);
+gboolean baobab_is_excluded_dir (const char *);
+void baobab_set_excluded_locations (GSList *);
 void set_toolbar_visible (gboolean visible);
 void set_statusbar_visible (gboolean visible);
 void set_statusbar (const gchar *);



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