gnome-icon-container-private.h 6.06 KB
Newer Older
Ettore Perazzoli's avatar
Ettore Perazzoli committed
1
2
3
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gnome-icon-container-private.h

Elliot Lee's avatar
Elliot Lee committed
4
   Copyright (C) 1999, 2000 Free Software Foundation
5
   Copyright (C) 2000 Eazel, Inc.
Ettore Perazzoli's avatar
Ettore Perazzoli committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

   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>
*/

25
26
#ifndef GNOME_ICON_CONTAINER_PRIVATE_H
#define GNOME_ICON_CONTAINER_PRIVATE_H
Ettore Perazzoli's avatar
Ettore Perazzoli committed
27
28
29

#include "gnome-icon-container.h"
#include "gnome-icon-container-dnd.h"
30
#include <libgnomeui/gnome-icon-item.h>
Ettore Perazzoli's avatar
Ettore Perazzoli committed
31
32
33
34
35

/* An Icon.  */

struct _GnomeIconContainerIcon {
	/* Group containing the text and the image.  */
36
	GnomeCanvasItem *item;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
37
38
39
40

	/* X/Y coordinates and size.  We could use the GnomeCanvasItem
           functions, but this is a lot faster.  */
	gdouble x, y;
41
	guint width, height;	
42
        
Ettore Perazzoli's avatar
Ettore Perazzoli committed
43
44
45
46
47
48
49
50
51
52
53
54
	/* Whether this item is selected (i.e. highlighted) for operation.  */
	gboolean is_selected : 1;

	/* Whether this item is selected for keyboard navigation.  */
	gboolean is_current : 1;

	/* Whether this item has been repositioned during layout already.  */
	gboolean layout_done : 1;

	/* Whether this item was selected before rubberbanding.  */
	gboolean was_selected_before_rubberband : 1;

55
	NautilusControllerIcon *data;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
};
typedef struct _GnomeIconContainerIcon GnomeIconContainerIcon;


#define INITIAL_GRID_WIDTH 64
#define INITIAL_GRID_HEIGHT 64
struct _GnomeIconContainerIconGrid {
	/* Size of the grid.  */
	guint width, height;

	/* This is the width that we can actually use for finding an empty
           position.  */
	guint visible_width;

	/* Array of grid elements.  */
	GList **elems;

	/* Size of the allocated array.  */
	guint alloc_width, alloc_height;

	/* Position of the first free cell (used to speed up progressive
	   updates).  If negative, there is no free cell.  */
	gint first_free_x, first_free_y;
};
typedef struct _GnomeIconContainerIconGrid GnomeIconContainerIconGrid;


/* Private GnomeIconContainer members.  */

struct _GnomeIconContainerRubberbandInfo {
	gboolean active : 1;

	gdouble start_x, start_y;

	GnomeCanvasItem *selection_rectangle;
	guint timer_tag;

	guint prev_x, prev_y;
	guint prev_x1, prev_y1;
	guint prev_x2, prev_y2;
};
typedef struct _GnomeIconContainerRubberbandInfo GnomeIconContainerRubberbandInfo;

99
struct _GnomeIconContainerDetails {
100
101
102
103
	NautilusIconsController *controller;

	/* linger selection mode setting. */
	gboolean linger_selection_mode : 1;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
104

105
106
107
	/* single-click mode setting */
	gboolean single_click_mode : 1;
	
Ettore Perazzoli's avatar
Ettore Perazzoli committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	/* Size of the container.  */
	guint width, height;

	/* List of icons.  */
	GList *icons;
	guint num_icons;

	/* The grid.  */
	GnomeIconContainerIconGrid *grid;

	/* FIXME: This is *ugly*, but more efficient (both memory- and
           speed-wise) than using gtk_object_{set,get}_data() for all the
           icon items.  */
	GHashTable *canvas_item_to_icon;

	/* Rectangle that shows that a certain icon is selected.  */
	GnomeCanvasItem *kbd_navigation_rectangle;

	/* Current icon for keyboard navigation.  */
	GnomeIconContainerIcon *kbd_current;

129
	/* Rubberbanding status. */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
130
131
132
133
134
	GnomeIconContainerRubberbandInfo rubberband_info;

	/* Timeout used to make a selected icon fully visible after a short
           period of time.  (The timeout is needed to make sure
           double-clicking still works.)  */
135
	int kbd_icon_visibility_timer_tag;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
136

137
138
139
        /* the time the mouse button went down in milliseconds */
        guint32 button_down_time;
        
Ettore Perazzoli's avatar
Ettore Perazzoli committed
140
	/* Position of the pointer during the last click.  */
141
	int drag_x, drag_y;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
142
143
144
145
146
147
148
149
150
151
152
153
154
155

	/* Button currently pressed, possibly for dragging.  */
	guint drag_button;

	/* Icon on which the click happened.  */
	GnomeIconContainerIcon *drag_icon;

	/* Whether we are actually performing a dragging action.  */
	gboolean doing_drag;

	/* Idle ID.  */
	guint idle_id;

	/* Timeout for selection in browser mode.  */
156
	int linger_selection_mode_timer_tag;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
157
158

	/* Icon to be selected at timeout in browser mode.  */
159
	GnomeIconContainerIcon *linger_selection_mode_icon;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
160
161
162

	/* DnD info.  */
	GnomeIconContainerDndInfo *dnd_info;
163

164
165
166
        /* zoom level */
        gint zoom_level;
        
167
168
        /* default font used to draw labels */
        GdkFont *label_font;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
169
170
};

171
172
173
174
175
176
177
178
179
180
181
182
183
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME:  These are also defined in fm-icon-cache.h and shouldn't be in both places */

typedef enum {
	NAUTILUS_ZOOM_LEVEL_SMALLEST,
	NAUTILUS_ZOOM_LEVEL_SMALLER,
	NAUTILUS_ZOOM_LEVEL_SMALL,
	NAUTILUS_ZOOM_LEVEL_STANDARD,
	NAUTILUS_ZOOM_LEVEL_LARGE,
	NAUTILUS_ZOOM_LEVEL_LARGER,
	NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;

184
185
186
187
/* Layout and icon size constants.
   These will change based on the zoom level eventually, so they
   should probably become function calls instead of macros.
*/
Ettore Perazzoli's avatar
Ettore Perazzoli committed
188

189
190
#define GNOME_ICON_CONTAINER_CELL_WIDTH(container)     80
#define GNOME_ICON_CONTAINER_CELL_HEIGHT(container)    80
Ettore Perazzoli's avatar
Ettore Perazzoli committed
191

192
#define GNOME_ICON_CONTAINER_CELL_SPACING(container)    4
Ettore Perazzoli's avatar
Ettore Perazzoli committed
193

194
195
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container)     48
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container)    48
Ettore Perazzoli's avatar
Ettore Perazzoli committed
196

197
198
199
200
201
202
203
204
GnomeIconContainerIcon *gnome_icon_container_get_icon_by_uri (GnomeIconContainer *container,
							      const char *uri);
void gnome_icon_container_move_icon (GnomeIconContainer *container,
				     GnomeIconContainerIcon *icon,
				     int x, int y, gboolean raise);
void gnome_icon_container_select_list_unselect_others (GnomeIconContainer *container,
						       GList *icons);

205
#endif /* GNOME_ICON_CONTAINER_PRIVATE_H */