diff options
-rw-r--r-- | libnautilus-private/Makefile.am | 4 | ||||
-rw-r--r-- | libnautilus-private/nautilus.convert | 47 | ||||
-rw-r--r-- | src/Makefile.am | 9 | ||||
-rw-r--r-- | src/nautilus-application.c | 56 | ||||
-rw-r--r-- | src/nautilus-convert-metadata.c | 337 |
5 files changed, 0 insertions, 453 deletions
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 92c601451..774cd77f4 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -191,15 +191,11 @@ gsettingsschema_in_files = org.gnome.nautilus.gschema.xml.in gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml) .PRECIOUS: $(gsettings_SCHEMAS) -convertdir = $(datadir)/GConf/gsettings -convert_DATA = nautilus.convert - @INTLTOOL_XML_NOMERGE_RULE@ @GSETTINGS_RULES@ EXTRA_DIST = \ - nautilus.convert \ $(gsettingsschema_in_files) \ $(TRACKER_SOURCES) \ nautilus-private-enum-types.h.template \ diff --git a/libnautilus-private/nautilus.convert b/libnautilus-private/nautilus.convert deleted file mode 100644 index 4784f796a..000000000 --- a/libnautilus-private/nautilus.convert +++ /dev/null @@ -1,47 +0,0 @@ -[org.gnome.nautilus.preferences] -tabs-open-position = /desktop/gnome/file_views/tabs_open_position -always-use-location-entry = /apps/nautilus/preferences/always_use_location_entry -confirm-trash = /apps/nautilus/preferences/confirm_trash -show-directory-item-counts = /apps/nautilus/preferences/show_directory_item_counts -click-policy = /apps/nautilus/preferences/click_policy -executable-text-activation = /apps/nautilus/preferences/executable_text_activation -install-mime-activation = /apps/nautilus/preferences/install_mime_activation -mouse-use-extra-buttons = /apps/nautilus/preferences/mouse_use_extra_buttons -mouse-forward-button = /apps/nautilus/preferences/mouse_forward_button -mouse-back-button = /apps/nautilus/preferences/mouse_back_button -show-image-thumbnails = /apps/nautilus/preferences/show_image_thumbnails -thumbnail-limit = /apps/nautilus/preferences/thumbnail_limit -sort-directories-first = /apps/nautilus/preferences/sort_directories_first -default-sort-order = /apps/nautilus/icon_view/default_sort_order -default-sort-in-reverse-order = /apps/nautilus/icon_view/default_sort_in_reverse_order -default-folder-viewer = /apps/nautilus/preferences/default_folder_viewer -show-hidden-files = /desktop/gnome/file_views/show_hidden_files - -[org.gnome.nautilus.icon-view] -captions = /apps/nautilus/icon_view/captions -default-zoom-level = /apps/nautilus/icon_view/default_zoom_level -thumbnail-size = /apps/nautilus/icon_view/thumbnail_size -text-ellipsis-limit = /apps/nautilus/icon_view/text_ellipsis_limit - -[org.gnome.nautilus.list-view] -default-zoom-level = /apps/nautilus/list_view/default_zoom_level -default-visible-columns = /apps/nautilus/list_view/default_visible_columns -default-column-order = /apps/nautilus/list_view/default_column_order - -[org.gnome.nautilus.desktop] -font = /apps/nautilus/preferences/desktop_font -home-icon-visible = /apps/nautilus/desktop/home_icon_visible -trash-icon-visible = /apps/nautilus/desktop/trash_icon_visible -volumes-visible = /apps/nautilus/desktop/volumes_visible -network-icon-visible = /apps/nautilus/desktop/network_icon_visible -home-icon-name = /apps/nautilus/desktop/home_icon_name -trash-icon-name = /apps/nautilus/desktop/trash_icon_name -network-icon-name = /apps/nautilus/desktop/network_icon_name -text-ellipsis-limit = /apps/nautilus/desktop/text_ellipsis_limit - -[org.gnome.nautilus.window-state] -geometry = /apps/nautilus/preferences/navigation_window_saved_geometry -maximized = /apps/nautilus/preferences/navigation_window_saved_maximized -sidebar-width = /apps/nautilus/preferences/sidebar_width -start-with-location-bar = /apps/nautilus/preferences/start_with_location_bar -start-with-sidebar = /apps/nautilus/preferences/start_with_sidebar diff --git a/src/Makefile.am b/src/Makefile.am index f631b7fbe..44f978061 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,10 +5,6 @@ bin_PROGRAMS= \ nautilus-autorun-software \ $(NULL) -libexec_PROGRAMS= \ - nautilus-convert-metadata \ - $(NULL) - AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/libnautilus-private \ @@ -22,7 +18,6 @@ AM_CPPFLAGS = \ $(EXEMPI_CFLAGS) \ -DDATADIR=\""$(datadir)"\" \ -DLIBDIR=\""$(libdir)"\" \ - -DLIBEXECDIR=\""$(libexecdir)"\" \ -DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \ -DPREFIX=\""$(prefix)"\" \ -DVERSION="\"$(VERSION)\"" \ @@ -243,10 +238,6 @@ nautilus_autorun_software_SOURCES= \ nautilus-autorun-software.c \ $(NULL) -nautilus_convert_metadata_SOURCES= \ - nautilus-convert-metadata.c \ - $(NULL) - BUILT_SOURCES = \ $(nautilus_built_sources) \ $(NULL) diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 260d966a6..cba275c20 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -275,60 +275,6 @@ mark_desktop_files_trusted (void) g_free (do_once_file); } -static void -do_upgrades_once (NautilusApplication *self) -{ - char *metafile_dir, *updated, *nautilus_dir, *xdg_dir; - const gchar *message; - int fd, res; - - mark_desktop_files_trusted (); - - metafile_dir = g_build_filename (g_get_home_dir (), - ".nautilus/metafiles", NULL); - if (g_file_test (metafile_dir, G_FILE_TEST_IS_DIR)) { - updated = g_build_filename (metafile_dir, "migrated-to-gvfs", NULL); - if (!g_file_test (updated, G_FILE_TEST_EXISTS)) { - g_spawn_command_line_async (LIBEXECDIR"/nautilus-convert-metadata --quiet", NULL); - fd = g_creat (updated, 0600); - if (fd != -1) { - close (fd); - } - } - g_free (updated); - } - g_free (metafile_dir); - - nautilus_dir = g_build_filename (g_get_home_dir (), - ".nautilus", NULL); - xdg_dir = nautilus_get_user_directory (); - if (g_file_test (nautilus_dir, G_FILE_TEST_IS_DIR)) { - /* test if we already attempted to migrate first */ - updated = g_build_filename (nautilus_dir, "DEPRECATED-DIRECTORY", NULL); - message = _("Nautilus 3.0 deprecated this directory and tried migrating " - "this configuration to ~/.config/nautilus"); - if (!g_file_test (updated, G_FILE_TEST_EXISTS)) { - /* rename() works fine if the destination directory is - * empty. - */ - res = g_rename (nautilus_dir, xdg_dir); - - if (res == -1) { - fd = g_creat (updated, 0600); - if (fd != -1) { - res = write (fd, message, strlen (message)); - close (fd); - } - } - } - - g_free (updated); - } - - g_free (nautilus_dir); - g_free (xdg_dir); -} - NautilusWindow * nautilus_application_create_window (NautilusApplication *application, GdkScreen *screen) @@ -1061,8 +1007,6 @@ nautilus_application_startup (GApplication *app) */ check_required_directories (self); - do_upgrades_once (self); - nautilus_init_application_actions (self); init_desktop (self); diff --git a/src/nautilus-convert-metadata.c b/src/nautilus-convert-metadata.c deleted file mode 100644 index 88c926698..000000000 --- a/src/nautilus-convert-metadata.c +++ /dev/null @@ -1,337 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-convert-metadata.c - Convert old metadata format to gvfs metadata. - * - * Copyright (C) 2009 Alexander Larsson - * - * Nautilus 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. - * - * Nautilus 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; see the file COPYING. If not, - * see <http://www.gnu.org/licenses/>. - * - * Authors: - * Alexander Larsson <alexl@redhat.com> - */ - -#include <config.h> - -#include <glib.h> -#include <gio/gio.h> -#include <glib/gi18n.h> -#include <string.h> -#include <libxml/tree.h> - -#include <libnautilus-private/nautilus-metadata.h> - -static gboolean quiet = FALSE; - -static xmlNodePtr -xml_get_children (xmlNodePtr parent) -{ - if (parent == NULL) { - return NULL; - } - return parent->children; -} - -static xmlNodePtr -xml_get_root_children (xmlDocPtr document) -{ - return xml_get_children (xmlDocGetRootElement (document)); -} - - -static char * -get_uri_from_nautilus_metafile_name (const char *filename) -{ - GString *s; - char c; - char *base_name, *p; - int len; - - base_name = g_path_get_basename (filename); - len = strlen (base_name); - if (len <= 4 || - strcmp (base_name + len - 4, ".xml") != 0) { - g_free (base_name); - return NULL; - } - base_name[len-4] = 0; - - s = g_string_new (NULL); - - p = base_name; - while (*p) { - c = *p++; - if (c == '%') { - c = g_ascii_xdigit_value (p[0]) << 4 | - g_ascii_xdigit_value (p[1]); - p += 2; - } - g_string_append_c (s, c); - } - g_free (base_name); - - return g_string_free (s, FALSE); -} - -static struct { - const char *old_key; - const char *new_key; -} metadata_keys[] = { - {"background_color", "metadata::" NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR}, - {"background_tile_image", "metadata::" NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE}, - {"icon_view_auto_layout", "metadata::" NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT}, - {"icon_view_sort_by", "metadata::" NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY}, - {"icon_view_sort_reversed", "metadata::" NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED}, - {"icon_view_keep_aligned", "metadata::" NAUTILUS_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED}, - {"icon_view_layout_timestamp", "metadata::" NAUTILUS_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP}, - {"list_view_sort_column", "metadata::" NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN}, - {"list_view_sort_reversed", "metadata::" NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED}, - {"list_view_visible_columns", "metadata::" NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS}, - {"list_view_column_order", "metadata::" NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER}, - {"window_geometry", "metadata::" NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY}, - {"window_scroll_position", "metadata::" NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION}, - {"window_show_hidden_files", "metadata::" NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES}, - {"window_maximized", "metadata::" NAUTILUS_METADATA_KEY_WINDOW_MAXIMIZED}, - {"window_sticky", "metadata::" NAUTILUS_METADATA_KEY_WINDOW_STICKY}, - {"window_keep_above", "metadata::" NAUTILUS_METADATA_KEY_WINDOW_KEEP_ABOVE}, - {"sidebar_background_color", "metadata::" NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR}, - {"sidebar_background_tile_image", "metadata::" NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE}, - {"sidebar_buttons", "metadata::" NAUTILUS_METADATA_KEY_SIDEBAR_BUTTONS}, - {"annotation", "metadata::" NAUTILUS_METADATA_KEY_ANNOTATION}, - {"icon_position", "metadata::" NAUTILUS_METADATA_KEY_ICON_POSITION}, - {"icon_position_timestamp", "metadata::" NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP}, - {"icon_scale", "metadata::" NAUTILUS_METADATA_KEY_ICON_SCALE}, - {"custom_icon", "metadata::" NAUTILUS_METADATA_KEY_CUSTOM_ICON}, - {"screen", "metadata::" NAUTILUS_METADATA_KEY_SCREEN}, - {"keyword", "metadata::" NAUTILUS_METADATA_KEY_EMBLEMS}, -}; - -static const char * -convert_key_name (const char *old_key) -{ - int i; - - for (i = 0; i < G_N_ELEMENTS (metadata_keys); i++) { - if (strcmp (metadata_keys[i].old_key, old_key) == 0) { - return metadata_keys[i].new_key; - } - } - - return NULL; -} - -static void -parse_xml_node (GFile *file, - xmlNodePtr filenode) -{ - xmlNodePtr node; - xmlAttrPtr attr; - xmlChar *property; - const char *new_key; - GHashTable *list_keys; - GList *keys, *l; - GHashTableIter iter; - GFileInfo *info; - int i; - char **strv; - GError *error; - - info = g_file_info_new (); - - for (attr = filenode->properties; attr != NULL; attr = attr->next) { - if (strcmp ((char *)attr->name, "name") == 0 || - strcmp ((char *)attr->name, "timestamp") == 0) { - continue; - } - - new_key = convert_key_name ((const gchar *) attr->name); - if (new_key) { - property = xmlGetProp (filenode, attr->name); - if (property) { - g_file_info_set_attribute_string (info, - new_key, - (const gchar *) property); - xmlFree (property); - } - } - } - - list_keys = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); - for (node = filenode->children; node != NULL; node = node->next) { - for (attr = node->properties; attr != NULL; attr = attr->next) { - new_key = convert_key_name ((const gchar *) node->name); - if (new_key) { - property = xmlGetProp (node, attr->name); - if (property) { - keys = g_hash_table_lookup (list_keys, new_key); - keys = g_list_append (keys, property); - g_hash_table_replace (list_keys, (char *)new_key, keys); - } - } - } - } - - g_hash_table_iter_init (&iter, list_keys); - while (g_hash_table_iter_next (&iter, (void **)&new_key, (void **)&keys)) { - strv = g_new0 (char *, g_list_length (keys) + 1); - - for (l = keys, i = 0; l != NULL; l = l->next, i++) { - strv[i] = l->data; - } - g_file_info_set_attribute_stringv (info, - new_key, - strv); - g_free (strv); - g_list_foreach (keys, (GFunc)xmlFree, NULL); - g_list_free (keys); - } - g_hash_table_destroy (list_keys); - - if (info) { - error = NULL; - if (!g_file_set_attributes_from_info (file, - info, - 0, NULL, &error)) { - char *uri; - - uri = g_file_get_uri (file); - if (!quiet) { - g_print ("error setting info for %s: %s\n", uri, error->message); - } - g_free (uri); - g_error_free (error); - } - g_object_unref (info); - } -} - -static void -convert_xml_file (xmlDocPtr xml, - GFile *dir) -{ - xmlNodePtr node; - xmlChar *name; - char *unescaped_name; - GFile *file; - - for (node = xml_get_root_children (xml); - node != NULL; node = node->next) { - if (strcmp ((char *)node->name, "file") == 0) { - name = xmlGetProp (node, (xmlChar *)"name"); - unescaped_name = g_uri_unescape_string ((char *)name, "/"); - xmlFree (name); - - if (unescaped_name == NULL) { - continue; - } - - if (strcmp (unescaped_name, ".") == 0) { - file = g_object_ref (dir); - } else { - file = g_file_get_child (dir, unescaped_name); - } - - parse_xml_node (file, node); - g_object_unref (file); - g_free (unescaped_name); - } - } -} - -static void -convert_nautilus_file (char *file) -{ - GFile *dir; - char *uri; - gchar *contents; - gsize length; - xmlDocPtr xml; - - if (!g_file_get_contents (file, &contents, &length, NULL)) { - if (!quiet) { - g_print ("failed to load %s\n", file); - } - return; - } - - uri = get_uri_from_nautilus_metafile_name (file); - if (uri == NULL) { - g_free (contents); - return; - } - - dir = g_file_new_for_uri (uri); - g_free (uri); - - xml = xmlParseMemory (contents, length); - g_free (contents); - if (xml == NULL) { - return; - } - - convert_xml_file (xml, dir); - xmlFreeDoc (xml); -} - -static GOptionEntry entries[] = -{ - { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, - "Don't show errors", NULL }, - { NULL } -}; - -int -main (int argc, char *argv[]) -{ - GOptionContext *context; - GError *error = NULL; - int i; - - context = g_option_context_new ("<nautilus metadata files> - convert nautilus metadata"); - g_option_context_add_main_entries (context, entries, NULL); - if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_printerr ("option parsing failed: %s\n", error->message); - return 1; - } - - if (argc < 2) { - GDir *dir; - char *metafile_dir; - char *file; - const char *entry; - - /* Convert all metafiles */ - - metafile_dir = g_build_filename (g_get_home_dir (), - ".nautilus/metafiles", NULL); - - dir = g_dir_open (metafile_dir, 0, NULL); - if (dir) { - while ((entry = g_dir_read_name (dir)) != NULL) { - file = g_build_filename (metafile_dir, entry, NULL); - if (g_str_has_suffix (file, ".xml")) - convert_nautilus_file (file); - g_free (file); - } - g_dir_close (dir); - } - g_free (metafile_dir); - } else { - for (i = 1; i < argc; i++) { - convert_nautilus_file (argv[i]); - } - } - - return 0; -} |