Commit 61fe873c authored by Darin Adler's avatar Darin Adler

Remove. Remove. Remove. Remove. Remove.

	* components/tree/nautilus-tree-change-queue.c: Remove.
	* components/tree/nautilus-tree-change-queue.h: Remove.
	* components/tree/nautilus-tree-view-dnd.c: Remove.
	* components/tree/nautilus-tree-view-dnd.h: Remove.
	* components/tree/nautilus-tree-view-private.h: Remove.

	* libnautilus-private/Makefile.am:
	* libnautilus-private/nautilus-dnd.c:
	* libnautilus-private/nautilus-dnd.h:
	Move eel-dnd.[ch] back into Nautilus, because it currently is
	completely file-manager-specific.

	* libnautilus-private/nautilus-file-dnd.c:
	* libnautilus-private/nautilus-file-dnd.h:
	* libnautilus-private/nautilus-icon-dnd.c:
	* libnautilus-private/nautilus-icon-dnd.h:
	* src/file-manager/fm-icon-view.c:
	* src/file-manager/fm-list-view.c:
	Change to use eel-dnd.[ch] in their new location in Nautilus.

	* src/file-manager/fm-directory-view.c: Add included needed due
	to include changes.
parent c1758967
2002-02-05 Darin Adler <darin@bentspoon.com>
* components/tree/nautilus-tree-change-queue.c: Remove.
* components/tree/nautilus-tree-change-queue.h: Remove.
* components/tree/nautilus-tree-view-dnd.c: Remove.
* components/tree/nautilus-tree-view-dnd.h: Remove.
* components/tree/nautilus-tree-view-private.h: Remove.
* libnautilus-private/Makefile.am:
* libnautilus-private/nautilus-dnd.c:
* libnautilus-private/nautilus-dnd.h:
Move eel-dnd.[ch] back into Nautilus, because it currently is
completely file-manager-specific.
* libnautilus-private/nautilus-file-dnd.c:
* libnautilus-private/nautilus-file-dnd.h:
* libnautilus-private/nautilus-icon-dnd.c:
* libnautilus-private/nautilus-icon-dnd.h:
* src/file-manager/fm-icon-view.c:
* src/file-manager/fm-list-view.c:
Change to use eel-dnd.[ch] in their new location in Nautilus.
* src/file-manager/fm-directory-view.c: Add included needed due
to include changes.
2002-02-05 Anders Carlsson <andersca@gnu.org>
* components/tree/Makefile.am:
......
/* -*- 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-change-queue.c - Class to help pool changes and defer
them to an idle handler. */
#include <config.h>
#include "nautilus-tree-change-queue.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
struct NautilusTreeChangeQueueDetails {
GSList *head;
GSList *tail;
};
static void nautilus_tree_change_queue_destroy (GtkObject *object);
static void nautilus_tree_change_queue_init (gpointer object,
gpointer klass);
static void nautilus_tree_change_queue_class_init (gpointer klass);
EEL_CLASS_BOILERPLATE (NautilusTreeChangeQueue, nautilus_tree_change_queue, GTK_TYPE_OBJECT)
static NautilusTreeChange *nautilus_tree_change_new (NautilusTreeChangeType change_type,
NautilusTreeNode *node);
/* type system infrastructure code */
static void
nautilus_tree_change_queue_class_init (gpointer klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = nautilus_tree_change_queue_destroy;
}
static void
nautilus_tree_change_queue_init (gpointer object,
gpointer klass)
{
NautilusTreeChangeQueue *change_queue;
change_queue = NAUTILUS_TREE_CHANGE_QUEUE (object);
change_queue->details = g_new0 (NautilusTreeChangeQueueDetails, 1);
}
static void
nautilus_tree_change_queue_destroy (GtkObject *object)
{
NautilusTreeChangeQueue *queue;
queue = (NautilusTreeChangeQueue *) object;
eel_g_slist_free_deep_custom (queue->details->head,
(GFunc) nautilus_tree_change_free,
NULL);
g_free (queue->details);
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
NautilusTreeChangeQueue *
nautilus_tree_change_queue_new (void)
{
NautilusTreeChangeQueue *change_queue;
change_queue = NAUTILUS_TREE_CHANGE_QUEUE (g_object_new (NAUTILUS_TYPE_TREE_CHANGE_QUEUE, NULL));
g_object_ref (change_queue);
gtk_object_sink (GTK_OBJECT (change_queue));
return change_queue;
}
void
nautilus_tree_change_queue_enqueue (NautilusTreeChangeQueue *queue,
NautilusTreeChangeType change_type,
NautilusTreeNode *node)
{
NautilusTreeChange *change;
change = nautilus_tree_change_new (change_type, node);
if (queue->details->head == NULL) {
queue->details->head = g_slist_prepend (NULL, change);
queue->details->tail = queue->details->head;
} else {
g_slist_append (queue->details->tail, change);
queue->details->tail = queue->details->tail->next;
}
}
NautilusTreeChange *
nautilus_tree_change_queue_dequeue (NautilusTreeChangeQueue *queue)
{
NautilusTreeChange *change;
GSList *tmp_slist;
if (queue->details->head == NULL) {
return NULL;
}
change = (NautilusTreeChange *) queue->details->head->data;
/* Remove head from list */
tmp_slist = queue->details->head;
queue->details->head = queue->details->head->next;
tmp_slist->next = NULL;
g_slist_free (tmp_slist);
if (queue->details->head == NULL) {
queue->details->tail = NULL;
}
return change;
}
static NautilusTreeChange *
nautilus_tree_change_new (NautilusTreeChangeType change_type,
NautilusTreeNode *node)
{
NautilusTreeChange *change;
change = g_new0 (NautilusTreeChange, 1);
change->change_type = change_type;
g_object_ref (node);
change->node = node;
return change;
}
void
nautilus_tree_change_free (NautilusTreeChange *change)
{
g_object_unref (change->node);
g_free (change);
}
/* -*- 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-change-queue.h - Class to help pool changes and defer
them to an idle handler. */
#ifndef NAUTILUS_TREE_CHANGE_QUEUE_H
#define NAUTILUS_TREE_CHANGE_QUEUE_H
#include <gtk/gtkobject.h>
#include "nautilus-tree-node.h"
typedef struct NautilusTreeChangeQueue NautilusTreeChangeQueue;
typedef struct NautilusTreeChangeQueueClass NautilusTreeChangeQueueClass;
#define NAUTILUS_TYPE_TREE_CHANGE_QUEUE (nautilus_tree_change_queue_get_type ())
#define NAUTILUS_TREE_CHANGE_QUEUE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TREE_CHANGE_QUEUE, NautilusTreeChangeQueue))
#define NAUTILUS_TREE_CHANGE_QUEUE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TREE_CHANGE_QUEUE, NautilusTreeChangeQueueClass))
#define NAUTILUS_IS_TREE_CHANGE_QUEUE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TREE_CHANGE_QUEUE))
#define NAUTILUS_IS_TREE_CHANGE_QUEUE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TREE_CHANGE_QUEUE))
typedef enum {
NAUTILUS_TREE_CHANGE_TYPE_CHANGED,
NAUTILUS_TREE_CHANGE_TYPE_REMOVED,
NAUTILUS_TREE_CHANGE_TYPE_DONE_LOADING
} NautilusTreeChangeType;
typedef struct {
NautilusTreeChangeType change_type;
NautilusTreeNode *node;
} NautilusTreeChange;
typedef struct NautilusTreeChangeQueueDetails NautilusTreeChangeQueueDetails;
struct NautilusTreeChangeQueue {
GtkObject parent;
NautilusTreeChangeQueueDetails *details;
};
struct NautilusTreeChangeQueueClass {
GtkObjectClass parent_class;
};
GtkType nautilus_tree_change_queue_get_type (void);
NautilusTreeChangeQueue * nautilus_tree_change_queue_new (void);
void nautilus_tree_change_queue_enqueue (NautilusTreeChangeQueue *queue,
NautilusTreeChangeType change_type,
NautilusTreeNode *node);
NautilusTreeChange * nautilus_tree_change_queue_dequeue (NautilusTreeChangeQueue *queue);
void nautilus_tree_change_free (NautilusTreeChange *change);
#endif /* NAUTILUS_TREE_CHANGE_QUEUE_H */
This diff is collapsed.
/* -*- 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: Mathieu Lacage <mathieu@eazel.com>
*/
#ifndef NAUTILUS_TREE_VIEW_DND_H
#define NAUTILUS_TREE_VIEW_DND_H
#include <eel/eel-dnd.h>
#include "nautilus-tree-view-private.h"
struct NautilusTreeViewDndDetails {
EelDragInfo *drag_info;
/* data setup by button_press signal for dragging */
/* coordinates of the begening of a drag/press event */
int press_x, press_y;
/* used to remember between press/release that we pressed
a hot spot. */
gboolean pressed_hot_spot;
/* used to remember between motion events that we are
tracking a drag. */
gboolean drag_pending;
/* used to remmeber in motion_notify events which buton
was pressed. */
guint pressed_button;
/* data used by the drag_motion code */
GSList *expanded_nodes;
/* row being highlighted */
EelCTreeNode *current_prelighted_node;
GtkStyle *normal_style;
GtkStyle *highlight_style;
};
#endif /* NAUTILUS_TREE_VIEW_DND_H */
/* -*- 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.
*
* Authors:
* Maciej Stachowiak <mjs@eazel.com>
*/
#ifndef NAUTILUS_TREE_VIEW_PRIVATE_H
#define NAUTILUS_TREE_VIEW_PRIVATE_H
#include "nautilus-tree-view.h"
#include "nautilus-tree-change-queue.h"
#include "nautilus-tree-expansion-state.h"
#include "nautilus-tree-model.h"
#include <eel/eel-ctree.h>
#include <libnautilus/nautilus-view.h>
typedef struct NautilusTreeViewDndDetails NautilusTreeViewDndDetails;
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
(clist)->row_list_end : \
g_list_nth ((clist)->row_list, (row)))
/* A NautilusContentView's private information. */
struct NautilusTreeViewDetails {
NautilusView *nautilus_view;
GtkWidget *scrolled_window;
GtkWidget *tree;
NautilusTreeModel *model;
GHashTable *file_to_node_map;
GHashTable *view_node_to_uri_map;
gboolean show_hidden_files;
gboolean show_backup_files;
gboolean show_non_directories;
NautilusTreeExpansionState *expansion_state;
char *selected_uri;
char *current_main_view_uri;
NautilusTreeChangeQueue *change_queue;
guint pending_idle_id;
GList *unparented_tree_nodes;
char *wait_uri;
NautilusTreeNode *wait_node;
GList *in_progress_select_uris;
gboolean root_seen;
gboolean got_first_size_allocate;
gboolean inserting_node;
NautilusFile *activation_uri_wait_file;
NautilusTreeViewDndDetails *dnd;
};
NautilusTreeNode *nautilus_tree_view_node_to_model_node (NautilusTreeView *view,
EelCTreeNode *node);
NautilusFile *nautilus_tree_view_node_to_file (NautilusTreeView *view,
EelCTreeNode *node);
EelCTreeNode *nautilus_tree_view_model_node_to_view_node (NautilusTreeView *view,
NautilusTreeNode *node);
void nautilus_tree_view_init_dnd (NautilusTreeView *view);
void nautilus_tree_view_free_dnd (NautilusTreeView *view);
#endif /* NAUTILUS_TREE_VIEW_PRIVATE_H */
......@@ -59,6 +59,8 @@ libnautilus_private_la_SOURCES = \
nautilus-directory-private.h \
nautilus-directory.c \
nautilus-directory.h \
nautilus-dnd.c \
nautilus-dnd.h \
nautilus-drag-window.c \
nautilus-drag-window.h \
nautilus-entry.c \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-dnd.c - Common Drag & drop handling code shared by the icon container
and the list view.
Copyright (C) 2000, 2001 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: Pavel Cisler <pavel@eazel.com>,
Ettore Perazzoli <ettore@gnu.org>
*/
/* FIXME: This should really be back in Nautilus, not here in Eel. */
#include <config.h>
#include "nautilus-dnd.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkseparatormenuitem.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomevfs/gnome-vfs-find-directory.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <stdio.h>
#include <string.h>
#define COMMAND_SPECIFIER "command:"
/* a set of defines stolen from the eel-icon-dnd.c file.
* These are in microseconds.
*/
#define AUTOSCROLL_TIMEOUT_INTERVAL 100
#define AUTOSCROLL_INITIAL_DELAY 750000
/* drag this close to the view edge to start auto scroll*/
#define AUTO_SCROLL_MARGIN 20
/* the smallest amount of auto scroll used when we just enter the autoscroll
* margin
*/
#define MIN_AUTOSCROLL_DELTA 5
/* the largest amount of auto scroll used when we are right over the view
* edge
*/
#define MAX_AUTOSCROLL_DELTA 50
void
nautilus_drag_init (NautilusDragInfo *drag_info,
const GtkTargetEntry *drag_types, int drag_type_count,
GdkBitmap *stipple)
{
drag_info->target_list = gtk_target_list_new (drag_types,
drag_type_count);
if (stipple != NULL) {
drag_info->stipple = gdk_bitmap_ref (stipple);
}
drag_info->drop_occured = FALSE;
drag_info->need_to_destroy = FALSE;
}
void
nautilus_drag_finalize (NautilusDragInfo *drag_info)
{
gtk_target_list_unref (drag_info->target_list);
nautilus_drag_destroy_selection_list (drag_info->selection_list);
if (drag_info->stipple != NULL) {
gdk_bitmap_unref (drag_info->stipple);
}
g_free (drag_info);
}
/* Functions to deal with NautilusDragSelectionItems. */
NautilusDragSelectionItem *
nautilus_drag_selection_item_new (void)
{
return g_new0 (NautilusDragSelectionItem, 1);
}
static void
drag_selection_item_destroy (NautilusDragSelectionItem *item)
{
g_free (item->uri);
g_free (item);
}
void
nautilus_drag_destroy_selection_list (GList *list)
{
GList *p;
if (list == NULL)
return;
for (p = list; p != NULL; p = p->next)
drag_selection_item_destroy (p->data);
g_list_free (list);
}
GList *
nautilus_drag_build_selection_list (GtkSelectionData *data)
{
GList *result;
const guchar *p, *oldp;
int size;
result = NULL;
oldp = data->data;
size = data->length;
while (size > 0) {
NautilusDragSelectionItem *item;
guint len;
/* The list is in the form:
name\rx:y:width:height\r\n
The geometry information after the first \r is optional. */
/* 1: Decode name. */
p = memchr (oldp, '\r', size);
if (p == NULL) {
break;
}
item = nautilus_drag_selection_item_new ();
len = p - oldp;
item->uri = g_malloc (len + 1);
memcpy (item->uri, oldp, len);
item->uri[len] = 0;
p++;
if (*p == '\n' || *p == '\0') {
result = g_list_prepend (result, item);
if (p == 0) {
g_warning ("Invalid x-special/gnome-icon-list data received: "
"missing newline character.");
break;
} else {
oldp = p + 1;
continue;
}
}
size -= p - oldp;
oldp = p;
/* 2: Decode geometry information. */
item->got_icon_position = sscanf (p, "%d:%d:%d:%d%*s",
&item->icon_x, &item->icon_y,
&item->icon_width, &item->icon_height) == 4;
if (!item->got_icon_position) {
g_warning ("Invalid x-special/gnome-icon-list data received: "
"invalid icon position specification.");
}
result = g_list_prepend (result, item);
p = memchr (p, '\r', size);
if (p == NULL || p[1] != '\n') {
g_warning ("Invalid x-special/gnome-icon-list data received: "
"missing newline character.");
if (p == NULL) {
break;
}
} else {
p += 2;
}
size -= p - oldp;
oldp = p;
}
return result;
}
gboolean
nautilus_drag_items_local (const char *target_uri_string, const GList *selection_list)
{
/* check if the first item on the list has target_uri_string as a parent
* FIXME:
* we should really test each item but that would be slow for large selections
* and currently dropped items can only be from the same container
*/
GnomeVFSURI *target_uri;
GnomeVFSURI *item_uri;
gboolean result;
/* must have at least one item */
g_assert (selection_list);
result = FALSE;
target_uri = gnome_vfs_uri_new (target_uri_string);
/* get the parent URI of the first item in the selection */
item_uri = gnome_vfs_uri_new (((NautilusDragSelectionItem *)selection_list->data)->uri);
result = gnome_vfs_uri_is_parent (target_uri, item_uri, FALSE);
gnome_vfs_uri_unref (item_uri);
gnome_vfs_uri_unref (target_uri);
return result;
}
gboolean
nautilus_drag_items_in_trash (const GList *selection_list)
{
/* check if the first item on the list is in trash.
* FIXME:
* we should really test each item but that would be slow for large selections
* and currently dropped items can only be from the same container
*/
return eel_uri_is_in_trash (((NautilusDragSelectionItem *)selection_list->data)->uri);
}
void
nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
const char *target_uri_string, const GList *items,
int *default_action, int *non_default_action)
{
gboolean same_fs;
GnomeVFSURI *target_uri;
GnomeVFSURI *dropped_uri;
GdkDragAction actions;
GnomeVFSResult result;
if (target_uri_string == NULL) {
*default_action = 0;
*non_default_action = 0;
return;
}
actions = context->actions & (GDK_ACTION_MOVE | GDK_ACTION_COPY);
if (actions == 0) {
/* We can't use copy or move, just go with the suggested action.
*
* Note: it would be more correct to only choose between move
* and copy if both are specified in context->actions.
* There is a problem in gtk-dnd.c though where context->actions
* gets set only to copy when Control is held down, despite the
* fact that bot copy and move were requested.
*
*/
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
return;
}
/* Check for trash URI. We do a find_directory for any Trash directory. */
if (eel_uri_is_trash (target_uri_string)) {
result = gnome_vfs_find_directory (NULL, GNOME_VFS_DIRECTORY_KIND_TRASH,
&target_uri, TRUE, FALSE, 0777);
if (result != GNOME_VFS_OK) {
*default_action = 0;
*non_default_action = 0;
return;
}
/* Only move to Trash */
*default_action = GDK_ACTION_MOVE;
*non_default_action = GDK_ACTION_MOVE;
return;
} else if (eel_str_has_prefix (target_uri_string, COMMAND_SPECIFIER)) {
*default_action = GDK_ACTION_MOVE;