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