diff -uNr nautilus-2.6.1/src/file-manager/fm-tree-view.c nautilus-2.6.1.patch/src/file-manager/fm-tree-view.c --- nautilus-2.6.1/src/file-manager/fm-tree-view.c 2004-06-08 11:00:25.000000000 +0200 +++ nautilus-2.6.1.patch/src/file-manager/fm-tree-view.c 2004-06-22 13:48:30.000000000 +0200 @@ -1085,6 +1085,132 @@ 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"); g_free (home_uri); + + /* Hack start */ + + /* There can be two types of bookmarks : */ + /* ~/.nautilus-bookmarks : pipe separted list of item with format : */ + /* directory|alias name|icon name */ + /* It this file do not exists we use the default file */ + /* ~/.gtk-bookmarks which is just a list of directory */ + /* created by the new gtk file chooser (gtk+ >= 2.4) */ + + printf("Bookmark hack start"); + gboolean bookmarks_exist = TRUE; + gboolean nautilus_bookmarks = TRUE; + gchar *filename; + filename = g_build_filename (g_get_home_dir (),".nautilus-bookmarks", NULL); + if (!g_file_test (filename, G_FILE_TEST_EXISTS)) + { + nautilus_bookmarks = FALSE; + printf(".nautilus-bookmarks not found !"); + filename = g_build_filename (g_get_home_dir (),".gtk-bookmarks", NULL); + } + + if (!g_file_test (filename, G_FILE_TEST_EXISTS)) + { + bookmarks_exist = FALSE; + printf(".gtk-bookmarks not found !"); + } + + /* A bookmark was previously found, let's go ! */ + if (bookmarks_exist) + { + printf("Processing bookmark"); + gchar *contents; + if (g_file_get_contents (filename, &contents, NULL, NULL)) + { + /* Gets each line from filename */ + gchar **lines = g_strsplit (contents, "\n", -1); + int i; + + /* Hash table to memorize each bookmarked directory */ + GHashTable *table; + table = g_hash_table_new (g_str_hash, g_str_equal); + + /* Processing each lines */ + for (i = 0; lines[i]; i++) + { + printf("Found a new line"); + /* If we haven't already seen this line */ + if (!g_hash_table_lookup (table, lines[i])) + { + gchar *dir_uri = NULL; + gchar *dir_name = NULL; + gchar *dir_icon = NULL; + + /* Gets each part (uri,name and icon for directory) of the line because */ + /* we are in case of nautilus-bookmarks */ + /* For gtk-bookmarks auto set name and icon */ + /* If one part is missing we auto set it */ + if (nautilus_bookmarks) + { + /* Split the line */ + gchar **linesdatas = g_strsplit (lines[i], "|", -1); + + /* Is this a directory ? */ + if (g_file_test (linesdatas[0],G_FILE_TEST_IS_DIR)) + { + /* Directory uri */ + dir_uri=g_strdup(linesdatas[0]); + + /* Directory name */ + if (!linesdatas[1] || strlen(linesdatas[1])<1) + { + /* Problem with name, auto set name and icon */ + dir_name=g_path_get_basename(dir_uri); + dir_icon=g_strdup("gnome-folder"); + } + else + { + /* The name was found */ + dir_name=g_strdup(linesdatas[1]); + + /* Directory icon */ + if (!linesdatas[2] || strlen(linesdatas[2])<1) dir_icon=g_strdup("gnome-folder"); + else dir_icon=g_strdup(linesdatas[2]); + } + } + g_strfreev (linesdatas); + } + else + { + /* Removing the "file://" string beforce uri */ + gchar **linesdatas = g_strsplit (lines[i], "file://", -1); + + /* Is this a directory ? */ + if (g_file_test (linesdatas[1],G_FILE_TEST_IS_DIR)) + { + /* Directory uri */ + dir_uri=g_strdup(linesdatas[1]); + + /* Directory name */ + dir_name=g_path_get_basename(dir_uri); + + /* Directory icon */ + dir_icon=g_strdup("gnome-folder"); + } + g_strfreev (linesdatas); + } + + /* We have all we need so we had this to nautilus root tree */ + if (dir_uri && dir_name && dir_icon) + { + printf("Trying to add %s with uri %s and icon %s",dir_name,dir_uri,dir_icon); + fm_tree_model_add_root_uri (view->details->child_model, dir_uri, _(dir_name), dir_icon); + } + + /* Storing the line in hash table */ + g_hash_table_insert (table, lines[i], lines[i]); + + g_free (dir_uri); + g_free (dir_name); + g_free (dir_icon); + } + } + g_hash_table_destroy (table); + g_strfreev (lines); + } + g_free (contents); + } + else + { + printf("No bookmark !"); + } + g_free (filename); + printf("Bookmark hack end"); + + /* Hack end */ + fm_tree_model_add_root_uri (view->details->child_model, "file:///", _("Filesystem"), "gnome-fs-directory"); #ifdef NOT_YET_USABLE fm_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network Neighbourhood"), "gnome-fs-network");