annotate src/view_file_list.c @ 139:754c1e4349b6

display sidecar extensions in filelist some cleanup of file marks
author nadvornik
date Wed, 12 Sep 2007 21:17:31 +0000
parents 71e1ebee420e
children b5aa95241859
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * GQview
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 #include "gqview.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #include "view_file_list.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "cache_maint.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "editors.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "info.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "thumb.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "ui_tree_edit.h"
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
29 #include "typedefs.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 FILE_COLUMN_POINTER = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 FILE_COLUMN_THUMB,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 FILE_COLUMN_NAME,
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
38 FILE_COLUMN_SIDECARS,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 FILE_COLUMN_SIZE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 FILE_COLUMN_DATE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 FILE_COLUMN_COLOR,
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
42 FILE_COLUMN_MARKS,
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
43 FILE_COLUMN_MARKS_LAST = FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE - 1,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 FILE_COLUMN_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 static gint vflist_row_is_selected(ViewFileList *vfl, FileData *fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 static void vflist_populate_view(ViewFileList *vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 * signals
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 static void vflist_send_update(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 if (vfl->func_status) vfl->func_status(vfl, vfl->data_status);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 * misc
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 static gint vflist_find_row(ViewFileList *vfl, FileData *fd, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 FileData *fd_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, FILE_COLUMN_POINTER, &fd_n, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 if (fd_n == fd) return row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 static void vflist_color_set(ViewFileList *vfl, FileData *fd, gint color_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 if (vflist_find_row(vfl, fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 static void vflist_move_cursor(ViewFileList *vfl, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 tpath = gtk_tree_model_get_path(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vfl->listview), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 gint total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 if (!vfl->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 if (vflist_row_is_selected(vfl, vfl->click_fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 list = vflist_selection_get_list(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
135 list = g_list_append(NULL, file_data_ref(vfl->click_fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
140 uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
141 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 if (debug) printf(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
145 gtk_selection_data_set(selection_data, selection_data->target,
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
146 8, (guchar *)uri_text, total);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 static void vflist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 vflist_color_set(vfl, vfl->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 if (vfl->thumbs_enabled &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 vfl->click_fd && vfl->click_fd->pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 gint items;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 if (vflist_row_is_selected(vfl, vfl->click_fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 items = vflist_selection_count(vfl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 items = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 dnd_set_drag_icon(widget, context, vfl->click_fd->pixbuf, items);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 vflist_color_set(vfl, vfl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 if (context->action == GDK_ACTION_MOVE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 vflist_refresh(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 static void vflist_dnd_init(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 gtk_drag_source_set(vfl->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 dnd_file_drag_types, dnd_file_drag_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 g_signal_connect(G_OBJECT(vfl->listview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 G_CALLBACK(vflist_dnd_get), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 g_signal_connect(G_OBJECT(vfl->listview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 G_CALLBACK(vflist_dnd_begin), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 g_signal_connect(G_OBJECT(vfl->listview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 G_CALLBACK(vflist_dnd_end), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 * pop-up menu
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 static GList *vflist_pop_menu_file_list(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 if (!vfl->click_fd) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 if (vflist_row_is_selected(vfl, vfl->click_fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 return vflist_selection_get_list(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
210 return g_list_append(NULL, file_data_ref(vfl->click_fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 static void vflist_pop_menu_edit_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 ViewFileList *vfl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 vfl = submenu_item_get_data(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 n = GPOINTER_TO_INT(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 if (!vfl) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 list = vflist_pop_menu_file_list(vfl);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
225 start_editor_from_filelist(n, list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
226 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 static void vflist_pop_menu_info_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 info_window_new(NULL, vflist_pop_menu_file_list(vfl));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 static void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 if (vflist_row_is_selected(vfl, vfl->click_fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 list = vflist_selection_get_list(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 view_window_new_from_list(list);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
246 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
250 view_window_new(vfl->click_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 static void vflist_pop_menu_copy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 file_util_copy(NULL, vflist_pop_menu_file_list(vfl), NULL, vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 static void vflist_pop_menu_move_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 file_util_move(NULL, vflist_pop_menu_file_list(vfl), NULL, vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 static void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 list = vflist_pop_menu_file_list(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 if (enable_in_place_rename &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 list && !list->next && vfl->click_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
280 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 if (vflist_find_row(vfl, vfl->click_fd, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 tree_edit_by_path(GTK_TREE_VIEW(vfl->listview), tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 FILE_COLUMN_NAME -1, vfl->click_fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 vflist_row_rename_cb, vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 file_util_rename(NULL, list, vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 static void vflist_pop_menu_delete_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 file_util_delete(NULL, vflist_pop_menu_file_list(vfl), vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 static void vflist_pop_menu_sort_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 ViewFileList *vfl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 SortType type;
113
55166d93498d Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents: 111
diff changeset
310
55166d93498d Fri Nov 24 21:37:01 2006 John Ellis <johne@verizon.net>
gqview
parents: 111
diff changeset
311 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 vfl = submenu_item_get_data(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 if (!vfl) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 type = (SortType)GPOINTER_TO_INT(data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 if (vfl->layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 layout_sort_set(vfl->layout, type, vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 vflist_sort_set(vfl, type, vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 static void vflist_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 if (vfl->layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 layout_sort_set(vfl->layout, vfl->sort_method, !vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 vflist_sort_set(vfl, vfl->sort_method, !vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 static void vflist_pop_menu_icons_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 if (vfl->layout) layout_views_set(vfl->layout, vfl->layout->tree_view, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 static void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 vflist_color_set(vfl, vfl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 if (vfl->layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 layout_thumb_set(vfl->layout, !vfl->thumbs_enabled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 vflist_thumb_set(vfl, !vfl->thumbs_enabled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 static void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 vflist_color_set(vfl, vfl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 vflist_refresh(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 static void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 vflist_color_set(vfl, vfl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 vfl->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 vfl->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 static GtkWidget *vflist_pop_menu(ViewFileList *vfl, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 GtkWidget *item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 GtkWidget *submenu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 gint active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 vflist_color_set(vfl, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 active = (fd != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 G_CALLBACK(vflist_popup_destroy_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 submenu_add_edit(menu, &item, G_CALLBACK(vflist_pop_menu_edit_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 gtk_widget_set_sensitive(item, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 G_CALLBACK(vflist_pop_menu_info_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 G_CALLBACK(vflist_pop_menu_view_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 G_CALLBACK(vflist_pop_menu_copy_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 menu_item_add_sensitive(menu, _("_Move..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 G_CALLBACK(vflist_pop_menu_move_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 menu_item_add_sensitive(menu, _("_Rename..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 G_CALLBACK(vflist_pop_menu_rename_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 G_CALLBACK(vflist_pop_menu_delete_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 submenu = submenu_add_sort(NULL, G_CALLBACK(vflist_pop_menu_sort_cb), vfl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 FALSE, FALSE, TRUE, vfl->sort_method);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 menu_item_add_divider(submenu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 menu_item_add_check(submenu, _("Ascending"), vfl->sort_ascend,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 G_CALLBACK(vflist_pop_menu_sort_ascend_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 item = menu_item_add(menu, _("_Sort"), NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 menu_item_add_check(menu, _("View as _icons"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 G_CALLBACK(vflist_pop_menu_icons_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 menu_item_add_check(menu, _("Show _thumbnails"), vfl->thumbs_enabled,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 G_CALLBACK(vflist_pop_menu_thumbs_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vflist_pop_menu_refresh_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 * callbacks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 gchar *old_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 if (strlen(new) == 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 old_path = concat_dir_and_file(vfl->path, old);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 new_path = concat_dir_and_file(vfl->path, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 if (strchr(new, '/') != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 gchar *text = g_strdup_printf(_("Invalid file name:\n%s"), new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 else if (isfile(new_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 gchar *text = g_strdup_printf(_("A file with name %s already exists."), new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
461 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
463 gint row = vflist_index_by_path(vfl, old_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
464 if (row >= 0)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
465 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
466 GList *work = g_list_nth(vfl->list, row);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
467 FileData *fd = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
468 file_data_change_info_new(old_path, new_path, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
469 if (!rename_file_ext(fd))
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
470 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
471 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), old, new);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
472 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vfl->listview);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
473 g_free(text);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
474 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
475 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
476
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 static void vflist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 if (vflist_find_row(vfl, vfl->click_fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 tree_view_get_cell_clamped(GTK_TREE_VIEW(vfl->listview), tpath, FILE_COLUMN_NAME - 1, TRUE, x, y, &cw, &ch);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 static gint vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 if (event->keyval != GDK_Menu) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vfl->listview), &tpath, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &vfl->click_fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 vfl->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 vfl->popup = vflist_pop_menu(vfl, vfl->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 gtk_menu_popup(GTK_MENU(vfl->popup), NULL, NULL, vflist_menu_position_cb, vfl, 0, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 static gint vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 FileData *fd = NULL;
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
536 GtkTreeViewColumn *column;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
537 gint colnum;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
538
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
540 &tpath, &column, NULL, NULL))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 GtkTreeModel *store;
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
543 colnum = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), "column"));
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
544
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
545 if (colnum <= FILE_COLUMN_MARKS - 2 + FILEDATA_MARKS_SIZE && colnum >= FILE_COLUMN_MARKS - 2)
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
546 return FALSE;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
547
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
548 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 vfl->click_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 if (bevent->button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 vfl->popup = vflist_pop_menu(vfl, vfl->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 gtk_menu_popup(GTK_MENU(vfl->popup), NULL, NULL, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 if (!fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 if (bevent->button == 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 if (!vflist_row_is_selected(vfl, fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 vflist_color_set(vfl, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 !(bevent->state & GDK_SHIFT_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 !(bevent->state & GDK_CONTROL_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 vflist_row_is_selected(vfl, fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 gtk_widget_grab_focus(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 if (bevent->button == 1 && bevent->type == GDK_2BUTTON_PRESS)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 if (vfl->layout) layout_image_full_screen_start(vfl->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 static gint vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 if (bevent->button == 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 vflist_color_set(vfl, vfl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 if (bevent->button != 1 && bevent->button != 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 if ((bevent->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 if (bevent->button == 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 if (fd && vfl->click_fd == fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 if (vflist_row_is_selected(vfl, fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 gtk_tree_selection_unselect_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 if (fd && vfl->click_fd == fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 !(bevent->state & GDK_SHIFT_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 !(bevent->state & GDK_CONTROL_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 vflist_row_is_selected(vfl, fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 vflist_move_cursor(vfl, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 static void vflist_select_image(ViewFileList *vfl, gint row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
666 FileData *path;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
667 FileData *read_ahead_fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
669 path = vflist_index_get_data(vfl, row);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 if (path && enable_read_ahead)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 if (row > vflist_index_by_path(vfl, layout_image_get_path(vfl->layout)) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 row + 1 < vflist_count(vfl, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 fd = vflist_index_get_data(vfl, row + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 else if (row > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 fd = vflist_index_get_data(vfl, row - 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
688 if (fd) read_ahead_fd = fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
691 layout_image_set_with_ahead(vfl->layout, path, read_ahead_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 static gint vflist_select_idle_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 if (!vfl->layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 vfl->select_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 vflist_send_update(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 if (vfl->select_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 vflist_select_image(vfl, g_list_index(vfl->list, vfl->select_fd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 vfl->select_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 vfl->select_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 static void vflist_select_idle_cancel(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 if (vfl->select_idle_id != -1) g_source_remove(vfl->select_idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 vfl->select_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 gboolean path_currently_selected, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 if (!path_currently_selected &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 gtk_tree_model_get_iter(store, &iter, tpath))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &vfl->select_fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 vfl->select_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 if (vfl->layout &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 vfl->select_idle_id == -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 vfl->select_idle_id = g_idle_add(vflist_select_idle_cb, vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 * misc
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
753 static gboolean vflist_dummy_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
754 gboolean path_currently_selected, gpointer data)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
755 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
756 return TRUE;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
757 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
758
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 void vflist_sort_set(ViewFileList *vfl, SortType type, gint ascend)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 {
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
761 GtkTreeModel *model;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 GList *work;
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
764 GtkTreeSelection *selection;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
765 GtkTreePath *tpath;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
766 GtkTreeIter iter;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
767 GList *select_list;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
768 FileData *cursor_fd = NULL;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
769 gint single_select;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 if (vfl->sort_method == type && vfl->sort_ascend == ascend) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 vfl->sort_method = type;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 vfl->sort_ascend = ascend;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 if (!vfl->list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 vfl->list = filelist_sort(vfl->list, vfl->sort_method, vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
780 /* now reorder the treeview, maintaining current selection */
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
781
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
782 #if 0
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
783 /* this is simpler, but much slower */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 work = g_list_last(vfl->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 if (vflist_find_row(vfl, fd, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 gtk_list_store_move_after(store, &iter, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 }
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
800 #endif
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
801
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
802 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
803
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
804 gtk_tree_selection_set_select_function(selection, vflist_dummy_select_cb, vfl, NULL);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
805
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
806 select_list = gtk_tree_selection_get_selected_rows(selection, &model);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
807 work = select_list;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
808 while (work)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
809 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
810 FileData *fd;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
811
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
812 tpath = work->data;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
813 gtk_tree_model_get_iter(model, &iter, tpath);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
814 gtk_tree_model_get(model, &iter, FILE_COLUMN_POINTER, &fd, -1);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
815 gtk_tree_path_free(tpath);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
816
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
817 work->data = fd;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
818 work = work->next;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
819 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
820
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
821 select_list = filelist_sort(select_list, vfl->sort_method, vfl->sort_ascend);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
822
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
823 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vfl->listview), &tpath, NULL);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
824 if (tpath)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
825 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
826 if (gtk_tree_model_get_iter(model, &iter, tpath))
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
827 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
828 gtk_tree_model_get(model, &iter, FILE_COLUMN_POINTER, &cursor_fd, -1);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
829 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
830 gtk_tree_path_free(tpath);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
831 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
832
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
833 single_select = (select_list && !select_list->next);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
834 if (single_select) cursor_fd = select_list->data;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
835
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
836 store = GTK_LIST_STORE(model);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
837 gtk_list_store_clear(store);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
838
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
839 work = vfl->list;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
840 while (work)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
841 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
842 FileData *fd;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
843 gchar *size;
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
844 gchar *sidecars;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
845 int i;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
846
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
847 fd = work->data;
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
848 sidecars = sidecar_file_data_list_to_string(fd);
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
849 size = text_from_size(fd->size);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
850 gtk_list_store_append(store, &iter);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
851 gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd,
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
852 FILE_COLUMN_THUMB, (vfl->thumbs_enabled) ? fd->pixbuf : NULL,
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
853 FILE_COLUMN_NAME, fd->name,
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
854 FILE_COLUMN_SIDECARS, sidecars,
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
855 FILE_COLUMN_SIZE, size,
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
856 FILE_COLUMN_DATE, text_from_time(fd->date),
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
857 FILE_COLUMN_COLOR, FALSE, -1);
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
858 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
859 gtk_list_store_set(store, &iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
860
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
861 g_free(size);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
862 g_free(sidecars);
93
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
863
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
864 if (select_list && select_list->data == fd)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
865 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
866 select_list = g_list_remove(select_list, fd);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
867 gtk_tree_selection_select_iter(selection, &iter);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
868 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
869
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
870 work = work->next;
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
871 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
872
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
873 g_list_free(select_list);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
874
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
875 if (cursor_fd &&
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
876 vflist_find_row(vfl, cursor_fd, &iter) >= 0)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
877 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
878 if (single_select)
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
879 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
880 vflist_move_cursor(vfl, &iter);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
881 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
882 else
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
883 {
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
884 tree_view_row_make_visible(GTK_TREE_VIEW(vfl->listview), &iter, TRUE);
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
885 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
886 }
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
887
f1c8f8632e23 Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
888 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 * thumb updates
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 static gint vflist_thumb_next(ViewFileList *vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 static void vflist_thumb_status(ViewFileList *vfl, gdouble val, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 if (vfl->func_thumb_status)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 vfl->func_thumb_status(vfl, val, text, vfl->data_thumb_status);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 static void vflist_thumb_cleanup(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 vflist_thumb_status(vfl, 0.0, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 vfl->thumbs_count = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 vfl->thumbs_running = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 thumb_loader_free(vfl->thumbs_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 vfl->thumbs_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 vfl->thumbs_filedata = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 static void vflist_thumb_stop(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 if (vfl->thumbs_running) vflist_thumb_cleanup(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 static void vflist_thumb_do(ViewFileList *vfl, ThumbLoader *tl, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 if (!fd || vflist_find_row(vfl, fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 if (fd->pixbuf) g_object_unref(fd->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 gtk_list_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 vflist_thumb_status(vfl, (gdouble)(vfl->thumbs_count) / g_list_length(vfl->list), _("Loading thumbs..."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 if (vfl->thumbs_filedata && vfl->thumbs_loader == tl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 vflist_thumb_do(vfl, tl, vfl->thumbs_filedata);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 while (vflist_thumb_next(vfl));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 static void vflist_thumb_done_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 if (vfl->thumbs_filedata && vfl->thumbs_loader == tl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 vflist_thumb_do(vfl, tl, vfl->thumbs_filedata);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 while (vflist_thumb_next(vfl));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 static gint vflist_thumb_next(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 /* first check the visible files */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 if (GTK_WIDGET_REALIZED(vfl->listview) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vfl->listview), 0, 0, &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 gint valid = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vfl->listview), &iter, FALSE) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 if (fd->pixbuf) fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 /* then find first undone */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 if (!fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 GList *work = vfl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 while (work && !fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 FileData *fd_p = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 if (!fd_p->pixbuf) fd = fd_p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 if (!fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 /* done */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 vflist_thumb_cleanup(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 vfl->thumbs_count++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 vfl->thumbs_filedata = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 thumb_loader_free(vfl->thumbs_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 vfl->thumbs_loader = thumb_loader_new(thumb_max_width, thumb_max_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 thumb_loader_set_callbacks(vfl->thumbs_loader,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 vflist_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 vflist_thumb_error_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 if (!thumb_loader_start(vfl->thumbs_loader, fd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 /* set icon to unknown, continue */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 if (debug) printf("thumb loader start failed %s\n", vfl->thumbs_loader->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 vflist_thumb_do(vfl, vfl->thumbs_loader, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 static void vflist_thumb_update(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 vflist_thumb_stop(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 if (!vfl->thumbs_enabled) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 vflist_thumb_status(vfl, 0.0, _("Loading thumbs..."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 vfl->thumbs_running = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 while (vflist_thumb_next(vfl));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 * row stuff
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 FileData *vflist_index_get_data(ViewFileList *vfl, gint row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 return g_list_nth_data(vfl->list, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 gchar *vflist_index_get_path(ViewFileList *vfl, gint row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 fd = g_list_nth_data(vfl->list, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 return (fd ? fd->path : NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 static gint vflist_row_by_path(ViewFileList *vfl, const gchar *path, FileData **fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 gint p = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 if (!path) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 work = vfl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 FileData *fd_n = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 if (strcmp(path, fd_n->path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 if (fd) *fd = fd_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 return p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 p++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 if (fd) *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 gint vflist_index_by_path(ViewFileList *vfl, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 return vflist_row_by_path(vfl, path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 gint vflist_count(ViewFileList *vfl, gint64 *bytes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 if (bytes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 gint64 b = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 work = vfl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 b += fd->size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 *bytes = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 return g_list_length(vfl->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 GList *vflist_get_list(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 work = vfl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1130 list = g_list_prepend(list, file_data_ref(fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 return g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 * selections
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 static gint vflist_row_is_selected(ViewFileList *vfl, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 gint found = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 while (!found && work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 FileData *fd_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 if (fd_n == fd) found = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 return found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 gint vflist_index_is_selected(ViewFileList *vfl, gint row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 fd = vflist_index_get_data(vfl, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 return vflist_row_is_selected(vfl, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 gint vflist_selection_count(ViewFileList *vfl, gint64 *bytes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 gint count;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 if (bytes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 gint64 b = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 b += fd->size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 *bytes = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 count = g_list_length(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 return count;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 GList *vflist_selection_get_list(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1237 list = g_list_prepend(list, file_data_ref(fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 return g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 GList *vflist_selection_get_list_by_index(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vfl->list, fd)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 return g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 void vflist_select_all(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 gtk_tree_selection_select_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 vfl->select_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 void vflist_select_none(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 void vflist_select_by_path(ViewFileList *vfl, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 FileData *fd;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1298
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1299 if (vflist_row_by_path(vfl, path, &fd) < 0) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1300
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1301 vflist_select_by_fd(vfl, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1302 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1303
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1304 void vflist_select_by_fd(ViewFileList *vfl, FileData *fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1305 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 if (vflist_find_row(vfl, fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 tree_view_row_make_visible(GTK_TREE_VIEW(vfl->listview), &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 if (!vflist_row_is_selected(vfl, fd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 vflist_move_cursor(vfl, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vfl->listview), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 * core (population)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 static void vflist_listview_set_height(GtkWidget *listview, gint thumb)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 GtkCellRenderer *cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_COLUMN_THUMB - 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 if (!column) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1345 gtk_tree_view_column_set_fixed_width(column, (thumb) ? thumb_max_width : FILE_COLUMN_MARKS);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 list = gtk_tree_view_column_get_cell_renderers(column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 cell = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 g_object_set(G_OBJECT(cell), "height", (thumb) ? thumb_max_height : -1, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 static void vflist_populate_view(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 gint thumbs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 GtkTreeRowReference *visible_row = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 thumbs = vfl->thumbs_enabled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 vflist_thumb_stop(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 if (!vfl->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 vflist_send_update(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 if (GTK_WIDGET_REALIZED(vfl->listview) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vfl->listview), 0, 0, &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 visible_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 vflist_listview_set_height(vfl->listview, thumbs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 work = vfl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 gint match;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 gint done = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 while (!done)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 FileData *old_fd = NULL;
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1399 int i;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1400
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 if (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &old_fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 match = CASE_SORT(fd->name, old_fd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 match = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 if (match < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 GtkTreeIter new;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 gchar *size;
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1415 gchar *sidecars;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417 size = text_from_size(fd->size);
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1418 sidecars = sidecar_file_data_list_to_string(fd);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1419
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 if (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 gtk_list_store_insert_before(store, &new, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 gtk_list_store_append(store, &new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 gtk_list_store_set(store, &new, FILE_COLUMN_POINTER, fd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 FILE_COLUMN_NAME, fd->name,
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1431 FILE_COLUMN_SIDECARS, sidecars,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 FILE_COLUMN_SIZE, size,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 FILE_COLUMN_DATE, text_from_time(fd->date),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 FILE_COLUMN_COLOR, FALSE, -1);
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1435 for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1436 gtk_list_store_set(store, &new, FILE_COLUMN_MARKS + i, fd->marks[i], -1);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1437
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1438 g_free(size);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1439 g_free(sidecars);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 done = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 else if (match > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 valid = gtk_list_store_remove(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449 gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 if (fd->date != old_fd->date)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1451 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 gchar *size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 /* update, file changed */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455 size = text_from_size(fd->size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 gtk_list_store_set(store, &iter, FILE_COLUMN_SIZE, size,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457 FILE_COLUMN_DATE, text_from_time(fd->date), -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 g_free(size);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460 else if (fd != old_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 /* preserve thumbnail */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 if (fd->pixbuf) g_object_unref(fd->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 fd->pixbuf = old_fd->pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 if (fd->pixbuf) g_object_ref(fd->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 gtk_list_store_set(store, &iter, FILE_COLUMN_THUMB, (thumbs) ? fd->pixbuf : NULL, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 if (vfl->select_fd == old_fd) vfl->select_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 done = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 valid = gtk_list_store_remove(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 if (visible_row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 if (gtk_tree_row_reference_valid(visible_row))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 tpath = gtk_tree_row_reference_get_path(visible_row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vfl->listview), tpath, NULL, TRUE, 0.0, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 gtk_tree_row_reference_free(visible_row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 vflist_send_update(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 vflist_thumb_update(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 gint vflist_refresh(ViewFileList *vfl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 GList *old_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 gint ret = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505 old_list = vfl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 vfl->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508 if (vfl->path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510 ret = filelist_read(vfl->path, &vfl->list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1513 vfl->list = filelist_sort(vfl->list, vfl->sort_method, vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1514 vflist_populate_view(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516 filelist_free(old_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1518 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1519 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 #define CELL_HEIGHT_OVERRIDE 512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1525 static void cell_renderer_height_override(GtkCellRenderer *renderer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1526 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1527 GParamSpec *spec;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1528
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1529 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1530 if (spec && G_IS_PARAM_SPEC_INT(spec))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532 GParamSpecInt *spec_int;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534 spec_int = G_PARAM_SPEC_INT(spec);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1539 static GdkColor *vflist_listview_color_shifted(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1541 static GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1542 static GtkWidget *done = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1543
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1544 if (done != widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1545 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1546 GtkStyle *style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1548 style = gtk_widget_get_style(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550 shift_color(&color, -1, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551 done = widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1554 return &color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1555 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1557 static void vflist_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1561 gboolean set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1563 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564 g_object_set(G_OBJECT(cell),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565 "cell-background-gdk", vflist_listview_color_shifted(vfl->listview),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 "cell-background-set", set, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1568
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1569 static void vflist_listview_add_column(ViewFileList *vfl, gint n, const gchar *title, gint image, gint right_justify, gint expand)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1572 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1575 gtk_tree_view_column_set_title(column, title);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1576 gtk_tree_view_column_set_min_width(column, 4);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 if (!image)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1579 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1580 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 if (right_justify)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1588 if (expand)
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1589 gtk_tree_view_column_set_expand(column, TRUE);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1590 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1593 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1594 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1595 cell_renderer_height_override(renderer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1596 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1597 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vfl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 gtk_tree_view_append_column(GTK_TREE_VIEW(vfl->listview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1604
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1605 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkListStore *store)
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1606 {
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1607 GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1608 guint *marks;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1609 GtkTreeIter iter;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1610 FileData *fd;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1611 gboolean mark;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1612 guint column;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1613
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1614 if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1615 return;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1616
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1617 column = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(cell), "column"));
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1618
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1619 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, column, &mark, -1);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1620 mark ^= 1;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1621 fd->marks[column] = mark;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1622
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1623 gtk_list_store_set(store, &iter, column, mark, -1);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1624 gtk_tree_path_free(path);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1625 }
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1626
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1627 static void vflist_listview_add_column_toggle(ViewFileList *vfl, gint n, const gchar *title)
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1628 {
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1629 GtkTreeViewColumn *column;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1630 GtkCellRenderer *renderer;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1631 GtkListStore *store;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1632 gint index;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1633
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1634 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1635
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1636 renderer = gtk_cell_renderer_toggle_new();
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1637 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1638
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1639 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1640 g_object_set_data (G_OBJECT (column), "column", GUINT_TO_POINTER(n));
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1641 g_object_set_data (G_OBJECT (renderer), "column", GUINT_TO_POINTER(n));
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1642
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1643 index = gtk_tree_view_append_column(GTK_TREE_VIEW(vfl->listview), column);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1644 gtk_tree_view_column_set_fixed_width(column, 16);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1645 gtk_tree_view_column_set_visible(column, vfl->marks_enabled);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1646
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1647
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1648 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled), store);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1649 }
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1650
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1652 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1653 * base
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1654 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1655 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 gint vflist_set_path(ViewFileList *vfl, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1661 if (!path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662 if (vfl->path && strcmp(path, vfl->path) == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1664 g_free(vfl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1665 vfl->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1667 /* force complete reload */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1668 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1671 filelist_free(vfl->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1672 vfl->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1674 return vflist_refresh(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1675 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1677 static void vflist_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1678 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1679 ViewFileList *vfl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1680
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1681 if (vfl->popup)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 g_signal_handlers_disconnect_matched(G_OBJECT(vfl->popup), G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 0, 0, 0, NULL, vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685 gtk_widget_destroy(vfl->popup);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 vflist_select_idle_cancel(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1689 vflist_thumb_stop(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1690
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1691 g_free(vfl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1692 filelist_free(vfl->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1693 g_free(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1694 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1696 ViewFileList *vflist_new(const gchar *path, gint thumbs)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698 ViewFileList *vfl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1699 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1700 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1701
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1702 GType *flist_types;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1703 int i;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1704
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1705 vfl = g_new0(ViewFileList, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707 vfl->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708 vfl->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1709 vfl->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1710 vfl->select_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711 vfl->sort_method = SORT_NAME;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1712 vfl->sort_ascend = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 vfl->thumbs_enabled = thumbs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715 vfl->thumbs_running = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 vfl->thumbs_count = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717 vfl->thumbs_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1718 vfl->thumbs_filedata = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1720 vfl->select_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1722 vfl->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1724 vfl->widget = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vfl->widget), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1726 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vfl->widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1727 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1728 g_signal_connect(G_OBJECT(vfl->widget), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1729 G_CALLBACK(vflist_destroy_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1730
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1731 flist_types = g_new(GType, FILE_COLUMN_COUNT);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1732 flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1733 flist_types[FILE_COLUMN_THUMB] = GDK_TYPE_PIXBUF;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1734 flist_types[FILE_COLUMN_NAME] = G_TYPE_STRING;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1735 flist_types[FILE_COLUMN_SIDECARS] = G_TYPE_STRING;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1736 flist_types[FILE_COLUMN_SIZE] = G_TYPE_STRING;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1737 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1738 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN;
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1739 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++)
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1740 flist_types[i] = G_TYPE_BOOLEAN;
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1741
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1742 store = gtk_list_store_newv(FILE_COLUMN_COUNT, flist_types);
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1743 g_free(flist_types);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1744
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1745 vfl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1746 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1747
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1748 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1749 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1750 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1751
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1752 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vfl->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1753 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vfl->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1754
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1755 vflist_listview_add_column(vfl, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1756 vflist_listview_add_column(vfl, FILE_COLUMN_NAME, _("Name"), FALSE, FALSE, FALSE);
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1757 vflist_listview_add_column(vfl, FILE_COLUMN_SIDECARS, _("sidecars"), FALSE, FALSE, FALSE);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1758 vflist_listview_add_column(vfl, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1759 vflist_listview_add_column(vfl, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1760
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1761 for(i = 0; i < FILEDATA_MARKS_SIZE;i++)
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1762 vflist_listview_add_column_toggle(vfl, i + FILE_COLUMN_MARKS, "");
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1763
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1764
139
754c1e4349b6 display sidecar extensions in filelist
nadvornik
parents: 138
diff changeset
1765 g_signal_connect(G_OBJECT(vfl->listview), "key_press_event",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1766 G_CALLBACK(vflist_press_key_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1767
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1768 gtk_container_add (GTK_CONTAINER(vfl->widget), vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1769 gtk_widget_show(vfl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1771 vflist_dnd_init(vfl);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1772
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1773 g_signal_connect(G_OBJECT(vfl->listview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1774 G_CALLBACK(vflist_press_cb), vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1775 g_signal_connect(G_OBJECT(vfl->listview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1776 G_CALLBACK(vflist_release_cb), vfl);
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1777
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1778
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1779 if (path) vflist_set_path(vfl, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1781 return vfl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1782 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1783
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1784 void vflist_set_status_func(ViewFileList *vfl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1785 void (*func)(ViewFileList *vfl, gpointer data), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1786 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1787 vfl->func_status = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1788 vfl->data_status = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1789 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1790
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1791 void vflist_set_thumb_status_func(ViewFileList *vfl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1792 void (*func)(ViewFileList *vfl, gdouble val, const gchar *text, gpointer data),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1793 gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1794 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1795 vfl->func_thumb_status = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1796 vfl->data_thumb_status = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1797 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1798
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1799 void vflist_thumb_set(ViewFileList *vfl, gint enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1800 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1801 if (vfl->thumbs_enabled == enable) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1803 vfl->thumbs_enabled = enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1804 vflist_refresh(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1805 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1806
132
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1807 void vflist_marks_set(ViewFileList *vfl, gint enable)
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1808 {
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1809 GtkListStore *store;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1810 GtkTreeViewColumn *column;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1811 int i;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1812
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1813 if (vfl->marks_enabled == enable) return;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1814
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1815 vfl->marks_enabled = enable;
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1816
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1817 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) {
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1818 /* index - 2 because column's store != tree view */
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1819 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vfl->listview), i + FILE_COLUMN_MARKS - 2);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1820
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1821 gtk_tree_view_column_set_visible(column, enable);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1822 }
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1823
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1824 //vflist_refresh(vfl);
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1825 }
661cd91e5a7e First implementation of marks for all photos.
bruclik
parents: 113
diff changeset
1826
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1827 void vflist_set_layout(ViewFileList *vfl, LayoutWindow *layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1828 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1829 vfl->layout = layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1830 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1831
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1832 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1833 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1834 * maintenance (for rename, move, remove)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1835 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1836 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1838 static gint vflist_maint_find_closest(ViewFileList *vfl, gint row, gint count, GList *ignore_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1839 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1840 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1841 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1842 gint rev = row - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1843 row ++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1844
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1845 work = ignore_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1846 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1847 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1848 gint f = vflist_index_by_path(vfl, work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1849 if (f >= 0) list = g_list_prepend(list, GINT_TO_POINTER(f));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1850 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1851 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1852
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1853 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1854 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1855 gint c = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1856 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1857 while (work && c)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1858 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1859 gpointer p = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1860 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1861 if (row == GPOINTER_TO_INT(p))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1862 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1863 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1864 c = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1865 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1866 if (rev == GPOINTER_TO_INT(p))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1867 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1868 rev--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1869 c = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1870 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1871 if (!c) list = g_list_remove(list, p);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1872 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1873 if (c && list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1874 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1875 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1876 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1877 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1878 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1879 if (row > count - 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1880 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1881 if (rev < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1882 return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1883 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1884 return rev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1885 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1886 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1887 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1888 return row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1889 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1890 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1891
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1892 gint vflist_maint_renamed(ViewFileList *vfl, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1893 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1894 gint ret = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1895 gint row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1896 gchar *source_base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1897 gchar *dest_base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1898 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1899
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1900 row = g_list_index(vfl->list, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1901 if (row < 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1902
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1903 source_base = remove_level_from_path(fd->change->source);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1904 dest_base = remove_level_from_path(fd->change->dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1905
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1907 if (strcmp(source_base, dest_base) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1908 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1909 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1910 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1911 GtkTreeIter position;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1912 gint old_row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1913 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1915 old_row = g_list_index(vfl->list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1916
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1917 vfl->list = g_list_remove(vfl->list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1919 vfl->list = filelist_insert_sort(vfl->list, fd, vfl->sort_method, vfl->sort_ascend);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1920 n = g_list_index(vfl->list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1921
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1922 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1923 row = vflist_find_row(vfl, fd, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1924 if (vflist_find_row(vfl, fd, &iter) >= 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1925 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1926 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1927 if (old_row >= n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1928 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1929 gtk_list_store_move_before(store, &iter, &position);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1930 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1931 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1932 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1933 gtk_list_store_move_after(store, &iter, &position);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1934 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1935 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1936 gtk_list_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1937
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1938 ret = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1939 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1940 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1941 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1942 ret = vflist_maint_removed(vfl, fd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1943 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1944
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1945 g_free(source_base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1946 g_free(dest_base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1947
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1948 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1949 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1950
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1951 gint vflist_maint_removed(ViewFileList *vfl, FileData *fd, GList *ignore_list)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1952 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1953 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1954 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1955 gint row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1956 gint new_row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1957
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
1958 row = g_list_index(vfl->list, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1959 if (row < 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1960
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1961 if (vflist_index_is_selected(vfl, row) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1962 layout_image_get_collection(vfl->layout, NULL) == NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1963 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1964 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1965
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1966 n = vflist_count(vfl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1967 if (ignore_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1969 new_row = vflist_maint_find_closest(vfl, row, n, ignore_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1970 if (debug) printf("row = %d, closest is %d\n", row, new_row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1971 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1972 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1973 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1974 if (row + 1 < n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1975 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1976 new_row = row + 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1977 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1978 else if (row > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1979 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1980 new_row = row - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1981 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1982 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1983 vflist_select_none(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1984 if (new_row >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1985 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1986 fd = vflist_index_get_data(vfl, new_row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1987 if (vflist_find_row(vfl, fd, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1988 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1989 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1991 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1992 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1993 vflist_move_cursor(vfl, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1994 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1995 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1996 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1998 fd = vflist_index_get_data(vfl, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1999 if (vflist_find_row(vfl, fd, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2000 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2001 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2002 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2003 gtk_list_store_remove(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2004 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2005 list = g_list_nth(vfl->list, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2006 fd = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2007
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2008 /* thumbnail loader check */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2009 if (fd == vfl->thumbs_filedata) vfl->thumbs_filedata = NULL;
111
3a69a7a3f461 Wed Nov 15 02:05:27 2006 John Ellis <johne@verizon.net>
gqview
parents: 93
diff changeset
2010 if (vfl->thumbs_count > 0) vfl->thumbs_count--;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2011
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2012 vfl->list = g_list_remove(vfl->list, fd);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
2013 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2014
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2015 vflist_send_update(vfl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2016
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2017 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2018 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2019
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
2020 gint vflist_maint_moved(ViewFileList *vfl, FileData *fd, GList *ignore_list)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2021 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2022 gint ret = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2023 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2024
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
2025 if (!fd->change->source || !vfl->path) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2026
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
2027 buf = remove_level_from_path(fd->change->source);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2028
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2029 if (strcmp(buf, vfl->path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2030 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 132
diff changeset
2031 ret = vflist_maint_removed(vfl, fd, ignore_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2032 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2033
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2034 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2035
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2036 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2037 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2038