Commit 49f7a162 authored by Darin Adler's avatar Darin Adler

Started some cleanup of the icon view.

	* libnautilus/Makefile.am:
	libnautilus/gnome-icon-container-layout.c:
	libnautilus/gnome-icon-container-layout.h:
	libnautilus/gnome-icon-container.c:
	libnautilus/gnome-icon-container.h:
	src/file-manager/fm-directory-view-icons.c:
	src/file-manager/fm-directory-view-icons.h:
	Got rid of the GnomeIconContainerLayout.
	This was the old mechanism for saving and loading
	icon positions and we have a better signal-based one.
	Also made the new mechanism work more the way that
	Ettore had intended to make the layout work, where
	all the icons that have preassigned positions get
	positioned first, then the ones that are auto positioned.
	In the long run, we'll need something a bit fancier.

	* libnautilus/gnome-icon-container-dnd.c:
	libnautilus/gnome-icon-container.c:
	libnautilus/gnome-icon-container.h:
	libnautilus/gnome-icon-container-private.h:
	Change the priv pointer to be named details to match
	what we use in other places in Nautilus.
parent 7c1de70b
2000-01-21 Darin Adler <darin@eazel.com>
Started some cleanup of the icon view.
* libnautilus/Makefile.am:
libnautilus/gnome-icon-container-layout.c:
libnautilus/gnome-icon-container-layout.h:
libnautilus/gnome-icon-container.c:
libnautilus/gnome-icon-container.h:
src/file-manager/fm-directory-view-icons.c:
src/file-manager/fm-directory-view-icons.h:
Got rid of the GnomeIconContainerLayout.
This was the old mechanism for saving and loading
icon positions and we have a better signal-based one.
Also made the new mechanism work more the way that
Ettore had intended to make the layout work, where
all the icons that have preassigned positions get
positioned first, then the ones that are auto positioned.
In the long run, we'll need something a bit fancier.
* libnautilus/gnome-icon-container-dnd.c:
libnautilus/gnome-icon-container.c:
libnautilus/gnome-icon-container.h:
libnautilus/gnome-icon-container-private.h:
Change the priv pointer to be named details to match
what we use in other places in Nautilus.
2000-01-21 John Sullivan <sullivan@eazel.com>
Made list view activation work on single click, like icon view.
......@@ -16,13 +43,13 @@
is true, selection isn't being extended, mouse hasn't moved to a different
row, and not too much time has passed.
(gtk_flist_motion): Deploy button_down_row name change.
2000-01-20 Andy Hertzfeld <andy@eazel.com>
* libnautilus/gnome-icon-container.c:
disabled the pernicious call to relayout in size_allocate. We will want to do automatic layout
when the window size changes, but this is the wrong level for it, it happens too frequently
Disabled the pernicious call to relayout in size_allocate. We
will want to do automatic layout when the window size changes, but
this is the wrong level for it, it happens too frequently
2000-01-20 Elliot Lee <sopwith@redhat.com>
......@@ -372,10 +399,11 @@
2000-01-18 Andy Hertzfeld <andy@eazel.com>
* libnautilus/gnome-icon-container.c
made icon centered in cell by setting "x_set" pixbuf property so it listens to our offset
also, adjusted x_offset constant
made icon centered in cell by setting "x_set" pixbuf property so
it listens to our offset also, adjusted x_offset constant
* libnautilus/gnome-icon-container-dnd.c
made shadow be centered properly by taking difference between cellwidth and iconwidth into account
made shadow be centered properly by taking difference between
cellwidth and iconwidth into account
2000-01-18 Ettore Perazzoli <ettore@helixcode.com>
......@@ -598,7 +626,8 @@
added "single_click_mode" boolean
*libnautilus/gnome-icon-container.h
made single-click open optionally work by adding code in button_release_event to activate the icon if appropriate
made single-click open optionally work by adding code in
button_release_event to activate the icon if appropriate
enabled single-click mode by default
*libnautilus/gnome-icon-container-dnd.c
......
......@@ -23,7 +23,6 @@ libnautilusincludedir=$(includedir)/libnautilus
libnautilusinclude_HEADERS= \
gdk-extensions.h \
gnome-icon-container-dnd.h \
gnome-icon-container-layout.h \
gnome-icon-container-private.h \
gnome-icon-container.h \
gnome-progressive-loader.c \
......@@ -46,7 +45,6 @@ libnautilusinclude_HEADERS= \
libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gdk-extensions.c \
gnome-icon-container-dnd.c \
gnome-icon-container-layout.c \
gnome-icon-container.c \
gtkflist.c \
gtkscrollframe.c \
......
......@@ -76,7 +76,7 @@ create_selection_shadow (GnomeIconContainer *container,
if (list == NULL)
return NULL;
stipple = container->priv->dnd_info->stipple;
stipple = container->details->dnd_info->stipple;
g_return_val_if_fail (stipple != NULL, NULL);
icon_width = GNOME_ICON_CONTAINER_ICON_WIDTH (container);
......@@ -199,13 +199,13 @@ static void
set_gnome_icon_list_selection (GnomeIconContainer *container,
GtkSelectionData *selection_data)
{
GnomeIconContainerPrivate *priv;
GnomeIconContainerDetails *details;
GList *p;
GString *data;
gdouble x_offset, y_offset;
priv = container->priv;
if (priv->icons == NULL) {
details = container->details;
if (details->icons == NULL) {
/* FIXME? Actually this probably shouldn't happen. */
gtk_selection_data_set (selection_data,
selection_data->target,
......@@ -213,11 +213,11 @@ set_gnome_icon_list_selection (GnomeIconContainer *container,
return;
}
x_offset = container->priv->dnd_info->start_x;
y_offset = container->priv->dnd_info->start_y;
x_offset = container->details->dnd_info->start_x;
y_offset = container->details->dnd_info->start_y;
data = g_string_new (NULL);
for (p = priv->icons; p != NULL; p = p->next) {
for (p = details->icons; p != NULL; p = p->next) {
GnomeIconContainerIcon *icon;
gchar *s;
gint x, y;
......@@ -234,9 +234,9 @@ set_gnome_icon_list_selection (GnomeIconContainer *container,
y += (GNOME_ICON_CONTAINER_ICON_YOFFSET (container)
- GNOME_ICON_CONTAINER_ICON_HEIGHT (container) / 2);
if (priv->base_uri != NULL)
if (details->base_uri != NULL)
s = g_strdup_printf ("%s/%s\r%d:%d\r\n",
priv->base_uri, icon->text,
details->base_uri, icon->text,
x, y);
else
s = g_strdup_printf ("%s\r%d:%d\r\n",
......@@ -258,13 +258,13 @@ static void
set_uri_list_selection (GnomeIconContainer *container,
GtkSelectionData *selection_data)
{
GnomeIconContainerPrivate *priv;
GnomeIconContainerDetails *details;
GList *p;
gchar *temp_data;
GString *data;
priv = container->priv;
if (priv->icons == NULL) {
details = container->details;
if (details->icons == NULL) {
/* FIXME? Actually this probably shouldn't happen. */
gtk_selection_data_set (selection_data,
selection_data->target,
......@@ -274,14 +274,14 @@ set_uri_list_selection (GnomeIconContainer *container,
data = g_string_new (NULL);
for (p = priv->icons; p != NULL; p = p->next) {
for (p = details->icons; p != NULL; p = p->next) {
GnomeIconContainerIcon *icon;
icon = p->data;
if (! icon->is_selected)
continue;
temp_data = g_strdup_printf ("%s/%s\r\n", priv->base_uri, icon->text);
temp_data = g_strdup_printf ("%s/%s\r\n", details->base_uri, icon->text);
g_string_append(data, temp_data);
g_free(temp_data);
}
......@@ -332,7 +332,7 @@ get_gnome_icon_list_selection (GnomeIconContainer *container,
const guchar *p, *oldp;
gint size;
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
oldp = data->data;
size = data->length;
......@@ -410,7 +410,7 @@ gnome_icon_container_position_shadow (GnomeIconContainer *container,
GnomeCanvasItem *shadow;
double world_x, world_y;
shadow = container->priv->dnd_info->shadow;
shadow = container->details->dnd_info->shadow;
if (shadow == NULL)
return;
......@@ -431,7 +431,7 @@ gnome_icon_container_dropped_icon_feedback (GtkWidget *widget,
double world_x, world_y;
container = GNOME_ICON_CONTAINER (widget);
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
/* delete old selection list if any */
......@@ -472,7 +472,7 @@ drag_data_received_cb (GtkWidget *widget,
{
GnomeIconContainerDndInfo *dnd_info;
dnd_info = GNOME_ICON_CONTAINER (widget)->priv->dnd_info;
dnd_info = GNOME_ICON_CONTAINER (widget)->details->dnd_info;
dnd_info->got_data_type = TRUE;
dnd_info->data_type = info;
......@@ -497,7 +497,7 @@ gnome_icon_container_ensure_drag_data (GnomeIconContainer *container,
{
GnomeIconContainerDndInfo *dnd_info;
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
if (!dnd_info->got_data_type)
gtk_drag_get_data (GTK_WIDGET (container), context,
......@@ -528,7 +528,7 @@ drag_end_cb (GtkWidget *widget,
GnomeIconContainerDndInfo *dnd_info;
container = GNOME_ICON_CONTAINER (widget);
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
destroy_selection_list (dnd_info->selection_list);
dnd_info->selection_list = NULL;
......@@ -564,7 +564,7 @@ gnome_icon_container_receive_dropped_icons (GnomeIconContainer *container,
DndSelectionItem *item;
char *item_directory_uri;
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
if (dnd_info->selection_list == NULL)
return;
......@@ -572,7 +572,7 @@ gnome_icon_container_receive_dropped_icons (GnomeIconContainer *container,
item = dnd_info->selection_list->data;
item_directory_uri = extract_directory(item->uri);
if (strcmp(item_directory_uri, container->priv->base_uri) != 0) {
if (strcmp(item_directory_uri, container->details->base_uri) != 0) {
g_warning ("not implemented: drop from other directory: %s", item_directory_uri);
} else {
/* copy files in same directory */
......@@ -601,7 +601,7 @@ gnome_icon_container_free_drag_data (GnomeIconContainer *container)
{
GnomeIconContainerDndInfo *dnd_info;
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
dnd_info->got_data_type = FALSE;
......@@ -626,7 +626,7 @@ drag_drop_cb (GtkWidget *widget,
{
GnomeIconContainerDndInfo *dnd_info;
dnd_info = GNOME_ICON_CONTAINER (widget)->priv->dnd_info;
dnd_info = GNOME_ICON_CONTAINER (widget)->details->dnd_info;
gnome_icon_container_ensure_drag_data (GNOME_ICON_CONTAINER (widget), context, time);
......@@ -704,7 +704,7 @@ gnome_icon_container_dnd_init (GnomeIconContainer *container,
gtk_signal_connect (GTK_OBJECT (container), "drag_leave",
GTK_SIGNAL_FUNC (drag_leave_cb), NULL);
container->priv->dnd_info = dnd_info;
container->details->dnd_info = dnd_info;
}
void
......@@ -715,7 +715,7 @@ gnome_icon_container_dnd_fini (GnomeIconContainer *container)
g_return_if_fail (container != NULL);
g_return_if_fail (GNOME_IS_ICON_CONTAINER (container));
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
g_return_if_fail (dnd_info != NULL);
gtk_target_list_unref (dnd_info->target_list);
......@@ -747,7 +747,7 @@ gnome_icon_container_dnd_begin_drag (GnomeIconContainer *container,
g_return_if_fail (GNOME_IS_ICON_CONTAINER (container));
g_return_if_fail (event != NULL);
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
g_return_if_fail (dnd_info != NULL);
/* Notice that the event is already in world coordinates, because of
......@@ -762,7 +762,7 @@ gnome_icon_container_dnd_begin_drag (GnomeIconContainer *container,
(GdkEvent *) event);
/* create a pixmap and mask to drag with */
pixbuf_item = GNOME_CANVAS_ITEM (container->priv->drag_icon->image_item);
pixbuf_item = GNOME_CANVAS_ITEM (container->details->drag_icon->image_item);
pixbuf_args[0].name = "GnomeCanvasPixbuf::pixbuf";
gtk_object_getv (GTK_OBJECT (pixbuf_item), 1, pixbuf_args);
temp_pixbuf = (GdkPixbuf *) GTK_VALUE_OBJECT (pixbuf_args[0]);
......@@ -782,6 +782,6 @@ gnome_icon_container_dnd_end_drag (GnomeIconContainer *container)
g_return_if_fail (container != NULL);
g_return_if_fail (GNOME_IS_ICON_CONTAINER (container));
dnd_info = container->priv->dnd_info;
dnd_info = container->details->dnd_info;
g_return_if_fail (dnd_info != NULL);
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gnome-icon-layout.c
Copyright (C) 1999, 2000 Free Software Foundation
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.
Author: Ettore Perazzoli <ettore@gnu.org>
*/
#include "gnome-icon-container-layout.h"
struct _IconLayoutInfo {
gchar *text;
gint x, y;
};
typedef struct _IconLayoutInfo IconLayoutInfo;
struct _GnomeIconContainerLayout {
GHashTable *name_to_layout;
};
GnomeIconContainerLayout *
gnome_icon_container_layout_new (void)
{
GnomeIconContainerLayout *new;
new = g_new (GnomeIconContainerLayout, 1);
new->name_to_layout = g_hash_table_new (g_str_hash, g_str_equal);
return new;
}
static void
hash_foreach_destroy (gpointer key,
gpointer value,
gpointer data)
{
IconLayoutInfo *info;
info = (IconLayoutInfo *) value;
g_free (info->text);
g_free (info);
}
void
gnome_icon_container_layout_free (GnomeIconContainerLayout *layout)
{
g_return_if_fail (layout != NULL);
g_hash_table_foreach (layout->name_to_layout,
hash_foreach_destroy, NULL);
g_hash_table_destroy (layout->name_to_layout);
g_free (layout);
}
void
gnome_icon_container_layout_add (GnomeIconContainerLayout *layout,
const gchar *icon_text,
gint x,
gint y)
{
IconLayoutInfo *info;
g_return_if_fail (layout != NULL);
g_return_if_fail (icon_text != NULL);
info = g_new (IconLayoutInfo, 1);
info->text = g_strdup (icon_text);
info->x = x;
info->y = y;
g_hash_table_remove (layout->name_to_layout, info->text);
g_hash_table_insert (layout->name_to_layout, info->text, info);
}
gboolean
gnome_icon_container_layout_get_position (const GnomeIconContainerLayout *layout,
const gchar *icon_text,
gint *x_return,
gint *y_return)
{
IconLayoutInfo *info;
g_return_val_if_fail (layout != NULL, FALSE);
g_return_val_if_fail (icon_text != NULL, FALSE);
info = g_hash_table_lookup (layout->name_to_layout, icon_text);
if (info == NULL)
return FALSE;
*x_return = info->x;
*y_return = info->y;
return TRUE;
}
struct _ForeachData {
GnomeIconContainerLayout *layout;
GnomeIconContainerLayoutForeachFunc callback;
gpointer callback_data;
};
typedef struct _ForeachData ForeachData;
static void
foreach_helper (gpointer key,
gpointer value,
gpointer user_data)
{
IconLayoutInfo *info;
ForeachData *data;
info = (IconLayoutInfo *) value;
data = (ForeachData *) user_data;
(* data->callback) (data->layout, info->text, info->x, info->y,
data->callback_data);
}
void
gnome_icon_container_layout_foreach (GnomeIconContainerLayout *layout,
GnomeIconContainerLayoutForeachFunc callback,
gpointer callback_data)
{
ForeachData *data;
g_return_if_fail (layout != NULL);
g_return_if_fail (callback != NULL);
data = g_new (ForeachData, 1);
data->layout = layout;
data->callback = callback;
data->callback_data = callback_data;
g_hash_table_foreach (layout->name_to_layout, foreach_helper, data);
g_free (data);
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gnome-icon-layout.h
Copyright (C) 1999, 2000 Free Software Foundation
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.
Author: Ettore Perazzoli <ettore@gnu.org>
*/
#ifndef _GNOME_ICON_CONTAINER_LAYOUT_H
#define _GNOME_ICON_CONTAINER_LAYOUT_H
#include <glib.h>
typedef struct _GnomeIconContainerLayout GnomeIconContainerLayout;
typedef void (* GnomeIconContainerLayoutForeachFunc)
(const GnomeIconContainerLayout *layout,
const gchar *text,
gint x, gint y,
gpointer callback_data);
GnomeIconContainerLayout *
gnome_icon_container_layout_new (void);
void gnome_icon_container_layout_free (GnomeIconContainerLayout *layout);
void gnome_icon_container_layout_add (GnomeIconContainerLayout *layout,
const gchar *icon,
gint x,
gint y);
gboolean
gnome_icon_container_layout_get_position (const GnomeIconContainerLayout *layout,
const gchar *icon,
gint *x_return,
gint *y_return);
void gnome_icon_container_layout_foreach (GnomeIconContainerLayout *layout,
GnomeIconContainerLayoutForeachFunc callback,
gpointer callback_data);
#endif /* _GNOME_ICON_CONTAINER_LAYOUT_H */
......@@ -21,8 +21,8 @@
Author: Ettore Perazzoli <ettore@gnu.org>
*/
#ifndef _GNOME_ICON_CONTAINER_PRIVATE_H
#define _GNOME_ICON_CONTAINER_PRIVATE_H
#ifndef GNOME_ICON_CONTAINER_PRIVATE_H
#define GNOME_ICON_CONTAINER_PRIVATE_H
#include "gnome-icon-container.h"
#include "gnome-icon-container-dnd.h"
......@@ -106,7 +106,7 @@ struct _GnomeIconContainerRubberbandInfo {
};
typedef struct _GnomeIconContainerRubberbandInfo GnomeIconContainerRubberbandInfo;
struct _GnomeIconContainerPrivate {
struct _GnomeIconContainerDetails {
/* Base URI for Drag & Drop. */
gchar *base_uri;
......@@ -200,24 +200,24 @@ typedef struct _GnomeIconContainerIconModeInfo GnomeIconContainerIconModeInfo;
extern GnomeIconContainerIconModeInfo gnome_icon_container_icon_mode_info[];
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].icon_width
gnome_icon_container_icon_mode_info[container->details->icon_mode].icon_width
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].icon_height
gnome_icon_container_icon_mode_info[container->details->icon_mode].icon_height
#define GNOME_ICON_CONTAINER_CELL_WIDTH(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].cell_width
gnome_icon_container_icon_mode_info[container->details->icon_mode].cell_width
#define GNOME_ICON_CONTAINER_CELL_HEIGHT(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].cell_height
gnome_icon_container_icon_mode_info[container->details->icon_mode].cell_height
#define GNOME_ICON_CONTAINER_CELL_SPACING(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].cell_spacing
gnome_icon_container_icon_mode_info[container->details->icon_mode].cell_spacing
#define GNOME_ICON_CONTAINER_ICON_XOFFSET(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].icon_xoffset
gnome_icon_container_icon_mode_info[container->details->icon_mode].icon_xoffset
#define GNOME_ICON_CONTAINER_ICON_YOFFSET(container) \
gnome_icon_container_icon_mode_info[container->priv->icon_mode].icon_yoffset
gnome_icon_container_icon_mode_info[container->details->icon_mode].icon_yoffset
#endif /* _GNOME_ICON_CONTAINER_PRIVATE_H */
#endif /* GNOME_ICON_CONTAINER_PRIVATE_H */
......@@ -33,17 +33,9 @@ enum _GnomeIconContainerIconMode {
};
typedef enum _GnomeIconContainerIconMode GnomeIconContainerIconMode;
enum _GnomeIconContainerLayoutMode {
GNOME_ICON_LAYOUT_MANUAL,
GNOME_ICON_LAYOUT_AUTO
};
typedef enum _GnomeIconContainerLayoutMode GnomeIconContainerLayoutMode;
typedef struct _GnomeIconContainer GnomeIconContainer;
typedef struct _GnomeIconContainerClass GnomeIconContainerClass;
typedef struct _GnomeIconContainerPrivate GnomeIconContainerPrivate;
#include "gnome-icon-container-layout.h"
typedef struct _GnomeIconContainerDetails GnomeIconContainerDetails;
#define GNOME_ICON_CONTAINER(obj) \
......@@ -62,7 +54,7 @@ typedef gint (* GnomeIconContainerSortFunc) (const gchar *name_a,
struct _GnomeIconContainer {
GnomeCanvas canvas;
GnomeIconContainerPrivate *priv;
GnomeIconContainerDetails *details;
};
struct _GnomeIconContainerClass {
......@@ -119,14 +111,6 @@ void gnome_icon_container_add_pixbuf_auto
GdkPixbuf *image,
const gchar *text,
gpointer data);
gboolean gnome_icon_container_add_pixbuf_with_layout
(GnomeIconContainer
*container,
GdkPixbuf *image,
const gchar *text,
gpointer data,
const GnomeIconContainerLayout
*layout);
gpointer gnome_icon_container_get_icon_data
(GnomeIconContainer *view,
......@@ -155,7 +139,4 @@ void gnome_icon_container_xlate_selected
gint amount_y,
gboolean raise);
GnomeIconContainerLayout *
gnome_icon_container_get_layout
(GnomeIconContainer *container);
#endif
......@@ -23,7 +23,6 @@ libnautilusincludedir=$(includedir)/libnautilus
libnautilusinclude_HEADERS= \
gdk-extensions.h \
gnome-icon-container-dnd.h \
gnome-icon-container-layout.h \
gnome-icon-container-private.h \
gnome-icon-container.h \
gnome-progressive-loader.c \
......@@ -46,7 +45,6 @@ libnautilusinclude_HEADERS= \
libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gdk-extensions.c \
gnome-icon-container-dnd.c \
gnome-icon-container-layout.c \
gnome-icon-container.c \
gtkflist.c \
gtkscrollframe.c \
......