Mercurial > geeqie.yaz
annotate src/collect-table.c @ 1593:2b2aa3326763
enabled XDG directory layout
author | nadvornik |
---|---|
date | Thu, 07 May 2009 19:34:33 +0000 |
parents | 760f585d9fa0 |
children | 760e8d68290c |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
1284 | 4 * Copyright (C) 2008 - 2009 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 | |
281 | 14 #include "main.h" |
9 | 15 #include "collect-table.h" |
16 | |
17 #include "cellrenderericon.h" | |
18 #include "collect-dlg.h" | |
19 #include "collect-io.h" | |
20 #include "dnd.h" | |
21 #include "dupe.h" | |
22 #include "editors.h" | |
586 | 23 #include "filedata.h" |
9 | 24 #include "img-view.h" |
25 #include "layout.h" | |
26 #include "layout_image.h" | |
27 #include "menu.h" | |
28 #include "print.h" | |
29 #include "utilops.h" | |
30 #include "ui_fileops.h" | |
31 #include "ui_menu.h" | |
32 #include "ui_tree_edit.h" | |
904
1698baa37871
Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents:
826
diff
changeset
|
33 #include "uri_utils.h" |
9 | 34 |
35 #include "icons/marker.xpm" | |
36 #define MARKER_WIDTH 26 | |
37 #define MARKER_HEIGHT 32 | |
38 | |
39 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
40 | |
41 /* between these, the icon width is increased by thumb_max_width / 2 */ | |
42 #define THUMB_MIN_ICON_WIDTH 128 | |
43 #define THUMB_MAX_ICON_WIDTH 150 | |
44 | |
45 #define COLLECT_TABLE_MAX_COLUMNS 32 | |
46 #define THUMB_BORDER_PADDING 2 | |
47 | |
48 #define COLLECT_TABLE_TIP_DELAY 500 | |
274
2710d14f6a28
Fix the "continuous display" of tooltips in the collection view
zas_
parents:
196
diff
changeset
|
49 #define COLLECT_TABLE_TIP_DELAY_PATH (COLLECT_TABLE_TIP_DELAY * 1.7) |
9 | 50 |
51 | |
52 enum { | |
53 CTABLE_COLUMN_POINTER = 0, | |
54 CTABLE_COLUMN_COUNT | |
55 }; | |
56 | |
57 typedef enum { | |
58 SELECTION_NONE = 0, | |
59 SELECTION_SELECTED = 1 << 0, | |
60 SELECTION_PRELIGHT = 1 << 1, | |
61 SELECTION_FOCUS = 1 << 2 | |
62 } SelectionType; | |
63 | |
64 | |
65 #define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED) | |
66 | |
67 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
68 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force); |
9 | 69 |
70 | |
71 /* | |
72 *------------------------------------------------------------------- | |
73 * more misc | |
74 *------------------------------------------------------------------- | |
75 */ | |
76 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
77 static gboolean collection_table_find_position(CollectTable *ct, CollectInfo *info, gint *row, gint *col) |
9 | 78 { |
79 gint n; | |
80 | |
81 n = g_list_index(ct->cd->list, info); | |
82 | |
83 if (n < 0) return FALSE; | |
84 | |
85 *row = n / ct->columns; | |
86 *col = n - (*row * ct->columns); | |
87 | |
88 return TRUE; | |
89 } | |
90 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
91 static gboolean collection_table_find_iter(CollectTable *ct, CollectInfo *info, GtkTreeIter *iter, gint *column) |
9 | 92 { |
93 GtkTreeModel *store; | |
94 gint row, col; | |
95 | |
96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
97 if (!collection_table_find_position(ct, info, &row, &col)) return FALSE; | |
98 if (!gtk_tree_model_iter_nth_child(store, iter, NULL, row)) return FALSE; | |
99 if (column) *column = col; | |
100 | |
101 return TRUE; | |
102 } | |
103 | |
104 static CollectInfo *collection_table_find_data(CollectTable *ct, gint row, gint col, GtkTreeIter *iter) | |
105 { | |
106 GtkTreeModel *store; | |
107 GtkTreeIter p; | |
108 | |
109 if (row < 0 || col < 0) return NULL; | |
110 | |
111 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
112 if (gtk_tree_model_iter_nth_child(store, &p, NULL, row)) | |
113 { | |
114 GList *list; | |
115 | |
116 gtk_tree_model_get(store, &p, CTABLE_COLUMN_POINTER, &list, -1); | |
117 if (!list) return NULL; | |
118 | |
119 if (iter) *iter = p; | |
120 | |
121 return g_list_nth_data(list, col); | |
122 } | |
123 | |
124 return NULL; | |
125 } | |
126 | |
127 static CollectInfo *collection_table_find_data_by_coord(CollectTable *ct, gint x, gint y, GtkTreeIter *iter) | |
128 { | |
129 GtkTreePath *tpath; | |
130 GtkTreeViewColumn *column; | |
777 | 131 GtkTreeModel *store; |
132 GtkTreeIter row; | |
133 GList *list; | |
134 gint n; | |
135 | |
136 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ct->listview), x, y, | |
137 &tpath, &column, NULL, NULL)) | |
138 return NULL; | |
139 | |
140 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
141 gtk_tree_model_get_iter(store, &row, tpath); | |
142 gtk_tree_path_free(tpath); | |
143 | |
144 gtk_tree_model_get(store, &row, CTABLE_COLUMN_POINTER, &list, -1); | |
145 if (!list) return NULL; | |
146 | |
147 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number")); | |
148 if (iter) *iter = row; | |
149 return g_list_nth_data(list, n); | |
9 | 150 } |
151 | |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
152 static guint collection_table_list_count(CollectTable *ct, gint64 *bytes) |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
153 { |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
154 if (bytes) |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
155 { |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
156 gint64 b = 0; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
157 GList *work; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
158 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
159 work = ct->cd->list; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
160 while (work) |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
161 { |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
162 CollectInfo *ci = work->data; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
163 work = work->next; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
164 b += ci->fd->size; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
165 } |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
166 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
167 *bytes = b; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
168 } |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
169 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
170 return g_list_length(ct->cd->list); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
171 } |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
172 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
173 static guint collection_table_selection_count(CollectTable *ct, gint64 *bytes) |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
174 { |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
175 if (bytes) |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
176 { |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
177 gint64 b = 0; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
178 GList *work; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
179 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
180 work = ct->selection; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
181 while (work) |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
182 { |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
183 CollectInfo *ci = work->data; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
184 work = work->next; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
185 b += ci->fd->size; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
186 } |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
187 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
188 *bytes = b; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
189 } |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
190 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
191 return g_list_length(ct->selection); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
192 } |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
193 |
9 | 194 static void collection_table_update_status(CollectTable *ct) |
195 { | |
777 | 196 gchar *buf; |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
197 guint n; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
198 gint64 n_bytes = 0; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
199 guint s; |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
200 gint64 s_bytes = 0; |
777 | 201 |
202 if (!ct->status_label) return; | |
203 | |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
204 n = collection_table_list_count(ct, &n_bytes); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
205 s = collection_table_selection_count(ct, &s_bytes); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
206 |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
207 if (s > 0) |
777 | 208 { |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
209 gchar *b = text_from_size_abrev(n_bytes); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
210 gchar *sb = text_from_size_abrev(s_bytes); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
211 buf = g_strdup_printf(_("%s, %d images (%s, %d)"), b, n, sb, s); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
212 g_free(b); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
213 g_free(sb); |
777 | 214 } |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
215 else if (n > 0) |
9 | 216 { |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
217 gchar *b = text_from_size_abrev(n_bytes); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
218 buf = g_strdup_printf(_("%s, %d images"), b, n); |
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
219 g_free(b); |
9 | 220 } |
777 | 221 else |
222 { | |
826
daebdd1f5bc6
Display total size of files in collection window, for the list and for the selection.
zas_
parents:
783
diff
changeset
|
223 buf = g_strdup(_("Empty")); |
777 | 224 } |
225 | |
226 gtk_label_set_text(GTK_LABEL(ct->status_label), buf); | |
227 g_free(buf); | |
9 | 228 } |
229 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
230 static void collection_table_update_extras(CollectTable *ct, gboolean loading, gdouble value) |
9 | 231 { |
777 | 232 gchar *text; |
233 | |
234 if (!ct->extra_label) return; | |
235 | |
236 if (loading) | |
237 text = _("Loading thumbs..."); | |
238 else | |
239 text = " "; | |
240 | |
241 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ct->extra_label), value); | |
242 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ct->extra_label), text); | |
9 | 243 } |
244 | |
245 static void collection_table_toggle_filenames(CollectTable *ct) | |
246 { | |
247 ct->show_text = !ct->show_text; | |
320 | 248 options->show_icon_names = ct->show_text; |
9 | 249 |
250 collection_table_populate_at_new_size(ct, ct->listview->allocation.width, ct->listview->allocation.height, TRUE); | |
251 } | |
252 | |
253 static gint collection_table_get_icon_width(CollectTable *ct) | |
254 { | |
255 gint width; | |
256 | |
333 | 257 if (!ct->show_text) return options->thumbnails.max_width; |
258 | |
259 width = options->thumbnails.max_width + options->thumbnails.max_width / 2; | |
9 | 260 if (width < THUMB_MIN_ICON_WIDTH) width = THUMB_MIN_ICON_WIDTH; |
333 | 261 if (width > THUMB_MAX_ICON_WIDTH) width = options->thumbnails.max_width; |
9 | 262 |
263 return width; | |
264 } | |
265 | |
266 /* | |
267 *------------------------------------------------------------------- | |
268 * cell updates | |
269 *------------------------------------------------------------------- | |
270 */ | |
271 | |
272 static void collection_table_selection_set(CollectTable *ct, CollectInfo *info, SelectionType value, GtkTreeIter *iter) | |
273 { | |
274 GtkTreeModel *store; | |
275 GList *list; | |
276 | |
277 if (!info) return; | |
278 | |
279 if (info->flag_mask == value) return; | |
280 info->flag_mask = value; | |
281 | |
282 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
283 if (iter) | |
284 { | |
285 gtk_tree_model_get(store, iter, CTABLE_COLUMN_POINTER, &list, -1); | |
286 if (list) gtk_list_store_set(GTK_LIST_STORE(store), iter, CTABLE_COLUMN_POINTER, list, -1); | |
287 } | |
288 else | |
289 { | |
290 GtkTreeIter row; | |
291 | |
292 if (collection_table_find_iter(ct, info, &row, NULL)) | |
293 { | |
294 gtk_tree_model_get(store, &row, CTABLE_COLUMN_POINTER, &list, -1); | |
295 if (list) gtk_list_store_set(GTK_LIST_STORE(store), &row, CTABLE_COLUMN_POINTER, list, -1); | |
296 } | |
297 } | |
298 } | |
299 | |
300 static void collection_table_selection_add(CollectTable *ct, CollectInfo *info, SelectionType mask, GtkTreeIter *iter) | |
301 { | |
302 if (!info) return; | |
303 | |
304 collection_table_selection_set(ct, info, info->flag_mask | mask, iter); | |
305 } | |
306 | |
307 static void collection_table_selection_remove(CollectTable *ct, CollectInfo *info, SelectionType mask, GtkTreeIter *iter) | |
308 { | |
309 if (!info) return; | |
310 | |
311 collection_table_selection_set(ct, info, info->flag_mask & ~mask, iter); | |
312 } | |
313 /* | |
314 *------------------------------------------------------------------- | |
315 * selections | |
316 *------------------------------------------------------------------- | |
317 */ | |
318 | |
319 static void collection_table_verify_selections(CollectTable *ct) | |
320 { | |
321 GList *work; | |
322 | |
323 work = ct->selection; | |
324 while (work) | |
325 { | |
326 CollectInfo *info = work->data; | |
327 work = work->next; | |
328 if (!g_list_find(ct->cd->list, info)) | |
329 { | |
330 ct->selection = g_list_remove(ct->selection, info); | |
331 } | |
332 } | |
333 } | |
334 | |
335 void collection_table_select_all(CollectTable *ct) | |
336 { | |
337 GList *work; | |
338 | |
339 g_list_free(ct->selection); | |
340 ct->selection = NULL; | |
341 | |
342 work = ct->cd->list; | |
516 | 343 while (work) |
9 | 344 { |
345 ct->selection = g_list_append(ct->selection, work->data); | |
346 collection_table_selection_add(ct, work->data, SELECTION_SELECTED, NULL); | |
347 work = work->next; | |
348 } | |
349 | |
350 collection_table_update_status(ct); | |
351 } | |
352 | |
353 void collection_table_unselect_all(CollectTable *ct) | |
354 { | |
355 GList *work; | |
356 | |
357 work = ct->selection; | |
358 while (work) | |
359 { | |
360 collection_table_selection_remove(ct, work->data, SELECTION_SELECTED, NULL); | |
361 work = work->next; | |
362 } | |
363 | |
364 g_list_free(ct->selection); | |
365 ct->selection = NULL; | |
366 | |
367 collection_table_update_status(ct); | |
368 } | |
369 | |
1200
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
370 /* Invert the current collection's selection */ |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
371 static void collection_table_select_invert_all(CollectTable *ct) |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
372 { |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
373 GList *work; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
374 GList *new_selection = NULL; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
375 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
376 work = ct->cd->list; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
377 while (work) |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
378 { |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
379 CollectInfo *info = work->data; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
380 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
381 if (INFO_SELECTED(info)) |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
382 { |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
383 collection_table_selection_remove(ct, info, SELECTION_SELECTED, NULL); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
384 } |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
385 else |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
386 { |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
387 new_selection = g_list_append(new_selection, info); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
388 collection_table_selection_add(ct, info, SELECTION_SELECTED, NULL); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
389 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
390 } |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
391 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
392 work = work->next; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
393 } |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
394 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
395 g_list_free(ct->selection); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
396 ct->selection = new_selection; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
397 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
398 collection_table_update_status(ct); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
399 } |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
400 |
9 | 401 static void collection_table_select(CollectTable *ct, CollectInfo *info) |
402 { | |
403 ct->prev_selection = info; | |
404 | |
405 if (!info || INFO_SELECTED(info)) return; | |
406 | |
407 ct->selection = g_list_append(ct->selection, info); | |
408 collection_table_selection_add(ct, info, SELECTION_SELECTED, NULL); | |
409 | |
410 collection_table_update_status(ct); | |
411 } | |
412 | |
413 static void collection_table_unselect(CollectTable *ct, CollectInfo *info) | |
414 { | |
415 ct->prev_selection = info; | |
416 | |
417 if (!info || !INFO_SELECTED(info) ) return; | |
418 | |
419 ct->selection = g_list_remove(ct->selection, info); | |
420 collection_table_selection_remove(ct, info, SELECTION_SELECTED, NULL); | |
421 | |
422 collection_table_update_status(ct); | |
423 } | |
424 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
425 static void collection_table_select_util(CollectTable *ct, CollectInfo *info, gboolean select) |
9 | 426 { |
427 if (select) | |
428 { | |
429 collection_table_select(ct, info); | |
430 } | |
431 else | |
432 { | |
433 collection_table_unselect(ct, info); | |
434 } | |
435 } | |
436 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
437 static void collection_table_select_region_util(CollectTable *ct, CollectInfo *start, CollectInfo *end, gboolean select) |
9 | 438 { |
439 gint row1, col1; | |
440 gint row2, col2; | |
441 gint t; | |
442 gint i, j; | |
443 | |
444 if (!collection_table_find_position(ct, start, &row1, &col1) || | |
445 !collection_table_find_position(ct, end, &row2, &col2) ) return; | |
446 | |
447 ct->prev_selection = end; | |
448 | |
330 | 449 if (!options->collections.rectangular_selection) |
9 | 450 { |
451 GList *work; | |
452 CollectInfo *info; | |
453 | |
454 if (g_list_index(ct->cd->list, start) > g_list_index(ct->cd->list, end)) | |
455 { | |
456 info = start; | |
457 start = end; | |
458 end = info; | |
459 } | |
460 | |
461 work = g_list_find(ct->cd->list, start); | |
462 while (work) | |
463 { | |
464 info = work->data; | |
465 collection_table_select_util(ct, info, select); | |
442 | 466 |
9 | 467 if (work->data != end) |
468 work = work->next; | |
469 else | |
470 work = NULL; | |
471 } | |
472 return; | |
473 } | |
474 | |
475 if (row2 < row1) | |
476 { | |
477 t = row1; | |
478 row1 = row2; | |
479 row2 = t; | |
480 } | |
481 if (col2 < col1) | |
482 { | |
483 t = col1; | |
484 col1 = col2; | |
485 col2 = t; | |
486 } | |
487 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
488 DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2); |
9 | 489 |
490 for (i = row1; i <= row2; i++) | |
491 { | |
492 for (j = col1; j <= col2; j++) | |
493 { | |
494 CollectInfo *info = collection_table_find_data(ct, i, j, NULL); | |
495 if (info) collection_table_select_util(ct, info, select); | |
496 } | |
497 } | |
498 } | |
499 | |
500 GList *collection_table_selection_get_list(CollectTable *ct) | |
501 { | |
138 | 502 return collection_list_to_filelist(ct->selection); |
9 | 503 } |
504 | |
505 static GList *collection_table_get_list(CollectTable *ct) | |
506 { | |
138 | 507 return collection_list_to_filelist(ct->cd->list); |
9 | 508 } |
509 | |
510 /* | |
511 *------------------------------------------------------------------- | |
512 * tooltip type window | |
513 *------------------------------------------------------------------- | |
514 */ | |
515 | |
516 static void tip_show(CollectTable *ct) | |
517 { | |
518 GtkWidget *label; | |
519 gint x, y; | |
520 | |
521 if (ct->tip_window) return; | |
522 | |
523 gdk_window_get_pointer(ct->listview->window, &x, &y, NULL); | |
524 | |
525 ct->tip_info = collection_table_find_data_by_coord(ct, x, y, NULL); | |
526 if (!ct->tip_info) return; | |
527 | |
528 ct->tip_window = gtk_window_new(GTK_WINDOW_POPUP); | |
529 gtk_window_set_resizable(GTK_WINDOW(ct->tip_window), FALSE); | |
530 gtk_container_set_border_width(GTK_CONTAINER(ct->tip_window), 2); | |
531 | |
274
2710d14f6a28
Fix the "continuous display" of tooltips in the collection view
zas_
parents:
196
diff
changeset
|
532 label = gtk_label_new(ct->show_text ? ct->tip_info->fd->path : ct->tip_info->fd->name); |
9 | 533 |
534 g_object_set_data(G_OBJECT(ct->tip_window), "tip_label", label); | |
535 gtk_container_add(GTK_CONTAINER(ct->tip_window), label); | |
536 gtk_widget_show(label); | |
537 | |
538 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
539 | |
540 if (!GTK_WIDGET_REALIZED(ct->tip_window)) gtk_widget_realize(ct->tip_window); | |
541 gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16); | |
542 gtk_widget_show(ct->tip_window); | |
543 } | |
544 | |
545 static void tip_hide(CollectTable *ct) | |
546 { | |
547 if (ct->tip_window) gtk_widget_destroy(ct->tip_window); | |
548 ct->tip_window = NULL; | |
549 } | |
550 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
551 static gboolean tip_schedule_cb(gpointer data) |
9 | 552 { |
553 CollectTable *ct = data; | |
554 | |
1523 | 555 if (!ct->tip_delay_id) return FALSE; |
9 | 556 |
557 tip_show(ct); | |
558 | |
1523 | 559 ct->tip_delay_id = 0; |
9 | 560 return FALSE; |
561 } | |
562 | |
563 static void tip_schedule(CollectTable *ct) | |
564 { | |
565 tip_hide(ct); | |
566 | |
1523 | 567 if (ct->tip_delay_id) |
9 | 568 { |
569 g_source_remove(ct->tip_delay_id); | |
1523 | 570 ct->tip_delay_id = 0; |
9 | 571 } |
572 | |
274
2710d14f6a28
Fix the "continuous display" of tooltips in the collection view
zas_
parents:
196
diff
changeset
|
573 ct->tip_delay_id = g_timeout_add(ct->show_text ? COLLECT_TABLE_TIP_DELAY_PATH : COLLECT_TABLE_TIP_DELAY, tip_schedule_cb, ct); |
9 | 574 } |
575 | |
576 static void tip_unschedule(CollectTable *ct) | |
577 { | |
578 tip_hide(ct); | |
579 | |
1523 | 580 if (ct->tip_delay_id) |
581 { | |
582 g_source_remove(ct->tip_delay_id); | |
583 ct->tip_delay_id = 0; | |
584 } | |
9 | 585 } |
586 | |
587 static void tip_update(CollectTable *ct, CollectInfo *info) | |
588 { | |
274
2710d14f6a28
Fix the "continuous display" of tooltips in the collection view
zas_
parents:
196
diff
changeset
|
589 tip_schedule(ct); |
2710d14f6a28
Fix the "continuous display" of tooltips in the collection view
zas_
parents:
196
diff
changeset
|
590 |
9 | 591 if (ct->tip_window) |
592 { | |
593 gint x, y; | |
594 | |
595 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
596 gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16); | |
597 | |
598 if (info != ct->tip_info) | |
599 { | |
600 GtkWidget *label; | |
601 | |
602 ct->tip_info = info; | |
603 | |
604 if (!ct->tip_info) | |
605 { | |
606 return; | |
607 } | |
608 | |
609 label = g_object_get_data(G_OBJECT(ct->tip_window), "tip_label"); | |
274
2710d14f6a28
Fix the "continuous display" of tooltips in the collection view
zas_
parents:
196
diff
changeset
|
610 gtk_label_set_text(GTK_LABEL(label), ct->show_text ? ct->tip_info->fd->path : ct->tip_info->fd->name); |
9 | 611 } |
612 } | |
613 } | |
614 | |
615 /* | |
616 *------------------------------------------------------------------- | |
617 * popup menus | |
618 *------------------------------------------------------------------- | |
619 */ | |
620 | |
621 static void collection_table_popup_save_as_cb(GtkWidget *widget, gpointer data) | |
622 { | |
623 CollectTable *ct = data; | |
624 | |
625 collection_dialog_save_as(NULL, ct->cd); | |
626 } | |
627 | |
628 static void collection_table_popup_save_cb(GtkWidget *widget, gpointer data) | |
629 { | |
630 CollectTable *ct = data; | |
631 | |
632 if (!ct->cd->path) | |
633 { | |
634 collection_table_popup_save_as_cb(widget, data); | |
635 return; | |
636 } | |
637 | |
638 if (!collection_save(ct->cd, ct->cd->path)) | |
639 { | |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
640 log_printf("failed saving to collection path: %s\n", ct->cd->path); |
9 | 641 } |
642 } | |
643 | |
644 static GList *collection_table_popup_file_list(CollectTable *ct) | |
645 { | |
646 if (!ct->click_info) return NULL; | |
647 | |
648 if (INFO_SELECTED(ct->click_info)) | |
649 { | |
650 return collection_table_selection_get_list(ct); | |
651 } | |
652 | |
565
85b9cec260bc
Fix a bug occuring when using certain actions on a collection
zas_
parents:
516
diff
changeset
|
653 return g_list_append(NULL, file_data_ref(ct->click_info->fd)); |
9 | 654 } |
655 | |
656 static void collection_table_popup_edit_cb(GtkWidget *widget, gpointer data) | |
657 { | |
658 CollectTable *ct; | |
1272 | 659 const gchar *key = data; |
9 | 660 GList *list; |
661 | |
662 ct = submenu_item_get_data(widget); | |
663 | |
664 if (!ct) return; | |
665 | |
666 list = collection_table_popup_file_list(ct); | |
667 if (list) | |
668 { | |
1272 | 669 file_util_start_editor_from_filelist(key, list, ct->listview); |
138 | 670 filelist_free(list); |
9 | 671 } |
672 } | |
673 | |
674 static void collection_table_popup_copy_cb(GtkWidget *widget, gpointer data) | |
675 { | |
676 CollectTable *ct = data; | |
677 | |
678 file_util_copy(NULL, collection_table_popup_file_list(ct), NULL, ct->listview); | |
679 } | |
680 | |
681 static void collection_table_popup_move_cb(GtkWidget *widget, gpointer data) | |
682 { | |
683 CollectTable *ct = data; | |
684 | |
685 file_util_move(NULL, collection_table_popup_file_list(ct), NULL, ct->listview); | |
686 } | |
687 | |
688 static void collection_table_popup_rename_cb(GtkWidget *widget, gpointer data) | |
689 { | |
690 CollectTable *ct = data; | |
691 | |
692 file_util_rename(NULL, collection_table_popup_file_list(ct), ct->listview); | |
693 } | |
694 | |
695 static void collection_table_popup_delete_cb(GtkWidget *widget, gpointer data) | |
696 { | |
697 CollectTable *ct = data; | |
698 | |
699 file_util_delete(NULL, collection_table_popup_file_list(ct), ct->listview); | |
700 } | |
701 | |
497 | 702 static void collection_table_popup_copy_path_cb(GtkWidget *widget, gpointer data) |
703 { | |
704 CollectTable *ct = data; | |
705 | |
706 file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct)); | |
707 } | |
708 | |
9 | 709 static void collection_table_popup_sort_cb(GtkWidget *widget, gpointer data) |
710 { | |
711 CollectTable *ct; | |
712 SortType type; | |
713 | |
714 ct = submenu_item_get_data(widget); | |
715 | |
716 if (!ct) return; | |
717 | |
718 type = (SortType)GPOINTER_TO_INT(data); | |
719 | |
720 collection_set_sort_method(ct->cd, type); | |
721 } | |
722 | |
1535 | 723 static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer data) |
724 { | |
725 CollectTable *ct; | |
726 | |
727 ct = submenu_item_get_data(widget); | |
728 | |
729 if (!ct) return; | |
730 | |
731 collection_randomize(ct->cd); | |
732 } | |
733 | |
9 | 734 static void collection_table_popup_view_new_cb(GtkWidget *widget, gpointer data) |
735 { | |
736 CollectTable *ct = data; | |
737 | |
738 if (ct->click_info && g_list_find(ct->cd->list, ct->click_info)) | |
739 { | |
740 view_window_new_from_collection(ct->cd, ct->click_info); | |
741 } | |
742 } | |
743 | |
744 static void collection_table_popup_view_cb(GtkWidget *widget, gpointer data) | |
745 { | |
746 CollectTable *ct = data; | |
747 | |
748 if (ct->click_info && g_list_find(ct->cd->list, ct->click_info)) | |
749 { | |
750 layout_image_set_collection(NULL, ct->cd, ct->click_info); | |
751 } | |
752 } | |
753 | |
754 static void collection_table_popup_selectall_cb(GtkWidget *widget, gpointer data) | |
755 { | |
756 CollectTable *ct = data; | |
757 | |
758 collection_table_select_all(ct); | |
759 ct->prev_selection= ct->click_info; | |
760 } | |
761 | |
762 static void collection_table_popup_unselectall_cb(GtkWidget *widget, gpointer data) | |
763 { | |
764 CollectTable *ct = data; | |
765 | |
766 collection_table_unselect_all(ct); | |
767 ct->prev_selection= ct->click_info; | |
768 } | |
769 | |
1200
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
770 static void collection_table_popup_select_invert_cb(GtkWidget *widget, gpointer data) |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
771 { |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
772 CollectTable *ct = data; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
773 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
774 collection_table_select_invert_all(ct); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
775 ct->prev_selection= ct->click_info; |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
776 } |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
777 |
9 | 778 static void collection_table_popup_remove_cb(GtkWidget *widget, gpointer data) |
779 { | |
780 CollectTable *ct = data; | |
781 GList *list; | |
782 | |
783 if (!ct->click_info) return; | |
442 | 784 |
9 | 785 if (INFO_SELECTED(ct->click_info)) |
786 { | |
787 list = g_list_copy(ct->selection); | |
788 } | |
789 else | |
790 { | |
791 list = g_list_append(NULL, ct->click_info); | |
792 } | |
793 | |
794 collection_remove_by_info_list(ct->cd, list); | |
795 g_list_free(list); | |
796 } | |
797 | |
798 static void collection_table_popup_add_filelist_cb(GtkWidget *widget, gpointer data) | |
799 { | |
800 CollectTable *ct = data; | |
801 GList *list; | |
802 | |
803 list = layout_list(NULL); | |
804 | |
805 if (list) | |
806 { | |
138 | 807 collection_table_add_filelist(ct, list); |
808 filelist_free(list); | |
9 | 809 } |
810 } | |
811 | |
812 static void collection_table_popup_add_collection_cb(GtkWidget *widget, gpointer data) | |
813 { | |
814 CollectTable *ct = data; | |
815 | |
816 collection_dialog_append(NULL, ct->cd); | |
817 } | |
818 | |
819 static void collection_table_popup_find_dupes_cb(GtkWidget *widget, gpointer data) | |
820 { | |
821 CollectTable *ct = data; | |
822 DupeWindow *dw; | |
823 | |
824 dw = dupe_window_new(DUPE_MATCH_NAME); | |
825 dupe_window_add_collection(dw, ct->cd); | |
826 } | |
827 | |
828 static void collection_table_popup_print_cb(GtkWidget *widget, gpointer data) | |
829 { | |
830 CollectTable *ct = data; | |
138 | 831 FileData *fd; |
832 | |
833 fd = (ct->click_info) ? ct->click_info->fd : NULL; | |
834 | |
835 print_window_new(fd, collection_table_selection_get_list(ct), collection_table_get_list(ct), ct->listview); | |
9 | 836 } |
837 | |
838 static void collection_table_popup_show_names_cb(GtkWidget *widget, gpointer data) | |
839 { | |
840 CollectTable *ct = data; | |
841 | |
842 collection_table_toggle_filenames(ct); | |
843 } | |
844 | |
845 static void collection_table_popup_destroy_cb(GtkWidget *widget, gpointer data) | |
846 { | |
847 CollectTable *ct = data; | |
848 | |
849 collection_table_selection_remove(ct, ct->click_info, SELECTION_PRELIGHT, NULL); | |
850 ct->click_info = NULL; | |
851 ct->popup = NULL; | |
852 | |
576
9dc0513837b5
dropped path_list functions, use filelist functions everywhere
nadvornik
parents:
565
diff
changeset
|
853 filelist_free(ct->drop_list); |
9 | 854 ct->drop_list = NULL; |
855 ct->drop_info = NULL; | |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1367
diff
changeset
|
856 |
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1367
diff
changeset
|
857 filelist_free(ct->editmenu_fd_list); |
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1367
diff
changeset
|
858 ct->editmenu_fd_list = NULL; |
9 | 859 } |
860 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
861 static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_icon) |
9 | 862 { |
863 GtkWidget *menu; | |
864 GtkWidget *item; | |
1200
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
865 GtkWidget *submenu; |
9 | 866 |
867 menu = popup_menu_short_lived(); | |
868 | |
869 g_signal_connect(G_OBJECT(menu), "destroy", | |
870 G_CALLBACK(collection_table_popup_destroy_cb), ct); | |
871 | |
872 menu_item_add_sensitive(menu, _("_View"), over_icon, | |
873 G_CALLBACK(collection_table_popup_view_cb), ct); | |
874 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, over_icon, | |
875 G_CALLBACK(collection_table_popup_view_new_cb), ct); | |
876 menu_item_add_divider(menu); | |
877 menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, over_icon, | |
878 G_CALLBACK(collection_table_popup_remove_cb), ct); | |
879 | |
880 menu_item_add_stock(menu, _("Append from file list"), GTK_STOCK_ADD, | |
881 G_CALLBACK(collection_table_popup_add_filelist_cb), ct); | |
882 menu_item_add_stock(menu, _("Append from collection..."), GTK_STOCK_OPEN, | |
883 G_CALLBACK(collection_table_popup_add_collection_cb), ct); | |
884 menu_item_add_divider(menu); | |
1200
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
885 |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
886 item = menu_item_add(menu, _("_Selection"), NULL, NULL); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
887 submenu = gtk_menu_new(); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
888 menu_item_add(submenu, _("Select all"), |
9 | 889 G_CALLBACK(collection_table_popup_selectall_cb), ct); |
1200
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
890 menu_item_add(submenu, _("Select none"), |
9 | 891 G_CALLBACK(collection_table_popup_unselectall_cb), ct); |
1200
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
892 menu_item_add(submenu, _("Invert selection"), |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
893 G_CALLBACK(collection_table_popup_select_invert_cb), ct); |
6eeefdb30618
Allow to invert the current selection in Collection view. A new Selection submenu was added to the contextual menu, Select All and Select None were moved to it, and Invert selection was added.
zas_
parents:
1055
diff
changeset
|
894 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
9 | 895 menu_item_add_divider(menu); |
896 | |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1367
diff
changeset
|
897 |
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1367
diff
changeset
|
898 ct->editmenu_fd_list = collection_table_selection_get_list(ct); |
9 | 899 submenu_add_edit(menu, &item, |
1397
a0bd58a6535f
In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents:
1367
diff
changeset
|
900 G_CALLBACK(collection_table_popup_edit_cb), ct, ct->editmenu_fd_list); |
9 | 901 gtk_widget_set_sensitive(item, over_icon); |
902 | |
903 menu_item_add_divider(menu); | |
904 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, over_icon, | |
905 G_CALLBACK(collection_table_popup_copy_cb), ct); | |
906 menu_item_add_sensitive(menu, _("_Move..."), over_icon, | |
907 G_CALLBACK(collection_table_popup_move_cb), ct); | |
908 menu_item_add_sensitive(menu, _("_Rename..."), over_icon, | |
909 G_CALLBACK(collection_table_popup_rename_cb), ct); | |
910 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, over_icon, | |
911 G_CALLBACK(collection_table_popup_delete_cb), ct); | |
1513 | 912 menu_item_add_sensitive(menu, _("_Copy path"), over_icon, |
913 G_CALLBACK(collection_table_popup_copy_path_cb), ct); | |
9 | 914 menu_item_add_divider(menu); |
915 | |
1535 | 916 submenu = submenu_add_sort(NULL, G_CALLBACK(collection_table_popup_sort_cb), ct, FALSE, TRUE, FALSE, 0); |
917 menu_item_add_divider(submenu); | |
918 menu_item_add(submenu, _("Randomize"), | |
919 G_CALLBACK(collection_table_popup_randomize_cb), ct); | |
920 item = menu_item_add(menu, _("_Sort"), NULL, NULL); | |
921 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
922 | |
9 | 923 menu_item_add_check(menu, _("Show filename _text"), ct->show_text, |
924 G_CALLBACK(collection_table_popup_show_names_cb), ct); | |
925 menu_item_add_divider(menu); | |
926 menu_item_add_stock(menu, _("_Save collection"), GTK_STOCK_SAVE, | |
927 G_CALLBACK(collection_table_popup_save_cb), ct); | |
928 menu_item_add_stock(menu, _("Save collection _as..."), GTK_STOCK_SAVE_AS, | |
929 G_CALLBACK(collection_table_popup_save_as_cb), ct); | |
930 menu_item_add_divider(menu); | |
931 menu_item_add_stock(menu, _("_Find duplicates..."), GTK_STOCK_FIND, | |
932 G_CALLBACK(collection_table_popup_find_dupes_cb), ct); | |
933 menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, over_icon, | |
442 | 934 G_CALLBACK(collection_table_popup_print_cb), ct); |
9 | 935 |
936 return menu; | |
937 } | |
938 /* | |
939 *------------------------------------------------------------------- | |
940 * keyboard callbacks | |
941 *------------------------------------------------------------------- | |
942 */ | |
943 | |
944 static void collection_table_set_focus(CollectTable *ct, CollectInfo *info) | |
945 { | |
946 GtkTreeIter iter; | |
947 gint row, col; | |
948 | |
949 if (g_list_find(ct->cd->list, ct->focus_info)) | |
950 { | |
951 if (info == ct->focus_info) | |
952 { | |
953 /* ensure focus row col are correct */ | |
954 collection_table_find_position(ct, ct->focus_info, | |
955 &ct->focus_row, &ct->focus_column); | |
956 return; | |
957 } | |
958 collection_table_selection_remove(ct, ct->focus_info, SELECTION_FOCUS, NULL); | |
959 } | |
960 | |
961 if (!collection_table_find_position(ct, info, &row, &col)) | |
962 { | |
963 ct->focus_info = NULL; | |
964 ct->focus_row = -1; | |
965 ct->focus_column = -1; | |
966 return; | |
967 } | |
968 | |
969 ct->focus_info = info; | |
970 ct->focus_row = row; | |
971 ct->focus_column = col; | |
972 collection_table_selection_add(ct, ct->focus_info, SELECTION_FOCUS, NULL); | |
973 | |
974 if (collection_table_find_iter(ct, ct->focus_info, &iter, NULL)) | |
975 { | |
976 GtkTreePath *tpath; | |
977 GtkTreeViewColumn *column; | |
978 GtkTreeModel *store; | |
979 | |
980 tree_view_row_make_visible(GTK_TREE_VIEW(ct->listview), &iter, FALSE); | |
981 | |
982 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
983 tpath = gtk_tree_model_get_path(store, &iter); | |
984 /* focus is set to an extra column with 0 width to hide focus, we draw it ourself */ | |
985 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), COLLECT_TABLE_MAX_COLUMNS); | |
986 gtk_tree_view_set_cursor(GTK_TREE_VIEW(ct->listview), tpath, column, FALSE); | |
987 gtk_tree_path_free(tpath); | |
988 } | |
989 } | |
990 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
991 static void collection_table_move_focus(CollectTable *ct, gint row, gint col, gboolean relative) |
9 | 992 { |
993 gint new_row; | |
994 gint new_col; | |
995 | |
996 if (relative) | |
997 { | |
998 new_row = ct->focus_row; | |
999 new_col = ct->focus_column; | |
1000 | |
1001 new_row += row; | |
1002 if (new_row < 0) new_row = 0; | |
1003 if (new_row >= ct->rows) new_row = ct->rows - 1; | |
1004 | |
516 | 1005 while (col != 0) |
9 | 1006 { |
1007 if (col < 0) | |
1008 { | |
1009 new_col--; | |
1010 col++; | |
1011 } | |
1012 else | |
1013 { | |
1014 new_col++; | |
1015 col--; | |
1016 } | |
1017 | |
1018 if (new_col < 0) | |
1019 { | |
1020 if (new_row > 0) | |
1021 { | |
1022 new_row--; | |
1023 new_col = ct->columns - 1; | |
1024 } | |
1025 else | |
1026 { | |
1027 new_col = 0; | |
1028 } | |
1029 } | |
1030 if (new_col >= ct->columns) | |
1031 { | |
1032 if (new_row < ct->rows - 1) | |
1033 { | |
1034 new_row++; | |
1035 new_col = 0; | |
1036 } | |
1037 else | |
1038 { | |
1039 new_col = ct->columns - 1; | |
1040 } | |
1041 } | |
1042 } | |
1043 } | |
1044 else | |
1045 { | |
1046 new_row = row; | |
1047 new_col = col; | |
1048 | |
1049 if (new_row >= ct->rows) | |
1050 { | |
1051 if (ct->rows > 0) | |
1052 new_row = ct->rows - 1; | |
1053 else | |
1054 new_row = 0; | |
1055 new_col = ct->columns - 1; | |
1056 } | |
1057 if (new_col >= ct->columns) new_col = ct->columns - 1; | |
1058 } | |
1059 | |
1060 if (new_row == ct->rows - 1) | |
1061 { | |
1062 gint l; | |
1063 | |
1064 /* if we moved beyond the last image, go to the last image */ | |
1065 | |
1066 l = g_list_length(ct->cd->list); | |
1067 if (ct->rows > 1) l -= (ct->rows - 1) * ct->columns; | |
1068 if (new_col >= l) new_col = l - 1; | |
1069 } | |
1070 | |
1071 if (new_row == -1 || new_col == -1) | |
1072 { | |
1073 if (!ct->cd->list) return; | |
1074 new_row = new_col = 0; | |
1075 } | |
1076 | |
1077 collection_table_set_focus(ct, collection_table_find_data(ct, new_row, new_col, NULL)); | |
1078 } | |
1079 | |
1080 static void collection_table_update_focus(CollectTable *ct) | |
1081 { | |
1082 gint new_row = 0; | |
1083 gint new_col = 0; | |
1084 | |
1085 if (ct->focus_info && collection_table_find_position(ct, ct->focus_info, &new_row, &new_col)) | |
1086 { | |
1087 /* first find the old focus, if it exists and is valid */ | |
1088 } | |
1089 else | |
1090 { | |
1091 /* (try to) stay where we were */ | |
1092 new_row = ct->focus_row; | |
1093 new_col = ct->focus_column; | |
1094 } | |
1095 | |
1096 collection_table_move_focus(ct, new_row, new_col, FALSE); | |
1097 } | |
1098 | |
1099 /* used to figure the page up/down distances */ | |
1100 static gint page_height(CollectTable *ct) | |
1101 { | |
1102 GtkAdjustment *adj; | |
1103 gint page_size; | |
1104 gint row_height; | |
1105 gint ret; | |
1106 | |
1107 adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview)); | |
1108 page_size = (gint)adj->page_increment; | |
1109 | |
333 | 1110 row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2; |
1111 if (ct->show_text) row_height += options->thumbnails.max_height / 3; | |
9 | 1112 |
1113 ret = page_size / row_height; | |
1114 if (ret < 1) ret = 1; | |
1115 | |
1116 return ret; | |
1117 } | |
1118 | |
1119 static void collection_table_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
1120 { | |
1121 CollectTable *ct = data; | |
1122 GtkTreeModel *store; | |
1123 GtkTreeIter iter; | |
1124 gint column; | |
1125 GtkTreePath *tpath; | |
1126 gint cw, ch; | |
1127 | |
1128 if (!collection_table_find_iter(ct, ct->click_info, &iter, &column)) return; | |
1129 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
1130 tpath = gtk_tree_model_get_path(store, &iter); | |
1131 tree_view_get_cell_clamped(GTK_TREE_VIEW(ct->listview), tpath, column, FALSE, x, y, &cw, &ch); | |
1132 gtk_tree_path_free(tpath); | |
1133 *y += ch; | |
1134 popup_menu_position_clamp(menu, x, y, 0); | |
1135 } | |
1136 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1137 static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
9 | 1138 { |
1139 CollectTable *ct = data; | |
1140 gint focus_row = 0; | |
1141 gint focus_col = 0; | |
1142 CollectInfo *info; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1143 gboolean stop_signal = TRUE; |
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1144 |
9 | 1145 switch (event->keyval) |
1146 { | |
1147 case GDK_Left: case GDK_KP_Left: | |
1148 focus_col = -1; | |
1149 break; | |
1150 case GDK_Right: case GDK_KP_Right: | |
1151 focus_col = 1; | |
1152 break; | |
1153 case GDK_Up: case GDK_KP_Up: | |
1154 focus_row = -1; | |
1155 break; | |
1156 case GDK_Down: case GDK_KP_Down: | |
1157 focus_row = 1; | |
1158 break; | |
1159 case GDK_Page_Up: case GDK_KP_Page_Up: | |
1160 focus_row = -page_height(ct); | |
1161 break; | |
1162 case GDK_Page_Down: case GDK_KP_Page_Down: | |
1163 focus_row = page_height(ct); | |
1164 break; | |
1165 case GDK_Home: case GDK_KP_Home: | |
1166 focus_row = -ct->focus_row; | |
1167 focus_col = -ct->focus_column; | |
1168 break; | |
1169 case GDK_End: case GDK_KP_End: | |
1170 focus_row = ct->rows - 1 - ct->focus_row; | |
1171 focus_col = ct->columns - 1 - ct->focus_column; | |
1172 break; | |
1173 case GDK_space: | |
1174 info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL); | |
1175 if (info) | |
1176 { | |
1177 ct->click_info = info; | |
1178 if (event->state & GDK_CONTROL_MASK) | |
1179 { | |
1180 collection_table_select_util(ct, info, !INFO_SELECTED(info)); | |
1181 } | |
1182 else | |
1183 { | |
1184 collection_table_unselect_all(ct); | |
1185 collection_table_select(ct, info); | |
1186 } | |
1187 } | |
1188 break; | |
1189 case 'T': case 't': | |
1190 if (event->state & GDK_CONTROL_MASK) collection_table_toggle_filenames(ct); | |
1191 break; | |
1192 case GDK_Menu: | |
1193 case GDK_F10: | |
1194 info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL); | |
1195 ct->click_info = info; | |
1196 | |
1197 collection_table_selection_add(ct, ct->click_info, SELECTION_PRELIGHT, NULL); | |
1198 tip_unschedule(ct); | |
1199 | |
1200 ct->popup = collection_table_popup_menu(ct, (info != NULL)); | |
1201 gtk_menu_popup(GTK_MENU(ct->popup), NULL, NULL, collection_table_menu_pos_cb, ct, 0, GDK_CURRENT_TIME); | |
1202 break; | |
1203 default: | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1204 stop_signal = FALSE; |
9 | 1205 break; |
1206 } | |
1207 | |
1208 if (focus_row != 0 || focus_col != 0) | |
1209 { | |
1210 CollectInfo *new_info; | |
1211 CollectInfo *old_info; | |
1212 | |
1213 old_info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL); | |
1214 collection_table_move_focus(ct, focus_row, focus_col, TRUE); | |
1215 new_info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL); | |
1216 | |
1217 if (new_info != old_info) | |
1218 { | |
1219 if (event->state & GDK_SHIFT_MASK) | |
1220 { | |
330 | 1221 if (!options->collections.rectangular_selection) |
9 | 1222 { |
1223 collection_table_select_region_util(ct, old_info, new_info, FALSE); | |
1224 } | |
1225 else | |
1226 { | |
1227 collection_table_select_region_util(ct, ct->click_info, old_info, FALSE); | |
1228 } | |
1229 collection_table_select_region_util(ct, ct->click_info, new_info, TRUE); | |
1230 } | |
1231 else if (event->state & GDK_CONTROL_MASK) | |
1232 { | |
1233 ct->click_info = new_info; | |
1234 } | |
1235 else | |
1236 { | |
1237 ct->click_info = new_info; | |
1238 collection_table_unselect_all(ct); | |
1239 collection_table_select(ct, new_info); | |
1240 } | |
1241 } | |
1242 } | |
1243 | |
1244 if (stop_signal) | |
1245 { | |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1246 #if 0 |
9 | 1247 g_signal_stop_emission_by_name(GTK_OBJECT(widget), "key_press_event"); |
85
9d5c75b5ec28
Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
1248 #endif |
9 | 1249 tip_unschedule(ct); |
1250 } | |
1251 | |
1252 return stop_signal; | |
1253 } | |
1254 | |
1255 /* | |
1256 *------------------------------------------------------------------- | |
1257 * insert marker | |
1258 *------------------------------------------------------------------- | |
1259 */ | |
1260 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1261 static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *source, gboolean *after, GdkRectangle *cell, |
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1262 gboolean use_coord, gint x, gint y) |
9 | 1263 { |
1264 CollectInfo *info = NULL; | |
1265 GtkTreeModel *store; | |
1266 GtkTreeIter iter; | |
1267 GtkTreePath *tpath; | |
1268 GtkTreeViewColumn *column; | |
1269 | |
1270 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
1271 | |
1272 if (!use_coord) gdk_window_get_pointer(ct->listview->window, &x, &y, NULL); | |
1273 | |
1274 if (source) | |
1275 { | |
1276 gint col; | |
1277 if (collection_table_find_iter(ct, source, &iter, &col)) | |
1278 { | |
1279 tpath = gtk_tree_model_get_path(store, &iter); | |
1280 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), col); | |
1281 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell); | |
1282 gtk_tree_path_free(tpath); | |
1283 | |
1284 info = source; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1285 *after = !!(x > cell->x + (cell->width / 2)); |
9 | 1286 } |
1287 return info; | |
1288 } | |
1289 | |
1290 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ct->listview), x, y, | |
1291 &tpath, &column, NULL, NULL)) | |
1292 { | |
1293 GList *list; | |
1294 gint n; | |
1295 | |
1296 gtk_tree_model_get_iter(store, &iter, tpath); | |
1297 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1); | |
1298 | |
1299 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number")); | |
1300 info = g_list_nth_data(list, n); | |
1301 | |
1302 if (info) | |
1303 { | |
1304 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell); | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1305 *after = !!(x > cell->x + (cell->width / 2)); |
9 | 1306 } |
1307 | |
1308 gtk_tree_path_free(tpath); | |
1309 } | |
1310 | |
1311 if (info == NULL) | |
1312 { | |
1313 GList *work; | |
1314 | |
1315 work = g_list_last(ct->cd->list); | |
1316 if (work) | |
1317 { | |
1318 gint col; | |
1319 | |
1320 info = work->data; | |
1321 *after = TRUE; | |
1322 | |
1323 if (collection_table_find_iter(ct, info, &iter, &col)) | |
1324 { | |
1325 tpath = gtk_tree_model_get_path(store, &iter); | |
1326 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), col); | |
1327 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell); | |
1328 gtk_tree_path_free(tpath); | |
1329 } | |
1330 } | |
1331 } | |
1332 | |
1333 return info; | |
1334 } | |
1335 | |
1336 static CollectInfo *collection_table_insert_point(CollectTable *ct, gint x, gint y) | |
1337 { | |
1338 CollectInfo *info; | |
1339 GdkRectangle cell; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1340 gboolean after = FALSE; |
9 | 1341 |
1342 info = collection_table_insert_find(ct, NULL, &after, &cell, TRUE, x, y); | |
1343 | |
1344 if (info && after) | |
1345 { | |
1346 GList *work; | |
1347 | |
1348 work = g_list_find(ct->cd->list, info); | |
1349 if (work && work->next) | |
1350 { | |
1351 info = work->next->data; | |
1352 } | |
1353 else | |
1354 { | |
1355 info = NULL; | |
1356 } | |
1357 } | |
1358 | |
1359 return info; | |
1360 } | |
1361 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1362 static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gboolean enable) |
9 | 1363 { |
1364 gint row, col; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1365 gboolean after = FALSE; |
9 | 1366 GdkRectangle cell; |
1367 | |
1368 if (!enable) | |
1369 { | |
1370 if (ct->marker_window) gdk_window_destroy(ct->marker_window); | |
1371 ct->marker_window = NULL; | |
1372 | |
1373 return; | |
1374 } | |
1375 | |
1376 info = collection_table_insert_find(ct, info, &after, &cell, FALSE, 0, 0); | |
1377 | |
1378 /* this setting does not take into account (after), but since it is not really used... */ | |
1379 ct->marker_info = info; | |
1380 | |
1381 row = -1; | |
1382 col = -1; | |
1383 | |
1384 if (!ct->marker_window) | |
1385 { | |
1386 GdkWindow *parent; | |
1387 GdkWindowAttr attributes; | |
1388 gint attributes_mask; | |
1389 GdkPixmap *pixmap; | |
1390 GdkBitmap *mask; | |
1391 GdkPixbuf *pb; | |
1392 gint w, h; | |
1393 | |
1394 parent = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(ct->listview)); | |
1395 | |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
904
diff
changeset
|
1396 pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm); |
9 | 1397 gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128); |
1043 | 1398 g_object_unref(pb); |
9 | 1399 |
1400 gdk_drawable_get_size(pixmap, &w, &h); | |
1401 | |
1402 attributes.window_type = GDK_WINDOW_CHILD; | |
1403 attributes.wclass = GDK_INPUT_OUTPUT; | |
1404 attributes.width = w; | |
1405 attributes.height = h; | |
1406 attributes.event_mask = gtk_widget_get_events(ct->listview); | |
1407 attributes_mask = 0; | |
1408 | |
1409 ct->marker_window = gdk_window_new(parent, &attributes, attributes_mask); | |
1410 gdk_window_set_back_pixmap(ct->marker_window, pixmap, FALSE); | |
1411 gdk_window_shape_combine_mask(ct->marker_window, mask, 0, 0); | |
1412 | |
1413 g_object_unref(pixmap); | |
1414 if (mask) g_object_unref(mask); | |
1415 } | |
1416 | |
1417 if (info) | |
1418 { | |
1419 gint x, y; | |
1420 gint w, h; | |
1421 | |
1422 gdk_drawable_get_size(ct->marker_window, &w, &h); | |
1423 | |
1424 if (!after) | |
1425 { | |
1426 x = cell.x; | |
1427 } | |
1428 else | |
1429 { | |
1430 x = cell.x + cell.width; | |
1431 } | |
1432 x -= (w / 2); | |
1433 y = cell.y + (cell.height / 2) - (h / 2); | |
1434 | |
1435 gdk_window_move(ct->marker_window, x, y); | |
1436 gdk_window_clear(ct->marker_window); | |
1437 if (!gdk_window_is_visible(ct->marker_window)) gdk_window_show(ct->marker_window); | |
1438 } | |
1439 else | |
1440 { | |
1441 if (gdk_window_is_visible(ct->marker_window)) gdk_window_hide(ct->marker_window); | |
1442 } | |
1443 } | |
1444 | |
1445 /* | |
1446 *------------------------------------------------------------------- | |
1447 * mouse drag auto-scroll | |
1448 *------------------------------------------------------------------- | |
1449 */ | |
1450 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1451 static void collection_table_motion_update(CollectTable *ct, gint x, gint y, gboolean drop_event) |
9 | 1452 { |
1453 CollectInfo *info; | |
1454 | |
1455 info = collection_table_find_data_by_coord(ct, x, y, NULL); | |
1456 | |
1457 if (drop_event) | |
1458 { | |
1459 tip_unschedule(ct); | |
1460 collection_table_insert_marker(ct, info, TRUE); | |
1461 } | |
1462 else | |
1463 { | |
1464 tip_update(ct, info); | |
1465 } | |
1466 } | |
1467 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1468 static gboolean collection_table_auto_scroll_idle_cb(gpointer data) |
9 | 1469 { |
1470 CollectTable *ct = data; | |
1471 GdkWindow *window; | |
1472 gint x, y; | |
1473 gint w, h; | |
1474 | |
1523 | 1475 if (!ct->drop_idle_id) return FALSE; |
9 | 1476 |
1477 window = ct->listview->window; | |
1478 gdk_window_get_pointer(window, &x, &y, NULL); | |
1479 gdk_drawable_get_size(window, &w, &h); | |
1480 if (x >= 0 && x < w && y >= 0 && y < h) | |
1481 { | |
1482 collection_table_motion_update(ct, x, y, TRUE); | |
1483 } | |
1484 | |
1523 | 1485 ct->drop_idle_id = 0; |
9 | 1486 return FALSE; |
1487 } | |
1488 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1489 static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) |
9 | 1490 { |
1491 CollectTable *ct = data; | |
1492 | |
1523 | 1493 if (!ct->drop_idle_id) |
1494 { | |
1495 ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct); | |
1496 } | |
9 | 1497 |
1498 return TRUE; | |
1499 } | |
1500 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1501 static void collection_table_scroll(CollectTable *ct, gboolean scroll) |
9 | 1502 { |
1503 if (!scroll) | |
1504 { | |
1523 | 1505 if (ct->drop_idle_id) |
9 | 1506 { |
1507 g_source_remove(ct->drop_idle_id); | |
1523 | 1508 ct->drop_idle_id = 0; |
9 | 1509 } |
1510 widget_auto_scroll_stop(ct->listview); | |
1511 collection_table_insert_marker(ct, NULL, FALSE); | |
1512 } | |
1513 else | |
1514 { | |
1515 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview)); | |
333 | 1516 widget_auto_scroll_start(ct->listview, adj, -1, options->thumbnails.max_height / 2, |
9 | 1517 collection_table_auto_scroll_notify_cb, ct); |
1518 } | |
1519 } | |
1520 | |
1521 /* | |
1522 *------------------------------------------------------------------- | |
1523 * mouse callbacks | |
1524 *------------------------------------------------------------------- | |
1525 */ | |
1526 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1527 static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1528 { |
1529 CollectTable *ct = data; | |
1530 | |
1531 collection_table_motion_update(ct, (gint)bevent->x, (gint)bevent->y, FALSE); | |
1532 | |
1533 return FALSE; | |
1534 } | |
1535 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1536 static gboolean collection_table_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1537 { |
1538 CollectTable *ct = data; | |
1539 GtkTreeIter iter; | |
1540 CollectInfo *info; | |
1541 | |
1542 tip_unschedule(ct); | |
1543 | |
1544 info = collection_table_find_data_by_coord(ct, (gint)bevent->x, (gint)bevent->y, &iter); | |
1545 | |
1546 ct->click_info = info; | |
1547 collection_table_selection_add(ct, ct->click_info, SELECTION_PRELIGHT, &iter); | |
1548 | |
1549 switch (bevent->button) | |
1550 { | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1551 case MOUSE_BUTTON_LEFT: |
9 | 1552 if (bevent->type == GDK_2BUTTON_PRESS) |
1553 { | |
1554 if (info) | |
1555 { | |
1556 layout_image_set_collection(NULL, ct->cd, info); | |
1557 } | |
1558 } | |
1559 else if (!GTK_WIDGET_HAS_FOCUS(ct->listview)) | |
1560 { | |
1561 gtk_widget_grab_focus(ct->listview); | |
1562 } | |
1563 break; | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1564 case MOUSE_BUTTON_RIGHT: |
9 | 1565 ct->popup = collection_table_popup_menu(ct, (info != NULL)); |
1566 gtk_menu_popup(GTK_MENU(ct->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time); | |
1567 break; | |
1568 default: | |
1569 break; | |
1570 } | |
1571 | |
1572 return TRUE; | |
1573 } | |
1574 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1575 static gboolean collection_table_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 1576 { |
1577 CollectTable *ct = data; | |
1578 GtkTreeIter iter; | |
1579 CollectInfo *info = NULL; | |
1580 | |
1581 tip_schedule(ct); | |
1582 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1583 if ((gint)bevent->x != 0 || (gint)bevent->y != 0) |
9 | 1584 { |
1585 info = collection_table_find_data_by_coord(ct, (gint)bevent->x, (gint)bevent->y, &iter); | |
1586 } | |
1587 | |
1588 if (ct->click_info) | |
1589 { | |
1590 collection_table_selection_remove(ct, ct->click_info, SELECTION_PRELIGHT, NULL); | |
1591 } | |
1592 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1593 if (bevent->button == MOUSE_BUTTON_LEFT && |
9 | 1594 info && ct->click_info == info) |
1595 { | |
1596 collection_table_set_focus(ct, info); | |
1597 | |
1598 if (bevent->state & GDK_CONTROL_MASK) | |
1599 { | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1600 gboolean select = !INFO_SELECTED(info); |
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1601 |
9 | 1602 if ((bevent->state & GDK_SHIFT_MASK) && ct->prev_selection) |
1603 { | |
1604 collection_table_select_region_util(ct, ct->prev_selection, info, select); | |
1605 } | |
1606 else | |
1607 { | |
1608 collection_table_select_util(ct, info, select); | |
1609 } | |
1610 } | |
1611 else | |
1612 { | |
1613 collection_table_unselect_all(ct); | |
1614 | |
1615 if ((bevent->state & GDK_SHIFT_MASK) && | |
1616 ct->prev_selection) | |
1617 { | |
1618 collection_table_select_region_util(ct, ct->prev_selection, info, TRUE); | |
1619 } | |
1620 else | |
1621 { | |
1622 collection_table_select_util(ct, info, TRUE); | |
1623 } | |
1624 } | |
1625 } | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
1626 else if (bevent->button == MOUSE_BUTTON_MIDDLE && |
9 | 1627 info && ct->click_info == info) |
1628 { | |
1629 collection_table_select_util(ct, info, !INFO_SELECTED(info)); | |
1630 } | |
1631 | |
1632 return TRUE; | |
1633 } | |
1634 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1635 static gboolean collection_table_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) |
9 | 1636 { |
1637 CollectTable *ct = data; | |
1638 | |
1639 tip_unschedule(ct); | |
1640 return FALSE; | |
1641 } | |
1642 | |
1643 /* | |
1644 *------------------------------------------------------------------- | |
1645 * populate, add, insert, etc. | |
1646 *------------------------------------------------------------------- | |
1647 */ | |
1648 | |
1649 static gboolean collection_table_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data) | |
1650 { | |
1651 GList *list; | |
1652 | |
1653 gtk_tree_model_get(store, iter, CTABLE_COLUMN_POINTER, &list, -1); | |
1654 g_list_free(list); | |
1655 | |
1656 return FALSE; | |
1657 } | |
1658 | |
1659 static void collection_table_clear_store(CollectTable *ct) | |
1660 { | |
1661 GtkTreeModel *store; | |
1662 | |
1663 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
1664 gtk_tree_model_foreach(store, collection_table_destroy_node_cb, NULL); | |
1665 | |
1666 gtk_list_store_clear(GTK_LIST_STORE(store)); | |
1667 } | |
1668 | |
1669 static GList *collection_table_add_row(CollectTable *ct, GtkTreeIter *iter) | |
1670 { | |
1671 GtkListStore *store; | |
1672 GList *list = NULL; | |
1673 gint i; | |
1674 | |
1675 for (i = 0; i < ct->columns; i++) list = g_list_prepend(list, NULL); | |
1676 | |
1677 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview))); | |
1678 gtk_list_store_append(store, iter); | |
1679 gtk_list_store_set(store, iter, CTABLE_COLUMN_POINTER, list, -1); | |
1680 | |
1681 return list; | |
1682 } | |
1683 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1684 static void collection_table_populate(CollectTable *ct, gboolean resize) |
9 | 1685 { |
1686 gint row; | |
1687 GList *work; | |
1688 | |
1689 collection_table_verify_selections(ct); | |
1690 | |
1691 collection_table_clear_store(ct); | |
1692 | |
1693 if (resize) | |
1694 { | |
1695 gint i; | |
1696 gint thumb_width; | |
1697 | |
1698 thumb_width = collection_table_get_icon_width(ct); | |
1699 | |
1700 for (i = 0; i < COLLECT_TABLE_MAX_COLUMNS; i++) | |
1701 { | |
1702 GtkTreeViewColumn *column; | |
1703 GtkCellRenderer *cell; | |
1704 GList *list; | |
1705 | |
1706 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), i); | |
1707 gtk_tree_view_column_set_visible(column, (i < ct->columns)); | |
1708 gtk_tree_view_column_set_fixed_width(column, thumb_width + (THUMB_BORDER_PADDING * 6)); | |
1709 | |
1710 list = gtk_tree_view_column_get_cell_renderers(column); | |
1711 cell = (list) ? list->data : NULL; | |
1712 g_list_free(list); | |
1713 | |
1714 if (cell && GQV_IS_CELL_RENDERER_ICON(cell)) | |
1715 { | |
1716 g_object_set(G_OBJECT(cell), "fixed_width", thumb_width, | |
333 | 1717 "fixed_height", options->thumbnails.max_height, |
9 | 1718 "show_text", ct->show_text, NULL); |
1719 } | |
1720 } | |
1721 if (GTK_WIDGET_REALIZED(ct->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(ct->listview)); | |
1722 } | |
1723 | |
1724 row = -1; | |
1725 work = ct->cd->list; | |
1726 while (work) | |
1727 { | |
1728 GList *list; | |
1729 GtkTreeIter iter; | |
1730 | |
1731 row++; | |
1732 | |
1733 list = collection_table_add_row(ct, &iter); | |
1734 while (work && list) | |
1735 { | |
1736 list->data = work->data; | |
1737 list = list->next; | |
1738 work = work->next; | |
1739 } | |
1740 } | |
1741 | |
1742 ct->rows = row + 1; | |
1743 | |
1744 collection_table_update_focus(ct); | |
1745 collection_table_update_status(ct); | |
1746 } | |
1747 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1748 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force) |
9 | 1749 { |
1750 gint new_cols; | |
1751 gint thumb_width; | |
1752 | |
1753 thumb_width = collection_table_get_icon_width(ct); | |
1754 | |
1755 new_cols = w / (thumb_width + (THUMB_BORDER_PADDING * 6)); | |
1756 if (new_cols < 1) new_cols = 1; | |
1757 | |
1758 if (!force && new_cols == ct->columns) return; | |
1759 | |
1760 ct->columns = new_cols; | |
1761 | |
1762 collection_table_populate(ct, TRUE); | |
1763 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1764 DEBUG_1("col tab pop cols=%d rows=%d", ct->columns, ct->rows); |
9 | 1765 } |
1766 | |
1767 static void collection_table_sync(CollectTable *ct) | |
1768 { | |
1769 GtkTreeModel *store; | |
1770 GtkTreeIter iter; | |
1771 GList *work; | |
1772 gint r, c; | |
1773 | |
1774 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
1775 | |
1776 r = -1; | |
1777 c = 0; | |
1778 | |
1779 work = ct->cd->list; | |
1780 while (work) | |
1781 { | |
1782 GList *list; | |
1783 r++; | |
1784 c = 0; | |
1785 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, r)) | |
1786 { | |
1787 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1); | |
1788 gtk_list_store_set(GTK_LIST_STORE(store), &iter, CTABLE_COLUMN_POINTER, list, -1); | |
1789 } | |
1790 else | |
1791 { | |
1792 list = collection_table_add_row(ct, &iter); | |
1793 } | |
1794 | |
1795 while (list) | |
1796 { | |
1797 CollectInfo *info; | |
1798 if (work) | |
1799 { | |
1800 info = work->data; | |
1801 work = work->next; | |
1802 c++; | |
1803 } | |
1804 else | |
1805 { | |
1806 info = NULL; | |
1807 } | |
1808 if (list) | |
1809 { | |
1810 list->data = info; | |
1811 list = list->next; | |
1812 } | |
1813 } | |
1814 } | |
1815 | |
1816 r++; | |
1817 while (gtk_tree_model_iter_nth_child(store, &iter, NULL, r)) | |
1818 { | |
1819 GList *list; | |
1820 | |
1821 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1); | |
1822 gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
1823 g_list_free(list); | |
1824 } | |
1825 | |
1826 ct->rows = r; | |
1827 | |
1828 collection_table_update_focus(ct); | |
1829 collection_table_update_status(ct); | |
1830 } | |
1831 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
1832 static gboolean collection_table_sync_idle_cb(gpointer data) |
9 | 1833 { |
1834 CollectTable *ct = data; | |
1835 | |
1523 | 1836 if (!ct->sync_idle_id) return FALSE; |
1837 g_source_remove(ct->sync_idle_id); | |
1838 ct->sync_idle_id = 0; | |
9 | 1839 |
1840 collection_table_sync(ct); | |
1841 return FALSE; | |
1842 } | |
1843 | |
1844 static void collection_table_sync_idle(CollectTable *ct) | |
1845 { | |
1523 | 1846 if (!ct->sync_idle_id) |
9 | 1847 { |
1848 /* high priority, the view needs to be resynced before a redraw | |
1849 * may contain invalid pointers at this time | |
1850 */ | |
1851 ct->sync_idle_id = g_idle_add_full(G_PRIORITY_HIGH, collection_table_sync_idle_cb, ct, NULL); | |
1852 } | |
1853 } | |
1854 | |
138 | 1855 void collection_table_add_filelist(CollectTable *ct, GList *list) |
9 | 1856 { |
1857 GList *work; | |
1858 | |
1859 if (!list) return; | |
1860 | |
1861 work = list; | |
1862 while (work) | |
1863 { | |
138 | 1864 collection_add(ct->cd, (FileData *)work->data, FALSE); |
9 | 1865 work = work->next; |
1866 } | |
1867 } | |
1868 | |
138 | 1869 static void collection_table_insert_filelist(CollectTable *ct, GList *list, CollectInfo *insert_info) |
9 | 1870 { |
1871 GList *work; | |
1872 | |
1873 if (!list) return; | |
1874 | |
1875 work = list; | |
1876 while (work) | |
1877 { | |
138 | 1878 collection_insert(ct->cd, (FileData *)work->data, insert_info, FALSE); |
9 | 1879 work = work->next; |
1880 } | |
1881 | |
1882 collection_table_sync_idle(ct); | |
1883 } | |
1884 | |
1885 static void collection_table_move_by_info_list(CollectTable *ct, GList *info_list, gint row, gint col) | |
1886 { | |
1887 GList *work; | |
1888 GList *insert_pos = NULL; | |
1889 GList *temp; | |
1890 CollectInfo *info; | |
1891 | |
1892 if (!info_list) return; | |
1893 | |
1894 info = collection_table_find_data(ct, row, col, NULL); | |
1895 | |
1896 if (!info_list->next && info_list->data == info) return; | |
1897 | |
1898 if (info) insert_pos = g_list_find(ct->cd->list, info); | |
1899 | |
1900 /* FIXME: this may get slow for large lists */ | |
1901 work = info_list; | |
1902 while (insert_pos && work) | |
1903 { | |
1904 if (insert_pos->data == work->data) | |
1905 { | |
1906 insert_pos = insert_pos->next; | |
1907 work = info_list; | |
1908 } | |
1909 else | |
1910 { | |
1911 work = work->next; | |
1912 } | |
1913 } | |
1914 | |
1915 work = info_list; | |
1916 while (work) | |
1917 { | |
1918 ct->cd->list = g_list_remove(ct->cd->list, work->data); | |
1919 work = work->next; | |
1920 } | |
1921 | |
1922 /* place them back in */ | |
1923 temp = g_list_copy(info_list); | |
1924 | |
1925 if (insert_pos) | |
1926 { | |
1927 ct->cd->list = uig_list_insert_list(ct->cd->list, insert_pos, temp); | |
1928 } | |
1929 else if (info) | |
1930 { | |
1931 ct->cd->list = g_list_concat(temp, ct->cd->list); | |
1932 } | |
1933 else | |
1934 { | |
1935 ct->cd->list = g_list_concat(ct->cd->list, temp); | |
1936 } | |
1937 | |
1938 ct->cd->changed = TRUE; | |
1939 | |
1940 collection_table_sync_idle(ct); | |
1941 } | |
1942 | |
1943 | |
1944 /* | |
1945 *------------------------------------------------------------------- | |
1946 * updating | |
1947 *------------------------------------------------------------------- | |
1948 */ | |
1949 | |
1950 void collection_table_file_update(CollectTable *ct, CollectInfo *info) | |
1951 { | |
1952 GtkTreeIter iter; | |
1953 gint row, col; | |
1954 gdouble value; | |
1955 | |
1956 if (!info) | |
1957 { | |
1958 collection_table_update_extras(ct, FALSE, 0.0); | |
1959 return; | |
1960 } | |
1961 | |
1962 if (!collection_table_find_position(ct, info, &row, &col)) return; | |
1963 | |
1964 if (ct->columns != 0 && ct->rows != 0) | |
1965 { | |
1966 value = (gdouble)(row * ct->columns + col) / (ct->columns * ct->rows); | |
1967 } | |
1968 else | |
1969 { | |
1970 value = 0.0; | |
1971 } | |
1972 | |
1973 collection_table_update_extras(ct, TRUE, value); | |
1974 | |
1975 if (collection_table_find_iter(ct, info, &iter, NULL)) | |
1976 { | |
1977 GtkTreeModel *store; | |
1978 GList *list; | |
1979 | |
1980 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); | |
1981 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1); | |
1982 gtk_list_store_set(GTK_LIST_STORE(store), &iter, CTABLE_COLUMN_POINTER, list, -1); | |
1983 } | |
1984 } | |
1985 | |
1986 void collection_table_file_add(CollectTable *ct, CollectInfo *info) | |
1987 { | |
1988 collection_table_sync_idle(ct); | |
1989 } | |
1990 | |
1991 void collection_table_file_insert(CollectTable *ct, CollectInfo *ci) | |
1992 { | |
1993 collection_table_sync_idle(ct); | |
1994 } | |
1995 | |
1996 void collection_table_file_remove(CollectTable *ct, CollectInfo *ci) | |
1997 { | |
1998 if (ci && INFO_SELECTED(ci)) | |
1999 { | |
2000 ct->selection = g_list_remove(ct->selection, ci); | |
2001 } | |
2002 | |
2003 collection_table_sync_idle(ct); | |
2004 } | |
2005 | |
2006 void collection_table_refresh(CollectTable *ct) | |
2007 { | |
2008 collection_table_populate(ct, FALSE); | |
2009 } | |
2010 | |
2011 /* | |
2012 *------------------------------------------------------------------- | |
2013 * dnd | |
2014 *------------------------------------------------------------------- | |
2015 */ | |
2016 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
2017 static void collection_table_add_dir_recursive(CollectTable *ct, FileData *dir_fd, gboolean recursive) |
9 | 2018 { |
780
44128da39e13
Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents:
778
diff
changeset
|
2019 GList *d; |
44128da39e13
Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents:
778
diff
changeset
|
2020 GList *f; |
778 | 2021 GList *work; |
2022 | |
783 | 2023 if (!filelist_read(dir_fd, &f, recursive ? &d : NULL)) |
778 | 2024 return; |
2025 | |
2026 f = filelist_filter(f, FALSE); | |
2027 d = filelist_filter(d, TRUE); | |
2028 | |
2029 f = filelist_sort_path(f); | |
2030 d = filelist_sort_path(d); | |
2031 | |
2032 collection_table_insert_filelist(ct, f, ct->marker_info); | |
2033 | |
2034 work = g_list_last(d); | |
2035 while (work) | |
9 | 2036 { |
783 | 2037 collection_table_add_dir_recursive(ct, (FileData *)work->data, TRUE); |
778 | 2038 work = work->prev; |
9 | 2039 } |
778 | 2040 |
2041 filelist_free(f); | |
2042 filelist_free(d); | |
9 | 2043 } |
2044 | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
2045 static void confirm_dir_list_do(CollectTable *ct, GList *list, gboolean recursive) |
9 | 2046 { |
2047 GList *work = list; | |
2048 while (work) | |
2049 { | |
138 | 2050 FileData *fd = work->data; |
9 | 2051 work = work->next; |
783 | 2052 if (isdir(fd->path)) collection_table_add_dir_recursive(ct, fd, recursive); |
9 | 2053 } |
138 | 2054 collection_table_insert_filelist(ct, list, ct->marker_info); |
9 | 2055 } |
2056 | |
2057 | |
2058 static void confirm_dir_list_add(GtkWidget *widget, gpointer data) | |
2059 { | |
2060 CollectTable *ct = data; | |
2061 | |
2062 confirm_dir_list_do(ct, ct->drop_list, FALSE); | |
2063 } | |
2064 | |
2065 static void confirm_dir_list_recurse(GtkWidget *widget, gpointer data) | |
2066 { | |
2067 CollectTable *ct = data; | |
2068 | |
2069 confirm_dir_list_do(ct, ct->drop_list, TRUE); | |
2070 } | |
2071 | |
2072 static void confirm_dir_list_skip(GtkWidget *widget, gpointer data) | |
2073 { | |
2074 CollectTable *ct = data; | |
2075 | |
138 | 2076 collection_table_insert_filelist(ct, ct->drop_list, ct->marker_info); |
9 | 2077 } |
2078 | |
2079 static GtkWidget *collection_table_drop_menu(CollectTable *ct) | |
2080 { | |
2081 GtkWidget *menu; | |
2082 | |
2083 menu = popup_menu_short_lived(); | |
2084 g_signal_connect(G_OBJECT(menu), "destroy", | |
2085 G_CALLBACK(collection_table_popup_destroy_cb), ct); | |
2086 | |
2087 menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, NULL, NULL); | |
2088 menu_item_add_divider(menu); | |
2089 menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK, | |
2090 G_CALLBACK(confirm_dir_list_add), ct); | |
2091 menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD, | |
2092 G_CALLBACK(confirm_dir_list_recurse), ct); | |
2093 menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE, | |
2094 G_CALLBACK(confirm_dir_list_skip), ct); | |
2095 menu_item_add_divider(menu); | |
2096 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, ct); | |
2097 | |
2098 return menu; | |
2099 } | |
2100 | |
2101 /* | |
2102 *------------------------------------------------------------------- | |
2103 * dnd | |
2104 *------------------------------------------------------------------- | |
2105 */ | |
2106 | |
2107 static GtkTargetEntry collection_drag_types[] = { | |
316 | 2108 { TARGET_APP_COLLECTION_MEMBER_STRING, 0, TARGET_APP_COLLECTION_MEMBER }, |
9 | 2109 { "text/uri-list", 0, TARGET_URI_LIST }, |
2110 { "text/plain", 0, TARGET_TEXT_PLAIN } | |
2111 }; | |
2112 static gint n_collection_drag_types = 3; | |
2113 | |
2114 static GtkTargetEntry collection_drop_types[] = { | |
316 | 2115 { TARGET_APP_COLLECTION_MEMBER_STRING, 0, TARGET_APP_COLLECTION_MEMBER }, |
9 | 2116 { "text/uri-list", 0, TARGET_URI_LIST } |
2117 }; | |
2118 static gint n_collection_drop_types = 2; | |
2119 | |
2120 | |
2121 static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
2122 GtkSelectionData *selection_data, guint info, | |
2123 guint time, gpointer data) | |
2124 { | |
2125 CollectTable *ct = data; | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
2126 gboolean selected; |
9 | 2127 GList *list = NULL; |
2128 gchar *uri_text = NULL; | |
2129 gint total; | |
2130 | |
2131 if (!ct->click_info) return; | |
2132 | |
2133 selected = INFO_SELECTED(ct->click_info); | |
442 | 2134 |
9 | 2135 switch (info) |
2136 { | |
2137 case TARGET_APP_COLLECTION_MEMBER: | |
2138 if (selected) | |
2139 { | |
2140 uri_text = collection_info_list_to_dnd_data(ct->cd, ct->selection, &total); | |
2141 } | |
2142 else | |
2143 { | |
2144 list = g_list_append(NULL, ct->click_info); | |
2145 uri_text = collection_info_list_to_dnd_data(ct->cd, list, &total); | |
2146 g_list_free(list); | |
2147 } | |
2148 break; | |
2149 case TARGET_URI_LIST: | |
2150 case TARGET_TEXT_PLAIN: | |
2151 default: | |
2152 if (selected) | |
2153 { | |
2154 list = collection_table_selection_get_list(ct); | |
2155 } | |
2156 else | |
2157 { | |
138 | 2158 list = g_list_append(NULL, file_data_ref(ct->click_info->fd)); |
9 | 2159 } |
2160 if (!list) return; | |
2161 | |
138 | 2162 uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN)); |
2163 filelist_free(list); | |
9 | 2164 break; |
2165 } | |
2166 | |
2167 gtk_selection_data_set(selection_data, selection_data->target, | |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
2168 8, (guchar *)uri_text, total); |
9 | 2169 g_free(uri_text); |
2170 } | |
2171 | |
2172 | |
2173 static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *context, | |
2174 gint x, gint y, | |
2175 GtkSelectionData *selection_data, guint info, | |
2176 guint time, gpointer data) | |
2177 { | |
2178 CollectTable *ct = data; | |
2179 GList *list = NULL; | |
2180 GList *info_list = NULL; | |
2181 CollectionData *source; | |
2182 CollectInfo *drop_info; | |
2183 GList *work; | |
2184 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
2185 DEBUG_1("%s", selection_data->data); |
9 | 2186 |
2187 collection_table_scroll(ct, FALSE); | |
2188 collection_table_insert_marker(ct, NULL, FALSE); | |
2189 | |
2190 drop_info = collection_table_insert_point(ct, x, y); | |
2191 | |
2192 switch (info) | |
2193 { | |
2194 case TARGET_APP_COLLECTION_MEMBER: | |
2195 source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list); | |
2196 if (source) | |
2197 { | |
2198 if (source == ct->cd) | |
2199 { | |
2200 gint row = -1; | |
2201 gint col = -1; | |
2202 | |
2203 /* it is a move within a collection */ | |
138 | 2204 filelist_free(list); |
9 | 2205 list = NULL; |
2206 | |
2207 if (!drop_info) | |
2208 { | |
2209 collection_table_move_by_info_list(ct, info_list, -1, -1); | |
2210 } | |
2211 else if (collection_table_find_position(ct, drop_info, &row, &col)) | |
2212 { | |
2213 collection_table_move_by_info_list(ct, info_list, row, col); | |
2214 } | |
2215 } | |
2216 else | |
2217 { | |
2218 /* it is a move/copy across collections */ | |
2219 if (context->action == GDK_ACTION_MOVE) | |
2220 { | |
2221 collection_remove_by_info_list(source, info_list); | |
2222 } | |
2223 } | |
2224 g_list_free(info_list); | |
2225 } | |
2226 break; | |
2227 case TARGET_URI_LIST: | |
138 | 2228 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); |
9 | 2229 work = list; |
2230 while (work) | |
2231 { | |
138 | 2232 FileData *fd = work->data; |
2233 if (isdir(fd->path)) | |
9 | 2234 { |
2235 GtkWidget *menu; | |
2236 | |
2237 ct->drop_list = list; | |
2238 ct->drop_info = drop_info; | |
2239 menu = collection_table_drop_menu(ct); | |
2240 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, time); | |
2241 return; | |
2242 } | |
2243 work = work->next; | |
2244 } | |
2245 break; | |
2246 default: | |
2247 list = NULL; | |
2248 break; | |
2249 } | |
2250 | |
2251 if (list) | |
2252 { | |
138 | 2253 collection_table_insert_filelist(ct, list, drop_info); |
2254 filelist_free(list); | |
9 | 2255 } |
2256 } | |
2257 | |
2258 static void collection_table_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
2259 { | |
2260 CollectTable *ct = data; | |
2261 | |
2262 if (ct->click_info && ct->click_info->pixbuf) | |
2263 { | |
2264 gint items; | |
2265 | |
2266 if (INFO_SELECTED(ct->click_info)) | |
2267 items = g_list_length(ct->selection); | |
2268 else | |
2269 items = 1; | |
2270 dnd_set_drag_icon(widget, context, ct->click_info->pixbuf, items); | |
2271 } | |
2272 } | |
2273 | |
2274 static void collection_table_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
2275 { | |
2276 CollectTable *ct = data; | |
2277 | |
2278 /* apparently a leave event is not generated on a drop */ | |
2279 tip_unschedule(ct); | |
2280 | |
2281 collection_table_scroll(ct, FALSE); | |
2282 } | |
2283 | |
2284 static gint collection_table_dnd_motion(GtkWidget *widget, GdkDragContext *context, | |
2285 gint x, gint y, guint time, gpointer data) | |
2286 { | |
2287 CollectTable *ct = data; | |
2288 | |
2289 collection_table_motion_update(ct, x, y, TRUE); | |
2290 collection_table_scroll(ct, TRUE); | |
2291 | |
2292 return FALSE; | |
2293 } | |
2294 | |
2295 static void collection_table_dnd_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) | |
2296 { | |
2297 CollectTable *ct = data; | |
2298 | |
2299 collection_table_scroll(ct, FALSE); | |
2300 } | |
442 | 2301 |
9 | 2302 static void collection_table_dnd_init(CollectTable *ct) |
2303 { | |
2304 gtk_drag_source_set(ct->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
2305 collection_drag_types, n_collection_drag_types, | |
2306 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
2307 g_signal_connect(G_OBJECT(ct->listview), "drag_data_get", | |
2308 G_CALLBACK(collection_table_dnd_get), ct); | |
2309 g_signal_connect(G_OBJECT(ct->listview), "drag_begin", | |
2310 G_CALLBACK(collection_table_dnd_begin), ct); | |
2311 g_signal_connect(G_OBJECT(ct->listview), "drag_end", | |
2312 G_CALLBACK(collection_table_dnd_end), ct); | |
2313 | |
2314 gtk_drag_dest_set(ct->listview, | |
2315 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, | |
2316 collection_drop_types, n_collection_drop_types, | |
2317 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); | |
2318 g_signal_connect(G_OBJECT(ct->listview), "drag_motion", | |
2319 G_CALLBACK(collection_table_dnd_motion), ct); | |
2320 g_signal_connect(G_OBJECT(ct->listview), "drag_leave", | |
2321 G_CALLBACK(collection_table_dnd_leave), ct); | |
2322 g_signal_connect(G_OBJECT(ct->listview), "drag_data_received", | |
2323 G_CALLBACK(collection_table_dnd_receive), ct); | |
2324 } | |
2325 | |
2326 /* | |
2327 *----------------------------------------------------------------------------- | |
2328 * draw, etc. | |
2329 *----------------------------------------------------------------------------- | |
2330 */ | |
2331 | |
2332 typedef struct _ColumnData ColumnData; | |
2333 struct _ColumnData | |
2334 { | |
2335 CollectTable *ct; | |
2336 gint number; | |
2337 }; | |
2338 | |
2339 static void collection_table_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
2340 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
2341 { | |
2342 ColumnData *cd = data; | |
2343 CollectTable *ct; | |
2344 GtkStyle *style; | |
2345 GList *list; | |
2346 CollectInfo *info; | |
2347 GdkColor color_fg; | |
2348 GdkColor color_bg; | |
2349 | |
2350 ct = cd->ct; | |
2351 | |
2352 gtk_tree_model_get(tree_model, iter, CTABLE_COLUMN_POINTER, &list, -1); | |
2353 info = g_list_nth_data(list, cd->number); | |
2354 | |
2355 style = gtk_widget_get_style(ct->listview); | |
2356 if (info && (info->flag_mask & SELECTION_SELECTED) ) | |
2357 { | |
2358 memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg)); | |
2359 memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg)); | |
2360 } | |
2361 else | |
2362 { | |
2363 memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg)); | |
2364 memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg)); | |
2365 } | |
2366 | |
2367 if (info && (info->flag_mask & SELECTION_PRELIGHT)) | |
2368 { | |
2369 #if 0 | |
2370 shift_color(&color_fg, -1, 0); | |
2371 #endif | |
2372 shift_color(&color_bg, -1, 0); | |
2373 } | |
2374 | |
2375 if (GQV_IS_CELL_RENDERER_ICON(cell)) | |
2376 { | |
2377 if (info) | |
2378 { | |
2379 g_object_set(cell, "pixbuf", info->pixbuf, | |
138 | 2380 "text", info->fd->name, |
9 | 2381 "cell-background-gdk", &color_bg, |
2382 "cell-background-set", TRUE, | |
2383 "foreground-gdk", &color_fg, | |
2384 "foreground-set", TRUE, | |
2385 "has-focus", (ct->focus_info == info), NULL); | |
2386 } | |
2387 else | |
2388 { | |
2389 g_object_set(cell, "pixbuf", NULL, | |
2390 "text", NULL, | |
2391 "cell-background-set", FALSE, | |
2392 "foreground-set", FALSE, | |
2393 "has-focus", FALSE, NULL); | |
2394 } | |
2395 } | |
2396 } | |
2397 | |
2398 static void collection_table_append_column(CollectTable *ct, gint n) | |
2399 { | |
2400 ColumnData *cd; | |
2401 GtkTreeViewColumn *column; | |
2402 GtkCellRenderer *renderer; | |
2403 | |
2404 column = gtk_tree_view_column_new(); | |
2405 gtk_tree_view_column_set_min_width(column, 0); | |
2406 | |
2407 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
2408 gtk_tree_view_column_set_alignment(column, 0.5); | |
2409 | |
2410 renderer = gqv_cell_renderer_icon_new(); | |
2411 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
2412 g_object_set(G_OBJECT(renderer), "xpad", THUMB_BORDER_PADDING * 2, | |
2413 "ypad", THUMB_BORDER_PADDING, | |
2414 "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); | |
2415 | |
2416 g_object_set_data(G_OBJECT(column), "column_number", GINT_TO_POINTER(n)); | |
2417 | |
2418 cd = g_new0(ColumnData, 1); | |
2419 cd->ct = ct; | |
2420 cd->number = n; | |
2421 gtk_tree_view_column_set_cell_data_func(column, renderer, collection_table_cell_data_cb, cd, g_free); | |
2422 | |
2423 gtk_tree_view_append_column(GTK_TREE_VIEW(ct->listview), column); | |
2424 } | |
2425 | |
2426 /* | |
2427 *------------------------------------------------------------------- | |
2428 * init, destruction | |
2429 *------------------------------------------------------------------- | |
2430 */ | |
2431 | |
2432 static void collection_table_destroy(GtkWidget *widget, gpointer data) | |
2433 { | |
2434 CollectTable *ct = data; | |
2435 | |
2436 if (ct->popup) | |
2437 { | |
2438 g_signal_handlers_disconnect_matched(GTK_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA, | |
2439 0, 0, 0, NULL, ct); | |
2440 gtk_widget_destroy(ct->popup); | |
2441 } | |
2442 | |
1523 | 2443 if (ct->sync_idle_id) g_source_remove(ct->sync_idle_id); |
9 | 2444 |
2445 tip_unschedule(ct); | |
2446 collection_table_scroll(ct, FALSE); | |
2447 | |
2448 g_free(ct); | |
2449 } | |
2450 | |
2451 static void collection_table_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
2452 { | |
2453 CollectTable *ct = data; | |
2454 | |
2455 collection_table_populate_at_new_size(ct, allocation->width, allocation->height, FALSE); | |
2456 } | |
2457 | |
2458 CollectTable *collection_table_new(CollectionData *cd) | |
2459 { | |
2460 CollectTable *ct; | |
2461 GtkListStore *store; | |
2462 GtkTreeSelection *selection; | |
2463 gint i; | |
2464 | |
2465 ct = g_new0(CollectTable, 1); | |
1367
fe4da037be21
When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass.
zas_
parents:
1292
diff
changeset
|
2466 |
9 | 2467 ct->cd = cd; |
320 | 2468 ct->show_text = options->show_icon_names; |
9 | 2469 |
2470 ct->scrolled = gtk_scrolled_window_new(NULL, NULL); | |
2471 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN); | |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
2472 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled), |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
2473 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
9 | 2474 |
2475 store = gtk_list_store_new(1, G_TYPE_POINTER); | |
2476 ct->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
2477 g_object_unref(store); | |
2478 | |
2479 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ct->listview)); | |
2480 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_NONE); | |
2481 | |
2482 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(ct->listview), FALSE); | |
2483 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ct->listview), FALSE); | |
2484 | |
2485 for (i = 0; i < COLLECT_TABLE_MAX_COLUMNS; i++) | |
2486 { | |
2487 collection_table_append_column(ct, i); | |
2488 } | |
2489 | |
2490 /* zero width column to hide tree view focus, we draw it ourselves */ | |
2491 collection_table_append_column(ct, i); | |
2492 /* end column to fill white space */ | |
2493 collection_table_append_column(ct, i); | |
2494 | |
2495 g_signal_connect(G_OBJECT(ct->listview), "destroy", | |
2496 G_CALLBACK(collection_table_destroy), ct); | |
2497 g_signal_connect(G_OBJECT(ct->listview), "size_allocate", | |
2498 G_CALLBACK(collection_table_sized), ct); | |
2499 g_signal_connect(G_OBJECT(ct->listview), "key_press_event", | |
2500 G_CALLBACK(collection_table_press_key_cb), ct); | |
2501 | |
2502 gtk_container_add(GTK_CONTAINER(ct->scrolled), ct->listview); | |
2503 gtk_widget_show(ct->listview); | |
2504 | |
2505 collection_table_dnd_init(ct); | |
2506 | |
2507 gtk_widget_set_events(ct->listview, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | | |
2508 GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK); | |
2509 g_signal_connect(G_OBJECT(ct->listview),"button_press_event", | |
2510 G_CALLBACK(collection_table_press_cb), ct); | |
2511 g_signal_connect(G_OBJECT(ct->listview),"button_release_event", | |
2512 G_CALLBACK(collection_table_release_cb), ct); | |
2513 g_signal_connect(G_OBJECT(ct->listview),"motion_notify_event", | |
2514 G_CALLBACK(collection_table_motion_cb), ct); | |
2515 g_signal_connect(G_OBJECT(ct->listview), "leave_notify_event", | |
2516 G_CALLBACK(collection_table_leave_cb), ct); | |
2517 | |
2518 return ct; | |
2519 } | |
2520 | |
2521 void collection_table_set_labels(CollectTable *ct, GtkWidget *status, GtkWidget *extra) | |
2522 { | |
2523 ct->status_label = status; | |
2524 ct->extra_label = extra; | |
2525 collection_table_update_status(ct); | |
2526 collection_table_update_extras(ct, FALSE, 0.0); | |
2527 } | |
2528 | |
2529 CollectInfo *collection_table_get_focus_info(CollectTable *ct) | |
2530 { | |
2531 return collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL); | |
2532 } | |
1420
3a9fb1b52559
Use gboolean where applicable, for the sake of consistency.
zas_
parents:
1397
diff
changeset
|
2533 |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1043
diff
changeset
|
2534 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |