Commit 0653c1cc authored by John Sullivan's avatar John Sullivan
Browse files

Made bookmarks display just file/directory name (instead of path) by default;

made history items appear in Go menu.
parent aa304686
2000-02-18 John Sullivan <sullivan@eazel.com>
Made bookmarks (including in history list) for file system
items display just the name of the file or directory instead
of the entire path. Made history list appear in Go menu.
Still need to muck with CORBA so that history metaview is
getting the history list from Nautilus rather than
maintaining its own parallel copy.
* libnautilus/nautilus-bookmark.h:
(nautilus_bookmark_new_with_name): Renamed this function, which
takes both a uri and a display name, from nautilus_bookmark_new.
(nautilus_bookmark_new): New function, takes just a uri.
* libnautilus/nautilus-bookmark.c:
(nautilus_boookmark_new_with_name): Renamed.
(nautilus_bookmark_new): New function, determines what initial
name to use for a bookmark given its uri. Right now the only rule
it knows is to use just the leaf file/directory name for file
system uris. (Someday it should also know to get the page title
for web uris.)
* libnautilus/nautilus-bookmark.c,
* components/history/ntl-history-view.c,
* src/nautilus-bookmarklist.c,
* src/nautilus-bookmarks-menu.c,
* src/nautilus-bookmarks-window.c,
* src/ntl-window-msgs.c:
Updated callers of old nautilus_bookmark_new to either use new
one-parameter version or to use nautilus_bookmark_new_with_name.
* libnautilus/nautilus-directory.c: (nautilus_self_check_directory):
Added new test that catches gnome-vfs bug I ran into where the name
computed for uris with a trailing slash is "". Maciej plans to fix
this in gnome-vfs; for now, make check catches it.
* src/nautilus-signaller.c,
* src/nautilus-signaller.h: New files for an object that manages
nautilus-wide signals (not associated with a particular window, e.g.).
The initial nautilus-wide signal is "history_list_changed".
* src/Makefile.am: Build these two new files.
* src/ntl-window.h:
Removed window_signals from NautilusWindowClass struct, made it a static
variable in the file to better hide it and match existing practice;
Added go_menu and go_menu_separator_item widgets to the set maintained
for each window. (This will have to change when I convert the menus
to using BonoboUIHandler, but that's for another day.)
* src/ntl-window.c:
I added then later removed a signal to this class. In the process, I
cleaned up some of the signal-handling details: Added an enum for
signal names (currently only LAST_SIGNAL); moved array of signals to
a static variable instead of field in Class struct; used LAST_SIGNAL
instead of 0 in (nautilus_window_class_init).
Added static history_list variable. Perhaps this and related functions
belong in their own file.
(nautilus_add_to_history_list): New function, updates global history
list and emits "history_list_changed" signal.
(clear_go_menu_history): New function, erase all the bookmark menu
items from the Go menu.
(activate_bookmark_in_menu_item): New function, go to the uri in the
bookmark stored as user data in the given menu item.
(history_list_changed_cb): New function, updates history section of
Go menu.
(nautilus_window_init): Connect history_list_changed_cb to
"history_list_changed" signal of nautilus_signaller object.
(nautilus_window_constructed): Stores away pointers to Go menu and
separator between static & dynamic parts of this menu.
* src/ntl-window-private.h: (nautilus_add_to_history_list): Prototype
for new function.
* src/ntl-window-msgs.c: (nautilus_window_update_internals): Call
nautilus_add_to_history_list with the new uri.
2000-02-17 Andy Hertzfeld <andy@eazel.com>
improved index panel command buttons. There's still a problem with the button box removal, though.
......
......@@ -99,7 +99,7 @@ hyperbola_navigation_history_notify_location_change (NautilusViewFrame *view,
clist = hview->clist;
gtk_clist_freeze(clist);
bookmark = nautilus_bookmark_new (loci->requested_uri, loci->requested_uri);
bookmark = nautilus_bookmark_new (loci->requested_uri);
/* If a bookmark for this location was already in list, remove it
* (no duplicates in list, new one goes at top)
......
......@@ -99,7 +99,7 @@ hyperbola_navigation_history_notify_location_change (NautilusViewFrame *view,
clist = hview->clist;
gtk_clist_freeze(clist);
bookmark = nautilus_bookmark_new (loci->requested_uri, loci->requested_uri);
bookmark = nautilus_bookmark_new (loci->requested_uri);
/* If a bookmark for this location was already in list, remove it
* (no duplicates in list, new one goes at top)
......
......@@ -24,6 +24,10 @@
#include "nautilus-bookmark.h"
#include "nautilus-icon-factory.h"
#include "nautilus-string.h"
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
struct _NautilusBookmarkDetails
{
......@@ -153,9 +157,9 @@ nautilus_bookmark_copy (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return nautilus_bookmark_new(
nautilus_bookmark_get_name(bookmark),
nautilus_bookmark_get_uri(bookmark));
return nautilus_bookmark_new_with_name(
nautilus_bookmark_get_uri(bookmark),
nautilus_bookmark_get_name(bookmark));
}
const gchar *
......@@ -207,8 +211,18 @@ nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
return bookmark->details->uri;
}
/**
* nautilus_bookmark_new_with_name:
*
* Create a new NautilusBookmark from a text uri and a display name.
* @uri: Any uri, even a malformed or non-existent one.
* @name: A string to display to the user as the bookmark's name.
*
* Return value: A newly allocated NautilusBookmark.
*
**/
NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
nautilus_bookmark_new_with_name (const gchar *uri, const gchar *name)
{
NautilusBookmark *new_bookmark;
......@@ -220,6 +234,55 @@ nautilus_bookmark_new (const gchar *name, const gchar *uri)
return new_bookmark;
}
/**
* nautilus_bookmark_new:
*
* Create a new NautilusBookmark from just a text uri.
* @uri: Any uri, even a malformed or non-existent one.
*
* Return value: A newly allocated NautilusBookmark, whose display
* name is chosen using default rules based on the uri.
*
**/
NautilusBookmark *
nautilus_bookmark_new (const gchar *uri)
{
/* Use default rules to determine the displayed name */
NautilusBookmark *result;
GnomeVFSURI *vfs_uri;
result = NULL;
/* For now, the only default rule is to use the file/directory name
* rather than the whole path. */
/* FIXME: This needs to do better (use just file names for file:// urls,
* use page names for http://, etc.)
*/
vfs_uri = gnome_vfs_uri_new (uri);
if (vfs_uri != NULL)
{
if (strcmp (vfs_uri->method_string, "file") == 0)
{
gchar *short_name;
short_name = gnome_vfs_uri_extract_short_name (vfs_uri);
result = nautilus_bookmark_new_with_name (uri, short_name);
g_free (short_name);
}
gnome_vfs_uri_unref (vfs_uri);
}
if (result == NULL)
{
result = nautilus_bookmark_new_with_name (uri, uri);
}
return result;
}
static GtkWidget *
create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
{
......@@ -242,7 +305,7 @@ create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
*
* Return a menu item representing a bookmark.
* @bookmark: The bookmark the menu item represents.
* Return value: A newly-created bookmark.
* Return value: A newly-created bookmark, not yet shown.
**/
GtkWidget *
nautilus_bookmark_menu_item_new (const NautilusBookmark *bookmark)
......
......@@ -54,12 +54,13 @@ struct _NautilusBookmarkClass {
typedef struct _NautilusBookmarkClass NautilusBookmarkClass;
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new (const gchar *name,
const gchar *uri);
NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new_with_name (const gchar *uri,
const gchar *name);
NautilusBookmark *nautilus_bookmark_new (const gchar *uri);
NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b);
......
......@@ -1922,6 +1922,14 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
file_1 = nautilus_file_get ("file:///home/");
NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
file_1 = nautilus_file_get ("file:///home");
NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
/* sorting */
file_1 = nautilus_file_get ("file:///etc");
file_2 = nautilus_file_get ("file:///usr");
......@@ -1932,6 +1940,9 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
nautilus_file_unref (file_1);
nautilus_file_unref (file_2);
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
......@@ -24,6 +24,10 @@
#include "nautilus-bookmark.h"
#include "nautilus-icon-factory.h"
#include "nautilus-string.h"
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
struct _NautilusBookmarkDetails
{
......@@ -153,9 +157,9 @@ nautilus_bookmark_copy (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return nautilus_bookmark_new(
nautilus_bookmark_get_name(bookmark),
nautilus_bookmark_get_uri(bookmark));
return nautilus_bookmark_new_with_name(
nautilus_bookmark_get_uri(bookmark),
nautilus_bookmark_get_name(bookmark));
}
const gchar *
......@@ -207,8 +211,18 @@ nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
return bookmark->details->uri;
}
/**
* nautilus_bookmark_new_with_name:
*
* Create a new NautilusBookmark from a text uri and a display name.
* @uri: Any uri, even a malformed or non-existent one.
* @name: A string to display to the user as the bookmark's name.
*
* Return value: A newly allocated NautilusBookmark.
*
**/
NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
nautilus_bookmark_new_with_name (const gchar *uri, const gchar *name)
{
NautilusBookmark *new_bookmark;
......@@ -220,6 +234,55 @@ nautilus_bookmark_new (const gchar *name, const gchar *uri)
return new_bookmark;
}
/**
* nautilus_bookmark_new:
*
* Create a new NautilusBookmark from just a text uri.
* @uri: Any uri, even a malformed or non-existent one.
*
* Return value: A newly allocated NautilusBookmark, whose display
* name is chosen using default rules based on the uri.
*
**/
NautilusBookmark *
nautilus_bookmark_new (const gchar *uri)
{
/* Use default rules to determine the displayed name */
NautilusBookmark *result;
GnomeVFSURI *vfs_uri;
result = NULL;
/* For now, the only default rule is to use the file/directory name
* rather than the whole path. */
/* FIXME: This needs to do better (use just file names for file:// urls,
* use page names for http://, etc.)
*/
vfs_uri = gnome_vfs_uri_new (uri);
if (vfs_uri != NULL)
{
if (strcmp (vfs_uri->method_string, "file") == 0)
{
gchar *short_name;
short_name = gnome_vfs_uri_extract_short_name (vfs_uri);
result = nautilus_bookmark_new_with_name (uri, short_name);
g_free (short_name);
}
gnome_vfs_uri_unref (vfs_uri);
}
if (result == NULL)
{
result = nautilus_bookmark_new_with_name (uri, uri);
}
return result;
}
static GtkWidget *
create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
{
......@@ -242,7 +305,7 @@ create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
*
* Return a menu item representing a bookmark.
* @bookmark: The bookmark the menu item represents.
* Return value: A newly-created bookmark.
* Return value: A newly-created bookmark, not yet shown.
**/
GtkWidget *
nautilus_bookmark_menu_item_new (const NautilusBookmark *bookmark)
......
......@@ -54,12 +54,13 @@ struct _NautilusBookmarkClass {
typedef struct _NautilusBookmarkClass NautilusBookmarkClass;
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new (const gchar *name,
const gchar *uri);
NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new_with_name (const gchar *uri,
const gchar *name);
NautilusBookmark *nautilus_bookmark_new (const gchar *uri);
NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b);
......
......@@ -1922,6 +1922,14 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
file_1 = nautilus_file_get ("file:///home/");
NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
file_1 = nautilus_file_get ("file:///home");
NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
/* sorting */
file_1 = nautilus_file_get ("file:///etc");
file_2 = nautilus_file_get ("file:///usr");
......@@ -1932,6 +1940,9 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
nautilus_file_unref (file_1);
nautilus_file_unref (file_2);
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
......@@ -24,6 +24,10 @@
#include "nautilus-bookmark.h"
#include "nautilus-icon-factory.h"
#include "nautilus-string.h"
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
struct _NautilusBookmarkDetails
{
......@@ -153,9 +157,9 @@ nautilus_bookmark_copy (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return nautilus_bookmark_new(
nautilus_bookmark_get_name(bookmark),
nautilus_bookmark_get_uri(bookmark));
return nautilus_bookmark_new_with_name(
nautilus_bookmark_get_uri(bookmark),
nautilus_bookmark_get_name(bookmark));
}
const gchar *
......@@ -207,8 +211,18 @@ nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
return bookmark->details->uri;
}
/**
* nautilus_bookmark_new_with_name:
*
* Create a new NautilusBookmark from a text uri and a display name.
* @uri: Any uri, even a malformed or non-existent one.
* @name: A string to display to the user as the bookmark's name.
*
* Return value: A newly allocated NautilusBookmark.
*
**/
NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
nautilus_bookmark_new_with_name (const gchar *uri, const gchar *name)
{
NautilusBookmark *new_bookmark;
......@@ -220,6 +234,55 @@ nautilus_bookmark_new (const gchar *name, const gchar *uri)
return new_bookmark;
}
/**
* nautilus_bookmark_new:
*
* Create a new NautilusBookmark from just a text uri.
* @uri: Any uri, even a malformed or non-existent one.
*
* Return value: A newly allocated NautilusBookmark, whose display
* name is chosen using default rules based on the uri.
*
**/
NautilusBookmark *
nautilus_bookmark_new (const gchar *uri)
{
/* Use default rules to determine the displayed name */
NautilusBookmark *result;
GnomeVFSURI *vfs_uri;
result = NULL;
/* For now, the only default rule is to use the file/directory name
* rather than the whole path. */
/* FIXME: This needs to do better (use just file names for file:// urls,
* use page names for http://, etc.)
*/
vfs_uri = gnome_vfs_uri_new (uri);
if (vfs_uri != NULL)
{
if (strcmp (vfs_uri->method_string, "file") == 0)
{
gchar *short_name;
short_name = gnome_vfs_uri_extract_short_name (vfs_uri);
result = nautilus_bookmark_new_with_name (uri, short_name);
g_free (short_name);
}
gnome_vfs_uri_unref (vfs_uri);
}
if (result == NULL)
{
result = nautilus_bookmark_new_with_name (uri, uri);
}
return result;
}
static GtkWidget *
create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
{
......@@ -242,7 +305,7 @@ create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
*
* Return a menu item representing a bookmark.
* @bookmark: The bookmark the menu item represents.
* Return value: A newly-created bookmark.
* Return value: A newly-created bookmark, not yet shown.
**/
GtkWidget *
nautilus_bookmark_menu_item_new (const NautilusBookmark *bookmark)
......
......@@ -54,12 +54,13 @@ struct _NautilusBookmarkClass {
typedef struct _NautilusBookmarkClass NautilusBookmarkClass;
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new (const gchar *name,
const gchar *uri);
NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new_with_name (const gchar *uri,
const gchar *name);
NautilusBookmark *nautilus_bookmark_new (const gchar *uri);
NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b);
......
......@@ -1922,6 +1922,14 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
file_1 = nautilus_file_get ("file:///home/");
NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
file_1 = nautilus_file_get ("file:///home");
NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
/* sorting */
file_1 = nautilus_file_get ("file:///etc");
file_2 = nautilus_file_get ("file:///usr");
......@@ -1932,6 +1940,9 @@ nautilus_self_check_directory (void)
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) < 0, TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort_reversed (file_1, file_2, NAUTILUS_FILE_SORT_BY_NAME) > 0, TRUE);
NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_compare_for_sort (file_1, file_1, NAUTILUS_FILE_SORT_BY_NAME) == 0, TRUE);
nautilus_file_unref (file_1);
nautilus_file_unref (file_2);
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
......@@ -34,6 +34,8 @@ nautilus_SOURCES= \
nautilus-index-title.h \
nautilus-self-check-functions.c \
nautilus-self-check-functions.h \
nautilus-signaller.c \
nautilus-signaller.h \
nautilus-zoom-control.c \
nautilus-zoom-control.h \
ntl-app.c \
......
......@@ -375,7 +375,7 @@ nautilus_bookmarklist_load_file (NautilusBookmarklist *bookmarks)
bookmarks->list = g_list_append(
bookmarks->list,
nautilus_bookmark_new(xml_name, xml_uri));
nautilus_bookmark_new_with_name (xml_uri, xml_name));
xmlFree (xml_name);
xmlFree (xml_uri);
......
......@@ -108,8 +108,7 @@ add_bookmark_cb(GtkMenuItem* item, gpointer func_data)
current_uri = nautilus_window_get_requested_uri(bookmarks_menu->window);
/* FIXME: initial name should be extracted from http document title (e.g.) */
bookmark = nautilus_bookmark_new(current_uri, current_uri);
bookmark = nautilus_bookmark_new(current_uri);
if (!nautilus_bookmarklist_contains(bookmarks, bookmark))
{
......
......@@ -468,9 +468,9 @@ on_text_field_focus_out_event (GtkWidget *widget,
g_assert(GTK_IS_ENTRY(name_field));
g_assert(GTK_IS_ENTRY(uri_field));
bookmark = nautilus_bookmark_new(
gtk_entry_get_text(GTK_ENTRY(name_field)),
gtk_entry_get_text(GTK_ENTRY(uri_field)));
bookmark = nautilus_bookmark_new_with_name (
gtk_entry_get_text(GTK_ENTRY(uri_field)),
gtk_entry_get_text(GTK_ENTRY(name_field)));
selected_row = get_selected_row();
/* turn off list updating 'cuz otherwise the list-reordering code runs
......
......@@ -31,19 +31,32 @@
#include <math.h>
#include "nautilus.h"
#include "nautilus-bookmarks-menu.h"
#include "nautilus-signaller.h"