mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-13 04:51:15 +00:00
Huge ass redhat merge
This commit is contained in:
parent
badc7589bc
commit
61d960f12c
464
ChangeLog
464
ChangeLog
|
@ -1,3 +1,467 @@
|
|||
2001-09-20 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-desktop-file-loader.c:
|
||||
Correct filename in header.
|
||||
(nautilus_desktop_file_new): Use g_new0
|
||||
(nautilus_desktop_file_load):
|
||||
Don't initialize contents. Don't need to check contents
|
||||
for NULL.
|
||||
(nautilus_desktop_file_foreach_section):
|
||||
Coding style fix.
|
||||
|
||||
* libnautilus-private/nautilus-link-desktop-file.c
|
||||
(nautilus_link_desktop_file_local_create): Use fputs instead
|
||||
of fwrite.
|
||||
|
||||
2001-09-19 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-link-desktop-file.c
|
||||
(nautilus_link_desktop_file_get_link_uri_from_desktop):
|
||||
Handle broken .desktop file with type "URL".
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c:
|
||||
Load the default icon name even when we have a custom icon uri.
|
||||
It may be needed if the custom icon was not there.
|
||||
|
||||
2001-09-19 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-directory-async.c
|
||||
(make_dot_directory_uri): gnome_vfs_uri_new() may fail.
|
||||
(link_info_start): Handle make_dot_directory_uri failing.
|
||||
|
||||
* libnautilus-private/nautilus-icon-container.c:
|
||||
Remove fixed FIXME.
|
||||
|
||||
* libnautilus-private/nautilus-link-desktop-file.c
|
||||
(slurp_key_string): Pass uris to nautilus_desktop_file_load ().
|
||||
(nautilus_link_desktop_file_local_create): Create files
|
||||
using FILE * instead of GnomeVFS.
|
||||
(nautilus_link_desktop_file_local_set_icon,
|
||||
nautilus_link_desktop_file_local_get_link_uri):
|
||||
The argument is a path, not a uri.
|
||||
(nautilus_link_desktop_file_local_set_type,
|
||||
nautilus_link_desktop_file_local_set_link_uri): Remove failing functions.
|
||||
(nautilus_link_desktop_file_local_get_additional_text): Comment
|
||||
out additional text for now.
|
||||
|
||||
* libnautilus-private/nautilus-link-desktop-file.h
|
||||
(nautilus_link_desktop_file_local_set_type,
|
||||
nautilus_link_desktop_file_local_set_link_uri): Remove failing functions.
|
||||
|
||||
* libnautilus-private/nautilus-link-historical.c:
|
||||
(local_get_root_property):
|
||||
Always use paths for the arguments.
|
||||
|
||||
* libnautilus-private/nautilus-link.c:
|
||||
Make nautilus_link_local_set_link_uri and nautilus_link_local_set_type
|
||||
not be called for .desktop files.
|
||||
|
||||
* src/file-manager/fm-directory-view.c:
|
||||
Remove unnecessary include
|
||||
|
||||
* src/file-manager/fm-icon-view.c:
|
||||
Re-enable additional text.
|
||||
|
||||
2001-09-19 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/Makefile.am:
|
||||
* libnautilus-private/nautilus-desktop-file-loader.[ch]:
|
||||
* libnautilus-private/nautilus-link-historical.[ch]:
|
||||
Rename nautilus-link-impl to nautilus-link-historical
|
||||
and nauitlus-link-desktop to nautilus-link-desktop-file.
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.[ch]:
|
||||
* libnautilus-private/nautilus-link-impl.[ch]:
|
||||
Removed old files.
|
||||
|
||||
* libnautilus-private/nautilus-link.c:
|
||||
* libnautilus-private/nautilus-file.c:
|
||||
* libnautilus-private/nautilus-icon-factory.c:
|
||||
Update for the renames.
|
||||
|
||||
* libnautilus-private/nautilus-desktop-file-loader.c:
|
||||
Some coding style changes.
|
||||
|
||||
2001-09-18 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/desktop-file-loader.[ch],
|
||||
libnautilus-private/nautilus-desktop-file.[ch]:
|
||||
Removed files.
|
||||
* libnautilus-private/nautilus-desktop-file-loader.[ch],
|
||||
libnautilus-private/Makefile.am:
|
||||
New, cleaned up version of the desktop-file loader.
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c:
|
||||
Update to the new desktop file parser names.
|
||||
|
||||
2001-09-13 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-file.c
|
||||
(nautilus_file_contains_text): Fix test for NULL mime type with
|
||||
reverse polarity; don't free the mime type string since we are not
|
||||
copying it. I could have sworn I fixed both of these problems
|
||||
before merging my changes to the RH branch!
|
||||
|
||||
2001-09-01 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
Merged changes from mjs-patches-to-redhat-patches branch to
|
||||
redhat-outstanding-patches:
|
||||
|
||||
2001-08-27 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-directory-async.c
|
||||
(nautilus_directory_invalidate_count_and_mime_list): Fix a
|
||||
reference count underflow.
|
||||
|
||||
2001-08-27 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-directory-async.c:
|
||||
(link_info_read_done, start_or_stop_io,
|
||||
file_needs_high_priority_work_done,
|
||||
file_needs_low_priority_work_done, file_needs_work_done,
|
||||
nautilus_directory_add_file_to_work_queue,
|
||||
nautilus_directory_remove_file_from_work_queue,
|
||||
move_file_to_low_priority_queue): Use two queues instead of one
|
||||
for file attributes. The high priority attributes are ones needed
|
||||
to display an icon at all (file_info and link_info), the rest are
|
||||
things that can be displayed later. This change makes directory
|
||||
counts and top left text generally get loaded after all the files
|
||||
appear, instead of slowing down the load.
|
||||
* libnautilus-private/nautilus-directory-private.h: Adjusted
|
||||
for the two queue change.
|
||||
libnautilus-private/nautilus-directory.c
|
||||
(nautilus_directory_initialize, nautilus_directory_destroy):
|
||||
Likewise.
|
||||
* libnautilus-private/nautilus-file-queue.h,
|
||||
libnautilus-private/nautilus-file-queue.c:
|
||||
(nautilus_file_queue_new, nautilus_file_queue_destroy,
|
||||
nautilus_file_queue_enqueue, nautilus_file_queue_dequeue,
|
||||
nautilus_file_queue_remove, nautilus_file_queue_head,
|
||||
nautilus_file_queue_is_empty): New data structure that provides a
|
||||
queue of NautilusFiles that allows constant time removal from an
|
||||
arbitrary point in the list and avoids storing duplicates
|
||||
(basically factored out this code from nautilus-direcvtory-async).
|
||||
* libnautilus-private/Makefile.am: Add nautilus-file-queue.[ch] to
|
||||
build.
|
||||
|
||||
2001-08-27 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-directory-async.c
|
||||
(lacks_link_info): If we can determine here that link info will
|
||||
not be applicable to this file, set the proper flags and say it's
|
||||
not wanted. This removes much of the chunky loading effect the
|
||||
previous changes were causing.
|
||||
(link_info_start): Make test for gmc link more efficient by using
|
||||
nutilus_file_is_mime_type for mime type checking.
|
||||
|
||||
* libnautilus-private/nautilus-file.c:
|
||||
(nautilus_file_contains_text): Speed this check up by avoiding
|
||||
memory allocation.
|
||||
|
||||
2001-08-25 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
Reworked nautilus-directory-async to maintain a queue of files
|
||||
that need some async I/O done, to avoid n^2 behavior on large
|
||||
directory loads.
|
||||
|
||||
* libnautilus-private/nautilus-directory-private.h: Added
|
||||
declarations of file queue data structures and functions.
|
||||
|
||||
* libnautilus-private/nautilus-directory-async.c:
|
||||
(nautilus_directory_add_file_to_work_queue,
|
||||
add_all_files_to_work_queue,
|
||||
nautilus_directory_remove_file_from_work_queue): New functions for
|
||||
managing work queue.
|
||||
(file_needs_work_done): New function to determine when a file
|
||||
needs async I/O of any kind done.
|
||||
(nautilus_directory_monitor_add_internal,
|
||||
nautilus_directory_monitor_remove_internal,
|
||||
nautilus_directory_remove_file_monitors,
|
||||
nautilus_directory_add_file_monitors,
|
||||
nautilus_directory_call_when_ready_internal,
|
||||
nautilus_directory_force_reload_internal): Add files to work
|
||||
queue or remove files from work queue as appropriate.
|
||||
(nautilus_directory_invalidate_count_and_mime_list): Invalidate
|
||||
using the generic file attribute invalidation code, to make sure
|
||||
the right file is added to the work queue.
|
||||
(lacks_directory_count, lacks_deep_count, lacks_mime_list): Don't
|
||||
bother to check if it's a directory, since the relevant `_start'
|
||||
functions will check for that case and set the flag that says the
|
||||
data is up to date.
|
||||
(file_list_start_or_stop): Renamed to make effects more clear.
|
||||
(directory_count_callback): Set directory count info properly in
|
||||
the failure case.
|
||||
(link_info_done): Don't send a file changed notification
|
||||
here, since this might be called in cases where link info doesn't
|
||||
apply, and we don't want to send a notice in that case.
|
||||
(link_info_read_done): Instead, send it here, since cases where
|
||||
the link info applies all go through here.
|
||||
(top_left_read_done): Don't say we got the top left text when it
|
||||
failed.
|
||||
(directory_count_stop, directory_count_start, deep_count_stop,
|
||||
deep_count_start, mime_list_stop, mime_list_start,
|
||||
top_left_read_callback, top_left_stop, top_left_start),
|
||||
file_info_stop, file_info_start, link_info_stop, link_info_start):
|
||||
Split start and stop functions; make start functions take a file
|
||||
to start work on, if applicable, instead of searching the file
|
||||
list for a needy file.
|
||||
(start_or_stop_io): Revise algorithm as follows: stop all I/O that
|
||||
is no longer wanted; remove all files from the head of the queue
|
||||
that need no more I/O; and start any needed I/O for the file
|
||||
currently at the head of the queue.
|
||||
|
||||
* libnautilus-private/nautilus-directory.c:
|
||||
(nautilus_directory_initialize, nautilus_directory_destroy):
|
||||
Create and destroy work queue hash table.
|
||||
(nautilus_directory_add_file, nautilus_directory_remove_file): Add
|
||||
file to or remove file from work queue.
|
||||
* libnautilus-private/nautilus-file.c
|
||||
(nautilus_file_invalidate_attributes): Add file to work queue.
|
||||
|
||||
2001-08-22 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c:
|
||||
(image_uri_to_name_or_uri,
|
||||
nautilus_icon_factory_get_icon_for_file): Don't crash (oops).
|
||||
|
||||
2001-08-21 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c
|
||||
(nautilus_icon_factory_get_icon_for_file): Fix slight merge
|
||||
problem.
|
||||
|
||||
2001-08-21 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
These changes are meant to fix some of the areas of slowness
|
||||
uncovered by getting the link info asynchronously. They don't do
|
||||
the job all the way though.
|
||||
|
||||
* libnautilus-private/nautilus-directory-async.c: (lacks_top_left,
|
||||
lacks_link_info, top_left_start): Fix these up a bit to avoid
|
||||
doing the more expensive mime type comparing checks too
|
||||
frequently.
|
||||
|
||||
* libnautilus-private/nautilus-icon-private.h,
|
||||
libnautilus-private/nautilus-icon-container.c: (destroy),
|
||||
(nautilus_icon_container_initialize),
|
||||
(nautilus_icon_container_clear), (icon_destroy),
|
||||
(nautilus_icon_container_add), (nautilus_icon_container_remove),
|
||||
(nautilus_icon_container_request_update),
|
||||
(nautilus_icon_container_reveal): Add a hashtable mapping from
|
||||
icon data to icons, to make some formerly linear operations
|
||||
constant time and so hopefully avoid N^2 behavior. Manage the
|
||||
hashtable properly.
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.h,
|
||||
libnautilus-private/nautilus-icon-factory.c:
|
||||
(nautilus_icon_factory_get_icon_for_file,
|
||||
nautilus_icon_factory_get_required_file_attributes): Tweak a bit.
|
||||
(nautilus_icon_factory_get_basic_file_attributes,
|
||||
nautilus_icon_factory_is_basic_icon_ready_for_file): New functions
|
||||
that let you determine if most of the info needed to get an icon
|
||||
is ready - "most" being everything but top left text right now.
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c
|
||||
(nautilus_link_impl_desktop_get_link_icon_from_desktop): Remove
|
||||
stray printf.
|
||||
|
||||
2001-08-21 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* src/file-manager/fm-icon-view.c: (fm_icon_view_add_file,
|
||||
fm_icon_view_file_changed): Try to avoid displaying the generic
|
||||
icon before custom icon data is read.
|
||||
|
||||
2001-08-21 Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
|
||||
* libnautilus-private/nautilus-file-attributes.h: Add
|
||||
NAUTILUS_FILE_CUSTOM_NAME attribute.
|
||||
|
||||
* libnautilus-private/nautilus-directory-private.h,
|
||||
libnautilus-private/nautilus-directory-async.c:
|
||||
(link_info_cancel), (nautilus_directory_set_up_request),
|
||||
(nautilus_async_destroying_file), (lacks_link_info),
|
||||
(wants_link_info), (request_is_satisfied), (link_info_done),
|
||||
(link_info_read_done), (link_info_nautilus_link_read_callback),
|
||||
(link_info_gmc_link_read_callback),
|
||||
(link_info_gmc_link_read_more_callback), (make_dot_directory_uri),
|
||||
(link_info_start), (start_or_stop_io),
|
||||
(nautilus_directory_cancel),
|
||||
(cancel_link_info_for_file), (cancel_loading_attributes),
|
||||
(nautilus_directory_cancel_loading_file_attributes): Changes to
|
||||
get the custom name and custom icon out of a link files and
|
||||
.directory files asynchronously and with caching. The I/O is
|
||||
shared with the fetching of the activation URI.
|
||||
|
||||
* libnautilus-private/nautilus-file-private.h,
|
||||
libnautilus-private/nautilus-file.c: (destroy),
|
||||
(nautilus_file_get_name), (nautilus_file_get_activation_uri),
|
||||
(nautilus_file_get_custom_icon_uri), (invalidate_link_info),
|
||||
(nautilus_file_invalidate_attributes_internal),
|
||||
(nautilus_file_get_all_attributes): Handle new custom_name and
|
||||
custom_icon_uri attributes and link_info internal attribute
|
||||
properly.
|
||||
|
||||
* libnautilus-private/nautilus-file.h: Prototype new
|
||||
nautilus_file_get_custom_icon_uri call.
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c
|
||||
(nautilus_icon_factory_get_icon_for_file): Remove code for reading
|
||||
icons from .directory files and various kinds of links. Instead
|
||||
rely on nautilus_file_get_custom_icon_uri.
|
||||
|
||||
* libnautilus-private/nautilus-link.h,
|
||||
libnautilus-private/nautilus-link.c:
|
||||
(nautilus_link_get_link_uri_given_file_contents): Fix to work for
|
||||
classic nautilus links.
|
||||
(nautilus_link_get_link_name_given_file_contents): New call to get
|
||||
a custom name given link contents. (Actually does nothing for
|
||||
old-style nautilus links).
|
||||
(nautilus_link_get_link_icon_given_file_contents): New call to get
|
||||
a custom icon given link contents.
|
||||
(nautilus_link_local_set_icon, nautilus_link_local_set_link_uri):
|
||||
Invalidate the relevant file attributes.
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.h,
|
||||
libnautilus-private/nautilus-link-impl-desktop.c:
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.h,
|
||||
libnautilus-private/nautilus-link-impl-desktop.c:
|
||||
(nautilus_link_impl_desktop_local_set_icon): Remve attempt at
|
||||
notification (now done by generic layer).
|
||||
(nautilus_link_impl_desktop_get_link_name_from_desktop,
|
||||
nautilus_link_impl_desktop_get_link_name_given_file_contents):
|
||||
Implement getting the custom name.
|
||||
(nautilus_link_impl_desktop_get_link_icon_from_desktop,
|
||||
nautilus_link_impl_desktop_get_link_icon_given_file_contents):
|
||||
Implement getting the custom icon. This no longer attempts the
|
||||
hack of asynchronously downloading and caching remote
|
||||
icons. Nothing uses this feature and it should really be done in
|
||||
the icon factory, not here.
|
||||
|
||||
* libnautilus-private/nautilus-link-impl.h,
|
||||
libnautilus-private/nautilus-link-impl.c:
|
||||
(nautilus_link_impl_local_set_link_uri): Remove attempt at
|
||||
notification (done by generic layer now).
|
||||
(nautilus_link_impl_get_link_icon_given_file_contents): Implement
|
||||
getting the custom icon. This no longer attempts the hack of
|
||||
asynchronously downloading and caching remote icons. Nothing uses
|
||||
this feature and it should really be done in the icon factory, not
|
||||
here.
|
||||
|
||||
* components/tree/nautilus-tree-model.c:
|
||||
(nautilus_tree_model_monitor_add,
|
||||
nautilus_tree_model_node_begin_monitoring_no_connect): Monitor
|
||||
custom_name and attributes required by icon factory.
|
||||
|
||||
* src/file-manager/fm-directory-view.c (finish_loading): Monitor
|
||||
custom name attribute.
|
||||
|
||||
* src/file-manager/fm-properties-window.c
|
||||
(create_properties_window): Monitor custom name attribute.
|
||||
|
||||
* src/file-manager/fm-search-list-view.c (real_adding_file):
|
||||
Monitor custom name attribute.
|
||||
|
||||
* src/nautilus-window-manage-views.c
|
||||
(viewed_file_changed_callback): Always update title even if URI
|
||||
did not change because custom name may have changed or just been
|
||||
retrieved.
|
||||
|
||||
* src/nautilus-window.c: (nautilus_window_set_viewed_file):
|
||||
Monitor custom name attribute.
|
||||
|
||||
2001-08-20 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c
|
||||
(nautilus_icon_factory_get_icon_for_file):
|
||||
add a nautilus_file_is_local() before loading desktop files; this
|
||||
breaks Nautilus links, which are actually async. We lost the
|
||||
is_local() check on .desktop files because the .desktop files were
|
||||
added as a nautilus link backend, and nautilus links were async,
|
||||
so people were using them in nonlocal cases, but we deleted the
|
||||
.desktop codepath in favor of the nautilus link codepath.
|
||||
|
||||
(nautilus_icon_factory_get_icon_for_file): Do same processing for
|
||||
.directory image URI that we do for .desktop image URI, allowing
|
||||
us to handle X-Nautilus-Icon in .directory
|
||||
(image_uri_to_name_or_uri): function with the common processing
|
||||
|
||||
Wed Aug 8 21:02:33 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c
|
||||
(nautilus_link_impl_desktop_local_create): fix to really work with
|
||||
gnome_vfs.
|
||||
|
||||
Mon Aug 6 15:04:14 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c
|
||||
(nautilus_link_impl_desktop_local_create): write nautilus files
|
||||
using gnome-vfs instead of FILE.
|
||||
|
||||
2001-08-01 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c: use
|
||||
desktop_file_get_locale_string() instead of
|
||||
desktop_file_get_string() to get the names from the desktop files.
|
||||
|
||||
Wed Aug 1 04:58:35 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-link.c: Fix a crash when some files
|
||||
could return NULL as a mime-type.
|
||||
|
||||
* src/file-manager/fm-icon-view.c (get_icon_text_callback):
|
||||
Disable additional_text for .desktop files.
|
||||
|
||||
2001-07-31 Alex Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c (nautilus_link_impl_desktop_get_link_uri_from_desktop):
|
||||
Handle FSType desktop files here to. To allow unmounts.
|
||||
|
||||
2001-07-31 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-file.c (nautilus_file_get_name):
|
||||
get_text, not get_additional_text, for .directory files. fixes
|
||||
sidebar names hopefully.
|
||||
|
||||
Fri Jul 27 16:03:12 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-link.c (get_uri_mime_type_full):
|
||||
check the file for the mime-type rather then just the file name.
|
||||
Grabs old nautilus-link files.
|
||||
|
||||
Thu Jul 26 19:09:48 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* src/file-manager/fm-desktop-icon-view.c
|
||||
(update_trash_link_and_delete_copies): fix Trash.desktop file.
|
||||
|
||||
* libnautilus-private/nautilus-link-impl-desktop.c
|
||||
(slurp_uri_contents): '\000' terminate buffer read in.
|
||||
(nautilus_link_impl_desktop_local_set_icon): Implement.
|
||||
|
||||
2001-07-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* src/file-manager/fm-directory-view.c
|
||||
(activate_callback): remove the hack for .desktop files, we now
|
||||
do them the same way as Nautilus link files
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c
|
||||
(nautilus_icon_factory_get_icon_for_file):
|
||||
get icons for .desktop files and .directory files
|
||||
|
||||
* libnautilus-private/nautilus-file.c
|
||||
(nautilus_file_get_name): handle .desktop files using the
|
||||
desktop loader that works on non-file: URIs
|
||||
|
||||
* libnautilus-private/desktop-file-loader.h,
|
||||
libnautilus-private/desktop-file-loader.c: lame desktop file
|
||||
parser to be used temporarily until George finishes the Ultimate
|
||||
Desktop File Loader.
|
||||
|
||||
* libnautilus-private/Makefile.am: Add files for link file
|
||||
abstraction, intended to allow use of .desktop files in place of
|
||||
Nautilus link files.
|
||||
|
||||
2001-09-25 Darin Adler <darin@bentspoon.com>
|
||||
|
||||
* components/adapter/nautilus-adapter.c:
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <gtk/gtksignal.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <libnautilus-private/nautilus-file-attributes.h>
|
||||
#include <libnautilus-private/nautilus-icon-factory.h>
|
||||
#include <eel/eel-glib-extensions.h>
|
||||
#include <eel/eel-gtk-macros.h>
|
||||
#include <stdio.h>
|
||||
|
@ -328,7 +329,9 @@ nautilus_tree_model_monitor_add (NautilusTreeModel *model,
|
|||
nautilus_tree_model_root_node_file_monitor,
|
||||
model);
|
||||
|
||||
monitor_attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY);
|
||||
monitor_attributes = nautilus_icon_factory_get_required_file_attributes ();
|
||||
monitor_attributes = g_list_prepend (monitor_attributes, NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY);
|
||||
monitor_attributes = g_list_prepend (monitor_attributes, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (nautilus_tree_node_get_file (model->details->root_node),
|
||||
model,
|
||||
monitor_attributes);
|
||||
|
@ -412,7 +415,9 @@ nautilus_tree_model_node_begin_monitoring_no_connect (NautilusTreeModel
|
|||
nautilus_directory_force_reload (directory);
|
||||
}
|
||||
|
||||
monitor_attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY);
|
||||
monitor_attributes = nautilus_icon_factory_get_required_file_attributes ();
|
||||
monitor_attributes = g_list_prepend (monitor_attributes, NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY);
|
||||
monitor_attributes = g_list_prepend (monitor_attributes, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_directory_file_monitor_add (directory,
|
||||
model,
|
||||
TRUE, TRUE,
|
||||
|
|
|
@ -48,6 +48,7 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-bookmark.c \
|
||||
nautilus-customization-data.c \
|
||||
nautilus-default-file-icon.c \
|
||||
nautilus-desktop-file-loader.c \
|
||||
nautilus-directory-async.c \
|
||||
nautilus-directory-background.c \
|
||||
nautilus-directory-metafile-monitor.c \
|
||||
|
@ -60,6 +61,7 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-file-changes-queue.c \
|
||||
nautilus-file-dnd.c \
|
||||
nautilus-file-operations-progress.c \
|
||||
nautilus-file-queue.c \
|
||||
nautilus-file-operations.c \
|
||||
nautilus-file-utilities.c \
|
||||
nautilus-file.c \
|
||||
|
@ -75,6 +77,8 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-lib-self-check-functions.c \
|
||||
nautilus-link-set.c \
|
||||
nautilus-link.c \
|
||||
nautilus-link-desktop-file.c \
|
||||
nautilus-link-historical.c \
|
||||
nautilus-medusa-support.c \
|
||||
nautilus-merged-directory.c \
|
||||
nautilus-metafile-factory.c \
|
||||
|
@ -106,6 +110,7 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-cdrom-extensions.h \
|
||||
nautilus-customization-data.h \
|
||||
nautilus-default-file-icon.h \
|
||||
nautilus-desktop-file-loader.h \
|
||||
nautilus-directory-background.h \
|
||||
nautilus-directory-metafile-monitor.h \
|
||||
nautilus-directory-metafile.h \
|
||||
|
@ -124,6 +129,7 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-file-private.h \
|
||||
nautilus-file-utilities.h \
|
||||
nautilus-file.h \
|
||||
nautilus-file-queue.h \
|
||||
nautilus-font-factory.h \
|
||||
nautilus-global-preferences.h \
|
||||
nautilus-horizontal-splitter.h \
|
||||
|
@ -139,6 +145,8 @@ libnautilus_private_la_SOURCES = \
|
|||
nautilus-lib-self-check-functions.h \
|
||||
nautilus-link-set.h \
|
||||
nautilus-link.h \
|
||||
nautilus-link-desktop-file.h \
|
||||
nautilus-link-historical.h \
|
||||
nautilus-medusa-support.h \
|
||||
nautilus-merged-directory.h \
|
||||
nautilus-metadata.h \
|
||||
|
|
1223
libnautilus-private/nautilus-desktop-file-loader.c
Normal file
1223
libnautilus-private/nautilus-desktop-file-loader.c
Normal file
File diff suppressed because it is too large
Load diff
85
libnautilus-private/nautilus-desktop-file-loader.h
Normal file
85
libnautilus-private/nautilus-desktop-file-loader.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
|
||||
|
||||
/* eel-desktop-file-loader.h
|
||||
|
||||
Copyright (C) 2001 Red Hat, Inc.
|
||||
|
||||
Developers: Havoc Pennington <hp@redhat.com>
|
||||
Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
as published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
The library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place -
|
||||
Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_DESKTOP_FILE_LOADER_H
|
||||
#define NAUTILUS_DESKTOP_FILE_LOADER_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <libgnomevfs/gnome-vfs-result.h>
|
||||
|
||||
typedef struct NautilusDesktopFile NautilusDesktopFile;
|
||||
|
||||
/* This is a quick-hack to read and modify .desktop files.
|
||||
* It has severe limitations, but does what nautilus
|
||||
* needs right now. You cannot create new sections or add non-existing keys.
|
||||
*
|
||||
* The right way to solve this is to write a good desktop file parser
|
||||
* and put it in another library for use by the panel, nautilus etc.
|
||||
*/
|
||||
|
||||
GnomeVFSResult nautilus_desktop_file_load (const char *uri,
|
||||
NautilusDesktopFile **desktop_file);
|
||||
NautilusDesktopFile *nautilus_desktop_file_from_string (const char *data);
|
||||
GnomeVFSResult nautilus_desktop_file_save (NautilusDesktopFile *df,
|
||||
const char *uri);
|
||||
void nautilus_desktop_file_free (NautilusDesktopFile *df);
|
||||
|
||||
/* This is crap, it just ignores the %f etc. in the exec string,
|
||||
* and has no error handling.
|
||||
*/
|
||||
void nautilus_desktop_file_launch (NautilusDesktopFile *df);
|
||||
|
||||
|
||||
gboolean nautilus_desktop_file_get_boolean (NautilusDesktopFile *df,
|
||||
const char *section,
|
||||
const char *keyname,
|
||||
gboolean *val);
|
||||
gboolean nautilus_desktop_file_get_number (NautilusDesktopFile *df,
|
||||
const char *section,
|
||||
const char *keyname,
|
||||
double *val);
|
||||
gboolean nautilus_desktop_file_get_string (NautilusDesktopFile *df,
|
||||
const char *section,
|
||||
const char *keyname,
|
||||
char **val);
|
||||
gboolean nautilus_desktop_file_get_locale_string (NautilusDesktopFile *df,
|
||||
const char *section,
|
||||
const char *keyname,
|
||||
char **val);
|
||||
gboolean nautilus_desktop_file_get_regexp (NautilusDesktopFile *df,
|
||||
const char *section,
|
||||
const char *keyname,
|
||||
char **val);
|
||||
gboolean nautilus_desktop_file_set_string (NautilusDesktopFile *df,
|
||||
const char *section,
|
||||
const char *keyname,
|
||||
const char *value);
|
||||
|
||||
|
||||
/* Some getters and setters are missing, they should be added as needed */
|
||||
|
||||
|
||||
#endif /* NAUTILUS_DESKTOP_FILE_LOADER_H */
|
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,7 @@
|
|||
#include "nautilus-file.h"
|
||||
#include "nautilus-metafile-server.h"
|
||||
#include "nautilus-monitor.h"
|
||||
#include "nautilus-file-queue.h"
|
||||
#include <eel/eel-vfs-extensions.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libgnomevfs/gnome-vfs-file-info.h>
|
||||
|
@ -35,7 +36,7 @@
|
|||
#include <libgnomevfs/gnome-vfs-utils.h>
|
||||
#include <libnautilus/nautilus-idle-queue.h>
|
||||
|
||||
typedef struct ActivationURIReadState ActivationURIReadState;
|
||||
typedef struct LinkInfoReadState LinkInfoReadState;
|
||||
typedef struct TopLeftTextReadState TopLeftTextReadState;
|
||||
typedef struct FileMonitors FileMonitors;
|
||||
|
||||
|
@ -50,6 +51,10 @@ struct NautilusDirectoryDetails
|
|||
GList *file_list;
|
||||
GHashTable *file_hash;
|
||||
|
||||
/* Queues of files needing some I/O done. */
|
||||
NautilusFileQueue *high_priority_queue;
|
||||
NautilusFileQueue *low_priority_queue;
|
||||
|
||||
/* These lists are going to be pretty short. If we think they
|
||||
* are going to get big, we can use hash tables instead.
|
||||
*/
|
||||
|
@ -97,14 +102,15 @@ struct NautilusDirectoryDetails
|
|||
GnomeVFSAsyncHandle *get_info_in_progress;
|
||||
|
||||
TopLeftTextReadState *top_left_read_state;
|
||||
ActivationURIReadState *activation_uri_read_state;
|
||||
|
||||
LinkInfoReadState *link_info_read_state;
|
||||
|
||||
GList *file_operations_in_progress; /* list of FileOperation * */
|
||||
};
|
||||
|
||||
/* A request for information about one or more files. */
|
||||
typedef struct {
|
||||
gboolean activation_uri;
|
||||
gboolean link_info;
|
||||
gboolean deep_count;
|
||||
gboolean directory_count;
|
||||
gboolean file_info;
|
||||
|
@ -205,6 +211,12 @@ void nautilus_directory_end_file_name_change (NautilusD
|
|||
GList *node);
|
||||
void nautilus_directory_moved (const char *from_uri,
|
||||
const char *to_uri);
|
||||
/* Interface to the work queue. */
|
||||
|
||||
void nautilus_directory_add_file_to_work_queue (NautilusDirectory *directory,
|
||||
NautilusFile *file);
|
||||
void nautilus_directory_remove_file_from_work_queue (NautilusDirectory *directory,
|
||||
NautilusFile *file);
|
||||
|
||||
/* debugging functions */
|
||||
int nautilus_directory_number_outstanding (void);
|
||||
|
|
|
@ -128,6 +128,8 @@ nautilus_directory_initialize (gpointer object, gpointer klass)
|
|||
|
||||
directory->details = g_new0 (NautilusDirectoryDetails, 1);
|
||||
directory->details->file_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
directory->details->high_priority_queue = nautilus_file_queue_new ();
|
||||
directory->details->low_priority_queue = nautilus_file_queue_new ();
|
||||
directory->details->idle_queue = nautilus_idle_queue_new ();
|
||||
}
|
||||
|
||||
|
@ -195,6 +197,8 @@ nautilus_directory_destroy (GtkObject *object)
|
|||
}
|
||||
g_assert (directory->details->file_list == NULL);
|
||||
g_hash_table_destroy (directory->details->file_hash);
|
||||
nautilus_file_queue_destroy (directory->details->high_priority_queue);
|
||||
nautilus_file_queue_destroy (directory->details->low_priority_queue);
|
||||
nautilus_idle_queue_destroy (directory->details->idle_queue);
|
||||
g_assert (directory->details->directory_load_in_progress == NULL);
|
||||
g_assert (directory->details->count_in_progress == NULL);
|
||||
|
@ -309,7 +313,8 @@ nautilus_directory_make_uri_canonical (const char *uri)
|
|||
* created. (See bugzilla.gnome.org 43322 for an example.)
|
||||
*/
|
||||
canonical = eel_str_strip_trailing_chr (canonical_maybe_trailing_slash, '/');
|
||||
if (strcmp (canonical, canonical_maybe_trailing_slash) != 0) {
|
||||
if (strcmp (canonical, canonical_maybe_trailing_slash) != 0 &&
|
||||
strcmp (canonical, "favorites:") != 0) {
|
||||
/* If some trailing '/' were stripped, there's the possibility,
|
||||
* that we stripped away all the '/' from a uri that has only
|
||||
* '/' characters. If you change this code, check to make sure
|
||||
|
@ -561,6 +566,7 @@ nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
|
|||
/* Ref if we are monitoring. */
|
||||
if (nautilus_directory_is_file_list_monitored (directory)) {
|
||||
nautilus_file_ref (file);
|
||||
nautilus_directory_add_file_to_work_queue (directory, file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,6 +589,8 @@ nautilus_directory_remove_file (NautilusDirectory *directory, NautilusFile *file
|
|||
(directory->details->file_list, node);
|
||||
g_list_free_1 (node);
|
||||
|
||||
nautilus_directory_remove_file_from_work_queue (directory, file);
|
||||
|
||||
if (!file->details->unconfirmed) {
|
||||
directory->details->confirmed_file_count--;
|
||||
}
|
||||
|
|
|
@ -40,5 +40,6 @@
|
|||
#define NAUTILUS_FILE_ATTRIBUTE_METADATA "metadata"
|
||||
#define NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE "MIME type"
|
||||
#define NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT "top left text"
|
||||
#define NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME "custom name"
|
||||
|
||||
#endif /* NAUTILUS_FILE_ATTRIBUTES_H */
|
||||
|
|
|
@ -67,6 +67,10 @@ struct NautilusFileDetails
|
|||
|
||||
GList *mime_list; /* If this is a directory, the list of MIME types in it. */
|
||||
char *top_left_text;
|
||||
|
||||
/* Info you might get from a link (.desktop, .directory or nautilus link) */
|
||||
char *custom_name;
|
||||
char *custom_icon_uri;
|
||||
char *activation_uri;
|
||||
|
||||
/* The following is for file operations in progress. Since
|
||||
|
@ -109,8 +113,8 @@ struct NautilusFileDetails
|
|||
eel_boolean_bit got_top_left_text : 1;
|
||||
eel_boolean_bit top_left_text_is_up_to_date : 1;
|
||||
|
||||
eel_boolean_bit got_activation_uri : 1;
|
||||
eel_boolean_bit activation_uri_is_up_to_date : 1;
|
||||
eel_boolean_bit got_link_info : 1;
|
||||
eel_boolean_bit link_info_is_up_to_date : 1;
|
||||
};
|
||||
|
||||
NautilusFile *nautilus_file_new_from_info (NautilusDirectory *directory,
|
||||
|
|
125
libnautilus-private/nautilus-file-queue.c
Normal file
125
libnautilus-private/nautilus-file-queue.c
Normal file
|
@ -0,0 +1,125 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
Copyright (C) 2001 Maciej Stachowiak
|
||||
|
||||
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: Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-file-queue.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct NautilusFileQueue {
|
||||
GList *head;
|
||||
GList *tail;
|
||||
GHashTable *item_to_link_map;
|
||||
};
|
||||
|
||||
NautilusFileQueue *
|
||||
nautilus_file_queue_new (void)
|
||||
{
|
||||
NautilusFileQueue *queue;
|
||||
|
||||
queue = g_new0 (NautilusFileQueue, 1);
|
||||
queue->item_to_link_map = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_file_queue_destroy (NautilusFileQueue *queue)
|
||||
{
|
||||
g_hash_table_destroy (queue->item_to_link_map);
|
||||
nautilus_file_list_free (queue->head);
|
||||
g_free (queue);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_file_queue_enqueue (NautilusFileQueue *queue,
|
||||
NautilusFile *file)
|
||||
{
|
||||
if (g_hash_table_lookup (queue->item_to_link_map, file) != NULL) {
|
||||
/* It's already on the queue. */
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue->tail == NULL) {
|
||||
queue->head = g_list_append (NULL, file);
|
||||
queue->tail = queue->head;
|
||||
} else {
|
||||
g_list_append (queue->tail, file);
|
||||
queue->tail = queue->tail->next;
|
||||
}
|
||||
|
||||
nautilus_file_ref (file);
|
||||
g_hash_table_insert (queue->item_to_link_map, file, queue->tail);
|
||||
}
|
||||
|
||||
NautilusFile *
|
||||
nautilus_file_queue_dequeue (NautilusFileQueue *queue)
|
||||
{
|
||||
NautilusFile *file;
|
||||
|
||||
file = nautilus_file_queue_head (queue);
|
||||
nautilus_file_queue_remove (queue, file);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_file_queue_remove (NautilusFileQueue *queue,
|
||||
NautilusFile *file)
|
||||
{
|
||||
GList *link;
|
||||
|
||||
link = g_hash_table_lookup (queue->item_to_link_map, file);
|
||||
|
||||
if (link == NULL) {
|
||||
/* It's not on the queue */
|
||||
return;
|
||||
}
|
||||
|
||||
if (link == queue->tail) {
|
||||
/* Need to special-case removing the tail. */
|
||||
queue->tail = queue->tail->prev;
|
||||
}
|
||||
|
||||
queue->head = g_list_remove_link (queue->head, link);
|
||||
g_list_free (link);
|
||||
g_hash_table_remove (queue->item_to_link_map, file);
|
||||
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
|
||||
NautilusFile *
|
||||
nautilus_file_queue_head (NautilusFileQueue *queue)
|
||||
{
|
||||
if (queue->head == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NAUTILUS_FILE (queue->head->data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_file_queue_is_empty (NautilusFileQueue *queue)
|
||||
{
|
||||
return (queue->head == NULL);
|
||||
}
|
52
libnautilus-private/nautilus-file-queue.h
Normal file
52
libnautilus-private/nautilus-file-queue.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
Copyright (C) 2001 Maciej Stachowiak
|
||||
|
||||
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: Maciej Stachowiak <mjs@noisehavoc.org>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_FILE_QUEUE_H
|
||||
#define NAUTILUS_FILE_QUEUE_H
|
||||
|
||||
#include <libnautilus-private/nautilus-file.h>
|
||||
|
||||
typedef struct NautilusFileQueue NautilusFileQueue;
|
||||
|
||||
NautilusFileQueue *nautilus_file_queue_new (void);
|
||||
void nautilus_file_queue_destroy (NautilusFileQueue *queue);
|
||||
|
||||
/* Add a file to the tail of the queue, unless it's already in the queue */
|
||||
void nautilus_file_queue_enqueue (NautilusFileQueue *queue,
|
||||
NautilusFile *file);
|
||||
|
||||
/* Return the file at the head of the queue after removing it from the
|
||||
* queue. This is dangerous unless you have another ref to the file,
|
||||
* since it will unref it.
|
||||
*/
|
||||
NautilusFile * nautilus_file_queue_dequeue (NautilusFileQueue *queue);
|
||||
|
||||
/* Remove a file from an arbitrary point in the queue in constant time. */
|
||||
void nautilus_file_queue_remove (NautilusFileQueue *queue,
|
||||
NautilusFile *file);
|
||||
|
||||
/* Get the file at the head of the queue without removing or unrefing it. */
|
||||
NautilusFile * nautilus_file_queue_head (NautilusFileQueue *queue);
|
||||
|
||||
gboolean nautilus_file_queue_is_empty (NautilusFileQueue *queue);
|
||||
|
||||
#endif /* NAUTILUS_FILE_CHANGES_QUEUE_H */
|
|
@ -50,7 +50,6 @@
|
|||
#include <libgnome/gnome-dentry.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnome/gnome-metadata.h>
|
||||
#include <libgnome/gnome-mime-info.h>
|
||||
#include <libgnome/gnome-mime.h>
|
||||
#include <libgnomevfs/gnome-vfs-file-info.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
|
@ -449,6 +448,8 @@ destroy (GtkObject *object)
|
|||
gnome_vfs_file_info_unref (file->details->info);
|
||||
}
|
||||
g_free (file->details->top_left_text);
|
||||
g_free (file->details->custom_name);
|
||||
g_free (file->details->custom_icon_uri);
|
||||
g_free (file->details->activation_uri);
|
||||
g_free (file->details->compare_by_emblem_cache);
|
||||
|
||||
|
@ -2251,81 +2252,18 @@ nautilus_file_set_integer_metadata (NautilusFile *file,
|
|||
metadata);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
nautilus_file_get_name (NautilusFile *file)
|
||||
{
|
||||
char *name;
|
||||
GnomeDesktopEntry *entry;
|
||||
char *path, *uri;
|
||||
char *caption;
|
||||
int size, res;
|
||||
|
||||
if (file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
|
||||
|
||||
/* FIXME: It's very bad to do this I/O here. For one thing,
|
||||
* this means that a file's name can change when the MIME
|
||||
* type is fetched. For another, it means that there's I/O
|
||||
* done every single time nautilus_file_get_name is called.
|
||||
* This goes against the design of NautilusFile. The proper
|
||||
* way to do this is to do this I/O in an async. way when
|
||||
* the object is created, but at the very least we need to
|
||||
* change this so it only does the I/O once!
|
||||
*/
|
||||
if (nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
|
||||
uri = nautilus_file_get_uri (file);
|
||||
path = gnome_vfs_get_local_path_from_uri (uri);
|
||||
|
||||
name = NULL;
|
||||
if (path != NULL) {
|
||||
entry = gnome_desktop_entry_load (path);
|
||||
if (entry != NULL) {
|
||||
name = g_strdup (entry->name);
|
||||
gnome_desktop_entry_free (entry);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
g_free (uri);
|
||||
|
||||
if (name != NULL) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: It's very bad to do this I/O here. For one thing,
|
||||
* this means that a file's name can change when the MIME
|
||||
* type is fetched. For another, it means that there's I/O
|
||||
* done every single time nautilus_file_get_name is called.
|
||||
* This goes against the design of NautilusFile. The proper
|
||||
* way to do this is to do this I/O in an async. way when
|
||||
* the object is created, but at the very least we need to
|
||||
* change this so it only does the I/O once!
|
||||
*/
|
||||
/* Desktop directories contain special "URL" files, handle
|
||||
* those by using the gnome metadata caption.
|
||||
*/
|
||||
if (nautilus_file_is_gmc_url (file)) {
|
||||
uri = nautilus_file_get_uri (file);
|
||||
path = gnome_vfs_get_local_path_from_uri (uri);
|
||||
|
||||
if (path != NULL) {
|
||||
res = gnome_metadata_get (path, "icon-caption", &size, &caption);
|
||||
} else {
|
||||
res = -1;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
g_free (uri);
|
||||
|
||||
if (res == 0 && caption != NULL) {
|
||||
return caption;
|
||||
}
|
||||
if (file->details->got_link_info && file->details->custom_name != NULL) {
|
||||
return g_strdup (file->details->custom_name);
|
||||
}
|
||||
|
||||
name = gnome_vfs_unescape_string (file->details->relative_uri, "/");
|
||||
|
@ -2375,7 +2313,7 @@ nautilus_file_get_activation_uri (NautilusFile *file)
|
|||
{
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
|
||||
|
||||
if (!file->details->got_activation_uri) {
|
||||
if (!file->details->got_link_info) {
|
||||
return NULL;
|
||||
}
|
||||
return file->details->activation_uri == NULL
|
||||
|
@ -2383,6 +2321,26 @@ nautilus_file_get_activation_uri (NautilusFile *file)
|
|||
: g_strdup (file->details->activation_uri);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_file_get_custom_icon_uri (NautilusFile *file)
|
||||
{
|
||||
char *uri;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
|
||||
|
||||
uri = NULL;
|
||||
|
||||
/* Metadata takes precedence */
|
||||
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
|
||||
|
||||
if (uri == NULL && file->details->got_link_info) {
|
||||
uri = g_strdup (file->details->custom_icon_uri);
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
|
||||
/* Return the actual uri associated with the passed-in file. */
|
||||
char *
|
||||
nautilus_file_get_uri (NautilusFile *file)
|
||||
|
@ -4469,7 +4427,8 @@ nautilus_file_get_symbolic_link_target_path (NautilusFile *file)
|
|||
/**
|
||||
* nautilus_file_is_nautilus_link
|
||||
*
|
||||
* Check if this file is a nautilus link.
|
||||
* Check if this file is a "nautilus link", meaning a historical
|
||||
* nautilus xml link file or a desktop file.
|
||||
* @file: NautilusFile representing the file in question.
|
||||
*
|
||||
* Returns: True if the file is a nautilus link.
|
||||
|
@ -4478,7 +4437,8 @@ nautilus_file_get_symbolic_link_target_path (NautilusFile *file)
|
|||
gboolean
|
||||
nautilus_file_is_nautilus_link (NautilusFile *file)
|
||||
{
|
||||
return nautilus_file_is_mime_type (file, "application/x-nautilus-link");
|
||||
return nautilus_file_is_mime_type (file, "application/x-nautilus-link") ||
|
||||
nautilus_file_is_mime_type (file, "application/x-gnome-app-info");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4552,20 +4512,17 @@ nautilus_file_get_file_info_result (NautilusFile *file)
|
|||
gboolean
|
||||
nautilus_file_contains_text (NautilusFile *file)
|
||||
{
|
||||
char *mime_type;
|
||||
gboolean contains_text;
|
||||
|
||||
if (file == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
|
||||
|
||||
mime_type = nautilus_file_get_mime_type (file);
|
||||
contains_text = eel_istr_has_prefix (mime_type, "text/");
|
||||
g_free (mime_type);
|
||||
if (file->details->info == NULL || file->details->info->mime_type == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return contains_text;
|
||||
return eel_istr_has_prefix (file->details->info->mime_type, "text/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4875,12 +4832,11 @@ invalidate_file_info (NautilusFile *file)
|
|||
}
|
||||
|
||||
static void
|
||||
invalidate_activation_uri (NautilusFile *file)
|
||||
invalidate_link_info (NautilusFile *file)
|
||||
{
|
||||
file->details->activation_uri_is_up_to_date = FALSE;
|
||||
file->details->link_info_is_up_to_date = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_file_invalidate_attributes_internal (NautilusFile *file,
|
||||
GList *file_attributes)
|
||||
|
@ -4908,8 +4864,8 @@ nautilus_file_invalidate_attributes_internal (NautilusFile *file,
|
|||
if (request.top_left_text) {
|
||||
invalidate_top_left_text (file);
|
||||
}
|
||||
if (request.activation_uri) {
|
||||
invalidate_activation_uri (file);
|
||||
if (request.link_info) {
|
||||
invalidate_link_info (file);
|
||||
}
|
||||
|
||||
/* FIXME bugzilla.gnome.org 45075: implement invalidating metadata */
|
||||
|
@ -4936,6 +4892,8 @@ nautilus_file_invalidate_attributes (NautilusFile *file,
|
|||
/* Actually invalidate the values */
|
||||
nautilus_file_invalidate_attributes_internal (file, file_attributes);
|
||||
|
||||
nautilus_directory_add_file_to_work_queue (file->details->directory, file);
|
||||
|
||||
/* Kick off I/O if necessary */
|
||||
nautilus_directory_async_state_changed (file->details->directory);
|
||||
}
|
||||
|
@ -4958,6 +4916,7 @@ nautilus_file_get_all_attributes (void)
|
|||
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA);
|
||||
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
|
||||
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT);
|
||||
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
|
|
@ -290,6 +290,9 @@ GList *nautilus_file_list_filter_hidden_and_backup (GList
|
|||
*/
|
||||
char * nautilus_file_get_activation_uri (NautilusFile *file);
|
||||
|
||||
/* Get custom icon (if specified by metadata or link contents) */
|
||||
char * nautilus_file_get_custom_icon_uri (NautilusFile *file);
|
||||
|
||||
/* Convenience functions for dealing with a list of NautilusFile objects that each have a ref.
|
||||
* These are just convenient names for functions that work on lists of GtkObject *.
|
||||
*/
|
||||
|
|
|
@ -2340,6 +2340,9 @@ destroy (GtkObject *object)
|
|||
|
||||
nautilus_icon_container_flush_typeselect_state (container);
|
||||
|
||||
g_hash_table_destroy (container->details->icon_set);
|
||||
container->details->icon_set = NULL;
|
||||
|
||||
g_free (container->details);
|
||||
|
||||
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
|
||||
|
@ -3331,6 +3334,8 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
|
|||
|
||||
details = g_new0 (NautilusIconContainerDetails, 1);
|
||||
|
||||
details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
|
||||
|
||||
/* font table - this isn't exactly proportional, but it looks better than computed */
|
||||
|
@ -3597,6 +3602,9 @@ nautilus_icon_container_clear (NautilusIconContainer *container)
|
|||
g_list_free (details->new_icons);
|
||||
details->new_icons = NULL;
|
||||
|
||||
g_hash_table_destroy (details->icon_set);
|
||||
details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
nautilus_icon_container_update_scroll_region (container);
|
||||
}
|
||||
|
||||
|
@ -3652,6 +3660,7 @@ icon_destroy (NautilusIconContainer *container,
|
|||
|
||||
details->icons = g_list_remove (details->icons, icon);
|
||||
details->new_icons = g_list_remove (details->new_icons, icon);
|
||||
g_hash_table_remove (details->icon_set, icon->data);
|
||||
|
||||
was_selected = icon->is_selected;
|
||||
|
||||
|
@ -3928,7 +3937,6 @@ nautilus_icon_container_add (NautilusIconContainer *container,
|
|||
NautilusIconData *data)
|
||||
{
|
||||
NautilusIconContainerDetails *details;
|
||||
GList *p;
|
||||
NautilusIcon *icon;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE);
|
||||
|
@ -3936,15 +3944,9 @@ nautilus_icon_container_add (NautilusIconContainer *container,
|
|||
|
||||
details = container->details;
|
||||
|
||||
/* FIXME bugzilla.gnome.org 41288:
|
||||
* I guess we need to use an indexed data structure to avoid this loop.
|
||||
*/
|
||||
for (p = details->icons; p != NULL; p = p->next) {
|
||||
icon = p->data;
|
||||
if (icon->data == data) {
|
||||
if (g_hash_table_lookup (details->icon_set, data) != NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the new icon, including the canvas item. */
|
||||
icon = g_new0 (NautilusIcon, 1);
|
||||
|
@ -3964,6 +3966,8 @@ nautilus_icon_container_add (NautilusIconContainer *container,
|
|||
details->icons = g_list_prepend (details->icons, icon);
|
||||
details->new_icons = g_list_prepend (details->new_icons, icon);
|
||||
|
||||
g_hash_table_insert (details->icon_set, data, icon);
|
||||
|
||||
/* Run an idle function to add the icons. */
|
||||
schedule_redo_layout (container);
|
||||
|
||||
|
@ -3982,26 +3986,22 @@ nautilus_icon_container_remove (NautilusIconContainer *container,
|
|||
NautilusIconData *data)
|
||||
{
|
||||
NautilusIcon *icon;
|
||||
GList *p;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE);
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
end_renaming_mode (container, FALSE);
|
||||
|
||||
/* FIXME bugzilla.gnome.org 41288:
|
||||
* I guess we need to use an indexed data structure to avoid this loop.
|
||||
*/
|
||||
for (p = container->details->icons; p != NULL; p = p->next) {
|
||||
icon = p->data;
|
||||
if (icon->data == data) {
|
||||
icon_destroy (container, icon);
|
||||
schedule_redo_layout (container);
|
||||
return TRUE;
|
||||
}
|
||||
icon = g_hash_table_lookup (container->details->icon_set, data);
|
||||
|
||||
if (icon == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
icon_destroy (container, icon);
|
||||
schedule_redo_layout (container);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4016,18 +4016,15 @@ nautilus_icon_container_request_update (NautilusIconContainer *container,
|
|||
NautilusIconData *data)
|
||||
{
|
||||
NautilusIcon *icon;
|
||||
GList *p;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
for (p = container->details->icons; p != NULL; p = p->next) {
|
||||
icon = p->data;
|
||||
if (icon->data == data) {
|
||||
icon = g_hash_table_lookup (container->details->icon_set, data);
|
||||
|
||||
if (icon != NULL) {
|
||||
nautilus_icon_container_update_icon (container, icon);
|
||||
schedule_redo_layout (container);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4097,21 +4094,16 @@ nautilus_icon_container_request_update_all (NautilusIconContainer *container)
|
|||
void
|
||||
nautilus_icon_container_reveal (NautilusIconContainer *container, NautilusIconData *data)
|
||||
{
|
||||
GList *p;
|
||||
NautilusIcon *icon;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
/* FIXME bugzilla.gnome.org 41288:
|
||||
* I guess we need to use an indexed data structure to avoid this loop.
|
||||
*/
|
||||
for (p = container->details->icons; p != NULL; p = p->next) {
|
||||
icon = p->data;
|
||||
if (icon->data == data) {
|
||||
icon = g_hash_table_lookup (container->details->icon_set, data);
|
||||
|
||||
if (icon != NULL) {
|
||||
reveal_icon (container, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "nautilus-icon-factory-private.h"
|
||||
#include "nautilus-lib-self-check-functions.h"
|
||||
#include "nautilus-link.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-theme.h"
|
||||
#include "nautilus-thumbnails.h"
|
||||
#include "nautilus-trash-monitor.h"
|
||||
|
@ -54,12 +53,13 @@
|
|||
#include <gtk/gtksignal.h>
|
||||
#include <libgnome/gnome-dentry.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnome/gnome-metadata.h>
|
||||
#include <libgnome/gnome-util.h>
|
||||
#include <libgnomevfs/gnome-vfs-file-info.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-info.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-monitor.h>
|
||||
#include <libgnomevfs/gnome-vfs-ops.h>
|
||||
#include <libgnomevfs/gnome-vfs-types.h>
|
||||
#include <librsvg/rsvg.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1458,26 +1458,53 @@ is_supported_mime_type (const char *mime_type)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
image_uri_to_name_or_uri (const char *image_uri,
|
||||
char **icon_name,
|
||||
char **uri)
|
||||
{
|
||||
char *icon_path;
|
||||
|
||||
if (image_uri == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2564: All custom icons must be in file:. */
|
||||
icon_path = gnome_vfs_get_local_path_from_uri (image_uri);
|
||||
if (icon_path == NULL && image_uri[0] == '/') {
|
||||
icon_path = g_strdup (image_uri);
|
||||
}
|
||||
if (icon_path != NULL) {
|
||||
if (*uri == NULL) {
|
||||
*uri = gnome_vfs_get_uri_from_local_path (icon_path);
|
||||
}
|
||||
g_free (icon_path);
|
||||
} else if (strpbrk (image_uri, ":/") == NULL) {
|
||||
*icon_name = remove_icon_name_suffix (image_uri);
|
||||
}
|
||||
}
|
||||
|
||||
/* key routine to get the scalable icon for a file */
|
||||
NautilusScalableIcon *
|
||||
nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifier)
|
||||
{
|
||||
char *uri, *file_uri, *file_path, *image_uri, *icon_name, *mime_type, *top_left_text;
|
||||
char *directory, *desktop_directory, *buf, *icon_path;
|
||||
char *uri, *custom_uri, *file_uri, *icon_name, *mime_type, *top_left_text;
|
||||
int file_size;
|
||||
gboolean is_local;
|
||||
int file_size, size, res;
|
||||
NautilusScalableIcon *scalable_icon;
|
||||
char *directory_uri;
|
||||
GnomeDesktopEntry *entry;
|
||||
|
||||
if (file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
icon_name = NULL;
|
||||
uri = NULL;
|
||||
|
||||
/* if there is a custom image in the metadata or link info, use that. */
|
||||
custom_uri = nautilus_file_get_custom_icon_uri (file);
|
||||
image_uri_to_name_or_uri (custom_uri, &icon_name, &uri);
|
||||
g_free (custom_uri);
|
||||
|
||||
/* if there is a custom image in the metadata, use that. */
|
||||
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
|
||||
file_uri = nautilus_file_get_uri (file);
|
||||
is_local = nautilus_file_is_local (file);
|
||||
mime_type = nautilus_file_get_mime_type (file);
|
||||
|
@ -1487,37 +1514,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
|
|||
If a thumbnail is required, but does not yet exist, put an entry on the thumbnail queue so we
|
||||
eventually make one */
|
||||
|
||||
if (uri == NULL) {
|
||||
/* Do we have to check the gnome metadata?
|
||||
*
|
||||
* Do this only for the ~/.gnome-desktop directory, as it was
|
||||
* the only place where GMC used it (since everywhere else we could
|
||||
* not do it because of the imlib leaks).
|
||||
*/
|
||||
desktop_directory = nautilus_get_gmc_desktop_directory ();
|
||||
directory_uri = nautilus_file_get_parent_uri (file);
|
||||
directory = gnome_vfs_get_local_path_from_uri (directory_uri);
|
||||
if (directory != NULL && strcmp (directory, desktop_directory) == 0) {
|
||||
file_path = gnome_vfs_get_local_path_from_uri (file_uri);
|
||||
|
||||
if (file_path != NULL) {
|
||||
res = gnome_metadata_get (file_path, "icon-filename", &size, &buf);
|
||||
} else {
|
||||
res = -1;
|
||||
}
|
||||
|
||||
if (res == 0 && buf != NULL) {
|
||||
uri = gnome_vfs_get_uri_from_local_path (buf);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
g_free (file_path);
|
||||
}
|
||||
g_free (directory);
|
||||
g_free (directory_uri);
|
||||
g_free (desktop_directory);
|
||||
}
|
||||
|
||||
/* also, dont make thumbnails for images in the thumbnails directory */
|
||||
if (uri == NULL) {
|
||||
file_size = nautilus_file_get_size (file);
|
||||
|
@ -1540,49 +1536,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
|
|||
}
|
||||
}
|
||||
|
||||
/* Handle nautilus link xml files, which may specify their own image */
|
||||
if (nautilus_file_is_nautilus_link (file)) {
|
||||
/* FIXME bugzilla.gnome.org 42563: This does sync. I/O and only works for local paths. */
|
||||
file_path = gnome_vfs_get_local_path_from_uri (file_uri);
|
||||
if (file_path != NULL) {
|
||||
image_uri = nautilus_link_local_get_image_uri (file_path);
|
||||
if (image_uri != NULL) {
|
||||
/* FIXME bugzilla.gnome.org 42564: All custom icons must be in file:. */
|
||||
icon_path = gnome_vfs_get_local_path_from_uri (image_uri);
|
||||
if (icon_path == NULL && image_uri[0] == '/') {
|
||||
icon_path = g_strdup (image_uri);
|
||||
}
|
||||
if (icon_path != NULL) {
|
||||
if (uri == NULL) {
|
||||
uri = gnome_vfs_get_uri_from_local_path (icon_path);
|
||||
}
|
||||
g_free (icon_path);
|
||||
} else if (strpbrk (image_uri, ":/") == NULL) {
|
||||
icon_name = remove_icon_name_suffix (image_uri);
|
||||
}
|
||||
g_free (image_uri);
|
||||
}
|
||||
g_free (file_path);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle .desktop files. */
|
||||
if (uri == NULL
|
||||
&& nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
|
||||
/* FIXME bugzilla.gnome.org 42563: This does sync. I/O and only works for local paths. */
|
||||
file_path = gnome_vfs_get_local_path_from_uri (file_uri);
|
||||
if (file_path != NULL) {
|
||||
entry = gnome_desktop_entry_load (file_path);
|
||||
if (entry != NULL) {
|
||||
if (entry->icon != NULL) {
|
||||
uri = gnome_vfs_get_uri_from_local_path (entry->icon);
|
||||
}
|
||||
gnome_desktop_entry_free (entry);
|
||||
}
|
||||
g_free (file_path);
|
||||
}
|
||||
}
|
||||
|
||||
/* handle SVG files */
|
||||
if (uri == NULL && icon_name == NULL
|
||||
&& nautilus_file_is_mime_type (file, "image/svg")) {
|
||||
|
@ -1609,6 +1562,27 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie
|
|||
return scalable_icon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_icon_factory_get_basic_file_attributes
|
||||
*
|
||||
* Get the list of file attributes required to obtain a file's basic icon.
|
||||
* This includes attributes needed to get a custom icon, but not those needed
|
||||
* for text preview.
|
||||
* Callers must free this list.
|
||||
*/
|
||||
GList *
|
||||
nautilus_icon_factory_get_basic_file_attributes (void)
|
||||
{
|
||||
GList *attributes;
|
||||
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON);
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_icon_factory_get_required_file_attributes
|
||||
*
|
||||
|
@ -1620,15 +1594,14 @@ nautilus_icon_factory_get_required_file_attributes (void)
|
|||
{
|
||||
GList *attributes;
|
||||
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON);
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
|
||||
attributes = nautilus_icon_factory_get_basic_file_attributes ();
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT);
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_icon_factory_is_icon_ready_for_file
|
||||
*
|
||||
|
@ -1650,6 +1623,31 @@ nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_icon_factory_is_basic_icon_ready_for_file
|
||||
*
|
||||
* Check whether a NautilusFile has enough information to report
|
||||
* what its basic icon should be. This will account for custom icons
|
||||
* but not text preview.
|
||||
*
|
||||
* @file: The NautilusFile in question.
|
||||
*/
|
||||
gboolean
|
||||
nautilus_icon_factory_is_basic_icon_ready_for_file (NautilusFile *file)
|
||||
{
|
||||
GList *attributes;
|
||||
gboolean result;
|
||||
|
||||
attributes = nautilus_icon_factory_get_basic_file_attributes ();
|
||||
result = nautilus_file_check_if_ready (file, attributes);
|
||||
g_list_free (attributes);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NautilusScalableIcon *
|
||||
nautilus_icon_factory_get_emblem_icon_by_name (const char *emblem_name)
|
||||
{
|
||||
|
@ -1916,6 +1914,7 @@ load_named_icon (const char *name,
|
|||
path = get_icon_file_path (name, modifier,
|
||||
size_in_pixels, optimized_for_aa,
|
||||
details);
|
||||
|
||||
pixbuf = load_icon_from_path (path, size_in_pixels, FALSE,
|
||||
eel_str_has_prefix (name, EMBLEM_NAME_PREFIX),
|
||||
optimized_for_aa);
|
||||
|
|
|
@ -105,6 +105,11 @@ NautilusScalableIcon *nautilus_icon_factory_get_icon_for_file (Nautil
|
|||
const char *modifier);
|
||||
gboolean nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file);
|
||||
GList * nautilus_icon_factory_get_required_file_attributes (void);
|
||||
|
||||
/* The calls below do not account for top-left text, allowing it to be loaded progressively. */
|
||||
gboolean nautilus_icon_factory_is_basic_icon_ready_for_file (NautilusFile *file);
|
||||
GList * nautilus_icon_factory_get_basic_file_attributes (void);
|
||||
|
||||
GList * nautilus_icon_factory_get_emblem_icons_for_file (NautilusFile *file,
|
||||
EelStringList *exclude);
|
||||
NautilusScalableIcon *nautilus_icon_factory_get_emblem_icon_by_name (const char *emblem_name);
|
||||
|
|
|
@ -102,6 +102,7 @@ struct NautilusIconContainerDetails {
|
|||
/* List of icons. */
|
||||
GList *icons;
|
||||
GList *new_icons;
|
||||
GHashTable *icon_set;
|
||||
|
||||
/* Current icon for keyboard navigation. */
|
||||
NautilusIcon *keyboard_focus;
|
||||
|
|
532
libnautilus-private/nautilus-link-desktop-file.c
Normal file
532
libnautilus-private/nautilus-link-desktop-file.c
Normal file
|
@ -0,0 +1,532 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-link-desktop-file.c: .desktop link files.
|
||||
|
||||
Copyright (C) 2001 Red Hat, 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 historicalied 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.
|
||||
|
||||
Authors: Jonathan Blandford <jrb@redhat.com>
|
||||
Alexander Larsson <alexl@redhat.com>
|
||||
*/
|
||||
#include <config.h>
|
||||
#include "nautilus-link.h"
|
||||
#include "nautilus-link-desktop-file.h"
|
||||
#include "nautilus-directory-notify.h"
|
||||
#include "nautilus-directory.h"
|
||||
#include "nautilus-file-attributes.h"
|
||||
#include "nautilus-file.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-desktop-file-loader.h"
|
||||
#include <eel/eel-glib-extensions.h>
|
||||
#include <eel/eel-gnome-extensions.h>
|
||||
#include <eel/eel-stock-dialogs.h>
|
||||
#include <eel/eel-string.h>
|
||||
#include <eel/eel-xml-extensions.h>
|
||||
#include <gnome-xml/parser.h>
|
||||
#include <gnome-xml/xmlmemory.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnome/gnome-util.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NAUTILUS_LINK_GENERIC_TAG "Link"
|
||||
#define NAUTILUS_LINK_TRASH_TAG "X-nautilus-trash"
|
||||
#define NAUTILUS_LINK_MOUNT_TAG "FSDevice"
|
||||
#define NAUTILUS_LINK_HOME_TAG "X-nautilus-home"
|
||||
|
||||
static const char *
|
||||
get_tag (NautilusLinkType type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
/* fall through */
|
||||
case NAUTILUS_LINK_GENERIC:
|
||||
return NAUTILUS_LINK_GENERIC_TAG;
|
||||
case NAUTILUS_LINK_TRASH:
|
||||
return NAUTILUS_LINK_TRASH_TAG;
|
||||
case NAUTILUS_LINK_MOUNT:
|
||||
return NAUTILUS_LINK_MOUNT_TAG;
|
||||
case NAUTILUS_LINK_HOME:
|
||||
return NAUTILUS_LINK_HOME_TAG;
|
||||
}
|
||||
}
|
||||
|
||||
static gchar *
|
||||
slurp_key_string (const char *path,
|
||||
const char *keyname,
|
||||
gboolean localize)
|
||||
{
|
||||
NautilusDesktopFile *desktop_file = NULL;
|
||||
gchar *text;
|
||||
gboolean set;
|
||||
GnomeVFSResult result;
|
||||
gchar *uri;
|
||||
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
if (uri == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = nautilus_desktop_file_load (uri, &desktop_file);
|
||||
|
||||
g_free (uri);
|
||||
|
||||
if (result != GNOME_VFS_OK) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (localize) {
|
||||
set = nautilus_desktop_file_get_locale_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
keyname,
|
||||
&text);
|
||||
} else {
|
||||
set = nautilus_desktop_file_get_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
keyname,
|
||||
&text);
|
||||
}
|
||||
|
||||
nautilus_desktop_file_free (desktop_file);
|
||||
|
||||
if (set == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_desktop_file_local_create (const char *directory_path,
|
||||
const char *name,
|
||||
const char *image,
|
||||
const char *target_uri,
|
||||
const GdkPoint *point,
|
||||
NautilusLinkType type)
|
||||
{
|
||||
gchar *path;
|
||||
FILE *file;
|
||||
char *uri;
|
||||
GList dummy_list;
|
||||
NautilusFileChangesQueuePosition item;
|
||||
GnomeVFSHandle *handle;
|
||||
|
||||
g_return_val_if_fail (directory_path != NULL, FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
g_return_val_if_fail (target_uri != NULL, FALSE);
|
||||
|
||||
path = nautilus_make_path (directory_path, name);
|
||||
handle = NULL;
|
||||
|
||||
file = fopen (path, "w");
|
||||
|
||||
if (file == NULL) {
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fputs ("[Desktop Entry]\nEncoding=Legacy-Mixed\nName=", file);
|
||||
fputs (name, file);
|
||||
fputs ("\nType=", file);
|
||||
fputs (get_tag (type), file);
|
||||
fputs ("\nX-Nautilus-Icon=", file);
|
||||
fputs (image, file);
|
||||
fputs ("\nURL=", file);
|
||||
fputs (target_uri, file);
|
||||
fputs ("\n", file);
|
||||
/* ... */
|
||||
fclose (file);
|
||||
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
dummy_list.data = uri;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
nautilus_directory_notify_files_added (&dummy_list);
|
||||
nautilus_directory_schedule_metadata_remove (&dummy_list);
|
||||
|
||||
if (point != NULL) {
|
||||
item.uri = uri;
|
||||
item.set = TRUE;
|
||||
item.point.x = point->x;
|
||||
item.point.y = point->y;
|
||||
|
||||
dummy_list.data = &item;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
|
||||
nautilus_directory_schedule_position_set (&dummy_list);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
g_free (path);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_desktop_file_local_set_icon (const char *path,
|
||||
const char *icon_name)
|
||||
{
|
||||
NautilusDesktopFile *desktop_file;
|
||||
GnomeVFSResult result;
|
||||
char *uri;
|
||||
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
if (uri == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
result = nautilus_desktop_file_load (uri, &desktop_file);
|
||||
|
||||
if (result != GNOME_VFS_OK) {
|
||||
g_free (uri);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nautilus_desktop_file_set_string (desktop_file, "Desktop Entry", "X-Nautilus-Icon", icon_name);
|
||||
|
||||
result = nautilus_desktop_file_save (desktop_file, uri);
|
||||
nautilus_desktop_file_free (desktop_file);
|
||||
|
||||
g_free (uri);
|
||||
|
||||
if (result != GNOME_VFS_OK) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_desktop_file_local_get_text (const char *path)
|
||||
{
|
||||
return slurp_key_string (path, "Name", TRUE);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_desktop_file_local_get_additional_text (const char *path)
|
||||
{
|
||||
/* The comment field of current .desktop files is often bad.
|
||||
* It just contains a copy of the name. This is probably because the
|
||||
* panel shows the comment field as a tooltip.
|
||||
*/
|
||||
return NULL;
|
||||
#ifdef THIS_IS_NOT_USED_RIGHT_NOW
|
||||
gchar *type;
|
||||
gchar *retval;
|
||||
|
||||
type = slurp_key_string (path, "Type", FALSE);
|
||||
retval = NULL;
|
||||
if (type == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp (type, "Application") == 0) {
|
||||
retval = slurp_key_string (path, "Comment", TRUE);
|
||||
}
|
||||
|
||||
g_free (type);
|
||||
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
NautilusLinkType
|
||||
nautilus_link_desktop_file_local_get_link_type (const char *path)
|
||||
{
|
||||
gchar *type;
|
||||
NautilusLinkType retval;
|
||||
|
||||
type = slurp_key_string (path, "Type", FALSE);
|
||||
|
||||
if (type == NULL) {
|
||||
return NAUTILUS_LINK_GENERIC;
|
||||
}
|
||||
if (strcmp (type, NAUTILUS_LINK_HOME_TAG) == 0) {
|
||||
retval = NAUTILUS_LINK_HOME;
|
||||
} else if (strcmp (type, NAUTILUS_LINK_MOUNT_TAG) == 0) {
|
||||
retval = NAUTILUS_LINK_MOUNT;
|
||||
} else if (strcmp (type, NAUTILUS_LINK_TRASH_TAG) == 0) {
|
||||
retval = NAUTILUS_LINK_TRASH;
|
||||
} else {
|
||||
retval = NAUTILUS_LINK_GENERIC;
|
||||
}
|
||||
|
||||
g_free (type);
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_desktop_file_local_is_volume_link (const char *path)
|
||||
{
|
||||
return (nautilus_link_desktop_file_local_get_link_type (path) == NAUTILUS_LINK_MOUNT);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_desktop_file_local_is_home_link (const char *path)
|
||||
{
|
||||
return (nautilus_link_desktop_file_local_get_link_type (path) == NAUTILUS_LINK_HOME);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_desktop_file_local_is_trash_link (const char *path)
|
||||
{
|
||||
return (nautilus_link_desktop_file_local_get_link_type (path) == NAUTILUS_LINK_TRASH);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
nautilus_link_desktop_file_get_link_uri_from_desktop (NautilusDesktopFile *desktop_file)
|
||||
{
|
||||
gchar *terminal_command;
|
||||
gchar *launch_string;
|
||||
gboolean need_term;
|
||||
gchar *type;
|
||||
gchar *retval;
|
||||
|
||||
retval = NULL;
|
||||
|
||||
type = NULL;
|
||||
if (! nautilus_desktop_file_get_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
"Type",
|
||||
&type)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp (type, "Application") == 0) {
|
||||
if (! nautilus_desktop_file_get_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
"Exec",
|
||||
&launch_string)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
need_term = FALSE;
|
||||
nautilus_desktop_file_get_boolean (desktop_file,
|
||||
"Desktop Entry",
|
||||
"Terminal",
|
||||
&need_term);
|
||||
if (need_term) {
|
||||
terminal_command = eel_gnome_make_terminal_command (launch_string);
|
||||
retval = g_strconcat ("command:", terminal_command, NULL);
|
||||
g_free (terminal_command);
|
||||
} else {
|
||||
retval = g_strconcat ("command:", launch_string, NULL);
|
||||
}
|
||||
g_free (launch_string);
|
||||
} else if (strcmp (type, "URL") == 0) {
|
||||
/* Some old broken desktop files use this nonstandard feature, we need handle it though */
|
||||
nautilus_desktop_file_get_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
"Exec",
|
||||
&retval);
|
||||
} else if ((strcmp (type, NAUTILUS_LINK_GENERIC_TAG) == 0) ||
|
||||
(strcmp (type, NAUTILUS_LINK_MOUNT_TAG) == 0) ||
|
||||
(strcmp (type, NAUTILUS_LINK_TRASH_TAG) == 0) ||
|
||||
(strcmp (type, NAUTILUS_LINK_HOME_TAG) == 0)) {
|
||||
nautilus_desktop_file_get_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
"URL",
|
||||
&retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
nautilus_link_desktop_file_get_link_name_from_desktop (NautilusDesktopFile *desktop_file)
|
||||
{
|
||||
gchar *name;
|
||||
|
||||
name = NULL;
|
||||
|
||||
if (nautilus_desktop_file_get_string (desktop_file,
|
||||
"Desktop Entry",
|
||||
"Name",
|
||||
&name)) {
|
||||
return name;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gchar *
|
||||
nautilus_link_desktop_file_get_link_icon_from_desktop (NautilusDesktopFile *desktop_file)
|
||||
{
|
||||
char *icon_uri;
|
||||
gchar *absolute;
|
||||
gchar *icon_name;
|
||||
|
||||
if (nautilus_desktop_file_get_string (desktop_file, "Desktop Entry", "X-Nautilus-Icon", &icon_uri)) {
|
||||
return icon_uri;
|
||||
}
|
||||
|
||||
/* Fall back to a standard icon. */
|
||||
if (nautilus_desktop_file_get_string (desktop_file, "Desktop Entry", "Icon", &icon_name)) {
|
||||
if (icon_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
absolute = gnome_pixmap_file (icon_name);
|
||||
if (absolute != NULL) {
|
||||
g_free (icon_name);
|
||||
icon_name = absolute;
|
||||
}
|
||||
if (icon_name[0] == '/') {
|
||||
icon_uri = gnome_vfs_get_uri_from_local_path (icon_name);
|
||||
} else {
|
||||
icon_uri = NULL;
|
||||
}
|
||||
g_free (icon_name);
|
||||
|
||||
return icon_uri;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_desktop_file_local_get_link_uri (const char *path)
|
||||
{
|
||||
NautilusDesktopFile *desktop_file = NULL;
|
||||
gchar *retval;
|
||||
GnomeVFSResult result;
|
||||
char *uri;
|
||||
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
if (uri == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
result = nautilus_desktop_file_load (uri, &desktop_file);
|
||||
|
||||
g_free (uri);
|
||||
|
||||
if (result != GNOME_VFS_OK) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
retval = nautilus_link_desktop_file_get_link_uri_from_desktop (desktop_file);
|
||||
|
||||
nautilus_desktop_file_free (desktop_file);
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_desktop_file_get_link_uri_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size)
|
||||
{
|
||||
NautilusDesktopFile *desktop_file;
|
||||
gchar *slurp;
|
||||
gchar *retval;
|
||||
|
||||
slurp = g_strndup (link_file_contents, link_file_size);
|
||||
desktop_file = nautilus_desktop_file_from_string (slurp);
|
||||
g_free (slurp);
|
||||
if (desktop_file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
retval = nautilus_link_desktop_file_get_link_uri_from_desktop (desktop_file);
|
||||
|
||||
nautilus_desktop_file_free (desktop_file);
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_desktop_file_get_link_name_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size)
|
||||
{
|
||||
NautilusDesktopFile *desktop_file;
|
||||
gchar *slurp;
|
||||
gchar *retval;
|
||||
|
||||
slurp = g_strndup (link_file_contents, link_file_size);
|
||||
desktop_file = nautilus_desktop_file_from_string (slurp);
|
||||
g_free (slurp);
|
||||
if (desktop_file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
retval = nautilus_link_desktop_file_get_link_name_from_desktop (desktop_file);
|
||||
|
||||
nautilus_desktop_file_free (desktop_file);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
nautilus_link_desktop_file_get_link_icon_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size)
|
||||
{
|
||||
NautilusDesktopFile *desktop_file;
|
||||
gchar *slurp;
|
||||
gchar *retval;
|
||||
|
||||
slurp = g_strndup (link_file_contents, link_file_size);
|
||||
desktop_file = nautilus_desktop_file_from_string (slurp);
|
||||
g_free (slurp);
|
||||
if (desktop_file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
retval = nautilus_link_desktop_file_get_link_icon_from_desktop (desktop_file);
|
||||
|
||||
nautilus_desktop_file_free (desktop_file);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
|
||||
const char *dest_path,
|
||||
const GdkPoint *position)
|
||||
{
|
||||
char *uri;
|
||||
GList dummy_list;
|
||||
NautilusFileChangesQueuePosition item;
|
||||
GnomeDesktopEntry *new_entry;
|
||||
char *file_name;
|
||||
|
||||
new_entry = gnome_desktop_entry_copy (entry);
|
||||
g_free (new_entry->location);
|
||||
file_name = g_strdup_printf ("%s.desktop", entry->name);
|
||||
new_entry->location = nautilus_make_path (dest_path, file_name);
|
||||
g_free (file_name);
|
||||
gnome_desktop_entry_save (new_entry);
|
||||
|
||||
uri = gnome_vfs_get_uri_from_local_path (dest_path);
|
||||
dummy_list.data = uri;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
nautilus_directory_notify_files_added (&dummy_list);
|
||||
nautilus_directory_schedule_metadata_remove (&dummy_list);
|
||||
|
||||
if (position != NULL) {
|
||||
item.uri = uri;
|
||||
item.set = TRUE;
|
||||
item.point.x = position->x;
|
||||
item.point.y = position->y;
|
||||
|
||||
dummy_list.data = &item;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
|
||||
nautilus_directory_schedule_position_set (&dummy_list);
|
||||
}
|
||||
gnome_desktop_entry_free (new_entry);
|
||||
}
|
||||
|
61
libnautilus-private/nautilus-link-desktop-file.h
Normal file
61
libnautilus-private/nautilus-link-desktop-file.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-link-desktop-file.h: .
|
||||
|
||||
Copyright (C) 2001 Red Hat, 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.
|
||||
|
||||
Authors: Jonathan Blandford <jrb@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_LINK_DESKTOP_FILE_H
|
||||
#define NAUTILUS_LINK_DESKTOP_FILE_H
|
||||
|
||||
#include "nautilus-file.h"
|
||||
#include <gdk/gdk.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnome/gnome-dentry.h>
|
||||
|
||||
|
||||
gboolean nautilus_link_desktop_file_local_create (const char *directory_path,
|
||||
const char *name,
|
||||
const char *image,
|
||||
const char *target_uri,
|
||||
const GdkPoint *point,
|
||||
NautilusLinkType type);
|
||||
gboolean nautilus_link_desktop_file_local_set_icon (const char *path,
|
||||
const char *icon_name);
|
||||
char * nautilus_link_desktop_file_local_get_text (const char *path);
|
||||
char * nautilus_link_desktop_file_local_get_additional_text (const char *path);
|
||||
NautilusLinkType nautilus_link_desktop_file_local_get_link_type (const char *path);
|
||||
gboolean nautilus_link_desktop_file_local_is_volume_link (const char *path);
|
||||
gboolean nautilus_link_desktop_file_local_is_home_link (const char *path);
|
||||
gboolean nautilus_link_desktop_file_local_is_trash_link (const char *path);
|
||||
char * nautilus_link_desktop_file_local_get_link_uri (const char *path);
|
||||
char * nautilus_link_desktop_file_get_link_uri_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size);
|
||||
char * nautilus_link_desktop_file_get_link_name_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size);
|
||||
char * nautilus_link_desktop_file_get_link_icon_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size);
|
||||
void nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
|
||||
const char *dest_path,
|
||||
const GdkPoint *position);
|
||||
|
||||
|
||||
#endif /* NAUTILUS_LINK_DESKTOP_FILE_H */
|
||||
|
435
libnautilus-private/nautilus-link-historical.c
Normal file
435
libnautilus-private/nautilus-link-historical.c
Normal file
|
@ -0,0 +1,435 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-link-historical.c: xml-based link files.
|
||||
|
||||
Copyright (C) 1999, 2000, 2001 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 historicalied 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: Andy Hertzfeld <andy@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-link.h"
|
||||
#include "nautilus-link-historical.h"
|
||||
|
||||
#include "nautilus-directory-notify.h"
|
||||
#include "nautilus-directory.h"
|
||||
#include "nautilus-file-attributes.h"
|
||||
#include "nautilus-file.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include <eel/eel-glib-extensions.h>
|
||||
#include <eel/eel-gnome-extensions.h>
|
||||
#include <eel/eel-stock-dialogs.h>
|
||||
#include <eel/eel-string.h>
|
||||
#include <eel/eel-vfs-extensions.h>
|
||||
#include <eel/eel-xml-extensions.h>
|
||||
#include <gnome-xml/parser.h>
|
||||
#include <gnome-xml/xmlmemory.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnome/gnome-util.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define NAUTILUS_LINK_GENERIC_TAG "Generic Link"
|
||||
#define NAUTILUS_LINK_TRASH_TAG "Trash Link"
|
||||
#define NAUTILUS_LINK_MOUNT_TAG "Mount Link"
|
||||
#define NAUTILUS_LINK_HOME_TAG "Home Link"
|
||||
|
||||
#define REMOTE_ICON_DIR_PERMISSIONS (GNOME_VFS_PERM_USER_ALL \
|
||||
| GNOME_VFS_PERM_GROUP_ALL \
|
||||
| GNOME_VFS_PERM_OTHER_ALL)
|
||||
|
||||
typedef void (* NautilusFileFunction) (NautilusFile *file);
|
||||
|
||||
static const char *
|
||||
get_tag (NautilusLinkType type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
/* fall through */
|
||||
case NAUTILUS_LINK_GENERIC:
|
||||
return NAUTILUS_LINK_GENERIC_TAG;
|
||||
case NAUTILUS_LINK_TRASH:
|
||||
return NAUTILUS_LINK_TRASH_TAG;
|
||||
case NAUTILUS_LINK_MOUNT:
|
||||
return NAUTILUS_LINK_MOUNT_TAG;
|
||||
case NAUTILUS_LINK_HOME:
|
||||
return NAUTILUS_LINK_HOME_TAG;
|
||||
}
|
||||
}
|
||||
|
||||
static NautilusLinkType
|
||||
get_link_type (const char *tag)
|
||||
{
|
||||
if (tag != NULL) {
|
||||
if (strcmp (tag, NAUTILUS_LINK_TRASH_TAG) == 0) {
|
||||
return NAUTILUS_LINK_TRASH;
|
||||
}
|
||||
if (strcmp (tag, NAUTILUS_LINK_MOUNT_TAG) == 0) {
|
||||
return NAUTILUS_LINK_MOUNT;
|
||||
}
|
||||
if (strcmp (tag, NAUTILUS_LINK_HOME_TAG) == 0) {
|
||||
return NAUTILUS_LINK_HOME;
|
||||
}
|
||||
}
|
||||
return NAUTILUS_LINK_GENERIC;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_historical_local_create (const char *directory_path,
|
||||
const char *name,
|
||||
const char *image,
|
||||
const char *target_uri,
|
||||
const GdkPoint *point,
|
||||
NautilusLinkType type)
|
||||
{
|
||||
xmlDocPtr output_document;
|
||||
xmlNodePtr root_node;
|
||||
char *path;
|
||||
int result;
|
||||
char *uri;
|
||||
GList dummy_list;
|
||||
NautilusFileChangesQueuePosition item;
|
||||
|
||||
|
||||
g_return_val_if_fail (directory_path != NULL, FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
g_return_val_if_fail (target_uri != NULL, FALSE);
|
||||
|
||||
/* create a new xml document */
|
||||
output_document = xmlNewDoc ("1.0");
|
||||
|
||||
/* add the root node to the output document */
|
||||
root_node = xmlNewDocNode (output_document, NULL, "nautilus_object", NULL);
|
||||
xmlDocSetRootElement (output_document, root_node);
|
||||
|
||||
/* Add mime magic string so that the mime sniffer can recognize us.
|
||||
* Note: The value of the tag identfies what type of link this. */
|
||||
xmlSetProp (root_node, "nautilus_link", get_tag (type));
|
||||
|
||||
/* Add link and custom icon tags */
|
||||
xmlSetProp (root_node, "custom_icon", image);
|
||||
xmlSetProp (root_node, "link", target_uri);
|
||||
|
||||
/* all done, so save the xml document as a link file */
|
||||
path = nautilus_make_path (directory_path, name);
|
||||
result = xmlSaveFile (path, output_document);
|
||||
|
||||
xmlFreeDoc (output_document);
|
||||
|
||||
if (result <= 0) {
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Notify that this new file has been created. */
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
dummy_list.data = uri;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
nautilus_directory_notify_files_added (&dummy_list);
|
||||
nautilus_directory_schedule_metadata_remove (&dummy_list);
|
||||
|
||||
if (point != NULL) {
|
||||
item.uri = uri;
|
||||
item.set = TRUE;
|
||||
item.point.x = point->x;
|
||||
item.point.y = point->y;
|
||||
|
||||
dummy_list.data = &item;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
|
||||
nautilus_directory_schedule_position_set (&dummy_list);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
|
||||
g_free (path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *
|
||||
xml_get_root_property (xmlDoc *doc,
|
||||
const char *key)
|
||||
{
|
||||
char *property, *duplicate;
|
||||
|
||||
/* Need to g_strdup so we can free with g_free instead of xmlFree. */
|
||||
property = xmlGetProp (xmlDocGetRootElement (doc), key);
|
||||
duplicate = g_strdup (property);
|
||||
xmlFree (property);
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
static char *
|
||||
local_get_root_property (const char *path,
|
||||
const char *key)
|
||||
{
|
||||
xmlDoc *document;
|
||||
char *property;
|
||||
const char *mime_type;
|
||||
|
||||
property = NULL;
|
||||
|
||||
/* Check mime type. Exit if it is not a nautilus link */
|
||||
mime_type = gnome_vfs_get_file_mime_type (path, NULL, FALSE);
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
document = xmlParseFile (path);
|
||||
if (document != NULL) {
|
||||
property = xml_get_root_property (document, key);
|
||||
xmlFreeDoc (document);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
local_set_root_property (const char *uri,
|
||||
const char *key,
|
||||
const char *value,
|
||||
NautilusFileFunction extra_notify)
|
||||
{
|
||||
xmlDocPtr document;
|
||||
xmlNodePtr root;
|
||||
xmlChar *old_value;
|
||||
char *path;
|
||||
NautilusFile *file;
|
||||
|
||||
path = gnome_vfs_get_local_path_from_uri (uri);
|
||||
document = xmlParseFile (path);
|
||||
if (document == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
root = xmlDocGetRootElement (document);
|
||||
if (root == NULL) {
|
||||
xmlFreeDoc (document);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check if the property value is already correct. */
|
||||
old_value = xmlGetProp (root, key);
|
||||
if (old_value != NULL && strcmp (old_value, value) == 0) {
|
||||
xmlFreeDoc (document);
|
||||
xmlFree (old_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
xmlFree (old_value);
|
||||
|
||||
/* Change and write the property. */
|
||||
xmlSetProp (root, key, value);
|
||||
xmlSaveFile (path, document);
|
||||
xmlFreeDoc (document);
|
||||
|
||||
/* Notify about the change. */
|
||||
file = nautilus_file_get (uri);
|
||||
if (file != NULL) {
|
||||
if (extra_notify != NULL) {
|
||||
(* extra_notify) (file);
|
||||
}
|
||||
nautilus_file_changed (file);
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
g_free (path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Set the icon for a link file. This can only be called on local
|
||||
* paths, and only on files known to be link files.
|
||||
*/
|
||||
gboolean
|
||||
nautilus_link_historical_local_set_icon (const char *path, const char *icon_name)
|
||||
{
|
||||
return local_set_root_property (path,
|
||||
NAUTILUS_METADATA_KEY_CUSTOM_ICON,
|
||||
icon_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Set the link uri for a link file. This can only be called on local
|
||||
* paths, and only on files known to be link files.
|
||||
*/
|
||||
gboolean
|
||||
nautilus_link_historical_local_set_link_uri (const char *path, const char *link_uri)
|
||||
{
|
||||
return local_set_root_property (path,
|
||||
"link",
|
||||
link_uri,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_historical_local_set_type (const char *path,
|
||||
NautilusLinkType type)
|
||||
{
|
||||
return local_set_root_property (path,
|
||||
"nautilus_link",
|
||||
get_tag (type),
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* returns additional text to display under the name, NULL if none */
|
||||
char *
|
||||
nautilus_link_historical_local_get_additional_text (const char *path)
|
||||
{
|
||||
return local_get_root_property
|
||||
(path, NAUTILUS_METADATA_KEY_EXTRA_TEXT);
|
||||
}
|
||||
|
||||
|
||||
/* Returns the link uri associated with a link file. */
|
||||
char *
|
||||
nautilus_link_historical_local_get_link_uri (const char *path)
|
||||
{
|
||||
return local_get_root_property (path, "link");
|
||||
}
|
||||
|
||||
/* Returns the link type of the link file. */
|
||||
NautilusLinkType
|
||||
nautilus_link_historical_local_get_link_type (const char *path)
|
||||
{
|
||||
char *property;
|
||||
NautilusLinkType type;
|
||||
|
||||
property = local_get_root_property (path, "nautilus_link");
|
||||
type = get_link_type (property);
|
||||
g_free (property);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2495:
|
||||
* Caller has to know to pass in a file with a NUL character at the end.
|
||||
*/
|
||||
char *
|
||||
nautilus_link_historical_get_link_uri_given_file_contents (const char *file_contents,
|
||||
int file_size)
|
||||
{
|
||||
xmlDoc *doc;
|
||||
char *property;
|
||||
|
||||
doc = xmlParseMemory ((char *) file_contents, file_size);
|
||||
property = xml_get_root_property (doc, "link");
|
||||
xmlFreeDoc (doc);
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
nautilus_link_historical_get_link_icon_given_file_contents (const char *file_contents,
|
||||
int file_size)
|
||||
{
|
||||
xmlDoc *doc;
|
||||
char *property;
|
||||
|
||||
doc = xmlParseMemory ((char *) file_contents, file_size);
|
||||
property = xml_get_root_property (doc, NAUTILUS_METADATA_KEY_CUSTOM_ICON);
|
||||
xmlFreeDoc (doc);
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
nautilus_link_historical_local_is_volume_link (const char *path)
|
||||
{
|
||||
return nautilus_link_historical_local_get_link_type (path) == NAUTILUS_LINK_MOUNT;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_historical_local_is_home_link (const char *path)
|
||||
{
|
||||
return nautilus_link_historical_local_get_link_type (path) == NAUTILUS_LINK_HOME;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_historical_local_is_trash_link (const char *path)
|
||||
{
|
||||
return nautilus_link_historical_local_get_link_type (path) == NAUTILUS_LINK_TRASH;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopEntry *entry, const char *dest_path, const GdkPoint *position)
|
||||
{
|
||||
char *icon_name;
|
||||
char *launch_string, *terminal_command;
|
||||
char *quoted, *arguments, *temp_str;
|
||||
int i;
|
||||
|
||||
if (entry == NULL || dest_path == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Extract arguments from exec array */
|
||||
arguments = NULL;
|
||||
for (i = 0; i < entry->exec_length; ++i) {
|
||||
quoted = eel_shell_quote (entry->exec[i]);
|
||||
if (arguments == NULL) {
|
||||
arguments = quoted;
|
||||
} else {
|
||||
temp_str = arguments;
|
||||
arguments = g_strconcat (arguments, " ", quoted, NULL);
|
||||
g_free (temp_str);
|
||||
g_free (quoted);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp (entry->type, "Application") == 0) {
|
||||
if (entry->terminal) {
|
||||
terminal_command = eel_gnome_make_terminal_command (arguments);
|
||||
launch_string = g_strconcat ("command:", terminal_command, NULL);
|
||||
g_free (terminal_command);
|
||||
} else {
|
||||
launch_string = g_strconcat ("command:", arguments, NULL);
|
||||
}
|
||||
} else if (strcmp (entry->type, "URL") == 0) {
|
||||
launch_string = g_strdup (arguments);
|
||||
} else {
|
||||
/* Unknown .desktop file type */
|
||||
launch_string = NULL;
|
||||
}
|
||||
|
||||
if (entry->icon != NULL) {
|
||||
icon_name = eel_make_uri_from_half_baked_uri (entry->icon);
|
||||
} else {
|
||||
icon_name = g_strdup ("gnome-unknown.png");
|
||||
}
|
||||
|
||||
if (launch_string != NULL) {
|
||||
nautilus_link_historical_local_create (dest_path, entry->name, icon_name,
|
||||
launch_string, position, NAUTILUS_LINK_GENERIC);
|
||||
}
|
||||
|
||||
g_free (icon_name);
|
||||
g_free (launch_string);
|
||||
g_free (arguments);
|
||||
}
|
||||
|
||||
|
60
libnautilus-private/nautilus-link-historical.h
Normal file
60
libnautilus-private/nautilus-link-historical.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-link-historical.h: xml-based link files that control their appearance
|
||||
and behavior.
|
||||
|
||||
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.
|
||||
|
||||
Authors: Andy Hertzfeld <andy@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_LINK_HISTORICAL_H
|
||||
#define NAUTILUS_LINK_HISTORICAL_H
|
||||
|
||||
#include "nautilus-file.h"
|
||||
#include <gdk/gdk.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnome/gnome-dentry.h>
|
||||
|
||||
gboolean nautilus_link_historical_local_create (const char *directory_path,
|
||||
const char *name,
|
||||
const char *image,
|
||||
const char *target_uri,
|
||||
const GdkPoint *point,
|
||||
NautilusLinkType type);
|
||||
gboolean nautilus_link_historical_local_set_icon (const char *path,
|
||||
const char *icon_name);
|
||||
gboolean nautilus_link_historical_local_set_type (const char *path,
|
||||
NautilusLinkType type);
|
||||
gboolean nautilus_link_historical_local_set_link_uri (const char *path,
|
||||
const char *uri);
|
||||
char * nautilus_link_historical_local_get_additional_text (const char *path);
|
||||
NautilusLinkType nautilus_link_historical_local_get_link_type (const char *path);
|
||||
gboolean nautilus_link_historical_local_is_volume_link (const char *path);
|
||||
gboolean nautilus_link_historical_local_is_home_link (const char *path);
|
||||
gboolean nautilus_link_historical_local_is_trash_link (const char *path);
|
||||
char * nautilus_link_historical_local_get_link_uri (const char *path);
|
||||
char * nautilus_link_historical_get_link_uri_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size);
|
||||
char * nautilus_link_historical_get_link_icon_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size);
|
||||
void nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
|
||||
const char *dest_path,
|
||||
const GdkPoint *position);
|
||||
|
||||
#endif /* NAUTILUS_LINK_HISTORICAL_H */
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include <config.h>
|
||||
#include "nautilus-link.h"
|
||||
#include "nautilus-link-historical.h"
|
||||
#include "nautilus-link-desktop-file.h"
|
||||
|
||||
#include "nautilus-directory-notify.h"
|
||||
#include "nautilus-directory.h"
|
||||
|
@ -45,56 +47,19 @@
|
|||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Link type XML tags */
|
||||
#define NAUTILUS_LINK_GENERIC_TAG "Generic Link"
|
||||
#define NAUTILUS_LINK_TRASH_TAG "Trash Link"
|
||||
#define NAUTILUS_LINK_MOUNT_TAG "Mount Link"
|
||||
#define NAUTILUS_LINK_HOME_TAG "Home Link"
|
||||
const char *get_uri_mime_type_full (const gchar *uri_path);
|
||||
|
||||
#define REMOTE_ICON_DIR_PERMISSIONS (GNOME_VFS_PERM_USER_ALL \
|
||||
| GNOME_VFS_PERM_GROUP_ALL \
|
||||
| GNOME_VFS_PERM_OTHER_ALL)
|
||||
|
||||
typedef struct {
|
||||
char *link_uri;
|
||||
char *file_path;
|
||||
} NautilusLinkIconNotificationInfo;
|
||||
|
||||
typedef void (* NautilusFileFunction) (NautilusFile *file);
|
||||
|
||||
static const char *
|
||||
get_tag (NautilusLinkType type)
|
||||
const char *
|
||||
get_uri_mime_type_full (const gchar *uri_path)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
/* fall through */
|
||||
case NAUTILUS_LINK_GENERIC:
|
||||
return NAUTILUS_LINK_GENERIC_TAG;
|
||||
case NAUTILUS_LINK_TRASH:
|
||||
return NAUTILUS_LINK_TRASH_TAG;
|
||||
case NAUTILUS_LINK_MOUNT:
|
||||
return NAUTILUS_LINK_MOUNT_TAG;
|
||||
case NAUTILUS_LINK_HOME:
|
||||
return NAUTILUS_LINK_HOME_TAG;
|
||||
}
|
||||
}
|
||||
const gchar *retval;
|
||||
GnomeVFSURI *uri;
|
||||
|
||||
static NautilusLinkType
|
||||
get_link_type (const char *tag)
|
||||
{
|
||||
if (tag != NULL) {
|
||||
if (strcmp (tag, NAUTILUS_LINK_TRASH_TAG) == 0) {
|
||||
return NAUTILUS_LINK_TRASH;
|
||||
}
|
||||
if (strcmp (tag, NAUTILUS_LINK_MOUNT_TAG) == 0) {
|
||||
return NAUTILUS_LINK_MOUNT;
|
||||
}
|
||||
if (strcmp (tag, NAUTILUS_LINK_HOME_TAG) == 0) {
|
||||
return NAUTILUS_LINK_HOME;
|
||||
}
|
||||
}
|
||||
return NAUTILUS_LINK_GENERIC;
|
||||
uri = gnome_vfs_uri_new (uri_path);
|
||||
retval = gnome_vfs_get_mime_type (uri);
|
||||
gnome_vfs_uri_unref (uri);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -105,457 +70,292 @@ nautilus_link_local_create (const char *directory_path,
|
|||
const GdkPoint *point,
|
||||
NautilusLinkType type)
|
||||
{
|
||||
xmlDocPtr output_document;
|
||||
xmlNodePtr root_node;
|
||||
char *path;
|
||||
int result;
|
||||
char *uri;
|
||||
GList dummy_list;
|
||||
NautilusFileChangesQueuePosition item;
|
||||
gboolean retval;
|
||||
|
||||
retval = nautilus_link_desktop_file_local_create (directory_path,
|
||||
name, image,
|
||||
target_uri, point,
|
||||
type);
|
||||
|
||||
g_return_val_if_fail (directory_path != NULL, FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
g_return_val_if_fail (image != NULL, FALSE);
|
||||
g_return_val_if_fail (target_uri != NULL, FALSE);
|
||||
|
||||
/* create a new xml document */
|
||||
output_document = xmlNewDoc ("1.0");
|
||||
|
||||
/* add the root node to the output document */
|
||||
root_node = xmlNewDocNode (output_document, NULL, "nautilus_object", NULL);
|
||||
xmlDocSetRootElement (output_document, root_node);
|
||||
|
||||
/* Add mime magic string so that the mime sniffer can recognize us.
|
||||
* Note: The value of the tag identfies what type of link this. */
|
||||
xmlSetProp (root_node, "nautilus_link", get_tag (type));
|
||||
|
||||
/* Add link and custom icon tags */
|
||||
xmlSetProp (root_node, "custom_icon", image);
|
||||
xmlSetProp (root_node, "link", target_uri);
|
||||
|
||||
/* all done, so save the xml document as a link file */
|
||||
path = nautilus_make_path (directory_path, name);
|
||||
result = xmlSaveFile (path, output_document);
|
||||
|
||||
xmlFreeDoc (output_document);
|
||||
|
||||
if (result <= 0) {
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Notify that this new file has been created. */
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
dummy_list.data = uri;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
nautilus_directory_notify_files_added (&dummy_list);
|
||||
nautilus_directory_schedule_metadata_remove (&dummy_list);
|
||||
|
||||
if (point != NULL) {
|
||||
item.uri = uri;
|
||||
item.set = TRUE;
|
||||
item.point.x = point->x;
|
||||
item.point.y = point->y;
|
||||
|
||||
dummy_list.data = &item;
|
||||
dummy_list.next = NULL;
|
||||
dummy_list.prev = NULL;
|
||||
|
||||
nautilus_directory_schedule_position_set (&dummy_list);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
|
||||
g_free (path);
|
||||
|
||||
return TRUE;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char *
|
||||
xml_get_root_property (xmlDoc *doc,
|
||||
const char *key)
|
||||
{
|
||||
char *property, *duplicate;
|
||||
|
||||
/* Need to g_strdup so we can free with g_free instead of xmlFree. */
|
||||
property = xmlGetProp (xmlDocGetRootElement (doc), key);
|
||||
duplicate = g_strdup (property);
|
||||
xmlFree (property);
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
static char *
|
||||
local_get_root_property (const char *path,
|
||||
const char *key)
|
||||
{
|
||||
xmlDoc *document;
|
||||
char *property;
|
||||
const char *mime_type;
|
||||
|
||||
property = NULL;
|
||||
|
||||
/* Check mime type. Exit if it is not a nautilus link */
|
||||
mime_type = gnome_vfs_get_file_mime_type (path, NULL, FALSE);
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
document = xmlParseFile (path);
|
||||
if (document != NULL) {
|
||||
property = xml_get_root_property (document, key);
|
||||
xmlFreeDoc (document);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
local_set_root_property (const char *path,
|
||||
const char *key,
|
||||
const char *value,
|
||||
NautilusFileFunction extra_notify)
|
||||
{
|
||||
xmlDocPtr document;
|
||||
xmlNodePtr root;
|
||||
xmlChar *old_value;
|
||||
char *uri;
|
||||
NautilusFile *file;
|
||||
|
||||
document = xmlParseFile (path);
|
||||
if (document == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
root = xmlDocGetRootElement (document);
|
||||
if (root == NULL) {
|
||||
xmlFreeDoc (document);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check if the property value is already correct. */
|
||||
old_value = xmlGetProp (root, key);
|
||||
if (old_value != NULL && strcmp (old_value, value) == 0) {
|
||||
xmlFreeDoc (document);
|
||||
xmlFree (old_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
xmlFree (old_value);
|
||||
|
||||
/* Change and write the property. */
|
||||
xmlSetProp (root, key, value);
|
||||
xmlSaveFile (path, document);
|
||||
xmlFreeDoc (document);
|
||||
|
||||
/* Notify about the change. */
|
||||
uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
file = nautilus_file_get (uri);
|
||||
if (file != NULL) {
|
||||
if (extra_notify != NULL) {
|
||||
(* extra_notify) (file);
|
||||
}
|
||||
nautilus_file_changed (file);
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
g_free (uri);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Set the icon for a link file. This can only be called on local
|
||||
* paths, and only on files known to be link files.
|
||||
*/
|
||||
gboolean
|
||||
nautilus_link_local_set_icon (const char *path, const char *icon_name)
|
||||
{
|
||||
return local_set_root_property (path,
|
||||
NAUTILUS_METADATA_KEY_CUSTOM_ICON,
|
||||
icon_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
forget_file_activation_uri (NautilusFile *file)
|
||||
{
|
||||
const gchar *mime_type;
|
||||
gboolean retval;
|
||||
NautilusFile *file;
|
||||
GList *attributes;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = FALSE;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_set_icon (path, icon_name);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_set_icon (path, icon_name);
|
||||
}
|
||||
|
||||
file = nautilus_file_get (path);
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
|
||||
nautilus_file_invalidate_attributes (file, attributes);
|
||||
nautilus_file_unref (file);
|
||||
g_list_free (attributes);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Set the link uri for a link file. This can only be called on local
|
||||
* paths, and only on files known to be link files.
|
||||
*/
|
||||
gboolean
|
||||
nautilus_link_local_set_link_uri (const char *path, const char *link_uri)
|
||||
{
|
||||
return local_set_root_property (path,
|
||||
"link",
|
||||
link_uri,
|
||||
forget_file_activation_uri);
|
||||
const gchar *mime_type;
|
||||
gboolean retval;
|
||||
NautilusFile *file;
|
||||
GList *attributes;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = FALSE;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_set_link_uri (path, link_uri);
|
||||
}
|
||||
/* FIXME: May want to implement this for desktop files too */
|
||||
|
||||
file = nautilus_file_get (path);
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
|
||||
nautilus_file_invalidate_attributes (file, attributes);
|
||||
nautilus_file_unref (file);
|
||||
g_list_free (attributes);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_local_set_type (const char *path,
|
||||
NautilusLinkType type)
|
||||
{
|
||||
return local_set_root_property (path,
|
||||
"nautilus_link",
|
||||
get_tag (type),
|
||||
NULL);
|
||||
const gchar *mime_type;
|
||||
gboolean retval;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = FALSE;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_set_type (path, type);
|
||||
}
|
||||
/* FIXME: May want to implement this for desktop files too */
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* returns additional text to display under the name, NULL if none */
|
||||
char *
|
||||
nautilus_link_local_get_additional_text (const char *path)
|
||||
{
|
||||
return local_get_root_property
|
||||
(path, NAUTILUS_METADATA_KEY_EXTRA_TEXT);
|
||||
}
|
||||
const gchar *mime_type;
|
||||
gchar *retval;
|
||||
|
||||
/* utility to return the local pathname of a cached icon, given the leaf name */
|
||||
/* if the icons directory hasn't been created yet, create it */
|
||||
static char *
|
||||
make_local_path (const char *image_uri)
|
||||
{
|
||||
GnomeVFSResult result;
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = NULL;
|
||||
|
||||
char *escaped_uri, *local_directory_path, *local_directory_uri, *local_file_path;
|
||||
|
||||
escaped_uri = gnome_vfs_escape_slashes (image_uri);
|
||||
|
||||
local_directory_path = g_strconcat
|
||||
(g_get_home_dir (),
|
||||
"/.nautilus/remote_icons",
|
||||
NULL);
|
||||
|
||||
/* We must create the directory if it doesn't exist. */
|
||||
local_directory_uri = gnome_vfs_get_uri_from_local_path (local_directory_path);
|
||||
result = gnome_vfs_make_directory (local_directory_uri, REMOTE_ICON_DIR_PERMISSIONS);
|
||||
if (result != GNOME_VFS_OK) {
|
||||
g_free (local_directory_uri);
|
||||
g_free (escaped_uri);
|
||||
g_free (local_directory_path);
|
||||
return NULL;
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
local_file_path = nautilus_make_path (local_directory_path, escaped_uri);
|
||||
g_free (local_directory_uri);
|
||||
g_free (escaped_uri);
|
||||
g_free (local_directory_path);
|
||||
|
||||
return local_file_path;
|
||||
}
|
||||
|
||||
/* utility to free the icon notification info */
|
||||
|
||||
static void
|
||||
free_icon_notification_info (NautilusLinkIconNotificationInfo *info)
|
||||
{
|
||||
g_free (info->link_uri);
|
||||
g_free (info->file_path);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
/* callback to handle the asynchronous reading of icons */
|
||||
static void
|
||||
icon_read_done_callback (GnomeVFSResult result,
|
||||
GnomeVFSFileSize file_size,
|
||||
char *file_contents,
|
||||
gpointer callback_data)
|
||||
{
|
||||
int size;
|
||||
FILE* outfile;
|
||||
NautilusFile *file;
|
||||
NautilusLinkIconNotificationInfo *info;
|
||||
|
||||
info = (NautilusLinkIconNotificationInfo *) callback_data;
|
||||
|
||||
if (result != GNOME_VFS_OK) {
|
||||
g_assert (file_contents == NULL);
|
||||
free_icon_notification_info (info);
|
||||
return;
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_get_additional_text (path);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_get_additional_text (path);
|
||||
}
|
||||
|
||||
/* write out the file into the cache area */
|
||||
size = file_size;
|
||||
outfile = fopen (info->file_path, "wb");
|
||||
fwrite (file_contents, size, 1, outfile);
|
||||
fclose (outfile);
|
||||
|
||||
g_free (file_contents);
|
||||
|
||||
/* tell the world that the file has changed */
|
||||
file = nautilus_file_get (info->link_uri);
|
||||
if (file != NULL) {
|
||||
nautilus_file_changed (file);
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
|
||||
/* free up the notification info */
|
||||
free_icon_notification_info (info);
|
||||
}
|
||||
|
||||
/* returns the image associated with a link file */
|
||||
char *
|
||||
nautilus_link_local_get_image_uri (const char *path)
|
||||
{
|
||||
xmlDoc *doc;
|
||||
char *icon_uri;
|
||||
char *local_path, *local_uri;
|
||||
NautilusLinkIconNotificationInfo *info;
|
||||
|
||||
doc = xmlParseFile (path);
|
||||
if (doc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
icon_uri = xml_get_root_property (doc, NAUTILUS_METADATA_KEY_CUSTOM_ICON);
|
||||
xmlFreeDoc (doc);
|
||||
|
||||
if (icon_uri == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* if the image is remote, see if we can find it in our local cache */
|
||||
if (eel_is_remote_uri (icon_uri)) {
|
||||
local_path = make_local_path (icon_uri);
|
||||
if (local_path == NULL) {
|
||||
g_free (icon_uri);
|
||||
return NULL;
|
||||
}
|
||||
if (g_file_exists (local_path)) {
|
||||
g_free (icon_uri);
|
||||
local_uri = gnome_vfs_get_uri_from_local_path (local_path);
|
||||
g_free (local_path);
|
||||
return local_uri;
|
||||
}
|
||||
|
||||
/* load it asynchronously through gnome-vfs */
|
||||
info = g_new0 (NautilusLinkIconNotificationInfo, 1);
|
||||
info->link_uri = gnome_vfs_get_uri_from_local_path (path);
|
||||
info->file_path = local_path;
|
||||
eel_read_entire_file_async (icon_uri, icon_read_done_callback, info);
|
||||
|
||||
g_free (icon_uri);
|
||||
return NULL; /* return NULL since the icon is still loading - it will get correctly set by the callback */
|
||||
}
|
||||
|
||||
return icon_uri;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Returns the link uri associated with a link file. */
|
||||
char *
|
||||
nautilus_link_local_get_link_uri (const char *path)
|
||||
{
|
||||
return local_get_root_property (path, "link");
|
||||
const gchar *mime_type;
|
||||
gchar *retval;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = NULL;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_get_link_uri (path);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_get_link_uri (path);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Returns the link type of the link file. */
|
||||
NautilusLinkType
|
||||
nautilus_link_local_get_link_type (const char *path)
|
||||
{
|
||||
char *property;
|
||||
NautilusLinkType type;
|
||||
const gchar *mime_type;
|
||||
NautilusLinkType retval;
|
||||
|
||||
property = local_get_root_property (path, "nautilus_link");
|
||||
type = get_link_type (property);
|
||||
g_free (property);
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = NAUTILUS_LINK_GENERIC;
|
||||
|
||||
return type;
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_get_link_type (path);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_get_link_type (path);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* FIXME bugzilla.gnome.org 42495:
|
||||
* Caller has to know to pass in a file with a NUL character at the end.
|
||||
*/
|
||||
char *
|
||||
nautilus_link_get_link_uri_given_file_contents (const char *file_contents,
|
||||
int file_size)
|
||||
{
|
||||
xmlDoc *doc;
|
||||
char *property;
|
||||
const gchar *mime_type;
|
||||
gchar *retval;
|
||||
|
||||
doc = xmlParseMemory ((char *) file_contents, file_size);
|
||||
property = xml_get_root_property (doc, "link");
|
||||
xmlFreeDoc (doc);
|
||||
return property;
|
||||
mime_type = gnome_vfs_get_mime_type_for_data (file_contents, file_size);
|
||||
retval = NULL;
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_get_link_uri_given_file_contents (file_contents, file_size);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_get_link_uri_given_file_contents (file_contents, file_size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_get_link_name_given_file_contents (const char *file_contents,
|
||||
int file_size)
|
||||
{
|
||||
const gchar *mime_type;
|
||||
gchar *retval;
|
||||
|
||||
mime_type = gnome_vfs_get_mime_type_for_data (file_contents, file_size);
|
||||
retval = NULL;
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = NULL;
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_get_link_name_given_file_contents (file_contents, file_size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_link_get_link_icon_given_file_contents (const char *file_contents,
|
||||
int file_size)
|
||||
{
|
||||
const gchar *mime_type;
|
||||
gchar *retval;
|
||||
|
||||
mime_type = gnome_vfs_get_mime_type_for_data (file_contents, file_size);
|
||||
retval = NULL;
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_get_link_icon_given_file_contents (file_contents, file_size);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_get_link_icon_given_file_contents (file_contents, file_size);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_local_is_volume_link (const char *path)
|
||||
{
|
||||
return nautilus_link_local_get_link_type (path) == NAUTILUS_LINK_MOUNT;
|
||||
const gchar *mime_type;
|
||||
gboolean retval;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = FALSE;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_is_volume_link (path);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_is_volume_link (path);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_local_is_home_link (const char *path)
|
||||
{
|
||||
return nautilus_link_local_get_link_type (path) == NAUTILUS_LINK_HOME;
|
||||
const gchar *mime_type;
|
||||
gboolean retval;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = FALSE;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_is_home_link (path);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_is_home_link (path);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_link_local_is_trash_link (const char *path)
|
||||
{
|
||||
return nautilus_link_local_get_link_type (path) == NAUTILUS_LINK_TRASH;
|
||||
const gchar *mime_type;
|
||||
gboolean retval;
|
||||
|
||||
mime_type = get_uri_mime_type_full (path);
|
||||
retval = FALSE;
|
||||
|
||||
if (mime_type == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (strcmp (mime_type, "application/x-nautilus-link") == 0) {
|
||||
retval = nautilus_link_historical_local_is_trash_link (path);
|
||||
} else if (strcmp (mime_type, "application/x-gnome-app-info") == 0) {
|
||||
retval = nautilus_link_desktop_file_local_is_trash_link (path);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_link_local_create_from_gnome_entry (GnomeDesktopEntry *entry, const char *dest_path, const GdkPoint *position)
|
||||
{
|
||||
char *icon_name;
|
||||
char *launch_string, *terminal_command;
|
||||
char *quoted, *arguments, *temp_str;
|
||||
int i;
|
||||
|
||||
if (entry == NULL || dest_path == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Extract arguments from exec array */
|
||||
arguments = NULL;
|
||||
for (i = 0; i < entry->exec_length; ++i) {
|
||||
quoted = eel_shell_quote (entry->exec[i]);
|
||||
if (arguments == NULL) {
|
||||
arguments = quoted;
|
||||
} else {
|
||||
temp_str = arguments;
|
||||
arguments = g_strconcat (arguments, " ", quoted, NULL);
|
||||
g_free (temp_str);
|
||||
g_free (quoted);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp (entry->type, "Application") == 0) {
|
||||
if (entry->terminal) {
|
||||
terminal_command = eel_gnome_make_terminal_command (arguments);
|
||||
launch_string = g_strconcat ("command:", terminal_command, NULL);
|
||||
g_free (terminal_command);
|
||||
} else {
|
||||
launch_string = g_strconcat ("command:", arguments, NULL);
|
||||
}
|
||||
} else if (strcmp (entry->type, "URL") == 0) {
|
||||
launch_string = g_strdup (arguments);
|
||||
} else {
|
||||
/* Unknown .desktop file type */
|
||||
launch_string = NULL;
|
||||
}
|
||||
|
||||
if (entry->icon != NULL) {
|
||||
icon_name = eel_make_uri_from_half_baked_uri (entry->icon);
|
||||
} else {
|
||||
icon_name = g_strdup ("gnome-unknown.png");
|
||||
}
|
||||
|
||||
if (launch_string != NULL) {
|
||||
nautilus_link_local_create (dest_path, entry->name, icon_name,
|
||||
launch_string, position, NAUTILUS_LINK_GENERIC);
|
||||
}
|
||||
|
||||
g_free (icon_name);
|
||||
g_free (launch_string);
|
||||
g_free (arguments);
|
||||
nautilus_link_desktop_file_local_create_from_gnome_entry (entry, dest_path, position);
|
||||
}
|
||||
|
|
|
@ -78,13 +78,6 @@ gboolean nautilus_link_local_set_link_uri (const char
|
|||
*/
|
||||
char * nautilus_link_local_get_additional_text (const char *path);
|
||||
|
||||
/* Returns the image associated with a link file. Despite the fact
|
||||
* that it takes a URI parameter, works only if the file is local and
|
||||
* does sync. I/O on the link, although it does async. on the image
|
||||
* and caches if the image is remote.
|
||||
*/
|
||||
char * nautilus_link_local_get_image_uri (const char *path);
|
||||
|
||||
/* Returns the link type of a link file.
|
||||
* Works only if the file is local and does sync. I/O
|
||||
*/
|
||||
|
@ -115,7 +108,10 @@ gboolean nautilus_link_local_is_trash_link (const char
|
|||
char * nautilus_link_local_get_link_uri (const char *path);
|
||||
char * nautilus_link_get_link_uri_given_file_contents (const char *link_file_contents,
|
||||
int link_file_size);
|
||||
|
||||
char * nautilus_link_get_link_name_given_file_contents (const char *file_contents,
|
||||
int link_file_size);
|
||||
char * nautilus_link_get_link_icon_given_file_contents (const char *file_contents,
|
||||
int link_file_size);
|
||||
void nautilus_link_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
|
||||
const char *dest_path,
|
||||
const GdkPoint *position);
|
||||
|
|
|
@ -801,7 +801,6 @@ fm_desktop_icon_view_trash_state_changed_callback (NautilusTrashMonitor *trash_m
|
|||
|
||||
path = nautilus_make_path (desktop_directory, TRASH_LINK_NAME);
|
||||
|
||||
/* Change the XML file to have a new icon. */
|
||||
nautilus_link_local_set_icon (path, state ? "trash-empty" : "trash-full");
|
||||
|
||||
g_free (path);
|
||||
|
|
|
@ -4502,7 +4502,6 @@ activate_callback (NautilusFile *file, gpointer callback_data)
|
|||
FMDirectoryView *view;
|
||||
char *uri, *command, *executable_path, *quoted_path, *name;
|
||||
GnomeVFSMimeApplication *application;
|
||||
GnomeDesktopEntry *entry;
|
||||
ActivationAction action;
|
||||
|
||||
parameters = callback_data;
|
||||
|
@ -4545,24 +4544,6 @@ activate_callback (NautilusFile *file, gpointer callback_data)
|
|||
action = ACTIVATION_ACTION_DO_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
if (action != ACTIVATION_ACTION_DO_NOTHING
|
||||
&& strcmp (gnome_vfs_mime_type_from_name_or_default (uri, ""),
|
||||
"application/x-gnome-app-info") == 0) {
|
||||
|
||||
executable_path = gnome_vfs_get_local_path_from_uri (uri);
|
||||
if (executable_path != NULL) {
|
||||
entry = gnome_desktop_entry_load (executable_path);
|
||||
if (entry != NULL) {
|
||||
gnome_desktop_entry_launch (entry);
|
||||
}
|
||||
gnome_desktop_entry_free (entry);
|
||||
}
|
||||
g_free (executable_path);
|
||||
|
||||
action = ACTIVATION_ACTION_DO_NOTHING;
|
||||
}
|
||||
|
||||
if (action != ACTIVATION_ACTION_DO_NOTHING && file_is_launchable (file)) {
|
||||
|
||||
action = ACTIVATION_ACTION_LAUNCH;
|
||||
|
@ -4845,7 +4826,8 @@ finish_loading (FMDirectoryView *view)
|
|||
|
||||
/* Monitor the things needed to get the right icon. Also
|
||||
* monitor a directory's item count because the "size"
|
||||
* attribute is based on that, and the file's metadata.
|
||||
* attribute is based on that, and the file's metadata
|
||||
* and possible custom name.
|
||||
*/
|
||||
attributes = nautilus_icon_factory_get_required_file_attributes ();
|
||||
attributes = g_list_prepend (attributes,
|
||||
|
@ -4854,6 +4836,8 @@ finish_loading (FMDirectoryView *view)
|
|||
NAUTILUS_FILE_ATTRIBUTE_METADATA);
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
|
||||
nautilus_directory_file_monitor_add (view->details->model,
|
||||
&view->details->model,
|
||||
|
|
|
@ -514,7 +514,8 @@ fm_icon_view_add_file (FMDirectoryView *view, NautilusFile *file)
|
|||
nautilus_icon_container_reset_scroll_region (get_icon_container (icon_view));
|
||||
}
|
||||
|
||||
if (nautilus_icon_container_add (get_icon_container (icon_view),
|
||||
if (nautilus_icon_factory_is_basic_icon_ready_for_file (file) &&
|
||||
nautilus_icon_container_add (get_icon_container (icon_view),
|
||||
NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
|
||||
nautilus_file_ref (file);
|
||||
}
|
||||
|
@ -535,6 +536,10 @@ fm_icon_view_file_changed (FMDirectoryView *view, NautilusFile *file)
|
|||
if (removed) {
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
} else if (nautilus_icon_factory_is_basic_icon_ready_for_file (file) &&
|
||||
nautilus_icon_container_add (get_icon_container (FM_ICON_VIEW (view)),
|
||||
NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
|
||||
nautilus_file_ref (file);
|
||||
} else {
|
||||
nautilus_icon_container_request_update
|
||||
(get_icon_container (FM_ICON_VIEW (view)),
|
||||
|
@ -1980,6 +1985,7 @@ get_icon_text_callback (NautilusIconContainer *container,
|
|||
FMIconView *icon_view)
|
||||
{
|
||||
char *actual_uri, *path;
|
||||
gchar *description;
|
||||
char *attribute_names;
|
||||
char **text_array;
|
||||
int i , slot_index;
|
||||
|
@ -2005,9 +2011,12 @@ get_icon_text_callback (NautilusIconContainer *container,
|
|||
actual_uri = nautilus_file_get_uri (file);
|
||||
path = gnome_vfs_get_local_path_from_uri (actual_uri);
|
||||
g_free (actual_uri);
|
||||
*additional_text = NULL;
|
||||
if (path != NULL) {
|
||||
*additional_text = nautilus_link_local_get_additional_text (path);
|
||||
g_free (path);
|
||||
description = nautilus_link_local_get_additional_text (path);
|
||||
if (description)
|
||||
*additional_text = g_strdup_printf (" \n%s\n ", description);
|
||||
g_free (description);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2648,6 +2657,7 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur
|
|||
char *local_path;
|
||||
char *stripped_uri;
|
||||
char *container_uri_string;
|
||||
char *container_path;
|
||||
const char *last_slash, *link_name;
|
||||
int n_uris;
|
||||
gboolean all_local;
|
||||
|
@ -2733,6 +2743,7 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur
|
|||
if (points)
|
||||
g_array_free (points, TRUE);
|
||||
} else {
|
||||
container_path = gnome_vfs_get_local_path_from_uri (container_uri_string);
|
||||
for (node = real_uri_list; node != NULL; node = node->next) {
|
||||
/* Make a link using the desktop file contents? */
|
||||
local_path = gnome_vfs_get_local_path_from_uri (node->data);
|
||||
|
@ -2741,7 +2752,7 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur
|
|||
if (entry != NULL) {
|
||||
|
||||
/* FIXME: Handle name conflicts? */
|
||||
nautilus_link_local_create_from_gnome_entry (entry, container_uri_string, &point);
|
||||
nautilus_link_local_create_from_gnome_entry (entry, container_path, &point);
|
||||
gnome_desktop_entry_free (entry);
|
||||
}
|
||||
g_free (local_path);
|
||||
|
@ -2763,7 +2774,7 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur
|
|||
|
||||
if (!eel_str_is_empty (link_name)) {
|
||||
/* FIXME: Handle name conflicts? */
|
||||
nautilus_link_local_create (container_uri_string, link_name,
|
||||
nautilus_link_local_create (container_path, link_name,
|
||||
"gnome-http-url", local_path,
|
||||
&point, NAUTILUS_LINK_GENERIC);
|
||||
}
|
||||
|
@ -2772,6 +2783,7 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur
|
|||
|
||||
break;
|
||||
}
|
||||
g_free (container_path);
|
||||
}
|
||||
|
||||
gnome_uri_list_free_strings (real_uri_list);
|
||||
|
|
|
@ -2132,6 +2132,8 @@ create_properties_window (StartupData *startup_data)
|
|||
* target file.
|
||||
*/
|
||||
attributes = nautilus_icon_factory_get_required_file_attributes ();
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (window->details->original_file, window, attributes);
|
||||
g_list_free (attributes);
|
||||
|
||||
|
|
|
@ -632,7 +632,9 @@ real_adding_file (FMListView *view, NautilusFile *file)
|
|||
GTK_OBJECT (view));
|
||||
/* Monitor the things needed to get the right
|
||||
* icon. Also monitor a directory's item count because
|
||||
* the "size" attribute is based on that, and the file's metadata. */
|
||||
* the "size" attribute is based on that, and the file's metadata, and
|
||||
* possible custom icon.
|
||||
*/
|
||||
attributes = nautilus_icon_factory_get_required_file_attributes ();
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT);
|
||||
|
@ -640,6 +642,8 @@ real_adding_file (FMListView *view, NautilusFile *file)
|
|||
NAUTILUS_FILE_ATTRIBUTE_METADATA);
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
|
||||
attributes = g_list_prepend (attributes,
|
||||
NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (file, view, attributes);
|
||||
g_list_free (attributes);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <libnautilus-private/nautilus-bonobo-extensions.h>
|
||||
#include <libnautilus-private/nautilus-drag-window.h>
|
||||
#include <libnautilus-private/nautilus-file-utilities.h>
|
||||
#include <libnautilus-private/nautilus-file-attributes.h>
|
||||
#include <libnautilus-private/nautilus-global-preferences.h>
|
||||
#include <libnautilus-private/nautilus-horizontal-splitter.h>
|
||||
#include <libnautilus-private/nautilus-icon-factory.h>
|
||||
|
@ -2267,11 +2268,23 @@ void
|
|||
nautilus_window_set_viewed_file (NautilusWindow *window,
|
||||
NautilusFile *file)
|
||||
{
|
||||
GList *attributes;
|
||||
|
||||
if (window->details->viewed_file == file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->details->viewed_file != NULL) {
|
||||
nautilus_file_monitor_remove (window->details->viewed_file,
|
||||
window);
|
||||
}
|
||||
|
||||
nautilus_file_ref (file);
|
||||
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (file, window, attributes);
|
||||
g_list_free (attributes);
|
||||
|
||||
cancel_view_as_callback (window);
|
||||
cancel_chose_component_callback (window);
|
||||
nautilus_file_unref (window->details->viewed_file);
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <libnautilus-private/nautilus-bonobo-extensions.h>
|
||||
#include <libnautilus-private/nautilus-drag-window.h>
|
||||
#include <libnautilus-private/nautilus-file-utilities.h>
|
||||
#include <libnautilus-private/nautilus-file-attributes.h>
|
||||
#include <libnautilus-private/nautilus-global-preferences.h>
|
||||
#include <libnautilus-private/nautilus-horizontal-splitter.h>
|
||||
#include <libnautilus-private/nautilus-icon-factory.h>
|
||||
|
@ -2267,11 +2268,23 @@ void
|
|||
nautilus_window_set_viewed_file (NautilusWindow *window,
|
||||
NautilusFile *file)
|
||||
{
|
||||
GList *attributes;
|
||||
|
||||
if (window->details->viewed_file == file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->details->viewed_file != NULL) {
|
||||
nautilus_file_monitor_remove (window->details->viewed_file,
|
||||
window);
|
||||
}
|
||||
|
||||
nautilus_file_ref (file);
|
||||
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (file, window, attributes);
|
||||
g_list_free (attributes);
|
||||
|
||||
cancel_view_as_callback (window);
|
||||
cancel_chose_component_callback (window);
|
||||
nautilus_file_unref (window->details->viewed_file);
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <libnautilus-private/nautilus-bonobo-extensions.h>
|
||||
#include <libnautilus-private/nautilus-drag-window.h>
|
||||
#include <libnautilus-private/nautilus-file-utilities.h>
|
||||
#include <libnautilus-private/nautilus-file-attributes.h>
|
||||
#include <libnautilus-private/nautilus-global-preferences.h>
|
||||
#include <libnautilus-private/nautilus-horizontal-splitter.h>
|
||||
#include <libnautilus-private/nautilus-icon-factory.h>
|
||||
|
@ -2267,11 +2268,23 @@ void
|
|||
nautilus_window_set_viewed_file (NautilusWindow *window,
|
||||
NautilusFile *file)
|
||||
{
|
||||
GList *attributes;
|
||||
|
||||
if (window->details->viewed_file == file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->details->viewed_file != NULL) {
|
||||
nautilus_file_monitor_remove (window->details->viewed_file,
|
||||
window);
|
||||
}
|
||||
|
||||
nautilus_file_ref (file);
|
||||
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (file, window, attributes);
|
||||
g_list_free (attributes);
|
||||
|
||||
cancel_view_as_callback (window);
|
||||
cancel_chose_component_callback (window);
|
||||
nautilus_file_unref (window->details->viewed_file);
|
||||
|
|
|
@ -523,10 +523,11 @@ viewed_file_changed_callback (NautilusFile *file,
|
|||
(NAUTILUS_NAVIGATION_BAR (window->navigation_bar),
|
||||
window->details->location);
|
||||
|
||||
update_title (window);
|
||||
} else {
|
||||
g_free (new_location);
|
||||
}
|
||||
|
||||
update_title (window);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <libnautilus-private/nautilus-bonobo-extensions.h>
|
||||
#include <libnautilus-private/nautilus-drag-window.h>
|
||||
#include <libnautilus-private/nautilus-file-utilities.h>
|
||||
#include <libnautilus-private/nautilus-file-attributes.h>
|
||||
#include <libnautilus-private/nautilus-global-preferences.h>
|
||||
#include <libnautilus-private/nautilus-horizontal-splitter.h>
|
||||
#include <libnautilus-private/nautilus-icon-factory.h>
|
||||
|
@ -2267,11 +2268,23 @@ void
|
|||
nautilus_window_set_viewed_file (NautilusWindow *window,
|
||||
NautilusFile *file)
|
||||
{
|
||||
GList *attributes;
|
||||
|
||||
if (window->details->viewed_file == file) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->details->viewed_file != NULL) {
|
||||
nautilus_file_monitor_remove (window->details->viewed_file,
|
||||
window);
|
||||
}
|
||||
|
||||
nautilus_file_ref (file);
|
||||
|
||||
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_NAME);
|
||||
nautilus_file_monitor_add (file, window, attributes);
|
||||
g_list_free (attributes);
|
||||
|
||||
cancel_view_as_callback (window);
|
||||
cancel_chose_component_callback (window);
|
||||
nautilus_file_unref (window->details->viewed_file);
|
||||
|
|
Loading…
Reference in a new issue