mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-29 03:34:16 +00:00
Added first cut at code to put metafiles in the user's home directory if
* libnautilus/nautilus-directory.c: (nautilus_directory_read_metafile): (nautilus_directory_try_to_read_metafile): (nautilus_directory_write_metafile): (nautilus_directory_try_to_write_metafile): (nautilus_directory_switch_to_alternate_metafile_uri): (nautilus_directory_escape_slashes): (nautilus_make_directory_and_parents): Added first cut at code to put metafiles in the user's home directory if the directory is not accessible and you can't read and write a metafile in the directory itself. We'll have to refine this later to handle cases where you end up with two metafiles. * libnautilus/Makefile.am: libnautilus/nautilus-debug.h: libnautilus/nautilus-debug.c: Took trick for getting into the debugger and put it into a public header file so it can be used outside of the nautilus executable. * src/ntl-main.c: (stop_in_debugger): (nautilus_stop_after_default_log_handler): (main): Use the new calls from libnautilus to set up the drop into debugger for criticals and warnings. * src/file-manager/fm-main.c: (main): Minimized includes and used the new calls from libnautilus to set up the drop into debugger for criticals and warnings. * src/ntl-uri-map.c: (nautilus_navinfo_add_mapping): src/ntl-window.c: (nautilus_window_constructed): src/file-manager/fm-directory-view.c: (fm_directory_view_initialize): (fm_directory_view_destroy): (notify_location_change_cb): (stop_location_change_cb): (fm_directory_view_sort): Removed some messages that aren't so useful. * libnautilus/ntl-view-frame.h: Minimized includes. * libnautilus/ntl-view-frame.c: Include "ntl-view-frame.h" first so it tests to see that it has sufficient includes in it. * src/ntl-view.c: (nautilus_view_load_client): Changed function so that NULL for an iid is allowed and simply results in a failed load instead of being illegal. * src/ntl-window-msgs.c: (nautilus_window_change_location_internal): src/ntl-window.c: (nautilus_window_up): Got rid of calls to gnome_vfs_uri_destroy; use gnome_vfs_uri_unref instead since it's safer and Federico is getting rid of gnome_vfs_uri_destroy. * src/file-manager/fm-directory-view-icons.h: src/file-manager/fm-directory-view-icons.c: (fm_directory_view_icons_new): src/file-manager/fm-directory-view-list.h: src/file-manager/fm-directory-view-list.c: (fm_directory_view_list_new): src/file-manager/fm-directory-view.h: src/file-manager/fm-directory-view.c: (fm_directory_view_new): Minimized includes and got rid of the unused _new functions. * libnautilus/nautilus-directory.h: Added a missing 2000 copyright date.
This commit is contained in:
parent
98d22d4f2b
commit
7e292ac004
43 changed files with 1317 additions and 497 deletions
|
@ -1,3 +1,67 @@
|
|||
2000-01-18 Darin Adler <darin@eazel.com>
|
||||
|
||||
* libnautilus/nautilus-directory.c:
|
||||
(nautilus_directory_read_metafile):
|
||||
(nautilus_directory_try_to_read_metafile):
|
||||
(nautilus_directory_write_metafile):
|
||||
(nautilus_directory_try_to_write_metafile):
|
||||
(nautilus_directory_switch_to_alternate_metafile_uri):
|
||||
(nautilus_directory_escape_slashes):
|
||||
(nautilus_make_directory_and_parents): Added first cut at code to
|
||||
put metafiles in the user's home directory if the directory is not
|
||||
accessible and you can't read and write a metafile in the
|
||||
directory itself. We'll have to refine this later to handle cases
|
||||
where you end up with two metafiles.
|
||||
|
||||
* libnautilus/Makefile.am: libnautilus/nautilus-debug.h:
|
||||
libnautilus/nautilus-debug.c: Took trick for getting into the
|
||||
debugger and put it into a public header file so it can be used
|
||||
outside of the nautilus executable.
|
||||
|
||||
* src/ntl-main.c: (stop_in_debugger):
|
||||
(nautilus_stop_after_default_log_handler): (main): Use the new
|
||||
calls from libnautilus to set up the drop into debugger for
|
||||
criticals and warnings.
|
||||
|
||||
* src/file-manager/fm-main.c: (main): Minimized includes and used
|
||||
the new calls from libnautilus to set up the drop into debugger
|
||||
for criticals and warnings.
|
||||
|
||||
* src/ntl-uri-map.c: (nautilus_navinfo_add_mapping):
|
||||
src/ntl-window.c: (nautilus_window_constructed):
|
||||
src/file-manager/fm-directory-view.c:
|
||||
(fm_directory_view_initialize): (fm_directory_view_destroy):
|
||||
(notify_location_change_cb): (stop_location_change_cb):
|
||||
(fm_directory_view_sort): Removed some messages that aren't so
|
||||
useful.
|
||||
|
||||
* libnautilus/ntl-view-frame.h: Minimized includes.
|
||||
* libnautilus/ntl-view-frame.c: Include "ntl-view-frame.h" first
|
||||
so it tests to see that it has sufficient includes in it.
|
||||
|
||||
* src/ntl-view.c: (nautilus_view_load_client): Changed function so
|
||||
that NULL for an iid is allowed and simply results in a failed
|
||||
load instead of being illegal.
|
||||
|
||||
* src/ntl-window-msgs.c:
|
||||
(nautilus_window_change_location_internal): src/ntl-window.c:
|
||||
(nautilus_window_up): Got rid of calls to gnome_vfs_uri_destroy;
|
||||
use gnome_vfs_uri_unref instead since it's safer and Federico is
|
||||
getting rid of gnome_vfs_uri_destroy.
|
||||
|
||||
* src/file-manager/fm-directory-view-icons.h:
|
||||
src/file-manager/fm-directory-view-icons.c:
|
||||
(fm_directory_view_icons_new):
|
||||
src/file-manager/fm-directory-view-list.h:
|
||||
src/file-manager/fm-directory-view-list.c:
|
||||
(fm_directory_view_list_new):
|
||||
src/file-manager/fm-directory-view.h:
|
||||
src/file-manager/fm-directory-view.c: (fm_directory_view_new):
|
||||
Minimized includes and got rid of the unused _new functions.
|
||||
|
||||
* libnautilus/nautilus-directory.h: Added a missing 2000 copyright
|
||||
date.
|
||||
|
||||
2000-01-17 John Sullivan <sullivan@eazel.com>
|
||||
First steps towards making the list view non-degenerate.
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ libnautilusinclude_HEADERS= \
|
|||
gtkscrollframe.h \
|
||||
nautilus.h \
|
||||
nautilus-background.h \
|
||||
nautilus-debug.h \
|
||||
nautilus-directory.h \
|
||||
nautilus-file-utilities.h \
|
||||
nautilus-gtk-extensions.h \
|
||||
|
@ -51,6 +52,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
|
|||
gtkscrollframe.c \
|
||||
nautilus-background.c \
|
||||
nautilus-background-canvas-group.c \
|
||||
nautilus-debug.c \
|
||||
nautilus-directory.c \
|
||||
nautilus-file-utilities.c \
|
||||
nautilus-gtk-extensions.c \
|
||||
|
|
87
libnautilus-extensions/nautilus-debug.c
Normal file
87
libnautilus-extensions/nautilus-debug.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-debug.c: Nautilus debugging aids.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Darin Adler <darin@eazel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "nautilus-debug.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* Raise a SIGINT signal to get the attention of the debugger.
|
||||
When not running under the debugger, we don't want to stop,
|
||||
so we ignore the signal for just the moment that we raise it.
|
||||
*/
|
||||
void
|
||||
nautilus_stop_in_debugger (void)
|
||||
{
|
||||
void (* saved_handler) (int);
|
||||
|
||||
saved_handler = signal (SIGINT, SIG_IGN);
|
||||
raise (SIGINT);
|
||||
signal (SIGINT, saved_handler);
|
||||
}
|
||||
|
||||
/* Stop in the debugger after running the default log handler.
|
||||
This makes certain kinds of messages stop in the debugger
|
||||
without making them fatal.
|
||||
*/
|
||||
static void
|
||||
nautilus_stop_after_default_log_handler (const char *domain,
|
||||
GLogLevelFlags level,
|
||||
const char *message,
|
||||
gpointer data)
|
||||
{
|
||||
g_log_default_handler (domain, level, message, data);
|
||||
nautilus_stop_in_debugger ();
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_set_stop_after_default_log_handler (const char *domain)
|
||||
{
|
||||
g_log_set_handler (domain, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
|
||||
nautilus_stop_after_default_log_handler, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...)
|
||||
{
|
||||
va_list domains;
|
||||
const char *domain;
|
||||
|
||||
nautilus_set_stop_after_default_log_handler (first_domain);
|
||||
|
||||
va_start (domains, first_domain);
|
||||
|
||||
for (;;) {
|
||||
domain = va_arg (domains, const char *);
|
||||
if (domain == NULL)
|
||||
break;
|
||||
nautilus_set_stop_after_default_log_handler (domain);
|
||||
}
|
||||
|
||||
va_end (domains);
|
||||
}
|
31
libnautilus-extensions/nautilus-debug.h
Normal file
31
libnautilus-extensions/nautilus-debug.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-debug.h: Nautilus debugging aids.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Darin Adler <darin@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_DEBUG_H
|
||||
#define NAUTILUS_DEBUG_H
|
||||
|
||||
void nautilus_stop_in_debugger (void);
|
||||
void nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...);
|
||||
|
||||
#endif /* NAUTILUS_DEBUG_H */
|
|
@ -45,7 +45,18 @@
|
|||
#include "nautilus-lib-self-check-functions.h"
|
||||
#include "nautilus-string.h"
|
||||
|
||||
#define METAFILE_NAME ".nautilus.xml"
|
||||
#define METAFILE_NAME ".nautilus-metafile.xml"
|
||||
#define METAFILE_PERMISSIONS (GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE \
|
||||
| GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \
|
||||
| GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE)
|
||||
|
||||
#define NAUTILUS_DIRECTORY_NAME ".nautilus"
|
||||
#define METAFILES_DIRECTORY_NAME "metafiles"
|
||||
#define METAFILES_DIRECTORY_PERMISSIONS (GNOME_VFS_PERM_USER_ALL \
|
||||
| GNOME_VFS_PERM_GROUP_ALL \
|
||||
| GNOME_VFS_PERM_OTHER_ALL)
|
||||
#define METAFILE_SUFFIX ".xml"
|
||||
|
||||
#define METAFILE_XML_VERSION "1.0"
|
||||
|
||||
static void nautilus_directory_initialize_class (gpointer klass);
|
||||
|
@ -58,6 +69,7 @@ static void nautilus_directory_read_metafile (NautilusDirectory *directory);
|
|||
static void nautilus_directory_write_metafile (NautilusDirectory *directory);
|
||||
static void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
|
||||
static void nautilus_directory_remove_write_metafile_idle (NautilusDirectory *directory);
|
||||
static gboolean nautilus_directory_switch_to_alternate_metafile_uri (NautilusDirectory *directory);
|
||||
|
||||
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
|
||||
|
||||
|
@ -69,6 +81,7 @@ struct _NautilusDirectoryDetails
|
|||
GnomeVFSURI *uri;
|
||||
|
||||
GnomeVFSURI *metafile_uri;
|
||||
gboolean is_alternate_metafile_uri;
|
||||
xmlDoc *metafile_tree;
|
||||
int write_metafile_idle_id;
|
||||
|
||||
|
@ -172,52 +185,39 @@ nautilus_directory_get (const char *uri)
|
|||
with async. calls; currently you can only get the file length with
|
||||
a synchronous call.
|
||||
*/
|
||||
static void
|
||||
nautilus_directory_read_metafile (NautilusDirectory *directory)
|
||||
static GnomeVFSResult
|
||||
nautilus_directory_try_to_read_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSFileInfo metafile_info;
|
||||
GnomeVFSHandle *metafile_handle;
|
||||
char *buffer;
|
||||
GnomeVFSFileSize size, actual_size;
|
||||
char *buffer;
|
||||
|
||||
g_assert (directory->details->metafile_tree == NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details->metafile_tree == NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
|
||||
result = gnome_vfs_get_file_info_uri (directory->details->metafile_uri,
|
||||
&metafile_info,
|
||||
GNOME_VFS_FILE_INFO_DEFAULT,
|
||||
NULL);
|
||||
if (result == GNOME_VFS_ERROR_NOTFOUND)
|
||||
return;
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_get_file_info_uri failed");
|
||||
|
||||
metafile_handle = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
if (result == GNOME_VFS_OK)
|
||||
result = gnome_vfs_open_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_READ);
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_open_uri failed");
|
||||
}
|
||||
|
||||
if (result == GNOME_VFS_OK) {
|
||||
size = metafile_info.size;
|
||||
if (size != metafile_info.size) {
|
||||
g_warning ("nautilus_directory_read_metafile: metafile too large");
|
||||
if (size != metafile_info.size)
|
||||
result = GNOME_VFS_ERROR_TOOBIG;
|
||||
}
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
buffer = g_malloc (size);
|
||||
|
||||
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_read failed");
|
||||
else if (actual_size != size)
|
||||
g_warning ("nautilus_directory_read_metafile: size changed between get_info and read");
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
|
@ -227,6 +227,24 @@ nautilus_directory_read_metafile (NautilusDirectory *directory)
|
|||
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_directory_read_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
|
||||
|
||||
result = nautilus_directory_try_to_read_metafile (directory);
|
||||
if (result == GNOME_VFS_ERROR_ACCESSDENIED && !directory->details->is_alternate_metafile_uri)
|
||||
if (nautilus_directory_switch_to_alternate_metafile_uri (directory))
|
||||
result = nautilus_directory_try_to_read_metafile (directory);
|
||||
|
||||
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_NOTFOUND)
|
||||
g_warning ("nautilus_directory_read_metafile failed to read metafile - we should report this to the user");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -239,8 +257,8 @@ nautilus_directory_remove_write_metafile_idle (NautilusDirectory *directory)
|
|||
}
|
||||
|
||||
/* This writes the metafile synchronously. This must go eventually. */
|
||||
static void
|
||||
nautilus_directory_write_metafile (NautilusDirectory *directory)
|
||||
static GnomeVFSResult
|
||||
nautilus_directory_try_to_write_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
xmlChar *buffer;
|
||||
int buffer_size;
|
||||
|
@ -248,6 +266,38 @@ nautilus_directory_write_metafile (NautilusDirectory *directory)
|
|||
GnomeVFSHandle *metafile_handle;
|
||||
GnomeVFSFileSize actual_size;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details != NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details->metafile_tree != NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
|
||||
metafile_handle = NULL;
|
||||
result = gnome_vfs_create_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
FALSE,
|
||||
METAFILE_PERMISSIONS);
|
||||
|
||||
buffer = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
xmlDocDumpMemory (directory->details->metafile_tree, &buffer, &buffer_size);
|
||||
result = gnome_vfs_write (metafile_handle, buffer, buffer_size, &actual_size);
|
||||
if (buffer_size != actual_size)
|
||||
result = GNOME_VFS_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
gnome_vfs_close (metafile_handle);
|
||||
|
||||
xmlFree (buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_directory_write_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
|
||||
|
||||
/* We are about the write the metafile, so we can cancel the pending
|
||||
|
@ -261,30 +311,13 @@ nautilus_directory_write_metafile (NautilusDirectory *directory)
|
|||
if (directory->details->metafile_tree == NULL)
|
||||
return;
|
||||
|
||||
xmlDocDumpMemory (directory->details->metafile_tree, &buffer, &buffer_size);
|
||||
result = nautilus_directory_try_to_write_metafile (directory);
|
||||
if (result == GNOME_VFS_ERROR_ACCESSDENIED && !directory->details->is_alternate_metafile_uri)
|
||||
if (nautilus_directory_switch_to_alternate_metafile_uri (directory))
|
||||
result = nautilus_directory_try_to_write_metafile (directory);
|
||||
|
||||
metafile_handle = NULL;
|
||||
result = gnome_vfs_create_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
FALSE,
|
||||
GNOME_VFS_PERM_USER_ALL | GNOME_VFS_PERM_GROUP_ALL | GNOME_VFS_PERM_OTHER_ALL);
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_write_metafile: gnome_vfs_create_uri failed");
|
||||
|
||||
if (result == GNOME_VFS_OK) {
|
||||
result = gnome_vfs_write (metafile_handle, buffer, buffer_size, &actual_size);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_write_metafile: gnome_vfs_write failed");
|
||||
else if (actual_size != buffer_size)
|
||||
g_warning ("nautilus_directory_read_metafile: unable to write all");
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
gnome_vfs_close (metafile_handle);
|
||||
|
||||
xmlFree (buffer);
|
||||
g_warning ("nautilus_directory_write_metafile failed to write metafile - we should report this to the user");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -304,6 +337,134 @@ nautilus_directory_request_write_metafile (NautilusDirectory *directory)
|
|||
gtk_idle_add (nautilus_directory_write_metafile_on_idle,
|
||||
directory);
|
||||
}
|
||||
|
||||
/* To use a directory name as a file name, we need to escape any slashes.
|
||||
This means that "/" is replaced by "%2F" and "%" is replaced by "%25".
|
||||
Later we might share the escaping code with some more generic escaping
|
||||
function, but this should do for now.
|
||||
*/
|
||||
static char *
|
||||
nautilus_directory_escape_slashes (const char *path)
|
||||
{
|
||||
char c;
|
||||
const char *in;
|
||||
guint length;
|
||||
char *result;
|
||||
char *out;
|
||||
|
||||
/* Figure out how long the result needs to be. */
|
||||
in = path;
|
||||
length = 0;
|
||||
while ((c = *in++) != '\0')
|
||||
switch (c) {
|
||||
case '/':
|
||||
case '%':
|
||||
length += 3;
|
||||
break;
|
||||
default:
|
||||
length += 1;
|
||||
}
|
||||
|
||||
/* Create the result string. */
|
||||
result = g_malloc (length + 1);
|
||||
in = path;
|
||||
out = result;
|
||||
while ((c = *in++) != '\0')
|
||||
switch (c) {
|
||||
case '/':
|
||||
*out++ = '%';
|
||||
*out++ = '2';
|
||||
*out++ = 'F';
|
||||
break;
|
||||
case '%':
|
||||
*out++ = '%';
|
||||
*out++ = '2';
|
||||
*out++ = '5';
|
||||
break;
|
||||
default:
|
||||
*out++ = c;
|
||||
}
|
||||
g_assert (out == result + length);
|
||||
*out = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GnomeVFSResult
|
||||
nautilus_make_directory_and_parents (GnomeVFSURI *uri, guint permissions)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSURI *parent_uri;
|
||||
|
||||
/* Make the directory, and return right away unless there's
|
||||
a possible problem with the parent.
|
||||
*/
|
||||
result = gnome_vfs_make_directory_for_uri (uri, permissions);
|
||||
if (result != GNOME_VFS_ERROR_NOTFOUND)
|
||||
return result;
|
||||
|
||||
/* If we can't get a parent, we are done. */
|
||||
parent_uri = gnome_vfs_uri_get_parent (uri);
|
||||
if (parent_uri == NULL)
|
||||
return result;
|
||||
|
||||
/* If we can get a parent, use a recursive call to create
|
||||
the parent and its parents.
|
||||
*/
|
||||
result = nautilus_make_directory_and_parents (parent_uri, permissions);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
if (result != GNOME_VFS_OK)
|
||||
return result;
|
||||
|
||||
/* A second try at making the directory after the parents
|
||||
have all been created.
|
||||
*/
|
||||
result = gnome_vfs_make_directory_for_uri (uri, permissions);
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nautilus_directory_switch_to_alternate_metafile_uri (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSURI *home_uri, *nautilus_directory_uri, *metafiles_directory_uri, *alternate_uri;
|
||||
char *uri_as_string, *escaped_uri, *file_name;
|
||||
|
||||
g_return_val_if_fail (!directory->details->is_alternate_metafile_uri, FALSE);
|
||||
|
||||
/* Ensure that the metafiles directory exists. */
|
||||
home_uri = gnome_vfs_uri_new (g_get_home_dir ());
|
||||
nautilus_directory_uri = gnome_vfs_uri_append_path (home_uri, NAUTILUS_DIRECTORY_NAME);
|
||||
gnome_vfs_uri_unref (home_uri);
|
||||
metafiles_directory_uri = gnome_vfs_uri_append_path (nautilus_directory_uri, METAFILES_DIRECTORY_NAME);
|
||||
gnome_vfs_uri_unref (nautilus_directory_uri);
|
||||
result = nautilus_make_directory_and_parents (metafiles_directory_uri, METAFILES_DIRECTORY_PERMISSIONS);
|
||||
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILEEXISTS) {
|
||||
gnome_vfs_uri_unref (metafiles_directory_uri);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Construct a file name from the URI. */
|
||||
uri_as_string = gnome_vfs_uri_to_string (directory->details->uri,
|
||||
GNOME_VFS_URI_HIDE_NONE);
|
||||
escaped_uri = nautilus_directory_escape_slashes (uri_as_string);
|
||||
g_free (uri_as_string);
|
||||
file_name = g_strconcat (escaped_uri, ".xml", NULL);
|
||||
g_free (escaped_uri);
|
||||
|
||||
/* Construct a URI for something in the "metafiles" directory. */
|
||||
alternate_uri = gnome_vfs_uri_append_path (metafiles_directory_uri, file_name);
|
||||
gnome_vfs_uri_unref (metafiles_directory_uri);
|
||||
g_free (file_name);
|
||||
|
||||
/* Switch over to the new URI. */
|
||||
if (directory->details->metafile_uri != NULL)
|
||||
gnome_vfs_uri_unref (directory->details->metafile_uri);
|
||||
directory->details->metafile_uri = alternate_uri;
|
||||
directory->details->is_alternate_metafile_uri = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if NAUTILUS_DIRECTORY_ASYNC
|
||||
|
||||
|
@ -335,7 +496,7 @@ nautilus_directory_new (const char* uri)
|
|||
|
||||
directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
|
||||
|
||||
directory->details->uri_text = g_strdup (uri);
|
||||
directory->details->uri_text = g_strdup(uri);
|
||||
directory->details->uri = vfs_uri;
|
||||
directory->details->metafile_uri = metafile_uri;
|
||||
|
||||
|
@ -377,7 +538,7 @@ nautilus_directory_get_metadata (NautilusDirectory *directory,
|
|||
result = g_strdup (default_metadata);
|
||||
else
|
||||
result = g_strdup (property);
|
||||
g_free (property);
|
||||
xmlFree (property);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -461,6 +622,16 @@ nautilus_self_check_directory (void)
|
|||
gtk_object_unref (GTK_OBJECT (directory));
|
||||
|
||||
g_assert (g_hash_table_size (directory_objects) == 0);
|
||||
|
||||
/* nautilus_directory_escape_slashes */
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes (""), "");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a"), "a");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("/"), "%2F");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%"), "%25");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a/a"), "a%2Fa");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a%a"), "a%25a");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
|
||||
}
|
||||
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
nautilus-directory.h: Nautilus directory model.
|
||||
|
||||
Copyright (C) 1999 Eazel, Inc.
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
|
|
|
@ -32,6 +32,7 @@ libnautilusinclude_HEADERS= \
|
|||
gtkscrollframe.h \
|
||||
nautilus.h \
|
||||
nautilus-background.h \
|
||||
nautilus-debug.h \
|
||||
nautilus-directory.h \
|
||||
nautilus-file-utilities.h \
|
||||
nautilus-gtk-extensions.h \
|
||||
|
@ -51,6 +52,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
|
|||
gtkscrollframe.c \
|
||||
nautilus-background.c \
|
||||
nautilus-background-canvas-group.c \
|
||||
nautilus-debug.c \
|
||||
nautilus-directory.c \
|
||||
nautilus-file-utilities.c \
|
||||
nautilus-gtk-extensions.c \
|
||||
|
|
87
libnautilus-private/nautilus-debug.c
Normal file
87
libnautilus-private/nautilus-debug.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-debug.c: Nautilus debugging aids.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Darin Adler <darin@eazel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "nautilus-debug.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* Raise a SIGINT signal to get the attention of the debugger.
|
||||
When not running under the debugger, we don't want to stop,
|
||||
so we ignore the signal for just the moment that we raise it.
|
||||
*/
|
||||
void
|
||||
nautilus_stop_in_debugger (void)
|
||||
{
|
||||
void (* saved_handler) (int);
|
||||
|
||||
saved_handler = signal (SIGINT, SIG_IGN);
|
||||
raise (SIGINT);
|
||||
signal (SIGINT, saved_handler);
|
||||
}
|
||||
|
||||
/* Stop in the debugger after running the default log handler.
|
||||
This makes certain kinds of messages stop in the debugger
|
||||
without making them fatal.
|
||||
*/
|
||||
static void
|
||||
nautilus_stop_after_default_log_handler (const char *domain,
|
||||
GLogLevelFlags level,
|
||||
const char *message,
|
||||
gpointer data)
|
||||
{
|
||||
g_log_default_handler (domain, level, message, data);
|
||||
nautilus_stop_in_debugger ();
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_set_stop_after_default_log_handler (const char *domain)
|
||||
{
|
||||
g_log_set_handler (domain, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
|
||||
nautilus_stop_after_default_log_handler, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...)
|
||||
{
|
||||
va_list domains;
|
||||
const char *domain;
|
||||
|
||||
nautilus_set_stop_after_default_log_handler (first_domain);
|
||||
|
||||
va_start (domains, first_domain);
|
||||
|
||||
for (;;) {
|
||||
domain = va_arg (domains, const char *);
|
||||
if (domain == NULL)
|
||||
break;
|
||||
nautilus_set_stop_after_default_log_handler (domain);
|
||||
}
|
||||
|
||||
va_end (domains);
|
||||
}
|
31
libnautilus-private/nautilus-debug.h
Normal file
31
libnautilus-private/nautilus-debug.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-debug.h: Nautilus debugging aids.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Darin Adler <darin@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_DEBUG_H
|
||||
#define NAUTILUS_DEBUG_H
|
||||
|
||||
void nautilus_stop_in_debugger (void);
|
||||
void nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...);
|
||||
|
||||
#endif /* NAUTILUS_DEBUG_H */
|
|
@ -45,7 +45,18 @@
|
|||
#include "nautilus-lib-self-check-functions.h"
|
||||
#include "nautilus-string.h"
|
||||
|
||||
#define METAFILE_NAME ".nautilus.xml"
|
||||
#define METAFILE_NAME ".nautilus-metafile.xml"
|
||||
#define METAFILE_PERMISSIONS (GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE \
|
||||
| GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \
|
||||
| GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE)
|
||||
|
||||
#define NAUTILUS_DIRECTORY_NAME ".nautilus"
|
||||
#define METAFILES_DIRECTORY_NAME "metafiles"
|
||||
#define METAFILES_DIRECTORY_PERMISSIONS (GNOME_VFS_PERM_USER_ALL \
|
||||
| GNOME_VFS_PERM_GROUP_ALL \
|
||||
| GNOME_VFS_PERM_OTHER_ALL)
|
||||
#define METAFILE_SUFFIX ".xml"
|
||||
|
||||
#define METAFILE_XML_VERSION "1.0"
|
||||
|
||||
static void nautilus_directory_initialize_class (gpointer klass);
|
||||
|
@ -58,6 +69,7 @@ static void nautilus_directory_read_metafile (NautilusDirectory *directory);
|
|||
static void nautilus_directory_write_metafile (NautilusDirectory *directory);
|
||||
static void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
|
||||
static void nautilus_directory_remove_write_metafile_idle (NautilusDirectory *directory);
|
||||
static gboolean nautilus_directory_switch_to_alternate_metafile_uri (NautilusDirectory *directory);
|
||||
|
||||
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
|
||||
|
||||
|
@ -69,6 +81,7 @@ struct _NautilusDirectoryDetails
|
|||
GnomeVFSURI *uri;
|
||||
|
||||
GnomeVFSURI *metafile_uri;
|
||||
gboolean is_alternate_metafile_uri;
|
||||
xmlDoc *metafile_tree;
|
||||
int write_metafile_idle_id;
|
||||
|
||||
|
@ -172,52 +185,39 @@ nautilus_directory_get (const char *uri)
|
|||
with async. calls; currently you can only get the file length with
|
||||
a synchronous call.
|
||||
*/
|
||||
static void
|
||||
nautilus_directory_read_metafile (NautilusDirectory *directory)
|
||||
static GnomeVFSResult
|
||||
nautilus_directory_try_to_read_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSFileInfo metafile_info;
|
||||
GnomeVFSHandle *metafile_handle;
|
||||
char *buffer;
|
||||
GnomeVFSFileSize size, actual_size;
|
||||
char *buffer;
|
||||
|
||||
g_assert (directory->details->metafile_tree == NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details->metafile_tree == NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
|
||||
result = gnome_vfs_get_file_info_uri (directory->details->metafile_uri,
|
||||
&metafile_info,
|
||||
GNOME_VFS_FILE_INFO_DEFAULT,
|
||||
NULL);
|
||||
if (result == GNOME_VFS_ERROR_NOTFOUND)
|
||||
return;
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_get_file_info_uri failed");
|
||||
|
||||
metafile_handle = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
if (result == GNOME_VFS_OK)
|
||||
result = gnome_vfs_open_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_READ);
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_open_uri failed");
|
||||
}
|
||||
|
||||
if (result == GNOME_VFS_OK) {
|
||||
size = metafile_info.size;
|
||||
if (size != metafile_info.size) {
|
||||
g_warning ("nautilus_directory_read_metafile: metafile too large");
|
||||
if (size != metafile_info.size)
|
||||
result = GNOME_VFS_ERROR_TOOBIG;
|
||||
}
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
buffer = g_malloc (size);
|
||||
|
||||
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_read failed");
|
||||
else if (actual_size != size)
|
||||
g_warning ("nautilus_directory_read_metafile: size changed between get_info and read");
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
|
@ -227,6 +227,24 @@ nautilus_directory_read_metafile (NautilusDirectory *directory)
|
|||
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_directory_read_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
|
||||
|
||||
result = nautilus_directory_try_to_read_metafile (directory);
|
||||
if (result == GNOME_VFS_ERROR_ACCESSDENIED && !directory->details->is_alternate_metafile_uri)
|
||||
if (nautilus_directory_switch_to_alternate_metafile_uri (directory))
|
||||
result = nautilus_directory_try_to_read_metafile (directory);
|
||||
|
||||
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_NOTFOUND)
|
||||
g_warning ("nautilus_directory_read_metafile failed to read metafile - we should report this to the user");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -239,8 +257,8 @@ nautilus_directory_remove_write_metafile_idle (NautilusDirectory *directory)
|
|||
}
|
||||
|
||||
/* This writes the metafile synchronously. This must go eventually. */
|
||||
static void
|
||||
nautilus_directory_write_metafile (NautilusDirectory *directory)
|
||||
static GnomeVFSResult
|
||||
nautilus_directory_try_to_write_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
xmlChar *buffer;
|
||||
int buffer_size;
|
||||
|
@ -248,6 +266,38 @@ nautilus_directory_write_metafile (NautilusDirectory *directory)
|
|||
GnomeVFSHandle *metafile_handle;
|
||||
GnomeVFSFileSize actual_size;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details != NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details->metafile_tree != NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
|
||||
metafile_handle = NULL;
|
||||
result = gnome_vfs_create_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
FALSE,
|
||||
METAFILE_PERMISSIONS);
|
||||
|
||||
buffer = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
xmlDocDumpMemory (directory->details->metafile_tree, &buffer, &buffer_size);
|
||||
result = gnome_vfs_write (metafile_handle, buffer, buffer_size, &actual_size);
|
||||
if (buffer_size != actual_size)
|
||||
result = GNOME_VFS_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
gnome_vfs_close (metafile_handle);
|
||||
|
||||
xmlFree (buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_directory_write_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
|
||||
|
||||
/* We are about the write the metafile, so we can cancel the pending
|
||||
|
@ -261,30 +311,13 @@ nautilus_directory_write_metafile (NautilusDirectory *directory)
|
|||
if (directory->details->metafile_tree == NULL)
|
||||
return;
|
||||
|
||||
xmlDocDumpMemory (directory->details->metafile_tree, &buffer, &buffer_size);
|
||||
result = nautilus_directory_try_to_write_metafile (directory);
|
||||
if (result == GNOME_VFS_ERROR_ACCESSDENIED && !directory->details->is_alternate_metafile_uri)
|
||||
if (nautilus_directory_switch_to_alternate_metafile_uri (directory))
|
||||
result = nautilus_directory_try_to_write_metafile (directory);
|
||||
|
||||
metafile_handle = NULL;
|
||||
result = gnome_vfs_create_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
FALSE,
|
||||
GNOME_VFS_PERM_USER_ALL | GNOME_VFS_PERM_GROUP_ALL | GNOME_VFS_PERM_OTHER_ALL);
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_write_metafile: gnome_vfs_create_uri failed");
|
||||
|
||||
if (result == GNOME_VFS_OK) {
|
||||
result = gnome_vfs_write (metafile_handle, buffer, buffer_size, &actual_size);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_write_metafile: gnome_vfs_write failed");
|
||||
else if (actual_size != buffer_size)
|
||||
g_warning ("nautilus_directory_read_metafile: unable to write all");
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
gnome_vfs_close (metafile_handle);
|
||||
|
||||
xmlFree (buffer);
|
||||
g_warning ("nautilus_directory_write_metafile failed to write metafile - we should report this to the user");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -304,6 +337,134 @@ nautilus_directory_request_write_metafile (NautilusDirectory *directory)
|
|||
gtk_idle_add (nautilus_directory_write_metafile_on_idle,
|
||||
directory);
|
||||
}
|
||||
|
||||
/* To use a directory name as a file name, we need to escape any slashes.
|
||||
This means that "/" is replaced by "%2F" and "%" is replaced by "%25".
|
||||
Later we might share the escaping code with some more generic escaping
|
||||
function, but this should do for now.
|
||||
*/
|
||||
static char *
|
||||
nautilus_directory_escape_slashes (const char *path)
|
||||
{
|
||||
char c;
|
||||
const char *in;
|
||||
guint length;
|
||||
char *result;
|
||||
char *out;
|
||||
|
||||
/* Figure out how long the result needs to be. */
|
||||
in = path;
|
||||
length = 0;
|
||||
while ((c = *in++) != '\0')
|
||||
switch (c) {
|
||||
case '/':
|
||||
case '%':
|
||||
length += 3;
|
||||
break;
|
||||
default:
|
||||
length += 1;
|
||||
}
|
||||
|
||||
/* Create the result string. */
|
||||
result = g_malloc (length + 1);
|
||||
in = path;
|
||||
out = result;
|
||||
while ((c = *in++) != '\0')
|
||||
switch (c) {
|
||||
case '/':
|
||||
*out++ = '%';
|
||||
*out++ = '2';
|
||||
*out++ = 'F';
|
||||
break;
|
||||
case '%':
|
||||
*out++ = '%';
|
||||
*out++ = '2';
|
||||
*out++ = '5';
|
||||
break;
|
||||
default:
|
||||
*out++ = c;
|
||||
}
|
||||
g_assert (out == result + length);
|
||||
*out = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GnomeVFSResult
|
||||
nautilus_make_directory_and_parents (GnomeVFSURI *uri, guint permissions)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSURI *parent_uri;
|
||||
|
||||
/* Make the directory, and return right away unless there's
|
||||
a possible problem with the parent.
|
||||
*/
|
||||
result = gnome_vfs_make_directory_for_uri (uri, permissions);
|
||||
if (result != GNOME_VFS_ERROR_NOTFOUND)
|
||||
return result;
|
||||
|
||||
/* If we can't get a parent, we are done. */
|
||||
parent_uri = gnome_vfs_uri_get_parent (uri);
|
||||
if (parent_uri == NULL)
|
||||
return result;
|
||||
|
||||
/* If we can get a parent, use a recursive call to create
|
||||
the parent and its parents.
|
||||
*/
|
||||
result = nautilus_make_directory_and_parents (parent_uri, permissions);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
if (result != GNOME_VFS_OK)
|
||||
return result;
|
||||
|
||||
/* A second try at making the directory after the parents
|
||||
have all been created.
|
||||
*/
|
||||
result = gnome_vfs_make_directory_for_uri (uri, permissions);
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nautilus_directory_switch_to_alternate_metafile_uri (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSURI *home_uri, *nautilus_directory_uri, *metafiles_directory_uri, *alternate_uri;
|
||||
char *uri_as_string, *escaped_uri, *file_name;
|
||||
|
||||
g_return_val_if_fail (!directory->details->is_alternate_metafile_uri, FALSE);
|
||||
|
||||
/* Ensure that the metafiles directory exists. */
|
||||
home_uri = gnome_vfs_uri_new (g_get_home_dir ());
|
||||
nautilus_directory_uri = gnome_vfs_uri_append_path (home_uri, NAUTILUS_DIRECTORY_NAME);
|
||||
gnome_vfs_uri_unref (home_uri);
|
||||
metafiles_directory_uri = gnome_vfs_uri_append_path (nautilus_directory_uri, METAFILES_DIRECTORY_NAME);
|
||||
gnome_vfs_uri_unref (nautilus_directory_uri);
|
||||
result = nautilus_make_directory_and_parents (metafiles_directory_uri, METAFILES_DIRECTORY_PERMISSIONS);
|
||||
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILEEXISTS) {
|
||||
gnome_vfs_uri_unref (metafiles_directory_uri);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Construct a file name from the URI. */
|
||||
uri_as_string = gnome_vfs_uri_to_string (directory->details->uri,
|
||||
GNOME_VFS_URI_HIDE_NONE);
|
||||
escaped_uri = nautilus_directory_escape_slashes (uri_as_string);
|
||||
g_free (uri_as_string);
|
||||
file_name = g_strconcat (escaped_uri, ".xml", NULL);
|
||||
g_free (escaped_uri);
|
||||
|
||||
/* Construct a URI for something in the "metafiles" directory. */
|
||||
alternate_uri = gnome_vfs_uri_append_path (metafiles_directory_uri, file_name);
|
||||
gnome_vfs_uri_unref (metafiles_directory_uri);
|
||||
g_free (file_name);
|
||||
|
||||
/* Switch over to the new URI. */
|
||||
if (directory->details->metafile_uri != NULL)
|
||||
gnome_vfs_uri_unref (directory->details->metafile_uri);
|
||||
directory->details->metafile_uri = alternate_uri;
|
||||
directory->details->is_alternate_metafile_uri = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if NAUTILUS_DIRECTORY_ASYNC
|
||||
|
||||
|
@ -335,7 +496,7 @@ nautilus_directory_new (const char* uri)
|
|||
|
||||
directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
|
||||
|
||||
directory->details->uri_text = g_strdup (uri);
|
||||
directory->details->uri_text = g_strdup(uri);
|
||||
directory->details->uri = vfs_uri;
|
||||
directory->details->metafile_uri = metafile_uri;
|
||||
|
||||
|
@ -377,7 +538,7 @@ nautilus_directory_get_metadata (NautilusDirectory *directory,
|
|||
result = g_strdup (default_metadata);
|
||||
else
|
||||
result = g_strdup (property);
|
||||
g_free (property);
|
||||
xmlFree (property);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -461,6 +622,16 @@ nautilus_self_check_directory (void)
|
|||
gtk_object_unref (GTK_OBJECT (directory));
|
||||
|
||||
g_assert (g_hash_table_size (directory_objects) == 0);
|
||||
|
||||
/* nautilus_directory_escape_slashes */
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes (""), "");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a"), "a");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("/"), "%2F");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%"), "%25");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a/a"), "a%2Fa");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a%a"), "a%25a");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
|
||||
}
|
||||
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
nautilus-directory.h: Nautilus directory model.
|
||||
|
||||
Copyright (C) 1999 Eazel, Inc.
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
|
|
|
@ -32,6 +32,7 @@ libnautilusinclude_HEADERS= \
|
|||
gtkscrollframe.h \
|
||||
nautilus.h \
|
||||
nautilus-background.h \
|
||||
nautilus-debug.h \
|
||||
nautilus-directory.h \
|
||||
nautilus-file-utilities.h \
|
||||
nautilus-gtk-extensions.h \
|
||||
|
@ -51,6 +52,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
|
|||
gtkscrollframe.c \
|
||||
nautilus-background.c \
|
||||
nautilus-background-canvas-group.c \
|
||||
nautilus-debug.c \
|
||||
nautilus-directory.c \
|
||||
nautilus-file-utilities.c \
|
||||
nautilus-gtk-extensions.c \
|
||||
|
|
87
libnautilus/nautilus-debug.c
Normal file
87
libnautilus/nautilus-debug.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-debug.c: Nautilus debugging aids.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Darin Adler <darin@eazel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "nautilus-debug.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* Raise a SIGINT signal to get the attention of the debugger.
|
||||
When not running under the debugger, we don't want to stop,
|
||||
so we ignore the signal for just the moment that we raise it.
|
||||
*/
|
||||
void
|
||||
nautilus_stop_in_debugger (void)
|
||||
{
|
||||
void (* saved_handler) (int);
|
||||
|
||||
saved_handler = signal (SIGINT, SIG_IGN);
|
||||
raise (SIGINT);
|
||||
signal (SIGINT, saved_handler);
|
||||
}
|
||||
|
||||
/* Stop in the debugger after running the default log handler.
|
||||
This makes certain kinds of messages stop in the debugger
|
||||
without making them fatal.
|
||||
*/
|
||||
static void
|
||||
nautilus_stop_after_default_log_handler (const char *domain,
|
||||
GLogLevelFlags level,
|
||||
const char *message,
|
||||
gpointer data)
|
||||
{
|
||||
g_log_default_handler (domain, level, message, data);
|
||||
nautilus_stop_in_debugger ();
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_set_stop_after_default_log_handler (const char *domain)
|
||||
{
|
||||
g_log_set_handler (domain, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
|
||||
nautilus_stop_after_default_log_handler, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...)
|
||||
{
|
||||
va_list domains;
|
||||
const char *domain;
|
||||
|
||||
nautilus_set_stop_after_default_log_handler (first_domain);
|
||||
|
||||
va_start (domains, first_domain);
|
||||
|
||||
for (;;) {
|
||||
domain = va_arg (domains, const char *);
|
||||
if (domain == NULL)
|
||||
break;
|
||||
nautilus_set_stop_after_default_log_handler (domain);
|
||||
}
|
||||
|
||||
va_end (domains);
|
||||
}
|
31
libnautilus/nautilus-debug.h
Normal file
31
libnautilus/nautilus-debug.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-debug.h: Nautilus debugging aids.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Darin Adler <darin@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_DEBUG_H
|
||||
#define NAUTILUS_DEBUG_H
|
||||
|
||||
void nautilus_stop_in_debugger (void);
|
||||
void nautilus_make_warnings_and_criticals_stop_in_debugger (const char *first_domain, ...);
|
||||
|
||||
#endif /* NAUTILUS_DEBUG_H */
|
|
@ -45,7 +45,18 @@
|
|||
#include "nautilus-lib-self-check-functions.h"
|
||||
#include "nautilus-string.h"
|
||||
|
||||
#define METAFILE_NAME ".nautilus.xml"
|
||||
#define METAFILE_NAME ".nautilus-metafile.xml"
|
||||
#define METAFILE_PERMISSIONS (GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE \
|
||||
| GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \
|
||||
| GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE)
|
||||
|
||||
#define NAUTILUS_DIRECTORY_NAME ".nautilus"
|
||||
#define METAFILES_DIRECTORY_NAME "metafiles"
|
||||
#define METAFILES_DIRECTORY_PERMISSIONS (GNOME_VFS_PERM_USER_ALL \
|
||||
| GNOME_VFS_PERM_GROUP_ALL \
|
||||
| GNOME_VFS_PERM_OTHER_ALL)
|
||||
#define METAFILE_SUFFIX ".xml"
|
||||
|
||||
#define METAFILE_XML_VERSION "1.0"
|
||||
|
||||
static void nautilus_directory_initialize_class (gpointer klass);
|
||||
|
@ -58,6 +69,7 @@ static void nautilus_directory_read_metafile (NautilusDirectory *directory);
|
|||
static void nautilus_directory_write_metafile (NautilusDirectory *directory);
|
||||
static void nautilus_directory_request_write_metafile (NautilusDirectory *directory);
|
||||
static void nautilus_directory_remove_write_metafile_idle (NautilusDirectory *directory);
|
||||
static gboolean nautilus_directory_switch_to_alternate_metafile_uri (NautilusDirectory *directory);
|
||||
|
||||
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (NautilusDirectory, nautilus_directory, GTK_TYPE_OBJECT)
|
||||
|
||||
|
@ -69,6 +81,7 @@ struct _NautilusDirectoryDetails
|
|||
GnomeVFSURI *uri;
|
||||
|
||||
GnomeVFSURI *metafile_uri;
|
||||
gboolean is_alternate_metafile_uri;
|
||||
xmlDoc *metafile_tree;
|
||||
int write_metafile_idle_id;
|
||||
|
||||
|
@ -172,52 +185,39 @@ nautilus_directory_get (const char *uri)
|
|||
with async. calls; currently you can only get the file length with
|
||||
a synchronous call.
|
||||
*/
|
||||
static void
|
||||
nautilus_directory_read_metafile (NautilusDirectory *directory)
|
||||
static GnomeVFSResult
|
||||
nautilus_directory_try_to_read_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSFileInfo metafile_info;
|
||||
GnomeVFSHandle *metafile_handle;
|
||||
char *buffer;
|
||||
GnomeVFSFileSize size, actual_size;
|
||||
char *buffer;
|
||||
|
||||
g_assert (directory->details->metafile_tree == NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details->metafile_tree == NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
|
||||
result = gnome_vfs_get_file_info_uri (directory->details->metafile_uri,
|
||||
&metafile_info,
|
||||
GNOME_VFS_FILE_INFO_DEFAULT,
|
||||
NULL);
|
||||
if (result == GNOME_VFS_ERROR_NOTFOUND)
|
||||
return;
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_get_file_info_uri failed");
|
||||
|
||||
metafile_handle = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
if (result == GNOME_VFS_OK)
|
||||
result = gnome_vfs_open_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_READ);
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_open_uri failed");
|
||||
}
|
||||
|
||||
if (result == GNOME_VFS_OK) {
|
||||
size = metafile_info.size;
|
||||
if (size != metafile_info.size) {
|
||||
g_warning ("nautilus_directory_read_metafile: metafile too large");
|
||||
if (size != metafile_info.size)
|
||||
result = GNOME_VFS_ERROR_TOOBIG;
|
||||
}
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
buffer = g_malloc (size);
|
||||
|
||||
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_read_metafile: gnome_vfs_read failed");
|
||||
else if (actual_size != size)
|
||||
g_warning ("nautilus_directory_read_metafile: size changed between get_info and read");
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
|
@ -227,6 +227,24 @@ nautilus_directory_read_metafile (NautilusDirectory *directory)
|
|||
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_directory_read_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
|
||||
|
||||
result = nautilus_directory_try_to_read_metafile (directory);
|
||||
if (result == GNOME_VFS_ERROR_ACCESSDENIED && !directory->details->is_alternate_metafile_uri)
|
||||
if (nautilus_directory_switch_to_alternate_metafile_uri (directory))
|
||||
result = nautilus_directory_try_to_read_metafile (directory);
|
||||
|
||||
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_NOTFOUND)
|
||||
g_warning ("nautilus_directory_read_metafile failed to read metafile - we should report this to the user");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -239,8 +257,8 @@ nautilus_directory_remove_write_metafile_idle (NautilusDirectory *directory)
|
|||
}
|
||||
|
||||
/* This writes the metafile synchronously. This must go eventually. */
|
||||
static void
|
||||
nautilus_directory_write_metafile (NautilusDirectory *directory)
|
||||
static GnomeVFSResult
|
||||
nautilus_directory_try_to_write_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
xmlChar *buffer;
|
||||
int buffer_size;
|
||||
|
@ -248,6 +266,38 @@ nautilus_directory_write_metafile (NautilusDirectory *directory)
|
|||
GnomeVFSHandle *metafile_handle;
|
||||
GnomeVFSFileSize actual_size;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details != NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
g_return_val_if_fail (directory->details->metafile_tree != NULL, GNOME_VFS_ERROR_GENERIC);
|
||||
|
||||
metafile_handle = NULL;
|
||||
result = gnome_vfs_create_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
FALSE,
|
||||
METAFILE_PERMISSIONS);
|
||||
|
||||
buffer = NULL;
|
||||
if (result == GNOME_VFS_OK) {
|
||||
xmlDocDumpMemory (directory->details->metafile_tree, &buffer, &buffer_size);
|
||||
result = gnome_vfs_write (metafile_handle, buffer, buffer_size, &actual_size);
|
||||
if (buffer_size != actual_size)
|
||||
result = GNOME_VFS_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
gnome_vfs_close (metafile_handle);
|
||||
|
||||
xmlFree (buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_directory_write_metafile (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
|
||||
|
||||
/* We are about the write the metafile, so we can cancel the pending
|
||||
|
@ -261,30 +311,13 @@ nautilus_directory_write_metafile (NautilusDirectory *directory)
|
|||
if (directory->details->metafile_tree == NULL)
|
||||
return;
|
||||
|
||||
xmlDocDumpMemory (directory->details->metafile_tree, &buffer, &buffer_size);
|
||||
result = nautilus_directory_try_to_write_metafile (directory);
|
||||
if (result == GNOME_VFS_ERROR_ACCESSDENIED && !directory->details->is_alternate_metafile_uri)
|
||||
if (nautilus_directory_switch_to_alternate_metafile_uri (directory))
|
||||
result = nautilus_directory_try_to_write_metafile (directory);
|
||||
|
||||
metafile_handle = NULL;
|
||||
result = gnome_vfs_create_uri (&metafile_handle,
|
||||
directory->details->metafile_uri,
|
||||
GNOME_VFS_OPEN_WRITE,
|
||||
FALSE,
|
||||
GNOME_VFS_PERM_USER_ALL | GNOME_VFS_PERM_GROUP_ALL | GNOME_VFS_PERM_OTHER_ALL);
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_write_metafile: gnome_vfs_create_uri failed");
|
||||
|
||||
if (result == GNOME_VFS_OK) {
|
||||
result = gnome_vfs_write (metafile_handle, buffer, buffer_size, &actual_size);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
g_warning ("nautilus_directory_write_metafile: gnome_vfs_write failed");
|
||||
else if (actual_size != buffer_size)
|
||||
g_warning ("nautilus_directory_read_metafile: unable to write all");
|
||||
}
|
||||
|
||||
if (metafile_handle != NULL)
|
||||
gnome_vfs_close (metafile_handle);
|
||||
|
||||
xmlFree (buffer);
|
||||
g_warning ("nautilus_directory_write_metafile failed to write metafile - we should report this to the user");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -304,6 +337,134 @@ nautilus_directory_request_write_metafile (NautilusDirectory *directory)
|
|||
gtk_idle_add (nautilus_directory_write_metafile_on_idle,
|
||||
directory);
|
||||
}
|
||||
|
||||
/* To use a directory name as a file name, we need to escape any slashes.
|
||||
This means that "/" is replaced by "%2F" and "%" is replaced by "%25".
|
||||
Later we might share the escaping code with some more generic escaping
|
||||
function, but this should do for now.
|
||||
*/
|
||||
static char *
|
||||
nautilus_directory_escape_slashes (const char *path)
|
||||
{
|
||||
char c;
|
||||
const char *in;
|
||||
guint length;
|
||||
char *result;
|
||||
char *out;
|
||||
|
||||
/* Figure out how long the result needs to be. */
|
||||
in = path;
|
||||
length = 0;
|
||||
while ((c = *in++) != '\0')
|
||||
switch (c) {
|
||||
case '/':
|
||||
case '%':
|
||||
length += 3;
|
||||
break;
|
||||
default:
|
||||
length += 1;
|
||||
}
|
||||
|
||||
/* Create the result string. */
|
||||
result = g_malloc (length + 1);
|
||||
in = path;
|
||||
out = result;
|
||||
while ((c = *in++) != '\0')
|
||||
switch (c) {
|
||||
case '/':
|
||||
*out++ = '%';
|
||||
*out++ = '2';
|
||||
*out++ = 'F';
|
||||
break;
|
||||
case '%':
|
||||
*out++ = '%';
|
||||
*out++ = '2';
|
||||
*out++ = '5';
|
||||
break;
|
||||
default:
|
||||
*out++ = c;
|
||||
}
|
||||
g_assert (out == result + length);
|
||||
*out = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GnomeVFSResult
|
||||
nautilus_make_directory_and_parents (GnomeVFSURI *uri, guint permissions)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSURI *parent_uri;
|
||||
|
||||
/* Make the directory, and return right away unless there's
|
||||
a possible problem with the parent.
|
||||
*/
|
||||
result = gnome_vfs_make_directory_for_uri (uri, permissions);
|
||||
if (result != GNOME_VFS_ERROR_NOTFOUND)
|
||||
return result;
|
||||
|
||||
/* If we can't get a parent, we are done. */
|
||||
parent_uri = gnome_vfs_uri_get_parent (uri);
|
||||
if (parent_uri == NULL)
|
||||
return result;
|
||||
|
||||
/* If we can get a parent, use a recursive call to create
|
||||
the parent and its parents.
|
||||
*/
|
||||
result = nautilus_make_directory_and_parents (parent_uri, permissions);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
if (result != GNOME_VFS_OK)
|
||||
return result;
|
||||
|
||||
/* A second try at making the directory after the parents
|
||||
have all been created.
|
||||
*/
|
||||
result = gnome_vfs_make_directory_for_uri (uri, permissions);
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nautilus_directory_switch_to_alternate_metafile_uri (NautilusDirectory *directory)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
GnomeVFSURI *home_uri, *nautilus_directory_uri, *metafiles_directory_uri, *alternate_uri;
|
||||
char *uri_as_string, *escaped_uri, *file_name;
|
||||
|
||||
g_return_val_if_fail (!directory->details->is_alternate_metafile_uri, FALSE);
|
||||
|
||||
/* Ensure that the metafiles directory exists. */
|
||||
home_uri = gnome_vfs_uri_new (g_get_home_dir ());
|
||||
nautilus_directory_uri = gnome_vfs_uri_append_path (home_uri, NAUTILUS_DIRECTORY_NAME);
|
||||
gnome_vfs_uri_unref (home_uri);
|
||||
metafiles_directory_uri = gnome_vfs_uri_append_path (nautilus_directory_uri, METAFILES_DIRECTORY_NAME);
|
||||
gnome_vfs_uri_unref (nautilus_directory_uri);
|
||||
result = nautilus_make_directory_and_parents (metafiles_directory_uri, METAFILES_DIRECTORY_PERMISSIONS);
|
||||
if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_FILEEXISTS) {
|
||||
gnome_vfs_uri_unref (metafiles_directory_uri);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Construct a file name from the URI. */
|
||||
uri_as_string = gnome_vfs_uri_to_string (directory->details->uri,
|
||||
GNOME_VFS_URI_HIDE_NONE);
|
||||
escaped_uri = nautilus_directory_escape_slashes (uri_as_string);
|
||||
g_free (uri_as_string);
|
||||
file_name = g_strconcat (escaped_uri, ".xml", NULL);
|
||||
g_free (escaped_uri);
|
||||
|
||||
/* Construct a URI for something in the "metafiles" directory. */
|
||||
alternate_uri = gnome_vfs_uri_append_path (metafiles_directory_uri, file_name);
|
||||
gnome_vfs_uri_unref (metafiles_directory_uri);
|
||||
g_free (file_name);
|
||||
|
||||
/* Switch over to the new URI. */
|
||||
if (directory->details->metafile_uri != NULL)
|
||||
gnome_vfs_uri_unref (directory->details->metafile_uri);
|
||||
directory->details->metafile_uri = alternate_uri;
|
||||
directory->details->is_alternate_metafile_uri = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if NAUTILUS_DIRECTORY_ASYNC
|
||||
|
||||
|
@ -335,7 +496,7 @@ nautilus_directory_new (const char* uri)
|
|||
|
||||
directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
|
||||
|
||||
directory->details->uri_text = g_strdup (uri);
|
||||
directory->details->uri_text = g_strdup(uri);
|
||||
directory->details->uri = vfs_uri;
|
||||
directory->details->metafile_uri = metafile_uri;
|
||||
|
||||
|
@ -377,7 +538,7 @@ nautilus_directory_get_metadata (NautilusDirectory *directory,
|
|||
result = g_strdup (default_metadata);
|
||||
else
|
||||
result = g_strdup (property);
|
||||
g_free (property);
|
||||
xmlFree (property);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -461,6 +622,16 @@ nautilus_self_check_directory (void)
|
|||
gtk_object_unref (GTK_OBJECT (directory));
|
||||
|
||||
g_assert (g_hash_table_size (directory_objects) == 0);
|
||||
|
||||
/* nautilus_directory_escape_slashes */
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes (""), "");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a"), "a");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("/"), "%2F");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%"), "%25");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a/a"), "a%2Fa");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("a%a"), "a%25a");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%25"), "%2525");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_escape_slashes ("%2F"), "%252F");
|
||||
}
|
||||
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
nautilus-directory.h: Nautilus directory model.
|
||||
|
||||
Copyright (C) 1999 Eazel, Inc.
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
/* ntl-view-frame.c: Implementation for object that represents a
|
||||
nautilus view implementation. */
|
||||
|
||||
#include "ntl-view-frame.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "libnautilus.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
|
||||
|
||||
/*
|
||||
* libnautilus: A library for nautilus view implementations.
|
||||
|
@ -30,7 +30,9 @@
|
|||
#ifndef NTL_VIEW_FRAME_H
|
||||
#define NTL_VIEW_FRAME_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkbin.h>
|
||||
#include "nautilus.h"
|
||||
#include <bonobo/gnome-object.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -47,42 +49,42 @@ typedef struct _NautilusViewFrameClass NautilusViewFrameClass;
|
|||
|
||||
struct _NautilusViewFrameClass
|
||||
{
|
||||
GtkBinClass parent_spot;
|
||||
GtkBinClass parent_spot;
|
||||
|
||||
void (*notify_location_change) (NautilusViewFrame *view,
|
||||
void (*notify_location_change) (NautilusViewFrame *view,
|
||||
Nautilus_NavigationInfo *nav_context);
|
||||
void (*notify_selection_change) (NautilusViewFrame *view,
|
||||
void (*notify_selection_change) (NautilusViewFrame *view,
|
||||
Nautilus_SelectionInfo *nav_context);
|
||||
void (*load_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*save_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*show_properties) (NautilusViewFrame *view);
|
||||
void (*stop_location_change) (NautilusViewFrame *view);
|
||||
void (*load_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*save_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*show_properties) (NautilusViewFrame *view);
|
||||
void (*stop_location_change) (NautilusViewFrame *view);
|
||||
|
||||
GtkBinClass *parent_class;
|
||||
GtkBinClass *parent_class;
|
||||
|
||||
gpointer servant_init_func, servant_destroy_func, vepv;
|
||||
gpointer servant_init_func, servant_destroy_func, vepv;
|
||||
};
|
||||
|
||||
struct _NautilusViewFrame
|
||||
{
|
||||
GtkBin parent;
|
||||
GtkBin parent;
|
||||
|
||||
GtkWidget *main_window;
|
||||
GtkWidget *main_window;
|
||||
|
||||
GnomeObject *control, *view_server;
|
||||
Nautilus_ViewFrame view_frame;
|
||||
GnomeObject *control, *view_server;
|
||||
Nautilus_ViewFrame view_frame;
|
||||
};
|
||||
|
||||
GtkType nautilus_view_frame_get_type (void);
|
||||
void nautilus_view_frame_request_location_change (NautilusViewFrame *view,
|
||||
Nautilus_NavigationRequestInfo *loc);
|
||||
void nautilus_view_frame_request_selection_change (NautilusViewFrame *view,
|
||||
Nautilus_SelectionRequestInfo *loc);
|
||||
void nautilus_view_frame_request_status_change (NautilusViewFrame *view,
|
||||
Nautilus_StatusRequestInfo *loc);
|
||||
void nautilus_view_frame_request_progress_change (NautilusViewFrame *view,
|
||||
Nautilus_ProgressRequestInfo *loc);
|
||||
GnomeObject *nautilus_view_frame_get_gnome_object (NautilusViewFrame *view);
|
||||
GtkType nautilus_view_frame_get_type (void);
|
||||
void nautilus_view_frame_request_location_change (NautilusViewFrame *view,
|
||||
Nautilus_NavigationRequestInfo *loc);
|
||||
void nautilus_view_frame_request_selection_change (NautilusViewFrame *view,
|
||||
Nautilus_SelectionRequestInfo *loc);
|
||||
void nautilus_view_frame_request_status_change (NautilusViewFrame *view,
|
||||
Nautilus_StatusRequestInfo *loc);
|
||||
void nautilus_view_frame_request_progress_change (NautilusViewFrame *view,
|
||||
Nautilus_ProgressRequestInfo *loc);
|
||||
GnomeObject *nautilus_view_frame_get_gnome_object (NautilusViewFrame *view);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
/* ntl-view-frame.c: Implementation for object that represents a
|
||||
nautilus view implementation. */
|
||||
|
||||
#include "ntl-view-frame.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "libnautilus.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
|
||||
|
||||
/*
|
||||
* libnautilus: A library for nautilus view implementations.
|
||||
|
@ -30,7 +30,9 @@
|
|||
#ifndef NTL_VIEW_FRAME_H
|
||||
#define NTL_VIEW_FRAME_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkbin.h>
|
||||
#include "nautilus.h"
|
||||
#include <bonobo/gnome-object.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -47,42 +49,42 @@ typedef struct _NautilusViewFrameClass NautilusViewFrameClass;
|
|||
|
||||
struct _NautilusViewFrameClass
|
||||
{
|
||||
GtkBinClass parent_spot;
|
||||
GtkBinClass parent_spot;
|
||||
|
||||
void (*notify_location_change) (NautilusViewFrame *view,
|
||||
void (*notify_location_change) (NautilusViewFrame *view,
|
||||
Nautilus_NavigationInfo *nav_context);
|
||||
void (*notify_selection_change) (NautilusViewFrame *view,
|
||||
void (*notify_selection_change) (NautilusViewFrame *view,
|
||||
Nautilus_SelectionInfo *nav_context);
|
||||
void (*load_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*save_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*show_properties) (NautilusViewFrame *view);
|
||||
void (*stop_location_change) (NautilusViewFrame *view);
|
||||
void (*load_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*save_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*show_properties) (NautilusViewFrame *view);
|
||||
void (*stop_location_change) (NautilusViewFrame *view);
|
||||
|
||||
GtkBinClass *parent_class;
|
||||
GtkBinClass *parent_class;
|
||||
|
||||
gpointer servant_init_func, servant_destroy_func, vepv;
|
||||
gpointer servant_init_func, servant_destroy_func, vepv;
|
||||
};
|
||||
|
||||
struct _NautilusViewFrame
|
||||
{
|
||||
GtkBin parent;
|
||||
GtkBin parent;
|
||||
|
||||
GtkWidget *main_window;
|
||||
GtkWidget *main_window;
|
||||
|
||||
GnomeObject *control, *view_server;
|
||||
Nautilus_ViewFrame view_frame;
|
||||
GnomeObject *control, *view_server;
|
||||
Nautilus_ViewFrame view_frame;
|
||||
};
|
||||
|
||||
GtkType nautilus_view_frame_get_type (void);
|
||||
void nautilus_view_frame_request_location_change (NautilusViewFrame *view,
|
||||
Nautilus_NavigationRequestInfo *loc);
|
||||
void nautilus_view_frame_request_selection_change (NautilusViewFrame *view,
|
||||
Nautilus_SelectionRequestInfo *loc);
|
||||
void nautilus_view_frame_request_status_change (NautilusViewFrame *view,
|
||||
Nautilus_StatusRequestInfo *loc);
|
||||
void nautilus_view_frame_request_progress_change (NautilusViewFrame *view,
|
||||
Nautilus_ProgressRequestInfo *loc);
|
||||
GnomeObject *nautilus_view_frame_get_gnome_object (NautilusViewFrame *view);
|
||||
GtkType nautilus_view_frame_get_type (void);
|
||||
void nautilus_view_frame_request_location_change (NautilusViewFrame *view,
|
||||
Nautilus_NavigationRequestInfo *loc);
|
||||
void nautilus_view_frame_request_selection_change (NautilusViewFrame *view,
|
||||
Nautilus_SelectionRequestInfo *loc);
|
||||
void nautilus_view_frame_request_status_change (NautilusViewFrame *view,
|
||||
Nautilus_StatusRequestInfo *loc);
|
||||
void nautilus_view_frame_request_progress_change (NautilusViewFrame *view,
|
||||
Nautilus_ProgressRequestInfo *loc);
|
||||
GnomeObject *nautilus_view_frame_get_gnome_object (NautilusViewFrame *view);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
/* ntl-view-frame.c: Implementation for object that represents a
|
||||
nautilus view implementation. */
|
||||
|
||||
#include "ntl-view-frame.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "libnautilus.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
|
||||
|
||||
/*
|
||||
* libnautilus: A library for nautilus view implementations.
|
||||
|
@ -30,7 +30,9 @@
|
|||
#ifndef NTL_VIEW_FRAME_H
|
||||
#define NTL_VIEW_FRAME_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkbin.h>
|
||||
#include "nautilus.h"
|
||||
#include <bonobo/gnome-object.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -47,42 +49,42 @@ typedef struct _NautilusViewFrameClass NautilusViewFrameClass;
|
|||
|
||||
struct _NautilusViewFrameClass
|
||||
{
|
||||
GtkBinClass parent_spot;
|
||||
GtkBinClass parent_spot;
|
||||
|
||||
void (*notify_location_change) (NautilusViewFrame *view,
|
||||
void (*notify_location_change) (NautilusViewFrame *view,
|
||||
Nautilus_NavigationInfo *nav_context);
|
||||
void (*notify_selection_change) (NautilusViewFrame *view,
|
||||
void (*notify_selection_change) (NautilusViewFrame *view,
|
||||
Nautilus_SelectionInfo *nav_context);
|
||||
void (*load_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*save_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*show_properties) (NautilusViewFrame *view);
|
||||
void (*stop_location_change) (NautilusViewFrame *view);
|
||||
void (*load_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*save_state) (NautilusViewFrame *view, const char *config_path);
|
||||
void (*show_properties) (NautilusViewFrame *view);
|
||||
void (*stop_location_change) (NautilusViewFrame *view);
|
||||
|
||||
GtkBinClass *parent_class;
|
||||
GtkBinClass *parent_class;
|
||||
|
||||
gpointer servant_init_func, servant_destroy_func, vepv;
|
||||
gpointer servant_init_func, servant_destroy_func, vepv;
|
||||
};
|
||||
|
||||
struct _NautilusViewFrame
|
||||
{
|
||||
GtkBin parent;
|
||||
GtkBin parent;
|
||||
|
||||
GtkWidget *main_window;
|
||||
GtkWidget *main_window;
|
||||
|
||||
GnomeObject *control, *view_server;
|
||||
Nautilus_ViewFrame view_frame;
|
||||
GnomeObject *control, *view_server;
|
||||
Nautilus_ViewFrame view_frame;
|
||||
};
|
||||
|
||||
GtkType nautilus_view_frame_get_type (void);
|
||||
void nautilus_view_frame_request_location_change (NautilusViewFrame *view,
|
||||
Nautilus_NavigationRequestInfo *loc);
|
||||
void nautilus_view_frame_request_selection_change (NautilusViewFrame *view,
|
||||
Nautilus_SelectionRequestInfo *loc);
|
||||
void nautilus_view_frame_request_status_change (NautilusViewFrame *view,
|
||||
Nautilus_StatusRequestInfo *loc);
|
||||
void nautilus_view_frame_request_progress_change (NautilusViewFrame *view,
|
||||
Nautilus_ProgressRequestInfo *loc);
|
||||
GnomeObject *nautilus_view_frame_get_gnome_object (NautilusViewFrame *view);
|
||||
GtkType nautilus_view_frame_get_type (void);
|
||||
void nautilus_view_frame_request_location_change (NautilusViewFrame *view,
|
||||
Nautilus_NavigationRequestInfo *loc);
|
||||
void nautilus_view_frame_request_selection_change (NautilusViewFrame *view,
|
||||
Nautilus_SelectionRequestInfo *loc);
|
||||
void nautilus_view_frame_request_status_change (NautilusViewFrame *view,
|
||||
Nautilus_StatusRequestInfo *loc);
|
||||
void nautilus_view_frame_request_progress_change (NautilusViewFrame *view,
|
||||
Nautilus_ProgressRequestInfo *loc);
|
||||
GnomeObject *nautilus_view_frame_get_gnome_object (NautilusViewFrame *view);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,13 +26,9 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include <libnautilus/nautilus-gtk-macros.h>
|
||||
|
||||
#include "fm-directory-view.h"
|
||||
#include "fm-directory-view-icons.h"
|
||||
#include "fm-icon-cache.h"
|
||||
#include <libnautilus/nautilus-gtk-macros.h>
|
||||
|
||||
|
||||
/* forward declarations */
|
||||
|
@ -135,19 +131,6 @@ fm_directory_view_icons_initialize (gpointer object, gpointer klass)
|
|||
|
||||
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (FMDirectoryViewIcons, fm_directory_view_icons, FM_TYPE_DIRECTORY_VIEW);
|
||||
|
||||
/**
|
||||
* fm_directory_view_icons_new:
|
||||
*
|
||||
* Create a new FMDirectoryViewIcons.
|
||||
*
|
||||
* Return value: The newly-allocated FMDirectoryViewIcons.
|
||||
**/
|
||||
GtkWidget *
|
||||
fm_directory_view_icons_new (void)
|
||||
{
|
||||
return gtk_widget_new (fm_directory_view_icons_get_type (), NULL);
|
||||
}
|
||||
|
||||
|
||||
static GnomeIconContainer *
|
||||
create_icon_container (FMDirectoryViewIcons *icon_view)
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
Authors: John Sullivan <sullivan@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef __FM_DIRECTORY_VIEW_ICONS_H__
|
||||
#define __FM_DIRECTORY_VIEW_ICONS_H__
|
||||
#ifndef FM_DIRECTORY_VIEW_ICONS_H
|
||||
#define FM_DIRECTORY_VIEW_ICONS_H
|
||||
|
||||
#include "fm-directory-view.h"
|
||||
#include <libnautilus/gnome-icon-container.h>
|
||||
|
||||
|
||||
typedef struct _FMDirectoryViewIcons FMDirectoryViewIcons;
|
||||
typedef struct _FMDirectoryViewIconsClass FMDirectoryViewIconsClass;
|
||||
|
@ -48,22 +48,16 @@ struct _FMDirectoryViewIconsClass {
|
|||
FMDirectoryViewClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* GtkObject support */
|
||||
GtkType fm_directory_view_icons_get_type (void);
|
||||
GtkWidget *fm_directory_view_icons_new (void);
|
||||
|
||||
GtkType fm_directory_view_icons_get_type (void);
|
||||
|
||||
/* User interface related calls.
|
||||
* FIXME: None of these are currently used. Remove them eventually if
|
||||
* we're not going to use them.
|
||||
*/
|
||||
GnomeIconContainerLayout *
|
||||
fm_directory_view_icons_get_icon_layout (FMDirectoryViewIcons *view);
|
||||
void fm_directory_view_icons_set_icon_layout (FMDirectoryViewIcons *view,
|
||||
const GnomeIconContainerLayout
|
||||
*icon_layout);
|
||||
void fm_directory_view_icons_line_up_icons (FMDirectoryViewIcons *view);
|
||||
GnomeIconContainerLayout *fm_directory_view_icons_get_icon_layout (FMDirectoryViewIcons *view);
|
||||
void fm_directory_view_icons_set_icon_layout (FMDirectoryViewIcons *view,
|
||||
const GnomeIconContainerLayout *icon_layout);
|
||||
void fm_directory_view_icons_line_up_icons (FMDirectoryViewIcons *view);
|
||||
|
||||
|
||||
#endif /* __FM_DIRECTORY_VIEW_ICONS_H__ */
|
||||
#endif /* FM_DIRECTORY_VIEW_ICONS_H */
|
||||
|
|
|
@ -26,14 +26,11 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include <libnautilus/gtkflist.h>
|
||||
#include <libnautilus/nautilus-gtk-macros.h>
|
||||
|
||||
#include "fm-directory-view.h"
|
||||
#include "fm-directory-view-list.h"
|
||||
#include "fm-icon-cache.h"
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libnautilus/nautilus-gtk-macros.h>
|
||||
#include <libnautilus/gtkflist.h>
|
||||
|
||||
static FMDirectoryViewClass *parent_class = NULL;
|
||||
|
||||
|
@ -102,7 +99,6 @@ fm_directory_view_list_destroy (GtkObject *object)
|
|||
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define LIST_VIEW_COLUMN_ICON 0
|
||||
|
@ -111,13 +107,8 @@ fm_directory_view_list_destroy (GtkObject *object)
|
|||
#define LIST_VIEW_COLUMN_DATE_MODIFIED 3
|
||||
#define LIST_VIEW_COLUMN_COUNT 4
|
||||
|
||||
GtkWidget *
|
||||
fm_directory_view_list_new (void)
|
||||
{
|
||||
return gtk_widget_new (fm_directory_view_list_get_type (), NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GtkFList *
|
||||
create_flist (FMDirectoryViewList *list_view)
|
||||
{
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
Authors: John Sullivan <sullivan@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef __FM_DIRECTORY_VIEW_LIST_H__
|
||||
#define __FM_DIRECTORY_VIEW_LIST_H__
|
||||
#ifndef FM_DIRECTORY_VIEW_LIST_H
|
||||
#define FM_DIRECTORY_VIEW_LIST_H
|
||||
|
||||
|
||||
#include "fm-directory-view.h"
|
||||
|
||||
typedef struct _FMDirectoryViewList FMDirectoryViewList;
|
||||
typedef struct _FMDirectoryViewListClass FMDirectoryViewListClass;
|
||||
|
@ -44,9 +44,7 @@ struct _FMDirectoryViewListClass {
|
|||
FMDirectoryViewClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* GtkObject support */
|
||||
GtkType fm_directory_view_list_get_type (void);
|
||||
GtkWidget *fm_directory_view_list_new (void);
|
||||
GtkType fm_directory_view_list_get_type (void);
|
||||
|
||||
#endif /* __FM_DIRECTORY_VIEW_LIST_H__ */
|
||||
#endif /* FM_DIRECTORY_VIEW_LIST_H */
|
||||
|
|
|
@ -27,16 +27,16 @@
|
|||
#endif
|
||||
|
||||
#include "fm-directory-view.h"
|
||||
#include "fm-public-api.h"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
#include <gtk/gtkmain.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnomevfs/gnome-vfs-async-ops.h>
|
||||
#include <libgnomevfs/gnome-vfs-directory-list.h>
|
||||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <libgnomevfs/gnome-vfs-utils.h>
|
||||
#include <libnautilus/libnautilus.h>
|
||||
#include <libnautilus/nautilus-gtk-macros.h>
|
||||
|
||||
|
||||
#define FM_DEBUG(x) g_message x
|
||||
|
||||
#define DISPLAY_TIMEOUT_INTERVAL 500
|
||||
#define ENTRIES_PER_CB 1
|
||||
|
||||
|
@ -79,10 +79,10 @@ static void notify_location_change_cb (NautilusViewFrame *view_frame,
|
|||
Nautilus_NavigationInfo *nav_context,
|
||||
FMDirectoryView *directory_view);
|
||||
|
||||
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW);
|
||||
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_entry);
|
||||
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear);
|
||||
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection);
|
||||
NAUTILUS_DEFINE_GET_TYPE_FUNCTION (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW)
|
||||
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_entry)
|
||||
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear)
|
||||
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection)
|
||||
|
||||
static void
|
||||
fm_directory_view_initialize_class (gpointer klass)
|
||||
|
@ -174,8 +174,6 @@ fm_directory_view_initialize (gpointer object, gpointer klass)
|
|||
(nautilus_content_view_frame_get_type(),
|
||||
NULL));
|
||||
|
||||
printf("*********** A %x\n", (unsigned) directory_view);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(directory_view->details->view_frame),
|
||||
"stop_location_change",
|
||||
GTK_SIGNAL_FUNC (stop_location_change_cb),
|
||||
|
@ -197,8 +195,6 @@ fm_directory_view_destroy (GtkObject *object)
|
|||
{
|
||||
FMDirectoryView *view;
|
||||
|
||||
FM_DEBUG (("Entering function."));
|
||||
|
||||
view = FM_DIRECTORY_VIEW (object);
|
||||
|
||||
if (view->details->directory_list != NULL)
|
||||
|
@ -207,10 +203,8 @@ fm_directory_view_destroy (GtkObject *object)
|
|||
if (view->details->uri != NULL)
|
||||
gnome_vfs_uri_unref (view->details->uri);
|
||||
|
||||
if (view->details->vfs_async_handle != NULL) {
|
||||
FM_DEBUG (("Cancelling VFS operation."));
|
||||
if (view->details->vfs_async_handle != NULL)
|
||||
gnome_vfs_async_cancel (view->details->vfs_async_handle);
|
||||
}
|
||||
|
||||
if (view->details->display_timeout_id != 0)
|
||||
gtk_timeout_remove (view->details->display_timeout_id);
|
||||
|
@ -251,6 +245,8 @@ display_selection_info (FMDirectoryView *view)
|
|||
size += info->size;
|
||||
}
|
||||
|
||||
g_list_free (selection);
|
||||
|
||||
if (count == 0) {
|
||||
memset(&sri, 0, sizeof(sri));
|
||||
sri.status_string = "";
|
||||
|
@ -260,17 +256,18 @@ display_selection_info (FMDirectoryView *view)
|
|||
}
|
||||
|
||||
size_string = gnome_vfs_file_size_to_string (size);
|
||||
if (count == 1)
|
||||
msg = g_strdup_printf (_("1 file selected -- %s"), size_string);
|
||||
else
|
||||
msg = g_strdup_printf (_("%d files selected -- %s"), count, size_string);
|
||||
g_free (size_string);
|
||||
|
||||
msg = g_strdup_printf (_("%d %s selected -- %s"),
|
||||
count, (count==1)?_("file"):_("files"), size_string);
|
||||
memset(&sri, 0, sizeof(sri));
|
||||
sri.status_string = msg;
|
||||
nautilus_view_frame_request_status_change
|
||||
(NAUTILUS_VIEW_FRAME (view->details->view_frame), &sri);
|
||||
g_free (msg);
|
||||
|
||||
g_free (size_string);
|
||||
g_list_free (selection);
|
||||
g_free (msg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -278,17 +275,12 @@ display_selection_info (FMDirectoryView *view)
|
|||
static void
|
||||
notify_location_change_cb (NautilusViewFrame *view_frame, Nautilus_NavigationInfo *nav_context, FMDirectoryView *directory_view)
|
||||
{
|
||||
puts("******* XXX notify_location_change");
|
||||
g_message("Directory view is loading URL %s", nav_context->requested_uri);
|
||||
fm_directory_view_load_uri(directory_view, nav_context->requested_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
stop_location_change_cb (NautilusViewFrame *view_frame, FMDirectoryView *directory_view)
|
||||
{
|
||||
printf("*********** B %x\n", (unsigned) directory_view);
|
||||
|
||||
g_message("Directory view is stopping");
|
||||
fm_directory_view_stop(directory_view);
|
||||
}
|
||||
|
||||
|
@ -456,28 +448,11 @@ directory_load_cb (GnomeVFSAsyncHandle *handle,
|
|||
if (result == GNOME_VFS_ERROR_EOF) {
|
||||
display_pending_entries (view);
|
||||
stop_load (view, FALSE);
|
||||
/* gtk_signal_emit (GTK_OBJECT (view), signals[LOAD_DONE]); */
|
||||
} else if (result != GNOME_VFS_OK) {
|
||||
stop_load (view, TRUE);
|
||||
/* gtk_signal_emit (GTK_OBJECT (view), signals[LOAD_FAILED],
|
||||
result); */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fm_directory_view_new:
|
||||
*
|
||||
* Create a new FMDirectoryView.
|
||||
*
|
||||
* Return value: The newly-allocated FMDirectoryView.
|
||||
**/
|
||||
GtkWidget *
|
||||
fm_directory_view_new (void)
|
||||
{
|
||||
return gtk_widget_new(fm_directory_view_get_type (), NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* fm_directory_view_clear:
|
||||
|
@ -797,7 +772,6 @@ fm_directory_view_sort (FMDirectoryView *view,
|
|||
return;
|
||||
}
|
||||
|
||||
FM_DEBUG (("Sorting."));
|
||||
gnome_vfs_directory_list_sort (view->details->directory_list, FALSE, rules);
|
||||
|
||||
fm_directory_view_populate (view);
|
||||
|
|
|
@ -21,13 +21,16 @@
|
|||
*
|
||||
* Author: Ettore Perazzoli
|
||||
*/
|
||||
#ifndef __FM_DIRECTORY_VIEW_H__
|
||||
#define __FM_DIRECTORY_VIEW_H__
|
||||
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <libnautilus/libnautilus.h>
|
||||
#ifndef FM_DIRECTORY_VIEW_H
|
||||
#define FM_DIRECTORY_VIEW_H
|
||||
|
||||
#include <gtk/gtkscrolledwindow.h>
|
||||
#include <libgnomevfs/gnome-vfs-types.h>
|
||||
#include <libnautilus/ntl-content-view-frame.h>
|
||||
|
||||
|
||||
|
||||
enum _FMDirectoryViewSortType {
|
||||
FM_DIRECTORY_VIEW_SORT_BYNAME,
|
||||
FM_DIRECTORY_VIEW_SORT_BYSIZE,
|
||||
|
@ -72,6 +75,7 @@ struct _FMDirectoryViewClass {
|
|||
*/
|
||||
void (* add_entry) (FMDirectoryView *view,
|
||||
GnomeVFSFileInfo *info);
|
||||
|
||||
/* The 'done_adding_entries' signal is emitted after a set of entries
|
||||
* are added to the view. It can be replaced by a subclass to do any
|
||||
* necessary cleanup (typically, cleanup for code in begin_adding_entries).
|
||||
|
@ -98,7 +102,6 @@ struct _FMDirectoryViewClass {
|
|||
|
||||
/* GtkObject support */
|
||||
GtkType fm_directory_view_get_type (void);
|
||||
GtkWidget *fm_directory_view_new (void);
|
||||
|
||||
/* Component embedding support */
|
||||
NautilusContentViewFrame
|
||||
|
@ -140,5 +143,4 @@ void fm_directory_view_populate (FMDirectoryView *view);
|
|||
gchar *nautilus_file_date_as_string (time_t date);
|
||||
gchar *nautilus_file_size_as_string (GnomeVFSFileSize bytes);
|
||||
|
||||
|
||||
#endif /* __FM_DIRECTORY_VIEW_H__ */
|
||||
#endif /* FM_DIRECTORY_VIEW_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
|
||||
|
||||
/*
|
||||
* Nautilus
|
||||
|
@ -23,85 +23,84 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <libnautilus/libnautilus.h>
|
||||
|
||||
#include "fm-directory-view.h"
|
||||
#include "fm-directory-view-icons.h"
|
||||
#include "fm-directory-view-list.h"
|
||||
#include <libnautilus/nautilus-debug.h>
|
||||
#include <libgnorba/gnorba.h>
|
||||
#include <bonobo/gnome-object.h>
|
||||
#include <bonobo/gnome-generic-factory.h>
|
||||
#include <bonobo/gnome-main.h>
|
||||
#include <libgnomevfs/gnome-vfs-init.h>
|
||||
|
||||
static int object_count = 0;
|
||||
|
||||
static void
|
||||
do_destroy(GtkObject *obj)
|
||||
do_destroy (GtkObject *obj)
|
||||
{
|
||||
object_count--;
|
||||
if(object_count <= 0)
|
||||
gtk_main_quit();
|
||||
object_count--;
|
||||
if (object_count <= 0)
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
static GnomeObject *make_obj(GnomeGenericFactory *Factory, const char *goad_id, gpointer closure)
|
||||
static GnomeObject *
|
||||
make_obj (GnomeGenericFactory *Factory, const char *goad_id, gpointer closure)
|
||||
{
|
||||
FMDirectoryView *dir_view;
|
||||
NautilusContentViewFrame *view_frame;
|
||||
GnomeObject *ctl;
|
||||
|
||||
g_return_val_if_fail(strcmp(goad_id, "ntl_file_manager_icon_view") == 0 ||
|
||||
strcmp(goad_id, "ntl_file_manager_list_view") == 0, NULL);
|
||||
|
||||
if (strcmp (goad_id, "ntl_file_manager_icon_view") == 0)
|
||||
{
|
||||
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_icons_get_type(), NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_list_get_type(), NULL));
|
||||
}
|
||||
|
||||
g_return_val_if_fail(dir_view, NULL);
|
||||
|
||||
view_frame = fm_directory_view_get_view_frame (dir_view);
|
||||
|
||||
if(GNOME_IS_OBJECT(view_frame))
|
||||
return GNOME_OBJECT(view_frame);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(view_frame), "destroy", do_destroy, NULL);
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(view_frame));
|
||||
|
||||
ctl = nautilus_view_frame_get_gnome_object(NAUTILUS_VIEW_FRAME(view_frame));
|
||||
|
||||
object_count++;
|
||||
|
||||
printf("%x\n", (unsigned) ctl);
|
||||
|
||||
return ctl;
|
||||
FMDirectoryView *dir_view;
|
||||
NautilusContentViewFrame *view_frame;
|
||||
|
||||
g_return_val_if_fail (strcmp (goad_id, "ntl_file_manager_icon_view") == 0 ||
|
||||
strcmp (goad_id, "ntl_file_manager_list_view") == 0, NULL);
|
||||
|
||||
if (strcmp (goad_id, "ntl_file_manager_icon_view") == 0)
|
||||
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_icons_get_type (), NULL));
|
||||
else
|
||||
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_list_get_type (), NULL));
|
||||
|
||||
g_return_val_if_fail(dir_view, NULL);
|
||||
|
||||
view_frame = fm_directory_view_get_view_frame (dir_view);
|
||||
|
||||
if (GNOME_IS_OBJECT (view_frame))
|
||||
return GNOME_OBJECT (view_frame);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (view_frame), "destroy", do_destroy, NULL);
|
||||
gtk_widget_show (GTK_WIDGET (view_frame));
|
||||
|
||||
object_count++;
|
||||
|
||||
return nautilus_view_frame_get_gnome_object (NAUTILUS_VIEW_FRAME (view_frame));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
GnomeGenericFactory *factory;
|
||||
CORBA_ORB orb;
|
||||
CORBA_Environment ev;
|
||||
|
||||
CORBA_exception_init(&ev);
|
||||
|
||||
if (getenv("NAUTILUS_DEBUG"))
|
||||
g_log_set_always_fatal (G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL);
|
||||
|
||||
orb = gnome_CORBA_init_with_popt_table("ntl-file-manager", VERSION, &argc, argv, NULL, 0, NULL,
|
||||
GNORBA_INIT_SERVER_FUNC, &ev);
|
||||
bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);
|
||||
g_thread_init (NULL);
|
||||
gnome_vfs_init ();
|
||||
|
||||
factory = gnome_generic_factory_new_multi("ntl_file_manager_factory", make_obj, NULL);
|
||||
|
||||
do {
|
||||
bonobo_main();
|
||||
} while(object_count > 0);
|
||||
|
||||
return 0;
|
||||
CORBA_Environment ev;
|
||||
CORBA_ORB orb;
|
||||
GnomeGenericFactory *factory;
|
||||
|
||||
CORBA_exception_init(&ev);
|
||||
|
||||
/* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set.
|
||||
Unfortunately, this has to be done explicitly for each domain.
|
||||
*/
|
||||
if (getenv("NAUTILUS_DEBUG") != NULL)
|
||||
nautilus_make_warnings_and_criticals_stop_in_debugger
|
||||
(G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", NULL);
|
||||
|
||||
orb = gnome_CORBA_init_with_popt_table("ntl-file-manager", VERSION, &argc, argv, NULL, 0, NULL,
|
||||
GNORBA_INIT_SERVER_FUNC, &ev);
|
||||
bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);
|
||||
g_thread_init (NULL);
|
||||
gnome_vfs_init ();
|
||||
|
||||
factory = gnome_generic_factory_new_multi("ntl_file_manager_factory", make_obj, NULL);
|
||||
|
||||
do
|
||||
bonobo_main();
|
||||
while (object_count > 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef FM_PUBLIC_API_H
|
||||
#define FM_PUBLIC_API_H 1
|
||||
|
||||
GtkType fm_directory_view_get_type(void);
|
||||
|
||||
#endif
|
|
@ -124,9 +124,6 @@ navinfo_read_map_file(const char *fn)
|
|||
if(!strcasecmp(mimetype, "NULL"))
|
||||
mimetype = NULL;
|
||||
|
||||
g_message("Adding mapping of %s -> [%s, %s, %s]",
|
||||
sname, type, mimetype, data);
|
||||
|
||||
nautilus_navinfo_add_mapping(sname, typeval, data, mimetype);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,37 +31,10 @@
|
|||
#include "config.h"
|
||||
#include "nautilus.h"
|
||||
#include "nautilus-self-check-functions.h"
|
||||
#include <libnautilus/nautilus-debug.h>
|
||||
#include <libnautilus/nautilus-lib-self-check-functions.h>
|
||||
#include <libnautilus/nautilus-self-checks.h>
|
||||
|
||||
/* Raise a SIGINT signal to get the attention of the debugger.
|
||||
When not running under the debugger, we don't want to stop,
|
||||
so we ignore the signal for just the moment that we raise it.
|
||||
*/
|
||||
static void
|
||||
stop_in_debugger (void)
|
||||
{
|
||||
void (* saved_handler) (int);
|
||||
|
||||
saved_handler = signal (SIGINT, SIG_IGN);
|
||||
raise (SIGINT);
|
||||
signal (SIGINT, saved_handler);
|
||||
}
|
||||
|
||||
/* Stop in the debugger after running the default log handler.
|
||||
This makes certain kinds of messages stop in the debugger
|
||||
without making them fatal.
|
||||
*/
|
||||
static void
|
||||
nautilus_stop_after_default_log_handler (const char *domain,
|
||||
GLogLevelFlags level,
|
||||
const char *message,
|
||||
gpointer data)
|
||||
{
|
||||
g_log_default_handler (domain, level, message, data);
|
||||
stop_in_debugger ();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -81,10 +54,12 @@ main(int argc, char *argv[])
|
|||
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
/* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. */
|
||||
/* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set.
|
||||
Unfortunately, this has to be done explicitly for each domain.
|
||||
*/
|
||||
if (getenv("NAUTILUS_DEBUG") != NULL)
|
||||
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
|
||||
nautilus_stop_after_default_log_handler, NULL);
|
||||
nautilus_make_warnings_and_criticals_stop_in_debugger
|
||||
(G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "GnomeVFS", NULL);
|
||||
|
||||
/* Initialize the services that we use. */
|
||||
CORBA_exception_init(&ev);
|
||||
|
|
|
@ -417,8 +417,6 @@ nautilus_window_constructed(NautilusWindow *window)
|
|||
GtkWidget *location_bar_box, *statusbar;
|
||||
GtkWidget *temp_frame;
|
||||
|
||||
g_message("XXX Constructed.\n");
|
||||
|
||||
app = GNOME_APP(window);
|
||||
|
||||
/* set up toolbar */
|
||||
|
@ -781,13 +779,13 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
|
|||
|
||||
current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window));
|
||||
parent_uri = gnome_vfs_uri_get_parent (current_uri);
|
||||
gnome_vfs_uri_unref (current_uri);
|
||||
parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
|
||||
nautilus_window_goto_uri (window, parent_uri_string);
|
||||
|
||||
|
||||
g_free (parent_uri_string);
|
||||
gnome_vfs_uri_destroy (current_uri);
|
||||
gnome_vfs_uri_destroy (parent_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -417,8 +417,6 @@ nautilus_window_constructed(NautilusWindow *window)
|
|||
GtkWidget *location_bar_box, *statusbar;
|
||||
GtkWidget *temp_frame;
|
||||
|
||||
g_message("XXX Constructed.\n");
|
||||
|
||||
app = GNOME_APP(window);
|
||||
|
||||
/* set up toolbar */
|
||||
|
@ -781,13 +779,13 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
|
|||
|
||||
current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window));
|
||||
parent_uri = gnome_vfs_uri_get_parent (current_uri);
|
||||
gnome_vfs_uri_unref (current_uri);
|
||||
parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
|
||||
nautilus_window_goto_uri (window, parent_uri_string);
|
||||
|
||||
|
||||
g_free (parent_uri_string);
|
||||
gnome_vfs_uri_destroy (current_uri);
|
||||
gnome_vfs_uri_destroy (parent_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -417,8 +417,6 @@ nautilus_window_constructed(NautilusWindow *window)
|
|||
GtkWidget *location_bar_box, *statusbar;
|
||||
GtkWidget *temp_frame;
|
||||
|
||||
g_message("XXX Constructed.\n");
|
||||
|
||||
app = GNOME_APP(window);
|
||||
|
||||
/* set up toolbar */
|
||||
|
@ -781,13 +779,13 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
|
|||
|
||||
current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window));
|
||||
parent_uri = gnome_vfs_uri_get_parent (current_uri);
|
||||
gnome_vfs_uri_unref (current_uri);
|
||||
parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
|
||||
nautilus_window_goto_uri (window, parent_uri_string);
|
||||
|
||||
|
||||
g_free (parent_uri_string);
|
||||
gnome_vfs_uri_destroy (current_uri);
|
||||
gnome_vfs_uri_destroy (parent_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -344,7 +344,8 @@ nautilus_view_load_client(NautilusView *view, const char *iid)
|
|||
NULL
|
||||
};
|
||||
|
||||
g_return_val_if_fail(iid, FALSE);
|
||||
if (iid == NULL)
|
||||
return FALSE;
|
||||
|
||||
CORBA_exception_init(&ev);
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ nautilus_window_change_location_internal(NautilusWindow *window, Nautilus_Naviga
|
|||
new_uri = gnome_vfs_uri_new (loci->requested_uri);
|
||||
nautilus_window_allow_up(window,
|
||||
gnome_vfs_uri_has_parent(new_uri));
|
||||
gnome_vfs_uri_destroy(new_uri);
|
||||
gnome_vfs_uri_unref(new_uri);
|
||||
|
||||
if (window->ni != loci)
|
||||
{
|
||||
|
|
|
@ -417,8 +417,6 @@ nautilus_window_constructed(NautilusWindow *window)
|
|||
GtkWidget *location_bar_box, *statusbar;
|
||||
GtkWidget *temp_frame;
|
||||
|
||||
g_message("XXX Constructed.\n");
|
||||
|
||||
app = GNOME_APP(window);
|
||||
|
||||
/* set up toolbar */
|
||||
|
@ -781,13 +779,13 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
|
|||
|
||||
current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window));
|
||||
parent_uri = gnome_vfs_uri_get_parent (current_uri);
|
||||
gnome_vfs_uri_unref (current_uri);
|
||||
parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
|
||||
nautilus_window_goto_uri (window, parent_uri_string);
|
||||
|
||||
|
||||
g_free (parent_uri_string);
|
||||
gnome_vfs_uri_destroy (current_uri);
|
||||
gnome_vfs_uri_destroy (parent_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -31,37 +31,10 @@
|
|||
#include "config.h"
|
||||
#include "nautilus.h"
|
||||
#include "nautilus-self-check-functions.h"
|
||||
#include <libnautilus/nautilus-debug.h>
|
||||
#include <libnautilus/nautilus-lib-self-check-functions.h>
|
||||
#include <libnautilus/nautilus-self-checks.h>
|
||||
|
||||
/* Raise a SIGINT signal to get the attention of the debugger.
|
||||
When not running under the debugger, we don't want to stop,
|
||||
so we ignore the signal for just the moment that we raise it.
|
||||
*/
|
||||
static void
|
||||
stop_in_debugger (void)
|
||||
{
|
||||
void (* saved_handler) (int);
|
||||
|
||||
saved_handler = signal (SIGINT, SIG_IGN);
|
||||
raise (SIGINT);
|
||||
signal (SIGINT, saved_handler);
|
||||
}
|
||||
|
||||
/* Stop in the debugger after running the default log handler.
|
||||
This makes certain kinds of messages stop in the debugger
|
||||
without making them fatal.
|
||||
*/
|
||||
static void
|
||||
nautilus_stop_after_default_log_handler (const char *domain,
|
||||
GLogLevelFlags level,
|
||||
const char *message,
|
||||
gpointer data)
|
||||
{
|
||||
g_log_default_handler (domain, level, message, data);
|
||||
stop_in_debugger ();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -81,10 +54,12 @@ main(int argc, char *argv[])
|
|||
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
/* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. */
|
||||
/* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set.
|
||||
Unfortunately, this has to be done explicitly for each domain.
|
||||
*/
|
||||
if (getenv("NAUTILUS_DEBUG") != NULL)
|
||||
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
|
||||
nautilus_stop_after_default_log_handler, NULL);
|
||||
nautilus_make_warnings_and_criticals_stop_in_debugger
|
||||
(G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "GnomeVFS", NULL);
|
||||
|
||||
/* Initialize the services that we use. */
|
||||
CORBA_exception_init(&ev);
|
||||
|
|
|
@ -124,9 +124,6 @@ navinfo_read_map_file(const char *fn)
|
|||
if(!strcasecmp(mimetype, "NULL"))
|
||||
mimetype = NULL;
|
||||
|
||||
g_message("Adding mapping of %s -> [%s, %s, %s]",
|
||||
sname, type, mimetype, data);
|
||||
|
||||
nautilus_navinfo_add_mapping(sname, typeval, data, mimetype);
|
||||
}
|
||||
|
||||
|
|
|
@ -344,7 +344,8 @@ nautilus_view_load_client(NautilusView *view, const char *iid)
|
|||
NULL
|
||||
};
|
||||
|
||||
g_return_val_if_fail(iid, FALSE);
|
||||
if (iid == NULL)
|
||||
return FALSE;
|
||||
|
||||
CORBA_exception_init(&ev);
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ nautilus_window_change_location_internal(NautilusWindow *window, Nautilus_Naviga
|
|||
new_uri = gnome_vfs_uri_new (loci->requested_uri);
|
||||
nautilus_window_allow_up(window,
|
||||
gnome_vfs_uri_has_parent(new_uri));
|
||||
gnome_vfs_uri_destroy(new_uri);
|
||||
gnome_vfs_uri_unref(new_uri);
|
||||
|
||||
if (window->ni != loci)
|
||||
{
|
||||
|
|
|
@ -417,8 +417,6 @@ nautilus_window_constructed(NautilusWindow *window)
|
|||
GtkWidget *location_bar_box, *statusbar;
|
||||
GtkWidget *temp_frame;
|
||||
|
||||
g_message("XXX Constructed.\n");
|
||||
|
||||
app = GNOME_APP(window);
|
||||
|
||||
/* set up toolbar */
|
||||
|
@ -781,13 +779,13 @@ nautilus_window_up (GtkWidget *btn, NautilusWindow *window)
|
|||
|
||||
current_uri = gnome_vfs_uri_new (nautilus_window_get_requested_uri(window));
|
||||
parent_uri = gnome_vfs_uri_get_parent (current_uri);
|
||||
gnome_vfs_uri_unref (current_uri);
|
||||
parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
gnome_vfs_uri_unref (parent_uri);
|
||||
|
||||
nautilus_window_goto_uri (window, parent_uri_string);
|
||||
|
||||
|
||||
g_free (parent_uri_string);
|
||||
gnome_vfs_uri_destroy (current_uri);
|
||||
gnome_vfs_uri_destroy (parent_uri);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue