gnome-utils r7912 - in trunk/baobab: . src



Author: pborelli
Date: Sat May  3 19:42:39 2008
New Revision: 7912
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=7912&view=rev

Log:
2008-05-03  Paolo Borelli  <pborelli katamail com>

	* src/baobab.c:
	* src/baobab.h:
	* src/baobab-scan.c:
	* src/baobab-treeview.c:
	* src/baobab-treeview.h:
	* src/callbacks.c:
	Store the parse name in the model so that we do not have to use
	path or uri condtionally to the fact that the file is local or remote.



Modified:
   trunk/baobab/ChangeLog
   trunk/baobab/src/baobab-scan.c
   trunk/baobab/src/baobab-treeview.c
   trunk/baobab/src/baobab-treeview.h
   trunk/baobab/src/baobab.c
   trunk/baobab/src/baobab.h
   trunk/baobab/src/callbacks.c

Modified: trunk/baobab/src/baobab-scan.c
==============================================================================
--- trunk/baobab/src/baobab-scan.c	(original)
+++ trunk/baobab/src/baobab-scan.c	Sat May  3 19:42:39 2008
@@ -167,7 +167,7 @@
 	GFileEnumerator *file_enum;
 	gchar *dir_uri = NULL;
 	gchar *display_name = NULL;
-	gchar *string_to_display = NULL;
+	gchar *parse_name = NULL;
 	GError *err = NULL;
 
 	count++;
@@ -183,7 +183,7 @@
 	if (is_virtual_filesystem (file))
  		goto exit;
  
-	string_to_display = g_file_get_parse_name (file);	
+	parse_name = g_file_get_parse_name (file);	
 
 	/* Folders we can't access (e.g perms 644). Skip'em. */
 	if (!g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
@@ -212,7 +212,7 @@
 
 	if (file_enum == NULL) {
 		g_warning ("couldn't get dir enum for dir %s: %s\n",
-			   string_to_display, err->message);
+			   parse_name, err->message);
 		goto exit;
 	}
 
@@ -226,7 +226,7 @@
 	data.depth = count - 1;
 	data.elements = -1;
 	data.display_name = display_name;
-	data.dir = string_to_display;
+	data.parse_name = parse_name;
 	data.tempHLsize = tempHLsize;
 	fill_model (&data);
 
@@ -286,11 +286,11 @@
 	/* won't be an error if we've finished normally */
 	if (err != NULL) {
 		g_warning ("error in dir %s: %s\n", 
-			   string_to_display, err->message);
+			   parse_name, err->message);
 	}
 
 	data.display_name = display_name;
-	data.dir = string_to_display;
+	data.parse_name = parse_name;
 	data.size = retloop.size;
 	data.alloc_size = retloop.alloc_size;
 	data.depth = count - 1;
@@ -302,7 +302,7 @@
  exit:
 	g_free (dir_uri);
 	g_free (display_name);
-	g_free (string_to_display);
+	g_free (parse_name);
 	if (err)
 		g_error_free (err);
 

Modified: trunk/baobab/src/baobab-treeview.c
==============================================================================
--- trunk/baobab/src/baobab-treeview.c	(original)
+++ trunk/baobab/src/baobab-treeview.c	Sat May  3 19:42:39 2008
@@ -39,7 +39,7 @@
 {
 	GtkTreeStore *mdl = gtk_tree_store_new (NUM_TREE_COLUMNS,
 						G_TYPE_STRING,	/* COL_DIR_NAME */
-						G_TYPE_STRING,	/* COL_H_FULLPATH */
+						G_TYPE_STRING,	/* COL_H_PARSENAME */
 						G_TYPE_DOUBLE,	/* COL_H_PERC */
 						G_TYPE_STRING,	/* COL_DIR_SIZE */
 						G_TYPE_UINT64,	/* COL_H_SIZE */
@@ -65,30 +65,23 @@
 static void
 on_tv_cur_changed (GtkTreeView *treeview, gpointer data)
 {
-
 	GtkTreeIter iter;
-	gchar *text = NULL;
+	gchar *parsename = NULL;
 
 	gtk_tree_selection_get_selected (gtk_tree_view_get_selection (treeview), NULL, &iter);
 
 	if (gtk_tree_store_iter_is_valid (baobab.model, &iter)) {
-			gtk_tree_model_get (GTK_TREE_MODEL (baobab.model), &iter,
-				    COL_H_FULLPATH, &text, -1);
+		gtk_tree_model_get (GTK_TREE_MODEL (baobab.model), &iter,
+				    COL_H_PARSENAME, &parsename, -1);
 	}
-	
-	set_glade_widget_sens("menu_treemap",FALSE);
-	if (text) {
-		gchar *msg;
-
-		/* make sure it is utf8 */
-		msg = g_filename_display_name (text);
 
-		set_statusbar (msg);
-		if (strcmp (text, "") != 0 )
-			set_glade_widget_sens("menu_treemap",TRUE);
+	set_glade_widget_sens("menu_treemap",FALSE);
+	if (parsename) {
+		set_statusbar (parsename);
+		if (strcmp (parsename, "") != 0)
+			set_glade_widget_sens("menu_treemap", TRUE);
 
-		g_free (msg);
-		g_free (text);
+		g_free (parsename);
 	}
 }
 
@@ -123,10 +116,10 @@
 	gtk_tree_model_get_iter (GTK_TREE_MODEL (baobab.model), &iter,
 				 path);
 	gtk_tree_model_get (GTK_TREE_MODEL (baobab.model), &iter,
-			    COL_H_FULLPATH, &baobab.selected_path, -1);
+			    COL_H_PARSENAME, &baobab.selected_path, -1);
 	
 	if (strcmp (baobab.selected_path, "") == 0) {
-		set_glade_widget_sens("menu_treemap",FALSE);
+		set_glade_widget_sens ("menu_treemap",FALSE);
 		gtk_tree_path_free (path);
 		return FALSE;
 	}
@@ -135,12 +128,7 @@
 	if (event->button == 3) {
 		GFile *file;
 
-		if (baobab.is_local) {
-			file = g_file_new_for_path (baobab.selected_path);
-		}
-		else {
-			file = g_file_new_for_uri (baobab.selected_path);
-		}
+		file = g_file_parse_name (baobab.selected_path);
 
 		popupmenu_list (path, event, can_trash_file (file));
 

Modified: trunk/baobab/src/baobab-treeview.h
==============================================================================
--- trunk/baobab/src/baobab-treeview.h	(original)
+++ trunk/baobab/src/baobab-treeview.h	Sat May  3 19:42:39 2008
@@ -29,7 +29,7 @@
 enum
 {
 	COL_DIR_NAME,
-	COL_H_FULLPATH,
+	COL_H_PARSENAME,
 	COL_H_PERC,
 	COL_DIR_SIZE,
 	COL_H_SIZE,
@@ -41,20 +41,6 @@
 	NUM_TREE_COLUMNS
 };
 
-/* search model columns */
-enum
-{
-	COL0_ICON,
-	COL1_STRING,
-	COL2_STRING,
-	COL_FULLPATH,
-	COL_LASTACCESS,
-	COL_SIZE,
-	COL_FILETYPE,
-	COL_OWNER,	
-	NUM_COLUMNS
-};
-
 GtkWidget *create_directory_treeview (void);
 void baobab_treeview_show_allocated_size (GtkWidget *tv, gboolean show_allocated);
 

Modified: trunk/baobab/src/baobab.c
==============================================================================
--- trunk/baobab/src/baobab.c	(original)
+++ trunk/baobab/src/baobab.c	Sat May  3 19:42:39 2008
@@ -290,7 +290,7 @@
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (baobab.tree_view), TRUE);
 	gtk_tree_store_set (baobab.model, &iter,
 			    COL_DIR_NAME, name,
-			    COL_H_FULLPATH, "",
+			    COL_H_PARSENAME, "",
 			    COL_H_ELEMENTS, -1, 
  			    COL_H_PERC, -1.0,
 			    COL_DIR_SIZE, str,
@@ -323,7 +323,7 @@
 	label = g_strdup_printf ("<i>%s</i>", _("Total filesystem usage:"));
 	gtk_tree_store_set (baobab.model, &firstiter,
 			    COL_DIR_NAME, label,
-			    COL_H_FULLPATH, "",
+			    COL_H_PARSENAME, "",
 			    COL_H_PERC, perc,
 			    COL_DIR_SIZE, size,
 			    COL_H_SIZE, g_fs.used,
@@ -376,8 +376,8 @@
 
 	gtk_tree_store_set (baobab.model, &iter,
 			    COL_DIR_NAME, name,
-			    COL_H_FULLPATH, data->dir,
-			    COL_H_PERC, -1.0, 
+			    COL_H_PARSENAME, data->parse_name,
+			    COL_H_PERC, -1.0,
 			    COL_DIR_SIZE,
 			    baobab.show_allocated ? alloc_size : size,
 			    COL_H_SIZE, data->size,
@@ -738,7 +738,7 @@
                                                   GTK_TREE_MODEL (baobab.model),
                                                   COL_DIR_NAME,
                                                   COL_DIR_SIZE,
-                                                  COL_H_FULLPATH,
+                                                  COL_H_PARSENAME,
                                                   COL_H_PERC,
                                                   COL_H_ELEMENTS,
                                                   NULL);

Modified: trunk/baobab/src/baobab.h
==============================================================================
--- trunk/baobab/src/baobab.h	(original)
+++ trunk/baobab/src/baobab.h	Sat May  3 19:42:39 2008
@@ -82,7 +82,7 @@
 	guint depth;
 	gint elements;
 	gchar *display_name;
-	gchar *dir;
+	gchar *parse_name;
 };
 
 /* globals */

Modified: trunk/baobab/src/callbacks.c
==============================================================================
--- trunk/baobab/src/callbacks.c	(original)
+++ trunk/baobab/src/callbacks.c	Sat May  3 19:42:39 2008
@@ -210,12 +210,7 @@
 	g_assert (!dummy);
 	g_assert (baobab.selected_path);
 
-	if (baobab.is_local) {
-		file = g_file_new_for_path (baobab.selected_path);
-	}
-	else {
-		file = g_file_new_for_uri (baobab.selected_path);
-	}
+	file = g_file_parse_name (baobab.selected_path);
 
 	if (!g_file_query_exists (file, NULL)) {
 		message (_("The document does not exist."), "",
@@ -234,7 +229,7 @@
 	baobab_graphwin_create (GTK_TREE_MODEL (baobab.model),
 				path_to_string,
 				BAOBAB_GLADE_FILE,
-				COL_H_FULLPATH,
+				COL_H_PARSENAME,
 				baobab.is_local ? COL_H_ALLOCSIZE : COL_H_SIZE,
 				-1);
 	g_free (path_to_string);
@@ -248,12 +243,7 @@
 	g_assert (!dummy);
 	g_assert (baobab.selected_path);
 
-	if (baobab.is_local) {
-		file = g_file_new_for_path (baobab.selected_path);
-	}
-	else {
-		file = g_file_new_for_uri (baobab.selected_path);
-	}
+	file = g_file_parse_name (baobab.selected_path);
 
 	if (trash_file (file)) {
 		GtkTreeIter iter;
@@ -408,9 +398,9 @@
 	g_assert (!dummy);
 	g_assert (baobab.selected_path);
 
-	file = g_file_new_for_uri (baobab.selected_path);
+	file = g_file_parse_name (baobab.selected_path);
 
-	if (!g_file_query_exists(file,NULL)) {
+	if (!g_file_query_exists (file, NULL)) {
 		message (_("The folder does not exist."), "", GTK_MESSAGE_INFO, baobab.window);
 	}
 



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