mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-13 04:51:15 +00:00
Speed up stock icon registration, as discussed on the mailing list:
2006-03-19 Christian Neumair <chris@gnome-de.org> * src/nautilus-main.c: (register_icons): Speed up stock icon registration, as discussed on the mailing list: http://mail.gnome.org/archives/nautilus-list/2006-March/msg00036.html Also fixes #335158. * src/nautilus-spatial-window.c: (action_add_bookmark_callback): Don't add location bookmark for desktop windows. Fixes #334860. * libnautilus-private/nautilus-file-operations.c: (nautilus_file_operations_copy_move): Check whether enclosing volume for any of the source files is read-only, and set GNOME_VFS_XFER_TARGET_DEFAULT_PERMS in this case. Fixes #167102. * libnautilus-private/nautilus-file-utilities.c: * libnautilus-private/nautilus-file-utilities.h: Add nautilus_get_enclosing_volume.
This commit is contained in:
parent
d3902e5d26
commit
bb783d1380
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2006-03-19 Christian Neumair <chris@gnome-de.org>
|
||||
|
||||
* src/nautilus-main.c: (register_icons):
|
||||
Speed up stock icon registration, as discussed on the mailing list:
|
||||
|
||||
http://mail.gnome.org/archives/nautilus-list/2006-March/msg00036.html
|
||||
|
||||
Also fixes #335158.
|
||||
|
||||
* src/nautilus-spatial-window.c: (action_add_bookmark_callback):
|
||||
Don't add location bookmark for desktop windows. Fixes #334860.
|
||||
|
||||
* libnautilus-private/nautilus-file-operations.c:
|
||||
(nautilus_file_operations_copy_move):
|
||||
Check whether enclosing volume for any of the source files is
|
||||
read-only, and set GNOME_VFS_XFER_TARGET_DEFAULT_PERMS in this case.
|
||||
Fixes #167102.
|
||||
|
||||
* libnautilus-private/nautilus-file-utilities.c:
|
||||
* libnautilus-private/nautilus-file-utilities.h:
|
||||
Add nautilus_get_enclosing_volume.
|
||||
|
||||
2006-03-19 Martin Wehner <martin.wehner@gmail.com>
|
||||
|
||||
* nautilus-computer.desktop.in:
|
||||
|
|
|
@ -1875,12 +1875,14 @@ nautilus_file_operations_copy_move (const GList *item_uris,
|
|||
|
||||
TransferInfo *transfer_info;
|
||||
SyncTransferInfo *sync_transfer_info;
|
||||
GnomeVFSVolume *volume;
|
||||
GnomeVFSResult result;
|
||||
gboolean target_is_trash;
|
||||
gboolean duplicate;
|
||||
gboolean target_is_mapping;
|
||||
gboolean have_nonmapping_source;
|
||||
gboolean have_nonlocal_source;
|
||||
gboolean have_readonly_source;
|
||||
|
||||
IconPositionIterator *icon_position_iterator;
|
||||
|
||||
|
@ -1914,6 +1916,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
|
|||
target_uri_list = NULL;
|
||||
have_nonlocal_source = FALSE;
|
||||
have_nonmapping_source = FALSE;
|
||||
have_readonly_source = FALSE;
|
||||
duplicate = copy_action != GDK_ACTION_MOVE;
|
||||
for (p = item_uris; p != NULL; p = p->next) {
|
||||
/* Filter out special Nautilus link files */
|
||||
|
@ -1938,7 +1941,13 @@ nautilus_file_operations_copy_move (const GList *item_uris,
|
|||
if (strcmp (source_uri->method_string, "burn") != 0) {
|
||||
have_nonmapping_source = TRUE;
|
||||
}
|
||||
|
||||
|
||||
volume = nautilus_get_enclosing_volume (source_uri);
|
||||
if (volume != NULL && gnome_vfs_volume_is_read_only (volume)) {
|
||||
have_readonly_source = TRUE;
|
||||
}
|
||||
gnome_vfs_volume_unref (volume);
|
||||
|
||||
/* Note: this could be null if we're e.g. copying the top level file of a web site */
|
||||
source_dir_uri = gnome_vfs_uri_get_parent (source_uri);
|
||||
target_uri = NULL;
|
||||
|
@ -1996,6 +2005,10 @@ nautilus_file_operations_copy_move (const GList *item_uris,
|
|||
move_options |= GNOME_VFS_XFER_USE_UNIQUE_NAMES;
|
||||
}
|
||||
|
||||
if (have_readonly_source) {
|
||||
move_options |= GNOME_VFS_XFER_TARGET_DEFAULT_PERMS;
|
||||
}
|
||||
|
||||
/* List may be NULL if we filtered all items out */
|
||||
if (source_uri_list == NULL) {
|
||||
if (target_dir_uri != NULL) {
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include <libgnomevfs/gnome-vfs-ops.h>
|
||||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <libgnomevfs/gnome-vfs-utils.h>
|
||||
#include <libgnomevfs/gnome-vfs-volume.h>
|
||||
#include <libgnomevfs/gnome-vfs-volume-monitor.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -583,6 +585,64 @@ nautilus_get_uri_shortname_for_display (GnomeVFSURI *uri)
|
|||
return name;
|
||||
}
|
||||
|
||||
/* FIXME resolve basename symlinks before comparing URIs?
|
||||
* We may wrongly match a volume, or wrongly not match it.
|
||||
*/
|
||||
GnomeVFSVolume *
|
||||
nautilus_get_enclosing_volume (GnomeVFSURI *uri)
|
||||
{
|
||||
GnomeVFSVolume *volume, *one_volume;
|
||||
GList *l, *list;
|
||||
char *one_uri;
|
||||
GnomeVFSURI *one_vfs_uri, *potential_vfs_uri;
|
||||
|
||||
g_assert (uri != NULL);
|
||||
|
||||
volume = NULL;
|
||||
potential_vfs_uri = NULL;
|
||||
|
||||
list = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
|
||||
|
||||
for (l = list; l != NULL; l = l->next) {
|
||||
one_volume = l->data;
|
||||
|
||||
one_uri = gnome_vfs_volume_get_activation_uri (one_volume);
|
||||
if (one_uri == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
one_vfs_uri = gnome_vfs_uri_new (one_uri);
|
||||
if (one_vfs_uri == NULL) {
|
||||
g_free (one_uri);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gnome_vfs_uri_is_parent (one_vfs_uri, uri, TRUE) &&
|
||||
(potential_vfs_uri == NULL ||
|
||||
gnome_vfs_uri_is_parent (potential_vfs_uri, one_vfs_uri, TRUE))) {
|
||||
if (potential_vfs_uri != NULL) {
|
||||
gnome_vfs_uri_unref (potential_vfs_uri);
|
||||
gnome_vfs_volume_unref (volume);
|
||||
}
|
||||
|
||||
potential_vfs_uri = gnome_vfs_uri_ref (one_vfs_uri);
|
||||
volume = gnome_vfs_volume_ref (one_volume);
|
||||
}
|
||||
|
||||
gnome_vfs_uri_unref (one_vfs_uri);
|
||||
g_free (one_uri);
|
||||
}
|
||||
|
||||
if (potential_vfs_uri != NULL) {
|
||||
gnome_vfs_uri_unref (potential_vfs_uri);
|
||||
}
|
||||
|
||||
g_list_foreach (list, (GFunc) gnome_vfs_volume_unref, NULL);
|
||||
g_list_free (list);
|
||||
|
||||
return volume;
|
||||
}
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
|
||||
void
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define NAUTILUS_FILE_UTILITIES_H
|
||||
|
||||
#include <libgnomevfs/gnome-vfs-types.h>
|
||||
#include <libgnomevfs/gnome-vfs-volume.h>
|
||||
|
||||
#define NAUTILUS_SAVED_SEARCH_EXTENSION ".savedSearch"
|
||||
#define NAUTILUS_SAVED_SEARCH_MIMETYPE "application/x-gnome-saved-search"
|
||||
|
@ -88,4 +89,6 @@ GList * nautilus_find_all_files_in_gnome_path (char *file);
|
|||
const char *nautilus_get_vfs_method_display_name (char *method);
|
||||
char * nautilus_get_uri_shortname_for_display (GnomeVFSURI *uri);
|
||||
|
||||
GnomeVFSVolume *nautilus_get_enclosing_volume (GnomeVFSURI *uri);
|
||||
|
||||
#endif /* NAUTILUS_FILE_UTILITIES_H */
|
||||
|
|
|
@ -132,62 +132,33 @@ static void
|
|||
register_icons (void)
|
||||
{
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconInfo *info;
|
||||
const char *icon;
|
||||
GtkIconSource *source;
|
||||
GtkIconSet *set;
|
||||
GtkIconFactory *factory;
|
||||
const char *icons_to_register[] = {"gnome-fs-client", "gnome-fs-network", "gnome-fs-home", "gnome-fs-trash-empty", "gnome-dev-cdrom", "stock_new-template"};
|
||||
struct { int pixel; int gtk; } sizes[] = {
|
||||
{16, GTK_ICON_SIZE_MENU},
|
||||
{18, GTK_ICON_SIZE_SMALL_TOOLBAR},
|
||||
{20, GTK_ICON_SIZE_BUTTON},
|
||||
{24, GTK_ICON_SIZE_LARGE_TOOLBAR},
|
||||
{32, GTK_ICON_SIZE_DND},
|
||||
{48, GTK_ICON_SIZE_DIALOG},
|
||||
{48, 0},
|
||||
};
|
||||
int i, j;
|
||||
int i;
|
||||
|
||||
icon_theme = nautilus_icon_factory_get_icon_theme ();
|
||||
|
||||
factory = gtk_icon_factory_new ();
|
||||
gtk_icon_factory_add_default (factory);
|
||||
|
||||
source = gtk_icon_source_new ();
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(icons_to_register); i++) {
|
||||
|
||||
set = gtk_icon_set_new ();
|
||||
source = gtk_icon_source_new ();
|
||||
|
||||
for (j = 0; j < G_N_ELEMENTS(sizes); j++) {
|
||||
info = gtk_icon_theme_lookup_icon (icon_theme, icons_to_register[i], sizes[j].pixel, 0);
|
||||
|
||||
if (info != NULL &&
|
||||
(sizes[j].gtk == 0 ||
|
||||
gtk_icon_info_get_base_size (info) == sizes[j].pixel)) {
|
||||
icon = gtk_icon_info_get_filename (info);
|
||||
gtk_icon_source_set_filename (source, icon);
|
||||
if (sizes[j].gtk == 0) {
|
||||
gtk_icon_source_set_size (source, 0);
|
||||
gtk_icon_source_set_size_wildcarded (source, TRUE);
|
||||
} else {
|
||||
gtk_icon_source_set_size (source, sizes[j].gtk);
|
||||
gtk_icon_source_set_size_wildcarded (source, FALSE);
|
||||
}
|
||||
gtk_icon_set_add_source (set, source);
|
||||
}
|
||||
if (info != NULL) {
|
||||
gtk_icon_info_free (info);
|
||||
}
|
||||
}
|
||||
gtk_icon_source_set_icon_name (source, icons_to_register[i]);
|
||||
gtk_icon_set_add_source (set, source);
|
||||
|
||||
gtk_icon_source_free (source);
|
||||
gtk_icon_factory_add (factory, icons_to_register[i], set);
|
||||
gtk_icon_set_unref (set);
|
||||
|
||||
gtk_icon_set_unref (set);
|
||||
}
|
||||
|
||||
gtk_icon_source_free (source);
|
||||
g_object_unref (factory);
|
||||
g_object_unref (icon_theme);
|
||||
|
||||
}
|
||||
|
||||
/* Copied from libnautilus/nautilus-program-choosing.c; In this case,
|
||||
|
|
Loading…
Reference in a new issue