summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2005-01-12 12:32:04 +0000
committerAlexander Larsson <alexl@src.gnome.org>2005-01-12 12:32:04 +0000
commitab9f1298c557841efe1f8dd791570a6274281d5b (patch)
treea59dc3e491b46d39aca0b1266c7cb005338bd29e /libnautilus-private
parent893dfd2f2b886a4714b91c4cc8a9fe902d6139ad (diff)
downloadnautilus-ab9f1298c557841efe1f8dd791570a6274281d5b.tar.gz
Remove historical link support.
2005-01-12 Alexander Larsson <alexl@redhat.com> * libnautilus-private/Makefile.am: * libnautilus-private/nautilus-link-historical.c: * libnautilus-private/nautilus-link-historical.h: Remove historical link support. * libnautilus-private/nautilus-link-desktop-file.[ch]: * libnautilus-private/nautilus-link.[ch]: Remove historical link support and unused functions. * src/file-manager/fm-directory-view.h: Remove unused declaration. * src/file-manager/fm-icon-view.c: Fix up due to small api change for nautilus-link. * src/file-manager/fm-properties-window.c: (set_icon_callback): Fix icon change for desktop files that point to nonexisting binaries.
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/Makefile.am2
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.c93
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.h7
-rw-r--r--libnautilus-private/nautilus-link-historical.c440
-rw-r--r--libnautilus-private/nautilus-link-historical.h55
-rw-r--r--libnautilus-private/nautilus-link.c213
-rw-r--r--libnautilus-private/nautilus-link.h69
7 files changed, 36 insertions, 843 deletions
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index ea7b245ee..bb6a28cd1 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -130,8 +130,6 @@ libnautilus_private_la_SOURCES = \
nautilus-lib-self-check-functions.h \
nautilus-link-desktop-file.c \
nautilus-link-desktop-file.h \
- nautilus-link-historical.c \
- nautilus-link-historical.h \
nautilus-link.c \
nautilus-link.h \
nautilus-marshal.c \
diff --git a/libnautilus-private/nautilus-link-desktop-file.c b/libnautilus-private/nautilus-link-desktop-file.c
index c14a24ee4..c49c8e528 100644
--- a/libnautilus-private/nautilus-link-desktop-file.c
+++ b/libnautilus-private/nautilus-link-desktop-file.c
@@ -51,24 +51,6 @@
#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 char *
slurp_key_string (const char *uri,
const char *keyname,
@@ -102,8 +84,7 @@ nautilus_link_desktop_file_local_create (const char *directory_uri,
const char *image,
const char *target_uri,
const GdkPoint *point,
- int screen,
- NautilusLinkType type)
+ int screen)
{
char *uri, *contents, *escaped_name;
GnomeDesktopItem *desktop_item;
@@ -122,11 +103,10 @@ nautilus_link_desktop_file_local_create (const char *directory_uri,
contents = g_strdup_printf ("[Desktop Entry]\n"
"Encoding=UTF-8\n"
"Name=%s\n"
- "Type=%s\n"
+ "Type=Link\n"
"URL=%s\n"
"%s%s\n",
display_name,
- get_tag (type),
target_uri,
image != NULL ? "X-Nautilus-Icon=" : "",
image != NULL ? image : "");
@@ -175,25 +155,6 @@ nautilus_link_desktop_file_local_create (const char *directory_uri,
}
gboolean
-nautilus_link_desktop_file_local_set_icon (const char *uri,
- const char *icon_name)
-{
- GnomeDesktopItem *desktop_file;
- gboolean success;
-
- desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
- if (desktop_file == NULL) {
- return FALSE;
- }
-
- gnome_desktop_item_set_string (desktop_file, "X-Nautilus-Icon", icon_name);
- success = gnome_desktop_item_save (desktop_file, NULL, FALSE, NULL);
- gnome_desktop_item_unref (desktop_file);
-
- return success;
-}
-
-gboolean
nautilus_link_desktop_file_local_set_text (const char *uri,
const char *text)
{
@@ -246,56 +207,6 @@ nautilus_link_desktop_file_local_get_additional_text (const char *path)
#endif
}
-NautilusLinkType
-nautilus_link_desktop_file_local_get_link_type (const char *path)
-{
- char *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_utf8 (const char *uri)
-{
- char *contents;
- int file_size;
- gboolean retval;
-
- if (eel_read_entire_file (uri,
- &file_size,
- &contents) != GNOME_VFS_OK) {
- return FALSE;
- }
-
- if (g_strstr_len (contents, file_size, "Encoding=UTF-8\n") != NULL) {
- retval = TRUE;
- } else {
- retval = FALSE;
- }
-
- g_free (contents);
-
- return retval;
-}
-
-
static char *
nautilus_link_desktop_file_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
diff --git a/libnautilus-private/nautilus-link-desktop-file.h b/libnautilus-private/nautilus-link-desktop-file.h
index b70cebe23..9e189414a 100644
--- a/libnautilus-private/nautilus-link-desktop-file.h
+++ b/libnautilus-private/nautilus-link-desktop-file.h
@@ -33,17 +33,12 @@ gboolean nautilus_link_desktop_file_local_create (c
const char *image,
const char *target_uri,
const GdkPoint *point,
- int screen,
- NautilusLinkType type);
-gboolean nautilus_link_desktop_file_local_set_icon (const char *uri,
- const char *icon_name);
+ int screen);
gboolean nautilus_link_desktop_file_local_set_text (const char *uri,
const char *text);
char * nautilus_link_desktop_file_local_get_text (const char *uri);
char * nautilus_link_desktop_file_local_get_additional_text (const char *uri);
-NautilusLinkType nautilus_link_desktop_file_local_get_link_type (const char *uri);
char * nautilus_link_desktop_file_local_get_link_uri (const char *uri);
-gboolean nautilus_link_desktop_file_local_is_utf8 (const char *uri);
void nautilus_link_desktop_file_get_link_info_given_file_contents (const char *file_contents,
int link_file_size,
char **uri,
diff --git a/libnautilus-private/nautilus-link-historical.c b/libnautilus-private/nautilus-link-historical.c
deleted file mode 100644
index af71514bb..000000000
--- a/libnautilus-private/nautilus-link-historical.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/* -*- 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-historical.h"
-
-#include "nautilus-directory-notify.h"
-#include "nautilus-directory.h"
-#include "nautilus-file-attributes.h"
-#include "nautilus-file.h"
-#include "nautilus-file-utilities.h"
-#include "nautilus-global-preferences.h"
-#include "nautilus-metadata.h"
-#include "nautilus-program-choosing.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-preferences.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 <libxml/parser.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnome/gnome-util.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_uri,
- const char *name,
- const char *image,
- const char *target_uri,
- const GdkPoint *point,
- NautilusLinkType type)
-{
- xmlDocPtr output_document;
- xmlNodePtr root_node;
- char *directory_path, *path;
- int result;
- char *uri;
- GList dummy_list;
- NautilusFileChangesQueuePosition item;
-
-
- g_return_val_if_fail (directory_uri != 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 */
- directory_path = gnome_vfs_get_local_path_from_uri (directory_uri);
- if (directory_uri == NULL) {
- xmlFreeDoc (output_document);
- return FALSE;
- }
-
- path = g_build_filename (directory_path, name, NULL);
- g_free (directory_path);
-
- 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 *uri,
- const char *key)
-{
- GnomeVFSFileInfo *info;
- char *path;
- GnomeVFSResult result;
- gboolean is_link;
- xmlDoc *document;
- char *property;
-
- /* Check mime type. Exit if it is not a nautilus link */
-
- info = gnome_vfs_file_info_new ();
-
- result = gnome_vfs_get_file_info (uri, info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-
- is_link = result == GNOME_VFS_OK
- && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) != 0
- && g_ascii_strcasecmp (info->mime_type, "application/x-nautilus-link") == 0;
-
- gnome_vfs_file_info_unref (info);
-
- if (!is_link) {
- return NULL;
- }
-
- path = gnome_vfs_get_local_path_from_uri (uri);
- if (path == NULL) {
- return NULL;
- }
-
- document = xmlParseFile (path);
- g_free (path);
-
- if (document == NULL) {
- return 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);
- if (path == NULL) {
- return FALSE;
- }
- document = xmlParseFile (path);
- if (document == NULL) {
- g_free (path);
- return FALSE;
- }
- root = xmlDocGetRootElement (document);
- if (root == NULL) {
- xmlFreeDoc (document);
- g_free (path);
- return FALSE;
- }
-
- /* Check if the property value is already correct. */
- old_value = xmlGetProp (root, key);
- if (old_value != NULL && strcmp (old_value, value) == 0) {
- xmlFree (old_value);
- xmlFreeDoc (document);
- g_free (path);
- 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 *uri, const char *icon_name)
-{
- return local_set_root_property (uri,
- 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 *uri, const char *link_uri)
-{
- return local_set_root_property (uri,
- "link",
- link_uri,
- NULL);
-}
-
-gboolean
-nautilus_link_historical_local_set_type (const char *uri, NautilusLinkType type)
-{
- return local_set_root_property (uri,
- "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 *uri)
-{
- return local_get_root_property
- (uri, NAUTILUS_METADATA_KEY_EXTRA_TEXT);
-}
-
-
-/* Returns the link uri associated with a link file. */
-char *
-nautilus_link_historical_local_get_link_uri (const char *uri)
-{
- return local_get_root_property (uri, "link");
-}
-
-/* Returns the link type of the link file. */
-NautilusLinkType
-nautilus_link_historical_local_get_link_type (const char *uri)
-{
- char *property;
- NautilusLinkType type;
-
- property = local_get_root_property (uri, "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;
-}
-
-void
-nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopItem *entry, const char *dest_uri, const GdkPoint *position)
-{
- char *icon_name, *icon;
- char *launch_string, *terminal_command;
- const char *name, *arguments;
-
- if (entry == NULL || dest_uri == NULL) {
- return;
- }
-
- name = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_NAME);
- arguments = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_EXEC);
-
- switch (gnome_desktop_item_get_entry_type (entry)) {
- case GNOME_DESKTOP_ITEM_TYPE_APPLICATION:
- if (gnome_desktop_item_get_boolean (entry, GNOME_DESKTOP_ITEM_TERMINAL)) {
- terminal_command = eel_gnome_make_terminal_command (arguments);
- launch_string = g_strconcat (NAUTILUS_COMMAND_SPECIFIER, terminal_command, NULL);
- g_free (terminal_command);
- } else {
- launch_string = g_strconcat (NAUTILUS_COMMAND_SPECIFIER, arguments, NULL);
- }
- break;
- case GNOME_DESKTOP_ITEM_TYPE_LINK:
- launch_string = g_strdup (arguments);
- break;
- default:
- /* Unknown .desktop file type */
- launch_string = NULL;
- }
-
-
- icon = gnome_desktop_item_get_icon (entry, NULL);
- if (icon != NULL) {
- icon_name = eel_make_uri_from_half_baked_uri (icon);
- g_free (icon);
- } else {
- icon_name = g_strdup ("gnome-unknown.png");
- }
-
- if (launch_string != NULL) {
- nautilus_link_historical_local_create (dest_uri, name, icon_name,
- launch_string, position, NAUTILUS_LINK_GENERIC);
- }
-
- g_free (icon_name);
- g_free (launch_string);
-}
diff --git a/libnautilus-private/nautilus-link-historical.h b/libnautilus-private/nautilus-link-historical.h
deleted file mode 100644
index 79c7147ce..000000000
--- a/libnautilus-private/nautilus-link-historical.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- 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 <libnautilus-private/nautilus-link.h>
-
-gboolean nautilus_link_historical_local_create (const char *directory_uri,
- const char *name,
- const char *image,
- const char *target_uri,
- const GdkPoint *point,
- NautilusLinkType type);
-gboolean nautilus_link_historical_local_set_icon (const char *uri,
- 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 *uri,
- const char *target_uri);
-char * nautilus_link_historical_local_get_additional_text (const char *path);
-NautilusLinkType nautilus_link_historical_local_get_link_type (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 (GnomeDesktopItem *entry,
- const char *dest_path,
- const GdkPoint *position);
-
-#endif /* NAUTILUS_LINK_HISTORICAL_H */
diff --git a/libnautilus-private/nautilus-link.c b/libnautilus-private/nautilus-link.c
index c66b9db1d..199536b4e 100644
--- a/libnautilus-private/nautilus-link.c
+++ b/libnautilus-private/nautilus-link.c
@@ -24,7 +24,6 @@
#include <config.h>
#include "nautilus-link.h"
-#include "nautilus-link-historical.h"
#include "nautilus-link-desktop-file.h"
#include "nautilus-directory-notify.h"
@@ -48,31 +47,28 @@
#include <libgnomevfs/gnome-vfs-utils.h>
#include <stdlib.h>
-typedef enum {
- not_link,
- historical,
- desktop
-} LinkStyle;
+/* NOTE: This is pretty ugly.
+ * We once supported another type of link, "historical" links, which were xml files.
+ * I've now removed that code, but that makes this file sort of unnecessary, and we
+ * could clean up the code a lot since we know we're dealing with desktop files.
+ */
-static LinkStyle
-get_link_style_for_mime_type (const char *mime_type)
+static gboolean
+is_link_mime_type (const char *mime_type)
{
- if (mime_type != NULL) {
- if (g_ascii_strcasecmp (mime_type, "application/x-gnome-app-info") == 0 ||
- g_ascii_strcasecmp (mime_type, "application/x-desktop") == 0) {
- return desktop;
- }
- if (g_ascii_strcasecmp (mime_type, "application/x-nautilus-link") == 0) {
- return historical;
- }
+ if (mime_type != NULL &&
+ (g_ascii_strcasecmp (mime_type, "application/x-gnome-app-info") == 0 ||
+ g_ascii_strcasecmp (mime_type, "application/x-desktop") == 0)) {
+ return TRUE;
}
- return not_link;
+
+ return FALSE;
}
-static LinkStyle
-get_link_style_for_local_file (const char *uri, GnomeVFSFileInfo *opt_info)
+static gboolean
+is_local_file_a_link (const char *uri, GnomeVFSFileInfo *opt_info)
{
- LinkStyle type;
+ gboolean link;
GnomeVFSResult result;
GnomeVFSFileInfo *info;
@@ -89,160 +85,59 @@ get_link_style_for_local_file (const char *uri, GnomeVFSFileInfo *opt_info)
}
if (info && info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) {
- type = get_link_style_for_mime_type (info->mime_type);
+ link = is_link_mime_type (info->mime_type);
} else {
- type = not_link;
+ link = FALSE;
}
if (!opt_info && info)
gnome_vfs_file_info_unref (info);
- return type;
+ return link;
}
-static LinkStyle
-get_link_style_for_data (const char *file_contents, int file_size)
+static gboolean
+is_link_data (const char *file_contents, int file_size)
{
- return get_link_style_for_mime_type
+ return is_link_mime_type
(gnome_vfs_get_mime_type_for_data (file_contents, file_size));
}
gboolean
nautilus_link_local_create (const char *directory_uri,
- const char *file_name,
- const char *display_name,
+ const char *file_name,
+ const char *display_name,
const char *image,
const char *target_uri,
const GdkPoint *point,
- int screen,
- NautilusLinkType type)
+ int screen)
{
return nautilus_link_desktop_file_local_create (directory_uri,
file_name,
display_name, image,
target_uri,
- point, screen,
- type);
-}
-
-gboolean
-nautilus_link_local_set_icon (const char *uri, const char *icon_name)
-{
- gboolean result;
- NautilusFile *file;
-
- switch (get_link_style_for_local_file (uri, NULL)) {
- case desktop:
- result = nautilus_link_desktop_file_local_set_icon (uri, icon_name);
- break;
- case historical:
- result = nautilus_link_historical_local_set_icon (uri, icon_name);
- break;
- default:
- result = FALSE;
- }
-
- file = nautilus_file_get (uri);
- nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
- nautilus_file_unref (file);
-
- return result;
-}
-
-gboolean
-nautilus_link_local_set_link_uri (const char *uri, const char *link_uri)
-{
- gboolean result;
- NautilusFile *file;
-
- switch (get_link_style_for_local_file (uri, NULL)) {
- case desktop:
- /* FIXME: May want to implement this for desktop files too */
- result = FALSE;
- break;
- case historical:
- result = nautilus_link_historical_local_set_link_uri (uri, link_uri);
- break;
- default:
- result = FALSE;
- }
-
-
- file = nautilus_file_get (uri);
- nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
- nautilus_file_unref (file);
-
- return result;
-}
-
-gboolean
-nautilus_link_local_set_type (const char *uri,
- NautilusLinkType type)
-{
- switch (get_link_style_for_local_file (uri, NULL)) {
- case desktop:
- /* FIXME: May want to implement this for desktop files too */
- return FALSE;
- case historical:
- return nautilus_link_historical_local_set_type (uri, type);
- default:
- return FALSE;
- }
+ point, screen);
}
/* returns additional text to display under the name, NULL if none */
char *
nautilus_link_local_get_additional_text (const char *uri)
{
- switch (get_link_style_for_local_file (uri, NULL)) {
- case desktop:
- return nautilus_link_desktop_file_local_get_additional_text (uri);
- case historical:
- return nautilus_link_historical_local_get_additional_text (uri);
- default:
+ if (!is_local_file_a_link (uri, NULL)) {
return NULL;
}
+
+ return nautilus_link_desktop_file_local_get_additional_text (uri);
}
/* Returns the link uri associated with a link file. */
char *
nautilus_link_local_get_link_uri (const char *uri)
{
- switch (get_link_style_for_local_file (uri, NULL)) {
- case desktop:
- return nautilus_link_desktop_file_local_get_link_uri (uri);
- case historical:
- return nautilus_link_historical_local_get_link_uri (uri);
- default:
+ if (!is_local_file_a_link (uri, NULL)) {
return NULL;
}
-}
-
-/* Returns the link type of the link file. */
-NautilusLinkType
-nautilus_link_local_get_link_type (const char *uri, GnomeVFSFileInfo *info)
-{
- switch (get_link_style_for_local_file (uri, info)) {
- case desktop:
- return nautilus_link_desktop_file_local_get_link_type (uri);
- case historical:
- return nautilus_link_historical_local_get_link_type (uri);
- default:
- return NAUTILUS_LINK_GENERIC;
- }
-}
-
-gboolean
-nautilus_link_local_is_utf8 (const char *uri,
- GnomeVFSFileInfo *info)
-{
- switch (get_link_style_for_local_file (uri, info)) {
- case desktop:
- return nautilus_link_desktop_file_local_is_utf8 (uri);
- case historical:
- default:
- return FALSE;
- }
+ return nautilus_link_desktop_file_local_get_link_uri (uri);
}
void
@@ -260,53 +155,9 @@ nautilus_link_get_link_info_given_file_contents (const char *file_contents
*drive_id = 0;
*volume_id = 0;
- switch (get_link_style_for_data (file_contents, link_file_size)) {
- case desktop:
+ if (is_link_data (file_contents, link_file_size)) {
nautilus_link_desktop_file_get_link_info_given_file_contents (file_contents, link_file_size, uri, name, icon, drive_id, volume_id);
- break;
- case historical:
- *uri = nautilus_link_historical_get_link_uri_given_file_contents (file_contents, link_file_size);
- *icon = nautilus_link_historical_get_link_icon_given_file_contents (file_contents, link_file_size);
- break;
- default:
- return;
- }
-}
-
-gboolean
-nautilus_link_local_is_volume_link (const char *uri, GnomeVFSFileInfo *info)
-{
- return (nautilus_link_local_get_link_type (uri, info) == NAUTILUS_LINK_MOUNT);
-}
-
-gboolean
-nautilus_link_local_is_home_link (const char *uri, GnomeVFSFileInfo *info)
-{
- return (nautilus_link_local_get_link_type (uri, info) == NAUTILUS_LINK_HOME);
-}
-
-gboolean
-nautilus_link_local_is_trash_link (const char *uri, GnomeVFSFileInfo *info)
-{
- return (nautilus_link_local_get_link_type (uri, info) == NAUTILUS_LINK_TRASH);
-}
-
-gboolean
-nautilus_link_local_is_special_link (const char *uri)
-{
- switch (nautilus_link_local_get_link_type (uri, NULL)) {
- case NAUTILUS_LINK_HOME:
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
- return FALSE;
- }
- case NAUTILUS_LINK_TRASH:
- case NAUTILUS_LINK_MOUNT:
- return TRUE;
- case NAUTILUS_LINK_GENERIC:
- return FALSE;
}
-
- return FALSE;
}
void
diff --git a/libnautilus-private/nautilus-link.h b/libnautilus-private/nautilus-link.h
index cb325a454..71741e1bb 100644
--- a/libnautilus-private/nautilus-link.h
+++ b/libnautilus-private/nautilus-link.h
@@ -30,14 +30,6 @@
#include <libgnome/gnome-desktop-item.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
-/* Link types */
-typedef enum {
- NAUTILUS_LINK_GENERIC,
- NAUTILUS_LINK_TRASH,
- NAUTILUS_LINK_MOUNT,
- NAUTILUS_LINK_HOME
-} NautilusLinkType;
-
/* Create a new link file. Takes a path, works locally, and uses sync. I/O.
* Returns TRUE if it succeeds, FALSE if it fails.
*/
@@ -47,31 +39,7 @@ gboolean nautilus_link_local_create (const char
const char *image,
const char *target_uri,
const GdkPoint *point,
- int screen,
- NautilusLinkType type);
-
-/* Change the icon of an existing link file. Takes a path, works
- * locally, and uses sync. I/O. Returns TRUE if it succeeds, FALSE if
- * it fails. Does not check and see if it is a link file.
- */
-gboolean nautilus_link_local_set_icon (const char *uri,
- const char *icon_name);
-
-/* Specify the type of link that is represented
- * Takes a path, works locally, and uses sync. I/O.
- * Returns TRUE if it succeeds, FALSE if
- * it fails. Does not check and see if it is a link file.
- */
-gboolean nautilus_link_local_set_type (const char *uri,
- NautilusLinkType type);
-
-/* Specify the link uri of link that is represented
- * Takes a path, works locally, and uses sync. I/O.
- * Returns TRUE if it succeeds, FALSE if
- * it fails. Does not check and see if it is a link file.
- */
-gboolean nautilus_link_local_set_link_uri (const char *uri,
- const char *targeturi);
+ int screen);
/* Returns additional text to display under the name, NULL if
* none. Despite the fact that it takes a URI parameter, works only if
@@ -79,42 +47,7 @@ gboolean nautilus_link_local_set_link_uri (const char
*/
char * nautilus_link_local_get_additional_text (const char *uri);
-/* Returns the link type of a link file.
- * Works only if the file is local and does sync. I/O
- */
-NautilusLinkType nautilus_link_local_get_link_type (const char *uri,
- GnomeVFSFileInfo *info);
-
-/* Returns if a link is a mount link.
- * the Mime type field is neccessary for correct detection.
- */
-gboolean nautilus_link_local_is_volume_link (const char *uri,
- GnomeVFSFileInfo *info);
-
-/* Returns if a link is a home link.
- * the Mime type field is neccessary for correct detection.
- */
-gboolean nautilus_link_local_is_home_link (const char *uri,
- GnomeVFSFileInfo *info);
-
-/* Returns if a link is a trash link.
- * the Mime type field is neccessary for correct detection.
- */
-gboolean nautilus_link_local_is_trash_link (const char *uri,
- GnomeVFSFileInfo *info);
-
-/* Returns TRUE if the link is special (i.e. can NOT be copied or deleted), FALSE otherwise.
- * Works only if the file is local and does sync. I/O
- */
-gboolean nautilus_link_local_is_special_link (const char *uri);
-
-
-/* Returns TRUE if the link is encoded in utf8
- * Works only if the file is local and does sync. I/O
- */
-gboolean nautilus_link_local_is_utf8 (const char *uri,
- GnomeVFSFileInfo *info);
/* Returns the link uri associated with a link file. The first version
* works only if the file is local and does sync. I/O, despite the