summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2004-01-06 17:54:18 +0000
committerAlexander Larsson <alexl@src.gnome.org>2004-01-06 17:54:18 +0000
commit79ef6c260152725bbce47ce09143b7dd3387a9a6 (patch)
treed02f7cf5527d85bd6d4c9fa5250dddc21df80e6e /components
parent8e22b0c58533aa63eec9882c0c63b2b4ff588457 (diff)
downloadnautilus-79ef6c260152725bbce47ce09143b7dd3387a9a6.tar.gz
Patch from: Juerg Billeter <j@bitron.ch>
2004-01-06 Alexander Larsson <alexl@redhat.com> Patch from: Juerg Billeter <j@bitron.ch> * components/Makefile.am: * components/tree/ Remove tree component (moved to file-manager) * src/Nautilus_shell.server.in: * src/file-manager/Makefile.am: Move tree view here * src/nautilus-application.c: Tree view activation * src/file-manager/fm-properties-window.[ch]: * src/file-manager/fm-directory-view.c: Make properties window take GtkWidget instead of DirectoryView. * src/file-manager/fm-tree-model.[ch]: * src/file-manager/fm-tree-view.[ch]: Move tree view here, first cut at popup menus
Diffstat (limited to 'components')
-rw-r--r--components/Makefile.am1
-rw-r--r--components/tree/Makefile.am41
-rw-r--r--components/tree/Nautilus_View_tree.server.in.in15
-rw-r--r--components/tree/libmain.c85
-rw-r--r--components/tree/nautilus-tree-model.c1797
-rw-r--r--components/tree/nautilus-tree-model.h88
-rw-r--r--components/tree/nautilus-tree-view-iids.h32
-rw-r--r--components/tree/nautilus-tree-view.c743
-rw-r--r--components/tree/nautilus-tree-view.h53
9 files changed, 0 insertions, 2855 deletions
diff --git a/components/Makefile.am b/components/Makefile.am
index 6702f6536..01670366f 100644
--- a/components/Makefile.am
+++ b/components/Makefile.am
@@ -6,7 +6,6 @@ SUBDIRS = \
notes \
text \
throbber \
- tree \
emblem \
image_properties \
$(NULL)
diff --git a/components/tree/Makefile.am b/components/tree/Makefile.am
deleted file mode 100644
index 2a04acf19..000000000
--- a/components/tree/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-NULL =
-
-INCLUDES = \
- -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
- -DG_LOG_DOMAIN=\"Nautilus-Tree\" \
- -I$(top_srcdir) \
- $(DISABLE_DEPRECATED_CFLAGS) \
- $(COMPONENT_CFLAGS) \
- $(NULL)
-
-TREE_VIEW_COMMON_SOURCES = \
- nautilus-tree-model.c \
- nautilus-tree-model.h \
- nautilus-tree-view.c \
- nautilus-tree-view.h \
- nautilus-tree-view-iids.h \
- $(NULL)
-
-bonobodir = $(libdir)/bonobo
-bonobo_LTLIBRARIES = libnautilus-tree-view.la
-
-libnautilus_tree_view_la_SOURCES = $(TREE_VIEW_COMMON_SOURCES) libmain.c
-
-libnautilus_tree_view_la_LDFLAGS = -module -avoid-version -no-undefined
-
-libnautilus_tree_view_la_LIBADD = \
- $(top_builddir)/libnautilus/libnautilus.la \
- $(top_builddir)/libnautilus-private/libnautilus-private.la \
- $(COMPONENT_LIBS)
- $(NULL)
-
-server_in_files = Nautilus_View_tree.server.in.in
-
-serverdir = $(libdir)/bonobo/servers
-server_DATA = $(server_in_files:.server.in.in=.server)
-$(server_in_files:.server.in.in=.server.in): $(server_in_files)
- sed -e "s|\@BONOBODIR\@|$(bonobodir)|" $< > $@
-@INTLTOOL_SERVER_RULE@
-
-EXTRA_DIST = $(server_in_files)
-CLEANFILES = $(server_DATA) $(server_DATA).in
diff --git a/components/tree/Nautilus_View_tree.server.in.in b/components/tree/Nautilus_View_tree.server.in.in
deleted file mode 100644
index a9b29cb04..000000000
--- a/components/tree/Nautilus_View_tree.server.in.in
+++ /dev/null
@@ -1,15 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:Nautilus_Tree_View"
- type="shlib" location="@BONOBODIR@/libnautilus-tree-view">
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:Bonobo/Unknown:1.0"/>
- <item value="IDL:Bonobo/Control:1.0"/>
- <item value="IDL:Nautilus/View:1.0"/>
- </oaf_attribute>
- <oaf_attribute name="name" type="string" _value="Nautilus Tree view"/>
- <oaf_attribute name="description" type="string" _value="Nautilus Tree side pane"/>
- <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="Tree"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/components/tree/libmain.c b/components/tree/libmain.c
deleted file mode 100644
index 7f7f4d9c6..000000000
--- a/components/tree/libmain.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 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 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
- */
-
-/* libmain.c - object activation infrastructure for shared library
- version of tree view. */
-
-#include <config.h>
-#include <string.h>
-#include "nautilus-tree-view-iids.h"
-#include "nautilus-tree-view.h"
-#include <bonobo.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include <libnautilus-private/nautilus-bonobo-extensions.h>
-
-static gboolean shortcut_registered = FALSE;
-
-static CORBA_Object
-create_object (const char *iid,
- gpointer callback_data)
-{
- NautilusTreeView *view;
-
- if (strcmp (iid, TREE_VIEW_IID) != 0) {
- return CORBA_OBJECT_NIL;
- }
-
- view = NAUTILUS_TREE_VIEW (g_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
-
- return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
-}
-
-static CORBA_Object
-tree_shlib_make_object (PortableServer_POA poa,
- const char *iid,
- gpointer impl_ptr,
- CORBA_Environment *ev)
-{
- NautilusTreeView *view;
-
- if (!shortcut_registered) {
- nautilus_bonobo_register_activation_shortcut (TREE_VIEW_IID,
- create_object, NULL);
- shortcut_registered = TRUE;
- }
-
- if (strcmp (iid, TREE_VIEW_IID) != 0) {
- return CORBA_OBJECT_NIL;
- }
-
- view = NAUTILUS_TREE_VIEW (g_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
-
- bonobo_activation_plugin_use (poa, impl_ptr);
-
- return CORBA_Object_duplicate (BONOBO_OBJREF (view), ev);
-}
-
-static const BonoboActivationPluginObject tree_plugin_list[] = {
- { TREE_VIEW_IID, tree_shlib_make_object },
- { NULL }
-};
-
-const BonoboActivationPlugin Bonobo_Plugin_info = {
- tree_plugin_list,
- "Nautilus Tree Sidebar Panel"
-};
diff --git a/components/tree/nautilus-tree-model.c b/components/tree/nautilus-tree-model.c
deleted file mode 100644
index fe539fde5..000000000
--- a/components/tree/nautilus-tree-model.c
+++ /dev/null
@@ -1,1797 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright C) 2000, 2001 Eazel, Inc
- * Copyright (C) 2002 Anders Carlsson
- * Copyright (C) 2002 Bent Spoon Software
- *
- * 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: Anders Carlsson <andersca@gnu.org>
- * Darin Adler <darin@bentspoon.com>
- */
-
-/* nautilus-tree-model.c - model for the tree view */
-
-#include <config.h>
-#include "nautilus-tree-model.h"
-
-#include <eel/eel-glib-extensions.h>
-#include <libgnome/gnome-i18n.h>
-#include <libnautilus-private/nautilus-directory.h>
-#include <libnautilus-private/nautilus-file-attributes.h>
-#include <libnautilus-private/nautilus-file.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-#include <string.h>
-
-enum {
- ROW_LOADED,
- LAST_SIGNAL
-};
-
-static guint tree_model_signals[LAST_SIGNAL] = { 0 };
-
-typedef gboolean (* FilePredicate) (NautilusFile *);
-
-/* The user_data of the GtkTreeIter is the TreeNode pointer.
- * It's NULL for the dummy node. If it's NULL, then user_data2
- * is the TreeNode pointer to the parent.
- */
-
-typedef struct TreeNode TreeNode;
-typedef struct NautilusTreeModelRoot NautilusTreeModelRoot;
-
-struct TreeNode {
- /* part of this node for the file itself */
- int ref_count;
-
- NautilusFile *file;
- char *display_name;
- char *icon_name;
- GdkPixbuf *closed_pixbuf;
- GdkPixbuf *open_pixbuf;
-
- NautilusTreeModelRoot *root;
-
- TreeNode *parent;
- TreeNode *next;
- TreeNode *prev;
-
- /* part of the node used only for directories */
- int dummy_child_ref_count;
- int all_children_ref_count;
-
- NautilusDirectory *directory;
- guint done_loading_id;
- guint files_added_id;
- guint files_changed_id;
-
- TreeNode *first_child;
-
- /* misc. flags */
- guint done_loading : 1;
- guint inserting_first_child : 1;
- guint inserted : 1;
-};
-
-struct NautilusTreeModelDetails {
- int stamp;
-
- TreeNode *root_node;
-
- guint monitoring_update_idle_id;
-
- gboolean show_hidden_files;
- gboolean show_backup_files;
- gboolean show_only_directories;
-};
-
-struct NautilusTreeModelRoot {
- NautilusTreeModel *model;
-
- /* separate hash table for each root node needed */
- GHashTable *file_to_node_map;
-
- TreeNode *root_node;
-
- gulong changed_handler_id;
-};
-
-typedef struct {
- NautilusDirectory *directory;
- NautilusTreeModel *model;
-} DoneLoadingParameters;
-
-static GObjectClass *parent_class;
-
-static void schedule_monitoring_update (NautilusTreeModel *model);
-static void destroy_node_without_reporting (NautilusTreeModel *model,
- TreeNode *node);
-static void report_node_contents_changed (NautilusTreeModel *model,
- TreeNode *node);
-
-static guint
-nautilus_tree_model_get_flags (GtkTreeModel *tree_model)
-{
- return GTK_TREE_MODEL_ITERS_PERSIST;
-}
-
-static void
-object_unref_if_not_NULL (gpointer object)
-{
- if (object == NULL) {
- return;
- }
- g_object_unref (object);
-}
-
-static NautilusTreeModelRoot *
-tree_model_root_new (NautilusTreeModel *model)
-{
- NautilusTreeModelRoot *root;
-
- root = g_new0 (NautilusTreeModelRoot, 1);
- root->model = model;
- root->file_to_node_map = g_hash_table_new (NULL, NULL);
-
- return root;
-}
-
-static TreeNode *
-tree_node_new (NautilusFile *file, NautilusTreeModelRoot *root)
-{
- TreeNode *node;
-
- node = g_new0 (TreeNode, 1);
- node->file = nautilus_file_ref (file);
- node->root = root;
- return node;
-}
-
-static void
-tree_node_unparent (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *parent, *next, *prev;
-
- parent = node->parent;
- next = node->next;
- prev = node->prev;
-
- if (parent == NULL &&
- node == model->details->root_node) {
- /* it's the first root node -> if there is a next then let it be the first root node */
- model->details->root_node = next;
- }
-
- if (next != NULL) {
- next->prev = prev;
- }
- if (prev == NULL && parent != NULL) {
- g_assert (parent->first_child == node);
- parent->first_child = next;
- } else if (prev != NULL) {
- prev->next = next;
- }
-
- node->parent = NULL;
- node->next = NULL;
- node->prev = NULL;
- node->root = NULL;
-}
-
-static void
-tree_node_destroy (NautilusTreeModel *model, TreeNode *node)
-{
- g_assert (node->first_child == NULL);
- g_assert (node->ref_count == 0);
-
- tree_node_unparent (model, node);
-
- g_object_unref (node->file);
- g_free (node->display_name);
- g_free (node->icon_name);
- object_unref_if_not_NULL (node->closed_pixbuf);
- object_unref_if_not_NULL (node->open_pixbuf);
-
- g_assert (node->done_loading_id == 0);
- g_assert (node->files_added_id == 0);
- g_assert (node->files_changed_id == 0);
- object_unref_if_not_NULL (node->directory);
-
- g_free (node);
-}
-
-static void
-tree_node_parent (TreeNode *node, TreeNode *parent)
-{
- TreeNode *first_child;
-
- g_assert (parent != NULL);
- g_assert (node->parent == NULL);
- g_assert (node->prev == NULL);
- g_assert (node->next == NULL);
-
- first_child = parent->first_child;
-
- node->parent = parent;
- node->root = parent->root;
- node->next = first_child;
-
- if (first_child != NULL) {
- g_assert (first_child->prev == NULL);
- first_child->prev = node;
- }
-
- parent->first_child = node;
-}
-
-static GdkPixbuf *
-tree_node_get_pixbuf_from_factory (TreeNode *node,
- const char *modifier)
-{
- if (node->parent == NULL) {
- return nautilus_icon_factory_get_pixbuf_from_name
- (node->icon_name, NULL,
- NAUTILUS_ICON_SIZE_FOR_MENUS, NULL);
- }
- return nautilus_icon_factory_get_pixbuf_for_file
- (node->file, modifier, NAUTILUS_ICON_SIZE_FOR_MENUS);
-}
-
-static gboolean
-tree_node_update_pixbuf (TreeNode *node,
- GdkPixbuf **pixbuf_storage,
- const char *modifier)
-{
- GdkPixbuf *pixbuf;
-
- if (*pixbuf_storage == NULL) {
- return FALSE;
- }
- pixbuf = tree_node_get_pixbuf_from_factory (node, modifier);
- if (pixbuf == *pixbuf_storage) {
- g_object_unref (pixbuf);
- return FALSE;
- }
- g_object_unref (*pixbuf_storage);
- *pixbuf_storage = pixbuf;
- return TRUE;
-}
-
-static gboolean
-tree_node_update_closed_pixbuf (TreeNode *node)
-{
- return tree_node_update_pixbuf (node, &node->closed_pixbuf, NULL);
-}
-
-static gboolean
-tree_node_update_open_pixbuf (TreeNode *node)
-{
- return tree_node_update_pixbuf (node, &node->open_pixbuf, "accept");
-}
-
-static gboolean
-tree_node_update_display_name (TreeNode *node)
-{
- char *display_name;
-
- if (node->display_name == NULL) {
- return FALSE;
- }
- /* don't update root node display names */
- if (node->parent == NULL) {
- return FALSE;
- }
- display_name = nautilus_file_get_display_name (node->file);
- if (strcmp (display_name, node->display_name) == 0) {
- g_free (display_name);
- return FALSE;
- }
- g_free (node->display_name);
- node->display_name = NULL;
- return TRUE;
-}
-
-static GdkPixbuf *
-tree_node_get_closed_pixbuf (TreeNode *node)
-{
- if (node->closed_pixbuf == NULL) {
- node->closed_pixbuf = tree_node_get_pixbuf_from_factory (node, NULL);
- }
- return node->closed_pixbuf;
-}
-
-static GdkPixbuf *
-tree_node_get_open_pixbuf (TreeNode *node)
-{
- if (node->open_pixbuf == NULL) {
- node->open_pixbuf = tree_node_get_pixbuf_from_factory (node, "accept");
- }
- return node->open_pixbuf;
-}
-
-static const char *
-tree_node_get_display_name (TreeNode *node)
-{
- if (node->display_name == NULL) {
- node->display_name = nautilus_file_get_display_name (node->file);
- }
- return node->display_name;
-}
-
-static gboolean
-tree_node_has_dummy_child (TreeNode *node)
-{
- return node->directory != NULL
- && (!node->done_loading
- || node->first_child == NULL
- || node->inserting_first_child);
-}
-
-static int
-tree_node_get_child_index (TreeNode *parent, TreeNode *child)
-{
- int i;
- TreeNode *node;
-
- if (child == NULL) {
- g_assert (tree_node_has_dummy_child (parent));
- return 0;
- }
-
- i = tree_node_has_dummy_child (parent) ? 1 : 0;
- for (node = parent->first_child; node != NULL; node = node->next, i++) {
- if (child == node) {
- return i;
- }
- }
-
- g_assert_not_reached ();
- return 0;
-}
-
-static gboolean
-make_iter_invalid (GtkTreeIter *iter)
-{
- iter->stamp = 0;
- iter->user_data = NULL;
- iter->user_data2 = NULL;
- iter->user_data3 = NULL;
- return FALSE;
-}
-
-static gboolean
-make_iter_for_node (TreeNode *node, GtkTreeIter *iter, int stamp)
-{
- if (node == NULL) {
- return make_iter_invalid (iter);
- }
- iter->stamp = stamp;
- iter->user_data = node;
- iter->user_data2 = NULL;
- iter->user_data3 = NULL;
- return TRUE;
-}
-
-static gboolean
-make_iter_for_dummy_row (TreeNode *parent, GtkTreeIter *iter, int stamp)
-{
- g_assert (tree_node_has_dummy_child (parent));
- g_assert (parent != NULL);
- iter->stamp = stamp;
- iter->user_data = NULL;
- iter->user_data2 = parent;
- iter->user_data3 = NULL;
- return TRUE;
-}
-
-static TreeNode *
-get_node_from_file (NautilusTreeModelRoot *root, NautilusFile *file)
-{
- return g_hash_table_lookup (root->file_to_node_map, file);
-}
-
-static TreeNode *
-get_parent_node_from_file (NautilusTreeModelRoot *root, NautilusFile *file)
-{
- NautilusFile *parent_file;
- TreeNode *parent_node;
-
- parent_file = nautilus_file_get_parent (file);
- parent_node = get_node_from_file (root, parent_file);
- nautilus_file_unref (parent_file);
- return parent_node;
-}
-
-static TreeNode *
-create_node_for_file (NautilusTreeModelRoot *root, NautilusFile *file)
-{
- TreeNode *node;
-
- g_assert (get_node_from_file (root, file) == NULL);
- node = tree_node_new (file, root);
- g_hash_table_insert (root->file_to_node_map, node->file, node);
- return node;
-}
-
-#if LOG_REF_COUNTS
-
-static char *
-get_node_uri (GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
- char *parent_uri, *node_uri;
-
- node = iter->user_data;
- if (node != NULL) {
- return nautilus_file_get_uri (node->file);
- }
-
- parent = iter->user_data2;
- parent_uri = nautilus_file_get_uri (parent->file);
- node_uri = g_strconcat (parent_uri, " -- DUMMY", NULL);
- g_free (parent_uri);
- return node_uri;
-}
-
-#endif
-
-static void
-decrement_ref_count (NautilusTreeModel *model, TreeNode *node, int count)
-{
- node->all_children_ref_count -= count;
- if (node->all_children_ref_count == 0) {
- schedule_monitoring_update (model);
- }
-}
-
-static void
-abandon_node_ref_count (NautilusTreeModel *model, TreeNode *node)
-{
- if (node->parent != NULL) {
- decrement_ref_count (model, node->parent, node->ref_count);
-#if LOG_REF_COUNTS
- if (node->ref_count != 0) {
- char *uri;
-
- uri = nautilus_file_get_uri (node->file);
- g_message ("abandoning %d ref of %s, count is now %d",
- node->ref_count, uri, node->parent->all_children_ref_count);
- g_free (uri);
- }
-#endif
- }
- node->ref_count = 0;
-}
-
-static void
-abandon_dummy_row_ref_count (NautilusTreeModel *model, TreeNode *node)
-{
- decrement_ref_count (model, node, node->dummy_child_ref_count);
- if (node->dummy_child_ref_count != 0) {
-#if LOG_REF_COUNTS
- char *uri;
-
- uri = nautilus_file_get_uri (node->file);
- g_message ("abandoning %d ref of %s -- DUMMY, count is now %d",
- node->dummy_child_ref_count, uri, node->all_children_ref_count);
- g_free (uri);
-#endif
- }
- node->dummy_child_ref_count = 0;
-}
-
-static void
-report_row_inserted (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
-}
-
-static void
-report_row_contents_changed (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
-}
-
-static void
-report_row_has_child_toggled (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, iter);
- gtk_tree_path_free (path);
-}
-
-static GtkTreePath *
-get_node_path (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- make_iter_for_node (node, &iter, model->details->stamp);
- return gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
-}
-
-static void
-report_dummy_row_inserted (NautilusTreeModel *model, TreeNode *parent)
-{
- GtkTreeIter iter;
-
- if (!parent->inserted) {
- return;
- }
- make_iter_for_dummy_row (parent, &iter, model->details->stamp);
- report_row_inserted (model, &iter);
-}
-
-static void
-report_dummy_row_deleted (NautilusTreeModel *model, TreeNode *parent)
-{
- GtkTreeIter iter;
- GtkTreePath *path;
-
- abandon_dummy_row_ref_count (model, parent);
- if (!parent->inserted) {
- return;
- }
- make_iter_for_node (parent, &iter, model->details->stamp);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
- gtk_tree_path_append_index (path, 0);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
-}
-
-static void
-report_node_inserted (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- make_iter_for_node (node, &iter, model->details->stamp);
- report_row_inserted (model, &iter);
- node->inserted = TRUE;
-
- if (node->directory != NULL) {
- report_row_has_child_toggled (model, &iter);
- }
- if (tree_node_has_dummy_child (node)) {
- report_dummy_row_inserted (model, node);
- }
-}
-
-static void
-report_node_contents_changed (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- if (!node->inserted) {
- return;
- }
- make_iter_for_node (node, &iter, model->details->stamp);
- report_row_contents_changed (model, &iter);
-}
-
-static void
-report_node_has_child_toggled (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreeIter iter;
-
- if (!node->inserted) {
- return;
- }
- make_iter_for_node (node, &iter, model->details->stamp);
- report_row_has_child_toggled (model, &iter);
-}
-
-static void
-report_dummy_row_contents_changed (NautilusTreeModel *model, TreeNode *parent)
-{
- GtkTreeIter iter;
-
- if (!parent->inserted) {
- return;
- }
- make_iter_for_dummy_row (parent, &iter, model->details->stamp);
- report_row_contents_changed (model, &iter);
-}
-
-static void
-stop_monitoring_directory (NautilusTreeModel *model, TreeNode *node)
-{
- NautilusDirectory *directory;
-
- if (node->done_loading_id == 0) {
- g_assert (node->files_added_id == 0);
- g_assert (node->files_changed_id == 0);
- return;
- }
-
- directory = node->directory;
-
- g_signal_handler_disconnect (node->directory, node->done_loading_id);
- g_signal_handler_disconnect (node->directory, node->files_added_id);
- g_signal_handler_disconnect (node->directory, node->files_changed_id);
-
- node->done_loading_id = 0;
- node->files_added_id = 0;
- node->files_changed_id = 0;
-
- nautilus_directory_file_monitor_remove (node->directory, model);
-}
-
-static void
-destroy_children_without_reporting (NautilusTreeModel *model, TreeNode *parent)
-{
- while (parent->first_child != NULL) {
- destroy_node_without_reporting (model, parent->first_child);
- }
-}
-
-static void
-destroy_node_without_reporting (NautilusTreeModel *model, TreeNode *node)
-{
- abandon_node_ref_count (model, node);
- stop_monitoring_directory (model, node);
- node->inserted = FALSE;
- destroy_children_without_reporting (model, node);
- g_hash_table_remove (node->root->file_to_node_map, node->file);
- tree_node_destroy (model, node);
-}
-
-static void
-destroy_node (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *parent;
- gboolean parent_had_dummy_child;
- GtkTreePath *path;
-
- parent = node->parent;
- parent_had_dummy_child = tree_node_has_dummy_child (parent);
-
- path = get_node_path (model, node);
-
- destroy_node_without_reporting (model, node);
-
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
-
- if (tree_node_has_dummy_child (parent)) {
- if (!parent_had_dummy_child) {
- report_dummy_row_inserted (model, parent);
- }
- } else {
- g_assert (!parent_had_dummy_child);
- }
-}
-
-static void
-destroy_children (NautilusTreeModel *model, TreeNode *parent)
-{
- while (parent->first_child != NULL) {
- destroy_node (model, parent->first_child);
- }
-}
-
-static void
-destroy_children_by_function (NautilusTreeModel *model, TreeNode *parent, FilePredicate f)
-{
- TreeNode *child, *next;
-
- for (child = parent->first_child; child != NULL; child = next) {
- next = child->next;
- if (f (child->file)) {
- destroy_node (model, child);
- } else {
- destroy_children_by_function (model, child, f);
- }
- }
-}
-
-static void
-destroy_by_function (NautilusTreeModel *model, FilePredicate f)
-{
- TreeNode *node;
- for (node = model->details->root_node; node != NULL; node = node->next) {
- destroy_children_by_function (model, node, f);
- }
-}
-
-static gboolean
-update_node_without_reporting (NautilusTreeModel *model, TreeNode *node)
-{
- gboolean changed;
-
- changed = FALSE;
-
- if (node->directory == NULL && nautilus_file_is_directory (node->file)) {
- node->directory = nautilus_directory_get_for_file (node->file);
- } else if (node->directory != NULL && !nautilus_file_is_directory (node->file)) {
- stop_monitoring_directory (model, node);
- destroy_children (model, node);
- nautilus_directory_unref (node->directory);
- node->directory = NULL;
- }
-
- changed |= tree_node_update_display_name (node);
- changed |= tree_node_update_closed_pixbuf (node);
- changed |= tree_node_update_open_pixbuf (node);
-
- return changed;
-}
-
-static void
-insert_node (NautilusTreeModel *model, TreeNode *parent, TreeNode *node)
-{
- gboolean parent_empty;
-
- parent_empty = parent->first_child == NULL;
- if (parent_empty) {
- parent->inserting_first_child = TRUE;
- }
-
- tree_node_parent (node, parent);
-
- update_node_without_reporting (model, node);
- report_node_inserted (model, node);
-
- if (parent_empty) {
- parent->inserting_first_child = FALSE;
- if (!tree_node_has_dummy_child (parent)) {
- report_dummy_row_deleted (model, parent);
- }
- }
-}
-
-static void
-reparent_node (NautilusTreeModel *model, TreeNode *node)
-{
- GtkTreePath *path;
- TreeNode *new_parent;
-
- new_parent = get_parent_node_from_file (node->root, node->file);
- if (new_parent == NULL || new_parent->directory == NULL) {
- destroy_node (model, node);
- return;
- }
-
- path = get_node_path (model, node);
-
- abandon_node_ref_count (model, node);
- tree_node_unparent (model, node);
-
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
-
- insert_node (model, new_parent, node);
-}
-
-static gboolean
-should_show_file (NautilusTreeModel *model, NautilusFile *file)
-{
- gboolean should;
- TreeNode *node;
-
- should = nautilus_file_should_show (file,
- model->details->show_hidden_files,
- model->details->show_backup_files);
-
- if (should
- && model->details->show_only_directories
- &&! nautilus_file_is_directory (file)) {
- should = FALSE;
- }
-
- if (should && nautilus_file_is_gone (file)) {
- should = FALSE;
- }
-
- for (node = model->details->root_node; node != NULL; node = node->next) {
- if (!should && node != NULL && file == node->file) {
- should = TRUE;
- }
- }
-
- return should;
-}
-
-static void
-update_node (NautilusTreeModel *model, TreeNode *node)
-{
- gboolean had_dummy_child, has_dummy_child;
- gboolean had_directory, has_directory;
- gboolean changed;
-
- if (!should_show_file (model, node->file)) {
- destroy_node (model, node);
- return;
- }
-
- if (node->parent != NULL && node->parent->directory != NULL
- && !nautilus_directory_contains_file (node->parent->directory, node->file)) {
- reparent_node (model, node);
- return;
- }
-
- had_dummy_child = tree_node_has_dummy_child (node);
- had_directory = node->directory != NULL;
-
- changed = update_node_without_reporting (model, node);
-
- has_dummy_child = tree_node_has_dummy_child (node);
- has_directory = node->directory != NULL;
-
- if (had_dummy_child != has_dummy_child) {
- if (has_dummy_child) {
- report_dummy_row_inserted (model, node);
- } else {
- report_dummy_row_deleted (model, node);
- }
- }
- if (had_directory != has_directory) {
- report_node_has_child_toggled (model, node);
- }
-
- if (changed) {
- report_node_contents_changed (model, node);
- }
-}
-
-static void
-process_file_change (NautilusTreeModelRoot *root,
- NautilusFile *file)
-{
- TreeNode *node, *parent;
-
- node = get_node_from_file (root, file);
- if (node != NULL) {
- update_node (root->model, node);
- return;
- }
-
- if (!should_show_file (root->model, file)) {
- return;
- }
-
- parent = get_parent_node_from_file (root, file);
- if (parent == NULL) {
- return;
- }
-
- insert_node (root->model, parent, create_node_for_file (root, file));
-}
-
-static void
-files_changed_callback (NautilusDirectory *directory,
- GList *changed_files,
- gpointer callback_data)
-{
- NautilusTreeModelRoot *root;
- GList *node;
-
- root = (NautilusTreeModelRoot *) (callback_data);
-
- for (node = changed_files; node != NULL; node = node->next) {
- process_file_change (root, NAUTILUS_FILE (node->data));
- }
-}
-
-static void
-set_done_loading (NautilusTreeModel *model, TreeNode *node, gboolean done_loading)
-{
- gboolean had_dummy;
-
- if (node == NULL || node->done_loading == done_loading) {
- return;
- }
-
- had_dummy = tree_node_has_dummy_child (node);
-
- node->done_loading = done_loading;
-
- if (tree_node_has_dummy_child (node)) {
- if (had_dummy) {
- report_dummy_row_contents_changed (model, node);
- } else {
- report_dummy_row_inserted (model, node);
- }
- } else {
- if (had_dummy) {
- report_dummy_row_deleted (model, node);
- } else {
- g_assert_not_reached ();
- }
- }
-}
-
-static void
-done_loading_callback (NautilusDirectory *directory,
- NautilusTreeModelRoot *root)
-{
- NautilusFile *file;
- TreeNode *node;
- GtkTreeIter iter;
-
- file = nautilus_directory_get_corresponding_file (directory);
- node = get_node_from_file (root, file);
- g_assert (node != NULL);
- set_done_loading (root->model, node, TRUE);
- nautilus_file_unref (file);
-
- make_iter_for_node (node, &iter, root->model->details->stamp);
- g_signal_emit_by_name (root->model, "row_loaded", &iter);
-}
-
-static NautilusFileAttributes
-get_tree_monitor_attributes (void)
-{
- NautilusFileAttributes attributes;
-
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
-
- return attributes;
-}
-
-static void
-start_monitoring_directory (NautilusTreeModel *model, TreeNode *node)
-{
- NautilusDirectory *directory;
- NautilusFileAttributes attributes;
-
- if (node->done_loading_id != 0) {
- return;
- }
-
- g_assert (node->files_added_id == 0);
- g_assert (node->files_changed_id == 0);
-
- directory = node->directory;
-
- node->done_loading_id = g_signal_connect
- (directory, "done_loading",
- G_CALLBACK (done_loading_callback), node->root);
- node->files_added_id = g_signal_connect
- (directory, "files_added",
- G_CALLBACK (files_changed_callback), node->root);
- node->files_changed_id = g_signal_connect
- (directory, "files_changed",
- G_CALLBACK (files_changed_callback), node->root);
-
- set_done_loading (model, node, nautilus_directory_are_all_files_seen (directory));
-
- attributes = get_tree_monitor_attributes ();
- nautilus_directory_file_monitor_add (directory, model,
- model->details->show_hidden_files,
- model->details->show_backup_files,
- attributes, files_changed_callback, node->root);
-}
-
-static int
-nautilus_tree_model_get_n_columns (GtkTreeModel *model)
-{
- return NAUTILUS_TREE_MODEL_NUM_COLUMNS;
-}
-
-static GType
-nautilus_tree_model_get_column_type (GtkTreeModel *model, int index)
-{
- switch (index) {
- case NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN:
- return G_TYPE_STRING;
- case NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN:
- return GDK_TYPE_PIXBUF;
- case NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN:
- return GDK_TYPE_PIXBUF;
- case NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN:
- return PANGO_TYPE_STYLE;
- case NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN:
- return PANGO_TYPE_WEIGHT;
- default:
- g_assert_not_reached ();
- }
-
- return G_TYPE_INVALID;
-}
-
-static gboolean
-iter_is_valid (NautilusTreeModel *model, const GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
-
- if (iter->stamp != model->details->stamp) {
- return FALSE;
- }
-
- node = iter->user_data;
- parent = iter->user_data2;
- if (node == NULL) {
- if (parent != NULL) {
- if (!NAUTILUS_IS_FILE (parent->file)) {
- return FALSE;
- }
- if (!tree_node_has_dummy_child (parent)) {
- return FALSE;
- }
- }
- } else {
- if (!NAUTILUS_IS_FILE (node->file)) {
- return FALSE;
- }
- if (parent != NULL) {
- return FALSE;
- }
- }
- if (iter->user_data3 != NULL) {
- return FALSE;
- }
- return TRUE;
-}
-
-static gboolean
-nautilus_tree_model_get_iter (GtkTreeModel *model, GtkTreeIter *iter, GtkTreePath *path)
-{
- int *indices;
- GtkTreeIter parent;
- int depth, i;
-
- indices = gtk_tree_path_get_indices (path);
- depth = gtk_tree_path_get_depth (path);
-
- if (! gtk_tree_model_iter_nth_child (model, iter, NULL, indices[0])) {
- return FALSE;
- }
-
- for (i = 1; i < depth; i++) {
- parent = *iter;
-
- if (! gtk_tree_model_iter_nth_child (model, iter, &parent, indices[i])) {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static GtkTreePath *
-nautilus_tree_model_get_path (GtkTreeModel *model, GtkTreeIter *iter)
-{
- NautilusTreeModel *tree_model;
- TreeNode *node, *parent, *cnode;
- GtkTreePath *path;
- GtkTreeIter parent_iter;
- int i;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), NULL);
- tree_model = NAUTILUS_TREE_MODEL (model);
- g_return_val_if_fail (iter_is_valid (tree_model, iter), NULL);
-
- node = iter->user_data;
- if (node == NULL) {
- parent = iter->user_data2;
- if (parent == NULL) {
- return gtk_tree_path_new ();
- }
- } else {
- parent = node->parent;
- if (parent == NULL) {
- i = 0;
- for (cnode = tree_model->details->root_node; cnode != node; cnode = cnode->next) {
- i++;
- }
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, i);
- return path;
- }
- }
-
- parent_iter.stamp = iter->stamp;
- parent_iter.user_data = parent;
- parent_iter.user_data2 = NULL;
- parent_iter.user_data3 = NULL;
-
- path = nautilus_tree_model_get_path (model, &parent_iter);
-
- gtk_tree_path_append_index (path, tree_node_get_child_index (parent, node));
-
- return path;
-}
-
-static void
-nautilus_tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, int column, GValue *value)
-{
- TreeNode *node, *parent;
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter));
-
- node = iter->user_data;
-
- switch (column) {
- case NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN:
- g_value_init (value, G_TYPE_STRING);
- if (node == NULL) {
- parent = iter->user_data2;
- g_value_set_static_string (value, parent->done_loading
- ? _("(Empty)") : _("Loading..."));
- } else {
- g_value_set_string (value, tree_node_get_display_name (node));
- }
- break;
- case NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_set_object (value, node == NULL ? NULL : tree_node_get_closed_pixbuf (node));
- break;
- case NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_set_object (value, node == NULL ? NULL : tree_node_get_open_pixbuf (node));
- break;
- case NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN:
- g_value_init (value, PANGO_TYPE_STYLE);
- if (node == NULL) {
- g_value_set_enum (value, PANGO_STYLE_ITALIC);
- } else {
- g_value_set_enum (value, PANGO_STYLE_NORMAL);
- }
- break;
- case NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN:
- g_value_init (value, PANGO_TYPE_STYLE);
- if (node != NULL && node->parent == NULL) {
- g_value_set_enum (value, PANGO_WEIGHT_BOLD);
- } else {
- g_value_set_enum (value, PANGO_WEIGHT_NORMAL);
- }
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static gboolean
-nautilus_tree_model_iter_next (GtkTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node, *parent, *next;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), FALSE);
-
- node = iter->user_data;
-
- if (node == NULL) {
- parent = iter->user_data2;
- next = parent->first_child;
- } else {
- next = node->next;
- }
-
- return make_iter_for_node (next, iter, iter->stamp);
-}
-
-static gboolean
-nautilus_tree_model_iter_children (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *parent_iter)
-{
- TreeNode *parent;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), parent_iter), FALSE);
-
- parent = parent_iter->user_data;
- if (parent == NULL) {
- return make_iter_invalid (iter);
- }
-
- if (tree_node_has_dummy_child (parent)) {
- return make_iter_for_dummy_row (parent, iter, parent_iter->stamp);
- }
- return make_iter_for_node (parent->first_child, iter, parent_iter->stamp);
-}
-
-static gboolean
-nautilus_tree_model_iter_parent (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *child_iter)
-{ TreeNode *child, *parent;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), child_iter), FALSE);
-
- child = child_iter->user_data;
-
- if (child == NULL) {
- parent = child_iter->user_data2;
- } else {
- parent = child->parent;
- }
-
- return make_iter_for_node (parent, iter, child_iter->stamp);
-}
-
-static gboolean
-nautilus_tree_model_iter_has_child (GtkTreeModel *model, GtkTreeIter *iter)
-{
- gboolean has_child;
- TreeNode *node;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), FALSE);
-
- node = iter->user_data;
-
- has_child = node != NULL && node->directory != NULL;
-
-#if 0
- g_warning ("Node '%s' %s",
- node && node->file ? nautilus_file_get_uri (node->file) : "no name",
- has_child ? "has child" : "no child");
-#endif
-
- return has_child;
-}
-
-static int
-nautilus_tree_model_iter_n_children (GtkTreeModel *model, GtkTreeIter *iter)
-{
- NautilusTreeModel *tree_model;
- TreeNode *parent, *node;
- int n;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (iter == NULL || iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), FALSE);
-
- tree_model = NAUTILUS_TREE_MODEL (model);
-
- if (iter == NULL) {
- return 1;
- }
-
- parent = iter->user_data;
- if (parent == NULL) {
- return 0;
- }
-
- n = tree_node_has_dummy_child (parent) ? 1 : 0;
- for (node = parent->first_child; node != NULL; node = node->next) {
- n++;
- }
-
- return n;
-}
-
-static gboolean
-nautilus_tree_model_iter_nth_child (GtkTreeModel *model, GtkTreeIter *iter,
- GtkTreeIter *parent_iter, int n)
-{
- NautilusTreeModel *tree_model;
- TreeNode *parent, *node;
- int i;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), FALSE);
- g_return_val_if_fail (parent_iter == NULL
- || iter_is_valid (NAUTILUS_TREE_MODEL (model), parent_iter), FALSE);
-
- tree_model = NAUTILUS_TREE_MODEL (model);
-
- if (parent_iter == NULL) {
- node = tree_model->details->root_node;
- for (i = 0; i < n && node != NULL; i++, node = node->next);
- return make_iter_for_node (node, iter,
- tree_model->details->stamp);
- }
-
- parent = parent_iter->user_data;
- if (parent == NULL) {
- return make_iter_invalid (iter);
- }
-
- i = tree_node_has_dummy_child (parent) ? 1 : 0;
- if (n == 0 && i == 1) {
- return make_iter_for_dummy_row (parent, iter, parent_iter->stamp);
- }
- for (node = parent->first_child; i != n; i++, node = node->next) {
- if (node == NULL) {
- return make_iter_invalid (iter);
- }
- }
-
- return make_iter_for_node (node, iter, parent_iter->stamp);
-}
-
-static void
-update_monitoring (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *child;
-
- if (node->all_children_ref_count == 0) {
- stop_monitoring_directory (model, node);
- destroy_children (model, node);
- } else {
- for (child = node->first_child; child != NULL; child = child->next) {
- update_monitoring (model, child);
- }
- start_monitoring_directory (model, node);
- }
-}
-
-static gboolean
-update_monitoring_idle_callback (gpointer callback_data)
-{
- NautilusTreeModel *model;
- TreeNode *node;
-
- model = NAUTILUS_TREE_MODEL (callback_data);
- model->details->monitoring_update_idle_id = 0;
- for (node = model->details->root_node; node != NULL; node = node->next) {
- update_monitoring (model, node);
- }
- return FALSE;
-}
-
-static void
-schedule_monitoring_update (NautilusTreeModel *model)
-{
- if (model->details->monitoring_update_idle_id == 0) {
- model->details->monitoring_update_idle_id =
- g_idle_add (update_monitoring_idle_callback, model);
- }
-}
-
-static void
-stop_monitoring_directory_and_children (NautilusTreeModel *model, TreeNode *node)
-{
- TreeNode *child;
-
- stop_monitoring_directory (model, node);
- for (child = node->first_child; child != NULL; child = child->next) {
- stop_monitoring_directory_and_children (model, child);
- }
-}
-
-static void
-stop_monitoring (NautilusTreeModel *model)
-{
- TreeNode *node;
-
- for (node = model->details->root_node; node != NULL; node = node->next) {
- stop_monitoring_directory_and_children (model, node);
- }
-}
-
-static void
-nautilus_tree_model_ref_node (GtkTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
-#if LOG_REF_COUNTS
- char *uri;
-#endif
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter));
-
- node = iter->user_data;
- if (node == NULL) {
- parent = iter->user_data2;
- g_assert (parent->dummy_child_ref_count >= 0);
- ++parent->dummy_child_ref_count;
- } else {
- parent = node->parent;
- g_assert (node->ref_count >= 0);
- ++node->ref_count;
- }
-
- if (parent != NULL) {
- g_assert (parent->all_children_ref_count >= 0);
- if (++parent->all_children_ref_count == 1) {
- if (parent->first_child == NULL) {
- parent->done_loading = FALSE;
- }
- schedule_monitoring_update (NAUTILUS_TREE_MODEL (model));
- }
-#if LOG_REF_COUNTS
- uri = get_node_uri (iter);
- g_message ("ref of %s, count is now %d",
- uri, parent->all_children_ref_count);
- g_free (uri);
-#endif
- }
-}
-
-static void
-nautilus_tree_model_unref_node (GtkTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node, *parent;
-#if LOG_REF_COUNTS
- char *uri;
-#endif
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter));
-
- node = iter->user_data;
- if (node == NULL) {
- parent = iter->user_data2;
- g_assert (parent->dummy_child_ref_count > 0);
- --parent->dummy_child_ref_count;
- } else {
- parent = node->parent;
- g_assert (node->ref_count > 0);
- --node->ref_count;
- }
-
- if (parent != NULL) {
- g_assert (parent->all_children_ref_count > 0);
-#if LOG_REF_COUNTS
- uri = get_node_uri (iter);
- g_message ("unref of %s, count is now %d",
- uri, parent->all_children_ref_count - 1);
- g_free (uri);
-#endif
- if (--parent->all_children_ref_count == 0) {
- schedule_monitoring_update (NAUTILUS_TREE_MODEL (model));
- }
- }
-}
-
-static void
-root_node_file_changed_callback (NautilusFile *file, NautilusTreeModelRoot *root)
-{
- if (root->root_node != NULL) {
- update_node (root->model, root->root_node);
- }
-}
-
-void
-nautilus_tree_model_add_root_uri (NautilusTreeModel *model, const char *root_uri, const char *display_name, const char *icon_name)
-{
- NautilusFile *file;
- TreeNode *node, *cnode;
- NautilusFileAttributes attributes;
- NautilusTreeModelRoot *newroot;
-
- file = nautilus_file_get (root_uri);
-
- newroot = tree_model_root_new (model);
- node = create_node_for_file (newroot, file);
- node->display_name = g_strdup (display_name);
- node->icon_name = g_strdup (icon_name);
- newroot->root_node = node;
- node->parent = NULL;
- if (model->details->root_node == NULL) {
- model->details->root_node = node;
- } else {
- /* append it */
- for (cnode = model->details->root_node; cnode->next != NULL; cnode = cnode->next);
- cnode->next = node;
- node->prev = cnode;
- }
-
- newroot->changed_handler_id = g_signal_connect (node->file, "changed",
- G_CALLBACK (root_node_file_changed_callback),
- node->root);
-
- attributes = get_tree_monitor_attributes ();
- nautilus_file_monitor_add (file, model, attributes);
-
- nautilus_file_unref (file);
-
- update_node_without_reporting (model, node);
- report_node_inserted (model, node);
-}
-
-void
-nautilus_tree_model_remove_root_uri (NautilusTreeModel *model, const char *uri)
-{
- TreeNode *node;
- GtkTreePath *path;
- NautilusTreeModelRoot *root;
- NautilusFile *file;
-
- file = nautilus_file_get (uri);
- for (node = model->details->root_node; node != NULL; node = node->next) {
- if (file == node->file) {
- break;
- }
- }
- nautilus_file_unref (file);
-
- if (node) {
- /* remove the node */
- nautilus_file_monitor_remove (node->file, model);
- path = get_node_path (model, node);
-
- if (node->prev) {
- node->prev->next = node->next;
- }
- if (node->next) {
- node->next->prev = node->prev;
- }
- if (node == model->details->root_node) {
- model->details->root_node = node->next;
- }
-
- /* destroy the root identifier */
- root = node->root;
- destroy_node_without_reporting (model, node);
- g_hash_table_destroy (root->file_to_node_map);
- g_free (root);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
- }
-}
-
-NautilusTreeModel *
-nautilus_tree_model_new (void)
-{
- NautilusTreeModel *model;
-
- model = g_object_new (NAUTILUS_TYPE_TREE_MODEL, NULL);
-
- return model;
-}
-
-static void
-set_theme (TreeNode *node, NautilusTreeModel *model)
-{
- TreeNode *child;
-
- tree_node_update_closed_pixbuf (node);
- tree_node_update_open_pixbuf (node);
-
- report_node_contents_changed (model, node);
-
- for (child = node->first_child; child != NULL; child = child->next) {
- set_theme (child, model);
- }
-}
-
-void
-nautilus_tree_model_set_theme (NautilusTreeModel *model)
-{
- TreeNode *node;
-
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
-
- node = model->details->root_node;
- while (node != NULL) {
- set_theme (node, model);
- node = node->next;
- }
-}
-
-
-void
-nautilus_tree_model_set_show_hidden_files (NautilusTreeModel *model,
- gboolean show_hidden_files)
-{
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (show_hidden_files == FALSE || show_hidden_files == TRUE);
-
- show_hidden_files = show_hidden_files != FALSE;
- if (model->details->show_hidden_files == show_hidden_files) {
- return;
- }
- model->details->show_hidden_files = show_hidden_files;
- stop_monitoring (model);
- if (!show_hidden_files) {
- destroy_by_function (model, nautilus_file_is_hidden_file);
- }
- schedule_monitoring_update (model);
-}
-
-void
-nautilus_tree_model_set_show_backup_files (NautilusTreeModel *model,
- gboolean show_backup_files)
-{
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (show_backup_files == FALSE || show_backup_files == TRUE);
-
- show_backup_files = show_backup_files != FALSE;
- if (model->details->show_backup_files == show_backup_files) {
- return;
- }
- model->details->show_backup_files = show_backup_files;
- stop_monitoring (model);
- if (!show_backup_files) {
- destroy_by_function (model, nautilus_file_is_backup_file);
- }
- schedule_monitoring_update (model);
-}
-
-static gboolean
-file_is_not_directory (NautilusFile *file)
-{
- return !nautilus_file_is_directory (file);
-}
-
-void
-nautilus_tree_model_set_show_only_directories (NautilusTreeModel *model,
- gboolean show_only_directories)
-{
- g_return_if_fail (NAUTILUS_IS_TREE_MODEL (model));
- g_return_if_fail (show_only_directories == FALSE || show_only_directories == TRUE);
-
- show_only_directories = show_only_directories != FALSE;
- if (model->details->show_only_directories == show_only_directories) {
- return;
- }
- model->details->show_only_directories = show_only_directories;
- stop_monitoring (model);
- if (show_only_directories) {
- destroy_by_function (model, file_is_not_directory);
- }
- schedule_monitoring_update (model);
-}
-
-NautilusFile *
-nautilus_tree_model_iter_get_file (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), 0);
- g_return_val_if_fail (iter_is_valid (NAUTILUS_TREE_MODEL (model), iter), 0);
-
- node = iter->user_data;
- return node == NULL ? NULL : nautilus_file_ref (node->file);
-}
-
-gboolean
-nautilus_tree_model_iter_is_root (NautilusTreeModel *model, GtkTreeIter *iter)
-{
- TreeNode *node;
-
- g_return_val_if_fail (NAUTILUS_IS_TREE_MODEL (model), 0);
- g_return_val_if_fail (iter_is_valid (model, iter), 0);
- node = iter->user_data;
- if (node == NULL) {
- return FALSE;
- } else {
- return (node->parent == NULL);
- }
-}
-
-gboolean
-nautilus_tree_model_file_get_iter (NautilusTreeModel *model,
- GtkTreeIter *iter,
- NautilusFile *file,
- GtkTreeIter *current_iter)
-{
- TreeNode *node, *root_node;
-
- if (current_iter != NULL && current_iter->user_data != NULL) {
- node = get_node_from_file (((TreeNode *) current_iter->user_data)->root, file);
- return make_iter_for_node (node, iter, model->details->stamp);
- }
-
- for (root_node = model->details->root_node; root_node != NULL; root_node = root_node->next) {
- node = get_node_from_file (root_node->root, file);
- if (node != NULL) {
- return make_iter_for_node (node, iter, model->details->stamp);
- }
- }
- return FALSE;
-}
-
-static void
-nautilus_tree_model_init (NautilusTreeModel *model)
-{
- model->details = g_new0 (NautilusTreeModelDetails, 1);
-
- do {
- model->details->stamp = g_random_int ();
- } while (model->details->stamp == 0);
-}
-
-static void
-nautilus_tree_model_finalize (GObject *object)
-{
- NautilusTreeModel *model;
- TreeNode *root_node, *next_root;
- NautilusTreeModelRoot *root;
-
- model = NAUTILUS_TREE_MODEL (object);
-
- for (root_node = model->details->root_node; root_node != NULL; root_node = next_root) {
- next_root = root_node->next;
- root = root_node->root;
- g_signal_handler_disconnect (root_node->file, root->changed_handler_id);
- nautilus_file_monitor_remove (root_node->file, model);
- destroy_node_without_reporting (model, root_node);
- g_hash_table_destroy (root->file_to_node_map);
- g_free (root);
- }
-
- if (model->details->monitoring_update_idle_id != 0) {
- g_source_remove (model->details->monitoring_update_idle_id);
- }
-
- g_free (model->details);
-
- parent_class->finalize (object);
-}
-
-static void
-nautilus_tree_model_class_init (NautilusTreeModelClass *class)
-{
- parent_class = g_type_class_peek_parent (class);
-
- G_OBJECT_CLASS (class)->finalize = nautilus_tree_model_finalize;
-
- tree_model_signals[ROW_LOADED] =
- g_signal_new ("row_loaded",
- NAUTILUS_TYPE_TREE_MODEL,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusTreeModelClass, row_loaded),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- GTK_TYPE_TREE_ITER);
-}
-
-static void
-nautilus_tree_model_tree_model_init (GtkTreeModelIface *iface)
-{
- iface->get_flags = nautilus_tree_model_get_flags;
- iface->get_n_columns = nautilus_tree_model_get_n_columns;
- iface->get_column_type = nautilus_tree_model_get_column_type;
- iface->get_iter = nautilus_tree_model_get_iter;
- iface->get_path = nautilus_tree_model_get_path;
- iface->get_value = nautilus_tree_model_get_value;
- iface->iter_next = nautilus_tree_model_iter_next;
- iface->iter_children = nautilus_tree_model_iter_children;
- iface->iter_has_child = nautilus_tree_model_iter_has_child;
- iface->iter_n_children = nautilus_tree_model_iter_n_children;
- iface->iter_nth_child = nautilus_tree_model_iter_nth_child;
- iface->iter_parent = nautilus_tree_model_iter_parent;
- iface->ref_node = nautilus_tree_model_ref_node;
- iface->unref_node = nautilus_tree_model_unref_node;
-}
-
-GType
-nautilus_tree_model_get_type (void)
-{
- static GType object_type = 0;
-
- if (object_type == 0) {
- static const GTypeInfo object_info = {
- sizeof (NautilusTreeModelClass),
- NULL,
- NULL,
- (GClassInitFunc) nautilus_tree_model_class_init,
- NULL,
- NULL,
- sizeof (NautilusTreeModel),
- 0,
- (GInstanceInitFunc) nautilus_tree_model_init,
- };
-
- static const GInterfaceInfo tree_model_info = {
- (GInterfaceInitFunc) nautilus_tree_model_tree_model_init,
- NULL,
- NULL
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT, "NautilusTreeModel", &object_info, 0);
- g_type_add_interface_static (object_type,
- GTK_TYPE_TREE_MODEL,
- &tree_model_info);
- }
-
- return object_type;
-}
diff --git a/components/tree/nautilus-tree-model.h b/components/tree/nautilus-tree-model.h
deleted file mode 100644
index f41a05740..000000000
--- a/components/tree/nautilus-tree-model.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2002 Anders Carlsson
- * Copyright (C) 2002 Bent Spoon Software
- *
- * 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: Anders Carlsson <andersca@gnu.org>
- */
-
-/* nautilus-tree-model.h - Model for the tree view */
-
-#ifndef NAUTILUS_TREE_MODEL_H
-#define NAUTILUS_TREE_MODEL_H
-
-#include <glib-object.h>
-#include <gtk/gtktreemodel.h>
-#include <libnautilus-private/nautilus-file.h>
-
-#define NAUTILUS_TYPE_TREE_MODEL (nautilus_tree_model_get_type ())
-#define NAUTILUS_TREE_MODEL(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TREE_MODEL, NautilusTreeModel))
-#define NAUTILUS_TREE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TREE_MODEL, NautilusTreeModelClass))
-#define NAUTILUS_IS_TREE_MODEL(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TREE_MODEL))
-#define NAUTILUS_IS_TREE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TREE_MODEL))
-
-enum {
- NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN,
- NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
- NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN,
- NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN,
- NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN,
- NAUTILUS_TREE_MODEL_NUM_COLUMNS
-};
-
-typedef struct NautilusTreeModelDetails NautilusTreeModelDetails;
-
-typedef struct {
- GObject parent;
- NautilusTreeModelDetails *details;
-} NautilusTreeModel;
-
-typedef struct {
- GObjectClass parent_class;
-
- void (* row_loaded) (NautilusTreeModel *tree_model,
- GtkTreeIter *iter);
-} NautilusTreeModelClass;
-
-GType nautilus_tree_model_get_type (void);
-NautilusTreeModel *nautilus_tree_model_new (void);
-void nautilus_tree_model_set_show_hidden_files (NautilusTreeModel *model,
- gboolean show_hidden_files);
-void nautilus_tree_model_set_show_backup_files (NautilusTreeModel *model,
- gboolean show_backup_files);
-void nautilus_tree_model_set_show_only_directories (NautilusTreeModel *model,
- gboolean show_only_directories);
-NautilusFile * nautilus_tree_model_iter_get_file (NautilusTreeModel *model,
- GtkTreeIter *iter);
-void nautilus_tree_model_add_root_uri (NautilusTreeModel *model,
- const char *root_uri,
- const char *display_name,
- const char *icon_name);
-void nautilus_tree_model_remove_root_uri (NautilusTreeModel *model,
- const char *root_uri);
-gboolean nautilus_tree_model_iter_is_root (NautilusTreeModel *model,
- GtkTreeIter *iter);
-gboolean nautilus_tree_model_file_get_iter (NautilusTreeModel *model,
- GtkTreeIter *iter,
- NautilusFile *file,
- GtkTreeIter *currentIter);
-
-void nautilus_tree_model_set_theme (NautilusTreeModel *model);
-
-#endif /* NAUTILUS_TREE_MODEL_H */
diff --git a/components/tree/nautilus-tree-view-iids.h b/components/tree/nautilus-tree-view-iids.h
deleted file mode 100644
index e9309a6d5..000000000
--- a/components/tree/nautilus-tree-view-iids.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * 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.
- *
- * Author: Maciej Stachowiak <mjs@eazel.com>
- */
-
-/* nautilus-tree-view-iids.h - IIDs for tree view */
-
-#ifndef NAUTILUS_TREE_VIEW_IIDS_H
-#define NAUTILUS_TREE_VIEW_IIDS_H
-
-#define TREE_VIEW_IID "OAFIID:Nautilus_Tree_View"
-#define TREE_VIEW_FACTORY_IID "OAFIID:Nautilus_Tree_View_Factory"
-
-#endif /* NAUTILUS_TREE_VIEW_IIDS_H */
diff --git a/components/tree/nautilus-tree-view.c b/components/tree/nautilus-tree-view.c
deleted file mode 100644
index 6c64df02f..000000000
--- a/components/tree/nautilus-tree-view.c
+++ /dev/null
@@ -1,743 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000, 2001 Eazel, Inc
- * Copyright (C) 2002 Anders Carlsson
- * Copyright (C) 2002 Darin Adler
- *
- * 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:
- * Maciej Stachowiak <mjs@eazel.com>
- * Anders Carlsson <andersca@gnu.org>
- * Darin Adler <darin@bentspoon.com>
- */
-
-/* nautilus-tree-view.c - tree sidebar panel
- */
-
-#include <config.h>
-#include "nautilus-tree-view.h"
-
-#include "nautilus-tree-model.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-preferences.h>
-#include <eel/eel-string.h>
-#include <gtk/gtkcellrendererpixbuf.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktreemodelsort.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtktreeview.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libnautilus-private/nautilus-file-attributes.h>
-#include <libnautilus-private/nautilus-file-operations.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-program-choosing.h>
-#include <libnautilus-private/nautilus-tree-view-drag-dest.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-
-struct NautilusTreeViewDetails {
- GtkWidget *scrolled_window;
- GtkTreeView *tree_widget;
- GtkTreeModelSort *sort_model;
- NautilusTreeModel *child_model;
-
- NautilusFile *activation_file;
-
- NautilusTreeViewDragDest *drag_dest;
-
- char *selection_location;
- gboolean selecting;
-
- guint show_selection_idle_id;
-};
-
-typedef struct {
- GList *uris;
- NautilusTreeView *view;
-} PrependURIParameters;
-
-BONOBO_CLASS_BOILERPLATE (NautilusTreeView, nautilus_tree_view,
- NautilusView, NAUTILUS_TYPE_VIEW)
-
-static gboolean
-show_iter_for_file (NautilusTreeView *view, NautilusFile *file, GtkTreeIter *iter)
-{
- GtkTreeModel *model;
- NautilusFile *parent_file;
- GtkTreeIter parent_iter;
- GtkTreePath *path, *sort_path;
- GtkTreeIter cur_iter;
-
- if (view->details->child_model == NULL) {
- return FALSE;
- }
- model = GTK_TREE_MODEL (view->details->child_model);
-
- /* check if file is visible in the same root as the currently selected folder is */
- gtk_tree_view_get_cursor (view->details->tree_widget, &path, NULL);
- if (path != NULL) {
- if (gtk_tree_model_get_iter (model, &cur_iter, path)) {
- if (nautilus_tree_model_file_get_iter (view->details->child_model,
- iter, file, &cur_iter)) {
- return TRUE;
- }
- }
- }
- /* check if file is visible at all */
- if (nautilus_tree_model_file_get_iter (view->details->child_model,
- iter, file, NULL)) {
- return TRUE;
- }
-
- parent_file = nautilus_file_get_parent (file);
-
- if (parent_file == NULL) {
- return FALSE;
- }
- if (!show_iter_for_file (view, parent_file, &parent_iter)) {
- nautilus_file_unref (parent_file);
- return FALSE;
- }
- nautilus_file_unref (parent_file);
-
- if (parent_iter.user_data == NULL || parent_iter.stamp == 0) {
- return FALSE;
- }
- path = gtk_tree_model_get_path (model, &parent_iter);
- sort_path = gtk_tree_model_sort_convert_child_path_to_path
- (view->details->sort_model, path);
- gtk_tree_path_free (path);
- gtk_tree_view_expand_row (view->details->tree_widget, sort_path, FALSE);
- gtk_tree_path_free (sort_path);
-
- return FALSE;
-}
-
-static gboolean
-show_selection_idle_callback (gpointer callback_data)
-{
- NautilusTreeView *view;
- NautilusFile *file, *old_file;
- GtkTreeIter iter;
- GtkTreePath *path, *sort_path;
-
- view = NAUTILUS_TREE_VIEW (callback_data);
-
- view->details->show_selection_idle_id = 0;
-
- file = nautilus_file_get (view->details->selection_location);
- if (file == NULL) {
- return FALSE;
- }
-
- if (!nautilus_file_is_directory (file)) {
- old_file = file;
- file = nautilus_file_get_parent (file);
- nautilus_file_unref (old_file);
- if (file == NULL) {
- return FALSE;
- }
- }
-
- view->details->selecting = TRUE;
- if (!show_iter_for_file (view, file, &iter)) {
- nautilus_file_unref (file);
- return FALSE;
- }
- view->details->selecting = FALSE;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->details->child_model), &iter);
- sort_path = gtk_tree_model_sort_convert_child_path_to_path
- (view->details->sort_model, path);
- gtk_tree_path_free (path);
- gtk_tree_view_set_cursor (view->details->tree_widget, sort_path, NULL, FALSE);
- gtk_tree_view_scroll_to_cell (view->details->tree_widget, sort_path, NULL, FALSE, 0, 0);
- gtk_tree_path_free (sort_path);
-
- nautilus_file_unref (file);
-
- return FALSE;
-}
-
-static void
-schedule_show_selection (NautilusTreeView *view)
-{
- if (view->details->show_selection_idle_id == 0) {
- view->details->show_selection_idle_id = g_idle_add (show_selection_idle_callback, view);
- }
-}
-
-static void
-row_loaded_callback (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- NautilusTreeView *view)
-{
- NautilusFile *file, *tmp_file, *selection_file;
-
- if (view->details->selection_location == NULL
- || !view->details->selecting
- || iter->user_data == NULL || iter->stamp == 0) {
- return;
- }
-
- file = nautilus_tree_model_iter_get_file (view->details->child_model, iter);
- if (file == NULL) {
- return;
- }
- if (!nautilus_file_is_directory (file)) {
- nautilus_file_unref(file);
- return;
- }
-
- /* if iter is ancestor of wanted selection_location then update selection */
- selection_file = nautilus_file_get (view->details->selection_location);
- while (selection_file != NULL) {
- if (file == selection_file) {
- nautilus_file_unref (file);
- nautilus_file_unref (selection_file);
-
- schedule_show_selection (view);
- return;
- }
- tmp_file = nautilus_file_get_parent (selection_file);
- nautilus_file_unref (selection_file);
- selection_file = tmp_file;
- }
- nautilus_file_unref (file);
-}
-
-static NautilusFile *
-sort_model_iter_to_file (NautilusTreeView *view, GtkTreeIter *iter)
-{
- GtkTreeIter child_iter;
-
- gtk_tree_model_sort_convert_iter_to_child_iter (view->details->sort_model, &child_iter, iter);
- return nautilus_tree_model_iter_get_file (view->details->child_model, &child_iter);
-}
-
-static NautilusFile *
-sort_model_path_to_file (NautilusTreeView *view, GtkTreePath *path)
-{
- GtkTreeIter iter;
-
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (view->details->sort_model), &iter, path)) {
- return NULL;
- }
- return sort_model_iter_to_file (view, &iter);
-}
-
-static void
-got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
-{
- char *uri, *file_uri;
- NautilusTreeView *view;
- GdkScreen *screen;
-
- view = NAUTILUS_TREE_VIEW (callback_data);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (view->details->tree_widget));
-
- g_assert (file == view->details->activation_file);
-
- /* FIXME: reenable && !eel_uris_match_ignore_fragments (view->details->current_main_view_uri, uri) */
-
- uri = nautilus_file_get_activation_uri (file);
- if (uri != NULL
- && eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
-
- uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
- nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
-
- } else if (uri != NULL
- && eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
-
- file_uri = nautilus_file_get_uri (file);
- nautilus_launch_desktop_file (screen, file_uri, NULL, NULL);
- g_free (file_uri);
-
- } else if (uri != NULL
- && nautilus_file_is_executable (file)
- && nautilus_file_can_execute (file)
- && !nautilus_file_is_directory (file)) {
-
- file_uri = gnome_vfs_get_local_path_from_uri (uri);
-
- /* Non-local executables don't get launched. They act like non-executables. */
- if (file_uri == NULL) {
- nautilus_view_open_location
- (NAUTILUS_VIEW (view),
- uri,
- Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
- 0,
- NULL);
- } else {
- nautilus_launch_application_from_command (screen, NULL, file_uri, NULL, FALSE);
- g_free (file_uri);
- }
-
- } else if (uri != NULL) {
- if (view->details->selection_location == NULL ||
- strcmp (uri, view->details->selection_location) != 0) {
- if (view->details->selection_location != NULL) {
- g_free (view->details->selection_location);
- }
- view->details->selection_location = g_strdup (uri);
- nautilus_view_open_location
- (NAUTILUS_VIEW (view),
- uri,
- Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE,
- 0,
- NULL);
- }
- }
-
- g_free (uri);
- nautilus_file_unref (view->details->activation_file);
- view->details->activation_file = NULL;
-}
-
-static void
-cancel_activation (NautilusTreeView *view)
-{
- if (view->details->activation_file == NULL) {
- return;
- }
-
- nautilus_file_cancel_call_when_ready
- (view->details->activation_file,
- got_activation_uri_callback, view);
- nautilus_file_unref (view->details->activation_file);
- view->details->activation_file = NULL;
-}
-
-static void
-row_activated_callback (GtkTreeView *treeview, GtkTreePath *path,
- GtkTreeViewColumn *column, NautilusTreeView *view)
-{
- if (gtk_tree_view_row_expanded (view->details->tree_widget, path)) {
- gtk_tree_view_collapse_row (view->details->tree_widget, path);
- } else {
- gtk_tree_view_expand_row (view->details->tree_widget,
- path, FALSE);
- }
-}
-
-
-static void
-selection_changed_callback (GtkTreeSelection *selection,
- NautilusTreeView *view)
-{
- NautilusFileAttributes attributes;
- GtkTreeIter iter;
-
- cancel_activation (view);
-
- if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- return;
- }
-
- view->details->activation_file = sort_model_iter_to_file (view, &iter);
- if (view->details->activation_file == NULL) {
- return;
- }
-
- attributes = NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI;
- nautilus_file_call_when_ready (view->details->activation_file, attributes,
- got_activation_uri_callback, view);
-}
-
-static int
-compare_rows (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer callback_data)
-{
- NautilusFile *file_a, *file_b;
- int result;
-
- if (a->user_data == NULL) {
- return -1;
- }
- else if (b->user_data == NULL) {
- return -1;
- }
-
- /* don't sort root nodes */
- if (nautilus_tree_model_iter_is_root (NAUTILUS_TREE_MODEL (model), a)
- || nautilus_tree_model_iter_is_root (NAUTILUS_TREE_MODEL (model), b)) {
- return 0;
- }
-
- file_a = nautilus_tree_model_iter_get_file (NAUTILUS_TREE_MODEL (model), a);
- file_b = nautilus_tree_model_iter_get_file (NAUTILUS_TREE_MODEL (model), b);
-
- if (file_a == file_b) {
- result = 0;
- } else if (file_a == NULL) {
- result = -1;
- } else if (file_b == NULL) {
- result = +1;
- } else {
- result = nautilus_file_compare_for_sort (file_a, file_b,
- NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
- FALSE, FALSE);
- }
-
- nautilus_file_unref (file_a);
- nautilus_file_unref (file_b);
-
- return result;
-}
-
-
-static char *
-get_root_uri_callback (NautilusTreeViewDragDest *dest,
- gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- /* Don't allow drops on background */
- return NULL;
-}
-
-static NautilusFile *
-get_file_for_path_callback (NautilusTreeViewDragDest *dest,
- GtkTreePath *path,
- gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- return sort_model_path_to_file (view, path);
-}
-
-static void
-move_copy_items_callback (NautilusTreeViewDragDest *dest,
- const GList *item_uris,
- const char *target_uri,
- guint action,
- int x,
- int y,
- gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- nautilus_file_operations_copy_move
- (item_uris,
- NULL,
- target_uri,
- action,
- GTK_WIDGET (view->details->tree_widget),
- NULL, NULL);
-}
-
-static void
-theme_changed_callback (GObject *icon_factory, gpointer callback_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (callback_data);
- if (view->details->child_model != NULL) {
- nautilus_tree_model_set_theme (NAUTILUS_TREE_MODEL (view->details->child_model));
- }
-}
-
-static void
-add_root_for_volume (NautilusTreeView *view,
- GnomeVFSVolume *volume)
-{
- char *icon, *mount_uri, *name;
-
- if (!gnome_vfs_volume_is_user_visible (volume)) {
- return;
- }
-
- icon = gnome_vfs_volume_get_icon (volume);
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- name = gnome_vfs_volume_get_display_name (volume);
-
- nautilus_tree_model_add_root_uri (view->details->child_model,
- mount_uri, name, icon);
-
- g_free (icon);
- g_free (name);
- g_free (mount_uri);
-
-}
-
-static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
- NautilusTreeView *view)
-{
- add_root_for_volume (view, volume);
-}
-
-static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
- NautilusTreeView *view)
-{
- char *mount_uri;
-
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- nautilus_tree_model_remove_root_uri (view->details->child_model,
- mount_uri);
- g_free (mount_uri);
-}
-
-
-static void
-create_tree (NautilusTreeView *view)
-{
- GtkCellRenderer *cell;
- GtkTreeViewColumn *column;
- GnomeVFSVolumeMonitor *volume_monitor;
- char *home_uri;
- GList *volumes, *l;
-
- view->details->child_model = nautilus_tree_model_new ();
- view->details->sort_model = GTK_TREE_MODEL_SORT
- (gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (view->details->child_model)));
- view->details->tree_widget = GTK_TREE_VIEW
- (gtk_tree_view_new_with_model (GTK_TREE_MODEL (view->details->sort_model)));
- g_object_unref (view->details->sort_model);
- g_signal_connect_object
- (view->details->child_model, "row_loaded",
- G_CALLBACK (row_loaded_callback),
- view, G_CONNECT_AFTER);
- home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
- nautilus_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), "gnome-home");
- g_free (home_uri);
- nautilus_tree_model_add_root_uri (view->details->child_model, "file:///", _("Filesystem"), "gnome-folder");
-#ifdef NOT_YET_USABLE
- nautilus_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network Neighbourhood"), "gnome-fs-network");
-#endif
-
- volume_monitor = gnome_vfs_get_volume_monitor ();
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
- for (l = volumes; l != NULL; l = l->next) {
- add_root_for_volume (view, l->data);
- gnome_vfs_volume_unref (l->data);
- }
- g_list_free (volumes);
-
- g_signal_connect_object (volume_monitor, "volume_mounted",
- G_CALLBACK (volume_mounted_callback), view, 0);
- g_signal_connect_object (volume_monitor, "volume_unmounted",
- G_CALLBACK (volume_unmounted_callback), view, 0);
-
- g_object_unref (view->details->child_model);
-
- gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (view->details->sort_model),
- compare_rows, view, NULL);
-
- gtk_tree_view_set_headers_visible (view->details->tree_widget, FALSE);
-
- view->details->drag_dest =
- nautilus_tree_view_drag_dest_new (view->details->tree_widget);
- g_signal_connect_object (view->details->drag_dest,
- "get_root_uri",
- G_CALLBACK (get_root_uri_callback),
- view, 0);
- g_signal_connect_object (view->details->drag_dest,
- "get_file_for_path",
- G_CALLBACK (get_file_for_path_callback),
- view, 0);
- g_signal_connect_object (view->details->drag_dest,
- "move_copy_items",
- G_CALLBACK (move_copy_items_callback),
- view, 0);
-
- /* Create column */
- column = gtk_tree_view_column_new ();
-
- cell = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, cell, FALSE);
- gtk_tree_view_column_set_attributes (column, cell,
- "pixbuf", NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
- "pixbuf_expander_closed", NAUTILUS_TREE_MODEL_CLOSED_PIXBUF_COLUMN,
- "pixbuf_expander_open", NAUTILUS_TREE_MODEL_OPEN_PIXBUF_COLUMN,
- NULL);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_set_attributes (column, cell,
- "text", NAUTILUS_TREE_MODEL_DISPLAY_NAME_COLUMN,
- "style", NAUTILUS_TREE_MODEL_FONT_STYLE_COLUMN,
- "weight", NAUTILUS_TREE_MODEL_FONT_WEIGHT_COLUMN,
- NULL);
-
- gtk_tree_view_append_column (view->details->tree_widget, column);
-
- gtk_widget_show (GTK_WIDGET (view->details->tree_widget));
-
- gtk_container_add (GTK_CONTAINER (view->details->scrolled_window),
- GTK_WIDGET (view->details->tree_widget));
-
- g_signal_connect_object (gtk_tree_view_get_selection (GTK_TREE_VIEW (view->details->tree_widget)), "changed",
- G_CALLBACK (selection_changed_callback), view, 0);
-
- g_signal_connect (G_OBJECT (view->details->tree_widget),
- "row-activated", G_CALLBACK (row_activated_callback),
- view);
-
- schedule_show_selection (view);
-}
-
-static void
-update_filtering_from_preferences (NautilusTreeView *view)
-{
- if (view->details->child_model == NULL) {
- return;
- }
-
- nautilus_tree_model_set_show_hidden_files
- (view->details->child_model,
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES));
- nautilus_tree_model_set_show_backup_files
- (view->details->child_model,
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES));
- nautilus_tree_model_set_show_only_directories
- (view->details->child_model,
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES));
-}
-
-static void
-tree_activate_callback (BonoboControl *control, gboolean activating, gpointer user_data)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (user_data);
-
- if (activating && view->details->tree_widget == NULL) {
- create_tree (view);
- update_filtering_from_preferences (view);
- }
-}
-
-static void
-filtering_changed_callback (gpointer callback_data)
-{
- update_filtering_from_preferences (NAUTILUS_TREE_VIEW (callback_data));
-}
-
-static void
-load_location_callback (NautilusTreeView *view, char *location)
-{
- if (view->details->selection_location != NULL) {
- g_free (view->details->selection_location);
- }
- view->details->selection_location = g_strdup (location);
-
- schedule_show_selection (view);
-}
-
-static void
-nautilus_tree_view_instance_init (NautilusTreeView *view)
-{
- BonoboControl *control;
-
- view->details = g_new0 (NautilusTreeViewDetails, 1);
-
- view->details->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->details->scrolled_window),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gtk_widget_show (view->details->scrolled_window);
-
- control = bonobo_control_new (view->details->scrolled_window);
- g_signal_connect_object (control, "activate",
- G_CALLBACK (tree_activate_callback), view, 0);
-
- nautilus_view_construct_from_bonobo_control (NAUTILUS_VIEW (view), control);
-
- view->details->selection_location = NULL;
- g_signal_connect_object (view, "load_location",
- G_CALLBACK (load_location_callback), view, 0);
- view->details->selecting = FALSE;
-
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
- filtering_changed_callback, view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
- filtering_changed_callback, view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
- filtering_changed_callback, view);
-
- g_signal_connect_object (nautilus_icon_factory_get(), "icons_changed",
- G_CALLBACK (theme_changed_callback), view, 0);
-
-}
-
-static void
-nautilus_tree_view_dispose (GObject *object)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (object);
-
- if (view->details->drag_dest) {
- g_object_unref (view->details->drag_dest);
- view->details->drag_dest = NULL;
- }
-
- if (view->details->show_selection_idle_id) {
- g_source_remove (view->details->show_selection_idle_id);
- view->details->show_selection_idle_id = 0;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-nautilus_tree_view_finalize (GObject *object)
-{
- NautilusTreeView *view;
-
- view = NAUTILUS_TREE_VIEW (object);
-
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
- filtering_changed_callback, view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
- filtering_changed_callback, view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
- filtering_changed_callback, view);
-
- cancel_activation (view);
-
- if (view->details->selection_location != NULL) {
- g_free (view->details->selection_location);
- }
-
- g_free (view->details);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-nautilus_tree_view_class_init (NautilusTreeViewClass *class)
-{
- G_OBJECT_CLASS (class)->dispose = nautilus_tree_view_dispose;
- G_OBJECT_CLASS (class)->finalize = nautilus_tree_view_finalize;
-}
diff --git a/components/tree/nautilus-tree-view.h b/components/tree/nautilus-tree-view.h
deleted file mode 100644
index aef643080..000000000
--- a/components/tree/nautilus-tree-view.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Copyright (C) 2000, 2001 Eazel, Inc
- * Copyright (C) 2002 Anders Carlsson
- *
- * 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: Maciej Stachowiak <mjs@eazel.com>
- * Anders Carlsson <andersca@gnu.org>
- */
-
-/* nautilus-tree-view.h - tree view. */
-
-
-#ifndef NAUTILUS_TREE_VIEW_H
-#define NAUTILUS_TREE_VIEW_H
-
-#include <libnautilus/nautilus-view.h>
-
-#define NAUTILUS_TYPE_TREE_VIEW (nautilus_tree_view_get_type ())
-#define NAUTILUS_TREE_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TREE_VIEW, NautilusTreeView))
-#define NAUTILUS_TREE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TREE_VIEW, NautilusTreeViewClass))
-#define NAUTILUS_IS_TREE_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TREE_VIEW))
-#define NAUTILUS_IS_TREE_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TREE_VIEW))
-
-typedef struct NautilusTreeViewDetails NautilusTreeViewDetails;
-
-typedef struct {
- NautilusView parent;
- NautilusTreeViewDetails *details;
-} NautilusTreeView;
-
-typedef struct {
- NautilusViewClass parent_class;
-} NautilusTreeViewClass;
-
-GType nautilus_tree_view_get_type (void);
-
-#endif /* NAUTILUS_TREE_VIEW_H */