Re: [PATCH] - New sidepanel plug-in for Gtk bookmarks and places




Alexander Larsson wrote:
The behavour you want for the places part of the tree sidebar is:
* separator between the roots and the shortcuts
* Allow expansion of tree sidebars
* But, don't consider them "roots" when auto-expanding due to a location
change.
* Allow dnd of folders to the empty part of the sidebar, meaning "add
bookmark"

The main problem I can see with using the tree sidebar as a places
sidebar is that the tree auto-expands when you navigate the tree, thus
the shortcuts are almost always scrolled out of view.

yes I noticed!


I can see two main ways to solve this:
* Add a preference about auto-expansion on location change. (This really
makes sense as a preference, because it works with the way some use the
tree, but not with others.) It also solves a similar issue with the
auto-expansion of the tree hiding the mounted volumes below.

Not sure about that. I only use the tree view for navigating deep hierarchies and in those case I would want it to auto-expand. Having to goto prefs and constantly change the setting would be irritating.

* Somehow split into two trees and pack the trees such that expanding
something in the volumes part never totally hides the shortcut part of
the tree.
I tried to figure out a way to do this, and it may be possible if you
have a custom container widget for the splitting and a slightly
customized GtkScrolledWindow that size_requests the full height of the
child. However, its not obvious how the splitting up should work (i.e.
in the case of both trees being tall, how should we split? 50% each?)
Another way would be to put the trees in a vpane and let the user change
the relative sizes.

vpane makes more sense IMO - user gets to control it but the tree view already suffers from lack of space anyway so this will just make it worse. Still it offers a way to split out the tree view from the places if the lower pane always shows the hierarchical tree for the current location (without any places) and the upper pane just the non-expandable places and volumes.


I'm not sure this two-tree splitting is better than having it all in one
big tree. It gives you less prefs, and works for everyones use habits
without having to mess with prefs, but it uses more space, and you can't
get as much space for one of the trees as you can in the one-tree case.

Too true!


OSX seems to go with the one-tree model, but then they don't allow the
trees to be expanded, and especially, they don't auto expand them. The
way they resize the shortcuts depending on how many there are makes it
clear that they assume there isn't gonna be a lot of them.

They and GtkFileChooser went that way based on ease of use (AFAIK). I appreciate power users want trees and I feel Thunar gets it right in its approach. They have two toolbar buttons for tree and shortcuts so you can flick between both easily. Their tree view only shows the tree for the current path and has no "places" as such so for them it makes sense to separate the two and the result is a much cleaner interface. So a third way might be to do likewise? (IE strip the places/volumes from the treeview and either use my separate places sidebar or add a toolbar to the current treeview to switch between the two or use dual panes as above?)


Maybe we could experiment a bit with the two approaches.

I've already added them to the single tree view and Im suffering problems. At the moment the sort function "compare_rows" in fm-tree-view.c jumbles up all my bookmarks and volumes into a right mess (they are correctly inserted if I disable that function). I cant figure out why as that function skips sorting root nodes...(patch attached - let me know if you have an idea or feel free to extend if you want to experiment).

I would be happier experimenting with one of the third ways I mentioned above as I dont think theres much mileage in the one big tree approach to be frank.

jamie.
Index: src/file-manager/fm-tree-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-tree-view.c,v
retrieving revision 1.12
diff -u -r1.12 fm-tree-view.c
--- src/file-manager/fm-tree-view.c	20 Jun 2005 08:43:46 -0000	1.12
+++ src/file-manager/fm-tree-view.c	29 Jun 2005 17:42:49 -0000
@@ -34,6 +34,7 @@
 
 #include "fm-tree-model.h"
 #include "fm-properties-window.h"
+#include "../nautilus-bookmark-list.h"
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-preferences.h>
 #include <eel/eel-string.h>
@@ -119,6 +120,8 @@
 
 static GdkAtom copied_files_atom;
 
+static NautilusBookmarkList *bookmarks;
+
 enum {
 	GNOME_COPIED_FILES
 };
@@ -1220,28 +1223,50 @@
 	GtkCellRenderer *cell;
 	GtkTreeViewColumn *column;
 	GnomeVFSVolumeMonitor *volume_monitor;
-	char *home_uri;
+	char *home_uri, *file_path, *mount_uri, *name, *icon_name;
 	GList *volumes, *l;
 	char *location;
+	NautilusBookmark *bookmark;
+	int bookmark_count, bookmark_index;
+	NautilusFile *file;
 	
 	view->details->child_model = fm_tree_model_new ();
 	view->details->sort_model = GTK_TREE_MODEL_SORT
 		(gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (view->details->child_model)));
 	view->details->tree_widget = GTK_TREE_VIEW
 		(gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->details->sort_model)));
+
 	g_object_unref (view->details->sort_model);
 	g_signal_connect_object
 		(view->details->child_model, "row_loaded",
 		 G_CALLBACK (row_loaded_callback),
 		 view, G_CONNECT_AFTER);
+
+	file_path = g_build_filename (g_get_home_dir (), "Documents", NULL);
+	if (g_file_test (file_path, G_FILE_TEST_IS_DIR)) {
+		mount_uri = gnome_vfs_get_uri_from_local_path (file_path);
+		fm_tree_model_add_root_uri (view->details->child_model, mount_uri, _("Documents"), "gnome-fs-directory", NULL);
+		g_free (mount_uri);
+	}
+	g_free (file_path);
+
 	home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-	fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), "gnome-home", NULL);
+	fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home"), "gnome-home", NULL);
 	g_free (home_uri);
-	fm_tree_model_add_root_uri (view->details->child_model, "file:///", _("Filesystem"), "gnome-fs-directory", NULL);
+	fm_tree_model_add_root_uri (view->details->child_model, "file:///", _("Filesystem"), "gnome-fs-blockdev", NULL);
 #ifdef NOT_YET_USABLE
 	fm_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network Neighbourhood"), "gnome-fs-network", NULL);
 #endif
 	
+	file_path = g_build_filename (g_get_home_dir (), "Desktop", NULL);
+	if (g_file_test (file_path, G_FILE_TEST_IS_DIR)) {
+		mount_uri = gnome_vfs_get_uri_from_local_path (file_path);
+		fm_tree_model_add_root_uri (view->details->child_model, mount_uri, _("Desktop"), "gnome-fs-desktop", NULL);
+		g_free (mount_uri);
+	}
+	g_free (file_path);
+	
+
 	volume_monitor = gnome_vfs_get_volume_monitor ();
 	volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
 	for (l = volumes; l != NULL; l = l->next) {
@@ -1249,6 +1274,26 @@
 		gnome_vfs_volume_unref (l->data);
 	}
 	g_list_free (volumes);
+
+	bookmark_count = nautilus_bookmark_list_length (bookmarks);
+	for (bookmark_index = 0; bookmark_index < bookmark_count; ++bookmark_index) {
+		bookmark = nautilus_bookmark_list_item_at (bookmarks, bookmark_index),
+		mount_uri = nautilus_bookmark_get_uri (bookmark);
+		name = nautilus_bookmark_get_name (bookmark);
+		file = nautilus_file_get (mount_uri);
+		icon_name = NULL;
+		if (nautilus_icon_factory_is_icon_ready_for_file (file)) {
+			icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
+		}
+		nautilus_file_unref (file);
+		if (!icon_name) {
+			icon_name = g_strdup ("gnome-fs-directory");
+		}
+		fm_tree_model_add_root_uri (view->details->child_model, mount_uri, name, icon_name, NULL);
+		g_free (mount_uri);		
+		g_free (name);
+		g_free (icon_name);
+	}
 	
 	g_signal_connect_object (volume_monitor, "volume_mounted",
 				 G_CALLBACK (volume_mounted_callback), view, 0);
@@ -1293,8 +1338,8 @@
 	gtk_tree_view_column_pack_start (column, cell, TRUE);
 	gtk_tree_view_column_set_attributes (column, cell,
 					     "text", FM_TREE_MODEL_DISPLAY_NAME_COLUMN,
-					     "style", FM_TREE_MODEL_FONT_STYLE_COLUMN,
-					     "weight", FM_TREE_MODEL_FONT_WEIGHT_COLUMN,
+					//     "style", FM_TREE_MODEL_FONT_STYLE_COLUMN,
+					//     "weight", FM_TREE_MODEL_FONT_WEIGHT_COLUMN,
 					     NULL);
 
 	gtk_tree_view_append_column (view->details->tree_widget, column);
@@ -1519,7 +1564,7 @@
 	char *location;
 	
 	sidebar->details->window = window;
-
+	bookmarks = nautilus_window_info_get_bookmark_list (window);
 	g_signal_connect_object (window, "loading_uri",
 				 G_CALLBACK (loading_uri_callback), sidebar, 0);
 	location = nautilus_window_info_get_current_location (window);
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.449
diff -u -r1.449 nautilus-window.c
--- src/nautilus-window.c	23 Jun 2005 14:16:59 -0000	1.449
+++ src/nautilus-window.c	29 Jun 2005 17:42:52 -0000
@@ -32,6 +32,7 @@
 
 #include "nautilus-actions.h"
 #include "nautilus-application.h"
+#include "nautilus-bookmark-list.h"
 #include "nautilus-bookmarks-window.h"
 #include "nautilus-information-panel.h"
 #include "nautilus-main.h"
@@ -1385,6 +1386,12 @@
 			       mode);
 }
 
+static NautilusBookmarkList *
+nautilus_window_get_bookmark_list (NautilusWindow *window)
+{
+  return nautilus_get_bookmark_list ();
+}
+
 static void
 nautilus_window_info_iface_init (NautilusWindowInfoIface *iface)
 {
@@ -1399,6 +1406,7 @@
 	iface->get_window_type = nautilus_window_get_window_type;
 	iface->get_title = nautilus_window_get_cached_title;
 	iface->get_history = nautilus_window_get_history;
+	iface->get_bookmark_list = nautilus_window_get_bookmark_list;
 	iface->get_current_location = nautilus_window_get_location;
 	iface->get_ui_manager = nautilus_window_get_ui_manager;
 	iface->get_selection_count = nautilus_window_get_selection_count;
Index: libnautilus-private/nautilus-window-info.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-window-info.c,v
retrieving revision 1.3
diff -u -r1.3 nautilus-window-info.c
--- libnautilus-private/nautilus-window-info.c	22 Mar 2005 09:22:22 -0000	1.3
+++ libnautilus-private/nautilus-window-info.c	29 Jun 2005 17:42:53 -0000
@@ -217,6 +217,15 @@
 	return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_history) (window);
 }
 
+NautilusBookmarkList *
+nautilus_window_info_get_bookmark_list (NautilusWindowInfo *window)
+{
+	g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NULL);
+	
+	return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_bookmark_list) (window);
+}
+
+
 char *
 nautilus_window_info_get_current_location (NautilusWindowInfo *window)
 {
Index: libnautilus-private/nautilus-window-info.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-window-info.h,v
retrieving revision 1.3
diff -u -r1.3 nautilus-window-info.h
--- libnautilus-private/nautilus-window-info.h	22 Mar 2005 09:22:22 -0000	1.3
+++ libnautilus-private/nautilus-window-info.h	29 Jun 2005 17:42:53 -0000
@@ -28,6 +28,7 @@
 #include <glib-object.h>
 #include <libnautilus-private/nautilus-view.h>
 #include <gtk/gtkuimanager.h>
+#include "../src/nautilus-bookmark-list.h"
 
 G_BEGIN_DECLS
 
@@ -115,6 +116,8 @@
 					  const char *status);
 	char * (* get_title)             (NautilusWindowInfo *window);
 	GList *(* get_history)           (NautilusWindowInfo *window);
+	NautilusBookmarkList *  
+	       (* get_bookmark_list)     (NautilusWindowInfo *window);
 	NautilusWindowType
 	       (* get_window_type)       (NautilusWindowInfo *window);
 	NautilusWindowShowHiddenFilesMode
@@ -152,6 +155,7 @@
 NautilusWindowType                nautilus_window_info_get_window_type          (NautilusWindowInfo                *window);
 char *                            nautilus_window_info_get_title                (NautilusWindowInfo                *window);
 GList *                           nautilus_window_info_get_history              (NautilusWindowInfo                *window);
+NautilusBookmarkList *		  nautilus_window_info_get_bookmark_list        (NautilusWindowInfo                *window);
 char *                            nautilus_window_info_get_current_location     (NautilusWindowInfo                *window);
 int                               nautilus_window_info_get_selection_count      (NautilusWindowInfo                *window);
 GList *                           nautilus_window_info_get_selection            (NautilusWindowInfo                *window);


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