annotate src/collect.c @ 1535:760f585d9fa0

Implement random sort method for collections This patch allows to randomize the collections. (Closes: #2497413) https://sourceforge.net/tracker/?func=detail&aid=2497413&group_id=222125&atid=1054683
author mow
date Fri, 10 Apr 2009 13:44:37 +0000
parents 5f49f305a6b6
children b1e622788c4a
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 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
2 * Geeqie
94
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
3 * (C) 2006 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1272
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * 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
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
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 259
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "collect-dlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "collect-io.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "collect-table.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "editors.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 516
diff changeset
21 #include "filedata.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "img-view.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"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 816
diff changeset
25 #include "misc.h"
91
d063f97503b7 Wed Nov 1 11:39:48 2006 John Ellis <johne@verizon.net>
gqview
parents: 85
diff changeset
26 #include "pixbuf_util.h"
94
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
27 #include "print.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include "ui_tree_edit.h"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 816
diff changeset
30 #include "utilops.h"
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents: 586
diff changeset
31 #include "window.h"
9
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 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34
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 #define COLLECT_DEF_WIDTH 440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 #define COLLECT_DEF_HEIGHT 450
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 GList *collection_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 static GList *collection_window_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 static void collection_window_get_geometry(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 static void collection_window_refresh(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 static void collection_window_update_title(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 static void collection_window_add(CollectWindow *cw, CollectInfo *ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 static void collection_window_update(CollectWindow *cw, CollectInfo *ci);
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 static void collection_window_close(CollectWindow *cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
52 static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data);
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
53
9
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 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 * data, list handling
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
60 CollectInfo *collection_info_new(FileData *fd, struct stat *st, GdkPixbuf *pixbuf)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 CollectInfo *ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
64 if (!fd) return NULL;
9
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 = g_new0(CollectInfo, 1);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
67 ci->fd = file_data_ref(fd);
9
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 ci->pixbuf = pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 if (ci->pixbuf) g_object_ref(ci->pixbuf);
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 return 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 void collection_info_free_thumb(CollectInfo *ci)
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 if (ci->pixbuf) g_object_unref(ci->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 ci->pixbuf = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 void collection_info_free(CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 if (!ci) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
85 file_data_unref(ci->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 collection_info_free_thumb(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 g_free(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 void collection_info_set_thumb(CollectInfo *ci, GdkPixbuf *pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 if (pixbuf) g_object_ref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 collection_info_free_thumb(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 ci->pixbuf = pixbuf;
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
97 gboolean collection_info_load_thumb(CollectInfo *ci)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 if (!ci) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 collection_info_free_thumb(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
103 log_printf("collection_info_load_thumb not implemented!\n(because an instant thumb loader not implemented)");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 return FALSE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 358
diff changeset
105 #if 0
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
106 if (create_thumbnail(ci->fd->path, &ci->pixmap, &ci->mask) < 0) return FALSE;
9
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 if (ci->pixmap) gdk_pixmap_ref(ci->pixmap);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 if (ci->mask) gdk_bitmap_ref(ci->mask);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 #endif
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 void collection_list_free(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 work = list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
119 while (work)
9
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 collection_info_free((CollectInfo *)work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 work = work->next;
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 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 }
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 /* an ugly static var, well what ya gonna do ? */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 static SortType collection_list_sort_method = SORT_NAME;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 static gint collection_list_sort_cb(gconstpointer a, gconstpointer 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 const CollectInfo *cia = a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 const CollectInfo *cib = b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134
1347
79937bc55f3a Add missing space between switch and first parenthesis.
zas_
parents: 1292
diff changeset
135 switch (collection_list_sort_method)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 {
785
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 753
diff changeset
137 case SORT_NAME:
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 753
diff changeset
138 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 case SORT_NONE:
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_SIZE:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
143 if (cia->fd->size < cib->fd->size) return -1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
144 if (cia->fd->size > cib->fd->size) return 1;
9
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_TIME:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
148 if (cia->fd->date < cib->fd->date) return -1;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
149 if (cia->fd->date > cib->fd->date) return 1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 case SORT_PATH:
786
a20ff446347e Compare paths using utf8_collate_key() since paths are utf8-encoded.
zas_
parents: 785
diff changeset
153 return utf8_compare(cia->fd->path, cib->fd->path, options->file_sort.case_sensitive);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 #ifdef HAVE_STRVERSCMP
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 case SORT_NUMBER:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
157 return strverscmp(cia->fd->name, cib->fd->name);
9
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 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 break;
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
785
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 753
diff changeset
164 if (options->file_sort.case_sensitive)
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 753
diff changeset
165 return strcmp(cia->fd->collate_key_name, cib->fd->collate_key_name);
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 753
diff changeset
166 else
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 753
diff changeset
167 return strcmp(cia->fd->collate_key_name_nocase, cib->fd->collate_key_name_nocase);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 GList *collection_list_sort(GList *list, SortType method)
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 if (method == SORT_NONE) return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 collection_list_sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 return g_list_sort(list, collection_list_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
1535
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
179 GList *collection_list_randomize(GList *list)
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
180 {
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
181 guint random, length, i;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
182 gpointer tmp;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
183 GList *nlist, *olist;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
184
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
185 length = g_list_length(list);
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
186 if (!length) return NULL;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
187
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
188 srand((unsigned int)time(NULL)); // Initialize random generator (hasn't to be that much strong)
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
189
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
190 for (i = 0; i < length; i++)
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
191 {
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
192 random = (guint) (1.0 * length * rand()/(RAND_MAX + 1.0));
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
193 olist = g_list_nth(list, i);
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
194 nlist = g_list_nth(list, random);
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
195 tmp = olist->data;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
196 olist->data = nlist->data;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
197 nlist->data = tmp;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
198 }
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
199
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
200 return list;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
201 }
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
202
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 GList *collection_list_add(GList *list, CollectInfo *ci, SortType method)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 if (method != SORT_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 collection_list_sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 else
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 list = g_list_append(list, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 }
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 return 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 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
219 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 if (method != SORT_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 collection_list_sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 list = g_list_insert_sorted(list, ci, collection_list_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 else
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 GList *point;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 point = g_list_find(list, insert_ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 list = uig_list_insert_link(list, point, ci);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 GList *collection_list_remove(GList *list, CollectInfo *ci)
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 list = g_list_remove(list, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 collection_info_free(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 return list;
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
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
243 CollectInfo *collection_list_find_fd(GList *list, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 {
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
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
247 while (work)
9
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;
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
250 if (ci->fd == fd) return ci;
9
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 }
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 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 static GList *collection_list_find_link(GList *list, gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
262 while (work)
9
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 CollectInfo *ci = work->data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
265 if (strcmp(ci->fd->path, path) == 0) return work;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 static gint collection_list_find_index(GList *list, gchar *path)
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 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
277 while (work)
9
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 CollectInfo *ci = work->data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
280 if (strcmp(ci->fd->path, path) == 0) return c;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 return -1;
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 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
289 GList *collection_list_to_filelist(GList *list)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
291 GList *filelist = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 GList *work = list;
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 while (work)
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 CollectInfo *info = work->data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
297 filelist = g_list_prepend(filelist, file_data_ref(info->fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
301 filelist = g_list_reverse(filelist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
302 return filelist;
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 CollectWindow *collection_window_find(CollectionData *cd)
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 GList *work;
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 work = collection_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 while (work)
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 CollectWindow *cw = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 if (cw->cd == cd) return cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 }
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 CollectWindow *collection_window_find_by_path(const gchar *path)
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 GList *work;
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 if (!path) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 work = collection_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 while (work)
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 CollectWindow *cw = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 if (cw->cd->path && strcmp(cw->cd->path, path) == 0) return cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 * please use these to actually add/remove stuff
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 CollectionData *collection_new(const gchar *path)
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 CollectionData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 static gint untitled_counter = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 cd = g_new0(CollectionData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 cd->ref = 1; /* starts with a ref of 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 cd->sort_method = SORT_NONE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 cd->window_w = COLLECT_DEF_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 cd->window_h = COLLECT_DEF_HEIGHT;
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
354 cd->existence = g_hash_table_new(NULL, NULL);
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
355
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 if (path)
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 cd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 cd->name = g_strdup(filename_from_path(cd->path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 /* load it */
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 else
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 (untitled_counter == 0)
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 cd->name = g_strdup(_("Untitled"));
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 cd->name = g_strdup_printf(_("Untitled (%d)"), untitled_counter + 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 untitled_counter++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
376 file_data_register_notify_func(collection_notify_cb, cd, NOTIFY_PRIORITY_MEDIUM);
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
377
1367
fe4da037be21 When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass.
zas_
parents: 1347
diff changeset
378
fe4da037be21 When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass.
zas_
parents: 1347
diff changeset
379 collection_list = g_list_append(collection_list, cd);
fe4da037be21 When g_new0() is used, drop redundant initializations to NULL, FALSE or 0, second pass.
zas_
parents: 1347
diff changeset
380
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 return cd;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 void collection_free(CollectionData *cd)
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 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
388 DEBUG_1("collection \"%s\" freed", cd->name);
9
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 collection_load_stop(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 collection_list_free(cd->list);
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
392
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
393 file_data_unregister_notify_func(collection_notify_cb, cd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 collection_list = g_list_remove(collection_list, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
397 g_hash_table_destroy(cd->existence);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 358
diff changeset
398
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 g_free(cd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 g_free(cd->name);
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 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 }
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 void collection_ref(CollectionData *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 cd->ref++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
409 DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 }
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 void collection_unref(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 cd->ref--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
416 DEBUG_1("collection \"%s\" ref count = %d", cd->name, cd->ref);
9
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 (cd->ref < 1)
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 collection_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 void collection_path_changed(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 collection_window_update_title(collection_window_find(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 }
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 gint collection_to_number(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 return g_list_index(collection_list, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 CollectionData *collection_from_number(gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 return g_list_nth_data(collection_list, n);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 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
440 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 CollectionData *cd;
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
442 gint collection_number;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
443 const gchar *ptr;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
444
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
445 if (list) *list = NULL;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
446 if (info_list) *info_list = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 if (strncmp(data, "COLLECTION:", 11) != 0) return NULL;
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
449
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
450 ptr = data + 11;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
451
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
452 collection_number = atoi(ptr);
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
453 cd = collection_from_number(collection_number);
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
454 if (!cd) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
456 if (!list && !info_list) return cd;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
457
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
458 while (*ptr != '\0' && *ptr != '\n' ) ptr++;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
459 if (*ptr == '\0') return cd;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
460 ptr++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
462 while (*ptr != '\0')
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
463 {
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
464 guint item_number;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
465 CollectInfo *info;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
466
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
467 item_number = (guint) atoi(ptr);
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
468 while (*ptr != '\n' && *ptr != '\0') ptr++;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
469 if (*ptr == '\0')
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
470 break;
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
471 else
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
472 while (*ptr == '\n') ptr++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
474 info = g_list_nth_data(cd->list, item_number);
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
475 if (!info) continue;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
477 if (list) *list = g_list_append(*list, file_data_ref(info->fd));
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
478 if (info_list) *info_list = g_list_append(*info_list, info);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 }
816
cf5bbd0beaae collection_from_dnd_data(): simplify and optimize.
zas_
parents: 815
diff changeset
480
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 return cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 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
485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 GList *work;
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
487 GList *temp = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 gchar *ptr;
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
489 gchar *text;
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
490 gchar *uri_text;
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
491 gint collection_number;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
493 *length = 0;
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
494 if (!list) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
496 collection_number = collection_to_number(cd);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
497 if (collection_number < 0) return NULL;
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
498
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
499 text = g_strdup_printf("COLLECTION:%d\n", collection_number);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
500 *length += strlen(text);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
501 temp = g_list_prepend(temp, text);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
502
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 work = list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
504 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 {
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
506 gint item_number = g_list_index(cd->list, work->data);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
507
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 work = work->next;
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
509
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
510 if (item_number < 0) continue;
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
511
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
512 text = g_strdup_printf("%d\n", item_number);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
513 temp = g_list_prepend(temp, text);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
514 *length += strlen(text);
9
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
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
517 *length += 1; /* ending nul char */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
519 uri_text = g_malloc(*length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 ptr = uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 work = g_list_last(temp);
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
523 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 {
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
525 gint len;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 gchar *text = work->data;
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 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
815
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
530 len = strlen(text);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
531 memcpy(ptr, text, len);
7daea970a89a collection_info_list_to_dnd_data(): simplify and optimize.
zas_
parents: 803
diff changeset
532 ptr += len;
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 ptr[0] = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
537 string_list_free(temp);
9
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 return uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 }
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 gint collection_info_valid(CollectionData *cd, CollectInfo *info)
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 if (collection_to_number(cd) < 0) return FALSE;
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 return (g_list_index(cd->list, info) != 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 CollectInfo *collection_next_by_info(CollectionData *cd, CollectInfo *info)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 work = g_list_find(cd->list, info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 if (!work) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 if (work) return work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 CollectInfo *collection_prev_by_info(CollectionData *cd, CollectInfo *info)
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 GList *work;
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 work = g_list_find(cd->list, info);
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 if (!work) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 if (work) return work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 CollectInfo *collection_get_first(CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 if (cd->list) return cd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 CollectInfo *collection_get_last(CollectionData *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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 list = g_list_last(cd->list);
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 if (list) return list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 void collection_set_sort_method(CollectionData *cd, SortType method)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 if (!cd) return;
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 (cd->sort_method == method) return;
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 cd->sort_method = method;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 cd->list = collection_list_sort(cd->list, cd->sort_method);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 if (cd->list) cd->changed = TRUE;
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 collection_window_refresh(collection_window_find(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603
1535
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
604 void collection_randomize(CollectionData *cd)
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
605 {
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
606 if (!cd) return;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
607
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
608 cd->list = collection_list_randomize(cd->list);
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
609 if (cd->list) cd->changed = TRUE;
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
610
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
611 collection_window_refresh(collection_window_find(cd));
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
612 }
760f585d9fa0 Implement random sort method for collections
mow
parents: 1498
diff changeset
613
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 void collection_set_update_info_func(CollectionData *cd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 void (*func)(CollectionData *, CollectInfo *, gpointer), gpointer data)
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 cd->info_updated_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 cd->info_updated_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
621 static CollectInfo *collection_info_new_if_not_exists(CollectionData *cd, struct stat *st, FileData *fd)
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
622 {
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
623 CollectInfo *ci;
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
624
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
625 if (g_hash_table_lookup(cd->existence, fd->path)) return NULL;
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
626
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
627 ci = collection_info_new(fd, st, NULL);
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
628 if (ci) g_hash_table_insert(cd->existence, fd->path, "");
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
629 return ci;
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
630 }
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
631
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
632 gboolean collection_add_check(CollectionData *cd, FileData *fd, gboolean sorted, gboolean must_exist)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 struct stat st;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
635 gboolean valid;
9
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 (must_exist)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
639 valid = (stat_utf8(fd->path, &st) && !S_ISDIR(st.st_mode));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 valid = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 st.st_size = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 st.st_mtime = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 if (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 CollectInfo *ci;
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
651
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
652 ci = collection_info_new_if_not_exists(cd, &st, fd);
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
653 if (!ci) return FALSE;
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
654 DEBUG_3("add to collection: %s", fd->path);
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
655
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 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
657 cd->changed = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 if (!sorted || cd->sort_method == SORT_NONE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 collection_window_add(collection_window_find(cd), ci);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 collection_window_insert(collection_window_find(cd), ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 }
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 return valid;
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
672 gboolean collection_add(CollectionData *cd, FileData *fd, gboolean sorted)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
674 return collection_add_check(cd, fd, sorted, TRUE);
9
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
677 gboolean collection_insert(CollectionData *cd, FileData *fd, CollectInfo *insert_ci, gboolean sorted)
9
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 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
681 if (!insert_ci) return collection_add(cd, fd, sorted);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
683 if (stat_utf8(fd->path, &st) >= 0 && !S_ISDIR(st.st_mode))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 CollectInfo *ci;
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
686
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
687 ci = collection_info_new_if_not_exists(cd, &st, fd);
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
688 if (!ci) return FALSE;
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
689
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
690 DEBUG_3("insert in collection: %s", fd->path);
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
691
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 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
693 cd->changed = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 collection_window_insert(collection_window_find(cd), ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
703 gboolean collection_remove(CollectionData *cd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 CollectInfo *ci;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
707 ci = collection_list_find_fd(cd->list, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 if (!ci) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710
303
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
711 g_hash_table_remove(cd->existence, fd->path);
6ff0bc50ac46 Prevent multiple insertion of the same file in a collection.
zas_
parents: 289
diff changeset
712
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 cd->list = g_list_remove(cd->list, ci);
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_remove(collection_window_find(cd), ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 collection_info_free(ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 static void collection_remove_by_info(CollectionData *cd, CollectInfo *info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 if (!info || !g_list_find(cd->list, info)) return;
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 cd->list = g_list_remove(cd->list, info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 cd->changed = (cd->list != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 collection_window_remove(collection_window_find(cd), info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 collection_info_free(info);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 void collection_remove_by_info_list(CollectionData *cd, GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 if (!list) return;
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 if (!list->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 /* more efficient (in collect-table) to remove a single item this way */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 collection_remove_by_info(cd, (CollectInfo *)list->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 work = list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
747 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 cd->list = collection_list_remove(cd->list, work->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 work = work->next;
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 cd->changed = (cd->list != NULL);
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 collection_window_refresh(collection_window_find(cd));
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
757 gboolean collection_rename(CollectionData *cd, FileData *fd)
9
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 CollectInfo *ci;
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
760 ci = collection_list_find_fd(cd->list, fd);
9
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 if (!ci) return FALSE;
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 cd->changed = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 collection_window_update(collection_window_find(cd), ci);
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 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 void collection_update_geometry(CollectionData *cd)
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 collection_window_get_geometry(collection_window_find(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 * simple maintenance for renaming, deleting
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 *-------------------------------------------------------------------
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
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
782 static void collection_notify_cb(FileData *fd, NotifyType type, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 {
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
784 CollectionData *cd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
1432
cf4029d10d38 improved notification system
nadvornik
parents: 1420
diff changeset
786 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
1498
5f49f305a6b6 improved debug messages
nadvornik
parents: 1436
diff changeset
787
5f49f305a6b6 improved debug messages
nadvornik
parents: 1436
diff changeset
788 DEBUG_1("Notify collection: %s %04x", fd->path, type);
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
789
1347
79937bc55f3a Add missing space between switch and first parenthesis.
zas_
parents: 1292
diff changeset
790 switch (fd->change->type)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 {
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
792 case FILEDATA_CHANGE_MOVE:
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
793 case FILEDATA_CHANGE_RENAME:
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
794 collection_rename(cd, fd);
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
795 break;
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
796 case FILEDATA_CHANGE_COPY:
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
797 break;
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
798 case FILEDATA_CHANGE_DELETE:
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
799 while (collection_remove(cd, fd));
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
800 break;
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
801 case FILEDATA_CHANGE_UNSPECIFIED:
1211
e2bbe90b0dcd most of the metadata options now works
nadvornik
parents: 1176
diff changeset
802 case FILEDATA_CHANGE_WRITE_METADATA:
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
803 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 }
799
278962ba162a use the new notification for collections
nadvornik
parents: 786
diff changeset
805
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 * window key presses
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
815 static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 CollectWindow *cw = data;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
818 gboolean stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 gint edit_val = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 GList *list;
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 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
824 stop_signal = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 case '1':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 edit_val = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 case '2':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 edit_val = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 case '3':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 edit_val = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 case '4':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 edit_val = 3;
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 '5':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 edit_val = 4;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 case '6':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 edit_val = 5;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 case '7':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 edit_val = 6;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 case '8':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 edit_val = 7;
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 '9':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 edit_val = 8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 case '0':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 edit_val = 9;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 case 'A': case 'a':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 if (event->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 collection_table_unselect_all(cw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 collection_table_select_all(cw->table);
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 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 case 'L': case 'l':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 list = layout_list(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 if (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
871 collection_table_add_filelist(cw->table, list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
872 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 case 'C': case 'c':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 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
877 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 case 'M': case 'm':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 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
880 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 case 'R': case 'r':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 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
883 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 case 'D': case 'd':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 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
886 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 case 'S': case 's':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 collection_dialog_save_as(NULL, cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 case 'W': case 'w':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 collection_window_close(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 default:
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
894 stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
900 stop_signal = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 case GDK_Return: case GDK_KP_Enter:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 layout_image_set_collection(NULL, cw->cd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 collection_table_get_focus_info(cw->table));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 case 'V': case 'v':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 view_window_new_from_collection(cw->cd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 collection_table_get_focus_info(cw->table));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 case 'S': case 's':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 if (!cw->cd->path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 collection_dialog_save_as(NULL, cw->cd);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 358
diff changeset
915 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 else if (!collection_save(cw->cd, cw->cd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
918 log_printf("failed saving to collection path: %s\n", cw->cd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 case 'A': case 'a':
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
922 collection_dialog_append(NULL, cw->cd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 case 'N': case 'n':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 collection_set_sort_method(cw->cd, SORT_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 #ifdef HAVE_STRVERSCMP
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 case 'I': case 'i':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 collection_set_sort_method(cw->cd, SORT_NUMBER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 case 'D': case 'd':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 collection_set_sort_method(cw->cd, SORT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 case 'B': case 'b':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 collection_set_sort_method(cw->cd, SORT_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 case 'P': case 'p':
94
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
939 if (event->state & GDK_SHIFT_MASK)
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
940 {
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
941 CollectInfo *info;
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
942
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
943 info = collection_table_get_focus_info(cw->table);
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
944
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
945 print_window_new(info->fd, collection_table_selection_get_list(cw->table),
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
946 collection_list_to_filelist(cw->cd->list), cw->window);
94
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
947 }
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
948 else
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
949 {
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
950 collection_set_sort_method(cw->cd, SORT_PATH);
50dc5a14d37b Thu Nov 2 17:51:31 2006 John Ellis <johne@verizon.net>
gqview
parents: 91
diff changeset
951 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 case GDK_Delete: case GDK_KP_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 list = g_list_copy(cw->table->selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 if (list)
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 collection_remove_by_info_list(cw->cd, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 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
963 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 default:
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
966 stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 break;
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 }
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
970 #if 0
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 if (edit_val != -1)
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 list = collection_table_selection_get_list(cw->table);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 726
diff changeset
974 file_util_start_editor_from_filelist(edit_val, list, cw->window);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 94
diff changeset
975 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 }
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
977 #endif
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 return stop_signal;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 * window
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 static void collection_window_get_geometry(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 CollectionData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 if (!cw) return;
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 cd = cw->cd;
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 507
diff changeset
993 gdk_window_get_position(cw->window->window, &cd->window_x, &cd->window_y);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 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
995 cd->window_read = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 static void collection_window_refresh(CollectWindow *cw)
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 if (!cw) return;
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 collection_table_refresh(cw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 static void collection_window_update_title(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 {
1176
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1007 gboolean free_name = FALSE;
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1008 gchar *name;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012
1176
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1013 if (file_extension_match(cw->cd->name, GQ_COLLECTION_EXT))
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1014 {
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1015 name = remove_extension_from_path(cw->cd->name);
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1016 free_name = TRUE;
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1017 }
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1018 else
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1019 {
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1020 name = cw->cd->name;
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1021 }
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1022
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1023 buf = g_strdup_printf(_("%s - Collection - %s"), name, GQ_APPNAME);
d3e51e1a02f8 Hide .gqv extension from collection name in collection window title and recent menu list.
zas_
parents: 1174
diff changeset
1024 if (free_name) g_free(name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 gtk_window_set_title(GTK_WINDOW(cw->window), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 static void collection_window_update_info(CollectionData *cd, CollectInfo *ci, gpointer data)
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 CollectWindow *cw = data;
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 collection_table_file_update(cw->table, ci);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 static void collection_window_add(CollectWindow *cw, CollectInfo *ci)
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 if (!cw) return;
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 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 collection_table_file_add(cw->table, ci);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 static void collection_window_insert(CollectWindow *cw, CollectInfo *ci)
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 if (!cw) return;
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 if (!ci->pixbuf) collection_load_thumb_idle(cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 collection_table_file_insert(cw->table, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 }
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 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 static void collection_window_move(CollectWindow *cw, CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 if (!cw) 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 #endif
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 static void collection_window_remove(CollectWindow *cw, CollectInfo *ci)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 collection_table_file_remove(cw->table, ci);
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 static void collection_window_update(CollectWindow *cw, CollectInfo *ci)
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 if (!cw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 collection_table_file_update(cw->table, ci);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 collection_table_file_update(cw->table, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 static void collection_window_close_final(CollectWindow *cw)
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 if (cw->close_dialog) return;
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 collection_window_list = g_list_remove(collection_window_list, cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 collection_window_get_geometry(cw);
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 gtk_widget_destroy(cw->window);
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 collection_set_update_info_func(cw->cd, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 collection_unref(cw->cd);
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 g_free(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 static void collection_close_save_cb(GenericDialog *gd, gpointer data)
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 CollectWindow *cw = data;
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 cw->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 generic_dialog_close(gd);
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 if (!cw->cd->path)
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 358
diff changeset
1098 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 collection_dialog_save_close(NULL, cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 else if (!collection_save(cw->cd, cw->cd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 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
1106 warning_dialog(_("Save Failed"), buf, GTK_STOCK_DIALOG_ERROR, cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 collection_window_close_final(cw);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 static void collection_close_close_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 CollectWindow *cw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 cw->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 generic_dialog_close(gd);
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_window_close_final(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 static void collection_close_cancel_cb(GenericDialog *gd, gpointer data)
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 = data;
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->close_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 generic_dialog_close(gd);
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 static void collection_close_dlg_show(CollectWindow *cw)
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 GenericDialog *gd;
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 if (cw->close_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 gtk_window_present(GTK_WINDOW(cw->close_dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 gd = generic_dialog_new(_("Close collection"),
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1055
diff changeset
1143 "close_collection", cw->window, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 collection_close_cancel_cb, cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 _("Close collection"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 _("Collection has been modified.\nSave first?"));
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 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
1150 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
1151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 cw->close_dialog = gd->dialog;
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 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 }
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 static void collection_window_close(CollectWindow *cw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 if (!cw->cd->changed && !cw->close_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 collection_window_close_final(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 collection_close_dlg_show(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 void collection_window_close_by_collection(CollectionData *cd)
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 CollectWindow *cw;
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 = collection_window_find(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 if (cw) collection_window_close_final(cw);
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
1176 gboolean collection_window_modified_exists(void)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 work = collection_window_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 while (work)
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 CollectWindow *cw = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 if (cw->cd->changed) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 }
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 return FALSE;
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1367
diff changeset
1191 static gboolean collection_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
9
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 CollectWindow *cw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 collection_window_close(cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 CollectWindow *collection_window_new(const gchar *path)
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 CollectWindow *cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 GtkWidget *frame;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 GtkWidget *status_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 GtkWidget *extra_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 GdkGeometry geometry;
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 = g_new0(CollectWindow, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 collection_window_list = g_list_append(collection_window_list, cw);
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->cd = collection_new(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 288
diff changeset
1214 cw->window = window_new(GTK_WINDOW_TOPLEVEL, "collection", PIXBUF_INLINE_ICON_BOOK, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215
1029
1a4b18c58556 Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents: 1022
diff changeset
1216 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
1a4b18c58556 Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents: 1022
diff changeset
1217 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 geometry.base_width = COLLECT_DEF_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 geometry.base_height = COLLECT_DEF_HEIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 gtk_window_set_geometry_hints(GTK_WINDOW(cw->window), NULL, &geometry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223
1436
d7a6fb7a90dd completely separated global and layout window options
nadvornik
parents: 1432
diff changeset
1224 if (options->save_window_positions && path && collection_load_only_geometry(cw->cd, path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 /* FIXME: x, y is not implemented */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 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
1228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 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
1232 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 gtk_window_set_resizable(GTK_WINDOW(cw->window), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 collection_window_update_title(cw);
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
1236 gtk_container_set_border_width(GTK_CONTAINER(cw->window), 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 g_signal_connect(G_OBJECT(cw->window), "delete_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 G_CALLBACK(collection_window_delete), cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
1241 g_signal_connect(G_OBJECT(cw->window), "key_press_event",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 G_CALLBACK(collection_window_keypress), cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 gtk_container_add(GTK_CONTAINER(cw->window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 cw->table = collection_table_new(cw->cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 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
1250 gtk_widget_show(cw->table->scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 cw->status_box = gtk_hbox_new(TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 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
1254 gtk_widget_show(cw->status_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 frame = gtk_frame_new(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 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
1259 gtk_widget_show(frame);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 status_label = gtk_label_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 gtk_container_add(GTK_CONTAINER(frame), status_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 gtk_widget_show(status_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 extra_label = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(extra_label), 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 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
1268 gtk_widget_show(extra_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 collection_table_set_labels(cw->table, status_label, extra_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 gtk_widget_show(cw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 gtk_widget_grab_focus(cw->table->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 collection_set_update_info_func(cw->cd, collection_window_update_info, cw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276
726
a1dcef8cd1ae Use G_DIR_SEPARATOR where applicable.
zas_
parents: 673
diff changeset
1277 if (path && *path == G_DIR_SEPARATOR) collection_load_begin(cw->cd, NULL, COLLECTION_LOAD_NONE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 return cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1029
diff changeset
1281 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */