Commit fc3d3932 authored by John Sullivan's avatar John Sullivan

Made location-entering field handle bogus URIs better.

parent 78860f9f
2000-01-04 John Sullivan <sullivan@eazel.com>
Made location-entering field handle bogus URIs better
(next: bookmarks)
* libnautilus/nautilus-uri-utilities.c: new file
* libnautilus/nautilus-uri-utilities.h: new file
At this point there's just one uri utility function,
nautilus_path_known_not_to_exist(), which is a quick
check for a bogus URI. (It's not guaranteed to return
TRUE for all bad URIs, just the ones it can tell quickly
are bogus).
* libnautilus/Makefile.am: added these two new files
to the build, and linked with GnomeVFS (needed for new
function)
* src/ntl-window.c: (nautilus_window_goto_uri_cb):
If typed path can quickly be rejected, puts an error
message in the status bar and doesn't try to go there.
* components/websearch/.cvsignore: added Makefile
2000-01-03 Maciej Stachowiak <mjs@eazel.com>
* idl/nautilus.idl: Added stop_location_change method to NautilusView interface.
......
lib_LTLIBRARIES=libnautilus.la
INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOME_CFLAGS) $(GNORBA_CFLAGS) $(WERROR)
INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
$(GNOME_CFLAGS) \
$(GNORBA_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(VFS_CFLAGS) \
$(WERROR)
nautilus_idl_sources=nautilus-stubs.c nautilus-skels.c nautilus.h nautilus-common.c
fsextension_idl_sources=fsextension-stubs.c fsextension-skels.c fsextension-common.c fsextension.h
......@@ -19,6 +24,7 @@ libnautilusinclude_HEADERS= \
gtkscrollframe.h \
nautilus.h \
nautilus-file-utilities.h \
nautilus-uri-utilities.h \
ntl-content-view-client.h \
ntl-meta-view-client.h \
ntl-view-client.h
......@@ -31,12 +37,16 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gtkflist.c \
gtkscrollframe.c \
nautilus-file-utilities.c \
nautilus-uri-utilities.c \
ntl-content-view-client.c \
ntl-meta-view-client.c \
ntl-view-client.c \
$(fsextension_idl_sources)
libnautilus_la_LDFLAGS=$(GNOME_LIBS) $(GNORBA_LIBS) $(GDK_PIXBUF_LIBS)
libnautilus_la_LDFLAGS=$(GNOME_LIBS) \
$(GNORBA_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(VFS_LIBS)
$(nautilus_idl_sources): nautilus_idl_stamp
$(fsextension_idl_sources): fsextension_idl_stamp
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-uri-utilities..c - implementation of uri manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#include "nautilus-uri-utilities.h"
#include <libgnomevfs/gnome-vfs.h>
/**
* nautilus_path_known_not_to_exist:
*
* Check whether a uri represents a path known in advance not to exist.
* A return value of FALSE does not guarantee that the path is valid,
* but a return value of TRUE does guarantee that the path is not valid.
* Use this to make quick rejection decisions.
* @uri: The uri to check.
*
* Return value: TRUE if inspection of uri reveals that it is invalid,
* FALSE otherwise.
**/
gboolean
nautilus_path_known_not_to_exist (const char *uri_string)
{
GnomeVFSURI *uri;
GnomeVFSFileInfo file_info;
GnomeVFSResult result;
g_return_val_if_fail(uri_string != NULL, TRUE);
/* Handle empty string here since gnome_vfs_uri_new chokes on it. */
if (uri_string[0] == 0)
return TRUE;
uri = gnome_vfs_uri_new(uri_string);
if (uri == NULL)
return TRUE;
/* Since we want only instant results, don't check remote uri's */
if (!gnome_vfs_uri_is_local(uri))
return FALSE;
result = gnome_vfs_get_file_info_uri(uri,
&file_info,
GNOME_VFS_FILE_INFO_DEFAULT,
NULL);
return result != GNOME_VFS_OK;
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-uri-utilities.h - interface for uri manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_URI_UTILITIES_H
#define NAUTILUS_URI_UTILITIES_H 1
#include <gnome.h>
gboolean nautilus_path_known_not_to_exist (const gchar *path);
#endif /* NAUTILUS_URI_UTILITIES_H */
lib_LTLIBRARIES=libnautilus.la
INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOME_CFLAGS) $(GNORBA_CFLAGS) $(WERROR)
INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
$(GNOME_CFLAGS) \
$(GNORBA_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(VFS_CFLAGS) \
$(WERROR)
nautilus_idl_sources=nautilus-stubs.c nautilus-skels.c nautilus.h nautilus-common.c
fsextension_idl_sources=fsextension-stubs.c fsextension-skels.c fsextension-common.c fsextension.h
......@@ -19,6 +24,7 @@ libnautilusinclude_HEADERS= \
gtkscrollframe.h \
nautilus.h \
nautilus-file-utilities.h \
nautilus-uri-utilities.h \
ntl-content-view-client.h \
ntl-meta-view-client.h \
ntl-view-client.h
......@@ -31,12 +37,16 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gtkflist.c \
gtkscrollframe.c \
nautilus-file-utilities.c \
nautilus-uri-utilities.c \
ntl-content-view-client.c \
ntl-meta-view-client.c \
ntl-view-client.c \
$(fsextension_idl_sources)
libnautilus_la_LDFLAGS=$(GNOME_LIBS) $(GNORBA_LIBS) $(GDK_PIXBUF_LIBS)
libnautilus_la_LDFLAGS=$(GNOME_LIBS) \
$(GNORBA_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(VFS_LIBS)
$(nautilus_idl_sources): nautilus_idl_stamp
$(fsextension_idl_sources): fsextension_idl_stamp
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-uri-utilities..c - implementation of uri manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#include "nautilus-uri-utilities.h"
#include <libgnomevfs/gnome-vfs.h>
/**
* nautilus_path_known_not_to_exist:
*
* Check whether a uri represents a path known in advance not to exist.
* A return value of FALSE does not guarantee that the path is valid,
* but a return value of TRUE does guarantee that the path is not valid.
* Use this to make quick rejection decisions.
* @uri: The uri to check.
*
* Return value: TRUE if inspection of uri reveals that it is invalid,
* FALSE otherwise.
**/
gboolean
nautilus_path_known_not_to_exist (const char *uri_string)
{
GnomeVFSURI *uri;
GnomeVFSFileInfo file_info;
GnomeVFSResult result;
g_return_val_if_fail(uri_string != NULL, TRUE);
/* Handle empty string here since gnome_vfs_uri_new chokes on it. */
if (uri_string[0] == 0)
return TRUE;
uri = gnome_vfs_uri_new(uri_string);
if (uri == NULL)
return TRUE;
/* Since we want only instant results, don't check remote uri's */
if (!gnome_vfs_uri_is_local(uri))
return FALSE;
result = gnome_vfs_get_file_info_uri(uri,
&file_info,
GNOME_VFS_FILE_INFO_DEFAULT,
NULL);
return result != GNOME_VFS_OK;
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-uri-utilities.h - interface for uri manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_URI_UTILITIES_H
#define NAUTILUS_URI_UTILITIES_H 1
#include <gnome.h>
gboolean nautilus_path_known_not_to_exist (const gchar *path);
#endif /* NAUTILUS_URI_UTILITIES_H */
lib_LTLIBRARIES=libnautilus.la
INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOME_CFLAGS) $(GNORBA_CFLAGS) $(WERROR)
INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
$(GNOME_CFLAGS) \
$(GNORBA_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
$(VFS_CFLAGS) \
$(WERROR)
nautilus_idl_sources=nautilus-stubs.c nautilus-skels.c nautilus.h nautilus-common.c
fsextension_idl_sources=fsextension-stubs.c fsextension-skels.c fsextension-common.c fsextension.h
......@@ -19,6 +24,7 @@ libnautilusinclude_HEADERS= \
gtkscrollframe.h \
nautilus.h \
nautilus-file-utilities.h \
nautilus-uri-utilities.h \
ntl-content-view-client.h \
ntl-meta-view-client.h \
ntl-view-client.h
......@@ -31,12 +37,16 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gtkflist.c \
gtkscrollframe.c \
nautilus-file-utilities.c \
nautilus-uri-utilities.c \
ntl-content-view-client.c \
ntl-meta-view-client.c \
ntl-view-client.c \
$(fsextension_idl_sources)
libnautilus_la_LDFLAGS=$(GNOME_LIBS) $(GNORBA_LIBS) $(GDK_PIXBUF_LIBS)
libnautilus_la_LDFLAGS=$(GNOME_LIBS) \
$(GNORBA_LIBS) \
$(GDK_PIXBUF_LIBS) \
$(VFS_LIBS)
$(nautilus_idl_sources): nautilus_idl_stamp
$(fsextension_idl_sources): fsextension_idl_stamp
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-uri-utilities..c - implementation of uri manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#include "nautilus-uri-utilities.h"
#include <libgnomevfs/gnome-vfs.h>
/**
* nautilus_path_known_not_to_exist:
*
* Check whether a uri represents a path known in advance not to exist.
* A return value of FALSE does not guarantee that the path is valid,
* but a return value of TRUE does guarantee that the path is not valid.
* Use this to make quick rejection decisions.
* @uri: The uri to check.
*
* Return value: TRUE if inspection of uri reveals that it is invalid,
* FALSE otherwise.
**/
gboolean
nautilus_path_known_not_to_exist (const char *uri_string)
{
GnomeVFSURI *uri;
GnomeVFSFileInfo file_info;
GnomeVFSResult result;
g_return_val_if_fail(uri_string != NULL, TRUE);
/* Handle empty string here since gnome_vfs_uri_new chokes on it. */
if (uri_string[0] == 0)
return TRUE;
uri = gnome_vfs_uri_new(uri_string);
if (uri == NULL)
return TRUE;
/* Since we want only instant results, don't check remote uri's */
if (!gnome_vfs_uri_is_local(uri))
return FALSE;
result = gnome_vfs_get_file_info_uri(uri,
&file_info,
GNOME_VFS_FILE_INFO_DEFAULT,
NULL);
return result != GNOME_VFS_OK;
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-uri-utilities.h - interface for uri manipulation routines.
Copyright (C) 1999, 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_URI_UTILITIES_H
#define NAUTILUS_URI_UTILITIES_H 1
#include <gnome.h>
gboolean nautilus_path_known_not_to_exist (const gchar *path);
#endif /* NAUTILUS_URI_UTILITIES_H */
......@@ -26,6 +26,7 @@
#include "config.h"
#include <gnome.h>
#include "libnautilus/nautilus-uri-utilities.h"
#include "nautilus.h"
#include "nautilus-bookmarks-menu.h"
#include "explorer-location-bar.h"
......@@ -402,7 +403,18 @@ nautilus_window_goto_uri_cb (GtkWidget *widget,
const char *uri,
GtkWidget *window)
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
if (nautilus_path_known_not_to_exist(uri))
{
gchar *message;
message = g_strdup_printf(_("no such location: %s"), uri);
nautilus_window_set_status(NAUTILUS_WINDOW(window), message);
g_free(message);
}
else
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
}
}
static void
......@@ -867,7 +879,6 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
gnome_vfs_uri_destroy (parent_uri);
}
static void
nautilus_window_reload (GtkWidget *btn, NautilusWindow *window)
{
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include <gnome.h>
#include "libnautilus/nautilus-uri-utilities.h"
#include "nautilus.h"
#include "nautilus-bookmarks-menu.h"
#include "explorer-location-bar.h"
......@@ -402,7 +403,18 @@ nautilus_window_goto_uri_cb (GtkWidget *widget,
const char *uri,
GtkWidget *window)
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
if (nautilus_path_known_not_to_exist(uri))
{
gchar *message;
message = g_strdup_printf(_("no such location: %s"), uri);
nautilus_window_set_status(NAUTILUS_WINDOW(window), message);
g_free(message);
}
else
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
}
}
static void
......@@ -867,7 +879,6 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
gnome_vfs_uri_destroy (parent_uri);
}
static void
nautilus_window_reload (GtkWidget *btn, NautilusWindow *window)
{
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include <gnome.h>
#include "libnautilus/nautilus-uri-utilities.h"
#include "nautilus.h"
#include "nautilus-bookmarks-menu.h"
#include "explorer-location-bar.h"
......@@ -402,7 +403,18 @@ nautilus_window_goto_uri_cb (GtkWidget *widget,
const char *uri,
GtkWidget *window)
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
if (nautilus_path_known_not_to_exist(uri))
{
gchar *message;
message = g_strdup_printf(_("no such location: %s"), uri);
nautilus_window_set_status(NAUTILUS_WINDOW(window), message);
g_free(message);
}
else
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
}
}
static void
......@@ -867,7 +879,6 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
gnome_vfs_uri_destroy (parent_uri);
}
static void
nautilus_window_reload (GtkWidget *btn, NautilusWindow *window)
{
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include <gnome.h>
#include "libnautilus/nautilus-uri-utilities.h"
#include "nautilus.h"
#include "nautilus-bookmarks-menu.h"
#include "explorer-location-bar.h"
......@@ -402,7 +403,18 @@ nautilus_window_goto_uri_cb (GtkWidget *widget,
const char *uri,
GtkWidget *window)
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
if (nautilus_path_known_not_to_exist(uri))
{
gchar *message;
message = g_strdup_printf(_("no such location: %s"), uri);
nautilus_window_set_status(NAUTILUS_WINDOW(window), message);
g_free(message);
}
else
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
}
}
static void
......@@ -867,7 +879,6 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
gnome_vfs_uri_destroy (parent_uri);
}
static void
nautilus_window_reload (GtkWidget *btn, NautilusWindow *window)
{
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include <gnome.h>
#include "libnautilus/nautilus-uri-utilities.h"
#include "nautilus.h"
#include "nautilus-bookmarks-menu.h"
#include "explorer-location-bar.h"
......@@ -402,7 +403,18 @@ nautilus_window_goto_uri_cb (GtkWidget *widget,
const char *uri,
GtkWidget *window)
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
if (nautilus_path_known_not_to_exist(uri))
{
gchar *message;
message = g_strdup_printf(_("no such location: %s"), uri);
nautilus_window_set_status(NAUTILUS_WINDOW(window), message);
g_free(message);
}
else
{
nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri);
}
}
static void
......@@ -867,7 +879,6 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
gnome_vfs_uri_destroy (parent_uri);
}
static void
nautilus_window_reload (GtkWidget *btn, NautilusWindow *window)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment