annotate src/bar_sort.c @ 1452:67b40740122e

gint -> gboolean where applicable.
author zas_
date Mon, 16 Mar 2009 19:11:39 +0000
parents 1817f5178db3
children e015b6573d36
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
67
f63ecca6c087 Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents: 41
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: 254
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "bar_sort.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.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "collect-io.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 576
diff changeset
19 #include "filedata.h"
902
c414002a1f27 Move history_list_*() functions to separate files:
zas_
parents: 783
diff changeset
20 #include "history_list.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "utilops.h"
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
24 #include "editors.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "ui_misc.h"
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
29 #include "rcfile.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 * sort bar
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 BAR_SORT_MODE_FOLDER = 0,
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
40 BAR_SORT_MODE_COLLECTION,
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
41 BAR_SORT_MODE_COUNT
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 } SortModeType;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 typedef enum {
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
45 BAR_SORT_COPY = 0,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 BAR_SORT_MOVE,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
47 BAR_SORT_FILTER,
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
48 BAR_SORT_ACTION_COUNT
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 } SortActionType;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 typedef enum {
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
52 BAR_SORT_SELECTION_IMAGE = 0,
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
53 BAR_SORT_SELECTION_SELECTED,
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
54 BAR_SORT_SELECTION_COUNT
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 } SortSelectionType;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 typedef struct _SortData SortData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 struct _SortData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 GtkWidget *bookmarks;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 LayoutWindow *lw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 FileDialog *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 GtkWidget *dialog_name_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 SortModeType mode;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 SortActionType action;
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
69 gchar *filter_key;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
70
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 SortSelectionType selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 GtkWidget *folder_group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 GtkWidget *collection_group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 GtkWidget *add_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 GtkWidget *undo_button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 SortActionType undo_action;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 GList *undo_src_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 gchar *undo_src;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 gchar *undo_dest;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 #define SORT_KEY_FOLDERS "sort_manager"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 #define SORT_KEY_COLLECTIONS "sort_manager_collections"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
89 static void bar_sort_undo_set(SortData *sd, GList *src_list, FileData *src, const gchar *dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 static void bar_sort_add_close(SortData *sd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 static void bar_sort_collection_list_build(GtkWidget *bookmarks)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 781
diff changeset
95 FileData *dir_fd;
780
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 754
diff changeset
96 GList *list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 GList *work;
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 history_list_free_key(SORT_KEY_COLLECTIONS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1055
diff changeset
102 dir_fd = file_data_new_simple(get_collections_dir());
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 781
diff changeset
103 filelist_read(dir_fd, &list, NULL);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 781
diff changeset
104 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
106 list = filelist_sort_path(list);
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
111 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
114 fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
781
2d2cca2bceb0 Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents: 780
diff changeset
117 if (file_extension_match(fd->path, GQ_COLLECTION_EXT))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
119 name = remove_extension_from_path(fd->name);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
123 name = g_strdup(fd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 }
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
125 bookmark_list_add(bookmarks, name, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 g_free(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 521
diff changeset
129 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 static void bar_sort_mode_sync(SortData *sd, SortModeType mode)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 {
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
134 gboolean folder_mode;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 if (sd->mode == mode) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 sd->mode = mode;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 folder_mode = (sd->mode == BAR_SORT_MODE_FOLDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 bookmark_list_set_no_defaults(sd->bookmarks, !folder_mode);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 bookmark_list_set_editable(sd->bookmarks, folder_mode);
521
57007e49d767 Do not allow to add anything but directories to sort bar in
zas_
parents: 512
diff changeset
143 bookmark_list_set_only_directories(sd->bookmarks, folder_mode);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 if (folder_mode)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 gtk_widget_hide(sd->collection_group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 gtk_widget_show(sd->folder_group);
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 491
diff changeset
149 bookmark_list_set_key(sd->bookmarks, SORT_KEY_FOLDERS);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 gtk_widget_hide(sd->folder_group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 gtk_widget_show(sd->collection_group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 bar_sort_collection_list_build(sd->bookmarks);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 bar_sort_add_close(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 bar_sort_undo_set(sd, NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 }
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 static void bar_sort_mode_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == BAR_SORT_MODE_FOLDER)
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 bar_sort_mode_sync(sd, BAR_SORT_MODE_FOLDER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 bar_sort_mode_sync(sd, BAR_SORT_MODE_COLLECTION);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 /* this takes control of src_list */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
178 static void bar_sort_undo_set(SortData *sd, GList *src_list, FileData *src, const gchar *dest)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
180 string_list_free(sd->undo_src_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
181 sd->undo_src_list = filelist_to_path_list(src_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 g_free(sd->undo_src);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
184 sd->undo_src = src ? g_strdup(src->path) : NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 g_free(sd->undo_dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 sd->undo_dest = g_strdup(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 sd->undo_action = sd->action;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 if (sd->undo_button)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 gtk_widget_set_sensitive(sd->undo_button,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 ((sd->undo_src_list || sd->undo_src) && sd->undo_dest) );
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 static void bar_sort_undo_folder(SortData *sd, GtkWidget *button)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 if (!sd->undo_src || !sd->undo_dest) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 switch (sd->undo_action)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 case BAR_SORT_MOVE:
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 gchar *src_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
208 list = g_list_append(NULL, file_data_new_simple(sd->undo_dest));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 src_dir = remove_level_from_path(sd->undo_src);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
210 file_util_move_simple(list, src_dir, sd->lw->window);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 g_free(src_dir);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 case BAR_SORT_COPY:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
215 file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 break;
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 902
diff changeset
217 default:
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
218 /* undo external command */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
219 file_util_delete(file_data_new_simple(sd->undo_dest), NULL, button);
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
220 break;
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 layout_refresh(sd->lw);
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 if (isfile(sd->undo_src))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
227 layout_image_set_fd(sd->lw, file_data_new_simple(sd->undo_src));
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 bar_sort_undo_set(sd, NULL, NULL, NULL);
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 static void bar_sort_undo_collection(SortData *sd)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 work = sd->undo_src_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 gchar *source;
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 source = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 work = work->next;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
244 collect_manager_remove(file_data_new_simple(source), sd->undo_dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 bar_sort_undo_set(sd, NULL, NULL, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 static void bar_sort_undo_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 SortData *sd = data;
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 if (sd->mode == BAR_SORT_MODE_FOLDER)
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 bar_sort_undo_folder(sd, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 else
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 bar_sort_undo_collection(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
264 static void bar_sort_bookmark_select_folder(SortData *sd, FileData *source, const gchar *path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 gchar *dest_path;
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 if (!isdir(path)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
702
e07895754e65 Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents: 700
diff changeset
271 dest_path = g_build_filename(path, source->name, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 bar_sort_undo_set(sd, NULL, source, dest_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
274 list = g_list_append(NULL, file_data_ref(source));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 switch (sd->action)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 case BAR_SORT_COPY:
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
279 file_util_copy_simple(list, path, sd->lw->window);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 layout_image_next(sd->lw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 case BAR_SORT_MOVE:
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
284 file_util_move_simple(list, path, sd->lw->window);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 break;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
287 case BAR_SORT_FILTER:
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
288 file_util_start_filter_from_filelist(sd->filter_key, list, path, sd->lw->window);
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
289 list = NULL;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
290 layout_image_next(sd->lw);
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
291 break;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
292 default:
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
293 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 g_free(dest_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
300 static void bar_sort_bookmark_select_collection(SortData *sd, FileData *source, const gchar *path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 GList *list = NULL;
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 switch (sd->selection)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 case BAR_SORT_SELECTION_IMAGE:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
307 list = g_list_append(NULL, file_data_ref(source));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 case BAR_SORT_SELECTION_SELECTED:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 list = layout_selection_list(sd->lw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 break;
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
312 default:
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
313 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 if (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 bar_sort_undo_set(sd, NULL, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 }
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 bar_sort_undo_set(sd, list, NULL, path);
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 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
326 FileData *image_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
328 image_fd = list->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 list = list->next;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
330 collect_manager_add(image_fd, path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 }
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 static void bar_sort_bookmark_select(const gchar *path, gpointer data)
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 SortData *sd = data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
337 FileData *source;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 67
diff changeset
339 source = layout_image_get_fd(sd->lw);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 if (!path || !source) return;
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 if (sd->mode == BAR_SORT_MODE_FOLDER)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 bar_sort_bookmark_select_folder(sd, source, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 else
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 bar_sort_bookmark_select_collection(sd, source, path);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
352 static void bar_sort_set_action(SortData *sd, SortActionType action, const gchar *filter_key)
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
353 {
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
354 sd->action = action;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
355 if (action == BAR_SORT_FILTER)
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
356 {
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
357 if (!filter_key) filter_key = "";
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
358 sd->filter_key = g_strdup(filter_key);
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
359 }
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
360 else
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
361 {
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
362 sd->filter_key = NULL;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
363 }
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
364 }
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
365
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 static void bar_sort_set_copy_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
370 bar_sort_set_action(sd, BAR_SORT_COPY, NULL);
9
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 static void bar_sort_set_move_cb(GtkWidget *button, gpointer data)
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 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
377 bar_sort_set_action(sd, BAR_SORT_MOVE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
380 static void bar_sort_set_filter_cb(GtkWidget *button, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 SortData *sd = data;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
383 const gchar *key;
754
7dbdd80610a3 bar_sort_set_filter_cb(): filter_idx was set as uint so get it as uint.
zas_
parents: 753
diff changeset
384
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
386 key = g_object_get_data(G_OBJECT(button), "filter_key");
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
387 bar_sort_set_action(sd, BAR_SORT_FILTER, key);
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
388 }
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
389
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
390 static void bar_sort_set_selection(SortData *sd, SortSelectionType selection)
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
391 {
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
392 sd->selection = selection;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 static void bar_sort_set_selection_image_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return;
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
399 bar_sort_set_selection(sd, BAR_SORT_SELECTION_IMAGE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 }
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 static void bar_sort_set_selection_selected_cb(GtkWidget *button, gpointer data)
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 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) return;
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
406 bar_sort_set_selection(sd, BAR_SORT_SELECTION_SELECTED);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 static void bar_sort_add_close(SortData *sd)
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 if (sd->dialog) file_dialog_close(sd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 sd->dialog_name_entry = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 sd->dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 static void bar_sort_add_ok_cb(FileDialog *fd, gpointer data)
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 SortData *sd = data;
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
419 const gchar *name = gtk_entry_get_text(GTK_ENTRY(sd->dialog_name_entry));
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
420 gboolean empty_name = (name[0] == '\0');
9
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 name = gtk_entry_get_text(GTK_ENTRY(sd->dialog_name_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 if (sd->mode == BAR_SORT_MODE_FOLDER)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 {
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
425 if (empty_name)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 name = filename_from_path(fd->dest_path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 bookmark_list_add(sd->bookmarks, name, fd->dest_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 else
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 gchar *path;
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
435 gboolean has_extension;
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
436 gchar *filename = (gchar *) name;
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
437
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
438 if (empty_name) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
440 has_extension = file_extension_match(name, GQ_COLLECTION_EXT);
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
441 if (!has_extension)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 {
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
443 filename = g_strconcat(name, GQ_COLLECTION_EXT, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
446 path = g_build_filename(get_collections_dir(), filename, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 if (isfile(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 {
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
449 gchar *text = g_strdup_printf(_("The collection:\n%s\nalready exists."), filename);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 file_util_warning_dialog(_("Collection exists"), text, GTK_STOCK_DIALOG_INFO, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 CollectionData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 cd = collection_new(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 if (collection_save(cd, path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 bar_sort_collection_list_build(sd->bookmarks);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 gchar *text = g_strdup_printf(_("Failed to save the collection:\n%s"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 file_util_warning_dialog(_("Save Failed"), text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 GTK_STOCK_DIALOG_ERROR, GENERIC_DIALOG(fd)->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 collection_unref(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
472 if (!has_extension) g_free(filename);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 bar_sort_add_close(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 static void bar_sort_add_cancel_cb(FileDialog *fd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 SortData *sd = data;
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 bar_sort_add_close(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 }
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 static void bar_sort_add_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 if (sd->dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 gtk_window_present(GTK_WINDOW(GENERIC_DIALOG(sd->dialog)->dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 if (sd->mode == BAR_SORT_MODE_FOLDER)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 title = _("Add Bookmark");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 title = _("Add Collection");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 sd->dialog = file_util_file_dlg(title,
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: 1145
diff changeset
508 "add_bookmark", button,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 bar_sort_add_cancel_cb, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 file_dialog_add_button(sd->dialog, GTK_STOCK_OK, NULL, bar_sort_add_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 generic_dialog_add_message(GENERIC_DIALOG(sd->dialog), NULL, title, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 if (sd->mode == BAR_SORT_MODE_FOLDER)
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 file_dialog_add_path_widgets(sd->dialog, NULL, NULL, "add_bookmark", NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 hbox = pref_box_new(GENERIC_DIALOG(sd->dialog)->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 pref_label_new(hbox, _("Name:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 sd->dialog_name_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 gtk_box_pack_start(GTK_BOX(hbox), sd->dialog_name_entry, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 generic_dialog_attach_default(GENERIC_DIALOG(sd->dialog), sd->dialog_name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 gtk_widget_show(sd->dialog_name_entry);
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 if (sd->mode == BAR_SORT_MODE_COLLECTION)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 gtk_widget_grab_focus(sd->dialog_name_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 gtk_widget_show(GENERIC_DIALOG(sd->dialog)->dialog);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 void bar_sort_close(GtkWidget *bar)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 SortData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 sd = g_object_get_data(G_OBJECT(bar), "bar_sort_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 if (!sd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 gtk_widget_destroy(sd->vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 }
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 static void bar_sort_destroy(GtkWidget *widget, gpointer data)
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 SortData *sd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 bar_sort_add_close(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
552 g_free(sd->filter_key);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 g_free(sd->undo_src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 g_free(sd->undo_dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 g_free(sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
558 static void bar_sort_edit_button_free(gpointer data)
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
559 {
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
560 g_free(data);
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
561 }
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
562
1418
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
563 static GtkWidget *bar_sort_new(LayoutWindow *lw, SortActionType action,
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
564 SortModeType mode, SortSelectionType selection,
1817f5178db3 Fix bug when adding a new collection through sort manager. Tidy up.
zas_
parents: 1413
diff changeset
565 const gchar *filter_key)
9
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 SortData *sd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 GtkWidget *buttongrp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 GtkWidget *tbar;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 GtkWidget *combo;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
572 GList *editors_list, *work;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
573 gboolean have_filter;
9
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 (!lw) return NULL;
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 sd = g_new0(SortData, 1);
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 sd->lw = lw;
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
580
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
581 sd->action = action;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
582
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
583 if (sd->action == BAR_SORT_FILTER && (!filter_key || !filter_key[0]))
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
584 {
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
585 sd->action = BAR_SORT_COPY;
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
586 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
587
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
588 sd->selection = selection;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 sd->undo_src = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 sd->undo_dest = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 sd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 g_object_set_data(G_OBJECT(sd->vbox), "bar_sort_data", sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 g_signal_connect(G_OBJECT(sd->vbox), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 G_CALLBACK(bar_sort_destroy), sd);
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 label = gtk_label_new(_("Sort Manager"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 gtk_box_pack_start(GTK_BOX(sd->vbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 combo = gtk_combo_box_new_text();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 gtk_box_pack_start(GTK_BOX(sd->vbox), combo, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Folders"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Collections"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 g_signal_connect(G_OBJECT(combo), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 G_CALLBACK(bar_sort_mode_cb), sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 sd->folder_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
614 buttongrp = pref_radiobutton_new(sd->folder_group, NULL,
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
615 _("Copy"), (sd->action == BAR_SORT_COPY),
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
616 G_CALLBACK(bar_sort_set_copy_cb), sd);
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
617 pref_radiobutton_new(sd->folder_group, buttongrp,
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
618 _("Move"), (sd->action == BAR_SORT_MOVE),
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
619 G_CALLBACK(bar_sort_set_move_cb), sd);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
620
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
621
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
622 have_filter = FALSE;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
623 editors_list = editor_list_get();
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
624 work = editors_list;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
625 while (work)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
626 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
627 GtkWidget *button;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
628 EditorDescription *editor = work->data;
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
629 gchar *key;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
630 gboolean select = FALSE;
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
631
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
632 work = work->next;
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
633
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
634 if (!editor_is_filter(editor->key)) continue;
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
635
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
636 key = g_strdup(editor->key);
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
637 if (sd->action == BAR_SORT_FILTER && strcmp(key, filter_key) == 0)
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
638 {
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
639 bar_sort_set_action(sd, sd->action, key);
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
640 select = TRUE;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
641 have_filter = TRUE;
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
642 }
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
643
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
644 button = pref_radiobutton_new(sd->folder_group, buttongrp,
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
645 editor->name, select,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
646 G_CALLBACK(bar_sort_set_filter_cb), sd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
647
1413
3bc4967aaa57 Use dynamic allocation for editor key passed to various callbacks.
zas_
parents: 1320
diff changeset
648 g_object_set_data_full(G_OBJECT(button), "filter_key", key, bar_sort_edit_button_free);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 702
diff changeset
649 }
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
650 g_list_free(editors_list);
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
651
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1174
diff changeset
652 if (sd->action == BAR_SORT_FILTER && !have_filter) sd->action = BAR_SORT_COPY;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 sd->collection_group = pref_box_new(sd->vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
656 buttongrp = pref_radiobutton_new(sd->collection_group, NULL,
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
657 _("Add image"), (sd->selection == BAR_SORT_SELECTION_IMAGE),
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
658 G_CALLBACK(bar_sort_set_selection_image_cb), sd);
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
659 pref_radiobutton_new(sd->collection_group, buttongrp,
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
660 _("Add selection"), (sd->selection == BAR_SORT_SELECTION_SELECTED),
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
661 G_CALLBACK(bar_sort_set_selection_selected_cb), sd);
9
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 sd->bookmarks = bookmark_list_new(SORT_KEY_FOLDERS, bar_sort_bookmark_select, sd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 gtk_box_pack_start(GTK_BOX(sd->vbox), sd->bookmarks, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 gtk_widget_show(sd->bookmarks);
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 tbar = pref_toolbar_new(sd->vbox, GTK_TOOLBAR_ICONS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
669 sd->add_button = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 _("Add Bookmark"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 G_CALLBACK(bar_sort_add_cb), sd);
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
672 sd->undo_button = pref_toolbar_button(tbar, GTK_STOCK_UNDO, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 _("Undo last image"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 G_CALLBACK(bar_sort_undo_cb), sd);
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 sd->mode = -1;
491
4a9570cd06f8 Save sort manager state to rc file.
zas_
parents: 475
diff changeset
677 bar_sort_mode_sync(sd, mode);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), sd->mode);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 283
diff changeset
679
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 return sd->vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 }
1320
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
682
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
683 GtkWidget *bar_sort_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
684 {
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
685 GtkWidget *bar;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
686
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
687 gboolean enabled = TRUE;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
688 gint action = 0;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
689 gint mode = 0;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
690 gint selection = 0;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
691 gchar *filter_key = NULL;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
692
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
693 while (attribute_names && *attribute_names)
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
694 {
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
695 const gchar *option = *attribute_names++;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
696 const gchar *value = *attribute_values++;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
697
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
698 if (READ_BOOL_FULL("enabled", enabled)) continue;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
699 if (READ_INT_CLAMP_FULL("action", action, 0, BAR_SORT_ACTION_COUNT - 1)) continue;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
700 if (READ_INT_CLAMP_FULL("mode", mode, 0, BAR_SORT_MODE_COUNT - 1)) continue;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
701 if (READ_INT_CLAMP_FULL("selection", selection, 0, BAR_SORT_SELECTION_COUNT - 1)) continue;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
702 if (READ_CHAR_FULL("filter_key", filter_key)) continue;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
703
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
704 DEBUG_1("unknown attribute %s = %s", option, value);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
705 }
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
706 bar = bar_sort_new(lw, action, mode, selection, filter_key);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
707
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
708 g_free(filter_key);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
709 if (enabled) gtk_widget_show(bar);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
710 return bar;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
711 }
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
712
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
713 GtkWidget *bar_sort_new_default(LayoutWindow *lw)
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
714 {
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
715 return bar_sort_new_from_config(lw, NULL, NULL);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
716 }
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
717
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
718 void bar_sort_write_config(GtkWidget *bar, GString *outstr, gint indent)
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
719 {
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
720 SortData *sd;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
721
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
722 if (!bar) return;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
723 sd = g_object_get_data(G_OBJECT(bar), "bar_sort_data");
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
724 if (!sd) return;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
725
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
726 WRITE_STRING("<bar_sort\n");
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
727 indent++;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
728 write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
729 WRITE_INT(*sd, mode);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
730 WRITE_INT(*sd, action);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
731 WRITE_INT(*sd, selection);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
732 WRITE_CHAR(*sd, filter_key);
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
733 indent--;
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
734 WRITE_STRING("/>\n");
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
735 }
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
736
055ed09d5a03 improved bar_sort configuration
nadvornik
parents: 1309
diff changeset
737
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 995
diff changeset
738 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */