summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-12-29 01:06:28 +0000
committerDarin Adler <darin@src.gnome.org>2000-12-29 01:06:28 +0000
commitf75b46491911dd144adec834450dfa4a8bc4845f (patch)
tree0f4a9be5d0194617174abde2ee0d7ddefff558d4
parent96b848846b8840ddec13d88318264e1262aa7c08 (diff)
downloadnautilus-f75b46491911dd144adec834450dfa4a8bc4845f.tar.gz
reviewed by: Maciej Stachowiak <mjs@eazel.com>
Fixed bug 2802 (copy all metadata, not just certain items). There are still a few loose ends but it's basically there. Fixed bug 5296 (Hardware overview should be localized). Fixed bug 5299 (Spacing problems with sizes in bytes). * libnautilus-extensions/nautilus-directory-metafile.c: (get_file_node): Used a local variable for the hash table to make the code more readable because the full expression is too long. Removed the half-baked attempt at using xmlNode objects to represent "changes" data, which no longer seems a likely direction. (nautilus_directory_metafile_destroy): Local variable for hash table. (nautilus_directory_get_file_metadata): Return NULL, not FALSE, since the function returns char *, not gboolean. (nautilus_directory_rename_file_metadata): Local variable for hash table. Also added a FIXME for a case that won't work. (apply_file_changes): Broke out so it can be used elsewhere. (apply_one_file_changes): This is now the version that has the hash table iterator function interface. (nautilus_directory_get_integer_file_metadata): Use sscanf instead of atoi so we can do error checking. (nautilus_directory_copy_file_metadata): Removed the old code that copied fixed keys and wrote new code that copies all the metadata. (nautilus_directory_remove_file_metadata): Local variable for hash table. * icons/arlo/arlo.xml: Added an explicit H offset of 0 for the zoom control. It was inheriting the default theme's offset of -2. This seems to indicate a design problem with the "fall back on default" approach for themes, but for now it's nice to have the zoom control looking right again. * src/nautilus-window-menus.c: (help_menu_about_nautilus_callback): Use the real copyright character, not "(C)". * src/file-manager/fm-desktop-icon-view.c (find_and_update_home_link), (place_home_directory): Mark the "darin's Home" string for localization. Needs improvement beyond this, because just tacking "'s Home" onto the login name is probably no good. * components/hardware/nautilus-hardware-view.c: (read_proc_info): Tweak code style a bit. Use g_string_free (FALSE) instead of g_strdup and g_string_free (TRUE). (get_CPU_description): Make this a little more localizable by adding a strdup format string instead of appending things. Added FIXMEs about additional problems. (get_RAM_description): Add a little reality checking on the value read from the file and make a little more localizable. (get_IDE_description): Change to use the gnome-vfs file size formatting functions in the right way. The old code had been changed to not use them at all, probably because the first cut at this code was using it wrong and ran into a 32-bit limit. Use g_string_free (FALSE) instead of g_strdup and g_string_free (TRUE). * po/POTFILES.in: Marked nautilus-hardware-view.c as needing localization. * components/help/converters/gnome-db2html2/sect-elements.c: (sect_informaltable_start_element): Fixed a runaway string literal. * libnautilus-extensions/nautilus-directory-async.c: Moved the constants to the top of the file and put the compile-time switches at the top of the constants section. * NEWS: Removed out of date news. * README: Fixed a typo. * TODO: Removed out of date tasks.
-rw-r--r--ChangeLog80
-rw-r--r--NEWS78
-rw-r--r--README2
-rw-r--r--TODO15
-rw-r--r--components/hardware/nautilus-hardware-view.c166
-rw-r--r--components/help/converters/gnome-db2html2/sect-elements.c5
-rw-r--r--icons/arlo/arlo.xml2
-rw-r--r--libnautilus-extensions/nautilus-directory-async.c19
-rw-r--r--libnautilus-extensions/nautilus-directory-metafile.c228
-rw-r--r--libnautilus-private/nautilus-directory-async.c19
-rw-r--r--libnautilus-private/nautilus-directory-metafile.c228
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/file-manager/fm-desktop-icon-view.c4
-rw-r--r--src/nautilus-navigation-window-menus.c6
-rw-r--r--src/nautilus-window-menus.c6
15 files changed, 447 insertions, 412 deletions
diff --git a/ChangeLog b/ChangeLog
index 9950a8f25..14dc6d9d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,81 @@
+2000-12-28 Darin Adler <darin@eazel.com>
+
+ reviewed by: Maciej Stachowiak <mjs@eazel.com>
+
+ Fixed bug 2802 (copy all metadata, not just certain items). There
+ are still a few loose ends but it's basically there.
+
+ Fixed bug 5296 (Hardware overview should be localized).
+ Fixed bug 5299 (Spacing problems with sizes in bytes).
+
+ * libnautilus-extensions/nautilus-directory-metafile.c:
+ (get_file_node): Used a local variable for the hash table to make
+ the code more readable because the full expression is too long.
+ Removed the half-baked attempt at using xmlNode objects to
+ represent "changes" data, which no longer seems a likely
+ direction.
+ (nautilus_directory_metafile_destroy): Local variable for hash
+ table.
+ (nautilus_directory_get_file_metadata): Return NULL, not FALSE,
+ since the function returns char *, not gboolean.
+ (nautilus_directory_rename_file_metadata): Local variable for hash
+ table. Also added a FIXME for a case that won't work.
+ (apply_file_changes): Broke out so it can be used elsewhere.
+ (apply_one_file_changes): This is now the version that has the
+ hash table iterator function interface.
+ (nautilus_directory_get_integer_file_metadata): Use sscanf instead
+ of atoi so we can do error checking.
+ (nautilus_directory_copy_file_metadata): Removed the old code that
+ copied fixed keys and wrote new code that copies all the metadata.
+ (nautilus_directory_remove_file_metadata): Local variable for hash
+ table.
+
+ * icons/arlo/arlo.xml: Added an explicit H offset of 0 for the
+ zoom control. It was inheriting the default theme's offset of
+ -2. This seems to indicate a design problem with the "fall back on
+ default" approach for themes, but for now it's nice to have the
+ zoom control looking right again.
+
+ * src/nautilus-window-menus.c:
+ (help_menu_about_nautilus_callback): Use the real copyright
+ character, not "(C)".
+
+ * src/file-manager/fm-desktop-icon-view.c
+ (find_and_update_home_link), (place_home_directory): Mark the
+ "darin's Home" string for localization. Needs improvement beyond
+ this, because just tacking "'s Home" onto the login name is
+ probably no good.
+
+ * components/hardware/nautilus-hardware-view.c: (read_proc_info):
+ Tweak code style a bit. Use g_string_free (FALSE) instead of
+ g_strdup and g_string_free (TRUE).
+ (get_CPU_description): Make this a little more localizable by
+ adding a strdup format string instead of appending things. Added
+ FIXMEs about additional problems.
+ (get_RAM_description): Add a little reality checking on the value
+ read from the file and make a little more localizable.
+ (get_IDE_description): Change to use the gnome-vfs file size
+ formatting functions in the right way. The old code had been
+ changed to not use them at all, probably because the first cut at
+ this code was using it wrong and ran into a 32-bit limit. Use
+ g_string_free (FALSE) instead of g_strdup and g_string_free
+ (TRUE).
+
+ * po/POTFILES.in: Marked nautilus-hardware-view.c as needing
+ localization.
+
+ * components/help/converters/gnome-db2html2/sect-elements.c:
+ (sect_informaltable_start_element): Fixed a runaway string
+ literal.
+
+ * libnautilus-extensions/nautilus-directory-async.c: Moved the
+ constants to the top of the file and put the compile-time switches
+ at the top of the constants section.
+
+ * NEWS: Removed out of date news.
+ * README: Fixed a typo.
+ * TODO: Removed out of date tasks.
+
2000-12-27 Michael Engber <engber@eazel.com>
* libnautilus-extensions/nautilus-background-canvas-group.c:
@@ -73,7 +151,7 @@
Started work on volume black list. Added proc and boot to
list. Need to figure out a way to expose this to the UI
so it is easy for the user to specify what mounts they
- wnat dispalyed on the desktop.
+ want displayed on the desktop.
* libnautilus-extensions/nautilus-drag.c: (add_one_url_list),
(add_one_path_list), (nautilus_drag_drag_data_get):
diff --git a/NEWS b/NEWS
index c90ea2edc..e69de29bb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,78 +0,0 @@
-
------------------------------------
-- 0.1 -- PR1
------------------------------------
-Hi everybody.
-
-The first preview source code release of Nautilus is here. Nautilus is a
-graphical shell and file manager for GNOME. This preview release is a
-snapshot of Nautilus development.
-
-Nautilus is not yet ready for daily use. Intrepid hackers may want to get
-and build this preview to get an idea of what Nautilus will be like.
-
- You can get the Nautilus 0.1 tarball here:
-
- <ftp://ftp.gnome.org/pub/GNOME/unstable/sources/nautilus>
- (mirrored at <http://download.eazel.com/source>)
-
- A number of other packages are needed too, including the
- latest releases of libghttp, oaf, gconf, gnome-vfs, bonobo,
- gtkhtml, and medusa. The README file inside the tarball
- contains a complete list.
-
- The Nautilus web site at <http://nautilus.eazel.com> contains
- pointers to our mailing list, screen shots, and other information.
-
-Thanks to the many people who have sent in suggestions and fixes and
-contributed to Nautilus so far. Here's a partial list:
-
- Ali Abdin
- Anders Carlsson
- Andreas Hyden
- Andy Hertzfeld
- Arlo Rose
- Benedikt Roth
- Chris Blizzard
- Chris Lahey
- Cody Russell
- Elliot Lee
- Eskil Heyn Olsen
- Ettore Perazzoli
- Fatih Demir
- Gene Z. Ragan
- George Lebl
- Havoc Pennington
- Ian McKellar
- J Shane Culpepper
- Jean-Michel Ardantz
- Jesus Bravo Alvarez
- Joe Shaw
- John Sullivan
- Jonathan Blandford
- Josh Barrow
- JP Rosevear
- Kjartan Maraas
- Maciej Stachowiak
- Martin Baulig
- Mathieu Lacage
- Michael Meeks
- Mike Engber
- Mike Fleming
- Morten Welinder
- Nat Friedman
- Pablo Saratxaga
- Pavel Cisler
- Ramiro Estrugo
- Raph Levien
- Rebecca Schulman
- Robey Pointer
- Robin Slomkowski
- Seth Nickell
- Shane Culpepper
- Valek Filippov
- Yukihiro Nakai
-
-Thanks on behalf of the whole Nautilus team for checking out our preview.
-
- -- Darin
diff --git a/README b/README
index a50c90098..29c73e1a9 100644
--- a/README
+++ b/README
@@ -301,7 +301,7 @@ To learn more about FreeType2, please see:
http://freetype.sourceforge.net/
If you are using a RedHat 6.x or greater system, then you can easily
-add FreeType2 support byt installing the rpms found here:
+add FreeType2 support by installing the rpms found here:
http://developer.eazel.com/eazel-hacking/updates/freetype2
diff --git a/TODO b/TODO
index 0142c9cea..ccd02ac9f 100644
--- a/TODO
+++ b/TODO
@@ -1,16 +1 @@
You can see our planned task list in http://bugzilla.eazel.com
-
-Infrastructure
---------------
-. File manager - Virtual directories/files/actions
-. Figure out how to provide clean and separate abstractions for data
- transfer and presentation (views handle both right now).
-
-Components
-----------
-. Text, postscript, PDF
-. Bookmark meta view (in addition to the bookmarks menu).
-
-Documentation
----
-. Documentation on how to write a Nautilus view.
diff --git a/components/hardware/nautilus-hardware-view.c b/components/hardware/nautilus-hardware-view.c
index 10bfca2f6..e08543f79 100644
--- a/components/hardware/nautilus-hardware-view.c
+++ b/components/hardware/nautilus-hardware-view.c
@@ -28,31 +28,31 @@
#include <config.h>
#include "nautilus-hardware-view.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <dirent.h>
-
-#include <libnautilus/libnautilus.h>
+#include <fcntl.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gnome.h>
+#include <gtk/gtksignal.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include <libgnorba/gnorba.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-directory-background.h>
-#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-file.h>
+#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-font-factory.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-label.h>
#include <libnautilus-extensions/nautilus-metadata.h>
#include <libnautilus-extensions/nautilus-string.h>
-#include <libnautilus-extensions/nautilus-label.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gtk/gtksignal.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnorba/gnorba.h>
+#include <libnautilus/libnautilus.h>
#include <limits.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+/* FIXME: Hardwired font size here. */
#define HARDWARE_FONT_SIZE 14
#define HARDWARE_TITLE_FONT_SIZE 24
@@ -153,25 +153,25 @@ nautilus_hardware_view_get_nautilus_view (NautilusHardwareView *hardware_view)
return hardware_view->details->nautilus_view;
}
-static char*
+static char *
read_proc_info(const gchar* proc_filename)
{
FILE *thisFile;
char *result;
char buffer[256];
- char* path_name = g_strdup_printf("/proc/%s", proc_filename);
+ char* path_name;
GString* string_data = g_string_new("");
- thisFile = fopen( path_name, "r");
-
- while (fgets(buffer, 255, thisFile) != NULL) {
- g_string_append(string_data, buffer);
+ path_name = g_strdup_printf ("/proc/%s", proc_filename);
+ thisFile = fopen (path_name, "r");
+ g_free (path_name);
+ while (fgets (buffer, 255, thisFile) != NULL) {
+ g_string_append (string_data, buffer);
}
- fclose(thisFile);
+ fclose (thisFile);
- result = g_strdup(string_data->str);
- g_string_free(string_data, TRUE);
- g_free(path_name);
+ result = string_data->str;
+ g_string_free(string_data, FALSE);
return result;
}
@@ -179,7 +179,7 @@ read_proc_info(const gchar* proc_filename)
/* utility routine to extract information from a string and add it to an XML node */
static char*
-extract_info(gchar* data, const gchar *field_name, gint nth)
+extract_info (gchar* data, const gchar *field_name, gint nth)
{
int index;
char **info_array;
@@ -212,40 +212,42 @@ extract_info(gchar* data, const gchar *field_name, gint nth)
/* get descriptive text about the CPU */
-static char*
-get_CPU_description(gint nth)
+static char *
+get_CPU_description (int nth)
{
- char *temp_str, *result;
- GString* string_data = g_string_new("");
- char* proc_data = read_proc_info("cpuinfo");
+ char *proc_data;
+ char *model, *speed, *cache_size;
+ char *result;
- temp_str = extract_info(proc_data, "processor", nth);
- if(temp_str == NULL) {
- /* can't find nth processor */
- g_free(proc_data);
- g_string_free(string_data, TRUE);
- return NULL;
- }
- g_free (temp_str);
-
- temp_str = extract_info(proc_data, "model name", nth);
- g_string_append(string_data, temp_str);
- g_string_append(string_data, " CPU\n");
- g_free(temp_str);
-
- temp_str = extract_info(proc_data, "cpu MHz", nth);
- g_string_append(string_data, temp_str);
- g_string_append(string_data, " MHz\n");
- g_free(temp_str);
-
- temp_str = extract_info(proc_data, "cache size", nth);
- g_string_append(string_data, temp_str);
- g_string_append(string_data, " cache size\n");
- g_free(temp_str);
+ proc_data = read_proc_info ("cpuinfo");
+ model = extract_info (proc_data, "model name", nth);
+ speed = extract_info (proc_data, "cpu MHz", nth);
+ cache_size = extract_info (proc_data, "cache size", nth);
+ g_free (proc_data);
+
+ /* FIXME: The MHz value always comes in with a "." as the
+ * radix character. We need to change that to the local one
+ * ("," for many European countries).
+ */
+
+ /* FIXME bugzilla.eazel.com 5298: The KB string that comes
+ * from the proc data is wrong -- "kB" is correct, and we use
+ * "K" for file sizes as of this writing (although we use "MB"
+ * and "GB").
+ */
- g_free(proc_data);
- result = g_strdup(string_data->str);
- g_string_free(string_data, TRUE);
+ if (model == NULL || speed == NULL || cache_size == NULL) {
+ result = NULL;
+ } else {
+ result = g_strdup_printf (_("%s CPU\n"
+ "%s MHz\n"
+ "%s cache size"),
+ model, speed, cache_size);
+ }
+
+ g_free (model);
+ g_free (speed);
+ g_free (cache_size);
return result;
}
@@ -255,33 +257,38 @@ static char *
get_RAM_description (void)
{
char *temp_str, *num_str, *result;
- GString* string_data = g_string_new("");
- char* proc_data = read_proc_info("meminfo");
-
+ char* proc_data;
+
+ proc_data = read_proc_info("meminfo");
+
temp_str = extract_info (proc_data, "MemTotal", 0);
- /* strip kbyte suffix */
+ if (temp_str == NULL || strlen (temp_str) < 3) {
+ g_free (temp_str);
+ return NULL;
+ }
+
+ /* strip kbyte suffix */
temp_str[strlen(temp_str) - 3] = '\0';
- num_str = gnome_vfs_format_file_size_for_display (1024 * atoi (temp_str));
-
- g_string_append(string_data, num_str);
- g_string_append(string_data, " RAM");
- g_free(num_str);
- g_free(temp_str);
+ num_str = gnome_vfs_format_file_size_for_display (1024 * atol (temp_str));
+ g_free (temp_str);
- g_free(proc_data);
- result = g_strdup(string_data->str);
- g_string_free(string_data, TRUE);
+ g_free (proc_data);
+
+ result = g_strdup_printf (_("%s RAM"), num_str);
+
+ g_free (num_str);
return result;
}
-static char*
-get_IDE_description(char *device)
+static char *
+get_IDE_description (const char *device)
{
char *temp_str, *num_str, *result;
GString* string_data = g_string_new("");
char *proc_file;
+ GnomeVFSFileSize capacity;
/* Read model information string */
proc_file = g_strdup_printf("%s/model", device);
@@ -298,28 +305,15 @@ get_IDE_description(char *device)
/* If a hard disk, get the size */
if(!strcmp(temp_str, "disk\n")) {
- unsigned long capacity;
-
g_free(temp_str);
proc_file = g_strdup_printf("%s/capacity", device);
temp_str = read_proc_info(proc_file);
temp_str[strlen(temp_str) - 1] = '\0';
- /* NOTE: this should be
- capacity = strtoul (...)
- num_str = gnome_vfs_format_file_size_for_display (512 * capacity);
-
- (512 bytes pr sector)
- but 512 * 23579136 (numsectors) = 12072517632 > unsigned long,
- which is the type that gnome_vfs uses */
/* This converts & calcs the sectors into MB's */
- capacity = 512 * (strtoul (temp_str, NULL, 10) / (1024 * 1024));
- if (capacity > 1024) {
- num_str = g_strdup_printf ("%lu GB", capacity / 1024);
- } else {
- num_str = g_strdup_printf ("%lu MB", capacity);
- }
+ capacity = strtoul (temp_str, NULL, 10);
+ num_str = gnome_vfs_format_file_size_for_display (512 * capacity);
g_string_append(string_data, "\n");
g_string_append(string_data, num_str);
g_free(temp_str);
@@ -328,8 +322,8 @@ get_IDE_description(char *device)
g_free(temp_str);
}
- result = strdup(string_data->str);
- g_string_free(string_data, TRUE);
+ result = string_data->str;
+ g_string_free (string_data, FALSE);
return result;
}
diff --git a/components/help/converters/gnome-db2html2/sect-elements.c b/components/help/converters/gnome-db2html2/sect-elements.c
index d481c7148..1e28cc906 100644
--- a/components/help/converters/gnome-db2html2/sect-elements.c
+++ b/components/help/converters/gnome-db2html2/sect-elements.c
@@ -1768,8 +1768,9 @@ sect_informaltable_start_element (Context *context,
if (!IS_IN_SECT (context))
return;
- sect_print (context, "<TABLE BORDER=\"0\" BGCOLOR=\"#E0E0E0\"
- CELLSPACING=\"0\" CELLPADDING=\"4\">\n");
+ sect_print (context,
+ "<TABLE BORDER=\"0\" BGCOLOR=\"#E0E0E0\" "
+ "CELLSPACING=\"0\" CELLPADDING=\"4\">\n");
}
void
diff --git a/icons/arlo/arlo.xml b/icons/arlo/arlo.xml
index acba741c8..ff0f0a1f2 100644
--- a/icons/arlo/arlo.xml
+++ b/icons/arlo/arlo.xml
@@ -6,7 +6,7 @@ LIGHT_INFO_COLOR="0xAAAAAA" SELECTION_BOX_COLOR_RGBA="0x497B7E40" SELECTION_BOX_
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:6666/9999/9999-rgb:0000/3333/3333%90-rgb:0000/0000/0000:h" SIDEBAR_BACKGROUND_TILE_IMAGE="patterns/.striated.png" TAB_PIECE_IMAGES="sidebar_tab_pieces" COMBINE="TRUE"
LEFT_OFFSET="0" SHADOW_OFFSET="1" TEXT_H_OFFSET="-4" LABEL_COLOR="rgb:FFFF/FFFF/FFFF" TAB_FONT="-*-helvetica-bold-r-normal-*-24-*-*-*-*-*-*-*" />
<desktop BACKGROUND_TILE_IMAGE="./backgrounds/background_pattern.png"/>
- <zoom_control NUMBER_V_OFFSET="-6" DIGIT_WIDTH="6"/>
+ <zoom_control NUMBER_V_OFFSET="-6" NUMBER_H_OFFSET="0" DIGIT_WIDTH="6"/>
<throbber FRAME_COUNT="28" URL="http://www.eazel.com"/>
</theme>
diff --git a/libnautilus-extensions/nautilus-directory-async.c b/libnautilus-extensions/nautilus-directory-async.c
index c7ac68369..6b7ce0b0a 100644
--- a/libnautilus-extensions/nautilus-directory-async.c
+++ b/libnautilus-extensions/nautilus-directory-async.c
@@ -41,12 +41,6 @@
#include <stdlib.h>
#include <stdio.h>
-#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 DIRECTORY_LOAD_ITEMS_PER_CALLBACK 32
-
/* comment this back in to see messages about each load_directory call:
#define DEBUG_LOAD_DIRECTORY
*/
@@ -55,6 +49,15 @@
#define DEBUG_ASYNC_JOBS
*/
+#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 DIRECTORY_LOAD_ITEMS_PER_CALLBACK 32
+
+/* Keep async. jobs down to this number for all directories. */
+#define MAX_ASYNC_JOBS 10
+
struct MetafileReadState {
gboolean use_public_metafile;
NautilusReadFileHandle *handle;
@@ -98,9 +101,6 @@ typedef struct {
typedef gboolean (* RequestCheck) (const Request *);
typedef gboolean (* FileCheck) (NautilusFile *);
-/* Keep async. jobs down to this number for all directories. */
-#define MAX_ASYNC_JOBS 10
-
/* Current number of async. jobs. */
static int async_job_count;
static GHashTable *waiting_directories;
@@ -119,7 +119,6 @@ static gboolean request_is_satisfied (NautilusDirectory *directory,
static void cancel_loading_attributes (NautilusDirectory *directory,
GList *file_attributes);
-
/* Some helpers for case-insensitive strings.
* Move to nautilus-glib-extensions?
*/
diff --git a/libnautilus-extensions/nautilus-directory-metafile.c b/libnautilus-extensions/nautilus-directory-metafile.c
index 2acc19abe..f64cca3fd 100644
--- a/libnautilus-extensions/nautilus-directory-metafile.c
+++ b/libnautilus-extensions/nautilus-directory-metafile.c
@@ -98,29 +98,24 @@ get_file_node (NautilusDirectory *directory,
const char *file_name,
gboolean create)
{
+ GHashTable *hash;
xmlNode *root, *node;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
- if (directory->details->metafile_node_hash != NULL) {
- node = g_hash_table_lookup (directory->details->metafile_node_hash,
- file_name);
+ hash = directory->details->metafile_node_hash;
+ if (hash != NULL) {
+ node = g_hash_table_lookup (hash, file_name);
if (node != NULL) {
return node;
}
}
if (create) {
- if (directory->details->metafile_read) {
- root = create_metafile_root (directory);
- node = xmlNewChild (root, NULL, "FILE", NULL);
- } else {
- node = xmlNewNode (NULL, "FILE");
- }
+ root = create_metafile_root (directory);
+ node = xmlNewChild (root, NULL, "FILE", NULL);
xmlSetProp (node, "NAME", file_name);
- g_hash_table_insert (directory->details->metafile_node_hash,
- xmlMemStrdup (file_name),
- node);
+ g_hash_table_insert (hash, xmlMemStrdup (file_name), node);
return node;
}
@@ -175,8 +170,8 @@ set_metadata_string_in_metafile (NautilusDirectory *directory,
}
/* Data that matches the default is represented in the tree by
- the lack of an attribute.
- */
+ * the lack of an attribute.
+ */
if (nautilus_strcmp (default_metadata, metadata) == 0) {
value = NULL;
} else {
@@ -523,27 +518,30 @@ destroy_xml_string_key (gpointer key, gpointer value, gpointer user_data)
void
nautilus_directory_metafile_destroy (NautilusDirectory *directory)
{
- if (directory->details->metafile_node_hash != NULL) {
- g_hash_table_foreach (directory->details->metafile_node_hash,
- destroy_xml_string_key, NULL);
- g_hash_table_destroy (directory->details->metafile_node_hash);
+ GHashTable *hash;
+
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+
+ hash = directory->details->metafile_node_hash;
+ if (hash != NULL) {
+ g_hash_table_foreach (hash, destroy_xml_string_key, NULL);
+ g_hash_table_destroy (hash);
}
xmlFreeDoc (directory->details->metafile);
destroy_metadata_changes_hash_table (directory->details->metadata_changes);
}
-
char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata)
{
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
- g_return_val_if_fail (file_name != NULL, FALSE);
- g_return_val_if_fail (file_name[0] != '\0', FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (key[0] != '\0', FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
+ g_return_val_if_fail (file_name != NULL, NULL);
+ g_return_val_if_fail (file_name[0] != '\0', NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+ g_return_val_if_fail (key[0] != '\0', NULL);
if (directory->details->metafile_read) {
return get_metadata_string_from_metafile
@@ -637,41 +635,48 @@ nautilus_directory_rename_file_metadata (NautilusDirectory *directory,
gboolean found;
gpointer key, value;
xmlNode *file_node;
- GHashTable *directory_table;
+ GHashTable *hash;
char *old_file_uri, *new_file_uri;
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+ g_return_if_fail (old_file_name != NULL);
+ g_return_if_fail (new_file_name != NULL);
+
nautilus_directory_remove_file_metadata (directory, new_file_name);
if (directory->details->metafile_read) {
/* Move data in XML document if present. */
- found = directory->details->metafile_node_hash != NULL
- && g_hash_table_lookup_extended (directory->details->metafile_node_hash,
- old_file_name, &key, &value);
+ hash = directory->details->metafile_node_hash;
+ found = hash != NULL && g_hash_table_lookup_extended
+ (hash, old_file_name, &key, &value);
if (found) {
g_assert (strcmp (key, old_file_name) == 0);
file_node = value;
- g_hash_table_remove (directory->details->metafile_node_hash,
+ g_hash_table_remove (hash,
old_file_name);
xmlFree (key);
- g_hash_table_insert (directory->details->metafile_node_hash,
+ g_hash_table_insert (hash,
xmlMemStrdup (new_file_name), value);
xmlSetProp (file_node, "NAME", new_file_name);
nautilus_directory_request_write_metafile (directory);
}
} else {
/* Move data in hash table. */
- directory_table = directory->details->metadata_changes;
+ /* FIXME: If there's data for this file in the
+ * metafile on disk, this doesn't arrange for that
+ * data to be moved to the new name.
+ */
+ hash = directory->details->metadata_changes;
found = g_hash_table_lookup_extended
- (directory_table, old_file_name, &key, &value);
+ (hash, old_file_name, &key, &value);
if (found) {
- g_hash_table_remove (directory_table, old_file_name);
+ g_hash_table_remove (hash, old_file_name);
g_free (key);
- g_hash_table_insert (directory_table,
- g_strdup (new_file_name), value);
+ g_hash_table_insert (hash, g_strdup (new_file_name), value);
}
}
- /* rename the thumbnails for the file, if any */
+ /* Rename the thumbnails for the file, if any. */
old_file_uri = nautilus_directory_get_file_uri (directory, old_file_name);
new_file_uri = nautilus_directory_get_file_uri (directory, new_file_name);
nautilus_update_thumbnail_file_renamed (old_file_uri, new_file_uri);
@@ -717,17 +722,26 @@ apply_one_change (gpointer key, gpointer value, gpointer callback_data)
}
static void
-apply_file_changes (gpointer key, gpointer value, gpointer callback_data)
+apply_file_changes (NautilusDirectory *directory,
+ const char *file_name,
+ GHashTable *changes)
{
ChangeContext context;
- g_assert (value != NULL);
- g_assert (NAUTILUS_IS_DIRECTORY (callback_data));
+ g_assert (NAUTILUS_IS_DIRECTORY (directory));
+ g_assert (file_name != NULL);
+ g_assert (changes != NULL);
- context.directory = callback_data;
- context.file_name = key;
+ context.directory = directory;
+ context.file_name = file_name;
- g_hash_table_foreach (value, apply_one_change, &context);
+ g_hash_table_foreach (changes, apply_one_change, &context);
+}
+
+static void
+apply_one_file_changes (gpointer key, gpointer value, gpointer callback_data)
+{
+ apply_file_changes (callback_data, key, value);
g_hash_table_destroy (value);
}
@@ -738,7 +752,7 @@ nautilus_directory_metafile_apply_pending_changes (NautilusDirectory *directory)
return;
}
g_hash_table_foreach (directory->details->metadata_changes,
- apply_file_changes, directory);
+ apply_one_file_changes, directory);
g_hash_table_destroy (directory->details->metadata_changes);
directory->details->metadata_changes = NULL;
}
@@ -798,18 +812,21 @@ nautilus_directory_get_integer_file_metadata (NautilusDirectory *directory,
default_as_string = g_strdup_printf ("%d", default_metadata);
result_as_string = nautilus_directory_get_file_metadata
(directory, file_name, key, default_as_string);
-
- /* Handle oddball case of non-existent directory */
+
+ /* Normally we can't get a a NULL, but we check for it here to
+ * handle the oddball case of a non-existent directory.
+ */
if (result_as_string == NULL) {
result = default_metadata;
} else {
- result = atoi (result_as_string);
+ if (sscanf (result_as_string, " %d %*s", &result) != 1) {
+ result = default_metadata;
+ }
g_free (result_as_string);
}
g_free (default_as_string);
return result;
-
}
gboolean
@@ -833,57 +850,56 @@ nautilus_directory_set_integer_file_metadata (NautilusDirectory *directory,
g_free (default_as_string);
}
-static void
-copy_file_metadata_for_key (NautilusDirectory *source_directory,
- const char *source_file_name,
- NautilusDirectory *destination_directory,
- const char *destination_file_name,
- const char *key)
-{
- char *data;
-
- data = nautilus_directory_get_file_metadata
- (source_directory, source_file_name,
- key, NULL);
- nautilus_directory_set_file_metadata
- (destination_directory, destination_file_name,
- key, NULL, data);
- g_free (data);
-}
-
void
nautilus_directory_copy_file_metadata (NautilusDirectory *source_directory,
const char *source_file_name,
NautilusDirectory *destination_directory,
const char *destination_file_name)
{
- /* FIXME bugzilla.eazel.com 3343: This does nothing to ensure
- * the source directory metadata is read in.
- */
+ xmlNodePtr source_node, node, root;
+ GHashTable *hash, *changes;
+
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (source_directory));
+ g_return_if_fail (source_file_name != NULL);
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (destination_directory));
+ g_return_if_fail (destination_file_name != NULL);
- /* FIXME bugzilla.eazel.com 2808: Change this to copy all the
- * metadata, not just a hard-coded set of keys.
+ /* FIXME bugzilla.eazel.com 3343: This does not properly
+ * handle the case where we don't have the source metadata yet
+ * since it's not read in.
*/
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_NOTES);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_ICON_SCALE);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_ICON_POSITION);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_ANNOTATION);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_CUSTOM_ICON);
+
+ nautilus_directory_remove_file_metadata
+ (destination_directory, destination_file_name);
+ g_assert (get_file_node (destination_directory, destination_file_name, FALSE) == NULL);
+
+ source_node = get_file_node (source_directory, source_file_name, FALSE);
+ if (source_node != NULL) {
+ if (destination_directory->details->metafile_read) {
+ node = xmlCopyNode (source_node, TRUE);
+ root = create_metafile_root (destination_directory);
+ xmlAddChild (root, node);
+ xmlSetProp (node, "NAME", destination_file_name);
+ g_hash_table_insert (destination_directory->details->metafile_node_hash,
+ xmlMemStrdup (destination_file_name), node);
+ } else {
+ /* FIXME: Copying data into a destination
+ * where the metafile was not yet read is not
+ * implemented.
+ */
+ g_warning ("not copying metadata");
+ }
+ }
+
+ hash = source_directory->details->metadata_changes;
+ if (hash != NULL) {
+ changes = g_hash_table_lookup (hash, source_file_name);
+ if (changes != NULL) {
+ apply_file_changes (destination_directory,
+ destination_file_name,
+ changes);
+ }
+ }
/* FIXME: Do we want to copy the thumbnail here like in the
* rename and remove cases?
@@ -897,18 +913,21 @@ nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
gboolean found;
gpointer key, value;
xmlNode *file_node;
- GHashTable *directory_table;
+ GHashTable *hash;
char *file_uri;
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+ g_return_if_fail (file_name != NULL);
+
if (directory->details->metafile_read) {
/* Remove data in XML document if present. */
- found = directory->details->metafile_node_hash != NULL
- && g_hash_table_lookup_extended (directory->details->metafile_node_hash,
- file_name, &key, &value);
+ hash = directory->details->metafile_node_hash;
+ found = hash != NULL && g_hash_table_lookup_extended
+ (hash, file_name, &key, &value);
if (found) {
g_assert (strcmp (key, file_name) == 0);
file_node = value;
- g_hash_table_remove (directory->details->metafile_node_hash,
+ g_hash_table_remove (hash,
file_name);
xmlFree (key);
nautilus_xml_remove_node (file_node);
@@ -917,17 +936,21 @@ nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
}
} else {
/* Remove data from hash table. */
- directory_table = directory->details->metadata_changes;
+ /* FIXME: If there's data for this file on the
+ * metafile on disk, this does not arrange for it to
+ * be removed when the metafile is later read.
+ */
+ hash = directory->details->metadata_changes;
found = g_hash_table_lookup_extended
- (directory_table, file_name, &key, &value);
+ (hash, file_name, &key, &value);
if (found) {
- g_hash_table_remove (directory_table, file_name);
+ g_hash_table_remove (hash, file_name);
g_free (key);
metadata_value_destroy (value);
}
}
- /* delete the thumbnails for the file, if any */
+ /* Delete the thumbnails for the file, if any. */
file_uri = nautilus_directory_get_file_uri (directory, file_name);
nautilus_remove_thumbnail_for_file (file_uri);
g_free (file_uri);
@@ -941,8 +964,9 @@ nautilus_directory_set_metafile_contents (NautilusDirectory *directory,
xmlNodePtr node;
xmlChar *name;
- g_assert (directory->details->metafile == NULL);
- g_assert (directory->details->metafile_node_hash == NULL);
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+ g_return_if_fail (directory->details->metafile == NULL);
+ g_return_if_fail (directory->details->metafile_node_hash == NULL);
hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -956,7 +980,7 @@ nautilus_directory_set_metafile_contents (NautilusDirectory *directory,
name = xmlGetProp (node, "NAME");
if (g_hash_table_lookup (hash, name) != NULL) {
xmlFree (name);
- /* FIXME: Should we delete these duplicate nodes? */
+ /* FIXME: Should we delete duplicate nodes as we discover them? */
} else {
g_hash_table_insert (hash, name, node);
}
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index c7ac68369..6b7ce0b0a 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -41,12 +41,6 @@
#include <stdlib.h>
#include <stdio.h>
-#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 DIRECTORY_LOAD_ITEMS_PER_CALLBACK 32
-
/* comment this back in to see messages about each load_directory call:
#define DEBUG_LOAD_DIRECTORY
*/
@@ -55,6 +49,15 @@
#define DEBUG_ASYNC_JOBS
*/
+#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 DIRECTORY_LOAD_ITEMS_PER_CALLBACK 32
+
+/* Keep async. jobs down to this number for all directories. */
+#define MAX_ASYNC_JOBS 10
+
struct MetafileReadState {
gboolean use_public_metafile;
NautilusReadFileHandle *handle;
@@ -98,9 +101,6 @@ typedef struct {
typedef gboolean (* RequestCheck) (const Request *);
typedef gboolean (* FileCheck) (NautilusFile *);
-/* Keep async. jobs down to this number for all directories. */
-#define MAX_ASYNC_JOBS 10
-
/* Current number of async. jobs. */
static int async_job_count;
static GHashTable *waiting_directories;
@@ -119,7 +119,6 @@ static gboolean request_is_satisfied (NautilusDirectory *directory,
static void cancel_loading_attributes (NautilusDirectory *directory,
GList *file_attributes);
-
/* Some helpers for case-insensitive strings.
* Move to nautilus-glib-extensions?
*/
diff --git a/libnautilus-private/nautilus-directory-metafile.c b/libnautilus-private/nautilus-directory-metafile.c
index 2acc19abe..f64cca3fd 100644
--- a/libnautilus-private/nautilus-directory-metafile.c
+++ b/libnautilus-private/nautilus-directory-metafile.c
@@ -98,29 +98,24 @@ get_file_node (NautilusDirectory *directory,
const char *file_name,
gboolean create)
{
+ GHashTable *hash;
xmlNode *root, *node;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
- if (directory->details->metafile_node_hash != NULL) {
- node = g_hash_table_lookup (directory->details->metafile_node_hash,
- file_name);
+ hash = directory->details->metafile_node_hash;
+ if (hash != NULL) {
+ node = g_hash_table_lookup (hash, file_name);
if (node != NULL) {
return node;
}
}
if (create) {
- if (directory->details->metafile_read) {
- root = create_metafile_root (directory);
- node = xmlNewChild (root, NULL, "FILE", NULL);
- } else {
- node = xmlNewNode (NULL, "FILE");
- }
+ root = create_metafile_root (directory);
+ node = xmlNewChild (root, NULL, "FILE", NULL);
xmlSetProp (node, "NAME", file_name);
- g_hash_table_insert (directory->details->metafile_node_hash,
- xmlMemStrdup (file_name),
- node);
+ g_hash_table_insert (hash, xmlMemStrdup (file_name), node);
return node;
}
@@ -175,8 +170,8 @@ set_metadata_string_in_metafile (NautilusDirectory *directory,
}
/* Data that matches the default is represented in the tree by
- the lack of an attribute.
- */
+ * the lack of an attribute.
+ */
if (nautilus_strcmp (default_metadata, metadata) == 0) {
value = NULL;
} else {
@@ -523,27 +518,30 @@ destroy_xml_string_key (gpointer key, gpointer value, gpointer user_data)
void
nautilus_directory_metafile_destroy (NautilusDirectory *directory)
{
- if (directory->details->metafile_node_hash != NULL) {
- g_hash_table_foreach (directory->details->metafile_node_hash,
- destroy_xml_string_key, NULL);
- g_hash_table_destroy (directory->details->metafile_node_hash);
+ GHashTable *hash;
+
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+
+ hash = directory->details->metafile_node_hash;
+ if (hash != NULL) {
+ g_hash_table_foreach (hash, destroy_xml_string_key, NULL);
+ g_hash_table_destroy (hash);
}
xmlFreeDoc (directory->details->metafile);
destroy_metadata_changes_hash_table (directory->details->metadata_changes);
}
-
char *
nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *file_name,
const char *key,
const char *default_metadata)
{
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
- g_return_val_if_fail (file_name != NULL, FALSE);
- g_return_val_if_fail (file_name[0] != '\0', FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (key[0] != '\0', FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
+ g_return_val_if_fail (file_name != NULL, NULL);
+ g_return_val_if_fail (file_name[0] != '\0', NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+ g_return_val_if_fail (key[0] != '\0', NULL);
if (directory->details->metafile_read) {
return get_metadata_string_from_metafile
@@ -637,41 +635,48 @@ nautilus_directory_rename_file_metadata (NautilusDirectory *directory,
gboolean found;
gpointer key, value;
xmlNode *file_node;
- GHashTable *directory_table;
+ GHashTable *hash;
char *old_file_uri, *new_file_uri;
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+ g_return_if_fail (old_file_name != NULL);
+ g_return_if_fail (new_file_name != NULL);
+
nautilus_directory_remove_file_metadata (directory, new_file_name);
if (directory->details->metafile_read) {
/* Move data in XML document if present. */
- found = directory->details->metafile_node_hash != NULL
- && g_hash_table_lookup_extended (directory->details->metafile_node_hash,
- old_file_name, &key, &value);
+ hash = directory->details->metafile_node_hash;
+ found = hash != NULL && g_hash_table_lookup_extended
+ (hash, old_file_name, &key, &value);
if (found) {
g_assert (strcmp (key, old_file_name) == 0);
file_node = value;
- g_hash_table_remove (directory->details->metafile_node_hash,
+ g_hash_table_remove (hash,
old_file_name);
xmlFree (key);
- g_hash_table_insert (directory->details->metafile_node_hash,
+ g_hash_table_insert (hash,
xmlMemStrdup (new_file_name), value);
xmlSetProp (file_node, "NAME", new_file_name);
nautilus_directory_request_write_metafile (directory);
}
} else {
/* Move data in hash table. */
- directory_table = directory->details->metadata_changes;
+ /* FIXME: If there's data for this file in the
+ * metafile on disk, this doesn't arrange for that
+ * data to be moved to the new name.
+ */
+ hash = directory->details->metadata_changes;
found = g_hash_table_lookup_extended
- (directory_table, old_file_name, &key, &value);
+ (hash, old_file_name, &key, &value);
if (found) {
- g_hash_table_remove (directory_table, old_file_name);
+ g_hash_table_remove (hash, old_file_name);
g_free (key);
- g_hash_table_insert (directory_table,
- g_strdup (new_file_name), value);
+ g_hash_table_insert (hash, g_strdup (new_file_name), value);
}
}
- /* rename the thumbnails for the file, if any */
+ /* Rename the thumbnails for the file, if any. */
old_file_uri = nautilus_directory_get_file_uri (directory, old_file_name);
new_file_uri = nautilus_directory_get_file_uri (directory, new_file_name);
nautilus_update_thumbnail_file_renamed (old_file_uri, new_file_uri);
@@ -717,17 +722,26 @@ apply_one_change (gpointer key, gpointer value, gpointer callback_data)
}
static void
-apply_file_changes (gpointer key, gpointer value, gpointer callback_data)
+apply_file_changes (NautilusDirectory *directory,
+ const char *file_name,
+ GHashTable *changes)
{
ChangeContext context;
- g_assert (value != NULL);
- g_assert (NAUTILUS_IS_DIRECTORY (callback_data));
+ g_assert (NAUTILUS_IS_DIRECTORY (directory));
+ g_assert (file_name != NULL);
+ g_assert (changes != NULL);
- context.directory = callback_data;
- context.file_name = key;
+ context.directory = directory;
+ context.file_name = file_name;
- g_hash_table_foreach (value, apply_one_change, &context);
+ g_hash_table_foreach (changes, apply_one_change, &context);
+}
+
+static void
+apply_one_file_changes (gpointer key, gpointer value, gpointer callback_data)
+{
+ apply_file_changes (callback_data, key, value);
g_hash_table_destroy (value);
}
@@ -738,7 +752,7 @@ nautilus_directory_metafile_apply_pending_changes (NautilusDirectory *directory)
return;
}
g_hash_table_foreach (directory->details->metadata_changes,
- apply_file_changes, directory);
+ apply_one_file_changes, directory);
g_hash_table_destroy (directory->details->metadata_changes);
directory->details->metadata_changes = NULL;
}
@@ -798,18 +812,21 @@ nautilus_directory_get_integer_file_metadata (NautilusDirectory *directory,
default_as_string = g_strdup_printf ("%d", default_metadata);
result_as_string = nautilus_directory_get_file_metadata
(directory, file_name, key, default_as_string);
-
- /* Handle oddball case of non-existent directory */
+
+ /* Normally we can't get a a NULL, but we check for it here to
+ * handle the oddball case of a non-existent directory.
+ */
if (result_as_string == NULL) {
result = default_metadata;
} else {
- result = atoi (result_as_string);
+ if (sscanf (result_as_string, " %d %*s", &result) != 1) {
+ result = default_metadata;
+ }
g_free (result_as_string);
}
g_free (default_as_string);
return result;
-
}
gboolean
@@ -833,57 +850,56 @@ nautilus_directory_set_integer_file_metadata (NautilusDirectory *directory,
g_free (default_as_string);
}
-static void
-copy_file_metadata_for_key (NautilusDirectory *source_directory,
- const char *source_file_name,
- NautilusDirectory *destination_directory,
- const char *destination_file_name,
- const char *key)
-{
- char *data;
-
- data = nautilus_directory_get_file_metadata
- (source_directory, source_file_name,
- key, NULL);
- nautilus_directory_set_file_metadata
- (destination_directory, destination_file_name,
- key, NULL, data);
- g_free (data);
-}
-
void
nautilus_directory_copy_file_metadata (NautilusDirectory *source_directory,
const char *source_file_name,
NautilusDirectory *destination_directory,
const char *destination_file_name)
{
- /* FIXME bugzilla.eazel.com 3343: This does nothing to ensure
- * the source directory metadata is read in.
- */
+ xmlNodePtr source_node, node, root;
+ GHashTable *hash, *changes;
+
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (source_directory));
+ g_return_if_fail (source_file_name != NULL);
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (destination_directory));
+ g_return_if_fail (destination_file_name != NULL);
- /* FIXME bugzilla.eazel.com 2808: Change this to copy all the
- * metadata, not just a hard-coded set of keys.
+ /* FIXME bugzilla.eazel.com 3343: This does not properly
+ * handle the case where we don't have the source metadata yet
+ * since it's not read in.
*/
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_NOTES);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_ICON_SCALE);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_ICON_POSITION);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_ANNOTATION);
- copy_file_metadata_for_key
- (source_directory, source_file_name,
- destination_directory, destination_file_name,
- NAUTILUS_METADATA_KEY_CUSTOM_ICON);
+
+ nautilus_directory_remove_file_metadata
+ (destination_directory, destination_file_name);
+ g_assert (get_file_node (destination_directory, destination_file_name, FALSE) == NULL);
+
+ source_node = get_file_node (source_directory, source_file_name, FALSE);
+ if (source_node != NULL) {
+ if (destination_directory->details->metafile_read) {
+ node = xmlCopyNode (source_node, TRUE);
+ root = create_metafile_root (destination_directory);
+ xmlAddChild (root, node);
+ xmlSetProp (node, "NAME", destination_file_name);
+ g_hash_table_insert (destination_directory->details->metafile_node_hash,
+ xmlMemStrdup (destination_file_name), node);
+ } else {
+ /* FIXME: Copying data into a destination
+ * where the metafile was not yet read is not
+ * implemented.
+ */
+ g_warning ("not copying metadata");
+ }
+ }
+
+ hash = source_directory->details->metadata_changes;
+ if (hash != NULL) {
+ changes = g_hash_table_lookup (hash, source_file_name);
+ if (changes != NULL) {
+ apply_file_changes (destination_directory,
+ destination_file_name,
+ changes);
+ }
+ }
/* FIXME: Do we want to copy the thumbnail here like in the
* rename and remove cases?
@@ -897,18 +913,21 @@ nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
gboolean found;
gpointer key, value;
xmlNode *file_node;
- GHashTable *directory_table;
+ GHashTable *hash;
char *file_uri;
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+ g_return_if_fail (file_name != NULL);
+
if (directory->details->metafile_read) {
/* Remove data in XML document if present. */
- found = directory->details->metafile_node_hash != NULL
- && g_hash_table_lookup_extended (directory->details->metafile_node_hash,
- file_name, &key, &value);
+ hash = directory->details->metafile_node_hash;
+ found = hash != NULL && g_hash_table_lookup_extended
+ (hash, file_name, &key, &value);
if (found) {
g_assert (strcmp (key, file_name) == 0);
file_node = value;
- g_hash_table_remove (directory->details->metafile_node_hash,
+ g_hash_table_remove (hash,
file_name);
xmlFree (key);
nautilus_xml_remove_node (file_node);
@@ -917,17 +936,21 @@ nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
}
} else {
/* Remove data from hash table. */
- directory_table = directory->details->metadata_changes;
+ /* FIXME: If there's data for this file on the
+ * metafile on disk, this does not arrange for it to
+ * be removed when the metafile is later read.
+ */
+ hash = directory->details->metadata_changes;
found = g_hash_table_lookup_extended
- (directory_table, file_name, &key, &value);
+ (hash, file_name, &key, &value);
if (found) {
- g_hash_table_remove (directory_table, file_name);
+ g_hash_table_remove (hash, file_name);
g_free (key);
metadata_value_destroy (value);
}
}
- /* delete the thumbnails for the file, if any */
+ /* Delete the thumbnails for the file, if any. */
file_uri = nautilus_directory_get_file_uri (directory, file_name);
nautilus_remove_thumbnail_for_file (file_uri);
g_free (file_uri);
@@ -941,8 +964,9 @@ nautilus_directory_set_metafile_contents (NautilusDirectory *directory,
xmlNodePtr node;
xmlChar *name;
- g_assert (directory->details->metafile == NULL);
- g_assert (directory->details->metafile_node_hash == NULL);
+ g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
+ g_return_if_fail (directory->details->metafile == NULL);
+ g_return_if_fail (directory->details->metafile_node_hash == NULL);
hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -956,7 +980,7 @@ nautilus_directory_set_metafile_contents (NautilusDirectory *directory,
name = xmlGetProp (node, "NAME");
if (g_hash_table_lookup (hash, name) != NULL) {
xmlFree (name);
- /* FIXME: Should we delete these duplicate nodes? */
+ /* FIXME: Should we delete duplicate nodes as we discover them? */
} else {
g_hash_table_insert (hash, name, node);
}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b5e0c6828..5018b25ef 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,5 @@
applets/launcher/nautilus-launcher-applet.c
+components/hardware/nautilus-hardware-view.c
components/help/converters/gnome-db2html2/gdb3html.c
components/help/converters/gnome-db2html2/sect-elements.c
components/help/converters/gnome-db2html2/toc-elements.c
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 8203c2e9b..1b9bf0901 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -701,7 +701,7 @@ find_and_update_home_link (void)
if (nautilus_link_local_is_home_link (link_path)) {
/* Create the home link */
- home_link_name = g_strdup_printf ("%s's Home", g_get_user_name ());
+ home_link_name = g_strdup_printf (_("%s's Home"), g_get_user_name ());
home_link_path = nautilus_make_path (desktop_path, home_link_name);
home_dir_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
@@ -748,7 +748,7 @@ place_home_directory (FMDesktopIconView *icon_view)
/* Create the home link */
desktop_path = nautilus_get_desktop_directory ();
- home_link_name = g_strdup_printf ("%s's Home", g_get_user_name ());
+ home_link_name = g_strdup_printf (_("%s's Home"), g_get_user_name ());
home_link_path = nautilus_make_path (desktop_path, home_link_name);
home_dir_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 953543cd3..68042b539 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -608,6 +608,10 @@ help_menu_about_nautilus_callback (BonoboUIComponent *component,
time_stamp = g_strdup ("");
}
+ /* The copyright character in here is correct for
+ * Latin-1 encoding, but not for UTF-8, so we have
+ * to change it when we upgrade to GTK 2.0.
+ */
about = nautilus_about_new (_("Nautilus"),
VERSION,
/* Localize to deal with
@@ -616,7 +620,7 @@ help_menu_about_nautilus_callback (BonoboUIComponent *component,
* not translate the
* company name, please.
*/
- _("(C) 1999, 2000 Eazel, Inc."),
+ _("\xA9 1999, 2000 Eazel, Inc."),
authors,
_("Nautilus is a graphical shell\n"
"for GNOME that makes it\n"
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 953543cd3..68042b539 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -608,6 +608,10 @@ help_menu_about_nautilus_callback (BonoboUIComponent *component,
time_stamp = g_strdup ("");
}
+ /* The copyright character in here is correct for
+ * Latin-1 encoding, but not for UTF-8, so we have
+ * to change it when we upgrade to GTK 2.0.
+ */
about = nautilus_about_new (_("Nautilus"),
VERSION,
/* Localize to deal with
@@ -616,7 +620,7 @@ help_menu_about_nautilus_callback (BonoboUIComponent *component,
* not translate the
* company name, please.
*/
- _("(C) 1999, 2000 Eazel, Inc."),
+ _("\xA9 1999, 2000 Eazel, Inc."),
authors,
_("Nautilus is a graphical shell\n"
"for GNOME that makes it\n"