Here's one more. This one patches Nautilus so that:
1) the Documents folder appears on the right
2) the Nautilus pathbar is consistent with the one from gtk+

This is mostly a preview, expect new versions of it to be posted
because I need to:
- make Nautilus show the right icon ("gnome-fs-documents") in the home
directory for the documents folder, so that the user can spot it
immediately.
- make it clean: separate the pathbar localization and the Documents
handling things.

Now, the gtk patch may be updated too, depending on the answers to the
following question:
- Is there anyone who understands why my Nautilus patch makes the
pathbar use the correct icon ("gnome-fs-documents", I made one to see
if my code works) and why the pathbar in gtk filechooser doesn't use
it ?
Furthermore, I'll need to modify the gnome-panel patch so that it uses
this icon too.

Anyway, if anyone has any advice to give me on the patch, or any
remark, please, feel free.

--
Alain Perry
--- nautilus-2.13.3.orig/src/nautilus-places-sidebar.c	2006-01-01 14:32:57.000000000 +0100
+++ nautilus-2.13.3/src/nautilus-places-sidebar.c	2006-01-01 14:41:21.000000000 +0100
@@ -136,7 +136,7 @@
 	GList 		      *volumes, *l;
 	GnomeVFSVolume 	      *volume;
 	int 		      bookmark_count, index;
-	char 		      *location, *icon, *mount_uri, *name, *desktop_path;
+	char 		      *location, *icon, *mount_uri, *name, *desktop_path, *documents_path;
 		
 	selection = gtk_tree_view_get_selection (sidebar->tree_view);
 	gtk_list_store_clear (sidebar->store);
@@ -147,19 +147,27 @@
 	desktop_path = nautilus_get_desktop_directory ();
 
 	if (strcmp (g_get_home_dir(), desktop_path) != 0) {
-		char *display_name;
-
 		mount_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
-		display_name = g_filename_display_basename (g_get_home_dir ());
 		last_iter = add_place (sidebar->store, PLACES_BUILT_IN,
-				       display_name, "gnome-fs-home", mount_uri);
- 		g_free (display_name);
+				       _("Home"), "gnome-fs-home", mount_uri);
 		if (strcmp (location, mount_uri) == 0) {
 			gtk_tree_selection_select_iter (selection, &last_iter);
 		}	
 		g_free (mount_uri);
 	}
 
+        documents_path = g_build_filename (g_get_home_dir (), "Documents", NULL);
+        if (g_file_test (documents_path, G_FILE_TEST_IS_DIR)) {
+                mount_uri = gnome_vfs_get_uri_from_local_path (documents_path);
+                last_iter = add_place (sidebar->store, PLACES_BUILT_IN,
+                                       _("Documents"), "gnome-fs-documents", mount_uri);
+                if (strcmp (location, mount_uri) == 0) {
+                        gtk_tree_selection_select_iter (selection, &last_iter);
+                }
+                g_free (mount_uri);
+        }
+        g_free (documents_path);
+
 	mount_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
 	last_iter = add_place (sidebar->store, PLACES_BUILT_IN,
 			       _("Desktop"), "gnome-fs-desktop", mount_uri);
--- nautilus-2.13.3.orig/src/nautilus-pathbar.h	2006-01-01 14:32:57.000000000 +0100
+++ nautilus-2.13.3/src/nautilus-pathbar.h	2006-01-01 14:08:49.000000000 +0100
@@ -41,10 +41,12 @@
 	char *root_path;
 	char *home_path;
 	char *desktop_path;
+        char *documents_path;
 
 	GdkPixbuf *root_icon;
 	GdkPixbuf *home_icon;
 	GdkPixbuf *desktop_icon;
+        GdkPixbuf *documents_icon;
 
 	GList *button_list;
 	GList *first_scrolled_button;
--- nautilus-2.13.3.orig/src/nautilus-pathbar.c	2006-01-01 14:32:57.000000000 +0100
+++ nautilus-2.13.3/src/nautilus-pathbar.c	2006-01-01 14:08:49.000000000 +0100
@@ -50,6 +50,7 @@
         ROOT_BUTTON,
         HOME_BUTTON,
         DESKTOP_BUTTON,
+        DOCUMENTS_BUTTON,
 	VOLUME_BUTTON
 } ButtonType;
 
@@ -66,6 +67,7 @@
 
 #define DEFAULT_ICON 		"gnome-fs-directory"
 #define DEFAULT_DESKTOP_ICON 	"gnome-fs-desktop"
+#define DEFAULT_DOCUMENTS_ICON 	"gnome-fs-documents"
 #define DEFAULT_HOME_ICON 	"gnome-fs-home"
 #define DEFAULT_FILESYSTEM_ICON	"gnome-dev-harddisk"
 
@@ -212,6 +214,7 @@
         path_bar->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
 
         path_bar->desktop_path = nautilus_get_desktop_directory_uri ();
+        path_bar->documents_path = gnome_vfs_get_uri_from_local_path (g_build_filename (g_get_home_dir (), "Documents", NULL));
 	path_bar->home_path = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
 	path_bar->root_path = g_strdup ("file:///");
 	desktop_is_home = (strcmp (path_bar->home_path, path_bar->desktop_path) == 0);
@@ -292,7 +295,11 @@
 		g_free (path_bar->desktop_path);
 		path_bar->desktop_path = NULL;
 	}
-
+        if (path_bar->documents_path) {
+                g_free (path_bar->documents_path);
+                path_bar->documents_path = NULL;
+        }
+        
 	if (path_bar->root_icon) {
 		g_object_unref (path_bar->root_icon);
 		path_bar->root_icon = NULL;
@@ -305,6 +312,10 @@
 		g_object_unref (path_bar->desktop_icon);
 		path_bar->desktop_icon = NULL;
 	}
+        if (path_bar->documents_icon) {
+                g_object_unref (path_bar->documents_icon);
+                path_bar->documents_icon = NULL;
+        }
 
         G_OBJECT_CLASS (nautilus_path_bar_parent_class)->finalize (object);
 }
@@ -916,6 +927,10 @@
                 g_object_unref (path_bar->desktop_icon);
                 path_bar->desktop_icon = NULL;
         }
+        if (path_bar->documents_icon) {
+                g_object_unref (path_bar->documents_icon);
+                path_bar->documents_icon = NULL;
+        }
 
 
         for (list = path_bar->button_list; list; list = list->next) {
@@ -1102,6 +1117,24 @@
 			g_free (icon_name);
       			return path_bar->desktop_icon;
 
+                case DOCUMENTS_BUTTON:
+                        if (path_bar->documents_icon != NULL) {
+                                return path_bar->documents_icon;
+                        }
+                        icon_name = get_icon_name_for_file_path (path_bar->documents_path);
+                        if (strcmp (icon_name, DEFAULT_ICON) == 0) {
+                                path_bar->documents_icon = nautilus_icon_factory_get_pixbuf_from_name (DEFAULT_DOCUMENTS_ICON,
+                                                                                               NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
+                                                                                               TRUE, NULL);
+                        } else {
+                                path_bar->documents_icon = nautilus_icon_factory_get_pixbuf_from_name (icon_name,
+                                                                                            NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
+                                                                                            TRUE, NULL);
+                        }
+
+                        g_free (icon_name);
+                        return path_bar->documents_icon;
+
 	    	default:
                        return NULL;
         }
@@ -1123,11 +1156,21 @@
 static const char *
 get_dir_name (ButtonData *button_data)
 {
-        if (button_data->type == DESKTOP_BUTTON || (button_data->type == HOME_BUTTON && desktop_is_home)) {
-		return _("Desktop");
-	} else {
-		return button_data->dir_name;
-	}
+        switch (button_data->type)
+        {
+                case HOME_BUTTON:
+                        if (desktop_is_home)
+                                return _("Desktop");
+                        else
+                                return _("Home");
+                case DESKTOP_BUTTON:
+                        return _("Desktop");
+                case DOCUMENTS_BUTTON:
+                        return _("Documents");
+                default:
+                        return button_data->dir_name;
+        }
+        return button_data->dir_name;
 }
 
 /* We always want to request the same size for the label, whether
@@ -1283,6 +1326,9 @@
 			return NORMAL_BUTTON;
 		}
 	}
+        if (path_bar->documents_path != NULL && is_file_path_equal (path, path_bar->documents_path)) {
+                return DOCUMENTS_BUTTON;
+        }
 	if (is_file_path_mounted_volume (path, button_data)) {
 		return VOLUME_BUTTON;
 	}	
@@ -1345,6 +1391,7 @@
                         break;
                 case HOME_BUTTON:
                 case DESKTOP_BUTTON:
+                case DOCUMENTS_BUTTON:
 		case VOLUME_BUTTON:
                         button_data->image = gtk_image_new ();
                         button_data->label = gtk_label_new (NULL);
-- 
ubuntu-desktop mailing list
[email protected]
http://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop

Reply via email to