annotate src/collect.c @ 42:606fcf461a68

Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net> * po/cs.po: Update Czech translation, submitted by Jan Raska <jan.raska@tiscali.cz> * de.po, fr.po: Typo and spelling fixes. Sat May 14 12:23:19 2005 John Ellis <johne@verizon.net> * image.c, pixbuf-renderer.c: Fix sending of complete signal. * ui_pathsel.c: Guard against strcmp of NULL dd->path, fixes crash. * utilops.c: Additional validation for destination of copy/move dialogs, and do not include extension when conveniently selecting filename text in rename dialogs. ##### Note: GQview CVS on sourceforge is not always up to date, please use ##### ##### an offical release when making enhancements and translation updates. #####
author gqview
date Sat, 14 May 2005 20:58:18 +0000
parents d907d608745f
children 9d5c75b5ec28
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #include "gqview.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "collect-dlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "collect-io.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "collect-table.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "editors.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "info.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "utilops.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_tree_edit.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include <gdk/gdkkeysyms.h> /* for keyboard values */
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 "icons/collect.xpm"
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 #define COLLECT_DEF_WIDTH 440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #define COLLECT_DEF_HEIGHT 450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 static GList *collection_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 static GList *collection_window_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 static void collection_window_get_geometry(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 static void collection_window_refresh(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 static void collection_window_update_title(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 static void collection_window_add(CollectWindow *cw, CollectInfo *ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 static void collection_window_update(CollectWindow *cw, CollectInfo *ci);
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 static void collection_window_close(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 * data, list handling
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 CollectInfo *collection_info_new(const gchar *path, struct stat *st, GdkPixbuf *pixbuf)
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 CollectInfo *ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 if (!path) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 ci = g_new0(CollectInfo, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 ci->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 ci->size = st->st_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 ci->date = st->st_mtime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 ci->pixbuf = pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 if (ci->pixbuf) g_object_ref(ci->pixbuf);
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 return ci;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 void collection_info_free_thumb(CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 if (ci->pixbuf) g_object_unref(ci->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 ci->pixbuf = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 void collection_info_free(CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 if (!ci) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 g_free(ci->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 collection_info_free_thumb(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 g_free(ci);
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 void collection_info_set_thumb(CollectInfo *ci, GdkPixbuf *pixbuf)
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 if (pixbuf) g_object_ref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 collection_info_free_thumb(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 ci->pixbuf = pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 gint collection_info_load_thumb(CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 if (!ci) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 collection_info_free_thumb(ci);
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 printf("collection_info_load_thumb not implemented!\n(because an instant thumb loader not implemented)");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 if (create_thumbnail(ci->path, &ci->pixmap, &ci->mask) < 0) return FALSE;
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 if (ci->pixmap) gdk_pixmap_ref(ci->pixmap);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 if (ci->mask) gdk_bitmap_ref(ci->mask);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 #endif
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 void collection_list_free(GList *list)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 while(work)
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 collection_info_free((CollectInfo *)work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 /* an ugly static var, well what ya gonna do ? */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 static SortType collection_list_sort_method = SORT_NAME;
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 static gint collection_list_sort_cb(gconstpointer a, gconstpointer b)
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 const CollectInfo *cia = a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 const CollectInfo *cib = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 switch(collection_list_sort_method)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 case SORT_NONE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 case SORT_SIZE:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 if (cia->size < cib->size) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 if (cia->size > cib->size) return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 case SORT_TIME:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 if (cia->date < cib->date) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 if (cia->date > cib->date) return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 case SORT_PATH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 return CASE_SORT(cia->path, cib->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 #ifdef HAVE_STRVERSCMP
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 case SORT_NUMBER:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 return strverscmp(filename_from_path(cia->path), filename_from_path(cib->path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 case SORT_NAME:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 return CASE_SORT(filename_from_path(cia->path), filename_from_path(cib->path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 }
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 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 GList *collection_list_sort(GList *list, SortType method)
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 if (method == SORT_NONE) return list;
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 collection_list_sort_method = method;
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 return g_list_sort(list, collection_list_sort_cb);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 GList *collection_list_add(GList *list, CollectInfo *ci, SortType method)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 if (method != SORT_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 collection_list_sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
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 else
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 list = g_list_append(list, ci);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 GList *collection_list_insert(GList *list, CollectInfo *ci, CollectInfo *insert_ci, SortType method)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 if (method != SORT_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 collection_list_sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
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 else
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 GList *point;
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 point = g_list_find(list, insert_ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 list = uig_list_insert_link(list, point, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 }
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 return list;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 GList *collection_list_remove(GList *list, CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 list = g_list_remove(list, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 collection_info_free(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 return list;
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 CollectInfo *collection_list_find(GList *list, const gchar *path)
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 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 while(work)
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 CollectInfo *ci = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 if (strcmp(ci->path, path) == 0) return ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 }
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 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 static GList *collection_list_find_link(GList *list, gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 CollectInfo *ci = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 if (strcmp(ci->path, path) == 0) return work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 }
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 static gint collection_list_find_index(GList *list, gchar *path)
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 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 CollectInfo *ci = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 if (strcmp(ci->path, path) == 0) return c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 c++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 GList *collection_list_to_path_list(GList *list)
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 GList *pathlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 CollectInfo *info = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 pathlist = g_list_prepend(pathlist, g_strdup(info->path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 pathlist = g_list_reverse(pathlist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 return pathlist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 CollectWindow *collection_window_find(CollectionData *cd)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 work = collection_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 while (work)
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 CollectWindow *cw = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 if (cw->cd == cd) return cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 }
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 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 CollectWindow *collection_window_find_by_path(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 if (!path) return NULL;
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 work = collection_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 while (work)
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 CollectWindow *cw = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 if (cw->cd->path && strcmp(cw->cd->path, path) == 0) return cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 return NULL;
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
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 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 * please use these to actually add/remove stuff
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 */
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 CollectionData *collection_new(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 CollectionData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 static gint untitled_counter = 0;
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 cd = g_new0(CollectionData, 1);
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 collection_list = g_list_append(collection_list, cd);
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 cd->ref = 1; /* starts with a ref of 1 */
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 cd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 cd->sort_method = SORT_NONE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 cd->thumb_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 cd->info_updated_func = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 cd->window_read = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 cd->window_x = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 cd->window_y = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 cd->window_w = COLLECT_DEF_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 cd->window_h = COLLECT_DEF_HEIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 cd->changed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 if (path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 cd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 cd->name = g_strdup(filename_from_path(cd->path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 /* load it */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 cd->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 if (untitled_counter == 0)
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 cd->name = g_strdup(_("Untitled"));
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 else
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 cd->name = g_strdup_printf(_("Untitled (%d)"), untitled_counter + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 }
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 untitled_counter++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 return cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 }
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 void collection_free(CollectionData *cd)
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 if (!cd) return;
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 if (debug) printf("collection \"%s\" freed\n", cd->name);
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 collection_load_stop(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 collection_list_free(cd->list);
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 collection_list = g_list_remove(collection_list, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 g_free(cd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 g_free(cd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 }
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 void collection_ref(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 cd->ref++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 if (debug) printf("collection \"%s\" ref count = %d\n", cd->name, cd->ref);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 void collection_unref(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 cd->ref--;
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 if (debug) printf("collection \"%s\" ref count = %d\n", cd->name, cd->ref);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 if (cd->ref < 1)
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 collection_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 void collection_path_changed(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 collection_window_update_title(collection_window_find(cd));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 gint collection_to_number(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 return g_list_index(collection_list, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 CollectionData *collection_from_number(gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 return g_list_nth_data(collection_list, n);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 CollectionData *collection_from_dnd_data(const gchar *data, GList **list, GList **info_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 CollectionData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 if (strncmp(data, "COLLECTION:", 11) != 0) return NULL;
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 n = (gint)strtol(data + 11, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 cd = collection_from_number(n);
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 if (!cd || (!list && !info_list))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 return cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 else
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 GList *work = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 GList *infol = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 gint b, e;
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 b = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 while(data[b] != '\0' && data[b] != '\n' ) b++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 b++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 e = b;
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 while (data[b] != '\0')
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 CollectInfo *info;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 while (data[e] != '\n' && data[e] != '\0') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 n = (gint)strtol(data + b, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 info = g_list_nth_data(cd->list, n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 if (info && list) work = g_list_append(work, g_strdup(info->path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 if (info && info_list) infol = g_list_append(infol, info);
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 while (data[e] == '\n') e++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 b = e;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 if (list) *list = work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 if (info_list) *info_list = infol;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 return cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 gchar *collection_info_list_to_dnd_data(CollectionData *cd, GList *list, gint *length)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gint total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 GList *temp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 n = collection_to_number(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 if (!list || n < 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 *length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 temp = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 temp = g_list_prepend(temp, g_strdup_printf("COLLECTION:%d\n", n));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 while(work)
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 n = g_list_index(cd->list, work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 if (n >= 0)
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 temp = g_list_prepend(temp, g_strdup_printf("%d\n", n));
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 total = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 work = temp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 total += strlen((gchar *)work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 total += 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 uri_text = g_malloc(total);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 ptr = uri_text;
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 work = g_list_last(temp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 gchar *text = work->data;
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 work = work->prev;
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 strcpy(ptr, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 ptr += strlen(text);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 ptr[0] = '\0';
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 path_list_free(temp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 *length = total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 return uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 }
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 gint collection_info_valid(CollectionData *cd, CollectInfo *info)
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 if (collection_to_number(cd) < 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 return (g_list_index(cd->list, info) != 0);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 CollectInfo *collection_next_by_info(CollectionData *cd, CollectInfo *info)
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 GList *work;
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 work = g_list_find(cd->list, info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 if (!work) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 if (work) return work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 CollectInfo *collection_prev_by_info(CollectionData *cd, CollectInfo *info)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 work = g_list_find(cd->list, info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 if (!work) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 if (work) return work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 CollectInfo *collection_get_first(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 if (cd->list) return cd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 CollectInfo *collection_get_last(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 list = g_list_last(cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 if (list) return list->data;
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 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 }
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 void collection_set_sort_method(CollectionData *cd, SortType method)
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 (!cd) return;
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 if (cd->sort_method == method) return;
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 cd->sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 cd->list = collection_list_sort(cd->list, cd->sort_method);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 if (cd->list) cd->changed = TRUE;
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 collection_window_refresh(collection_window_find(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 void collection_set_update_info_func(CollectionData *cd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 void (*func)(CollectionData *, CollectInfo *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 cd->info_updated_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 cd->info_updated_data = data;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 gint collection_add_check(CollectionData *cd, const gchar *path, gint sorted, gint must_exist)
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 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 if (must_exist)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 valid = (stat_utf8(path, &st) && !S_ISDIR(st.st_mode));
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 else
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 valid = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 st.st_size = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 st.st_mtime = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 }
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 (valid)
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 CollectInfo *ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 ci = collection_info_new(path, &st, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 cd->list = collection_list_add(cd->list, ci, sorted ? cd->sort_method : SORT_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 cd->changed = TRUE;
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 if (!sorted || cd->sort_method == SORT_NONE)
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 collection_window_add(collection_window_find(cd), ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 collection_window_insert(collection_window_find(cd), ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 return valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 gint collection_add(CollectionData *cd, const gchar *path, gint sorted)
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 return collection_add_check(cd, path, sorted, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 gint collection_insert(CollectionData *cd, const gchar *path, CollectInfo *insert_ci, gint sorted)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 if (!insert_ci) return collection_add(cd, path, sorted);
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 if (stat_utf8(path, &st) >= 0 && !S_ISDIR(st.st_mode))
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 CollectInfo *ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 ci = collection_info_new(path, &st, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 cd->list = collection_list_insert(cd->list, ci, insert_ci, sorted ? cd->sort_method : SORT_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 cd->changed = TRUE;
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 collection_window_insert(collection_window_find(cd), ci);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 }
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 gint collection_remove(CollectionData *cd, const gchar *path)
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 CollectInfo *ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 ci = collection_list_find(cd->list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 if (!ci) return FALSE;
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 cd->list = g_list_remove(cd->list, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 cd->changed = TRUE;
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 collection_window_remove(collection_window_find(cd), ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 collection_info_free(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 static void collection_remove_by_info(CollectionData *cd, CollectInfo *info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 if (!info || !g_list_find(cd->list, info)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 cd->list = g_list_remove(cd->list, info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 cd->changed = (cd->list != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 collection_window_remove(collection_window_find(cd), info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 collection_info_free(info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 }
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 void collection_remove_by_info_list(CollectionData *cd, GList *list)
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 GList *work;
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 if (!list) return;
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 if (!list->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 /* more efficient (in collect-table) to remove a single item this way */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 collection_remove_by_info(cd, (CollectInfo *)list->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 }
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 while(work)
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 cd->list = collection_list_remove(cd->list, work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 cd->changed = (cd->list != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 collection_window_refresh(collection_window_find(cd));
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 gint collection_rename(CollectionData *cd, const gchar *source, const gchar *dest)
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 CollectInfo *ci;
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 ci = collection_list_find(cd->list, source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 if (!ci) return FALSE;
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 g_free(ci->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 ci->path = g_strdup(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 cd->changed = TRUE;
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 collection_window_update(collection_window_find(cd), ci);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 }
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 void collection_update_geometry(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 collection_window_get_geometry(collection_window_find(cd));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 /*
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 * simple maintenance for renaming, deleting
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 *-------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 void collection_maint_removed(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 work = collection_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 CollectionData *cd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 while(collection_remove(cd, path));
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 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 /* Do we really need to do this? removed files are
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 * automatically ignored when loading a collection.
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 collect_manager_moved(path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 #endif
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 void collection_maint_renamed(const gchar *source, const gchar *dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 work = collection_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 while(work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 CollectionData *cd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 while(collection_rename(cd, source, dest));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 collect_manager_moved(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 * window key presses
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 *-------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 static gint collection_window_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data)
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 CollectWindow *cw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 gint stop_signal = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 gint edit_val = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 case '1':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 edit_val = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 case '2':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 edit_val = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 case '3':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 edit_val = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 case '4':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 edit_val = 3;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 case '5':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 edit_val = 4;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 case '6':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 edit_val = 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 case '7':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 edit_val = 6;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 case '8':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 edit_val = 7;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 case '9':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 edit_val = 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 case '0':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 edit_val = 9;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 case 'A': case 'a':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 collection_table_unselect_all(cw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 collection_table_select_all(cw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 case 'L': case 'l':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 list = layout_list(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 if (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 collection_table_add_path_list(cw->table, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 case 'C': case 'c':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 file_util_copy(NULL, collection_table_selection_get_list(cw->table), NULL, cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 case 'M': case 'm':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 file_util_move(NULL, collection_table_selection_get_list(cw->table), NULL, cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 case 'R': case 'r':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 file_util_rename(NULL, collection_table_selection_get_list(cw->table), cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 case 'D': case 'd':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 file_util_delete(NULL, collection_table_selection_get_list(cw->table), cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 case 'P': case 'p':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 info_window_new(NULL, collection_table_selection_get_list(cw->table));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 case 'S': case 's':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 collection_dialog_save_as(NULL, cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 case 'W': case 'w':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 collection_window_close(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 case GDK_Return: case GDK_KP_Enter:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 layout_image_set_collection(NULL, cw->cd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 collection_table_get_focus_info(cw->table));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 case 'V': case 'v':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 view_window_new_from_collection(cw->cd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 collection_table_get_focus_info(cw->table));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 case 'S': case 's':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 if (!cw->cd->path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 collection_dialog_save_as(NULL, cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 else if (!collection_save(cw->cd, cw->cd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 printf("failed saving to collection path: %s\n", cw->cd->path);
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 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 case 'A': case 'a':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 if (!(event->state & GDK_CONTROL_MASK))
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 collection_dialog_append(NULL, cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 case 'N': case 'n':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 collection_set_sort_method(cw->cd, SORT_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 #ifdef HAVE_STRVERSCMP
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 case 'I': case 'i':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 collection_set_sort_method(cw->cd, SORT_NUMBER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 case 'D': case 'd':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 collection_set_sort_method(cw->cd, SORT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 case 'B': case 'b':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 collection_set_sort_method(cw->cd, SORT_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 case 'P': case 'p':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 collection_set_sort_method(cw->cd, SORT_PATH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 case GDK_Delete: case GDK_KP_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 list = g_list_copy(cw->table->selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 if (list)
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 collection_remove_by_info_list(cw->cd, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 else
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 collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table));
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 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 if (edit_val != -1)
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 list = collection_table_selection_get_list(cw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 start_editor_from_path_list(edit_val, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 stop_signal = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 }
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 return stop_signal;
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 /*
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 * window
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 *-------------------------------------------------------------------
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 static void collection_window_get_geometry(CollectWindow *cw)
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 CollectionData *cd;
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 if (!cw) return;
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 cd = cw->cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 gdk_window_get_position (cw->window->window, &cd->window_x, &cd->window_y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 gdk_drawable_get_size(cw->window->window, &cd->window_w, &cd->window_h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 cd->window_read = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 }
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 static void collection_window_refresh(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 collection_table_refresh(cw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 static void collection_window_update_title(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 buf = g_strdup_printf(_("%s - GQview Collection"), cw->cd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 gtk_window_set_title(GTK_WINDOW(cw->window), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 }
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 static void collection_window_update_info(CollectionData *cd, CollectInfo *ci, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 CollectWindow *cw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 collection_table_file_update(cw->table, ci);
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 static void collection_window_add(CollectWindow *cw, CollectInfo *ci)
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 (!cw) return;
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 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 collection_table_file_add(cw->table, ci);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci)
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 (!cw) return;
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 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 collection_table_file_insert(cw->table, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 if (!cw) return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 static void collection_window_move(CollectWindow *cw, CollectInfo *ci)
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 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 collection_table_file_remove(cw->table, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 static void collection_window_update(CollectWindow *cw, CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 collection_table_file_update(cw->table, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 collection_table_file_update(cw->table, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 static void collection_window_close_final(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 if (cw->close_dialog) return;
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 collection_window_list = g_list_remove(collection_window_list, cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 collection_window_get_geometry(cw);
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 gtk_widget_destroy(cw->window);
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 collection_set_update_info_func(cw->cd, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 collection_unref(cw->cd);
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 g_free(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 }
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 static void collection_close_save_cb(GenericDialog *gd, gpointer data)
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 CollectWindow *cw = data;
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 cw->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 generic_dialog_close(gd);
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 if (!cw->cd->path)
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 collection_dialog_save_close(NULL, cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 else if (!collection_save(cw->cd, cw->cd->path))
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 *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cw->cd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 warning_dialog(_("Save Failed"), buf, GTK_STOCK_DIALOG_ERROR, cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 collection_window_close_final(cw);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 static void collection_close_close_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 CollectWindow *cw = data;
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 cw->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 collection_window_close_final(cw);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 static void collection_close_cancel_cb(GenericDialog *gd, gpointer data)
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 CollectWindow *cw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 cw->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 generic_dialog_close(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 }
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 static void collection_close_dlg_show(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 GenericDialog *gd;
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 if (cw->close_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 gtk_window_present(GTK_WINDOW(cw->close_dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 return;
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 gd = generic_dialog_new(_("Close collection"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 "GQview", "close_collection", cw->window, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 collection_close_cancel_cb, cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 _("Close collection"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 _("Collection has been modified.\nSave first?"));
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 generic_dialog_add_button(gd, GTK_STOCK_SAVE, NULL, collection_close_save_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 generic_dialog_add_button(gd, GTK_STOCK_DELETE, _("_Discard"), collection_close_close_cb, FALSE);
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 cw->close_dialog = gd->dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 gtk_widget_show(gd->dialog);
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 static void collection_window_close(CollectWindow *cw)
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 if (!cw->cd->changed && !cw->close_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 collection_window_close_final(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 }
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 collection_close_dlg_show(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 }
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 void collection_window_close_by_collection(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 CollectWindow *cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 cw = collection_window_find(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 if (cw) collection_window_close_final(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 }
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 gint collection_window_modified_exists(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 GList *work;
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 work = collection_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 CollectWindow *cw = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 if (cw->cd->changed) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 }
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 static gint collection_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 CollectWindow *cw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 collection_window_close(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 }
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 CollectWindow *collection_window_new(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 CollectWindow *cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 GtkWidget *frame;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 GtkWidget *status_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 GtkWidget *extra_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 GdkGeometry geometry;
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 cw = g_new0(CollectWindow, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 cw->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 collection_window_list = g_list_append(collection_window_list, cw);
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 cw->cd = collection_new(path);
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 cw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 window_set_icon(cw->window, (const gchar **)collect_xpm, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 geometry.min_width = 32;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 geometry.min_height = 32;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 geometry.base_width = COLLECT_DEF_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 geometry.base_height = COLLECT_DEF_HEIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 gtk_window_set_geometry_hints(GTK_WINDOW(cw->window), NULL, &geometry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 if (save_window_positions && path && collection_load_only_geometry(cw->cd, path))
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 /* FIXME: x, y is not implemented */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 gtk_window_set_default_size(GTK_WINDOW(cw->window), cw->cd->window_w, cw->cd->window_h);
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 else
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 gtk_window_set_default_size(GTK_WINDOW(cw->window), COLLECT_DEF_WIDTH, COLLECT_DEF_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 }
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 gtk_window_set_resizable(GTK_WINDOW(cw->window), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 collection_window_update_title(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 gtk_window_set_wmclass(GTK_WINDOW(cw->window), "collection", "GQview");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 gtk_container_set_border_width (GTK_CONTAINER (cw->window), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 g_signal_connect(G_OBJECT(cw->window), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 G_CALLBACK(collection_window_delete), cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 g_signal_connect(G_OBJECT(cw->window),"key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 G_CALLBACK(collection_window_keypress), cw);
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 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 gtk_container_add(GTK_CONTAINER(cw->window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 cw->table = collection_table_new(cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 gtk_box_pack_start(GTK_BOX(vbox), cw->table->scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 gtk_widget_show(cw->table->scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 cw->status_box = gtk_hbox_new(TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 gtk_box_pack_start(GTK_BOX(vbox), cw->status_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 gtk_widget_show(cw->status_box);
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 frame = gtk_frame_new(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 gtk_box_pack_start(GTK_BOX(cw->status_box), frame, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 gtk_widget_show(frame);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 status_label = gtk_label_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 gtk_container_add(GTK_CONTAINER(frame), status_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 gtk_widget_show(status_label);
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 extra_label = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(extra_label), 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 gtk_box_pack_start(GTK_BOX(cw->status_box), extra_label, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 gtk_widget_show(extra_label);
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 collection_table_set_labels(cw->table, status_label, extra_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 gtk_widget_show(cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 gtk_widget_grab_focus(cw->table->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 collection_set_update_info_func(cw->cd, collection_window_update_info, cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 if (path && *path == '/') collection_load_begin(cw->cd, NULL, FALSE);
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 return cw;
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