Re: [Nautilus-list] Patch for custom icon
- From: Johan Dahlin <jdahlin telia com>
- To: Darin Adler <darin bentspoon com>
- Cc: nautilus-list lists eazel com
- Subject: Re: [Nautilus-list] Patch for custom icon
- Date: 24 Mar 2002 19:31:57 +0100
sön 2002-03-24 klockan 18.11 skrev Darin Adler:
>
> On Sunday, March 24, 2002, at 08:27 AM, Johan Dahlin wrote:
>
> > But you're probably right when you saying that it should be done in
> > another level, but my knowledge about nautilus code is limited, this
> > just worked.
>
> Test and make sure it works for file names that have "%" in them. If
> your code doesn't break things for those files, then it might be OK to
> take the patch. If it does break, then we have to do better.
>
With a few modification it works with &, %, $, @ etc.
But it seems to fail with # in the filename.
Seems to be another problem, since it don't work without my patch.
Attached new patch.
> We don't want to play "whack-a-mole"
> <http://www.tuxedo.org/~esr/jargon/html/entry/whack-a-mole.html>, where
> we fix one bug and it makes another bug pop up.
This fixes at least 2 bugs, so we would still be one plus :)
>
> -- Darin
>
--
Johan Dahlin
Index: nautilus-sidebar.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-sidebar.c,v
retrieving revision 1.209
diff -u -r1.209 nautilus-sidebar.c
--- nautilus-sidebar.c 7 Mar 2002 19:36:07 -0000 1.209
+++ nautilus-sidebar.c 24 Mar 2002 18:29:27 -0000
@@ -716,10 +716,14 @@
char **uris;
gboolean exactly_one;
GtkWindow *window;
+ char *escaped_name;
uris = g_strsplit (selection_data->data, "\r\n", 0);
- exactly_one = uris[0] != NULL && uris[1] == NULL;
+ exactly_one = uris[0] != NULL && (uris[1] == NULL || *uris[1] == 0);
window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar)));
+
+ escaped_name = gnome_vfs_escape_host_and_path_string (uris[0]);
+ g_strfreev (uris);
switch (hit_test (sidebar, x, y)) {
case NO_PART:
@@ -727,14 +731,14 @@
/* FIXME bugzilla.gnome.org 42507: Does this work for all images, or only background images?
* Other views handle background images differently from other URIs.
*/
- if (exactly_one && uri_is_local_image (uris[0])) {
+ if (exactly_one && uri_is_local_image (escaped_name)) {
eel_background_receive_dropped_background_image
(eel_get_widget_background (GTK_WIDGET (sidebar)),
- uris[0]);
+ escaped_name);
} else if (exactly_one) {
g_signal_emit (sidebar,
signals[LOCATION_CHANGED], 0,
- uris[0]);
+ escaped_name);
}
break;
case TABS_PART:
@@ -742,7 +746,7 @@
break;
case ICON_PART:
/* handle images dropped on the logo specially */
-
+
if (!exactly_one) {
eel_show_error_dialog (
_("You can't assign more than one custom icon at a time! "
@@ -752,19 +756,23 @@
break;
}
- if (uri_is_local_image (uris[0])) {
+ if (uri_is_local_image (escaped_name)) {
if (sidebar->details->file != NULL) {
+
+ /* use escape_host_and_path_string, instead of escape_string since we
+ * don't want to escape / and :
+ */
nautilus_file_set_metadata (sidebar->details->file,
NAUTILUS_METADATA_KEY_CUSTOM_ICON,
NULL,
- uris[0]);
+ escaped_name);
nautilus_file_set_metadata (sidebar->details->file,
NAUTILUS_METADATA_KEY_ICON_SCALE,
NULL,
NULL);
}
} else {
- if (eel_is_remote_uri (uris[0])) {
+ if (eel_is_remote_uri (escaped_name)) {
eel_show_error_dialog (
_("The file that you dropped is not local. "
"You can only use local images as custom icons."),
@@ -782,7 +790,7 @@
break;
}
- g_strfreev (uris);
+ g_free (escaped_name);
}
static void
Index: file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.149
diff -u -r1.149 fm-properties-window.c
--- file-manager/fm-properties-window.c 22 Mar 2002 13:23:38 -0000 1.149
+++ file-manager/fm-properties-window.c 24 Mar 2002 18:29:28 -0000
@@ -2419,6 +2419,7 @@
{
NautilusFile *file;
char *icon_uri;
+ char *escaped_name;
g_return_if_fail (properties_window != NULL);
g_return_if_fail (FM_IS_PROPERTIES_WINDOW (properties_window));
@@ -2426,8 +2427,16 @@
if (icon_path != NULL) {
file = properties_window->details->original_file;
icon_uri = gnome_vfs_get_uri_from_local_path (icon_path);
- nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL, icon_uri);
+
+ /* use escape_host_and_path_string, instead of escape_string since we
+ * don't want to escape / and :
+ */
+ escaped_name = gnome_vfs_escape_host_and_path_string (icon_uri);
g_free (icon_uri);
+
+ nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL, escaped_name);
+ g_free (escaped_name);
+
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_ICON_SCALE, NULL, NULL);
/* re-enable the property window's clear image button */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]