nautilus-canvas-private.h 6.27 KB
Newer Older
1
/* gnome-canvas-container-private.h
Ettore Perazzoli's avatar
Ettore Perazzoli committed
2

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

   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,
18
   see <http://www.gnu.org/licenses/>.
Ettore Perazzoli's avatar
Ettore Perazzoli committed
19 20 21 22

   Author: Ettore Perazzoli <ettore@gnu.org>
*/

23
#pragma once
Ettore Perazzoli's avatar
Ettore Perazzoli committed
24

Ramiro Estrugo's avatar
Ramiro Estrugo committed
25
#include <eel/eel-glib-extensions.h>
26 27 28
#include "nautilus-canvas-item.h"
#include "nautilus-canvas-container.h"
#include "nautilus-canvas-dnd.h"
Ettore Perazzoli's avatar
Ettore Perazzoli committed
29

30
/* An Icon. */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
31

32
typedef struct {
33
	/* Object represented by this icon. */
34
	NautilusCanvasIconData *data;
35

36
	/* Canvas item for the icon. */
37
	NautilusCanvasItem *item;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
38

39
	/* X/Y coordinates. */
40
	double x, y;
41 42 43 44 45 46 47 48

	/*
	 * In RTL mode x is RTL x position, we use saved_ltr_x for
	 * keeping track of x value before it gets converted into
	 * RTL value, this is used for saving the icon position 
	 * to the nautilus metafile. 
	 */
	 double saved_ltr_x;
49

50 51 52
	/* Position in the view */
	int position;

53
	/* Whether this item is selected. */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
54
	eel_boolean_bit is_selected : 1;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
55

56
	/* Whether this item was selected before rubberbanding. */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
57
	eel_boolean_bit was_selected_before_rubberband : 1;
58

59 60
	/* Whether this item is visible in the view. */
	eel_boolean_bit is_visible : 1;
61
} NautilusCanvasIcon;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
62

63

64
/* Private NautilusCanvasContainer members. */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
65

66 67
typedef struct {
	gboolean active;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
68

69
	double start_x, start_y;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
70

71
	EelCanvasItem *selection_rectangle;
72
	GdkDevice *device;
73

74
	guint timer_id;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
75 76

	guint prev_x, prev_y;
77
	int last_adj_x;
78
	int last_adj_y;
79
} NautilusCanvasRubberbandInfo;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
80

81
typedef enum {
82 83 84 85
	DRAG_STATE_INITIAL,
	DRAG_STATE_MOVE_OR_COPY,
	DRAG_STATE_STRETCH
} DragState;
86 87 88 89 90 91 92 93 94 95

typedef struct {
	/* Pointer position in canvas coordinates. */
	int pointer_x, pointer_y;

	/* Icon top, left, and size in canvas coordinates. */
	int icon_x, icon_y;
	guint icon_size;
} StretchState;

96 97 98 99 100 101
typedef enum {
	AXIS_NONE,
	AXIS_HORIZONTAL,
	AXIS_VERTICAL
} Axis;

102 103 104
enum {
	LABEL_COLOR,
	LABEL_COLOR_HIGHLIGHT,
105
	LABEL_COLOR_ACTIVE,
106
	LABEL_COLOR_PRELIGHT,
107 108
	LABEL_INFO_COLOR,
	LABEL_INFO_COLOR_HIGHLIGHT,
109
	LABEL_INFO_COLOR_ACTIVE,
110 111 112
	LAST_LABEL_COLOR
};

113
struct NautilusCanvasContainerDetails {
114
	/* List of icons. */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
115
	GList *icons;
116
	GList *new_icons;
117
	GList *selection;
118
	GHashTable *icon_set;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
119

120 121 122 123 124
	/* Currently focused icon for accessibility. */
	NautilusCanvasIcon *focus;
	gboolean keyboard_focus;

	/* Starting icon for keyboard rubberbanding. */
125
	NautilusCanvasIcon *keyboard_rubberband_start;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
126

127
	/* Last highlighted drop target. */
128
	NautilusCanvasIcon *drop_target;
129

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

	/* Timeout used to make a selected icon fully visible after a short
134 135
	 * period of time. (The timeout is needed to make sure
	 * double-clicking still works.)
136
	 */
137
	guint keyboard_icon_reveal_timer_id;
138
	NautilusCanvasIcon *keyboard_icon_to_reveal;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
139

140 141 142
	/* Used to coalesce selection changed signals in some cases */
	guint selection_changed_id;
	
Mike Engber's avatar
Mike Engber committed
143 144 145
	/* If a request is made to reveal an unpositioned icon we remember
	 * it and reveal it once it gets positioned (in relayout).
	 */
146
	NautilusCanvasIcon *pending_icon_to_reveal;
Mike Engber's avatar
Mike Engber committed
147

148
	/* Remembered information about the start of the current event. */
149
	guint32 button_down_time;
150
	
151
	/* Drag state. Valid only if drag_button is non-zero. */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
152
	guint drag_button;
153
	NautilusCanvasIcon *drag_icon;
154
	int drag_x, drag_y;
155
	DragState drag_state;
156
	gboolean drag_started;
Ettore Perazzoli's avatar
Ettore Perazzoli committed
157

158
	gboolean icon_selected_on_button_down;
159
	gboolean double_clicked;
160
	NautilusCanvasIcon *double_click_icon[2]; /* Both clicks in a double click need to be on the same icon */
161
	guint double_click_button[2];
162

163
	NautilusCanvasIcon *range_selection_base_icon;
164
	
165
	/* Idle ID. */
Ettore Perazzoli's avatar
Ettore Perazzoli committed
166 167
	guint idle_id;

168 169 170
	/* Align idle id */
	guint align_idle_id;

171
	/* DnD info. */
172
	NautilusCanvasDndInfo *dnd_info;
173
	NautilusDragInfo *dnd_source_info;
174

175 176
	/* zoom level */
	int zoom_level;
177

178 179 180
	/* specific fonts used to draw labels */
	char *font;
	
181 182
	/* State used so arrow keys don't wander if icons aren't lined up.
	 */
183 184 185
	int arrow_key_start_x;
	int arrow_key_start_y;
	GtkDirectionType arrow_key_direction;
186 187 188

	/* Mode settings. */
	gboolean single_click_mode;
189 190

        /* Set to TRUE after first allocation has been done */
191
	gboolean has_been_allocated;
192 193 194

	int size_allocation_count;
	guint size_allocation_count_id;
195

196 197 198
	/* a11y items used by canvas items */
	guint a11y_item_action_idle_handler;
	GQueue* a11y_item_action_queue;
199

200
	eel_boolean_bit in_layout_now : 1;
201
	eel_boolean_bit is_loading : 1;
202
	eel_boolean_bit is_populating_container : 1;
203
	eel_boolean_bit needs_resort : 1;
204
	eel_boolean_bit selection_needs_resort : 1;
205
};
Ettore Perazzoli's avatar
Ettore Perazzoli committed
206

207
/* Private functions shared by mutiple files. */
208 209 210 211 212 213
NautilusCanvasIcon *nautilus_canvas_container_get_icon_by_uri             (NautilusCanvasContainer *container,
									 const char            *uri);
void          nautilus_canvas_container_select_list_unselect_others (NautilusCanvasContainer *container,
								     GList                 *icons);
char *        nautilus_canvas_container_get_icon_uri                (NautilusCanvasContainer *container,
								       NautilusCanvasIcon          *canvas);
214 215
char *        nautilus_canvas_container_get_icon_activation_uri     (NautilusCanvasContainer *container,
								     NautilusCanvasIcon          *canvas);
216 217 218 219 220 221 222 223
char *        nautilus_canvas_container_get_icon_drop_target_uri    (NautilusCanvasContainer *container,
								       NautilusCanvasIcon          *canvas);
void          nautilus_canvas_container_update_icon                 (NautilusCanvasContainer *container,
								       NautilusCanvasIcon          *canvas);
gboolean      nautilus_canvas_container_scroll                      (NautilusCanvasContainer *container,
								     int                    delta_x,
								     int                    delta_y);
void          nautilus_canvas_container_update_scroll_region        (NautilusCanvasContainer *container);