annotate src/collect-dlg.c @ 1420:3a9fb1b52559

Use gboolean where applicable, for the sake of consistency.
author zas_
date Thu, 12 Mar 2009 21:06:37 +0000
parents 8b89e3ff286b
children
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: 9
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1199
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 "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "collect-dlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
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 "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 DIALOG_SAVE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 DIALOG_SAVE_CLOSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 DIALOG_LOAD,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 DIALOG_APPEND
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1284
diff changeset
33 static gboolean collection_save_confirmed(FileDialog *fd, gboolean overwrite, CollectionData *cd);
9
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 static void collection_confirm_ok_cb(GenericDialog *gd, gpointer data)
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 FileDialog *fd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 CollectionData *cd = GENERIC_DIALOG(fd)->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 if (!collection_save_confirmed(fd, TRUE, cd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 collection_unref(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 file_dialog_close(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 static void collection_confirm_cancel_cb(GenericDialog *gd, gpointer data)
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 /* this is a no-op, so the cancel button is added */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1284
diff changeset
53 static gboolean collection_save_confirmed(FileDialog *fd, gboolean overwrite, CollectionData *cd)
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 gchar *buf;
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 if (isdir(fd->dest_path))
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 buf = g_strdup_printf(_("Specified path:\n%s\nis a folder, collections are files"), fd->dest_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 file_util_warning_dialog(_("Invalid filename"), buf, GTK_STOCK_DIALOG_INFO, GENERIC_DIALOG(fd)->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 if (!overwrite && isfile(fd->dest_path))
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 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68
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
69 gd = file_util_gen_dlg(_("Overwrite File"), "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 GENERIC_DIALOG(fd)->dialog, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 collection_confirm_cancel_cb, fd);
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 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 _("Overwrite existing file?"), fd->dest_path);
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 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), collection_confirm_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 gtk_widget_show(gd->dialog);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 if (!collection_save(cd, fd->dest_path))
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 buf = g_strdup_printf(_("Failed to save the collection:\n%s"), fd->dest_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 file_util_warning_dialog(_("Save Failed"), buf, GTK_STOCK_DIALOG_ERROR, GENERIC_DIALOG(fd)->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 g_free(buf);
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 collection_unref(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 file_dialog_sync_history(fd, TRUE);
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 if (fd->type == DIALOG_SAVE_CLOSE) collection_window_close_by_collection(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 file_dialog_close(fd);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 static void collection_save_cb(FileDialog *fd, gpointer data)
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 CollectionData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 path = fd->dest_path;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 283
diff changeset
105
605
651ae2be1031 Use g_ascii_strncasecmp() instead of strncasecmp() where applicable.
zas_
parents: 475
diff changeset
106 /* FIXME: utf8 */
781
2d2cca2bceb0 Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents: 711
diff changeset
107 if (!file_extension_match(path, GQ_COLLECTION_EXT))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 gchar *buf;
781
2d2cca2bceb0 Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents: 711
diff changeset
110 buf = g_strconcat(path, GQ_COLLECTION_EXT, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 gtk_entry_set_text(GTK_ENTRY(fd->entry), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 g_free(buf);
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 collection_save_confirmed(fd, FALSE, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 static void real_collection_button_pressed(FileDialog *fd, gpointer data, gint append)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 CollectionData *cd = data;
1199
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
121 gboolean err = FALSE;
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
122 gchar *text = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
1199
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
124 if (!isname(fd->dest_path))
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
125 {
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
126 err = TRUE;
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
127 text = g_strdup_printf(_("No such file '%s'."), fd->dest_path);
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
128 }
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
129 if (!err && isdir(fd->dest_path))
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
130 {
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
131 err = TRUE;
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
132 text = g_strdup_printf(_("'%s' is a directory, not a collection file."), fd->dest_path);
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
133 }
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
134 if (!err && !access_file(fd->dest_path, R_OK))
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
135 {
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
136 err = TRUE;
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
137 text = g_strdup_printf(_("You do not have read permissions on the file '%s'."), fd->dest_path);
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
138 }
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
139
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
140 if (err) {
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
141 if (text)
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
142 {
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
143 file_util_warning_dialog(_("Can not open collection file"), text, GTK_STOCK_DIALOG_ERROR, NULL);
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
144 g_free(text);
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
145 }
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
146 return;
404168a124aa Display error dialog with appropriate message when user is trying to open an invalid collection file.
zas_
parents: 1174
diff changeset
147 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 if (append)
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 collection_load(cd, fd->dest_path, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 collection_unref(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 collection_window_new(fd->dest_path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 file_dialog_sync_history(fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 file_dialog_close(fd);
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 collection_load_cb(FileDialog *fd, 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 real_collection_button_pressed(fd, data, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 static void collection_append_cb(FileDialog *fd, gpointer data)
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 real_collection_button_pressed(fd, data, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 static void collection_save_or_load_dialog_close_cb(FileDialog *fd, gpointer data)
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 CollectionData *cd = data;
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 if (cd) collection_unref(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 file_dialog_close(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 static void collection_save_or_load_dialog(const gchar *path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 gint type, CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 FileDialog *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 GtkWidget *parent = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 CollectWindow *cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 const gchar *btntext;
1002
3096a47232ec Use gpointer instead of void *.
zas_
parents: 781
diff changeset
189 gpointer btnfunc;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 const gchar *stock_id;
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 if (type == DIALOG_SAVE || type == DIALOG_SAVE_CLOSE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 title = _("Save collection");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 btntext = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 btnfunc = collection_save_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 stock_id = GTK_STOCK_SAVE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 else if (type == DIALOG_LOAD)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 title = _("Open collection");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 btntext = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 btnfunc = collection_load_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 stock_id = GTK_STOCK_OPEN;
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 if (!cd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 title = _("Append collection");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 btntext = _("_Append");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 btnfunc = collection_append_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 stock_id = GTK_STOCK_ADD;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 if (cd) collection_ref(cd);
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 cw = collection_window_find(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 if (cw) parent = cw->window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
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
221 fd = file_util_file_dlg(title, "dlg_collection", parent,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 collection_save_or_load_dialog_close_cb, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, title, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 file_dialog_add_button(fd, stock_id, btntext, btnfunc, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1055
diff changeset
227 file_dialog_add_path_widgets(fd, get_collections_dir(), path,
781
2d2cca2bceb0 Replace hardcoded collection filename extension by a macro (GQ_COLLECTION_EXT).
zas_
parents: 711
diff changeset
228 "collection_load_save", GQ_COLLECTION_EXT, _("Collection Files"));
9
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 fd->type = type;
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 gtk_widget_show(GENERIC_DIALOG(fd)->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 void collection_dialog_save_as(gchar *path, CollectionData *cd)
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 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 if (!cd->list)
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 GtkWidget *parent = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 CollectWindow *cw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 cw = collection_window_find(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 if (cw) parent = cw->window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 file_util_warning_dialog(_("Collection empty"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 _("The current collection is empty, save aborted."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 GTK_STOCK_DIALOG_INFO, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 return;
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 #endif
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 if (!path) path = cd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 if (!path) path = cd->name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 collection_save_or_load_dialog(path, DIALOG_SAVE, cd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 void collection_dialog_save_close(gchar *path, CollectionData *cd)
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 if (!path) path = cd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 if (!path) path = cd->name;
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 collection_save_or_load_dialog(path, DIALOG_SAVE_CLOSE, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 void collection_dialog_load(gchar *path)
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 collection_save_or_load_dialog(path, DIALOG_LOAD, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 void collection_dialog_append(gchar *path, CollectionData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 collection_save_or_load_dialog(path, DIALOG_APPEND, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1002
diff changeset
275 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */