From 8defbe3b01dc847e77944a68756c0292520d8cec Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Fri, 16 Aug 2024 19:21:00 +0000 Subject: Deploy mate-desktop/engrampa to github.com/mate-desktop/engrampa.git:gh-pages --- .../index.html | 132 + .../report-198a90.html | 1870 ++++ .../report-22051c.html | 9656 +++++++++++++++++++ .../report-281643.html | 1776 ++++ .../report-41f5bf.html | 1083 +++ .../report-4a22f4.html | 9657 ++++++++++++++++++++ .../report-4de11e.html | 1225 +++ .../report-5b979e.html | 1267 +++ .../report-8954c3.html | 1121 +++ .../report-b8f564.html | 2089 +++++ .../report-ceaaa0.html | 1264 +++ .../report-cf3974.html | 2089 +++++ .../scanview.css | 62 + .../sorttable.js | 492 + 14 files changed, 33783 insertions(+) create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/index.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-198a90.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-22051c.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-281643.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-41f5bf.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4a22f4.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4de11e.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-5b979e.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-8954c3.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-b8f564.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-ceaaa0.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-cf3974.html create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/scanview.css create mode 100644 2024-08-16-185447-5355-1@4e0906a4dd0d_master/sorttable.js (limited to '2024-08-16-185447-5355-1@4e0906a4dd0d_master') diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/index.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/index.html new file mode 100644 index 0000000..3c465b9 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/index.html @@ -0,0 +1,132 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@9079afcb1130
Working Directory:/rootdir
Command Line:make -j 3
Clang Version:clang version 18.1.6 (Fedora 18.1.6-3.fc40) +
Date:Fri Aug 16 18:54:47 2024
+

Bug Summary

+ + + + + + + + + + + + +
Bug TypeQuantityDisplay?
All Bugs11
API
Argument with 'nonnull' attribute passed null2
Logic error
Cast from non-struct type to struct type2
Dereference of null pointer2
Out-of-bound access2
Result of operation is garbage or undefined1
Unused code
Dead assignment1
Dead nested assignment1
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
APIArgument with 'nonnull' attribute passed nullsrc/fr-window.crename_selection737726View Report
APIArgument with 'nonnull' attribute passed nullsrc/fr-window.crename_selection737726View Report
Logic errorCast from non-struct type to struct typemate-submodules/libegg/eggsmclient-xsmp.carray_prop11991View Report
Logic errorCast from non-struct type to struct typemate-submodules/libegg/eggsmclient-xsmp.cptrarray_prop12321View Report
Unused codeDead assignmentsrc/fr-process.cfr_close_suspend_process10061View Report
Unused codeDead nested assignmentsrc/java-utils.cget_package_name_from_class_file2541View Report
Logic errorDereference of null pointersrc/file-utils.censure_dir_exists48319View Report
Logic errorDereference of null pointersrc/dlg-update.cupdate_file_list1498View Report
Logic errorOut-of-bound accesssrc/glib-utils.csearch_util_get_regexps3515View Report
Logic errorOut-of-bound accesssrc/glib-utils.cg_utf8_strsplit22121View Report
Logic errorResult of operation is garbage or undefinedsrc/glib-utils.csearch_util_get_patterns32423View Report
+ + diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-198a90.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-198a90.html new file mode 100644 index 0000000..fce1bfe --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-198a90.html @@ -0,0 +1,1870 @@ + + + +file-utils.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/file-utils.c
Warning:line 483, column 52
Access to field 'message' results in a dereference of a null pointer
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name file-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c file-utils.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2001, 2003 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#define _XOPEN_SOURCE700 700
24
25#include <config.h>
26#include <pwd.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <strings.h>
31#include <ctype.h>
32#include <time.h>
33#include <unistd.h>
34#include <strings.h>
35#include <sys/param.h>
36#include <sys/stat.h>
37#include <sys/time.h>
38#include <sys/types.h>
39#include <dirent.h>
40
41#include <glib.h>
42#include <gio/gio.h>
43#include "file-utils.h"
44#include "glib-utils.h"
45#include "fr-init.h"
46
47#define SPECIAL_DIR(x)((strcmp ((x), "..") == 0) || (strcmp ((x), ".") == 0)) ((strcmp ((x), "..") == 0) || (strcmp ((x), ".") == 0))
48
49gboolean
50uri_exists (const char *uri)
51{
52 GFile *file;
53 gboolean exists;
54
55 if (uri == NULL((void*)0))
56 return FALSE(0);
57
58 file = g_file_new_for_uri (uri);
59 exists = g_file_query_exists (file, NULL((void*)0));
60 g_object_unref (file);
61
62 return exists;
63}
64
65static gboolean
66uri_is_filetype (const char *uri,
67 GFileType file_type)
68{
69 gboolean result = FALSE(0);
70 GFile *file;
71 GFileInfo *info;
72 GError *error = NULL((void*)0);
73
74 file = g_file_new_for_uri (uri);
75
76 if (! g_file_query_exists (file, NULL((void*)0))) {
77 g_object_unref (file);
78 return FALSE(0);
79 }
80
81 info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE"standard::type", 0, NULL((void*)0), &error);
82 if (error == NULL((void*)0)) {
83 result = (g_file_info_get_file_type (info) == file_type);
84 }
85 else {
86 g_warning ("Failed to get file type for uri %s: %s", uri, error->message);
87 g_error_free (error);
88 }
89
90 g_object_unref (info);
91 g_object_unref (file);
92
93 return result;
94}
95
96gboolean
97uri_is_file (const char *uri)
98{
99 return uri_is_filetype (uri, G_FILE_TYPE_REGULAR);
100}
101
102gboolean
103uri_is_dir (const char *uri)
104{
105 return uri_is_filetype (uri, G_FILE_TYPE_DIRECTORY);
106}
107
108gboolean
109path_is_dir (const char *path)
110{
111 char *uri;
112 gboolean result;
113
114 uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
115 result = uri_is_dir (uri);
116 g_free (uri);
117
118 return result;
119}
120
121gboolean
122uri_is_local (const char *uri)
123{
124 return strncmp (uri, "file://", 7) == 0;
125}
126
127char *
128get_dir_content_if_unique (const char *uri)
129{
130 GFile *file;
131 GFileEnumerator *file_enum;
132 GFileInfo *info;
133 GError *err = NULL((void*)0);
134 char *content_uri = NULL((void*)0);
135
136 file = g_file_new_for_uri (uri);
137
138 if (! g_file_query_exists (file, NULL((void*)0))) {
139 g_object_unref (file);
140 return NULL((void*)0);
141 }
142
143 file_enum = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME"standard::name", 0, NULL((void*)0), &err);
144 if (err != NULL((void*)0)) {
145 g_warning ("Failed to enumerate children of %s: %s", uri, err->message);
146 g_error_free (err);
147 return NULL((void*)0);
148 }
149
150 while ((info = g_file_enumerator_next_file (file_enum, NULL((void*)0), &err)) != NULL((void*)0)) {
151 const char *name;
152 char *new_name;
153
154 if (err != NULL((void*)0)) {
155 g_warning ("Failed to get info while enumerating children: %s", err->message);
156 g_clear_error (&err);
157 g_object_unref (info);
158 continue;
159 }
160
161 name = g_file_info_get_name (info);
162 if ((strcmp (name, ".") == 0) || (strcmp (name, "..") == 0)) {
163 g_object_unref (info);
164 continue;
165 }
166
167 if (content_uri != NULL((void*)0)) {
168 g_free (content_uri);
169 g_object_unref (info);
170 content_uri = NULL((void*)0);
171 break;
172 }
173
174 new_name = g_uri_escape_string (name, NULL((void*)0), TRUE(!(0)));
175 content_uri = build_uri (uri, new_name, NULL((void*)0));
176 g_object_unref (info);
177 g_free (new_name);
178 }
179
180 if (err != NULL((void*)0)) {
181 g_warning ("Failed to get info after enumerating children: %s", err->message);
182 g_clear_error (&err);
183 }
184
185 g_object_unref (file_enum);
186 g_object_unref (file);
187
188 return content_uri;
189}
190
191/* Check whether the dirname is contained in filename */
192gboolean
193path_in_path (const char *dirname,
194 const char *filename)
195{
196 int dirname_l, filename_l, separator_position;
197
198 if ((dirname == NULL((void*)0)) || (filename == NULL((void*)0)))
199 return FALSE(0);
200
201 dirname_l = strlen (dirname);
202 filename_l = strlen (filename);
203
204 if ((dirname_l == filename_l + 1)
205 && (dirname[dirname_l - 1] == '/'))
206 return FALSE(0);
207
208 if ((filename_l == dirname_l + 1)
209 && (filename[filename_l - 1] == '/'))
210 return FALSE(0);
211
212 if (dirname[dirname_l - 1] == '/')
213 separator_position = dirname_l - 1;
214 else
215 separator_position = dirname_l;
216
217 return ((filename_l > dirname_l)
218 && (strncmp (dirname, filename, dirname_l) == 0)
219 && (filename[separator_position] == '/'));
220}
221
222goffset
223get_file_size (const char *uri)
224{
225 goffset size = 0;
226 GFile *file;
227 GFileInfo *info;
228 GError *err = NULL((void*)0);
229
230 if ((uri == NULL((void*)0)) || (*uri == '\0'))
231 return 0;
232
233 file = g_file_new_for_uri (uri);
234 info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE"standard::size", 0, NULL((void*)0), &err);
235 if (err == NULL((void*)0)) {
236 size = g_file_info_get_size (info);
237 }
238 else {
239 g_warning ("Failed to get file size for %s: %s", uri, err->message);
240 g_error_free (err);
241 }
242
243 g_object_unref (info);
244 g_object_unref (file);
245
246 return size;
247}
248
249goffset
250get_file_size_for_path (const char *path)
251{
252 char *uri;
253 goffset result;
254
255 uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
256 result = get_file_size (uri);
257 g_free (uri);
258
259 return result;
260}
261
262static time_t
263get_file_time_type (const char *uri,
264 const char *type)
265{
266 time_t result = 0;
267 GFile *file;
268 GFileInfo *info;
269 GError *err = NULL((void*)0);
270
271 if ((uri == NULL((void*)0)) || (*uri == '\0'))
272 return 0;
273
274 file = g_file_new_for_uri (uri);
275 info = g_file_query_info (file, type, 0, NULL((void*)0), &err);
276 if (err == NULL((void*)0)) {
277 result = (time_t) g_file_info_get_attribute_uint64 (info, type);
278 }
279 else {
280 g_warning ("Failed to get %s: %s", type, err->message);
281 g_error_free (err);
282 result = 0;
283 }
284
285 g_object_unref (info);
286 g_object_unref (file);
287
288 return result;
289}
290
291time_t
292get_file_mtime (const char *uri)
293{
294 return get_file_time_type (uri, G_FILE_ATTRIBUTE_TIME_MODIFIED"time::modified");
295}
296
297time_t
298get_file_mtime_for_path (const char *path)
299{
300 char *uri;
301 time_t result;
302
303 uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
304 result = get_file_mtime (uri);
305 g_free (uri);
306
307 return result;
308}
309
310/* like g_path_get_basename but does not warn about NULL and does not
311 * alloc a new string. */
312const gchar* file_name_from_path(const gchar *file_name)
313{
314 register char *base;
315 register gssize last_char;
316
317 if (file_name == NULL((void*)0))
318 return NULL((void*)0);
319
320 if ((file_name[0] == '\0') || (strlen (file_name) == 0))
321 return "";
322
323 last_char = strlen (file_name) - 1;
324
325 if (file_name [last_char] == G_DIR_SEPARATOR'/')
326 return "";
327
328 base = g_utf8_strrchr (file_name, -1, G_DIR_SEPARATOR'/');
329 if (! base)
330 return file_name;
331
332 return base + 1;
333}
334
335char *
336dir_name_from_path (const gchar *path)
337{
338 register gssize base;
339 register gssize last_char;
340
341 if (path == NULL((void*)0))
342 return NULL((void*)0);
343
344 if (path[0] == '\0')
345 return g_strdup ("")g_strdup_inline ("");
346
347 last_char = strlen (path) - 1;
348 if (path[last_char] == G_DIR_SEPARATOR'/')
349 last_char--;
350
351 base = last_char;
352 while ((base >= 0) && (path[base] != G_DIR_SEPARATOR'/'))
353 base--;
354
355 return g_strndup (path + base + 1, last_char - base);
356}
357
358gchar *
359remove_level_from_path (const gchar *path)
360{
361 int p;
362 const char *ptr = path;
363 char *new_path;
364
365 if (path == NULL((void*)0))
366 return NULL((void*)0);
367
368 p = strlen (path) - 1;
369 if (p < 0)
370 return NULL((void*)0);
371
372 while ((p > 0) && (ptr[p] != '/'))
373 p--;
374 if ((p == 0) && (ptr[p] == '/'))
375 p++;
376 new_path = g_strndup (path, (guint)p);
377
378 return new_path;
379}
380
381char *
382remove_ending_separator (const char *path)
383{
384 gint len, copy_len;
385
386 if (path == NULL((void*)0))
387 return NULL((void*)0);
388
389 copy_len = len = strlen (path);
390 if ((len > 1) && (path[len - 1] == '/'))
391 copy_len--;
392
393 return g_strndup (path, copy_len);
394}
395
396char *
397build_uri (const char *base, ...)
398{
399 va_list args;
400 const char *child;
401 GString *uri;
402
403 uri = g_string_new (base);
404
405 va_start (args, base)__builtin_va_start(args, base);
406 while ((child = va_arg (args, const char *)__builtin_va_arg(args, const char *)) != NULL((void*)0)) {
407 if (! g_str_has_suffix (uri->str, "/")(__builtin_constant_p ("/")? __extension__ ({ const char * const
__str = (uri->str); const char * const __suffix = ("/"); gboolean
__result = (0); if (__str == ((void*)0) || __suffix == ((void
*)0)) __result = (g_str_has_suffix) (__str, __suffix); else {
const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __suffix_len = strlen (((__suffix) + !(__suffix))); if
(__str_len >= __suffix_len) __result = memcmp (__str + __str_len
- __suffix_len, ((__suffix) + !(__suffix)), __suffix_len) ==
0; } __result; }) : (g_str_has_suffix) (uri->str, "/") )
&& ! g_str_has_prefix (child, "/")(__builtin_constant_p ("/")? __extension__ ({ const char * const
__str = (child); const char * const __prefix = ("/"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)0)) __result = (g_str_has_prefix) (__str, __prefix); else {
const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (child, "/") )
)
408 g_string_append (uri, "/")(__builtin_constant_p ("/") ? __extension__ ({ const char * const
__val = ("/"); g_string_append_len_inline (uri, __val, (__val
!= ((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize
) -1); }) : g_string_append_len_inline (uri, "/", (gssize) -1
))
;
409 g_string_append (uri, child)(__builtin_constant_p (child) ? __extension__ ({ const char *
const __val = (child); g_string_append_len_inline (uri, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (uri, child
, (gssize) -1))
;
410 }
411 va_end (args)__builtin_va_end(args);
412
413 return g_string_free (uri, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((uri)
, ((0))) : g_string_free_and_steal (uri)) : (g_string_free) (
(uri), ((0))))
;
414}
415
416gchar *
417remove_extension_from_path (const gchar *path)
418{
419 const char *ext;
420
421 if (path == NULL((void*)0))
422 return NULL((void*)0);
423
424 ext = get_archive_filename_extension (path);
425 if (ext == NULL((void*)0) || strlen (ext) == strlen (path))
426 return g_strdup (path)g_strdup_inline (path);
427 else
428 return g_strndup (path, strlen (path) - strlen (ext));
429}
430
431gboolean
432make_directory_tree (GFile *dir,
433 mode_t mode,
434 GError **error)
435{
436 gboolean success = TRUE(!(0));
437 GFile *parent;
438
439 if ((dir == NULL((void*)0)) || g_file_query_exists (dir, NULL((void*)0)))
7
Assuming 'dir' is not equal to NULL
8
Assuming the condition is false
9
Taking false branch
440 return TRUE(!(0));
441
442 parent = g_file_get_parent (dir);
443 if (parent != NULL((void*)0)) {
10
Assuming 'parent' is equal to NULL
11
Taking false branch
444 success = make_directory_tree (parent, mode, error);
445 g_object_unref (parent);
446 if (! success)
447 return FALSE(0);
448 }
449
450 success = g_file_make_directory (dir, NULL((void*)0), error);
12
Assigning value
451 if ((error
12.1
'error' is not equal to NULL
!= NULL((void*)0)) && (*error != NULL((void*)0)) && g_error_matches (*error, G_IO_ERRORg_io_error_quark(), G_IO_ERROR_EXISTS)) {
13
Assuming pointer value is null
452 g_clear_error (error);
453 success = TRUE(!(0));
454 }
455
456 if (success)
14
Assuming 'success' is 0
15
Taking false branch
457 g_file_set_attribute_uint32 (dir,
458 G_FILE_ATTRIBUTE_UNIX_MODE"unix::mode",
459 mode,
460 0,
461 NULL((void*)0),
462 NULL((void*)0));
463
464 return success;
465}
466
467gboolean
468ensure_dir_exists (const char *uri,
469 mode_t mode,
470 GError **error)
471{
472 GFile *dir;
473 GError *priv_error = NULL((void*)0);
474
475 if (uri == NULL((void*)0))
2
Assuming 'uri' is not equal to NULL
3
Taking false branch
476 return FALSE(0);
477
478 if (error == NULL((void*)0))
4
Assuming 'error' is not equal to NULL
5
Taking false branch
479 error = &priv_error;
480
481 dir = g_file_new_for_uri (uri);
482 if (! make_directory_tree (dir, mode, error)) {
6
Calling 'make_directory_tree'
16
Returning from 'make_directory_tree'
17
Taking true branch
483 g_warning ("could create directory %s: %s", uri, (*error)->message);
18
Access to field 'message' results in a dereference of a null pointer
484 if (priv_error != NULL((void*)0))
485 g_clear_error (&priv_error);
486 return FALSE(0);
487 }
488
489 return TRUE(!(0));
490}
491
492gboolean
493make_directory_tree_from_path (const char *path,
494 mode_t mode,
495 GError **error)
496{
497 char *uri;
498 gboolean result;
499
500 uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
501 result = ensure_dir_exists (uri, mode, error);
1
Calling 'ensure_dir_exists'
502 g_free (uri);
503
504 return result;
505}
506
507const char *
508get_file_extension (const char *filename)
509{
510 const char *ptr = filename;
511 int len;
512 int p;
513 const char *ext;
514 const char *tar_exts[] = {".7z", ".br", ".bz", ".bz2", ".gz", ".lrz", ".lz", ".lzma", ".lzo", ".xz", ".Z", ".xst", NULL((void*)0)};
515
516 if (filename == NULL((void*)0))
517 return NULL((void*)0);
518
519 len = strlen (filename);
520 if (len <= 1)
521 return NULL((void*)0);
522
523 p = len - 1;
524 while ((p >= 0) && (ptr[p] != '.'))
525 p--;
526 if (p < 0)
527 return NULL((void*)0);
528
529 ext = filename + p;
530 p = 0;
531 if (ext - 4 > filename) {
532 const char *test = ext - 4;
533 if (strncmp (test, ".tar", 4) == 0) {
534 while (tar_exts[p] != NULL((void*)0)) {
535 if (strcmp (ext, tar_exts[p]) == 0)
536 ext = ext - 4;
537 p++;
538 }
539 }
540 }
541 return ext;
542}
543
544gboolean
545file_extension_is (const char *filename,
546 const char *ext)
547{
548 int filename_l, ext_l;
549
550 filename_l = strlen (filename);
551 ext_l = strlen (ext);
552
553 if (filename_l < ext_l)
554 return FALSE(0);
555 return strcasecmp (filename + filename_l - ext_l, ext) == 0;
556}
557
558gboolean
559is_mime_type (const char *mime_type,
560 const char *pattern)
561{
562 return g_content_type_equals (mime_type, pattern);
563}
564
565const char*
566get_file_mime_type (const char *uri,
567 gboolean fast_file_type)
568{
569 GFile *file;
570 GFileInfo *info;
571 GError *err = NULL((void*)0);
572 const char *result = NULL((void*)0);
573
574 file = g_file_new_for_uri (uri);
575 info = g_file_query_info (file,
576 fast_file_type ?
577 G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE"standard::fast-content-type" :
578 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
579 0, NULL((void*)0), &err);
580 if (info == NULL((void*)0)) {
581 g_warning ("could not get content type for %s: %s", uri, err->message);
582 g_clear_error (&err);
583 }
584 else {
585 result = get_static_string (g_file_info_get_content_type (info));
586 g_object_unref (info);
587 }
588
589 g_object_unref (file);
590
591 return result;
592}
593
594const char*
595get_file_mime_type_for_path (const char *filename,
596 gboolean fast_file_type)
597{
598 char *uri;
599 const char *mime_type;
600
601 uri = g_filename_to_uri (filename, NULL((void*)0), NULL((void*)0));
602 mime_type = get_file_mime_type (uri, fast_file_type);
603 g_free (uri);
604
605 return mime_type;
606}
607
608void
609path_list_free (GList *path_list)
610{
611 if (path_list == NULL((void*)0))
612 return;
613 g_list_free_full (path_list, g_free);
614}
615
616GList *
617path_list_dup (GList *path_list)
618{
619 GList *new_list = NULL((void*)0);
620 GList *scan;
621
622 for (scan = path_list; scan; scan = scan->next)
623 new_list = g_list_prepend (new_list, g_strdup (scan->data)g_strdup_inline (scan->data));
624
625 return g_list_reverse (new_list);
626}
627
628guint64
629get_dest_free_space (const char *path)
630{
631 guint64 freespace = 0;
632 GFile *file;
633 GFileInfo *info;
634 GError *err = NULL((void*)0);
635
636 file = g_file_new_for_path (path);
637 info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_FREE"filesystem::free", NULL((void*)0), &err);
638 if (info != NULL((void*)0)) {
639 freespace = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE"filesystem::free");
640 g_object_unref (info);
641 }
642 else {
643 g_warning ("Could not get filesystem free space on volume that contains %s: %s", path, err->message);
644 g_error_free (err);
645 }
646 g_object_unref (file);
647
648 return freespace;
649}
650
651static gboolean
652delete_directory_recursive (GFile *dir,
653 GError **error)
654{
655 char *uri;
656 GFileEnumerator *file_enum;
657 GFileInfo *info;
658 gboolean error_occurred = FALSE(0);
659
660 if (error != NULL((void*)0))
661 *error = NULL((void*)0);
662
663 file_enum = g_file_enumerate_children (dir,
664 G_FILE_ATTRIBUTE_STANDARD_NAME"standard::name" ","
665 G_FILE_ATTRIBUTE_STANDARD_TYPE"standard::type",
666 0, NULL((void*)0), error);
667
668 uri = g_file_get_uri (dir);
669 while (! error_occurred && (info = g_file_enumerator_next_file (file_enum, NULL((void*)0), error)) != NULL((void*)0)) {
670 char *child_uri;
671 GFile *child;
672
673 child_uri = build_uri (uri, g_file_info_get_name (info), NULL((void*)0));
674 child = g_file_new_for_uri (child_uri);
675
676 switch (g_file_info_get_file_type (info)) {
677 case G_FILE_TYPE_DIRECTORY:
678 if (! delete_directory_recursive (child, error))
679 error_occurred = TRUE(!(0));
680 break;
681 default:
682 if (! g_file_delete (child, NULL((void*)0), error))
683 error_occurred = TRUE(!(0));
684 break;
685 }
686
687 g_object_unref (child);
688 g_free (child_uri);
689 g_object_unref (info);
690 }
691 g_free (uri);
692
693 if (! error_occurred && ! g_file_delete (dir, NULL((void*)0), error))
694 error_occurred = TRUE(!(0));
695
696 g_object_unref (file_enum);
697
698 return ! error_occurred;
699}
700
701gboolean
702remove_directory (const char *uri)
703{
704 GFile *dir;
705 gboolean result;
706 GError *error = NULL((void*)0);
707
708 dir = g_file_new_for_uri (uri);
709 result = delete_directory_recursive (dir, &error);
710 if (! result) {
711 g_warning ("Cannot delete %s: %s", uri, error->message);
712 g_clear_error (&error);
713 }
714 g_object_unref (dir);
715
716 return result;
717}
718
719gboolean
720remove_local_directory (const char *path)
721{
722 char *uri;
723 gboolean result;
724
725 if (path == NULL((void*)0))
726 return TRUE(!(0));
727
728 uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
729 result = remove_directory (uri);
730 g_free (uri);
731
732 return result;
733}
734
735static const char *try_folder[] = { "cache", "~", "tmp", NULL((void*)0) };
736
737static char *
738ith_temp_folder_to_try (int n)
739{
740 const char *folder;
741
742 folder = try_folder[n];
743 if (strcmp (folder, "cache") == 0)
744 folder = g_get_user_cache_dir ();
745 else if (strcmp (folder, "~") == 0)
746 folder = g_get_home_dir ();
747 else if (strcmp (folder, "tmp") == 0)
748 folder = g_get_tmp_dir ();
749
750 return g_strdup (folder)g_strdup_inline (folder);
751}
752
753char *
754get_temp_work_dir (const char *parent_folder)
755{
756 guint64 max_size = 0;
757 char *best_folder = NULL((void*)0);
758 char *template;
759 char *result = NULL((void*)0);
760
761 if (parent_folder == NULL((void*)0)) {
762 /* find the folder with more free space. */
763 int i;
764
765 for (i = 0; try_folder[i] != NULL((void*)0); i++) {
766 char *folder;
767 guint64 size;
768
769 folder = ith_temp_folder_to_try (i);
770 size = get_dest_free_space (folder);
771 if (max_size < size) {
772 max_size = size;
773 g_free (best_folder);
774 best_folder = folder;
775 }
776 else
777 g_free (folder);
778 }
779 }
780 else
781 best_folder = g_strdup (parent_folder)g_strdup_inline (parent_folder);
782
783 if (best_folder == NULL((void*)0))
784 return NULL((void*)0);
785
786 template = g_strconcat (best_folder, "/.fr-XXXXXX", NULL((void*)0));
787 result = mkdtemp (template);
788
789 if ((result == NULL((void*)0)) || (*result == '\0')) {
790 g_free (template);
791 result = NULL((void*)0);
792 }
793
794 return result;
795}
796
797gboolean
798is_temp_work_dir (const char *dir)
799{
800 int i;
801 char *folder = NULL((void*)0);
802
803 if (strncmp (dir, "file://", 7) == 0)
804 dir = dir + 7;
805 else if (dir[0] != '/')
806 return FALSE(0);
807
808 for (i = 0; try_folder[i] != NULL((void*)0); i++) {
809 folder = ith_temp_folder_to_try (i);
810 if (strncmp (dir, folder, strlen (folder)) == 0)
811 if (strncmp (dir + strlen (folder), "/.fr-", 5) == 0) {
812 g_free (folder);
813 return TRUE(!(0));
814 }
815 g_free (folder);
816 }
817
818 return FALSE(0);
819}
820
821gboolean
822is_temp_dir (const char *dir)
823{
824 if (strncmp (dir, "file://", 7) == 0)
825 dir = dir + 7;
826 if (strcmp (g_get_tmp_dir (), dir) == 0)
827 return TRUE(!(0));
828 if (path_in_path (g_get_tmp_dir (), dir))
829 return TRUE(!(0));
830 else
831 return is_temp_work_dir (dir);
832}
833
834/* file list utils */
835
836gboolean
837file_list__match_pattern (const char *line,
838 const char *pattern)
839{
840 const char *l = line, *p = pattern;
841
842 for (; (*p != 0) && (*l != 0); p++, l++) {
843 if (*p != '%') {
844 if (*p != *l)
845 return FALSE(0);
846 }
847 else {
848 p++;
849 switch (*p) {
850 case 'a':
851 break;
852 case 'n':
853 if (!isdigit (*l)((*__ctype_b_loc ())[(int) ((*l))] & (unsigned short int)
_ISdigit)
)
854 return FALSE(0);
855 break;
856 case 'c':
857 if (!isalpha (*l)((*__ctype_b_loc ())[(int) ((*l))] & (unsigned short int)
_ISalpha)
)
858 return FALSE(0);
859 break;
860 default:
861 return FALSE(0);
862 }
863 }
864 }
865
866 return (*p == 0);
867}
868
869int
870file_list__get_index_from_pattern (const char *line,
871 const char *pattern)
872{
873 int line_l, pattern_l;
874 const char *l;
875
876 line_l = strlen (line);
877 pattern_l = strlen (pattern);
878
879 if ((pattern_l == 0) || (line_l == 0))
880 return -1;
881
882 for (l = line; *l != 0; l++)
883 if (file_list__match_pattern (l, pattern))
884 return (l - line);
885
886 return -1;
887}
888
889char*
890file_list__get_prev_field (const char *line,
891 int start_from,
892 int field_n)
893{
894 const char *f_start, *f_end;
895
896 f_start = line + start_from - 1;
897 while ((*f_start == ' ') && (*f_start != *line))
898 f_start--;
899 f_end = f_start;
900
901 while ((field_n > 0) && (*f_start != *line)) {
902 if (*f_start == ' ') {
903 field_n--;
904 if (field_n != 0) {
905 while ((*f_start == ' ') && (*f_start != *line))
906 f_start--;
907 f_end = f_start;
908 }
909 } else
910 f_start--;
911 }
912
913 return g_strndup (f_start + 1, f_end - f_start);
914}
915
916gboolean
917check_permissions (const char *uri,
918 int mode)
919{
920 GFile *file;
921 gboolean result;
922
923 file = g_file_new_for_uri (uri);
924 result = check_file_permissions (file, mode);
925
926 g_object_unref (file);
927
928 return result;
929}
930
931gboolean
932check_file_permissions (GFile *file,
933 int mode)
934{
935 gboolean result = TRUE(!(0));
936 GFileInfo *info;
937 GError *err = NULL((void*)0);
938 gboolean default_permission_when_unknown = TRUE(!(0));
939
940 info = g_file_query_info (file, "access::*", 0, NULL((void*)0), &err);
941 if (err != NULL((void*)0)) {
942 g_clear_error (&err);
943 result = FALSE(0);
944 }
945 else {
946 if ((mode & R_OK4) == R_OK4) {
947 if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ"access::can-read"))
948 result = (result && g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ"access::can-read"));
949 else
950 result = (result && default_permission_when_unknown);
951 }
952
953 if ((mode & W_OK2) == W_OK2) {
954 if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE"access::can-write"))
955 result = (result && g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE"access::can-write"));
956 else
957 result = (result && default_permission_when_unknown);
958 }
959
960 if ((mode & X_OK1) == X_OK1) {
961 if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE"access::can-execute"))
962 result = (result && g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE"access::can-execute"));
963 else
964 result = (result && default_permission_when_unknown);
965 }
966
967 g_object_unref (info);
968 }
969
970 return result;
971}
972
973gboolean
974is_program_in_path (const char *filename)
975{
976 char *str;
977 char *value;
978 int result = FALSE(0);
979
980 value = g_hash_table_lookup (ProgramsCache, filename);
981 if (value != NULL((void*)0)) {
982 result = (strcmp (value, "1") == 0);
983 return result;
984 }
985
986 str = g_find_program_in_path (filename);
987 if (str != NULL((void*)0)) {
988 g_free (str);
989 result = TRUE(!(0));
990 }
991
992 g_hash_table_insert (ProgramsCache,
993 g_strdup (filename)g_strdup_inline (filename),
994 result ? "1" : "0");
995
996 return result;
997}
998
999gboolean
1000is_program_available (const char *filename,
1001 gboolean check)
1002{
1003 return ! check || is_program_in_path (filename);
1004}
1005
1006const char *
1007get_home_uri (void)
1008{
1009 static char *home_uri = NULL((void*)0);
1010 if (home_uri == NULL((void*)0))
1011 home_uri = g_filename_to_uri (g_get_home_dir (), NULL((void*)0), NULL((void*)0));
1012 return home_uri;
1013}
1014
1015GFile *
1016get_user_config_subdirectory (const char *child_name,
1017 gboolean create_child)
1018{
1019 char *full_path;
1020 GFile *file;
1021 GError *error = NULL((void*)0);
1022
1023 full_path = g_strconcat (g_get_user_config_dir (), "/", child_name, NULL((void*)0));
1024 file = g_file_new_for_path (full_path);
1025 g_free (full_path);
1026
1027 if (create_child && ! make_directory_tree (file, 0700, &error)) {
1028 g_warning ("%s", error->message);
1029 g_error_free (error);
1030 g_object_unref (file);
1031 file = NULL((void*)0);
1032 }
1033
1034 return file;
1035}
1036
1037int
1038uricmp (const char *uri1,
1039 const char *uri2)
1040{
1041 return g_strcmp0 (uri1, uri2);
1042}
1043
1044/**
1045 * get_alternative_uri:
1046 * @folder_uri: The URI of the containing folder
1047 * @escaped_name: The URI-escaped name of the member to find a name for
1048 *
1049 * Tries to find an unused name for @escaped_name in @folder_uri.
1050 *
1051 * Returns: The full URI for the free slot (including directory)
1052 */
1053char *
1054get_alternative_uri (const char *folder_uri,
1055 const char *escaped_name)
1056{
1057 char *new_uri = NULL((void*)0);
1058 int n = 1;
1059
1060 do {
1061 g_free (new_uri);
1062 if (n == 1)
1063 new_uri = g_strconcat (folder_uri, "/", escaped_name, NULL((void*)0));
1064 else
1065 new_uri = g_strdup_printf ("%s/%s%%20(%d)", folder_uri, escaped_name, n);
1066 n++;
1067 } while (uri_exists (new_uri));
1068
1069 return new_uri;
1070}
1071
1072char *
1073get_alternative_uri_for_uri (const char *uri)
1074{
1075 char *base_uri;
1076 char *new_uri;
1077
1078 base_uri = remove_level_from_path (uri);
1079 new_uri = get_alternative_uri (base_uri, file_name_from_path (uri));
1080 g_free (base_uri);
1081
1082 return new_uri;
1083}
1084
1085GList *
1086gio_file_list_dup (GList *l)
1087{
1088 GList *r = NULL((void*)0), *scan;
1089 for (scan = l; scan; scan = scan->next)
1090 r = g_list_prepend (r, g_file_dup ((GFile*)scan->data));
1091 return g_list_reverse (r);
1092}
1093
1094void
1095gio_file_list_free (GList *l)
1096{
1097 GList *scan;
1098 for (scan = l; scan; scan = scan->next)
1099 g_object_unref (scan->data);
1100 g_list_free (l);
1101}
1102
1103void
1104g_key_file_save (GKeyFile *key_file,
1105 GFile *file)
1106{
1107 char *file_data;
1108 gsize size;
1109 GError *error = NULL((void*)0);
1110
1111 file_data = g_key_file_to_data (key_file, &size, &error);
1112 if (error != NULL((void*)0)) {
1113 g_warning ("Could not save options: %s\n", error->message);
1114 g_clear_error (&error);
1115 }
1116 else {
1117 GFileOutputStream *stream;
1118
1119 stream = g_file_replace (file, NULL((void*)0), FALSE(0), 0, NULL((void*)0), &error);
1120 if (stream == NULL((void*)0)) {
1121 g_warning ("Could not save options: %s\n", error->message);
1122 g_clear_error (&error);
1123 }
1124 else if (! g_output_stream_write_all (G_OUTPUT_STREAM (stream)((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((stream)), ((g_output_stream_get_type ()))))))
, file_data, size, NULL((void*)0), NULL((void*)0), &error)) {
1125 g_warning ("Could not save options: %s\n", error->message);
1126 g_clear_error (&error);
1127 }
1128 else if (! g_output_stream_close (G_OUTPUT_STREAM (stream)((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((stream)), ((g_output_stream_get_type ()))))))
, NULL((void*)0), &error)) {
1129 g_warning ("Could not save options: %s\n", error->message);
1130 g_clear_error (&error);
1131 }
1132
1133 g_object_unref (stream);
1134 }
1135
1136 g_free (file_data);
1137}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-22051c.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-22051c.html new file mode 100644 index 0000000..09b8558 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-22051c.html @@ -0,0 +1,9656 @@ + + + +fr-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/fr-window.c
Warning:line 7377, column 28
Null pointer passed to 1st parameter expecting 'nonnull'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name fr-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c fr-window.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2007 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include <config.h>
23#include <math.h>
24#include <string.h>
25
26#include <glib.h>
27#include <glib/gi18n.h>
28#include <gio/gio.h>
29#include <gdk/gdk.h>
30#include <gdk/gdkkeysyms.h>
31#include <gdk-pixbuf/gdk-pixbuf.h>
32
33#include "actions.h"
34#include "dlg-batch-add.h"
35#include "dlg-delete.h"
36#include "dlg-extract.h"
37#include "dlg-open-with.h"
38#include "dlg-ask-password.h"
39#include "dlg-package-installer.h"
40#include "dlg-update.h"
41#include "eggtreemultidnd.h"
42#include "fr-marshal.h"
43#include "fr-list-model.h"
44#include "fr-archive.h"
45#include "fr-error.h"
46#include "fr-window.h"
47#include "file-data.h"
48#include "file-utils.h"
49#include "glib-utils.h"
50#include "fr-init.h"
51#include "gtk-utils.h"
52#include "open-file.h"
53#include "typedefs.h"
54#include "ui.h"
55
56#ifdef __GNUC__4
57#define UNUSED_VARIABLE__attribute__ ((unused)) __attribute__ ((unused))
58#else
59#define UNUSED_VARIABLE__attribute__ ((unused))
60#endif
61
62#define LAST_OUTPUT_DIALOG_NAME"last-output" "last-output"
63#define ACTIVITY_DELAY100 100
64#define ACTIVITY_PULSE_STEP(0.033) (0.033)
65
66#define PROGRESS_TIMEOUT_MSECS5000 5000
67#define PROGRESS_DIALOG_DEFAULT_WIDTH500 500
68#define PROGRESS_BAR_HEIGHT10 10
69#undef LOG_PROGRESS
70
71#define HIDE_PROGRESS_TIMEOUT_MSECS500 500
72#define DEFAULT_NAME_COLUMN_WIDTH250 250
73#define OTHER_COLUMNS_WIDTH100 100
74
75#define FILE_LIST_ICON_SIZEGTK_ICON_SIZE_LARGE_TOOLBAR GTK_ICON_SIZE_LARGE_TOOLBAR
76
77#define BAD_CHARS"/\\*" "/\\*"
78
79static GHashTable *tree_pixbuf_hash = NULL((void*)0);
80static GtkIconTheme *icon_theme = NULL((void*)0);
81static int file_list_icon_size = 0;
82
83#define XDS_FILENAME"xds.txt" "xds.txt"
84#define MAX_XDS_ATOM_VAL_LEN4096 4096
85#define XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)) gdk_atom_intern ("XdndDirectSave0", FALSE(0))
86#define TEXT_ATOMgdk_atom_intern ("text/plain", (0)) gdk_atom_intern ("text/plain", FALSE(0))
87#define XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0)) gdk_atom_intern ("XdndEngrampa0", FALSE(0))
88
89#define FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"))
90#define FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
(gdk_atom_intern_static_string ("application/engrampa-uri-list"))
91
92static GtkTargetEntry clipboard_targets[] = {
93 { "application/engrampa-uri-list", 0, 1 }
94};
95
96static GtkTargetEntry target_table[] = {
97 { "XdndEngrampa0", 0, 0 },
98 { "text/uri-list", 0, 1 },
99};
100
101static GtkTargetEntry folder_tree_targets[] = {
102 { "XdndEngrampa0", 0, 0 },
103 { "XdndDirectSave0", 0, 2 }
104};
105
106typedef struct {
107 FrBatchActionType type;
108 void * data;
109 GFreeFunc free_func;
110} FRBatchAction;
111
112typedef struct {
113 guint converting : 1;
114 char *temp_dir;
115 FrArchive *new_archive;
116 char *password;
117 gboolean encrypt_header;
118 guint volume_size;
119 char *new_file;
120} FRConvertData;
121
122typedef enum {
123 FR_CLIPBOARD_OP_CUT,
124 FR_CLIPBOARD_OP_COPY
125} FRClipboardOp;
126
127typedef struct {
128 GList *file_list;
129 char *extract_to_dir;
130 char *sub_dir;
131 char *base_dir;
132 gboolean skip_older;
133 FrOverwrite overwrite;
134 gboolean junk_paths;
135 char *password;
136 gboolean extract_here;
137 gboolean ask_to_open_destination;
138} ExtractData;
139
140typedef enum {
141 FR_WINDOW_AREA_MENUBAR,
142 FR_WINDOW_AREA_TOOLBAR,
143 FR_WINDOW_AREA_LOCATIONBAR,
144 FR_WINDOW_AREA_CONTENTS,
145 FR_WINDOW_AREA_FILTERBAR,
146 FR_WINDOW_AREA_STATUSBAR,
147} FrWindowArea;
148
149typedef enum {
150 DIALOG_RESPONSE_NONE = 1,
151 DIALOG_RESPONSE_OPEN_ARCHIVE,
152 DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER,
153 DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT,
154 DIALOG_RESPONSE_QUIT
155} DialogResponse;
156
157/* -- FrClipboardData -- */
158
159typedef struct {
160 int refs;
161 char *archive_filename;
162 char *archive_password;
163 FRClipboardOp op;
164 char *base_dir;
165 GList *files;
166 char *tmp_dir;
167 char *current_dir;
168} FrClipboardData;
169
170static FrClipboardData*
171fr_clipboard_data_new (void)
172{
173 FrClipboardData *data;
174
175 data = g_new0 (FrClipboardData, 1)((FrClipboardData *) g_malloc0_n ((1), sizeof (FrClipboardData
)))
;
176 data->refs = 1;
177
178 return data;
179}
180
181static FrClipboardData *
182fr_clipboard_data_ref (FrClipboardData *clipboard_data)
183{
184 clipboard_data->refs++;
185 return clipboard_data;
186}
187
188static void
189fr_clipboard_data_unref (FrClipboardData *clipboard_data)
190{
191 if (clipboard_data == NULL((void*)0))
192 return;
193 if (--clipboard_data->refs > 0)
194 return;
195
196 g_free (clipboard_data->archive_filename);
197 g_free (clipboard_data->archive_password);
198 g_free (clipboard_data->base_dir);
199 g_free (clipboard_data->tmp_dir);
200 g_free (clipboard_data->current_dir);
201 g_list_free_full (clipboard_data->files, g_free);
202 g_free (clipboard_data);
203}
204
205static void
206fr_clipboard_data_set_password (FrClipboardData *clipboard_data,
207 const char *password)
208{
209 if (clipboard_data->archive_password != password)
210 g_free (clipboard_data->archive_password);
211 if (password != NULL((void*)0))
212 clipboard_data->archive_password = g_strdup (password)g_strdup_inline (password);
213}
214
215/**/
216
217enum {
218 ARCHIVE_LOADED,
219 PROGRESS,
220 READY,
221 LAST_SIGNAL
222};
223
224static GtkApplicationWindowClass *parent_class = NULL((void*)0);
225static guint fr_window_signals[LAST_SIGNAL] = { 0 };
226
227struct _FrWindowPrivateData {
228 GtkWidget *layout;
229 GtkWidget *contents;
230 GtkWidget *list_view;
231 GtkListStore *list_store;
232 GtkWidget *tree_view;
233 GtkTreeStore *tree_store;
234 GtkWidget *toolbar;
235 GtkWidget *statusbar;
236 GtkWidget *progress_bar;
237 GtkWidget *location_bar;
238 GtkWidget *location_entry;
239 GtkWidget *location_label;
240 GtkWidget *filter_bar;
241 GtkWidget *filter_entry;
242 GtkWidget *paned;
243 GtkWidget *sidepane;
244 GtkTreePath *list_hover_path;
245 GtkTreeViewColumn *filename_column;
246
247 gboolean filter_mode;
248 gint current_view_length;
249
250 guint help_message_cid;
251 guint list_info_cid;
252 guint progress_cid;
253
254 GtkWidget * up_arrows[5];
255 GtkWidget * down_arrows[5];
256
257 FrAction action;
258 gboolean archive_present;
259 gboolean archive_new; /* A new archive has been created
260 * but it doesn't contain any
261 * file yet. The real file will
262 * be created only when the user
263 * adds some file to the
264 * archive.*/
265
266 char * archive_uri;
267 char * open_default_dir; /* default directory to be used
268 * in the Open dialog. */
269 char * add_default_dir; /* default directory to be used
270 * in the Add dialog. */
271 char * extract_default_dir; /* default directory to be used
272 * in the Extract dialog. */
273 gboolean freeze_default_dir;
274 gboolean asked_for_password;
275 gboolean ask_to_open_destination_after_extraction;
276 gboolean destroy_with_error_dialog;
277
278 FRBatchAction current_batch_action;
279
280 gboolean give_focus_to_the_list;
281 gboolean single_click;
282 GtkTreePath *path_clicked;
283
284 FrWindowSortMethod sort_method;
285 GtkSortType sort_type;
286
287 char * last_location;
288
289 gboolean view_folders;
290 FrWindowListMode list_mode;
291 FrWindowListMode last_list_mode;
292 GList * history;
293 GList * history_current;
294 char * password;
295 char * password_for_paste;
296 gboolean encrypt_header;
297 FrCompression compression;
298 guint volume_size;
299
300 guint activity_timeout_handle; /* activity timeout
301 * handle. */
302 gint activity_ref; /* when > 0 some activity
303 * is present. */
304
305 guint update_timeout_handle; /* update file list
306 * timeout handle. */
307
308 FRConvertData convert_data;
309
310 gboolean stoppable;
311 gboolean closing;
312
313 FrClipboardData *clipboard_data;
314 FrClipboardData *copy_data;
315
316 FrArchive *copy_from_archive;
317
318 GActionGroup *actions;
319 GtkBuilder *ui_manager;
320 GtkWidget *menubar_recentmenu;
321 GtkWidget *toolbar_recentmenu;
322
323 GtkWidget *file_popup_menu;
324 GtkWidget *folder_popup_menu;
325 GtkWidget *sidebar_folder_popup_menu;
326
327 /* dragged files data */
328
329 char *drag_destination_folder;
330 char *drag_base_dir;
331 GError *drag_error;
332 GList *drag_file_list; /* the list of files we are
333 * dragging*/
334
335 /* progress dialog data */
336
337 GtkWidget *progress_dialog;
338 GtkWidget *pd_action;
339 GtkWidget *pd_message;
340 GtkWidget *pd_progress_bar;
341 GtkWidget *pd_cancel_button;
342 GtkWidget *pd_close_button;
343 GtkWidget *pd_open_archive_button;
344 GtkWidget *pd_open_destination_button;
345 GtkWidget *pd_open_destination_and_quit_button;
346 GtkWidget *pd_quit_button;
347 GtkWidget *pd_state_button; //Switch state, pause state or start state
348 GtkWidget *pd_icon;
349 gboolean progress_pulse;
350 guint progress_timeout; /* Timeout to display the progress dialog. */
351 guint hide_progress_timeout; /* Timeout to hide the progress dialog. */
352 char *pd_last_archive;
353 char *working_archive;
354 double pd_last_fraction;
355 char *pd_last_message;
356 gboolean use_progress_dialog;
357
358 /* update dialog data */
359
360 gpointer update_dialog;
361 GList *open_files;
362
363 /* batch mode data */
364
365 gboolean batch_mode; /* whether we are in a non interactive
366 * mode. */
367 GList *batch_action_list; /* FRBatchAction * elements */
368 GList *batch_action; /* current action. */
369 char *batch_title;
370
371 /* misc */
372
373 GSettings *settings_listing;
374 GSettings *settings_ui;
375 GSettings *settings_general;
376 GSettings *settings_dialogs;
377 GSettings *settings_caja;
378
379 gulong theme_changed_handler_id;
380 gboolean non_interactive;
381 char *extract_here_dir;
382 gboolean extract_interact_use_default_dir;
383 gboolean update_dropped_files;
384 gboolean batch_adding_one_file;
385
386 GtkWindow *load_error_parent_window;
387 gboolean showing_error_dialog;
388 GtkWindow *error_dialog_parent;
389
390 gboolean close_dialog;
391};
392
393/* -- fr_window_free_private_data -- */
394
395static void
396fr_window_free_batch_data (FrWindow *window)
397{
398 GList *scan;
399
400 for (scan = window->priv->batch_action_list; scan; scan = scan->next) {
401 FRBatchAction *adata = scan->data;
402
403 if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0)))
404 (*adata->free_func) (adata->data);
405 g_free (adata);
406 }
407
408 g_list_free (window->priv->batch_action_list);
409 window->priv->batch_action_list = NULL((void*)0);
410 window->priv->batch_action = NULL((void*)0);
411
412 g_free (window->priv->batch_title);
413 window->priv->batch_title = NULL((void*)0);
414}
415
416static void
417gh_unref_pixbuf (gpointer key,
418 gpointer value,
419 gpointer user_data)
420{
421 g_object_unref (value);
422}
423
424static void
425fr_window_clipboard_remove_file_list (FrWindow *window,
426 GList *file_list)
427{
428 GList *scan1;
429
430 if (window->priv->copy_data == NULL((void*)0))
431 return;
432
433 if (file_list == NULL((void*)0)) {
434 fr_clipboard_data_unref (window->priv->copy_data);
435 window->priv->copy_data = NULL((void*)0);
436 return;
437 }
438
439 for (scan1 = file_list; scan1; scan1 = scan1->next) {
440 const char *name1 = scan1->data;
441 GList *scan2;
442
443 for (scan2 = window->priv->copy_data->files; scan2;) {
444 const char *name2 = scan2->data;
445
446 if (strcmp (name1, name2) == 0) {
447 GList *tmp = scan2->next;
448 window->priv->copy_data->files = g_list_remove_link (window->priv->copy_data->files, scan2);
449 g_free (scan2->data);
450 g_list_free (scan2);
451 scan2 = tmp;
452 }
453 else
454 scan2 = scan2->next;
455 }
456 }
457
458 if (window->priv->copy_data->files == NULL((void*)0)) {
459 fr_clipboard_data_unref (window->priv->copy_data);
460 window->priv->copy_data = NULL((void*)0);
461 }
462}
463
464static void
465fr_window_history_clear (FrWindow *window)
466{
467 if (window->priv->history != NULL((void*)0))
468 path_list_free (window->priv->history);
469 window->priv->history = NULL((void*)0);
470 window->priv->history_current = NULL((void*)0);
471 g_free (window->priv->last_location);
472 window->priv->last_location = NULL((void*)0);
473}
474
475static void
476fr_window_free_open_files (FrWindow *window)
477{
478 GList *scan;
479
480 for (scan = window->priv->open_files; scan; scan = scan->next) {
481 OpenFile *file = scan->data;
482
483 if (file->monitor != NULL((void*)0))
484 g_file_monitor_cancel (file->monitor);
485 open_file_free (file);
486 }
487 g_list_free (window->priv->open_files);
488 window->priv->open_files = NULL((void*)0);
489}
490
491static void
492fr_window_convert_data_free (FrWindow *window,
493 gboolean all)
494{
495 if (all) {
496 g_free (window->priv->convert_data.new_file);
497 window->priv->convert_data.new_file = NULL((void*)0);
498 }
499
500 window->priv->convert_data.converting = FALSE(0);
501
502 if (window->priv->convert_data.temp_dir != NULL((void*)0)) {
503 g_free (window->priv->convert_data.temp_dir);
504 window->priv->convert_data.temp_dir = NULL((void*)0);
505 }
506
507 if (window->priv->convert_data.new_archive != NULL((void*)0)) {
508 g_object_unref (window->priv->convert_data.new_archive);
509 window->priv->convert_data.new_archive = NULL((void*)0);
510 }
511
512 if (window->priv->convert_data.password != NULL((void*)0)) {
513 g_free (window->priv->convert_data.password);
514 window->priv->convert_data.password = NULL((void*)0);
515 }
516}
517
518static void
519fr_window_free_private_data (FrWindow *window)
520{
521 if (window->priv->update_timeout_handle != 0) {
522 g_source_remove (window->priv->update_timeout_handle);
523 window->priv->update_timeout_handle = 0;
524 }
525
526 while (window->priv->activity_ref > 0)
527 fr_window_stop_activity_mode (window);
528
529 if (window->priv->progress_timeout != 0) {
530 g_source_remove (window->priv->progress_timeout);
531 window->priv->progress_timeout = 0;
532 }
533
534 if (window->priv->hide_progress_timeout != 0) {
535 g_source_remove (window->priv->hide_progress_timeout);
536 window->priv->hide_progress_timeout = 0;
537 }
538
539 if (window->priv->theme_changed_handler_id != 0)
540 g_signal_handler_disconnect (icon_theme, window->priv->theme_changed_handler_id);
541
542 fr_window_history_clear (window);
543
544 g_free (window->priv->open_default_dir);
545 g_free (window->priv->add_default_dir);
546 g_free (window->priv->extract_default_dir);
547 g_free (window->priv->archive_uri);
548 g_free (window->priv->working_archive);
549
550 g_free (window->priv->password);
551 g_free (window->priv->password_for_paste);
552
553 g_object_unref (window->priv->list_store);
554
555 if (window->priv->clipboard_data != NULL((void*)0)) {
556 fr_clipboard_data_unref (window->priv->clipboard_data);
557 window->priv->clipboard_data = NULL((void*)0);
558 }
559 if (window->priv->copy_data != NULL((void*)0)) {
560 fr_clipboard_data_unref (window->priv->copy_data);
561 window->priv->copy_data = NULL((void*)0);
562 }
563 if (window->priv->copy_from_archive != NULL((void*)0)) {
564 g_object_unref (window->priv->copy_from_archive);
565 window->priv->copy_from_archive = NULL((void*)0);
566 }
567
568 fr_window_free_open_files (window);
569
570 fr_window_convert_data_free (window, TRUE(!(0)));
571
572 g_clear_error (&window->priv->drag_error);
573 path_list_free (window->priv->drag_file_list);
574 window->priv->drag_file_list = NULL((void*)0);
575
576 if (window->priv->file_popup_menu != NULL((void*)0)) {
577 gtk_widget_destroy (window->priv->file_popup_menu);
578 window->priv->file_popup_menu = NULL((void*)0);
579 }
580
581 if (window->priv->folder_popup_menu != NULL((void*)0)) {
582 gtk_widget_destroy (window->priv->folder_popup_menu);
583 window->priv->folder_popup_menu = NULL((void*)0);
584 }
585
586 if (window->priv->sidebar_folder_popup_menu != NULL((void*)0)) {
587 gtk_widget_destroy (window->priv->sidebar_folder_popup_menu);
588 window->priv->sidebar_folder_popup_menu = NULL((void*)0);
589 }
590
591 g_free (window->priv->last_location);
592
593 fr_window_free_batch_data (window);
594 fr_window_reset_current_batch_action (window);
595
596 g_free (window->priv->pd_last_archive);
597 g_free (window->priv->pd_last_message);
598 g_free (window->priv->extract_here_dir);
599
600 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method", window->priv->sort_method);
601 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type", window->priv->sort_type);
602 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode);
603
604 _g_object_unref (window->priv->settings_listing);
605 _g_object_unref (window->priv->settings_ui);
606 _g_object_unref (window->priv->settings_general);
607 _g_object_unref (window->priv->settings_dialogs);
608
609 if (window->priv->settings_caja)
610 _g_object_unref (window->priv->settings_caja);
611
612 if (window->priv->ui_manager)
613 {
614 g_object_unref (window->priv->ui_manager);
615 window->priv->ui_manager = NULL((void*)0);
616 }
617}
618
619static void
620fr_window_finalize (GObject *object)
621{
622 FrWindow *window = FR_WINDOW (object)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((fr_window_get_type ()))))))
;
623
624 fr_window_free_open_files (window);
625
626 if (window->archive != NULL((void*)0)) {
627 g_object_unref (window->archive);
628 window->archive = NULL((void*)0);
629 }
630
631 if (window->priv != NULL((void*)0)) {
632 fr_window_free_private_data (window);
633 g_free (window->priv);
634 window->priv = NULL((void*)0);
635 }
636
637 if (gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ())((((GtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_application_get_default ())), ((gtk_application_get_type
()))))))
) == NULL((void*)0)) {
638 if (tree_pixbuf_hash != NULL((void*)0)) {
639 g_hash_table_foreach (tree_pixbuf_hash,
640 gh_unref_pixbuf,
641 NULL((void*)0));
642 g_hash_table_destroy (tree_pixbuf_hash);
643 tree_pixbuf_hash = NULL((void*)0);
644 }
645 }
646
647 G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->finalize (object);
648}
649
650static gboolean
651close__step2 (gpointer data)
652{
653 gtk_widget_destroy (GTK_WIDGET (data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_widget_get_type ()))))))
);
654 return FALSE(0);
655}
656
657void
658fr_window_close (FrWindow *window)
659{
660 if (window->priv->activity_ref > 0)
661 return;
662
663 window->priv->closing = TRUE(!(0));
664
665 if (gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)) {
666 int width, height;
667
668 width = gtk_widget_get_allocated_width (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
669 height = gtk_widget_get_allocated_height (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
670 g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width", width);
671 g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height", height);
672
673 width = gtk_paned_get_position (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
);
674 if (width > 0)
675 g_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width", width);
676
677 width = gtk_tree_view_column_get_width (window->priv->filename_column);
678 if (width > 0)
679 g_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width", width);
680 }
681
682 g_idle_add (close__step2, window);
683}
684
685static void
686fr_window_class_init (FrWindowClass *class)
687{
688 GObjectClass *gobject_class;
689
690 parent_class = g_type_class_peek_parent (class);
691
692 fr_window_signals[ARCHIVE_LOADED] =
693 g_signal_new ("archive-loaded",
694 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
695 G_SIGNAL_RUN_LAST,
696 G_STRUCT_OFFSET (FrWindowClass, archive_loaded)((glong) __builtin_offsetof(FrWindowClass, archive_loaded)),
697 NULL((void*)0), NULL((void*)0),
698 fr_marshal_VOID__BOOLEANg_cclosure_marshal_VOID__BOOLEAN,
699 G_TYPE_NONE((GType) ((1) << (2))), 1,
700 G_TYPE_BOOLEAN((GType) ((5) << (2))));
701 fr_window_signals[PROGRESS] =
702 g_signal_new ("progress",
703 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
704 G_SIGNAL_RUN_LAST,
705 G_STRUCT_OFFSET (FrWindowClass, progress)((glong) __builtin_offsetof(FrWindowClass, progress)),
706 NULL((void*)0), NULL((void*)0),
707 fr_marshal_VOID__DOUBLE_STRING,
708 G_TYPE_NONE((GType) ((1) << (2))), 2,
709 G_TYPE_DOUBLE((GType) ((15) << (2))),
710 G_TYPE_STRING((GType) ((16) << (2))));
711 fr_window_signals[READY] =
712 g_signal_new ("ready",
713 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
714 G_SIGNAL_RUN_LAST,
715 G_STRUCT_OFFSET (FrWindowClass, ready)((glong) __builtin_offsetof(FrWindowClass, ready)),
716 NULL((void*)0), NULL((void*)0),
717 fr_marshal_VOID__POINTERg_cclosure_marshal_VOID__POINTER,
718 G_TYPE_NONE((GType) ((1) << (2))), 1,
719 G_TYPE_POINTER((GType) ((17) << (2))));
720
721 gobject_class = (GObjectClass*) class;
722 gobject_class->finalize = fr_window_finalize;
723}
724
725static void fr_window_update_paste_command_sensitivity (FrWindow *, GtkClipboard *);
726
727static void
728clipboard_owner_change_cb (GtkClipboard *clipboard,
729 GdkEvent *event,
730 gpointer user_data)
731{
732 fr_window_update_paste_command_sensitivity ((FrWindow *) user_data, clipboard);
733}
734
735static void
736fr_window_realized (GtkWidget *window,
737 gpointer *data)
738{
739 GtkClipboard *clipboard;
740
741 clipboard = gtk_widget_get_clipboard (window, FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
742 g_signal_connect (clipboard,g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
743 "owner_change",g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
744 G_CALLBACK (clipboard_owner_change_cb),g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
745 window)g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
746}
747
748static void
749fr_window_unrealized (GtkWidget *window,
750 gpointer *data)
751{
752 GtkClipboard *clipboard;
753
754 clipboard = gtk_widget_get_clipboard (window, FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
755 g_signal_handlers_disconnect_by_func (clipboard,g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (clipboard_owner_change_cb))), (window))
756 G_CALLBACK (clipboard_owner_change_cb),g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (clipboard_owner_change_cb))), (window))
757 window)g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (clipboard_owner_change_cb))), (window))
;
758}
759
760static void
761fr_window_init (FrWindow *window)
762{
763 GtkStyleContext *context;
764
765 window->priv = g_new0 (FrWindowPrivateData, 1)((FrWindowPrivateData *) g_malloc0_n ((1), sizeof (FrWindowPrivateData
)))
;
766 window->priv->update_dropped_files = FALSE(0);
767 window->priv->filter_mode = FALSE(0);
768 window->priv->batch_title = NULL((void*)0);
769 window->priv->use_progress_dialog = TRUE(!(0));
770 window->priv->batch_title = NULL((void*)0);
771
772 context = gtk_widget_get_style_context (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
773 gtk_style_context_add_class (context, "engrampa-window");
774
775 g_signal_connect (window,g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
776 "realize",g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
777 G_CALLBACK (fr_window_realized),g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
778 NULL)g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
779 g_signal_connect (window,g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
780 "unrealize",g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
781 G_CALLBACK (fr_window_unrealized),g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
782 NULL)g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
783}
784
785GType
786fr_window_get_type (void)
787{
788 static GType type = 0;
789
790 if (! type) {
791 GTypeInfo type_info = {
792 sizeof (FrWindowClass),
793 NULL((void*)0),
794 NULL((void*)0),
795 (GClassInitFunc) fr_window_class_init,
796 NULL((void*)0),
797 NULL((void*)0),
798 sizeof (FrWindow),
799 0,
800 (GInstanceInitFunc) fr_window_init,
801 NULL((void*)0)
802 };
803
804 type = g_type_register_static (GTK_TYPE_APPLICATION_WINDOW(gtk_application_window_get_type ()),
805 "FrWindow",
806 &type_info,
807 0);
808 }
809
810 return type;
811}
812
813/* -- window history -- */
814
815#if 0
816static void
817fr_window_history_print (FrWindow *window)
818{
819 GList *list;
820
821 debug (DEBUG_INFO"fr-window.c", 821, __FUNCTION__, "history:\n");
822 for (list = window->priv->history; list; list = list->next)
823 g_print ("\t%s %s\n",
824 (char*) list->data,
825 (list == window->priv->history_current)? "<-": "");
826 g_print ("\n");
827}
828#endif
829
830static void
831fr_window_history_add (FrWindow *window,
832 const char *path)
833{
834 if ((window->priv->history_current == NULL((void*)0)) || (g_strcmp0 (path, window->priv->history_current->data) != 0)) {
835 GList *scan;
836 GList *new_current = NULL((void*)0);
837
838 /* search the path in the history */
839 for (scan = window->priv->history_current; scan; scan = scan->next) {
840 char *path_in_history = scan->data;
841
842 if (g_strcmp0 (path, path_in_history) == 0) {
843 new_current = scan;
844 break;
845 }
846 }
847
848 if (new_current != NULL((void*)0)) {
849 window->priv->history_current = new_current;
850 }
851 else {
852 /* remove all the paths after the current position */
853 for (scan = window->priv->history; scan && (scan != window->priv->history_current); /* void */) {
854 GList *next = scan->next;
855
856 window->priv->history = g_list_remove_link (window->priv->history, scan);
857 path_list_free (scan);
858
859 scan = next;
860 }
861
862 window->priv->history = g_list_prepend (window->priv->history, g_strdup (path)g_strdup_inline (path));
863 window->priv->history_current = window->priv->history;
864 }
865 }
866}
867
868static void
869fr_window_history_pop (FrWindow *window)
870{
871 GList *first;
872
873 if (window->priv->history == NULL((void*)0))
874 return;
875
876 first = window->priv->history;
877 window->priv->history = g_list_remove_link (window->priv->history, first);
878 if (window->priv->history_current == first)
879 window->priv->history_current = window->priv->history;
880 g_free (first->data);
881 g_list_free (first);
882}
883
884/* -- window_update_file_list -- */
885
886static GPtrArray *
887fr_window_get_current_dir_list (FrWindow *window)
888{
889 GPtrArray *files;
890 guint i;
891
892 files = g_ptr_array_sized_new (128);
893
894 for (i = 0; i < window->archive->command->files->len; i++) {
895 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
896
897 if (fdata->list_name == NULL((void*)0))
898 continue;
899 g_ptr_array_add (files, fdata);
900 }
901
902 return files;
903}
904
905static gint
906sort_by_name (gconstpointer ptr1,
907 gconstpointer ptr2)
908{
909 FileData *fdata1 = *((FileData **) ptr1);
910 FileData *fdata2 = *((FileData **) ptr2);
911
912 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
913 if (file_data_is_dir (fdata1))
914 return -1;
915 else
916 return 1;
917 }
918
919 return strcmp (fdata1->sort_key, fdata2->sort_key);
920}
921
922static gint
923sort_by_size (gconstpointer ptr1,
924 gconstpointer ptr2)
925{
926 FileData *fdata1 = *((FileData **) ptr1);
927 FileData *fdata2 = *((FileData **) ptr2);
928
929 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
930 if (file_data_is_dir (fdata1))
931 return -1;
932 else
933 return 1;
934 }
935 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) {
936 if (fdata1->dir_size > fdata2->dir_size)
937 return 1;
938 else
939 return -1;
940 }
941
942 if (fdata1->size == fdata2->size)
943 return sort_by_name (ptr1, ptr2);
944 else if (fdata1->size > fdata2->size)
945 return 1;
946 else
947 return -1;
948}
949
950static gint
951sort_by_type (gconstpointer ptr1,
952 gconstpointer ptr2)
953{
954 FileData *fdata1 = *((FileData **) ptr1);
955 FileData *fdata2 = *((FileData **) ptr2);
956 int result;
957 char *desc1, *desc2;
958
959 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
960 if (file_data_is_dir (fdata1))
961 return -1;
962 else
963 return 1;
964 }
965 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2))
966 return sort_by_name (ptr1, ptr2);
967
968 desc1 = g_content_type_get_description (fdata1->content_type);
969 desc2 = g_content_type_get_description (fdata2->content_type);
970
971 result = strcasecmp (desc1, desc2);
972 g_free (desc1);
973 g_free (desc2);
974
975 if (result == 0)
976 return sort_by_name (ptr1, ptr2);
977 else
978 return result;
979}
980
981static gint
982sort_by_time (gconstpointer ptr1,
983 gconstpointer ptr2)
984{
985 FileData *fdata1 = *((FileData **) ptr1);
986 FileData *fdata2 = *((FileData **) ptr2);
987
988 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
989 if (file_data_is_dir (fdata1))
990 return -1;
991 else
992 return 1;
993 }
994 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2))
995 return sort_by_name (ptr1, ptr2);
996
997 if (fdata1->modified == fdata2->modified)
998 return sort_by_name (ptr1, ptr2);
999 else if (fdata1->modified > fdata2->modified)
1000 return 1;
1001 else
1002 return -1;
1003}
1004
1005static gint
1006sort_by_path (gconstpointer ptr1,
1007 gconstpointer ptr2)
1008{
1009 FileData *fdata1 = *((FileData **) ptr1);
1010 FileData *fdata2 = *((FileData **) ptr2);
1011 int result;
1012
1013 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
1014 if (file_data_is_dir (fdata1))
1015 return -1;
1016 else
1017 return 1;
1018 }
1019 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2))
1020 return sort_by_name (ptr1, ptr2);
1021
1022 /* 2 files */
1023
1024 result = strcasecmp (fdata1->path, fdata2->path);
1025 if (result == 0)
1026 return sort_by_name (ptr1, ptr2);
1027 else
1028 return result;
1029}
1030
1031static guint64
1032get_dir_size (FrWindow *window,
1033 const char *current_dir,
1034 const char *name)
1035{
1036 guint64 size;
1037 char *dirname;
1038 int dirname_l;
1039 guint i;
1040
1041 dirname = g_strconcat (current_dir, name, "/", NULL((void*)0));
1042 dirname_l = strlen (dirname);
1043
1044 size = 0;
1045 for (i = 0; i < window->archive->command->files->len; i++) {
1046 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
1047
1048 if (strncmp (dirname, fd->full_path, dirname_l) == 0)
1049 size += fd->size;
1050 }
1051
1052 g_free (dirname);
1053
1054 return size;
1055}
1056
1057static gboolean
1058file_data_respects_filter (FrWindow *window,
1059 FileData *fdata)
1060{
1061 const char *filter;
1062
1063 filter = gtk_entry_get_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
);
1064 if ((fdata == NULL((void*)0)) || (filter == NULL((void*)0)) || (*filter == '\0'))
1065 return TRUE(!(0));
1066
1067 if (fdata->dir || (fdata->name == NULL((void*)0)))
1068 return FALSE(0);
1069
1070 return strncasecmp (fdata->name, filter, strlen (filter)) == 0;
1071}
1072
1073static gboolean
1074compute_file_list_name (FrWindow *window,
1075 FileData *fdata,
1076 const char *current_dir,
1077 size_t current_dir_len,
1078 GHashTable *names_hash,
1079 gboolean *different_name)
1080{
1081 register char *scan, *end;
1082
1083 *different_name = FALSE(0);
1084
1085 if (! file_data_respects_filter (window, fdata))
1086 return FALSE(0);
1087
1088 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
1089 if (!(fdata->dir))
1090 file_data_set_list_name (fdata, fdata->name);
1091 return FALSE(0);
1092 }
1093
1094 if (strncmp (fdata->full_path, current_dir, current_dir_len) != 0) {
1095 *different_name = TRUE(!(0));
1096 return FALSE(0);
1097 }
1098
1099 if (strlen (fdata->full_path) == current_dir_len)
1100 return FALSE(0);
1101
1102 scan = fdata->full_path + current_dir_len;
1103 end = strchr (scan, '/');
1104 if ((end == NULL((void*)0)) && ! fdata->dir) { /* file */
1105 file_data_set_list_name (fdata, scan);
1106 }
1107 else { /* folder */
1108 char *dir_name;
1109
1110 if (end != NULL((void*)0))
1111 dir_name = g_strndup (scan, end - scan);
1112 else
1113 dir_name = g_strdup (scan)g_strdup_inline (scan);
1114
1115 /* avoid to insert duplicated folders */
1116 if (g_hash_table_lookup (names_hash, dir_name) != NULL((void*)0)) {
1117 g_free (dir_name);
1118 return FALSE(0);
1119 }
1120 g_hash_table_insert (names_hash, dir_name, GINT_TO_POINTER (1)((gpointer) (glong) (1)));
1121
1122 if ((end != NULL((void*)0)) && (*(end + 1) != '\0'))
1123 fdata->list_dir = TRUE(!(0));
1124 file_data_set_list_name (fdata, dir_name);
1125 fdata->dir_size = get_dir_size (window, current_dir, dir_name);
1126 }
1127
1128 return TRUE(!(0));
1129}
1130
1131static void
1132fr_window_compute_list_names (FrWindow *window,
1133 GPtrArray *files)
1134{
1135 const char *current_dir;
1136 size_t current_dir_len;
1137 GHashTable *names_hash;
1138 guint i;
1139 gboolean visible_list_started = FALSE(0);
1140 gboolean visible_list_completed = FALSE(0);
1141 gboolean different_name;
1142
1143 current_dir = fr_window_get_current_location (window);
1144 current_dir_len = strlen (current_dir);
1145 names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
1146
1147 for (i = 0; i < files->len; i++) {
1148 FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i];
1149
1150 file_data_set_list_name (fdata, NULL((void*)0));
1151 fdata->list_dir = FALSE(0);
1152
1153 /* the files array is sorted by path, when the visible list
1154 * is started and we find a path that doesn't match the
1155 * current_dir path, the following files can't match
1156 * the current_dir path. */
1157
1158 if (visible_list_completed)
1159 continue;
1160
1161 if (compute_file_list_name (window, fdata, current_dir, current_dir_len, names_hash, &different_name)) {
1162 visible_list_started = TRUE(!(0));
1163 }
1164 else if (visible_list_started && different_name)
1165 visible_list_completed = TRUE(!(0));
1166 }
1167
1168 g_hash_table_destroy (names_hash);
1169}
1170
1171static gboolean
1172fr_window_dir_exists_in_archive (FrWindow *window,
1173 const char *dir_name)
1174{
1175 int dir_name_len;
1176 guint i;
1177
1178 if (dir_name == NULL((void*)0))
1179 return FALSE(0);
1180
1181 dir_name_len = strlen (dir_name);
1182 if (dir_name_len == 0)
1183 return TRUE(!(0));
1184
1185 if (strcmp (dir_name, "/") == 0)
1186 return TRUE(!(0));
1187
1188 for (i = 0; i < window->archive->command->files->len; i++) {
1189 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
1190
1191 if (strncmp (dir_name, fdata->full_path, dir_name_len) == 0) {
1192 return TRUE(!(0));
1193 }
1194 else if (fdata->dir
1195 && (fdata->full_path[strlen (fdata->full_path) -1] != '/')
1196 && (strncmp (dir_name, fdata->full_path, dir_name_len - 1) == 0))
1197 {
1198 return TRUE(!(0));
1199 }
1200 }
1201
1202 return FALSE(0);
1203}
1204
1205static char *
1206get_parent_dir (const char *current_dir)
1207{
1208 char *dir;
1209 char *new_dir;
1210 char *retval;
1211
1212 if (current_dir == NULL((void*)0))
1213 return NULL((void*)0);
1214 if (strcmp (current_dir, "/") == 0)
1215 return g_strdup ("/")g_strdup_inline ("/");
1216
1217 dir = g_strdup (current_dir)g_strdup_inline (current_dir);
1218 dir[strlen (dir) - 1] = 0;
1219 new_dir = remove_level_from_path (dir);
1220 g_free (dir);
1221
1222 if (new_dir[strlen (new_dir) - 1] == '/')
1223 retval = new_dir;
1224 else {
1225 retval = g_strconcat (new_dir, "/", NULL((void*)0));
1226 g_free (new_dir);
1227 }
1228
1229 return retval;
1230}
1231
1232static void fr_window_update_statusbar_list_info (FrWindow *window);
1233
1234static GdkPixbuf *
1235get_mime_type_icon (const char *mime_type)
1236{
1237 GdkPixbuf *pixbuf = NULL((void*)0);
1238
1239 pixbuf = g_hash_table_lookup (tree_pixbuf_hash, mime_type);
1240 if (pixbuf != NULL((void*)0)) {
1241 g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
)))))))
;
1242 return pixbuf;
1243 }
1244
1245 pixbuf = get_mime_type_pixbuf (mime_type, file_list_icon_size, icon_theme);
1246 if (pixbuf == NULL((void*)0))
1247 return NULL((void*)0);
1248
1249 pixbuf = gdk_pixbuf_copy (pixbuf);
1250 g_hash_table_insert (tree_pixbuf_hash, (gpointer) mime_type, pixbuf);
1251 g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
)))))))
;
1252
1253 return pixbuf;
1254}
1255
1256static GdkPixbuf *
1257get_icon (FileData *fdata)
1258{
1259 const char *content_type;
1260
1261 if (file_data_is_dir (fdata))
1262 content_type = MIME_TYPE_DIRECTORY"folder";
1263 else
1264 content_type = fdata->content_type;
1265
1266 return get_mime_type_icon (content_type);
1267}
1268
1269static GdkPixbuf *
1270get_emblem (FileData *fdata)
1271{
1272 if (! fdata->encrypted)
1273 return NULL((void*)0);
1274
1275 return get_mime_type_icon ("emblem-nowrite");
1276}
1277
1278static int
1279get_column_from_sort_method (FrWindowSortMethod sort_method)
1280{
1281 switch (sort_method) {
1282 case FR_WINDOW_SORT_BY_NAME: return COLUMN_NAME;
1283 case FR_WINDOW_SORT_BY_SIZE: return COLUMN_SIZE;
1284 case FR_WINDOW_SORT_BY_TYPE: return COLUMN_TYPE;
1285 case FR_WINDOW_SORT_BY_TIME: return COLUMN_TIME;
1286 case FR_WINDOW_SORT_BY_PATH: return COLUMN_PATH;
1287 default:
1288 break;
1289 }
1290
1291 return COLUMN_NAME;
1292}
1293
1294static int
1295get_sort_method_from_column (int column_id)
1296{
1297 switch (column_id) {
1298 case COLUMN_NAME: return FR_WINDOW_SORT_BY_NAME;
1299 case COLUMN_SIZE: return FR_WINDOW_SORT_BY_SIZE;
1300 case COLUMN_TYPE: return FR_WINDOW_SORT_BY_TYPE;
1301 case COLUMN_TIME: return FR_WINDOW_SORT_BY_TIME;
1302 case COLUMN_PATH: return FR_WINDOW_SORT_BY_PATH;
1303 default:
1304 break;
1305 }
1306
1307 return FR_WINDOW_SORT_BY_NAME;
1308}
1309
1310static void
1311add_selected_from_list_view (GtkTreeModel *model,
1312 GtkTreePath *path,
1313 GtkTreeIter *iter,
1314 gpointer data)
1315{
1316 GList **list = data;
1317 FileData *fdata;
1318
1319 gtk_tree_model_get (model, iter,
1320 COLUMN_FILE_DATA, &fdata,
1321 -1);
1322 *list = g_list_prepend (*list, fdata);
1323}
1324
1325static void
1326add_selected_from_tree_view (GtkTreeModel *model,
1327 GtkTreePath *path,
1328 GtkTreeIter *iter,
1329 gpointer data)
1330{
1331 GList **list = data;
1332 char *dir_path;
1333
1334 gtk_tree_model_get (model, iter,
1335 TREE_COLUMN_PATH, &dir_path,
1336 -1);
1337 *list = g_list_prepend (*list, dir_path);
1338}
1339
1340static void
1341add_selected_fd (GtkTreeModel *model,
1342 GtkTreePath *path,
1343 GtkTreeIter *iter,
1344 gpointer data)
1345{
1346 GList **list = data;
1347 FileData *fdata;
1348
1349 gtk_tree_model_get (model, iter,
1350 COLUMN_FILE_DATA, &fdata,
1351 -1);
1352 if (! fdata->list_dir)
1353 *list = g_list_prepend (*list, fdata);
1354}
1355
1356static GList *
1357get_selection_as_fd (FrWindow *window)
1358{
1359 GtkTreeSelection *selection;
1360 GList *list = NULL((void*)0);
1361
1362 if (! gtk_widget_get_realized (window->priv->list_view))
1363 return NULL((void*)0);
1364
1365 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
1366 if (selection == NULL((void*)0))
1367 return NULL((void*)0);
1368 gtk_tree_selection_selected_foreach (selection, add_selected_fd, &list);
1369
1370 return list;
1371}
1372
1373static void
1374fr_window_update_statusbar_list_info (FrWindow *window)
1375{
1376 char *info, *archive_info, *selected_info;
1377 char *size_txt, *sel_size_txt;
1378 gulong tot_n = 0;
1379 gulong sel_n = 0;
1380 goffset tot_size = 0;
1381 goffset sel_size = 0;
1382 GList *scan;
1383
1384 if (window == NULL((void*)0))
1385 return;
1386
1387 if ((window->archive == NULL((void*)0)) || (window->archive->command == NULL((void*)0))) {
1388 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, window->priv->list_info_cid);
1389 return;
1390 }
1391
1392 if (window->priv->archive_present) {
1393 GPtrArray *files = fr_window_get_current_dir_list (window);
1394 guint i;
1395
1396 for (i = 0; i < files->len; i++) {
1397 FileData *fd = g_ptr_array_index (files, i)((files)->pdata)[i];
1398
1399 tot_n++;
1400 if (! file_data_is_dir (fd))
1401 tot_size += fd->size;
1402 else
1403 tot_size += fd->dir_size;
1404 }
1405 g_ptr_array_free (files, TRUE(!(0)));
1406 }
1407
1408 if (window->priv->archive_present) {
1409 GList *selection = get_selection_as_fd (window);
1410
1411 for (scan = selection; scan; scan = scan->next) {
1412 FileData *fd = scan->data;
1413
1414 sel_n++;
1415 if (! file_data_is_dir (fd))
1416 sel_size += fd->size;
1417 }
1418 g_list_free (selection);
1419 }
1420
1421 size_txt = g_format_size (tot_size);
1422 sel_size_txt = g_format_size (sel_size);
1423
1424 if (tot_n == 0)
1425 archive_info = g_strdup ("")g_strdup_inline ("");
1426 else
1427 archive_info = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa", "%lu object (%s)", "%lu objects (%s)", tot_n), tot_n, size_txt);
1428
1429 if (sel_n == 0)
1430 selected_info = g_strdup ("")g_strdup_inline ("");
1431 else
1432 selected_info = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa", "%lu object selected (%s)", "%lu objects selected (%s)", sel_n), sel_n, sel_size_txt);
1433
1434 info = g_strconcat (archive_info,
1435 ((sel_n == 0) ? NULL((void*)0) : ", "),
1436 selected_info,
1437 NULL((void*)0));
1438
1439 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, window->priv->list_info_cid, info);
1440
1441 g_free (size_txt);
1442 g_free (sel_size_txt);
1443 g_free (archive_info);
1444 g_free (selected_info);
1445 g_free (info);
1446}
1447
1448static void
1449fr_window_populate_file_list (FrWindow *window,
1450 GPtrArray *files)
1451{
1452 guint i;
1453
1454 gtk_list_store_clear (window->priv->list_store);
1455
1456 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
1457 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1),
1458 GTK_SORT_ASCENDING);
1459
1460 for (i = 0; i < files->len; i++) {
1461 FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i];
1462 GtkTreeIter iter;
1463 GdkPixbuf *icon, *emblem;
1464 char *utf8_name;
1465
1466 if (fdata->list_name == NULL((void*)0))
1467 continue;
1468
1469 gtk_list_store_append (window->priv->list_store, &iter);
1470
1471 icon = get_icon (fdata);
1472 utf8_name = g_filename_display_name (fdata->list_name);
1473 emblem = get_emblem (fdata);
1474
1475 if (file_data_is_dir (fdata)) {
1476 char *utf8_path;
1477 char *tmp;
1478 char *s_size;
1479 char *s_time;
1480
1481 if (fdata->list_dir)
1482 tmp = remove_ending_separator (fr_window_get_current_location (window));
1483
1484 else
1485 tmp = remove_level_from_path (fdata->path);
1486 utf8_path = g_filename_display_name (tmp);
1487 g_free (tmp);
1488
1489 s_size = g_format_size (fdata->dir_size);
1490
1491 if (fdata->list_dir) {
1492 s_time = g_strdup ("")g_strdup_inline ("");
1493 } else {
1494 GDateTime *date_time;
1495 date_time = g_date_time_new_from_unix_local (fdata->modified);
1496 s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M"));
1497 g_date_time_unref (date_time);
1498 }
1499
1500 gtk_list_store_set (window->priv->list_store, &iter,
1501 COLUMN_FILE_DATA, fdata,
1502 COLUMN_ICON, icon,
1503 COLUMN_NAME, utf8_name,
1504 COLUMN_EMBLEM, emblem,
1505 COLUMN_TYPE, _("Folder")gettext ("Folder"),
1506 COLUMN_SIZE, s_size,
1507 COLUMN_TIME, s_time,
1508 COLUMN_PATH, utf8_path,
1509 -1);
1510 g_free (utf8_path);
1511 g_free (s_size);
1512 g_free (s_time);
1513 }
1514 else {
1515 GDateTime *date_time;
1516 char *utf8_path;
1517 char *s_size;
1518 char *s_time;
1519 char *desc;
1520
1521 utf8_path = g_filename_display_name (fdata->path);
1522
1523 s_size = g_format_size (fdata->size);
1524 date_time = g_date_time_new_from_unix_local (fdata->modified);
1525 s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M"));
1526 g_date_time_unref (date_time);
1527 desc = g_content_type_get_description (fdata->content_type);
1528
1529 gtk_list_store_set (window->priv->list_store, &iter,
1530 COLUMN_FILE_DATA, fdata,
1531 COLUMN_ICON, icon,
1532 COLUMN_NAME, utf8_name,
1533 COLUMN_EMBLEM, emblem,
1534 COLUMN_TYPE, desc,
1535 COLUMN_SIZE, s_size,
1536 COLUMN_TIME, s_time,
1537 COLUMN_PATH, utf8_path,
1538 -1);
1539 g_free (utf8_path);
1540 g_free (s_size);
1541 g_free (s_time);
1542 g_free (desc);
1543 }
1544 g_free (utf8_name);
1545 if (icon != NULL((void*)0))
1546 g_object_unref (icon);
1547 if (emblem != NULL((void*)0))
1548 g_object_unref (emblem);
1549 }
1550
1551 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
1552 get_column_from_sort_method (window->priv->sort_method),
1553 window->priv->sort_type);
1554
1555 fr_window_update_statusbar_list_info (window);
1556 fr_window_stop_activity_mode (window);
1557}
1558
1559static int
1560path_compare (gconstpointer a,
1561 gconstpointer b)
1562{
1563 char *path_a = *((char**) a);
1564 char *path_b = *((char**) b);
1565
1566 return strcmp (path_a, path_b);
1567}
1568
1569static gboolean
1570get_tree_iter_from_path (FrWindow *window,
1571 const char *path,
1572 GtkTreeIter *parent,
1573 GtkTreeIter *iter)
1574{
1575 gboolean result = FALSE(0);
1576
1577 if (! gtk_tree_model_iter_children (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, iter, parent))
1578 return FALSE(0);
1579
1580 do {
1581 GtkTreeIter tmp;
1582 char *iter_path;
1583
1584 if (get_tree_iter_from_path (window, path, iter, &tmp)) {
1585 *iter = tmp;
1586 return TRUE(!(0));
1587 }
1588
1589 gtk_tree_model_get (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
,
1590 iter,
1591 TREE_COLUMN_PATH, &iter_path,
1592 -1);
1593
1594 if ((iter_path != NULL((void*)0)) && (strcmp (path, iter_path) == 0)) {
1595 result = TRUE(!(0));
1596 g_free (iter_path);
1597 break;
1598 }
1599 g_free (iter_path);
1600 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, iter));
1601
1602 return result;
1603}
1604
1605static void
1606set_sensitive (FrWindow *window,
1607 const char *id,
1608 gboolean sensitive)
1609{
1610 GtkWidget *widget;
1611
1612 widget = (GtkWidget *)gtk_builder_get_object (window->priv->ui_manager, id);
1613 g_object_set (widget, "sensitive", sensitive, NULL((void*)0));
1614}
1615
1616static void
1617fr_window_update_current_location (FrWindow *window)
1618{
1619 const char *current_dir = fr_window_get_current_location (window);
1620 char *path;
1621 GtkTreeIter iter;
1622
1623 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
1624 gtk_widget_hide (window->priv->location_bar);
1625 return;
1626 }
1627
1628 gtk_widget_show (window->priv->location_bar);
1629
1630 gtk_entry_set_text (GTK_ENTRY (window->priv->location_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_entry)), ((gtk_entry_get_type
()))))))
, window->priv->archive_present? current_dir: "");
1631
1632 set_sensitive (window, "tool_goback_item", window->priv->archive_present && (current_dir != NULL((void*)0)) && (window->priv->history_current != NULL((void*)0)) && (window->priv->history_current->next != NULL((void*)0)));
1633 set_sensitive (window, "tool_gonext_item", window->priv->archive_present && (current_dir != NULL((void*)0)) && (window->priv->history_current != NULL((void*)0)) && (window->priv->history_current->prev != NULL((void*)0)));
1634 set_sensitive (window, "tool_goup_item", window->priv->archive_present && (current_dir != NULL((void*)0)) && (strcmp (current_dir, "/") != 0));
1635 set_sensitive (window, "tool_gohome_item", window->priv->archive_present);
1636 gtk_widget_set_sensitive (window->priv->location_entry, window->priv->archive_present);
1637 gtk_widget_set_sensitive (window->priv->location_label, window->priv->archive_present);
1638 gtk_widget_set_sensitive (window->priv->filter_entry, window->priv->archive_present);
1639
1640#if 0
1641 fr_window_history_print (window);
1642#endif
1643
1644 path = remove_ending_separator (current_dir);
1645 if (get_tree_iter_from_path (window, path, NULL((void*)0), &iter)) {
1646 GtkTreeSelection *selection;
1647 GtkTreePath *t_path;
1648
1649 t_path = gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &iter);
1650 gtk_tree_view_expand_to_path (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
, t_path);
1651 gtk_tree_path_free (t_path);
1652
1653 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
1654 gtk_tree_selection_select_iter (selection, &iter);
1655 }
1656 g_free (path);
1657}
1658
1659static void
1660fr_window_update_dir_tree (FrWindow *window)
1661{
1662 GPtrArray *dirs;
1663 GHashTable *dir_cache;
1664 guint i;
1665 GdkPixbuf *icon;
1666
1667 gtk_tree_store_clear (window->priv->tree_store);
1668
1669 if (! window->priv->view_folders
1670 || ! window->priv->archive_present
1671 || (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT))
1672 {
1673 gtk_widget_set_sensitive (window->priv->tree_view, FALSE(0));
1674 gtk_widget_hide (window->priv->sidepane);
1675 return;
1676 }
1677 else {
1678 gtk_widget_set_sensitive (window->priv->tree_view, TRUE(!(0)));
1679 if (! gtk_widget_get_visible (window->priv->sidepane))
1680 gtk_widget_show_all (window->priv->sidepane);
1681 }
1682
1683 if (gtk_widget_get_realized (window->priv->tree_view))
1684 gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
, 0, 0);
1685
1686 /**/
1687
1688 dirs = g_ptr_array_sized_new (128);
1689
1690 dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), NULL((void*)0));
1691 for (i = 0; i < window->archive->command->files->len; i++) {
1692 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
1693 char *dir;
1694
1695 if (gtk_entry_get_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
) != NULL((void*)0)) {
1696 if (! file_data_respects_filter (window, fdata))
1697 continue;
1698 }
1699
1700 if (fdata->dir)
1701 dir = remove_ending_separator (fdata->full_path);
1702 else
1703 dir = remove_level_from_path (fdata->full_path);
1704
1705 while ((dir != NULL((void*)0)) && (strcmp (dir, "/") != 0)) {
1706 char *new_dir;
1707
1708 if (g_hash_table_lookup (dir_cache, dir) != NULL((void*)0))
1709 break;
1710
1711 new_dir = dir;
1712 g_ptr_array_add (dirs, new_dir);
1713 g_hash_table_replace (dir_cache, new_dir, "1");
1714
1715 dir = remove_level_from_path (new_dir);
1716 }
1717
1718 g_free (dir);
1719 }
1720 g_hash_table_destroy (dir_cache);
1721
1722 g_ptr_array_sort (dirs, path_compare);
1723 dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), (GDestroyNotify) gtk_tree_path_free);
1724
1725 /**/
1726
1727 icon = get_mime_type_icon (MIME_TYPE_ARCHIVE"application/x-archive");
1728 {
1729 GtkTreeIter node;
1730 char *uri;
1731 char *name;
1732
1733 uri = g_file_get_uri (window->archive->file);
1734 name = g_uri_display_basename (uri);
1735
1736 gtk_tree_store_append (window->priv->tree_store, &node, NULL((void*)0));
1737 gtk_tree_store_set (window->priv->tree_store, &node,
1738 TREE_COLUMN_ICON, icon,
1739 TREE_COLUMN_NAME, name,
1740 TREE_COLUMN_PATH, "/",
1741 TREE_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
1742 -1);
1743 g_hash_table_replace (dir_cache, "/", gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &node));
1744
1745 g_free (name);
1746 g_free (uri);
1747 }
1748 g_object_unref (icon);
1749
1750 /**/
1751
1752 icon = get_mime_type_icon (MIME_TYPE_DIRECTORY"folder");
1753 for (i = 0; i < dirs->len; i++) {
1754 char *dir = g_ptr_array_index (dirs, i)((dirs)->pdata)[i];
1755 char *parent_dir;
1756 GtkTreePath *parent_path;
1757 GtkTreeIter parent;
1758 GtkTreeIter node;
1759
1760 parent_dir = remove_level_from_path (dir);
1761 if (parent_dir == NULL((void*)0))
1762 continue;
1763
1764 parent_path = g_hash_table_lookup (dir_cache, parent_dir);
1765 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
,
1766 &parent,
1767 parent_path);
1768 gtk_tree_store_append (window->priv->tree_store, &node, &parent);
1769 gtk_tree_store_set (window->priv->tree_store, &node,
1770 TREE_COLUMN_ICON, icon,
1771 TREE_COLUMN_NAME, file_name_from_path (dir),
1772 TREE_COLUMN_PATH, dir,
1773 TREE_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
1774 -1);
1775 g_hash_table_replace (dir_cache, dir, gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &node));
1776
1777 g_free (parent_dir);
1778 }
1779 g_hash_table_destroy (dir_cache);
1780 if (icon != NULL((void*)0))
1781 g_object_unref (icon);
1782
1783 g_ptr_array_free (dirs, TRUE(!(0)));
1784
1785 fr_window_update_current_location (window);
1786}
1787
1788static void
1789fr_window_update_filter_bar_visibility (FrWindow *window)
1790{
1791 const char *filter;
1792
1793 filter = gtk_entry_get_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
);
1794 if ((filter == NULL((void*)0)) || (*filter == '\0'))
1795 gtk_widget_hide (window->priv->filter_bar);
1796 else
1797 gtk_widget_show (window->priv->filter_bar);
1798}
1799
1800static void
1801fr_window_update_file_list (FrWindow *window,
1802 gboolean update_view)
1803{
1804 GPtrArray *files;
1805 gboolean free_files = FALSE(0);
1806
1807 if (gtk_widget_get_realized (window->priv->list_view))
1808 gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
, 0, 0);
1809
1810 if (! window->priv->archive_present || window->priv->archive_new) {
1811 if (update_view)
1812 gtk_list_store_clear (window->priv->list_store);
1813
1814 window->priv->current_view_length = 0;
1815
1816 if (window->priv->archive_new) {
1817 gtk_widget_set_sensitive (window->priv->list_view, TRUE(!(0)));
1818 gtk_widget_show_all (gtk_widget_get_parent (window->priv->list_view));
1819 }
1820 else {
1821 gtk_widget_set_sensitive (window->priv->list_view, FALSE(0));
1822 gtk_widget_hide (gtk_widget_get_parent (window->priv->list_view));
1823 }
1824
1825 return;
1826 }
1827 else {
1828 gtk_widget_set_sensitive (window->priv->list_view, TRUE(!(0)));
1829 gtk_widget_show_all (gtk_widget_get_parent (window->priv->list_view));
1830 }
1831
1832 if (window->priv->give_focus_to_the_list) {
1833 gtk_widget_grab_focus (window->priv->list_view);
1834 window->priv->give_focus_to_the_list = FALSE(0);
1835 }
1836
1837 /**/
1838
1839 fr_window_start_activity_mode (window);
1840
1841 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
1842 fr_window_compute_list_names (window, window->archive->command->files);
1843 files = window->archive->command->files;
1844 free_files = FALSE(0);
1845 }
1846 else {
1847 char *current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
1848
1849 while (! fr_window_dir_exists_in_archive (window, current_dir)) {
1850 char *tmp;
1851
1852 fr_window_history_pop (window);
1853
1854 tmp = get_parent_dir (current_dir);
1855 g_free (current_dir);
1856 current_dir = tmp;
1857
1858 fr_window_history_add (window, current_dir);
1859 }
1860 g_free (current_dir);
1861
1862 fr_window_compute_list_names (window, window->archive->command->files);
1863 files = fr_window_get_current_dir_list (window);
1864 free_files = TRUE(!(0));
1865 }
1866
1867 if (files != NULL((void*)0))
1868 window->priv->current_view_length = files->len;
1869 else
1870 window->priv->current_view_length = 0;
1871
1872 if (update_view)
1873 fr_window_populate_file_list (window, files);
1874
1875 if (free_files)
1876 g_ptr_array_free (files, TRUE(!(0)));
1877}
1878
1879void
1880fr_window_update_list_order (FrWindow *window)
1881{
1882 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
, get_column_from_sort_method (window->priv->sort_method), window->priv->sort_type);
1883}
1884
1885static void
1886fr_window_update_title (FrWindow *window)
1887{
1888 if (! window->priv->archive_present)
1889 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, _("Archive Manager")gettext ("Archive Manager"));
1890 else {
1891 char *title;
1892 char *name;
1893
1894 name = g_uri_display_basename (fr_window_get_archive_uri (window));
1895 title = g_strdup_printf ("%s %s",
1896 name,
1897 window->archive->read_only ? _("[read only]")gettext ("[read only]") : "");
1898
1899 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, title);
1900 g_free (title);
1901 g_free (name);
1902 }
1903}
1904
1905static void
1906check_whether_has_a_dir (GtkTreeModel *model,
1907 GtkTreePath *path,
1908 GtkTreeIter *iter,
1909 gpointer data)
1910{
1911 gboolean *has_a_dir = data;
1912 FileData *fdata;
1913
1914 gtk_tree_model_get (model, iter,
1915 COLUMN_FILE_DATA, &fdata,
1916 -1);
1917 if (file_data_is_dir (fdata))
1918 *has_a_dir = TRUE(!(0));
1919}
1920
1921static gboolean
1922selection_has_a_dir (FrWindow *window)
1923{
1924 GtkTreeSelection *selection;
1925 gboolean has_a_dir = FALSE(0);
1926
1927 if (! gtk_widget_get_realized (window->priv->list_view))
1928 return FALSE(0);
1929
1930 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
1931 if (selection == NULL((void*)0))
1932 return FALSE(0);
1933
1934 gtk_tree_selection_selected_foreach (selection,
1935 check_whether_has_a_dir,
1936 &has_a_dir);
1937
1938 return has_a_dir;
1939}
1940
1941static void
1942set_active (FrWindow *window,
1943 const char *action_name,
1944 gboolean is_active)
1945{
1946 GAction *action;
1947
1948 action = g_action_map_lookup_action (G_ACTION_MAP (window->priv->actions)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->actions)), ((g_action_map_get_type (
)))))))
, action_name);
1949 g_simple_action_set_state (G_SIMPLE_ACTION (action)((((GSimpleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((g_simple_action_get_type ()))))))
, g_variant_new_boolean (is_active));
1950}
1951
1952static void
1953fr_window_update_paste_command_sensitivity (FrWindow *window,
1954 GtkClipboard *clipboard)
1955{
1956 gboolean running;
1957 gboolean no_archive;
1958 gboolean ro;
1959 gboolean compr_file;
1960
1961 if (window->priv->closing)
1962 return;
1963
1964 if (clipboard == NULL((void*)0))
1965 clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
1966 running = window->priv->activity_ref > 0;
1967 no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present;
1968 ro = ! no_archive && window->archive->read_only;
1969 compr_file = ! no_archive && window->archive->is_compressed_file;
1970
1971 set_sensitive (window, "paste_item", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && gtk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
));
1972 set_sensitive (window, "popup_paste_item", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && gtk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
));
1973 set_sensitive (window, "popup_paste_item1", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && gtk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
));
1974}
1975
1976static void
1977fr_window_update_sensitivity (FrWindow *window)
1978{
1979 gboolean no_archive;
1980 gboolean ro;
1981 gboolean file_op;
1982 gboolean running;
1983 gboolean compr_file;
1984 gboolean sel_not_null;
1985 gboolean one_file_selected;
1986 gboolean dir_selected;
1987 int n_selected;
1988
1989 if (window->priv->batch_mode)
1990 return;
1991
1992 running = window->priv->activity_ref > 0;
1993 no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present;
1994 ro = ! no_archive && window->archive->read_only;
1995 file_op = ! no_archive && ! window->priv->archive_new && ! running;
1996 compr_file = ! no_archive && window->archive->is_compressed_file;
1997 n_selected = fr_window_get_n_selected_files (window);
1998 sel_not_null = n_selected > 0;
1999 one_file_selected = n_selected == 1;
2000 dir_selected = selection_has_a_dir (window);
2001
2002 set_sensitive (window, "add_files_item", ! no_archive && ! ro && ! running && ! compr_file);
2003 set_sensitive (window, "tool_add_files_item", ! no_archive && ! ro && ! running && ! compr_file);
2004 set_sensitive (window, "add_folder_item", ! no_archive && ! ro && ! running && ! compr_file);
2005 set_sensitive (window, "tool_add_folder_item", ! no_archive && ! ro && ! running && ! compr_file);
2006 set_sensitive (window, "copy_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2007 set_sensitive (window, "popup_copy_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2008 set_sensitive (window, "popup_copy_item1", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2009 set_sensitive (window, "cut_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2010 set_sensitive (window, "popup_cut_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2011 set_sensitive (window, "popup_cut_item1", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2012 set_sensitive (window, "delete_item", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file);
2013 set_sensitive (window, "popup_delete_item", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file);
2014 set_sensitive (window, "popup_delete_item1", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file);
2015 set_sensitive (window, "deselect_all_item", ! no_archive && sel_not_null);
2016 set_sensitive (window, "extract_item", file_op);
2017 set_sensitive (window, "tool_extract_item", file_op);
2018 set_sensitive (window, "find_item", ! no_archive);
2019 set_sensitive (window, "last_output_item", ((window->archive != NULL((void*)0))
2020 && (window->archive->process != NULL((void*)0))
2021 && (window->archive->process->out.raw != NULL((void*)0))));
2022 set_sensitive (window, "new_item", ! running);
2023 set_sensitive (window, "tool_new_item", ! running);
2024 set_sensitive (window, "open_item", ! running);
2025 set_sensitive (window, "popup_open_select_item", file_op && sel_not_null && ! dir_selected);
2026 set_sensitive (window, "popup_open_item1", file_op && one_file_selected && dir_selected);
2027 set_sensitive (window, "password_item", ! running && (window->priv->asked_for_password || (! no_archive && window->archive->command->propPassword)));
2028 set_sensitive (window, "properties_item", file_op);
2029 set_sensitive (window, "close_item", !running || window->priv->stoppable);
2030 set_sensitive (window, "reload_item", ! (no_archive || running));
2031 set_sensitive (window, "rename_item", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected);
2032 set_sensitive (window, "popup_rename_item", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected);
2033 set_sensitive (window, "popup_rename_item1", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected);
2034 set_sensitive (window, "open_saveas_item", ! no_archive && ! compr_file && ! running);
2035 set_sensitive (window, "select_all_item", ! no_archive);
2036 set_sensitive (window, "stop_item", running && window->priv->stoppable);
2037 set_sensitive (window, "tool_stop_item", running && window->priv->stoppable);
2038 set_sensitive (window, "test_integrity_item", ! no_archive && ! running && window->archive->command->propTest);
2039 set_sensitive (window, "popup_open_item", file_op && one_file_selected && ! dir_selected);
2040
2041 if (window->priv->progress_dialog != NULL((void*)0))
2042 gtk_dialog_set_response_sensitive (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
,
2043 GTK_RESPONSE_OK,
2044 running && window->priv->stoppable);
2045
2046 fr_window_update_paste_command_sensitivity (window, NULL((void*)0));
2047
2048 set_sensitive (window, "select_all_item", (window->priv->current_view_length > 0) && (window->priv->current_view_length != n_selected));
2049 set_sensitive (window, "deselect_all_item", n_selected > 0);
2050 set_sensitive (window, "open_recent_item", ! running);
2051 set_sensitive (window, "tool_open_recent_item", ! running);
2052
2053 set_sensitive (window, "view_folder_item", (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR));
2054
2055 set_sensitive (window, "view_all_files_item", ! window->priv->filter_mode);
2056 set_sensitive (window, "view_as_folder_item", ! window->priv->filter_mode);
2057}
2058
2059static gboolean
2060location_entry_key_press_event_cb (GtkWidget *widget,
2061 GdkEventKey *event,
2062 FrWindow *window)
2063{
2064 if ((event->keyval == GDK_KEY_Return0xff0d)
2065 || (event->keyval == GDK_KEY_KP_Enter0xff8d)
2066 || (event->keyval == GDK_KEY_ISO_Enter0xfe34))
2067 {
2068 fr_window_go_to_location (window, gtk_entry_get_text (GTK_ENTRY (window->priv->location_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_entry)), ((gtk_entry_get_type
()))))))
), FALSE(0));
2069 }
2070
2071 return FALSE(0);
2072}
2073
2074static gboolean
2075real_close_progress_dialog (gpointer data)
2076{
2077 FrWindow *window = data;
2078
2079 if (window->priv->hide_progress_timeout != 0) {
2080 g_source_remove (window->priv->hide_progress_timeout);
2081 window->priv->hide_progress_timeout = 0;
2082 }
2083
2084 if (window->priv->progress_dialog != NULL((void*)0))
2085 gtk_widget_hide (window->priv->progress_dialog);
2086
2087 return FALSE(0);
2088}
2089
2090static void close_suspend_process(FrWindow *window)
2091{
2092 if (window->archive->process != NULL((void*)0))
2093 {
2094 start_close_suspend_process(window->archive->process);
2095 }
2096}
2097static void
2098close_progress_dialog (FrWindow *window,
2099 gboolean close_now)
2100{
2101 if (window->priv->progress_timeout != 0) {
2102 g_source_remove (window->priv->progress_timeout);
2103 window->priv->progress_timeout = 0;
2104 }
2105
2106 if (! window->priv->batch_mode && gtk_widget_get_mapped (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2107 gtk_widget_hide (window->priv->progress_bar);
2108
2109 if (window->priv->progress_dialog == NULL((void*)0))
2110 return;
2111
2112 if (close_now) {
2113 if (window->priv->hide_progress_timeout != 0) {
2114 g_source_remove (window->priv->hide_progress_timeout);
2115 window->priv->hide_progress_timeout = 0;
2116 }
2117 real_close_progress_dialog (window);
2118 }
2119 else {
2120 if (window->priv->hide_progress_timeout != 0)
2121 return;
2122 window->priv->hide_progress_timeout = g_timeout_add (HIDE_PROGRESS_TIMEOUT_MSECS500,
2123 real_close_progress_dialog,
2124 window);
2125 }
2126 close_suspend_process(window);
2127}
2128
2129static gboolean
2130progress_dialog_delete_event (GtkWidget *caller,
2131 GdkEvent *event,
2132 FrWindow *window)
2133{
2134 if (window->priv->stoppable) {
2135 activate_action_stop (NULL((void*)0), NULL((void*)0), window);
2136 close_progress_dialog (window, TRUE(!(0)));
2137 }
2138
2139 return TRUE(!(0));
2140}
2141
2142static void
2143open_folder (GtkWindow *parent,
2144 const char *folder)
2145{
2146 GError *error = NULL((void*)0);
2147
2148 if (folder == NULL((void*)0))
2149 return;
2150
2151 if (! gtk_show_uri_on_window (parent, folder, GDK_CURRENT_TIME0L, &error)) {
2152 GtkWidget *d;
2153 char *utf8_name;
2154 char *message;
2155
2156 utf8_name = g_filename_display_name (folder);
2157 message = g_strdup_printf (_("Could not display the folder \"%s\"")gettext ("Could not display the folder \"%s\""), utf8_name);
2158 g_free (utf8_name);
2159
2160 d = _gtk_error_dialog_new (parent,
2161 GTK_DIALOG_MODAL,
2162 NULL((void*)0),
2163 message,
2164 "%s",
2165 error->message);
2166 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
2167 gtk_widget_destroy (d);
2168
2169 g_free (message);
2170 g_clear_error (&error);
2171 }
2172}
2173
2174static void
2175fr_window_view_extraction_destination_folder (FrWindow *window)
2176{
2177 open_folder (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, fr_archive_get_last_extraction_destination (window->archive));
2178}
2179
2180static void change_button_label (FrWindow *window,
2181 GtkWidget *button)
2182{
2183 const gchar *state;
2184 state = gtk_button_get_label (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
);
2185
2186 if (g_strrstr (_("_Pause")gettext ("_Pause"), state) != NULL((void*)0))
2187 {
2188 gtk_widget_set_visible (window->priv->pd_progress_bar, FALSE(0));
2189 fr_command_message (window->archive->command, _("Process paused")gettext ("Process paused"));
2190
2191 gtk_button_set_label (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, _("_Resume")gettext ("_Resume"));
2192 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
2193 gtk_image_new_from_icon_name ("media-playback-start",
2194 GTK_ICON_SIZE_BUTTON));
2195 }
2196 else
2197 {
2198 gtk_widget_set_visible (window->priv->pd_progress_bar, TRUE(!(0)));
2199 fr_command_message (window->archive->command, _("Please wait…")gettext ("Please wait…"));
2200
2201 gtk_button_set_label (GTK_BUTTON(button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, _("_Pause")gettext ("_Pause"));
2202 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
2203 gtk_image_new_from_icon_name ("media-playback-pause",
2204 GTK_ICON_SIZE_BUTTON));
2205 }
2206}
2207
2208static void
2209fr_state_switch (FrWindow *window)
2210{
2211 if ((window->archive->process != NULL((void*)0)) &&
2212 ((start_switch_state (window->archive->process) == 0))) {
2213 change_button_label (window, window->priv->pd_state_button);
2214 }
2215}
2216
2217static void
2218progress_dialog_response (GtkDialog *dialog,
2219 int response_id,
2220 FrWindow *window)
2221{
2222 GtkWidget *new_window;
2223
2224 switch (response_id) {
2225 case GTK_RESPONSE_CANCEL:
2226 if (window->priv->stoppable) {
2227 activate_action_stop (NULL((void*)0), NULL((void*)0), window);
2228 close_progress_dialog (window, TRUE(!(0)));
2229 }
2230 break;
2231 case GTK_RESPONSE_CLOSE:
2232 close_progress_dialog (window, TRUE(!(0)));
2233 break;
2234 case DIALOG_RESPONSE_OPEN_ARCHIVE:
2235 new_window = fr_window_new ();
2236 gtk_widget_show (new_window);
2237 fr_window_archive_open (FR_WINDOW (new_window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((fr_window_get_type ()))))))
, window->priv->convert_data.new_file, GTK_WINDOW (new_window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((gtk_window_get_type ()))))))
);
2238 close_progress_dialog (window, TRUE(!(0)));
2239 break;
2240 case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER:
2241 fr_window_view_extraction_destination_folder (window);
2242 close_progress_dialog (window, TRUE(!(0)));
2243 break;
2244 case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT:
2245 fr_window_view_extraction_destination_folder (window);
2246 close_progress_dialog (window, TRUE(!(0)));
2247 fr_window_close (window);
2248 break;
2249 case DIALOG_RESPONSE_QUIT:
2250 fr_window_close (window);
2251 break;
2252 case GTK_RESPONSE_ACCEPT:
2253 fr_state_switch (window);
2254 break;
2255 default:
2256 break;
2257 }
2258}
2259
2260static char*
2261get_action_description (FrAction action,
2262 const char *uri)
2263{
2264 char *basename;
2265 char *message;
2266
2267 basename = (uri != NULL((void*)0)) ? g_uri_display_basename (uri) : NULL((void*)0);
2268
2269 message = NULL((void*)0);
2270 switch (action) {
2271 case FR_ACTION_CREATING_NEW_ARCHIVE:
2272 /* Translators: %s is a filename */
2273 message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename);
2274 break;
2275 case FR_ACTION_LOADING_ARCHIVE:
2276 /* Translators: %s is a filename */
2277 message = g_strdup_printf (_("Loading \"%s\"")gettext ("Loading \"%s\""), basename);
2278 break;
2279 case FR_ACTION_LISTING_CONTENT:
2280 /* Translators: %s is a filename */
2281 message = g_strdup_printf (_("Reading \"%s\"")gettext ("Reading \"%s\""), basename);
2282 break;
2283 case FR_ACTION_DELETING_FILES:
2284 /* Translators: %s is a filename */
2285 message = g_strdup_printf (_("Deleting files from \"%s\"")gettext ("Deleting files from \"%s\""), basename);
2286 break;
2287 case FR_ACTION_TESTING_ARCHIVE:
2288 /* Translators: %s is a filename */
2289 message = g_strdup_printf (_("Testing \"%s\"")gettext ("Testing \"%s\""), basename);
2290 break;
2291 case FR_ACTION_GETTING_FILE_LIST:
2292 message = g_strdup (_("Getting the file list"))g_strdup_inline (gettext ("Getting the file list"));
2293 break;
2294 case FR_ACTION_COPYING_FILES_FROM_REMOTE:
2295 /* Translators: %s is a filename */
2296 message = g_strdup_printf (_("Copying the files to add to \"%s\"")gettext ("Copying the files to add to \"%s\""), basename);
2297 break;
2298 case FR_ACTION_ADDING_FILES:
2299 /* Translators: %s is a filename */
2300 message = g_strdup_printf (_("Adding files to \"%s\"")gettext ("Adding files to \"%s\""), basename);
2301 break;
2302 case FR_ACTION_EXTRACTING_FILES:
2303 /* Translators: %s is a filename */
2304 message = g_strdup_printf (_("Extracting files from \"%s\"")gettext ("Extracting files from \"%s\""), basename);
2305 break;
2306 case FR_ACTION_COPYING_FILES_TO_REMOTE:
2307 message = g_strdup (_("Copying the extracted files to the destination"))g_strdup_inline (gettext ("Copying the extracted files to the destination"
))
;
2308 break;
2309 case FR_ACTION_CREATING_ARCHIVE:
2310 /* Translators: %s is a filename */
2311 message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename);
2312 break;
2313 case FR_ACTION_SAVING_REMOTE_ARCHIVE:
2314 /* Translators: %s is a filename */
2315 message = g_strdup_printf (_("Saving \"%s\"")gettext ("Saving \"%s\""), basename);
2316 break;
2317 case FR_ACTION_NONE:
2318 break;
2319 }
2320 g_free (basename);
2321
2322 return message;
2323}
2324
2325static void
2326progress_dialog_update_action_description (FrWindow *window)
2327{
2328 const char *current_archive;
2329 char *description;
2330 char *description_markup;
2331
2332 if (window->priv->progress_dialog == NULL((void*)0))
2333 return;
2334
2335 if (window->priv->convert_data.converting)
2336 current_archive = window->priv->convert_data.new_file;
2337 else if (window->priv->working_archive != NULL((void*)0))
2338 current_archive = window->priv->working_archive;
2339 else
2340 current_archive = window->priv->archive_uri;
2341
2342 g_free (window->priv->pd_last_archive);
2343 window->priv->pd_last_archive = NULL((void*)0);
2344 if (current_archive != NULL((void*)0))
2345 window->priv->pd_last_archive = g_strdup (current_archive)g_strdup_inline (current_archive);
2346
2347 description = get_action_description (window->priv->action, window->priv->pd_last_archive);
2348 description_markup = g_markup_printf_escaped ("<span weight=\"bold\" size=\"larger\">%s</span>", description);
2349 gtk_label_set_markup (GTK_LABEL (window->priv->pd_action)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_action)), ((gtk_label_get_type ()
))))))
, description_markup);
2350
2351 g_free (description_markup);
2352 g_free (description);
2353}
2354
2355static gboolean
2356fr_window_working_archive_cb (FrCommand *command,
2357 const char *archive_filename,
2358 FrWindow *window)
2359{
2360 g_free (window->priv->working_archive);
2361 if (archive_filename != NULL((void*)0))
2362 window->priv->working_archive = g_strdup (archive_filename)g_strdup_inline (archive_filename);
2363 else
2364 window->priv->working_archive = NULL((void*)0);
2365 progress_dialog_update_action_description (window);
2366
2367 return TRUE(!(0));
2368}
2369
2370static gboolean
2371fr_window_message_cb (FrCommand *command,
2372 const char *msg,
2373 FrWindow *window)
2374{
2375 if (window->priv->pd_last_message != msg) {
2376 g_free (window->priv->pd_last_message);
2377 window->priv->pd_last_message = g_strdup (msg)g_strdup_inline (msg);
2378 }
2379
2380 if (window->priv->progress_dialog == NULL((void*)0))
2381 return TRUE(!(0));
2382
2383 if (msg != NULL((void*)0)) {
2384 while (*msg == ' ')
2385 msg++;
2386 if (*msg == 0)
2387 msg = NULL((void*)0);
2388 }
2389
2390 if (msg != NULL((void*)0)) {
2391 char *utf8_msg;
2392
2393 if (! g_utf8_validate (msg, -1, NULL((void*)0)))
2394 utf8_msg = g_locale_to_utf8 (msg, -1 , 0, 0, 0);
2395 else
2396 utf8_msg = g_strdup (msg)g_strdup_inline (msg);
2397 if (utf8_msg == NULL((void*)0))
2398 return TRUE(!(0));
2399
2400 if (g_utf8_validate (utf8_msg, -1, NULL((void*)0)))
2401 gtk_label_set_text (GTK_LABEL (window->priv->pd_message)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_message)), ((gtk_label_get_type (
)))))))
, utf8_msg);
2402
2403 g_free (window->priv->pd_last_message);
2404 window->priv->pd_last_message = g_strdup (utf8_msg)g_strdup_inline (utf8_msg);
2405
2406 g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
,
2407 fr_window_signals[PROGRESS],
2408 0,
2409 window->priv->pd_last_fraction,
2410 window->priv->pd_last_message);
2411
2412#ifdef LOG_PROGRESS
2413 g_print ("message > %s\n", utf8_msg);
2414#endif
2415
2416 g_free (utf8_msg);
2417 }
2418 else
2419 gtk_label_set_text (GTK_LABEL (window->priv->pd_message)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_message)), ((gtk_label_get_type (
)))))))
, "");
2420
2421 progress_dialog_update_action_description (window);
2422
2423 return TRUE(!(0));
2424}
2425
2426static GtkWidget*
2427dialog_add_button_with_icon_name (GtkDialog *dialog,
2428 const gchar *button_text,
2429 const gchar *icon_name,
2430 gint response_id)
2431{
2432 GtkWidget *button;
2433
2434 button = gtk_button_new_with_mnemonic (button_text);
2435 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
2436
2437 gtk_button_set_use_underline (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, TRUE(!(0)));
2438 gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
2439 gtk_widget_set_can_default (button, TRUE(!(0)));
2440 gtk_widget_show (button);
2441 gtk_dialog_add_action_widget (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, button, response_id);
2442
2443 return button;
2444}
2445
2446static void
2447create_the_progress_dialog (FrWindow *window)
2448{
2449 GtkWindow *parent;
2450 GtkDialogFlags flags;
2451 GtkDialog *d;
2452 GtkWidget *hbox;
2453 GtkWidget *vbox;
2454 GtkWidget *progress_vbox;
2455 GtkWidget *lbl;
2456 PangoAttrList *attr_list;
2457 GdkPixbuf *icon;
2458
2459 if (window->priv->progress_dialog != NULL((void*)0))
2460 return;
2461
2462 flags = GTK_DIALOG_DESTROY_WITH_PARENT;
2463 if (window->priv->batch_mode) {
2464 parent = NULL((void*)0);
2465 }
2466 else {
2467 parent = GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
;
2468 flags |= GTK_DIALOG_MODAL;
2469 }
2470
2471 window->priv->progress_dialog = gtk_dialog_new_with_buttons ((window->priv->batch_mode ? window->priv->batch_title : NULL((void*)0)),
2472 parent,
2473 flags,
2474 NULL((void*)0),
2475 NULL((void*)0));
2476
2477 window->priv->pd_quit_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Quit")gettext ("_Quit"), "application-exit", DIALOG_RESPONSE_QUIT);
2478 window->priv->pd_open_archive_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Open the Archive")gettext ("_Open the Archive"), DIALOG_RESPONSE_OPEN_ARCHIVE);
2479 window->priv->pd_open_destination_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Show the Files")gettext ("_Show the Files"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER);
2480 window->priv->pd_open_destination_and_quit_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("Show the _Files and Quit")gettext ("Show the _Files and Quit"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT);
2481 window->priv->pd_close_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Close")gettext ("_Close"), "window-close", GTK_RESPONSE_CLOSE);
2482 window->priv->pd_cancel_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Cancel")gettext ("_Cancel"), "process-stop", GTK_RESPONSE_CANCEL);
2483 /*add start button default suspend*/
2484 window->priv->pd_state_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Pause")gettext ("_Pause"), "media-playback-pause", GTK_RESPONSE_ACCEPT);
2485 d = GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
;
2486 gtk_window_set_resizable (GTK_WINDOW (d)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2487 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
2488 gtk_window_set_default_size (GTK_WINDOW (d)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_window_get_type ()))))))
, PROGRESS_DIALOG_DEFAULT_WIDTH500, -1);
2489
2490 /* Main */
2491
2492 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 24);
2493 gtk_container_set_border_width (GTK_CONTAINER (hbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_container_get_type ()))))))
, 6);
2494 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (d))), ((gtk_box_get_type ()
))))))
, hbox, FALSE(0), FALSE(0), 10);
2495
2496 icon = get_mime_type_pixbuf ("package-x-generic", _gtk_widget_lookup_for_size (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, GTK_ICON_SIZE_DIALOG), NULL((void*)0));
2497 window->priv->pd_icon = gtk_image_new_from_pixbuf (icon);
2498 g_object_unref (icon);
2499
2500 gtk_widget_set_valign (window->priv->pd_icon, GTK_ALIGN_START);
2501 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, window->priv->pd_icon, FALSE(0), FALSE(0), 0);
2502
2503 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
2504 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, vbox, TRUE(!(0)), TRUE(!(0)), 0);
2505
2506 /* action description */
2507
2508 lbl = window->priv->pd_action = gtk_label_new ("");
2509 gtk_widget_set_halign (lbl, GTK_ALIGN_START);
2510 gtk_widget_set_valign (lbl, GTK_ALIGN_START);
2511 gtk_widget_set_hexpand (lbl, TRUE(!(0)));
2512 gtk_widget_set_vexpand (lbl, TRUE(!(0)));
2513 gtk_widget_set_margin_bottom (lbl, 12);
2514
2515 gtk_label_set_xalign (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, 0.0);
2516 gtk_label_set_ellipsize (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, PANGO_ELLIPSIZE_END);
2517 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, lbl, TRUE(!(0)), TRUE(!(0)), 0);
2518
2519 /* archive name */
2520
2521 g_free (window->priv->pd_last_archive);
2522 window->priv->pd_last_archive = NULL((void*)0);
2523
2524 if (window->priv->archive_uri != NULL((void*)0))
2525 window->priv->pd_last_archive = g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri);
2526
2527 /* progress and details */
2528
2529 progress_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2530 gtk_widget_set_valign (progress_vbox, GTK_ALIGN_START);
2531 gtk_widget_set_hexpand (progress_vbox, TRUE(!(0)));
2532 gtk_widget_set_vexpand (progress_vbox, TRUE(!(0)));
2533 gtk_widget_set_margin_bottom (progress_vbox, 6);
2534 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, progress_vbox, TRUE(!(0)), TRUE(!(0)), 0);
2535
2536 /* progress bar */
2537
2538 window->priv->pd_progress_bar = gtk_progress_bar_new ();
2539 gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
, ACTIVITY_PULSE_STEP(0.033));
2540 gtk_box_pack_start (GTK_BOX (progress_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((progress_vbox)), ((gtk_box_get_type ()))))))
, window->priv->pd_progress_bar, TRUE(!(0)), TRUE(!(0)), 0);
2541
2542 /* details label */
2543
2544 lbl = window->priv->pd_message = gtk_label_new ("");
2545
2546 attr_list = pango_attr_list_new ();
2547 pango_attr_list_insert (attr_list, pango_attr_size_new (9000));
2548 gtk_label_set_attributes (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, attr_list);
2549 pango_attr_list_unref (attr_list);
2550
2551 gtk_label_set_xalign (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, 0.0);
2552 gtk_label_set_ellipsize (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, PANGO_ELLIPSIZE_END);
2553 gtk_box_pack_start (GTK_BOX (progress_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((progress_vbox)), ((gtk_box_get_type ()))))))
, lbl, TRUE(!(0)), TRUE(!(0)), 0);
2554
2555 gtk_widget_show_all (hbox);
2556
2557 progress_dialog_update_action_description (window);
2558
2559 /* signals */
2560
2561 g_signal_connect (G_OBJECT (window->priv->progress_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
2562 "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
2563 G_CALLBACK (progress_dialog_response),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
2564 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
;
2565 g_signal_connect (G_OBJECT (window->priv->progress_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
2566 "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
2567 G_CALLBACK (progress_dialog_delete_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
2568 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
;
2569}
2570
2571static gboolean
2572display_progress_dialog (gpointer data)
2573{
2574 FrWindow *window = data;
2575
2576 if (window->priv->progress_timeout != 0)
2577 g_source_remove (window->priv->progress_timeout);
2578
2579 if (window->priv->use_progress_dialog && (window->priv->progress_dialog != NULL((void*)0))) {
2580 gtk_dialog_set_response_sensitive (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
,
2581 GTK_RESPONSE_OK,
2582 window->priv->stoppable);
2583 if (! window->priv->non_interactive)
2584 gtk_widget_show (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2585 gtk_widget_hide (window->priv->progress_bar);
2586 gtk_widget_show (window->priv->progress_dialog);
2587 fr_window_message_cb (NULL((void*)0), window->priv->pd_last_message, window);
2588 }
2589
2590 window->priv->progress_timeout = 0;
2591
2592 return FALSE(0);
2593}
2594
2595static void
2596open_progress_dialog (FrWindow *window,
2597 gboolean open_now)
2598{
2599 if (window->priv->hide_progress_timeout != 0) {
2600 g_source_remove (window->priv->hide_progress_timeout);
2601 window->priv->hide_progress_timeout = 0;
2602 }
2603
2604 if (open_now) {
2605 if (window->priv->progress_timeout != 0)
2606 g_source_remove (window->priv->progress_timeout);
2607 window->priv->progress_timeout = 0;
2608 }
2609
2610 if ((window->priv->progress_timeout != 0)
2611 || ((window->priv->progress_dialog != NULL((void*)0)) && gtk_widget_get_visible (window->priv->progress_dialog)))
2612 return;
2613
2614 if (! window->priv->batch_mode && ! open_now)
2615 gtk_widget_show (window->priv->progress_bar);
2616
2617 create_the_progress_dialog (window);
2618 gtk_widget_show (window->priv->pd_cancel_button);
2619 gtk_widget_show (window->priv->pd_state_button);
2620 gtk_widget_hide (window->priv->pd_open_archive_button);
2621 gtk_widget_hide (window->priv->pd_open_destination_button);
2622 gtk_widget_hide (window->priv->pd_open_destination_and_quit_button);
2623 gtk_widget_hide (window->priv->pd_quit_button);
2624 gtk_widget_hide (window->priv->pd_close_button);
2625
2626 if (open_now)
2627 display_progress_dialog (window);
2628 else
2629 window->priv->progress_timeout = g_timeout_add (PROGRESS_TIMEOUT_MSECS5000,
2630 display_progress_dialog,
2631 window);
2632}
2633
2634static gboolean
2635fr_window_progress_cb (FrArchive *archive,
2636 double fraction,
2637 FrWindow *window)
2638{
2639 window->priv->progress_pulse = (fraction < 0.0);
2640 if (! window->priv->progress_pulse) {
2641 fraction = CLAMP (fraction, 0.0, 1.0)(((fraction) > (1.0)) ? (1.0) : (((fraction) < (0.0)) ?
(0.0) : (fraction)))
;
2642 if (window->priv->progress_dialog != NULL((void*)0))
2643 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
, fraction);
2644 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
, fraction);
2645
2646 if ((archive != NULL((void*)0)) && (archive->command != NULL((void*)0)) && (archive->command->n_files > 0)) {
2647 char *message = NULL((void*)0);
2648 gulong remaining_files;
2649
2650 remaining_files = (gulong) (archive->command->n_files - archive->command->n_file + 1);
2651
2652 switch (window->priv->action) {
2653 case FR_ACTION_ADDING_FILES:
2654 case FR_ACTION_EXTRACTING_FILES:
2655 case FR_ACTION_DELETING_FILES:
2656 message = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa",
2657 "%lu file remaining",
2658 "%lu files remaining",
2659 remaining_files),
2660 remaining_files);
2661 break;
2662 default:
2663 break;
2664 }
2665
2666 if (message != NULL((void*)0))
2667 fr_command_message (archive->command, message);
2668 }
2669
2670 window->priv->pd_last_fraction = fraction;
2671
2672 g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
,
2673 fr_window_signals[PROGRESS],
2674 0,
2675 window->priv->pd_last_fraction,
2676 window->priv->pd_last_message);
2677
2678#ifdef LOG_PROGRESS
2679 g_print ("progress > %2.2f\n", fraction);
2680#endif
2681 }
2682 return TRUE(!(0));
2683}
2684
2685static void
2686open_progress_dialog_with_open_destination (FrWindow *window)
2687{
2688 window->priv->ask_to_open_destination_after_extraction = FALSE(0);
2689
2690 if (window->priv->hide_progress_timeout != 0) {
2691 g_source_remove (window->priv->hide_progress_timeout);
2692 window->priv->hide_progress_timeout = 0;
2693 }
2694 if (window->priv->progress_timeout != 0) {
2695 g_source_remove (window->priv->progress_timeout);
2696 window->priv->progress_timeout = 0;
2697 }
2698
2699 create_the_progress_dialog (window);
2700 gtk_widget_hide (window->priv->pd_cancel_button);
2701 gtk_widget_hide (window->priv->pd_state_button);
2702 gtk_widget_hide (window->priv->pd_open_archive_button);
2703 gtk_widget_show (window->priv->pd_open_destination_button);
2704 gtk_widget_show (window->priv->pd_open_destination_and_quit_button);
2705 gtk_widget_show (window->priv->pd_quit_button);
2706 gtk_widget_show (window->priv->pd_close_button);
2707 display_progress_dialog (window);
2708 fr_window_progress_cb (NULL((void*)0), 1.0, window);
2709 fr_window_message_cb (NULL((void*)0), _("Extraction completed successfully")gettext ("Extraction completed successfully"), window);
2710
2711 if (window->priv->close_dialog)
2712 close_progress_dialog (window, TRUE(!(0)));
2713
2714}
2715
2716static void
2717open_progress_dialog_with_open_archive (FrWindow *window)
2718{
2719 if (window->priv->hide_progress_timeout != 0) {
2720 g_source_remove (window->priv->hide_progress_timeout);
2721 window->priv->hide_progress_timeout = 0;
2722 }
2723 if (window->priv->progress_timeout != 0) {
2724 g_source_remove (window->priv->progress_timeout);
2725 window->priv->progress_timeout = 0;
2726 }
2727
2728 create_the_progress_dialog (window);
2729 gtk_widget_hide (window->priv->pd_cancel_button);
2730 gtk_widget_hide (window->priv->pd_state_button);
2731 gtk_widget_hide (window->priv->pd_open_destination_button);
2732 gtk_widget_hide (window->priv->pd_open_destination_and_quit_button);
2733 gtk_widget_show (window->priv->pd_open_archive_button);
2734 gtk_widget_show (window->priv->pd_close_button);
2735 display_progress_dialog (window);
2736 fr_window_progress_cb (NULL((void*)0), 1.0, window);
2737 fr_window_message_cb (NULL((void*)0), _("Archive created successfully")gettext ("Archive created successfully"), window);
2738}
2739
2740void
2741fr_window_push_message (FrWindow *window,
2742 const char *msg)
2743{
2744 if (! gtk_widget_get_mapped (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2745 return;
2746
2747 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
2748 window->priv->progress_cid,
2749 msg);
2750}
2751
2752void
2753fr_window_pop_message (FrWindow *window)
2754{
2755 if (! gtk_widget_get_mapped (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2756 return;
2757 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, window->priv->progress_cid);
2758 if (window->priv->progress_dialog != NULL((void*)0))
2759 gtk_label_set_text (GTK_LABEL (window->priv->pd_message)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_message)), ((gtk_label_get_type (
)))))))
, "");
2760}
2761
2762static void
2763action_started (FrArchive *archive,
2764 FrAction action,
2765 gpointer data)
2766{
2767 FrWindow *window = data;
2768 char *message;
2769
2770 window->priv->action = action;
2771 fr_window_start_activity_mode (window);
2772
2773#ifdef MATE_ENABLE_DEBUG
2774 debug (DEBUG_INFO"fr-window.c", 2774, __FUNCTION__, "%s [START] (FR::Window)\n", get_action_name (action));
2775#endif
2776
2777 message = get_action_description (action, window->priv->pd_last_archive);
2778 fr_window_push_message (window, message);
2779 g_free (message);
2780
2781 switch (action) {
2782 case FR_ACTION_EXTRACTING_FILES:
2783 open_progress_dialog (window, window->priv->ask_to_open_destination_after_extraction || window->priv->convert_data.converting || window->priv->batch_mode);
2784 break;
2785 default:
2786 open_progress_dialog (window, window->priv->batch_mode);
2787 break;
2788 }
2789
2790 if (archive->command != NULL((void*)0)) {
2791 fr_command_progress (archive->command, -1.0);
2792 fr_command_message (archive->command, _("Please wait…")gettext ("Please wait…"));
2793 }
2794}
2795
2796static void
2797fr_window_add_to_recent_list (FrWindow *window,
2798 char *uri)
2799{
2800 if (window->priv->batch_mode)
2801 return;
2802
2803 if (is_temp_dir (uri))
2804 return;
2805
2806 if (window->archive->content_type != NULL((void*)0)) {
2807 GtkRecentData *recent_data;
2808
2809 recent_data = g_new0 (GtkRecentData, 1)((GtkRecentData *) g_malloc0_n ((1), sizeof (GtkRecentData)));
2810 recent_data->mime_type = g_content_type_get_mime_type (window->archive->content_type);
2811 recent_data->app_name = "Engrampa";
2812 recent_data->app_exec = "engrampa";
2813 gtk_recent_manager_add_full (gtk_recent_manager_get_default (), uri, recent_data);
2814
2815 g_free (recent_data->mime_type);
2816 g_free (recent_data);
2817 }
2818 else
2819 gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri);
2820}
2821
2822static void
2823fr_window_remove_from_recent_list (FrWindow *window,
2824 char *filename)
2825{
2826 if (filename != NULL((void*)0))
2827 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), filename, NULL((void*)0));
2828}
2829
2830static void
2831error_dialog_response_cb (GtkDialog *dialog,
2832 gint arg1,
2833 gpointer user_data)
2834{
2835 FrWindow *window = user_data;
2836 GtkWindow *dialog_parent = window->priv->error_dialog_parent;
2837
2838 window->priv->showing_error_dialog = FALSE(0);
2839 window->priv->error_dialog_parent = NULL((void*)0);
2840
2841 if ((dialog_parent != NULL((void*)0)) && (gtk_widget_get_toplevel (GTK_WIDGET (dialog_parent)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog_parent)), ((gtk_widget_get_type ()))))))
) != (GtkWidget*) dialog_parent))
2842 gtk_window_set_modal (dialog_parent, TRUE(!(0)));
2843 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
2844
2845 if (window->priv->destroy_with_error_dialog)
2846 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2847}
2848
2849static void
2850fr_window_show_error_dialog (FrWindow *window,
2851 GtkWidget *dialog,
2852 GtkWindow *dialog_parent,
2853 const char *details)
2854{
2855 if (window->priv->batch_mode && ! window->priv->use_progress_dialog) {
2856 GError *error;
2857
2858 error = g_error_new_literal (FR_ERRORfr_error_quark (), FR_PROC_ERROR_GENERIC, details ? details : _("Command exited abnormally.")gettext ("Command exited abnormally."));
2859 g_signal_emit (window,
2860 fr_window_signals[READY],
2861 0,
2862 error);
2863
2864 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2865
2866 return;
2867 }
2868
2869 close_progress_dialog (window, TRUE(!(0)));
2870
2871 if (window->priv->batch_mode)
2872 fr_window_destroy_with_error_dialog (window);
2873
2874 if (dialog_parent != NULL((void*)0))
2875 gtk_window_set_modal (dialog_parent, FALSE(0));
2876 g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2877 "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2878 G_CALLBACK (error_dialog_response_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2879 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2880 gtk_window_set_modal (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2881 gtk_widget_show (dialog);
2882
2883 window->priv->showing_error_dialog = TRUE(!(0));
2884 window->priv->error_dialog_parent = dialog_parent;
2885}
2886
2887void
2888fr_window_destroy_with_error_dialog (FrWindow *window)
2889{
2890 window->priv->destroy_with_error_dialog = TRUE(!(0));
2891}
2892
2893static gboolean
2894handle_errors (FrWindow *window,
2895 FrArchive *archive,
2896 FrAction action,
2897 FrProcError *error)
2898{
2899 if (error->type == FR_PROC_ERROR_ASK_PASSWORD) {
2900 close_progress_dialog (window, TRUE(!(0)));
2901 dlg_ask_password (window);
2902 return FALSE(0);
2903 }
2904 else if (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT) {
2905 close_progress_dialog (window, TRUE(!(0)));
2906 dlg_package_installer (window, archive, action);
2907 return FALSE(0);
2908 }
2909#if 0
2910 else if (error->type == FR_PROC_ERROR_BAD_CHARSET) {
2911 close_progress_dialog (window, TRUE(!(0)));
2912 /* dlg_ask_archive_charset (window); FIXME: implement after feature freeze */
2913 return FALSE(0);
2914 }
2915#endif
2916 else if (error->type == FR_PROC_ERROR_STOPPED) {
2917 /* nothing */
2918 }
2919 else if (error->type != FR_PROC_ERROR_NONE) {
2920 char *msg = NULL((void*)0);
2921 char *utf8_name;
2922 char *details = NULL((void*)0);
2923 GtkWindow *dialog_parent;
2924 GtkWidget *dialog;
2925 FrProcess *process = archive->process;
2926 GList *output = NULL((void*)0);
2927
2928 if (window->priv->batch_mode) {
2929 dialog_parent = NULL((void*)0);
2930 window->priv->load_error_parent_window = NULL((void*)0);
2931 }
2932 else {
2933 dialog_parent = (GtkWindow *) window;
2934 if (window->priv->load_error_parent_window == NULL((void*)0))
2935 window->priv->load_error_parent_window = (GtkWindow *) window;
2936 }
2937
2938 if ((action == FR_ACTION_LISTING_CONTENT) || (action == FR_ACTION_LOADING_ARCHIVE))
2939 fr_window_archive_close (window);
2940
2941 switch (action) {
2942 case FR_ACTION_CREATING_NEW_ARCHIVE:
2943 dialog_parent = window->priv->load_error_parent_window;
2944 msg = _("Could not create the archive")gettext ("Could not create the archive");
2945 break;
2946
2947 case FR_ACTION_EXTRACTING_FILES:
2948 case FR_ACTION_COPYING_FILES_TO_REMOTE:
2949 msg = _("An error occurred while extracting files.")gettext ("An error occurred while extracting files.");
2950 break;
2951
2952 case FR_ACTION_LOADING_ARCHIVE:
2953 dialog_parent = window->priv->load_error_parent_window;
2954 utf8_name = g_uri_display_basename (window->priv->archive_uri);
2955 msg = g_strdup_printf (_("Could not open \"%s\"")gettext ("Could not open \"%s\""), utf8_name);
2956 g_free (utf8_name);
2957 break;
2958
2959 case FR_ACTION_LISTING_CONTENT:
2960 msg = _("An error occurred while loading the archive.")gettext ("An error occurred while loading the archive.");
2961 break;
2962
2963 case FR_ACTION_DELETING_FILES:
2964 msg = _("An error occurred while deleting files from the archive.")gettext ("An error occurred while deleting files from the archive."
)
;
2965 break;
2966
2967 case FR_ACTION_ADDING_FILES:
2968 case FR_ACTION_GETTING_FILE_LIST:
2969 case FR_ACTION_COPYING_FILES_FROM_REMOTE:
2970 msg = _("An error occurred while adding files to the archive.")gettext ("An error occurred while adding files to the archive."
)
;
2971 break;
2972
2973 case FR_ACTION_TESTING_ARCHIVE:
2974 msg = _("An error occurred while testing archive.")gettext ("An error occurred while testing archive.");
2975 break;
2976
2977 case FR_ACTION_SAVING_REMOTE_ARCHIVE:
2978 msg = _("An error occurred while saving the archive.")gettext ("An error occurred while saving the archive.");
2979 break;
2980
2981 default:
2982 msg = _("An error occurred.")gettext ("An error occurred.");
2983 break;
2984 }
2985
2986 switch (error->type) {
2987 case FR_PROC_ERROR_COMMAND_NOT_FOUND:
2988 details = _("Command not found.")gettext ("Command not found.");
2989 break;
2990 case FR_PROC_ERROR_EXITED_ABNORMALLY:
2991 details = _("Command exited abnormally.")gettext ("Command exited abnormally.");
2992 break;
2993 case FR_PROC_ERROR_SPAWN:
2994 details = error->gerror->message;
2995 break;
2996 default:
2997 if (error->gerror != NULL((void*)0))
2998 details = error->gerror->message;
2999 else
3000 details = NULL((void*)0);
3001 break;
3002 }
3003
3004 if (error->type != FR_PROC_ERROR_GENERIC)
3005 output = (process->err.raw != NULL((void*)0)) ? process->err.raw : process->out.raw;
3006
3007 dialog = _gtk_error_dialog_new (dialog_parent,
3008 0,
3009 output,
3010 msg,
3011 ((details != NULL((void*)0)) ? "%s" : NULL((void*)0)),
3012 details);
3013 fr_window_show_error_dialog (window, dialog, dialog_parent, details);
3014
3015 return FALSE(0);
3016 }
3017
3018 return TRUE(!(0));
3019}
3020
3021static void
3022convert__action_performed (FrArchive *archive,
3023 FrAction action,
3024 FrProcError *error,
3025 gpointer data)
3026{
3027 FrWindow *window = data;
3028
3029#ifdef MATE_ENABLE_DEBUG
3030 debug (DEBUG_INFO"fr-window.c", 3030, __FUNCTION__, "%s [CONVERT::DONE] (FR::Window)\n", get_action_name (action));
3031#endif
3032
3033 if ((action == FR_ACTION_GETTING_FILE_LIST) || (action == FR_ACTION_ADDING_FILES)) {
3034 fr_window_stop_activity_mode (window);
3035 fr_window_pop_message (window);
3036 close_progress_dialog (window, FALSE(0));
3037 }
3038
3039 if (action != FR_ACTION_ADDING_FILES)
3040 return;
3041
3042 handle_errors (window, archive, action, error);
3043
3044 if (error->type == FR_PROC_ERROR_NONE)
3045 open_progress_dialog_with_open_archive (window);
3046
3047 remove_local_directory (window->priv->convert_data.temp_dir);
3048 fr_window_convert_data_free (window, FALSE(0));
3049
3050 fr_window_update_sensitivity (window);
3051 fr_window_update_statusbar_list_info (window);
3052}
3053
3054static void fr_window_exec_next_batch_action (FrWindow *window);
3055
3056static void
3057action_performed (FrArchive *archive,
3058 FrAction action,
3059 FrProcError *error,
3060 gpointer data)
3061{
3062 FrWindow *window = data;
3063 gboolean continue_batch = FALSE(0);
3064 char *archive_dir;
3065 gboolean temp_dir;
3066
3067#ifdef MATE_ENABLE_DEBUG
3068 debug (DEBUG_INFO"fr-window.c", 3068, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action));
3069#endif
3070
3071 fr_window_stop_activity_mode (window);
3072 fr_window_pop_message (window);
3073
3074 continue_batch = handle_errors (window, archive, action, error);
3075
3076 if ((error->type == FR_PROC_ERROR_ASK_PASSWORD)
3077 || (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT)
3078 /*|| (error->type == FR_PROC_ERROR_BAD_CHARSET)*/)
3079 {
3080 return;
3081 }
3082
3083 switch (action) {
3084 case FR_ACTION_CREATING_NEW_ARCHIVE:
3085 case FR_ACTION_CREATING_ARCHIVE:
3086 close_progress_dialog (window, FALSE(0));
3087 if (error->type != FR_PROC_ERROR_STOPPED) {
3088 fr_window_history_clear (window);
3089 fr_window_go_to_location (window, "/", TRUE(!(0)));
3090 fr_window_update_dir_tree (window);
3091 fr_window_update_title (window);
3092 fr_window_update_sensitivity (window);
3093 }
3094 break;
3095
3096 case FR_ACTION_LOADING_ARCHIVE:
3097 close_progress_dialog (window, FALSE(0));
3098 if (error->type != FR_PROC_ERROR_NONE) {
3099 fr_window_remove_from_recent_list (window, window->priv->archive_uri);
3100 if (window->priv->non_interactive) {
3101 fr_window_archive_close (window);
3102 fr_window_stop_batch (window);
3103 }
3104 }
3105 else {
3106 fr_window_add_to_recent_list (window, window->priv->archive_uri);
3107 if (! window->priv->non_interactive)
3108 gtk_window_present (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
3109 }
3110 continue_batch = FALSE(0);
3111 g_signal_emit (window,
3112 fr_window_signals[ARCHIVE_LOADED],
3113 0,
3114 error->type == FR_PROC_ERROR_NONE);
3115 break;
3116
3117 case FR_ACTION_LISTING_CONTENT:
3118 /* update the uri because multi-volume archives can have
3119 * a different name after loading. */
3120 g_free (window->priv->archive_uri);
3121 window->priv->archive_uri = g_file_get_uri (window->archive->file);
3122
3123 close_progress_dialog (window, FALSE(0));
3124 if (error->type != FR_PROC_ERROR_NONE) {
3125 fr_window_remove_from_recent_list (window, window->priv->archive_uri);
3126 fr_window_archive_close (window);
3127 fr_window_set_password (window, NULL((void*)0));
3128 break;
3129 }
3130
3131 archive_dir = remove_level_from_path (window->priv->archive_uri);
3132 temp_dir = is_temp_dir (archive_dir);
3133 if (! window->priv->archive_present) {
3134 window->priv->archive_present = TRUE(!(0));
3135
3136 fr_window_history_clear (window);
3137 fr_window_history_add (window, "/");
3138
3139 if (! temp_dir) {
3140 fr_window_set_open_default_dir (window, archive_dir);
3141 fr_window_set_add_default_dir (window, archive_dir);
3142 if (! window->priv->freeze_default_dir)
3143 fr_window_set_extract_default_dir (window, archive_dir, FALSE(0));
3144 }
3145
3146 window->priv->archive_new = FALSE(0);
3147 }
3148 g_free (archive_dir);
3149
3150 if (! temp_dir)
3151 fr_window_add_to_recent_list (window, window->priv->archive_uri);
3152
3153 fr_window_update_title (window);
3154 fr_window_go_to_location (window, fr_window_get_current_location (window), TRUE(!(0)));
3155 fr_window_update_dir_tree (window);
3156 if (! window->priv->batch_mode && window->priv->non_interactive)
3157 gtk_window_present (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
3158 break;
3159
3160 case FR_ACTION_DELETING_FILES:
3161 close_progress_dialog (window, FALSE(0));
3162 if (error->type != FR_PROC_ERROR_STOPPED)
3163 fr_window_archive_reload (window);
3164 return;
3165
3166 case FR_ACTION_ADDING_FILES:
3167 close_progress_dialog (window, FALSE(0));
3168
3169 /* update the uri because multi-volume archives can have
3170 * a different name after creation. */
3171 g_free (window->priv->archive_uri);
3172 window->priv->archive_uri = g_file_get_uri (window->archive->file);
3173
3174 if (error->type == FR_PROC_ERROR_NONE) {
3175 if (window->priv->archive_new)
3176 window->priv->archive_new = FALSE(0);
3177 fr_window_add_to_recent_list (window, window->priv->archive_uri);
3178 }
3179 if (! window->priv->batch_mode && (error->type != FR_PROC_ERROR_STOPPED)) {
3180 fr_window_archive_reload (window);
3181 return;
3182 }
3183 break;
3184
3185 case FR_ACTION_TESTING_ARCHIVE:
3186 close_progress_dialog (window, FALSE(0));
3187 if (error->type == FR_PROC_ERROR_NONE)
3188 fr_window_view_last_output (window, _("Test Result")gettext ("Test Result"));
3189 return;
3190
3191 case FR_ACTION_EXTRACTING_FILES:
3192 if (error->type != FR_PROC_ERROR_NONE) {
3193 if (window->priv->convert_data.converting) {
3194 remove_local_directory (window->priv->convert_data.temp_dir);
3195 fr_window_convert_data_free (window, TRUE(!(0)));
3196 }
3197 break;
3198 }
3199 if (window->priv->convert_data.converting) {
3200 char *source_dir;
3201
3202 source_dir = g_filename_to_uri (window->priv->convert_data.temp_dir, NULL((void*)0), NULL((void*)0));
3203 fr_archive_add_with_wildcard (
3204 window->priv->convert_data.new_archive,
3205 "*",
3206 NULL((void*)0),
3207 NULL((void*)0),
3208 source_dir,
3209 NULL((void*)0),
3210 FALSE(0),
3211 TRUE(!(0)),
3212 window->priv->convert_data.password,
3213 window->priv->convert_data.encrypt_header,
3214 window->priv->compression,
3215 window->priv->convert_data.volume_size);
3216 g_free (source_dir);
3217 }
3218 else {
3219 if (window->priv->ask_to_open_destination_after_extraction)
3220 open_progress_dialog_with_open_destination (window);
3221 else
3222 close_progress_dialog (window, FALSE(0));
3223 }
3224 break;
3225
3226 default:
3227 close_progress_dialog (window, FALSE(0));
3228 continue_batch = FALSE(0);
3229 break;
3230 }
3231
3232 if (window->priv->batch_action == NULL((void*)0)) {
3233 fr_window_update_sensitivity (window);
3234 fr_window_update_statusbar_list_info (window);
3235 }
3236
3237 if (continue_batch) {
3238 if (error->type != FR_PROC_ERROR_NONE)
3239 fr_window_stop_batch (window);
3240 else
3241 fr_window_exec_next_batch_action (window);
3242 }
3243}
3244
3245/* -- selections -- */
3246
3247#undef DEBUG_GET_DIR_LIST_FROM_PATH
3248
3249static GList *
3250get_dir_list_from_path (FrWindow *window,
3251 char *path)
3252{
3253 char *dirname;
3254 int dirname_l;
3255 GList *list = NULL((void*)0);
3256 guint i;
3257
3258 if (path[strlen (path) - 1] != '/')
3259 dirname = g_strconcat (path, "/", NULL((void*)0));
3260 else
3261 dirname = g_strdup (path)g_strdup_inline (path);
3262 dirname_l = strlen (dirname);
3263 for (i = 0; i < window->archive->command->files->len; i++) {
3264 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
3265 gboolean matches = FALSE(0);
3266
3267#ifdef DEBUG_GET_DIR_LIST_FROM_PATH
3268 g_print ("%s <=> %s (%d)\n", dirname, fd->full_path, dirname_l);
3269#endif
3270
3271 if (fd->dir) {
3272 int full_path_l = strlen (fd->full_path);
3273 if ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l) == 0))
3274 /* example: dirname is '/path/to/dir/' and fd->full_path is '/path/to/dir' */
3275 matches = TRUE(!(0));
3276 else if (strcmp (dirname, fd->full_path) == 0)
3277 matches = TRUE(!(0));
3278 }
3279
3280 if (! matches && strncmp (dirname, fd->full_path, dirname_l) == 0) {
3281 matches = TRUE(!(0));
3282 }
3283
3284 if (matches) {
3285#ifdef DEBUG_GET_DIR_LIST_FROM_PATH
3286 g_print ("`-> OK\n");
3287#endif
3288 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3289 }
3290 }
3291 g_free (dirname);
3292
3293 return g_list_reverse (list);
3294}
3295
3296static GList *
3297get_dir_list_from_file_data (FrWindow *window,
3298 FileData *fdata)
3299{
3300 char *dirname;
3301 GList *list;
3302
3303 dirname = g_strconcat (fr_window_get_current_location (window),
3304 fdata->list_name,
3305 NULL((void*)0));
3306 list = get_dir_list_from_path (window, dirname);
3307 g_free (dirname);
3308
3309 return list;
3310}
3311
3312GList *
3313fr_window_get_file_list_selection (FrWindow *window,
3314 gboolean recursive,
3315 gboolean *has_dirs)
3316{
3317 GtkTreeSelection *selection;
3318 GList *selections = NULL((void*)0), *list, *scan;
3319
3320 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3321
3322 if (has_dirs != NULL((void*)0))
3323 *has_dirs = FALSE(0);
3324
3325 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3326 if (selection == NULL((void*)0))
3327 return NULL((void*)0);
3328 gtk_tree_selection_selected_foreach (selection, add_selected_from_list_view, &selections);
3329
3330 list = NULL((void*)0);
3331 for (scan = selections; scan; scan = scan->next) {
3332 FileData *fd = scan->data;
3333
3334 if (!fd)
3335 continue;
3336
3337 if (file_data_is_dir (fd)) {
3338 if (has_dirs != NULL((void*)0))
3339 *has_dirs = TRUE(!(0));
3340
3341 if (recursive)
3342 list = g_list_concat (list, get_dir_list_from_file_data (window, fd));
3343 }
3344 else
3345 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3346 }
3347 if (selections)
3348 g_list_free (selections);
3349
3350 return g_list_reverse (list);
3351}
3352
3353GList *
3354fr_window_get_folder_tree_selection (FrWindow *window,
3355 gboolean recursive,
3356 gboolean *has_dirs)
3357{
3358 GtkTreeSelection *tree_selection;
3359 GList *selections, *list, *scan;
3360
3361 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3362
3363 if (has_dirs != NULL((void*)0))
3364 *has_dirs = FALSE(0);
3365
3366 tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
3367 if (tree_selection == NULL((void*)0))
3368 return NULL((void*)0);
3369
3370 selections = NULL((void*)0);
3371 gtk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections);
3372 if (selections == NULL((void*)0))
3373 return NULL((void*)0);
3374
3375 if (has_dirs != NULL((void*)0))
3376 *has_dirs = TRUE(!(0));
3377
3378 list = NULL((void*)0);
3379 for (scan = selections; scan; scan = scan->next) {
3380 char *path = scan->data;
3381
3382 if (recursive)
3383 list = g_list_concat (list, get_dir_list_from_path (window, path));
3384 }
3385 path_list_free (selections);
3386
3387 return g_list_reverse (list);
3388}
3389
3390GList *
3391fr_window_get_file_list_from_path_list (FrWindow *window,
3392 GList *path_list,
3393 gboolean *has_dirs)
3394{
3395 GtkTreeModel *model;
3396 GList *selections, *list, *scan;
3397
3398 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3399
3400 model = GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
;
3401 selections = NULL((void*)0);
3402
3403 if (has_dirs != NULL((void*)0))
3404 *has_dirs = FALSE(0);
3405
3406 for (scan = path_list; scan; scan = scan->next) {
3407 GtkTreeRowReference *reference = scan->data;
3408 GtkTreePath *path;
3409 GtkTreeIter iter;
3410 FileData *fdata;
3411
3412 path = gtk_tree_row_reference_get_path (reference);
3413 if (path == NULL((void*)0))
3414 continue;
3415
3416 if (! gtk_tree_model_get_iter (model, &iter, path))
3417 continue;
3418
3419 gtk_tree_model_get (model, &iter,
3420 COLUMN_FILE_DATA, &fdata,
3421 -1);
3422
3423 selections = g_list_prepend (selections, fdata);
3424 }
3425
3426 list = NULL((void*)0);
3427 for (scan = selections; scan; scan = scan->next) {
3428 FileData *fd = scan->data;
3429
3430 if (!fd)
3431 continue;
3432
3433 if (file_data_is_dir (fd)) {
3434 if (has_dirs != NULL((void*)0))
3435 *has_dirs = TRUE(!(0));
3436 list = g_list_concat (list, get_dir_list_from_file_data (window, fd));
3437 }
3438 else
3439 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3440 }
3441
3442 if (selections != NULL((void*)0))
3443 g_list_free (selections);
3444
3445 return g_list_reverse (list);
3446}
3447
3448GList *
3449fr_window_get_file_list_pattern (FrWindow *window,
3450 const char *pattern)
3451{
3452 GRegex **regexps;
3453 GList *list;
3454 guint i;
3455
3456 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3457
3458 regexps = search_util_get_regexps (pattern, G_REGEX_CASELESS);
3459 list = NULL((void*)0);
3460 for (i = 0; i < window->archive->command->files->len; i++) {
3461 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
3462 char *utf8_name;
3463
3464 /* FIXME: only files in the current location ? */
3465
3466 if (fd == NULL((void*)0))
3467 continue;
3468
3469 utf8_name = g_filename_to_utf8 (fd->name, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
3470 if (match_regexps (regexps, utf8_name, 0))
3471 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3472 g_free (utf8_name);
3473 }
3474 free_regexps (regexps);
3475
3476 return g_list_reverse (list);
3477}
3478
3479static GList *
3480fr_window_get_file_list (FrWindow *window)
3481{
3482 GList *list;
3483 guint i;
3484
3485 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3486
3487 list = NULL((void*)0);
3488 for (i = 0; i < window->archive->command->files->len; i++) {
3489 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
3490 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3491 }
3492
3493 return g_list_reverse (list);
3494}
3495
3496int
3497fr_window_get_n_selected_files (FrWindow *window)
3498{
3499 return gtk_tree_selection_count_selected_rows (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
));
3500}
3501
3502/**/
3503
3504static int
3505dir_tree_button_press_cb (GtkWidget *widget,
3506 GdkEventButton *event,
3507 gpointer data)
3508{
3509 FrWindow *window = data;
3510 GtkTreeSelection *selection;
3511
3512 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
))
3513 return FALSE(0);
3514
3515 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
3516 if (selection == NULL((void*)0))
3517 return FALSE(0);
3518
3519 if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
3520 GtkTreePath *path;
3521 GtkTreeIter iter;
3522
3523 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
,
3524 (int) event->x, (int) event->y,
3525 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3526
3527 if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &iter, path)) {
3528 gtk_tree_path_free (path);
3529 return FALSE(0);
3530 }
3531 gtk_tree_path_free (path);
3532
3533 if (! gtk_tree_selection_iter_is_selected (selection, &iter)) {
3534 gtk_tree_selection_unselect_all (selection);
3535 gtk_tree_selection_select_iter (selection, &iter);
3536 }
3537
3538 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->sidebar_folder_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->sidebar_folder_popup_menu)), ((gtk_menu_get_type
()))))))
,
3539 (const GdkEvent*) event);
3540 }
3541 else
3542 gtk_tree_selection_unselect_all (selection);
3543
3544 return TRUE(!(0));
3545 }
3546 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 8)) {
3547 fr_window_go_back (window);
3548 return TRUE(!(0));
3549 }
3550 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 9)) {
3551 fr_window_go_forward (window);
3552 return TRUE(!(0));
3553 }
3554
3555 return FALSE(0);
3556}
3557
3558static FileData *
3559fr_window_get_selected_item_from_file_list (FrWindow *window)
3560{
3561 GtkTreeSelection *tree_selection;
3562 GList *selection;
3563 FileData *fdata = NULL((void*)0);
3564
3565 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3566
3567 tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3568 if (tree_selection == NULL((void*)0))
3569 return NULL((void*)0);
3570
3571 selection = NULL((void*)0);
3572 gtk_tree_selection_selected_foreach (tree_selection, add_selected_from_list_view, &selection);
3573 if ((selection == NULL((void*)0)) || (selection->next != NULL((void*)0))) {
3574 /* return NULL if the selection contains more than one entry. */
3575 g_list_free (selection);
3576 return NULL((void*)0);
3577 }
3578
3579 fdata = file_data_copy (selection->data);
3580 g_list_free (selection);
3581
3582 return fdata;
3583}
3584
3585static char *
3586fr_window_get_selected_folder_in_tree_view (FrWindow *window)
3587{
3588 GtkTreeSelection *tree_selection;
3589 GList *selections;
3590 char *path = NULL((void*)0);
3591
3592 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3593
3594 tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
3595 if (tree_selection == NULL((void*)0))
3596 return NULL((void*)0);
3597
3598 selections = NULL((void*)0);
3599 gtk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections);
3600
3601 if (selections != NULL((void*)0)) {
3602 path = selections->data;
3603 g_list_free (selections);
3604 }
3605
3606 return path;
3607}
3608
3609void
3610fr_window_current_folder_activated (FrWindow *window,
3611 gboolean from_sidebar)
3612{
3613 char *dir_path;
3614
3615 if (! from_sidebar) {
3616 FileData *fdata;
3617 char *dir_name;
3618
3619 fdata = fr_window_get_selected_item_from_file_list (window);
3620 if ((fdata == NULL((void*)0)) || ! file_data_is_dir (fdata)) {
3621 file_data_free (fdata);
3622 return;
3623 }
3624 dir_name = g_strdup (fdata->list_name)g_strdup_inline (fdata->list_name);
3625 dir_path = g_strconcat (fr_window_get_current_location (window),
3626 dir_name,
3627 "/",
3628 NULL((void*)0));
3629 g_free (dir_name);
3630 file_data_free (fdata);
3631 }
3632 else
3633 dir_path = fr_window_get_selected_folder_in_tree_view (window);
3634
3635 fr_window_go_to_location (window, dir_path, FALSE(0));
3636
3637 g_free (dir_path);
3638}
3639
3640static gboolean
3641row_activated_cb (GtkTreeView *tree_view,
3642 GtkTreePath *path,
3643 GtkTreeViewColumn *column,
3644 gpointer data)
3645{
3646 FrWindow *window = data;
3647 FileData *fdata;
3648 GtkTreeIter iter;
3649
3650 if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3651 &iter,
3652 path))
3653 return FALSE(0);
3654
3655 gtk_tree_model_get (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
, &iter,
3656 COLUMN_FILE_DATA, &fdata,
3657 -1);
3658
3659 if (! file_data_is_dir (fdata)) {
3660 GList *list = g_list_prepend (NULL((void*)0), fdata->original_path);
3661 fr_window_open_files (window, list, FALSE(0));
3662 g_list_free (list);
3663 }
3664 else if (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR) {
3665 char *new_dir;
3666 new_dir = g_strconcat (fr_window_get_current_location (window),
3667 fdata->list_name,
3668 "/",
3669 NULL((void*)0));
3670 fr_window_go_to_location (window, new_dir, FALSE(0));
3671 g_free (new_dir);
3672 }
3673
3674 return FALSE(0);
3675}
3676
3677static int
3678file_button_press_cb (GtkWidget *widget,
3679 GdkEventButton *event,
3680 gpointer data)
3681{
3682 FrWindow *window = data;
3683 GtkTreeSelection *selection;
3684
3685 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
))
3686 return FALSE(0);
3687
3688 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3689 if (selection == NULL((void*)0))
3690 return FALSE(0);
3691
3692 if (window->priv->path_clicked != NULL((void*)0)) {
3693 gtk_tree_path_free (window->priv->path_clicked);
3694 window->priv->path_clicked = NULL((void*)0);
3695 }
3696
3697 if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
3698 GtkTreePath *path;
3699 GtkTreeIter iter;
3700 int n_selected;
3701
3702 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
3703 (int) event->x, (int) event->y,
3704 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3705
3706 if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
, &iter, path)) {
3707 gtk_tree_path_free (path);
3708 return FALSE(0);
3709 }
3710 gtk_tree_path_free (path);
3711
3712 if (! gtk_tree_selection_iter_is_selected (selection, &iter)) {
3713 gtk_tree_selection_unselect_all (selection);
3714 gtk_tree_selection_select_iter (selection, &iter);
3715 }
3716 }
3717 else
3718 gtk_tree_selection_unselect_all (selection);
3719
3720 n_selected = fr_window_get_n_selected_files (window);
3721 if ((n_selected == 1) && selection_has_a_dir (window))
3722 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->folder_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->folder_popup_menu)), ((gtk_menu_get_type
()))))))
,
3723 (const GdkEvent*) event);
3724 else
3725 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->file_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->file_popup_menu)), ((gtk_menu_get_type
()))))))
,
3726 (const GdkEvent*) event);
3727 return TRUE(!(0));
3728 }
3729 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 1)) {
3730 GtkTreePath *path = NULL((void*)0);
3731
3732 if (! gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
3733 (int) event->x, (int) event->y,
3734 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3735 gtk_tree_selection_unselect_all (selection);
3736 }
3737
3738 if (window->priv->path_clicked != NULL((void*)0)) {
3739 gtk_tree_path_free (window->priv->path_clicked);
3740 window->priv->path_clicked = NULL((void*)0);
3741 }
3742
3743 if (path != NULL((void*)0)) {
3744 window->priv->path_clicked = gtk_tree_path_copy (path);
3745 gtk_tree_path_free (path);
3746 }
3747
3748 return FALSE(0);
3749 }
3750 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 8)) {
3751 // go back
3752 fr_window_go_back (window);
3753 return TRUE(!(0));
3754 }
3755 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 9)) {
3756 // go forward
3757 fr_window_go_forward (window);
3758 return TRUE(!(0));
3759 }
3760
3761 return FALSE(0);
3762}
3763
3764static int
3765file_button_release_cb (GtkWidget *widget,
3766 GdkEventButton *event,
3767 gpointer data)
3768{
3769 FrWindow *window = data;
3770 GtkTreeSelection *selection;
3771
3772 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
))
3773 return FALSE(0);
3774
3775 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3776 if (selection == NULL((void*)0))
3777 return FALSE(0);
3778
3779 if (window->priv->path_clicked == NULL((void*)0))
3780 return FALSE(0);
3781
3782 if ((event->type == GDK_BUTTON_RELEASE)
3783 && (event->button == 1)
3784 && (window->priv->path_clicked != NULL((void*)0))) {
3785 GtkTreePath *path = NULL((void*)0);
3786
3787 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
3788 (int) event->x, (int) event->y,
3789 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3790
3791 if ((gtk_tree_path_compare (window->priv->path_clicked, path) == 0)
3792 && window->priv->single_click
3793 && ! ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_SHIFT_MASK))) {
3794 gtk_tree_view_set_cursor (GTK_TREE_VIEW (widget)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_tree_view_get_type ()))))))
,
3795 path,
3796 NULL((void*)0),
3797 FALSE(0));
3798 gtk_tree_view_row_activated (GTK_TREE_VIEW (widget)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_tree_view_get_type ()))))))
,
3799 path,
3800 NULL((void*)0));
3801 }
3802 }
3803
3804 if (path != NULL((void*)0))
3805 gtk_tree_path_free (path);
3806 }
3807
3808 if (window->priv->path_clicked != NULL((void*)0)) {
3809 gtk_tree_path_free (window->priv->path_clicked);
3810 window->priv->path_clicked = NULL((void*)0);
3811 }
3812
3813 return FALSE(0);
3814}
3815
3816static gboolean
3817file_motion_notify_callback (GtkWidget *widget,
3818 GdkEventMotion *event,
3819 gpointer user_data)
3820{
3821 FrWindow *window = user_data;
3822 GdkCursor *cursor;
3823 GtkTreePath *last_hover_path;
3824 GdkDisplay *display;
3825 GtkTreeIter iter;
3826
3827 if (! window->priv->single_click)
3828 return FALSE(0);
3829
3830 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
))
3831 return FALSE(0);
3832
3833 last_hover_path = window->priv->list_hover_path;
3834
3835 gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_tree_view_get_type ()))))))
,
3836 (int) event->x, (int) event->y,
3837 &window->priv->list_hover_path,
3838 NULL((void*)0), NULL((void*)0), NULL((void*)0));
3839
3840 display = gtk_widget_get_display (GTK_WIDGET (widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_widget_get_type ()))))))
);
3841
3842 if (window->priv->list_hover_path != NULL((void*)0))
3843 cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
3844 else
3845 cursor = NULL((void*)0);
3846
3847 gdk_window_set_cursor (event->window, cursor);
3848
3849 /* only redraw if the hover row has changed */
3850 if (!(last_hover_path == NULL((void*)0) && window->priv->list_hover_path == NULL((void*)0)) &&
3851 (!(last_hover_path != NULL((void*)0) && window->priv->list_hover_path != NULL((void*)0)) ||
3852 gtk_tree_path_compare (last_hover_path, window->priv->list_hover_path)))
3853 {
3854 if (last_hover_path) {
3855 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3856 &iter, last_hover_path);
3857 gtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3858 last_hover_path, &iter);
3859 }
3860
3861 if (window->priv->list_hover_path) {
3862 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3863 &iter, window->priv->list_hover_path);
3864 gtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3865 window->priv->list_hover_path, &iter);
3866 }
3867 }
3868
3869 gtk_tree_path_free (last_hover_path);
3870
3871 return FALSE(0);
3872}
3873
3874static gboolean
3875file_leave_notify_callback (GtkWidget *widget,
3876 GdkEventCrossing *event,
3877 gpointer user_data)
3878{
3879 FrWindow *window = user_data;
3880 GtkTreeIter iter;
3881
3882 if (window->priv->single_click && (window->priv->list_hover_path != NULL((void*)0))) {
3883 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3884 &iter,
3885 window->priv->list_hover_path);
3886 gtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3887 window->priv->list_hover_path,
3888 &iter);
3889
3890 gtk_tree_path_free (window->priv->list_hover_path);
3891 window->priv->list_hover_path = NULL((void*)0);
3892 }
3893
3894 return FALSE(0);
3895}
3896
3897/* -- drag and drop -- */
3898
3899static GList *
3900get_uri_list_from_selection_data (char *uri_list)
3901{
3902 GList *list = NULL((void*)0);
3903 char **uris;
3904 int i;
3905
3906 if (uri_list == NULL((void*)0))
3907 return NULL((void*)0);
3908
3909 uris = g_uri_list_extract_uris (uri_list);
3910 for (i = 0; uris[i] != NULL((void*)0); i++)
3911 list = g_list_prepend (list, g_strdup (uris[i])g_strdup_inline (uris[i]));
3912 g_strfreev (uris);
3913
3914 return g_list_reverse (list);
3915}
3916
3917static gboolean
3918fr_window_drag_motion (GtkWidget *widget,
3919 GdkDragContext *context,
3920 gint x,
3921 gint y,
3922 guint time,
3923 gpointer user_data)
3924{
3925 FrWindow *window = user_data;
3926
3927 if ((gtk_drag_get_source_widget (context) == window->priv->list_view)
3928 || (gtk_drag_get_source_widget (context) == window->priv->tree_view))
3929 {
3930 gdk_drag_status (context, 0, time);
3931 return FALSE(0);
3932 }
3933
3934 return TRUE(!(0));
3935}
3936
3937static void fr_window_paste_from_clipboard_data (FrWindow *window, FrClipboardData *data);
3938
3939static FrClipboardData*
3940get_clipboard_data_from_selection_data (FrWindow *window,
3941 const char *data)
3942{
3943 FrClipboardData *clipboard_data;
3944 char **uris;
3945 int i;
3946
3947 clipboard_data = fr_clipboard_data_new ();
3948
3949 uris = g_strsplit (data, "\r\n", -1);
3950
3951 clipboard_data->archive_filename = g_strdup (uris[0])g_strdup_inline (uris[0]);
3952 if (window->priv->password_for_paste != NULL((void*)0))
3953 clipboard_data->archive_password = g_strdup (window->priv->password_for_paste)g_strdup_inline (window->priv->password_for_paste);
3954 else if (strcmp (uris[1], "") != 0)
3955 clipboard_data->archive_password = g_strdup (uris[1])g_strdup_inline (uris[1]);
3956 clipboard_data->op = (strcmp (uris[2], "copy") == 0) ? FR_CLIPBOARD_OP_COPY : FR_CLIPBOARD_OP_CUT;
3957 clipboard_data->base_dir = g_strdup (uris[3])g_strdup_inline (uris[3]);
3958 for (i = 4; uris[i] != NULL((void*)0); i++)
3959 if (uris[i][0] != '\0')
3960 clipboard_data->files = g_list_prepend (clipboard_data->files, g_strdup (uris[i])g_strdup_inline (uris[i]));
3961 clipboard_data->files = g_list_reverse (clipboard_data->files);
3962
3963 g_strfreev (uris);
3964
3965 return clipboard_data;
3966}
3967
3968static void
3969fr_window_drag_data_received (GtkWidget *widget,
3970 GdkDragContext *context,
3971 gint x,
3972 gint y,
3973 GtkSelectionData *data,
3974 guint info,
3975 guint time,
3976 gpointer extra_data)
3977{
3978 FrWindow *window = extra_data;
3979 GList *list;
3980 gboolean one_file;
3981 gboolean is_an_archive;
3982
3983 debug (DEBUG_INFO"fr-window.c", 3983, __FUNCTION__, "::DragDataReceived -->\n");
3984
3985 if ((gtk_drag_get_source_widget (context) == window->priv->list_view)
3986 || (gtk_drag_get_source_widget (context) == window->priv->tree_view))
3987 {
3988 gtk_drag_finish (context, FALSE(0), FALSE(0), time);
3989 return;
3990 }
3991
3992 if (! ((gtk_selection_data_get_length (data) >= 0) && (gtk_selection_data_get_format (data) == 8))) {
3993 gtk_drag_finish (context, FALSE(0), FALSE(0), time);
3994 return;
3995 }
3996
3997 if (window->priv->activity_ref > 0) {
3998 gtk_drag_finish (context, FALSE(0), FALSE(0), time);
3999 return;
4000 }
4001
4002 gtk_drag_finish (context, TRUE(!(0)), FALSE(0), time);
4003
4004 if (gtk_selection_data_get_target (data) == XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0))) {
4005 FrClipboardData *dnd_data;
4006
4007 dnd_data = get_clipboard_data_from_selection_data (window, (char*) gtk_selection_data_get_data (data));
4008 dnd_data->current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4009 fr_window_paste_from_clipboard_data (window, dnd_data);
4010
4011 return;
4012 }
4013
4014 list = get_uri_list_from_selection_data ((char*) gtk_selection_data_get_data (data));
4015 if (list == NULL((void*)0)) {
4016 GtkWidget *d;
4017
4018 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4019 GTK_DIALOG_MODAL,
4020 NULL((void*)0),
4021 _("Could not perform the operation")gettext ("Could not perform the operation"),
4022 NULL((void*)0));
4023 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
4024 gtk_widget_destroy(d);
4025
4026 return;
4027 }
4028
4029 one_file = (list->next == NULL((void*)0));
4030 if (one_file)
4031 is_an_archive = uri_is_archive (list->data);
4032 else
4033 is_an_archive = FALSE(0);
4034
4035 if (window->priv->archive_present
4036 && (window->archive != NULL((void*)0))
4037 && ! window->archive->read_only
4038 && ! window->archive->is_compressed_file)
4039 {
4040 if (one_file && is_an_archive) {
4041 GtkWidget *d;
4042 gint r;
4043
4044 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4045 GTK_DIALOG_MODAL,
4046 "dialog-question",
4047 _("Do you want to add this file to the current archive or open it as a new archive?")gettext ("Do you want to add this file to the current archive or open it as a new archive?"
)
,
4048 NULL((void*)0),
4049 "gtk-cancel", GTK_RESPONSE_CANCEL,
4050 "gtk-add", 0,
4051 "gtk-open", 1,
4052 NULL((void*)0));
4053
4054 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, 2);
4055
4056 r = gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
4057 gtk_widget_destroy (GTK_WIDGET (d)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_widget_get_type ()))))))
);
4058
4059 if (r == 0) /* Add */
4060 fr_window_archive_add_dropped_items (window, list, FALSE(0));
4061 else if (r == 1) /* Open */
4062 fr_window_archive_open (window, list->data, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
4063 }
4064 else
4065 fr_window_archive_add_dropped_items (window, list, FALSE(0));
4066 }
4067 else {
4068 if (one_file && is_an_archive)
4069 fr_window_archive_open (window, list->data, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
4070 else {
4071 GtkWidget *d;
4072 int r;
4073
4074 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4075 GTK_DIALOG_MODAL,
4076 "dialog-question",
4077 _("Do you want to create a new archive with these files?")gettext ("Do you want to create a new archive with these files?"
)
,
4078 NULL((void*)0),
4079 "gtk-cancel", GTK_RESPONSE_CANCEL,
4080 _("Create _Archive")gettext ("Create _Archive"), GTK_RESPONSE_YES,
4081 NULL((void*)0));
4082
4083 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_YES);
4084 r = gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
4085 gtk_widget_destroy (GTK_WIDGET (d)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_widget_get_type ()))))))
);
4086
4087 if (r == GTK_RESPONSE_YES) {
4088 char *first_item;
4089 char *folder;
4090 char *local_path = NULL((void*)0);
4091 char *utf8_path = NULL((void*)0);
4092 const char *archive_name;
4093
4094 fr_window_free_batch_data (window);
4095 fr_window_append_batch_action (window,
4096 FR_BATCH_ACTION_ADD,
4097 path_list_dup (list),
4098 (GFreeFunc) path_list_free);
4099
4100 first_item = (char*) list->data;
4101 folder = remove_level_from_path (first_item);
4102 if (folder != NULL((void*)0))
4103 fr_window_set_open_default_dir (window, folder);
4104
4105 if ((list->next != NULL((void*)0)) && (folder != NULL((void*)0))) {
4106 archive_name = file_name_from_path (folder);
4107 }
4108 else {
4109 if (uri_is_local (first_item)) {
4110 local_path = g_filename_from_uri (first_item, NULL((void*)0), NULL((void*)0));
4111 if (local_path)
4112 utf8_path = g_filename_to_utf8 (local_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
4113 if (!utf8_path)
4114 utf8_path= g_strdup (first_item)g_strdup_inline (first_item);
4115 g_free (local_path);
4116 }
4117 else {
4118 utf8_path = g_strdup (first_item)g_strdup_inline (first_item);
4119 }
4120 archive_name = file_name_from_path (utf8_path);
4121 }
4122
4123 show_new_archive_dialog (window, archive_name);
4124 g_free (utf8_path);
4125
4126 g_free (folder);
4127 }
4128 }
4129 }
4130
4131 path_list_free (list);
4132
4133 debug (DEBUG_INFO"fr-window.c", 4133, __FUNCTION__, "::DragDataReceived <--\n");
4134}
4135
4136static gboolean
4137file_list_drag_begin (GtkWidget *widget,
4138 GdkDragContext *context,
4139 gpointer data)
4140{
4141 FrWindow *window = data;
4142
4143 debug (DEBUG_INFO"fr-window.c", 4143, __FUNCTION__, "::DragBegin -->\n");
4144
4145 if (window->priv->activity_ref > 0)
4146 return FALSE(0);
4147
4148 g_free (window->priv->drag_destination_folder);
4149 window->priv->drag_destination_folder = NULL((void*)0);
4150
4151 g_free (window->priv->drag_base_dir);
4152 window->priv->drag_base_dir = NULL((void*)0);
4153
4154 gdk_property_change (gdk_drag_context_get_source_window (context),
4155 XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMgdk_atom_intern ("text/plain", (0)),
4156 8, GDK_PROP_MODE_REPLACE,
4157 (guchar *) XDS_FILENAME"xds.txt",
4158 strlen (XDS_FILENAME"xds.txt"));
4159
4160 return TRUE(!(0));
4161}
4162
4163static void
4164file_list_drag_end (GtkWidget *widget,
4165 GdkDragContext *context,
4166 gpointer data)
4167{
4168 FrWindow *window = data;
4169
4170 debug (DEBUG_INFO"fr-window.c", 4170, __FUNCTION__, "::DragEnd -->\n");
4171
4172 gdk_property_delete (gdk_drag_context_get_source_window (context), XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)));
4173
4174 if (window->priv->drag_error != NULL((void*)0)) {
4175 _gtk_error_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4176 _("Extraction not performed")gettext ("Extraction not performed"),
4177 "%s",
4178 window->priv->drag_error->message);
4179 g_clear_error (&window->priv->drag_error);
4180 }
4181 else if (window->priv->drag_destination_folder != NULL((void*)0)) {
4182 fr_window_archive_extract (window,
4183 window->priv->drag_file_list,
4184 window->priv->drag_destination_folder,
4185 NULL((void*)0),
4186 window->priv->drag_base_dir,
4187 FALSE(0),
4188 FR_OVERWRITE_ASK,
4189 FALSE(0),
4190 FALSE(0));
4191 path_list_free (window->priv->drag_file_list);
4192 window->priv->drag_file_list = NULL((void*)0);
4193 }
4194
4195 debug (DEBUG_INFO"fr-window.c", 4195, __FUNCTION__, "::DragEnd <--\n");
4196}
4197
4198/* The following three functions taken from bugzilla
4199 * (http://bugzilla.mate.org/attachment.cgi?id=49362&action=view)
4200 * Author: Christian Neumair
4201 * Copyright: 2005 Free Software Foundation, Inc
4202 * License: GPL */
4203static char *
4204get_xds_atom_value (GdkDragContext *context)
4205{
4206 gint actual_length;
4207 char *data;
4208 char *ret = NULL((void*)0);
4209
4210 g_return_val_if_fail (context != NULL, NULL)do { if ((context != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "context != NULL"
); return (((void*)0)); } } while (0)
;
4211 g_return_val_if_fail (gdk_drag_context_get_source_window (context) != NULL, NULL)do { if ((gdk_drag_context_get_source_window (context) != ((void
*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "gdk_drag_context_get_source_window (context) != NULL"
); return (((void*)0)); } } while (0)
;
4212
4213 if (gdk_property_get (gdk_drag_context_get_source_window (context),
4214 XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMgdk_atom_intern ("text/plain", (0)),
4215 0, MAX_XDS_ATOM_VAL_LEN4096,
4216 FALSE(0), NULL((void*)0), NULL((void*)0), &actual_length,
4217 (unsigned char **) &data)) {
4218 /* add not included \0 to the end of the string */
4219 ret = g_strndup ((gchar *) data, actual_length);
4220 g_free (data);
4221 }
4222
4223 return ret;
4224}
4225
4226static gboolean
4227context_offers_target (GdkDragContext *context,
4228 GdkAtom target)
4229{
4230 return (g_list_find (gdk_drag_context_list_targets (context), target) != NULL((void*)0));
4231}
4232
4233static gboolean
4234caja_xds_dnd_is_valid_xds_context (GdkDragContext *context)
4235{
4236 char *tmp;
4237 gboolean ret;
4238
4239 g_return_val_if_fail (context != NULL, FALSE)do { if ((context != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "context != NULL"
); return ((0)); } } while (0)
;
4240
4241 tmp = NULL((void*)0);
4242 if (context_offers_target (context, XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)))) {
4243 tmp = get_xds_atom_value (context);
4244 }
4245
4246 ret = (tmp != NULL((void*)0));
4247 g_free (tmp);
4248
4249 return ret;
4250}
4251
4252static char *
4253get_selection_data_from_clipboard_data (FrWindow *window,
4254 FrClipboardData *data)
4255{
4256 GString *list;
4257 char *local_filename;
4258 GList *scan;
4259
4260 list = g_string_new (NULL((void*)0));
4261
4262 local_filename = g_file_get_uri (window->archive->local_copy);
4263 g_string_append (list, local_filename)(__builtin_constant_p (local_filename) ? __extension__ ({ const
char * const __val = (local_filename); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, local_filename, (gssize) -1))
;
4264 g_free (local_filename);
4265
4266 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4267 if (window->priv->password != NULL((void*)0))
4268 g_string_append (list, window->priv->password)(__builtin_constant_p (window->priv->password) ? __extension__
({ const char * const __val = (window->priv->password)
; g_string_append_len_inline (list, __val, (__val != ((void*)
0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize) -1); }
) : g_string_append_len_inline (list, window->priv->password
, (gssize) -1))
;
4269 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4270 g_string_append (list, (data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut")(__builtin_constant_p ((data->op == FR_CLIPBOARD_OP_COPY) ?
"copy" : "cut") ? __extension__ ({ const char * const __val =
((data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut"); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, (data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut"
, (gssize) -1))
;
4271 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4272 g_string_append (list, data->base_dir)(__builtin_constant_p (data->base_dir) ? __extension__ ({ const
char * const __val = (data->base_dir); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, data->base_dir, (gssize) -1))
;
4273 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4274 for (scan = data->files; scan; scan = scan->next) {
4275 g_string_append (list, scan->data)(__builtin_constant_p (scan->data) ? __extension__ ({ const
char * const __val = (scan->data); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, scan->data, (gssize) -1))
;
4276 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4277 }
4278
4279 return g_string_free (list, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((list
), ((0))) : g_string_free_and_steal (list)) : (g_string_free)
((list), ((0))))
;
4280}
4281
4282static gboolean
4283fr_window_folder_tree_drag_data_get (GtkWidget *widget,
4284 GdkDragContext *context,
4285 GtkSelectionData *selection_data,
4286 guint info,
4287 guint time,
4288 gpointer user_data)
4289{
4290 FrWindow *window = user_data;
4291 GList *file_list;
4292 char *destination;
4293 char *destination_folder;
4294
4295 debug (DEBUG_INFO"fr-window.c", 4295, __FUNCTION__, "::DragDataGet -->\n");
4296
4297 if (window->priv->activity_ref > 0)
4298 return FALSE(0);
4299
4300 file_list = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0));
4301 if (file_list == NULL((void*)0))
4302 return FALSE(0);
4303
4304 if (gtk_selection_data_get_target (selection_data) == XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0))) {
4305 FrClipboardData *tmp;
4306 char *data;
4307
4308 tmp = fr_clipboard_data_new ();
4309 tmp->files = file_list;
4310 tmp->op = FR_CLIPBOARD_OP_COPY;
4311 tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4312
4313 data = get_selection_data_from_clipboard_data (window, tmp);
4314 gtk_selection_data_set (selection_data, XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0)), 8, (guchar *) data, strlen (data));
4315
4316 fr_clipboard_data_unref (tmp);
4317 g_free (data);
4318
4319 return TRUE(!(0));
4320 }
4321
4322 if (! caja_xds_dnd_is_valid_xds_context (context))
4323 return FALSE(0);
4324
4325 destination = get_xds_atom_value (context);
4326 g_return_val_if_fail (destination != NULL, FALSE)do { if ((destination != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "destination != NULL"
); return ((0)); } } while (0)
;
4327
4328 destination_folder = remove_level_from_path (destination);
4329 g_free (destination);
4330
4331 /* check whether the extraction can be performed in the destination
4332 * folder */
4333
4334 g_clear_error (&window->priv->drag_error);
4335
4336 if (! check_permissions (destination_folder, R_OK4 | W_OK2)) {
4337 char *destination_folder_display_name;
4338
4339 destination_folder_display_name = g_filename_display_name (destination_folder);
4340 window->priv->drag_error = g_error_new (FR_ERRORfr_error_quark (), 0, _("You don't have the right permissions to extract archives in the folder \"%s\"")gettext ("You don't have the right permissions to extract archives in the folder \"%s\""
)
, destination_folder_display_name);
4341 g_free (destination_folder_display_name);
4342 }
4343
4344 if (window->priv->drag_error == NULL((void*)0)) {
4345 g_free (window->priv->drag_destination_folder);
4346 g_free (window->priv->drag_base_dir);
4347 path_list_free (window->priv->drag_file_list);
4348 window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder);
4349 window->priv->drag_base_dir = fr_window_get_selected_folder_in_tree_view (window);
4350 window->priv->drag_file_list = file_list;
4351 }
4352
4353 g_free (destination_folder);
4354
4355 /* sends back the response */
4356
4357 gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL((void*)0)) ? "S" : "E"), 1);
4358
4359 debug (DEBUG_INFO"fr-window.c", 4359, __FUNCTION__, "::DragDataGet <--\n");
4360
4361 return TRUE(!(0));
4362}
4363
4364gboolean
4365fr_window_file_list_drag_data_get (FrWindow *window,
4366 GdkDragContext *context,
4367 GtkSelectionData *selection_data,
4368 GList *path_list)
4369{
4370 char *destination;
4371 char *destination_folder;
4372
4373 debug (DEBUG_INFO"fr-window.c", 4373, __FUNCTION__, "::DragDataGet -->\n");
4374
4375 if (window->priv->path_clicked != NULL((void*)0)) {
4376 gtk_tree_path_free (window->priv->path_clicked);
4377 window->priv->path_clicked = NULL((void*)0);
4378 }
4379
4380 if (window->priv->activity_ref > 0)
4381 return FALSE(0);
4382
4383 if (gtk_selection_data_get_target (selection_data) == XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0))) {
4384 FrClipboardData *tmp;
4385 char *data;
4386
4387 tmp = fr_clipboard_data_new ();
4388 tmp->files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0));
4389 tmp->op = FR_CLIPBOARD_OP_COPY;
4390 tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4391
4392 data = get_selection_data_from_clipboard_data (window, tmp);
4393 gtk_selection_data_set (selection_data, XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0)), 8, (guchar *) data, strlen (data));
4394
4395 fr_clipboard_data_unref (tmp);
4396 g_free (data);
4397
4398 return TRUE(!(0));
4399 }
4400
4401 if (! caja_xds_dnd_is_valid_xds_context (context))
4402 return FALSE(0);
4403
4404 destination = get_xds_atom_value (context);
4405 g_return_val_if_fail (destination != NULL, FALSE)do { if ((destination != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "destination != NULL"
); return ((0)); } } while (0)
;
4406
4407 destination_folder = remove_level_from_path (destination);
4408 g_free (destination);
4409
4410 /* check whether the extraction can be performed in the destination
4411 * folder */
4412
4413 g_clear_error (&window->priv->drag_error);
4414
4415 if (! check_permissions (destination_folder, R_OK4 | W_OK2)) {
4416 char *destination_folder_display_name;
4417
4418 destination_folder_display_name = g_filename_display_name (destination_folder);
4419 window->priv->drag_error = g_error_new (FR_ERRORfr_error_quark (), 0, _("You don't have the right permissions to extract archives in the folder \"%s\"")gettext ("You don't have the right permissions to extract archives in the folder \"%s\""
)
, destination_folder_display_name);
4420 g_free (destination_folder_display_name);
4421 }
4422
4423 if (window->priv->drag_error == NULL((void*)0)) {
4424 g_free (window->priv->drag_destination_folder);
4425 g_free (window->priv->drag_base_dir);
4426 path_list_free (window->priv->drag_file_list);
4427 window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder);
4428 window->priv->drag_base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4429 window->priv->drag_file_list = fr_window_get_file_list_from_path_list (window, path_list, NULL((void*)0));
4430 }
4431
4432 g_free (destination_folder);
4433
4434 /* sends back the response */
4435
4436 gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL((void*)0)) ? "S" : "E"), 1);
4437
4438 debug (DEBUG_INFO"fr-window.c", 4438, __FUNCTION__, "::DragDataGet <--\n");
4439
4440 return TRUE(!(0));
4441}
4442
4443/* -- window_new -- */
4444
4445static void
4446fr_window_deactivate_filter (FrWindow *window)
4447{
4448 window->priv->filter_mode = FALSE(0);
4449 window->priv->list_mode = window->priv->last_list_mode;
4450
4451 gtk_entry_set_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
, "");
4452 fr_window_update_filter_bar_visibility (window);
4453
4454 gtk_list_store_clear (window->priv->list_store);
4455
4456 fr_window_update_columns_visibility (window);
4457 fr_window_update_file_list (window, TRUE(!(0)));
4458 fr_window_update_dir_tree (window);
4459 fr_window_update_current_location (window);
4460}
4461
4462static gboolean
4463key_press_cb (GtkWidget *widget,
4464 GdkEventKey *event,
4465 gpointer data)
4466{
4467 FrWindow *window = data;
4468 gboolean retval = FALSE(0);
4469 gboolean alt;
4470
4471 if (gtk_widget_has_focus (window->priv->location_entry))
4472 return FALSE(0);
4473
4474 if (gtk_widget_has_focus (window->priv->filter_entry)) {
4475 switch (event->keyval) {
4476 case GDK_KEY_Escape0xff1b:
4477 fr_window_deactivate_filter (window);
4478 retval = TRUE(!(0));
4479 break;
4480 default:
4481 break;
4482 }
4483 return retval;
4484 }
4485
4486 alt = (event->state & GDK_MOD1_MASK) == GDK_MOD1_MASK;
4487
4488 switch (event->keyval) {
4489 case GDK_KEY_Escape0xff1b:
4490 activate_action_stop (NULL((void*)0), NULL((void*)0), window);
4491 if (window->priv->filter_mode)
4492 fr_window_deactivate_filter (window);
4493 retval = TRUE(!(0));
4494 break;
4495
4496 case GDK_KEY_F100xffc7:
4497 if (event->state & GDK_SHIFT_MASK) {
4498 GtkTreeSelection *selection;
4499
4500 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
4501 if (selection == NULL((void*)0))
4502 return FALSE(0);
4503
4504 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->file_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->file_popup_menu)), ((gtk_menu_get_type
()))))))
,
4505 (const GdkEvent*) event);
4506 retval = TRUE(!(0));
4507 }
4508 break;
4509
4510 case GDK_KEY_Up0xff52:
4511 case GDK_KEY_KP_Up0xff97:
4512 if (alt) {
4513 fr_window_go_up_one_level (window);
4514 retval = TRUE(!(0));
4515 }
4516 break;
4517
4518 case GDK_KEY_BackSpace0xff08:
4519 fr_window_go_up_one_level (window);
4520 retval = TRUE(!(0));
4521 break;
4522
4523 case GDK_KEY_Right0xff53:
4524 case GDK_KEY_KP_Right0xff98:
4525 if (alt) {
4526 fr_window_go_forward (window);
4527 retval = TRUE(!(0));
4528 }
4529 break;
4530
4531 case GDK_KEY_Left0xff51:
4532 case GDK_KEY_KP_Left0xff96:
4533 if (alt) {
4534 fr_window_go_back (window);
4535 retval = TRUE(!(0));
4536 }
4537 break;
4538
4539 case GDK_KEY_Home0xff50:
4540 case GDK_KEY_KP_Home0xff95:
4541 if (alt) {
4542 fr_window_go_to_location (window, "/", FALSE(0));
4543 retval = TRUE(!(0));
4544 }
4545 break;
4546
4547 default:
4548 break;
4549 }
4550
4551 return retval;
4552}
4553
4554static gboolean
4555dir_tree_selection_changed_cb (GtkTreeSelection *selection,
4556 gpointer user_data)
4557{
4558 FrWindow *window = user_data;
4559 GtkTreeIter iter;
4560
4561 if (gtk_tree_selection_get_selected (selection, NULL((void*)0), &iter)) {
4562 char *path;
4563
4564 gtk_tree_model_get (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
,
4565 &iter,
4566 TREE_COLUMN_PATH, &path,
4567 -1);
4568 fr_window_go_to_location (window, path, FALSE(0));
4569 g_free (path);
4570 }
4571
4572 return FALSE(0);
4573}
4574
4575static gboolean
4576selection_changed_cb (GtkTreeSelection *selection,
4577 gpointer user_data)
4578{
4579 FrWindow *window = user_data;
4580
4581 fr_window_update_statusbar_list_info (window);
4582 fr_window_update_sensitivity (window);
4583
4584 return FALSE(0);
4585}
4586
4587static void
4588fr_window_delete_event_cb (GtkWidget *caller,
4589 GdkEvent *event,
4590 FrWindow *window)
4591{
4592 fr_window_close (window);
4593}
4594
4595static gboolean
4596is_single_click_policy (FrWindow *window)
4597{
4598 gboolean result = FALSE(0);
4599
4600 if (window->priv->settings_caja) {
4601 char *value;
4602
4603 value = g_settings_get_string (window->priv->settings_caja, CAJA_CLICK_POLICY"click-policy");
4604 result = (value != NULL((void*)0)) && (strncmp (value, "single", 6) == 0);
4605 g_free (value);
4606 }
4607
4608 return result;
4609}
4610
4611static void
4612filename_cell_data_func (GtkTreeViewColumn *column,
4613 GtkCellRenderer *renderer,
4614 GtkTreeModel *model,
4615 GtkTreeIter *iter,
4616 FrWindow *window)
4617{
4618 char *text;
4619 PangoUnderline underline;
4620
4621 gtk_tree_model_get (model, iter,
4622 COLUMN_NAME, &text,
4623 -1);
4624
4625 if (window->priv->single_click) {
4626 GtkTreePath *path;
4627
4628 path = gtk_tree_model_get_path (model, iter);
4629
4630 if ((window->priv->list_hover_path == NULL((void*)0))
4631 || gtk_tree_path_compare (path, window->priv->list_hover_path))
4632 underline = PANGO_UNDERLINE_NONE;
4633 else
4634 underline = PANGO_UNDERLINE_SINGLE;
4635
4636 gtk_tree_path_free (path);
4637 }
4638 else
4639 underline = PANGO_UNDERLINE_NONE;
4640
4641 g_object_set (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
,
4642 "text", text,
4643 "underline", underline,
4644 NULL((void*)0));
4645
4646 g_free (text);
4647}
4648
4649static void
4650add_dir_tree_columns (FrWindow *window,
4651 GtkTreeView *treeview)
4652{
4653 GtkCellRenderer *renderer;
4654 GtkTreeViewColumn *column;
4655 GValue value = { 0, };
4656
4657 /* First column. */
4658
4659 column = gtk_tree_view_column_new ();
4660 gtk_tree_view_column_set_title (column, _("Folders")gettext ("Folders"));
4661
4662 /* icon */
4663
4664 renderer = gtk_cell_renderer_pixbuf_new ();
4665 gtk_tree_view_column_pack_start (column, renderer, FALSE(0));
4666 gtk_tree_view_column_set_attributes (column, renderer,
4667 "pixbuf", TREE_COLUMN_ICON,
4668 NULL((void*)0));
4669
4670 /* name */
4671
4672 renderer = gtk_cell_renderer_text_new ();
4673
4674 g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()));
4675 g_value_set_enum (&value, PANGO_ELLIPSIZE_END);
4676 g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
, "ellipsize", &value);
4677 g_value_unset (&value);
4678
4679 gtk_tree_view_column_pack_start (column,
4680 renderer,
4681 TRUE(!(0)));
4682 gtk_tree_view_column_set_attributes (column, renderer,
4683 "text", TREE_COLUMN_NAME,
4684 "weight", TREE_COLUMN_WEIGHT,
4685 NULL((void*)0));
4686
4687 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
4688 gtk_tree_view_column_set_sort_column_id (column, TREE_COLUMN_NAME);
4689
4690 gtk_tree_view_append_column (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
, column);
4691}
4692
4693static void
4694add_file_list_columns (FrWindow *window,
4695 GtkTreeView *treeview)
4696{
4697 static const char *titles[] = {NC_("File", "Size")("Size"),
4698 NC_("File", "Type")("Type"),
4699 NC_("File", "Date Modified")("Date Modified"),
4700 NC_("File", "Location")("Location")};
4701 GtkCellRenderer *renderer;
4702 GtkTreeViewColumn *column;
4703 GValue value = { 0, };
4704 int i, j, w;
4705
4706 /* First column. */
4707
4708 window->priv->filename_column = column = gtk_tree_view_column_new ();
4709 gtk_tree_view_column_set_title (column, C_("File", "Name")g_dpgettext (((void*)0), "File" "\004" "Name", strlen ("File"
) + 1)
);
4710
4711 /* emblem */
4712
4713 renderer = gtk_cell_renderer_pixbuf_new ();
4714 gtk_tree_view_column_pack_end (column, renderer, FALSE(0));
4715 gtk_tree_view_column_set_attributes (column, renderer,
4716 "pixbuf", COLUMN_EMBLEM,
4717 NULL((void*)0));
4718
4719 /* icon */
4720
4721 renderer = gtk_cell_renderer_pixbuf_new ();
4722 gtk_tree_view_column_pack_start (column, renderer, FALSE(0));
4723 gtk_tree_view_column_set_attributes (column, renderer,
4724 "pixbuf", COLUMN_ICON,
4725 NULL((void*)0));
4726
4727 /* name */
4728
4729 window->priv->single_click = is_single_click_policy (window);
4730
4731 renderer = gtk_cell_renderer_text_new ();
4732
4733 g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()));
4734 g_value_set_enum (&value, PANGO_ELLIPSIZE_END);
4735 g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
, "ellipsize", &value);
4736 g_value_unset (&value);
4737
4738 gtk_tree_view_column_pack_start (column,
4739 renderer,
4740 TRUE(!(0)));
4741 gtk_tree_view_column_set_attributes (column, renderer,
4742 "text", COLUMN_NAME,
4743 NULL((void*)0));
4744
4745 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
4746 w = g_settings_get_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width");
4747 if (w <= 0)
4748 w = DEFAULT_NAME_COLUMN_WIDTH250;
4749 gtk_tree_view_column_set_fixed_width (column, w);
4750 gtk_tree_view_column_set_resizable (column, TRUE(!(0)));
4751 gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
4752 gtk_tree_view_column_set_cell_data_func (column, renderer,
4753 (GtkTreeCellDataFunc) filename_cell_data_func,
4754 window, NULL((void*)0));
4755
4756 gtk_tree_view_append_column (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
, column);
4757
4758 /* Other columns */
4759
4760 for (j = 0, i = COLUMN_SIZE; i < NUMBER_OF_COLUMNS; i++, j++) {
4761 GValue value_oc = { 0, };
4762
4763 renderer = gtk_cell_renderer_text_new ();
4764 column = gtk_tree_view_column_new_with_attributes (g_dpgettext2 (NULL((void*)0), "File", titles[j]),
4765 renderer,
4766 "text", i,
4767 NULL((void*)0));
4768
4769 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
4770 gtk_tree_view_column_set_fixed_width (column, OTHER_COLUMNS_WIDTH100);
4771 gtk_tree_view_column_set_resizable (column, TRUE(!(0)));
4772
4773 gtk_tree_view_column_set_sort_column_id (column, i);
4774
4775 g_value_init (&value_oc, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()));
4776 g_value_set_enum (&value_oc, PANGO_ELLIPSIZE_END);
4777 g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
, "ellipsize", &value_oc);
4778 g_value_unset (&value_oc);
4779
4780 gtk_tree_view_append_column (treeview, column);
4781 }
4782}
4783
4784static int
4785name_column_sort_func (GtkTreeModel *model,
4786 GtkTreeIter *a,
4787 GtkTreeIter *b,
4788 gpointer user_data)
4789{
4790 FileData *fdata1, *fdata2;
4791
4792 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4793 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4794
4795 return sort_by_name (&fdata1, &fdata2);
4796}
4797
4798static int
4799size_column_sort_func (GtkTreeModel *model,
4800 GtkTreeIter *a,
4801 GtkTreeIter *b,
4802 gpointer user_data)
4803{
4804 FileData *fdata1, *fdata2;
4805
4806 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4807 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4808
4809 return sort_by_size (&fdata1, &fdata2);
4810}
4811
4812static int
4813type_column_sort_func (GtkTreeModel *model,
4814 GtkTreeIter *a,
4815 GtkTreeIter *b,
4816 gpointer user_data)
4817{
4818 FileData *fdata1, *fdata2;
4819
4820 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4821 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4822
4823 return sort_by_type (&fdata1, &fdata2);
4824}
4825
4826static int
4827time_column_sort_func (GtkTreeModel *model,
4828 GtkTreeIter *a,
4829 GtkTreeIter *b,
4830 gpointer user_data)
4831{
4832 FileData *fdata1, *fdata2;
4833
4834 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4835 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4836
4837 return sort_by_time (&fdata1, &fdata2);
4838}
4839
4840static int
4841path_column_sort_func (GtkTreeModel *model,
4842 GtkTreeIter *a,
4843 GtkTreeIter *b,
4844 gpointer user_data)
4845{
4846 FileData *fdata1, *fdata2;
4847
4848 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4849 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4850
4851 return sort_by_path (&fdata1, &fdata2);
4852}
4853
4854static int
4855no_sort_column_sort_func (GtkTreeModel *model,
4856 GtkTreeIter *a,
4857 GtkTreeIter *b,
4858 gpointer user_data)
4859{
4860 return -1;
4861}
4862
4863static void
4864sort_column_changed_cb (GtkTreeSortable *sortable,
4865 gpointer user_data)
4866{
4867 FrWindow *window = user_data;
4868 GtkSortType order;
4869 int column_id;
4870
4871 if (! gtk_tree_sortable_get_sort_column_id (sortable,
4872 &column_id,
4873 &order))
4874 return;
4875
4876 window->priv->sort_method = get_sort_method_from_column (column_id);
4877 window->priv->sort_type = order;
4878}
4879
4880static gboolean
4881fr_window_show_cb (GtkWidget *widget,
4882 FrWindow *window)
4883{
4884 fr_window_update_current_location (window);
4885
4886 set_active (window, "ViewToolbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar"));
4887 set_active (window, "ViewStatusbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar"));
4888
4889 window->priv->view_folders = g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_FOLDERS"view-folders");
4890 set_active (window, "ViewFolders", window->priv->view_folders);
4891
4892 fr_window_update_filter_bar_visibility (window);
4893
4894 return TRUE(!(0));
4895}
4896
4897/* preferences changes notification callbacks */
4898
4899static void
4900pref_history_len_changed (GSettings *settings,
4901 const char *key,
4902 gpointer user_data)
4903{
4904 FrWindow *window = user_data;
4905 int limit;
4906
4907 limit = g_settings_get_int (settings, PREF_UI_HISTORY_LEN"history-len");
4908
4909 gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (window->priv->menubar_recentmenu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((window->priv->menubar_recentmenu)), (
(gtk_recent_chooser_get_type ()))))))
, limit);
4910 gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (window->priv->toolbar_recentmenu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((window->priv->toolbar_recentmenu)), (
(gtk_recent_chooser_get_type ()))))))
, limit);
4911}
4912
4913static void
4914pref_view_toolbar_changed (GSettings *settings,
4915 const char *key,
4916 gpointer user_data)
4917{
4918 FrWindow *window = user_data;
4919 fr_window_set_toolbar_visibility (window, g_settings_get_boolean (settings, key));
4920}
4921
4922static void
4923pref_view_statusbar_changed (GSettings *settings,
4924 const char *key,
4925 gpointer user_data)
4926{
4927 FrWindow *window = user_data;
4928
4929 fr_window_set_statusbar_visibility (window, g_settings_get_boolean (settings, key));
4930}
4931
4932static void
4933pref_view_folders_changed (GSettings *settings,
4934 const char *key,
4935 gpointer user_data)
4936{
4937 FrWindow *window = user_data;
4938
4939 fr_window_set_folders_visibility (window, g_settings_get_boolean (settings, key));
4940}
4941
4942static void
4943pref_show_field_changed (GSettings *settings,
4944 const char *key,
4945 gpointer user_data)
4946{
4947 FrWindow *window = user_data;
4948
4949 fr_window_update_columns_visibility (window);
4950}
4951
4952static void
4953pref_click_policy_changed (GSettings *settings,
4954 const char *key,
4955 gpointer user_data)
4956{
4957 FrWindow *window = user_data;
4958 GdkWindow *win = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
4959 GdkDisplay *display;
4960
4961 window->priv->single_click = is_single_click_policy (window);
4962
4963 gdk_window_set_cursor (win, NULL((void*)0));
4964 display = gtk_widget_get_display (GTK_WIDGET (window->priv->list_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_widget_get_type (
)))))))
);
4965 if (display != NULL((void*)0))
4966 gdk_display_flush (display);
4967}
4968
4969static void
4970pref_use_mime_icons_changed (GSettings *settings,
4971 const char *key,
4972 gpointer user_data)
4973{
4974 FrWindow *window = user_data;
4975
4976 if (tree_pixbuf_hash != NULL((void*)0)) {
4977 g_hash_table_foreach (tree_pixbuf_hash,
4978 gh_unref_pixbuf,
4979 NULL((void*)0));
4980 g_hash_table_destroy (tree_pixbuf_hash);
4981 tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal);
4982 }
4983
4984 fr_window_update_file_list (window, FALSE(0));
4985 fr_window_update_dir_tree (window);
4986}
4987
4988static void
4989theme_changed_cb (GtkIconTheme *theme, FrWindow *window)
4990{
4991 file_list_icon_size = _gtk_widget_lookup_for_size (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FILE_LIST_ICON_SIZEGTK_ICON_SIZE_LARGE_TOOLBAR);
4992
4993 if (tree_pixbuf_hash != NULL((void*)0)) {
4994 g_hash_table_foreach (tree_pixbuf_hash,
4995 gh_unref_pixbuf,
4996 NULL((void*)0));
4997 g_hash_table_destroy (tree_pixbuf_hash);
4998 tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal);
4999 }
5000
5001 fr_window_update_file_list (window, TRUE(!(0)));
5002 fr_window_update_dir_tree (window);
5003}
5004
5005static gboolean
5006fr_window_stoppable_cb (FrCommand *command,
5007 gboolean stoppable,
5008 FrWindow *window)
5009{
5010 window->priv->stoppable = stoppable;
5011 set_sensitive (window, "stop_item", stoppable);
5012 set_sensitive (window, "tool_stop_item", stoppable);
5013 if (window->priv->progress_dialog != NULL((void*)0))
5014 gtk_dialog_set_response_sensitive (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
,
5015 GTK_RESPONSE_OK,
5016 stoppable);
5017 return TRUE(!(0));
5018}
5019
5020static gboolean
5021fr_window_fake_load (FrArchive *archive,
5022 gpointer data)
5023{
5024 /* fake loads are disabled to allow exact progress dialogs (#153281) */
5025
5026 return FALSE(0);
5027
5028#if 0
5029 FrWindow *window = data;
5030 gboolean add_after_opening = FALSE(0);
5031 gboolean extract_after_opening = FALSE(0);
5032 GList *scan;
5033
5034 /* fake loads are used only in batch mode to avoid unnecessary
5035 * archive loadings. */
5036
5037 if (! window->priv->batch_mode)
5038 return FALSE(0);
5039
5040 /* Check whether there is an ADD or EXTRACT action in the batch list. */
5041
5042 for (scan = window->priv->batch_action; scan; scan = scan->next) {
5043 FRBatchAction *action;
5044
5045 action = (FRBatchAction *) scan->data;
5046 if (action->type == FR_BATCH_ACTION_ADD) {
5047 add_after_opening = TRUE(!(0));
5048 break;
5049 }
5050 if ((action->type == FR_BATCH_ACTION_EXTRACT_HERE)
5051 || (action->type == FR_BATCH_ACTION_EXTRACT_INTERACT))
5052 {
5053 extract_after_opening = TRUE(!(0));
5054 break;
5055 }
5056 }
5057
5058 /* use fake load when in batch mode and the archive type supports all
5059 * of the required features */
5060
5061 return (window->priv->batch_mode
5062 && ! (add_after_opening && window->priv->update_dropped_files && ! archive->command->propAddCanUpdate)
5063 && ! (add_after_opening && ! window->priv->update_dropped_files && ! archive->command->propAddCanReplace)
5064 && ! (extract_after_opening && !archive->command->propCanExtractAll));
5065#endif
5066}
5067
5068static void
5069menu_item_select_cb (GtkMenuItem *proxy,
5070 FrWindow *window)
5071{
5072 char *message;
5073
5074 message = gtk_widget_get_tooltip_text (GTK_WIDGET (proxy)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((gtk_widget_get_type ()))))))
);
5075 if (message) {
5076 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
5077 window->priv->help_message_cid, message);
5078 g_free (message);
5079 }
5080}
5081
5082static void
5083menu_item_deselect_cb (GtkMenuItem *proxy,
5084 FrWindow *window)
5085{
5086 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
5087 window->priv->help_message_cid);
5088}
5089
5090static void
5091view_all_files_selected_toggled (GtkMenuItem *menuitem,
5092 gpointer data)
5093{
5094 FrWindow *window = data;
5095
5096 if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)((((GtkCheckMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_check_menu_item_get_type (
)))))))
))
5097 fr_window_set_list_mode (window, FR_WINDOW_LIST_MODE_FLAT);
5098 else
5099 fr_window_set_list_mode (window, FR_WINDOW_LIST_MODE_AS_DIR);
5100}
5101
5102static void
5103recent_chooser_item_activated_cb (GtkRecentChooser *chooser,
5104 FrWindow *window)
5105{
5106 char *uri;
5107
5108 uri = gtk_recent_chooser_get_current_uri (chooser);
5109 if (uri != NULL((void*)0)) {
5110 fr_window_archive_open (window, uri, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
5111 g_free (uri);
5112 }
5113}
5114
5115static GtkWidget *
5116fr_window_create_recent_chooser (FrWindow *window)
5117{
5118 GtkRecentManager *manager;
5119 GtkRecentFilter *filter;
5120 GtkWidget *menu;
5121 int i;
5122
5123 manager = gtk_recent_manager_get_default ();
5124 menu = gtk_recent_chooser_menu_new_for_manager (manager);
5125
5126 filter = gtk_recent_filter_new ();
5127 gtk_recent_filter_set_name (filter, _("All archives")gettext ("All archives"));
5128 for (i = 0; open_type[i] != -1; i++)
5129 gtk_recent_filter_add_mime_type (filter, mime_type_desc[open_type[i]].mime_type);
5130 gtk_recent_filter_add_application (filter, "Engrampa");
5131 gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, filter);
5132
5133 gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, FALSE(0));
5134 gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, g_settings_get_int (window->priv->settings_ui, PREF_UI_HISTORY_LEN"history-len"));
5135 gtk_recent_chooser_set_show_not_found (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, TRUE(!(0)));
5136 gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, GTK_RECENT_SORT_MRU);
5137
5138 g_signal_connect (G_OBJECT (menu),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5139 "item_activated",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5140 G_CALLBACK (recent_chooser_item_activated_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5141 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5142 return menu;
5143}
5144
5145static void
5146close_sidepane_button_clicked_cb (GtkButton *button,
5147 FrWindow *window)
5148{
5149 fr_window_set_folders_visibility (window, FALSE(0));
5150}
5151
5152static void
5153fr_window_activate_filter (FrWindow *window)
5154{
5155 GtkTreeView *tree_view = GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
;
5156 GtkTreeViewColumn *column;
5157
5158 fr_window_update_filter_bar_visibility (window);
5159 window->priv->list_mode = FR_WINDOW_LIST_MODE_FLAT;
5160
5161 gtk_list_store_clear (window->priv->list_store);
5162
5163 column = gtk_tree_view_get_column (tree_view, 4);
5164 gtk_tree_view_column_set_visible (column, TRUE(!(0)));
5165
5166 fr_window_update_file_list (window, TRUE(!(0)));
5167 fr_window_update_dir_tree (window);
5168 fr_window_update_current_location (window);
5169}
5170
5171static void
5172filter_entry_activate_cb (GtkEntry *entry,
5173 FrWindow *window)
5174{
5175 fr_window_activate_filter (window);
5176}
5177
5178static void
5179filter_entry_icon_release_cb (GtkEntry *entry,
5180 GtkEntryIconPosition icon_pos,
5181 GdkEventButton *event,
5182 gpointer user_data)
5183{
5184 FrWindow *window = FR_WINDOW (user_data)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((fr_window_get_type ()))))))
;
5185
5186 if ((event->button == 1) && (icon_pos == GTK_ENTRY_ICON_SECONDARY))
5187 fr_window_deactivate_filter (window);
5188}
5189
5190static void
5191fr_window_attach (FrWindow *window,
5192 GtkWidget *child,
5193 FrWindowArea area)
5194{
5195 int position;
5196
5197 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
5198 g_return_if_fail (FR_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((fr_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "FR_IS_WINDOW (window)"); return; } } while (0
)
;
5199 g_return_if_fail (child != NULL)do { if ((child != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "child != NULL");
return; } } while (0)
;
5200 g_return_if_fail (GTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((child)); GType __t = ((gtk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GTK_IS_WIDGET (child)"); return; } } while (0
)
;
5201
5202 switch (area) {
5203 case FR_WINDOW_AREA_MENUBAR:
5204 position = 0;
5205 break;
5206 case FR_WINDOW_AREA_TOOLBAR:
5207 position = 1;
5208 break;
5209 case FR_WINDOW_AREA_LOCATIONBAR:
5210 position = 2;
5211 break;
5212 case FR_WINDOW_AREA_CONTENTS:
5213 position = 3;
5214 if (window->priv->contents != NULL((void*)0))
5215 gtk_widget_destroy (window->priv->contents);
5216 window->priv->contents = child;
5217 gtk_widget_set_vexpand (child, TRUE(!(0)));
5218 break;
5219 case FR_WINDOW_AREA_FILTERBAR:
5220 position = 4;
5221 break;
5222 case FR_WINDOW_AREA_STATUSBAR:
5223 position = 5;
5224 break;
5225 default:
5226 g_critical ("%s: area not recognized!", G_STRFUNC((const char*) (__func__)));
5227 return;
5228 break;
5229 }
5230
5231 gtk_widget_set_hexpand (child, TRUE(!(0)));
5232 gtk_grid_attach (GTK_GRID (window->priv->layout)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->layout)), ((gtk_grid_get_type ()))))
))
,
5233 child,
5234 0, position,
5235 1, 1);
5236}
5237
5238static void
5239fr_window_construct (FrWindow *window)
5240{
5241 GtkWidget *menubar;
5242 GtkWidget *toolbar;
5243 GtkWidget *list_scrolled_window;
5244 GtkWidget *location_box;
5245 GtkStatusbar *statusbar;
5246 GtkWidget *statusbar_box;
5247 GtkWidget *filter_box;
5248 GtkWidget *tree_scrolled_window;
5249 GtkWidget *sidepane_title;
5250 GtkWidget *sidepane_title_box;
5251 GtkWidget *sidepane_title_label;
5252 GtkWidget *close_sidepane_button;
5253 GtkWidget *menu_radio_files;
5254 GtkWidget *menuitem;
5255 GtkTreeSelection *selection;
5256 GActionGroup *actions;
5257 GSimpleAction *action;
5258 GtkAccelGroup *accel_group;
5259 GtkBuilder *ui;
5260 GError *error = NULL((void*)0);
5261 GSettingsSchemaSource *schema_source;
5262 GSettingsSchema *caja_schema;
5263
5264 /* data common to all windows. */
5265
5266 if (tree_pixbuf_hash == NULL((void*)0))
5267 tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal);
5268
5269 if (icon_theme == NULL((void*)0))
5270 icon_theme = gtk_icon_theme_get_default ();
5271
5272 /* Create the settings objects */
5273
5274 window->priv->settings_listing = g_settings_new (ENGRAMPA_SCHEMA_LISTING"org.mate.engrampa" ".listing");
5275 window->priv->settings_ui = g_settings_new (ENGRAMPA_SCHEMA_UI"org.mate.engrampa" ".ui");
5276 window->priv->settings_general = g_settings_new (ENGRAMPA_SCHEMA_GENERAL"org.mate.engrampa" ".general");
5277 window->priv->settings_dialogs = g_settings_new (ENGRAMPA_SCHEMA_DIALOGS"org.mate.engrampa" ".dialogs");
5278
5279 schema_source = g_settings_schema_source_get_default ();
5280 caja_schema = g_settings_schema_source_lookup (schema_source, CAJA_SCHEMA"org.mate.caja.preferences", FALSE(0));
5281 if (caja_schema) {
5282 window->priv->settings_caja = g_settings_new (CAJA_SCHEMA"org.mate.caja.preferences");
5283 g_settings_schema_unref (caja_schema);
5284 }
5285
5286 /* Create the application. */
5287
5288 window->priv->layout = gtk_grid_new ();
5289 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, window->priv->layout);
5290 gtk_widget_show (window->priv->layout);
5291
5292 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, _("Archive Manager")gettext ("Archive Manager"));
5293
5294 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5295 "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5296 G_CALLBACK (fr_window_delete_event_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5297 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5298
5299 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
5300 "show",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
5301 G_CALLBACK (fr_window_show_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
5302 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
;
5303
5304 window->priv->theme_changed_handler_id =
5305 g_signal_connect (icon_theme,g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
5306 "changed",g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
5307 G_CALLBACK (theme_changed_cb),g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
5308 window)g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
;
5309
5310 file_list_icon_size = _gtk_widget_lookup_for_size (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FILE_LIST_ICON_SIZEGTK_ICON_SIZE_LARGE_TOOLBAR);
5311
5312 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
5313 g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width"),
5314 g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height"));
5315
5316 gtk_drag_dest_set (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
5317 GTK_DEST_DEFAULT_ALL,
5318 target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])),
5319 GDK_ACTION_COPY);
5320
5321 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
5322 "drag_data_received",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
5323 G_CALLBACK (fr_window_drag_data_received),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
5324 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
;
5325 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
5326 "drag_motion",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
5327 G_CALLBACK (fr_window_drag_motion),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
5328 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
;
5329
5330 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
5331 "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
5332 G_CALLBACK (key_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
5333 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
;
5334
5335 /* Initialize Data. */
5336
5337 window->archive = fr_archive_new ();
5338 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
5339 "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
5340 G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
5341 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
;
5342 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
5343 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
5344 G_CALLBACK (action_performed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
5345 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
;
5346 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5347 "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5348 G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5349 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5350 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5351 "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5352 G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5353 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5354 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5355 "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5356 G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5357 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5358 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5359 "working_archive",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5360 G_CALLBACK (fr_window_working_archive_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5361 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5362
5363 fr_archive_set_fake_load_func (window->archive,
5364 fr_window_fake_load,
5365 window);
5366
5367 window->priv->sort_method = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method");
5368 window->priv->sort_type = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type");
5369
5370 window->priv->list_mode = window->priv->last_list_mode = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode");
5371 g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT));
5372
5373 window->priv->history = NULL((void*)0);
5374 window->priv->history_current = NULL((void*)0);
5375
5376 window->priv->action = FR_ACTION_NONE;
5377
5378 window->priv->open_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ());
5379 window->priv->add_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ());
5380 window->priv->extract_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ());
5381
5382 window->priv->give_focus_to_the_list = FALSE(0);
5383
5384 window->priv->activity_ref = 0;
5385 window->priv->activity_timeout_handle = 0;
5386
5387 window->priv->update_timeout_handle = 0;
5388
5389 window->priv->archive_present = FALSE(0);
5390 window->priv->archive_new = FALSE(0);
5391 window->priv->archive_uri = NULL((void*)0);
5392
5393 window->priv->drag_destination_folder = NULL((void*)0);
5394 window->priv->drag_base_dir = NULL((void*)0);
5395 window->priv->drag_error = NULL((void*)0);
5396 window->priv->drag_file_list = NULL((void*)0);
5397
5398 window->priv->batch_mode = FALSE(0);
5399 window->priv->batch_action_list = NULL((void*)0);
5400 window->priv->batch_action = NULL((void*)0);
5401 window->priv->extract_interact_use_default_dir = FALSE(0);
5402 window->priv->non_interactive = FALSE(0);
5403
5404 window->priv->password = NULL((void*)0);
5405 window->priv->compression = g_settings_get_enum (window->priv->settings_general, PREF_GENERAL_COMPRESSION_LEVEL"compression-level");
5406 window->priv->encrypt_header = g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_ENCRYPT_HEADER"encrypt-header");
5407 window->priv->volume_size = 0;
5408
5409 window->priv->convert_data.converting = FALSE(0);
5410 window->priv->convert_data.temp_dir = NULL((void*)0);
5411 window->priv->convert_data.new_archive = NULL((void*)0);
5412 window->priv->convert_data.password = NULL((void*)0);
5413 window->priv->convert_data.encrypt_header = FALSE(0);
5414 window->priv->convert_data.volume_size = 0;
5415
5416 window->priv->stoppable = TRUE(!(0));
5417
5418 window->priv->batch_adding_one_file = FALSE(0);
5419
5420 window->priv->path_clicked = NULL((void*)0);
5421
5422 window->priv->current_view_length = 0;
5423
5424 window->priv->current_batch_action.type = FR_BATCH_ACTION_NONE;
5425 window->priv->current_batch_action.data = NULL((void*)0);
5426 window->priv->current_batch_action.free_func = NULL((void*)0);
5427
5428 window->priv->pd_last_archive = NULL((void*)0);
5429 window->priv->pd_last_message = NULL((void*)0);
5430 window->priv->pd_last_fraction = 0.0;
5431
5432 /* Create the widgets. */
5433
5434 /* * File list. */
5435
5436 window->priv->list_store = fr_list_model_new (NUMBER_OF_COLUMNS,
5437 G_TYPE_POINTER((GType) ((17) << (2))),
5438 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()),
5439 G_TYPE_STRING((GType) ((16) << (2))),
5440 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()),
5441 G_TYPE_STRING((GType) ((16) << (2))),
5442 G_TYPE_STRING((GType) ((16) << (2))),
5443 G_TYPE_STRING((GType) ((16) << (2))),
5444 G_TYPE_STRING((GType) ((16) << (2))));
5445 g_object_set_data (G_OBJECT (window->priv->list_store)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), (((GType) ((20) <<
(2))))))))
, "FrWindow", window);
5446 window->priv->list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
);
5447
5448 add_file_list_columns (window, GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
5449 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
5450 TRUE(!(0)));
5451 gtk_tree_view_set_search_column (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
5452 COLUMN_NAME);
5453
5454 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5455 COLUMN_NAME, name_column_sort_func,
5456 NULL((void*)0), NULL((void*)0));
5457 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5458 COLUMN_SIZE, size_column_sort_func,
5459 NULL((void*)0), NULL((void*)0));
5460 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5461 COLUMN_TYPE, type_column_sort_func,
5462 NULL((void*)0), NULL((void*)0));
5463 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5464 COLUMN_TIME, time_column_sort_func,
5465 NULL((void*)0), NULL((void*)0));
5466 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5467 COLUMN_PATH, path_column_sort_func,
5468 NULL((void*)0), NULL((void*)0));
5469
5470 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5471 no_sort_column_sort_func,
5472 NULL((void*)0), NULL((void*)0));
5473
5474 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
5475 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
5476
5477 g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5478 "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5479 G_CALLBACK (selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5480 window)g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5481 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
5482 "row_activated",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
5483 G_CALLBACK (row_activated_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
5484 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
;
5485
5486 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5487 "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5488 G_CALLBACK (file_button_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5489 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5490 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5491 "button_release_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5492 G_CALLBACK (file_button_release_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5493 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5494 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5495 "motion_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5496 G_CALLBACK (file_motion_notify_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5497 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
;
5498 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5499 "leave_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5500 G_CALLBACK (file_leave_notify_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5501 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
;
5502
5503 g_signal_connect (G_OBJECT (window->priv->list_store),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5504 "sort_column_changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5505 G_CALLBACK (sort_column_changed_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5506 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5507
5508 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5509 "drag_begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5510 G_CALLBACK (file_list_drag_begin),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5511 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
;
5512 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5513 "drag_end",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5514 G_CALLBACK (file_list_drag_end),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5515 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
;
5516 egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
5517
5518 list_scrolled_window = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
5519 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((list_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5520 GTK_POLICY_AUTOMATIC,
5521 GTK_POLICY_AUTOMATIC);
5522 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (list_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((list_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5523 GTK_SHADOW_IN);
5524 gtk_container_add (GTK_CONTAINER (list_scrolled_window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_scrolled_window)), ((gtk_container_get_type ())))))
)
, window->priv->list_view);
5525
5526 /* filter bar */
5527
5528 window->priv->filter_bar = filter_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
5529 gtk_container_set_border_width (GTK_CONTAINER (filter_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((filter_box)), ((gtk_container_get_type ()))))))
, 3);
5530 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->filter_bar, FR_WINDOW_AREA_FILTERBAR);
5531
5532 gtk_box_pack_start (GTK_BOX (filter_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((filter_box)), ((gtk_box_get_type ()))))))
,
5533 gtk_label_new (_("Find:")gettext ("Find:")), FALSE(0), FALSE(0), 0);
5534
5535 /* * filter entry */
5536
5537 window->priv->filter_entry = GTK_WIDGET (gtk_entry_new ())((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_entry_new ())), ((gtk_widget_get_type ()))))))
;
5538 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
,
5539 GTK_ENTRY_ICON_SECONDARY,
5540 "edit-clear");
5541
5542 gtk_widget_set_size_request (window->priv->filter_entry, 300, -1);
5543 gtk_box_pack_start (GTK_BOX (filter_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((filter_box)), ((gtk_box_get_type ()))))))
,
5544 window->priv->filter_entry, FALSE(0), FALSE(0), 6);
5545
5546 g_signal_connect (G_OBJECT (window->priv->filter_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5547 "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5548 G_CALLBACK (filter_entry_activate_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5549 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5550 g_signal_connect (G_OBJECT (window->priv->filter_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5551 "icon-release",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5552 G_CALLBACK (filter_entry_icon_release_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5553 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5554
5555 gtk_widget_show_all (filter_box);
5556
5557 /* tree view */
5558
5559 window->priv->tree_store = gtk_tree_store_new (TREE_NUMBER_OF_COLUMNS,
5560 G_TYPE_STRING((GType) ((16) << (2))),
5561 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()),
5562 G_TYPE_STRING((GType) ((16) << (2))),
5563 PANGO_TYPE_WEIGHT(pango_weight_get_type ()));
5564 window->priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
);
5565 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
, FALSE(0));
5566 add_dir_tree_columns (window, GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
5567
5568 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5569 "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5570 G_CALLBACK (dir_tree_button_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5571 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5572
5573 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
5574 g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5575 "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5576 G_CALLBACK (dir_tree_selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5577 window)g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5578
5579 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5580 "drag_begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5581 G_CALLBACK (file_list_drag_begin),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5582 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
;
5583 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5584 "drag_end",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5585 G_CALLBACK (file_list_drag_end),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5586 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
;
5587 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
5588 "drag_data_get",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
5589 G_CALLBACK (fr_window_folder_tree_drag_data_get),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
5590 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
;
5591 gtk_drag_source_set (window->priv->tree_view,
5592 GDK_BUTTON1_MASK,
5593 folder_tree_targets, G_N_ELEMENTS (folder_tree_targets)(sizeof (folder_tree_targets) / sizeof ((folder_tree_targets)
[0]))
,
5594 GDK_ACTION_COPY);
5595
5596 tree_scrolled_window = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
5597 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tree_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((tree_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5598 GTK_POLICY_AUTOMATIC,
5599 GTK_POLICY_AUTOMATIC);
5600 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (tree_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((tree_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5601 GTK_SHADOW_IN);
5602 gtk_container_add (GTK_CONTAINER (tree_scrolled_window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_scrolled_window)), ((gtk_container_get_type ())))))
)
, window->priv->tree_view);
5603
5604 /* side pane */
5605
5606 window->priv->sidepane = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
5607
5608 sidepane_title = gtk_frame_new (NULL((void*)0));
5609 gtk_frame_set_shadow_type (GTK_FRAME (sidepane_title)((((GtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title)), ((gtk_frame_get_type ()))))))
, GTK_SHADOW_ETCHED_IN);
5610
5611 sidepane_title_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
5612 gtk_container_set_border_width (GTK_CONTAINER (sidepane_title_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_box)), ((gtk_container_get_type ()))))))
, 2);
5613 gtk_container_add (GTK_CONTAINER (sidepane_title)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title)), ((gtk_container_get_type ()))))))
, sidepane_title_box);
5614 sidepane_title_label = gtk_label_new (_("Folders")gettext ("Folders"));
5615
5616 gtk_label_set_xalign (GTK_LABEL (sidepane_title_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_label)), ((gtk_label_get_type ()))))))
, 0.0);
5617 gtk_box_pack_start (GTK_BOX (sidepane_title_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_box)), ((gtk_box_get_type ()))))))
, sidepane_title_label, TRUE(!(0)), TRUE(!(0)), 0);
5618
5619 close_sidepane_button = gtk_button_new ();
5620 gtk_container_add (GTK_CONTAINER (close_sidepane_button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((close_sidepane_button)), ((gtk_container_get_type ()))))
))
,
5621 gtk_image_new_from_icon_name ("window-close",
5622 GTK_ICON_SIZE_MENU));
5623 gtk_button_set_relief (GTK_BUTTON (close_sidepane_button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((close_sidepane_button)), ((gtk_button_get_type ()))))))
, GTK_RELIEF_NONE);
5624 gtk_widget_set_tooltip_text (close_sidepane_button, _("Close the folders pane")gettext ("Close the folders pane"));
5625 g_signal_connect (close_sidepane_button,g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
5626 "clicked",g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
5627 G_CALLBACK (close_sidepane_button_clicked_cb),g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
5628 window)g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
5629 gtk_box_pack_end (GTK_BOX (sidepane_title_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_box)), ((gtk_box_get_type ()))))))
, close_sidepane_button, FALSE(0), FALSE(0), 0);
5630
5631 gtk_box_pack_start (GTK_BOX (window->priv->sidepane)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->sidepane)), ((gtk_box_get_type ())))
)))
, sidepane_title, FALSE(0), FALSE(0), 0);
5632 gtk_box_pack_start (GTK_BOX (window->priv->sidepane)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->sidepane)), ((gtk_box_get_type ())))
)))
, tree_scrolled_window, TRUE(!(0)), TRUE(!(0)), 0);
5633
5634 /* main content */
5635
5636 window->priv->paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
5637 gtk_paned_pack1 (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
, window->priv->sidepane, FALSE(0), TRUE(!(0)));
5638 gtk_paned_pack2 (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
, list_scrolled_window, TRUE(!(0)), TRUE(!(0)));
5639 gtk_paned_set_position (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
, g_settings_get_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width"));
5640
5641 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->paned, FR_WINDOW_AREA_CONTENTS);
5642 gtk_widget_show_all (window->priv->paned);
5643
5644 /* Build the menu and the toolbar. */
5645
5646 window->priv->ui_manager = ui = gtk_builder_new ();
5647
5648 window->priv->actions = actions = (GActionGroup*)g_simple_action_group_new ();
5649
5650 /* other actions */
5651 g_action_map_add_action_entries (G_ACTION_MAP (actions)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((actions)), ((g_action_map_get_type ()))))))
,
5652 action_entries, G_N_ELEMENTS (action_entries)(sizeof (action_entries) / sizeof ((action_entries)[0])),
5653 window);
5654
5655 accel_group = gtk_accel_group_new ();
5656 gtk_widget_insert_action_group (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, "win", actions);
5657 gtk_window_add_accel_group (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, accel_group);
5658
5659 /* Add a hidden short cut Ctrl-Q for power users */
5660 gtk_accel_group_connect (accel_group,
5661 GDK_KEY_q0x071, GDK_CONTROL_MASK, 0,
5662 g_cclosure_new_swap (G_CALLBACK (fr_window_close)((GCallback) (fr_window_close)), window, NULL((void*)0)));
5663
5664 if (! gtk_builder_add_from_resource (ui, ENGRAMPA_RESOURCE_UI_PATH"/org/mate/Engrampa/ui" G_DIR_SEPARATOR_S"/" "menus-toolbars.ui", &error)) {
5665 g_message ("building menus failed: %s", error->message);
5666 g_error_free (error);
5667 }
5668 /*Add shortcut keys*/
5669 for (gulong i = 0; i < G_N_ELEMENTS (menu_keybindings)(sizeof (menu_keybindings) / sizeof ((menu_keybindings)[0])); i++)
5670 {
5671 menuitem = (GtkWidget*)gtk_builder_get_object (ui, menu_keybindings[i].widget_id);
5672 gtk_widget_add_accelerator (menuitem, "activate", accel_group,
5673 menu_keybindings[i].keyval,
5674 menu_keybindings[i].modifier,
5675 GTK_ACCEL_VISIBLE);
5676 }
5677
5678 gtk_builder_add_callback_symbols (ui,
5679 "menu_item_select_cb", G_CALLBACK (menu_item_select_cb)((GCallback) (menu_item_select_cb)),
5680 "menu_item_deselect_cb", G_CALLBACK (menu_item_deselect_cb)((GCallback) (menu_item_deselect_cb)),
5681 NULL((void*)0));
5682 gtk_builder_connect_signals (ui, window);
5683 /* open recent toolbar item action */
5684
5685 window->priv->menubar_recentmenu = fr_window_create_recent_chooser (window);
5686 menuitem = (GtkWidget *)gtk_builder_get_object (ui, "open_recent_item");
5687 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem)((((GtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, window->priv->menubar_recentmenu);
5688
5689 /* open recent toolbar item action */
5690 menuitem = (GtkWidget *)gtk_builder_get_object (ui, "tool_open_recent_item");
5691 window->priv->toolbar_recentmenu = fr_window_create_recent_chooser (window);
5692 gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (menuitem)((((GtkMenuToolButton*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((menuitem)), ((gtk_menu_tool_button_get_type
()))))))
, window->priv->toolbar_recentmenu);
5693
5694 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
5695 action = g_simple_action_new_stateful ("ViewAllFiles", G_VARIANT_TYPE ("s")(g_variant_type_checked_ (("s"))), g_variant_new_string ("files"));
5696 else
5697 action = g_simple_action_new_stateful ("ViewAllFiles", G_VARIANT_TYPE ("s")(g_variant_type_checked_ (("s"))), g_variant_new_string ("folder"));
5698
5699 g_action_map_add_action (G_ACTION_MAP (actions)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((actions)), ((g_action_map_get_type ()))))))
, G_ACTION (action)((((GAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((g_action_get_type ()))))))
);
5700 g_object_unref (action);
5701
5702 menubar = (GtkWidget *)gtk_builder_get_object (ui, "engrampamenubar");
5703 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, menubar, FR_WINDOW_AREA_MENUBAR);
5704 gtk_widget_show (menubar);
5705
5706 window->priv->toolbar = toolbar = (GtkWidget *)gtk_builder_get_object (ui, "engrampatoolbar");
5707 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((gtk_toolbar_get_type ()))))))
, TRUE(!(0)));
5708 gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar");
5709
5710 /* location bar */
5711
5712 window->priv->location_bar = (GtkWidget *)gtk_builder_get_object (ui, "locationbar");
5713 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, FALSE(0));
5714 gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, GTK_TOOLBAR_BOTH_HORIZ);
5715 gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar), GTK_STYLE_CLASS_TOOLBAR"toolbar");
5716
5717 init_engramp_menu_popup (window, ui);
5718
5719 /* file list mode */
5720 menu_radio_files = (GtkWidget *)gtk_builder_get_object (ui, "view_all_files_item");
5721 g_signal_connect (G_OBJECT (menu_radio_files),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
5722 "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
5723 G_CALLBACK (view_all_files_selected_toggled),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
5724 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
;
5725 /* current location */
5726
5727 location_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
5728 /* Translators: after the colon there is a folder name. */
5729 window->priv->location_label = gtk_label_new_with_mnemonic (_("_Location:")gettext ("_Location:"));
5730 gtk_box_pack_start (GTK_BOX (location_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((location_box)), ((gtk_box_get_type ()))))))
,
5731 window->priv->location_label, FALSE(0), FALSE(0), 5);
5732
5733 window->priv->location_entry = gtk_entry_new ();
5734 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->location_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_entry)), ((gtk_entry_get_type
()))))))
,
5735 GTK_ENTRY_ICON_PRIMARY,
5736 "folder");
5737 gtk_label_set_mnemonic_widget (GTK_LABEL (window->priv->location_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_label)), ((gtk_label_get_type
()))))))
,
5738 window->priv->location_entry);
5739
5740 gtk_box_pack_start (GTK_BOX (location_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((location_box)), ((gtk_box_get_type ()))))))
,
5741 window->priv->location_entry, TRUE(!(0)), TRUE(!(0)), 5);
5742
5743 g_signal_connect (G_OBJECT (window->priv->location_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
5744 "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
5745 G_CALLBACK (location_entry_key_press_event_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
5746 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
5747
5748 {
5749 GtkToolItem *tool_item;
5750
5751 tool_item = gtk_separator_tool_item_new ();
5752 gtk_widget_show_all (GTK_WIDGET (tool_item)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tool_item)), ((gtk_widget_get_type ()))))))
);
5753 gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, tool_item, -1);
5754
5755 tool_item = gtk_tool_item_new ();
5756 gtk_tool_item_set_expand (tool_item, TRUE(!(0)));
5757 gtk_container_add (GTK_CONTAINER (tool_item)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tool_item)), ((gtk_container_get_type ()))))))
, location_box);
5758 gtk_widget_show_all (GTK_WIDGET (tool_item)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tool_item)), ((gtk_widget_get_type ()))))))
);
5759 gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, tool_item, -1);
5760 }
5761
5762 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR);
5763 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
5764 gtk_widget_hide (window->priv->location_bar);
5765 else
5766 gtk_widget_show (window->priv->location_bar);
5767
5768 /**/
5769
5770 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->toolbar, FR_WINDOW_AREA_TOOLBAR);
5771 if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar"))
5772 gtk_widget_show (toolbar);
5773 else
5774 gtk_widget_hide (toolbar);
5775
5776 window->priv->file_popup_menu = (GtkWidget *)gtk_builder_get_object (ui, "FilePopupMenu");
5777 window->priv->folder_popup_menu = (GtkWidget *)gtk_builder_get_object (ui, "FolderPopupMenu");
5778 window->priv->sidebar_folder_popup_menu = (GtkWidget *)gtk_builder_get_object (ui, "SidebarFolderPopupMenu");
5779
5780 /* Create the statusbar. */
5781
5782 window->priv->statusbar = gtk_statusbar_new ();
5783 window->priv->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, "help_message");
5784 window->priv->list_info_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, "list_info");
5785 window->priv->progress_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, "progress");
5786
5787 statusbar = GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
;
5788
5789 /*reduce size of statusbar */
5790 gtk_widget_set_margin_top (GTK_WIDGET (statusbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar)), ((gtk_widget_get_type ()))))))
, 0);
5791 gtk_widget_set_margin_bottom (GTK_WIDGET (statusbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar)), ((gtk_widget_get_type ()))))))
, 0);
5792
5793 statusbar_box = gtk_statusbar_get_message_area (statusbar);
5794 gtk_box_set_homogeneous (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, FALSE(0));
5795 gtk_box_set_spacing (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, 4);
5796 gtk_box_set_child_packing (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, gtk_statusbar_get_message_area (statusbar), TRUE(!(0)), TRUE(!(0)), 0, GTK_PACK_START );
5797
5798 window->priv->progress_bar = gtk_progress_bar_new ();
5799 gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
, ACTIVITY_PULSE_STEP(0.033));
5800 gtk_widget_set_size_request (window->priv->progress_bar, -1, PROGRESS_BAR_HEIGHT10);
5801 {
5802 GtkWidget *vbox;
5803
5804 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
5805 gtk_box_pack_start (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
5806 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, window->priv->progress_bar, TRUE(!(0)), TRUE(!(0)), 1);
5807 gtk_widget_show (vbox);
5808 }
5809 gtk_widget_show (statusbar_box);
5810
5811 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->statusbar, FR_WINDOW_AREA_STATUSBAR);
5812 if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar"))
5813 gtk_widget_show (window->priv->statusbar);
5814 else
5815 gtk_widget_hide (window->priv->statusbar);
5816
5817 /**/
5818
5819 fr_window_update_title (window);
5820 fr_window_update_sensitivity (window);
5821 fr_window_update_file_list (window, FALSE(0));
5822 fr_window_update_dir_tree (window);
5823 fr_window_update_current_location (window);
5824 fr_window_update_columns_visibility (window);
5825
5826 /* Add notification callbacks. */
5827
5828 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
5829 "changed::" PREF_UI_HISTORY_LEN,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
5830 G_CALLBACK (pref_history_len_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
5831 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
;
5832 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5833 "changed::" PREF_UI_VIEW_TOOLBAR,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5834 G_CALLBACK (pref_view_toolbar_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5835 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
;
5836 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5837 "changed::" PREF_UI_VIEW_STATUSBAR,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5838 G_CALLBACK (pref_view_statusbar_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5839 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5840 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5841 "changed::" PREF_UI_VIEW_FOLDERS,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5842 G_CALLBACK (pref_view_folders_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5843 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
;
5844 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5845 "changed::" PREF_LISTING_SHOW_TYPE,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5846 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5847 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5848 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5849 "changed::" PREF_LISTING_SHOW_SIZE,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5850 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5851 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5852 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5853 "changed::" PREF_LISTING_SHOW_TIME,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5854 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5855 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5856 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5857 "changed::" PREF_LISTING_SHOW_PATH,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5858 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5859 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5860 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5861 "changed::" PREF_LISTING_USE_MIME_ICONS,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5862 G_CALLBACK (pref_use_mime_icons_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5863 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5864
5865 if (window->priv->settings_caja)
5866 g_signal_connect (window->priv->settings_caja,g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5867 "changed::" CAJA_CLICK_POLICY,g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5868 G_CALLBACK (pref_click_policy_changed),g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5869 window)g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5870
5871 /* Give focus to the list. */
5872
5873 gtk_widget_grab_focus (window->priv->list_view);
5874}
5875
5876GtkWidget *
5877fr_window_new (void)
5878{
5879 GtkWidget *window;
5880
5881 window = g_object_new (FR_TYPE_WINDOW(fr_window_get_type ()), "application", g_application_get_default (), NULL((void*)0));
5882 fr_window_construct ((FrWindow*) window);
5883
5884 return window;
5885}
5886
5887static void
5888fr_window_set_archive_uri (FrWindow *window,
5889 const char *uri)
5890{
5891 if (window->priv->archive_uri != NULL((void*)0))
5892 g_free (window->priv->archive_uri);
5893 window->priv->archive_uri = g_strdup (uri)g_strdup_inline (uri);
5894}
5895
5896gboolean
5897fr_window_archive_new (FrWindow *window,
5898 const char *uri)
5899{
5900 g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return ((0)); } } while (0)
;
5901
5902 if (! fr_archive_create (window->archive, uri)) {
5903 GtkWindow *file_sel = g_object_get_data (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "fr_file_sel");
5904
5905 window->priv->load_error_parent_window = file_sel;
5906 fr_archive_action_completed (window->archive,
5907 FR_ACTION_CREATING_NEW_ARCHIVE,
5908 FR_PROC_ERROR_GENERIC,
5909 _("Archive type not supported.")gettext ("Archive type not supported."));
5910
5911 return FALSE(0);
5912 }
5913
5914 fr_window_set_archive_uri (window, uri);
5915 window->priv->archive_present = TRUE(!(0));
5916 window->priv->archive_new = TRUE(!(0));
5917
5918 fr_archive_action_completed (window->archive,
5919 FR_ACTION_CREATING_NEW_ARCHIVE,
5920 FR_PROC_ERROR_NONE,
5921 NULL((void*)0));
5922
5923 return TRUE(!(0));
5924}
5925
5926FrWindow *
5927fr_window_archive_open (FrWindow *current_window,
5928 const char *uri,
5929 GtkWindow *parent)
5930{
5931 FrWindow *window = current_window;
5932
5933 if (current_window->priv->archive_present)
5934 window = (FrWindow *) fr_window_new ();
5935
5936 g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return ((0)); } } while (0)
;
5937
5938 fr_window_archive_close (window);
5939
5940 fr_window_set_archive_uri (window, uri);
5941 window->priv->archive_present = FALSE(0);
5942 window->priv->give_focus_to_the_list = TRUE(!(0));
5943 window->priv->load_error_parent_window = parent;
5944
5945 fr_window_set_current_batch_action (window,
5946 FR_BATCH_ACTION_LOAD,
5947 g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri),
5948 (GFreeFunc) g_free);
5949
5950 fr_archive_load (window->archive, window->priv->archive_uri, window->priv->password);
5951
5952 return window;
5953}
5954
5955void
5956fr_window_archive_close (FrWindow *window)
5957{
5958 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
5959
5960 if (! window->priv->archive_new && ! window->priv->archive_present)
5961 return;
5962
5963 fr_window_free_open_files (window);
5964 fr_clipboard_data_unref (window->priv->copy_data);
5965 window->priv->copy_data = NULL((void*)0);
5966
5967 fr_window_set_password (window, NULL((void*)0));
5968 fr_window_set_volume_size(window, 0);
5969 fr_window_history_clear (window);
5970
5971 window->priv->archive_new = FALSE(0);
5972 window->priv->archive_present = FALSE(0);
5973
5974 fr_window_update_title (window);
5975 fr_window_update_sensitivity (window);
5976 fr_window_update_file_list (window, FALSE(0));
5977 fr_window_update_dir_tree (window);
5978 fr_window_update_current_location (window);
5979 fr_window_update_statusbar_list_info (window);
5980}
5981
5982const char *
5983fr_window_get_archive_uri (FrWindow *window)
5984{
5985 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
5986
5987 return window->priv->archive_uri;
5988}
5989
5990const char *
5991fr_window_get_paste_archive_uri (FrWindow *window)
5992{
5993 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
5994
5995 if (window->priv->clipboard_data != NULL((void*)0))
5996 return window->priv->clipboard_data->archive_filename;
5997 else
5998 return NULL((void*)0);
5999}
6000
6001gboolean
6002fr_window_archive_is_present (FrWindow *window)
6003{
6004 g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return ((0)); } } while (0)
;
6005
6006 return window->priv->archive_present;
6007}
6008
6009typedef struct {
6010 char *uri;
6011 char *password;
6012 gboolean encrypt_header;
6013 guint volume_size;
6014} SaveAsData;
6015
6016static SaveAsData *
6017save_as_data_new (const char *uri,
6018 const char *password,
6019 gboolean encrypt_header,
6020 guint volume_size)
6021{
6022 SaveAsData *sdata;
6023
6024 sdata = g_new0 (SaveAsData, 1)((SaveAsData *) g_malloc0_n ((1), sizeof (SaveAsData)));
6025 if (uri != NULL((void*)0))
6026 sdata->uri = g_strdup (uri)g_strdup_inline (uri);
6027 if (password != NULL((void*)0))
6028 sdata->password = g_strdup (password)g_strdup_inline (password);
6029 sdata->encrypt_header = encrypt_header;
6030 sdata->volume_size = volume_size;
6031
6032 return sdata;
6033}
6034
6035static void
6036save_as_data_free (SaveAsData *sdata)
6037{
6038 if (sdata == NULL((void*)0))
6039 return;
6040 g_free (sdata->uri);
6041 g_free (sdata->password);
6042 g_free (sdata);
6043}
6044
6045void
6046fr_window_archive_save_as (FrWindow *window,
6047 const char *uri,
6048 const char *password,
6049 gboolean encrypt_header,
6050 guint volume_size)
6051{
6052 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6053 g_return_if_fail (uri != NULL)do { if ((uri != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "uri != NULL"); return
; } } while (0)
;
6054 g_return_if_fail (window->archive != NULL)do { if ((window->archive != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window->archive != NULL"
); return; } } while (0)
;
6055
6056 fr_window_convert_data_free (window, TRUE(!(0)));
6057 window->priv->convert_data.new_file = g_strdup (uri)g_strdup_inline (uri);
6058
6059 /* create the new archive */
6060
6061 window->priv->convert_data.new_archive = fr_archive_new ();
6062 if (! fr_archive_create (window->priv->convert_data.new_archive, uri)) {
6063 GtkWidget *d;
6064 char *utf8_name;
6065 char *message;
6066
6067 utf8_name = g_uri_display_basename (uri);
6068 message = g_strdup_printf (_("Could not save the archive \"%s\"")gettext ("Could not save the archive \"%s\""), utf8_name);
6069 g_free (utf8_name);
6070
6071 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6072 GTK_DIALOG_DESTROY_WITH_PARENT,
6073 NULL((void*)0),
6074 message,
6075 "%s",
6076 _("Archive type not supported.")gettext ("Archive type not supported."));
6077 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
6078 gtk_widget_destroy (d);
6079
6080 g_free (message);
6081
6082 g_object_unref (window->priv->convert_data.new_archive);
6083 window->priv->convert_data.new_archive = NULL((void*)0);
6084
6085 return;
6086 }
6087
6088 g_return_if_fail (window->priv->convert_data.new_archive->command != NULL)do { if ((window->priv->convert_data.new_archive->command
!= ((void*)0))) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "window->priv->convert_data.new_archive->command != NULL"
); return; } } while (0)
;
6089
6090 if (password != NULL((void*)0)) {
6091 window->priv->convert_data.password = g_strdup (password)g_strdup_inline (password);
6092 window->priv->convert_data.encrypt_header = encrypt_header;
6093 }
6094 else
6095 window->priv->convert_data.encrypt_header = FALSE(0);
6096 window->priv->convert_data.volume_size = volume_size;
6097
6098 fr_window_set_current_batch_action (window,
6099 FR_BATCH_ACTION_SAVE_AS,
6100 save_as_data_new (uri, password, encrypt_header, volume_size),
6101 (GFreeFunc) save_as_data_free);
6102
6103 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
6104 "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
6105 G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
6106 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
;
6107 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
6108 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
6109 G_CALLBACK (convert__action_performed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
6110 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
;
6111 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6112 "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6113 G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6114 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
6115 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6116 "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6117 G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6118 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
6119 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6120 "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6121 G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6122 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
6123
6124 window->priv->convert_data.converting = TRUE(!(0));
6125 window->priv->convert_data.temp_dir = get_temp_work_dir (NULL((void*)0));
6126
6127 fr_process_clear (window->archive->process);
6128 fr_archive_extract_to_local (window->archive,
6129 NULL((void*)0),
6130 window->priv->convert_data.temp_dir,
6131 NULL((void*)0),
6132 FALSE(0),
6133 TRUE(!(0)),
6134 FALSE(0),
6135 window->priv->password);
6136 fr_process_start (window->archive->process);
6137}
6138
6139void
6140fr_window_archive_reload (FrWindow *window)
6141{
6142 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6143
6144 if (window->priv->activity_ref > 0)
6145 return;
6146 if (window->priv->archive_new)
6147 return;
6148
6149 fr_archive_reload (window->archive, window->priv->password);
6150}
6151
6152/**/
6153
6154void
6155fr_window_archive_add_files (FrWindow *window,
6156 GList *file_list, /* GFile list */
6157 gboolean update)
6158{
6159 GFile *base;
6160 char *base_dir;
6161 int base_len;
6162 GList *files = NULL((void*)0);
6163 GList *scan;
6164 char *base_uri;
6165
6166 base = g_file_get_parent ((GFile *) file_list->data);
6167 base_dir = g_file_get_path (base);
6168 base_len = 0;
6169 if (strcmp (base_dir, "/") != 0)
6170 base_len = strlen (base_dir);
6171
6172 for (scan = file_list; scan; scan = scan->next) {
6173 GFile *file = scan->data;
6174 char *path;
6175 char *rel_path;
6176
6177 path = g_file_get_path (file);
6178 rel_path = g_strdup (path + base_len + 1)g_strdup_inline (path + base_len + 1);
6179 files = g_list_prepend (files, rel_path);
6180
6181 g_free (path);
6182 }
6183
6184 base_uri = g_file_get_uri (base);
6185
6186 fr_archive_add_files (window->archive,
6187 files,
6188 base_uri,
6189 fr_window_get_current_location (window),
6190 update,
6191 window->priv->password,
6192 window->priv->encrypt_header,
6193 window->priv->compression,
6194 window->priv->volume_size);
6195
6196 g_free (base_uri);
6197 path_list_free (files);
6198 g_free (base_dir);
6199 g_object_unref (base);
6200}
6201
6202void
6203fr_window_archive_add_with_wildcard (FrWindow *window,
6204 const char *include_files,
6205 const char *exclude_files,
6206 const char *exclude_folders,
6207 const char *base_dir,
6208 const char *dest_dir,
6209 gboolean update,
6210 gboolean follow_links)
6211{
6212 fr_archive_add_with_wildcard (window->archive,
6213 include_files,
6214 exclude_files,
6215 exclude_folders,
6216 base_dir,
6217 (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir,
6218 update,
6219 follow_links,
6220 window->priv->password,
6221 window->priv->encrypt_header,
6222 window->priv->compression,
6223 window->priv->volume_size);
6224}
6225
6226void
6227fr_window_archive_add_directory (FrWindow *window,
6228 const char *directory,
6229 const char *base_dir,
6230 const char *dest_dir,
6231 gboolean update)
6232{
6233 fr_archive_add_directory (window->archive,
6234 directory,
6235 base_dir,
6236 (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir,
6237 update,
6238 window->priv->password,
6239 window->priv->encrypt_header,
6240 window->priv->compression,
6241 window->priv->volume_size);
6242}
6243
6244void
6245fr_window_archive_add_items (FrWindow *window,
6246 GList *item_list,
6247 const char *base_dir,
6248 const char *dest_dir,
6249 gboolean update)
6250{
6251 fr_archive_add_items (window->archive,
6252 item_list,
6253 base_dir,
6254 (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir,
6255 update,
6256 window->priv->password,
6257 window->priv->encrypt_header,
6258 window->priv->compression,
6259 window->priv->volume_size);
6260}
6261
6262void
6263fr_window_archive_add_dropped_items (FrWindow *window,
6264 GList *item_list,
6265 gboolean update)
6266{
6267 fr_archive_add_dropped_items (window->archive,
6268 item_list,
6269 fr_window_get_current_location (window),
6270 fr_window_get_current_location (window),
6271 update,
6272 window->priv->password,
6273 window->priv->encrypt_header,
6274 window->priv->compression,
6275 window->priv->volume_size);
6276}
6277
6278static void
6279remove_data_free (GList *rdata)
6280{
6281 g_list_free_full(rdata, g_free);
6282}
6283
6284void
6285fr_window_archive_remove (FrWindow *window,
6286 GList *file_list)
6287{
6288 char *password;
6289 GList *remove_list;
6290
6291 fr_window_clipboard_remove_file_list (window, file_list);
6292
6293 fr_process_clear (window->archive->process);
6294
6295 remove_list = g_list_copy_deep (file_list, (GCopyFunc) g_strdup, NULL((void*)0));
6296 fr_window_set_current_batch_action (window,
6297 FR_BATCH_ACTION_DELETE,
6298 remove_list,
6299 (GFreeFunc) remove_data_free);
6300
6301 password = window->priv->password;
6302 if (password != NULL((void*)0) && password[0] != '\0')
6303 g_object_set (window->archive->command, "password", password, NULL((void*)0));
6304
6305 fr_archive_remove (window->archive, remove_list, window->priv->compression);
6306 fr_process_start (window->archive->process);
6307}
6308
6309/* -- window_archive_extract -- */
6310
6311static ExtractData*
6312extract_data_new (GList *file_list,
6313 const char *extract_to_dir,
6314 const char *sub_dir,
6315 const char *base_dir,
6316 gboolean skip_older,
6317 FrOverwrite overwrite,
6318 gboolean junk_paths,
6319 gboolean extract_here,
6320 gboolean ask_to_open_destination)
6321{
6322 ExtractData *edata;
6323 int i = 1;
6324
6325 edata = g_new0 (ExtractData, 1)((ExtractData *) g_malloc0_n ((1), sizeof (ExtractData)));
6326 edata->file_list = path_list_dup (file_list);
6327 if (sub_dir != NULL((void*)0))
6328 edata->sub_dir = g_strdup (sub_dir)g_strdup_inline (sub_dir);
6329 if (extract_to_dir != NULL((void*)0) && sub_dir == NULL((void*)0)) {
6330 edata->extract_to_dir = g_strdup (extract_to_dir)g_strdup_inline (extract_to_dir);
6331 } else if (extract_to_dir != NULL((void*)0) && sub_dir != NULL((void*)0)) {
6332 edata->extract_to_dir = g_build_filename (extract_to_dir, sub_dir, NULL((void*)0));
6333 while (uri_exists (edata->extract_to_dir) && uri_is_file (edata->extract_to_dir)) {
6334 g_free (edata->extract_to_dir);
6335 edata->extract_to_dir = g_strdup_printf ("%s/%s_%d", extract_to_dir, sub_dir, i++);
6336 }
6337 }
6338 edata->skip_older = skip_older;
6339 edata->overwrite = overwrite;
6340 edata->junk_paths = junk_paths;
6341 if (base_dir != NULL((void*)0))
6342 edata->base_dir = g_strdup (base_dir)g_strdup_inline (base_dir);
6343 edata->extract_here = extract_here;
6344 edata->ask_to_open_destination = ask_to_open_destination;
6345
6346 return edata;
6347}
6348
6349static ExtractData*
6350extract_to_data_new (const char *extract_to_dir)
6351{
6352 return extract_data_new (NULL((void*)0),
6353 extract_to_dir,
6354 NULL((void*)0),
6355 NULL((void*)0),
6356 FALSE(0),
6357 TRUE(!(0)),
6358 FALSE(0),
6359 FALSE(0),
6360 FALSE(0));
6361}
6362
6363static void
6364extract_data_free (ExtractData *edata)
6365{
6366 g_return_if_fail (edata != NULL)do { if ((edata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "edata != NULL");
return; } } while (0)
;
6367
6368 path_list_free (edata->file_list);
6369 g_free (edata->extract_to_dir);
6370 g_free (edata->sub_dir);
6371 g_free (edata->base_dir);
6372
6373 g_free (edata);
6374}
6375
6376static gboolean
6377archive_is_encrypted (FrWindow *window,
6378 GList *file_list)
6379{
6380 gboolean encrypted = FALSE(0);
6381
6382 if (file_list == NULL((void*)0)) {
6383 guint i;
6384
6385 for (i = 0; ! encrypted && i < window->archive->command->files->len; i++) {
6386 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
6387
6388 if (fdata->encrypted)
6389 encrypted = TRUE(!(0));
6390 }
6391 }
6392 else {
6393
6394 GHashTable *file_hash;
6395 guint i;
6396 GList *scan;
6397
6398 file_hash = g_hash_table_new (g_str_hash, g_str_equal);
6399 for (i = 0; i < window->archive->command->files->len; i++) {
6400 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
6401 g_hash_table_insert (file_hash, fdata->original_path, fdata);
6402 }
6403
6404 for (scan = file_list; ! encrypted && scan; scan = scan->next) {
6405 char *filename = scan->data;
6406 FileData *fdata;
6407
6408 fdata = g_hash_table_lookup (file_hash, filename);
6409 g_return_val_if_fail (fdata != NULL, FALSE)do { if ((fdata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "fdata != NULL");
return ((0)); } } while (0)
;
6410
6411 if (fdata->encrypted)
6412 encrypted = TRUE(!(0));
6413 }
6414
6415 g_hash_table_destroy (file_hash);
6416 }
6417
6418 return encrypted;
6419}
6420
6421static gboolean
6422archive_extract_check_disk_space_full (GPtrArray *files,
6423 const char *extract_to_dir)
6424{
6425 guint64 freespace;
6426 guint64 archive_size = 0;
6427 guint i;
6428
6429 freespace = get_dest_free_space (g_filename_from_uri (extract_to_dir, NULL((void*)0), NULL((void*)0)));
6430
6431 for (i = 0; i <files->len; i++)
6432 {
6433 FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i];
6434 archive_size += fdata->size;
6435 }
6436 /* When the decompressed target file is less than 100MB,
6437 2 * (target file size) needs to disk space
6438 and when it is greater than 100MB,
6439 100MB + (target file size) needs to disk space */
6440
6441 if (archive_size <= 1024 * 1024 * 100)
6442 archive_size = archive_size * 2;
6443 else
6444 archive_size += 1024 * 1024 * 100;
6445
6446 return freespace < archive_size * 2;
6447}
6448
6449void
6450fr_window_archive_extract_here (FrWindow *window,
6451 gboolean skip_older,
6452 FrOverwrite overwrite,
6453 gboolean junk_paths)
6454{
6455 ExtractData *edata;
6456
6457 edata = extract_data_new (NULL((void*)0),
6458 NULL((void*)0),
6459 NULL((void*)0),
6460 NULL((void*)0),
6461 skip_older,
6462 overwrite,
6463 junk_paths,
6464 TRUE(!(0)),
6465 FALSE(0));
6466 fr_window_set_current_batch_action (window,
6467 FR_BATCH_ACTION_EXTRACT_INTERACT,
6468 edata,
6469 (GFreeFunc) extract_data_free);
6470
6471 if (archive_is_encrypted (window, NULL((void*)0)) && (window->priv->password == NULL((void*)0))) {
6472 dlg_ask_password (window);
6473 return;
6474 }
6475
6476 window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination;
6477
6478 fr_process_clear (window->archive->process);
6479 if (fr_archive_extract_here (window->archive,
6480 edata->skip_older,
6481 edata->overwrite,
6482 edata->junk_paths,
6483 window->priv->password))
6484 {
6485 fr_process_start (window->archive->process);
6486 }
6487}
6488
6489/* -- fr_window_archive_extract -- */
6490
6491typedef struct {
6492 FrWindow *window;
6493 ExtractData *edata;
6494 GList *current_file;
6495 gboolean extract_all;
6496} OverwriteData;
6497
6498#define _FR_RESPONSE_OVERWRITE_YES_ALL100 100
6499#define _FR_RESPONSE_OVERWRITE_YES101 101
6500#define _FR_RESPONSE_OVERWRITE_NO102 102
6501
6502static void
6503_fr_window_archive_extract_from_edata (FrWindow *window,
6504 ExtractData *edata)
6505{
6506 window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination;
6507
6508 fr_process_clear (window->archive->process);
6509 fr_archive_extract (window->archive,
6510 edata->file_list,
6511 edata->extract_to_dir,
6512 edata->base_dir,
6513 edata->skip_older,
6514 edata->overwrite == FR_OVERWRITE_YES,
6515 edata->junk_paths,
6516 window->priv->password);
6517 fr_process_start (window->archive->process);
6518}
6519
6520static void _fr_window_ask_overwrite_dialog (OverwriteData *odata);
6521
6522static void
6523overwrite_dialog_response_cb (GtkDialog *dialog,
6524 int response_id,
6525 gpointer user_data)
6526{
6527 OverwriteData *odata = user_data;
6528 gboolean do_not_extract = FALSE(0);
6529
6530 switch (response_id) {
6531 case _FR_RESPONSE_OVERWRITE_YES_ALL100:
6532 odata->edata->overwrite = FR_OVERWRITE_YES;
6533 break;
6534
6535 case _FR_RESPONSE_OVERWRITE_YES101:
6536 odata->current_file = odata->current_file->next;
6537 break;
6538
6539 case _FR_RESPONSE_OVERWRITE_NO102:
6540 {
6541 /* remove the file from the list to extract */
6542 GList *next = odata->current_file->next;
6543 odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file);
6544 path_list_free (odata->current_file);
6545 odata->current_file = next;
6546 odata->extract_all = FALSE(0);
6547 }
6548 break;
6549
6550 case GTK_RESPONSE_DELETE_EVENT:
6551 case GTK_RESPONSE_CANCEL:
6552 do_not_extract = TRUE(!(0));
6553 break;
6554
6555 default:
6556 break;
6557 }
6558
6559 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
6560
6561 if (do_not_extract) {
6562 fr_window_stop_batch (odata->window);
6563 g_free (odata);
6564 return;
6565 }
6566
6567 _fr_window_ask_overwrite_dialog (odata);
6568}
6569
6570static void
6571_fr_window_ask_overwrite_dialog (OverwriteData *odata)
6572{
6573 while ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL((void*)0))) {
6574 const char *base_name;
6575 char *e_base_name;
6576 char *dest_uri;
6577 GFile *file;
6578 GFileInfo *info;
6579 GFileType file_type;
6580
6581 base_name = _g_path_get_base_name ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths);
6582 e_base_name = g_uri_escape_string (base_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH"!$&'()*+,;=" ":@" "/", TRUE(!(0)));
6583 dest_uri = g_strdup_printf ("%s/%s", odata->edata->extract_to_dir, e_base_name);
6584 file = g_file_new_for_uri (dest_uri);
6585 info = g_file_query_info (file,
6586 G_FILE_ATTRIBUTE_STANDARD_TYPE"standard::type" "," G_FILE_ATTRIBUTE_STANDARD_NAME"standard::name" "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME"standard::display-name",
6587 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
6588 NULL((void*)0),
6589 NULL((void*)0));
6590
6591 g_free (dest_uri);
6592 g_free (e_base_name);
6593
6594 if (info == NULL((void*)0)) {
6595 g_object_unref (file);
6596 odata->current_file = odata->current_file->next;
6597 continue;
6598 }
6599
6600 file_type = g_file_info_get_file_type (info);
6601 if ((file_type != G_FILE_TYPE_UNKNOWN) && (file_type != G_FILE_TYPE_DIRECTORY)) {
6602 char *msg;
6603 GFile *parent;
6604 char *parent_name;
6605 char *details;
6606 GtkWidget *d;
6607
6608 msg = g_strdup_printf (_("Replace file \"%s\"?")gettext ("Replace file \"%s\"?"), g_file_info_get_display_name (info));
6609 parent = g_file_get_parent (file);
6610 parent_name = g_file_get_parse_name (parent);
6611 details = g_strdup_printf (_("Another file with the same name already exists in \"%s\".")gettext ("Another file with the same name already exists in \"%s\"."
)
, parent_name);
6612 d = _gtk_message_dialog_new (GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
,
6613 GTK_DIALOG_MODAL,
6614 "dialog-question",
6615 msg,
6616 details,
6617 "gtk-cancel", GTK_RESPONSE_CANCEL,
6618 _("Replace _All")gettext ("Replace _All"), _FR_RESPONSE_OVERWRITE_YES_ALL100,
6619 _("_Skip")gettext ("_Skip"), _FR_RESPONSE_OVERWRITE_NO102,
6620 _("_Replace")gettext ("_Replace"), _FR_RESPONSE_OVERWRITE_YES101,
6621 NULL((void*)0));
6622 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, _FR_RESPONSE_OVERWRITE_YES101);
6623 g_signal_connect (d,g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
6624 "response",g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
6625 G_CALLBACK (overwrite_dialog_response_cb),g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
6626 odata)g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
;
6627 gtk_widget_show (d);
6628
6629 g_free (parent_name);
6630 g_object_unref (parent);
6631 g_object_unref (info);
6632 g_object_unref (file);
6633
6634 return;
6635 }
6636 else
6637 odata->current_file = odata->current_file->next;
6638
6639 g_object_unref (info);
6640 g_object_unref (file);
6641 }
6642
6643 if (odata->edata->file_list != NULL((void*)0)) {
6644 /* speed optimization: passing NULL when extracting all the
6645 * files is faster if the command supports the
6646 * propCanExtractAll property. */
6647 if (odata->extract_all) {
6648 path_list_free (odata->edata->file_list);
6649 odata->edata->file_list = NULL((void*)0);
6650 }
6651 odata->edata->overwrite = FR_OVERWRITE_YES;
6652 _fr_window_archive_extract_from_edata (odata->window, odata->edata);
6653 }
6654 else {
6655 GtkWidget *d;
6656
6657 d = _gtk_message_dialog_new (GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
,
6658 0,
6659 "dialog-warning",
6660 _("Extraction not performed")gettext ("Extraction not performed"),
6661 NULL((void*)0),
6662 "gtk-ok", GTK_RESPONSE_OK,
6663 NULL((void*)0));
6664 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
6665 fr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
, _("Extraction not performed")gettext ("Extraction not performed"));
6666
6667 fr_window_stop_batch (odata->window);
6668 }
6669 g_free (odata);
6670}
6671
6672void
6673fr_window_archive_extract (FrWindow *window,
6674 GList *file_list,
6675 const char *extract_to_dir,
6676 const char *sub_dir,
6677 const char *base_dir,
6678 gboolean skip_older,
6679 FrOverwrite overwrite,
6680 gboolean junk_paths,
6681 gboolean ask_to_open_destination)
6682{
6683 ExtractData *edata;
6684 gboolean do_not_extract = FALSE(0);
6685 GError *error = NULL((void*)0);
6686
6687 edata = extract_data_new (file_list,
6688 extract_to_dir,
6689 sub_dir,
6690 base_dir,
6691 skip_older,
6692 overwrite,
6693 junk_paths,
6694 FALSE(0),
6695 ask_to_open_destination);
6696
6697 fr_window_set_current_batch_action (window,
6698 FR_BATCH_ACTION_EXTRACT_INTERACT,
6699 edata,
6700 (GFreeFunc) extract_data_free);
6701
6702 if (archive_extract_check_disk_space_full (window->archive->command->files, extract_to_dir))
6703 {
6704 GtkWidget *d;
6705
6706 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6707 GTK_DIALOG_MODAL,
6708 NULL((void*)0),
6709 _("Insufficient remaining disk space")gettext ("Insufficient remaining disk space"),
6710 NULL((void*)0));
6711 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
6712 gtk_widget_destroy(d);
6713 return;
6714 }
6715
6716 if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL((void*)0))) {
6717 dlg_ask_password (window);
6718 return;
6719 }
6720
6721 if (! uri_is_dir (edata->extract_to_dir)) {
6722
6723 /* There is nothing to ask if the destination doesn't exist. */
6724 if (edata->overwrite == FR_OVERWRITE_ASK)
6725 edata->overwrite = FR_OVERWRITE_YES;
6726
6727 if (! ForceDirectoryCreation) {
6728 GtkWidget *d;
6729 int r;
6730 char *folder_name;
6731 char *msg;
6732
6733 folder_name = g_filename_display_name (edata->extract_to_dir);
6734 msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?")gettext ("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"
)
, folder_name);
6735 g_free (folder_name);
6736
6737 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6738 GTK_DIALOG_MODAL,
6739 "dialog-question",
6740 msg,
6741 NULL((void*)0),
6742 "gtk-cancel", GTK_RESPONSE_CANCEL,
6743 _("Create _Folder")gettext ("Create _Folder"), GTK_RESPONSE_YES,
6744 NULL((void*)0));
6745
6746 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_YES);
6747 r = gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
6748 gtk_widget_destroy (GTK_WIDGET (d)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_widget_get_type ()))))))
);
6749
6750 g_free (msg);
6751
6752 if (r != GTK_RESPONSE_YES)
6753 do_not_extract = TRUE(!(0));
6754 }
6755
6756 if (! do_not_extract && ! ensure_dir_exists (edata->extract_to_dir, 0755, &error)) {
6757 GtkWidget *d;
6758 char *details;
6759
6760 details = g_strdup_printf (_("Could not create the destination folder: %s.")gettext ("Could not create the destination folder: %s."), error->message);
6761 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6762 0,
6763 NULL((void*)0),
6764 _("Extraction not performed")gettext ("Extraction not performed"),
6765 "%s",
6766 details);
6767 g_clear_error (&error);
6768 fr_window_show_error_dialog (window, d, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, details);
6769 fr_window_stop_batch (window);
6770
6771 g_free (details);
6772
6773 return;
6774 }
6775 }
6776
6777 if (do_not_extract) {
6778 GtkWidget *d;
6779
6780 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6781 0,
6782 "dialog-warning",
6783 _("Extraction not performed")gettext ("Extraction not performed"),
6784 NULL((void*)0),
6785 "gtk-ok", GTK_RESPONSE_OK,
6786 NULL((void*)0));
6787 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
6788 fr_window_show_error_dialog (window, d, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, _("Extraction not performed")gettext ("Extraction not performed"));
6789 fr_window_stop_batch (window);
6790
6791 return;
6792 }
6793
6794 if (edata->overwrite == FR_OVERWRITE_ASK) {
6795 OverwriteData *odata;
6796
6797 odata = g_new0 (OverwriteData, 1)((OverwriteData *) g_malloc0_n ((1), sizeof (OverwriteData)));
6798 odata->window = window;
6799 odata->edata = edata;
6800 odata->extract_all = (edata->file_list == NULL((void*)0)) || (g_list_length (edata->file_list) == window->archive->command->files->len);
6801 if (edata->file_list == NULL((void*)0))
6802 edata->file_list = fr_window_get_file_list (window);
6803 odata->current_file = odata->edata->file_list;
6804 _fr_window_ask_overwrite_dialog (odata);
6805 }
6806 else
6807 _fr_window_archive_extract_from_edata (window, edata);
6808}
6809
6810void
6811fr_window_archive_test (FrWindow *window)
6812{
6813 fr_window_set_current_batch_action (window,
6814 FR_BATCH_ACTION_TEST,
6815 NULL((void*)0),
6816 NULL((void*)0));
6817 fr_archive_test (window->archive, window->priv->password);
6818}
6819
6820void
6821fr_window_set_password (FrWindow *window,
6822 const char *password)
6823{
6824 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6825
6826 if (window->priv->password != NULL((void*)0)) {
6827 g_free (window->priv->password);
6828 window->priv->password = NULL((void*)0);
6829 }
6830
6831 if ((password != NULL((void*)0)) && (password[0] != '\0'))
6832 window->priv->password = g_strdup (password)g_strdup_inline (password);
6833}
6834
6835void
6836fr_window_set_password_for_paste (FrWindow *window,
6837 const char *password)
6838{
6839 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6840
6841 if (window->priv->password_for_paste != NULL((void*)0)) {
6842 g_free (window->priv->password_for_paste);
6843 window->priv->password_for_paste = NULL((void*)0);
6844 }
6845
6846 if ((password != NULL((void*)0)) && (password[0] != '\0'))
6847 window->priv->password_for_paste = g_strdup (password)g_strdup_inline (password);
6848}
6849
6850const char *
6851fr_window_get_password (FrWindow *window)
6852{
6853 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
6854
6855 return window->priv->password;
6856}
6857
6858void
6859fr_window_set_encrypt_header (FrWindow *window,
6860 gboolean encrypt_header)
6861{
6862 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6863
6864 window->priv->encrypt_header = encrypt_header;
6865}
6866
6867gboolean
6868fr_window_get_encrypt_header (FrWindow *window)
6869{
6870 return window->priv->encrypt_header;
6871}
6872
6873void
6874fr_window_set_compression (FrWindow *window,
6875 FrCompression compression)
6876{
6877 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6878
6879 window->priv->compression = compression;
6880}
6881
6882FrCompression
6883fr_window_get_compression (FrWindow *window)
6884{
6885 return window->priv->compression;
6886}
6887
6888void
6889fr_window_set_volume_size (FrWindow *window,
6890 guint volume_size)
6891{
6892 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6893
6894 window->priv->volume_size = volume_size;
6895}
6896
6897guint
6898fr_window_get_volume_size (FrWindow *window)
6899{
6900 return window->priv->volume_size;
6901}
6902
6903void
6904fr_window_go_to_location (FrWindow *window,
6905 const char *path,
6906 gboolean force_update)
6907{
6908 char *dir;
6909
6910 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6911 g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "path != NULL"); return
; } } while (0)
;
6912
6913 if (force_update) {
6914 g_free (window->priv->last_location);
6915 window->priv->last_location = NULL((void*)0);
6916 }
6917
6918 if (path[strlen (path) - 1] != '/')
6919 dir = g_strconcat (path, "/", NULL((void*)0));
6920 else
6921 dir = g_strdup (path)g_strdup_inline (path);
6922
6923 if ((window->priv->last_location == NULL((void*)0)) || (strcmp (window->priv->last_location, dir) != 0)) {
6924 g_free (window->priv->last_location);
6925 window->priv->last_location = dir;
6926
6927 fr_window_history_add (window, dir);
6928 fr_window_update_file_list (window, TRUE(!(0)));
6929 fr_window_update_current_location (window);
6930 }
6931 else
6932 g_free (dir);
6933}
6934
6935const char *
6936fr_window_get_current_location (FrWindow *window)
6937{
6938 if (window->priv->history_current == NULL((void*)0)) {
6939 fr_window_history_add (window, "/");
6940 return window->priv->history_current->data;
6941 }
6942 else
6943 return (const char*) window->priv->history_current->data;
6944}
6945
6946void
6947fr_window_go_up_one_level (FrWindow *window)
6948{
6949 char *parent_dir;
6950
6951 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6952
6953 parent_dir = get_parent_dir (fr_window_get_current_location (window));
6954 fr_window_go_to_location (window, parent_dir, FALSE(0));
6955 g_free (parent_dir);
6956}
6957
6958void
6959fr_window_go_back (FrWindow *window)
6960{
6961 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6962
6963 if (window->priv->history == NULL((void*)0))
6964 return;
6965 if (window->priv->history_current == NULL((void*)0))
6966 return;
6967 if (window->priv->history_current->next == NULL((void*)0))
6968 return;
6969 window->priv->history_current = window->priv->history_current->next;
6970
6971 fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0));
6972}
6973
6974void
6975fr_window_go_forward (FrWindow *window)
6976{
6977 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6978
6979 if (window->priv->history == NULL((void*)0))
6980 return;
6981 if (window->priv->history_current == NULL((void*)0))
6982 return;
6983 if (window->priv->history_current->prev == NULL((void*)0))
6984 return;
6985 window->priv->history_current = window->priv->history_current->prev;
6986
6987 fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0));
6988}
6989
6990void
6991fr_window_set_list_mode (FrWindow *window,
6992 FrWindowListMode list_mode)
6993{
6994 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6995
6996 window->priv->list_mode = window->priv->last_list_mode = list_mode;
6997 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
6998 fr_window_history_clear (window);
6999 fr_window_history_add (window, "/");
7000 }
7001
7002 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode);
7003 g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT));
7004
7005 fr_window_update_file_list (window, TRUE(!(0)));
7006 fr_window_update_dir_tree (window);
7007 fr_window_update_current_location (window);
7008}
7009
7010GtkTreeModel *
7011fr_window_get_list_store (FrWindow *window)
7012{
7013 return GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
;
7014}
7015
7016void
7017fr_window_find (FrWindow *window)
7018{
7019 window->priv->filter_mode = TRUE(!(0));
7020 gtk_widget_show (window->priv->filter_bar);
7021 gtk_widget_grab_focus (window->priv->filter_entry);
7022}
7023
7024void
7025fr_window_select_all (FrWindow *window)
7026{
7027 gtk_tree_selection_select_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
));
7028}
7029
7030void
7031fr_window_unselect_all (FrWindow *window)
7032{
7033 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
));
7034}
7035
7036void
7037fr_window_stop (FrWindow *window)
7038{
7039 if (! window->priv->stoppable)
7040 return;
7041
7042 if (window->priv->activity_ref > 0)
7043 fr_archive_stop (window->archive);
7044
7045 if (window->priv->convert_data.converting)
7046 fr_window_convert_data_free (window, TRUE(!(0)));
7047}
7048
7049/* -- start/stop activity mode -- */
7050
7051static int
7052activity_cb (gpointer data)
7053{
7054 FrWindow *window = data;
7055
7056 if ((window->priv->pd_progress_bar != NULL((void*)0)) && window->priv->progress_pulse)
7057 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
);
7058 if (window->priv->progress_pulse)
7059 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
);
7060
7061 return TRUE(!(0));
7062}
7063
7064void
7065fr_window_start_activity_mode (FrWindow *window)
7066{
7067 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
7068
7069 if (window->priv->activity_ref++ > 0)
7070 return;
7071
7072 window->priv->activity_timeout_handle = g_timeout_add (ACTIVITY_DELAY100,
7073 activity_cb,
7074 window);
7075 fr_window_update_sensitivity (window);
7076}
7077
7078void
7079fr_window_stop_activity_mode (FrWindow *window)
7080{
7081 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
7082
7083 if (window->priv->activity_ref == 0)
7084 return;
7085
7086 window->priv->activity_ref--;
7087
7088 if (window->priv->activity_ref > 0)
7089 return;
7090
7091 if (window->priv->activity_timeout_handle == 0)
7092 return;
7093
7094 g_source_remove (window->priv->activity_timeout_handle);
7095 window->priv->activity_timeout_handle = 0;
7096
7097 if (! gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
7098 return;
7099
7100 if (window->priv->progress_dialog != NULL((void*)0))
7101 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
, 0.0);
7102
7103 if (! window->priv->batch_mode) {
7104 if (window->priv->progress_bar != NULL((void*)0))
7105 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
, 0.0);
7106 fr_window_update_sensitivity (window);
7107 }
7108}
7109
7110static gboolean
7111last_output_window__unrealize_cb (GtkWidget *widget,
7112 gpointer data)
7113{
7114 pref_util_save_window_geometry (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, LAST_OUTPUT_DIALOG_NAME"last-output");
7115 return FALSE(0);
7116}
7117
7118static void
7119fr_window_view_last_output_print(GtkTextBuffer *text_buffer,
7120 GtkTextIter *iter,
7121 GList *scan)
7122{
7123 for (; scan; scan = scan->next) {
7124 char *line = scan->data;
7125 char *utf8_line;
7126 gsize bytes_written;
7127
7128 utf8_line = g_locale_to_utf8 (line, -1, NULL((void*)0), &bytes_written, NULL((void*)0));
7129 gtk_text_buffer_insert_with_tags_by_name (text_buffer,
7130 iter,
7131 utf8_line,
7132 bytes_written,
7133 "monospace", NULL((void*)0));
7134 g_free (utf8_line);
7135 gtk_text_buffer_insert (text_buffer, iter, "\n", 1);
7136 }
7137}
7138
7139void
7140fr_window_view_last_output (FrWindow *window,
7141 const char *title)
7142{
7143 GtkWidget *dialog;
7144 GtkWidget *vbox;
7145 GtkWidget *text_view;
7146 GtkWidget *scrolled;
7147 GtkTextBuffer *text_buffer;
7148 GtkTextIter iter;
7149
7150 if (title == NULL((void*)0))
7151 title = _("Last Output")gettext ("Last Output");
7152
7153 dialog = gtk_dialog_new_with_buttons (title,
7154 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7155 /* Make this dialog modal, otherwise with most WMs
7156 * the focus can’t be regained without the mouse. */
7157 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
7158 "gtk-close", GTK_RESPONSE_CLOSE,
7159 NULL((void*)0));
7160 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_CLOSE);
7161 gtk_window_set_resizable (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
7162 gtk_widget_set_size_request (dialog, 500, 300);
7163
7164 /* Add text */
7165
7166 scrolled = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
7167 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
7168 GTK_POLICY_AUTOMATIC,
7169 GTK_POLICY_AUTOMATIC);
7170 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
7171 GTK_SHADOW_ETCHED_IN);
7172
7173 text_buffer = gtk_text_buffer_new (NULL((void*)0));
7174 gtk_text_buffer_create_tag (text_buffer, "monospace",
7175 "family", "monospace", NULL((void*)0));
7176
7177 text_view = gtk_text_view_new_with_buffer (text_buffer);
7178 g_object_unref (text_buffer);
7179 gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
, FALSE(0));
7180 /* Although this isn’t an editable text area, we do want the
7181 * cursor for accessibility purposes. */
7182 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
, TRUE(!(0)));
7183
7184 /**/
7185
7186 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
7187 gtk_container_set_border_width (GTK_CONTAINER (vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_container_get_type ()))))))
, 5);
7188
7189 gtk_container_add (GTK_CONTAINER (scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, text_view);
7190 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, scrolled,
7191 TRUE(!(0)), TRUE(!(0)), 0);
7192
7193 gtk_widget_show_all (vbox);
7194 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_box_get_type ()))))))
,
7195 vbox,
7196 TRUE(!(0)), TRUE(!(0)), 0);
7197
7198 /* signals */
7199
7200 g_signal_connect (G_OBJECT (dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
7201 "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
7202 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
7203 NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
;
7204
7205 g_signal_connect (G_OBJECT (dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
7206 "unrealize",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
7207 G_CALLBACK (last_output_window__unrealize_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
7208 NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
7209
7210 gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0);
7211 /* Show STDOUT of process */
7212 fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->out.raw);
7213 /* Show STDERR of process */
7214 fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->err.raw);
7215 /* place the cursor at the start */
7216 gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0);
7217 gtk_text_buffer_place_cursor(text_buffer, &iter);
7218
7219 /**/
7220
7221 pref_util_restore_window_geometry (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, LAST_OUTPUT_DIALOG_NAME"last-output");
7222 gtk_widget_grab_focus (text_view);
7223}
7224
7225/* -- fr_window_rename_selection -- */
7226
7227typedef struct {
7228 char *path_to_rename;
7229 char *old_name;
7230 char *new_name;
7231 char *current_dir;
7232 gboolean is_dir;
7233 gboolean dir_in_archive;
7234 char *original_path;
7235} RenameData;
7236
7237static RenameData*
7238rename_data_new (const char *path_to_rename,
7239 const char *old_name,
7240 const char *new_name,
7241 const char *current_dir,
7242 gboolean is_dir,
7243 gboolean dir_in_archive,
7244 const char *original_path)
7245{
7246 RenameData *rdata;
7247
7248 rdata = g_new0 (RenameData, 1)((RenameData *) g_malloc0_n ((1), sizeof (RenameData)));
5
Null pointer value stored to field 'current_dir'
7249 rdata->path_to_rename = g_strdup (path_to_rename)g_strdup_inline (path_to_rename);
7250 if (old_name != NULL((void*)0))
6
Assuming 'old_name' is equal to NULL
7
Taking false branch
7251 rdata->old_name = g_strdup (old_name)g_strdup_inline (old_name);
7252 if (new_name != NULL((void*)0))
8
Assuming 'new_name' is equal to NULL
9
Taking false branch
7253 rdata->new_name = g_strdup (new_name)g_strdup_inline (new_name);
7254 if (current_dir != NULL((void*)0))
10
Assuming 'current_dir' is equal to NULL
11
Taking false branch
7255 rdata->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir);
7256 rdata->is_dir = is_dir;
7257 rdata->dir_in_archive = dir_in_archive;
7258 if (original_path != NULL((void*)0))
12
Assuming 'original_path' is equal to NULL
13
Taking false branch
7259 rdata->original_path = g_strdup (original_path)g_strdup_inline (original_path);
7260
7261 return rdata;
7262}
7263
7264static void
7265rename_data_free (RenameData *rdata)
7266{
7267 g_return_if_fail (rdata != NULL)do { if ((rdata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "rdata != NULL");
return; } } while (0)
;
7268
7269 g_free (rdata->path_to_rename);
7270 g_free (rdata->old_name);
7271 g_free (rdata->new_name);
7272 g_free (rdata->current_dir);
7273 g_free (rdata->original_path);
7274 g_free (rdata);
7275}
7276
7277static void
7278rename_selection (FrWindow *window,
7279 const char *path_to_rename,
7280 const char *old_name,
7281 const char *new_name,
7282 const char *current_dir,
7283 gboolean is_dir,
7284 gboolean dir_in_archive,
7285 const char *original_path)
7286{
7287 FrArchive *archive = window->archive;
7288 RenameData *rdata;
7289 char *tmp_dir;
7290 GList *file_list;
7291 gboolean added_dir;
7292 char *new_dirname;
7293 GList *new_file_list;
7294 GList *scan;
7295
7296 rdata = rename_data_new (path_to_rename,
4
Calling 'rename_data_new'
14
Returning from 'rename_data_new'
7297 old_name,
7298 new_name,
7299 current_dir,
7300 is_dir,
7301 dir_in_archive,
7302 original_path);
7303 fr_window_set_current_batch_action (window,
15
Calling 'fr_window_set_current_batch_action'
17
Returning from 'fr_window_set_current_batch_action'
7304 FR_BATCH_ACTION_RENAME,
7305 rdata,
7306 (GFreeFunc) rename_data_free);
7307
7308 fr_process_clear (archive->process);
7309
7310 tmp_dir = get_temp_work_dir (NULL((void*)0));
7311
7312 if (is_dir)
18
Assuming 'is_dir' is 0
19
Taking false branch
7313 file_list = get_dir_list_from_path (window, rdata->path_to_rename);
7314 else
7315 file_list = g_list_append (NULL((void*)0), g_strdup (rdata->path_to_rename)g_strdup_inline (rdata->path_to_rename));
7316
7317 fr_archive_extract_to_local (archive,
7318 file_list,
7319 tmp_dir,
7320 NULL((void*)0),
7321 FALSE(0),
7322 TRUE(!(0)),
7323 FALSE(0),
7324 window->priv->password);
7325
7326 /* temporarily add the dir to rename to the list if it's stored in the
7327 * archive, this way it will be removed from the archive... */
7328 added_dir = FALSE(0);
7329 if (is_dir
19.1
'is_dir' is 0
&& dir_in_archive && ! g_list_find_custom (file_list, original_path, (GCompareFunc) strcmp)) {
7330 file_list = g_list_prepend (file_list, g_strdup (original_path)g_strdup_inline (original_path));
7331 added_dir = TRUE(!(0));
7332 }
7333
7334 fr_archive_remove (archive, file_list, window->priv->compression);
7335 fr_window_clipboard_remove_file_list (window, file_list);
7336
7337 /* ...and remove it from the list again */
7338 if (added_dir
19.2
'added_dir' is 0
) {
20
Taking false branch
7339 GList *tmp;
7340
7341 tmp = file_list;
7342 file_list = g_list_remove_link (file_list, tmp);
7343
7344 g_free (tmp->data);
7345 g_list_free (tmp);
7346 }
7347
7348 /* rename the files. */
7349
7350 new_dirname = g_build_filename (rdata->current_dir + 1, rdata->new_name, "/", NULL((void*)0));
7351 new_file_list = NULL((void*)0);
7352 if (rdata->is_dir
20.1
Field 'is_dir' is 0
) {
21
Taking false branch
7353 char *old_path;
7354 char *new_path;
7355
7356 old_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->old_name, NULL((void*)0));
7357 new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, NULL((void*)0));
7358
7359 fr_process_begin_command (archive->process, "mv");
7360 fr_process_add_arg (archive->process, "-f");
7361 fr_process_add_arg (archive->process, old_path);
7362 fr_process_add_arg (archive->process, new_path);
7363 fr_process_end_command (archive->process);
7364
7365 g_free (old_path);
7366 g_free (new_path);
7367 }
7368
7369 for (scan = file_list; scan; scan = scan->next) {
22
Loop condition is true. Entering loop body
7370 const char *current_dir_relative = rdata->current_dir + 1;
7371 const char *filename = (char*) scan->data;
7372 char *old_path = NULL((void*)0), *common = NULL((void*)0), *new_path = NULL((void*)0);
7373 char *new_filename;
7374
7375 old_path = g_build_filename (tmp_dir, filename, NULL((void*)0));
7376
7377 if (strlen (filename) > (strlen (rdata->current_dir) + strlen (rdata->old_name)))
23
Null pointer passed to 1st parameter expecting 'nonnull'
7378 common = g_strdup (filename + strlen (rdata->current_dir) + strlen (rdata->old_name))g_strdup_inline (filename + strlen (rdata->current_dir) + strlen
(rdata->old_name))
;
7379 new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, common, NULL((void*)0));
7380
7381 if (! rdata->is_dir) {
7382 fr_process_begin_command (archive->process, "mv");
7383 fr_process_add_arg (archive->process, "-f");
7384 fr_process_add_arg (archive->process, old_path);
7385 fr_process_add_arg (archive->process, new_path);
7386 fr_process_end_command (archive->process);
7387 }
7388
7389 new_filename = g_build_filename (current_dir_relative, rdata->new_name, common, NULL((void*)0));
7390 new_file_list = g_list_prepend (new_file_list, new_filename);
7391
7392 g_free (old_path);
7393 g_free (common);
7394 g_free (new_path);
7395 }
7396 new_file_list = g_list_reverse (new_file_list);
7397
7398 /* FIXME: this is broken for tar archives.
7399 if (is_dir && dir_in_archive && ! g_list_find_custom (new_file_list, new_dirname, (GCompareFunc) strcmp))
7400 new_file_list = g_list_prepend (new_file_list, g_build_filename (rdata->current_dir + 1, rdata->new_name, NULL));
7401 */
7402
7403 fr_archive_add (archive,
7404 new_file_list,
7405 tmp_dir,
7406 NULL((void*)0),
7407 FALSE(0),
7408 FALSE(0),
7409 window->priv->password,
7410 window->priv->encrypt_header,
7411 window->priv->compression,
7412 window->priv->volume_size);
7413
7414 g_free (new_dirname);
7415 path_list_free (new_file_list);
7416 path_list_free (file_list);
7417
7418 /* remove the tmp dir */
7419
7420 fr_process_begin_command (archive->process, "rm");
7421 fr_process_set_working_dir (archive->process, g_get_tmp_dir ());
7422 fr_process_set_sticky (archive->process, TRUE(!(0)));
7423 fr_process_add_arg (archive->process, "-rf");
7424 fr_process_add_arg (archive->process, tmp_dir);
7425 fr_process_end_command (archive->process);
7426
7427 fr_process_start (archive->process);
7428
7429 g_free (tmp_dir);
7430}
7431
7432static gboolean
7433valid_name (const char *new_name,
7434 const char *old_name,
7435 char **reason)
7436{
7437 char *utf8_new_name;
7438 gboolean retval = TRUE(!(0));
7439
7440 new_name = eat_spaces (new_name);
7441 utf8_new_name = g_filename_display_name (new_name);
7442
7443 if (*new_name == '\0') {
7444 /* Translators: the name references to a filename. This message can appear when renaming a file. */
7445 *reason = g_strdup (_("New name is void, please type a name."))g_strdup_inline (gettext ("New name is void, please type a name."
))
;
7446 retval = FALSE(0);
7447 }
7448 else if (strcmp (new_name, old_name) == 0) {
7449 /* Translators: the name references to a filename. This message can appear when renaming a file. */
7450 *reason = g_strdup (_("New name is the same as old one, please type other name."))g_strdup_inline (gettext ("New name is the same as old one, please type other name."
))
;
7451 retval = FALSE(0);
7452 }
7453 else if (strchrs (new_name, BAD_CHARS"/\\*")) {
7454 /* Translators: the %s references to a filename. This message can appear when renaming a file. */
7455 *reason = g_strdup_printf (_("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name.")gettext ("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name."
)
, utf8_new_name, BAD_CHARS"/\\*");
7456 retval = FALSE(0);
7457 }
7458
7459 g_free (utf8_new_name);
7460
7461 return retval;
7462}
7463
7464static gboolean
7465name_is_present (FrWindow *window,
7466 const char *current_dir,
7467 const char *new_name,
7468 char **reason)
7469{
7470 gboolean retval = FALSE(0);
7471 guint i;
7472 char *new_filename;
7473 int new_filename_l;
7474
7475 *reason = NULL((void*)0);
7476
7477 new_filename = g_build_filename (current_dir, new_name, NULL((void*)0));
7478 new_filename_l = strlen (new_filename);
7479
7480 for (i = 0; i < window->archive->command->files->len; i++) {
7481 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
7482 const char *filename = fdata->full_path;
7483
7484 if ((strncmp (filename, new_filename, new_filename_l) == 0)
7485 && ((filename[new_filename_l] == '\0')
7486 || (filename[new_filename_l] == G_DIR_SEPARATOR'/'))) {
7487 char *utf8_name = g_filename_display_name (new_name);
7488
7489 if (filename[new_filename_l] == G_DIR_SEPARATOR'/')
7490 *reason = g_strdup_printf (_("A folder named \"%s\" already exists.\n\n%s")gettext ("A folder named \"%s\" already exists.\n\n%s"), utf8_name, _("Please use a different name.")gettext ("Please use a different name."));
7491 else
7492 *reason = g_strdup_printf (_("A file named \"%s\" already exists.\n\n%s")gettext ("A file named \"%s\" already exists.\n\n%s"), utf8_name, _("Please use a different name.")gettext ("Please use a different name."));
7493
7494 retval = TRUE(!(0));
7495 break;
7496 }
7497 }
7498
7499 g_free (new_filename);
7500
7501 return retval;
7502}
7503
7504void
7505fr_window_rename_selection (FrWindow *window,
7506 gboolean from_sidebar)
7507{
7508 char *path_to_rename;
7509 char *parent_dir;
7510 char *old_name;
7511 gboolean renaming_dir = FALSE(0);
7512 gboolean dir_in_archive = FALSE(0);
7513 char *original_path = NULL((void*)0);
7514 char *utf8_old_name;
7515 char *utf8_new_name;
7516
7517 if (from_sidebar) {
7518 path_to_rename = fr_window_get_selected_folder_in_tree_view (window);
7519 if (path_to_rename == NULL((void*)0))
7520 return;
7521 parent_dir = remove_level_from_path (path_to_rename);
7522 old_name = g_strdup (file_name_from_path (path_to_rename))g_strdup_inline (file_name_from_path (path_to_rename));
7523 renaming_dir = TRUE(!(0));
7524 }
7525 else {
7526 FileData *selected_item;
7527
7528 selected_item = fr_window_get_selected_item_from_file_list (window);
7529 if (selected_item == NULL((void*)0))
7530 return;
7531
7532 renaming_dir = file_data_is_dir (selected_item);
7533 dir_in_archive = selected_item->dir;
7534 original_path = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path);
7535
7536 if (renaming_dir && ! dir_in_archive) {
7537 parent_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
7538 old_name = g_strdup (selected_item->list_name)g_strdup_inline (selected_item->list_name);
7539 path_to_rename = g_build_filename (parent_dir, old_name, NULL((void*)0));
7540 }
7541 else {
7542 if (renaming_dir) {
7543 path_to_rename = remove_ending_separator (selected_item->full_path);
7544 parent_dir = remove_level_from_path (path_to_rename);
7545 }
7546 else {
7547 path_to_rename = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path);
7548 parent_dir = remove_level_from_path (selected_item->full_path);
7549 }
7550 old_name = g_strdup (selected_item->name)g_strdup_inline (selected_item->name);
7551 }
7552
7553 file_data_free (selected_item);
7554 }
7555
7556 retry__rename_selection:
7557 utf8_old_name = g_locale_to_utf8 (old_name, -1 ,0 ,0 ,0);
7558 utf8_new_name = _gtk_request_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7559 (GTK_DIALOG_DESTROY_WITH_PARENT
7560 | GTK_DIALOG_MODAL),
7561 _("Rename")gettext ("Rename"),
7562 (renaming_dir ? _("_New folder name:")gettext ("_New folder name:") : _("_New file name:")gettext ("_New file name:")),
7563 utf8_old_name,
7564 1024,
7565 _("_Cancel")gettext ("_Cancel"),
7566 _("_Rename")gettext ("_Rename"));
7567 g_free (utf8_old_name);
7568
7569 if (utf8_new_name != NULL((void*)0)) {
7570 char *new_name;
7571 char *reason = NULL((void*)0);
7572
7573 new_name = g_filename_from_utf8 (utf8_new_name, -1, 0, 0, 0);
7574 g_free (utf8_new_name);
7575
7576 if (! valid_name (new_name, old_name, &reason)) {
7577 char *utf8_name = g_filename_display_name (new_name);
7578 GtkWidget *dlg;
7579
7580 dlg = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7581 GTK_DIALOG_DESTROY_WITH_PARENT,
7582 NULL((void*)0),
7583 (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")),
7584 "%s",
7585 reason);
7586 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
7587 gtk_widget_destroy (dlg);
7588
7589 g_free (reason);
7590 g_free (utf8_name);
7591 g_free (new_name);
7592
7593 goto retry__rename_selection;
7594 }
7595
7596 if (name_is_present (window, parent_dir, new_name, &reason)) {
7597 GtkWidget *dlg;
7598
7599 dlg = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7600 GTK_DIALOG_MODAL,
7601 "dialog-question",
7602 (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")),
7603 reason,
7604 "gtk-close", GTK_RESPONSE_OK,
7605 NULL((void*)0));
7606 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
7607 gtk_widget_destroy (dlg);
7608 g_free (reason);
7609 g_free (new_name);
7610 goto retry__rename_selection;
7611 }
7612
7613 rename_selection (window,
7614 path_to_rename,
7615 old_name,
7616 new_name,
7617 parent_dir,
7618 renaming_dir,
7619 dir_in_archive,
7620 original_path);
7621
7622 g_free (new_name);
7623 }
7624
7625 g_free (old_name);
7626 g_free (parent_dir);
7627 g_free (path_to_rename);
7628 g_free (original_path);
7629}
7630
7631static void
7632fr_clipboard_get (GtkClipboard *clipboard,
7633 GtkSelectionData *selection_data,
7634 guint info,
7635 gpointer user_data_or_owner)
7636{
7637 FrWindow *window = user_data_or_owner;
7638 char *data;
7639
7640 if (gtk_selection_data_get_target (selection_data) != FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
)
7641 return;
7642
7643 data = get_selection_data_from_clipboard_data (window, window->priv->copy_data);
7644 gtk_selection_data_set (selection_data,
7645 gtk_selection_data_get_target (selection_data),
7646 8,
7647 (guchar *) data,
7648 strlen (data));
7649 g_free (data);
7650}
7651
7652static void
7653fr_clipboard_clear (GtkClipboard *clipboard,
7654 gpointer user_data_or_owner)
7655{
7656 FrWindow *window = user_data_or_owner;
7657
7658 if (window->priv->copy_data != NULL((void*)0)) {
7659 fr_clipboard_data_unref (window->priv->copy_data);
7660 window->priv->copy_data = NULL((void*)0);
7661 }
7662}
7663
7664GList *
7665fr_window_get_selection (FrWindow *window,
7666 gboolean from_sidebar,
7667 char **return_base_dir)
7668{
7669 GList *files;
7670 char *base_dir;
7671
7672 if (from_sidebar) {
7673 char *selected_folder;
7674 char *parent_folder;
7675
7676 files = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0));
7677 selected_folder = fr_window_get_selected_folder_in_tree_view (window);
7678 parent_folder = remove_level_from_path (selected_folder);
7679 if (parent_folder == NULL((void*)0))
7680 base_dir = g_strdup ("/")g_strdup_inline ("/");
7681 else if (parent_folder[strlen (parent_folder) - 1] == '/')
7682 base_dir = g_strdup (parent_folder)g_strdup_inline (parent_folder);
7683 else
7684 base_dir = g_strconcat (parent_folder, "/", NULL((void*)0));
7685 g_free (selected_folder);
7686 g_free (parent_folder);
7687 }
7688 else {
7689 files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0));
7690 base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
7691 }
7692
7693 if (return_base_dir)
7694 *return_base_dir = base_dir;
7695 else
7696 g_free (base_dir);
7697
7698 return files;
7699}
7700
7701static void
7702fr_window_copy_or_cut_selection (FrWindow *window,
7703 FRClipboardOp op,
7704 gboolean from_sidebar)
7705{
7706 GList *files;
7707 char *base_dir;
7708 GtkClipboard *clipboard;
7709
7710 files = fr_window_get_selection (window, from_sidebar, &base_dir);
7711
7712 if (window->priv->copy_data != NULL((void*)0))
7713 fr_clipboard_data_unref (window->priv->copy_data);
7714 window->priv->copy_data = fr_clipboard_data_new ();
7715 window->priv->copy_data->files = files;
7716 window->priv->copy_data->op = op;
7717 window->priv->copy_data->base_dir = base_dir;
7718
7719 clipboard = gtk_clipboard_get (FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
7720 gtk_clipboard_set_with_owner (clipboard,
7721 clipboard_targets,
7722 G_N_ELEMENTS (clipboard_targets)(sizeof (clipboard_targets) / sizeof ((clipboard_targets)[0])
)
,
7723 fr_clipboard_get,
7724 fr_clipboard_clear,
7725 G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
);
7726
7727 fr_window_update_sensitivity (window);
7728}
7729
7730void
7731fr_window_copy_selection (FrWindow *window,
7732 gboolean from_sidebar)
7733{
7734 fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_COPY, from_sidebar);
7735}
7736
7737void
7738fr_window_cut_selection (FrWindow *window,
7739 gboolean from_sidebar)
7740{
7741 fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_CUT, from_sidebar);
7742}
7743
7744static gboolean
7745always_fake_load (FrArchive *archive,
7746 gpointer data)
7747{
7748 return TRUE(!(0));
7749}
7750
7751static void
7752add_pasted_files (FrWindow *window,
7753 FrClipboardData *data)
7754{
7755 const char *current_dir_relative = data->current_dir + 1;
7756 GList *scan;
7757 GList *new_file_list = NULL((void*)0);
7758
7759 if (window->priv->password_for_paste != NULL((void*)0)) {
7760 g_free (window->priv->password_for_paste);
7761 window->priv->password_for_paste = NULL((void*)0);
7762 }
7763
7764 fr_process_clear (window->archive->process);
7765 for (scan = data->files; scan; scan = scan->next) {
7766 const char *old_name = (char*) scan->data;
7767 char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0));
7768
7769 /* skip folders */
7770
7771 if ((strcmp (old_name, new_name) != 0)
7772 && (old_name[strlen (old_name) - 1] != '/'))
7773 {
7774 fr_process_begin_command (window->archive->process, "mv");
7775 fr_process_set_working_dir (window->archive->process, data->tmp_dir);
7776 fr_process_add_arg (window->archive->process, "-f");
7777 if (old_name[0] == '/')
7778 old_name = old_name + 1;
7779 fr_process_add_arg (window->archive->process, old_name);
7780 fr_process_add_arg (window->archive->process, new_name);
7781 fr_process_end_command (window->archive->process);
7782 }
7783
7784 new_file_list = g_list_prepend (new_file_list, new_name);
7785 }
7786
7787 fr_archive_add (window->archive,
7788 new_file_list,
7789 data->tmp_dir,
7790 NULL((void*)0),
7791 FALSE(0),
7792 FALSE(0),
7793 window->priv->password,
7794 window->priv->encrypt_header,
7795 window->priv->compression,
7796 window->priv->volume_size);
7797
7798 path_list_free (new_file_list);
7799
7800 /* remove the tmp dir */
7801
7802 fr_process_begin_command (window->archive->process, "rm");
7803 fr_process_set_working_dir (window->archive->process, g_get_tmp_dir ());
7804 fr_process_set_sticky (window->archive->process, TRUE(!(0)));
7805 fr_process_add_arg (window->archive->process, "-rf");
7806 fr_process_add_arg (window->archive->process, data->tmp_dir);
7807 fr_process_end_command (window->archive->process);
7808
7809 fr_process_start (window->archive->process);
7810}
7811
7812static void
7813copy_from_archive_action_performed_cb (FrArchive *archive,
7814 FrAction action,
7815 FrProcError *error,
7816 gpointer data)
7817{
7818 FrWindow *window = data;
7819 gboolean UNUSED_VARIABLE__attribute__ ((unused)) continue_batch = FALSE(0);
7820
7821#ifdef MATE_ENABLE_DEBUG
7822 debug (DEBUG_INFO"fr-window.c", 7822, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action));
7823#endif
7824
7825 fr_window_stop_activity_mode (window);
7826 fr_window_pop_message (window);
7827 close_progress_dialog (window, FALSE(0));
7828
7829 if (error->type == FR_PROC_ERROR_ASK_PASSWORD) {
7830 dlg_ask_password_for_paste_operation (window);
7831 return;
7832 }
7833
7834 (void) handle_errors (window, archive, action, error);
7835
7836 if (error->type != FR_PROC_ERROR_NONE) {
7837 fr_clipboard_data_unref (window->priv->clipboard_data);
7838 window->priv->clipboard_data = NULL((void*)0);
7839 return;
7840 }
7841
7842 switch (action) {
7843 case FR_ACTION_LISTING_CONTENT:
7844 fr_process_clear (window->priv->copy_from_archive->process);
7845 fr_archive_extract_to_local (window->priv->copy_from_archive,
7846 window->priv->clipboard_data->files,
7847 window->priv->clipboard_data->tmp_dir,
7848 NULL((void*)0),
7849 FALSE(0),
7850 TRUE(!(0)),
7851 FALSE(0),
7852 window->priv->clipboard_data->archive_password);
7853 fr_process_start (window->priv->copy_from_archive->process);
7854 break;
7855
7856 case FR_ACTION_EXTRACTING_FILES:
7857 if (window->priv->clipboard_data->op == FR_CLIPBOARD_OP_CUT) {
7858 fr_process_clear (window->priv->copy_from_archive->process);
7859 fr_archive_remove (window->priv->copy_from_archive,
7860 window->priv->clipboard_data->files,
7861 window->priv->compression);
7862 fr_process_start (window->priv->copy_from_archive->process);
7863 }
7864 else
7865 add_pasted_files (window, window->priv->clipboard_data);
7866 break;
7867
7868 case FR_ACTION_DELETING_FILES:
7869 add_pasted_files (window, window->priv->clipboard_data);
7870 break;
7871
7872 default:
7873 break;
7874 }
7875}
7876
7877static void
7878fr_window_paste_from_clipboard_data (FrWindow *window,
7879 FrClipboardData *data)
7880{
7881 const char *current_dir_relative;
7882 GHashTable *created_dirs;
7883 GList *scan;
7884
7885 if (window->priv->password_for_paste != NULL((void*)0))
7886 fr_clipboard_data_set_password (data, window->priv->password_for_paste);
7887
7888 if (window->priv->clipboard_data != data) {
7889 fr_clipboard_data_unref (window->priv->clipboard_data);
7890 window->priv->clipboard_data = data;
7891 }
7892
7893 fr_window_set_current_batch_action (window,
7894 FR_BATCH_ACTION_PASTE,
7895 fr_clipboard_data_ref (data),
7896 (GFreeFunc) fr_clipboard_data_unref);
7897
7898 current_dir_relative = data->current_dir + 1;
7899
7900 data->tmp_dir = get_temp_work_dir (NULL((void*)0));
7901 created_dirs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
7902 for (scan = data->files; scan; scan = scan->next) {
7903 const char *old_name = (char*) scan->data;
7904 char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0));
7905 char *dir = remove_level_from_path (new_name);
7906
7907 if ((dir != NULL((void*)0)) && (g_hash_table_lookup (created_dirs, dir) == NULL((void*)0))) {
7908 char *dir_path;
7909
7910 dir_path = g_build_filename (data->tmp_dir, dir, NULL((void*)0));
7911 debug (DEBUG_INFO"fr-window.c", 7911, __FUNCTION__, "mktree %s\n", dir_path);
7912 make_directory_tree_from_path (dir_path, 0700, NULL((void*)0));
7913
7914 g_free (dir_path);
7915 g_hash_table_replace (created_dirs, g_strdup (dir)g_strdup_inline (dir), "1");
7916 }
7917
7918 g_free (dir);
7919 g_free (new_name);
7920 }
7921 g_hash_table_destroy (created_dirs);
7922
7923 /**/
7924
7925 if (window->priv->copy_from_archive == NULL((void*)0)) {
7926 window->priv->copy_from_archive = fr_archive_new ();
7927 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
7928 "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
7929 G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
7930 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
;
7931 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
7932 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
7933 G_CALLBACK (copy_from_archive_action_performed_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
7934 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
;
7935 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7936 "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7937 G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7938 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
7939 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7940 "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7941 G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7942 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
7943 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7944 "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7945 G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7946 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
7947 fr_archive_set_fake_load_func (window->priv->copy_from_archive, always_fake_load, NULL((void*)0));
7948 }
7949 fr_archive_load_local (window->priv->copy_from_archive,
7950 data->archive_filename,
7951 data->archive_password);
7952}
7953
7954static void
7955fr_window_paste_selection_to (FrWindow *window,
7956 const char *current_dir)
7957{
7958 GtkClipboard *clipboard;
7959 GtkSelectionData *selection_data;
7960 FrClipboardData *paste_data;
7961
7962 clipboard = gtk_clipboard_get (FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
7963 selection_data = gtk_clipboard_wait_for_contents (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
);
7964 if (selection_data == NULL((void*)0))
7965 return;
7966
7967 paste_data = get_clipboard_data_from_selection_data (window, (char*) gtk_selection_data_get_data (selection_data));
7968 paste_data->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir);
7969 fr_window_paste_from_clipboard_data (window, paste_data);
7970
7971 gtk_selection_data_free (selection_data);
7972}
7973
7974void
7975fr_window_paste_selection (FrWindow *window,
7976 gboolean from_sidebar)
7977{
7978 char *utf8_path, *utf8_old_path, *destination;
7979 char *current_dir;
7980
7981 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
7982 return;
7983
7984 /**/
7985
7986 utf8_old_path = g_filename_to_utf8 (fr_window_get_current_location (window), -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
7987 utf8_path = _gtk_request_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7988 (GTK_DIALOG_DESTROY_WITH_PARENT
7989 | GTK_DIALOG_MODAL),
7990 _("Paste Selection")gettext ("Paste Selection"),
7991 _("_Destination folder:")gettext ("_Destination folder:"),
7992 utf8_old_path,
7993 1024,
7994 _("_Cancel")gettext ("_Cancel"),
7995 _("_Paste")gettext ("_Paste"));
7996 g_free (utf8_old_path);
7997 if (utf8_path == NULL((void*)0))
7998 return;
7999
8000 destination = g_filename_from_utf8 (utf8_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
8001 g_free (utf8_path);
8002
8003 if (destination[0] != '/')
8004 current_dir = build_uri (fr_window_get_current_location (window), destination, NULL((void*)0));
8005 else
8006 current_dir = g_strdup (destination)g_strdup_inline (destination);
8007 g_free (destination);
8008
8009 fr_window_paste_selection_to (window, current_dir);
8010
8011 g_free (current_dir);
8012}
8013
8014/* -- fr_window_open_files -- */
8015
8016void
8017fr_window_open_files_with_command (FrWindow *window,
8018 GList *file_list,
8019 char *command)
8020{
8021 GAppInfo *app;
8022 GError *error = NULL((void*)0);
8023
8024 app = g_app_info_create_from_commandline (command, NULL((void*)0), G_APP_INFO_CREATE_NONE, &error);
8025 if (error != NULL((void*)0)) {
8026 _gtk_error_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
8027 _("Could not perform the operation")gettext ("Could not perform the operation"),
8028 "%s",
8029 error->message);
8030 g_clear_error (&error);
8031 return;
8032 }
8033
8034 fr_window_open_files_with_application (window, file_list, app);
8035}
8036
8037void
8038fr_window_open_files_with_application (FrWindow *window,
8039 GList *file_list,
8040 GAppInfo *app)
8041{
8042 GList *uris;
8043 GList *scan;
8044 GdkAppLaunchContext *context;
8045 GError *error = NULL((void*)0);
8046
8047 if (window->priv->activity_ref > 0)
8048 return;
8049
8050 g_assert (file_list != NULL)do { if (file_list != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fr-window.c", 8050, ((const char*) (__func__
)), "file_list != NULL"); } while (0)
;
8051
8052 uris = NULL((void*)0);
8053 for (scan = file_list; scan; scan = scan->next)
8054 uris = g_list_prepend (uris, g_filename_to_uri (scan->data, NULL((void*)0), NULL((void*)0)));
8055
8056 context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
8057 gdk_app_launch_context_set_screen (context, gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
8058 gdk_app_launch_context_set_timestamp (context, 0);
8059
8060 if (! g_app_info_launch_uris (app, uris, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, &error)) {
8061 _gtk_error_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
8062 _("Could not perform the operation")gettext ("Could not perform the operation"),
8063 "%s",
8064 error->message);
8065 g_clear_error (&error);
8066 }
8067
8068 g_object_unref (context);
8069 path_list_free (uris);
8070}
8071
8072typedef struct {
8073 FrWindow *window;
8074 GList *file_list;
8075 gboolean ask_application;
8076 CommandData *cdata;
8077} OpenFilesData;
8078
8079static OpenFilesData*
8080open_files_data_new (FrWindow *window,
8081 GList *file_list,
8082 gboolean ask_application)
8083
8084{
8085 OpenFilesData *odata;
8086 GList *scan;
8087
8088 odata = g_new0 (OpenFilesData, 1)((OpenFilesData *) g_malloc0_n ((1), sizeof (OpenFilesData)));
8089 odata->window = window;
8090 odata->file_list = path_list_dup (file_list);
8091 odata->ask_application = ask_application;
8092 odata->cdata = g_new0 (CommandData, 1)((CommandData *) g_malloc0_n ((1), sizeof (CommandData)));
8093 odata->cdata->temp_dir = get_temp_work_dir (NULL((void*)0));
8094 odata->cdata->file_list = NULL((void*)0);
8095 for (scan = file_list; scan; scan = scan->next) {
8096 char *file = scan->data;
8097 char *filename;
8098
8099 filename = g_strconcat (odata->cdata->temp_dir,
8100 "/",
8101 file,
8102 NULL((void*)0));
8103 odata->cdata->file_list = g_list_prepend (odata->cdata->file_list, filename);
8104 }
8105
8106 /* Add to CommandList so the cdata is released on exit. */
8107 CommandList = g_list_prepend (CommandList, odata->cdata);
8108
8109 return odata;
8110}
8111
8112static void
8113open_files_data_free (OpenFilesData *odata)
8114{
8115 g_return_if_fail (odata != NULL)do { if ((odata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "odata != NULL");
return; } } while (0)
;
8116
8117 path_list_free (odata->file_list);
8118 g_free (odata);
8119}
8120
8121void
8122fr_window_update_dialog_closed (FrWindow *window)
8123{
8124 window->priv->update_dialog = NULL((void*)0);
8125}
8126
8127gboolean
8128fr_window_update_files (FrWindow *window,
8129 GList *file_list)
8130{
8131 GList *scan;
8132
8133 if (window->priv->activity_ref > 0)
8134 return FALSE(0);
8135
8136 if (window->archive->read_only)
8137 return FALSE(0);
8138
8139 fr_process_clear (window->archive->process);
8140
8141 for (scan = file_list; scan; scan = scan->next) {
8142 OpenFile *file = scan->data;
8143 GList *local_file_list;
8144
8145 local_file_list = g_list_append (NULL((void*)0), file->path);
8146 fr_archive_add (window->archive,
8147 local_file_list,
8148 file->temp_dir,
8149 "/",
8150 FALSE(0),
8151 FALSE(0),
8152 window->priv->password,
8153 window->priv->encrypt_header,
8154 window->priv->compression,
8155 window->priv->volume_size);
8156 g_list_free (local_file_list);
8157 }
8158
8159 fr_process_start (window->archive->process);
8160
8161 return TRUE(!(0));
8162}
8163
8164static void
8165open_file_modified_cb (GFileMonitor *monitor,
8166 GFile *monitor_file,
8167 GFile *other_file,
8168 GFileMonitorEvent event_type,
8169 gpointer user_data)
8170{
8171 FrWindow *window = user_data;
8172 char *monitor_uri;
8173 OpenFile *file;
8174 GList *scan;
8175
8176 if ((event_type != G_FILE_MONITOR_EVENT_CHANGED)
8177 && (event_type != G_FILE_MONITOR_EVENT_CREATED))
8178 {
8179 return;
8180 }
8181
8182 monitor_uri = g_file_get_uri (monitor_file);
8183 file = NULL((void*)0);
8184 for (scan = window->priv->open_files; scan; scan = scan->next) {
8185 OpenFile *test = scan->data;
8186 if (uricmp (test->extracted_uri, monitor_uri) == 0) {
8187 file = test;
8188 break;
8189 }
8190 }
8191 g_free (monitor_uri);
8192
8193 g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return
; } } while (0)
;
8194
8195 if (window->priv->update_dialog == NULL((void*)0))
8196 window->priv->update_dialog = dlg_update (window);
8197 dlg_update_add_file (window->priv->update_dialog, file);
8198}
8199
8200static void
8201fr_window_monitor_open_file (FrWindow *window,
8202 OpenFile *file)
8203{
8204 GFile *f;
8205
8206 window->priv->open_files = g_list_prepend (window->priv->open_files, file);
8207 f = g_file_new_for_uri (file->extracted_uri);
8208 file->monitor = g_file_monitor_file (f, 0, NULL((void*)0), NULL((void*)0));
8209 g_signal_connect (file->monitor,g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
8210 "changed",g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
8211 G_CALLBACK (open_file_modified_cb),g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
8212 window)g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
8213 g_object_unref (f);
8214}
8215
8216static void
8217monitor_extracted_files (OpenFilesData *odata)
8218{
8219 FrWindow *window = odata->window;
8220 GList *scan1, *scan2;
8221
8222 for (scan1 = odata->file_list, scan2 = odata->cdata->file_list;
8223 scan1 && scan2;
8224 scan1 = scan1->next, scan2 = scan2->next)
8225 {
8226 OpenFile *ofile;
8227 const char *file = scan1->data;
8228 const char *extracted_path = scan2->data;
8229
8230 ofile = open_file_new (file, extracted_path, odata->cdata->temp_dir);
8231 if (ofile != NULL((void*)0))
8232 fr_window_monitor_open_file (window, ofile);
8233 }
8234}
8235
8236static gboolean
8237fr_window_open_extracted_files (OpenFilesData *odata)
8238{
8239 GList *file_list = odata->cdata->file_list;
8240 const char *first_file;
8241 const char *first_mime_type;
8242 GAppInfo *app;
8243 GList *files_to_open = NULL((void*)0);
8244 GdkAppLaunchContext *context;
8245 gboolean result;
8246 GError *error = NULL((void*)0);
8247
8248 g_return_val_if_fail (file_list != NULL, FALSE)do { if ((file_list != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "file_list != NULL"
); return ((0)); } } while (0)
;
8249
8250 first_file = (char*) file_list->data;
8251 if (first_file == NULL((void*)0))
8252 return FALSE(0);
8253
8254 if (! odata->window->archive->read_only)
8255 monitor_extracted_files (odata);
8256
8257 if (odata->ask_application) {
8258 dlg_open_with (odata->window, file_list);
8259 return FALSE(0);
8260 }
8261
8262 first_mime_type = get_file_mime_type_for_path (first_file, FALSE(0));
8263 app = g_app_info_get_default_for_type (first_mime_type, FALSE(0));
8264
8265 if (app == NULL((void*)0)) {
8266 dlg_open_with (odata->window, file_list);
8267 return FALSE(0);
8268 }
8269
8270 files_to_open = g_list_append (files_to_open, g_filename_to_uri (first_file, NULL((void*)0), NULL((void*)0)));
8271
8272 if (g_app_info_supports_files (app)) {
8273 GList *scan;
8274
8275 for (scan = file_list->next; scan; scan = scan->next) {
8276 const char *path = scan->data;
8277 const char *mime_type;
8278
8279 mime_type = get_file_mime_type_for_path (path, FALSE(0));
8280 if (mime_type == NULL((void*)0))
8281 continue;
8282
8283 if (strcmp (mime_type, first_mime_type) == 0) {
8284 files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0)));
8285 }
8286 else {
8287 GAppInfo *app2;
8288
8289 app2 = g_app_info_get_default_for_type (mime_type, FALSE(0));
8290 if (g_app_info_equal (app, app2))
8291 files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0)));
8292 g_object_unref (app2);
8293 }
8294 }
8295 }
8296
8297 context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (odata->window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_widget_get_type ()))))))
));
8298 gdk_app_launch_context_set_screen (context, gtk_widget_get_screen (GTK_WIDGET (odata->window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_widget_get_type ()))))))
));
8299 gdk_app_launch_context_set_timestamp (context, 0);
8300 result = g_app_info_launch_uris (app, files_to_open, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, &error);
8301 if (! result) {
8302 _gtk_error_dialog_run (GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
,
8303 _("Could not perform the operation")gettext ("Could not perform the operation"),
8304 "%s",
8305 error->message);
8306 g_clear_error (&error);
8307 }
8308
8309 g_object_unref (context);
8310 g_object_unref (app);
8311 path_list_free (files_to_open);
8312
8313 return result;
8314}
8315
8316static void
8317fr_window_open_files__extract_done_cb (FrArchive *archive,
8318 FrAction action,
8319 FrProcError *error,
8320 gpointer callback_data)
8321{
8322 OpenFilesData *odata = callback_data;
8323
8324 g_signal_handlers_disconnect_matched (G_OBJECT (archive)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((archive)), (((GType) ((20) << (2))))))))
,
8325 G_SIGNAL_MATCH_DATA,
8326 0,
8327 0, NULL((void*)0),
8328 0,
8329 odata);
8330
8331 if (error->type == FR_PROC_ERROR_NONE)
8332 fr_window_open_extracted_files (odata);
8333}
8334
8335void
8336fr_window_open_files (FrWindow *window,
8337 GList *file_list,
8338 gboolean ask_application)
8339{
8340 OpenFilesData *odata;
8341
8342 if (window->priv->activity_ref > 0)
8343 return;
8344
8345 odata = open_files_data_new (window, file_list, ask_application);
8346 fr_window_set_current_batch_action (window,
8347 FR_BATCH_ACTION_OPEN_FILES,
8348 odata,
8349 (GFreeFunc) open_files_data_free);
8350
8351 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
8352 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
8353 G_CALLBACK (fr_window_open_files__extract_done_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
8354 odata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
;
8355
8356 fr_process_clear (window->archive->process);
8357 fr_archive_extract_to_local (window->archive,
8358 odata->file_list,
8359 odata->cdata->temp_dir,
8360 NULL((void*)0),
8361 FALSE(0),
8362 TRUE(!(0)),
8363 FALSE(0),
8364 window->priv->password);
8365 fr_process_start (window->archive->process);
8366}
8367
8368/**/
8369
8370static char*
8371get_default_dir (const char *dir)
8372{
8373 if (! is_temp_dir (dir))
8374 return g_strdup (dir)g_strdup_inline (dir);
8375 else
8376 return NULL((void*)0);
8377}
8378
8379void
8380fr_window_set_open_default_dir (FrWindow *window,
8381 const char *default_dir)
8382{
8383 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8384 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8385
8386 if (window->priv->open_default_dir != NULL((void*)0))
8387 g_free (window->priv->open_default_dir);
8388 window->priv->open_default_dir = get_default_dir (default_dir);
8389}
8390
8391const char *
8392fr_window_get_open_default_dir (FrWindow *window)
8393{
8394 if (window->priv->open_default_dir == NULL((void*)0))
8395 return get_home_uri ();
8396 else
8397 return window->priv->open_default_dir;
8398}
8399
8400void
8401fr_window_set_add_default_dir (FrWindow *window,
8402 const char *default_dir)
8403{
8404 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8405 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8406
8407 if (window->priv->add_default_dir != NULL((void*)0))
8408 g_free (window->priv->add_default_dir);
8409 window->priv->add_default_dir = get_default_dir (default_dir);
8410}
8411
8412const char *
8413fr_window_get_add_default_dir (FrWindow *window)
8414{
8415 if (window->priv->add_default_dir == NULL((void*)0))
8416 return get_home_uri ();
8417 else
8418 return window->priv->add_default_dir;
8419}
8420
8421void
8422fr_window_set_extract_default_dir (FrWindow *window,
8423 const char *default_dir,
8424 gboolean freeze)
8425{
8426 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8427 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8428
8429 /* do not change this dir while it's used by the non-interactive
8430 * extraction operation. */
8431 if (window->priv->extract_interact_use_default_dir)
8432 return;
8433
8434 window->priv->extract_interact_use_default_dir = freeze;
8435
8436 if (window->priv->extract_default_dir != NULL((void*)0))
8437 g_free (window->priv->extract_default_dir);
8438 window->priv->extract_default_dir = get_default_dir (default_dir);
8439}
8440
8441const char *
8442fr_window_get_extract_default_dir (FrWindow *window)
8443{
8444 if (window->priv->extract_default_dir == NULL((void*)0))
8445 return get_home_uri ();
8446 else
8447 return window->priv->extract_default_dir;
8448}
8449
8450void
8451fr_window_set_default_dir (FrWindow *window,
8452 const char *default_dir,
8453 gboolean freeze)
8454{
8455 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8456 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8457
8458 window->priv->freeze_default_dir = freeze;
8459
8460 fr_window_set_open_default_dir (window, default_dir);
8461 fr_window_set_add_default_dir (window, default_dir);
8462 fr_window_set_extract_default_dir (window, default_dir, FALSE(0));
8463}
8464
8465void
8466fr_window_update_columns_visibility (FrWindow *window)
8467{
8468 GtkTreeView *tree_view = GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
;
8469 GtkTreeViewColumn *column;
8470
8471 column = gtk_tree_view_get_column (tree_view, 1);
8472 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_SIZE"show-size"));
8473
8474 column = gtk_tree_view_get_column (tree_view, 2);
8475 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TYPE"show-type"));
8476
8477 column = gtk_tree_view_get_column (tree_view, 3);
8478 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TIME"show-time"));
8479
8480 column = gtk_tree_view_get_column (tree_view, 4);
8481 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path"));
8482}
8483
8484void
8485fr_window_set_toolbar_visibility (FrWindow *window,
8486 gboolean visible)
8487{
8488 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8489
8490 if (visible)
8491 gtk_widget_show (window->priv->toolbar);
8492 else
8493 gtk_widget_hide (window->priv->toolbar);
8494
8495 set_active (window, "ViewToolbar", visible);
8496}
8497
8498void
8499fr_window_set_statusbar_visibility (FrWindow *window,
8500 gboolean visible)
8501{
8502 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8503
8504 if (visible)
8505 gtk_widget_show (window->priv->statusbar);
8506 else
8507 gtk_widget_hide (window->priv->statusbar);
8508
8509 set_active (window, "ViewStatusbar", visible);
8510}
8511
8512void
8513fr_window_set_folders_visibility (FrWindow *window,
8514 gboolean value)
8515{
8516 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8517
8518 window->priv->view_folders = value;
8519 fr_window_update_dir_tree (window);
8520
8521 set_active (window, "ViewFolders", window->priv->view_folders);
8522}
8523
8524void
8525fr_window_use_progress_dialog (FrWindow *window,
8526 gboolean value)
8527{
8528 window->priv->use_progress_dialog = value;
8529}
8530
8531/* -- batch mode procedures -- */
8532
8533static void fr_window_exec_current_batch_action (FrWindow *window);
8534
8535static void
8536fr_window_exec_batch_action (FrWindow *window,
8537 FRBatchAction *action)
8538{
8539 ExtractData *edata;
8540 RenameData *rdata;
8541 OpenFilesData *odata;
8542 SaveAsData *sdata;
8543
8544 switch (action->type) {
2
Control jumps to 'case FR_BATCH_ACTION_RENAME:' at line 8604
8545 case FR_BATCH_ACTION_LOAD:
8546 debug (DEBUG_INFO"fr-window.c", 8546, __FUNCTION__, "[BATCH] LOAD\n");
8547
8548 if (! uri_exists ((char*) action->data))
8549 fr_window_archive_new (window, (char*) action->data);
8550 else
8551 fr_window_archive_open (window, (char*) action->data, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
8552 break;
8553
8554 case FR_BATCH_ACTION_ADD:
8555 debug (DEBUG_INFO"fr-window.c", 8555, __FUNCTION__, "[BATCH] ADD\n");
8556
8557 fr_window_archive_add_dropped_items (window, (GList*) action->data, FALSE(0));
8558 break;
8559
8560 case FR_BATCH_ACTION_DELETE:
8561 debug (DEBUG_INFO"fr-window.c", 8561, __FUNCTION__, "[BATCH] DELETE\n");
8562
8563 fr_window_archive_remove (window, (GList*) action->data);
8564 break;
8565
8566 case FR_BATCH_ACTION_OPEN:
8567 debug (DEBUG_INFO"fr-window.c", 8567, __FUNCTION__, "[BATCH] OPEN\n");
8568
8569 fr_window_push_message (window, _("Add files to an archive")gettext ("Add files to an archive"));
8570 dlg_batch_add_files (window, (GList*) action->data);
8571 break;
8572
8573 case FR_BATCH_ACTION_EXTRACT_HERE:
8574 debug (DEBUG_INFO"fr-window.c", 8574, __FUNCTION__, "[BATCH] EXTRACT HERE\n");
8575
8576 fr_window_archive_extract_here (window,
8577 FALSE(0),
8578 FR_OVERWRITE_NO,
8579 FALSE(0));
8580 break;
8581
8582 case FR_BATCH_ACTION_EXTRACT_INTERACT:
8583 debug (DEBUG_INFO"fr-window.c", 8583, __FUNCTION__, "[BATCH] EXTRACT_INTERACT\n");
8584
8585 if (window->priv->extract_interact_use_default_dir
8586 && (window->priv->extract_default_dir != NULL((void*)0)))
8587 {
8588 fr_window_archive_extract (window,
8589 NULL((void*)0),
8590 window->priv->extract_default_dir,
8591 NULL((void*)0),
8592 NULL((void*)0),
8593 FALSE(0),
8594 FR_OVERWRITE_ASK,
8595 FALSE(0),
8596 TRUE(!(0)));
8597 }
8598 else {
8599 fr_window_push_message (window, _("Extract archive")gettext ("Extract archive"));
8600 dlg_extract (NULL((void*)0), window);
8601 }
8602 break;
8603
8604 case FR_BATCH_ACTION_RENAME:
8605 debug (DEBUG_INFO"fr-window.c", 8605, __FUNCTION__, "[BATCH] RENAME\n");
8606
8607 rdata = action->data;
8608 rename_selection (window,
3
Calling 'rename_selection'
8609 rdata->path_to_rename,
8610 rdata->old_name,
8611 rdata->new_name,
8612 rdata->current_dir,
8613 rdata->is_dir,
8614 rdata->dir_in_archive,
8615 rdata->original_path);
8616 break;
8617
8618 case FR_BATCH_ACTION_PASTE:
8619 debug (DEBUG_INFO"fr-window.c", 8619, __FUNCTION__, "[BATCH] PASTE\n");
8620
8621 fr_window_paste_from_clipboard_data (window, (FrClipboardData*) action->data);
8622 break;
8623
8624 case FR_BATCH_ACTION_OPEN_FILES:
8625 debug (DEBUG_INFO"fr-window.c", 8625, __FUNCTION__, "[BATCH] OPEN FILES\n");
8626
8627 odata = action->data;
8628 fr_window_open_files (window, odata->file_list, odata->ask_application);
8629 break;
8630
8631 case FR_BATCH_ACTION_SAVE_AS:
8632 debug (DEBUG_INFO"fr-window.c", 8632, __FUNCTION__, "[BATCH] SAVE_AS\n");
8633
8634 sdata = action->data;
8635 fr_window_archive_save_as (window,
8636 sdata->uri,
8637 sdata->password,
8638 sdata->encrypt_header,
8639 sdata->volume_size);
8640 break;
8641
8642 case FR_BATCH_ACTION_TEST:
8643 debug (DEBUG_INFO"fr-window.c", 8643, __FUNCTION__, "[BATCH] TEST\n");
8644
8645 fr_window_archive_test (window);
8646 break;
8647
8648 case FR_BATCH_ACTION_CLOSE:
8649 debug (DEBUG_INFO"fr-window.c", 8649, __FUNCTION__, "[BATCH] CLOSE\n");
8650
8651 fr_window_archive_close (window);
8652 fr_window_exec_next_batch_action (window);
8653 break;
8654
8655 case FR_BATCH_ACTION_QUIT:
8656 debug (DEBUG_INFO"fr-window.c", 8656, __FUNCTION__, "[BATCH] QUIT\n");
8657
8658 g_signal_emit (window,
8659 fr_window_signals[READY],
8660 0,
8661 NULL((void*)0));
8662
8663 if ((window->priv->progress_dialog != NULL((void*)0)) && (gtk_widget_get_parent (window->priv->progress_dialog) != GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
8664 gtk_widget_destroy (window->priv->progress_dialog);
8665 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
8666 break;
8667
8668 default:
8669 break;
8670 }
8671}
8672
8673void
8674fr_window_reset_current_batch_action (FrWindow *window)
8675{
8676 FRBatchAction *adata = &window->priv->current_batch_action;
8677
8678 if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0)))
8679 (*adata->free_func) (adata->data);
8680 adata->type = FR_BATCH_ACTION_NONE;
8681 adata->data = NULL((void*)0);
8682 adata->free_func = NULL((void*)0);
8683}
8684
8685void
8686fr_window_set_current_batch_action (FrWindow *window,
8687 FrBatchActionType action,
8688 void *data,
8689 GFreeFunc free_func)
8690{
8691 FRBatchAction *adata = &window->priv->current_batch_action;
8692
8693 fr_window_reset_current_batch_action (window);
8694
8695 adata->type = action;
8696 adata->data = data;
8697 adata->free_func = free_func;
8698}
16
Returning without writing to 'data->current_dir'
8699
8700void
8701fr_window_restart_current_batch_action (FrWindow *window)
8702{
8703 fr_window_exec_batch_action (window, &window->priv->current_batch_action);
1
Calling 'fr_window_exec_batch_action'
8704}
8705
8706void
8707fr_window_append_batch_action (FrWindow *window,
8708 FrBatchActionType action,
8709 void *data,
8710 GFreeFunc free_func)
8711{
8712 FRBatchAction *a_desc;
8713
8714 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8715
8716 a_desc = g_new0 (FRBatchAction, 1)((FRBatchAction *) g_malloc0_n ((1), sizeof (FRBatchAction)));
8717 a_desc->type = action;
8718 a_desc->data = data;
8719 a_desc->free_func = free_func;
8720
8721 window->priv->batch_action_list = g_list_append (window->priv->batch_action_list, a_desc);
8722}
8723
8724static void
8725fr_window_exec_current_batch_action (FrWindow *window)
8726{
8727 FRBatchAction *action;
8728
8729 if (window->priv->batch_action == NULL((void*)0)) {
8730 window->priv->batch_mode = FALSE(0);
8731 return;
8732 }
8733 action = (FRBatchAction *) window->priv->batch_action->data;
8734 fr_window_exec_batch_action (window, action);
8735}
8736
8737static void
8738fr_window_exec_next_batch_action (FrWindow *window)
8739{
8740 if (window->priv->batch_action != NULL((void*)0))
8741 window->priv->batch_action = g_list_next (window->priv->batch_action)((window->priv->batch_action) ? (((GList *)(window->
priv->batch_action))->next) : ((void*)0))
;
8742 else
8743 window->priv->batch_action = window->priv->batch_action_list;
8744 fr_window_exec_current_batch_action (window);
8745}
8746
8747void
8748fr_window_start_batch (FrWindow *window)
8749{
8750 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8751
8752 if (window->priv->batch_mode)
8753 return;
8754
8755 if (window->priv->batch_action_list == NULL((void*)0))
8756 return;
8757
8758 if (window->priv->progress_dialog != NULL((void*)0))
8759 gtk_window_set_title (GTK_WINDOW (window->priv->progress_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_window_get_type
()))))))
,
8760 window->priv->batch_title);
8761
8762 window->priv->batch_mode = TRUE(!(0));
8763 window->priv->batch_action = window->priv->batch_action_list;
8764 window->archive->can_create_compressed_file = window->priv->batch_adding_one_file;
8765
8766 fr_window_exec_current_batch_action (window);
8767}
8768
8769void
8770fr_window_stop_batch (FrWindow *window)
8771{
8772 if (! window->priv->non_interactive)
8773 return;
8774
8775 window->priv->extract_interact_use_default_dir = FALSE(0);
8776 window->archive->can_create_compressed_file = FALSE(0);
8777
8778 if (window->priv->batch_mode) {
8779 if (! window->priv->showing_error_dialog) {
8780 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
8781 return;
8782 }
8783 }
8784 else {
8785 gtk_window_present (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
8786 fr_window_archive_close (window);
8787 }
8788
8789 window->priv->batch_mode = FALSE(0);
8790}
8791
8792void
8793fr_window_resume_batch (FrWindow *window)
8794{
8795 fr_window_exec_current_batch_action (window);
8796}
8797
8798gboolean
8799fr_window_is_batch_mode (FrWindow *window)
8800{
8801 return window->priv->batch_mode;
8802}
8803
8804void
8805fr_window_new_batch (FrWindow *window,
8806 const char *title)
8807{
8808 fr_window_free_batch_data (window);
8809 window->priv->non_interactive = TRUE(!(0));
8810 g_free (window->priv->batch_title);
8811 window->priv->batch_title = g_strdup (title)g_strdup_inline (title);
8812}
8813
8814void
8815fr_window_set_batch__extract_here (FrWindow *window,
8816 const char *filename)
8817{
8818 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8819 g_return_if_fail (filename != NULL)do { if ((filename != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "filename != NULL"
); return; } } while (0)
;
8820
8821 fr_window_append_batch_action (window,
8822 FR_BATCH_ACTION_LOAD,
8823 g_strdup (filename)g_strdup_inline (filename),
8824 (GFreeFunc) g_free);
8825 fr_window_append_batch_action (window,
8826 FR_BATCH_ACTION_EXTRACT_HERE,
8827 extract_to_data_new (NULL((void*)0)),
8828 (GFreeFunc) extract_data_free);
8829 fr_window_append_batch_action (window,
8830 FR_BATCH_ACTION_CLOSE,
8831 NULL((void*)0),
8832 NULL((void*)0));
8833}
8834
8835void
8836fr_window_set_batch__extract (FrWindow *window,
8837 const char *filename,
8838 const char *dest_dir)
8839{
8840 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8841 g_return_if_fail (filename != NULL)do { if ((filename != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "filename != NULL"
); return; } } while (0)
;
8842
8843 fr_window_append_batch_action (window,
8844 FR_BATCH_ACTION_LOAD,
8845 g_strdup (filename)g_strdup_inline (filename),
8846 (GFreeFunc) g_free);
8847 if (dest_dir != NULL((void*)0))
8848 fr_window_append_batch_action (window,
8849 FR_BATCH_ACTION_EXTRACT_INTERACT,
8850 extract_to_data_new (dest_dir),
8851 (GFreeFunc) extract_data_free);
8852 else
8853 fr_window_append_batch_action (window,
8854 FR_BATCH_ACTION_EXTRACT_INTERACT,
8855 NULL((void*)0),
8856 NULL((void*)0));
8857 fr_window_append_batch_action (window,
8858 FR_BATCH_ACTION_CLOSE,
8859 NULL((void*)0),
8860 NULL((void*)0));
8861}
8862
8863void
8864fr_window_set_batch__add (FrWindow *window,
8865 const char *archive,
8866 GList *file_list)
8867{
8868 window->priv->batch_adding_one_file = (file_list->next == NULL((void*)0)) && (uri_is_file (file_list->data));
8869
8870 if (archive != NULL((void*)0))
8871 fr_window_append_batch_action (window,
8872 FR_BATCH_ACTION_LOAD,
8873 g_strdup (archive)g_strdup_inline (archive),
8874 (GFreeFunc) g_free);
8875 else
8876 fr_window_append_batch_action (window,
8877 FR_BATCH_ACTION_OPEN,
8878 file_list,
8879 NULL((void*)0));
8880 fr_window_append_batch_action (window,
8881 FR_BATCH_ACTION_ADD,
8882 file_list,
8883 NULL((void*)0));
8884 fr_window_append_batch_action (window,
8885 FR_BATCH_ACTION_CLOSE,
8886 NULL((void*)0),
8887 NULL((void*)0));
8888}
8889
8890void
8891fr_window_set_close_dialog (FrWindow *window,
8892 gboolean state)
8893{
8894 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8895
8896 window->priv->close_dialog = state;
8897}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-281643.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-281643.html new file mode 100644 index 0000000..0e6a495 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-281643.html @@ -0,0 +1,1776 @@ + + + +fr-process.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/fr-process.c
Warning:line 1006, column 13
Value stored to 'ret' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name fr-process.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c fr-process.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2001, 2003, 2008 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <config.h>
24#include <errno(*__errno_location ()).h>
25#include <fcntl.h>
26#include <stdio.h>
27#include <signal.h>
28#include <stdlib.h>
29#include <string.h>
30#include <sys/types.h>
31#include <sys/wait.h>
32#include <unistd.h>
33#include <glib.h>
34#include "fr-proc-error.h"
35#include "fr-process.h"
36#include "fr-marshal.h"
37#include "glib-utils.h"
38
39#define REFRESH_RATE20 20
40#define BUFFER_SIZE16384 16384
41
42enum {
43 START,
44 DONE,
45 STICKY_ONLY,
46 LAST_SIGNAL
47};
48
49static GObjectClass *parent_class;
50static guint fr_process_signals[LAST_SIGNAL] = { 0 };
51
52static void fr_process_class_init (FrProcessClass *class);
53static void fr_process_init (FrProcess *process);
54static void fr_process_finalize (GObject *object);
55
56typedef struct {
57 GList *args; /* command to execute */
58 char *dir; /* working directory */
59 guint sticky : 1; /* whether the command must be
60 * executed even if a previous
61 * command has failed. */
62 guint ignore_error : 1; /* whether to continue to execute
63 * other commands if this command
64 * fails. */
65 ContinueFunc continue_func;
66 gpointer continue_data;
67 ProcFunc begin_func;
68 gpointer begin_data;
69 ProcFunc end_func;
70 gpointer end_data;
71} FrCommandInfo;
72
73static FrCommandInfo *
74fr_command_info_new (void)
75{
76 FrCommandInfo *info;
77
78 info = g_new0 (FrCommandInfo, 1)((FrCommandInfo *) g_malloc0_n ((1), sizeof (FrCommandInfo)));
79 info->args = NULL((void*)0);
80 info->dir = NULL((void*)0);
81 info->sticky = FALSE(0);
82 info->ignore_error = FALSE(0);
83
84 return info;
85}
86
87static void
88fr_command_info_free (gpointer data)
89{
90 FrCommandInfo *info = data;
91
92 if (info == NULL((void*)0))
93 return;
94
95 g_list_free_full (info->args, g_free);
96 g_free (info->dir);
97 g_clear_pointer (&info, g_free)do { _Static_assert (sizeof *(&info) == sizeof (gpointer)
, "Expression evaluates to false"); __typeof__ ((&info)) _pp
= (&info); __typeof__ (*(&info)) _ptr = *_pp; *_pp =
((void*)0); if (_ptr) (g_free) (_ptr); } while (0)
;
98}
99
100static void
101fr_channel_data_init (FrChannelData *channel)
102{
103 channel->source = NULL((void*)0);
104 channel->raw = NULL((void*)0);
105 channel->status = G_IO_STATUS_NORMAL;
106 channel->error = NULL((void*)0);
107}
108
109static void
110fr_channel_data_close_source (FrChannelData *channel)
111{
112 if (channel->source != NULL((void*)0)) {
113 g_io_channel_shutdown (channel->source, FALSE(0), NULL((void*)0));
114 g_io_channel_unref (channel->source);
115 channel->source = NULL((void*)0);
116 }
117}
118
119static GIOStatus
120fr_channel_data_read (FrChannelData *channel)
121{
122 char *line;
123 gsize length;
124 gsize terminator_pos;
125
126 channel->status = G_IO_STATUS_NORMAL;
127 g_clear_error (&channel->error);
128
129 while ((channel->status = g_io_channel_read_line (channel->source,
130 &line,
131 &length,
132 &terminator_pos,
133 &channel->error)) == G_IO_STATUS_NORMAL)
134 {
135 line[terminator_pos] = 0;
136 channel->raw = g_list_prepend (channel->raw, line);
137 if (channel->line_func != NULL((void*)0))
138 (*channel->line_func) (line, channel->line_data);
139 }
140
141 return channel->status;
142}
143
144static GIOStatus
145fr_channel_data_flush (FrChannelData *channel)
146{
147 GIOStatus status;
148
149 while (((status = fr_channel_data_read (channel)) != G_IO_STATUS_ERROR) && (status != G_IO_STATUS_EOF))
150 /* void */;
151 fr_channel_data_close_source (channel);
152
153 return status;
154}
155
156static void
157fr_channel_data_reset (FrChannelData *channel)
158{
159 fr_channel_data_close_source (channel);
160
161 if (channel->raw != NULL((void*)0)) {
162 g_list_free_full (channel->raw, g_free);
163 channel->raw = NULL((void*)0);
164 }
165}
166
167static void
168fr_channel_data_free (FrChannelData *channel)
169{
170 fr_channel_data_reset (channel);
171}
172
173static void
174fr_channel_data_set_fd (FrChannelData *channel,
175 int fd,
176 const char *charset)
177{
178 fr_channel_data_reset (channel);
179
180 channel->source = g_io_channel_unix_new (fd);
181 g_io_channel_set_flags (channel->source, G_IO_FLAG_NONBLOCK, NULL((void*)0));
182 g_io_channel_set_buffer_size (channel->source, BUFFER_SIZE16384);
183 if (charset != NULL((void*)0))
184 g_io_channel_set_encoding (channel->source, charset, NULL((void*)0));
185}
186
187const char *try_charsets[] = { "UTF-8", "ISO-8859-1", "WINDOW-1252" };
188int n_charsets = G_N_ELEMENTS (try_charsets)(sizeof (try_charsets) / sizeof ((try_charsets)[0]));
189
190struct _FrProcessPrivate {
191 GPtrArray *comm; /* FrCommandInfo elements. */
192 gint n_comm; /* total number of commands */
193 gint current_comm; /* currenlty editing command. */
194
195 GPid command_pid;
196 guint check_timeout;
197
198 FrProcError first_error;
199
200 gboolean running;
201 gboolean stopping;
202 gboolean suspend;
203 gint current_command;
204 gint error_command; /* command that coused an error. */
205
206 gboolean use_standard_locale;
207 gboolean sticky_only; /* whether to execute only sticky
208 * commands. */
209 int current_charset;
210};
211
212GType
213fr_process_get_type (void)
214{
215 static GType type = 0;
216
217 if (! type) {
218 GTypeInfo type_info = {
219 sizeof (FrProcessClass),
220 NULL((void*)0),
221 NULL((void*)0),
222 (GClassInitFunc) fr_process_class_init,
223 NULL((void*)0),
224 NULL((void*)0),
225 sizeof (FrProcess),
226 0,
227 (GInstanceInitFunc) fr_process_init,
228 NULL((void*)0)
229 };
230
231 type = g_type_register_static (G_TYPE_OBJECT((GType) ((20) << (2))),
232 "FRProcess",
233 &type_info,
234 0);
235 }
236
237 return type;
238}
239
240static void
241fr_process_class_init (FrProcessClass *class)
242{
243 GObjectClass *gobject_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
244
245 parent_class = g_type_class_peek_parent (class);
246
247 fr_process_signals[START] =
248 g_signal_new ("start",
249 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
250 G_SIGNAL_RUN_LAST,
251 G_STRUCT_OFFSET (FrProcessClass, start)((glong) __builtin_offsetof(FrProcessClass, start)),
252 NULL((void*)0), NULL((void*)0),
253 fr_marshal_VOID__VOIDg_cclosure_marshal_VOID__VOID,
254 G_TYPE_NONE((GType) ((1) << (2))), 0);
255 fr_process_signals[DONE] =
256 g_signal_new ("done",
257 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
258 G_SIGNAL_RUN_LAST,
259 G_STRUCT_OFFSET (FrProcessClass, done)((glong) __builtin_offsetof(FrProcessClass, done)),
260 NULL((void*)0), NULL((void*)0),
261 fr_marshal_VOID__BOXEDg_cclosure_marshal_VOID__BOXED,
262 G_TYPE_NONE((GType) ((1) << (2))), 1,
263 FR_TYPE_PROC_ERROR(fr_proc_error_get_type ()));
264 fr_process_signals[STICKY_ONLY] =
265 g_signal_new ("sticky_only",
266 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
267 G_SIGNAL_RUN_LAST,
268 G_STRUCT_OFFSET (FrProcessClass, sticky_only)((glong) __builtin_offsetof(FrProcessClass, sticky_only)),
269 NULL((void*)0), NULL((void*)0),
270 fr_marshal_VOID__VOIDg_cclosure_marshal_VOID__VOID,
271 G_TYPE_NONE((GType) ((1) << (2))), 0);
272
273 gobject_class->finalize = fr_process_finalize;
274
275 class->start = NULL((void*)0);
276 class->done = NULL((void*)0);
277}
278
279static void
280fr_process_init (FrProcess *process)
281{
282 process->priv = g_new0 (FrProcessPrivate, 1)((FrProcessPrivate *) g_malloc0_n ((1), sizeof (FrProcessPrivate
)))
;
283
284 process->term_on_stop = TRUE(!(0));
285
286 process->priv->comm = g_ptr_array_new_with_free_func (fr_command_info_free);
287 process->priv->n_comm = -1;
288 process->priv->current_comm = -1;
289
290 process->priv->command_pid = 0;
291 fr_channel_data_init (&process->out);
292 fr_channel_data_init (&process->err);
293
294 process->error.gerror = NULL((void*)0);
295 process->priv->first_error.gerror = NULL((void*)0);
296
297 process->priv->check_timeout = 0;
298 process->priv->running = FALSE(0);
299 process->priv->stopping = FALSE(0);
300 process->restart = FALSE(0);
301
302 process->priv->current_charset = -1;
303
304 process->priv->use_standard_locale = FALSE(0);
305}
306
307FrProcess *
308fr_process_new (void)
309{
310 return FR_PROCESS (g_object_new (FR_TYPE_PROCESS, NULL))((((FrProcess*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((fr_process_get_type ()), ((void*)0)))), (
(fr_process_get_type ()))))))
;
311}
312
313static void fr_process_stop_priv (FrProcess *process, gboolean emit_signal);
314static int fr_switch_process_state (FrProcess *process);
315
316static void
317fr_process_finalize (GObject *object)
318{
319 FrProcess *process;
320
321 g_return_if_fail (object != NULL)do { if ((object != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "object != NULL")
; return; } } while (0)
;
322 g_return_if_fail (FR_IS_PROCESS (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((fr_process_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "FR_IS_PROCESS (object)"); return; } } while (
0)
;
323
324 process = FR_PROCESS (object)((((FrProcess*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((fr_process_get_type ()))))))
;
325
326 fr_process_stop_priv (process, FALSE(0));
327
328 g_ptr_array_free (process->priv->comm, TRUE(!(0)));
329
330 fr_channel_data_free (&process->out);
331 fr_channel_data_free (&process->err);
332
333 g_clear_error (&process->error.gerror);
334 g_clear_error (&process->priv->first_error.gerror);
335
336 g_free (process->priv);
337
338 /* Chain up */
339
340 if (G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->finalize)
341 G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->finalize (object);
342}
343
344void
345fr_process_begin_command (FrProcess *process,
346 const char *arg)
347{
348 FrCommandInfo *info;
349
350 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
351
352 info = fr_command_info_new ();
353 info->args = g_list_prepend (NULL((void*)0), g_strdup (arg)g_strdup_inline (arg));
354
355 g_ptr_array_add (process->priv->comm, info);
356
357 process->priv->n_comm++;
358 process->priv->current_comm = process->priv->n_comm;
359}
360
361void
362fr_process_begin_command_at (FrProcess *process,
363 const char *arg,
364 int index)
365{
366 FrCommandInfo *info, *old_c_info;
367
368 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
369 g_return_if_fail (index >= 0 && index <= process->priv->n_comm)do { if ((index >= 0 && index <= process->priv
->n_comm)) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "index >= 0 && index <= process->priv->n_comm"
); return; } } while (0)
;
370
371 process->priv->current_comm = index;
372
373 old_c_info = g_ptr_array_index (process->priv->comm, index)((process->priv->comm)->pdata)[index];
374 fr_command_info_free (old_c_info);
375
376 info = fr_command_info_new ();
377 info->args = g_list_prepend (NULL((void*)0), g_strdup (arg)g_strdup_inline (arg));
378
379 g_ptr_array_index (process->priv->comm, index)((process->priv->comm)->pdata)[index] = info;
380}
381
382void
383fr_process_set_working_dir (FrProcess *process,
384 const char *dir)
385{
386 FrCommandInfo *info;
387
388 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
389 g_return_if_fail (process->priv->current_comm >= 0)do { if ((process->priv->current_comm >= 0)) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "process->priv->current_comm >= 0"); return; } }
while (0)
;
390
391 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
392 if (info->dir != NULL((void*)0))
393 g_free (info->dir);
394 info->dir = g_strdup (dir)g_strdup_inline (dir);
395}
396
397void
398fr_process_set_sticky (FrProcess *process,
399 gboolean sticky)
400{
401 FrCommandInfo *info;
402
403 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
404 g_return_if_fail (process->priv->current_comm >= 0)do { if ((process->priv->current_comm >= 0)) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "process->priv->current_comm >= 0"); return; } }
while (0)
;
405
406 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
407 info->sticky = (sticky != FALSE(0));
408}
409
410void
411fr_process_set_ignore_error (FrProcess *process,
412 gboolean ignore_error)
413{
414 FrCommandInfo *info;
415
416 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
417 g_return_if_fail (process->priv->current_comm >= 0)do { if ((process->priv->current_comm >= 0)) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "process->priv->current_comm >= 0"); return; } }
while (0)
;
418
419 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
420 info->ignore_error = (ignore_error != FALSE(0));
421}
422
423void
424fr_process_add_arg (FrProcess *process,
425 const char *arg)
426{
427 FrCommandInfo *info;
428
429 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
430 g_return_if_fail (process->priv->current_comm >= 0)do { if ((process->priv->current_comm >= 0)) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "process->priv->current_comm >= 0"); return; } }
while (0)
;
431
432 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
433 info->args = g_list_prepend (info->args, g_strdup (arg)g_strdup_inline (arg));
434}
435
436void
437fr_process_add_arg_concat (FrProcess *process,
438 const char *arg1,
439 ...)
440{
441 GString *arg;
442 va_list args;
443 char *s;
444
445 arg = g_string_new (arg1);
446
447 va_start (args, arg1)__builtin_va_start(args, arg1);
448 while ((s = va_arg (args, char*)__builtin_va_arg(args, char*)) != NULL((void*)0))
449 g_string_append (arg, s)(__builtin_constant_p (s) ? __extension__ ({ const char * const
__val = (s); g_string_append_len_inline (arg, __val, (__val !=
((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize
) -1); }) : g_string_append_len_inline (arg, s, (gssize) -1))
;
450 va_end (args)__builtin_va_end(args);
451
452 fr_process_add_arg (process, arg->str);
453 g_string_free (arg, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(arg), ((!(0)))) : g_string_free_and_steal (arg)) : (g_string_free
) ((arg), ((!(0)))))
;
454}
455
456void
457fr_process_add_arg_printf (FrProcess *fr_proc,
458 const char *format,
459 ...)
460{
461 va_list args;
462 char *arg;
463
464 va_start (args, format)__builtin_va_start(args, format);
465 arg = g_strdup_vprintf (format, args);
466 va_end (args)__builtin_va_end(args);
467
468 fr_process_add_arg (fr_proc, arg);
469
470 g_free (arg);
471}
472
473void
474fr_process_set_arg_at (FrProcess *process,
475 int n_comm,
476 int n_arg,
477 const char *arg_value)
478{
479 FrCommandInfo *info;
480 GList *arg;
481
482 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
483
484 info = g_ptr_array_index (process->priv->comm, n_comm)((process->priv->comm)->pdata)[n_comm];
485 arg = g_list_nth (info->args, n_arg);
486 g_return_if_fail (arg != NULL)do { if ((arg != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "arg != NULL"); return
; } } while (0)
;
487
488 g_free (arg->data);
489 arg->data = g_strdup (arg_value)g_strdup_inline (arg_value);
490}
491
492void
493fr_process_set_begin_func (FrProcess *process,
494 ProcFunc func,
495 gpointer func_data)
496{
497 FrCommandInfo *info;
498
499 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
500
501 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
502 info->begin_func = func;
503 info->begin_data = func_data;
504}
505
506void
507fr_process_set_end_func (FrProcess *process,
508 ProcFunc func,
509 gpointer func_data)
510{
511 FrCommandInfo *info;
512
513 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
514
515 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
516 info->end_func = func;
517 info->end_data = func_data;
518}
519
520void
521fr_process_set_continue_func (FrProcess *process,
522 ContinueFunc func,
523 gpointer func_data)
524{
525 FrCommandInfo *info;
526
527 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
528
529 if (process->priv->current_comm < 0)
530 return;
531
532 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
533 info->continue_func = func;
534 info->continue_data = func_data;
535}
536
537void
538fr_process_end_command (FrProcess *process)
539{
540 FrCommandInfo *info;
541
542 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
543
544 info = g_ptr_array_index (process->priv->comm, process->priv->current_comm)((process->priv->comm)->pdata)[process->priv->
current_comm]
;
545 info->args = g_list_reverse (info->args);
546}
547
548void
549fr_process_clear (FrProcess *process)
550{
551 gint i;
552
553 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
554
555 for (i = 0; i <= process->priv->n_comm; i++)
556 g_ptr_array_remove_index_fast (process->priv->comm, 0);
557
558 process->priv->n_comm = -1;
559 process->priv->current_comm = -1;
560}
561
562void
563fr_process_set_out_line_func (FrProcess *process,
564 LineFunc func,
565 gpointer data)
566{
567 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
568
569 process->out.line_func = func;
570 process->out.line_data = data;
571}
572
573void
574fr_process_set_err_line_func (FrProcess *process,
575 LineFunc func,
576 gpointer data)
577{
578 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
579
580 process->err.line_func = func;
581 process->err.line_data = data;
582}
583
584static gboolean check_child (gpointer data);
585
586static void
587child_setup (gpointer user_data)
588{
589 FrProcess *process = user_data;
590
591 if (process->priv->use_standard_locale) {
592 putenv ("LC_MESSAGES=C");
593 putenv ("LC_TIME=C");
594 putenv ("LC_NUMERIC=C");
595 }
596
597 /* detach from the tty */
598
599 setsid ();
600
601 /* create a process group to kill all the child processes when
602 * canceling the operation. */
603
604 setpgid (0, 0);
605}
606
607static const char *
608fr_process_get_charset (FrProcess *process)
609{
610 const char *charset = NULL((void*)0);
611
612 if (process->priv->current_charset >= 0)
613 charset = try_charsets[process->priv->current_charset];
614 else if (g_get_charset (&charset))
615 charset = NULL((void*)0);
616
617 return charset;
618}
619
620static void
621start_current_command (FrProcess *process)
622{
623 FrCommandInfo *info;
624 GList *scan;
625 char **argv;
626 int out_fd, err_fd;
627 int i = 0;
628 GString *commandline = g_string_new ("");
629 gboolean fixname = FALSE(0);
630
631 debug (DEBUG_INFO"fr-process.c", 631, __FUNCTION__, "%d/%d) ", process->priv->current_command, process->priv->n_comm);
632
633 info = g_ptr_array_index (process->priv->comm, process->priv->current_command)((process->priv->comm)->pdata)[process->priv->
current_command]
;
634
635 argv = g_new (char *, g_list_length (info->args) + 1)((char * *) g_malloc_n ((g_list_length (info->args) + 1), sizeof
(char *)))
;
636
637 for (scan = info->args; scan; scan = scan->next) {
638 argv[i++] = scan->data;
639
640 if (g_str_has_prefix (commandline->str, "mv")(__builtin_constant_p ("mv")? __extension__ ({ const char * const
__str = (commandline->str); const char * const __prefix =
("mv"); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (commandline->str, "mv"
) )
) {
641
642 if ((i == 3) && (!g_file_test (argv[2], G_FILE_TEST_EXISTS)) && (!fixname)) {
643 char rarfile[strlen (argv[2]) + 7];
644
645 g_strlcpy (rarfile, argv[2], sizeof (rarfile));
646 rarfile[strlen (rarfile) - 3] = 0;
647 g_strlcat (rarfile, "part1.rar", sizeof (rarfile));
648
649 if (g_str_has_suffix (argv[2], ".7z")(__builtin_constant_p (".7z")? __extension__ ({ const char * const
__str = (argv[2]); const char * const __suffix = (".7z"); gboolean
__result = (0); if (__str == ((void*)0) || __suffix == ((void
*)0)) __result = (g_str_has_suffix) (__str, __suffix); else {
const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __suffix_len = strlen (((__suffix) + !(__suffix))); if
(__str_len >= __suffix_len) __result = memcmp (__str + __str_len
- __suffix_len, ((__suffix) + !(__suffix)), __suffix_len) ==
0; } __result; }) : (g_str_has_suffix) (argv[2], ".7z") )
) {
650 g_string_append (commandline, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (commandline, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, " ", (gssize) -1))
;
651
652 gchar *tempstr = g_shell_quote (argv[2]);
653 g_string_append (commandline, tempstr)(__builtin_constant_p (tempstr) ? __extension__ ({ const char
* const __val = (tempstr); g_string_append_len_inline (commandline
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, tempstr, (gssize) -1))
;
654 g_free (tempstr);
655
656 g_string_append (commandline, ".*")(__builtin_constant_p (".*") ? __extension__ ({ const char * const
__val = (".*"); g_string_append_len_inline (commandline, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, ".*", (gssize) -1))
;
657 fixname = TRUE(!(0));
658 }
659 else if (g_str_has_suffix (argv[2], ".rar")(__builtin_constant_p (".rar")? __extension__ ({ const char *
const __str = (argv[2]); const char * const __suffix = (".rar"
); gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (argv[2], ".rar")
)
) {
660 rarfile[strlen(rarfile) - 5] = 0;
661 g_string_append (commandline, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (commandline, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, " ", (gssize) -1))
;
662
663 gchar *tempstr = g_shell_quote (rarfile);
664 g_string_append (commandline, tempstr)(__builtin_constant_p (tempstr) ? __extension__ ({ const char
* const __val = (tempstr); g_string_append_len_inline (commandline
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, tempstr, (gssize) -1))
;
665 g_free (tempstr);
666
667 g_string_append (commandline, "*.rar")(__builtin_constant_p ("*.rar") ? __extension__ ({ const char
* const __val = ("*.rar"); g_string_append_len_inline (commandline
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, "*.rar", (gssize) -1))
;
668 fixname = TRUE(!(0));
669 }
670 }
671 else if ((i == 4) && (fixname)) {
672 g_string_append (commandline, " \"$(dirname ")(__builtin_constant_p (" \"$(dirname ") ? __extension__ ({ const
char * const __val = (" \"$(dirname "); g_string_append_len_inline
(commandline, __val, (__val != ((void*)0)) ? (gssize) strlen
(((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(commandline, " \"$(dirname ", (gssize) -1))
;
673
674 gchar *tempstr = g_shell_quote (argv[3]);
675 g_string_append (commandline, tempstr)(__builtin_constant_p (tempstr) ? __extension__ ({ const char
* const __val = (tempstr); g_string_append_len_inline (commandline
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, tempstr, (gssize) -1))
;
676 g_free (tempstr);
677
678 g_string_append (commandline, ")\"")(__builtin_constant_p (")\"") ? __extension__ ({ const char *
const __val = (")\""); g_string_append_len_inline (commandline
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, ")\"", (gssize) -1))
;
679 }
680 else {
681 g_string_append (commandline, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (commandline, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, " ", (gssize) -1))
;
682 g_string_append (commandline, argv[(i - 1)])(__builtin_constant_p (argv[(i - 1)]) ? __extension__ ({ const
char * const __val = (argv[(i - 1)]); g_string_append_len_inline
(commandline, __val, (__val != ((void*)0)) ? (gssize) strlen
(((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(commandline, argv[(i - 1)], (gssize) -1))
;
683 }
684 }
685 else if (g_str_has_prefix (argv[0], "mv")(__builtin_constant_p ("mv")? __extension__ ({ const char * const
__str = (argv[0]); const char * const __prefix = ("mv"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)0)) __result = (g_str_has_prefix) (__str, __prefix); else {
const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (argv[0], "mv") )
) {
686 g_string_append (commandline, "mv")(__builtin_constant_p ("mv") ? __extension__ ({ const char * const
__val = ("mv"); g_string_append_len_inline (commandline, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (commandline
, "mv", (gssize) -1))
;
687 }
688 }
689
690 argv[i] = NULL((void*)0);
691
692#ifdef MATE_ENABLE_DEBUG
693 {
694 int j;
695
696 if (process->priv->use_standard_locale) {
697 g_print ("\tLC_MESSAGES=C\n");
698 g_print ("\tLC_TIME=C\n");
699 g_print ("\tLC_NUMERIC=C\n");
700 }
701
702 if (info->dir != NULL((void*)0))
703 g_print ("\tcd %s\n", info->dir);
704
705 g_print ("\t");
706 for (j = 0; j < i; j++)
707 g_print ("%s ", argv[j]);
708 g_print ("\n");
709 }
710#endif
711
712 if ((fixname) && (system (commandline->str) != 0))
713 g_warning ("The files could not be move: %s\n", commandline->str);
714
715 if (info->begin_func != NULL((void*)0))
716 (*info->begin_func) (info->begin_data);
717
718 if (! g_spawn_async_with_pipes (info->dir,
719 argv,
720 NULL((void*)0),
721 (G_SPAWN_LEAVE_DESCRIPTORS_OPEN
722 | G_SPAWN_SEARCH_PATH
723 | G_SPAWN_DO_NOT_REAP_CHILD),
724 child_setup,
725 process,
726 &process->priv->command_pid,
727 NULL((void*)0),
728 &out_fd,
729 &err_fd,
730 &process->error.gerror))
731 {
732 process->error.type = FR_PROC_ERROR_SPAWN;
733 g_signal_emit (G_OBJECT (process)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((process)), (((GType) ((20) << (2))))))))
,
734 fr_process_signals[DONE],
735 0,
736 &process->error);
737 g_string_free (commandline, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(commandline), ((!(0)))) : g_string_free_and_steal (commandline
)) : (g_string_free) ((commandline), ((!(0)))))
;
738 g_free (argv);
739 return;
740 }
741
742 g_string_free (commandline, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(commandline), ((!(0)))) : g_string_free_and_steal (commandline
)) : (g_string_free) ((commandline), ((!(0)))))
;
743 g_free (argv);
744
745 fr_channel_data_set_fd (&process->out, out_fd, fr_process_get_charset (process));
746 fr_channel_data_set_fd (&process->err, err_fd, fr_process_get_charset (process));
747
748 process->priv->check_timeout = g_timeout_add (REFRESH_RATE20,
749 check_child,
750 process);
751}
752
753static gboolean
754command_is_sticky (FrProcess *process,
755 int i)
756{
757 FrCommandInfo *info;
758
759 info = g_ptr_array_index (process->priv->comm, i)((process->priv->comm)->pdata)[i];
760 return info->sticky;
761}
762
763static void
764allow_sticky_processes_only (FrProcess *process,
765 gboolean emit_signal)
766{
767 if (! process->priv->sticky_only) {
768 /* Remember the first error. */
769 process->priv->error_command = process->priv->current_command;
770 process->priv->first_error.type = process->error.type;
771 process->priv->first_error.status = process->error.status;
772 g_clear_error (&process->priv->first_error.gerror);
773 if (process->error.gerror != NULL((void*)0))
774 process->priv->first_error.gerror = g_error_copy (process->error.gerror);
775 }
776
777 process->priv->sticky_only = TRUE(!(0));
778 if (emit_signal)
779 g_signal_emit (G_OBJECT (process)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((process)), (((GType) ((20) << (2))))))))
,
780 fr_process_signals[STICKY_ONLY],
781 0);
782}
783
784static void
785fr_process_set_error (FrProcess *process,
786 FrProcErrorType type,
787 int status,
788 GError *gerror)
789{
790 process->error.type = type;
791 process->error.status = status;
792 if (gerror != process->error.gerror) {
793 g_clear_error (&process->error.gerror);
794 if (gerror != NULL((void*)0))
795 process->error.gerror = g_error_copy (gerror);
796 }
797}
798
799static gint
800check_child (gpointer data)
801{
802 FrProcess *process = data;
803 FrCommandInfo *info;
804 pid_t pid;
805 int status;
806 gboolean continue_process;
807 gboolean channel_error = FALSE(0);
808
809 info = g_ptr_array_index (process->priv->comm, process->priv->current_command)((process->priv->comm)->pdata)[process->priv->
current_command]
;
810
811 /* Remove check. */
812
813 g_source_remove (process->priv->check_timeout);
814 process->priv->check_timeout = 0;
815
816 if (fr_channel_data_read (&process->out) == G_IO_STATUS_ERROR) {
817 fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->out.error);
818 channel_error = TRUE(!(0));
819 }
820 else if (fr_channel_data_read (&process->err) == G_IO_STATUS_ERROR) {
821 fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->err.error);
822 channel_error = TRUE(!(0));
823 }
824 else {
825 pid = waitpid (process->priv->command_pid, &status, WNOHANG1);
826 if (pid != process->priv->command_pid) {
827 /* Add check again. */
828 process->priv->check_timeout = g_timeout_add (REFRESH_RATE20,
829 check_child,
830 process);
831 return FALSE(0);
832 }
833 }
834
835 if (info->ignore_error) {
836 process->error.type = FR_PROC_ERROR_NONE;
837 debug (DEBUG_INFO"fr-process.c", 837, __FUNCTION__, "[ignore error]\n");
838 }
839 else if (! channel_error && (process->error.type != FR_PROC_ERROR_STOPPED)) {
840 if (WIFEXITED (status)(((status) & 0x7f) == 0)) {
841 if (WEXITSTATUS (status)(((status) & 0xff00) >> 8) == 0)
842 process->error.type = FR_PROC_ERROR_NONE;
843 else if (WEXITSTATUS (status)(((status) & 0xff00) >> 8) == 255)
844 process->error.type = FR_PROC_ERROR_COMMAND_NOT_FOUND;
845 else
846 process->error.type = FR_PROC_ERROR_COMMAND_ERROR;
847 process->error.status = WEXITSTATUS (status)(((status) & 0xff00) >> 8);
848 }
849 else {
850 process->error.type = FR_PROC_ERROR_EXITED_ABNORMALLY;
851 process->error.status = 255;
852 }
853 }
854
855 process->priv->command_pid = 0;
856
857 if (fr_channel_data_flush (&process->out) == G_IO_STATUS_ERROR) {
858 fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->out.error);
859 channel_error = TRUE(!(0));
860 }
861 else if (fr_channel_data_flush (&process->err) == G_IO_STATUS_ERROR) {
862 fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->err.error);
863 channel_error = TRUE(!(0));
864 }
865
866 if (info->end_func != NULL((void*)0))
867 (*info->end_func) (info->end_data);
868
869 /**/
870
871 if (channel_error
872 && (process->error.type == FR_PROC_ERROR_IO_CHANNEL)
873 && g_error_matches (process->error.gerror, G_CONVERT_ERRORg_convert_error_quark(), G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
874 {
875 if (process->priv->current_charset < n_charsets - 1) {
876 /* try with another charset */
877 process->priv->current_charset++;
878 process->priv->running = FALSE(0);
879 process->restart = TRUE(!(0));
880 fr_process_start (process);
881 return FALSE(0);
882 }
883 /*fr_process_set_error (process, FR_PROC_ERROR_NONE, 0, NULL);*/
884 fr_process_set_error (process, FR_PROC_ERROR_BAD_CHARSET, 0, process->error.gerror);
885 }
886
887 /* Check whether to continue or stop the process */
888
889 continue_process = TRUE(!(0));
890 if (info->continue_func != NULL((void*)0))
891 continue_process = (*info->continue_func) (info->continue_data);
892
893 /* Execute next command. */
894 if (continue_process) {
895 if (process->error.type != FR_PROC_ERROR_NONE) {
896 allow_sticky_processes_only (process, TRUE(!(0)));
897#ifdef MATE_ENABLE_DEBUG
898 {
899 GList *scan;
900
901 g_print ("** ERROR **\n");
902 for (scan = process->err.raw; scan; scan = scan->next)
903 g_print ("%s\n", (char *)scan->data);
904 }
905#endif
906 }
907
908 if (process->priv->sticky_only) {
909 do {
910 process->priv->current_command++;
911 } while ((process->priv->current_command <= process->priv->n_comm)
912 && ! command_is_sticky (process, process->priv->current_command));
913 }
914 else
915 process->priv->current_command++;
916
917 if (process->priv->current_command <= process->priv->n_comm) {
918 start_current_command (process);
919 return FALSE(0);
920 }
921 }
922
923 /* Done */
924
925 process->priv->current_command = -1;
926 process->priv->use_standard_locale = FALSE(0);
927
928 if (process->out.raw != NULL((void*)0))
929 process->out.raw = g_list_reverse (process->out.raw);
930 if (process->err.raw != NULL((void*)0))
931 process->err.raw = g_list_reverse (process->err.raw);
932
933 process->priv->running = FALSE(0);
934 process->priv->stopping = FALSE(0);
935
936 if (process->priv->sticky_only) {
937 /* Restore the first error. */
938 fr_process_set_error (process,
939 process->priv->first_error.type,
940 process->priv->first_error.status,
941 process->priv->first_error.gerror);
942 }
943
944 g_signal_emit (G_OBJECT (process)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((process)), (((GType) ((20) << (2))))))))
,
945 fr_process_signals[DONE],
946 0,
947 &process->error);
948
949 return FALSE(0);
950}
951
952void
953fr_process_use_standard_locale (FrProcess *process,
954 gboolean use_stand_locale)
955{
956 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
957 process->priv->use_standard_locale = use_stand_locale;
958}
959
960void
961fr_process_start (FrProcess *process)
962{
963 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
964
965 if (process->priv->running)
966 return;
967
968 fr_channel_data_reset (&process->out);
969 fr_channel_data_reset (&process->err);
970
971 process->priv->sticky_only = FALSE(0);
972 process->priv->current_command = 0;
973 fr_process_set_error (process, FR_PROC_ERROR_NONE, 0, NULL((void*)0));
974
975 if (! process->restart) {
976 process->priv->current_charset = -1;
977 g_signal_emit (G_OBJECT (process)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((process)), (((GType) ((20) << (2))))))))
,
978 fr_process_signals[START],
979 0);
980 }
981
982 process->priv->stopping = FALSE(0);
983
984 if (process->priv->n_comm == -1) {
985 process->priv->running = FALSE(0);
986 g_signal_emit (G_OBJECT (process)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((process)), (((GType) ((20) << (2))))))))
,
987 fr_process_signals[DONE],
988 0,
989 &process->error);
990 }
991 else {
992 process->priv->running = TRUE(!(0));
993 start_current_command (process);
994 }
995}
996static int
997fr_close_suspend_process(FrProcess *process)
998{
999 int ret = -1;
1000 g_return_val_if_fail(process != NULL, ret)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return (ret); } } while (0)
;
1001
1002 if (process->priv->suspend)
1003 {
1004 if (process->priv->command_pid > 0)
1005 {
1006 ret = killpg (process->priv->command_pid,SIGTERM15);
Value stored to 'ret' is never read
1007 ret = killpg (process->priv->command_pid,SIGCONT18);
1008 }
1009 if(ret == 0)
1010 process->priv->suspend = FALSE(0);
1011 }
1012
1013 return ret;
1014}
1015static int
1016fr_switch_process_state (FrProcess *process)
1017{
1018 int ret = -1;
1019 g_return_val_if_fail(process != NULL, ret)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return (ret); } } while (0)
;
1020
1021 if (process->priv->stopping)
1022 return ret;
1023
1024 if (process->priv->suspend)
1025 {
1026
1027 if (process->priv->command_pid > 0)
1028 ret = killpg (process->priv->command_pid,SIGCONT18);
1029 if(ret == 0)
1030 process->priv->suspend = FALSE(0);
1031 }
1032 else
1033 {
1034 if (process->priv->command_pid > 0)
1035 ret = killpg (process->priv->command_pid,SIGSTOP19);
1036 if(ret == 0)
1037 process->priv->suspend = TRUE(!(0));
1038 }
1039
1040 return ret;
1041}
1042static void
1043fr_process_stop_priv (FrProcess *process,
1044 gboolean emit_signal)
1045{
1046 g_return_if_fail (process != NULL)do { if ((process != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "process != NULL"
); return; } } while (0)
;
1047
1048 if (! process->priv->running)
1049 return;
1050
1051 if (process->priv->stopping)
1052 return;
1053
1054 process->priv->stopping = TRUE(!(0));
1055 process->error.type = FR_PROC_ERROR_STOPPED;
1056
1057 if (command_is_sticky (process, process->priv->current_command))
1058 allow_sticky_processes_only (process, emit_signal);
1059
1060 else if (process->term_on_stop && (process->priv->command_pid > 0))
1061 killpg (process->priv->command_pid, SIGTERM15);
1062
1063 else {
1064 if (process->priv->check_timeout != 0) {
1065 g_source_remove (process->priv->check_timeout);
1066 process->priv->check_timeout = 0;
1067 }
1068
1069 process->priv->command_pid = 0;
1070 fr_channel_data_close_source (&process->out);
1071 fr_channel_data_close_source (&process->err);
1072
1073 process->priv->running = FALSE(0);
1074
1075 if (emit_signal)
1076 g_signal_emit (G_OBJECT (process)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((process)), (((GType) ((20) << (2))))))))
,
1077 fr_process_signals[DONE],
1078 0,
1079 &process->error);
1080 }
1081}
1082
1083void
1084fr_process_stop (FrProcess *process)
1085{
1086 fr_process_stop_priv (process, TRUE(!(0)));
1087}
1088int start_switch_state (FrProcess *process)
1089{
1090 return fr_switch_process_state (process);
1091}
1092void start_close_suspend_process(FrProcess *process)
1093{
1094 fr_close_suspend_process(process);
1095}
1096
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-41f5bf.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-41f5bf.html new file mode 100644 index 0000000..aa95562 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-41f5bf.html @@ -0,0 +1,1083 @@ + + + +dlg-update.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/dlg-update.c
Warning:line 149, column 20
Access to field 'data' results in a dereference of a null pointer (loaded from field 'file_list')
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name dlg-update.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c dlg-update.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2008 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <config.h>
24#include <glib/gi18n.h>
25
26#include <string.h>
27#include <gtk/gtk.h>
28#include "dlg-update.h"
29#include "file-utils.h"
30#include "glib-utils.h"
31#include "gtk-utils.h"
32#include "fr-init.h"
33#include "fr-window.h"
34
35#define GET_WIDGET(x)(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, (x)))), ((gtk_widget_get_type
())))))))
(GTK_WIDGET (gtk_builder_get_object (builder, (x)))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, (x)))), ((gtk_widget_get_type
()))))))
)
36
37enum {
38 IS_SELECTED_COLUMN,
39 NAME_COLUMN,
40 DATA_COLUMN,
41 N_COLUMNS
42};
43
44typedef struct {
45 FrWindow *window;
46
47 GtkWidget *update_file_dialog;
48 GtkWidget *update_file_primary_text_label;
49 GtkWidget *update_file_secondary_text_label;
50
51 GtkWidget *update_files_dialog;
52 GtkWidget *update_files_primary_text_label;
53 GtkWidget *update_files_secondary_text_label;
54 GtkWidget *update_files_treeview;
55 GtkWidget *update_files_ok_button;
56
57 GList *file_list;
58 GtkTreeModel *list_model;
59} DialogData;
60
61/* called when the main dialog is closed. */
62static void
63dlg_update__destroy_cb (GtkWidget *widget,
64 DialogData *data)
65{
66 fr_window_update_dialog_closed (data->window);
67 if (data->file_list != NULL((void*)0))
68 g_list_free (data->file_list);
69 g_free (data);
70}
71
72static GList*
73get_selected_files (DialogData *data)
74{
75 GList *selection = NULL((void*)0);
76 GtkTreeIter iter;
77
78 if (! gtk_tree_model_get_iter_first (data->list_model, &iter))
79 return NULL((void*)0);
80
81 do {
82 gboolean is_selected;
83 OpenFile *file;
84
85 gtk_tree_model_get (data->list_model, &iter,
86 IS_SELECTED_COLUMN, &is_selected,
87 DATA_COLUMN, &file,
88 -1);
89 if (is_selected)
90 selection = g_list_prepend (selection, file);
91 } while (gtk_tree_model_iter_next (data->list_model, &iter));
92
93 return g_list_reverse (selection);
94}
95
96static void
97update_cb (GtkWidget *widget,
98 gpointer callback_data)
99{
100 DialogData *data = callback_data;
101 GList *selection;
102
103 selection = get_selected_files (data);
104 if (fr_window_update_files (data->window, selection)) {
105 int n_files;
106
107 n_files = g_list_length (data->file_list);
108 if (n_files == 1)
109 gtk_widget_destroy (data->update_file_dialog);
110 else
111 gtk_widget_destroy (data->update_files_dialog);
112 }
113 if (selection != NULL((void*)0))
114 g_list_free (selection);
115}
116
117static void
118update_file_list (DialogData *data)
119{
120 guint n_files;
121 GList *scan;
122 GtkTreeIter iter;
123
124 n_files = g_list_length (data->file_list);
125
126 /* update the file list */
127
128 gtk_list_store_clear (GTK_LIST_STORE (data->list_model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->list_model)), ((gtk_list_store_get_type ())))))
)
);
129 for (scan = data->file_list; scan; scan = scan->next) {
4
Assuming pointer value is null
5
Loop condition is false. Execution continues on line 148
130 char *utf8_name;
131 OpenFile *file = scan->data;
132
133 gtk_list_store_append (GTK_LIST_STORE (data->list_model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->list_model)), ((gtk_list_store_get_type ())))))
)
,
134 &iter);
135
136 utf8_name = g_filename_display_name (file_name_from_path (file->path));
137 gtk_list_store_set (GTK_LIST_STORE (data->list_model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->list_model)), ((gtk_list_store_get_type ())))))
)
,
138 &iter,
139 IS_SELECTED_COLUMN, TRUE(!(0)),
140 NAME_COLUMN, utf8_name,
141 DATA_COLUMN, file,
142 -1);
143 g_free (utf8_name);
144 }
145
146 /* update the labels */
147
148 if (n_files == 1) {
6
Assuming 'n_files' is equal to 1
7
Taking true branch
149 OpenFile *file = data->file_list->data;
8
Access to field 'data' results in a dereference of a null pointer (loaded from field 'file_list')
150 char *file_name;
151 char *unescaped;
152 char *archive_name;
153 char *label;
154 char *markup;
155
156 /* primary text */
157
158 file_name = g_filename_display_name (file_name_from_path (file->path));
159 unescaped = g_uri_unescape_string (fr_window_get_archive_uri (data->window), NULL((void*)0));
160 archive_name = g_path_get_basename (unescaped);
161 label = g_markup_printf_escaped (_("Update the file \"%s\" in the archive \"%s\"?")gettext ("Update the file \"%s\" in the archive \"%s\"?"), file_name, archive_name);
162 markup = g_strdup_printf ("<big><b>%s</b></big>", label);
163 gtk_label_set_markup (GTK_LABEL (data->update_file_primary_text_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_file_primary_text_label)), ((gtk_label_get_type
()))))))
, markup);
164
165 g_free (markup);
166 g_free (label);
167 g_free (archive_name);
168 g_free (unescaped);
169 g_free (file_name);
170
171 /* secondary text */
172
173 label = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa",
174 "The file has been modified with an external application. If you don't update the file in the archive, all of your changes will be lost.",
175 "%u files have been modified with an external application. If you don't update the files in the archive, all of your changes will be lost.",
176 (gulong) n_files),
177 n_files);
178 gtk_label_set_text (GTK_LABEL (data->update_file_secondary_text_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_file_secondary_text_label)), ((gtk_label_get_type
()))))))
, label);
179 g_free (label);
180 }
181 else if (n_files > 1) {
182 char *unescaped;
183 char *archive_name;
184 char *label;
185 char *markup;
186
187 /* primary text */
188
189 unescaped = g_uri_unescape_string (fr_window_get_archive_uri (data->window), NULL((void*)0));
190 archive_name = g_path_get_basename (unescaped);
191 label = g_markup_printf_escaped (_("Update the files in the archive \"%s\"?")gettext ("Update the files in the archive \"%s\"?"), archive_name);
192 markup = g_strdup_printf ("<big><b>%s</b></big>", label);
193 gtk_label_set_markup (GTK_LABEL (data->update_files_primary_text_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_files_primary_text_label)), ((gtk_label_get_type
()))))))
, markup);
194
195 g_free (markup);
196 g_free (label);
197 g_free (archive_name);
198 g_free (unescaped);
199
200 /* secondary text */
201
202 label = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa",
203 "The file has been modified with an external application. If you don't update the file in the archive, all of your changes will be lost.",
204 "%u files have been modified with an external application. If you don't update the files in the archive, all of your changes will be lost.",
205 (gulong) n_files),
206 n_files);
207 gtk_label_set_text (GTK_LABEL (data->update_files_secondary_text_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_files_secondary_text_label)), ((gtk_label_get_type
()))))))
, label);
208 g_free (label);
209 }
210
211 /* show the appropriate dialog */
212
213 if (n_files == 1) {
214 /*gtk_window_set_modal (GTK_WINDOW (data->update_files_dialog), FALSE);*/
215 gtk_widget_hide (data->update_files_dialog);
216 /*gtk_window_set_modal (GTK_WINDOW (data->update_file_dialog), TRUE);*/
217 gtk_widget_show (data->update_file_dialog);
218 }
219 else if (n_files > 1) {
220 /*gtk_window_set_modal (GTK_WINDOW (data->update_file_dialog), FALSE);*/
221 gtk_widget_hide (data->update_file_dialog);
222 /*gtk_window_set_modal (GTK_WINDOW (data->update_files_dialog), TRUE);*/
223 gtk_widget_show (data->update_files_dialog);
224 }
225 else { /* n_files == 0 */
226 /*gtk_window_set_modal (GTK_WINDOW (data->update_files_dialog), FALSE);*/
227 gtk_widget_hide (data->update_files_dialog);
228 /*gtk_window_set_modal (GTK_WINDOW (data->update_file_dialog), FALSE);*/
229 gtk_widget_hide (data->update_file_dialog);
230 }
231}
232
233static int
234n_selected (DialogData *data)
235{
236 int n = 0;
237 GtkTreeIter iter;
238
239 if (! gtk_tree_model_get_iter_first (data->list_model, &iter))
240 return 0;
241
242 do {
243 gboolean is_selected;
244 gtk_tree_model_get (data->list_model, &iter, IS_SELECTED_COLUMN, &is_selected, -1);
245 if (is_selected)
246 n++;
247 } while (gtk_tree_model_iter_next (data->list_model, &iter));
248
249 return n;
250}
251
252static void
253is_selected_toggled (GtkCellRendererToggle *cell,
254 char *path_string,
255 gpointer callback_data)
256{
257 DialogData *data = callback_data;
258 GtkTreeModel *model = GTK_TREE_MODEL (data->list_model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->list_model)), ((gtk_tree_model_get_type ())))))
)
;
259 GtkTreeIter iter;
260 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
261 guint value;
262
263 gtk_tree_model_get_iter (model, &iter, path);
264 value = ! gtk_cell_renderer_toggle_get_active (cell);
265 gtk_list_store_set (GTK_LIST_STORE (model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter, IS_SELECTED_COLUMN, value, -1);
266
267 gtk_tree_path_free (path);
268
269 gtk_widget_set_sensitive (data->update_files_ok_button, n_selected (data) > 0);
270}
271
272gpointer
273dlg_update (FrWindow *window)
274{
275 GtkBuilder *builder;
276 DialogData *data;
277 GtkCellRenderer *renderer;
278 GtkTreeViewColumn *column;
279
280 data = g_new0 (DialogData, 1)((DialogData *) g_malloc0_n ((1), sizeof (DialogData)));
281 builder = gtk_builder_new_from_resource (ENGRAMPA_RESOURCE_UI_PATH"/org/mate/Engrampa/ui" G_DIR_SEPARATOR_S"/" "update.ui");
282 data->file_list = NULL((void*)0);
283 data->window = window;
284
285 /* Get the widgets. */
286
287 data->update_file_dialog = GET_WIDGET ("update_file_dialog")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_file_dialog"))
)), ((gtk_widget_get_type ())))))))
;
288 data->update_file_primary_text_label = GET_WIDGET ("update_file_primary_text_label")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_file_primary_text_label"
)))), ((gtk_widget_get_type ())))))))
;
289 data->update_file_secondary_text_label = GET_WIDGET ("update_file_secondary_text_label")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_file_secondary_text_label"
)))), ((gtk_widget_get_type ())))))))
;
290
291 data->update_files_dialog = GET_WIDGET ("update_files_dialog")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_files_dialog")
))), ((gtk_widget_get_type ())))))))
;
292 data->update_files_primary_text_label = GET_WIDGET ("update_files_primary_text_label")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_files_primary_text_label"
)))), ((gtk_widget_get_type ())))))))
;
293 data->update_files_secondary_text_label = GET_WIDGET ("update_files_secondary_text_label")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_files_secondary_text_label"
)))), ((gtk_widget_get_type ())))))))
;
294 data->update_files_treeview = GET_WIDGET ("update_files_treeview")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_files_treeview"
)))), ((gtk_widget_get_type ())))))))
;
295 data->update_files_ok_button = GET_WIDGET ("update_files_ok_button")(((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, ("update_files_ok_button"
)))), ((gtk_widget_get_type ())))))))
;
296
297 /* Set the signals handlers. */
298
299 gtk_builder_add_callback_symbols (builder,
300 "on_update_file_dialog_destroy", G_CALLBACK (dlg_update__destroy_cb)((GCallback) (dlg_update__destroy_cb)),
301 "on_update_file_ok_button_clicked", G_CALLBACK (update_cb)((GCallback) (update_cb)),
302 "on_update_files_dialog_destroy", G_CALLBACK (dlg_update__destroy_cb)((GCallback) (dlg_update__destroy_cb)),
303 "on_update_files_ok_button_clicked", G_CALLBACK (update_cb)((GCallback) (update_cb)),
304 NULL((void*)0));
305
306 gtk_builder_connect_signals (builder, data);
307
308 g_signal_connect_swapped (gtk_builder_get_object (builder, "update_file_cancel_button"),g_signal_connect_data ((gtk_builder_get_object (builder, "update_file_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_file_dialog)), (((GType) ((20) << (2)))))))
)), ((void*)0), G_CONNECT_SWAPPED)
309 "clicked",g_signal_connect_data ((gtk_builder_get_object (builder, "update_file_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_file_dialog)), (((GType) ((20) << (2)))))))
)), ((void*)0), G_CONNECT_SWAPPED)
310 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((gtk_builder_get_object (builder, "update_file_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_file_dialog)), (((GType) ((20) << (2)))))))
)), ((void*)0), G_CONNECT_SWAPPED)
311 G_OBJECT (data->update_file_dialog))g_signal_connect_data ((gtk_builder_get_object (builder, "update_file_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_file_dialog)), (((GType) ((20) << (2)))))))
)), ((void*)0), G_CONNECT_SWAPPED)
;
312
313 g_signal_connect_swapped (gtk_builder_get_object (builder, "update_files_cancel_button"),g_signal_connect_data ((gtk_builder_get_object (builder, "update_files_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_files_dialog)), (((GType) ((20) << (2))))))
))), ((void*)0), G_CONNECT_SWAPPED)
314 "clicked",g_signal_connect_data ((gtk_builder_get_object (builder, "update_files_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_files_dialog)), (((GType) ((20) << (2))))))
))), ((void*)0), G_CONNECT_SWAPPED)
315 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((gtk_builder_get_object (builder, "update_files_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_files_dialog)), (((GType) ((20) << (2))))))
))), ((void*)0), G_CONNECT_SWAPPED)
316 G_OBJECT (data->update_files_dialog))g_signal_connect_data ((gtk_builder_get_object (builder, "update_files_cancel_button"
)), ("clicked"), (((GCallback) (gtk_widget_destroy))), (((((GObject
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data
->update_files_dialog)), (((GType) ((20) << (2))))))
))), ((void*)0), G_CONNECT_SWAPPED)
;
317
318 g_object_unref (builder);
319
320 /* Set dialog data. */
321
322 data->list_model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS,((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_list_store_new (N_COLUMNS, ((GType) ((5) << (2
))), ((GType) ((16) << (2))), ((GType) ((17) << (
2)))))), ((gtk_tree_model_get_type ()))))))
323 G_TYPE_BOOLEAN,((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_list_store_new (N_COLUMNS, ((GType) ((5) << (2
))), ((GType) ((16) << (2))), ((GType) ((17) << (
2)))))), ((gtk_tree_model_get_type ()))))))
324 G_TYPE_STRING,((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_list_store_new (N_COLUMNS, ((GType) ((5) << (2
))), ((GType) ((16) << (2))), ((GType) ((17) << (
2)))))), ((gtk_tree_model_get_type ()))))))
325 G_TYPE_POINTER))((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_list_store_new (N_COLUMNS, ((GType) ((5) << (2
))), ((GType) ((16) << (2))), ((GType) ((17) << (
2)))))), ((gtk_tree_model_get_type ()))))))
;
326 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->list_model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->list_model)), ((gtk_tree_sortable_get_type ()))
))))
,
327 NAME_COLUMN,
328 GTK_SORT_ASCENDING);
329 gtk_tree_view_set_model (GTK_TREE_VIEW (data->update_files_treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_files_treeview)), ((gtk_tree_view_get_type
()))))))
,
330 data->list_model);
331 g_object_unref (G_OBJECT (data->list_model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->list_model)), (((GType) ((20) << (2))))))
))
);
332
333 column = gtk_tree_view_column_new ();
334
335 renderer = gtk_cell_renderer_toggle_new ();
336 g_signal_connect (G_OBJECT (renderer),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (is_selected_toggled))),
(data), ((void*)0), (GConnectFlags) 0)
337 "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (is_selected_toggled))),
(data), ((void*)0), (GConnectFlags) 0)
338 G_CALLBACK (is_selected_toggled),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (is_selected_toggled))),
(data), ((void*)0), (GConnectFlags) 0)
339 data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (is_selected_toggled))),
(data), ((void*)0), (GConnectFlags) 0)
;
340 gtk_tree_view_column_pack_start (column, renderer, FALSE(0));
341 gtk_tree_view_column_set_attributes (column, renderer,
342 "active", IS_SELECTED_COLUMN,
343 NULL((void*)0));
344
345 renderer = gtk_cell_renderer_text_new ();
346 gtk_tree_view_column_pack_start (column, renderer, TRUE(!(0)));
347 gtk_tree_view_column_set_attributes (column, renderer,
348 "text", NAME_COLUMN,
349 NULL((void*)0));
350
351 gtk_tree_view_append_column (GTK_TREE_VIEW (data->update_files_treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_files_treeview)), ((gtk_tree_view_get_type
()))))))
, column);
352
353 /* Run dialog. */
354
355 gtk_window_set_transient_for (GTK_WINDOW (data->update_file_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_file_dialog)), ((gtk_window_get_type ())
)))))
,
356 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
357 gtk_window_set_transient_for (GTK_WINDOW (data->update_files_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->update_files_dialog)), ((gtk_window_get_type ()
))))))
,
358 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
359
360 update_file_list (data);
361
362 return data;
363}
364
365void
366dlg_update_add_file (gpointer dialog,
367 OpenFile *file)
368{
369 DialogData *data = dialog;
370 GList *scan;
371
372 /* avoid duplicates */
373
374 for (scan = data->file_list; scan; scan = scan->next) {
1
Loop condition is false. Execution continues on line 382
375 OpenFile *test = scan->data;
376 if (uricmp (test->extracted_uri, file->extracted_uri) == 0)
377 return;
378 }
379
380 /**/
381
382 data->file_list = g_list_append (data->file_list, file);
2
Value assigned to field 'file_list'
383 update_file_list (data);
3
Calling 'update_file_list'
384}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4a22f4.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4a22f4.html new file mode 100644 index 0000000..6e87b47 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4a22f4.html @@ -0,0 +1,9657 @@ + + + +fr-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/fr-window.c
Warning:line 7377, column 58
Null pointer passed to 1st parameter expecting 'nonnull'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name fr-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c fr-window.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2007 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include <config.h>
23#include <math.h>
24#include <string.h>
25
26#include <glib.h>
27#include <glib/gi18n.h>
28#include <gio/gio.h>
29#include <gdk/gdk.h>
30#include <gdk/gdkkeysyms.h>
31#include <gdk-pixbuf/gdk-pixbuf.h>
32
33#include "actions.h"
34#include "dlg-batch-add.h"
35#include "dlg-delete.h"
36#include "dlg-extract.h"
37#include "dlg-open-with.h"
38#include "dlg-ask-password.h"
39#include "dlg-package-installer.h"
40#include "dlg-update.h"
41#include "eggtreemultidnd.h"
42#include "fr-marshal.h"
43#include "fr-list-model.h"
44#include "fr-archive.h"
45#include "fr-error.h"
46#include "fr-window.h"
47#include "file-data.h"
48#include "file-utils.h"
49#include "glib-utils.h"
50#include "fr-init.h"
51#include "gtk-utils.h"
52#include "open-file.h"
53#include "typedefs.h"
54#include "ui.h"
55
56#ifdef __GNUC__4
57#define UNUSED_VARIABLE__attribute__ ((unused)) __attribute__ ((unused))
58#else
59#define UNUSED_VARIABLE__attribute__ ((unused))
60#endif
61
62#define LAST_OUTPUT_DIALOG_NAME"last-output" "last-output"
63#define ACTIVITY_DELAY100 100
64#define ACTIVITY_PULSE_STEP(0.033) (0.033)
65
66#define PROGRESS_TIMEOUT_MSECS5000 5000
67#define PROGRESS_DIALOG_DEFAULT_WIDTH500 500
68#define PROGRESS_BAR_HEIGHT10 10
69#undef LOG_PROGRESS
70
71#define HIDE_PROGRESS_TIMEOUT_MSECS500 500
72#define DEFAULT_NAME_COLUMN_WIDTH250 250
73#define OTHER_COLUMNS_WIDTH100 100
74
75#define FILE_LIST_ICON_SIZEGTK_ICON_SIZE_LARGE_TOOLBAR GTK_ICON_SIZE_LARGE_TOOLBAR
76
77#define BAD_CHARS"/\\*" "/\\*"
78
79static GHashTable *tree_pixbuf_hash = NULL((void*)0);
80static GtkIconTheme *icon_theme = NULL((void*)0);
81static int file_list_icon_size = 0;
82
83#define XDS_FILENAME"xds.txt" "xds.txt"
84#define MAX_XDS_ATOM_VAL_LEN4096 4096
85#define XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)) gdk_atom_intern ("XdndDirectSave0", FALSE(0))
86#define TEXT_ATOMgdk_atom_intern ("text/plain", (0)) gdk_atom_intern ("text/plain", FALSE(0))
87#define XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0)) gdk_atom_intern ("XdndEngrampa0", FALSE(0))
88
89#define FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"))
90#define FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
(gdk_atom_intern_static_string ("application/engrampa-uri-list"))
91
92static GtkTargetEntry clipboard_targets[] = {
93 { "application/engrampa-uri-list", 0, 1 }
94};
95
96static GtkTargetEntry target_table[] = {
97 { "XdndEngrampa0", 0, 0 },
98 { "text/uri-list", 0, 1 },
99};
100
101static GtkTargetEntry folder_tree_targets[] = {
102 { "XdndEngrampa0", 0, 0 },
103 { "XdndDirectSave0", 0, 2 }
104};
105
106typedef struct {
107 FrBatchActionType type;
108 void * data;
109 GFreeFunc free_func;
110} FRBatchAction;
111
112typedef struct {
113 guint converting : 1;
114 char *temp_dir;
115 FrArchive *new_archive;
116 char *password;
117 gboolean encrypt_header;
118 guint volume_size;
119 char *new_file;
120} FRConvertData;
121
122typedef enum {
123 FR_CLIPBOARD_OP_CUT,
124 FR_CLIPBOARD_OP_COPY
125} FRClipboardOp;
126
127typedef struct {
128 GList *file_list;
129 char *extract_to_dir;
130 char *sub_dir;
131 char *base_dir;
132 gboolean skip_older;
133 FrOverwrite overwrite;
134 gboolean junk_paths;
135 char *password;
136 gboolean extract_here;
137 gboolean ask_to_open_destination;
138} ExtractData;
139
140typedef enum {
141 FR_WINDOW_AREA_MENUBAR,
142 FR_WINDOW_AREA_TOOLBAR,
143 FR_WINDOW_AREA_LOCATIONBAR,
144 FR_WINDOW_AREA_CONTENTS,
145 FR_WINDOW_AREA_FILTERBAR,
146 FR_WINDOW_AREA_STATUSBAR,
147} FrWindowArea;
148
149typedef enum {
150 DIALOG_RESPONSE_NONE = 1,
151 DIALOG_RESPONSE_OPEN_ARCHIVE,
152 DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER,
153 DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT,
154 DIALOG_RESPONSE_QUIT
155} DialogResponse;
156
157/* -- FrClipboardData -- */
158
159typedef struct {
160 int refs;
161 char *archive_filename;
162 char *archive_password;
163 FRClipboardOp op;
164 char *base_dir;
165 GList *files;
166 char *tmp_dir;
167 char *current_dir;
168} FrClipboardData;
169
170static FrClipboardData*
171fr_clipboard_data_new (void)
172{
173 FrClipboardData *data;
174
175 data = g_new0 (FrClipboardData, 1)((FrClipboardData *) g_malloc0_n ((1), sizeof (FrClipboardData
)))
;
176 data->refs = 1;
177
178 return data;
179}
180
181static FrClipboardData *
182fr_clipboard_data_ref (FrClipboardData *clipboard_data)
183{
184 clipboard_data->refs++;
185 return clipboard_data;
186}
187
188static void
189fr_clipboard_data_unref (FrClipboardData *clipboard_data)
190{
191 if (clipboard_data == NULL((void*)0))
192 return;
193 if (--clipboard_data->refs > 0)
194 return;
195
196 g_free (clipboard_data->archive_filename);
197 g_free (clipboard_data->archive_password);
198 g_free (clipboard_data->base_dir);
199 g_free (clipboard_data->tmp_dir);
200 g_free (clipboard_data->current_dir);
201 g_list_free_full (clipboard_data->files, g_free);
202 g_free (clipboard_data);
203}
204
205static void
206fr_clipboard_data_set_password (FrClipboardData *clipboard_data,
207 const char *password)
208{
209 if (clipboard_data->archive_password != password)
210 g_free (clipboard_data->archive_password);
211 if (password != NULL((void*)0))
212 clipboard_data->archive_password = g_strdup (password)g_strdup_inline (password);
213}
214
215/**/
216
217enum {
218 ARCHIVE_LOADED,
219 PROGRESS,
220 READY,
221 LAST_SIGNAL
222};
223
224static GtkApplicationWindowClass *parent_class = NULL((void*)0);
225static guint fr_window_signals[LAST_SIGNAL] = { 0 };
226
227struct _FrWindowPrivateData {
228 GtkWidget *layout;
229 GtkWidget *contents;
230 GtkWidget *list_view;
231 GtkListStore *list_store;
232 GtkWidget *tree_view;
233 GtkTreeStore *tree_store;
234 GtkWidget *toolbar;
235 GtkWidget *statusbar;
236 GtkWidget *progress_bar;
237 GtkWidget *location_bar;
238 GtkWidget *location_entry;
239 GtkWidget *location_label;
240 GtkWidget *filter_bar;
241 GtkWidget *filter_entry;
242 GtkWidget *paned;
243 GtkWidget *sidepane;
244 GtkTreePath *list_hover_path;
245 GtkTreeViewColumn *filename_column;
246
247 gboolean filter_mode;
248 gint current_view_length;
249
250 guint help_message_cid;
251 guint list_info_cid;
252 guint progress_cid;
253
254 GtkWidget * up_arrows[5];
255 GtkWidget * down_arrows[5];
256
257 FrAction action;
258 gboolean archive_present;
259 gboolean archive_new; /* A new archive has been created
260 * but it doesn't contain any
261 * file yet. The real file will
262 * be created only when the user
263 * adds some file to the
264 * archive.*/
265
266 char * archive_uri;
267 char * open_default_dir; /* default directory to be used
268 * in the Open dialog. */
269 char * add_default_dir; /* default directory to be used
270 * in the Add dialog. */
271 char * extract_default_dir; /* default directory to be used
272 * in the Extract dialog. */
273 gboolean freeze_default_dir;
274 gboolean asked_for_password;
275 gboolean ask_to_open_destination_after_extraction;
276 gboolean destroy_with_error_dialog;
277
278 FRBatchAction current_batch_action;
279
280 gboolean give_focus_to_the_list;
281 gboolean single_click;
282 GtkTreePath *path_clicked;
283
284 FrWindowSortMethod sort_method;
285 GtkSortType sort_type;
286
287 char * last_location;
288
289 gboolean view_folders;
290 FrWindowListMode list_mode;
291 FrWindowListMode last_list_mode;
292 GList * history;
293 GList * history_current;
294 char * password;
295 char * password_for_paste;
296 gboolean encrypt_header;
297 FrCompression compression;
298 guint volume_size;
299
300 guint activity_timeout_handle; /* activity timeout
301 * handle. */
302 gint activity_ref; /* when > 0 some activity
303 * is present. */
304
305 guint update_timeout_handle; /* update file list
306 * timeout handle. */
307
308 FRConvertData convert_data;
309
310 gboolean stoppable;
311 gboolean closing;
312
313 FrClipboardData *clipboard_data;
314 FrClipboardData *copy_data;
315
316 FrArchive *copy_from_archive;
317
318 GActionGroup *actions;
319 GtkBuilder *ui_manager;
320 GtkWidget *menubar_recentmenu;
321 GtkWidget *toolbar_recentmenu;
322
323 GtkWidget *file_popup_menu;
324 GtkWidget *folder_popup_menu;
325 GtkWidget *sidebar_folder_popup_menu;
326
327 /* dragged files data */
328
329 char *drag_destination_folder;
330 char *drag_base_dir;
331 GError *drag_error;
332 GList *drag_file_list; /* the list of files we are
333 * dragging*/
334
335 /* progress dialog data */
336
337 GtkWidget *progress_dialog;
338 GtkWidget *pd_action;
339 GtkWidget *pd_message;
340 GtkWidget *pd_progress_bar;
341 GtkWidget *pd_cancel_button;
342 GtkWidget *pd_close_button;
343 GtkWidget *pd_open_archive_button;
344 GtkWidget *pd_open_destination_button;
345 GtkWidget *pd_open_destination_and_quit_button;
346 GtkWidget *pd_quit_button;
347 GtkWidget *pd_state_button; //Switch state, pause state or start state
348 GtkWidget *pd_icon;
349 gboolean progress_pulse;
350 guint progress_timeout; /* Timeout to display the progress dialog. */
351 guint hide_progress_timeout; /* Timeout to hide the progress dialog. */
352 char *pd_last_archive;
353 char *working_archive;
354 double pd_last_fraction;
355 char *pd_last_message;
356 gboolean use_progress_dialog;
357
358 /* update dialog data */
359
360 gpointer update_dialog;
361 GList *open_files;
362
363 /* batch mode data */
364
365 gboolean batch_mode; /* whether we are in a non interactive
366 * mode. */
367 GList *batch_action_list; /* FRBatchAction * elements */
368 GList *batch_action; /* current action. */
369 char *batch_title;
370
371 /* misc */
372
373 GSettings *settings_listing;
374 GSettings *settings_ui;
375 GSettings *settings_general;
376 GSettings *settings_dialogs;
377 GSettings *settings_caja;
378
379 gulong theme_changed_handler_id;
380 gboolean non_interactive;
381 char *extract_here_dir;
382 gboolean extract_interact_use_default_dir;
383 gboolean update_dropped_files;
384 gboolean batch_adding_one_file;
385
386 GtkWindow *load_error_parent_window;
387 gboolean showing_error_dialog;
388 GtkWindow *error_dialog_parent;
389
390 gboolean close_dialog;
391};
392
393/* -- fr_window_free_private_data -- */
394
395static void
396fr_window_free_batch_data (FrWindow *window)
397{
398 GList *scan;
399
400 for (scan = window->priv->batch_action_list; scan; scan = scan->next) {
401 FRBatchAction *adata = scan->data;
402
403 if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0)))
404 (*adata->free_func) (adata->data);
405 g_free (adata);
406 }
407
408 g_list_free (window->priv->batch_action_list);
409 window->priv->batch_action_list = NULL((void*)0);
410 window->priv->batch_action = NULL((void*)0);
411
412 g_free (window->priv->batch_title);
413 window->priv->batch_title = NULL((void*)0);
414}
415
416static void
417gh_unref_pixbuf (gpointer key,
418 gpointer value,
419 gpointer user_data)
420{
421 g_object_unref (value);
422}
423
424static void
425fr_window_clipboard_remove_file_list (FrWindow *window,
426 GList *file_list)
427{
428 GList *scan1;
429
430 if (window->priv->copy_data == NULL((void*)0))
431 return;
432
433 if (file_list == NULL((void*)0)) {
434 fr_clipboard_data_unref (window->priv->copy_data);
435 window->priv->copy_data = NULL((void*)0);
436 return;
437 }
438
439 for (scan1 = file_list; scan1; scan1 = scan1->next) {
440 const char *name1 = scan1->data;
441 GList *scan2;
442
443 for (scan2 = window->priv->copy_data->files; scan2;) {
444 const char *name2 = scan2->data;
445
446 if (strcmp (name1, name2) == 0) {
447 GList *tmp = scan2->next;
448 window->priv->copy_data->files = g_list_remove_link (window->priv->copy_data->files, scan2);
449 g_free (scan2->data);
450 g_list_free (scan2);
451 scan2 = tmp;
452 }
453 else
454 scan2 = scan2->next;
455 }
456 }
457
458 if (window->priv->copy_data->files == NULL((void*)0)) {
459 fr_clipboard_data_unref (window->priv->copy_data);
460 window->priv->copy_data = NULL((void*)0);
461 }
462}
463
464static void
465fr_window_history_clear (FrWindow *window)
466{
467 if (window->priv->history != NULL((void*)0))
468 path_list_free (window->priv->history);
469 window->priv->history = NULL((void*)0);
470 window->priv->history_current = NULL((void*)0);
471 g_free (window->priv->last_location);
472 window->priv->last_location = NULL((void*)0);
473}
474
475static void
476fr_window_free_open_files (FrWindow *window)
477{
478 GList *scan;
479
480 for (scan = window->priv->open_files; scan; scan = scan->next) {
481 OpenFile *file = scan->data;
482
483 if (file->monitor != NULL((void*)0))
484 g_file_monitor_cancel (file->monitor);
485 open_file_free (file);
486 }
487 g_list_free (window->priv->open_files);
488 window->priv->open_files = NULL((void*)0);
489}
490
491static void
492fr_window_convert_data_free (FrWindow *window,
493 gboolean all)
494{
495 if (all) {
496 g_free (window->priv->convert_data.new_file);
497 window->priv->convert_data.new_file = NULL((void*)0);
498 }
499
500 window->priv->convert_data.converting = FALSE(0);
501
502 if (window->priv->convert_data.temp_dir != NULL((void*)0)) {
503 g_free (window->priv->convert_data.temp_dir);
504 window->priv->convert_data.temp_dir = NULL((void*)0);
505 }
506
507 if (window->priv->convert_data.new_archive != NULL((void*)0)) {
508 g_object_unref (window->priv->convert_data.new_archive);
509 window->priv->convert_data.new_archive = NULL((void*)0);
510 }
511
512 if (window->priv->convert_data.password != NULL((void*)0)) {
513 g_free (window->priv->convert_data.password);
514 window->priv->convert_data.password = NULL((void*)0);
515 }
516}
517
518static void
519fr_window_free_private_data (FrWindow *window)
520{
521 if (window->priv->update_timeout_handle != 0) {
522 g_source_remove (window->priv->update_timeout_handle);
523 window->priv->update_timeout_handle = 0;
524 }
525
526 while (window->priv->activity_ref > 0)
527 fr_window_stop_activity_mode (window);
528
529 if (window->priv->progress_timeout != 0) {
530 g_source_remove (window->priv->progress_timeout);
531 window->priv->progress_timeout = 0;
532 }
533
534 if (window->priv->hide_progress_timeout != 0) {
535 g_source_remove (window->priv->hide_progress_timeout);
536 window->priv->hide_progress_timeout = 0;
537 }
538
539 if (window->priv->theme_changed_handler_id != 0)
540 g_signal_handler_disconnect (icon_theme, window->priv->theme_changed_handler_id);
541
542 fr_window_history_clear (window);
543
544 g_free (window->priv->open_default_dir);
545 g_free (window->priv->add_default_dir);
546 g_free (window->priv->extract_default_dir);
547 g_free (window->priv->archive_uri);
548 g_free (window->priv->working_archive);
549
550 g_free (window->priv->password);
551 g_free (window->priv->password_for_paste);
552
553 g_object_unref (window->priv->list_store);
554
555 if (window->priv->clipboard_data != NULL((void*)0)) {
556 fr_clipboard_data_unref (window->priv->clipboard_data);
557 window->priv->clipboard_data = NULL((void*)0);
558 }
559 if (window->priv->copy_data != NULL((void*)0)) {
560 fr_clipboard_data_unref (window->priv->copy_data);
561 window->priv->copy_data = NULL((void*)0);
562 }
563 if (window->priv->copy_from_archive != NULL((void*)0)) {
564 g_object_unref (window->priv->copy_from_archive);
565 window->priv->copy_from_archive = NULL((void*)0);
566 }
567
568 fr_window_free_open_files (window);
569
570 fr_window_convert_data_free (window, TRUE(!(0)));
571
572 g_clear_error (&window->priv->drag_error);
573 path_list_free (window->priv->drag_file_list);
574 window->priv->drag_file_list = NULL((void*)0);
575
576 if (window->priv->file_popup_menu != NULL((void*)0)) {
577 gtk_widget_destroy (window->priv->file_popup_menu);
578 window->priv->file_popup_menu = NULL((void*)0);
579 }
580
581 if (window->priv->folder_popup_menu != NULL((void*)0)) {
582 gtk_widget_destroy (window->priv->folder_popup_menu);
583 window->priv->folder_popup_menu = NULL((void*)0);
584 }
585
586 if (window->priv->sidebar_folder_popup_menu != NULL((void*)0)) {
587 gtk_widget_destroy (window->priv->sidebar_folder_popup_menu);
588 window->priv->sidebar_folder_popup_menu = NULL((void*)0);
589 }
590
591 g_free (window->priv->last_location);
592
593 fr_window_free_batch_data (window);
594 fr_window_reset_current_batch_action (window);
595
596 g_free (window->priv->pd_last_archive);
597 g_free (window->priv->pd_last_message);
598 g_free (window->priv->extract_here_dir);
599
600 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method", window->priv->sort_method);
601 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type", window->priv->sort_type);
602 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode);
603
604 _g_object_unref (window->priv->settings_listing);
605 _g_object_unref (window->priv->settings_ui);
606 _g_object_unref (window->priv->settings_general);
607 _g_object_unref (window->priv->settings_dialogs);
608
609 if (window->priv->settings_caja)
610 _g_object_unref (window->priv->settings_caja);
611
612 if (window->priv->ui_manager)
613 {
614 g_object_unref (window->priv->ui_manager);
615 window->priv->ui_manager = NULL((void*)0);
616 }
617}
618
619static void
620fr_window_finalize (GObject *object)
621{
622 FrWindow *window = FR_WINDOW (object)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((fr_window_get_type ()))))))
;
623
624 fr_window_free_open_files (window);
625
626 if (window->archive != NULL((void*)0)) {
627 g_object_unref (window->archive);
628 window->archive = NULL((void*)0);
629 }
630
631 if (window->priv != NULL((void*)0)) {
632 fr_window_free_private_data (window);
633 g_free (window->priv);
634 window->priv = NULL((void*)0);
635 }
636
637 if (gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ())((((GtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_application_get_default ())), ((gtk_application_get_type
()))))))
) == NULL((void*)0)) {
638 if (tree_pixbuf_hash != NULL((void*)0)) {
639 g_hash_table_foreach (tree_pixbuf_hash,
640 gh_unref_pixbuf,
641 NULL((void*)0));
642 g_hash_table_destroy (tree_pixbuf_hash);
643 tree_pixbuf_hash = NULL((void*)0);
644 }
645 }
646
647 G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->finalize (object);
648}
649
650static gboolean
651close__step2 (gpointer data)
652{
653 gtk_widget_destroy (GTK_WIDGET (data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_widget_get_type ()))))))
);
654 return FALSE(0);
655}
656
657void
658fr_window_close (FrWindow *window)
659{
660 if (window->priv->activity_ref > 0)
661 return;
662
663 window->priv->closing = TRUE(!(0));
664
665 if (gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)) {
666 int width, height;
667
668 width = gtk_widget_get_allocated_width (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
669 height = gtk_widget_get_allocated_height (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
670 g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width", width);
671 g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height", height);
672
673 width = gtk_paned_get_position (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
);
674 if (width > 0)
675 g_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width", width);
676
677 width = gtk_tree_view_column_get_width (window->priv->filename_column);
678 if (width > 0)
679 g_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width", width);
680 }
681
682 g_idle_add (close__step2, window);
683}
684
685static void
686fr_window_class_init (FrWindowClass *class)
687{
688 GObjectClass *gobject_class;
689
690 parent_class = g_type_class_peek_parent (class);
691
692 fr_window_signals[ARCHIVE_LOADED] =
693 g_signal_new ("archive-loaded",
694 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
695 G_SIGNAL_RUN_LAST,
696 G_STRUCT_OFFSET (FrWindowClass, archive_loaded)((glong) __builtin_offsetof(FrWindowClass, archive_loaded)),
697 NULL((void*)0), NULL((void*)0),
698 fr_marshal_VOID__BOOLEANg_cclosure_marshal_VOID__BOOLEAN,
699 G_TYPE_NONE((GType) ((1) << (2))), 1,
700 G_TYPE_BOOLEAN((GType) ((5) << (2))));
701 fr_window_signals[PROGRESS] =
702 g_signal_new ("progress",
703 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
704 G_SIGNAL_RUN_LAST,
705 G_STRUCT_OFFSET (FrWindowClass, progress)((glong) __builtin_offsetof(FrWindowClass, progress)),
706 NULL((void*)0), NULL((void*)0),
707 fr_marshal_VOID__DOUBLE_STRING,
708 G_TYPE_NONE((GType) ((1) << (2))), 2,
709 G_TYPE_DOUBLE((GType) ((15) << (2))),
710 G_TYPE_STRING((GType) ((16) << (2))));
711 fr_window_signals[READY] =
712 g_signal_new ("ready",
713 G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type),
714 G_SIGNAL_RUN_LAST,
715 G_STRUCT_OFFSET (FrWindowClass, ready)((glong) __builtin_offsetof(FrWindowClass, ready)),
716 NULL((void*)0), NULL((void*)0),
717 fr_marshal_VOID__POINTERg_cclosure_marshal_VOID__POINTER,
718 G_TYPE_NONE((GType) ((1) << (2))), 1,
719 G_TYPE_POINTER((GType) ((17) << (2))));
720
721 gobject_class = (GObjectClass*) class;
722 gobject_class->finalize = fr_window_finalize;
723}
724
725static void fr_window_update_paste_command_sensitivity (FrWindow *, GtkClipboard *);
726
727static void
728clipboard_owner_change_cb (GtkClipboard *clipboard,
729 GdkEvent *event,
730 gpointer user_data)
731{
732 fr_window_update_paste_command_sensitivity ((FrWindow *) user_data, clipboard);
733}
734
735static void
736fr_window_realized (GtkWidget *window,
737 gpointer *data)
738{
739 GtkClipboard *clipboard;
740
741 clipboard = gtk_widget_get_clipboard (window, FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
742 g_signal_connect (clipboard,g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
743 "owner_change",g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
744 G_CALLBACK (clipboard_owner_change_cb),g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
745 window)g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback
) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
746}
747
748static void
749fr_window_unrealized (GtkWidget *window,
750 gpointer *data)
751{
752 GtkClipboard *clipboard;
753
754 clipboard = gtk_widget_get_clipboard (window, FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
755 g_signal_handlers_disconnect_by_func (clipboard,g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (clipboard_owner_change_cb))), (window))
756 G_CALLBACK (clipboard_owner_change_cb),g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (clipboard_owner_change_cb))), (window))
757 window)g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (clipboard_owner_change_cb))), (window))
;
758}
759
760static void
761fr_window_init (FrWindow *window)
762{
763 GtkStyleContext *context;
764
765 window->priv = g_new0 (FrWindowPrivateData, 1)((FrWindowPrivateData *) g_malloc0_n ((1), sizeof (FrWindowPrivateData
)))
;
766 window->priv->update_dropped_files = FALSE(0);
767 window->priv->filter_mode = FALSE(0);
768 window->priv->batch_title = NULL((void*)0);
769 window->priv->use_progress_dialog = TRUE(!(0));
770 window->priv->batch_title = NULL((void*)0);
771
772 context = gtk_widget_get_style_context (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
773 gtk_style_context_add_class (context, "engrampa-window");
774
775 g_signal_connect (window,g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
776 "realize",g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
777 G_CALLBACK (fr_window_realized),g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
778 NULL)g_signal_connect_data ((window), ("realize"), (((GCallback) (
fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
779 g_signal_connect (window,g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
780 "unrealize",g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
781 G_CALLBACK (fr_window_unrealized),g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
782 NULL)g_signal_connect_data ((window), ("unrealize"), (((GCallback)
(fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
783}
784
785GType
786fr_window_get_type (void)
787{
788 static GType type = 0;
789
790 if (! type) {
791 GTypeInfo type_info = {
792 sizeof (FrWindowClass),
793 NULL((void*)0),
794 NULL((void*)0),
795 (GClassInitFunc) fr_window_class_init,
796 NULL((void*)0),
797 NULL((void*)0),
798 sizeof (FrWindow),
799 0,
800 (GInstanceInitFunc) fr_window_init,
801 NULL((void*)0)
802 };
803
804 type = g_type_register_static (GTK_TYPE_APPLICATION_WINDOW(gtk_application_window_get_type ()),
805 "FrWindow",
806 &type_info,
807 0);
808 }
809
810 return type;
811}
812
813/* -- window history -- */
814
815#if 0
816static void
817fr_window_history_print (FrWindow *window)
818{
819 GList *list;
820
821 debug (DEBUG_INFO"fr-window.c", 821, __FUNCTION__, "history:\n");
822 for (list = window->priv->history; list; list = list->next)
823 g_print ("\t%s %s\n",
824 (char*) list->data,
825 (list == window->priv->history_current)? "<-": "");
826 g_print ("\n");
827}
828#endif
829
830static void
831fr_window_history_add (FrWindow *window,
832 const char *path)
833{
834 if ((window->priv->history_current == NULL((void*)0)) || (g_strcmp0 (path, window->priv->history_current->data) != 0)) {
835 GList *scan;
836 GList *new_current = NULL((void*)0);
837
838 /* search the path in the history */
839 for (scan = window->priv->history_current; scan; scan = scan->next) {
840 char *path_in_history = scan->data;
841
842 if (g_strcmp0 (path, path_in_history) == 0) {
843 new_current = scan;
844 break;
845 }
846 }
847
848 if (new_current != NULL((void*)0)) {
849 window->priv->history_current = new_current;
850 }
851 else {
852 /* remove all the paths after the current position */
853 for (scan = window->priv->history; scan && (scan != window->priv->history_current); /* void */) {
854 GList *next = scan->next;
855
856 window->priv->history = g_list_remove_link (window->priv->history, scan);
857 path_list_free (scan);
858
859 scan = next;
860 }
861
862 window->priv->history = g_list_prepend (window->priv->history, g_strdup (path)g_strdup_inline (path));
863 window->priv->history_current = window->priv->history;
864 }
865 }
866}
867
868static void
869fr_window_history_pop (FrWindow *window)
870{
871 GList *first;
872
873 if (window->priv->history == NULL((void*)0))
874 return;
875
876 first = window->priv->history;
877 window->priv->history = g_list_remove_link (window->priv->history, first);
878 if (window->priv->history_current == first)
879 window->priv->history_current = window->priv->history;
880 g_free (first->data);
881 g_list_free (first);
882}
883
884/* -- window_update_file_list -- */
885
886static GPtrArray *
887fr_window_get_current_dir_list (FrWindow *window)
888{
889 GPtrArray *files;
890 guint i;
891
892 files = g_ptr_array_sized_new (128);
893
894 for (i = 0; i < window->archive->command->files->len; i++) {
895 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
896
897 if (fdata->list_name == NULL((void*)0))
898 continue;
899 g_ptr_array_add (files, fdata);
900 }
901
902 return files;
903}
904
905static gint
906sort_by_name (gconstpointer ptr1,
907 gconstpointer ptr2)
908{
909 FileData *fdata1 = *((FileData **) ptr1);
910 FileData *fdata2 = *((FileData **) ptr2);
911
912 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
913 if (file_data_is_dir (fdata1))
914 return -1;
915 else
916 return 1;
917 }
918
919 return strcmp (fdata1->sort_key, fdata2->sort_key);
920}
921
922static gint
923sort_by_size (gconstpointer ptr1,
924 gconstpointer ptr2)
925{
926 FileData *fdata1 = *((FileData **) ptr1);
927 FileData *fdata2 = *((FileData **) ptr2);
928
929 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
930 if (file_data_is_dir (fdata1))
931 return -1;
932 else
933 return 1;
934 }
935 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) {
936 if (fdata1->dir_size > fdata2->dir_size)
937 return 1;
938 else
939 return -1;
940 }
941
942 if (fdata1->size == fdata2->size)
943 return sort_by_name (ptr1, ptr2);
944 else if (fdata1->size > fdata2->size)
945 return 1;
946 else
947 return -1;
948}
949
950static gint
951sort_by_type (gconstpointer ptr1,
952 gconstpointer ptr2)
953{
954 FileData *fdata1 = *((FileData **) ptr1);
955 FileData *fdata2 = *((FileData **) ptr2);
956 int result;
957 char *desc1, *desc2;
958
959 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
960 if (file_data_is_dir (fdata1))
961 return -1;
962 else
963 return 1;
964 }
965 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2))
966 return sort_by_name (ptr1, ptr2);
967
968 desc1 = g_content_type_get_description (fdata1->content_type);
969 desc2 = g_content_type_get_description (fdata2->content_type);
970
971 result = strcasecmp (desc1, desc2);
972 g_free (desc1);
973 g_free (desc2);
974
975 if (result == 0)
976 return sort_by_name (ptr1, ptr2);
977 else
978 return result;
979}
980
981static gint
982sort_by_time (gconstpointer ptr1,
983 gconstpointer ptr2)
984{
985 FileData *fdata1 = *((FileData **) ptr1);
986 FileData *fdata2 = *((FileData **) ptr2);
987
988 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
989 if (file_data_is_dir (fdata1))
990 return -1;
991 else
992 return 1;
993 }
994 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2))
995 return sort_by_name (ptr1, ptr2);
996
997 if (fdata1->modified == fdata2->modified)
998 return sort_by_name (ptr1, ptr2);
999 else if (fdata1->modified > fdata2->modified)
1000 return 1;
1001 else
1002 return -1;
1003}
1004
1005static gint
1006sort_by_path (gconstpointer ptr1,
1007 gconstpointer ptr2)
1008{
1009 FileData *fdata1 = *((FileData **) ptr1);
1010 FileData *fdata2 = *((FileData **) ptr2);
1011 int result;
1012
1013 if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) {
1014 if (file_data_is_dir (fdata1))
1015 return -1;
1016 else
1017 return 1;
1018 }
1019 else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2))
1020 return sort_by_name (ptr1, ptr2);
1021
1022 /* 2 files */
1023
1024 result = strcasecmp (fdata1->path, fdata2->path);
1025 if (result == 0)
1026 return sort_by_name (ptr1, ptr2);
1027 else
1028 return result;
1029}
1030
1031static guint64
1032get_dir_size (FrWindow *window,
1033 const char *current_dir,
1034 const char *name)
1035{
1036 guint64 size;
1037 char *dirname;
1038 int dirname_l;
1039 guint i;
1040
1041 dirname = g_strconcat (current_dir, name, "/", NULL((void*)0));
1042 dirname_l = strlen (dirname);
1043
1044 size = 0;
1045 for (i = 0; i < window->archive->command->files->len; i++) {
1046 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
1047
1048 if (strncmp (dirname, fd->full_path, dirname_l) == 0)
1049 size += fd->size;
1050 }
1051
1052 g_free (dirname);
1053
1054 return size;
1055}
1056
1057static gboolean
1058file_data_respects_filter (FrWindow *window,
1059 FileData *fdata)
1060{
1061 const char *filter;
1062
1063 filter = gtk_entry_get_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
);
1064 if ((fdata == NULL((void*)0)) || (filter == NULL((void*)0)) || (*filter == '\0'))
1065 return TRUE(!(0));
1066
1067 if (fdata->dir || (fdata->name == NULL((void*)0)))
1068 return FALSE(0);
1069
1070 return strncasecmp (fdata->name, filter, strlen (filter)) == 0;
1071}
1072
1073static gboolean
1074compute_file_list_name (FrWindow *window,
1075 FileData *fdata,
1076 const char *current_dir,
1077 size_t current_dir_len,
1078 GHashTable *names_hash,
1079 gboolean *different_name)
1080{
1081 register char *scan, *end;
1082
1083 *different_name = FALSE(0);
1084
1085 if (! file_data_respects_filter (window, fdata))
1086 return FALSE(0);
1087
1088 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
1089 if (!(fdata->dir))
1090 file_data_set_list_name (fdata, fdata->name);
1091 return FALSE(0);
1092 }
1093
1094 if (strncmp (fdata->full_path, current_dir, current_dir_len) != 0) {
1095 *different_name = TRUE(!(0));
1096 return FALSE(0);
1097 }
1098
1099 if (strlen (fdata->full_path) == current_dir_len)
1100 return FALSE(0);
1101
1102 scan = fdata->full_path + current_dir_len;
1103 end = strchr (scan, '/');
1104 if ((end == NULL((void*)0)) && ! fdata->dir) { /* file */
1105 file_data_set_list_name (fdata, scan);
1106 }
1107 else { /* folder */
1108 char *dir_name;
1109
1110 if (end != NULL((void*)0))
1111 dir_name = g_strndup (scan, end - scan);
1112 else
1113 dir_name = g_strdup (scan)g_strdup_inline (scan);
1114
1115 /* avoid to insert duplicated folders */
1116 if (g_hash_table_lookup (names_hash, dir_name) != NULL((void*)0)) {
1117 g_free (dir_name);
1118 return FALSE(0);
1119 }
1120 g_hash_table_insert (names_hash, dir_name, GINT_TO_POINTER (1)((gpointer) (glong) (1)));
1121
1122 if ((end != NULL((void*)0)) && (*(end + 1) != '\0'))
1123 fdata->list_dir = TRUE(!(0));
1124 file_data_set_list_name (fdata, dir_name);
1125 fdata->dir_size = get_dir_size (window, current_dir, dir_name);
1126 }
1127
1128 return TRUE(!(0));
1129}
1130
1131static void
1132fr_window_compute_list_names (FrWindow *window,
1133 GPtrArray *files)
1134{
1135 const char *current_dir;
1136 size_t current_dir_len;
1137 GHashTable *names_hash;
1138 guint i;
1139 gboolean visible_list_started = FALSE(0);
1140 gboolean visible_list_completed = FALSE(0);
1141 gboolean different_name;
1142
1143 current_dir = fr_window_get_current_location (window);
1144 current_dir_len = strlen (current_dir);
1145 names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
1146
1147 for (i = 0; i < files->len; i++) {
1148 FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i];
1149
1150 file_data_set_list_name (fdata, NULL((void*)0));
1151 fdata->list_dir = FALSE(0);
1152
1153 /* the files array is sorted by path, when the visible list
1154 * is started and we find a path that doesn't match the
1155 * current_dir path, the following files can't match
1156 * the current_dir path. */
1157
1158 if (visible_list_completed)
1159 continue;
1160
1161 if (compute_file_list_name (window, fdata, current_dir, current_dir_len, names_hash, &different_name)) {
1162 visible_list_started = TRUE(!(0));
1163 }
1164 else if (visible_list_started && different_name)
1165 visible_list_completed = TRUE(!(0));
1166 }
1167
1168 g_hash_table_destroy (names_hash);
1169}
1170
1171static gboolean
1172fr_window_dir_exists_in_archive (FrWindow *window,
1173 const char *dir_name)
1174{
1175 int dir_name_len;
1176 guint i;
1177
1178 if (dir_name == NULL((void*)0))
1179 return FALSE(0);
1180
1181 dir_name_len = strlen (dir_name);
1182 if (dir_name_len == 0)
1183 return TRUE(!(0));
1184
1185 if (strcmp (dir_name, "/") == 0)
1186 return TRUE(!(0));
1187
1188 for (i = 0; i < window->archive->command->files->len; i++) {
1189 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
1190
1191 if (strncmp (dir_name, fdata->full_path, dir_name_len) == 0) {
1192 return TRUE(!(0));
1193 }
1194 else if (fdata->dir
1195 && (fdata->full_path[strlen (fdata->full_path) -1] != '/')
1196 && (strncmp (dir_name, fdata->full_path, dir_name_len - 1) == 0))
1197 {
1198 return TRUE(!(0));
1199 }
1200 }
1201
1202 return FALSE(0);
1203}
1204
1205static char *
1206get_parent_dir (const char *current_dir)
1207{
1208 char *dir;
1209 char *new_dir;
1210 char *retval;
1211
1212 if (current_dir == NULL((void*)0))
1213 return NULL((void*)0);
1214 if (strcmp (current_dir, "/") == 0)
1215 return g_strdup ("/")g_strdup_inline ("/");
1216
1217 dir = g_strdup (current_dir)g_strdup_inline (current_dir);
1218 dir[strlen (dir) - 1] = 0;
1219 new_dir = remove_level_from_path (dir);
1220 g_free (dir);
1221
1222 if (new_dir[strlen (new_dir) - 1] == '/')
1223 retval = new_dir;
1224 else {
1225 retval = g_strconcat (new_dir, "/", NULL((void*)0));
1226 g_free (new_dir);
1227 }
1228
1229 return retval;
1230}
1231
1232static void fr_window_update_statusbar_list_info (FrWindow *window);
1233
1234static GdkPixbuf *
1235get_mime_type_icon (const char *mime_type)
1236{
1237 GdkPixbuf *pixbuf = NULL((void*)0);
1238
1239 pixbuf = g_hash_table_lookup (tree_pixbuf_hash, mime_type);
1240 if (pixbuf != NULL((void*)0)) {
1241 g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
)))))))
;
1242 return pixbuf;
1243 }
1244
1245 pixbuf = get_mime_type_pixbuf (mime_type, file_list_icon_size, icon_theme);
1246 if (pixbuf == NULL((void*)0))
1247 return NULL((void*)0);
1248
1249 pixbuf = gdk_pixbuf_copy (pixbuf);
1250 g_hash_table_insert (tree_pixbuf_hash, (gpointer) mime_type, pixbuf);
1251 g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2)))
)))))))
;
1252
1253 return pixbuf;
1254}
1255
1256static GdkPixbuf *
1257get_icon (FileData *fdata)
1258{
1259 const char *content_type;
1260
1261 if (file_data_is_dir (fdata))
1262 content_type = MIME_TYPE_DIRECTORY"folder";
1263 else
1264 content_type = fdata->content_type;
1265
1266 return get_mime_type_icon (content_type);
1267}
1268
1269static GdkPixbuf *
1270get_emblem (FileData *fdata)
1271{
1272 if (! fdata->encrypted)
1273 return NULL((void*)0);
1274
1275 return get_mime_type_icon ("emblem-nowrite");
1276}
1277
1278static int
1279get_column_from_sort_method (FrWindowSortMethod sort_method)
1280{
1281 switch (sort_method) {
1282 case FR_WINDOW_SORT_BY_NAME: return COLUMN_NAME;
1283 case FR_WINDOW_SORT_BY_SIZE: return COLUMN_SIZE;
1284 case FR_WINDOW_SORT_BY_TYPE: return COLUMN_TYPE;
1285 case FR_WINDOW_SORT_BY_TIME: return COLUMN_TIME;
1286 case FR_WINDOW_SORT_BY_PATH: return COLUMN_PATH;
1287 default:
1288 break;
1289 }
1290
1291 return COLUMN_NAME;
1292}
1293
1294static int
1295get_sort_method_from_column (int column_id)
1296{
1297 switch (column_id) {
1298 case COLUMN_NAME: return FR_WINDOW_SORT_BY_NAME;
1299 case COLUMN_SIZE: return FR_WINDOW_SORT_BY_SIZE;
1300 case COLUMN_TYPE: return FR_WINDOW_SORT_BY_TYPE;
1301 case COLUMN_TIME: return FR_WINDOW_SORT_BY_TIME;
1302 case COLUMN_PATH: return FR_WINDOW_SORT_BY_PATH;
1303 default:
1304 break;
1305 }
1306
1307 return FR_WINDOW_SORT_BY_NAME;
1308}
1309
1310static void
1311add_selected_from_list_view (GtkTreeModel *model,
1312 GtkTreePath *path,
1313 GtkTreeIter *iter,
1314 gpointer data)
1315{
1316 GList **list = data;
1317 FileData *fdata;
1318
1319 gtk_tree_model_get (model, iter,
1320 COLUMN_FILE_DATA, &fdata,
1321 -1);
1322 *list = g_list_prepend (*list, fdata);
1323}
1324
1325static void
1326add_selected_from_tree_view (GtkTreeModel *model,
1327 GtkTreePath *path,
1328 GtkTreeIter *iter,
1329 gpointer data)
1330{
1331 GList **list = data;
1332 char *dir_path;
1333
1334 gtk_tree_model_get (model, iter,
1335 TREE_COLUMN_PATH, &dir_path,
1336 -1);
1337 *list = g_list_prepend (*list, dir_path);
1338}
1339
1340static void
1341add_selected_fd (GtkTreeModel *model,
1342 GtkTreePath *path,
1343 GtkTreeIter *iter,
1344 gpointer data)
1345{
1346 GList **list = data;
1347 FileData *fdata;
1348
1349 gtk_tree_model_get (model, iter,
1350 COLUMN_FILE_DATA, &fdata,
1351 -1);
1352 if (! fdata->list_dir)
1353 *list = g_list_prepend (*list, fdata);
1354}
1355
1356static GList *
1357get_selection_as_fd (FrWindow *window)
1358{
1359 GtkTreeSelection *selection;
1360 GList *list = NULL((void*)0);
1361
1362 if (! gtk_widget_get_realized (window->priv->list_view))
1363 return NULL((void*)0);
1364
1365 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
1366 if (selection == NULL((void*)0))
1367 return NULL((void*)0);
1368 gtk_tree_selection_selected_foreach (selection, add_selected_fd, &list);
1369
1370 return list;
1371}
1372
1373static void
1374fr_window_update_statusbar_list_info (FrWindow *window)
1375{
1376 char *info, *archive_info, *selected_info;
1377 char *size_txt, *sel_size_txt;
1378 gulong tot_n = 0;
1379 gulong sel_n = 0;
1380 goffset tot_size = 0;
1381 goffset sel_size = 0;
1382 GList *scan;
1383
1384 if (window == NULL((void*)0))
1385 return;
1386
1387 if ((window->archive == NULL((void*)0)) || (window->archive->command == NULL((void*)0))) {
1388 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, window->priv->list_info_cid);
1389 return;
1390 }
1391
1392 if (window->priv->archive_present) {
1393 GPtrArray *files = fr_window_get_current_dir_list (window);
1394 guint i;
1395
1396 for (i = 0; i < files->len; i++) {
1397 FileData *fd = g_ptr_array_index (files, i)((files)->pdata)[i];
1398
1399 tot_n++;
1400 if (! file_data_is_dir (fd))
1401 tot_size += fd->size;
1402 else
1403 tot_size += fd->dir_size;
1404 }
1405 g_ptr_array_free (files, TRUE(!(0)));
1406 }
1407
1408 if (window->priv->archive_present) {
1409 GList *selection = get_selection_as_fd (window);
1410
1411 for (scan = selection; scan; scan = scan->next) {
1412 FileData *fd = scan->data;
1413
1414 sel_n++;
1415 if (! file_data_is_dir (fd))
1416 sel_size += fd->size;
1417 }
1418 g_list_free (selection);
1419 }
1420
1421 size_txt = g_format_size (tot_size);
1422 sel_size_txt = g_format_size (sel_size);
1423
1424 if (tot_n == 0)
1425 archive_info = g_strdup ("")g_strdup_inline ("");
1426 else
1427 archive_info = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa", "%lu object (%s)", "%lu objects (%s)", tot_n), tot_n, size_txt);
1428
1429 if (sel_n == 0)
1430 selected_info = g_strdup ("")g_strdup_inline ("");
1431 else
1432 selected_info = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa", "%lu object selected (%s)", "%lu objects selected (%s)", sel_n), sel_n, sel_size_txt);
1433
1434 info = g_strconcat (archive_info,
1435 ((sel_n == 0) ? NULL((void*)0) : ", "),
1436 selected_info,
1437 NULL((void*)0));
1438
1439 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, window->priv->list_info_cid, info);
1440
1441 g_free (size_txt);
1442 g_free (sel_size_txt);
1443 g_free (archive_info);
1444 g_free (selected_info);
1445 g_free (info);
1446}
1447
1448static void
1449fr_window_populate_file_list (FrWindow *window,
1450 GPtrArray *files)
1451{
1452 guint i;
1453
1454 gtk_list_store_clear (window->priv->list_store);
1455
1456 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
1457 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1),
1458 GTK_SORT_ASCENDING);
1459
1460 for (i = 0; i < files->len; i++) {
1461 FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i];
1462 GtkTreeIter iter;
1463 GdkPixbuf *icon, *emblem;
1464 char *utf8_name;
1465
1466 if (fdata->list_name == NULL((void*)0))
1467 continue;
1468
1469 gtk_list_store_append (window->priv->list_store, &iter);
1470
1471 icon = get_icon (fdata);
1472 utf8_name = g_filename_display_name (fdata->list_name);
1473 emblem = get_emblem (fdata);
1474
1475 if (file_data_is_dir (fdata)) {
1476 char *utf8_path;
1477 char *tmp;
1478 char *s_size;
1479 char *s_time;
1480
1481 if (fdata->list_dir)
1482 tmp = remove_ending_separator (fr_window_get_current_location (window));
1483
1484 else
1485 tmp = remove_level_from_path (fdata->path);
1486 utf8_path = g_filename_display_name (tmp);
1487 g_free (tmp);
1488
1489 s_size = g_format_size (fdata->dir_size);
1490
1491 if (fdata->list_dir) {
1492 s_time = g_strdup ("")g_strdup_inline ("");
1493 } else {
1494 GDateTime *date_time;
1495 date_time = g_date_time_new_from_unix_local (fdata->modified);
1496 s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M"));
1497 g_date_time_unref (date_time);
1498 }
1499
1500 gtk_list_store_set (window->priv->list_store, &iter,
1501 COLUMN_FILE_DATA, fdata,
1502 COLUMN_ICON, icon,
1503 COLUMN_NAME, utf8_name,
1504 COLUMN_EMBLEM, emblem,
1505 COLUMN_TYPE, _("Folder")gettext ("Folder"),
1506 COLUMN_SIZE, s_size,
1507 COLUMN_TIME, s_time,
1508 COLUMN_PATH, utf8_path,
1509 -1);
1510 g_free (utf8_path);
1511 g_free (s_size);
1512 g_free (s_time);
1513 }
1514 else {
1515 GDateTime *date_time;
1516 char *utf8_path;
1517 char *s_size;
1518 char *s_time;
1519 char *desc;
1520
1521 utf8_path = g_filename_display_name (fdata->path);
1522
1523 s_size = g_format_size (fdata->size);
1524 date_time = g_date_time_new_from_unix_local (fdata->modified);
1525 s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M"));
1526 g_date_time_unref (date_time);
1527 desc = g_content_type_get_description (fdata->content_type);
1528
1529 gtk_list_store_set (window->priv->list_store, &iter,
1530 COLUMN_FILE_DATA, fdata,
1531 COLUMN_ICON, icon,
1532 COLUMN_NAME, utf8_name,
1533 COLUMN_EMBLEM, emblem,
1534 COLUMN_TYPE, desc,
1535 COLUMN_SIZE, s_size,
1536 COLUMN_TIME, s_time,
1537 COLUMN_PATH, utf8_path,
1538 -1);
1539 g_free (utf8_path);
1540 g_free (s_size);
1541 g_free (s_time);
1542 g_free (desc);
1543 }
1544 g_free (utf8_name);
1545 if (icon != NULL((void*)0))
1546 g_object_unref (icon);
1547 if (emblem != NULL((void*)0))
1548 g_object_unref (emblem);
1549 }
1550
1551 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
1552 get_column_from_sort_method (window->priv->sort_method),
1553 window->priv->sort_type);
1554
1555 fr_window_update_statusbar_list_info (window);
1556 fr_window_stop_activity_mode (window);
1557}
1558
1559static int
1560path_compare (gconstpointer a,
1561 gconstpointer b)
1562{
1563 char *path_a = *((char**) a);
1564 char *path_b = *((char**) b);
1565
1566 return strcmp (path_a, path_b);
1567}
1568
1569static gboolean
1570get_tree_iter_from_path (FrWindow *window,
1571 const char *path,
1572 GtkTreeIter *parent,
1573 GtkTreeIter *iter)
1574{
1575 gboolean result = FALSE(0);
1576
1577 if (! gtk_tree_model_iter_children (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, iter, parent))
1578 return FALSE(0);
1579
1580 do {
1581 GtkTreeIter tmp;
1582 char *iter_path;
1583
1584 if (get_tree_iter_from_path (window, path, iter, &tmp)) {
1585 *iter = tmp;
1586 return TRUE(!(0));
1587 }
1588
1589 gtk_tree_model_get (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
,
1590 iter,
1591 TREE_COLUMN_PATH, &iter_path,
1592 -1);
1593
1594 if ((iter_path != NULL((void*)0)) && (strcmp (path, iter_path) == 0)) {
1595 result = TRUE(!(0));
1596 g_free (iter_path);
1597 break;
1598 }
1599 g_free (iter_path);
1600 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, iter));
1601
1602 return result;
1603}
1604
1605static void
1606set_sensitive (FrWindow *window,
1607 const char *id,
1608 gboolean sensitive)
1609{
1610 GtkWidget *widget;
1611
1612 widget = (GtkWidget *)gtk_builder_get_object (window->priv->ui_manager, id);
1613 g_object_set (widget, "sensitive", sensitive, NULL((void*)0));
1614}
1615
1616static void
1617fr_window_update_current_location (FrWindow *window)
1618{
1619 const char *current_dir = fr_window_get_current_location (window);
1620 char *path;
1621 GtkTreeIter iter;
1622
1623 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
1624 gtk_widget_hide (window->priv->location_bar);
1625 return;
1626 }
1627
1628 gtk_widget_show (window->priv->location_bar);
1629
1630 gtk_entry_set_text (GTK_ENTRY (window->priv->location_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_entry)), ((gtk_entry_get_type
()))))))
, window->priv->archive_present? current_dir: "");
1631
1632 set_sensitive (window, "tool_goback_item", window->priv->archive_present && (current_dir != NULL((void*)0)) && (window->priv->history_current != NULL((void*)0)) && (window->priv->history_current->next != NULL((void*)0)));
1633 set_sensitive (window, "tool_gonext_item", window->priv->archive_present && (current_dir != NULL((void*)0)) && (window->priv->history_current != NULL((void*)0)) && (window->priv->history_current->prev != NULL((void*)0)));
1634 set_sensitive (window, "tool_goup_item", window->priv->archive_present && (current_dir != NULL((void*)0)) && (strcmp (current_dir, "/") != 0));
1635 set_sensitive (window, "tool_gohome_item", window->priv->archive_present);
1636 gtk_widget_set_sensitive (window->priv->location_entry, window->priv->archive_present);
1637 gtk_widget_set_sensitive (window->priv->location_label, window->priv->archive_present);
1638 gtk_widget_set_sensitive (window->priv->filter_entry, window->priv->archive_present);
1639
1640#if 0
1641 fr_window_history_print (window);
1642#endif
1643
1644 path = remove_ending_separator (current_dir);
1645 if (get_tree_iter_from_path (window, path, NULL((void*)0), &iter)) {
1646 GtkTreeSelection *selection;
1647 GtkTreePath *t_path;
1648
1649 t_path = gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &iter);
1650 gtk_tree_view_expand_to_path (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
, t_path);
1651 gtk_tree_path_free (t_path);
1652
1653 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
1654 gtk_tree_selection_select_iter (selection, &iter);
1655 }
1656 g_free (path);
1657}
1658
1659static void
1660fr_window_update_dir_tree (FrWindow *window)
1661{
1662 GPtrArray *dirs;
1663 GHashTable *dir_cache;
1664 guint i;
1665 GdkPixbuf *icon;
1666
1667 gtk_tree_store_clear (window->priv->tree_store);
1668
1669 if (! window->priv->view_folders
1670 || ! window->priv->archive_present
1671 || (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT))
1672 {
1673 gtk_widget_set_sensitive (window->priv->tree_view, FALSE(0));
1674 gtk_widget_hide (window->priv->sidepane);
1675 return;
1676 }
1677 else {
1678 gtk_widget_set_sensitive (window->priv->tree_view, TRUE(!(0)));
1679 if (! gtk_widget_get_visible (window->priv->sidepane))
1680 gtk_widget_show_all (window->priv->sidepane);
1681 }
1682
1683 if (gtk_widget_get_realized (window->priv->tree_view))
1684 gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
, 0, 0);
1685
1686 /**/
1687
1688 dirs = g_ptr_array_sized_new (128);
1689
1690 dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), NULL((void*)0));
1691 for (i = 0; i < window->archive->command->files->len; i++) {
1692 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
1693 char *dir;
1694
1695 if (gtk_entry_get_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
) != NULL((void*)0)) {
1696 if (! file_data_respects_filter (window, fdata))
1697 continue;
1698 }
1699
1700 if (fdata->dir)
1701 dir = remove_ending_separator (fdata->full_path);
1702 else
1703 dir = remove_level_from_path (fdata->full_path);
1704
1705 while ((dir != NULL((void*)0)) && (strcmp (dir, "/") != 0)) {
1706 char *new_dir;
1707
1708 if (g_hash_table_lookup (dir_cache, dir) != NULL((void*)0))
1709 break;
1710
1711 new_dir = dir;
1712 g_ptr_array_add (dirs, new_dir);
1713 g_hash_table_replace (dir_cache, new_dir, "1");
1714
1715 dir = remove_level_from_path (new_dir);
1716 }
1717
1718 g_free (dir);
1719 }
1720 g_hash_table_destroy (dir_cache);
1721
1722 g_ptr_array_sort (dirs, path_compare);
1723 dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), (GDestroyNotify) gtk_tree_path_free);
1724
1725 /**/
1726
1727 icon = get_mime_type_icon (MIME_TYPE_ARCHIVE"application/x-archive");
1728 {
1729 GtkTreeIter node;
1730 char *uri;
1731 char *name;
1732
1733 uri = g_file_get_uri (window->archive->file);
1734 name = g_uri_display_basename (uri);
1735
1736 gtk_tree_store_append (window->priv->tree_store, &node, NULL((void*)0));
1737 gtk_tree_store_set (window->priv->tree_store, &node,
1738 TREE_COLUMN_ICON, icon,
1739 TREE_COLUMN_NAME, name,
1740 TREE_COLUMN_PATH, "/",
1741 TREE_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
1742 -1);
1743 g_hash_table_replace (dir_cache, "/", gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &node));
1744
1745 g_free (name);
1746 g_free (uri);
1747 }
1748 g_object_unref (icon);
1749
1750 /**/
1751
1752 icon = get_mime_type_icon (MIME_TYPE_DIRECTORY"folder");
1753 for (i = 0; i < dirs->len; i++) {
1754 char *dir = g_ptr_array_index (dirs, i)((dirs)->pdata)[i];
1755 char *parent_dir;
1756 GtkTreePath *parent_path;
1757 GtkTreeIter parent;
1758 GtkTreeIter node;
1759
1760 parent_dir = remove_level_from_path (dir);
1761 if (parent_dir == NULL((void*)0))
1762 continue;
1763
1764 parent_path = g_hash_table_lookup (dir_cache, parent_dir);
1765 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
,
1766 &parent,
1767 parent_path);
1768 gtk_tree_store_append (window->priv->tree_store, &node, &parent);
1769 gtk_tree_store_set (window->priv->tree_store, &node,
1770 TREE_COLUMN_ICON, icon,
1771 TREE_COLUMN_NAME, file_name_from_path (dir),
1772 TREE_COLUMN_PATH, dir,
1773 TREE_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
1774 -1);
1775 g_hash_table_replace (dir_cache, dir, gtk_tree_model_get_path (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &node));
1776
1777 g_free (parent_dir);
1778 }
1779 g_hash_table_destroy (dir_cache);
1780 if (icon != NULL((void*)0))
1781 g_object_unref (icon);
1782
1783 g_ptr_array_free (dirs, TRUE(!(0)));
1784
1785 fr_window_update_current_location (window);
1786}
1787
1788static void
1789fr_window_update_filter_bar_visibility (FrWindow *window)
1790{
1791 const char *filter;
1792
1793 filter = gtk_entry_get_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
);
1794 if ((filter == NULL((void*)0)) || (*filter == '\0'))
1795 gtk_widget_hide (window->priv->filter_bar);
1796 else
1797 gtk_widget_show (window->priv->filter_bar);
1798}
1799
1800static void
1801fr_window_update_file_list (FrWindow *window,
1802 gboolean update_view)
1803{
1804 GPtrArray *files;
1805 gboolean free_files = FALSE(0);
1806
1807 if (gtk_widget_get_realized (window->priv->list_view))
1808 gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
, 0, 0);
1809
1810 if (! window->priv->archive_present || window->priv->archive_new) {
1811 if (update_view)
1812 gtk_list_store_clear (window->priv->list_store);
1813
1814 window->priv->current_view_length = 0;
1815
1816 if (window->priv->archive_new) {
1817 gtk_widget_set_sensitive (window->priv->list_view, TRUE(!(0)));
1818 gtk_widget_show_all (gtk_widget_get_parent (window->priv->list_view));
1819 }
1820 else {
1821 gtk_widget_set_sensitive (window->priv->list_view, FALSE(0));
1822 gtk_widget_hide (gtk_widget_get_parent (window->priv->list_view));
1823 }
1824
1825 return;
1826 }
1827 else {
1828 gtk_widget_set_sensitive (window->priv->list_view, TRUE(!(0)));
1829 gtk_widget_show_all (gtk_widget_get_parent (window->priv->list_view));
1830 }
1831
1832 if (window->priv->give_focus_to_the_list) {
1833 gtk_widget_grab_focus (window->priv->list_view);
1834 window->priv->give_focus_to_the_list = FALSE(0);
1835 }
1836
1837 /**/
1838
1839 fr_window_start_activity_mode (window);
1840
1841 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
1842 fr_window_compute_list_names (window, window->archive->command->files);
1843 files = window->archive->command->files;
1844 free_files = FALSE(0);
1845 }
1846 else {
1847 char *current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
1848
1849 while (! fr_window_dir_exists_in_archive (window, current_dir)) {
1850 char *tmp;
1851
1852 fr_window_history_pop (window);
1853
1854 tmp = get_parent_dir (current_dir);
1855 g_free (current_dir);
1856 current_dir = tmp;
1857
1858 fr_window_history_add (window, current_dir);
1859 }
1860 g_free (current_dir);
1861
1862 fr_window_compute_list_names (window, window->archive->command->files);
1863 files = fr_window_get_current_dir_list (window);
1864 free_files = TRUE(!(0));
1865 }
1866
1867 if (files != NULL((void*)0))
1868 window->priv->current_view_length = files->len;
1869 else
1870 window->priv->current_view_length = 0;
1871
1872 if (update_view)
1873 fr_window_populate_file_list (window, files);
1874
1875 if (free_files)
1876 g_ptr_array_free (files, TRUE(!(0)));
1877}
1878
1879void
1880fr_window_update_list_order (FrWindow *window)
1881{
1882 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
, get_column_from_sort_method (window->priv->sort_method), window->priv->sort_type);
1883}
1884
1885static void
1886fr_window_update_title (FrWindow *window)
1887{
1888 if (! window->priv->archive_present)
1889 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, _("Archive Manager")gettext ("Archive Manager"));
1890 else {
1891 char *title;
1892 char *name;
1893
1894 name = g_uri_display_basename (fr_window_get_archive_uri (window));
1895 title = g_strdup_printf ("%s %s",
1896 name,
1897 window->archive->read_only ? _("[read only]")gettext ("[read only]") : "");
1898
1899 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, title);
1900 g_free (title);
1901 g_free (name);
1902 }
1903}
1904
1905static void
1906check_whether_has_a_dir (GtkTreeModel *model,
1907 GtkTreePath *path,
1908 GtkTreeIter *iter,
1909 gpointer data)
1910{
1911 gboolean *has_a_dir = data;
1912 FileData *fdata;
1913
1914 gtk_tree_model_get (model, iter,
1915 COLUMN_FILE_DATA, &fdata,
1916 -1);
1917 if (file_data_is_dir (fdata))
1918 *has_a_dir = TRUE(!(0));
1919}
1920
1921static gboolean
1922selection_has_a_dir (FrWindow *window)
1923{
1924 GtkTreeSelection *selection;
1925 gboolean has_a_dir = FALSE(0);
1926
1927 if (! gtk_widget_get_realized (window->priv->list_view))
1928 return FALSE(0);
1929
1930 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
1931 if (selection == NULL((void*)0))
1932 return FALSE(0);
1933
1934 gtk_tree_selection_selected_foreach (selection,
1935 check_whether_has_a_dir,
1936 &has_a_dir);
1937
1938 return has_a_dir;
1939}
1940
1941static void
1942set_active (FrWindow *window,
1943 const char *action_name,
1944 gboolean is_active)
1945{
1946 GAction *action;
1947
1948 action = g_action_map_lookup_action (G_ACTION_MAP (window->priv->actions)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->actions)), ((g_action_map_get_type (
)))))))
, action_name);
1949 g_simple_action_set_state (G_SIMPLE_ACTION (action)((((GSimpleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((g_simple_action_get_type ()))))))
, g_variant_new_boolean (is_active));
1950}
1951
1952static void
1953fr_window_update_paste_command_sensitivity (FrWindow *window,
1954 GtkClipboard *clipboard)
1955{
1956 gboolean running;
1957 gboolean no_archive;
1958 gboolean ro;
1959 gboolean compr_file;
1960
1961 if (window->priv->closing)
1962 return;
1963
1964 if (clipboard == NULL((void*)0))
1965 clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
1966 running = window->priv->activity_ref > 0;
1967 no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present;
1968 ro = ! no_archive && window->archive->read_only;
1969 compr_file = ! no_archive && window->archive->is_compressed_file;
1970
1971 set_sensitive (window, "paste_item", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && gtk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
));
1972 set_sensitive (window, "popup_paste_item", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && gtk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
));
1973 set_sensitive (window, "popup_paste_item1", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && gtk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
));
1974}
1975
1976static void
1977fr_window_update_sensitivity (FrWindow *window)
1978{
1979 gboolean no_archive;
1980 gboolean ro;
1981 gboolean file_op;
1982 gboolean running;
1983 gboolean compr_file;
1984 gboolean sel_not_null;
1985 gboolean one_file_selected;
1986 gboolean dir_selected;
1987 int n_selected;
1988
1989 if (window->priv->batch_mode)
1990 return;
1991
1992 running = window->priv->activity_ref > 0;
1993 no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present;
1994 ro = ! no_archive && window->archive->read_only;
1995 file_op = ! no_archive && ! window->priv->archive_new && ! running;
1996 compr_file = ! no_archive && window->archive->is_compressed_file;
1997 n_selected = fr_window_get_n_selected_files (window);
1998 sel_not_null = n_selected > 0;
1999 one_file_selected = n_selected == 1;
2000 dir_selected = selection_has_a_dir (window);
2001
2002 set_sensitive (window, "add_files_item", ! no_archive && ! ro && ! running && ! compr_file);
2003 set_sensitive (window, "tool_add_files_item", ! no_archive && ! ro && ! running && ! compr_file);
2004 set_sensitive (window, "add_folder_item", ! no_archive && ! ro && ! running && ! compr_file);
2005 set_sensitive (window, "tool_add_folder_item", ! no_archive && ! ro && ! running && ! compr_file);
2006 set_sensitive (window, "copy_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2007 set_sensitive (window, "popup_copy_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2008 set_sensitive (window, "popup_copy_item1", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2009 set_sensitive (window, "cut_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2010 set_sensitive (window, "popup_cut_item", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2011 set_sensitive (window, "popup_cut_item1", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT));
2012 set_sensitive (window, "delete_item", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file);
2013 set_sensitive (window, "popup_delete_item", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file);
2014 set_sensitive (window, "popup_delete_item1", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file);
2015 set_sensitive (window, "deselect_all_item", ! no_archive && sel_not_null);
2016 set_sensitive (window, "extract_item", file_op);
2017 set_sensitive (window, "tool_extract_item", file_op);
2018 set_sensitive (window, "find_item", ! no_archive);
2019 set_sensitive (window, "last_output_item", ((window->archive != NULL((void*)0))
2020 && (window->archive->process != NULL((void*)0))
2021 && (window->archive->process->out.raw != NULL((void*)0))));
2022 set_sensitive (window, "new_item", ! running);
2023 set_sensitive (window, "tool_new_item", ! running);
2024 set_sensitive (window, "open_item", ! running);
2025 set_sensitive (window, "popup_open_select_item", file_op && sel_not_null && ! dir_selected);
2026 set_sensitive (window, "popup_open_item1", file_op && one_file_selected && dir_selected);
2027 set_sensitive (window, "password_item", ! running && (window->priv->asked_for_password || (! no_archive && window->archive->command->propPassword)));
2028 set_sensitive (window, "properties_item", file_op);
2029 set_sensitive (window, "close_item", !running || window->priv->stoppable);
2030 set_sensitive (window, "reload_item", ! (no_archive || running));
2031 set_sensitive (window, "rename_item", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected);
2032 set_sensitive (window, "popup_rename_item", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected);
2033 set_sensitive (window, "popup_rename_item1", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected);
2034 set_sensitive (window, "open_saveas_item", ! no_archive && ! compr_file && ! running);
2035 set_sensitive (window, "select_all_item", ! no_archive);
2036 set_sensitive (window, "stop_item", running && window->priv->stoppable);
2037 set_sensitive (window, "tool_stop_item", running && window->priv->stoppable);
2038 set_sensitive (window, "test_integrity_item", ! no_archive && ! running && window->archive->command->propTest);
2039 set_sensitive (window, "popup_open_item", file_op && one_file_selected && ! dir_selected);
2040
2041 if (window->priv->progress_dialog != NULL((void*)0))
2042 gtk_dialog_set_response_sensitive (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
,
2043 GTK_RESPONSE_OK,
2044 running && window->priv->stoppable);
2045
2046 fr_window_update_paste_command_sensitivity (window, NULL((void*)0));
2047
2048 set_sensitive (window, "select_all_item", (window->priv->current_view_length > 0) && (window->priv->current_view_length != n_selected));
2049 set_sensitive (window, "deselect_all_item", n_selected > 0);
2050 set_sensitive (window, "open_recent_item", ! running);
2051 set_sensitive (window, "tool_open_recent_item", ! running);
2052
2053 set_sensitive (window, "view_folder_item", (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR));
2054
2055 set_sensitive (window, "view_all_files_item", ! window->priv->filter_mode);
2056 set_sensitive (window, "view_as_folder_item", ! window->priv->filter_mode);
2057}
2058
2059static gboolean
2060location_entry_key_press_event_cb (GtkWidget *widget,
2061 GdkEventKey *event,
2062 FrWindow *window)
2063{
2064 if ((event->keyval == GDK_KEY_Return0xff0d)
2065 || (event->keyval == GDK_KEY_KP_Enter0xff8d)
2066 || (event->keyval == GDK_KEY_ISO_Enter0xfe34))
2067 {
2068 fr_window_go_to_location (window, gtk_entry_get_text (GTK_ENTRY (window->priv->location_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_entry)), ((gtk_entry_get_type
()))))))
), FALSE(0));
2069 }
2070
2071 return FALSE(0);
2072}
2073
2074static gboolean
2075real_close_progress_dialog (gpointer data)
2076{
2077 FrWindow *window = data;
2078
2079 if (window->priv->hide_progress_timeout != 0) {
2080 g_source_remove (window->priv->hide_progress_timeout);
2081 window->priv->hide_progress_timeout = 0;
2082 }
2083
2084 if (window->priv->progress_dialog != NULL((void*)0))
2085 gtk_widget_hide (window->priv->progress_dialog);
2086
2087 return FALSE(0);
2088}
2089
2090static void close_suspend_process(FrWindow *window)
2091{
2092 if (window->archive->process != NULL((void*)0))
2093 {
2094 start_close_suspend_process(window->archive->process);
2095 }
2096}
2097static void
2098close_progress_dialog (FrWindow *window,
2099 gboolean close_now)
2100{
2101 if (window->priv->progress_timeout != 0) {
2102 g_source_remove (window->priv->progress_timeout);
2103 window->priv->progress_timeout = 0;
2104 }
2105
2106 if (! window->priv->batch_mode && gtk_widget_get_mapped (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2107 gtk_widget_hide (window->priv->progress_bar);
2108
2109 if (window->priv->progress_dialog == NULL((void*)0))
2110 return;
2111
2112 if (close_now) {
2113 if (window->priv->hide_progress_timeout != 0) {
2114 g_source_remove (window->priv->hide_progress_timeout);
2115 window->priv->hide_progress_timeout = 0;
2116 }
2117 real_close_progress_dialog (window);
2118 }
2119 else {
2120 if (window->priv->hide_progress_timeout != 0)
2121 return;
2122 window->priv->hide_progress_timeout = g_timeout_add (HIDE_PROGRESS_TIMEOUT_MSECS500,
2123 real_close_progress_dialog,
2124 window);
2125 }
2126 close_suspend_process(window);
2127}
2128
2129static gboolean
2130progress_dialog_delete_event (GtkWidget *caller,
2131 GdkEvent *event,
2132 FrWindow *window)
2133{
2134 if (window->priv->stoppable) {
2135 activate_action_stop (NULL((void*)0), NULL((void*)0), window);
2136 close_progress_dialog (window, TRUE(!(0)));
2137 }
2138
2139 return TRUE(!(0));
2140}
2141
2142static void
2143open_folder (GtkWindow *parent,
2144 const char *folder)
2145{
2146 GError *error = NULL((void*)0);
2147
2148 if (folder == NULL((void*)0))
2149 return;
2150
2151 if (! gtk_show_uri_on_window (parent, folder, GDK_CURRENT_TIME0L, &error)) {
2152 GtkWidget *d;
2153 char *utf8_name;
2154 char *message;
2155
2156 utf8_name = g_filename_display_name (folder);
2157 message = g_strdup_printf (_("Could not display the folder \"%s\"")gettext ("Could not display the folder \"%s\""), utf8_name);
2158 g_free (utf8_name);
2159
2160 d = _gtk_error_dialog_new (parent,
2161 GTK_DIALOG_MODAL,
2162 NULL((void*)0),
2163 message,
2164 "%s",
2165 error->message);
2166 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
2167 gtk_widget_destroy (d);
2168
2169 g_free (message);
2170 g_clear_error (&error);
2171 }
2172}
2173
2174static void
2175fr_window_view_extraction_destination_folder (FrWindow *window)
2176{
2177 open_folder (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, fr_archive_get_last_extraction_destination (window->archive));
2178}
2179
2180static void change_button_label (FrWindow *window,
2181 GtkWidget *button)
2182{
2183 const gchar *state;
2184 state = gtk_button_get_label (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
);
2185
2186 if (g_strrstr (_("_Pause")gettext ("_Pause"), state) != NULL((void*)0))
2187 {
2188 gtk_widget_set_visible (window->priv->pd_progress_bar, FALSE(0));
2189 fr_command_message (window->archive->command, _("Process paused")gettext ("Process paused"));
2190
2191 gtk_button_set_label (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, _("_Resume")gettext ("_Resume"));
2192 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
2193 gtk_image_new_from_icon_name ("media-playback-start",
2194 GTK_ICON_SIZE_BUTTON));
2195 }
2196 else
2197 {
2198 gtk_widget_set_visible (window->priv->pd_progress_bar, TRUE(!(0)));
2199 fr_command_message (window->archive->command, _("Please wait…")gettext ("Please wait…"));
2200
2201 gtk_button_set_label (GTK_BUTTON(button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, _("_Pause")gettext ("_Pause"));
2202 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
2203 gtk_image_new_from_icon_name ("media-playback-pause",
2204 GTK_ICON_SIZE_BUTTON));
2205 }
2206}
2207
2208static void
2209fr_state_switch (FrWindow *window)
2210{
2211 if ((window->archive->process != NULL((void*)0)) &&
2212 ((start_switch_state (window->archive->process) == 0))) {
2213 change_button_label (window, window->priv->pd_state_button);
2214 }
2215}
2216
2217static void
2218progress_dialog_response (GtkDialog *dialog,
2219 int response_id,
2220 FrWindow *window)
2221{
2222 GtkWidget *new_window;
2223
2224 switch (response_id) {
2225 case GTK_RESPONSE_CANCEL:
2226 if (window->priv->stoppable) {
2227 activate_action_stop (NULL((void*)0), NULL((void*)0), window);
2228 close_progress_dialog (window, TRUE(!(0)));
2229 }
2230 break;
2231 case GTK_RESPONSE_CLOSE:
2232 close_progress_dialog (window, TRUE(!(0)));
2233 break;
2234 case DIALOG_RESPONSE_OPEN_ARCHIVE:
2235 new_window = fr_window_new ();
2236 gtk_widget_show (new_window);
2237 fr_window_archive_open (FR_WINDOW (new_window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((fr_window_get_type ()))))))
, window->priv->convert_data.new_file, GTK_WINDOW (new_window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_window)), ((gtk_window_get_type ()))))))
);
2238 close_progress_dialog (window, TRUE(!(0)));
2239 break;
2240 case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER:
2241 fr_window_view_extraction_destination_folder (window);
2242 close_progress_dialog (window, TRUE(!(0)));
2243 break;
2244 case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT:
2245 fr_window_view_extraction_destination_folder (window);
2246 close_progress_dialog (window, TRUE(!(0)));
2247 fr_window_close (window);
2248 break;
2249 case DIALOG_RESPONSE_QUIT:
2250 fr_window_close (window);
2251 break;
2252 case GTK_RESPONSE_ACCEPT:
2253 fr_state_switch (window);
2254 break;
2255 default:
2256 break;
2257 }
2258}
2259
2260static char*
2261get_action_description (FrAction action,
2262 const char *uri)
2263{
2264 char *basename;
2265 char *message;
2266
2267 basename = (uri != NULL((void*)0)) ? g_uri_display_basename (uri) : NULL((void*)0);
2268
2269 message = NULL((void*)0);
2270 switch (action) {
2271 case FR_ACTION_CREATING_NEW_ARCHIVE:
2272 /* Translators: %s is a filename */
2273 message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename);
2274 break;
2275 case FR_ACTION_LOADING_ARCHIVE:
2276 /* Translators: %s is a filename */
2277 message = g_strdup_printf (_("Loading \"%s\"")gettext ("Loading \"%s\""), basename);
2278 break;
2279 case FR_ACTION_LISTING_CONTENT:
2280 /* Translators: %s is a filename */
2281 message = g_strdup_printf (_("Reading \"%s\"")gettext ("Reading \"%s\""), basename);
2282 break;
2283 case FR_ACTION_DELETING_FILES:
2284 /* Translators: %s is a filename */
2285 message = g_strdup_printf (_("Deleting files from \"%s\"")gettext ("Deleting files from \"%s\""), basename);
2286 break;
2287 case FR_ACTION_TESTING_ARCHIVE:
2288 /* Translators: %s is a filename */
2289 message = g_strdup_printf (_("Testing \"%s\"")gettext ("Testing \"%s\""), basename);
2290 break;
2291 case FR_ACTION_GETTING_FILE_LIST:
2292 message = g_strdup (_("Getting the file list"))g_strdup_inline (gettext ("Getting the file list"));
2293 break;
2294 case FR_ACTION_COPYING_FILES_FROM_REMOTE:
2295 /* Translators: %s is a filename */
2296 message = g_strdup_printf (_("Copying the files to add to \"%s\"")gettext ("Copying the files to add to \"%s\""), basename);
2297 break;
2298 case FR_ACTION_ADDING_FILES:
2299 /* Translators: %s is a filename */
2300 message = g_strdup_printf (_("Adding files to \"%s\"")gettext ("Adding files to \"%s\""), basename);
2301 break;
2302 case FR_ACTION_EXTRACTING_FILES:
2303 /* Translators: %s is a filename */
2304 message = g_strdup_printf (_("Extracting files from \"%s\"")gettext ("Extracting files from \"%s\""), basename);
2305 break;
2306 case FR_ACTION_COPYING_FILES_TO_REMOTE:
2307 message = g_strdup (_("Copying the extracted files to the destination"))g_strdup_inline (gettext ("Copying the extracted files to the destination"
))
;
2308 break;
2309 case FR_ACTION_CREATING_ARCHIVE:
2310 /* Translators: %s is a filename */
2311 message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename);
2312 break;
2313 case FR_ACTION_SAVING_REMOTE_ARCHIVE:
2314 /* Translators: %s is a filename */
2315 message = g_strdup_printf (_("Saving \"%s\"")gettext ("Saving \"%s\""), basename);
2316 break;
2317 case FR_ACTION_NONE:
2318 break;
2319 }
2320 g_free (basename);
2321
2322 return message;
2323}
2324
2325static void
2326progress_dialog_update_action_description (FrWindow *window)
2327{
2328 const char *current_archive;
2329 char *description;
2330 char *description_markup;
2331
2332 if (window->priv->progress_dialog == NULL((void*)0))
2333 return;
2334
2335 if (window->priv->convert_data.converting)
2336 current_archive = window->priv->convert_data.new_file;
2337 else if (window->priv->working_archive != NULL((void*)0))
2338 current_archive = window->priv->working_archive;
2339 else
2340 current_archive = window->priv->archive_uri;
2341
2342 g_free (window->priv->pd_last_archive);
2343 window->priv->pd_last_archive = NULL((void*)0);
2344 if (current_archive != NULL((void*)0))
2345 window->priv->pd_last_archive = g_strdup (current_archive)g_strdup_inline (current_archive);
2346
2347 description = get_action_description (window->priv->action, window->priv->pd_last_archive);
2348 description_markup = g_markup_printf_escaped ("<span weight=\"bold\" size=\"larger\">%s</span>", description);
2349 gtk_label_set_markup (GTK_LABEL (window->priv->pd_action)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_action)), ((gtk_label_get_type ()
))))))
, description_markup);
2350
2351 g_free (description_markup);
2352 g_free (description);
2353}
2354
2355static gboolean
2356fr_window_working_archive_cb (FrCommand *command,
2357 const char *archive_filename,
2358 FrWindow *window)
2359{
2360 g_free (window->priv->working_archive);
2361 if (archive_filename != NULL((void*)0))
2362 window->priv->working_archive = g_strdup (archive_filename)g_strdup_inline (archive_filename);
2363 else
2364 window->priv->working_archive = NULL((void*)0);
2365 progress_dialog_update_action_description (window);
2366
2367 return TRUE(!(0));
2368}
2369
2370static gboolean
2371fr_window_message_cb (FrCommand *command,
2372 const char *msg,
2373 FrWindow *window)
2374{
2375 if (window->priv->pd_last_message != msg) {
2376 g_free (window->priv->pd_last_message);
2377 window->priv->pd_last_message = g_strdup (msg)g_strdup_inline (msg);
2378 }
2379
2380 if (window->priv->progress_dialog == NULL((void*)0))
2381 return TRUE(!(0));
2382
2383 if (msg != NULL((void*)0)) {
2384 while (*msg == ' ')
2385 msg++;
2386 if (*msg == 0)
2387 msg = NULL((void*)0);
2388 }
2389
2390 if (msg != NULL((void*)0)) {
2391 char *utf8_msg;
2392
2393 if (! g_utf8_validate (msg, -1, NULL((void*)0)))
2394 utf8_msg = g_locale_to_utf8 (msg, -1 , 0, 0, 0);
2395 else
2396 utf8_msg = g_strdup (msg)g_strdup_inline (msg);
2397 if (utf8_msg == NULL((void*)0))
2398 return TRUE(!(0));
2399
2400 if (g_utf8_validate (utf8_msg, -1, NULL((void*)0)))
2401 gtk_label_set_text (GTK_LABEL (window->priv->pd_message)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_message)), ((gtk_label_get_type (
)))))))
, utf8_msg);
2402
2403 g_free (window->priv->pd_last_message);
2404 window->priv->pd_last_message = g_strdup (utf8_msg)g_strdup_inline (utf8_msg);
2405
2406 g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
,
2407 fr_window_signals[PROGRESS],
2408 0,
2409 window->priv->pd_last_fraction,
2410 window->priv->pd_last_message);
2411
2412#ifdef LOG_PROGRESS
2413 g_print ("message > %s\n", utf8_msg);
2414#endif
2415
2416 g_free (utf8_msg);
2417 }
2418 else
2419 gtk_label_set_text (GTK_LABEL (window->priv->pd_message)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_message)), ((gtk_label_get_type (
)))))))
, "");
2420
2421 progress_dialog_update_action_description (window);
2422
2423 return TRUE(!(0));
2424}
2425
2426static GtkWidget*
2427dialog_add_button_with_icon_name (GtkDialog *dialog,
2428 const gchar *button_text,
2429 const gchar *icon_name,
2430 gint response_id)
2431{
2432 GtkWidget *button;
2433
2434 button = gtk_button_new_with_mnemonic (button_text);
2435 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
2436
2437 gtk_button_set_use_underline (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, TRUE(!(0)));
2438 gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
2439 gtk_widget_set_can_default (button, TRUE(!(0)));
2440 gtk_widget_show (button);
2441 gtk_dialog_add_action_widget (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, button, response_id);
2442
2443 return button;
2444}
2445
2446static void
2447create_the_progress_dialog (FrWindow *window)
2448{
2449 GtkWindow *parent;
2450 GtkDialogFlags flags;
2451 GtkDialog *d;
2452 GtkWidget *hbox;
2453 GtkWidget *vbox;
2454 GtkWidget *progress_vbox;
2455 GtkWidget *lbl;
2456 PangoAttrList *attr_list;
2457 GdkPixbuf *icon;
2458
2459 if (window->priv->progress_dialog != NULL((void*)0))
2460 return;
2461
2462 flags = GTK_DIALOG_DESTROY_WITH_PARENT;
2463 if (window->priv->batch_mode) {
2464 parent = NULL((void*)0);
2465 }
2466 else {
2467 parent = GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
;
2468 flags |= GTK_DIALOG_MODAL;
2469 }
2470
2471 window->priv->progress_dialog = gtk_dialog_new_with_buttons ((window->priv->batch_mode ? window->priv->batch_title : NULL((void*)0)),
2472 parent,
2473 flags,
2474 NULL((void*)0),
2475 NULL((void*)0));
2476
2477 window->priv->pd_quit_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Quit")gettext ("_Quit"), "application-exit", DIALOG_RESPONSE_QUIT);
2478 window->priv->pd_open_archive_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Open the Archive")gettext ("_Open the Archive"), DIALOG_RESPONSE_OPEN_ARCHIVE);
2479 window->priv->pd_open_destination_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Show the Files")gettext ("_Show the Files"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER);
2480 window->priv->pd_open_destination_and_quit_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("Show the _Files and Quit")gettext ("Show the _Files and Quit"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT);
2481 window->priv->pd_close_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Close")gettext ("_Close"), "window-close", GTK_RESPONSE_CLOSE);
2482 window->priv->pd_cancel_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Cancel")gettext ("_Cancel"), "process-stop", GTK_RESPONSE_CANCEL);
2483 /*add start button default suspend*/
2484 window->priv->pd_state_button = dialog_add_button_with_icon_name (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
, _("_Pause")gettext ("_Pause"), "media-playback-pause", GTK_RESPONSE_ACCEPT);
2485 d = GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
;
2486 gtk_window_set_resizable (GTK_WINDOW (d)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2487 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
2488 gtk_window_set_default_size (GTK_WINDOW (d)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_window_get_type ()))))))
, PROGRESS_DIALOG_DEFAULT_WIDTH500, -1);
2489
2490 /* Main */
2491
2492 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 24);
2493 gtk_container_set_border_width (GTK_CONTAINER (hbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_container_get_type ()))))))
, 6);
2494 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (d))), ((gtk_box_get_type ()
))))))
, hbox, FALSE(0), FALSE(0), 10);
2495
2496 icon = get_mime_type_pixbuf ("package-x-generic", _gtk_widget_lookup_for_size (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, GTK_ICON_SIZE_DIALOG), NULL((void*)0));
2497 window->priv->pd_icon = gtk_image_new_from_pixbuf (icon);
2498 g_object_unref (icon);
2499
2500 gtk_widget_set_valign (window->priv->pd_icon, GTK_ALIGN_START);
2501 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, window->priv->pd_icon, FALSE(0), FALSE(0), 0);
2502
2503 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
2504 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, vbox, TRUE(!(0)), TRUE(!(0)), 0);
2505
2506 /* action description */
2507
2508 lbl = window->priv->pd_action = gtk_label_new ("");
2509 gtk_widget_set_halign (lbl, GTK_ALIGN_START);
2510 gtk_widget_set_valign (lbl, GTK_ALIGN_START);
2511 gtk_widget_set_hexpand (lbl, TRUE(!(0)));
2512 gtk_widget_set_vexpand (lbl, TRUE(!(0)));
2513 gtk_widget_set_margin_bottom (lbl, 12);
2514
2515 gtk_label_set_xalign (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, 0.0);
2516 gtk_label_set_ellipsize (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, PANGO_ELLIPSIZE_END);
2517 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, lbl, TRUE(!(0)), TRUE(!(0)), 0);
2518
2519 /* archive name */
2520
2521 g_free (window->priv->pd_last_archive);
2522 window->priv->pd_last_archive = NULL((void*)0);
2523
2524 if (window->priv->archive_uri != NULL((void*)0))
2525 window->priv->pd_last_archive = g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri);
2526
2527 /* progress and details */
2528
2529 progress_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
2530 gtk_widget_set_valign (progress_vbox, GTK_ALIGN_START);
2531 gtk_widget_set_hexpand (progress_vbox, TRUE(!(0)));
2532 gtk_widget_set_vexpand (progress_vbox, TRUE(!(0)));
2533 gtk_widget_set_margin_bottom (progress_vbox, 6);
2534 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, progress_vbox, TRUE(!(0)), TRUE(!(0)), 0);
2535
2536 /* progress bar */
2537
2538 window->priv->pd_progress_bar = gtk_progress_bar_new ();
2539 gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
, ACTIVITY_PULSE_STEP(0.033));
2540 gtk_box_pack_start (GTK_BOX (progress_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((progress_vbox)), ((gtk_box_get_type ()))))))
, window->priv->pd_progress_bar, TRUE(!(0)), TRUE(!(0)), 0);
2541
2542 /* details label */
2543
2544 lbl = window->priv->pd_message = gtk_label_new ("");
2545
2546 attr_list = pango_attr_list_new ();
2547 pango_attr_list_insert (attr_list, pango_attr_size_new (9000));
2548 gtk_label_set_attributes (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, attr_list);
2549 pango_attr_list_unref (attr_list);
2550
2551 gtk_label_set_xalign (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, 0.0);
2552 gtk_label_set_ellipsize (GTK_LABEL (lbl)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lbl)), ((gtk_label_get_type ()))))))
, PANGO_ELLIPSIZE_END);
2553 gtk_box_pack_start (GTK_BOX (progress_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((progress_vbox)), ((gtk_box_get_type ()))))))
, lbl, TRUE(!(0)), TRUE(!(0)), 0);
2554
2555 gtk_widget_show_all (hbox);
2556
2557 progress_dialog_update_action_description (window);
2558
2559 /* signals */
2560
2561 g_signal_connect (G_OBJECT (window->priv->progress_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
2562 "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
2563 G_CALLBACK (progress_dialog_response),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
2564 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("response"), (((GCallback
) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags
) 0)
;
2565 g_signal_connect (G_OBJECT (window->priv->progress_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
2566 "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
2567 G_CALLBACK (progress_dialog_delete_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
2568 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->progress_dialog)), (
((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback
) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags
) 0)
;
2569}
2570
2571static gboolean
2572display_progress_dialog (gpointer data)
2573{
2574 FrWindow *window = data;
2575
2576 if (window->priv->progress_timeout != 0)
2577 g_source_remove (window->priv->progress_timeout);
2578
2579 if (window->priv->use_progress_dialog && (window->priv->progress_dialog != NULL((void*)0))) {
2580 gtk_dialog_set_response_sensitive (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
,
2581 GTK_RESPONSE_OK,
2582 window->priv->stoppable);
2583 if (! window->priv->non_interactive)
2584 gtk_widget_show (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2585 gtk_widget_hide (window->priv->progress_bar);
2586 gtk_widget_show (window->priv->progress_dialog);
2587 fr_window_message_cb (NULL((void*)0), window->priv->pd_last_message, window);
2588 }
2589
2590 window->priv->progress_timeout = 0;
2591
2592 return FALSE(0);
2593}
2594
2595static void
2596open_progress_dialog (FrWindow *window,
2597 gboolean open_now)
2598{
2599 if (window->priv->hide_progress_timeout != 0) {
2600 g_source_remove (window->priv->hide_progress_timeout);
2601 window->priv->hide_progress_timeout = 0;
2602 }
2603
2604 if (open_now) {
2605 if (window->priv->progress_timeout != 0)
2606 g_source_remove (window->priv->progress_timeout);
2607 window->priv->progress_timeout = 0;
2608 }
2609
2610 if ((window->priv->progress_timeout != 0)
2611 || ((window->priv->progress_dialog != NULL((void*)0)) && gtk_widget_get_visible (window->priv->progress_dialog)))
2612 return;
2613
2614 if (! window->priv->batch_mode && ! open_now)
2615 gtk_widget_show (window->priv->progress_bar);
2616
2617 create_the_progress_dialog (window);
2618 gtk_widget_show (window->priv->pd_cancel_button);
2619 gtk_widget_show (window->priv->pd_state_button);
2620 gtk_widget_hide (window->priv->pd_open_archive_button);
2621 gtk_widget_hide (window->priv->pd_open_destination_button);
2622 gtk_widget_hide (window->priv->pd_open_destination_and_quit_button);
2623 gtk_widget_hide (window->priv->pd_quit_button);
2624 gtk_widget_hide (window->priv->pd_close_button);
2625
2626 if (open_now)
2627 display_progress_dialog (window);
2628 else
2629 window->priv->progress_timeout = g_timeout_add (PROGRESS_TIMEOUT_MSECS5000,
2630 display_progress_dialog,
2631 window);
2632}
2633
2634static gboolean
2635fr_window_progress_cb (FrArchive *archive,
2636 double fraction,
2637 FrWindow *window)
2638{
2639 window->priv->progress_pulse = (fraction < 0.0);
2640 if (! window->priv->progress_pulse) {
2641 fraction = CLAMP (fraction, 0.0, 1.0)(((fraction) > (1.0)) ? (1.0) : (((fraction) < (0.0)) ?
(0.0) : (fraction)))
;
2642 if (window->priv->progress_dialog != NULL((void*)0))
2643 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
, fraction);
2644 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
, fraction);
2645
2646 if ((archive != NULL((void*)0)) && (archive->command != NULL((void*)0)) && (archive->command->n_files > 0)) {
2647 char *message = NULL((void*)0);
2648 gulong remaining_files;
2649
2650 remaining_files = (gulong) (archive->command->n_files - archive->command->n_file + 1);
2651
2652 switch (window->priv->action) {
2653 case FR_ACTION_ADDING_FILES:
2654 case FR_ACTION_EXTRACTING_FILES:
2655 case FR_ACTION_DELETING_FILES:
2656 message = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE"engrampa",
2657 "%lu file remaining",
2658 "%lu files remaining",
2659 remaining_files),
2660 remaining_files);
2661 break;
2662 default:
2663 break;
2664 }
2665
2666 if (message != NULL((void*)0))
2667 fr_command_message (archive->command, message);
2668 }
2669
2670 window->priv->pd_last_fraction = fraction;
2671
2672 g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
,
2673 fr_window_signals[PROGRESS],
2674 0,
2675 window->priv->pd_last_fraction,
2676 window->priv->pd_last_message);
2677
2678#ifdef LOG_PROGRESS
2679 g_print ("progress > %2.2f\n", fraction);
2680#endif
2681 }
2682 return TRUE(!(0));
2683}
2684
2685static void
2686open_progress_dialog_with_open_destination (FrWindow *window)
2687{
2688 window->priv->ask_to_open_destination_after_extraction = FALSE(0);
2689
2690 if (window->priv->hide_progress_timeout != 0) {
2691 g_source_remove (window->priv->hide_progress_timeout);
2692 window->priv->hide_progress_timeout = 0;
2693 }
2694 if (window->priv->progress_timeout != 0) {
2695 g_source_remove (window->priv->progress_timeout);
2696 window->priv->progress_timeout = 0;
2697 }
2698
2699 create_the_progress_dialog (window);
2700 gtk_widget_hide (window->priv->pd_cancel_button);
2701 gtk_widget_hide (window->priv->pd_state_button);
2702 gtk_widget_hide (window->priv->pd_open_archive_button);
2703 gtk_widget_show (window->priv->pd_open_destination_button);
2704 gtk_widget_show (window->priv->pd_open_destination_and_quit_button);
2705 gtk_widget_show (window->priv->pd_quit_button);
2706 gtk_widget_show (window->priv->pd_close_button);
2707 display_progress_dialog (window);
2708 fr_window_progress_cb (NULL((void*)0), 1.0, window);
2709 fr_window_message_cb (NULL((void*)0), _("Extraction completed successfully")gettext ("Extraction completed successfully"), window);
2710
2711 if (window->priv->close_dialog)
2712 close_progress_dialog (window, TRUE(!(0)));
2713
2714}
2715
2716static void
2717open_progress_dialog_with_open_archive (FrWindow *window)
2718{
2719 if (window->priv->hide_progress_timeout != 0) {
2720 g_source_remove (window->priv->hide_progress_timeout);
2721 window->priv->hide_progress_timeout = 0;
2722 }
2723 if (window->priv->progress_timeout != 0) {
2724 g_source_remove (window->priv->progress_timeout);
2725 window->priv->progress_timeout = 0;
2726 }
2727
2728 create_the_progress_dialog (window);
2729 gtk_widget_hide (window->priv->pd_cancel_button);
2730 gtk_widget_hide (window->priv->pd_state_button);
2731 gtk_widget_hide (window->priv->pd_open_destination_button);
2732 gtk_widget_hide (window->priv->pd_open_destination_and_quit_button);
2733 gtk_widget_show (window->priv->pd_open_archive_button);
2734 gtk_widget_show (window->priv->pd_close_button);
2735 display_progress_dialog (window);
2736 fr_window_progress_cb (NULL((void*)0), 1.0, window);
2737 fr_window_message_cb (NULL((void*)0), _("Archive created successfully")gettext ("Archive created successfully"), window);
2738}
2739
2740void
2741fr_window_push_message (FrWindow *window,
2742 const char *msg)
2743{
2744 if (! gtk_widget_get_mapped (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2745 return;
2746
2747 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
2748 window->priv->progress_cid,
2749 msg);
2750}
2751
2752void
2753fr_window_pop_message (FrWindow *window)
2754{
2755 if (! gtk_widget_get_mapped (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2756 return;
2757 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, window->priv->progress_cid);
2758 if (window->priv->progress_dialog != NULL((void*)0))
2759 gtk_label_set_text (GTK_LABEL (window->priv->pd_message)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_message)), ((gtk_label_get_type (
)))))))
, "");
2760}
2761
2762static void
2763action_started (FrArchive *archive,
2764 FrAction action,
2765 gpointer data)
2766{
2767 FrWindow *window = data;
2768 char *message;
2769
2770 window->priv->action = action;
2771 fr_window_start_activity_mode (window);
2772
2773#ifdef MATE_ENABLE_DEBUG
2774 debug (DEBUG_INFO"fr-window.c", 2774, __FUNCTION__, "%s [START] (FR::Window)\n", get_action_name (action));
2775#endif
2776
2777 message = get_action_description (action, window->priv->pd_last_archive);
2778 fr_window_push_message (window, message);
2779 g_free (message);
2780
2781 switch (action) {
2782 case FR_ACTION_EXTRACTING_FILES:
2783 open_progress_dialog (window, window->priv->ask_to_open_destination_after_extraction || window->priv->convert_data.converting || window->priv->batch_mode);
2784 break;
2785 default:
2786 open_progress_dialog (window, window->priv->batch_mode);
2787 break;
2788 }
2789
2790 if (archive->command != NULL((void*)0)) {
2791 fr_command_progress (archive->command, -1.0);
2792 fr_command_message (archive->command, _("Please wait…")gettext ("Please wait…"));
2793 }
2794}
2795
2796static void
2797fr_window_add_to_recent_list (FrWindow *window,
2798 char *uri)
2799{
2800 if (window->priv->batch_mode)
2801 return;
2802
2803 if (is_temp_dir (uri))
2804 return;
2805
2806 if (window->archive->content_type != NULL((void*)0)) {
2807 GtkRecentData *recent_data;
2808
2809 recent_data = g_new0 (GtkRecentData, 1)((GtkRecentData *) g_malloc0_n ((1), sizeof (GtkRecentData)));
2810 recent_data->mime_type = g_content_type_get_mime_type (window->archive->content_type);
2811 recent_data->app_name = "Engrampa";
2812 recent_data->app_exec = "engrampa";
2813 gtk_recent_manager_add_full (gtk_recent_manager_get_default (), uri, recent_data);
2814
2815 g_free (recent_data->mime_type);
2816 g_free (recent_data);
2817 }
2818 else
2819 gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri);
2820}
2821
2822static void
2823fr_window_remove_from_recent_list (FrWindow *window,
2824 char *filename)
2825{
2826 if (filename != NULL((void*)0))
2827 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), filename, NULL((void*)0));
2828}
2829
2830static void
2831error_dialog_response_cb (GtkDialog *dialog,
2832 gint arg1,
2833 gpointer user_data)
2834{
2835 FrWindow *window = user_data;
2836 GtkWindow *dialog_parent = window->priv->error_dialog_parent;
2837
2838 window->priv->showing_error_dialog = FALSE(0);
2839 window->priv->error_dialog_parent = NULL((void*)0);
2840
2841 if ((dialog_parent != NULL((void*)0)) && (gtk_widget_get_toplevel (GTK_WIDGET (dialog_parent)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog_parent)), ((gtk_widget_get_type ()))))))
) != (GtkWidget*) dialog_parent))
2842 gtk_window_set_modal (dialog_parent, TRUE(!(0)));
2843 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
2844
2845 if (window->priv->destroy_with_error_dialog)
2846 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2847}
2848
2849static void
2850fr_window_show_error_dialog (FrWindow *window,
2851 GtkWidget *dialog,
2852 GtkWindow *dialog_parent,
2853 const char *details)
2854{
2855 if (window->priv->batch_mode && ! window->priv->use_progress_dialog) {
2856 GError *error;
2857
2858 error = g_error_new_literal (FR_ERRORfr_error_quark (), FR_PROC_ERROR_GENERIC, details ? details : _("Command exited abnormally.")gettext ("Command exited abnormally."));
2859 g_signal_emit (window,
2860 fr_window_signals[READY],
2861 0,
2862 error);
2863
2864 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2865
2866 return;
2867 }
2868
2869 close_progress_dialog (window, TRUE(!(0)));
2870
2871 if (window->priv->batch_mode)
2872 fr_window_destroy_with_error_dialog (window);
2873
2874 if (dialog_parent != NULL((void*)0))
2875 gtk_window_set_modal (dialog_parent, FALSE(0));
2876 g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2877 "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2878 G_CALLBACK (error_dialog_response_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2879 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2880 gtk_window_set_modal (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2881 gtk_widget_show (dialog);
2882
2883 window->priv->showing_error_dialog = TRUE(!(0));
2884 window->priv->error_dialog_parent = dialog_parent;
2885}
2886
2887void
2888fr_window_destroy_with_error_dialog (FrWindow *window)
2889{
2890 window->priv->destroy_with_error_dialog = TRUE(!(0));
2891}
2892
2893static gboolean
2894handle_errors (FrWindow *window,
2895 FrArchive *archive,
2896 FrAction action,
2897 FrProcError *error)
2898{
2899 if (error->type == FR_PROC_ERROR_ASK_PASSWORD) {
2900 close_progress_dialog (window, TRUE(!(0)));
2901 dlg_ask_password (window);
2902 return FALSE(0);
2903 }
2904 else if (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT) {
2905 close_progress_dialog (window, TRUE(!(0)));
2906 dlg_package_installer (window, archive, action);
2907 return FALSE(0);
2908 }
2909#if 0
2910 else if (error->type == FR_PROC_ERROR_BAD_CHARSET) {
2911 close_progress_dialog (window, TRUE(!(0)));
2912 /* dlg_ask_archive_charset (window); FIXME: implement after feature freeze */
2913 return FALSE(0);
2914 }
2915#endif
2916 else if (error->type == FR_PROC_ERROR_STOPPED) {
2917 /* nothing */
2918 }
2919 else if (error->type != FR_PROC_ERROR_NONE) {
2920 char *msg = NULL((void*)0);
2921 char *utf8_name;
2922 char *details = NULL((void*)0);
2923 GtkWindow *dialog_parent;
2924 GtkWidget *dialog;
2925 FrProcess *process = archive->process;
2926 GList *output = NULL((void*)0);
2927
2928 if (window->priv->batch_mode) {
2929 dialog_parent = NULL((void*)0);
2930 window->priv->load_error_parent_window = NULL((void*)0);
2931 }
2932 else {
2933 dialog_parent = (GtkWindow *) window;
2934 if (window->priv->load_error_parent_window == NULL((void*)0))
2935 window->priv->load_error_parent_window = (GtkWindow *) window;
2936 }
2937
2938 if ((action == FR_ACTION_LISTING_CONTENT) || (action == FR_ACTION_LOADING_ARCHIVE))
2939 fr_window_archive_close (window);
2940
2941 switch (action) {
2942 case FR_ACTION_CREATING_NEW_ARCHIVE:
2943 dialog_parent = window->priv->load_error_parent_window;
2944 msg = _("Could not create the archive")gettext ("Could not create the archive");
2945 break;
2946
2947 case FR_ACTION_EXTRACTING_FILES:
2948 case FR_ACTION_COPYING_FILES_TO_REMOTE:
2949 msg = _("An error occurred while extracting files.")gettext ("An error occurred while extracting files.");
2950 break;
2951
2952 case FR_ACTION_LOADING_ARCHIVE:
2953 dialog_parent = window->priv->load_error_parent_window;
2954 utf8_name = g_uri_display_basename (window->priv->archive_uri);
2955 msg = g_strdup_printf (_("Could not open \"%s\"")gettext ("Could not open \"%s\""), utf8_name);
2956 g_free (utf8_name);
2957 break;
2958
2959 case FR_ACTION_LISTING_CONTENT:
2960 msg = _("An error occurred while loading the archive.")gettext ("An error occurred while loading the archive.");
2961 break;
2962
2963 case FR_ACTION_DELETING_FILES:
2964 msg = _("An error occurred while deleting files from the archive.")gettext ("An error occurred while deleting files from the archive."
)
;
2965 break;
2966
2967 case FR_ACTION_ADDING_FILES:
2968 case FR_ACTION_GETTING_FILE_LIST:
2969 case FR_ACTION_COPYING_FILES_FROM_REMOTE:
2970 msg = _("An error occurred while adding files to the archive.")gettext ("An error occurred while adding files to the archive."
)
;
2971 break;
2972
2973 case FR_ACTION_TESTING_ARCHIVE:
2974 msg = _("An error occurred while testing archive.")gettext ("An error occurred while testing archive.");
2975 break;
2976
2977 case FR_ACTION_SAVING_REMOTE_ARCHIVE:
2978 msg = _("An error occurred while saving the archive.")gettext ("An error occurred while saving the archive.");
2979 break;
2980
2981 default:
2982 msg = _("An error occurred.")gettext ("An error occurred.");
2983 break;
2984 }
2985
2986 switch (error->type) {
2987 case FR_PROC_ERROR_COMMAND_NOT_FOUND:
2988 details = _("Command not found.")gettext ("Command not found.");
2989 break;
2990 case FR_PROC_ERROR_EXITED_ABNORMALLY:
2991 details = _("Command exited abnormally.")gettext ("Command exited abnormally.");
2992 break;
2993 case FR_PROC_ERROR_SPAWN:
2994 details = error->gerror->message;
2995 break;
2996 default:
2997 if (error->gerror != NULL((void*)0))
2998 details = error->gerror->message;
2999 else
3000 details = NULL((void*)0);
3001 break;
3002 }
3003
3004 if (error->type != FR_PROC_ERROR_GENERIC)
3005 output = (process->err.raw != NULL((void*)0)) ? process->err.raw : process->out.raw;
3006
3007 dialog = _gtk_error_dialog_new (dialog_parent,
3008 0,
3009 output,
3010 msg,
3011 ((details != NULL((void*)0)) ? "%s" : NULL((void*)0)),
3012 details);
3013 fr_window_show_error_dialog (window, dialog, dialog_parent, details);
3014
3015 return FALSE(0);
3016 }
3017
3018 return TRUE(!(0));
3019}
3020
3021static void
3022convert__action_performed (FrArchive *archive,
3023 FrAction action,
3024 FrProcError *error,
3025 gpointer data)
3026{
3027 FrWindow *window = data;
3028
3029#ifdef MATE_ENABLE_DEBUG
3030 debug (DEBUG_INFO"fr-window.c", 3030, __FUNCTION__, "%s [CONVERT::DONE] (FR::Window)\n", get_action_name (action));
3031#endif
3032
3033 if ((action == FR_ACTION_GETTING_FILE_LIST) || (action == FR_ACTION_ADDING_FILES)) {
3034 fr_window_stop_activity_mode (window);
3035 fr_window_pop_message (window);
3036 close_progress_dialog (window, FALSE(0));
3037 }
3038
3039 if (action != FR_ACTION_ADDING_FILES)
3040 return;
3041
3042 handle_errors (window, archive, action, error);
3043
3044 if (error->type == FR_PROC_ERROR_NONE)
3045 open_progress_dialog_with_open_archive (window);
3046
3047 remove_local_directory (window->priv->convert_data.temp_dir);
3048 fr_window_convert_data_free (window, FALSE(0));
3049
3050 fr_window_update_sensitivity (window);
3051 fr_window_update_statusbar_list_info (window);
3052}
3053
3054static void fr_window_exec_next_batch_action (FrWindow *window);
3055
3056static void
3057action_performed (FrArchive *archive,
3058 FrAction action,
3059 FrProcError *error,
3060 gpointer data)
3061{
3062 FrWindow *window = data;
3063 gboolean continue_batch = FALSE(0);
3064 char *archive_dir;
3065 gboolean temp_dir;
3066
3067#ifdef MATE_ENABLE_DEBUG
3068 debug (DEBUG_INFO"fr-window.c", 3068, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action));
3069#endif
3070
3071 fr_window_stop_activity_mode (window);
3072 fr_window_pop_message (window);
3073
3074 continue_batch = handle_errors (window, archive, action, error);
3075
3076 if ((error->type == FR_PROC_ERROR_ASK_PASSWORD)
3077 || (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT)
3078 /*|| (error->type == FR_PROC_ERROR_BAD_CHARSET)*/)
3079 {
3080 return;
3081 }
3082
3083 switch (action) {
3084 case FR_ACTION_CREATING_NEW_ARCHIVE:
3085 case FR_ACTION_CREATING_ARCHIVE:
3086 close_progress_dialog (window, FALSE(0));
3087 if (error->type != FR_PROC_ERROR_STOPPED) {
3088 fr_window_history_clear (window);
3089 fr_window_go_to_location (window, "/", TRUE(!(0)));
3090 fr_window_update_dir_tree (window);
3091 fr_window_update_title (window);
3092 fr_window_update_sensitivity (window);
3093 }
3094 break;
3095
3096 case FR_ACTION_LOADING_ARCHIVE:
3097 close_progress_dialog (window, FALSE(0));
3098 if (error->type != FR_PROC_ERROR_NONE) {
3099 fr_window_remove_from_recent_list (window, window->priv->archive_uri);
3100 if (window->priv->non_interactive) {
3101 fr_window_archive_close (window);
3102 fr_window_stop_batch (window);
3103 }
3104 }
3105 else {
3106 fr_window_add_to_recent_list (window, window->priv->archive_uri);
3107 if (! window->priv->non_interactive)
3108 gtk_window_present (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
3109 }
3110 continue_batch = FALSE(0);
3111 g_signal_emit (window,
3112 fr_window_signals[ARCHIVE_LOADED],
3113 0,
3114 error->type == FR_PROC_ERROR_NONE);
3115 break;
3116
3117 case FR_ACTION_LISTING_CONTENT:
3118 /* update the uri because multi-volume archives can have
3119 * a different name after loading. */
3120 g_free (window->priv->archive_uri);
3121 window->priv->archive_uri = g_file_get_uri (window->archive->file);
3122
3123 close_progress_dialog (window, FALSE(0));
3124 if (error->type != FR_PROC_ERROR_NONE) {
3125 fr_window_remove_from_recent_list (window, window->priv->archive_uri);
3126 fr_window_archive_close (window);
3127 fr_window_set_password (window, NULL((void*)0));
3128 break;
3129 }
3130
3131 archive_dir = remove_level_from_path (window->priv->archive_uri);
3132 temp_dir = is_temp_dir (archive_dir);
3133 if (! window->priv->archive_present) {
3134 window->priv->archive_present = TRUE(!(0));
3135
3136 fr_window_history_clear (window);
3137 fr_window_history_add (window, "/");
3138
3139 if (! temp_dir) {
3140 fr_window_set_open_default_dir (window, archive_dir);
3141 fr_window_set_add_default_dir (window, archive_dir);
3142 if (! window->priv->freeze_default_dir)
3143 fr_window_set_extract_default_dir (window, archive_dir, FALSE(0));
3144 }
3145
3146 window->priv->archive_new = FALSE(0);
3147 }
3148 g_free (archive_dir);
3149
3150 if (! temp_dir)
3151 fr_window_add_to_recent_list (window, window->priv->archive_uri);
3152
3153 fr_window_update_title (window);
3154 fr_window_go_to_location (window, fr_window_get_current_location (window), TRUE(!(0)));
3155 fr_window_update_dir_tree (window);
3156 if (! window->priv->batch_mode && window->priv->non_interactive)
3157 gtk_window_present (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
3158 break;
3159
3160 case FR_ACTION_DELETING_FILES:
3161 close_progress_dialog (window, FALSE(0));
3162 if (error->type != FR_PROC_ERROR_STOPPED)
3163 fr_window_archive_reload (window);
3164 return;
3165
3166 case FR_ACTION_ADDING_FILES:
3167 close_progress_dialog (window, FALSE(0));
3168
3169 /* update the uri because multi-volume archives can have
3170 * a different name after creation. */
3171 g_free (window->priv->archive_uri);
3172 window->priv->archive_uri = g_file_get_uri (window->archive->file);
3173
3174 if (error->type == FR_PROC_ERROR_NONE) {
3175 if (window->priv->archive_new)
3176 window->priv->archive_new = FALSE(0);
3177 fr_window_add_to_recent_list (window, window->priv->archive_uri);
3178 }
3179 if (! window->priv->batch_mode && (error->type != FR_PROC_ERROR_STOPPED)) {
3180 fr_window_archive_reload (window);
3181 return;
3182 }
3183 break;
3184
3185 case FR_ACTION_TESTING_ARCHIVE:
3186 close_progress_dialog (window, FALSE(0));
3187 if (error->type == FR_PROC_ERROR_NONE)
3188 fr_window_view_last_output (window, _("Test Result")gettext ("Test Result"));
3189 return;
3190
3191 case FR_ACTION_EXTRACTING_FILES:
3192 if (error->type != FR_PROC_ERROR_NONE) {
3193 if (window->priv->convert_data.converting) {
3194 remove_local_directory (window->priv->convert_data.temp_dir);
3195 fr_window_convert_data_free (window, TRUE(!(0)));
3196 }
3197 break;
3198 }
3199 if (window->priv->convert_data.converting) {
3200 char *source_dir;
3201
3202 source_dir = g_filename_to_uri (window->priv->convert_data.temp_dir, NULL((void*)0), NULL((void*)0));
3203 fr_archive_add_with_wildcard (
3204 window->priv->convert_data.new_archive,
3205 "*",
3206 NULL((void*)0),
3207 NULL((void*)0),
3208 source_dir,
3209 NULL((void*)0),
3210 FALSE(0),
3211 TRUE(!(0)),
3212 window->priv->convert_data.password,
3213 window->priv->convert_data.encrypt_header,
3214 window->priv->compression,
3215 window->priv->convert_data.volume_size);
3216 g_free (source_dir);
3217 }
3218 else {
3219 if (window->priv->ask_to_open_destination_after_extraction)
3220 open_progress_dialog_with_open_destination (window);
3221 else
3222 close_progress_dialog (window, FALSE(0));
3223 }
3224 break;
3225
3226 default:
3227 close_progress_dialog (window, FALSE(0));
3228 continue_batch = FALSE(0);
3229 break;
3230 }
3231
3232 if (window->priv->batch_action == NULL((void*)0)) {
3233 fr_window_update_sensitivity (window);
3234 fr_window_update_statusbar_list_info (window);
3235 }
3236
3237 if (continue_batch) {
3238 if (error->type != FR_PROC_ERROR_NONE)
3239 fr_window_stop_batch (window);
3240 else
3241 fr_window_exec_next_batch_action (window);
3242 }
3243}
3244
3245/* -- selections -- */
3246
3247#undef DEBUG_GET_DIR_LIST_FROM_PATH
3248
3249static GList *
3250get_dir_list_from_path (FrWindow *window,
3251 char *path)
3252{
3253 char *dirname;
3254 int dirname_l;
3255 GList *list = NULL((void*)0);
3256 guint i;
3257
3258 if (path[strlen (path) - 1] != '/')
3259 dirname = g_strconcat (path, "/", NULL((void*)0));
3260 else
3261 dirname = g_strdup (path)g_strdup_inline (path);
3262 dirname_l = strlen (dirname);
3263 for (i = 0; i < window->archive->command->files->len; i++) {
3264 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
3265 gboolean matches = FALSE(0);
3266
3267#ifdef DEBUG_GET_DIR_LIST_FROM_PATH
3268 g_print ("%s <=> %s (%d)\n", dirname, fd->full_path, dirname_l);
3269#endif
3270
3271 if (fd->dir) {
3272 int full_path_l = strlen (fd->full_path);
3273 if ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l) == 0))
3274 /* example: dirname is '/path/to/dir/' and fd->full_path is '/path/to/dir' */
3275 matches = TRUE(!(0));
3276 else if (strcmp (dirname, fd->full_path) == 0)
3277 matches = TRUE(!(0));
3278 }
3279
3280 if (! matches && strncmp (dirname, fd->full_path, dirname_l) == 0) {
3281 matches = TRUE(!(0));
3282 }
3283
3284 if (matches) {
3285#ifdef DEBUG_GET_DIR_LIST_FROM_PATH
3286 g_print ("`-> OK\n");
3287#endif
3288 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3289 }
3290 }
3291 g_free (dirname);
3292
3293 return g_list_reverse (list);
3294}
3295
3296static GList *
3297get_dir_list_from_file_data (FrWindow *window,
3298 FileData *fdata)
3299{
3300 char *dirname;
3301 GList *list;
3302
3303 dirname = g_strconcat (fr_window_get_current_location (window),
3304 fdata->list_name,
3305 NULL((void*)0));
3306 list = get_dir_list_from_path (window, dirname);
3307 g_free (dirname);
3308
3309 return list;
3310}
3311
3312GList *
3313fr_window_get_file_list_selection (FrWindow *window,
3314 gboolean recursive,
3315 gboolean *has_dirs)
3316{
3317 GtkTreeSelection *selection;
3318 GList *selections = NULL((void*)0), *list, *scan;
3319
3320 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3321
3322 if (has_dirs != NULL((void*)0))
3323 *has_dirs = FALSE(0);
3324
3325 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3326 if (selection == NULL((void*)0))
3327 return NULL((void*)0);
3328 gtk_tree_selection_selected_foreach (selection, add_selected_from_list_view, &selections);
3329
3330 list = NULL((void*)0);
3331 for (scan = selections; scan; scan = scan->next) {
3332 FileData *fd = scan->data;
3333
3334 if (!fd)
3335 continue;
3336
3337 if (file_data_is_dir (fd)) {
3338 if (has_dirs != NULL((void*)0))
3339 *has_dirs = TRUE(!(0));
3340
3341 if (recursive)
3342 list = g_list_concat (list, get_dir_list_from_file_data (window, fd));
3343 }
3344 else
3345 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3346 }
3347 if (selections)
3348 g_list_free (selections);
3349
3350 return g_list_reverse (list);
3351}
3352
3353GList *
3354fr_window_get_folder_tree_selection (FrWindow *window,
3355 gboolean recursive,
3356 gboolean *has_dirs)
3357{
3358 GtkTreeSelection *tree_selection;
3359 GList *selections, *list, *scan;
3360
3361 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3362
3363 if (has_dirs != NULL((void*)0))
3364 *has_dirs = FALSE(0);
3365
3366 tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
3367 if (tree_selection == NULL((void*)0))
3368 return NULL((void*)0);
3369
3370 selections = NULL((void*)0);
3371 gtk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections);
3372 if (selections == NULL((void*)0))
3373 return NULL((void*)0);
3374
3375 if (has_dirs != NULL((void*)0))
3376 *has_dirs = TRUE(!(0));
3377
3378 list = NULL((void*)0);
3379 for (scan = selections; scan; scan = scan->next) {
3380 char *path = scan->data;
3381
3382 if (recursive)
3383 list = g_list_concat (list, get_dir_list_from_path (window, path));
3384 }
3385 path_list_free (selections);
3386
3387 return g_list_reverse (list);
3388}
3389
3390GList *
3391fr_window_get_file_list_from_path_list (FrWindow *window,
3392 GList *path_list,
3393 gboolean *has_dirs)
3394{
3395 GtkTreeModel *model;
3396 GList *selections, *list, *scan;
3397
3398 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3399
3400 model = GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
;
3401 selections = NULL((void*)0);
3402
3403 if (has_dirs != NULL((void*)0))
3404 *has_dirs = FALSE(0);
3405
3406 for (scan = path_list; scan; scan = scan->next) {
3407 GtkTreeRowReference *reference = scan->data;
3408 GtkTreePath *path;
3409 GtkTreeIter iter;
3410 FileData *fdata;
3411
3412 path = gtk_tree_row_reference_get_path (reference);
3413 if (path == NULL((void*)0))
3414 continue;
3415
3416 if (! gtk_tree_model_get_iter (model, &iter, path))
3417 continue;
3418
3419 gtk_tree_model_get (model, &iter,
3420 COLUMN_FILE_DATA, &fdata,
3421 -1);
3422
3423 selections = g_list_prepend (selections, fdata);
3424 }
3425
3426 list = NULL((void*)0);
3427 for (scan = selections; scan; scan = scan->next) {
3428 FileData *fd = scan->data;
3429
3430 if (!fd)
3431 continue;
3432
3433 if (file_data_is_dir (fd)) {
3434 if (has_dirs != NULL((void*)0))
3435 *has_dirs = TRUE(!(0));
3436 list = g_list_concat (list, get_dir_list_from_file_data (window, fd));
3437 }
3438 else
3439 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3440 }
3441
3442 if (selections != NULL((void*)0))
3443 g_list_free (selections);
3444
3445 return g_list_reverse (list);
3446}
3447
3448GList *
3449fr_window_get_file_list_pattern (FrWindow *window,
3450 const char *pattern)
3451{
3452 GRegex **regexps;
3453 GList *list;
3454 guint i;
3455
3456 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3457
3458 regexps = search_util_get_regexps (pattern, G_REGEX_CASELESS);
3459 list = NULL((void*)0);
3460 for (i = 0; i < window->archive->command->files->len; i++) {
3461 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
3462 char *utf8_name;
3463
3464 /* FIXME: only files in the current location ? */
3465
3466 if (fd == NULL((void*)0))
3467 continue;
3468
3469 utf8_name = g_filename_to_utf8 (fd->name, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
3470 if (match_regexps (regexps, utf8_name, 0))
3471 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3472 g_free (utf8_name);
3473 }
3474 free_regexps (regexps);
3475
3476 return g_list_reverse (list);
3477}
3478
3479static GList *
3480fr_window_get_file_list (FrWindow *window)
3481{
3482 GList *list;
3483 guint i;
3484
3485 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3486
3487 list = NULL((void*)0);
3488 for (i = 0; i < window->archive->command->files->len; i++) {
3489 FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
3490 list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path));
3491 }
3492
3493 return g_list_reverse (list);
3494}
3495
3496int
3497fr_window_get_n_selected_files (FrWindow *window)
3498{
3499 return gtk_tree_selection_count_selected_rows (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
));
3500}
3501
3502/**/
3503
3504static int
3505dir_tree_button_press_cb (GtkWidget *widget,
3506 GdkEventButton *event,
3507 gpointer data)
3508{
3509 FrWindow *window = data;
3510 GtkTreeSelection *selection;
3511
3512 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
))
3513 return FALSE(0);
3514
3515 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
3516 if (selection == NULL((void*)0))
3517 return FALSE(0);
3518
3519 if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
3520 GtkTreePath *path;
3521 GtkTreeIter iter;
3522
3523 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
,
3524 (int) event->x, (int) event->y,
3525 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3526
3527 if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
, &iter, path)) {
3528 gtk_tree_path_free (path);
3529 return FALSE(0);
3530 }
3531 gtk_tree_path_free (path);
3532
3533 if (! gtk_tree_selection_iter_is_selected (selection, &iter)) {
3534 gtk_tree_selection_unselect_all (selection);
3535 gtk_tree_selection_select_iter (selection, &iter);
3536 }
3537
3538 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->sidebar_folder_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->sidebar_folder_popup_menu)), ((gtk_menu_get_type
()))))))
,
3539 (const GdkEvent*) event);
3540 }
3541 else
3542 gtk_tree_selection_unselect_all (selection);
3543
3544 return TRUE(!(0));
3545 }
3546 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 8)) {
3547 fr_window_go_back (window);
3548 return TRUE(!(0));
3549 }
3550 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 9)) {
3551 fr_window_go_forward (window);
3552 return TRUE(!(0));
3553 }
3554
3555 return FALSE(0);
3556}
3557
3558static FileData *
3559fr_window_get_selected_item_from_file_list (FrWindow *window)
3560{
3561 GtkTreeSelection *tree_selection;
3562 GList *selection;
3563 FileData *fdata = NULL((void*)0);
3564
3565 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3566
3567 tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3568 if (tree_selection == NULL((void*)0))
3569 return NULL((void*)0);
3570
3571 selection = NULL((void*)0);
3572 gtk_tree_selection_selected_foreach (tree_selection, add_selected_from_list_view, &selection);
3573 if ((selection == NULL((void*)0)) || (selection->next != NULL((void*)0))) {
3574 /* return NULL if the selection contains more than one entry. */
3575 g_list_free (selection);
3576 return NULL((void*)0);
3577 }
3578
3579 fdata = file_data_copy (selection->data);
3580 g_list_free (selection);
3581
3582 return fdata;
3583}
3584
3585static char *
3586fr_window_get_selected_folder_in_tree_view (FrWindow *window)
3587{
3588 GtkTreeSelection *tree_selection;
3589 GList *selections;
3590 char *path = NULL((void*)0);
3591
3592 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
3593
3594 tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
3595 if (tree_selection == NULL((void*)0))
3596 return NULL((void*)0);
3597
3598 selections = NULL((void*)0);
3599 gtk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections);
3600
3601 if (selections != NULL((void*)0)) {
3602 path = selections->data;
3603 g_list_free (selections);
3604 }
3605
3606 return path;
3607}
3608
3609void
3610fr_window_current_folder_activated (FrWindow *window,
3611 gboolean from_sidebar)
3612{
3613 char *dir_path;
3614
3615 if (! from_sidebar) {
3616 FileData *fdata;
3617 char *dir_name;
3618
3619 fdata = fr_window_get_selected_item_from_file_list (window);
3620 if ((fdata == NULL((void*)0)) || ! file_data_is_dir (fdata)) {
3621 file_data_free (fdata);
3622 return;
3623 }
3624 dir_name = g_strdup (fdata->list_name)g_strdup_inline (fdata->list_name);
3625 dir_path = g_strconcat (fr_window_get_current_location (window),
3626 dir_name,
3627 "/",
3628 NULL((void*)0));
3629 g_free (dir_name);
3630 file_data_free (fdata);
3631 }
3632 else
3633 dir_path = fr_window_get_selected_folder_in_tree_view (window);
3634
3635 fr_window_go_to_location (window, dir_path, FALSE(0));
3636
3637 g_free (dir_path);
3638}
3639
3640static gboolean
3641row_activated_cb (GtkTreeView *tree_view,
3642 GtkTreePath *path,
3643 GtkTreeViewColumn *column,
3644 gpointer data)
3645{
3646 FrWindow *window = data;
3647 FileData *fdata;
3648 GtkTreeIter iter;
3649
3650 if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3651 &iter,
3652 path))
3653 return FALSE(0);
3654
3655 gtk_tree_model_get (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
, &iter,
3656 COLUMN_FILE_DATA, &fdata,
3657 -1);
3658
3659 if (! file_data_is_dir (fdata)) {
3660 GList *list = g_list_prepend (NULL((void*)0), fdata->original_path);
3661 fr_window_open_files (window, list, FALSE(0));
3662 g_list_free (list);
3663 }
3664 else if (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR) {
3665 char *new_dir;
3666 new_dir = g_strconcat (fr_window_get_current_location (window),
3667 fdata->list_name,
3668 "/",
3669 NULL((void*)0));
3670 fr_window_go_to_location (window, new_dir, FALSE(0));
3671 g_free (new_dir);
3672 }
3673
3674 return FALSE(0);
3675}
3676
3677static int
3678file_button_press_cb (GtkWidget *widget,
3679 GdkEventButton *event,
3680 gpointer data)
3681{
3682 FrWindow *window = data;
3683 GtkTreeSelection *selection;
3684
3685 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
))
3686 return FALSE(0);
3687
3688 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3689 if (selection == NULL((void*)0))
3690 return FALSE(0);
3691
3692 if (window->priv->path_clicked != NULL((void*)0)) {
3693 gtk_tree_path_free (window->priv->path_clicked);
3694 window->priv->path_clicked = NULL((void*)0);
3695 }
3696
3697 if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
3698 GtkTreePath *path;
3699 GtkTreeIter iter;
3700 int n_selected;
3701
3702 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
3703 (int) event->x, (int) event->y,
3704 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3705
3706 if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
, &iter, path)) {
3707 gtk_tree_path_free (path);
3708 return FALSE(0);
3709 }
3710 gtk_tree_path_free (path);
3711
3712 if (! gtk_tree_selection_iter_is_selected (selection, &iter)) {
3713 gtk_tree_selection_unselect_all (selection);
3714 gtk_tree_selection_select_iter (selection, &iter);
3715 }
3716 }
3717 else
3718 gtk_tree_selection_unselect_all (selection);
3719
3720 n_selected = fr_window_get_n_selected_files (window);
3721 if ((n_selected == 1) && selection_has_a_dir (window))
3722 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->folder_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->folder_popup_menu)), ((gtk_menu_get_type
()))))))
,
3723 (const GdkEvent*) event);
3724 else
3725 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->file_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->file_popup_menu)), ((gtk_menu_get_type
()))))))
,
3726 (const GdkEvent*) event);
3727 return TRUE(!(0));
3728 }
3729 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 1)) {
3730 GtkTreePath *path = NULL((void*)0);
3731
3732 if (! gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
3733 (int) event->x, (int) event->y,
3734 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3735 gtk_tree_selection_unselect_all (selection);
3736 }
3737
3738 if (window->priv->path_clicked != NULL((void*)0)) {
3739 gtk_tree_path_free (window->priv->path_clicked);
3740 window->priv->path_clicked = NULL((void*)0);
3741 }
3742
3743 if (path != NULL((void*)0)) {
3744 window->priv->path_clicked = gtk_tree_path_copy (path);
3745 gtk_tree_path_free (path);
3746 }
3747
3748 return FALSE(0);
3749 }
3750 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 8)) {
3751 // go back
3752 fr_window_go_back (window);
3753 return TRUE(!(0));
3754 }
3755 else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 9)) {
3756 // go forward
3757 fr_window_go_forward (window);
3758 return TRUE(!(0));
3759 }
3760
3761 return FALSE(0);
3762}
3763
3764static int
3765file_button_release_cb (GtkWidget *widget,
3766 GdkEventButton *event,
3767 gpointer data)
3768{
3769 FrWindow *window = data;
3770 GtkTreeSelection *selection;
3771
3772 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
))
3773 return FALSE(0);
3774
3775 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
3776 if (selection == NULL((void*)0))
3777 return FALSE(0);
3778
3779 if (window->priv->path_clicked == NULL((void*)0))
3780 return FALSE(0);
3781
3782 if ((event->type == GDK_BUTTON_RELEASE)
3783 && (event->button == 1)
3784 && (window->priv->path_clicked != NULL((void*)0))) {
3785 GtkTreePath *path = NULL((void*)0);
3786
3787 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
3788 (int) event->x, (int) event->y,
3789 &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) {
3790
3791 if ((gtk_tree_path_compare (window->priv->path_clicked, path) == 0)
3792 && window->priv->single_click
3793 && ! ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_SHIFT_MASK))) {
3794 gtk_tree_view_set_cursor (GTK_TREE_VIEW (widget)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_tree_view_get_type ()))))))
,
3795 path,
3796 NULL((void*)0),
3797 FALSE(0));
3798 gtk_tree_view_row_activated (GTK_TREE_VIEW (widget)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_tree_view_get_type ()))))))
,
3799 path,
3800 NULL((void*)0));
3801 }
3802 }
3803
3804 if (path != NULL((void*)0))
3805 gtk_tree_path_free (path);
3806 }
3807
3808 if (window->priv->path_clicked != NULL((void*)0)) {
3809 gtk_tree_path_free (window->priv->path_clicked);
3810 window->priv->path_clicked = NULL((void*)0);
3811 }
3812
3813 return FALSE(0);
3814}
3815
3816static gboolean
3817file_motion_notify_callback (GtkWidget *widget,
3818 GdkEventMotion *event,
3819 gpointer user_data)
3820{
3821 FrWindow *window = user_data;
3822 GdkCursor *cursor;
3823 GtkTreePath *last_hover_path;
3824 GdkDisplay *display;
3825 GtkTreeIter iter;
3826
3827 if (! window->priv->single_click)
3828 return FALSE(0);
3829
3830 if (event->window != gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
))
3831 return FALSE(0);
3832
3833 last_hover_path = window->priv->list_hover_path;
3834
3835 gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_tree_view_get_type ()))))))
,
3836 (int) event->x, (int) event->y,
3837 &window->priv->list_hover_path,
3838 NULL((void*)0), NULL((void*)0), NULL((void*)0));
3839
3840 display = gtk_widget_get_display (GTK_WIDGET (widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_widget_get_type ()))))))
);
3841
3842 if (window->priv->list_hover_path != NULL((void*)0))
3843 cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
3844 else
3845 cursor = NULL((void*)0);
3846
3847 gdk_window_set_cursor (event->window, cursor);
3848
3849 /* only redraw if the hover row has changed */
3850 if (!(last_hover_path == NULL((void*)0) && window->priv->list_hover_path == NULL((void*)0)) &&
3851 (!(last_hover_path != NULL((void*)0) && window->priv->list_hover_path != NULL((void*)0)) ||
3852 gtk_tree_path_compare (last_hover_path, window->priv->list_hover_path)))
3853 {
3854 if (last_hover_path) {
3855 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3856 &iter, last_hover_path);
3857 gtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3858 last_hover_path, &iter);
3859 }
3860
3861 if (window->priv->list_hover_path) {
3862 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3863 &iter, window->priv->list_hover_path);
3864 gtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3865 window->priv->list_hover_path, &iter);
3866 }
3867 }
3868
3869 gtk_tree_path_free (last_hover_path);
3870
3871 return FALSE(0);
3872}
3873
3874static gboolean
3875file_leave_notify_callback (GtkWidget *widget,
3876 GdkEventCrossing *event,
3877 gpointer user_data)
3878{
3879 FrWindow *window = user_data;
3880 GtkTreeIter iter;
3881
3882 if (window->priv->single_click && (window->priv->list_hover_path != NULL((void*)0))) {
3883 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3884 &iter,
3885 window->priv->list_hover_path);
3886 gtk_tree_model_row_changed (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
,
3887 window->priv->list_hover_path,
3888 &iter);
3889
3890 gtk_tree_path_free (window->priv->list_hover_path);
3891 window->priv->list_hover_path = NULL((void*)0);
3892 }
3893
3894 return FALSE(0);
3895}
3896
3897/* -- drag and drop -- */
3898
3899static GList *
3900get_uri_list_from_selection_data (char *uri_list)
3901{
3902 GList *list = NULL((void*)0);
3903 char **uris;
3904 int i;
3905
3906 if (uri_list == NULL((void*)0))
3907 return NULL((void*)0);
3908
3909 uris = g_uri_list_extract_uris (uri_list);
3910 for (i = 0; uris[i] != NULL((void*)0); i++)
3911 list = g_list_prepend (list, g_strdup (uris[i])g_strdup_inline (uris[i]));
3912 g_strfreev (uris);
3913
3914 return g_list_reverse (list);
3915}
3916
3917static gboolean
3918fr_window_drag_motion (GtkWidget *widget,
3919 GdkDragContext *context,
3920 gint x,
3921 gint y,
3922 guint time,
3923 gpointer user_data)
3924{
3925 FrWindow *window = user_data;
3926
3927 if ((gtk_drag_get_source_widget (context) == window->priv->list_view)
3928 || (gtk_drag_get_source_widget (context) == window->priv->tree_view))
3929 {
3930 gdk_drag_status (context, 0, time);
3931 return FALSE(0);
3932 }
3933
3934 return TRUE(!(0));
3935}
3936
3937static void fr_window_paste_from_clipboard_data (FrWindow *window, FrClipboardData *data);
3938
3939static FrClipboardData*
3940get_clipboard_data_from_selection_data (FrWindow *window,
3941 const char *data)
3942{
3943 FrClipboardData *clipboard_data;
3944 char **uris;
3945 int i;
3946
3947 clipboard_data = fr_clipboard_data_new ();
3948
3949 uris = g_strsplit (data, "\r\n", -1);
3950
3951 clipboard_data->archive_filename = g_strdup (uris[0])g_strdup_inline (uris[0]);
3952 if (window->priv->password_for_paste != NULL((void*)0))
3953 clipboard_data->archive_password = g_strdup (window->priv->password_for_paste)g_strdup_inline (window->priv->password_for_paste);
3954 else if (strcmp (uris[1], "") != 0)
3955 clipboard_data->archive_password = g_strdup (uris[1])g_strdup_inline (uris[1]);
3956 clipboard_data->op = (strcmp (uris[2], "copy") == 0) ? FR_CLIPBOARD_OP_COPY : FR_CLIPBOARD_OP_CUT;
3957 clipboard_data->base_dir = g_strdup (uris[3])g_strdup_inline (uris[3]);
3958 for (i = 4; uris[i] != NULL((void*)0); i++)
3959 if (uris[i][0] != '\0')
3960 clipboard_data->files = g_list_prepend (clipboard_data->files, g_strdup (uris[i])g_strdup_inline (uris[i]));
3961 clipboard_data->files = g_list_reverse (clipboard_data->files);
3962
3963 g_strfreev (uris);
3964
3965 return clipboard_data;
3966}
3967
3968static void
3969fr_window_drag_data_received (GtkWidget *widget,
3970 GdkDragContext *context,
3971 gint x,
3972 gint y,
3973 GtkSelectionData *data,
3974 guint info,
3975 guint time,
3976 gpointer extra_data)
3977{
3978 FrWindow *window = extra_data;
3979 GList *list;
3980 gboolean one_file;
3981 gboolean is_an_archive;
3982
3983 debug (DEBUG_INFO"fr-window.c", 3983, __FUNCTION__, "::DragDataReceived -->\n");
3984
3985 if ((gtk_drag_get_source_widget (context) == window->priv->list_view)
3986 || (gtk_drag_get_source_widget (context) == window->priv->tree_view))
3987 {
3988 gtk_drag_finish (context, FALSE(0), FALSE(0), time);
3989 return;
3990 }
3991
3992 if (! ((gtk_selection_data_get_length (data) >= 0) && (gtk_selection_data_get_format (data) == 8))) {
3993 gtk_drag_finish (context, FALSE(0), FALSE(0), time);
3994 return;
3995 }
3996
3997 if (window->priv->activity_ref > 0) {
3998 gtk_drag_finish (context, FALSE(0), FALSE(0), time);
3999 return;
4000 }
4001
4002 gtk_drag_finish (context, TRUE(!(0)), FALSE(0), time);
4003
4004 if (gtk_selection_data_get_target (data) == XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0))) {
4005 FrClipboardData *dnd_data;
4006
4007 dnd_data = get_clipboard_data_from_selection_data (window, (char*) gtk_selection_data_get_data (data));
4008 dnd_data->current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4009 fr_window_paste_from_clipboard_data (window, dnd_data);
4010
4011 return;
4012 }
4013
4014 list = get_uri_list_from_selection_data ((char*) gtk_selection_data_get_data (data));
4015 if (list == NULL((void*)0)) {
4016 GtkWidget *d;
4017
4018 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4019 GTK_DIALOG_MODAL,
4020 NULL((void*)0),
4021 _("Could not perform the operation")gettext ("Could not perform the operation"),
4022 NULL((void*)0));
4023 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
4024 gtk_widget_destroy(d);
4025
4026 return;
4027 }
4028
4029 one_file = (list->next == NULL((void*)0));
4030 if (one_file)
4031 is_an_archive = uri_is_archive (list->data);
4032 else
4033 is_an_archive = FALSE(0);
4034
4035 if (window->priv->archive_present
4036 && (window->archive != NULL((void*)0))
4037 && ! window->archive->read_only
4038 && ! window->archive->is_compressed_file)
4039 {
4040 if (one_file && is_an_archive) {
4041 GtkWidget *d;
4042 gint r;
4043
4044 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4045 GTK_DIALOG_MODAL,
4046 "dialog-question",
4047 _("Do you want to add this file to the current archive or open it as a new archive?")gettext ("Do you want to add this file to the current archive or open it as a new archive?"
)
,
4048 NULL((void*)0),
4049 "gtk-cancel", GTK_RESPONSE_CANCEL,
4050 "gtk-add", 0,
4051 "gtk-open", 1,
4052 NULL((void*)0));
4053
4054 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, 2);
4055
4056 r = gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
4057 gtk_widget_destroy (GTK_WIDGET (d)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_widget_get_type ()))))))
);
4058
4059 if (r == 0) /* Add */
4060 fr_window_archive_add_dropped_items (window, list, FALSE(0));
4061 else if (r == 1) /* Open */
4062 fr_window_archive_open (window, list->data, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
4063 }
4064 else
4065 fr_window_archive_add_dropped_items (window, list, FALSE(0));
4066 }
4067 else {
4068 if (one_file && is_an_archive)
4069 fr_window_archive_open (window, list->data, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
4070 else {
4071 GtkWidget *d;
4072 int r;
4073
4074 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4075 GTK_DIALOG_MODAL,
4076 "dialog-question",
4077 _("Do you want to create a new archive with these files?")gettext ("Do you want to create a new archive with these files?"
)
,
4078 NULL((void*)0),
4079 "gtk-cancel", GTK_RESPONSE_CANCEL,
4080 _("Create _Archive")gettext ("Create _Archive"), GTK_RESPONSE_YES,
4081 NULL((void*)0));
4082
4083 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_YES);
4084 r = gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
4085 gtk_widget_destroy (GTK_WIDGET (d)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_widget_get_type ()))))))
);
4086
4087 if (r == GTK_RESPONSE_YES) {
4088 char *first_item;
4089 char *folder;
4090 char *local_path = NULL((void*)0);
4091 char *utf8_path = NULL((void*)0);
4092 const char *archive_name;
4093
4094 fr_window_free_batch_data (window);
4095 fr_window_append_batch_action (window,
4096 FR_BATCH_ACTION_ADD,
4097 path_list_dup (list),
4098 (GFreeFunc) path_list_free);
4099
4100 first_item = (char*) list->data;
4101 folder = remove_level_from_path (first_item);
4102 if (folder != NULL((void*)0))
4103 fr_window_set_open_default_dir (window, folder);
4104
4105 if ((list->next != NULL((void*)0)) && (folder != NULL((void*)0))) {
4106 archive_name = file_name_from_path (folder);
4107 }
4108 else {
4109 if (uri_is_local (first_item)) {
4110 local_path = g_filename_from_uri (first_item, NULL((void*)0), NULL((void*)0));
4111 if (local_path)
4112 utf8_path = g_filename_to_utf8 (local_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
4113 if (!utf8_path)
4114 utf8_path= g_strdup (first_item)g_strdup_inline (first_item);
4115 g_free (local_path);
4116 }
4117 else {
4118 utf8_path = g_strdup (first_item)g_strdup_inline (first_item);
4119 }
4120 archive_name = file_name_from_path (utf8_path);
4121 }
4122
4123 show_new_archive_dialog (window, archive_name);
4124 g_free (utf8_path);
4125
4126 g_free (folder);
4127 }
4128 }
4129 }
4130
4131 path_list_free (list);
4132
4133 debug (DEBUG_INFO"fr-window.c", 4133, __FUNCTION__, "::DragDataReceived <--\n");
4134}
4135
4136static gboolean
4137file_list_drag_begin (GtkWidget *widget,
4138 GdkDragContext *context,
4139 gpointer data)
4140{
4141 FrWindow *window = data;
4142
4143 debug (DEBUG_INFO"fr-window.c", 4143, __FUNCTION__, "::DragBegin -->\n");
4144
4145 if (window->priv->activity_ref > 0)
4146 return FALSE(0);
4147
4148 g_free (window->priv->drag_destination_folder);
4149 window->priv->drag_destination_folder = NULL((void*)0);
4150
4151 g_free (window->priv->drag_base_dir);
4152 window->priv->drag_base_dir = NULL((void*)0);
4153
4154 gdk_property_change (gdk_drag_context_get_source_window (context),
4155 XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMgdk_atom_intern ("text/plain", (0)),
4156 8, GDK_PROP_MODE_REPLACE,
4157 (guchar *) XDS_FILENAME"xds.txt",
4158 strlen (XDS_FILENAME"xds.txt"));
4159
4160 return TRUE(!(0));
4161}
4162
4163static void
4164file_list_drag_end (GtkWidget *widget,
4165 GdkDragContext *context,
4166 gpointer data)
4167{
4168 FrWindow *window = data;
4169
4170 debug (DEBUG_INFO"fr-window.c", 4170, __FUNCTION__, "::DragEnd -->\n");
4171
4172 gdk_property_delete (gdk_drag_context_get_source_window (context), XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)));
4173
4174 if (window->priv->drag_error != NULL((void*)0)) {
4175 _gtk_error_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4176 _("Extraction not performed")gettext ("Extraction not performed"),
4177 "%s",
4178 window->priv->drag_error->message);
4179 g_clear_error (&window->priv->drag_error);
4180 }
4181 else if (window->priv->drag_destination_folder != NULL((void*)0)) {
4182 fr_window_archive_extract (window,
4183 window->priv->drag_file_list,
4184 window->priv->drag_destination_folder,
4185 NULL((void*)0),
4186 window->priv->drag_base_dir,
4187 FALSE(0),
4188 FR_OVERWRITE_ASK,
4189 FALSE(0),
4190 FALSE(0));
4191 path_list_free (window->priv->drag_file_list);
4192 window->priv->drag_file_list = NULL((void*)0);
4193 }
4194
4195 debug (DEBUG_INFO"fr-window.c", 4195, __FUNCTION__, "::DragEnd <--\n");
4196}
4197
4198/* The following three functions taken from bugzilla
4199 * (http://bugzilla.mate.org/attachment.cgi?id=49362&action=view)
4200 * Author: Christian Neumair
4201 * Copyright: 2005 Free Software Foundation, Inc
4202 * License: GPL */
4203static char *
4204get_xds_atom_value (GdkDragContext *context)
4205{
4206 gint actual_length;
4207 char *data;
4208 char *ret = NULL((void*)0);
4209
4210 g_return_val_if_fail (context != NULL, NULL)do { if ((context != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "context != NULL"
); return (((void*)0)); } } while (0)
;
4211 g_return_val_if_fail (gdk_drag_context_get_source_window (context) != NULL, NULL)do { if ((gdk_drag_context_get_source_window (context) != ((void
*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "gdk_drag_context_get_source_window (context) != NULL"
); return (((void*)0)); } } while (0)
;
4212
4213 if (gdk_property_get (gdk_drag_context_get_source_window (context),
4214 XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMgdk_atom_intern ("text/plain", (0)),
4215 0, MAX_XDS_ATOM_VAL_LEN4096,
4216 FALSE(0), NULL((void*)0), NULL((void*)0), &actual_length,
4217 (unsigned char **) &data)) {
4218 /* add not included \0 to the end of the string */
4219 ret = g_strndup ((gchar *) data, actual_length);
4220 g_free (data);
4221 }
4222
4223 return ret;
4224}
4225
4226static gboolean
4227context_offers_target (GdkDragContext *context,
4228 GdkAtom target)
4229{
4230 return (g_list_find (gdk_drag_context_list_targets (context), target) != NULL((void*)0));
4231}
4232
4233static gboolean
4234caja_xds_dnd_is_valid_xds_context (GdkDragContext *context)
4235{
4236 char *tmp;
4237 gboolean ret;
4238
4239 g_return_val_if_fail (context != NULL, FALSE)do { if ((context != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "context != NULL"
); return ((0)); } } while (0)
;
4240
4241 tmp = NULL((void*)0);
4242 if (context_offers_target (context, XDS_ATOMgdk_atom_intern ("XdndDirectSave0", (0)))) {
4243 tmp = get_xds_atom_value (context);
4244 }
4245
4246 ret = (tmp != NULL((void*)0));
4247 g_free (tmp);
4248
4249 return ret;
4250}
4251
4252static char *
4253get_selection_data_from_clipboard_data (FrWindow *window,
4254 FrClipboardData *data)
4255{
4256 GString *list;
4257 char *local_filename;
4258 GList *scan;
4259
4260 list = g_string_new (NULL((void*)0));
4261
4262 local_filename = g_file_get_uri (window->archive->local_copy);
4263 g_string_append (list, local_filename)(__builtin_constant_p (local_filename) ? __extension__ ({ const
char * const __val = (local_filename); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, local_filename, (gssize) -1))
;
4264 g_free (local_filename);
4265
4266 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4267 if (window->priv->password != NULL((void*)0))
4268 g_string_append (list, window->priv->password)(__builtin_constant_p (window->priv->password) ? __extension__
({ const char * const __val = (window->priv->password)
; g_string_append_len_inline (list, __val, (__val != ((void*)
0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize) -1); }
) : g_string_append_len_inline (list, window->priv->password
, (gssize) -1))
;
4269 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4270 g_string_append (list, (data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut")(__builtin_constant_p ((data->op == FR_CLIPBOARD_OP_COPY) ?
"copy" : "cut") ? __extension__ ({ const char * const __val =
((data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut"); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, (data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut"
, (gssize) -1))
;
4271 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4272 g_string_append (list, data->base_dir)(__builtin_constant_p (data->base_dir) ? __extension__ ({ const
char * const __val = (data->base_dir); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, data->base_dir, (gssize) -1))
;
4273 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4274 for (scan = data->files; scan; scan = scan->next) {
4275 g_string_append (list, scan->data)(__builtin_constant_p (scan->data) ? __extension__ ({ const
char * const __val = (scan->data); g_string_append_len_inline
(list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val
) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(list, scan->data, (gssize) -1))
;
4276 g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char *
const __val = ("\r\n"); g_string_append_len_inline (list, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n"
, (gssize) -1))
;
4277 }
4278
4279 return g_string_free (list, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((list
), ((0))) : g_string_free_and_steal (list)) : (g_string_free)
((list), ((0))))
;
4280}
4281
4282static gboolean
4283fr_window_folder_tree_drag_data_get (GtkWidget *widget,
4284 GdkDragContext *context,
4285 GtkSelectionData *selection_data,
4286 guint info,
4287 guint time,
4288 gpointer user_data)
4289{
4290 FrWindow *window = user_data;
4291 GList *file_list;
4292 char *destination;
4293 char *destination_folder;
4294
4295 debug (DEBUG_INFO"fr-window.c", 4295, __FUNCTION__, "::DragDataGet -->\n");
4296
4297 if (window->priv->activity_ref > 0)
4298 return FALSE(0);
4299
4300 file_list = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0));
4301 if (file_list == NULL((void*)0))
4302 return FALSE(0);
4303
4304 if (gtk_selection_data_get_target (selection_data) == XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0))) {
4305 FrClipboardData *tmp;
4306 char *data;
4307
4308 tmp = fr_clipboard_data_new ();
4309 tmp->files = file_list;
4310 tmp->op = FR_CLIPBOARD_OP_COPY;
4311 tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4312
4313 data = get_selection_data_from_clipboard_data (window, tmp);
4314 gtk_selection_data_set (selection_data, XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0)), 8, (guchar *) data, strlen (data));
4315
4316 fr_clipboard_data_unref (tmp);
4317 g_free (data);
4318
4319 return TRUE(!(0));
4320 }
4321
4322 if (! caja_xds_dnd_is_valid_xds_context (context))
4323 return FALSE(0);
4324
4325 destination = get_xds_atom_value (context);
4326 g_return_val_if_fail (destination != NULL, FALSE)do { if ((destination != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "destination != NULL"
); return ((0)); } } while (0)
;
4327
4328 destination_folder = remove_level_from_path (destination);
4329 g_free (destination);
4330
4331 /* check whether the extraction can be performed in the destination
4332 * folder */
4333
4334 g_clear_error (&window->priv->drag_error);
4335
4336 if (! check_permissions (destination_folder, R_OK4 | W_OK2)) {
4337 char *destination_folder_display_name;
4338
4339 destination_folder_display_name = g_filename_display_name (destination_folder);
4340 window->priv->drag_error = g_error_new (FR_ERRORfr_error_quark (), 0, _("You don't have the right permissions to extract archives in the folder \"%s\"")gettext ("You don't have the right permissions to extract archives in the folder \"%s\""
)
, destination_folder_display_name);
4341 g_free (destination_folder_display_name);
4342 }
4343
4344 if (window->priv->drag_error == NULL((void*)0)) {
4345 g_free (window->priv->drag_destination_folder);
4346 g_free (window->priv->drag_base_dir);
4347 path_list_free (window->priv->drag_file_list);
4348 window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder);
4349 window->priv->drag_base_dir = fr_window_get_selected_folder_in_tree_view (window);
4350 window->priv->drag_file_list = file_list;
4351 }
4352
4353 g_free (destination_folder);
4354
4355 /* sends back the response */
4356
4357 gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL((void*)0)) ? "S" : "E"), 1);
4358
4359 debug (DEBUG_INFO"fr-window.c", 4359, __FUNCTION__, "::DragDataGet <--\n");
4360
4361 return TRUE(!(0));
4362}
4363
4364gboolean
4365fr_window_file_list_drag_data_get (FrWindow *window,
4366 GdkDragContext *context,
4367 GtkSelectionData *selection_data,
4368 GList *path_list)
4369{
4370 char *destination;
4371 char *destination_folder;
4372
4373 debug (DEBUG_INFO"fr-window.c", 4373, __FUNCTION__, "::DragDataGet -->\n");
4374
4375 if (window->priv->path_clicked != NULL((void*)0)) {
4376 gtk_tree_path_free (window->priv->path_clicked);
4377 window->priv->path_clicked = NULL((void*)0);
4378 }
4379
4380 if (window->priv->activity_ref > 0)
4381 return FALSE(0);
4382
4383 if (gtk_selection_data_get_target (selection_data) == XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0))) {
4384 FrClipboardData *tmp;
4385 char *data;
4386
4387 tmp = fr_clipboard_data_new ();
4388 tmp->files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0));
4389 tmp->op = FR_CLIPBOARD_OP_COPY;
4390 tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4391
4392 data = get_selection_data_from_clipboard_data (window, tmp);
4393 gtk_selection_data_set (selection_data, XFR_ATOMgdk_atom_intern ("XdndEngrampa0", (0)), 8, (guchar *) data, strlen (data));
4394
4395 fr_clipboard_data_unref (tmp);
4396 g_free (data);
4397
4398 return TRUE(!(0));
4399 }
4400
4401 if (! caja_xds_dnd_is_valid_xds_context (context))
4402 return FALSE(0);
4403
4404 destination = get_xds_atom_value (context);
4405 g_return_val_if_fail (destination != NULL, FALSE)do { if ((destination != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "destination != NULL"
); return ((0)); } } while (0)
;
4406
4407 destination_folder = remove_level_from_path (destination);
4408 g_free (destination);
4409
4410 /* check whether the extraction can be performed in the destination
4411 * folder */
4412
4413 g_clear_error (&window->priv->drag_error);
4414
4415 if (! check_permissions (destination_folder, R_OK4 | W_OK2)) {
4416 char *destination_folder_display_name;
4417
4418 destination_folder_display_name = g_filename_display_name (destination_folder);
4419 window->priv->drag_error = g_error_new (FR_ERRORfr_error_quark (), 0, _("You don't have the right permissions to extract archives in the folder \"%s\"")gettext ("You don't have the right permissions to extract archives in the folder \"%s\""
)
, destination_folder_display_name);
4420 g_free (destination_folder_display_name);
4421 }
4422
4423 if (window->priv->drag_error == NULL((void*)0)) {
4424 g_free (window->priv->drag_destination_folder);
4425 g_free (window->priv->drag_base_dir);
4426 path_list_free (window->priv->drag_file_list);
4427 window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder);
4428 window->priv->drag_base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
4429 window->priv->drag_file_list = fr_window_get_file_list_from_path_list (window, path_list, NULL((void*)0));
4430 }
4431
4432 g_free (destination_folder);
4433
4434 /* sends back the response */
4435
4436 gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL((void*)0)) ? "S" : "E"), 1);
4437
4438 debug (DEBUG_INFO"fr-window.c", 4438, __FUNCTION__, "::DragDataGet <--\n");
4439
4440 return TRUE(!(0));
4441}
4442
4443/* -- window_new -- */
4444
4445static void
4446fr_window_deactivate_filter (FrWindow *window)
4447{
4448 window->priv->filter_mode = FALSE(0);
4449 window->priv->list_mode = window->priv->last_list_mode;
4450
4451 gtk_entry_set_text (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
, "");
4452 fr_window_update_filter_bar_visibility (window);
4453
4454 gtk_list_store_clear (window->priv->list_store);
4455
4456 fr_window_update_columns_visibility (window);
4457 fr_window_update_file_list (window, TRUE(!(0)));
4458 fr_window_update_dir_tree (window);
4459 fr_window_update_current_location (window);
4460}
4461
4462static gboolean
4463key_press_cb (GtkWidget *widget,
4464 GdkEventKey *event,
4465 gpointer data)
4466{
4467 FrWindow *window = data;
4468 gboolean retval = FALSE(0);
4469 gboolean alt;
4470
4471 if (gtk_widget_has_focus (window->priv->location_entry))
4472 return FALSE(0);
4473
4474 if (gtk_widget_has_focus (window->priv->filter_entry)) {
4475 switch (event->keyval) {
4476 case GDK_KEY_Escape0xff1b:
4477 fr_window_deactivate_filter (window);
4478 retval = TRUE(!(0));
4479 break;
4480 default:
4481 break;
4482 }
4483 return retval;
4484 }
4485
4486 alt = (event->state & GDK_MOD1_MASK) == GDK_MOD1_MASK;
4487
4488 switch (event->keyval) {
4489 case GDK_KEY_Escape0xff1b:
4490 activate_action_stop (NULL((void*)0), NULL((void*)0), window);
4491 if (window->priv->filter_mode)
4492 fr_window_deactivate_filter (window);
4493 retval = TRUE(!(0));
4494 break;
4495
4496 case GDK_KEY_F100xffc7:
4497 if (event->state & GDK_SHIFT_MASK) {
4498 GtkTreeSelection *selection;
4499
4500 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
4501 if (selection == NULL((void*)0))
4502 return FALSE(0);
4503
4504 gtk_menu_popup_at_pointer (GTK_MENU (window->priv->file_popup_menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->file_popup_menu)), ((gtk_menu_get_type
()))))))
,
4505 (const GdkEvent*) event);
4506 retval = TRUE(!(0));
4507 }
4508 break;
4509
4510 case GDK_KEY_Up0xff52:
4511 case GDK_KEY_KP_Up0xff97:
4512 if (alt) {
4513 fr_window_go_up_one_level (window);
4514 retval = TRUE(!(0));
4515 }
4516 break;
4517
4518 case GDK_KEY_BackSpace0xff08:
4519 fr_window_go_up_one_level (window);
4520 retval = TRUE(!(0));
4521 break;
4522
4523 case GDK_KEY_Right0xff53:
4524 case GDK_KEY_KP_Right0xff98:
4525 if (alt) {
4526 fr_window_go_forward (window);
4527 retval = TRUE(!(0));
4528 }
4529 break;
4530
4531 case GDK_KEY_Left0xff51:
4532 case GDK_KEY_KP_Left0xff96:
4533 if (alt) {
4534 fr_window_go_back (window);
4535 retval = TRUE(!(0));
4536 }
4537 break;
4538
4539 case GDK_KEY_Home0xff50:
4540 case GDK_KEY_KP_Home0xff95:
4541 if (alt) {
4542 fr_window_go_to_location (window, "/", FALSE(0));
4543 retval = TRUE(!(0));
4544 }
4545 break;
4546
4547 default:
4548 break;
4549 }
4550
4551 return retval;
4552}
4553
4554static gboolean
4555dir_tree_selection_changed_cb (GtkTreeSelection *selection,
4556 gpointer user_data)
4557{
4558 FrWindow *window = user_data;
4559 GtkTreeIter iter;
4560
4561 if (gtk_tree_selection_get_selected (selection, NULL((void*)0), &iter)) {
4562 char *path;
4563
4564 gtk_tree_model_get (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
,
4565 &iter,
4566 TREE_COLUMN_PATH, &path,
4567 -1);
4568 fr_window_go_to_location (window, path, FALSE(0));
4569 g_free (path);
4570 }
4571
4572 return FALSE(0);
4573}
4574
4575static gboolean
4576selection_changed_cb (GtkTreeSelection *selection,
4577 gpointer user_data)
4578{
4579 FrWindow *window = user_data;
4580
4581 fr_window_update_statusbar_list_info (window);
4582 fr_window_update_sensitivity (window);
4583
4584 return FALSE(0);
4585}
4586
4587static void
4588fr_window_delete_event_cb (GtkWidget *caller,
4589 GdkEvent *event,
4590 FrWindow *window)
4591{
4592 fr_window_close (window);
4593}
4594
4595static gboolean
4596is_single_click_policy (FrWindow *window)
4597{
4598 gboolean result = FALSE(0);
4599
4600 if (window->priv->settings_caja) {
4601 char *value;
4602
4603 value = g_settings_get_string (window->priv->settings_caja, CAJA_CLICK_POLICY"click-policy");
4604 result = (value != NULL((void*)0)) && (strncmp (value, "single", 6) == 0);
4605 g_free (value);
4606 }
4607
4608 return result;
4609}
4610
4611static void
4612filename_cell_data_func (GtkTreeViewColumn *column,
4613 GtkCellRenderer *renderer,
4614 GtkTreeModel *model,
4615 GtkTreeIter *iter,
4616 FrWindow *window)
4617{
4618 char *text;
4619 PangoUnderline underline;
4620
4621 gtk_tree_model_get (model, iter,
4622 COLUMN_NAME, &text,
4623 -1);
4624
4625 if (window->priv->single_click) {
4626 GtkTreePath *path;
4627
4628 path = gtk_tree_model_get_path (model, iter);
4629
4630 if ((window->priv->list_hover_path == NULL((void*)0))
4631 || gtk_tree_path_compare (path, window->priv->list_hover_path))
4632 underline = PANGO_UNDERLINE_NONE;
4633 else
4634 underline = PANGO_UNDERLINE_SINGLE;
4635
4636 gtk_tree_path_free (path);
4637 }
4638 else
4639 underline = PANGO_UNDERLINE_NONE;
4640
4641 g_object_set (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
,
4642 "text", text,
4643 "underline", underline,
4644 NULL((void*)0));
4645
4646 g_free (text);
4647}
4648
4649static void
4650add_dir_tree_columns (FrWindow *window,
4651 GtkTreeView *treeview)
4652{
4653 GtkCellRenderer *renderer;
4654 GtkTreeViewColumn *column;
4655 GValue value = { 0, };
4656
4657 /* First column. */
4658
4659 column = gtk_tree_view_column_new ();
4660 gtk_tree_view_column_set_title (column, _("Folders")gettext ("Folders"));
4661
4662 /* icon */
4663
4664 renderer = gtk_cell_renderer_pixbuf_new ();
4665 gtk_tree_view_column_pack_start (column, renderer, FALSE(0));
4666 gtk_tree_view_column_set_attributes (column, renderer,
4667 "pixbuf", TREE_COLUMN_ICON,
4668 NULL((void*)0));
4669
4670 /* name */
4671
4672 renderer = gtk_cell_renderer_text_new ();
4673
4674 g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()));
4675 g_value_set_enum (&value, PANGO_ELLIPSIZE_END);
4676 g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
, "ellipsize", &value);
4677 g_value_unset (&value);
4678
4679 gtk_tree_view_column_pack_start (column,
4680 renderer,
4681 TRUE(!(0)));
4682 gtk_tree_view_column_set_attributes (column, renderer,
4683 "text", TREE_COLUMN_NAME,
4684 "weight", TREE_COLUMN_WEIGHT,
4685 NULL((void*)0));
4686
4687 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
4688 gtk_tree_view_column_set_sort_column_id (column, TREE_COLUMN_NAME);
4689
4690 gtk_tree_view_append_column (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
, column);
4691}
4692
4693static void
4694add_file_list_columns (FrWindow *window,
4695 GtkTreeView *treeview)
4696{
4697 static const char *titles[] = {NC_("File", "Size")("Size"),
4698 NC_("File", "Type")("Type"),
4699 NC_("File", "Date Modified")("Date Modified"),
4700 NC_("File", "Location")("Location")};
4701 GtkCellRenderer *renderer;
4702 GtkTreeViewColumn *column;
4703 GValue value = { 0, };
4704 int i, j, w;
4705
4706 /* First column. */
4707
4708 window->priv->filename_column = column = gtk_tree_view_column_new ();
4709 gtk_tree_view_column_set_title (column, C_("File", "Name")g_dpgettext (((void*)0), "File" "\004" "Name", strlen ("File"
) + 1)
);
4710
4711 /* emblem */
4712
4713 renderer = gtk_cell_renderer_pixbuf_new ();
4714 gtk_tree_view_column_pack_end (column, renderer, FALSE(0));
4715 gtk_tree_view_column_set_attributes (column, renderer,
4716 "pixbuf", COLUMN_EMBLEM,
4717 NULL((void*)0));
4718
4719 /* icon */
4720
4721 renderer = gtk_cell_renderer_pixbuf_new ();
4722 gtk_tree_view_column_pack_start (column, renderer, FALSE(0));
4723 gtk_tree_view_column_set_attributes (column, renderer,
4724 "pixbuf", COLUMN_ICON,
4725 NULL((void*)0));
4726
4727 /* name */
4728
4729 window->priv->single_click = is_single_click_policy (window);
4730
4731 renderer = gtk_cell_renderer_text_new ();
4732
4733 g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()));
4734 g_value_set_enum (&value, PANGO_ELLIPSIZE_END);
4735 g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
, "ellipsize", &value);
4736 g_value_unset (&value);
4737
4738 gtk_tree_view_column_pack_start (column,
4739 renderer,
4740 TRUE(!(0)));
4741 gtk_tree_view_column_set_attributes (column, renderer,
4742 "text", COLUMN_NAME,
4743 NULL((void*)0));
4744
4745 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
4746 w = g_settings_get_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width");
4747 if (w <= 0)
4748 w = DEFAULT_NAME_COLUMN_WIDTH250;
4749 gtk_tree_view_column_set_fixed_width (column, w);
4750 gtk_tree_view_column_set_resizable (column, TRUE(!(0)));
4751 gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
4752 gtk_tree_view_column_set_cell_data_func (column, renderer,
4753 (GtkTreeCellDataFunc) filename_cell_data_func,
4754 window, NULL((void*)0));
4755
4756 gtk_tree_view_append_column (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
, column);
4757
4758 /* Other columns */
4759
4760 for (j = 0, i = COLUMN_SIZE; i < NUMBER_OF_COLUMNS; i++, j++) {
4761 GValue value_oc = { 0, };
4762
4763 renderer = gtk_cell_renderer_text_new ();
4764 column = gtk_tree_view_column_new_with_attributes (g_dpgettext2 (NULL((void*)0), "File", titles[j]),
4765 renderer,
4766 "text", i,
4767 NULL((void*)0));
4768
4769 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
4770 gtk_tree_view_column_set_fixed_width (column, OTHER_COLUMNS_WIDTH100);
4771 gtk_tree_view_column_set_resizable (column, TRUE(!(0)));
4772
4773 gtk_tree_view_column_set_sort_column_id (column, i);
4774
4775 g_value_init (&value_oc, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ()));
4776 g_value_set_enum (&value_oc, PANGO_ELLIPSIZE_END);
4777 g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((renderer)), (((GType) ((20) << (2))))))))
, "ellipsize", &value_oc);
4778 g_value_unset (&value_oc);
4779
4780 gtk_tree_view_append_column (treeview, column);
4781 }
4782}
4783
4784static int
4785name_column_sort_func (GtkTreeModel *model,
4786 GtkTreeIter *a,
4787 GtkTreeIter *b,
4788 gpointer user_data)
4789{
4790 FileData *fdata1, *fdata2;
4791
4792 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4793 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4794
4795 return sort_by_name (&fdata1, &fdata2);
4796}
4797
4798static int
4799size_column_sort_func (GtkTreeModel *model,
4800 GtkTreeIter *a,
4801 GtkTreeIter *b,
4802 gpointer user_data)
4803{
4804 FileData *fdata1, *fdata2;
4805
4806 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4807 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4808
4809 return sort_by_size (&fdata1, &fdata2);
4810}
4811
4812static int
4813type_column_sort_func (GtkTreeModel *model,
4814 GtkTreeIter *a,
4815 GtkTreeIter *b,
4816 gpointer user_data)
4817{
4818 FileData *fdata1, *fdata2;
4819
4820 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4821 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4822
4823 return sort_by_type (&fdata1, &fdata2);
4824}
4825
4826static int
4827time_column_sort_func (GtkTreeModel *model,
4828 GtkTreeIter *a,
4829 GtkTreeIter *b,
4830 gpointer user_data)
4831{
4832 FileData *fdata1, *fdata2;
4833
4834 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4835 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4836
4837 return sort_by_time (&fdata1, &fdata2);
4838}
4839
4840static int
4841path_column_sort_func (GtkTreeModel *model,
4842 GtkTreeIter *a,
4843 GtkTreeIter *b,
4844 gpointer user_data)
4845{
4846 FileData *fdata1, *fdata2;
4847
4848 gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
4849 gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
4850
4851 return sort_by_path (&fdata1, &fdata2);
4852}
4853
4854static int
4855no_sort_column_sort_func (GtkTreeModel *model,
4856 GtkTreeIter *a,
4857 GtkTreeIter *b,
4858 gpointer user_data)
4859{
4860 return -1;
4861}
4862
4863static void
4864sort_column_changed_cb (GtkTreeSortable *sortable,
4865 gpointer user_data)
4866{
4867 FrWindow *window = user_data;
4868 GtkSortType order;
4869 int column_id;
4870
4871 if (! gtk_tree_sortable_get_sort_column_id (sortable,
4872 &column_id,
4873 &order))
4874 return;
4875
4876 window->priv->sort_method = get_sort_method_from_column (column_id);
4877 window->priv->sort_type = order;
4878}
4879
4880static gboolean
4881fr_window_show_cb (GtkWidget *widget,
4882 FrWindow *window)
4883{
4884 fr_window_update_current_location (window);
4885
4886 set_active (window, "ViewToolbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar"));
4887 set_active (window, "ViewStatusbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar"));
4888
4889 window->priv->view_folders = g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_FOLDERS"view-folders");
4890 set_active (window, "ViewFolders", window->priv->view_folders);
4891
4892 fr_window_update_filter_bar_visibility (window);
4893
4894 return TRUE(!(0));
4895}
4896
4897/* preferences changes notification callbacks */
4898
4899static void
4900pref_history_len_changed (GSettings *settings,
4901 const char *key,
4902 gpointer user_data)
4903{
4904 FrWindow *window = user_data;
4905 int limit;
4906
4907 limit = g_settings_get_int (settings, PREF_UI_HISTORY_LEN"history-len");
4908
4909 gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (window->priv->menubar_recentmenu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((window->priv->menubar_recentmenu)), (
(gtk_recent_chooser_get_type ()))))))
, limit);
4910 gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (window->priv->toolbar_recentmenu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((window->priv->toolbar_recentmenu)), (
(gtk_recent_chooser_get_type ()))))))
, limit);
4911}
4912
4913static void
4914pref_view_toolbar_changed (GSettings *settings,
4915 const char *key,
4916 gpointer user_data)
4917{
4918 FrWindow *window = user_data;
4919 fr_window_set_toolbar_visibility (window, g_settings_get_boolean (settings, key));
4920}
4921
4922static void
4923pref_view_statusbar_changed (GSettings *settings,
4924 const char *key,
4925 gpointer user_data)
4926{
4927 FrWindow *window = user_data;
4928
4929 fr_window_set_statusbar_visibility (window, g_settings_get_boolean (settings, key));
4930}
4931
4932static void
4933pref_view_folders_changed (GSettings *settings,
4934 const char *key,
4935 gpointer user_data)
4936{
4937 FrWindow *window = user_data;
4938
4939 fr_window_set_folders_visibility (window, g_settings_get_boolean (settings, key));
4940}
4941
4942static void
4943pref_show_field_changed (GSettings *settings,
4944 const char *key,
4945 gpointer user_data)
4946{
4947 FrWindow *window = user_data;
4948
4949 fr_window_update_columns_visibility (window);
4950}
4951
4952static void
4953pref_click_policy_changed (GSettings *settings,
4954 const char *key,
4955 gpointer user_data)
4956{
4957 FrWindow *window = user_data;
4958 GdkWindow *win = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
4959 GdkDisplay *display;
4960
4961 window->priv->single_click = is_single_click_policy (window);
4962
4963 gdk_window_set_cursor (win, NULL((void*)0));
4964 display = gtk_widget_get_display (GTK_WIDGET (window->priv->list_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_widget_get_type (
)))))))
);
4965 if (display != NULL((void*)0))
4966 gdk_display_flush (display);
4967}
4968
4969static void
4970pref_use_mime_icons_changed (GSettings *settings,
4971 const char *key,
4972 gpointer user_data)
4973{
4974 FrWindow *window = user_data;
4975
4976 if (tree_pixbuf_hash != NULL((void*)0)) {
4977 g_hash_table_foreach (tree_pixbuf_hash,
4978 gh_unref_pixbuf,
4979 NULL((void*)0));
4980 g_hash_table_destroy (tree_pixbuf_hash);
4981 tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal);
4982 }
4983
4984 fr_window_update_file_list (window, FALSE(0));
4985 fr_window_update_dir_tree (window);
4986}
4987
4988static void
4989theme_changed_cb (GtkIconTheme *theme, FrWindow *window)
4990{
4991 file_list_icon_size = _gtk_widget_lookup_for_size (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FILE_LIST_ICON_SIZEGTK_ICON_SIZE_LARGE_TOOLBAR);
4992
4993 if (tree_pixbuf_hash != NULL((void*)0)) {
4994 g_hash_table_foreach (tree_pixbuf_hash,
4995 gh_unref_pixbuf,
4996 NULL((void*)0));
4997 g_hash_table_destroy (tree_pixbuf_hash);
4998 tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal);
4999 }
5000
5001 fr_window_update_file_list (window, TRUE(!(0)));
5002 fr_window_update_dir_tree (window);
5003}
5004
5005static gboolean
5006fr_window_stoppable_cb (FrCommand *command,
5007 gboolean stoppable,
5008 FrWindow *window)
5009{
5010 window->priv->stoppable = stoppable;
5011 set_sensitive (window, "stop_item", stoppable);
5012 set_sensitive (window, "tool_stop_item", stoppable);
5013 if (window->priv->progress_dialog != NULL((void*)0))
5014 gtk_dialog_set_response_sensitive (GTK_DIALOG (window->priv->progress_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_dialog_get_type
()))))))
,
5015 GTK_RESPONSE_OK,
5016 stoppable);
5017 return TRUE(!(0));
5018}
5019
5020static gboolean
5021fr_window_fake_load (FrArchive *archive,
5022 gpointer data)
5023{
5024 /* fake loads are disabled to allow exact progress dialogs (#153281) */
5025
5026 return FALSE(0);
5027
5028#if 0
5029 FrWindow *window = data;
5030 gboolean add_after_opening = FALSE(0);
5031 gboolean extract_after_opening = FALSE(0);
5032 GList *scan;
5033
5034 /* fake loads are used only in batch mode to avoid unnecessary
5035 * archive loadings. */
5036
5037 if (! window->priv->batch_mode)
5038 return FALSE(0);
5039
5040 /* Check whether there is an ADD or EXTRACT action in the batch list. */
5041
5042 for (scan = window->priv->batch_action; scan; scan = scan->next) {
5043 FRBatchAction *action;
5044
5045 action = (FRBatchAction *) scan->data;
5046 if (action->type == FR_BATCH_ACTION_ADD) {
5047 add_after_opening = TRUE(!(0));
5048 break;
5049 }
5050 if ((action->type == FR_BATCH_ACTION_EXTRACT_HERE)
5051 || (action->type == FR_BATCH_ACTION_EXTRACT_INTERACT))
5052 {
5053 extract_after_opening = TRUE(!(0));
5054 break;
5055 }
5056 }
5057
5058 /* use fake load when in batch mode and the archive type supports all
5059 * of the required features */
5060
5061 return (window->priv->batch_mode
5062 && ! (add_after_opening && window->priv->update_dropped_files && ! archive->command->propAddCanUpdate)
5063 && ! (add_after_opening && ! window->priv->update_dropped_files && ! archive->command->propAddCanReplace)
5064 && ! (extract_after_opening && !archive->command->propCanExtractAll));
5065#endif
5066}
5067
5068static void
5069menu_item_select_cb (GtkMenuItem *proxy,
5070 FrWindow *window)
5071{
5072 char *message;
5073
5074 message = gtk_widget_get_tooltip_text (GTK_WIDGET (proxy)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((gtk_widget_get_type ()))))))
);
5075 if (message) {
5076 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
5077 window->priv->help_message_cid, message);
5078 g_free (message);
5079 }
5080}
5081
5082static void
5083menu_item_deselect_cb (GtkMenuItem *proxy,
5084 FrWindow *window)
5085{
5086 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
5087 window->priv->help_message_cid);
5088}
5089
5090static void
5091view_all_files_selected_toggled (GtkMenuItem *menuitem,
5092 gpointer data)
5093{
5094 FrWindow *window = data;
5095
5096 if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)((((GtkCheckMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_check_menu_item_get_type (
)))))))
))
5097 fr_window_set_list_mode (window, FR_WINDOW_LIST_MODE_FLAT);
5098 else
5099 fr_window_set_list_mode (window, FR_WINDOW_LIST_MODE_AS_DIR);
5100}
5101
5102static void
5103recent_chooser_item_activated_cb (GtkRecentChooser *chooser,
5104 FrWindow *window)
5105{
5106 char *uri;
5107
5108 uri = gtk_recent_chooser_get_current_uri (chooser);
5109 if (uri != NULL((void*)0)) {
5110 fr_window_archive_open (window, uri, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
5111 g_free (uri);
5112 }
5113}
5114
5115static GtkWidget *
5116fr_window_create_recent_chooser (FrWindow *window)
5117{
5118 GtkRecentManager *manager;
5119 GtkRecentFilter *filter;
5120 GtkWidget *menu;
5121 int i;
5122
5123 manager = gtk_recent_manager_get_default ();
5124 menu = gtk_recent_chooser_menu_new_for_manager (manager);
5125
5126 filter = gtk_recent_filter_new ();
5127 gtk_recent_filter_set_name (filter, _("All archives")gettext ("All archives"));
5128 for (i = 0; open_type[i] != -1; i++)
5129 gtk_recent_filter_add_mime_type (filter, mime_type_desc[open_type[i]].mime_type);
5130 gtk_recent_filter_add_application (filter, "Engrampa");
5131 gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, filter);
5132
5133 gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, FALSE(0));
5134 gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, g_settings_get_int (window->priv->settings_ui, PREF_UI_HISTORY_LEN"history-len"));
5135 gtk_recent_chooser_set_show_not_found (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, TRUE(!(0)));
5136 gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu)((((GtkRecentChooser*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menu)), ((gtk_recent_chooser_get_type ())))
)))
, GTK_RECENT_SORT_MRU);
5137
5138 g_signal_connect (G_OBJECT (menu),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5139 "item_activated",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5140 G_CALLBACK (recent_chooser_item_activated_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5141 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5142 return menu;
5143}
5144
5145static void
5146close_sidepane_button_clicked_cb (GtkButton *button,
5147 FrWindow *window)
5148{
5149 fr_window_set_folders_visibility (window, FALSE(0));
5150}
5151
5152static void
5153fr_window_activate_filter (FrWindow *window)
5154{
5155 GtkTreeView *tree_view = GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
;
5156 GtkTreeViewColumn *column;
5157
5158 fr_window_update_filter_bar_visibility (window);
5159 window->priv->list_mode = FR_WINDOW_LIST_MODE_FLAT;
5160
5161 gtk_list_store_clear (window->priv->list_store);
5162
5163 column = gtk_tree_view_get_column (tree_view, 4);
5164 gtk_tree_view_column_set_visible (column, TRUE(!(0)));
5165
5166 fr_window_update_file_list (window, TRUE(!(0)));
5167 fr_window_update_dir_tree (window);
5168 fr_window_update_current_location (window);
5169}
5170
5171static void
5172filter_entry_activate_cb (GtkEntry *entry,
5173 FrWindow *window)
5174{
5175 fr_window_activate_filter (window);
5176}
5177
5178static void
5179filter_entry_icon_release_cb (GtkEntry *entry,
5180 GtkEntryIconPosition icon_pos,
5181 GdkEventButton *event,
5182 gpointer user_data)
5183{
5184 FrWindow *window = FR_WINDOW (user_data)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((fr_window_get_type ()))))))
;
5185
5186 if ((event->button == 1) && (icon_pos == GTK_ENTRY_ICON_SECONDARY))
5187 fr_window_deactivate_filter (window);
5188}
5189
5190static void
5191fr_window_attach (FrWindow *window,
5192 GtkWidget *child,
5193 FrWindowArea area)
5194{
5195 int position;
5196
5197 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
5198 g_return_if_fail (FR_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((fr_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "FR_IS_WINDOW (window)"); return; } } while (0
)
;
5199 g_return_if_fail (child != NULL)do { if ((child != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "child != NULL");
return; } } while (0)
;
5200 g_return_if_fail (GTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((child)); GType __t = ((gtk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GTK_IS_WIDGET (child)"); return; } } while (0
)
;
5201
5202 switch (area) {
5203 case FR_WINDOW_AREA_MENUBAR:
5204 position = 0;
5205 break;
5206 case FR_WINDOW_AREA_TOOLBAR:
5207 position = 1;
5208 break;
5209 case FR_WINDOW_AREA_LOCATIONBAR:
5210 position = 2;
5211 break;
5212 case FR_WINDOW_AREA_CONTENTS:
5213 position = 3;
5214 if (window->priv->contents != NULL((void*)0))
5215 gtk_widget_destroy (window->priv->contents);
5216 window->priv->contents = child;
5217 gtk_widget_set_vexpand (child, TRUE(!(0)));
5218 break;
5219 case FR_WINDOW_AREA_FILTERBAR:
5220 position = 4;
5221 break;
5222 case FR_WINDOW_AREA_STATUSBAR:
5223 position = 5;
5224 break;
5225 default:
5226 g_critical ("%s: area not recognized!", G_STRFUNC((const char*) (__func__)));
5227 return;
5228 break;
5229 }
5230
5231 gtk_widget_set_hexpand (child, TRUE(!(0)));
5232 gtk_grid_attach (GTK_GRID (window->priv->layout)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->layout)), ((gtk_grid_get_type ()))))
))
,
5233 child,
5234 0, position,
5235 1, 1);
5236}
5237
5238static void
5239fr_window_construct (FrWindow *window)
5240{
5241 GtkWidget *menubar;
5242 GtkWidget *toolbar;
5243 GtkWidget *list_scrolled_window;
5244 GtkWidget *location_box;
5245 GtkStatusbar *statusbar;
5246 GtkWidget *statusbar_box;
5247 GtkWidget *filter_box;
5248 GtkWidget *tree_scrolled_window;
5249 GtkWidget *sidepane_title;
5250 GtkWidget *sidepane_title_box;
5251 GtkWidget *sidepane_title_label;
5252 GtkWidget *close_sidepane_button;
5253 GtkWidget *menu_radio_files;
5254 GtkWidget *menuitem;
5255 GtkTreeSelection *selection;
5256 GActionGroup *actions;
5257 GSimpleAction *action;
5258 GtkAccelGroup *accel_group;
5259 GtkBuilder *ui;
5260 GError *error = NULL((void*)0);
5261 GSettingsSchemaSource *schema_source;
5262 GSettingsSchema *caja_schema;
5263
5264 /* data common to all windows. */
5265
5266 if (tree_pixbuf_hash == NULL((void*)0))
5267 tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal);
5268
5269 if (icon_theme == NULL((void*)0))
5270 icon_theme = gtk_icon_theme_get_default ();
5271
5272 /* Create the settings objects */
5273
5274 window->priv->settings_listing = g_settings_new (ENGRAMPA_SCHEMA_LISTING"org.mate.engrampa" ".listing");
5275 window->priv->settings_ui = g_settings_new (ENGRAMPA_SCHEMA_UI"org.mate.engrampa" ".ui");
5276 window->priv->settings_general = g_settings_new (ENGRAMPA_SCHEMA_GENERAL"org.mate.engrampa" ".general");
5277 window->priv->settings_dialogs = g_settings_new (ENGRAMPA_SCHEMA_DIALOGS"org.mate.engrampa" ".dialogs");
5278
5279 schema_source = g_settings_schema_source_get_default ();
5280 caja_schema = g_settings_schema_source_lookup (schema_source, CAJA_SCHEMA"org.mate.caja.preferences", FALSE(0));
5281 if (caja_schema) {
5282 window->priv->settings_caja = g_settings_new (CAJA_SCHEMA"org.mate.caja.preferences");
5283 g_settings_schema_unref (caja_schema);
5284 }
5285
5286 /* Create the application. */
5287
5288 window->priv->layout = gtk_grid_new ();
5289 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, window->priv->layout);
5290 gtk_widget_show (window->priv->layout);
5291
5292 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, _("Archive Manager")gettext ("Archive Manager"));
5293
5294 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5295 "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5296 G_CALLBACK (fr_window_delete_event_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5297 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5298
5299 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
5300 "show",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
5301 G_CALLBACK (fr_window_show_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
5302 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("show"), (((GCallback) (fr_window_show_cb))), (window
), ((void*)0), (GConnectFlags) 0)
;
5303
5304 window->priv->theme_changed_handler_id =
5305 g_signal_connect (icon_theme,g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
5306 "changed",g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
5307 G_CALLBACK (theme_changed_cb),g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
5308 window)g_signal_connect_data ((icon_theme), ("changed"), (((GCallback
) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags)
0)
;
5309
5310 file_list_icon_size = _gtk_widget_lookup_for_size (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FILE_LIST_ICON_SIZEGTK_ICON_SIZE_LARGE_TOOLBAR);
5311
5312 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
5313 g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width"),
5314 g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height"));
5315
5316 gtk_drag_dest_set (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
5317 GTK_DEST_DEFAULT_ALL,
5318 target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])),
5319 GDK_ACTION_COPY);
5320
5321 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
5322 "drag_data_received",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
5323 G_CALLBACK (fr_window_drag_data_received),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
5324 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received
))), (window), ((void*)0), (GConnectFlags) 0)
;
5325 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
5326 "drag_motion",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
5327 G_CALLBACK (fr_window_drag_motion),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
5328 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion
))), (window), ((void*)0), (GConnectFlags) 0)
;
5329
5330 g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
5331 "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
5332 G_CALLBACK (key_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
5333 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (((GType) ((20) << (2)))
)))))), ("key_press_event"), (((GCallback) (key_press_cb))), (
window), ((void*)0), (GConnectFlags) 0)
;
5334
5335 /* Initialize Data. */
5336
5337 window->archive = fr_archive_new ();
5338 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
5339 "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
5340 G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
5341 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("start"), (((GCallback) (action_started))), (window
), ((void*)0), (GConnectFlags) 0)
;
5342 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
5343 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
5344 G_CALLBACK (action_performed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
5345 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (action_performed))), (
window), ((void*)0), (GConnectFlags) 0)
;
5346 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5347 "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5348 G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5349 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5350 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5351 "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5352 G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5353 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("message"), (((GCallback) (fr_window_message_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5354 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5355 "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5356 G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5357 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5358 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5359 "working_archive",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5360 G_CALLBACK (fr_window_working_archive_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5361 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5362
5363 fr_archive_set_fake_load_func (window->archive,
5364 fr_window_fake_load,
5365 window);
5366
5367 window->priv->sort_method = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method");
5368 window->priv->sort_type = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type");
5369
5370 window->priv->list_mode = window->priv->last_list_mode = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode");
5371 g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT));
5372
5373 window->priv->history = NULL((void*)0);
5374 window->priv->history_current = NULL((void*)0);
5375
5376 window->priv->action = FR_ACTION_NONE;
5377
5378 window->priv->open_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ());
5379 window->priv->add_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ());
5380 window->priv->extract_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ());
5381
5382 window->priv->give_focus_to_the_list = FALSE(0);
5383
5384 window->priv->activity_ref = 0;
5385 window->priv->activity_timeout_handle = 0;
5386
5387 window->priv->update_timeout_handle = 0;
5388
5389 window->priv->archive_present = FALSE(0);
5390 window->priv->archive_new = FALSE(0);
5391 window->priv->archive_uri = NULL((void*)0);
5392
5393 window->priv->drag_destination_folder = NULL((void*)0);
5394 window->priv->drag_base_dir = NULL((void*)0);
5395 window->priv->drag_error = NULL((void*)0);
5396 window->priv->drag_file_list = NULL((void*)0);
5397
5398 window->priv->batch_mode = FALSE(0);
5399 window->priv->batch_action_list = NULL((void*)0);
5400 window->priv->batch_action = NULL((void*)0);
5401 window->priv->extract_interact_use_default_dir = FALSE(0);
5402 window->priv->non_interactive = FALSE(0);
5403
5404 window->priv->password = NULL((void*)0);
5405 window->priv->compression = g_settings_get_enum (window->priv->settings_general, PREF_GENERAL_COMPRESSION_LEVEL"compression-level");
5406 window->priv->encrypt_header = g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_ENCRYPT_HEADER"encrypt-header");
5407 window->priv->volume_size = 0;
5408
5409 window->priv->convert_data.converting = FALSE(0);
5410 window->priv->convert_data.temp_dir = NULL((void*)0);
5411 window->priv->convert_data.new_archive = NULL((void*)0);
5412 window->priv->convert_data.password = NULL((void*)0);
5413 window->priv->convert_data.encrypt_header = FALSE(0);
5414 window->priv->convert_data.volume_size = 0;
5415
5416 window->priv->stoppable = TRUE(!(0));
5417
5418 window->priv->batch_adding_one_file = FALSE(0);
5419
5420 window->priv->path_clicked = NULL((void*)0);
5421
5422 window->priv->current_view_length = 0;
5423
5424 window->priv->current_batch_action.type = FR_BATCH_ACTION_NONE;
5425 window->priv->current_batch_action.data = NULL((void*)0);
5426 window->priv->current_batch_action.free_func = NULL((void*)0);
5427
5428 window->priv->pd_last_archive = NULL((void*)0);
5429 window->priv->pd_last_message = NULL((void*)0);
5430 window->priv->pd_last_fraction = 0.0;
5431
5432 /* Create the widgets. */
5433
5434 /* * File list. */
5435
5436 window->priv->list_store = fr_list_model_new (NUMBER_OF_COLUMNS,
5437 G_TYPE_POINTER((GType) ((17) << (2))),
5438 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()),
5439 G_TYPE_STRING((GType) ((16) << (2))),
5440 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()),
5441 G_TYPE_STRING((GType) ((16) << (2))),
5442 G_TYPE_STRING((GType) ((16) << (2))),
5443 G_TYPE_STRING((GType) ((16) << (2))),
5444 G_TYPE_STRING((GType) ((16) << (2))));
5445 g_object_set_data (G_OBJECT (window->priv->list_store)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), (((GType) ((20) <<
(2))))))))
, "FrWindow", window);
5446 window->priv->list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
);
5447
5448 add_file_list_columns (window, GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
5449 gtk_tree_view_set_enable_search (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
5450 TRUE(!(0)));
5451 gtk_tree_view_set_search_column (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
,
5452 COLUMN_NAME);
5453
5454 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5455 COLUMN_NAME, name_column_sort_func,
5456 NULL((void*)0), NULL((void*)0));
5457 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5458 COLUMN_SIZE, size_column_sort_func,
5459 NULL((void*)0), NULL((void*)0));
5460 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5461 COLUMN_TYPE, type_column_sort_func,
5462 NULL((void*)0), NULL((void*)0));
5463 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5464 COLUMN_TIME, time_column_sort_func,
5465 NULL((void*)0), NULL((void*)0));
5466 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5467 COLUMN_PATH, path_column_sort_func,
5468 NULL((void*)0), NULL((void*)0));
5469
5470 gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (window->priv->list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_sortable_get_type
()))))))
,
5471 no_sort_column_sort_func,
5472 NULL((void*)0), NULL((void*)0));
5473
5474 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
5475 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
5476
5477 g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5478 "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5479 G_CALLBACK (selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5480 window)g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5481 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
5482 "row_activated",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
5483 G_CALLBACK (row_activated_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
5484 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("row_activated"), (((GCallback
) (row_activated_cb))), (window), ((void*)0), (GConnectFlags)
0)
;
5485
5486 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5487 "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5488 G_CALLBACK (file_button_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5489 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5490 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5491 "button_release_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5492 G_CALLBACK (file_button_release_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5493 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("button_release_event"), (((GCallback
) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5494 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5495 "motion_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5496 G_CALLBACK (file_motion_notify_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5497 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback
) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
;
5498 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5499 "leave_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5500 G_CALLBACK (file_leave_notify_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
5501 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback
) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags
) 0)
;
5502
5503 g_signal_connect (G_OBJECT (window->priv->list_store),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5504 "sort_column_changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5505 G_CALLBACK (sort_column_changed_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5506 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_store)), (((GType
) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback
) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5507
5508 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5509 "drag_begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5510 G_CALLBACK (file_list_drag_begin),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5511 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
;
5512 g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5513 "drag_end",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5514 G_CALLBACK (file_list_drag_end),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5515 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->list_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
;
5516 egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
);
5517
5518 list_scrolled_window = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
5519 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((list_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5520 GTK_POLICY_AUTOMATIC,
5521 GTK_POLICY_AUTOMATIC);
5522 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (list_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((list_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5523 GTK_SHADOW_IN);
5524 gtk_container_add (GTK_CONTAINER (list_scrolled_window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_scrolled_window)), ((gtk_container_get_type ())))))
)
, window->priv->list_view);
5525
5526 /* filter bar */
5527
5528 window->priv->filter_bar = filter_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
5529 gtk_container_set_border_width (GTK_CONTAINER (filter_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((filter_box)), ((gtk_container_get_type ()))))))
, 3);
5530 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->filter_bar, FR_WINDOW_AREA_FILTERBAR);
5531
5532 gtk_box_pack_start (GTK_BOX (filter_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((filter_box)), ((gtk_box_get_type ()))))))
,
5533 gtk_label_new (_("Find:")gettext ("Find:")), FALSE(0), FALSE(0), 0);
5534
5535 /* * filter entry */
5536
5537 window->priv->filter_entry = GTK_WIDGET (gtk_entry_new ())((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_entry_new ())), ((gtk_widget_get_type ()))))))
;
5538 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->filter_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->filter_entry)), ((gtk_entry_get_type
()))))))
,
5539 GTK_ENTRY_ICON_SECONDARY,
5540 "edit-clear");
5541
5542 gtk_widget_set_size_request (window->priv->filter_entry, 300, -1);
5543 gtk_box_pack_start (GTK_BOX (filter_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((filter_box)), ((gtk_box_get_type ()))))))
,
5544 window->priv->filter_entry, FALSE(0), FALSE(0), 6);
5545
5546 g_signal_connect (G_OBJECT (window->priv->filter_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5547 "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5548 G_CALLBACK (filter_entry_activate_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5549 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5550 g_signal_connect (G_OBJECT (window->priv->filter_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5551 "icon-release",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5552 G_CALLBACK (filter_entry_icon_release_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5553 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->filter_entry)), (((GType
) ((20) << (2))))))))), ("icon-release"), (((GCallback)
(filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5554
5555 gtk_widget_show_all (filter_box);
5556
5557 /* tree view */
5558
5559 window->priv->tree_store = gtk_tree_store_new (TREE_NUMBER_OF_COLUMNS,
5560 G_TYPE_STRING((GType) ((16) << (2))),
5561 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()),
5562 G_TYPE_STRING((GType) ((16) << (2))),
5563 PANGO_TYPE_WEIGHT(pango_weight_get_type ()));
5564 window->priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->tree_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_store)), ((gtk_tree_model_get_type
()))))))
);
5565 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
, FALSE(0));
5566 add_dir_tree_columns (window, GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
5567
5568 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5569 "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5570 G_CALLBACK (dir_tree_button_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5571 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("button_press_event"), (((GCallback
) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5572
5573 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->tree_view)), ((gtk_tree_view_get_type
()))))))
);
5574 g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5575 "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5576 G_CALLBACK (dir_tree_selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
5577 window)g_signal_connect_data ((selection), ("changed"), (((GCallback
) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
5578
5579 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5580 "drag_begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5581 G_CALLBACK (file_list_drag_begin),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
5582 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_begin"), (((GCallback) (
file_list_drag_begin))), (window), ((void*)0), (GConnectFlags
) 0)
;
5583 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5584 "drag_end",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5585 G_CALLBACK (file_list_drag_end),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
5586 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end
))), (window), ((void*)0), (GConnectFlags) 0)
;
5587 g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
5588 "drag_data_get",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
5589 G_CALLBACK (fr_window_folder_tree_drag_data_get),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
5590 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->tree_view)), (((GType
) ((20) << (2))))))))), ("drag_data_get"), (((GCallback
) (fr_window_folder_tree_drag_data_get))), (window), ((void*)
0), (GConnectFlags) 0)
;
5591 gtk_drag_source_set (window->priv->tree_view,
5592 GDK_BUTTON1_MASK,
5593 folder_tree_targets, G_N_ELEMENTS (folder_tree_targets)(sizeof (folder_tree_targets) / sizeof ((folder_tree_targets)
[0]))
,
5594 GDK_ACTION_COPY);
5595
5596 tree_scrolled_window = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
5597 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tree_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((tree_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5598 GTK_POLICY_AUTOMATIC,
5599 GTK_POLICY_AUTOMATIC);
5600 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (tree_scrolled_window)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((tree_scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
,
5601 GTK_SHADOW_IN);
5602 gtk_container_add (GTK_CONTAINER (tree_scrolled_window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_scrolled_window)), ((gtk_container_get_type ())))))
)
, window->priv->tree_view);
5603
5604 /* side pane */
5605
5606 window->priv->sidepane = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
5607
5608 sidepane_title = gtk_frame_new (NULL((void*)0));
5609 gtk_frame_set_shadow_type (GTK_FRAME (sidepane_title)((((GtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title)), ((gtk_frame_get_type ()))))))
, GTK_SHADOW_ETCHED_IN);
5610
5611 sidepane_title_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
5612 gtk_container_set_border_width (GTK_CONTAINER (sidepane_title_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_box)), ((gtk_container_get_type ()))))))
, 2);
5613 gtk_container_add (GTK_CONTAINER (sidepane_title)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title)), ((gtk_container_get_type ()))))))
, sidepane_title_box);
5614 sidepane_title_label = gtk_label_new (_("Folders")gettext ("Folders"));
5615
5616 gtk_label_set_xalign (GTK_LABEL (sidepane_title_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_label)), ((gtk_label_get_type ()))))))
, 0.0);
5617 gtk_box_pack_start (GTK_BOX (sidepane_title_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_box)), ((gtk_box_get_type ()))))))
, sidepane_title_label, TRUE(!(0)), TRUE(!(0)), 0);
5618
5619 close_sidepane_button = gtk_button_new ();
5620 gtk_container_add (GTK_CONTAINER (close_sidepane_button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((close_sidepane_button)), ((gtk_container_get_type ()))))
))
,
5621 gtk_image_new_from_icon_name ("window-close",
5622 GTK_ICON_SIZE_MENU));
5623 gtk_button_set_relief (GTK_BUTTON (close_sidepane_button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((close_sidepane_button)), ((gtk_button_get_type ()))))))
, GTK_RELIEF_NONE);
5624 gtk_widget_set_tooltip_text (close_sidepane_button, _("Close the folders pane")gettext ("Close the folders pane"));
5625 g_signal_connect (close_sidepane_button,g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
5626 "clicked",g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
5627 G_CALLBACK (close_sidepane_button_clicked_cb),g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
5628 window)g_signal_connect_data ((close_sidepane_button), ("clicked"), (
((GCallback) (close_sidepane_button_clicked_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
5629 gtk_box_pack_end (GTK_BOX (sidepane_title_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidepane_title_box)), ((gtk_box_get_type ()))))))
, close_sidepane_button, FALSE(0), FALSE(0), 0);
5630
5631 gtk_box_pack_start (GTK_BOX (window->priv->sidepane)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->sidepane)), ((gtk_box_get_type ())))
)))
, sidepane_title, FALSE(0), FALSE(0), 0);
5632 gtk_box_pack_start (GTK_BOX (window->priv->sidepane)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->sidepane)), ((gtk_box_get_type ())))
)))
, tree_scrolled_window, TRUE(!(0)), TRUE(!(0)), 0);
5633
5634 /* main content */
5635
5636 window->priv->paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
5637 gtk_paned_pack1 (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
, window->priv->sidepane, FALSE(0), TRUE(!(0)));
5638 gtk_paned_pack2 (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
, list_scrolled_window, TRUE(!(0)), TRUE(!(0)));
5639 gtk_paned_set_position (GTK_PANED (window->priv->paned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->paned)), ((gtk_paned_get_type ()))))
))
, g_settings_get_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width"));
5640
5641 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->paned, FR_WINDOW_AREA_CONTENTS);
5642 gtk_widget_show_all (window->priv->paned);
5643
5644 /* Build the menu and the toolbar. */
5645
5646 window->priv->ui_manager = ui = gtk_builder_new ();
5647
5648 window->priv->actions = actions = (GActionGroup*)g_simple_action_group_new ();
5649
5650 /* other actions */
5651 g_action_map_add_action_entries (G_ACTION_MAP (actions)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((actions)), ((g_action_map_get_type ()))))))
,
5652 action_entries, G_N_ELEMENTS (action_entries)(sizeof (action_entries) / sizeof ((action_entries)[0])),
5653 window);
5654
5655 accel_group = gtk_accel_group_new ();
5656 gtk_widget_insert_action_group (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, "win", actions);
5657 gtk_window_add_accel_group (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, accel_group);
5658
5659 /* Add a hidden short cut Ctrl-Q for power users */
5660 gtk_accel_group_connect (accel_group,
5661 GDK_KEY_q0x071, GDK_CONTROL_MASK, 0,
5662 g_cclosure_new_swap (G_CALLBACK (fr_window_close)((GCallback) (fr_window_close)), window, NULL((void*)0)));
5663
5664 if (! gtk_builder_add_from_resource (ui, ENGRAMPA_RESOURCE_UI_PATH"/org/mate/Engrampa/ui" G_DIR_SEPARATOR_S"/" "menus-toolbars.ui", &error)) {
5665 g_message ("building menus failed: %s", error->message);
5666 g_error_free (error);
5667 }
5668 /*Add shortcut keys*/
5669 for (gulong i = 0; i < G_N_ELEMENTS (menu_keybindings)(sizeof (menu_keybindings) / sizeof ((menu_keybindings)[0])); i++)
5670 {
5671 menuitem = (GtkWidget*)gtk_builder_get_object (ui, menu_keybindings[i].widget_id);
5672 gtk_widget_add_accelerator (menuitem, "activate", accel_group,
5673 menu_keybindings[i].keyval,
5674 menu_keybindings[i].modifier,
5675 GTK_ACCEL_VISIBLE);
5676 }
5677
5678 gtk_builder_add_callback_symbols (ui,
5679 "menu_item_select_cb", G_CALLBACK (menu_item_select_cb)((GCallback) (menu_item_select_cb)),
5680 "menu_item_deselect_cb", G_CALLBACK (menu_item_deselect_cb)((GCallback) (menu_item_deselect_cb)),
5681 NULL((void*)0));
5682 gtk_builder_connect_signals (ui, window);
5683 /* open recent toolbar item action */
5684
5685 window->priv->menubar_recentmenu = fr_window_create_recent_chooser (window);
5686 menuitem = (GtkWidget *)gtk_builder_get_object (ui, "open_recent_item");
5687 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem)((((GtkMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, window->priv->menubar_recentmenu);
5688
5689 /* open recent toolbar item action */
5690 menuitem = (GtkWidget *)gtk_builder_get_object (ui, "tool_open_recent_item");
5691 window->priv->toolbar_recentmenu = fr_window_create_recent_chooser (window);
5692 gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (menuitem)((((GtkMenuToolButton*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((menuitem)), ((gtk_menu_tool_button_get_type
()))))))
, window->priv->toolbar_recentmenu);
5693
5694 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
5695 action = g_simple_action_new_stateful ("ViewAllFiles", G_VARIANT_TYPE ("s")(g_variant_type_checked_ (("s"))), g_variant_new_string ("files"));
5696 else
5697 action = g_simple_action_new_stateful ("ViewAllFiles", G_VARIANT_TYPE ("s")(g_variant_type_checked_ (("s"))), g_variant_new_string ("folder"));
5698
5699 g_action_map_add_action (G_ACTION_MAP (actions)((((GActionMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((actions)), ((g_action_map_get_type ()))))))
, G_ACTION (action)((((GAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((g_action_get_type ()))))))
);
5700 g_object_unref (action);
5701
5702 menubar = (GtkWidget *)gtk_builder_get_object (ui, "engrampamenubar");
5703 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, menubar, FR_WINDOW_AREA_MENUBAR);
5704 gtk_widget_show (menubar);
5705
5706 window->priv->toolbar = toolbar = (GtkWidget *)gtk_builder_get_object (ui, "engrampatoolbar");
5707 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((gtk_toolbar_get_type ()))))))
, TRUE(!(0)));
5708 gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar");
5709
5710 /* location bar */
5711
5712 window->priv->location_bar = (GtkWidget *)gtk_builder_get_object (ui, "locationbar");
5713 gtk_toolbar_set_show_arrow (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, FALSE(0));
5714 gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, GTK_TOOLBAR_BOTH_HORIZ);
5715 gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar), GTK_STYLE_CLASS_TOOLBAR"toolbar");
5716
5717 init_engramp_menu_popup (window, ui);
5718
5719 /* file list mode */
5720 menu_radio_files = (GtkWidget *)gtk_builder_get_object (ui, "view_all_files_item");
5721 g_signal_connect (G_OBJECT (menu_radio_files),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
5722 "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
5723 G_CALLBACK (view_all_files_selected_toggled),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
5724 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu_radio_files)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (view_all_files_selected_toggled
))), (window), ((void*)0), (GConnectFlags) 0)
;
5725 /* current location */
5726
5727 location_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
5728 /* Translators: after the colon there is a folder name. */
5729 window->priv->location_label = gtk_label_new_with_mnemonic (_("_Location:")gettext ("_Location:"));
5730 gtk_box_pack_start (GTK_BOX (location_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((location_box)), ((gtk_box_get_type ()))))))
,
5731 window->priv->location_label, FALSE(0), FALSE(0), 5);
5732
5733 window->priv->location_entry = gtk_entry_new ();
5734 gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->location_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_entry)), ((gtk_entry_get_type
()))))))
,
5735 GTK_ENTRY_ICON_PRIMARY,
5736 "folder");
5737 gtk_label_set_mnemonic_widget (GTK_LABEL (window->priv->location_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_label)), ((gtk_label_get_type
()))))))
,
5738 window->priv->location_entry);
5739
5740 gtk_box_pack_start (GTK_BOX (location_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((location_box)), ((gtk_box_get_type ()))))))
,
5741 window->priv->location_entry, TRUE(!(0)), TRUE(!(0)), 5);
5742
5743 g_signal_connect (G_OBJECT (window->priv->location_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
5744 "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
5745 G_CALLBACK (location_entry_key_press_event_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
5746 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->location_entry)), ((
(GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback
) (location_entry_key_press_event_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
5747
5748 {
5749 GtkToolItem *tool_item;
5750
5751 tool_item = gtk_separator_tool_item_new ();
5752 gtk_widget_show_all (GTK_WIDGET (tool_item)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tool_item)), ((gtk_widget_get_type ()))))))
);
5753 gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, tool_item, -1);
5754
5755 tool_item = gtk_tool_item_new ();
5756 gtk_tool_item_set_expand (tool_item, TRUE(!(0)));
5757 gtk_container_add (GTK_CONTAINER (tool_item)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tool_item)), ((gtk_container_get_type ()))))))
, location_box);
5758 gtk_widget_show_all (GTK_WIDGET (tool_item)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tool_item)), ((gtk_widget_get_type ()))))))
);
5759 gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->location_bar)), ((gtk_toolbar_get_type
()))))))
, tool_item, -1);
5760 }
5761
5762 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR);
5763 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
5764 gtk_widget_hide (window->priv->location_bar);
5765 else
5766 gtk_widget_show (window->priv->location_bar);
5767
5768 /**/
5769
5770 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->toolbar, FR_WINDOW_AREA_TOOLBAR);
5771 if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar"))
5772 gtk_widget_show (toolbar);
5773 else
5774 gtk_widget_hide (toolbar);
5775
5776 window->priv->file_popup_menu = (GtkWidget *)gtk_builder_get_object (ui, "FilePopupMenu");
5777 window->priv->folder_popup_menu = (GtkWidget *)gtk_builder_get_object (ui, "FolderPopupMenu");
5778 window->priv->sidebar_folder_popup_menu = (GtkWidget *)gtk_builder_get_object (ui, "SidebarFolderPopupMenu");
5779
5780 /* Create the statusbar. */
5781
5782 window->priv->statusbar = gtk_statusbar_new ();
5783 window->priv->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, "help_message");
5784 window->priv->list_info_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, "list_info");
5785 window->priv->progress_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
, "progress");
5786
5787 statusbar = GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
;
5788
5789 /*reduce size of statusbar */
5790 gtk_widget_set_margin_top (GTK_WIDGET (statusbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar)), ((gtk_widget_get_type ()))))))
, 0);
5791 gtk_widget_set_margin_bottom (GTK_WIDGET (statusbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar)), ((gtk_widget_get_type ()))))))
, 0);
5792
5793 statusbar_box = gtk_statusbar_get_message_area (statusbar);
5794 gtk_box_set_homogeneous (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, FALSE(0));
5795 gtk_box_set_spacing (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, 4);
5796 gtk_box_set_child_packing (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, gtk_statusbar_get_message_area (statusbar), TRUE(!(0)), TRUE(!(0)), 0, GTK_PACK_START );
5797
5798 window->priv->progress_bar = gtk_progress_bar_new ();
5799 gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
, ACTIVITY_PULSE_STEP(0.033));
5800 gtk_widget_set_size_request (window->priv->progress_bar, -1, PROGRESS_BAR_HEIGHT10);
5801 {
5802 GtkWidget *vbox;
5803
5804 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
5805 gtk_box_pack_start (GTK_BOX (statusbar_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((statusbar_box)), ((gtk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
5806 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, window->priv->progress_bar, TRUE(!(0)), TRUE(!(0)), 1);
5807 gtk_widget_show (vbox);
5808 }
5809 gtk_widget_show (statusbar_box);
5810
5811 fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((fr_window_get_type ()))))))
, window->priv->statusbar, FR_WINDOW_AREA_STATUSBAR);
5812 if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar"))
5813 gtk_widget_show (window->priv->statusbar);
5814 else
5815 gtk_widget_hide (window->priv->statusbar);
5816
5817 /**/
5818
5819 fr_window_update_title (window);
5820 fr_window_update_sensitivity (window);
5821 fr_window_update_file_list (window, FALSE(0));
5822 fr_window_update_dir_tree (window);
5823 fr_window_update_current_location (window);
5824 fr_window_update_columns_visibility (window);
5825
5826 /* Add notification callbacks. */
5827
5828 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
5829 "changed::" PREF_UI_HISTORY_LEN,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
5830 G_CALLBACK (pref_history_len_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
5831 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"history-len"), (((GCallback) (pref_history_len_changed))), (
window), ((void*)0), (GConnectFlags) 0)
;
5832 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5833 "changed::" PREF_UI_VIEW_TOOLBAR,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5834 G_CALLBACK (pref_view_toolbar_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5835 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-toolbar"), (((GCallback) (pref_view_toolbar_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
;
5836 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5837 "changed::" PREF_UI_VIEW_STATUSBAR,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5838 G_CALLBACK (pref_view_statusbar_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5839 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-statusbar"), (((GCallback) (pref_view_statusbar_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5840 g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5841 "changed::" PREF_UI_VIEW_FOLDERS,g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5842 G_CALLBACK (pref_view_folders_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
5843 window)g_signal_connect_data ((window->priv->settings_ui), ("changed::"
"view-folders"), (((GCallback) (pref_view_folders_changed)))
, (window), ((void*)0), (GConnectFlags) 0)
;
5844 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5845 "changed::" PREF_LISTING_SHOW_TYPE,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5846 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5847 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-type"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5848 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5849 "changed::" PREF_LISTING_SHOW_SIZE,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5850 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5851 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-size"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5852 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5853 "changed::" PREF_LISTING_SHOW_TIME,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5854 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5855 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-time"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5856 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5857 "changed::" PREF_LISTING_SHOW_PATH,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5858 G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5859 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "show-path"), (((GCallback) (pref_show_field_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5860 g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5861 "changed::" PREF_LISTING_USE_MIME_ICONS,g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5862 G_CALLBACK (pref_use_mime_icons_changed),g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5863 window)g_signal_connect_data ((window->priv->settings_listing)
, ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5864
5865 if (window->priv->settings_caja)
5866 g_signal_connect (window->priv->settings_caja,g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5867 "changed::" CAJA_CLICK_POLICY,g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5868 G_CALLBACK (pref_click_policy_changed),g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
5869 window)g_signal_connect_data ((window->priv->settings_caja), (
"changed::" "click-policy"), (((GCallback) (pref_click_policy_changed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5870
5871 /* Give focus to the list. */
5872
5873 gtk_widget_grab_focus (window->priv->list_view);
5874}
5875
5876GtkWidget *
5877fr_window_new (void)
5878{
5879 GtkWidget *window;
5880
5881 window = g_object_new (FR_TYPE_WINDOW(fr_window_get_type ()), "application", g_application_get_default (), NULL((void*)0));
5882 fr_window_construct ((FrWindow*) window);
5883
5884 return window;
5885}
5886
5887static void
5888fr_window_set_archive_uri (FrWindow *window,
5889 const char *uri)
5890{
5891 if (window->priv->archive_uri != NULL((void*)0))
5892 g_free (window->priv->archive_uri);
5893 window->priv->archive_uri = g_strdup (uri)g_strdup_inline (uri);
5894}
5895
5896gboolean
5897fr_window_archive_new (FrWindow *window,
5898 const char *uri)
5899{
5900 g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return ((0)); } } while (0)
;
5901
5902 if (! fr_archive_create (window->archive, uri)) {
5903 GtkWindow *file_sel = g_object_get_data (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "fr_file_sel");
5904
5905 window->priv->load_error_parent_window = file_sel;
5906 fr_archive_action_completed (window->archive,
5907 FR_ACTION_CREATING_NEW_ARCHIVE,
5908 FR_PROC_ERROR_GENERIC,
5909 _("Archive type not supported.")gettext ("Archive type not supported."));
5910
5911 return FALSE(0);
5912 }
5913
5914 fr_window_set_archive_uri (window, uri);
5915 window->priv->archive_present = TRUE(!(0));
5916 window->priv->archive_new = TRUE(!(0));
5917
5918 fr_archive_action_completed (window->archive,
5919 FR_ACTION_CREATING_NEW_ARCHIVE,
5920 FR_PROC_ERROR_NONE,
5921 NULL((void*)0));
5922
5923 return TRUE(!(0));
5924}
5925
5926FrWindow *
5927fr_window_archive_open (FrWindow *current_window,
5928 const char *uri,
5929 GtkWindow *parent)
5930{
5931 FrWindow *window = current_window;
5932
5933 if (current_window->priv->archive_present)
5934 window = (FrWindow *) fr_window_new ();
5935
5936 g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return ((0)); } } while (0)
;
5937
5938 fr_window_archive_close (window);
5939
5940 fr_window_set_archive_uri (window, uri);
5941 window->priv->archive_present = FALSE(0);
5942 window->priv->give_focus_to_the_list = TRUE(!(0));
5943 window->priv->load_error_parent_window = parent;
5944
5945 fr_window_set_current_batch_action (window,
5946 FR_BATCH_ACTION_LOAD,
5947 g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri),
5948 (GFreeFunc) g_free);
5949
5950 fr_archive_load (window->archive, window->priv->archive_uri, window->priv->password);
5951
5952 return window;
5953}
5954
5955void
5956fr_window_archive_close (FrWindow *window)
5957{
5958 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
5959
5960 if (! window->priv->archive_new && ! window->priv->archive_present)
5961 return;
5962
5963 fr_window_free_open_files (window);
5964 fr_clipboard_data_unref (window->priv->copy_data);
5965 window->priv->copy_data = NULL((void*)0);
5966
5967 fr_window_set_password (window, NULL((void*)0));
5968 fr_window_set_volume_size(window, 0);
5969 fr_window_history_clear (window);
5970
5971 window->priv->archive_new = FALSE(0);
5972 window->priv->archive_present = FALSE(0);
5973
5974 fr_window_update_title (window);
5975 fr_window_update_sensitivity (window);
5976 fr_window_update_file_list (window, FALSE(0));
5977 fr_window_update_dir_tree (window);
5978 fr_window_update_current_location (window);
5979 fr_window_update_statusbar_list_info (window);
5980}
5981
5982const char *
5983fr_window_get_archive_uri (FrWindow *window)
5984{
5985 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
5986
5987 return window->priv->archive_uri;
5988}
5989
5990const char *
5991fr_window_get_paste_archive_uri (FrWindow *window)
5992{
5993 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
5994
5995 if (window->priv->clipboard_data != NULL((void*)0))
5996 return window->priv->clipboard_data->archive_filename;
5997 else
5998 return NULL((void*)0);
5999}
6000
6001gboolean
6002fr_window_archive_is_present (FrWindow *window)
6003{
6004 g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return ((0)); } } while (0)
;
6005
6006 return window->priv->archive_present;
6007}
6008
6009typedef struct {
6010 char *uri;
6011 char *password;
6012 gboolean encrypt_header;
6013 guint volume_size;
6014} SaveAsData;
6015
6016static SaveAsData *
6017save_as_data_new (const char *uri,
6018 const char *password,
6019 gboolean encrypt_header,
6020 guint volume_size)
6021{
6022 SaveAsData *sdata;
6023
6024 sdata = g_new0 (SaveAsData, 1)((SaveAsData *) g_malloc0_n ((1), sizeof (SaveAsData)));
6025 if (uri != NULL((void*)0))
6026 sdata->uri = g_strdup (uri)g_strdup_inline (uri);
6027 if (password != NULL((void*)0))
6028 sdata->password = g_strdup (password)g_strdup_inline (password);
6029 sdata->encrypt_header = encrypt_header;
6030 sdata->volume_size = volume_size;
6031
6032 return sdata;
6033}
6034
6035static void
6036save_as_data_free (SaveAsData *sdata)
6037{
6038 if (sdata == NULL((void*)0))
6039 return;
6040 g_free (sdata->uri);
6041 g_free (sdata->password);
6042 g_free (sdata);
6043}
6044
6045void
6046fr_window_archive_save_as (FrWindow *window,
6047 const char *uri,
6048 const char *password,
6049 gboolean encrypt_header,
6050 guint volume_size)
6051{
6052 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6053 g_return_if_fail (uri != NULL)do { if ((uri != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "uri != NULL"); return
; } } while (0)
;
6054 g_return_if_fail (window->archive != NULL)do { if ((window->archive != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window->archive != NULL"
); return; } } while (0)
;
6055
6056 fr_window_convert_data_free (window, TRUE(!(0)));
6057 window->priv->convert_data.new_file = g_strdup (uri)g_strdup_inline (uri);
6058
6059 /* create the new archive */
6060
6061 window->priv->convert_data.new_archive = fr_archive_new ();
6062 if (! fr_archive_create (window->priv->convert_data.new_archive, uri)) {
6063 GtkWidget *d;
6064 char *utf8_name;
6065 char *message;
6066
6067 utf8_name = g_uri_display_basename (uri);
6068 message = g_strdup_printf (_("Could not save the archive \"%s\"")gettext ("Could not save the archive \"%s\""), utf8_name);
6069 g_free (utf8_name);
6070
6071 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6072 GTK_DIALOG_DESTROY_WITH_PARENT,
6073 NULL((void*)0),
6074 message,
6075 "%s",
6076 _("Archive type not supported.")gettext ("Archive type not supported."));
6077 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
6078 gtk_widget_destroy (d);
6079
6080 g_free (message);
6081
6082 g_object_unref (window->priv->convert_data.new_archive);
6083 window->priv->convert_data.new_archive = NULL((void*)0);
6084
6085 return;
6086 }
6087
6088 g_return_if_fail (window->priv->convert_data.new_archive->command != NULL)do { if ((window->priv->convert_data.new_archive->command
!= ((void*)0))) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "window->priv->convert_data.new_archive->command != NULL"
); return; } } while (0)
;
6089
6090 if (password != NULL((void*)0)) {
6091 window->priv->convert_data.password = g_strdup (password)g_strdup_inline (password);
6092 window->priv->convert_data.encrypt_header = encrypt_header;
6093 }
6094 else
6095 window->priv->convert_data.encrypt_header = FALSE(0);
6096 window->priv->convert_data.volume_size = volume_size;
6097
6098 fr_window_set_current_batch_action (window,
6099 FR_BATCH_ACTION_SAVE_AS,
6100 save_as_data_new (uri, password, encrypt_header, volume_size),
6101 (GFreeFunc) save_as_data_free);
6102
6103 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
6104 "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
6105 G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
6106 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
;
6107 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
6108 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
6109 G_CALLBACK (convert__action_performed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
6110 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (convert__action_performed))), (window), ((void*)0), (GConnectFlags
) 0)
;
6111 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6112 "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6113 G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6114 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
6115 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6116 "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6117 G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6118 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
6119 g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6120 "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6121 G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
6122 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->convert_data.new_archive
)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
6123
6124 window->priv->convert_data.converting = TRUE(!(0));
6125 window->priv->convert_data.temp_dir = get_temp_work_dir (NULL((void*)0));
6126
6127 fr_process_clear (window->archive->process);
6128 fr_archive_extract_to_local (window->archive,
6129 NULL((void*)0),
6130 window->priv->convert_data.temp_dir,
6131 NULL((void*)0),
6132 FALSE(0),
6133 TRUE(!(0)),
6134 FALSE(0),
6135 window->priv->password);
6136 fr_process_start (window->archive->process);
6137}
6138
6139void
6140fr_window_archive_reload (FrWindow *window)
6141{
6142 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6143
6144 if (window->priv->activity_ref > 0)
6145 return;
6146 if (window->priv->archive_new)
6147 return;
6148
6149 fr_archive_reload (window->archive, window->priv->password);
6150}
6151
6152/**/
6153
6154void
6155fr_window_archive_add_files (FrWindow *window,
6156 GList *file_list, /* GFile list */
6157 gboolean update)
6158{
6159 GFile *base;
6160 char *base_dir;
6161 int base_len;
6162 GList *files = NULL((void*)0);
6163 GList *scan;
6164 char *base_uri;
6165
6166 base = g_file_get_parent ((GFile *) file_list->data);
6167 base_dir = g_file_get_path (base);
6168 base_len = 0;
6169 if (strcmp (base_dir, "/") != 0)
6170 base_len = strlen (base_dir);
6171
6172 for (scan = file_list; scan; scan = scan->next) {
6173 GFile *file = scan->data;
6174 char *path;
6175 char *rel_path;
6176
6177 path = g_file_get_path (file);
6178 rel_path = g_strdup (path + base_len + 1)g_strdup_inline (path + base_len + 1);
6179 files = g_list_prepend (files, rel_path);
6180
6181 g_free (path);
6182 }
6183
6184 base_uri = g_file_get_uri (base);
6185
6186 fr_archive_add_files (window->archive,
6187 files,
6188 base_uri,
6189 fr_window_get_current_location (window),
6190 update,
6191 window->priv->password,
6192 window->priv->encrypt_header,
6193 window->priv->compression,
6194 window->priv->volume_size);
6195
6196 g_free (base_uri);
6197 path_list_free (files);
6198 g_free (base_dir);
6199 g_object_unref (base);
6200}
6201
6202void
6203fr_window_archive_add_with_wildcard (FrWindow *window,
6204 const char *include_files,
6205 const char *exclude_files,
6206 const char *exclude_folders,
6207 const char *base_dir,
6208 const char *dest_dir,
6209 gboolean update,
6210 gboolean follow_links)
6211{
6212 fr_archive_add_with_wildcard (window->archive,
6213 include_files,
6214 exclude_files,
6215 exclude_folders,
6216 base_dir,
6217 (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir,
6218 update,
6219 follow_links,
6220 window->priv->password,
6221 window->priv->encrypt_header,
6222 window->priv->compression,
6223 window->priv->volume_size);
6224}
6225
6226void
6227fr_window_archive_add_directory (FrWindow *window,
6228 const char *directory,
6229 const char *base_dir,
6230 const char *dest_dir,
6231 gboolean update)
6232{
6233 fr_archive_add_directory (window->archive,
6234 directory,
6235 base_dir,
6236 (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir,
6237 update,
6238 window->priv->password,
6239 window->priv->encrypt_header,
6240 window->priv->compression,
6241 window->priv->volume_size);
6242}
6243
6244void
6245fr_window_archive_add_items (FrWindow *window,
6246 GList *item_list,
6247 const char *base_dir,
6248 const char *dest_dir,
6249 gboolean update)
6250{
6251 fr_archive_add_items (window->archive,
6252 item_list,
6253 base_dir,
6254 (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir,
6255 update,
6256 window->priv->password,
6257 window->priv->encrypt_header,
6258 window->priv->compression,
6259 window->priv->volume_size);
6260}
6261
6262void
6263fr_window_archive_add_dropped_items (FrWindow *window,
6264 GList *item_list,
6265 gboolean update)
6266{
6267 fr_archive_add_dropped_items (window->archive,
6268 item_list,
6269 fr_window_get_current_location (window),
6270 fr_window_get_current_location (window),
6271 update,
6272 window->priv->password,
6273 window->priv->encrypt_header,
6274 window->priv->compression,
6275 window->priv->volume_size);
6276}
6277
6278static void
6279remove_data_free (GList *rdata)
6280{
6281 g_list_free_full(rdata, g_free);
6282}
6283
6284void
6285fr_window_archive_remove (FrWindow *window,
6286 GList *file_list)
6287{
6288 char *password;
6289 GList *remove_list;
6290
6291 fr_window_clipboard_remove_file_list (window, file_list);
6292
6293 fr_process_clear (window->archive->process);
6294
6295 remove_list = g_list_copy_deep (file_list, (GCopyFunc) g_strdup, NULL((void*)0));
6296 fr_window_set_current_batch_action (window,
6297 FR_BATCH_ACTION_DELETE,
6298 remove_list,
6299 (GFreeFunc) remove_data_free);
6300
6301 password = window->priv->password;
6302 if (password != NULL((void*)0) && password[0] != '\0')
6303 g_object_set (window->archive->command, "password", password, NULL((void*)0));
6304
6305 fr_archive_remove (window->archive, remove_list, window->priv->compression);
6306 fr_process_start (window->archive->process);
6307}
6308
6309/* -- window_archive_extract -- */
6310
6311static ExtractData*
6312extract_data_new (GList *file_list,
6313 const char *extract_to_dir,
6314 const char *sub_dir,
6315 const char *base_dir,
6316 gboolean skip_older,
6317 FrOverwrite overwrite,
6318 gboolean junk_paths,
6319 gboolean extract_here,
6320 gboolean ask_to_open_destination)
6321{
6322 ExtractData *edata;
6323 int i = 1;
6324
6325 edata = g_new0 (ExtractData, 1)((ExtractData *) g_malloc0_n ((1), sizeof (ExtractData)));
6326 edata->file_list = path_list_dup (file_list);
6327 if (sub_dir != NULL((void*)0))
6328 edata->sub_dir = g_strdup (sub_dir)g_strdup_inline (sub_dir);
6329 if (extract_to_dir != NULL((void*)0) && sub_dir == NULL((void*)0)) {
6330 edata->extract_to_dir = g_strdup (extract_to_dir)g_strdup_inline (extract_to_dir);
6331 } else if (extract_to_dir != NULL((void*)0) && sub_dir != NULL((void*)0)) {
6332 edata->extract_to_dir = g_build_filename (extract_to_dir, sub_dir, NULL((void*)0));
6333 while (uri_exists (edata->extract_to_dir) && uri_is_file (edata->extract_to_dir)) {
6334 g_free (edata->extract_to_dir);
6335 edata->extract_to_dir = g_strdup_printf ("%s/%s_%d", extract_to_dir, sub_dir, i++);
6336 }
6337 }
6338 edata->skip_older = skip_older;
6339 edata->overwrite = overwrite;
6340 edata->junk_paths = junk_paths;
6341 if (base_dir != NULL((void*)0))
6342 edata->base_dir = g_strdup (base_dir)g_strdup_inline (base_dir);
6343 edata->extract_here = extract_here;
6344 edata->ask_to_open_destination = ask_to_open_destination;
6345
6346 return edata;
6347}
6348
6349static ExtractData*
6350extract_to_data_new (const char *extract_to_dir)
6351{
6352 return extract_data_new (NULL((void*)0),
6353 extract_to_dir,
6354 NULL((void*)0),
6355 NULL((void*)0),
6356 FALSE(0),
6357 TRUE(!(0)),
6358 FALSE(0),
6359 FALSE(0),
6360 FALSE(0));
6361}
6362
6363static void
6364extract_data_free (ExtractData *edata)
6365{
6366 g_return_if_fail (edata != NULL)do { if ((edata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "edata != NULL");
return; } } while (0)
;
6367
6368 path_list_free (edata->file_list);
6369 g_free (edata->extract_to_dir);
6370 g_free (edata->sub_dir);
6371 g_free (edata->base_dir);
6372
6373 g_free (edata);
6374}
6375
6376static gboolean
6377archive_is_encrypted (FrWindow *window,
6378 GList *file_list)
6379{
6380 gboolean encrypted = FALSE(0);
6381
6382 if (file_list == NULL((void*)0)) {
6383 guint i;
6384
6385 for (i = 0; ! encrypted && i < window->archive->command->files->len; i++) {
6386 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
6387
6388 if (fdata->encrypted)
6389 encrypted = TRUE(!(0));
6390 }
6391 }
6392 else {
6393
6394 GHashTable *file_hash;
6395 guint i;
6396 GList *scan;
6397
6398 file_hash = g_hash_table_new (g_str_hash, g_str_equal);
6399 for (i = 0; i < window->archive->command->files->len; i++) {
6400 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
6401 g_hash_table_insert (file_hash, fdata->original_path, fdata);
6402 }
6403
6404 for (scan = file_list; ! encrypted && scan; scan = scan->next) {
6405 char *filename = scan->data;
6406 FileData *fdata;
6407
6408 fdata = g_hash_table_lookup (file_hash, filename);
6409 g_return_val_if_fail (fdata != NULL, FALSE)do { if ((fdata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "fdata != NULL");
return ((0)); } } while (0)
;
6410
6411 if (fdata->encrypted)
6412 encrypted = TRUE(!(0));
6413 }
6414
6415 g_hash_table_destroy (file_hash);
6416 }
6417
6418 return encrypted;
6419}
6420
6421static gboolean
6422archive_extract_check_disk_space_full (GPtrArray *files,
6423 const char *extract_to_dir)
6424{
6425 guint64 freespace;
6426 guint64 archive_size = 0;
6427 guint i;
6428
6429 freespace = get_dest_free_space (g_filename_from_uri (extract_to_dir, NULL((void*)0), NULL((void*)0)));
6430
6431 for (i = 0; i <files->len; i++)
6432 {
6433 FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i];
6434 archive_size += fdata->size;
6435 }
6436 /* When the decompressed target file is less than 100MB,
6437 2 * (target file size) needs to disk space
6438 and when it is greater than 100MB,
6439 100MB + (target file size) needs to disk space */
6440
6441 if (archive_size <= 1024 * 1024 * 100)
6442 archive_size = archive_size * 2;
6443 else
6444 archive_size += 1024 * 1024 * 100;
6445
6446 return freespace < archive_size * 2;
6447}
6448
6449void
6450fr_window_archive_extract_here (FrWindow *window,
6451 gboolean skip_older,
6452 FrOverwrite overwrite,
6453 gboolean junk_paths)
6454{
6455 ExtractData *edata;
6456
6457 edata = extract_data_new (NULL((void*)0),
6458 NULL((void*)0),
6459 NULL((void*)0),
6460 NULL((void*)0),
6461 skip_older,
6462 overwrite,
6463 junk_paths,
6464 TRUE(!(0)),
6465 FALSE(0));
6466 fr_window_set_current_batch_action (window,
6467 FR_BATCH_ACTION_EXTRACT_INTERACT,
6468 edata,
6469 (GFreeFunc) extract_data_free);
6470
6471 if (archive_is_encrypted (window, NULL((void*)0)) && (window->priv->password == NULL((void*)0))) {
6472 dlg_ask_password (window);
6473 return;
6474 }
6475
6476 window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination;
6477
6478 fr_process_clear (window->archive->process);
6479 if (fr_archive_extract_here (window->archive,
6480 edata->skip_older,
6481 edata->overwrite,
6482 edata->junk_paths,
6483 window->priv->password))
6484 {
6485 fr_process_start (window->archive->process);
6486 }
6487}
6488
6489/* -- fr_window_archive_extract -- */
6490
6491typedef struct {
6492 FrWindow *window;
6493 ExtractData *edata;
6494 GList *current_file;
6495 gboolean extract_all;
6496} OverwriteData;
6497
6498#define _FR_RESPONSE_OVERWRITE_YES_ALL100 100
6499#define _FR_RESPONSE_OVERWRITE_YES101 101
6500#define _FR_RESPONSE_OVERWRITE_NO102 102
6501
6502static void
6503_fr_window_archive_extract_from_edata (FrWindow *window,
6504 ExtractData *edata)
6505{
6506 window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination;
6507
6508 fr_process_clear (window->archive->process);
6509 fr_archive_extract (window->archive,
6510 edata->file_list,
6511 edata->extract_to_dir,
6512 edata->base_dir,
6513 edata->skip_older,
6514 edata->overwrite == FR_OVERWRITE_YES,
6515 edata->junk_paths,
6516 window->priv->password);
6517 fr_process_start (window->archive->process);
6518}
6519
6520static void _fr_window_ask_overwrite_dialog (OverwriteData *odata);
6521
6522static void
6523overwrite_dialog_response_cb (GtkDialog *dialog,
6524 int response_id,
6525 gpointer user_data)
6526{
6527 OverwriteData *odata = user_data;
6528 gboolean do_not_extract = FALSE(0);
6529
6530 switch (response_id) {
6531 case _FR_RESPONSE_OVERWRITE_YES_ALL100:
6532 odata->edata->overwrite = FR_OVERWRITE_YES;
6533 break;
6534
6535 case _FR_RESPONSE_OVERWRITE_YES101:
6536 odata->current_file = odata->current_file->next;
6537 break;
6538
6539 case _FR_RESPONSE_OVERWRITE_NO102:
6540 {
6541 /* remove the file from the list to extract */
6542 GList *next = odata->current_file->next;
6543 odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file);
6544 path_list_free (odata->current_file);
6545 odata->current_file = next;
6546 odata->extract_all = FALSE(0);
6547 }
6548 break;
6549
6550 case GTK_RESPONSE_DELETE_EVENT:
6551 case GTK_RESPONSE_CANCEL:
6552 do_not_extract = TRUE(!(0));
6553 break;
6554
6555 default:
6556 break;
6557 }
6558
6559 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
6560
6561 if (do_not_extract) {
6562 fr_window_stop_batch (odata->window);
6563 g_free (odata);
6564 return;
6565 }
6566
6567 _fr_window_ask_overwrite_dialog (odata);
6568}
6569
6570static void
6571_fr_window_ask_overwrite_dialog (OverwriteData *odata)
6572{
6573 while ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL((void*)0))) {
6574 const char *base_name;
6575 char *e_base_name;
6576 char *dest_uri;
6577 GFile *file;
6578 GFileInfo *info;
6579 GFileType file_type;
6580
6581 base_name = _g_path_get_base_name ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths);
6582 e_base_name = g_uri_escape_string (base_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH"!$&'()*+,;=" ":@" "/", TRUE(!(0)));
6583 dest_uri = g_strdup_printf ("%s/%s", odata->edata->extract_to_dir, e_base_name);
6584 file = g_file_new_for_uri (dest_uri);
6585 info = g_file_query_info (file,
6586 G_FILE_ATTRIBUTE_STANDARD_TYPE"standard::type" "," G_FILE_ATTRIBUTE_STANDARD_NAME"standard::name" "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME"standard::display-name",
6587 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
6588 NULL((void*)0),
6589 NULL((void*)0));
6590
6591 g_free (dest_uri);
6592 g_free (e_base_name);
6593
6594 if (info == NULL((void*)0)) {
6595 g_object_unref (file);
6596 odata->current_file = odata->current_file->next;
6597 continue;
6598 }
6599
6600 file_type = g_file_info_get_file_type (info);
6601 if ((file_type != G_FILE_TYPE_UNKNOWN) && (file_type != G_FILE_TYPE_DIRECTORY)) {
6602 char *msg;
6603 GFile *parent;
6604 char *parent_name;
6605 char *details;
6606 GtkWidget *d;
6607
6608 msg = g_strdup_printf (_("Replace file \"%s\"?")gettext ("Replace file \"%s\"?"), g_file_info_get_display_name (info));
6609 parent = g_file_get_parent (file);
6610 parent_name = g_file_get_parse_name (parent);
6611 details = g_strdup_printf (_("Another file with the same name already exists in \"%s\".")gettext ("Another file with the same name already exists in \"%s\"."
)
, parent_name);
6612 d = _gtk_message_dialog_new (GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
,
6613 GTK_DIALOG_MODAL,
6614 "dialog-question",
6615 msg,
6616 details,
6617 "gtk-cancel", GTK_RESPONSE_CANCEL,
6618 _("Replace _All")gettext ("Replace _All"), _FR_RESPONSE_OVERWRITE_YES_ALL100,
6619 _("_Skip")gettext ("_Skip"), _FR_RESPONSE_OVERWRITE_NO102,
6620 _("_Replace")gettext ("_Replace"), _FR_RESPONSE_OVERWRITE_YES101,
6621 NULL((void*)0));
6622 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, _FR_RESPONSE_OVERWRITE_YES101);
6623 g_signal_connect (d,g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
6624 "response",g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
6625 G_CALLBACK (overwrite_dialog_response_cb),g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
6626 odata)g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
;
6627 gtk_widget_show (d);
6628
6629 g_free (parent_name);
6630 g_object_unref (parent);
6631 g_object_unref (info);
6632 g_object_unref (file);
6633
6634 return;
6635 }
6636 else
6637 odata->current_file = odata->current_file->next;
6638
6639 g_object_unref (info);
6640 g_object_unref (file);
6641 }
6642
6643 if (odata->edata->file_list != NULL((void*)0)) {
6644 /* speed optimization: passing NULL when extracting all the
6645 * files is faster if the command supports the
6646 * propCanExtractAll property. */
6647 if (odata->extract_all) {
6648 path_list_free (odata->edata->file_list);
6649 odata->edata->file_list = NULL((void*)0);
6650 }
6651 odata->edata->overwrite = FR_OVERWRITE_YES;
6652 _fr_window_archive_extract_from_edata (odata->window, odata->edata);
6653 }
6654 else {
6655 GtkWidget *d;
6656
6657 d = _gtk_message_dialog_new (GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
,
6658 0,
6659 "dialog-warning",
6660 _("Extraction not performed")gettext ("Extraction not performed"),
6661 NULL((void*)0),
6662 "gtk-ok", GTK_RESPONSE_OK,
6663 NULL((void*)0));
6664 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
6665 fr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
, _("Extraction not performed")gettext ("Extraction not performed"));
6666
6667 fr_window_stop_batch (odata->window);
6668 }
6669 g_free (odata);
6670}
6671
6672void
6673fr_window_archive_extract (FrWindow *window,
6674 GList *file_list,
6675 const char *extract_to_dir,
6676 const char *sub_dir,
6677 const char *base_dir,
6678 gboolean skip_older,
6679 FrOverwrite overwrite,
6680 gboolean junk_paths,
6681 gboolean ask_to_open_destination)
6682{
6683 ExtractData *edata;
6684 gboolean do_not_extract = FALSE(0);
6685 GError *error = NULL((void*)0);
6686
6687 edata = extract_data_new (file_list,
6688 extract_to_dir,
6689 sub_dir,
6690 base_dir,
6691 skip_older,
6692 overwrite,
6693 junk_paths,
6694 FALSE(0),
6695 ask_to_open_destination);
6696
6697 fr_window_set_current_batch_action (window,
6698 FR_BATCH_ACTION_EXTRACT_INTERACT,
6699 edata,
6700 (GFreeFunc) extract_data_free);
6701
6702 if (archive_extract_check_disk_space_full (window->archive->command->files, extract_to_dir))
6703 {
6704 GtkWidget *d;
6705
6706 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6707 GTK_DIALOG_MODAL,
6708 NULL((void*)0),
6709 _("Insufficient remaining disk space")gettext ("Insufficient remaining disk space"),
6710 NULL((void*)0));
6711 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
6712 gtk_widget_destroy(d);
6713 return;
6714 }
6715
6716 if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL((void*)0))) {
6717 dlg_ask_password (window);
6718 return;
6719 }
6720
6721 if (! uri_is_dir (edata->extract_to_dir)) {
6722
6723 /* There is nothing to ask if the destination doesn't exist. */
6724 if (edata->overwrite == FR_OVERWRITE_ASK)
6725 edata->overwrite = FR_OVERWRITE_YES;
6726
6727 if (! ForceDirectoryCreation) {
6728 GtkWidget *d;
6729 int r;
6730 char *folder_name;
6731 char *msg;
6732
6733 folder_name = g_filename_display_name (edata->extract_to_dir);
6734 msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?")gettext ("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"
)
, folder_name);
6735 g_free (folder_name);
6736
6737 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6738 GTK_DIALOG_MODAL,
6739 "dialog-question",
6740 msg,
6741 NULL((void*)0),
6742 "gtk-cancel", GTK_RESPONSE_CANCEL,
6743 _("Create _Folder")gettext ("Create _Folder"), GTK_RESPONSE_YES,
6744 NULL((void*)0));
6745
6746 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_YES);
6747 r = gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
6748 gtk_widget_destroy (GTK_WIDGET (d)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_widget_get_type ()))))))
);
6749
6750 g_free (msg);
6751
6752 if (r != GTK_RESPONSE_YES)
6753 do_not_extract = TRUE(!(0));
6754 }
6755
6756 if (! do_not_extract && ! ensure_dir_exists (edata->extract_to_dir, 0755, &error)) {
6757 GtkWidget *d;
6758 char *details;
6759
6760 details = g_strdup_printf (_("Could not create the destination folder: %s.")gettext ("Could not create the destination folder: %s."), error->message);
6761 d = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6762 0,
6763 NULL((void*)0),
6764 _("Extraction not performed")gettext ("Extraction not performed"),
6765 "%s",
6766 details);
6767 g_clear_error (&error);
6768 fr_window_show_error_dialog (window, d, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, details);
6769 fr_window_stop_batch (window);
6770
6771 g_free (details);
6772
6773 return;
6774 }
6775 }
6776
6777 if (do_not_extract) {
6778 GtkWidget *d;
6779
6780 d = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
6781 0,
6782 "dialog-warning",
6783 _("Extraction not performed")gettext ("Extraction not performed"),
6784 NULL((void*)0),
6785 "gtk-ok", GTK_RESPONSE_OK,
6786 NULL((void*)0));
6787 gtk_dialog_set_default_response (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
6788 fr_window_show_error_dialog (window, d, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, _("Extraction not performed")gettext ("Extraction not performed"));
6789 fr_window_stop_batch (window);
6790
6791 return;
6792 }
6793
6794 if (edata->overwrite == FR_OVERWRITE_ASK) {
6795 OverwriteData *odata;
6796
6797 odata = g_new0 (OverwriteData, 1)((OverwriteData *) g_malloc0_n ((1), sizeof (OverwriteData)));
6798 odata->window = window;
6799 odata->edata = edata;
6800 odata->extract_all = (edata->file_list == NULL((void*)0)) || (g_list_length (edata->file_list) == window->archive->command->files->len);
6801 if (edata->file_list == NULL((void*)0))
6802 edata->file_list = fr_window_get_file_list (window);
6803 odata->current_file = odata->edata->file_list;
6804 _fr_window_ask_overwrite_dialog (odata);
6805 }
6806 else
6807 _fr_window_archive_extract_from_edata (window, edata);
6808}
6809
6810void
6811fr_window_archive_test (FrWindow *window)
6812{
6813 fr_window_set_current_batch_action (window,
6814 FR_BATCH_ACTION_TEST,
6815 NULL((void*)0),
6816 NULL((void*)0));
6817 fr_archive_test (window->archive, window->priv->password);
6818}
6819
6820void
6821fr_window_set_password (FrWindow *window,
6822 const char *password)
6823{
6824 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6825
6826 if (window->priv->password != NULL((void*)0)) {
6827 g_free (window->priv->password);
6828 window->priv->password = NULL((void*)0);
6829 }
6830
6831 if ((password != NULL((void*)0)) && (password[0] != '\0'))
6832 window->priv->password = g_strdup (password)g_strdup_inline (password);
6833}
6834
6835void
6836fr_window_set_password_for_paste (FrWindow *window,
6837 const char *password)
6838{
6839 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6840
6841 if (window->priv->password_for_paste != NULL((void*)0)) {
6842 g_free (window->priv->password_for_paste);
6843 window->priv->password_for_paste = NULL((void*)0);
6844 }
6845
6846 if ((password != NULL((void*)0)) && (password[0] != '\0'))
6847 window->priv->password_for_paste = g_strdup (password)g_strdup_inline (password);
6848}
6849
6850const char *
6851fr_window_get_password (FrWindow *window)
6852{
6853 g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return (((void*)0)); } } while (0)
;
6854
6855 return window->priv->password;
6856}
6857
6858void
6859fr_window_set_encrypt_header (FrWindow *window,
6860 gboolean encrypt_header)
6861{
6862 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6863
6864 window->priv->encrypt_header = encrypt_header;
6865}
6866
6867gboolean
6868fr_window_get_encrypt_header (FrWindow *window)
6869{
6870 return window->priv->encrypt_header;
6871}
6872
6873void
6874fr_window_set_compression (FrWindow *window,
6875 FrCompression compression)
6876{
6877 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6878
6879 window->priv->compression = compression;
6880}
6881
6882FrCompression
6883fr_window_get_compression (FrWindow *window)
6884{
6885 return window->priv->compression;
6886}
6887
6888void
6889fr_window_set_volume_size (FrWindow *window,
6890 guint volume_size)
6891{
6892 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6893
6894 window->priv->volume_size = volume_size;
6895}
6896
6897guint
6898fr_window_get_volume_size (FrWindow *window)
6899{
6900 return window->priv->volume_size;
6901}
6902
6903void
6904fr_window_go_to_location (FrWindow *window,
6905 const char *path,
6906 gboolean force_update)
6907{
6908 char *dir;
6909
6910 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6911 g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "path != NULL"); return
; } } while (0)
;
6912
6913 if (force_update) {
6914 g_free (window->priv->last_location);
6915 window->priv->last_location = NULL((void*)0);
6916 }
6917
6918 if (path[strlen (path) - 1] != '/')
6919 dir = g_strconcat (path, "/", NULL((void*)0));
6920 else
6921 dir = g_strdup (path)g_strdup_inline (path);
6922
6923 if ((window->priv->last_location == NULL((void*)0)) || (strcmp (window->priv->last_location, dir) != 0)) {
6924 g_free (window->priv->last_location);
6925 window->priv->last_location = dir;
6926
6927 fr_window_history_add (window, dir);
6928 fr_window_update_file_list (window, TRUE(!(0)));
6929 fr_window_update_current_location (window);
6930 }
6931 else
6932 g_free (dir);
6933}
6934
6935const char *
6936fr_window_get_current_location (FrWindow *window)
6937{
6938 if (window->priv->history_current == NULL((void*)0)) {
6939 fr_window_history_add (window, "/");
6940 return window->priv->history_current->data;
6941 }
6942 else
6943 return (const char*) window->priv->history_current->data;
6944}
6945
6946void
6947fr_window_go_up_one_level (FrWindow *window)
6948{
6949 char *parent_dir;
6950
6951 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6952
6953 parent_dir = get_parent_dir (fr_window_get_current_location (window));
6954 fr_window_go_to_location (window, parent_dir, FALSE(0));
6955 g_free (parent_dir);
6956}
6957
6958void
6959fr_window_go_back (FrWindow *window)
6960{
6961 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6962
6963 if (window->priv->history == NULL((void*)0))
6964 return;
6965 if (window->priv->history_current == NULL((void*)0))
6966 return;
6967 if (window->priv->history_current->next == NULL((void*)0))
6968 return;
6969 window->priv->history_current = window->priv->history_current->next;
6970
6971 fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0));
6972}
6973
6974void
6975fr_window_go_forward (FrWindow *window)
6976{
6977 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6978
6979 if (window->priv->history == NULL((void*)0))
6980 return;
6981 if (window->priv->history_current == NULL((void*)0))
6982 return;
6983 if (window->priv->history_current->prev == NULL((void*)0))
6984 return;
6985 window->priv->history_current = window->priv->history_current->prev;
6986
6987 fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0));
6988}
6989
6990void
6991fr_window_set_list_mode (FrWindow *window,
6992 FrWindowListMode list_mode)
6993{
6994 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
6995
6996 window->priv->list_mode = window->priv->last_list_mode = list_mode;
6997 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) {
6998 fr_window_history_clear (window);
6999 fr_window_history_add (window, "/");
7000 }
7001
7002 g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode);
7003 g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT));
7004
7005 fr_window_update_file_list (window, TRUE(!(0)));
7006 fr_window_update_dir_tree (window);
7007 fr_window_update_current_location (window);
7008}
7009
7010GtkTreeModel *
7011fr_window_get_list_store (FrWindow *window)
7012{
7013 return GTK_TREE_MODEL (window->priv->list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_store)), ((gtk_tree_model_get_type
()))))))
;
7014}
7015
7016void
7017fr_window_find (FrWindow *window)
7018{
7019 window->priv->filter_mode = TRUE(!(0));
7020 gtk_widget_show (window->priv->filter_bar);
7021 gtk_widget_grab_focus (window->priv->filter_entry);
7022}
7023
7024void
7025fr_window_select_all (FrWindow *window)
7026{
7027 gtk_tree_selection_select_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
));
7028}
7029
7030void
7031fr_window_unselect_all (FrWindow *window)
7032{
7033 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
));
7034}
7035
7036void
7037fr_window_stop (FrWindow *window)
7038{
7039 if (! window->priv->stoppable)
7040 return;
7041
7042 if (window->priv->activity_ref > 0)
7043 fr_archive_stop (window->archive);
7044
7045 if (window->priv->convert_data.converting)
7046 fr_window_convert_data_free (window, TRUE(!(0)));
7047}
7048
7049/* -- start/stop activity mode -- */
7050
7051static int
7052activity_cb (gpointer data)
7053{
7054 FrWindow *window = data;
7055
7056 if ((window->priv->pd_progress_bar != NULL((void*)0)) && window->priv->progress_pulse)
7057 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
);
7058 if (window->priv->progress_pulse)
7059 gtk_progress_bar_pulse (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
);
7060
7061 return TRUE(!(0));
7062}
7063
7064void
7065fr_window_start_activity_mode (FrWindow *window)
7066{
7067 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
7068
7069 if (window->priv->activity_ref++ > 0)
7070 return;
7071
7072 window->priv->activity_timeout_handle = g_timeout_add (ACTIVITY_DELAY100,
7073 activity_cb,
7074 window);
7075 fr_window_update_sensitivity (window);
7076}
7077
7078void
7079fr_window_stop_activity_mode (FrWindow *window)
7080{
7081 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
7082
7083 if (window->priv->activity_ref == 0)
7084 return;
7085
7086 window->priv->activity_ref--;
7087
7088 if (window->priv->activity_ref > 0)
7089 return;
7090
7091 if (window->priv->activity_timeout_handle == 0)
7092 return;
7093
7094 g_source_remove (window->priv->activity_timeout_handle);
7095 window->priv->activity_timeout_handle = 0;
7096
7097 if (! gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
7098 return;
7099
7100 if (window->priv->progress_dialog != NULL((void*)0))
7101 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->pd_progress_bar)), ((gtk_progress_bar_get_type
()))))))
, 0.0);
7102
7103 if (! window->priv->batch_mode) {
7104 if (window->priv->progress_bar != NULL((void*)0))
7105 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress_bar)((((GtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_bar)), ((gtk_progress_bar_get_type
()))))))
, 0.0);
7106 fr_window_update_sensitivity (window);
7107 }
7108}
7109
7110static gboolean
7111last_output_window__unrealize_cb (GtkWidget *widget,
7112 gpointer data)
7113{
7114 pref_util_save_window_geometry (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, LAST_OUTPUT_DIALOG_NAME"last-output");
7115 return FALSE(0);
7116}
7117
7118static void
7119fr_window_view_last_output_print(GtkTextBuffer *text_buffer,
7120 GtkTextIter *iter,
7121 GList *scan)
7122{
7123 for (; scan; scan = scan->next) {
7124 char *line = scan->data;
7125 char *utf8_line;
7126 gsize bytes_written;
7127
7128 utf8_line = g_locale_to_utf8 (line, -1, NULL((void*)0), &bytes_written, NULL((void*)0));
7129 gtk_text_buffer_insert_with_tags_by_name (text_buffer,
7130 iter,
7131 utf8_line,
7132 bytes_written,
7133 "monospace", NULL((void*)0));
7134 g_free (utf8_line);
7135 gtk_text_buffer_insert (text_buffer, iter, "\n", 1);
7136 }
7137}
7138
7139void
7140fr_window_view_last_output (FrWindow *window,
7141 const char *title)
7142{
7143 GtkWidget *dialog;
7144 GtkWidget *vbox;
7145 GtkWidget *text_view;
7146 GtkWidget *scrolled;
7147 GtkTextBuffer *text_buffer;
7148 GtkTextIter iter;
7149
7150 if (title == NULL((void*)0))
7151 title = _("Last Output")gettext ("Last Output");
7152
7153 dialog = gtk_dialog_new_with_buttons (title,
7154 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7155 /* Make this dialog modal, otherwise with most WMs
7156 * the focus can’t be regained without the mouse. */
7157 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
7158 "gtk-close", GTK_RESPONSE_CLOSE,
7159 NULL((void*)0));
7160 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_CLOSE);
7161 gtk_window_set_resizable (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
7162 gtk_widget_set_size_request (dialog, 500, 300);
7163
7164 /* Add text */
7165
7166 scrolled = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
7167 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
7168 GTK_POLICY_AUTOMATIC,
7169 GTK_POLICY_AUTOMATIC);
7170 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
7171 GTK_SHADOW_ETCHED_IN);
7172
7173 text_buffer = gtk_text_buffer_new (NULL((void*)0));
7174 gtk_text_buffer_create_tag (text_buffer, "monospace",
7175 "family", "monospace", NULL((void*)0));
7176
7177 text_view = gtk_text_view_new_with_buffer (text_buffer);
7178 g_object_unref (text_buffer);
7179 gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
, FALSE(0));
7180 /* Although this isn’t an editable text area, we do want the
7181 * cursor for accessibility purposes. */
7182 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
, TRUE(!(0)));
7183
7184 /**/
7185
7186 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
7187 gtk_container_set_border_width (GTK_CONTAINER (vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_container_get_type ()))))))
, 5);
7188
7189 gtk_container_add (GTK_CONTAINER (scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, text_view);
7190 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, scrolled,
7191 TRUE(!(0)), TRUE(!(0)), 0);
7192
7193 gtk_widget_show_all (vbox);
7194 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_box_get_type ()))))))
,
7195 vbox,
7196 TRUE(!(0)), TRUE(!(0)), 0);
7197
7198 /* signals */
7199
7200 g_signal_connect (G_OBJECT (dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
7201 "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
7202 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
7203 NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("response"), (((GCallback) (gtk_widget_destroy))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
;
7204
7205 g_signal_connect (G_OBJECT (dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
7206 "unrealize",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
7207 G_CALLBACK (last_output_window__unrealize_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
7208 NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
)))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
7209
7210 gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0);
7211 /* Show STDOUT of process */
7212 fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->out.raw);
7213 /* Show STDERR of process */
7214 fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->err.raw);
7215 /* place the cursor at the start */
7216 gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0);
7217 gtk_text_buffer_place_cursor(text_buffer, &iter);
7218
7219 /**/
7220
7221 pref_util_restore_window_geometry (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, LAST_OUTPUT_DIALOG_NAME"last-output");
7222 gtk_widget_grab_focus (text_view);
7223}
7224
7225/* -- fr_window_rename_selection -- */
7226
7227typedef struct {
7228 char *path_to_rename;
7229 char *old_name;
7230 char *new_name;
7231 char *current_dir;
7232 gboolean is_dir;
7233 gboolean dir_in_archive;
7234 char *original_path;
7235} RenameData;
7236
7237static RenameData*
7238rename_data_new (const char *path_to_rename,
7239 const char *old_name,
7240 const char *new_name,
7241 const char *current_dir,
7242 gboolean is_dir,
7243 gboolean dir_in_archive,
7244 const char *original_path)
7245{
7246 RenameData *rdata;
7247
7248 rdata = g_new0 (RenameData, 1)((RenameData *) g_malloc0_n ((1), sizeof (RenameData)));
5
Null pointer value stored to field 'old_name'
7249 rdata->path_to_rename = g_strdup (path_to_rename)g_strdup_inline (path_to_rename);
7250 if (old_name != NULL((void*)0))
6
Assuming 'old_name' is equal to NULL
7
Taking false branch
7251 rdata->old_name = g_strdup (old_name)g_strdup_inline (old_name);
7252 if (new_name != NULL((void*)0))
8
Assuming 'new_name' is equal to NULL
9
Taking false branch
7253 rdata->new_name = g_strdup (new_name)g_strdup_inline (new_name);
7254 if (current_dir != NULL((void*)0))
10
Assuming 'current_dir' is not equal to NULL
11
Taking true branch
7255 rdata->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir);
7256 rdata->is_dir = is_dir;
7257 rdata->dir_in_archive = dir_in_archive;
7258 if (original_path != NULL((void*)0))
12
Assuming 'original_path' is equal to NULL
13
Taking false branch
7259 rdata->original_path = g_strdup (original_path)g_strdup_inline (original_path);
7260
7261 return rdata;
7262}
7263
7264static void
7265rename_data_free (RenameData *rdata)
7266{
7267 g_return_if_fail (rdata != NULL)do { if ((rdata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "rdata != NULL");
return; } } while (0)
;
7268
7269 g_free (rdata->path_to_rename);
7270 g_free (rdata->old_name);
7271 g_free (rdata->new_name);
7272 g_free (rdata->current_dir);
7273 g_free (rdata->original_path);
7274 g_free (rdata);
7275}
7276
7277static void
7278rename_selection (FrWindow *window,
7279 const char *path_to_rename,
7280 const char *old_name,
7281 const char *new_name,
7282 const char *current_dir,
7283 gboolean is_dir,
7284 gboolean dir_in_archive,
7285 const char *original_path)
7286{
7287 FrArchive *archive = window->archive;
7288 RenameData *rdata;
7289 char *tmp_dir;
7290 GList *file_list;
7291 gboolean added_dir;
7292 char *new_dirname;
7293 GList *new_file_list;
7294 GList *scan;
7295
7296 rdata = rename_data_new (path_to_rename,
4
Calling 'rename_data_new'
14
Returning from 'rename_data_new'
7297 old_name,
7298 new_name,
7299 current_dir,
7300 is_dir,
7301 dir_in_archive,
7302 original_path);
7303 fr_window_set_current_batch_action (window,
15
Calling 'fr_window_set_current_batch_action'
17
Returning from 'fr_window_set_current_batch_action'
7304 FR_BATCH_ACTION_RENAME,
7305 rdata,
7306 (GFreeFunc) rename_data_free);
7307
7308 fr_process_clear (archive->process);
7309
7310 tmp_dir = get_temp_work_dir (NULL((void*)0));
7311
7312 if (is_dir)
18
Assuming 'is_dir' is 0
19
Taking false branch
7313 file_list = get_dir_list_from_path (window, rdata->path_to_rename);
7314 else
7315 file_list = g_list_append (NULL((void*)0), g_strdup (rdata->path_to_rename)g_strdup_inline (rdata->path_to_rename));
7316
7317 fr_archive_extract_to_local (archive,
7318 file_list,
7319 tmp_dir,
7320 NULL((void*)0),
7321 FALSE(0),
7322 TRUE(!(0)),
7323 FALSE(0),
7324 window->priv->password);
7325
7326 /* temporarily add the dir to rename to the list if it's stored in the
7327 * archive, this way it will be removed from the archive... */
7328 added_dir = FALSE(0);
7329 if (is_dir
19.1
'is_dir' is 0
&& dir_in_archive && ! g_list_find_custom (file_list, original_path, (GCompareFunc) strcmp)) {
7330 file_list = g_list_prepend (file_list, g_strdup (original_path)g_strdup_inline (original_path));
7331 added_dir = TRUE(!(0));
7332 }
7333
7334 fr_archive_remove (archive, file_list, window->priv->compression);
7335 fr_window_clipboard_remove_file_list (window, file_list);
7336
7337 /* ...and remove it from the list again */
7338 if (added_dir
19.2
'added_dir' is 0
) {
20
Taking false branch
7339 GList *tmp;
7340
7341 tmp = file_list;
7342 file_list = g_list_remove_link (file_list, tmp);
7343
7344 g_free (tmp->data);
7345 g_list_free (tmp);
7346 }
7347
7348 /* rename the files. */
7349
7350 new_dirname = g_build_filename (rdata->current_dir + 1, rdata->new_name, "/", NULL((void*)0));
7351 new_file_list = NULL((void*)0);
7352 if (rdata->is_dir
20.1
Field 'is_dir' is 0
) {
21
Taking false branch
7353 char *old_path;
7354 char *new_path;
7355
7356 old_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->old_name, NULL((void*)0));
7357 new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, NULL((void*)0));
7358
7359 fr_process_begin_command (archive->process, "mv");
7360 fr_process_add_arg (archive->process, "-f");
7361 fr_process_add_arg (archive->process, old_path);
7362 fr_process_add_arg (archive->process, new_path);
7363 fr_process_end_command (archive->process);
7364
7365 g_free (old_path);
7366 g_free (new_path);
7367 }
7368
7369 for (scan = file_list; scan; scan = scan->next) {
22
Loop condition is true. Entering loop body
7370 const char *current_dir_relative = rdata->current_dir + 1;
7371 const char *filename = (char*) scan->data;
7372 char *old_path = NULL((void*)0), *common = NULL((void*)0), *new_path = NULL((void*)0);
7373 char *new_filename;
7374
7375 old_path = g_build_filename (tmp_dir, filename, NULL((void*)0));
7376
7377 if (strlen (filename) > (strlen (rdata->current_dir) + strlen (rdata->old_name)))
23
Null pointer passed to 1st parameter expecting 'nonnull'
7378 common = g_strdup (filename + strlen (rdata->current_dir) + strlen (rdata->old_name))g_strdup_inline (filename + strlen (rdata->current_dir) + strlen
(rdata->old_name))
;
7379 new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, common, NULL((void*)0));
7380
7381 if (! rdata->is_dir) {
7382 fr_process_begin_command (archive->process, "mv");
7383 fr_process_add_arg (archive->process, "-f");
7384 fr_process_add_arg (archive->process, old_path);
7385 fr_process_add_arg (archive->process, new_path);
7386 fr_process_end_command (archive->process);
7387 }
7388
7389 new_filename = g_build_filename (current_dir_relative, rdata->new_name, common, NULL((void*)0));
7390 new_file_list = g_list_prepend (new_file_list, new_filename);
7391
7392 g_free (old_path);
7393 g_free (common);
7394 g_free (new_path);
7395 }
7396 new_file_list = g_list_reverse (new_file_list);
7397
7398 /* FIXME: this is broken for tar archives.
7399 if (is_dir && dir_in_archive && ! g_list_find_custom (new_file_list, new_dirname, (GCompareFunc) strcmp))
7400 new_file_list = g_list_prepend (new_file_list, g_build_filename (rdata->current_dir + 1, rdata->new_name, NULL));
7401 */
7402
7403 fr_archive_add (archive,
7404 new_file_list,
7405 tmp_dir,
7406 NULL((void*)0),
7407 FALSE(0),
7408 FALSE(0),
7409 window->priv->password,
7410 window->priv->encrypt_header,
7411 window->priv->compression,
7412 window->priv->volume_size);
7413
7414 g_free (new_dirname);
7415 path_list_free (new_file_list);
7416 path_list_free (file_list);
7417
7418 /* remove the tmp dir */
7419
7420 fr_process_begin_command (archive->process, "rm");
7421 fr_process_set_working_dir (archive->process, g_get_tmp_dir ());
7422 fr_process_set_sticky (archive->process, TRUE(!(0)));
7423 fr_process_add_arg (archive->process, "-rf");
7424 fr_process_add_arg (archive->process, tmp_dir);
7425 fr_process_end_command (archive->process);
7426
7427 fr_process_start (archive->process);
7428
7429 g_free (tmp_dir);
7430}
7431
7432static gboolean
7433valid_name (const char *new_name,
7434 const char *old_name,
7435 char **reason)
7436{
7437 char *utf8_new_name;
7438 gboolean retval = TRUE(!(0));
7439
7440 new_name = eat_spaces (new_name);
7441 utf8_new_name = g_filename_display_name (new_name);
7442
7443 if (*new_name == '\0') {
7444 /* Translators: the name references to a filename. This message can appear when renaming a file. */
7445 *reason = g_strdup (_("New name is void, please type a name."))g_strdup_inline (gettext ("New name is void, please type a name."
))
;
7446 retval = FALSE(0);
7447 }
7448 else if (strcmp (new_name, old_name) == 0) {
7449 /* Translators: the name references to a filename. This message can appear when renaming a file. */
7450 *reason = g_strdup (_("New name is the same as old one, please type other name."))g_strdup_inline (gettext ("New name is the same as old one, please type other name."
))
;
7451 retval = FALSE(0);
7452 }
7453 else if (strchrs (new_name, BAD_CHARS"/\\*")) {
7454 /* Translators: the %s references to a filename. This message can appear when renaming a file. */
7455 *reason = g_strdup_printf (_("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name.")gettext ("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name."
)
, utf8_new_name, BAD_CHARS"/\\*");
7456 retval = FALSE(0);
7457 }
7458
7459 g_free (utf8_new_name);
7460
7461 return retval;
7462}
7463
7464static gboolean
7465name_is_present (FrWindow *window,
7466 const char *current_dir,
7467 const char *new_name,
7468 char **reason)
7469{
7470 gboolean retval = FALSE(0);
7471 guint i;
7472 char *new_filename;
7473 int new_filename_l;
7474
7475 *reason = NULL((void*)0);
7476
7477 new_filename = g_build_filename (current_dir, new_name, NULL((void*)0));
7478 new_filename_l = strlen (new_filename);
7479
7480 for (i = 0; i < window->archive->command->files->len; i++) {
7481 FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i];
7482 const char *filename = fdata->full_path;
7483
7484 if ((strncmp (filename, new_filename, new_filename_l) == 0)
7485 && ((filename[new_filename_l] == '\0')
7486 || (filename[new_filename_l] == G_DIR_SEPARATOR'/'))) {
7487 char *utf8_name = g_filename_display_name (new_name);
7488
7489 if (filename[new_filename_l] == G_DIR_SEPARATOR'/')
7490 *reason = g_strdup_printf (_("A folder named \"%s\" already exists.\n\n%s")gettext ("A folder named \"%s\" already exists.\n\n%s"), utf8_name, _("Please use a different name.")gettext ("Please use a different name."));
7491 else
7492 *reason = g_strdup_printf (_("A file named \"%s\" already exists.\n\n%s")gettext ("A file named \"%s\" already exists.\n\n%s"), utf8_name, _("Please use a different name.")gettext ("Please use a different name."));
7493
7494 retval = TRUE(!(0));
7495 break;
7496 }
7497 }
7498
7499 g_free (new_filename);
7500
7501 return retval;
7502}
7503
7504void
7505fr_window_rename_selection (FrWindow *window,
7506 gboolean from_sidebar)
7507{
7508 char *path_to_rename;
7509 char *parent_dir;
7510 char *old_name;
7511 gboolean renaming_dir = FALSE(0);
7512 gboolean dir_in_archive = FALSE(0);
7513 char *original_path = NULL((void*)0);
7514 char *utf8_old_name;
7515 char *utf8_new_name;
7516
7517 if (from_sidebar) {
7518 path_to_rename = fr_window_get_selected_folder_in_tree_view (window);
7519 if (path_to_rename == NULL((void*)0))
7520 return;
7521 parent_dir = remove_level_from_path (path_to_rename);
7522 old_name = g_strdup (file_name_from_path (path_to_rename))g_strdup_inline (file_name_from_path (path_to_rename));
7523 renaming_dir = TRUE(!(0));
7524 }
7525 else {
7526 FileData *selected_item;
7527
7528 selected_item = fr_window_get_selected_item_from_file_list (window);
7529 if (selected_item == NULL((void*)0))
7530 return;
7531
7532 renaming_dir = file_data_is_dir (selected_item);
7533 dir_in_archive = selected_item->dir;
7534 original_path = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path);
7535
7536 if (renaming_dir && ! dir_in_archive) {
7537 parent_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
7538 old_name = g_strdup (selected_item->list_name)g_strdup_inline (selected_item->list_name);
7539 path_to_rename = g_build_filename (parent_dir, old_name, NULL((void*)0));
7540 }
7541 else {
7542 if (renaming_dir) {
7543 path_to_rename = remove_ending_separator (selected_item->full_path);
7544 parent_dir = remove_level_from_path (path_to_rename);
7545 }
7546 else {
7547 path_to_rename = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path);
7548 parent_dir = remove_level_from_path (selected_item->full_path);
7549 }
7550 old_name = g_strdup (selected_item->name)g_strdup_inline (selected_item->name);
7551 }
7552
7553 file_data_free (selected_item);
7554 }
7555
7556 retry__rename_selection:
7557 utf8_old_name = g_locale_to_utf8 (old_name, -1 ,0 ,0 ,0);
7558 utf8_new_name = _gtk_request_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7559 (GTK_DIALOG_DESTROY_WITH_PARENT
7560 | GTK_DIALOG_MODAL),
7561 _("Rename")gettext ("Rename"),
7562 (renaming_dir ? _("_New folder name:")gettext ("_New folder name:") : _("_New file name:")gettext ("_New file name:")),
7563 utf8_old_name,
7564 1024,
7565 _("_Cancel")gettext ("_Cancel"),
7566 _("_Rename")gettext ("_Rename"));
7567 g_free (utf8_old_name);
7568
7569 if (utf8_new_name != NULL((void*)0)) {
7570 char *new_name;
7571 char *reason = NULL((void*)0);
7572
7573 new_name = g_filename_from_utf8 (utf8_new_name, -1, 0, 0, 0);
7574 g_free (utf8_new_name);
7575
7576 if (! valid_name (new_name, old_name, &reason)) {
7577 char *utf8_name = g_filename_display_name (new_name);
7578 GtkWidget *dlg;
7579
7580 dlg = _gtk_error_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7581 GTK_DIALOG_DESTROY_WITH_PARENT,
7582 NULL((void*)0),
7583 (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")),
7584 "%s",
7585 reason);
7586 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
7587 gtk_widget_destroy (dlg);
7588
7589 g_free (reason);
7590 g_free (utf8_name);
7591 g_free (new_name);
7592
7593 goto retry__rename_selection;
7594 }
7595
7596 if (name_is_present (window, parent_dir, new_name, &reason)) {
7597 GtkWidget *dlg;
7598
7599 dlg = _gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7600 GTK_DIALOG_MODAL,
7601 "dialog-question",
7602 (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")),
7603 reason,
7604 "gtk-close", GTK_RESPONSE_OK,
7605 NULL((void*)0));
7606 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
7607 gtk_widget_destroy (dlg);
7608 g_free (reason);
7609 g_free (new_name);
7610 goto retry__rename_selection;
7611 }
7612
7613 rename_selection (window,
7614 path_to_rename,
7615 old_name,
7616 new_name,
7617 parent_dir,
7618 renaming_dir,
7619 dir_in_archive,
7620 original_path);
7621
7622 g_free (new_name);
7623 }
7624
7625 g_free (old_name);
7626 g_free (parent_dir);
7627 g_free (path_to_rename);
7628 g_free (original_path);
7629}
7630
7631static void
7632fr_clipboard_get (GtkClipboard *clipboard,
7633 GtkSelectionData *selection_data,
7634 guint info,
7635 gpointer user_data_or_owner)
7636{
7637 FrWindow *window = user_data_or_owner;
7638 char *data;
7639
7640 if (gtk_selection_data_get_target (selection_data) != FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
)
7641 return;
7642
7643 data = get_selection_data_from_clipboard_data (window, window->priv->copy_data);
7644 gtk_selection_data_set (selection_data,
7645 gtk_selection_data_get_target (selection_data),
7646 8,
7647 (guchar *) data,
7648 strlen (data));
7649 g_free (data);
7650}
7651
7652static void
7653fr_clipboard_clear (GtkClipboard *clipboard,
7654 gpointer user_data_or_owner)
7655{
7656 FrWindow *window = user_data_or_owner;
7657
7658 if (window->priv->copy_data != NULL((void*)0)) {
7659 fr_clipboard_data_unref (window->priv->copy_data);
7660 window->priv->copy_data = NULL((void*)0);
7661 }
7662}
7663
7664GList *
7665fr_window_get_selection (FrWindow *window,
7666 gboolean from_sidebar,
7667 char **return_base_dir)
7668{
7669 GList *files;
7670 char *base_dir;
7671
7672 if (from_sidebar) {
7673 char *selected_folder;
7674 char *parent_folder;
7675
7676 files = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0));
7677 selected_folder = fr_window_get_selected_folder_in_tree_view (window);
7678 parent_folder = remove_level_from_path (selected_folder);
7679 if (parent_folder == NULL((void*)0))
7680 base_dir = g_strdup ("/")g_strdup_inline ("/");
7681 else if (parent_folder[strlen (parent_folder) - 1] == '/')
7682 base_dir = g_strdup (parent_folder)g_strdup_inline (parent_folder);
7683 else
7684 base_dir = g_strconcat (parent_folder, "/", NULL((void*)0));
7685 g_free (selected_folder);
7686 g_free (parent_folder);
7687 }
7688 else {
7689 files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0));
7690 base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window));
7691 }
7692
7693 if (return_base_dir)
7694 *return_base_dir = base_dir;
7695 else
7696 g_free (base_dir);
7697
7698 return files;
7699}
7700
7701static void
7702fr_window_copy_or_cut_selection (FrWindow *window,
7703 FRClipboardOp op,
7704 gboolean from_sidebar)
7705{
7706 GList *files;
7707 char *base_dir;
7708 GtkClipboard *clipboard;
7709
7710 files = fr_window_get_selection (window, from_sidebar, &base_dir);
7711
7712 if (window->priv->copy_data != NULL((void*)0))
7713 fr_clipboard_data_unref (window->priv->copy_data);
7714 window->priv->copy_data = fr_clipboard_data_new ();
7715 window->priv->copy_data->files = files;
7716 window->priv->copy_data->op = op;
7717 window->priv->copy_data->base_dir = base_dir;
7718
7719 clipboard = gtk_clipboard_get (FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
7720 gtk_clipboard_set_with_owner (clipboard,
7721 clipboard_targets,
7722 G_N_ELEMENTS (clipboard_targets)(sizeof (clipboard_targets) / sizeof ((clipboard_targets)[0])
)
,
7723 fr_clipboard_get,
7724 fr_clipboard_clear,
7725 G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
);
7726
7727 fr_window_update_sensitivity (window);
7728}
7729
7730void
7731fr_window_copy_selection (FrWindow *window,
7732 gboolean from_sidebar)
7733{
7734 fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_COPY, from_sidebar);
7735}
7736
7737void
7738fr_window_cut_selection (FrWindow *window,
7739 gboolean from_sidebar)
7740{
7741 fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_CUT, from_sidebar);
7742}
7743
7744static gboolean
7745always_fake_load (FrArchive *archive,
7746 gpointer data)
7747{
7748 return TRUE(!(0));
7749}
7750
7751static void
7752add_pasted_files (FrWindow *window,
7753 FrClipboardData *data)
7754{
7755 const char *current_dir_relative = data->current_dir + 1;
7756 GList *scan;
7757 GList *new_file_list = NULL((void*)0);
7758
7759 if (window->priv->password_for_paste != NULL((void*)0)) {
7760 g_free (window->priv->password_for_paste);
7761 window->priv->password_for_paste = NULL((void*)0);
7762 }
7763
7764 fr_process_clear (window->archive->process);
7765 for (scan = data->files; scan; scan = scan->next) {
7766 const char *old_name = (char*) scan->data;
7767 char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0));
7768
7769 /* skip folders */
7770
7771 if ((strcmp (old_name, new_name) != 0)
7772 && (old_name[strlen (old_name) - 1] != '/'))
7773 {
7774 fr_process_begin_command (window->archive->process, "mv");
7775 fr_process_set_working_dir (window->archive->process, data->tmp_dir);
7776 fr_process_add_arg (window->archive->process, "-f");
7777 if (old_name[0] == '/')
7778 old_name = old_name + 1;
7779 fr_process_add_arg (window->archive->process, old_name);
7780 fr_process_add_arg (window->archive->process, new_name);
7781 fr_process_end_command (window->archive->process);
7782 }
7783
7784 new_file_list = g_list_prepend (new_file_list, new_name);
7785 }
7786
7787 fr_archive_add (window->archive,
7788 new_file_list,
7789 data->tmp_dir,
7790 NULL((void*)0),
7791 FALSE(0),
7792 FALSE(0),
7793 window->priv->password,
7794 window->priv->encrypt_header,
7795 window->priv->compression,
7796 window->priv->volume_size);
7797
7798 path_list_free (new_file_list);
7799
7800 /* remove the tmp dir */
7801
7802 fr_process_begin_command (window->archive->process, "rm");
7803 fr_process_set_working_dir (window->archive->process, g_get_tmp_dir ());
7804 fr_process_set_sticky (window->archive->process, TRUE(!(0)));
7805 fr_process_add_arg (window->archive->process, "-rf");
7806 fr_process_add_arg (window->archive->process, data->tmp_dir);
7807 fr_process_end_command (window->archive->process);
7808
7809 fr_process_start (window->archive->process);
7810}
7811
7812static void
7813copy_from_archive_action_performed_cb (FrArchive *archive,
7814 FrAction action,
7815 FrProcError *error,
7816 gpointer data)
7817{
7818 FrWindow *window = data;
7819 gboolean UNUSED_VARIABLE__attribute__ ((unused)) continue_batch = FALSE(0);
7820
7821#ifdef MATE_ENABLE_DEBUG
7822 debug (DEBUG_INFO"fr-window.c", 7822, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action));
7823#endif
7824
7825 fr_window_stop_activity_mode (window);
7826 fr_window_pop_message (window);
7827 close_progress_dialog (window, FALSE(0));
7828
7829 if (error->type == FR_PROC_ERROR_ASK_PASSWORD) {
7830 dlg_ask_password_for_paste_operation (window);
7831 return;
7832 }
7833
7834 (void) handle_errors (window, archive, action, error);
7835
7836 if (error->type != FR_PROC_ERROR_NONE) {
7837 fr_clipboard_data_unref (window->priv->clipboard_data);
7838 window->priv->clipboard_data = NULL((void*)0);
7839 return;
7840 }
7841
7842 switch (action) {
7843 case FR_ACTION_LISTING_CONTENT:
7844 fr_process_clear (window->priv->copy_from_archive->process);
7845 fr_archive_extract_to_local (window->priv->copy_from_archive,
7846 window->priv->clipboard_data->files,
7847 window->priv->clipboard_data->tmp_dir,
7848 NULL((void*)0),
7849 FALSE(0),
7850 TRUE(!(0)),
7851 FALSE(0),
7852 window->priv->clipboard_data->archive_password);
7853 fr_process_start (window->priv->copy_from_archive->process);
7854 break;
7855
7856 case FR_ACTION_EXTRACTING_FILES:
7857 if (window->priv->clipboard_data->op == FR_CLIPBOARD_OP_CUT) {
7858 fr_process_clear (window->priv->copy_from_archive->process);
7859 fr_archive_remove (window->priv->copy_from_archive,
7860 window->priv->clipboard_data->files,
7861 window->priv->compression);
7862 fr_process_start (window->priv->copy_from_archive->process);
7863 }
7864 else
7865 add_pasted_files (window, window->priv->clipboard_data);
7866 break;
7867
7868 case FR_ACTION_DELETING_FILES:
7869 add_pasted_files (window, window->priv->clipboard_data);
7870 break;
7871
7872 default:
7873 break;
7874 }
7875}
7876
7877static void
7878fr_window_paste_from_clipboard_data (FrWindow *window,
7879 FrClipboardData *data)
7880{
7881 const char *current_dir_relative;
7882 GHashTable *created_dirs;
7883 GList *scan;
7884
7885 if (window->priv->password_for_paste != NULL((void*)0))
7886 fr_clipboard_data_set_password (data, window->priv->password_for_paste);
7887
7888 if (window->priv->clipboard_data != data) {
7889 fr_clipboard_data_unref (window->priv->clipboard_data);
7890 window->priv->clipboard_data = data;
7891 }
7892
7893 fr_window_set_current_batch_action (window,
7894 FR_BATCH_ACTION_PASTE,
7895 fr_clipboard_data_ref (data),
7896 (GFreeFunc) fr_clipboard_data_unref);
7897
7898 current_dir_relative = data->current_dir + 1;
7899
7900 data->tmp_dir = get_temp_work_dir (NULL((void*)0));
7901 created_dirs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
7902 for (scan = data->files; scan; scan = scan->next) {
7903 const char *old_name = (char*) scan->data;
7904 char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0));
7905 char *dir = remove_level_from_path (new_name);
7906
7907 if ((dir != NULL((void*)0)) && (g_hash_table_lookup (created_dirs, dir) == NULL((void*)0))) {
7908 char *dir_path;
7909
7910 dir_path = g_build_filename (data->tmp_dir, dir, NULL((void*)0));
7911 debug (DEBUG_INFO"fr-window.c", 7911, __FUNCTION__, "mktree %s\n", dir_path);
7912 make_directory_tree_from_path (dir_path, 0700, NULL((void*)0));
7913
7914 g_free (dir_path);
7915 g_hash_table_replace (created_dirs, g_strdup (dir)g_strdup_inline (dir), "1");
7916 }
7917
7918 g_free (dir);
7919 g_free (new_name);
7920 }
7921 g_hash_table_destroy (created_dirs);
7922
7923 /**/
7924
7925 if (window->priv->copy_from_archive == NULL((void*)0)) {
7926 window->priv->copy_from_archive = fr_archive_new ();
7927 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
7928 "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
7929 G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
7930 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("start"), (((GCallback
) (action_started))), (window), ((void*)0), (GConnectFlags) 0
)
;
7931 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
7932 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
7933 G_CALLBACK (copy_from_archive_action_performed_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
7934 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("done"), (((GCallback
) (copy_from_archive_action_performed_cb))), (window), ((void
*)0), (GConnectFlags) 0)
;
7935 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7936 "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7937 G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7938 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("progress"), (((GCallback
) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
7939 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7940 "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7941 G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7942 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("message"), (((GCallback
) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
7943 g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7944 "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7945 G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
7946 window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->priv->copy_from_archive)),
(((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback
) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
7947 fr_archive_set_fake_load_func (window->priv->copy_from_archive, always_fake_load, NULL((void*)0));
7948 }
7949 fr_archive_load_local (window->priv->copy_from_archive,
7950 data->archive_filename,
7951 data->archive_password);
7952}
7953
7954static void
7955fr_window_paste_selection_to (FrWindow *window,
7956 const char *current_dir)
7957{
7958 GtkClipboard *clipboard;
7959 GtkSelectionData *selection_data;
7960 FrClipboardData *paste_data;
7961
7962 clipboard = gtk_clipboard_get (FR_CLIPBOARD(gdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD"
))
);
7963 selection_data = gtk_clipboard_wait_for_contents (clipboard, FR_SPECIAL_URI_LIST(gdk_atom_intern_static_string ("application/engrampa-uri-list"
))
);
7964 if (selection_data == NULL((void*)0))
7965 return;
7966
7967 paste_data = get_clipboard_data_from_selection_data (window, (char*) gtk_selection_data_get_data (selection_data));
7968 paste_data->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir);
7969 fr_window_paste_from_clipboard_data (window, paste_data);
7970
7971 gtk_selection_data_free (selection_data);
7972}
7973
7974void
7975fr_window_paste_selection (FrWindow *window,
7976 gboolean from_sidebar)
7977{
7978 char *utf8_path, *utf8_old_path, *destination;
7979 char *current_dir;
7980
7981 if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
7982 return;
7983
7984 /**/
7985
7986 utf8_old_path = g_filename_to_utf8 (fr_window_get_current_location (window), -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
7987 utf8_path = _gtk_request_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
7988 (GTK_DIALOG_DESTROY_WITH_PARENT
7989 | GTK_DIALOG_MODAL),
7990 _("Paste Selection")gettext ("Paste Selection"),
7991 _("_Destination folder:")gettext ("_Destination folder:"),
7992 utf8_old_path,
7993 1024,
7994 _("_Cancel")gettext ("_Cancel"),
7995 _("_Paste")gettext ("_Paste"));
7996 g_free (utf8_old_path);
7997 if (utf8_path == NULL((void*)0))
7998 return;
7999
8000 destination = g_filename_from_utf8 (utf8_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
8001 g_free (utf8_path);
8002
8003 if (destination[0] != '/')
8004 current_dir = build_uri (fr_window_get_current_location (window), destination, NULL((void*)0));
8005 else
8006 current_dir = g_strdup (destination)g_strdup_inline (destination);
8007 g_free (destination);
8008
8009 fr_window_paste_selection_to (window, current_dir);
8010
8011 g_free (current_dir);
8012}
8013
8014/* -- fr_window_open_files -- */
8015
8016void
8017fr_window_open_files_with_command (FrWindow *window,
8018 GList *file_list,
8019 char *command)
8020{
8021 GAppInfo *app;
8022 GError *error = NULL((void*)0);
8023
8024 app = g_app_info_create_from_commandline (command, NULL((void*)0), G_APP_INFO_CREATE_NONE, &error);
8025 if (error != NULL((void*)0)) {
8026 _gtk_error_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
8027 _("Could not perform the operation")gettext ("Could not perform the operation"),
8028 "%s",
8029 error->message);
8030 g_clear_error (&error);
8031 return;
8032 }
8033
8034 fr_window_open_files_with_application (window, file_list, app);
8035}
8036
8037void
8038fr_window_open_files_with_application (FrWindow *window,
8039 GList *file_list,
8040 GAppInfo *app)
8041{
8042 GList *uris;
8043 GList *scan;
8044 GdkAppLaunchContext *context;
8045 GError *error = NULL((void*)0);
8046
8047 if (window->priv->activity_ref > 0)
8048 return;
8049
8050 g_assert (file_list != NULL)do { if (file_list != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fr-window.c", 8050, ((const char*) (__func__
)), "file_list != NULL"); } while (0)
;
8051
8052 uris = NULL((void*)0);
8053 for (scan = file_list; scan; scan = scan->next)
8054 uris = g_list_prepend (uris, g_filename_to_uri (scan->data, NULL((void*)0), NULL((void*)0)));
8055
8056 context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
8057 gdk_app_launch_context_set_screen (context, gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
8058 gdk_app_launch_context_set_timestamp (context, 0);
8059
8060 if (! g_app_info_launch_uris (app, uris, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, &error)) {
8061 _gtk_error_dialog_run (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
8062 _("Could not perform the operation")gettext ("Could not perform the operation"),
8063 "%s",
8064 error->message);
8065 g_clear_error (&error);
8066 }
8067
8068 g_object_unref (context);
8069 path_list_free (uris);
8070}
8071
8072typedef struct {
8073 FrWindow *window;
8074 GList *file_list;
8075 gboolean ask_application;
8076 CommandData *cdata;
8077} OpenFilesData;
8078
8079static OpenFilesData*
8080open_files_data_new (FrWindow *window,
8081 GList *file_list,
8082 gboolean ask_application)
8083
8084{
8085 OpenFilesData *odata;
8086 GList *scan;
8087
8088 odata = g_new0 (OpenFilesData, 1)((OpenFilesData *) g_malloc0_n ((1), sizeof (OpenFilesData)));
8089 odata->window = window;
8090 odata->file_list = path_list_dup (file_list);
8091 odata->ask_application = ask_application;
8092 odata->cdata = g_new0 (CommandData, 1)((CommandData *) g_malloc0_n ((1), sizeof (CommandData)));
8093 odata->cdata->temp_dir = get_temp_work_dir (NULL((void*)0));
8094 odata->cdata->file_list = NULL((void*)0);
8095 for (scan = file_list; scan; scan = scan->next) {
8096 char *file = scan->data;
8097 char *filename;
8098
8099 filename = g_strconcat (odata->cdata->temp_dir,
8100 "/",
8101 file,
8102 NULL((void*)0));
8103 odata->cdata->file_list = g_list_prepend (odata->cdata->file_list, filename);
8104 }
8105
8106 /* Add to CommandList so the cdata is released on exit. */
8107 CommandList = g_list_prepend (CommandList, odata->cdata);
8108
8109 return odata;
8110}
8111
8112static void
8113open_files_data_free (OpenFilesData *odata)
8114{
8115 g_return_if_fail (odata != NULL)do { if ((odata != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "odata != NULL");
return; } } while (0)
;
8116
8117 path_list_free (odata->file_list);
8118 g_free (odata);
8119}
8120
8121void
8122fr_window_update_dialog_closed (FrWindow *window)
8123{
8124 window->priv->update_dialog = NULL((void*)0);
8125}
8126
8127gboolean
8128fr_window_update_files (FrWindow *window,
8129 GList *file_list)
8130{
8131 GList *scan;
8132
8133 if (window->priv->activity_ref > 0)
8134 return FALSE(0);
8135
8136 if (window->archive->read_only)
8137 return FALSE(0);
8138
8139 fr_process_clear (window->archive->process);
8140
8141 for (scan = file_list; scan; scan = scan->next) {
8142 OpenFile *file = scan->data;
8143 GList *local_file_list;
8144
8145 local_file_list = g_list_append (NULL((void*)0), file->path);
8146 fr_archive_add (window->archive,
8147 local_file_list,
8148 file->temp_dir,
8149 "/",
8150 FALSE(0),
8151 FALSE(0),
8152 window->priv->password,
8153 window->priv->encrypt_header,
8154 window->priv->compression,
8155 window->priv->volume_size);
8156 g_list_free (local_file_list);
8157 }
8158
8159 fr_process_start (window->archive->process);
8160
8161 return TRUE(!(0));
8162}
8163
8164static void
8165open_file_modified_cb (GFileMonitor *monitor,
8166 GFile *monitor_file,
8167 GFile *other_file,
8168 GFileMonitorEvent event_type,
8169 gpointer user_data)
8170{
8171 FrWindow *window = user_data;
8172 char *monitor_uri;
8173 OpenFile *file;
8174 GList *scan;
8175
8176 if ((event_type != G_FILE_MONITOR_EVENT_CHANGED)
8177 && (event_type != G_FILE_MONITOR_EVENT_CREATED))
8178 {
8179 return;
8180 }
8181
8182 monitor_uri = g_file_get_uri (monitor_file);
8183 file = NULL((void*)0);
8184 for (scan = window->priv->open_files; scan; scan = scan->next) {
8185 OpenFile *test = scan->data;
8186 if (uricmp (test->extracted_uri, monitor_uri) == 0) {
8187 file = test;
8188 break;
8189 }
8190 }
8191 g_free (monitor_uri);
8192
8193 g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return
; } } while (0)
;
8194
8195 if (window->priv->update_dialog == NULL((void*)0))
8196 window->priv->update_dialog = dlg_update (window);
8197 dlg_update_add_file (window->priv->update_dialog, file);
8198}
8199
8200static void
8201fr_window_monitor_open_file (FrWindow *window,
8202 OpenFile *file)
8203{
8204 GFile *f;
8205
8206 window->priv->open_files = g_list_prepend (window->priv->open_files, file);
8207 f = g_file_new_for_uri (file->extracted_uri);
8208 file->monitor = g_file_monitor_file (f, 0, NULL((void*)0), NULL((void*)0));
8209 g_signal_connect (file->monitor,g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
8210 "changed",g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
8211 G_CALLBACK (open_file_modified_cb),g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
8212 window)g_signal_connect_data ((file->monitor), ("changed"), (((GCallback
) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
8213 g_object_unref (f);
8214}
8215
8216static void
8217monitor_extracted_files (OpenFilesData *odata)
8218{
8219 FrWindow *window = odata->window;
8220 GList *scan1, *scan2;
8221
8222 for (scan1 = odata->file_list, scan2 = odata->cdata->file_list;
8223 scan1 && scan2;
8224 scan1 = scan1->next, scan2 = scan2->next)
8225 {
8226 OpenFile *ofile;
8227 const char *file = scan1->data;
8228 const char *extracted_path = scan2->data;
8229
8230 ofile = open_file_new (file, extracted_path, odata->cdata->temp_dir);
8231 if (ofile != NULL((void*)0))
8232 fr_window_monitor_open_file (window, ofile);
8233 }
8234}
8235
8236static gboolean
8237fr_window_open_extracted_files (OpenFilesData *odata)
8238{
8239 GList *file_list = odata->cdata->file_list;
8240 const char *first_file;
8241 const char *first_mime_type;
8242 GAppInfo *app;
8243 GList *files_to_open = NULL((void*)0);
8244 GdkAppLaunchContext *context;
8245 gboolean result;
8246 GError *error = NULL((void*)0);
8247
8248 g_return_val_if_fail (file_list != NULL, FALSE)do { if ((file_list != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "file_list != NULL"
); return ((0)); } } while (0)
;
8249
8250 first_file = (char*) file_list->data;
8251 if (first_file == NULL((void*)0))
8252 return FALSE(0);
8253
8254 if (! odata->window->archive->read_only)
8255 monitor_extracted_files (odata);
8256
8257 if (odata->ask_application) {
8258 dlg_open_with (odata->window, file_list);
8259 return FALSE(0);
8260 }
8261
8262 first_mime_type = get_file_mime_type_for_path (first_file, FALSE(0));
8263 app = g_app_info_get_default_for_type (first_mime_type, FALSE(0));
8264
8265 if (app == NULL((void*)0)) {
8266 dlg_open_with (odata->window, file_list);
8267 return FALSE(0);
8268 }
8269
8270 files_to_open = g_list_append (files_to_open, g_filename_to_uri (first_file, NULL((void*)0), NULL((void*)0)));
8271
8272 if (g_app_info_supports_files (app)) {
8273 GList *scan;
8274
8275 for (scan = file_list->next; scan; scan = scan->next) {
8276 const char *path = scan->data;
8277 const char *mime_type;
8278
8279 mime_type = get_file_mime_type_for_path (path, FALSE(0));
8280 if (mime_type == NULL((void*)0))
8281 continue;
8282
8283 if (strcmp (mime_type, first_mime_type) == 0) {
8284 files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0)));
8285 }
8286 else {
8287 GAppInfo *app2;
8288
8289 app2 = g_app_info_get_default_for_type (mime_type, FALSE(0));
8290 if (g_app_info_equal (app, app2))
8291 files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0)));
8292 g_object_unref (app2);
8293 }
8294 }
8295 }
8296
8297 context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (odata->window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_widget_get_type ()))))))
));
8298 gdk_app_launch_context_set_screen (context, gtk_widget_get_screen (GTK_WIDGET (odata->window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_widget_get_type ()))))))
));
8299 gdk_app_launch_context_set_timestamp (context, 0);
8300 result = g_app_info_launch_uris (app, files_to_open, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, &error);
8301 if (! result) {
8302 _gtk_error_dialog_run (GTK_WINDOW (odata->window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((odata->window)), ((gtk_window_get_type ()))))))
,
8303 _("Could not perform the operation")gettext ("Could not perform the operation"),
8304 "%s",
8305 error->message);
8306 g_clear_error (&error);
8307 }
8308
8309 g_object_unref (context);
8310 g_object_unref (app);
8311 path_list_free (files_to_open);
8312
8313 return result;
8314}
8315
8316static void
8317fr_window_open_files__extract_done_cb (FrArchive *archive,
8318 FrAction action,
8319 FrProcError *error,
8320 gpointer callback_data)
8321{
8322 OpenFilesData *odata = callback_data;
8323
8324 g_signal_handlers_disconnect_matched (G_OBJECT (archive)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((archive)), (((GType) ((20) << (2))))))))
,
8325 G_SIGNAL_MATCH_DATA,
8326 0,
8327 0, NULL((void*)0),
8328 0,
8329 odata);
8330
8331 if (error->type == FR_PROC_ERROR_NONE)
8332 fr_window_open_extracted_files (odata);
8333}
8334
8335void
8336fr_window_open_files (FrWindow *window,
8337 GList *file_list,
8338 gboolean ask_application)
8339{
8340 OpenFilesData *odata;
8341
8342 if (window->priv->activity_ref > 0)
8343 return;
8344
8345 odata = open_files_data_new (window, file_list, ask_application);
8346 fr_window_set_current_batch_action (window,
8347 FR_BATCH_ACTION_OPEN_FILES,
8348 odata,
8349 (GFreeFunc) open_files_data_free);
8350
8351 g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
8352 "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
8353 G_CALLBACK (fr_window_open_files__extract_done_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
8354 odata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window->archive)), (((GType) ((20) <<
(2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb
))), (odata), ((void*)0), (GConnectFlags) 0)
;
8355
8356 fr_process_clear (window->archive->process);
8357 fr_archive_extract_to_local (window->archive,
8358 odata->file_list,
8359 odata->cdata->temp_dir,
8360 NULL((void*)0),
8361 FALSE(0),
8362 TRUE(!(0)),
8363 FALSE(0),
8364 window->priv->password);
8365 fr_process_start (window->archive->process);
8366}
8367
8368/**/
8369
8370static char*
8371get_default_dir (const char *dir)
8372{
8373 if (! is_temp_dir (dir))
8374 return g_strdup (dir)g_strdup_inline (dir);
8375 else
8376 return NULL((void*)0);
8377}
8378
8379void
8380fr_window_set_open_default_dir (FrWindow *window,
8381 const char *default_dir)
8382{
8383 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8384 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8385
8386 if (window->priv->open_default_dir != NULL((void*)0))
8387 g_free (window->priv->open_default_dir);
8388 window->priv->open_default_dir = get_default_dir (default_dir);
8389}
8390
8391const char *
8392fr_window_get_open_default_dir (FrWindow *window)
8393{
8394 if (window->priv->open_default_dir == NULL((void*)0))
8395 return get_home_uri ();
8396 else
8397 return window->priv->open_default_dir;
8398}
8399
8400void
8401fr_window_set_add_default_dir (FrWindow *window,
8402 const char *default_dir)
8403{
8404 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8405 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8406
8407 if (window->priv->add_default_dir != NULL((void*)0))
8408 g_free (window->priv->add_default_dir);
8409 window->priv->add_default_dir = get_default_dir (default_dir);
8410}
8411
8412const char *
8413fr_window_get_add_default_dir (FrWindow *window)
8414{
8415 if (window->priv->add_default_dir == NULL((void*)0))
8416 return get_home_uri ();
8417 else
8418 return window->priv->add_default_dir;
8419}
8420
8421void
8422fr_window_set_extract_default_dir (FrWindow *window,
8423 const char *default_dir,
8424 gboolean freeze)
8425{
8426 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8427 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8428
8429 /* do not change this dir while it's used by the non-interactive
8430 * extraction operation. */
8431 if (window->priv->extract_interact_use_default_dir)
8432 return;
8433
8434 window->priv->extract_interact_use_default_dir = freeze;
8435
8436 if (window->priv->extract_default_dir != NULL((void*)0))
8437 g_free (window->priv->extract_default_dir);
8438 window->priv->extract_default_dir = get_default_dir (default_dir);
8439}
8440
8441const char *
8442fr_window_get_extract_default_dir (FrWindow *window)
8443{
8444 if (window->priv->extract_default_dir == NULL((void*)0))
8445 return get_home_uri ();
8446 else
8447 return window->priv->extract_default_dir;
8448}
8449
8450void
8451fr_window_set_default_dir (FrWindow *window,
8452 const char *default_dir,
8453 gboolean freeze)
8454{
8455 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8456 g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL"
); return; } } while (0)
;
8457
8458 window->priv->freeze_default_dir = freeze;
8459
8460 fr_window_set_open_default_dir (window, default_dir);
8461 fr_window_set_add_default_dir (window, default_dir);
8462 fr_window_set_extract_default_dir (window, default_dir, FALSE(0));
8463}
8464
8465void
8466fr_window_update_columns_visibility (FrWindow *window)
8467{
8468 GtkTreeView *tree_view = GTK_TREE_VIEW (window->priv->list_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->list_view)), ((gtk_tree_view_get_type
()))))))
;
8469 GtkTreeViewColumn *column;
8470
8471 column = gtk_tree_view_get_column (tree_view, 1);
8472 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_SIZE"show-size"));
8473
8474 column = gtk_tree_view_get_column (tree_view, 2);
8475 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TYPE"show-type"));
8476
8477 column = gtk_tree_view_get_column (tree_view, 3);
8478 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TIME"show-time"));
8479
8480 column = gtk_tree_view_get_column (tree_view, 4);
8481 gtk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path"));
8482}
8483
8484void
8485fr_window_set_toolbar_visibility (FrWindow *window,
8486 gboolean visible)
8487{
8488 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8489
8490 if (visible)
8491 gtk_widget_show (window->priv->toolbar);
8492 else
8493 gtk_widget_hide (window->priv->toolbar);
8494
8495 set_active (window, "ViewToolbar", visible);
8496}
8497
8498void
8499fr_window_set_statusbar_visibility (FrWindow *window,
8500 gboolean visible)
8501{
8502 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8503
8504 if (visible)
8505 gtk_widget_show (window->priv->statusbar);
8506 else
8507 gtk_widget_hide (window->priv->statusbar);
8508
8509 set_active (window, "ViewStatusbar", visible);
8510}
8511
8512void
8513fr_window_set_folders_visibility (FrWindow *window,
8514 gboolean value)
8515{
8516 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8517
8518 window->priv->view_folders = value;
8519 fr_window_update_dir_tree (window);
8520
8521 set_active (window, "ViewFolders", window->priv->view_folders);
8522}
8523
8524void
8525fr_window_use_progress_dialog (FrWindow *window,
8526 gboolean value)
8527{
8528 window->priv->use_progress_dialog = value;
8529}
8530
8531/* -- batch mode procedures -- */
8532
8533static void fr_window_exec_current_batch_action (FrWindow *window);
8534
8535static void
8536fr_window_exec_batch_action (FrWindow *window,
8537 FRBatchAction *action)
8538{
8539 ExtractData *edata;
8540 RenameData *rdata;
8541 OpenFilesData *odata;
8542 SaveAsData *sdata;
8543
8544 switch (action->type) {
2
Control jumps to 'case FR_BATCH_ACTION_RENAME:' at line 8604
8545 case FR_BATCH_ACTION_LOAD:
8546 debug (DEBUG_INFO"fr-window.c", 8546, __FUNCTION__, "[BATCH] LOAD\n");
8547
8548 if (! uri_exists ((char*) action->data))
8549 fr_window_archive_new (window, (char*) action->data);
8550 else
8551 fr_window_archive_open (window, (char*) action->data, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
8552 break;
8553
8554 case FR_BATCH_ACTION_ADD:
8555 debug (DEBUG_INFO"fr-window.c", 8555, __FUNCTION__, "[BATCH] ADD\n");
8556
8557 fr_window_archive_add_dropped_items (window, (GList*) action->data, FALSE(0));
8558 break;
8559
8560 case FR_BATCH_ACTION_DELETE:
8561 debug (DEBUG_INFO"fr-window.c", 8561, __FUNCTION__, "[BATCH] DELETE\n");
8562
8563 fr_window_archive_remove (window, (GList*) action->data);
8564 break;
8565
8566 case FR_BATCH_ACTION_OPEN:
8567 debug (DEBUG_INFO"fr-window.c", 8567, __FUNCTION__, "[BATCH] OPEN\n");
8568
8569 fr_window_push_message (window, _("Add files to an archive")gettext ("Add files to an archive"));
8570 dlg_batch_add_files (window, (GList*) action->data);
8571 break;
8572
8573 case FR_BATCH_ACTION_EXTRACT_HERE:
8574 debug (DEBUG_INFO"fr-window.c", 8574, __FUNCTION__, "[BATCH] EXTRACT HERE\n");
8575
8576 fr_window_archive_extract_here (window,
8577 FALSE(0),
8578 FR_OVERWRITE_NO,
8579 FALSE(0));
8580 break;
8581
8582 case FR_BATCH_ACTION_EXTRACT_INTERACT:
8583 debug (DEBUG_INFO"fr-window.c", 8583, __FUNCTION__, "[BATCH] EXTRACT_INTERACT\n");
8584
8585 if (window->priv->extract_interact_use_default_dir
8586 && (window->priv->extract_default_dir != NULL((void*)0)))
8587 {
8588 fr_window_archive_extract (window,
8589 NULL((void*)0),
8590 window->priv->extract_default_dir,
8591 NULL((void*)0),
8592 NULL((void*)0),
8593 FALSE(0),
8594 FR_OVERWRITE_ASK,
8595 FALSE(0),
8596 TRUE(!(0)));
8597 }
8598 else {
8599 fr_window_push_message (window, _("Extract archive")gettext ("Extract archive"));
8600 dlg_extract (NULL((void*)0), window);
8601 }
8602 break;
8603
8604 case FR_BATCH_ACTION_RENAME:
8605 debug (DEBUG_INFO"fr-window.c", 8605, __FUNCTION__, "[BATCH] RENAME\n");
8606
8607 rdata = action->data;
8608 rename_selection (window,
3
Calling 'rename_selection'
8609 rdata->path_to_rename,
8610 rdata->old_name,
8611 rdata->new_name,
8612 rdata->current_dir,
8613 rdata->is_dir,
8614 rdata->dir_in_archive,
8615 rdata->original_path);
8616 break;
8617
8618 case FR_BATCH_ACTION_PASTE:
8619 debug (DEBUG_INFO"fr-window.c", 8619, __FUNCTION__, "[BATCH] PASTE\n");
8620
8621 fr_window_paste_from_clipboard_data (window, (FrClipboardData*) action->data);
8622 break;
8623
8624 case FR_BATCH_ACTION_OPEN_FILES:
8625 debug (DEBUG_INFO"fr-window.c", 8625, __FUNCTION__, "[BATCH] OPEN FILES\n");
8626
8627 odata = action->data;
8628 fr_window_open_files (window, odata->file_list, odata->ask_application);
8629 break;
8630
8631 case FR_BATCH_ACTION_SAVE_AS:
8632 debug (DEBUG_INFO"fr-window.c", 8632, __FUNCTION__, "[BATCH] SAVE_AS\n");
8633
8634 sdata = action->data;
8635 fr_window_archive_save_as (window,
8636 sdata->uri,
8637 sdata->password,
8638 sdata->encrypt_header,
8639 sdata->volume_size);
8640 break;
8641
8642 case FR_BATCH_ACTION_TEST:
8643 debug (DEBUG_INFO"fr-window.c", 8643, __FUNCTION__, "[BATCH] TEST\n");
8644
8645 fr_window_archive_test (window);
8646 break;
8647
8648 case FR_BATCH_ACTION_CLOSE:
8649 debug (DEBUG_INFO"fr-window.c", 8649, __FUNCTION__, "[BATCH] CLOSE\n");
8650
8651 fr_window_archive_close (window);
8652 fr_window_exec_next_batch_action (window);
8653 break;
8654
8655 case FR_BATCH_ACTION_QUIT:
8656 debug (DEBUG_INFO"fr-window.c", 8656, __FUNCTION__, "[BATCH] QUIT\n");
8657
8658 g_signal_emit (window,
8659 fr_window_signals[READY],
8660 0,
8661 NULL((void*)0));
8662
8663 if ((window->priv->progress_dialog != NULL((void*)0)) && (gtk_widget_get_parent (window->priv->progress_dialog) != GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
8664 gtk_widget_destroy (window->priv->progress_dialog);
8665 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
8666 break;
8667
8668 default:
8669 break;
8670 }
8671}
8672
8673void
8674fr_window_reset_current_batch_action (FrWindow *window)
8675{
8676 FRBatchAction *adata = &window->priv->current_batch_action;
8677
8678 if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0)))
8679 (*adata->free_func) (adata->data);
8680 adata->type = FR_BATCH_ACTION_NONE;
8681 adata->data = NULL((void*)0);
8682 adata->free_func = NULL((void*)0);
8683}
8684
8685void
8686fr_window_set_current_batch_action (FrWindow *window,
8687 FrBatchActionType action,
8688 void *data,
8689 GFreeFunc free_func)
8690{
8691 FRBatchAction *adata = &window->priv->current_batch_action;
8692
8693 fr_window_reset_current_batch_action (window);
8694
8695 adata->type = action;
8696 adata->data = data;
8697 adata->free_func = free_func;
8698}
16
Returning without writing to 'data->old_name'
8699
8700void
8701fr_window_restart_current_batch_action (FrWindow *window)
8702{
8703 fr_window_exec_batch_action (window, &window->priv->current_batch_action);
1
Calling 'fr_window_exec_batch_action'
8704}
8705
8706void
8707fr_window_append_batch_action (FrWindow *window,
8708 FrBatchActionType action,
8709 void *data,
8710 GFreeFunc free_func)
8711{
8712 FRBatchAction *a_desc;
8713
8714 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8715
8716 a_desc = g_new0 (FRBatchAction, 1)((FRBatchAction *) g_malloc0_n ((1), sizeof (FRBatchAction)));
8717 a_desc->type = action;
8718 a_desc->data = data;
8719 a_desc->free_func = free_func;
8720
8721 window->priv->batch_action_list = g_list_append (window->priv->batch_action_list, a_desc);
8722}
8723
8724static void
8725fr_window_exec_current_batch_action (FrWindow *window)
8726{
8727 FRBatchAction *action;
8728
8729 if (window->priv->batch_action == NULL((void*)0)) {
8730 window->priv->batch_mode = FALSE(0);
8731 return;
8732 }
8733 action = (FRBatchAction *) window->priv->batch_action->data;
8734 fr_window_exec_batch_action (window, action);
8735}
8736
8737static void
8738fr_window_exec_next_batch_action (FrWindow *window)
8739{
8740 if (window->priv->batch_action != NULL((void*)0))
8741 window->priv->batch_action = g_list_next (window->priv->batch_action)((window->priv->batch_action) ? (((GList *)(window->
priv->batch_action))->next) : ((void*)0))
;
8742 else
8743 window->priv->batch_action = window->priv->batch_action_list;
8744 fr_window_exec_current_batch_action (window);
8745}
8746
8747void
8748fr_window_start_batch (FrWindow *window)
8749{
8750 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8751
8752 if (window->priv->batch_mode)
8753 return;
8754
8755 if (window->priv->batch_action_list == NULL((void*)0))
8756 return;
8757
8758 if (window->priv->progress_dialog != NULL((void*)0))
8759 gtk_window_set_title (GTK_WINDOW (window->priv->progress_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->progress_dialog)), ((gtk_window_get_type
()))))))
,
8760 window->priv->batch_title);
8761
8762 window->priv->batch_mode = TRUE(!(0));
8763 window->priv->batch_action = window->priv->batch_action_list;
8764 window->archive->can_create_compressed_file = window->priv->batch_adding_one_file;
8765
8766 fr_window_exec_current_batch_action (window);
8767}
8768
8769void
8770fr_window_stop_batch (FrWindow *window)
8771{
8772 if (! window->priv->non_interactive)
8773 return;
8774
8775 window->priv->extract_interact_use_default_dir = FALSE(0);
8776 window->archive->can_create_compressed_file = FALSE(0);
8777
8778 if (window->priv->batch_mode) {
8779 if (! window->priv->showing_error_dialog) {
8780 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
8781 return;
8782 }
8783 }
8784 else {
8785 gtk_window_present (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
8786 fr_window_archive_close (window);
8787 }
8788
8789 window->priv->batch_mode = FALSE(0);
8790}
8791
8792void
8793fr_window_resume_batch (FrWindow *window)
8794{
8795 fr_window_exec_current_batch_action (window);
8796}
8797
8798gboolean
8799fr_window_is_batch_mode (FrWindow *window)
8800{
8801 return window->priv->batch_mode;
8802}
8803
8804void
8805fr_window_new_batch (FrWindow *window,
8806 const char *title)
8807{
8808 fr_window_free_batch_data (window);
8809 window->priv->non_interactive = TRUE(!(0));
8810 g_free (window->priv->batch_title);
8811 window->priv->batch_title = g_strdup (title)g_strdup_inline (title);
8812}
8813
8814void
8815fr_window_set_batch__extract_here (FrWindow *window,
8816 const char *filename)
8817{
8818 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8819 g_return_if_fail (filename != NULL)do { if ((filename != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "filename != NULL"
); return; } } while (0)
;
8820
8821 fr_window_append_batch_action (window,
8822 FR_BATCH_ACTION_LOAD,
8823 g_strdup (filename)g_strdup_inline (filename),
8824 (GFreeFunc) g_free);
8825 fr_window_append_batch_action (window,
8826 FR_BATCH_ACTION_EXTRACT_HERE,
8827 extract_to_data_new (NULL((void*)0)),
8828 (GFreeFunc) extract_data_free);
8829 fr_window_append_batch_action (window,
8830 FR_BATCH_ACTION_CLOSE,
8831 NULL((void*)0),
8832 NULL((void*)0));
8833}
8834
8835void
8836fr_window_set_batch__extract (FrWindow *window,
8837 const char *filename,
8838 const char *dest_dir)
8839{
8840 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8841 g_return_if_fail (filename != NULL)do { if ((filename != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "filename != NULL"
); return; } } while (0)
;
8842
8843 fr_window_append_batch_action (window,
8844 FR_BATCH_ACTION_LOAD,
8845 g_strdup (filename)g_strdup_inline (filename),
8846 (GFreeFunc) g_free);
8847 if (dest_dir != NULL((void*)0))
8848 fr_window_append_batch_action (window,
8849 FR_BATCH_ACTION_EXTRACT_INTERACT,
8850 extract_to_data_new (dest_dir),
8851 (GFreeFunc) extract_data_free);
8852 else
8853 fr_window_append_batch_action (window,
8854 FR_BATCH_ACTION_EXTRACT_INTERACT,
8855 NULL((void*)0),
8856 NULL((void*)0));
8857 fr_window_append_batch_action (window,
8858 FR_BATCH_ACTION_CLOSE,
8859 NULL((void*)0),
8860 NULL((void*)0));
8861}
8862
8863void
8864fr_window_set_batch__add (FrWindow *window,
8865 const char *archive,
8866 GList *file_list)
8867{
8868 window->priv->batch_adding_one_file = (file_list->next == NULL((void*)0)) && (uri_is_file (file_list->data));
8869
8870 if (archive != NULL((void*)0))
8871 fr_window_append_batch_action (window,
8872 FR_BATCH_ACTION_LOAD,
8873 g_strdup (archive)g_strdup_inline (archive),
8874 (GFreeFunc) g_free);
8875 else
8876 fr_window_append_batch_action (window,
8877 FR_BATCH_ACTION_OPEN,
8878 file_list,
8879 NULL((void*)0));
8880 fr_window_append_batch_action (window,
8881 FR_BATCH_ACTION_ADD,
8882 file_list,
8883 NULL((void*)0));
8884 fr_window_append_batch_action (window,
8885 FR_BATCH_ACTION_CLOSE,
8886 NULL((void*)0),
8887 NULL((void*)0));
8888}
8889
8890void
8891fr_window_set_close_dialog (FrWindow *window,
8892 gboolean state)
8893{
8894 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
8895
8896 window->priv->close_dialog = state;
8897}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4de11e.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4de11e.html new file mode 100644 index 0000000..f871afc --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-4de11e.html @@ -0,0 +1,1225 @@ + + + +glib-utils.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/glib-utils.c
Warning:line 351, column 14
Access of the heap area at index 1, while it holds only a single 'char *' element
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name glib-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c glib-utils.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2005 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <config.h>
24#include <string.h>
25#include <stdio.h>
26#include <glib.h>
27#include <glib/gi18n.h>
28#include <glib/gprintf.h>
29#include <glib-object.h>
30#include "glib-utils.h"
31
32#define MAX_PATTERNS128 128
33
34/* gobject utils*/
35
36void
37_g_object_unref (gpointer object)
38{
39 if (object != NULL((void*)0))
40 g_object_unref (object);
41}
42
43/* string utils */
44
45gboolean
46strchrs (const char *str,
47 const char *chars)
48{
49 const char *c;
50 for (c = chars; *c != '\0'; c++)
51 if (strchr (str, *c) != NULL((void*)0))
52 return TRUE(!(0));
53 return FALSE(0);
54}
55
56char *
57str_substitute (const char *str,
58 const char *from_str,
59 const char *to_str)
60{
61 char **tokens;
62 int i;
63 GString *gstr;
64
65 if (str == NULL((void*)0))
66 return NULL((void*)0);
67
68 if (from_str == NULL((void*)0))
69 return g_strdup (str)g_strdup_inline (str);
70
71 if (strcmp (str, from_str) == 0)
72 return g_strdup (to_str)g_strdup_inline (to_str);
73
74 tokens = g_strsplit (str, from_str, -1);
75
76 gstr = g_string_new (NULL((void*)0));
77 for (i = 0; tokens[i] != NULL((void*)0); i++) {
78 gstr = g_string_append (gstr, tokens[i])(__builtin_constant_p (tokens[i]) ? __extension__ ({ const char
* const __val = (tokens[i]); g_string_append_len_inline (gstr
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (gstr
, tokens[i], (gssize) -1))
;
79 if ((to_str != NULL((void*)0)) && (tokens[i+1] != NULL((void*)0)))
80 gstr = g_string_append (gstr, to_str)(__builtin_constant_p (to_str) ? __extension__ ({ const char *
const __val = (to_str); g_string_append_len_inline (gstr, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (gstr, to_str
, (gssize) -1))
;
81 }
82
83 g_strfreev (tokens);
84
85 return g_string_free (gstr, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((gstr
), ((0))) : g_string_free_and_steal (gstr)) : (g_string_free)
((gstr), ((0))))
;
86}
87
88/* counts how many characters to escape in @str. */
89static int
90count_chars_to_escape (const char *str,
91 const char *meta_chars)
92{
93 int meta_chars_n = strlen (meta_chars);
94 const char *s;
95 int n = 0;
96
97 for (s = str; *s != 0; s++) {
98 int i;
99 for (i = 0; i < meta_chars_n; i++)
100 if (*s == meta_chars[i]) {
101 n++;
102 break;
103 }
104 }
105 return n;
106}
107
108static char*
109escape_str_common (const char *str,
110 const char *meta_chars,
111 const char prefix,
112 const char postfix)
113{
114 int meta_chars_n = strlen (meta_chars);
115 char *escaped;
116 int i, new_l, extra_chars = 0;
117 const char *s;
118 char *t;
119
120 if (str == NULL((void*)0))
121 return NULL((void*)0);
122
123 if (prefix)
124 extra_chars++;
125 if (postfix)
126 extra_chars++;
127
128 new_l = strlen (str) + (count_chars_to_escape (str, meta_chars) * extra_chars);
129 escaped = g_malloc (new_l + 1);
130
131 s = str;
132 t = escaped;
133 while (*s) {
134 gboolean is_bad = FALSE(0);
135 for (i = 0; (i < meta_chars_n) && !is_bad; i++)
136 is_bad = (*s == meta_chars[i]);
137 if (is_bad && prefix)
138 *t++ = prefix;
139 *t++ = *s++;
140 if (is_bad && postfix)
141 *t++ = postfix;
142 }
143 *t = 0;
144
145 return escaped;
146}
147
148/* escape with backslash the string @str. */
149char*
150escape_str (const char *str,
151 const char *meta_chars)
152{
153 return escape_str_common (str, meta_chars, '\\', 0);
154}
155
156static const char *
157g_utf8_strstr (const char *haystack, const char *needle)
158{
159 const char *s;
160 gsize i;
161 gsize haystack_len = g_utf8_strlen (haystack, -1);
162 gsize needle_len = g_utf8_strlen (needle, -1);
163 int needle_size = strlen (needle);
164
165 s = haystack;
166 for (i = 0; i <= haystack_len - needle_len; i++) {
167 if (strncmp (s, needle, needle_size) == 0)
168 return s;
169 s = g_utf8_next_char(s)(char *)((s) + g_utf8_skip[*(const guchar *)(s)]);
170 }
171
172 return NULL((void*)0);
173}
174
175static char**
176g_utf8_strsplit (const char *string,
177 const char *delimiter,
178 int max_tokens)
179{
180 GSList *string_list = NULL((void*)0), *slist;
181 char **str_array;
182 const char *s;
183 guint n = 0;
184 const char *remainder;
185
186 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
187 g_return_val_if_fail (delimiter != NULL, NULL)do { if ((delimiter != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "delimiter != NULL"
); return (((void*)0)); } } while (0)
;
188 g_return_val_if_fail (delimiter[0] != '\0', NULL)do { if ((delimiter[0] != '\0')) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "delimiter[0] != '\\0'"
); return (((void*)0)); } } while (0)
;
189
190 if (max_tokens < 1)
191 max_tokens = G_MAXINT2147483647;
192
193 remainder = string;
194 s = g_utf8_strstr (remainder, delimiter);
195 if (s != NULL((void*)0)) {
196 gsize delimiter_size = strlen (delimiter);
197
198 while (--max_tokens && (s != NULL((void*)0))) {
199 gsize size = s - remainder;
200 char *new_string;
201
202 new_string = g_new (char, size + 1)((char *) g_malloc_n ((size + 1), sizeof (char)));
203 strncpy (new_string, remainder, size);
204 new_string[size] = 0;
205
206 string_list = g_slist_prepend (string_list, new_string);
207 n++;
208 remainder = s + delimiter_size;
209 s = g_utf8_strstr (remainder, delimiter);
210 }
211 }
212 if (*string) {
213 n++;
214 string_list = g_slist_prepend (string_list, g_strdup (remainder)g_strdup_inline (remainder));
215 }
216
217 str_array = g_new (char*, n + 1)((char* *) g_malloc_n ((n + 1), sizeof (char*)));
218
219 str_array[n--] = NULL((void*)0);
220 for (slist = string_list; slist; slist = slist->next)
221 str_array[n--] = slist->data;
222
223 g_slist_free (string_list);
224
225 return str_array;
226}
227
228static char*
229g_utf8_strchug (char *string)
230{
231 char *scan;
232 gunichar c;
233
234 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
235
236 scan = string;
237 c = g_utf8_get_char (scan);
238 while (g_unichar_isspace (c)) {
239 scan = g_utf8_next_char (scan)(char *)((scan) + g_utf8_skip[*(const guchar *)(scan)]);
240 c = g_utf8_get_char (scan);
241 }
242
243 memmove (string, scan, strlen (scan) + 1);
244
245 return string;
246}
247
248static char*
249g_utf8_strchomp (char *string)
250{
251 char *scan;
252 gsize len;
253
254 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
255
256 len = g_utf8_strlen (string, -1);
257
258 if (len == 0)
259 return string;
260
261 scan = g_utf8_offset_to_pointer (string, len - 1);
262
263 while (len--) {
264 gunichar c = g_utf8_get_char (scan);
265 if (g_unichar_isspace (c))
266 *scan = '\0';
267 else
268 break;
269 scan = g_utf8_find_prev_char (string, scan);
270 }
271
272 return string;
273}
274
275#define g_utf8_strstrip(string)g_utf8_strchomp (g_utf8_strchug (string)) g_utf8_strchomp (g_utf8_strchug (string))
276
277gboolean
278match_regexps (GRegex **regexps,
279 const char *string,
280 GRegexMatchFlags match_options)
281{
282 gboolean matched;
283 int i;
284
285 if ((regexps == NULL((void*)0)) || (regexps[0] == NULL((void*)0)))
286 return TRUE(!(0));
287
288 if (string == NULL((void*)0))
289 return FALSE(0);
290
291 matched = FALSE(0);
292 for (i = 0; regexps[i] != NULL((void*)0); i++)
293 if (g_regex_match (regexps[i], string, match_options, NULL((void*)0))) {
294 matched = TRUE(!(0));
295 break;
296 }
297
298 return matched;
299}
300
301void
302free_regexps (GRegex **regexps)
303{
304 int i;
305
306 if (regexps == NULL((void*)0))
307 return;
308
309 for (i = 0; regexps[i] != NULL((void*)0); i++)
310 g_regex_unref (regexps[i]);
311 g_free (regexps);
312}
313
314char **
315search_util_get_patterns (const char *pattern_string)
316{
317 char **patterns;
318 int i;
319
320 if (pattern_string == NULL((void*)0))
321 return NULL((void*)0);
322
323 patterns = g_utf8_strsplit (pattern_string, ";", MAX_PATTERNS128);
324 for (i = 0; patterns[i] != NULL((void*)0); i++) {
325 char *p1, *p2;
326
327 p1 = g_utf8_strstrip (patterns[i])g_utf8_strchomp (g_utf8_strchug (patterns[i]));
328 p2 = str_substitute (p1, ".", "\\.");
329 patterns[i] = str_substitute (p2, "*", ".*");
330
331 g_free (p2);
332 g_free (p1);
333 }
334
335 return patterns;
336}
337
338GRegex **
339search_util_get_regexps (const char *pattern_string,
340 GRegexCompileFlags compile_options)
341{
342 char **patterns;
343 GRegex **regexps;
344 int i;
345
346 patterns = search_util_get_patterns (pattern_string);
347 if (patterns
0.1
'patterns' is not equal to NULL
== NULL((void*)0))
1
Taking false branch
348 return NULL((void*)0);
349
350 regexps = g_new0 (GRegex*, g_strv_length (patterns) + 1)((GRegex* *) g_malloc0_n ((g_strv_length (patterns) + 1), sizeof
(GRegex*)))
;
351 for (i = 0; patterns[i] != NULL((void*)0); i++)
2
Assuming the condition is true
3
Loop condition is true. Entering loop body
4
Access of the heap area at index 1, while it holds only a single 'char *' element
352 regexps[i] = g_regex_new (patterns[i],
353 G_REGEX_OPTIMIZE | compile_options,
354 G_REGEX_MATCH_NOTEMPTY,
355 NULL((void*)0));
356 g_strfreev (patterns);
357
358 return regexps;
359}
360
361const char *
362eat_spaces (const char *line)
363{
364 if (line == NULL((void*)0))
365 return NULL((void*)0);
366 while (*line == ' ')
367 line++;
368 return line;
369}
370
371char **
372split_line (const char *line,
373 int n_fields)
374{
375 char **fields;
376 const char *scan, *field_end;
377 int i;
378
379 fields = g_new0 (char *, n_fields + 1)((char * *) g_malloc0_n ((n_fields + 1), sizeof (char *)));
380 fields[n_fields] = NULL((void*)0);
381
382 scan = eat_spaces (line);
383 for (i = 0; i < n_fields; i++) {
384 if (scan == NULL((void*)0)) {
385 fields[i] = NULL((void*)0);
386 continue;
387 }
388 field_end = strchr (scan, ' ');
389 if (field_end != NULL((void*)0)) {
390 fields[i] = g_strndup (scan, field_end - scan);
391 scan = eat_spaces (field_end);
392 }
393 else if (scan != NULL((void*)0) && i == n_fields - 1)
394 {
395 fields[i] = g_strdup (scan)g_strdup_inline (scan);
396 }
397 }
398
399 return fields;
400}
401
402const char *
403get_last_field (const char *line,
404 int last_field)
405{
406 const char *field;
407 int i;
408
409 if (line == NULL((void*)0))
410 return NULL((void*)0);
411
412 last_field--;
413 field = eat_spaces (line);
414 for (i = 0; i < last_field; i++) {
415 if (field == NULL((void*)0))
416 return NULL((void*)0);
417 field = strchr (field, ' ');
418 field = eat_spaces (field);
419 }
420
421 return field;
422}
423
424void
425debug (const char *file,
426 int line,
427 const char *function,
428 const char *format, ...)
429{
430#ifdef MATE_ENABLE_DEBUG
431 va_list args;
432 char *str;
433
434 g_return_if_fail (format != NULL)do { if ((format != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "format != NULL")
; return; } } while (0)
;
435
436 va_start (args, format)__builtin_va_start(args, format);
437 str = g_strdup_vprintf (format, args);
438 va_end (args)__builtin_va_end(args);
439
440 g_fprintf (stderrstderr, "[FR] %s:%d (%s):\n\t%s\n", file, line, function, str);
441
442 g_free (str);
443#else /* ! DEBUG */
444#endif
445}
446
447GHashTable *static_strings = NULL((void*)0);
448
449const char *
450get_static_string (const char *s)
451{
452 const char *result;
453
454 if (s == NULL((void*)0))
455 return NULL((void*)0);
456
457 if (static_strings == NULL((void*)0))
458 static_strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
459
460 if (! g_hash_table_lookup_extended (static_strings, s, (gpointer*) &result, NULL((void*)0))) {
461 result = g_strdup (s)g_strdup_inline (s);
462 g_hash_table_insert (static_strings,
463 (gpointer) result,
464 GINT_TO_POINTER (1)((gpointer) (glong) (1)));
465 }
466
467 return result;
468}
469
470char*
471g_uri_display_basename (const char *uri)
472{
473 char *e_name, *name;
474
475 e_name = g_filename_display_basename (uri);
476 name = g_uri_unescape_string (e_name, "");
477 g_free (e_name);
478
479 return name;
480}
481
482const gchar *
483_g_path_get_file_name (const gchar *file_name)
484{
485 register char *base;
486 register gssize last_char;
487
488 if (file_name == NULL((void*)0))
489 return NULL((void*)0);
490
491 if (file_name[0] == '\0')
492 return "";
493
494 last_char = strlen (file_name) - 1;
495
496 if (file_name [last_char] == G_DIR_SEPARATOR'/')
497 return "";
498
499 base = g_utf8_strrchr (file_name, -1, G_DIR_SEPARATOR'/');
500 if (! base)
501 return file_name;
502
503 return base + 1;
504}
505
506const char *
507_g_path_get_base_name (const char *path,
508 const char *base_dir,
509 gboolean junk_paths)
510{
511 size_t base_dir_len;
512 const char *base_path;
513
514 if (junk_paths)
515 return _g_path_get_file_name (path);
516
517 if (base_dir == NULL((void*)0))
518 return (path[0] == '/') ? path + 1 : path;
519
520 base_dir_len = strlen (base_dir);
521 if (strlen (path) < base_dir_len)
522 return NULL((void*)0);
523
524 base_path = path + base_dir_len;
525 if (path[0] != '/')
526 base_path -= 1;
527
528 return base_path;
529}
530
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-5b979e.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-5b979e.html new file mode 100644 index 0000000..5b64fc2 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-5b979e.html @@ -0,0 +1,1267 @@ + + + +glib-utils.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/glib-utils.c
Warning:line 324, column 26
The left operand of '!=' is a garbage value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name glib-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c glib-utils.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2005 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <config.h>
24#include <string.h>
25#include <stdio.h>
26#include <glib.h>
27#include <glib/gi18n.h>
28#include <glib/gprintf.h>
29#include <glib-object.h>
30#include "glib-utils.h"
31
32#define MAX_PATTERNS128 128
33
34/* gobject utils*/
35
36void
37_g_object_unref (gpointer object)
38{
39 if (object != NULL((void*)0))
40 g_object_unref (object);
41}
42
43/* string utils */
44
45gboolean
46strchrs (const char *str,
47 const char *chars)
48{
49 const char *c;
50 for (c = chars; *c != '\0'; c++)
51 if (strchr (str, *c) != NULL((void*)0))
52 return TRUE(!(0));
53 return FALSE(0);
54}
55
56char *
57str_substitute (const char *str,
58 const char *from_str,
59 const char *to_str)
60{
61 char **tokens;
62 int i;
63 GString *gstr;
64
65 if (str == NULL((void*)0))
66 return NULL((void*)0);
67
68 if (from_str == NULL((void*)0))
69 return g_strdup (str)g_strdup_inline (str);
70
71 if (strcmp (str, from_str) == 0)
72 return g_strdup (to_str)g_strdup_inline (to_str);
73
74 tokens = g_strsplit (str, from_str, -1);
75
76 gstr = g_string_new (NULL((void*)0));
77 for (i = 0; tokens[i] != NULL((void*)0); i++) {
78 gstr = g_string_append (gstr, tokens[i])(__builtin_constant_p (tokens[i]) ? __extension__ ({ const char
* const __val = (tokens[i]); g_string_append_len_inline (gstr
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (gstr
, tokens[i], (gssize) -1))
;
79 if ((to_str != NULL((void*)0)) && (tokens[i+1] != NULL((void*)0)))
80 gstr = g_string_append (gstr, to_str)(__builtin_constant_p (to_str) ? __extension__ ({ const char *
const __val = (to_str); g_string_append_len_inline (gstr, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (gstr, to_str
, (gssize) -1))
;
81 }
82
83 g_strfreev (tokens);
84
85 return g_string_free (gstr, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((gstr
), ((0))) : g_string_free_and_steal (gstr)) : (g_string_free)
((gstr), ((0))))
;
86}
87
88/* counts how many characters to escape in @str. */
89static int
90count_chars_to_escape (const char *str,
91 const char *meta_chars)
92{
93 int meta_chars_n = strlen (meta_chars);
94 const char *s;
95 int n = 0;
96
97 for (s = str; *s != 0; s++) {
98 int i;
99 for (i = 0; i < meta_chars_n; i++)
100 if (*s == meta_chars[i]) {
101 n++;
102 break;
103 }
104 }
105 return n;
106}
107
108static char*
109escape_str_common (const char *str,
110 const char *meta_chars,
111 const char prefix,
112 const char postfix)
113{
114 int meta_chars_n = strlen (meta_chars);
115 char *escaped;
116 int i, new_l, extra_chars = 0;
117 const char *s;
118 char *t;
119
120 if (str == NULL((void*)0))
121 return NULL((void*)0);
122
123 if (prefix)
124 extra_chars++;
125 if (postfix)
126 extra_chars++;
127
128 new_l = strlen (str) + (count_chars_to_escape (str, meta_chars) * extra_chars);
129 escaped = g_malloc (new_l + 1);
130
131 s = str;
132 t = escaped;
133 while (*s) {
134 gboolean is_bad = FALSE(0);
135 for (i = 0; (i < meta_chars_n) && !is_bad; i++)
136 is_bad = (*s == meta_chars[i]);
137 if (is_bad && prefix)
138 *t++ = prefix;
139 *t++ = *s++;
140 if (is_bad && postfix)
141 *t++ = postfix;
142 }
143 *t = 0;
144
145 return escaped;
146}
147
148/* escape with backslash the string @str. */
149char*
150escape_str (const char *str,
151 const char *meta_chars)
152{
153 return escape_str_common (str, meta_chars, '\\', 0);
154}
155
156static const char *
157g_utf8_strstr (const char *haystack, const char *needle)
158{
159 const char *s;
160 gsize i;
161 gsize haystack_len = g_utf8_strlen (haystack, -1);
162 gsize needle_len = g_utf8_strlen (needle, -1);
163 int needle_size = strlen (needle);
164
165 s = haystack;
166 for (i = 0; i <= haystack_len - needle_len; i++) {
167 if (strncmp (s, needle, needle_size) == 0)
168 return s;
169 s = g_utf8_next_char(s)(char *)((s) + g_utf8_skip[*(const guchar *)(s)]);
170 }
171
172 return NULL((void*)0);
173}
174
175static char**
176g_utf8_strsplit (const char *string,
177 const char *delimiter,
178 int max_tokens)
179{
180 GSList *string_list = NULL((void*)0), *slist;
181 char **str_array;
182 const char *s;
183 guint n = 0;
184 const char *remainder;
185
186 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
5
Taking true branch
6
Loop condition is false. Exiting loop
187 g_return_val_if_fail (delimiter != NULL, NULL)do { if ((delimiter != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "delimiter != NULL"
); return (((void*)0)); } } while (0)
;
7
Taking true branch
8
Loop condition is false. Exiting loop
188 g_return_val_if_fail (delimiter[0] != '\0', NULL)do { if ((delimiter[0] != '\0')) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "delimiter[0] != '\\0'"
); return (((void*)0)); } } while (0)
;
9
Taking true branch
10
Loop condition is false. Exiting loop
189
190 if (max_tokens
10.1
'max_tokens' is >= 1
< 1)
11
Taking false branch
191 max_tokens = G_MAXINT2147483647;
192
193 remainder = string;
194 s = g_utf8_strstr (remainder, delimiter);
195 if (s != NULL((void*)0)) {
12
Assuming 's' is equal to NULL
13
Taking false branch
196 gsize delimiter_size = strlen (delimiter);
197
198 while (--max_tokens && (s != NULL((void*)0))) {
199 gsize size = s - remainder;
200 char *new_string;
201
202 new_string = g_new (char, size + 1)((char *) g_malloc_n ((size + 1), sizeof (char)));
203 strncpy (new_string, remainder, size);
204 new_string[size] = 0;
205
206 string_list = g_slist_prepend (string_list, new_string);
207 n++;
208 remainder = s + delimiter_size;
209 s = g_utf8_strstr (remainder, delimiter);
210 }
211 }
212 if (*string) {
14
Assuming the condition is true
15
Taking true branch
213 n++;
214 string_list = g_slist_prepend (string_list, g_strdup (remainder)g_strdup_inline (remainder));
215 }
216
217 str_array = g_new (char*, n + 1)((char* *) g_malloc_n ((n + 1), sizeof (char*)));
16
Storing uninitialized value
218
219 str_array[n--] = NULL((void*)0);
220 for (slist = string_list; slist; slist = slist->next)
17
Loop condition is false. Execution continues on line 223
221 str_array[n--] = slist->data;
222
223 g_slist_free (string_list);
224
225 return str_array;
226}
227
228static char*
229g_utf8_strchug (char *string)
230{
231 char *scan;
232 gunichar c;
233
234 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
235
236 scan = string;
237 c = g_utf8_get_char (scan);
238 while (g_unichar_isspace (c)) {
239 scan = g_utf8_next_char (scan)(char *)((scan) + g_utf8_skip[*(const guchar *)(scan)]);
240 c = g_utf8_get_char (scan);
241 }
242
243 memmove (string, scan, strlen (scan) + 1);
244
245 return string;
246}
247
248static char*
249g_utf8_strchomp (char *string)
250{
251 char *scan;
252 gsize len;
253
254 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
255
256 len = g_utf8_strlen (string, -1);
257
258 if (len == 0)
259 return string;
260
261 scan = g_utf8_offset_to_pointer (string, len - 1);
262
263 while (len--) {
264 gunichar c = g_utf8_get_char (scan);
265 if (g_unichar_isspace (c))
266 *scan = '\0';
267 else
268 break;
269 scan = g_utf8_find_prev_char (string, scan);
270 }
271
272 return string;
273}
274
275#define g_utf8_strstrip(string)g_utf8_strchomp (g_utf8_strchug (string)) g_utf8_strchomp (g_utf8_strchug (string))
276
277gboolean
278match_regexps (GRegex **regexps,
279 const char *string,
280 GRegexMatchFlags match_options)
281{
282 gboolean matched;
283 int i;
284
285 if ((regexps == NULL((void*)0)) || (regexps[0] == NULL((void*)0)))
286 return TRUE(!(0));
287
288 if (string == NULL((void*)0))
289 return FALSE(0);
290
291 matched = FALSE(0);
292 for (i = 0; regexps[i] != NULL((void*)0); i++)
293 if (g_regex_match (regexps[i], string, match_options, NULL((void*)0))) {
294 matched = TRUE(!(0));
295 break;
296 }
297
298 return matched;
299}
300
301void
302free_regexps (GRegex **regexps)
303{
304 int i;
305
306 if (regexps == NULL((void*)0))
307 return;
308
309 for (i = 0; regexps[i] != NULL((void*)0); i++)
310 g_regex_unref (regexps[i]);
311 g_free (regexps);
312}
313
314char **
315search_util_get_patterns (const char *pattern_string)
316{
317 char **patterns;
318 int i;
319
320 if (pattern_string == NULL((void*)0))
2
Assuming 'pattern_string' is not equal to NULL
3
Taking false branch
321 return NULL((void*)0);
322
323 patterns = g_utf8_strsplit (pattern_string, ";", MAX_PATTERNS128);
4
Calling 'g_utf8_strsplit'
18
Returning from 'g_utf8_strsplit'
324 for (i = 0; patterns[i] != NULL((void*)0); i++) {
19
The value 0 is assigned to 'i'
20
The left operand of '!=' is a garbage value
325 char *p1, *p2;
326
327 p1 = g_utf8_strstrip (patterns[i])g_utf8_strchomp (g_utf8_strchug (patterns[i]));
328 p2 = str_substitute (p1, ".", "\\.");
329 patterns[i] = str_substitute (p2, "*", ".*");
330
331 g_free (p2);
332 g_free (p1);
333 }
334
335 return patterns;
336}
337
338GRegex **
339search_util_get_regexps (const char *pattern_string,
340 GRegexCompileFlags compile_options)
341{
342 char **patterns;
343 GRegex **regexps;
344 int i;
345
346 patterns = search_util_get_patterns (pattern_string);
1
Calling 'search_util_get_patterns'
347 if (patterns == NULL((void*)0))
348 return NULL((void*)0);
349
350 regexps = g_new0 (GRegex*, g_strv_length (patterns) + 1)((GRegex* *) g_malloc0_n ((g_strv_length (patterns) + 1), sizeof
(GRegex*)))
;
351 for (i = 0; patterns[i] != NULL((void*)0); i++)
352 regexps[i] = g_regex_new (patterns[i],
353 G_REGEX_OPTIMIZE | compile_options,
354 G_REGEX_MATCH_NOTEMPTY,
355 NULL((void*)0));
356 g_strfreev (patterns);
357
358 return regexps;
359}
360
361const char *
362eat_spaces (const char *line)
363{
364 if (line == NULL((void*)0))
365 return NULL((void*)0);
366 while (*line == ' ')
367 line++;
368 return line;
369}
370
371char **
372split_line (const char *line,
373 int n_fields)
374{
375 char **fields;
376 const char *scan, *field_end;
377 int i;
378
379 fields = g_new0 (char *, n_fields + 1)((char * *) g_malloc0_n ((n_fields + 1), sizeof (char *)));
380 fields[n_fields] = NULL((void*)0);
381
382 scan = eat_spaces (line);
383 for (i = 0; i < n_fields; i++) {
384 if (scan == NULL((void*)0)) {
385 fields[i] = NULL((void*)0);
386 continue;
387 }
388 field_end = strchr (scan, ' ');
389 if (field_end != NULL((void*)0)) {
390 fields[i] = g_strndup (scan, field_end - scan);
391 scan = eat_spaces (field_end);
392 }
393 else if (scan != NULL((void*)0) && i == n_fields - 1)
394 {
395 fields[i] = g_strdup (scan)g_strdup_inline (scan);
396 }
397 }
398
399 return fields;
400}
401
402const char *
403get_last_field (const char *line,
404 int last_field)
405{
406 const char *field;
407 int i;
408
409 if (line == NULL((void*)0))
410 return NULL((void*)0);
411
412 last_field--;
413 field = eat_spaces (line);
414 for (i = 0; i < last_field; i++) {
415 if (field == NULL((void*)0))
416 return NULL((void*)0);
417 field = strchr (field, ' ');
418 field = eat_spaces (field);
419 }
420
421 return field;
422}
423
424void
425debug (const char *file,
426 int line,
427 const char *function,
428 const char *format, ...)
429{
430#ifdef MATE_ENABLE_DEBUG
431 va_list args;
432 char *str;
433
434 g_return_if_fail (format != NULL)do { if ((format != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "format != NULL")
; return; } } while (0)
;
435
436 va_start (args, format)__builtin_va_start(args, format);
437 str = g_strdup_vprintf (format, args);
438 va_end (args)__builtin_va_end(args);
439
440 g_fprintf (stderrstderr, "[FR] %s:%d (%s):\n\t%s\n", file, line, function, str);
441
442 g_free (str);
443#else /* ! DEBUG */
444#endif
445}
446
447GHashTable *static_strings = NULL((void*)0);
448
449const char *
450get_static_string (const char *s)
451{
452 const char *result;
453
454 if (s == NULL((void*)0))
455 return NULL((void*)0);
456
457 if (static_strings == NULL((void*)0))
458 static_strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
459
460 if (! g_hash_table_lookup_extended (static_strings, s, (gpointer*) &result, NULL((void*)0))) {
461 result = g_strdup (s)g_strdup_inline (s);
462 g_hash_table_insert (static_strings,
463 (gpointer) result,
464 GINT_TO_POINTER (1)((gpointer) (glong) (1)));
465 }
466
467 return result;
468}
469
470char*
471g_uri_display_basename (const char *uri)
472{
473 char *e_name, *name;
474
475 e_name = g_filename_display_basename (uri);
476 name = g_uri_unescape_string (e_name, "");
477 g_free (e_name);
478
479 return name;
480}
481
482const gchar *
483_g_path_get_file_name (const gchar *file_name)
484{
485 register char *base;
486 register gssize last_char;
487
488 if (file_name == NULL((void*)0))
489 return NULL((void*)0);
490
491 if (file_name[0] == '\0')
492 return "";
493
494 last_char = strlen (file_name) - 1;
495
496 if (file_name [last_char] == G_DIR_SEPARATOR'/')
497 return "";
498
499 base = g_utf8_strrchr (file_name, -1, G_DIR_SEPARATOR'/');
500 if (! base)
501 return file_name;
502
503 return base + 1;
504}
505
506const char *
507_g_path_get_base_name (const char *path,
508 const char *base_dir,
509 gboolean junk_paths)
510{
511 size_t base_dir_len;
512 const char *base_path;
513
514 if (junk_paths)
515 return _g_path_get_file_name (path);
516
517 if (base_dir == NULL((void*)0))
518 return (path[0] == '/') ? path + 1 : path;
519
520 base_dir_len = strlen (base_dir);
521 if (strlen (path) < base_dir_len)
522 return NULL((void*)0);
523
524 base_path = path + base_dir_len;
525 if (path[0] != '/')
526 base_path -= 1;
527
528 return base_path;
529}
530
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-8954c3.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-8954c3.html new file mode 100644 index 0000000..7dc2e1f --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-8954c3.html @@ -0,0 +1,1121 @@ + + + +java-utils.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/java-utils.c
Warning:line 254, column 7
Although the value stored to 'i' is used in the enclosing expression, the value is never actually read from 'i'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name java-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c java-utils.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2006 The Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <config.h>
24#include <fcntl.h>
25#include <unistd.h>
26#include <errno(*__errno_location ()).h>
27#include <string.h>
28#include <ctype.h>
29#include <glib.h>
30#include "java-utils.h"
31
32/*
33 * The following code conforms to the JVM specification.(Java 2 Platform)
34 * For further changes to the classfile structure, please update the
35 * following macros.
36 */
37
38/* Tags that identify structures */
39
40#define CONST_CLASS7 7
41#define CONST_FIELDREF9 9
42#define CONST_METHODREF10 10
43#define CONST_INTERFACEMETHODREF11 11
44#define CONST_STRING8 8
45#define CONST_INTEGER3 3
46#define CONST_FLOAT4 4
47#define CONST_LONG5 5
48#define CONST_DOUBLE6 6
49#define CONST_NAMEANDTYPE12 12
50#define CONST_UTF81 1
51
52/* Sizes of structures */
53
54#define CONST_FIELDREF_INFO4 4
55#define CONST_METHODREF_INFO4 4
56#define CONST_INTERFACEMETHODREF_INFO4 4
57#define CONST_STRING_INFO2 2
58#define CONST_INTEGER_INFO4 4
59#define CONST_FLOAT_INFO4 4
60#define CONST_LONG_INFO8 8
61#define CONST_DOUBLE_INFO8 8
62#define CONST_NAMEANDTYPE_INFO4 4
63
64/* represents the utf8 strings in class file */
65struct utf_string
66{
67 guint16 index;
68 guint16 length;
69 char *str;
70};
71
72/* structure that holds class information in a class file */
73struct class_info
74{
75 guint16 index;
76 guint16 name_index; /* index into the utf_strings */
77};
78
79typedef struct {
80 int fd;
81
82 guint32 magic_no; /* 0xCAFEBABE (JVM Specification) :) */
83
84 guint16 major; /* versions */
85 guint16 minor;
86
87 guint16 const_pool_count;
88 GSList *const_pool_class; /* (const_pool_count - 1) elements of tye 'CONST_class_info' */
89 GSList *const_pool_utf; /* (const_pool_count - 1) elements of type 'utf_strings' */
90
91 guint16 access_flags;
92 guint16 this_class; /* the index of the class the file is named after. */
93
94#if 0 /* not needed */
95 guint16 super_class;
96 guint16 interfaces_count;
97 guint16 *interfaces;
98 guint16 fields_count;
99 field_info *fields;
100 guint16 methods_count;
101 method_info *methods;
102 guint16 attributes_count;
103 attribute_info *attributes;
104#endif
105} JavaClassFile;
106
107static JavaClassFile*
108java_class_file_new (void)
109{
110 JavaClassFile *cfile;
111
112 cfile = g_new0 (JavaClassFile, 1)((JavaClassFile *) g_malloc0_n ((1), sizeof (JavaClassFile)));
113 cfile->fd = -1;
114
115 return cfile;
116}
117
118static void
119java_class_file_free (JavaClassFile *cfile)
120{
121 GSList *scan;
122
123 if (cfile->const_pool_class != NULL((void*)0))
124 g_slist_free_full (cfile->const_pool_class, g_free);
125
126 for (scan = cfile->const_pool_utf; scan ; scan = scan->next) {
127 struct utf_string *string = scan->data;
128 g_free (string->str);
129 }
130
131 if (cfile->const_pool_utf != NULL((void*)0))
132 g_slist_free_full (cfile->const_pool_utf, g_free);
133
134 if (cfile->fd != -1)
135 close (cfile->fd);
136
137 g_free (cfile);
138}
139
140/* The following function loads the utf8 strings and class structures from the
141 * class file. */
142static void
143load_constant_pool_utfs (JavaClassFile *cfile)
144{
145 guint8 tag;
146 guint16 i = 0; /* should be comparable with const_pool_count */
147
148 while ((i < cfile->const_pool_count - 1) && (read (cfile->fd, &tag, 1) != -1)) {
149 struct utf_string *txt = NULL((void*)0);
150 struct class_info *class = NULL((void*)0);
151
152 switch (tag) {
153 case CONST_CLASS7:
154 class = g_new0 (struct class_info, 1)((struct class_info *) g_malloc0_n ((1), sizeof (struct class_info
)))
;
155 class->index = i + 1;
156 if (read (cfile->fd, &class->name_index, 2) != 2) {
157 g_free (class);
158 return; /* error reading */
159 }
160 class->name_index = GUINT16_FROM_BE (class->name_index)(((((guint16) ( (guint16) ((guint16) (class->name_index) >>
8) | (guint16) ((guint16) (class->name_index) << 8)
)))))
;
161 cfile->const_pool_class = g_slist_append (cfile->const_pool_class, class);
162 break;
163
164 case CONST_FIELDREF9:
165 lseek (cfile->fd, CONST_FIELDREF_INFO4, SEEK_CUR1);
166 break;
167
168 case CONST_METHODREF10:
169 lseek (cfile->fd, CONST_METHODREF_INFO4, SEEK_CUR1);
170 break;
171
172 case CONST_INTERFACEMETHODREF11:
173 lseek (cfile->fd, CONST_INTERFACEMETHODREF_INFO4, SEEK_CUR1);
174 break;
175
176 case CONST_STRING8:
177 lseek (cfile->fd, CONST_STRING_INFO2, SEEK_CUR1);
178 break;
179
180 case CONST_INTEGER3:
181 lseek (cfile->fd, CONST_INTEGER_INFO4, SEEK_CUR1);
182 break;
183
184 case CONST_FLOAT4:
185 lseek (cfile->fd, CONST_FLOAT_INFO4, SEEK_CUR1);
186 break;
187
188 case CONST_LONG5:
189 lseek (cfile->fd, CONST_LONG_INFO8, SEEK_CUR1);
190 break;
191
192 case CONST_DOUBLE6:
193 lseek (cfile->fd, CONST_DOUBLE_INFO8, SEEK_CUR1);
194 break;
195
196 case CONST_NAMEANDTYPE12:
197 lseek (cfile->fd, CONST_NAMEANDTYPE_INFO4, SEEK_CUR1);
198 break;
199
200 case CONST_UTF81:
201 txt = g_new0 (struct utf_string, 1)((struct utf_string *) g_malloc0_n ((1), sizeof (struct utf_string
)))
;
202 txt->index = i + 1;
203 if (read (cfile->fd, &(txt->length), 2) == -1) {
204 g_free (txt);
205 return; /* error while reading */
206 }
207 txt->length = GUINT16_FROM_BE (txt->length)(((((guint16) ( (guint16) ((guint16) (txt->length) >>
8) | (guint16) ((guint16) (txt->length) << 8))))))
;
208 txt->str = g_new0 (char, txt->length)((char *) g_malloc0_n ((txt->length), sizeof (char)));
209 if (read (cfile->fd, txt->str, txt->length) == -1) {
210 g_free (txt);
211 return; /* error while reading */
212 }
213 cfile->const_pool_utf = g_slist_append (cfile->const_pool_utf, txt);
214 break;
215
216 default:
217 return; /* error - unknown tag in class file */
218 break;
219 }
220 i++;
221 }
222
223#ifdef MATE_ENABLE_DEBUG
224 g_print( "Number of Entries: %d\n", i );
225#endif
226}
227
228static char*
229close_and_exit (JavaClassFile *cfile)
230{
231 java_class_file_free (cfile);
232 return NULL((void*)0);
233}
234
235/* This function extracts the package name from a class file */
236char*
237get_package_name_from_class_file (char *fname)
238{
239 char *package = NULL((void*)0);
240 JavaClassFile *cfile;
241 guint16 length = 0, end = 0, utf_index = 0;
242 guint32 magic;
243 guint16 major, minor, count;
244 guint i = 0;
245
246 if (! g_file_test (fname, G_FILE_TEST_EXISTS))
247 return NULL((void*)0);
248
249 cfile = java_class_file_new ();
250 cfile->fd = open (fname, O_RDONLY00);
251 if (cfile->fd == -1)
252 return close_and_exit (cfile);
253
254 if ((i = read (cfile->fd, &magic, 4)) != 4)
Although the value stored to 'i' is used in the enclosing expression, the value is never actually read from 'i'
255 return close_and_exit (cfile);
256 cfile->magic_no = GUINT32_FROM_BE (magic)(((((guint32) ( (((guint32) (magic) & (guint32) 0x000000ffU
) << 24) | (((guint32) (magic) & (guint32) 0x0000ff00U
) << 8) | (((guint32) (magic) & (guint32) 0x00ff0000U
) >> 8) | (((guint32) (magic) & (guint32) 0xff000000U
) >> 24))))))
;
257
258 if (read (cfile->fd, &major, 2 ) != 2)
259 return close_and_exit (cfile);
260 cfile->major = GUINT16_FROM_BE (major)(((((guint16) ( (guint16) ((guint16) (major) >> 8) | (guint16
) ((guint16) (major) << 8))))))
;
261
262 if (read (cfile->fd, &minor, 2) != 2)
263 return close_and_exit (cfile);
264 cfile->minor = GUINT16_FROM_BE (minor)(((((guint16) ( (guint16) ((guint16) (minor) >> 8) | (guint16
) ((guint16) (minor) << 8))))))
;
265
266 if (read (cfile->fd, &count, 2) != 2)
267 return close_and_exit (cfile);
268 cfile->const_pool_count = GUINT16_FROM_BE(count)(((((guint16) ( (guint16) ((guint16) (count) >> 8) | (guint16
) ((guint16) (count) << 8))))))
;
269 load_constant_pool_utfs (cfile);
270
271 if (read (cfile->fd, &cfile->access_flags, 2) != 2)
272 return close_and_exit (cfile);
273 cfile->access_flags = GUINT16_FROM_BE (cfile->access_flags)(((((guint16) ( (guint16) ((guint16) (cfile->access_flags)
>> 8) | (guint16) ((guint16) (cfile->access_flags) <<
8))))))
;
274
275 if (read (cfile->fd, &cfile->this_class, 2) != 2)
276 return close_and_exit (cfile);
277 cfile->this_class = GUINT16_FROM_BE(cfile->this_class)(((((guint16) ( (guint16) ((guint16) (cfile->this_class) >>
8) | (guint16) ((guint16) (cfile->this_class) << 8)
)))))
;
278
279 /* now search for the class structure with index = cfile->this_class */
280
281 for (i = 0; (i < g_slist_length (cfile->const_pool_class)) && (utf_index == 0); i++ ) {
282 struct class_info *class = g_slist_nth_data (cfile->const_pool_class, i);
283 if (class->index == cfile->this_class)
284 utf_index = class->name_index; /* terminates loop */
285 }
286
287 /* now search for the utf8 string with index = utf_index */
288
289 for (i = 0; i < g_slist_length (cfile->const_pool_utf); i++) {
290 struct utf_string *data = g_slist_nth_data (cfile->const_pool_utf, i);
291 if (data->index == utf_index) {
292 package = g_strndup (data->str, data->length);
293 length = data->length;
294 break;
295 }
296 }
297
298 if (package != NULL((void*)0)) {
299 int j;
300 for (j = (int) length; (j >= 0) && (end == 0); j--)
301 if (package[j] == '/')
302 end = (guint16) j;
303 char *package_padded = g_strndup (package, end);
304 g_free(package);
305 package = package_padded;
306 }
307
308 java_class_file_free (cfile);
309
310 return package;
311}
312
313/* This function consumes a comment from the java file
314 * multiline = TRUE implies that comment is multiline */
315static void
316consume_comment (int fdesc,
317 gboolean multiline)
318{
319 gboolean escaped = FALSE(0);
320 gboolean star = FALSE(0);
321 char ch;
322
323 while (read (fdesc, &ch, 1) == 1) {
324 switch (ch) {
325 case '/':
326 if (escaped)
327 break;
328 else if (star)
329 return;
330 break;
331
332 case '\n':
333 if (! multiline)
334 return;
335 break;
336
337 case '*':
338 escaped = FALSE(0);
339 star = TRUE(!(0));
340 break;
341
342 case '\\':
343 escaped = ! escaped;
344 break;
345
346 default:
347 escaped = FALSE(0);
348 star = FALSE(0);
349 break;
350 }
351 }
352}
353
354/* This function extracts package name from a java file */
355char*
356get_package_name_from_java_file (char *fname)
357{
358 char *package = NULL((void*)0);
359 JavaClassFile *cfile;
360 gboolean prev_char_is_bslash = FALSE(0);
361 gboolean valid_char_found = FALSE(0);
362 char ch;
363
364 if (! g_file_test (fname, G_FILE_TEST_EXISTS))
365 return NULL((void*)0);
366
367 cfile = java_class_file_new ();
368 cfile->fd = open (fname, O_RDONLY00);
369 if (cfile->fd == -1)
370 return close_and_exit (cfile);
371
372 while (! valid_char_found && (read (cfile->fd, &ch, 1) == 1)) {
373 switch (ch) {
374 case '/':
375 if (prev_char_is_bslash == TRUE(!(0))) {
376 consume_comment (cfile->fd, FALSE(0));
377 prev_char_is_bslash = FALSE(0);
378 }
379 else
380 prev_char_is_bslash = TRUE(!(0));
381 break;
382
383 case '*':
384 if (prev_char_is_bslash == TRUE(!(0)))
385 consume_comment (cfile->fd, TRUE(!(0)));
386 prev_char_is_bslash = FALSE(0);
387 break;
388
389 case ' ':
390 case '\t':
391 case '\r':
392 case '\n':
393 prev_char_is_bslash = FALSE(0);
394 break;
395
396 default:
397 prev_char_is_bslash = FALSE(0);
398 valid_char_found = TRUE(!(0));
399 break;
400 }
401 }
402
403 if (ch == 'p') {
404 char first_valid_word[8] = "";
405
406 first_valid_word[0] = 'p';
407 if (read (cfile->fd, &first_valid_word[1], 6) != 6)
408 return close_and_exit (cfile);
409
410 first_valid_word[7] = 0;
411 if (g_ascii_strcasecmp (first_valid_word, "package") == 0) {
412 char buffer[500];
413 int index = 0;
414
415 while (read (cfile->fd, &ch, 1) == 1) {
416 if ((ch != ' ') && (ch != '\t'))
417 break;
418 }
419 do {
420 if (ch == ';')
421 break;
422 if (ch == '.') {
423 buffer[index++] = '/';
424 } else if (isalnum (ch)((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int)
_ISalnum)
!= 0) {
425 buffer[index++] = ch;
426 } else if ((ch == '_') || (ch == '$')) {
427 buffer[index++] = ch;
428 } else {
429 index = 0;
430 break;
431 }
432 } while (read (cfile->fd, &ch, 1) == 1);
433 buffer[index] = 0;
434 package = g_strdup (buffer)g_strdup_inline (buffer);
435 }
436 }
437
438 java_class_file_free (cfile);
439
440 return package;
441}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-b8f564.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-b8f564.html new file mode 100644 index 0000000..af2567c --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-b8f564.html @@ -0,0 +1,2089 @@ + + + +eggsmclient-xsmp.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-submodules/libegg/eggsmclient-xsmp.c
Warning:line 1199, column 18
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eggsmclient-xsmp.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-submodules/libegg -fcoverage-compilation-dir=/rootdir/mate-submodules/libegg -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/gio-unix-2.0 -I /usr/include/uuid -D EGG_SM_CLIENT_BACKEND_XSMP -D G_LOG_DOMAIN="EggSMClient" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/gio-unix-2.0 -I /usr/include/uuid -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c eggsmclient-xsmp.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 Novell, Inc.
3 *
4 * Inspired by various other pieces of code including GsmClient (C)
5 * 2001 Havoc Pennington, MateClient (C) 1998 Carsten Schaar, and twm
6 * session code (C) 1998 The Open Group.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include "config.h"
25
26#include "eggsmclient.h"
27#include "eggsmclient-private.h"
28
29#include "eggdesktopfile.h"
30
31#include <errno(*__errno_location ()).h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <X11/SM/SMlib.h>
37
38#include <gtk/gtk.h>
39#include <gdk/gdk.h>
40
41#if defined(GDK_WINDOWING_X11) || defined(HAVE_X11)
42#include <gdk/gdkx.h>
43#endif
44
45#define EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()) (egg_sm_client_xsmp_get_type ())
46#define EGG_SM_CLIENT_XSMP(obj)((((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ()))))))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP)(((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ())))))
)
47#define EGG_SM_CLIENT_XSMP_CLASS(klass)((((EggSMClientXSMPClass*) (void *) g_type_check_class_cast (
(GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ()))))
))
(G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (void *) g_type_check_class_cast ((
GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ())))))
)
48#define EGG_IS_SM_CLIENT_XSMP(obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))
)
49#define EGG_IS_SM_CLIENT_XSMP_CLASS(klass)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; }))))
(G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; })))
)
50#define EGG_SM_CLIENT_XSMP_GET_CLASS(obj)((((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
))))
(G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
)))
)
51
52typedef struct _EggSMClientXSMP EggSMClientXSMP;
53typedef struct _EggSMClientXSMPClass EggSMClientXSMPClass;
54
55/* These mostly correspond to the similarly-named states in section
56 * 9.1 of the XSMP spec. Some of the states there aren't represented
57 * here, because we don't need them. SHUTDOWN_CANCELLED is slightly
58 * different from the spec; we use it when the client is IDLE after a
59 * ShutdownCancelled message, but the application is still interacting
60 * and doesn't know the shutdown has been cancelled yet.
61 */
62typedef enum
63{
64 XSMP_STATE_IDLE,
65 XSMP_STATE_SAVE_YOURSELF,
66 XSMP_STATE_INTERACT_REQUEST,
67 XSMP_STATE_INTERACT,
68 XSMP_STATE_SAVE_YOURSELF_DONE,
69 XSMP_STATE_SHUTDOWN_CANCELLED,
70 XSMP_STATE_CONNECTION_CLOSED
71} EggSMClientXSMPState;
72
73static const char *state_names[] =
74{
75 "idle",
76 "save-yourself",
77 "interact-request",
78 "interact",
79 "save-yourself-done",
80 "shutdown-cancelled",
81 "connection-closed"
82};
83
84#define EGG_SM_CLIENT_XSMP_STATE(xsmp)(state_names[(xsmp)->state]) (state_names[(xsmp)->state])
85
86struct _EggSMClientXSMP
87{
88 EggSMClient parent;
89
90 SmcConn connection;
91 char *client_id;
92
93 EggSMClientXSMPState state;
94 char **restart_command;
95 gboolean set_restart_command;
96 int restart_style;
97 char **discard_command;
98 gboolean set_discard_command;
99
100 guint idle;
101
102 /* Current SaveYourself state */
103 guint expecting_initial_save_yourself : 1;
104 guint need_save_state : 1;
105 guint need_quit_requested : 1;
106 guint interact_errors : 1;
107 guint shutting_down : 1;
108
109 /* Todo list */
110 guint waiting_to_set_initial_properties : 1;
111 guint waiting_to_emit_quit : 1;
112 guint waiting_to_emit_quit_cancelled : 1;
113 guint waiting_to_save_myself : 1;
114
115};
116
117struct _EggSMClientXSMPClass
118{
119 EggSMClientClass parent_class;
120
121};
122
123static void sm_client_xsmp_startup (EggSMClient *client,
124 const char *client_id);
125static void sm_client_xsmp_set_restart_command (EggSMClient *client,
126 int argc,
127 const char **argv);
128static void sm_client_xsmp_set_discard_command (EggSMClient *client,
129 int argc,
130 const char **argv);
131static void sm_client_xsmp_will_quit (EggSMClient *client,
132 gboolean will_quit);
133static gboolean sm_client_xsmp_end_session (EggSMClient *client,
134 EggSMClientEndStyle style,
135 gboolean request_confirmation);
136
137static void xsmp_save_yourself (SmcConn smc_conn,
138 SmPointer client_data,
139 int save_style,
140 Boolint shutdown,
141 int interact_style,
142 Boolint fast);
143static void xsmp_die (SmcConn smc_conn,
144 SmPointer client_data);
145static void xsmp_save_complete (SmcConn smc_conn,
146 SmPointer client_data);
147static void xsmp_shutdown_cancelled (SmcConn smc_conn,
148 SmPointer client_data);
149static void xsmp_interact (SmcConn smc_conn,
150 SmPointer client_data);
151
152static SmProp *array_prop (const char *name,
153 ...);
154static SmProp *ptrarray_prop (const char *name,
155 GPtrArray *values);
156static SmProp *string_prop (const char *name,
157 const char *value);
158static SmProp *card8_prop (const char *name,
159 unsigned char value);
160
161static void set_properties (EggSMClientXSMP *xsmp, ...);
162static void delete_properties (EggSMClientXSMP *xsmp, ...);
163
164static GPtrArray *generate_command (char **restart_command,
165 const char *client_id,
166 const char *state_file);
167
168static void save_state (EggSMClientXSMP *xsmp);
169static void do_save_yourself (EggSMClientXSMP *xsmp);
170static void update_pending_events (EggSMClientXSMP *xsmp);
171
172static void ice_init (void);
173static gboolean process_ice_messages (IceConn ice_conn);
174static void smc_error_handler (SmcConn smc_conn,
175 Boolint swap,
176 int offending_minor_opcode,
177 unsigned long offending_sequence,
178 int error_class,
179 int severity,
180 SmPointer values);
181
182G_DEFINE_TYPE (EggSMClientXSMP, egg_sm_client_xsmp, EGG_TYPE_SM_CLIENT)static void egg_sm_client_xsmp_init (EggSMClientXSMP *self); static
void egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass
); static GType egg_sm_client_xsmp_get_type_once (void); static
gpointer egg_sm_client_xsmp_parent_class = ((void*)0); static
gint EggSMClientXSMP_private_offset; static void egg_sm_client_xsmp_class_intern_init
(gpointer klass) { egg_sm_client_xsmp_parent_class = g_type_class_peek_parent
(klass); if (EggSMClientXSMP_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggSMClientXSMP_private_offset); egg_sm_client_xsmp_class_init
((EggSMClientXSMPClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer egg_sm_client_xsmp_get_instance_private
(EggSMClientXSMP *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggSMClientXSMP_private_offset)))); } GType egg_sm_client_xsmp_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= egg_sm_client_xsmp_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType egg_sm_client_xsmp_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((egg_sm_client_get_type ()), g_intern_static_string ("EggSMClientXSMP"
), sizeof (EggSMClientXSMPClass), (GClassInitFunc)(void (*)(void
)) egg_sm_client_xsmp_class_intern_init, sizeof (EggSMClientXSMP
), (GInstanceInitFunc)(void (*)(void)) egg_sm_client_xsmp_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
183
184static void
185egg_sm_client_xsmp_init (EggSMClientXSMP *xsmp)
186{
187 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
188 xsmp->connection = NULL((void*)0);
189 xsmp->restart_style = SmRestartIfRunning0;
190}
191
192static void
193egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
194{
195 EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
196
197 sm_client_class->startup = sm_client_xsmp_startup;
198 sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
199 sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
200 sm_client_class->will_quit = sm_client_xsmp_will_quit;
201 sm_client_class->end_session = sm_client_xsmp_end_session;
202}
203
204EggSMClient *
205egg_sm_client_xsmp_new (void)
206{
207 if (!g_getenv ("SESSION_MANAGER"))
208 return NULL((void*)0);
209
210 return g_object_new (EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()), NULL((void*)0));
211}
212
213static gboolean
214sm_client_xsmp_set_initial_properties (gpointer user_data)
215{
216 EggSMClientXSMP *xsmp = user_data;
217 EggDesktopFile *desktop_file;
218 GPtrArray *clone, *restart;
219 char pid_str[64];
220
221 if (xsmp->idle)
222 {
223 g_source_remove (xsmp->idle);
224 xsmp->idle = 0;
225 }
226 xsmp->waiting_to_set_initial_properties = FALSE(0);
227
228 if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART)
229 xsmp->restart_style = SmRestartNever3;
230
231 /* Parse info out of desktop file */
232 desktop_file = egg_get_desktop_file ();
233 if (desktop_file)
234 {
235 GError *err = NULL((void*)0);
236 char **argv;
237 int argc;
238
239 if (xsmp->restart_style == SmRestartIfRunning0)
240 {
241 if (egg_desktop_file_get_boolean (desktop_file,
242 "X-MATE-AutoRestart", NULL((void*)0)))
243 xsmp->restart_style = SmRestartImmediately2;
244 }
245
246 if (!xsmp->set_restart_command)
247 {
248 char *cmdline;
249
250 cmdline = egg_desktop_file_parse_exec (desktop_file, NULL((void*)0), &err);
251 if (cmdline && g_shell_parse_argv (cmdline, &argc, &argv, &err))
252 {
253 egg_sm_client_set_restart_command (EGG_SM_CLIENT (xsmp),
254 argc, (const char **)argv);
255 g_strfreev (argv);
256 }
257 else
258 {
259 g_warning ("Could not parse Exec line in desktop file: %s",
260 err->message);
261 g_error_free (err);
262 }
263 g_free (cmdline);
264 }
265 }
266
267 if (!xsmp->set_restart_command)
268 xsmp->restart_command = g_strsplit (g_get_prgname (), " ", -1);
269
270 clone = generate_command (xsmp->restart_command, NULL((void*)0), NULL((void*)0));
271 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
272
273 g_debug ("Setting initial properties");
274
275 /* Program, CloneCommand, RestartCommand, and UserID are required.
276 * ProcessID isn't required, but the SM may be able to do something
277 * useful with it.
278 */
279 g_snprintf (pid_str, sizeof (pid_str), "%lu", (gulong) getpid ());
280 set_properties (xsmp,
281 string_prop (SmProgram"Program", g_get_prgname ()),
282 ptrarray_prop (SmCloneCommand"CloneCommand", clone),
283 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
284 string_prop (SmUserID"UserID", g_get_user_name ()),
285 string_prop (SmProcessID"ProcessID", pid_str),
286 card8_prop (SmRestartStyleHint"RestartStyleHint", xsmp->restart_style),
287 NULL((void*)0));
288 g_ptr_array_free (clone, TRUE(!(0)));
289 g_ptr_array_free (restart, TRUE(!(0)));
290
291 if (desktop_file)
292 {
293 set_properties (xsmp,
294 string_prop ("_GSM_DesktopFile", egg_desktop_file_get_source (desktop_file)),
295 NULL((void*)0));
296 }
297
298 update_pending_events (xsmp);
299 return FALSE(0);
300}
301
302/* This gets called from two different places: xsmp_die() (when the
303 * server asks us to disconnect) and process_ice_messages() (when the
304 * server disconnects unexpectedly).
305 */
306static void
307sm_client_xsmp_disconnect (EggSMClientXSMP *xsmp)
308{
309 SmcConn connection;
310
311 if (!xsmp->connection)
312 return;
313
314 g_debug ("Disconnecting");
315
316 connection = xsmp->connection;
317 xsmp->connection = NULL((void*)0);
318 SmcCloseConnection (connection, 0, NULL((void*)0));
319 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
320
321 xsmp->waiting_to_save_myself = FALSE(0);
322 update_pending_events (xsmp);
323}
324
325static void
326sm_client_xsmp_startup (EggSMClient *client,
327 const char *client_id)
328{
329 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
330 SmcCallbacks callbacks;
331 char *ret_client_id;
332 char error_string_ret[256];
333
334 xsmp->client_id = g_strdup (client_id)g_strdup_inline (client_id);
335
336 ice_init ();
337 SmcSetErrorHandler (smc_error_handler);
338
339 callbacks.save_yourself.callback = xsmp_save_yourself;
340 callbacks.die.callback = xsmp_die;
341 callbacks.save_complete.callback = xsmp_save_complete;
342 callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
343
344 callbacks.save_yourself.client_data = xsmp;
345 callbacks.die.client_data = xsmp;
346 callbacks.save_complete.client_data = xsmp;
347 callbacks.shutdown_cancelled.client_data = xsmp;
348
349 client_id = NULL((void*)0);
350 error_string_ret[0] = '\0';
351 xsmp->connection =
352 SmcOpenConnection (NULL((void*)0), xsmp, SmProtoMajor1, SmProtoMinor0,
353 SmcSaveYourselfProcMask(1L << 0) | SmcDieProcMask(1L << 1) |
354 SmcSaveCompleteProcMask(1L << 2) |
355 SmcShutdownCancelledProcMask(1L << 3),
356 &callbacks,
357 xsmp->client_id, &ret_client_id,
358 sizeof (error_string_ret), error_string_ret);
359
360 if (!xsmp->connection)
361 {
362 g_warning ("Failed to connect to the session manager: %s\n",
363 error_string_ret[0] ?
364 error_string_ret : "no error message given");
365 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
366 return;
367 }
368
369 /* We expect a pointless initial SaveYourself if either (a) we
370 * didn't have an initial client ID, or (b) we DID have an initial
371 * client ID, but the server rejected it and gave us a new one.
372 */
373 if (!xsmp->client_id ||
374 (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0))
375 xsmp->expecting_initial_save_yourself = TRUE(!(0));
376
377 if (ret_client_id)
378 {
379 g_free (xsmp->client_id);
380 xsmp->client_id = g_strdup (ret_client_id)g_strdup_inline (ret_client_id);
381 free (ret_client_id);
382
383#if defined(GDK_WINDOWING_X11) || defined(HAVE_X11)
384 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
385 gdk_x11_set_sm_client_id (xsmp->client_id);
386#endif
387
388 g_debug ("Got client ID \"%s\"", xsmp->client_id);
389 }
390
391 xsmp->state = XSMP_STATE_IDLE;
392
393 /* Do not set the initial properties until we reach the main loop,
394 * so that the application has a chance to call
395 * egg_set_desktop_file(). (This may also help the session manager
396 * have a better idea of when the application is fully up and
397 * running.)
398 */
399 xsmp->waiting_to_set_initial_properties = TRUE(!(0));
400 xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client);
401}
402
403static void
404sm_client_xsmp_set_restart_command (EggSMClient *client,
405 int argc,
406 const char **argv)
407{
408 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
409 int i;
410
411 g_strfreev (xsmp->restart_command);
412
413 xsmp->restart_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
414 for (i = 0; i < argc; i++)
415 xsmp->restart_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
416 xsmp->restart_command[i] = NULL((void*)0);
417
418 xsmp->set_restart_command = TRUE(!(0));
419}
420
421static void
422sm_client_xsmp_set_discard_command (EggSMClient *client,
423 int argc,
424 const char **argv)
425{
426 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
427 int i;
428
429 g_strfreev (xsmp->discard_command);
430
431 xsmp->discard_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
432 for (i = 0; i < argc; i++)
433 xsmp->discard_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
434 xsmp->discard_command[i] = NULL((void*)0);
435
436 xsmp->set_discard_command = TRUE(!(0));
437}
438
439static void
440sm_client_xsmp_will_quit (EggSMClient *client,
441 gboolean will_quit)
442{
443 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
444
445 if (xsmp->state == XSMP_STATE_CONNECTION_CLOSED)
446 {
447 /* The session manager has already exited! Schedule a quit
448 * signal.
449 */
450 xsmp->waiting_to_emit_quit = TRUE(!(0));
451 update_pending_events (xsmp);
452 return;
453 }
454 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
455 {
456 /* We received a ShutdownCancelled message while the application
457 * was interacting; Schedule a quit_cancelled signal.
458 */
459 xsmp->waiting_to_emit_quit_cancelled = TRUE(!(0));
460 update_pending_events (xsmp);
461 return;
462 }
463
464 g_return_if_fail (xsmp->state == XSMP_STATE_INTERACT)do { if ((xsmp->state == XSMP_STATE_INTERACT)) { } else { g_return_if_fail_warning
("EggSMClient", ((const char*) (__func__)), "xsmp->state == XSMP_STATE_INTERACT"
); return; } } while (0)
;
465
466 g_debug ("Sending InteractDone(%s)", will_quit ? "False" : "True");
467 SmcInteractDone (xsmp->connection, !will_quit);
468
469 if (will_quit && xsmp->need_save_state)
470 save_state (xsmp);
471
472 g_debug ("Sending SaveYourselfDone(%s)", will_quit ? "True" : "False");
473 SmcSaveYourselfDone (xsmp->connection, will_quit);
474 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
475}
476
477static gboolean
478sm_client_xsmp_end_session (EggSMClient *client,
479 EggSMClientEndStyle style,
480 gboolean request_confirmation)
481{
482 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
483 int save_type;
484
485 /* To end the session via XSMP, we have to send a
486 * SaveYourselfRequest. We aren't allowed to do that if anything
487 * else is going on, but we don't want to expose this fact to the
488 * application. So we do our best to patch things up here...
489 *
490 * In the worst case, this method might block for some length of
491 * time in process_ice_messages, but the only time that code path is
492 * honestly likely to get hit is if the application tries to end the
493 * session as the very first thing it does, in which case it
494 * probably won't actually block anyway. It's not worth gunking up
495 * the API to try to deal nicely with the other 0.01% of cases where
496 * this happens.
497 */
498
499 while (xsmp->state != XSMP_STATE_IDLE ||
500 xsmp->expecting_initial_save_yourself)
501 {
502 /* If we're already shutting down, we don't need to do anything. */
503 if (xsmp->shutting_down)
504 return TRUE(!(0));
505
506 switch (xsmp->state)
507 {
508 case XSMP_STATE_CONNECTION_CLOSED:
509 return FALSE(0);
510
511 case XSMP_STATE_SAVE_YOURSELF:
512 /* Trying to log out from the save_state callback? Whatever.
513 * Abort the save_state.
514 */
515 SmcSaveYourselfDone (xsmp->connection, FALSE(0));
516 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
517 break;
518
519 case XSMP_STATE_INTERACT_REQUEST:
520 case XSMP_STATE_INTERACT:
521 case XSMP_STATE_SHUTDOWN_CANCELLED:
522 /* Already in a shutdown-related state, just ignore
523 * the new shutdown request...
524 */
525 return TRUE(!(0));
526
527 case XSMP_STATE_IDLE:
528 if (xsmp->waiting_to_set_initial_properties)
529 sm_client_xsmp_set_initial_properties (xsmp);
530
531 if (!xsmp->expecting_initial_save_yourself)
532 break;
533 /* else fall through */
534
535 case XSMP_STATE_SAVE_YOURSELF_DONE:
536 /* We need to wait for some response from the server.*/
537 process_ice_messages (SmcGetIceConnection (xsmp->connection));
538 break;
539
540 default:
541 /* Hm... shouldn't happen */
542 return FALSE(0);
543 }
544 }
545
546 /* xfce4-session will do the wrong thing if we pass SmSaveGlobal and
547 * the user chooses to save the session. But mate-session will do
548 * the wrong thing if we pass SmSaveBoth and the user chooses NOT to
549 * save the session... Sigh.
550 */
551 if (!strcmp (SmcVendor (xsmp->connection), "xfce4-session"))
552 save_type = SmSaveBoth2;
553 else
554 save_type = SmSaveGlobal0;
555
556 g_debug ("Sending SaveYourselfRequest(SmSaveGlobal, Shutdown, SmInteractStyleAny, %sFast)", request_confirmation ? "!" : "");
557 SmcRequestSaveYourself (xsmp->connection,
558 save_type,
559 True1, /* shutdown */
560 SmInteractStyleAny2,
561 !request_confirmation, /* fast */
562 True1 /* global */);
563 return TRUE(!(0));
564}
565
566static gboolean
567idle_do_pending_events (gpointer data)
568{
569 EggSMClientXSMP *xsmp = data;
570 EggSMClient *client = data;
571
572 xsmp->idle = 0;
573
574 if (xsmp->waiting_to_emit_quit)
575 {
576 xsmp->waiting_to_emit_quit = FALSE(0);
577 egg_sm_client_quit (client);
578 goto out;
579 }
580
581 if (xsmp->waiting_to_emit_quit_cancelled)
582 {
583 xsmp->waiting_to_emit_quit_cancelled = FALSE(0);
584 egg_sm_client_quit_cancelled (client);
585 xsmp->state = XSMP_STATE_IDLE;
586 }
587
588 if (xsmp->waiting_to_save_myself)
589 {
590 xsmp->waiting_to_save_myself = FALSE(0);
591 do_save_yourself (xsmp);
592 }
593
594out:
595 return FALSE(0);
596}
597
598static void
599update_pending_events (EggSMClientXSMP *xsmp)
600{
601 gboolean want_idle =
602 xsmp->waiting_to_emit_quit ||
603 xsmp->waiting_to_emit_quit_cancelled ||
604 xsmp->waiting_to_save_myself;
605
606 if (want_idle)
607 {
608 if (xsmp->idle == 0)
609 xsmp->idle = g_idle_add (idle_do_pending_events, xsmp);
610 }
611 else
612 {
613 if (xsmp->idle != 0)
614 g_source_remove (xsmp->idle);
615 xsmp->idle = 0;
616 }
617}
618
619static void
620fix_broken_state (EggSMClientXSMP *xsmp, const char *message,
621 gboolean send_interact_done,
622 gboolean send_save_yourself_done)
623{
624 g_warning ("Received XSMP %s message in state %s: client or server error",
625 message, EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
626
627 /* Forget any pending SaveYourself plans we had */
628 xsmp->waiting_to_save_myself = FALSE(0);
629 update_pending_events (xsmp);
630
631 if (send_interact_done)
632 SmcInteractDone (xsmp->connection, False0);
633 if (send_save_yourself_done)
634 SmcSaveYourselfDone (xsmp->connection, True1);
635
636 xsmp->state = send_save_yourself_done ? XSMP_STATE_SAVE_YOURSELF_DONE : XSMP_STATE_IDLE;
637}
638
639/* SM callbacks */
640
641static void
642xsmp_save_yourself (SmcConn smc_conn,
643 SmPointer client_data,
644 int save_type,
645 Boolint shutdown,
646 int interact_style,
647 Boolint fast)
648{
649 EggSMClientXSMP *xsmp = client_data;
650 gboolean wants_quit_requested;
651
652 g_debug ("Received SaveYourself(%s, %s, %s, %s) in state %s",
653 save_type == SmSaveLocal1 ? "SmSaveLocal" :
654 save_type == SmSaveGlobal0 ? "SmSaveGlobal" : "SmSaveBoth",
655 shutdown ? "Shutdown" : "!Shutdown",
656 interact_style == SmInteractStyleAny2 ? "SmInteractStyleAny" :
657 interact_style == SmInteractStyleErrors1 ? "SmInteractStyleErrors" :
658 "SmInteractStyleNone", fast ? "Fast" : "!Fast",
659 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
660
661 if (xsmp->state != XSMP_STATE_IDLE &&
662 xsmp->state != XSMP_STATE_SHUTDOWN_CANCELLED)
663 {
664 fix_broken_state (xsmp, "SaveYourself", FALSE(0), TRUE(!(0)));
665 return;
666 }
667
668 if (xsmp->waiting_to_set_initial_properties)
669 sm_client_xsmp_set_initial_properties (xsmp);
670
671 /* If this is the initial SaveYourself, ignore it; we've already set
672 * properties and there's no reason to actually save state too.
673 */
674 if (xsmp->expecting_initial_save_yourself)
675 {
676 xsmp->expecting_initial_save_yourself = FALSE(0);
677
678 if (save_type == SmSaveLocal1 &&
679 interact_style == SmInteractStyleNone0 &&
680 !shutdown && !fast)
681 {
682 g_debug ("Sending SaveYourselfDone(True) for initial SaveYourself");
683 SmcSaveYourselfDone (xsmp->connection, True1);
684 /* As explained in the comment at the end of
685 * do_save_yourself(), SAVE_YOURSELF_DONE is the correct
686 * state here, not IDLE.
687 */
688 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
689 return;
690 }
691 else
692 g_warning ("First SaveYourself was not the expected one!");
693 }
694
695 /* Even ignoring the "fast" flag completely, there are still 18
696 * different combinations of save_type, shutdown and interact_style.
697 * We interpret them as follows:
698 *
699 * Type Shutdown Interact Interpretation
700 * G F A/E/N do nothing (1)
701 * G T N do nothing (1)*
702 * G T A/E quit_requested (2)
703 * L/B F A/E/N save_state (3)
704 * L/B T N save_state (3)*
705 * L/B T A/E quit_requested, then save_state (4)
706 *
707 * 1. Do nothing, because the SM asked us to do something
708 * uninteresting (save open files, but then don't quit
709 * afterward) or rude (save open files without asking the user
710 * for confirmation).
711 *
712 * 2. Request interaction and then emit ::quit_requested. This
713 * perhaps isn't quite correct for the SmInteractStyleErrors
714 * case, but we don't care.
715 *
716 * 3. Emit ::save_state. The SmSaveBoth SaveYourselfs in these
717 * rows essentially get demoted to SmSaveLocal, because their
718 * Global halves correspond to "do nothing".
719 *
720 * 4. Request interaction, emit ::quit_requested, and then emit
721 * ::save_state after interacting. This is the SmSaveBoth
722 * equivalent of #2, but we also promote SmSaveLocal shutdown
723 * SaveYourselfs to SmSaveBoth here, because we want to give
724 * the user a chance to save open files before quitting.
725 *
726 * (* It would be nice if we could do something useful when the
727 * session manager sends a SaveYourself with shutdown True and
728 * SmInteractStyleNone. But we can't, so we just pretend it didn't
729 * even tell us it was shutting down. The docs for ::quit mention
730 * that it might not always be preceded by ::quit_requested.)
731 */
732
733 /* As an optimization, we don't actually request interaction and
734 * emit ::quit_requested if the application isn't listening to the
735 * signal.
736 */
737 wants_quit_requested = g_signal_has_handler_pending (xsmp, g_signal_lookup ("quit_requested", EGG_TYPE_SM_CLIENT(egg_sm_client_get_type ())), 0, FALSE(0));
738
739 xsmp->need_save_state = (save_type != SmSaveGlobal0);
740 xsmp->need_quit_requested = (shutdown && wants_quit_requested &&
741 interact_style != SmInteractStyleNone0);
742 xsmp->interact_errors = (interact_style == SmInteractStyleErrors1);
743
744 xsmp->shutting_down = shutdown;
745
746 do_save_yourself (xsmp);
747}
748
749static void
750do_save_yourself (EggSMClientXSMP *xsmp)
751{
752 if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
753 {
754 /* The SM cancelled a previous SaveYourself, but we haven't yet
755 * had a chance to tell the application, so we can't start
756 * processing this SaveYourself yet.
757 */
758 xsmp->waiting_to_save_myself = TRUE(!(0));
759 update_pending_events (xsmp);
760 return;
761 }
762
763 if (xsmp->need_quit_requested)
764 {
765 xsmp->state = XSMP_STATE_INTERACT_REQUEST;
766
767 g_debug ("Sending InteractRequest(%s)",
768 xsmp->interact_errors ? "Error" : "Normal");
769 SmcInteractRequest (xsmp->connection,
770 xsmp->interact_errors ? SmDialogError0 : SmDialogNormal1,
771 xsmp_interact,
772 xsmp);
773 return;
774 }
775
776 if (xsmp->need_save_state)
777 {
778 save_state (xsmp);
779
780 /* Though unlikely, the client could have been disconnected
781 * while the application was saving its state.
782 */
783 if (!xsmp->connection)
784 return;
785 }
786
787 g_debug ("Sending SaveYourselfDone(True)");
788 SmcSaveYourselfDone (xsmp->connection, True1);
789
790 /* The client state diagram in the XSMP spec says that after a
791 * non-shutdown SaveYourself, we go directly back to "idle". But
792 * everything else in both the XSMP spec and the libSM docs
793 * disagrees.
794 */
795 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
796}
797
798static void
799save_state (EggSMClientXSMP *xsmp)
800{
801 GKeyFile *state_file;
802 char *state_file_path, *data;
803 EggDesktopFile *desktop_file;
804 GPtrArray *restart, *discard;
805 int offset, fd;
806
807 /* We set xsmp->state before emitting save_state, but our caller is
808 * responsible for setting it back afterward.
809 */
810 xsmp->state = XSMP_STATE_SAVE_YOURSELF;
811
812 state_file = egg_sm_client_save_state ((EggSMClient *)xsmp);
813 if (!state_file)
814 {
815 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
816 set_properties (xsmp,
817 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
818 NULL((void*)0));
819 g_ptr_array_free (restart, TRUE(!(0)));
820
821 if (xsmp->set_discard_command)
822 {
823 discard = generate_command (xsmp->discard_command, NULL((void*)0), NULL((void*)0));
824 set_properties (xsmp,
825 ptrarray_prop (SmDiscardCommand"DiscardCommand", discard),
826 NULL((void*)0));
827 g_ptr_array_free (discard, TRUE(!(0)));
828 }
829 else
830 delete_properties (xsmp, SmDiscardCommand"DiscardCommand", NULL((void*)0));
831
832 return;
833 }
834
835 desktop_file = egg_get_desktop_file ();
836 if (desktop_file)
837 {
838 GKeyFile *merged_file;
839 char *desktop_file_path;
840
841 merged_file = g_key_file_new ();
842 desktop_file_path =
843 g_filename_from_uri (egg_desktop_file_get_source (desktop_file),
844 NULL((void*)0), NULL((void*)0));
845 if (desktop_file_path &&
846 g_key_file_load_from_file (merged_file, desktop_file_path,
847 G_KEY_FILE_KEEP_COMMENTS |
848 G_KEY_FILE_KEEP_TRANSLATIONS, NULL((void*)0)))
849 {
850 guint g, k, i;
851 char **groups, **keys, *value, *exec;
852
853 groups = g_key_file_get_groups (state_file, NULL((void*)0));
854 for (g = 0; groups[g]; g++)
855 {
856 keys = g_key_file_get_keys (state_file, groups[g], NULL((void*)0), NULL((void*)0));
857 for (k = 0; keys[k]; k++)
858 {
859 value = g_key_file_get_value (state_file, groups[g],
860 keys[k], NULL((void*)0));
861 if (value)
862 {
863 g_key_file_set_value (merged_file, groups[g],
864 keys[k], value);
865 g_free (value);
866 }
867 }
868 g_strfreev (keys);
869 }
870 g_strfreev (groups);
871
872 g_key_file_free (state_file);
873 state_file = merged_file;
874
875 /* Update Exec key using "--sm-client-state-file %k" */
876 restart = generate_command (xsmp->restart_command,
877 NULL((void*)0), "%k");
878 for (i = 0; i < restart->len; i++)
879 restart->pdata[i] = g_shell_quote (restart->pdata[i]);
880 g_ptr_array_add (restart, NULL((void*)0));
881 exec = g_strjoinv (" ", (char **)restart->pdata);
882 g_strfreev ((char **)restart->pdata);
883 g_ptr_array_free (restart, FALSE(0));
884
885 g_key_file_set_string (state_file, EGG_DESKTOP_FILE_GROUP"Desktop Entry",
886 EGG_DESKTOP_FILE_KEY_EXEC"Exec",
887 exec);
888 g_free (exec);
889 }
890 else
891 desktop_file = NULL((void*)0);
892
893 g_free (desktop_file_path);
894 }
895
896 /* Now write state_file to disk. (We can't use mktemp(), because
897 * that requires the filename to end with "XXXXXX", and we want
898 * it to end with ".desktop".)
899 */
900
901 data = g_key_file_to_data (state_file, NULL((void*)0), NULL((void*)0));
902 g_key_file_free (state_file);
903
904 offset = 0;
905 while (1)
906 {
907 state_file_path = g_strdup_printf ("%s%csession-state%c%s-%ld.%s",
908 g_get_user_config_dir (),
909 G_DIR_SEPARATOR'/', G_DIR_SEPARATOR'/',
910 g_get_prgname (),
911 (long)time (NULL((void*)0)) + offset,
912 desktop_file ? "desktop" : "state");
913
914 fd = open (state_file_path, O_WRONLY01 | O_CREAT0100 | O_EXCL0200, 0644);
915 if (fd == -1)
916 {
917 if (errno(*__errno_location ()) == EEXIST17)
918 {
919 offset++;
920 g_free (state_file_path);
921 continue;
922 }
923 else if (errno(*__errno_location ()) == ENOTDIR20 || errno(*__errno_location ()) == ENOENT2)
924 {
925 char *sep = strrchr (state_file_path, G_DIR_SEPARATOR'/');
926
927 *sep = '\0';
928 if (g_mkdir_with_parents (state_file_path, 0755) != 0)
929 {
930 g_warning ("Could not create directory '%s'",
931 state_file_path);
932 g_free (state_file_path);
933 state_file_path = NULL((void*)0);
934 break;
935 }
936
937 continue;
938 }
939
940 g_warning ("Could not create file '%s': %s",
941 state_file_path, g_strerror (errno(*__errno_location ())));
942 g_free (state_file_path);
943 state_file_path = NULL((void*)0);
944 break;
945 }
946
947 close (fd);
948 g_file_set_contents (state_file_path, data, -1, NULL((void*)0));
949 break;
950 }
951 g_free (data);
952
953 restart = generate_command (xsmp->restart_command, xsmp->client_id,
954 state_file_path);
955 set_properties (xsmp,
956 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
957 NULL((void*)0));
958 g_ptr_array_free (restart, TRUE(!(0)));
959
960 if (state_file_path)
961 {
962 set_properties (xsmp,
963 array_prop (SmDiscardCommand"DiscardCommand",
964 "/bin/rm", "-rf", state_file_path,
965 NULL((void*)0)),
966 NULL((void*)0));
967 g_free (state_file_path);
968 }
969}
970
971static void
972xsmp_interact (SmcConn smc_conn,
973 SmPointer client_data)
974{
975 EggSMClientXSMP *xsmp = client_data;
976 EggSMClient *client = client_data;
977
978 g_debug ("Received Interact message in state %s",
979 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
980
981 if (xsmp->state != XSMP_STATE_INTERACT_REQUEST)
982 {
983 fix_broken_state (xsmp, "Interact", TRUE(!(0)), TRUE(!(0)));
984 return;
985 }
986
987 xsmp->state = XSMP_STATE_INTERACT;
988 egg_sm_client_quit_requested (client);
989}
990
991static void
992xsmp_die (SmcConn smc_conn,
993 SmPointer client_data)
994{
995 EggSMClientXSMP *xsmp = client_data;
996 EggSMClient *client = client_data;
997
998 g_debug ("Received Die message in state %s",
999 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1000
1001 sm_client_xsmp_disconnect (xsmp);
1002 egg_sm_client_quit (client);
1003}
1004
1005static void
1006xsmp_save_complete (SmcConn smc_conn,
1007 SmPointer client_data)
1008{
1009 EggSMClientXSMP *xsmp = client_data;
1010
1011 g_debug ("Received SaveComplete message in state %s",
1012 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1013
1014 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1015 xsmp->state = XSMP_STATE_IDLE;
1016 else
1017 fix_broken_state (xsmp, "SaveComplete", FALSE(0), FALSE(0));
1018}
1019
1020static void
1021xsmp_shutdown_cancelled (SmcConn smc_conn,
1022 SmPointer client_data)
1023{
1024 EggSMClientXSMP *xsmp = client_data;
1025 EggSMClient *client = client_data;
1026
1027 g_debug ("Received ShutdownCancelled message in state %s",
1028 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1029
1030 xsmp->shutting_down = FALSE(0);
1031
1032 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1033 {
1034 /* We've finished interacting and now the SM has agreed to
1035 * cancel the shutdown.
1036 */
1037 xsmp->state = XSMP_STATE_IDLE;
1038 egg_sm_client_quit_cancelled (client);
1039 }
1040 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
1041 {
1042 /* Hm... ok, so we got a shutdown SaveYourself, which got
1043 * cancelled, but the application was still interacting, so we
1044 * didn't tell it yet, and then *another* SaveYourself arrived,
1045 * which we must still be waiting to tell the app about, except
1046 * that now that SaveYourself has been cancelled too! Dizzy yet?
1047 */
1048 xsmp->waiting_to_save_myself = FALSE(0);
1049 update_pending_events (xsmp);
1050 }
1051 else
1052 {
1053 g_debug ("Sending SaveYourselfDone(False)");
1054 SmcSaveYourselfDone (xsmp->connection, False0);
1055
1056 if (xsmp->state == XSMP_STATE_INTERACT)
1057 {
1058 /* The application is currently interacting, so we can't
1059 * tell it about the cancellation yet; we will wait until
1060 * after it calls egg_sm_client_will_quit().
1061 */
1062 xsmp->state = XSMP_STATE_SHUTDOWN_CANCELLED;
1063 }
1064 else
1065 {
1066 /* The shutdown was cancelled before the application got a
1067 * chance to interact.
1068 */
1069 xsmp->state = XSMP_STATE_IDLE;
1070 }
1071 }
1072}
1073
1074/* Utilities */
1075
1076/* Create a restart/clone/Exec command based on @restart_command.
1077 * If @client_id is non-%NULL, add "--sm-client-id @client_id".
1078 * If @state_file is non-%NULL, add "--sm-client-state-file @state_file".
1079 *
1080 * None of the input strings are g_strdup()ed; the caller must keep
1081 * them around until it is done with the returned GPtrArray, and must
1082 * then free the array, but not its contents.
1083 */
1084static GPtrArray *
1085generate_command (char **restart_command, const char *client_id,
1086 const char *state_file)
1087{
1088 GPtrArray *cmd;
1089 int i;
1090
1091 cmd = g_ptr_array_new ();
1092 g_ptr_array_add (cmd, restart_command[0]);
1093
1094 if (client_id)
1095 {
1096 g_ptr_array_add (cmd, (char *)"--sm-client-id");
1097 g_ptr_array_add (cmd, (char *)client_id);
1098 }
1099
1100 if (state_file)
1101 {
1102 g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
1103 g_ptr_array_add (cmd, (char *)state_file);
1104 }
1105
1106 for (i = 1; restart_command[i]; i++)
1107 g_ptr_array_add (cmd, restart_command[i]);
1108
1109 return cmd;
1110}
1111
1112/* Takes a NULL-terminated list of SmProp * values, created by
1113 * array_prop, ptrarray_prop, string_prop, card8_prop, sets them, and
1114 * frees them.
1115 */
1116static void
1117set_properties (EggSMClientXSMP *xsmp, ...)
1118{
1119 GPtrArray *props;
1120 SmProp *prop;
1121 va_list ap;
1122 guint i;
1123
1124 props = g_ptr_array_new ();
1125
1126 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1127 while ((prop = va_arg (ap, SmProp *)__builtin_va_arg(ap, SmProp *)))
1128 g_ptr_array_add (props, prop);
1129 va_end (ap)__builtin_va_end(ap);
1130
1131 if (xsmp->connection)
1132 {
1133 SmcSetProperties (xsmp->connection, props->len,
1134 (SmProp **)props->pdata);
1135 }
1136
1137 for (i = 0; i < props->len; i++)
1138 {
1139 prop = props->pdata[i];
1140 g_free (prop->vals);
1141 g_free (prop);
1142 }
1143 g_ptr_array_free (props, TRUE(!(0)));
1144}
1145
1146/* Takes a NULL-terminated list of property names and deletes them. */
1147static void
1148delete_properties (EggSMClientXSMP *xsmp, ...)
1149{
1150 GPtrArray *props;
1151 char *prop;
1152 va_list ap;
1153
1154 if (!xsmp->connection)
1155 return;
1156
1157 props = g_ptr_array_new ();
1158
1159 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1160 while ((prop = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1161 g_ptr_array_add (props, prop);
1162 va_end (ap)__builtin_va_end(ap);
1163
1164 SmcDeleteProperties (xsmp->connection, props->len,
1165 (char **)props->pdata);
1166
1167 g_ptr_array_free (props, TRUE(!(0)));
1168}
1169
1170/* Takes an array of strings and creates a LISTofARRAY8 property. The
1171 * strings are neither dupped nor freed; they need to remain valid
1172 * until you're done with the SmProp.
1173 */
1174static SmProp *
1175array_prop (const char *name, ...)
1176{
1177 SmProp *prop;
1178 SmPropValue pv;
1179 GArray *vals;
1180 char *value;
1181 va_list ap;
1182
1183 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1184 prop->name = (char *)name;
1185 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1186
1187 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1188
1189 va_start (ap, name)__builtin_va_start(ap, name);
1190 while ((value = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1191 {
1192 pv.length = strlen (value);
1193 pv.value = value;
1194 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1195 }
1196 va_end (ap)__builtin_va_end(ap);
1197
1198 prop->num_vals = vals->len;
1199 prop->vals = (SmPropValue *)vals->data;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1200
1201 g_array_free (vals, FALSE(0));
1202
1203 return prop;
1204}
1205
1206/* Takes a GPtrArray of strings and creates a LISTofARRAY8 property.
1207 * The array contents are neither dupped nor freed; they need to
1208 * remain valid until you're done with the SmProp.
1209 */
1210static SmProp *
1211ptrarray_prop (const char *name, GPtrArray *values)
1212{
1213 SmProp *prop;
1214 SmPropValue pv;
1215 GArray *vals;
1216 guint i;
1217
1218 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1219 prop->name = (char *)name;
1220 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1221
1222 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1223
1224 for (i = 0; i < values->len; i++)
1225 {
1226 pv.length = strlen (values->pdata[i]);
1227 pv.value = values->pdata[i];
1228 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1229 }
1230
1231 prop->num_vals = vals->len;
1232 prop->vals = (SmPropValue *)vals->data;
1233
1234 g_array_free (vals, FALSE(0));
1235
1236 return prop;
1237}
1238
1239/* Takes a string and creates an ARRAY8 property. The string is
1240 * neither dupped nor freed; it needs to remain valid until you're
1241 * done with the SmProp.
1242 */
1243static SmProp *
1244string_prop (const char *name, const char *value)
1245{
1246 SmProp *prop;
1247
1248 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1249 prop->name = (char *)name;
1250 prop->type = (char *)SmARRAY8"ARRAY8";
1251
1252 prop->num_vals = 1;
1253 prop->vals = g_new (SmPropValue, 1)((SmPropValue *) g_malloc_n ((1), sizeof (SmPropValue)));
1254
1255 prop->vals[0].length = strlen (value);
1256 prop->vals[0].value = (char *)value;
1257
1258 return prop;
1259}
1260
1261/* Takes a char and creates a CARD8 property. */
1262static SmProp *
1263card8_prop (const char *name, unsigned char value)
1264{
1265 SmProp *prop;
1266 char *card8val;
1267
1268 /* To avoid having to allocate and free prop->vals[0], we cheat and
1269 * make vals a 2-element-long array and then use the second element
1270 * to store value.
1271 */
1272
1273 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1274 prop->name = (char *)name;
1275 prop->type = (char *)SmCARD8"CARD8";
1276
1277 prop->num_vals = 1;
1278 prop->vals = g_new (SmPropValue, 2)((SmPropValue *) g_malloc_n ((2), sizeof (SmPropValue)));
1279 card8val = (char *)(&prop->vals[1]);
1280 card8val[0] = value;
1281
1282 prop->vals[0].length = 1;
1283 prop->vals[0].value = card8val;
1284
1285 return prop;
1286}
1287
1288/* ICE code. This makes no effort to play nice with anyone else trying
1289 * to use libICE. Fortunately, no one uses libICE for anything other
1290 * than SM. (DCOP uses ICE, but it has its own private copy of
1291 * libICE.)
1292 *
1293 * When this moves to gtk, it will need to be cleverer, to avoid
1294 * tripping over old apps that use MateClient or that use libSM
1295 * directly.
1296 */
1297
1298#include <X11/ICE/ICElib.h>
1299#include <fcntl.h>
1300
1301static void ice_error_handler (IceConn ice_conn,
1302 Boolint swap,
1303 int offending_minor_opcode,
1304 unsigned long offending_sequence,
1305 int error_class,
1306 int severity,
1307 IcePointer values);
1308static void ice_io_error_handler (IceConn ice_conn);
1309static void ice_connection_watch (IceConn ice_conn,
1310 IcePointer client_data,
1311 Boolint opening,
1312 IcePointer *watch_data);
1313
1314static void
1315ice_init (void)
1316{
1317 IceSetIOErrorHandler (ice_io_error_handler);
1318 IceSetErrorHandler (ice_error_handler);
1319 IceAddConnectionWatch (ice_connection_watch, NULL((void*)0));
1320}
1321
1322static gboolean
1323process_ice_messages (IceConn ice_conn)
1324{
1325 IceProcessMessagesStatus status;
1326 status = IceProcessMessages (ice_conn, NULL((void*)0), NULL((void*)0));
1327
1328 switch (status)
1329 {
1330 case IceProcessMessagesSuccess:
1331 return TRUE(!(0));
1332
1333 case IceProcessMessagesIOError:
1334 sm_client_xsmp_disconnect (IceGetConnectionContext (ice_conn));
1335 return FALSE(0);
1336
1337 case IceProcessMessagesConnectionClosed:
1338 return FALSE(0);
1339
1340 default:
1341 g_assert_not_reached ()do { g_assertion_message_expr ("EggSMClient", "eggsmclient-xsmp.c"
, 1341, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1342 }
1343}
1344
1345static gboolean
1346ice_iochannel_watch (GIOChannel *channel,
1347 GIOCondition condition,
1348 gpointer client_data)
1349{
1350 return process_ice_messages (client_data);
1351}
1352
1353static void
1354ice_connection_watch (IceConn ice_conn,
1355 IcePointer client_data,
1356 Boolint opening,
1357 IcePointer *watch_data)
1358{
1359 guint watch_id;
1360
1361 if (opening)
1362 {
1363 GIOChannel *channel;
1364 int fd = IceConnectionNumber (ice_conn);
1365
1366 fcntl (fd, F_SETFD2, fcntl (fd, F_GETFD1, 0) | FD_CLOEXEC1);
1367 channel = g_io_channel_unix_new (fd);
1368 watch_id = g_io_add_watch (channel, G_IO_IN | G_IO_ERR,
1369 ice_iochannel_watch, ice_conn);
1370 g_io_channel_unref (channel);
1371
1372 *watch_data = GUINT_TO_POINTER (watch_id)((gpointer) (gulong) (watch_id));
1373 }
1374 else
1375 {
1376 watch_id = GPOINTER_TO_UINT (*watch_data)((guint) (gulong) (*watch_data));
1377 g_source_remove (watch_id);
1378 }
1379}
1380
1381static void
1382ice_error_handler (IceConn ice_conn,
1383 Boolint swap,
1384 int offending_minor_opcode,
1385 unsigned long offending_sequence,
1386 int error_class,
1387 int severity,
1388 IcePointer values)
1389{
1390 /* Do nothing */
1391}
1392
1393static void
1394ice_io_error_handler (IceConn ice_conn)
1395{
1396 /* Do nothing */
1397}
1398
1399static void
1400smc_error_handler (SmcConn smc_conn,
1401 Boolint swap,
1402 int offending_minor_opcode,
1403 unsigned long offending_sequence,
1404 int error_class,
1405 int severity,
1406 SmPointer values)
1407{
1408 /* Do nothing */
1409}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-ceaaa0.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-ceaaa0.html new file mode 100644 index 0000000..366b4ef --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-ceaaa0.html @@ -0,0 +1,1264 @@ + + + +glib-utils.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/glib-utils.c
Warning:line 221, column 3
Access of the heap area at index 4294967295, while it holds only 2 'char *' elements
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name glib-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I ../mate-submodules/libegg/ -I .. -I .. -D ENGRAMPA_RESOURCE_UI_PATH="/org/mate/Engrampa/ui" -D FR_PREFIX="/usr/local" -D FR_SYSCONFDIR="/usr/local/etc" -D FR_DATADIR="/usr/local/share" -D PRIVDATADIR="/usr/local/share/engrampa/" -D FR_LIBDIR="/usr/local/lib" -D PKG_DATA_DIR="/usr/local/share/engrampa" -D PIXMAPSDIR="/usr/local/share/pixmaps" -D GLADEDIR="" -D LOCALEDIR="/usr/local/share/locale" -D SHDIR="/usr/local/libexec/engrampa/" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/json-glib-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c glib-utils.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Engrampa
5 *
6 * Copyright (C) 2005 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include <config.h>
24#include <string.h>
25#include <stdio.h>
26#include <glib.h>
27#include <glib/gi18n.h>
28#include <glib/gprintf.h>
29#include <glib-object.h>
30#include "glib-utils.h"
31
32#define MAX_PATTERNS128 128
33
34/* gobject utils*/
35
36void
37_g_object_unref (gpointer object)
38{
39 if (object != NULL((void*)0))
40 g_object_unref (object);
41}
42
43/* string utils */
44
45gboolean
46strchrs (const char *str,
47 const char *chars)
48{
49 const char *c;
50 for (c = chars; *c != '\0'; c++)
51 if (strchr (str, *c) != NULL((void*)0))
52 return TRUE(!(0));
53 return FALSE(0);
54}
55
56char *
57str_substitute (const char *str,
58 const char *from_str,
59 const char *to_str)
60{
61 char **tokens;
62 int i;
63 GString *gstr;
64
65 if (str == NULL((void*)0))
66 return NULL((void*)0);
67
68 if (from_str == NULL((void*)0))
69 return g_strdup (str)g_strdup_inline (str);
70
71 if (strcmp (str, from_str) == 0)
72 return g_strdup (to_str)g_strdup_inline (to_str);
73
74 tokens = g_strsplit (str, from_str, -1);
75
76 gstr = g_string_new (NULL((void*)0));
77 for (i = 0; tokens[i] != NULL((void*)0); i++) {
78 gstr = g_string_append (gstr, tokens[i])(__builtin_constant_p (tokens[i]) ? __extension__ ({ const char
* const __val = (tokens[i]); g_string_append_len_inline (gstr
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (gstr
, tokens[i], (gssize) -1))
;
79 if ((to_str != NULL((void*)0)) && (tokens[i+1] != NULL((void*)0)))
80 gstr = g_string_append (gstr, to_str)(__builtin_constant_p (to_str) ? __extension__ ({ const char *
const __val = (to_str); g_string_append_len_inline (gstr, __val
, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val
))) : (gssize) -1); }) : g_string_append_len_inline (gstr, to_str
, (gssize) -1))
;
81 }
82
83 g_strfreev (tokens);
84
85 return g_string_free (gstr, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((gstr
), ((0))) : g_string_free_and_steal (gstr)) : (g_string_free)
((gstr), ((0))))
;
86}
87
88/* counts how many characters to escape in @str. */
89static int
90count_chars_to_escape (const char *str,
91 const char *meta_chars)
92{
93 int meta_chars_n = strlen (meta_chars);
94 const char *s;
95 int n = 0;
96
97 for (s = str; *s != 0; s++) {
98 int i;
99 for (i = 0; i < meta_chars_n; i++)
100 if (*s == meta_chars[i]) {
101 n++;
102 break;
103 }
104 }
105 return n;
106}
107
108static char*
109escape_str_common (const char *str,
110 const char *meta_chars,
111 const char prefix,
112 const char postfix)
113{
114 int meta_chars_n = strlen (meta_chars);
115 char *escaped;
116 int i, new_l, extra_chars = 0;
117 const char *s;
118 char *t;
119
120 if (str == NULL((void*)0))
121 return NULL((void*)0);
122
123 if (prefix)
124 extra_chars++;
125 if (postfix)
126 extra_chars++;
127
128 new_l = strlen (str) + (count_chars_to_escape (str, meta_chars) * extra_chars);
129 escaped = g_malloc (new_l + 1);
130
131 s = str;
132 t = escaped;
133 while (*s) {
134 gboolean is_bad = FALSE(0);
135 for (i = 0; (i < meta_chars_n) && !is_bad; i++)
136 is_bad = (*s == meta_chars[i]);
137 if (is_bad && prefix)
138 *t++ = prefix;
139 *t++ = *s++;
140 if (is_bad && postfix)
141 *t++ = postfix;
142 }
143 *t = 0;
144
145 return escaped;
146}
147
148/* escape with backslash the string @str. */
149char*
150escape_str (const char *str,
151 const char *meta_chars)
152{
153 return escape_str_common (str, meta_chars, '\\', 0);
154}
155
156static const char *
157g_utf8_strstr (const char *haystack, const char *needle)
158{
159 const char *s;
160 gsize i;
161 gsize haystack_len = g_utf8_strlen (haystack, -1);
162 gsize needle_len = g_utf8_strlen (needle, -1);
163 int needle_size = strlen (needle);
164
165 s = haystack;
166 for (i = 0; i <= haystack_len - needle_len; i++) {
167 if (strncmp (s, needle, needle_size) == 0)
168 return s;
169 s = g_utf8_next_char(s)(char *)((s) + g_utf8_skip[*(const guchar *)(s)]);
170 }
171
172 return NULL((void*)0);
173}
174
175static char**
176g_utf8_strsplit (const char *string,
177 const char *delimiter,
178 int max_tokens)
179{
180 GSList *string_list = NULL((void*)0), *slist;
181 char **str_array;
182 const char *s;
183 guint n = 0;
184 const char *remainder;
185
186 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
5
Taking true branch
6
Loop condition is false. Exiting loop
187 g_return_val_if_fail (delimiter != NULL, NULL)do { if ((delimiter != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "delimiter != NULL"
); return (((void*)0)); } } while (0)
;
7
Taking true branch
8
Loop condition is false. Exiting loop
188 g_return_val_if_fail (delimiter[0] != '\0', NULL)do { if ((delimiter[0] != '\0')) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "delimiter[0] != '\\0'"
); return (((void*)0)); } } while (0)
;
9
Taking true branch
10
Loop condition is false. Exiting loop
189
190 if (max_tokens
10.1
'max_tokens' is >= 1
< 1)
11
Taking false branch
191 max_tokens = G_MAXINT2147483647;
192
193 remainder = string;
194 s = g_utf8_strstr (remainder, delimiter);
195 if (s != NULL((void*)0)) {
12
Assuming 's' is equal to NULL
13
Taking false branch
196 gsize delimiter_size = strlen (delimiter);
197
198 while (--max_tokens && (s != NULL((void*)0))) {
199 gsize size = s - remainder;
200 char *new_string;
201
202 new_string = g_new (char, size + 1)((char *) g_malloc_n ((size + 1), sizeof (char)));
203 strncpy (new_string, remainder, size);
204 new_string[size] = 0;
205
206 string_list = g_slist_prepend (string_list, new_string);
207 n++;
208 remainder = s + delimiter_size;
209 s = g_utf8_strstr (remainder, delimiter);
210 }
211 }
212 if (*string) {
14
Assuming the condition is true
15
Taking true branch
213 n++;
214 string_list = g_slist_prepend (string_list, g_strdup (remainder)g_strdup_inline (remainder));
215 }
216
217 str_array = g_new (char*, n + 1)((char* *) g_malloc_n ((n + 1), sizeof (char*)));
218
219 str_array[n--] = NULL((void*)0);
220 for (slist = string_list; slist; slist = slist->next)
16
Loop condition is true. Entering loop body
17
Loop condition is true. Entering loop body
221 str_array[n--] = slist->data;
18
Access of the heap area at index 4294967295, while it holds only 2 'char *' elements
222
223 g_slist_free (string_list);
224
225 return str_array;
226}
227
228static char*
229g_utf8_strchug (char *string)
230{
231 char *scan;
232 gunichar c;
233
234 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
235
236 scan = string;
237 c = g_utf8_get_char (scan);
238 while (g_unichar_isspace (c)) {
239 scan = g_utf8_next_char (scan)(char *)((scan) + g_utf8_skip[*(const guchar *)(scan)]);
240 c = g_utf8_get_char (scan);
241 }
242
243 memmove (string, scan, strlen (scan) + 1);
244
245 return string;
246}
247
248static char*
249g_utf8_strchomp (char *string)
250{
251 char *scan;
252 gsize len;
253
254 g_return_val_if_fail (string != NULL, NULL)do { if ((string != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "string != NULL")
; return (((void*)0)); } } while (0)
;
255
256 len = g_utf8_strlen (string, -1);
257
258 if (len == 0)
259 return string;
260
261 scan = g_utf8_offset_to_pointer (string, len - 1);
262
263 while (len--) {
264 gunichar c = g_utf8_get_char (scan);
265 if (g_unichar_isspace (c))
266 *scan = '\0';
267 else
268 break;
269 scan = g_utf8_find_prev_char (string, scan);
270 }
271
272 return string;
273}
274
275#define g_utf8_strstrip(string)g_utf8_strchomp (g_utf8_strchug (string)) g_utf8_strchomp (g_utf8_strchug (string))
276
277gboolean
278match_regexps (GRegex **regexps,
279 const char *string,
280 GRegexMatchFlags match_options)
281{
282 gboolean matched;
283 int i;
284
285 if ((regexps == NULL((void*)0)) || (regexps[0] == NULL((void*)0)))
286 return TRUE(!(0));
287
288 if (string == NULL((void*)0))
289 return FALSE(0);
290
291 matched = FALSE(0);
292 for (i = 0; regexps[i] != NULL((void*)0); i++)
293 if (g_regex_match (regexps[i], string, match_options, NULL((void*)0))) {
294 matched = TRUE(!(0));
295 break;
296 }
297
298 return matched;
299}
300
301void
302free_regexps (GRegex **regexps)
303{
304 int i;
305
306 if (regexps == NULL((void*)0))
307 return;
308
309 for (i = 0; regexps[i] != NULL((void*)0); i++)
310 g_regex_unref (regexps[i]);
311 g_free (regexps);
312}
313
314char **
315search_util_get_patterns (const char *pattern_string)
316{
317 char **patterns;
318 int i;
319
320 if (pattern_string == NULL((void*)0))
2
Assuming 'pattern_string' is not equal to NULL
3
Taking false branch
321 return NULL((void*)0);
322
323 patterns = g_utf8_strsplit (pattern_string, ";", MAX_PATTERNS128);
4
Calling 'g_utf8_strsplit'
324 for (i = 0; patterns[i] != NULL((void*)0); i++) {
325 char *p1, *p2;
326
327 p1 = g_utf8_strstrip (patterns[i])g_utf8_strchomp (g_utf8_strchug (patterns[i]));
328 p2 = str_substitute (p1, ".", "\\.");
329 patterns[i] = str_substitute (p2, "*", ".*");
330
331 g_free (p2);
332 g_free (p1);
333 }
334
335 return patterns;
336}
337
338GRegex **
339search_util_get_regexps (const char *pattern_string,
340 GRegexCompileFlags compile_options)
341{
342 char **patterns;
343 GRegex **regexps;
344 int i;
345
346 patterns = search_util_get_patterns (pattern_string);
1
Calling 'search_util_get_patterns'
347 if (patterns == NULL((void*)0))
348 return NULL((void*)0);
349
350 regexps = g_new0 (GRegex*, g_strv_length (patterns) + 1)((GRegex* *) g_malloc0_n ((g_strv_length (patterns) + 1), sizeof
(GRegex*)))
;
351 for (i = 0; patterns[i] != NULL((void*)0); i++)
352 regexps[i] = g_regex_new (patterns[i],
353 G_REGEX_OPTIMIZE | compile_options,
354 G_REGEX_MATCH_NOTEMPTY,
355 NULL((void*)0));
356 g_strfreev (patterns);
357
358 return regexps;
359}
360
361const char *
362eat_spaces (const char *line)
363{
364 if (line == NULL((void*)0))
365 return NULL((void*)0);
366 while (*line == ' ')
367 line++;
368 return line;
369}
370
371char **
372split_line (const char *line,
373 int n_fields)
374{
375 char **fields;
376 const char *scan, *field_end;
377 int i;
378
379 fields = g_new0 (char *, n_fields + 1)((char * *) g_malloc0_n ((n_fields + 1), sizeof (char *)));
380 fields[n_fields] = NULL((void*)0);
381
382 scan = eat_spaces (line);
383 for (i = 0; i < n_fields; i++) {
384 if (scan == NULL((void*)0)) {
385 fields[i] = NULL((void*)0);
386 continue;
387 }
388 field_end = strchr (scan, ' ');
389 if (field_end != NULL((void*)0)) {
390 fields[i] = g_strndup (scan, field_end - scan);
391 scan = eat_spaces (field_end);
392 }
393 else if (scan != NULL((void*)0) && i == n_fields - 1)
394 {
395 fields[i] = g_strdup (scan)g_strdup_inline (scan);
396 }
397 }
398
399 return fields;
400}
401
402const char *
403get_last_field (const char *line,
404 int last_field)
405{
406 const char *field;
407 int i;
408
409 if (line == NULL((void*)0))
410 return NULL((void*)0);
411
412 last_field--;
413 field = eat_spaces (line);
414 for (i = 0; i < last_field; i++) {
415 if (field == NULL((void*)0))
416 return NULL((void*)0);
417 field = strchr (field, ' ');
418 field = eat_spaces (field);
419 }
420
421 return field;
422}
423
424void
425debug (const char *file,
426 int line,
427 const char *function,
428 const char *format, ...)
429{
430#ifdef MATE_ENABLE_DEBUG
431 va_list args;
432 char *str;
433
434 g_return_if_fail (format != NULL)do { if ((format != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "format != NULL")
; return; } } while (0)
;
435
436 va_start (args, format)__builtin_va_start(args, format);
437 str = g_strdup_vprintf (format, args);
438 va_end (args)__builtin_va_end(args);
439
440 g_fprintf (stderrstderr, "[FR] %s:%d (%s):\n\t%s\n", file, line, function, str);
441
442 g_free (str);
443#else /* ! DEBUG */
444#endif
445}
446
447GHashTable *static_strings = NULL((void*)0);
448
449const char *
450get_static_string (const char *s)
451{
452 const char *result;
453
454 if (s == NULL((void*)0))
455 return NULL((void*)0);
456
457 if (static_strings == NULL((void*)0))
458 static_strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
459
460 if (! g_hash_table_lookup_extended (static_strings, s, (gpointer*) &result, NULL((void*)0))) {
461 result = g_strdup (s)g_strdup_inline (s);
462 g_hash_table_insert (static_strings,
463 (gpointer) result,
464 GINT_TO_POINTER (1)((gpointer) (glong) (1)));
465 }
466
467 return result;
468}
469
470char*
471g_uri_display_basename (const char *uri)
472{
473 char *e_name, *name;
474
475 e_name = g_filename_display_basename (uri);
476 name = g_uri_unescape_string (e_name, "");
477 g_free (e_name);
478
479 return name;
480}
481
482const gchar *
483_g_path_get_file_name (const gchar *file_name)
484{
485 register char *base;
486 register gssize last_char;
487
488 if (file_name == NULL((void*)0))
489 return NULL((void*)0);
490
491 if (file_name[0] == '\0')
492 return "";
493
494 last_char = strlen (file_name) - 1;
495
496 if (file_name [last_char] == G_DIR_SEPARATOR'/')
497 return "";
498
499 base = g_utf8_strrchr (file_name, -1, G_DIR_SEPARATOR'/');
500 if (! base)
501 return file_name;
502
503 return base + 1;
504}
505
506const char *
507_g_path_get_base_name (const char *path,
508 const char *base_dir,
509 gboolean junk_paths)
510{
511 size_t base_dir_len;
512 const char *base_path;
513
514 if (junk_paths)
515 return _g_path_get_file_name (path);
516
517 if (base_dir == NULL((void*)0))
518 return (path[0] == '/') ? path + 1 : path;
519
520 base_dir_len = strlen (base_dir);
521 if (strlen (path) < base_dir_len)
522 return NULL((void*)0);
523
524 base_path = path + base_dir_len;
525 if (path[0] != '/')
526 base_path -= 1;
527
528 return base_path;
529}
530
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-cf3974.html b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-cf3974.html new file mode 100644 index 0000000..ca53297 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/report-cf3974.html @@ -0,0 +1,2089 @@ + + + +eggsmclient-xsmp.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-submodules/libegg/eggsmclient-xsmp.c
Warning:line 1232, column 18
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eggsmclient-xsmp.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-submodules/libegg -fcoverage-compilation-dir=/rootdir/mate-submodules/libegg -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/gio-unix-2.0 -I /usr/include/uuid -D EGG_SM_CLIENT_BACKEND_XSMP -D G_LOG_DOMAIN="EggSMClient" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/webp -D WITH_GZFILEOP -I /usr/include/libpng16 -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/gio-unix-2.0 -I /usr/include/uuid -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-08-16-185447-5355-1 -x c eggsmclient-xsmp.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 Novell, Inc.
3 *
4 * Inspired by various other pieces of code including GsmClient (C)
5 * 2001 Havoc Pennington, MateClient (C) 1998 Carsten Schaar, and twm
6 * session code (C) 1998 The Open Group.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include "config.h"
25
26#include "eggsmclient.h"
27#include "eggsmclient-private.h"
28
29#include "eggdesktopfile.h"
30
31#include <errno(*__errno_location ()).h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <X11/SM/SMlib.h>
37
38#include <gtk/gtk.h>
39#include <gdk/gdk.h>
40
41#if defined(GDK_WINDOWING_X11) || defined(HAVE_X11)
42#include <gdk/gdkx.h>
43#endif
44
45#define EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()) (egg_sm_client_xsmp_get_type ())
46#define EGG_SM_CLIENT_XSMP(obj)((((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ()))))))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP)(((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ())))))
)
47#define EGG_SM_CLIENT_XSMP_CLASS(klass)((((EggSMClientXSMPClass*) (void *) g_type_check_class_cast (
(GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ()))))
))
(G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (void *) g_type_check_class_cast ((
GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ())))))
)
48#define EGG_IS_SM_CLIENT_XSMP(obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))
)
49#define EGG_IS_SM_CLIENT_XSMP_CLASS(klass)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; }))))
(G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; })))
)
50#define EGG_SM_CLIENT_XSMP_GET_CLASS(obj)((((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
))))
(G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
)))
)
51
52typedef struct _EggSMClientXSMP EggSMClientXSMP;
53typedef struct _EggSMClientXSMPClass EggSMClientXSMPClass;
54
55/* These mostly correspond to the similarly-named states in section
56 * 9.1 of the XSMP spec. Some of the states there aren't represented
57 * here, because we don't need them. SHUTDOWN_CANCELLED is slightly
58 * different from the spec; we use it when the client is IDLE after a
59 * ShutdownCancelled message, but the application is still interacting
60 * and doesn't know the shutdown has been cancelled yet.
61 */
62typedef enum
63{
64 XSMP_STATE_IDLE,
65 XSMP_STATE_SAVE_YOURSELF,
66 XSMP_STATE_INTERACT_REQUEST,
67 XSMP_STATE_INTERACT,
68 XSMP_STATE_SAVE_YOURSELF_DONE,
69 XSMP_STATE_SHUTDOWN_CANCELLED,
70 XSMP_STATE_CONNECTION_CLOSED
71} EggSMClientXSMPState;
72
73static const char *state_names[] =
74{
75 "idle",
76 "save-yourself",
77 "interact-request",
78 "interact",
79 "save-yourself-done",
80 "shutdown-cancelled",
81 "connection-closed"
82};
83
84#define EGG_SM_CLIENT_XSMP_STATE(xsmp)(state_names[(xsmp)->state]) (state_names[(xsmp)->state])
85
86struct _EggSMClientXSMP
87{
88 EggSMClient parent;
89
90 SmcConn connection;
91 char *client_id;
92
93 EggSMClientXSMPState state;
94 char **restart_command;
95 gboolean set_restart_command;
96 int restart_style;
97 char **discard_command;
98 gboolean set_discard_command;
99
100 guint idle;
101
102 /* Current SaveYourself state */
103 guint expecting_initial_save_yourself : 1;
104 guint need_save_state : 1;
105 guint need_quit_requested : 1;
106 guint interact_errors : 1;
107 guint shutting_down : 1;
108
109 /* Todo list */
110 guint waiting_to_set_initial_properties : 1;
111 guint waiting_to_emit_quit : 1;
112 guint waiting_to_emit_quit_cancelled : 1;
113 guint waiting_to_save_myself : 1;
114
115};
116
117struct _EggSMClientXSMPClass
118{
119 EggSMClientClass parent_class;
120
121};
122
123static void sm_client_xsmp_startup (EggSMClient *client,
124 const char *client_id);
125static void sm_client_xsmp_set_restart_command (EggSMClient *client,
126 int argc,
127 const char **argv);
128static void sm_client_xsmp_set_discard_command (EggSMClient *client,
129 int argc,
130 const char **argv);
131static void sm_client_xsmp_will_quit (EggSMClient *client,
132 gboolean will_quit);
133static gboolean sm_client_xsmp_end_session (EggSMClient *client,
134 EggSMClientEndStyle style,
135 gboolean request_confirmation);
136
137static void xsmp_save_yourself (SmcConn smc_conn,
138 SmPointer client_data,
139 int save_style,
140 Boolint shutdown,
141 int interact_style,
142 Boolint fast);
143static void xsmp_die (SmcConn smc_conn,
144 SmPointer client_data);
145static void xsmp_save_complete (SmcConn smc_conn,
146 SmPointer client_data);
147static void xsmp_shutdown_cancelled (SmcConn smc_conn,
148 SmPointer client_data);
149static void xsmp_interact (SmcConn smc_conn,
150 SmPointer client_data);
151
152static SmProp *array_prop (const char *name,
153 ...);
154static SmProp *ptrarray_prop (const char *name,
155 GPtrArray *values);
156static SmProp *string_prop (const char *name,
157 const char *value);
158static SmProp *card8_prop (const char *name,
159 unsigned char value);
160
161static void set_properties (EggSMClientXSMP *xsmp, ...);
162static void delete_properties (EggSMClientXSMP *xsmp, ...);
163
164static GPtrArray *generate_command (char **restart_command,
165 const char *client_id,
166 const char *state_file);
167
168static void save_state (EggSMClientXSMP *xsmp);
169static void do_save_yourself (EggSMClientXSMP *xsmp);
170static void update_pending_events (EggSMClientXSMP *xsmp);
171
172static void ice_init (void);
173static gboolean process_ice_messages (IceConn ice_conn);
174static void smc_error_handler (SmcConn smc_conn,
175 Boolint swap,
176 int offending_minor_opcode,
177 unsigned long offending_sequence,
178 int error_class,
179 int severity,
180 SmPointer values);
181
182G_DEFINE_TYPE (EggSMClientXSMP, egg_sm_client_xsmp, EGG_TYPE_SM_CLIENT)static void egg_sm_client_xsmp_init (EggSMClientXSMP *self); static
void egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass
); static GType egg_sm_client_xsmp_get_type_once (void); static
gpointer egg_sm_client_xsmp_parent_class = ((void*)0); static
gint EggSMClientXSMP_private_offset; static void egg_sm_client_xsmp_class_intern_init
(gpointer klass) { egg_sm_client_xsmp_parent_class = g_type_class_peek_parent
(klass); if (EggSMClientXSMP_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggSMClientXSMP_private_offset); egg_sm_client_xsmp_class_init
((EggSMClientXSMPClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer egg_sm_client_xsmp_get_instance_private
(EggSMClientXSMP *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggSMClientXSMP_private_offset)))); } GType egg_sm_client_xsmp_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= egg_sm_client_xsmp_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType egg_sm_client_xsmp_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((egg_sm_client_get_type ()), g_intern_static_string ("EggSMClientXSMP"
), sizeof (EggSMClientXSMPClass), (GClassInitFunc)(void (*)(void
)) egg_sm_client_xsmp_class_intern_init, sizeof (EggSMClientXSMP
), (GInstanceInitFunc)(void (*)(void)) egg_sm_client_xsmp_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
183
184static void
185egg_sm_client_xsmp_init (EggSMClientXSMP *xsmp)
186{
187 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
188 xsmp->connection = NULL((void*)0);
189 xsmp->restart_style = SmRestartIfRunning0;
190}
191
192static void
193egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
194{
195 EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
196
197 sm_client_class->startup = sm_client_xsmp_startup;
198 sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
199 sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
200 sm_client_class->will_quit = sm_client_xsmp_will_quit;
201 sm_client_class->end_session = sm_client_xsmp_end_session;
202}
203
204EggSMClient *
205egg_sm_client_xsmp_new (void)
206{
207 if (!g_getenv ("SESSION_MANAGER"))
208 return NULL((void*)0);
209
210 return g_object_new (EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()), NULL((void*)0));
211}
212
213static gboolean
214sm_client_xsmp_set_initial_properties (gpointer user_data)
215{
216 EggSMClientXSMP *xsmp = user_data;
217 EggDesktopFile *desktop_file;
218 GPtrArray *clone, *restart;
219 char pid_str[64];
220
221 if (xsmp->idle)
222 {
223 g_source_remove (xsmp->idle);
224 xsmp->idle = 0;
225 }
226 xsmp->waiting_to_set_initial_properties = FALSE(0);
227
228 if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART)
229 xsmp->restart_style = SmRestartNever3;
230
231 /* Parse info out of desktop file */
232 desktop_file = egg_get_desktop_file ();
233 if (desktop_file)
234 {
235 GError *err = NULL((void*)0);
236 char **argv;
237 int argc;
238
239 if (xsmp->restart_style == SmRestartIfRunning0)
240 {
241 if (egg_desktop_file_get_boolean (desktop_file,
242 "X-MATE-AutoRestart", NULL((void*)0)))
243 xsmp->restart_style = SmRestartImmediately2;
244 }
245
246 if (!xsmp->set_restart_command)
247 {
248 char *cmdline;
249
250 cmdline = egg_desktop_file_parse_exec (desktop_file, NULL((void*)0), &err);
251 if (cmdline && g_shell_parse_argv (cmdline, &argc, &argv, &err))
252 {
253 egg_sm_client_set_restart_command (EGG_SM_CLIENT (xsmp),
254 argc, (const char **)argv);
255 g_strfreev (argv);
256 }
257 else
258 {
259 g_warning ("Could not parse Exec line in desktop file: %s",
260 err->message);
261 g_error_free (err);
262 }
263 g_free (cmdline);
264 }
265 }
266
267 if (!xsmp->set_restart_command)
268 xsmp->restart_command = g_strsplit (g_get_prgname (), " ", -1);
269
270 clone = generate_command (xsmp->restart_command, NULL((void*)0), NULL((void*)0));
271 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
272
273 g_debug ("Setting initial properties");
274
275 /* Program, CloneCommand, RestartCommand, and UserID are required.
276 * ProcessID isn't required, but the SM may be able to do something
277 * useful with it.
278 */
279 g_snprintf (pid_str, sizeof (pid_str), "%lu", (gulong) getpid ());
280 set_properties (xsmp,
281 string_prop (SmProgram"Program", g_get_prgname ()),
282 ptrarray_prop (SmCloneCommand"CloneCommand", clone),
283 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
284 string_prop (SmUserID"UserID", g_get_user_name ()),
285 string_prop (SmProcessID"ProcessID", pid_str),
286 card8_prop (SmRestartStyleHint"RestartStyleHint", xsmp->restart_style),
287 NULL((void*)0));
288 g_ptr_array_free (clone, TRUE(!(0)));
289 g_ptr_array_free (restart, TRUE(!(0)));
290
291 if (desktop_file)
292 {
293 set_properties (xsmp,
294 string_prop ("_GSM_DesktopFile", egg_desktop_file_get_source (desktop_file)),
295 NULL((void*)0));
296 }
297
298 update_pending_events (xsmp);
299 return FALSE(0);
300}
301
302/* This gets called from two different places: xsmp_die() (when the
303 * server asks us to disconnect) and process_ice_messages() (when the
304 * server disconnects unexpectedly).
305 */
306static void
307sm_client_xsmp_disconnect (EggSMClientXSMP *xsmp)
308{
309 SmcConn connection;
310
311 if (!xsmp->connection)
312 return;
313
314 g_debug ("Disconnecting");
315
316 connection = xsmp->connection;
317 xsmp->connection = NULL((void*)0);
318 SmcCloseConnection (connection, 0, NULL((void*)0));
319 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
320
321 xsmp->waiting_to_save_myself = FALSE(0);
322 update_pending_events (xsmp);
323}
324
325static void
326sm_client_xsmp_startup (EggSMClient *client,
327 const char *client_id)
328{
329 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
330 SmcCallbacks callbacks;
331 char *ret_client_id;
332 char error_string_ret[256];
333
334 xsmp->client_id = g_strdup (client_id)g_strdup_inline (client_id);
335
336 ice_init ();
337 SmcSetErrorHandler (smc_error_handler);
338
339 callbacks.save_yourself.callback = xsmp_save_yourself;
340 callbacks.die.callback = xsmp_die;
341 callbacks.save_complete.callback = xsmp_save_complete;
342 callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
343
344 callbacks.save_yourself.client_data = xsmp;
345 callbacks.die.client_data = xsmp;
346 callbacks.save_complete.client_data = xsmp;
347 callbacks.shutdown_cancelled.client_data = xsmp;
348
349 client_id = NULL((void*)0);
350 error_string_ret[0] = '\0';
351 xsmp->connection =
352 SmcOpenConnection (NULL((void*)0), xsmp, SmProtoMajor1, SmProtoMinor0,
353 SmcSaveYourselfProcMask(1L << 0) | SmcDieProcMask(1L << 1) |
354 SmcSaveCompleteProcMask(1L << 2) |
355 SmcShutdownCancelledProcMask(1L << 3),
356 &callbacks,
357 xsmp->client_id, &ret_client_id,
358 sizeof (error_string_ret), error_string_ret);
359
360 if (!xsmp->connection)
361 {
362 g_warning ("Failed to connect to the session manager: %s\n",
363 error_string_ret[0] ?
364 error_string_ret : "no error message given");
365 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
366 return;
367 }
368
369 /* We expect a pointless initial SaveYourself if either (a) we
370 * didn't have an initial client ID, or (b) we DID have an initial
371 * client ID, but the server rejected it and gave us a new one.
372 */
373 if (!xsmp->client_id ||
374 (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0))
375 xsmp->expecting_initial_save_yourself = TRUE(!(0));
376
377 if (ret_client_id)
378 {
379 g_free (xsmp->client_id);
380 xsmp->client_id = g_strdup (ret_client_id)g_strdup_inline (ret_client_id);
381 free (ret_client_id);
382
383#if defined(GDK_WINDOWING_X11) || defined(HAVE_X11)
384 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
385 gdk_x11_set_sm_client_id (xsmp->client_id);
386#endif
387
388 g_debug ("Got client ID \"%s\"", xsmp->client_id);
389 }
390
391 xsmp->state = XSMP_STATE_IDLE;
392
393 /* Do not set the initial properties until we reach the main loop,
394 * so that the application has a chance to call
395 * egg_set_desktop_file(). (This may also help the session manager
396 * have a better idea of when the application is fully up and
397 * running.)
398 */
399 xsmp->waiting_to_set_initial_properties = TRUE(!(0));
400 xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client);
401}
402
403static void
404sm_client_xsmp_set_restart_command (EggSMClient *client,
405 int argc,
406 const char **argv)
407{
408 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
409 int i;
410
411 g_strfreev (xsmp->restart_command);
412
413 xsmp->restart_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
414 for (i = 0; i < argc; i++)
415 xsmp->restart_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
416 xsmp->restart_command[i] = NULL((void*)0);
417
418 xsmp->set_restart_command = TRUE(!(0));
419}
420
421static void
422sm_client_xsmp_set_discard_command (EggSMClient *client,
423 int argc,
424 const char **argv)
425{
426 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
427 int i;
428
429 g_strfreev (xsmp->discard_command);
430
431 xsmp->discard_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
432 for (i = 0; i < argc; i++)
433 xsmp->discard_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
434 xsmp->discard_command[i] = NULL((void*)0);
435
436 xsmp->set_discard_command = TRUE(!(0));
437}
438
439static void
440sm_client_xsmp_will_quit (EggSMClient *client,
441 gboolean will_quit)
442{
443 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
444
445 if (xsmp->state == XSMP_STATE_CONNECTION_CLOSED)
446 {
447 /* The session manager has already exited! Schedule a quit
448 * signal.
449 */
450 xsmp->waiting_to_emit_quit = TRUE(!(0));
451 update_pending_events (xsmp);
452 return;
453 }
454 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
455 {
456 /* We received a ShutdownCancelled message while the application
457 * was interacting; Schedule a quit_cancelled signal.
458 */
459 xsmp->waiting_to_emit_quit_cancelled = TRUE(!(0));
460 update_pending_events (xsmp);
461 return;
462 }
463
464 g_return_if_fail (xsmp->state == XSMP_STATE_INTERACT)do { if ((xsmp->state == XSMP_STATE_INTERACT)) { } else { g_return_if_fail_warning
("EggSMClient", ((const char*) (__func__)), "xsmp->state == XSMP_STATE_INTERACT"
); return; } } while (0)
;
465
466 g_debug ("Sending InteractDone(%s)", will_quit ? "False" : "True");
467 SmcInteractDone (xsmp->connection, !will_quit);
468
469 if (will_quit && xsmp->need_save_state)
470 save_state (xsmp);
471
472 g_debug ("Sending SaveYourselfDone(%s)", will_quit ? "True" : "False");
473 SmcSaveYourselfDone (xsmp->connection, will_quit);
474 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
475}
476
477static gboolean
478sm_client_xsmp_end_session (EggSMClient *client,
479 EggSMClientEndStyle style,
480 gboolean request_confirmation)
481{
482 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
483 int save_type;
484
485 /* To end the session via XSMP, we have to send a
486 * SaveYourselfRequest. We aren't allowed to do that if anything
487 * else is going on, but we don't want to expose this fact to the
488 * application. So we do our best to patch things up here...
489 *
490 * In the worst case, this method might block for some length of
491 * time in process_ice_messages, but the only time that code path is
492 * honestly likely to get hit is if the application tries to end the
493 * session as the very first thing it does, in which case it
494 * probably won't actually block anyway. It's not worth gunking up
495 * the API to try to deal nicely with the other 0.01% of cases where
496 * this happens.
497 */
498
499 while (xsmp->state != XSMP_STATE_IDLE ||
500 xsmp->expecting_initial_save_yourself)
501 {
502 /* If we're already shutting down, we don't need to do anything. */
503 if (xsmp->shutting_down)
504 return TRUE(!(0));
505
506 switch (xsmp->state)
507 {
508 case XSMP_STATE_CONNECTION_CLOSED:
509 return FALSE(0);
510
511 case XSMP_STATE_SAVE_YOURSELF:
512 /* Trying to log out from the save_state callback? Whatever.
513 * Abort the save_state.
514 */
515 SmcSaveYourselfDone (xsmp->connection, FALSE(0));
516 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
517 break;
518
519 case XSMP_STATE_INTERACT_REQUEST:
520 case XSMP_STATE_INTERACT:
521 case XSMP_STATE_SHUTDOWN_CANCELLED:
522 /* Already in a shutdown-related state, just ignore
523 * the new shutdown request...
524 */
525 return TRUE(!(0));
526
527 case XSMP_STATE_IDLE:
528 if (xsmp->waiting_to_set_initial_properties)
529 sm_client_xsmp_set_initial_properties (xsmp);
530
531 if (!xsmp->expecting_initial_save_yourself)
532 break;
533 /* else fall through */
534
535 case XSMP_STATE_SAVE_YOURSELF_DONE:
536 /* We need to wait for some response from the server.*/
537 process_ice_messages (SmcGetIceConnection (xsmp->connection));
538 break;
539
540 default:
541 /* Hm... shouldn't happen */
542 return FALSE(0);
543 }
544 }
545
546 /* xfce4-session will do the wrong thing if we pass SmSaveGlobal and
547 * the user chooses to save the session. But mate-session will do
548 * the wrong thing if we pass SmSaveBoth and the user chooses NOT to
549 * save the session... Sigh.
550 */
551 if (!strcmp (SmcVendor (xsmp->connection), "xfce4-session"))
552 save_type = SmSaveBoth2;
553 else
554 save_type = SmSaveGlobal0;
555
556 g_debug ("Sending SaveYourselfRequest(SmSaveGlobal, Shutdown, SmInteractStyleAny, %sFast)", request_confirmation ? "!" : "");
557 SmcRequestSaveYourself (xsmp->connection,
558 save_type,
559 True1, /* shutdown */
560 SmInteractStyleAny2,
561 !request_confirmation, /* fast */
562 True1 /* global */);
563 return TRUE(!(0));
564}
565
566static gboolean
567idle_do_pending_events (gpointer data)
568{
569 EggSMClientXSMP *xsmp = data;
570 EggSMClient *client = data;
571
572 xsmp->idle = 0;
573
574 if (xsmp->waiting_to_emit_quit)
575 {
576 xsmp->waiting_to_emit_quit = FALSE(0);
577 egg_sm_client_quit (client);
578 goto out;
579 }
580
581 if (xsmp->waiting_to_emit_quit_cancelled)
582 {
583 xsmp->waiting_to_emit_quit_cancelled = FALSE(0);
584 egg_sm_client_quit_cancelled (client);
585 xsmp->state = XSMP_STATE_IDLE;
586 }
587
588 if (xsmp->waiting_to_save_myself)
589 {
590 xsmp->waiting_to_save_myself = FALSE(0);
591 do_save_yourself (xsmp);
592 }
593
594out:
595 return FALSE(0);
596}
597
598static void
599update_pending_events (EggSMClientXSMP *xsmp)
600{
601 gboolean want_idle =
602 xsmp->waiting_to_emit_quit ||
603 xsmp->waiting_to_emit_quit_cancelled ||
604 xsmp->waiting_to_save_myself;
605
606 if (want_idle)
607 {
608 if (xsmp->idle == 0)
609 xsmp->idle = g_idle_add (idle_do_pending_events, xsmp);
610 }
611 else
612 {
613 if (xsmp->idle != 0)
614 g_source_remove (xsmp->idle);
615 xsmp->idle = 0;
616 }
617}
618
619static void
620fix_broken_state (EggSMClientXSMP *xsmp, const char *message,
621 gboolean send_interact_done,
622 gboolean send_save_yourself_done)
623{
624 g_warning ("Received XSMP %s message in state %s: client or server error",
625 message, EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
626
627 /* Forget any pending SaveYourself plans we had */
628 xsmp->waiting_to_save_myself = FALSE(0);
629 update_pending_events (xsmp);
630
631 if (send_interact_done)
632 SmcInteractDone (xsmp->connection, False0);
633 if (send_save_yourself_done)
634 SmcSaveYourselfDone (xsmp->connection, True1);
635
636 xsmp->state = send_save_yourself_done ? XSMP_STATE_SAVE_YOURSELF_DONE : XSMP_STATE_IDLE;
637}
638
639/* SM callbacks */
640
641static void
642xsmp_save_yourself (SmcConn smc_conn,
643 SmPointer client_data,
644 int save_type,
645 Boolint shutdown,
646 int interact_style,
647 Boolint fast)
648{
649 EggSMClientXSMP *xsmp = client_data;
650 gboolean wants_quit_requested;
651
652 g_debug ("Received SaveYourself(%s, %s, %s, %s) in state %s",
653 save_type == SmSaveLocal1 ? "SmSaveLocal" :
654 save_type == SmSaveGlobal0 ? "SmSaveGlobal" : "SmSaveBoth",
655 shutdown ? "Shutdown" : "!Shutdown",
656 interact_style == SmInteractStyleAny2 ? "SmInteractStyleAny" :
657 interact_style == SmInteractStyleErrors1 ? "SmInteractStyleErrors" :
658 "SmInteractStyleNone", fast ? "Fast" : "!Fast",
659 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
660
661 if (xsmp->state != XSMP_STATE_IDLE &&
662 xsmp->state != XSMP_STATE_SHUTDOWN_CANCELLED)
663 {
664 fix_broken_state (xsmp, "SaveYourself", FALSE(0), TRUE(!(0)));
665 return;
666 }
667
668 if (xsmp->waiting_to_set_initial_properties)
669 sm_client_xsmp_set_initial_properties (xsmp);
670
671 /* If this is the initial SaveYourself, ignore it; we've already set
672 * properties and there's no reason to actually save state too.
673 */
674 if (xsmp->expecting_initial_save_yourself)
675 {
676 xsmp->expecting_initial_save_yourself = FALSE(0);
677
678 if (save_type == SmSaveLocal1 &&
679 interact_style == SmInteractStyleNone0 &&
680 !shutdown && !fast)
681 {
682 g_debug ("Sending SaveYourselfDone(True) for initial SaveYourself");
683 SmcSaveYourselfDone (xsmp->connection, True1);
684 /* As explained in the comment at the end of
685 * do_save_yourself(), SAVE_YOURSELF_DONE is the correct
686 * state here, not IDLE.
687 */
688 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
689 return;
690 }
691 else
692 g_warning ("First SaveYourself was not the expected one!");
693 }
694
695 /* Even ignoring the "fast" flag completely, there are still 18
696 * different combinations of save_type, shutdown and interact_style.
697 * We interpret them as follows:
698 *
699 * Type Shutdown Interact Interpretation
700 * G F A/E/N do nothing (1)
701 * G T N do nothing (1)*
702 * G T A/E quit_requested (2)
703 * L/B F A/E/N save_state (3)
704 * L/B T N save_state (3)*
705 * L/B T A/E quit_requested, then save_state (4)
706 *
707 * 1. Do nothing, because the SM asked us to do something
708 * uninteresting (save open files, but then don't quit
709 * afterward) or rude (save open files without asking the user
710 * for confirmation).
711 *
712 * 2. Request interaction and then emit ::quit_requested. This
713 * perhaps isn't quite correct for the SmInteractStyleErrors
714 * case, but we don't care.
715 *
716 * 3. Emit ::save_state. The SmSaveBoth SaveYourselfs in these
717 * rows essentially get demoted to SmSaveLocal, because their
718 * Global halves correspond to "do nothing".
719 *
720 * 4. Request interaction, emit ::quit_requested, and then emit
721 * ::save_state after interacting. This is the SmSaveBoth
722 * equivalent of #2, but we also promote SmSaveLocal shutdown
723 * SaveYourselfs to SmSaveBoth here, because we want to give
724 * the user a chance to save open files before quitting.
725 *
726 * (* It would be nice if we could do something useful when the
727 * session manager sends a SaveYourself with shutdown True and
728 * SmInteractStyleNone. But we can't, so we just pretend it didn't
729 * even tell us it was shutting down. The docs for ::quit mention
730 * that it might not always be preceded by ::quit_requested.)
731 */
732
733 /* As an optimization, we don't actually request interaction and
734 * emit ::quit_requested if the application isn't listening to the
735 * signal.
736 */
737 wants_quit_requested = g_signal_has_handler_pending (xsmp, g_signal_lookup ("quit_requested", EGG_TYPE_SM_CLIENT(egg_sm_client_get_type ())), 0, FALSE(0));
738
739 xsmp->need_save_state = (save_type != SmSaveGlobal0);
740 xsmp->need_quit_requested = (shutdown && wants_quit_requested &&
741 interact_style != SmInteractStyleNone0);
742 xsmp->interact_errors = (interact_style == SmInteractStyleErrors1);
743
744 xsmp->shutting_down = shutdown;
745
746 do_save_yourself (xsmp);
747}
748
749static void
750do_save_yourself (EggSMClientXSMP *xsmp)
751{
752 if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
753 {
754 /* The SM cancelled a previous SaveYourself, but we haven't yet
755 * had a chance to tell the application, so we can't start
756 * processing this SaveYourself yet.
757 */
758 xsmp->waiting_to_save_myself = TRUE(!(0));
759 update_pending_events (xsmp);
760 return;
761 }
762
763 if (xsmp->need_quit_requested)
764 {
765 xsmp->state = XSMP_STATE_INTERACT_REQUEST;
766
767 g_debug ("Sending InteractRequest(%s)",
768 xsmp->interact_errors ? "Error" : "Normal");
769 SmcInteractRequest (xsmp->connection,
770 xsmp->interact_errors ? SmDialogError0 : SmDialogNormal1,
771 xsmp_interact,
772 xsmp);
773 return;
774 }
775
776 if (xsmp->need_save_state)
777 {
778 save_state (xsmp);
779
780 /* Though unlikely, the client could have been disconnected
781 * while the application was saving its state.
782 */
783 if (!xsmp->connection)
784 return;
785 }
786
787 g_debug ("Sending SaveYourselfDone(True)");
788 SmcSaveYourselfDone (xsmp->connection, True1);
789
790 /* The client state diagram in the XSMP spec says that after a
791 * non-shutdown SaveYourself, we go directly back to "idle". But
792 * everything else in both the XSMP spec and the libSM docs
793 * disagrees.
794 */
795 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
796}
797
798static void
799save_state (EggSMClientXSMP *xsmp)
800{
801 GKeyFile *state_file;
802 char *state_file_path, *data;
803 EggDesktopFile *desktop_file;
804 GPtrArray *restart, *discard;
805 int offset, fd;
806
807 /* We set xsmp->state before emitting save_state, but our caller is
808 * responsible for setting it back afterward.
809 */
810 xsmp->state = XSMP_STATE_SAVE_YOURSELF;
811
812 state_file = egg_sm_client_save_state ((EggSMClient *)xsmp);
813 if (!state_file)
814 {
815 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
816 set_properties (xsmp,
817 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
818 NULL((void*)0));
819 g_ptr_array_free (restart, TRUE(!(0)));
820
821 if (xsmp->set_discard_command)
822 {
823 discard = generate_command (xsmp->discard_command, NULL((void*)0), NULL((void*)0));
824 set_properties (xsmp,
825 ptrarray_prop (SmDiscardCommand"DiscardCommand", discard),
826 NULL((void*)0));
827 g_ptr_array_free (discard, TRUE(!(0)));
828 }
829 else
830 delete_properties (xsmp, SmDiscardCommand"DiscardCommand", NULL((void*)0));
831
832 return;
833 }
834
835 desktop_file = egg_get_desktop_file ();
836 if (desktop_file)
837 {
838 GKeyFile *merged_file;
839 char *desktop_file_path;
840
841 merged_file = g_key_file_new ();
842 desktop_file_path =
843 g_filename_from_uri (egg_desktop_file_get_source (desktop_file),
844 NULL((void*)0), NULL((void*)0));
845 if (desktop_file_path &&
846 g_key_file_load_from_file (merged_file, desktop_file_path,
847 G_KEY_FILE_KEEP_COMMENTS |
848 G_KEY_FILE_KEEP_TRANSLATIONS, NULL((void*)0)))
849 {
850 guint g, k, i;
851 char **groups, **keys, *value, *exec;
852
853 groups = g_key_file_get_groups (state_file, NULL((void*)0));
854 for (g = 0; groups[g]; g++)
855 {
856 keys = g_key_file_get_keys (state_file, groups[g], NULL((void*)0), NULL((void*)0));
857 for (k = 0; keys[k]; k++)
858 {
859 value = g_key_file_get_value (state_file, groups[g],
860 keys[k], NULL((void*)0));
861 if (value)
862 {
863 g_key_file_set_value (merged_file, groups[g],
864 keys[k], value);
865 g_free (value);
866 }
867 }
868 g_strfreev (keys);
869 }
870 g_strfreev (groups);
871
872 g_key_file_free (state_file);
873 state_file = merged_file;
874
875 /* Update Exec key using "--sm-client-state-file %k" */
876 restart = generate_command (xsmp->restart_command,
877 NULL((void*)0), "%k");
878 for (i = 0; i < restart->len; i++)
879 restart->pdata[i] = g_shell_quote (restart->pdata[i]);
880 g_ptr_array_add (restart, NULL((void*)0));
881 exec = g_strjoinv (" ", (char **)restart->pdata);
882 g_strfreev ((char **)restart->pdata);
883 g_ptr_array_free (restart, FALSE(0));
884
885 g_key_file_set_string (state_file, EGG_DESKTOP_FILE_GROUP"Desktop Entry",
886 EGG_DESKTOP_FILE_KEY_EXEC"Exec",
887 exec);
888 g_free (exec);
889 }
890 else
891 desktop_file = NULL((void*)0);
892
893 g_free (desktop_file_path);
894 }
895
896 /* Now write state_file to disk. (We can't use mktemp(), because
897 * that requires the filename to end with "XXXXXX", and we want
898 * it to end with ".desktop".)
899 */
900
901 data = g_key_file_to_data (state_file, NULL((void*)0), NULL((void*)0));
902 g_key_file_free (state_file);
903
904 offset = 0;
905 while (1)
906 {
907 state_file_path = g_strdup_printf ("%s%csession-state%c%s-%ld.%s",
908 g_get_user_config_dir (),
909 G_DIR_SEPARATOR'/', G_DIR_SEPARATOR'/',
910 g_get_prgname (),
911 (long)time (NULL((void*)0)) + offset,
912 desktop_file ? "desktop" : "state");
913
914 fd = open (state_file_path, O_WRONLY01 | O_CREAT0100 | O_EXCL0200, 0644);
915 if (fd == -1)
916 {
917 if (errno(*__errno_location ()) == EEXIST17)
918 {
919 offset++;
920 g_free (state_file_path);
921 continue;
922 }
923 else if (errno(*__errno_location ()) == ENOTDIR20 || errno(*__errno_location ()) == ENOENT2)
924 {
925 char *sep = strrchr (state_file_path, G_DIR_SEPARATOR'/');
926
927 *sep = '\0';
928 if (g_mkdir_with_parents (state_file_path, 0755) != 0)
929 {
930 g_warning ("Could not create directory '%s'",
931 state_file_path);
932 g_free (state_file_path);
933 state_file_path = NULL((void*)0);
934 break;
935 }
936
937 continue;
938 }
939
940 g_warning ("Could not create file '%s': %s",
941 state_file_path, g_strerror (errno(*__errno_location ())));
942 g_free (state_file_path);
943 state_file_path = NULL((void*)0);
944 break;
945 }
946
947 close (fd);
948 g_file_set_contents (state_file_path, data, -1, NULL((void*)0));
949 break;
950 }
951 g_free (data);
952
953 restart = generate_command (xsmp->restart_command, xsmp->client_id,
954 state_file_path);
955 set_properties (xsmp,
956 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
957 NULL((void*)0));
958 g_ptr_array_free (restart, TRUE(!(0)));
959
960 if (state_file_path)
961 {
962 set_properties (xsmp,
963 array_prop (SmDiscardCommand"DiscardCommand",
964 "/bin/rm", "-rf", state_file_path,
965 NULL((void*)0)),
966 NULL((void*)0));
967 g_free (state_file_path);
968 }
969}
970
971static void
972xsmp_interact (SmcConn smc_conn,
973 SmPointer client_data)
974{
975 EggSMClientXSMP *xsmp = client_data;
976 EggSMClient *client = client_data;
977
978 g_debug ("Received Interact message in state %s",
979 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
980
981 if (xsmp->state != XSMP_STATE_INTERACT_REQUEST)
982 {
983 fix_broken_state (xsmp, "Interact", TRUE(!(0)), TRUE(!(0)));
984 return;
985 }
986
987 xsmp->state = XSMP_STATE_INTERACT;
988 egg_sm_client_quit_requested (client);
989}
990
991static void
992xsmp_die (SmcConn smc_conn,
993 SmPointer client_data)
994{
995 EggSMClientXSMP *xsmp = client_data;
996 EggSMClient *client = client_data;
997
998 g_debug ("Received Die message in state %s",
999 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1000
1001 sm_client_xsmp_disconnect (xsmp);
1002 egg_sm_client_quit (client);
1003}
1004
1005static void
1006xsmp_save_complete (SmcConn smc_conn,
1007 SmPointer client_data)
1008{
1009 EggSMClientXSMP *xsmp = client_data;
1010
1011 g_debug ("Received SaveComplete message in state %s",
1012 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1013
1014 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1015 xsmp->state = XSMP_STATE_IDLE;
1016 else
1017 fix_broken_state (xsmp, "SaveComplete", FALSE(0), FALSE(0));
1018}
1019
1020static void
1021xsmp_shutdown_cancelled (SmcConn smc_conn,
1022 SmPointer client_data)
1023{
1024 EggSMClientXSMP *xsmp = client_data;
1025 EggSMClient *client = client_data;
1026
1027 g_debug ("Received ShutdownCancelled message in state %s",
1028 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1029
1030 xsmp->shutting_down = FALSE(0);
1031
1032 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1033 {
1034 /* We've finished interacting and now the SM has agreed to
1035 * cancel the shutdown.
1036 */
1037 xsmp->state = XSMP_STATE_IDLE;
1038 egg_sm_client_quit_cancelled (client);
1039 }
1040 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
1041 {
1042 /* Hm... ok, so we got a shutdown SaveYourself, which got
1043 * cancelled, but the application was still interacting, so we
1044 * didn't tell it yet, and then *another* SaveYourself arrived,
1045 * which we must still be waiting to tell the app about, except
1046 * that now that SaveYourself has been cancelled too! Dizzy yet?
1047 */
1048 xsmp->waiting_to_save_myself = FALSE(0);
1049 update_pending_events (xsmp);
1050 }
1051 else
1052 {
1053 g_debug ("Sending SaveYourselfDone(False)");
1054 SmcSaveYourselfDone (xsmp->connection, False0);
1055
1056 if (xsmp->state == XSMP_STATE_INTERACT)
1057 {
1058 /* The application is currently interacting, so we can't
1059 * tell it about the cancellation yet; we will wait until
1060 * after it calls egg_sm_client_will_quit().
1061 */
1062 xsmp->state = XSMP_STATE_SHUTDOWN_CANCELLED;
1063 }
1064 else
1065 {
1066 /* The shutdown was cancelled before the application got a
1067 * chance to interact.
1068 */
1069 xsmp->state = XSMP_STATE_IDLE;
1070 }
1071 }
1072}
1073
1074/* Utilities */
1075
1076/* Create a restart/clone/Exec command based on @restart_command.
1077 * If @client_id is non-%NULL, add "--sm-client-id @client_id".
1078 * If @state_file is non-%NULL, add "--sm-client-state-file @state_file".
1079 *
1080 * None of the input strings are g_strdup()ed; the caller must keep
1081 * them around until it is done with the returned GPtrArray, and must
1082 * then free the array, but not its contents.
1083 */
1084static GPtrArray *
1085generate_command (char **restart_command, const char *client_id,
1086 const char *state_file)
1087{
1088 GPtrArray *cmd;
1089 int i;
1090
1091 cmd = g_ptr_array_new ();
1092 g_ptr_array_add (cmd, restart_command[0]);
1093
1094 if (client_id)
1095 {
1096 g_ptr_array_add (cmd, (char *)"--sm-client-id");
1097 g_ptr_array_add (cmd, (char *)client_id);
1098 }
1099
1100 if (state_file)
1101 {
1102 g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
1103 g_ptr_array_add (cmd, (char *)state_file);
1104 }
1105
1106 for (i = 1; restart_command[i]; i++)
1107 g_ptr_array_add (cmd, restart_command[i]);
1108
1109 return cmd;
1110}
1111
1112/* Takes a NULL-terminated list of SmProp * values, created by
1113 * array_prop, ptrarray_prop, string_prop, card8_prop, sets them, and
1114 * frees them.
1115 */
1116static void
1117set_properties (EggSMClientXSMP *xsmp, ...)
1118{
1119 GPtrArray *props;
1120 SmProp *prop;
1121 va_list ap;
1122 guint i;
1123
1124 props = g_ptr_array_new ();
1125
1126 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1127 while ((prop = va_arg (ap, SmProp *)__builtin_va_arg(ap, SmProp *)))
1128 g_ptr_array_add (props, prop);
1129 va_end (ap)__builtin_va_end(ap);
1130
1131 if (xsmp->connection)
1132 {
1133 SmcSetProperties (xsmp->connection, props->len,
1134 (SmProp **)props->pdata);
1135 }
1136
1137 for (i = 0; i < props->len; i++)
1138 {
1139 prop = props->pdata[i];
1140 g_free (prop->vals);
1141 g_free (prop);
1142 }
1143 g_ptr_array_free (props, TRUE(!(0)));
1144}
1145
1146/* Takes a NULL-terminated list of property names and deletes them. */
1147static void
1148delete_properties (EggSMClientXSMP *xsmp, ...)
1149{
1150 GPtrArray *props;
1151 char *prop;
1152 va_list ap;
1153
1154 if (!xsmp->connection)
1155 return;
1156
1157 props = g_ptr_array_new ();
1158
1159 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1160 while ((prop = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1161 g_ptr_array_add (props, prop);
1162 va_end (ap)__builtin_va_end(ap);
1163
1164 SmcDeleteProperties (xsmp->connection, props->len,
1165 (char **)props->pdata);
1166
1167 g_ptr_array_free (props, TRUE(!(0)));
1168}
1169
1170/* Takes an array of strings and creates a LISTofARRAY8 property. The
1171 * strings are neither dupped nor freed; they need to remain valid
1172 * until you're done with the SmProp.
1173 */
1174static SmProp *
1175array_prop (const char *name, ...)
1176{
1177 SmProp *prop;
1178 SmPropValue pv;
1179 GArray *vals;
1180 char *value;
1181 va_list ap;
1182
1183 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1184 prop->name = (char *)name;
1185 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1186
1187 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1188
1189 va_start (ap, name)__builtin_va_start(ap, name);
1190 while ((value = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1191 {
1192 pv.length = strlen (value);
1193 pv.value = value;
1194 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1195 }
1196 va_end (ap)__builtin_va_end(ap);
1197
1198 prop->num_vals = vals->len;
1199 prop->vals = (SmPropValue *)vals->data;
1200
1201 g_array_free (vals, FALSE(0));
1202
1203 return prop;
1204}
1205
1206/* Takes a GPtrArray of strings and creates a LISTofARRAY8 property.
1207 * The array contents are neither dupped nor freed; they need to
1208 * remain valid until you're done with the SmProp.
1209 */
1210static SmProp *
1211ptrarray_prop (const char *name, GPtrArray *values)
1212{
1213 SmProp *prop;
1214 SmPropValue pv;
1215 GArray *vals;
1216 guint i;
1217
1218 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1219 prop->name = (char *)name;
1220 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1221
1222 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1223
1224 for (i = 0; i < values->len; i++)
1225 {
1226 pv.length = strlen (values->pdata[i]);
1227 pv.value = values->pdata[i];
1228 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1229 }
1230
1231 prop->num_vals = vals->len;
1232 prop->vals = (SmPropValue *)vals->data;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1233
1234 g_array_free (vals, FALSE(0));
1235
1236 return prop;
1237}
1238
1239/* Takes a string and creates an ARRAY8 property. The string is
1240 * neither dupped nor freed; it needs to remain valid until you're
1241 * done with the SmProp.
1242 */
1243static SmProp *
1244string_prop (const char *name, const char *value)
1245{
1246 SmProp *prop;
1247
1248 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1249 prop->name = (char *)name;
1250 prop->type = (char *)SmARRAY8"ARRAY8";
1251
1252 prop->num_vals = 1;
1253 prop->vals = g_new (SmPropValue, 1)((SmPropValue *) g_malloc_n ((1), sizeof (SmPropValue)));
1254
1255 prop->vals[0].length = strlen (value);
1256 prop->vals[0].value = (char *)value;
1257
1258 return prop;
1259}
1260
1261/* Takes a char and creates a CARD8 property. */
1262static SmProp *
1263card8_prop (const char *name, unsigned char value)
1264{
1265 SmProp *prop;
1266 char *card8val;
1267
1268 /* To avoid having to allocate and free prop->vals[0], we cheat and
1269 * make vals a 2-element-long array and then use the second element
1270 * to store value.
1271 */
1272
1273 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1274 prop->name = (char *)name;
1275 prop->type = (char *)SmCARD8"CARD8";
1276
1277 prop->num_vals = 1;
1278 prop->vals = g_new (SmPropValue, 2)((SmPropValue *) g_malloc_n ((2), sizeof (SmPropValue)));
1279 card8val = (char *)(&prop->vals[1]);
1280 card8val[0] = value;
1281
1282 prop->vals[0].length = 1;
1283 prop->vals[0].value = card8val;
1284
1285 return prop;
1286}
1287
1288/* ICE code. This makes no effort to play nice with anyone else trying
1289 * to use libICE. Fortunately, no one uses libICE for anything other
1290 * than SM. (DCOP uses ICE, but it has its own private copy of
1291 * libICE.)
1292 *
1293 * When this moves to gtk, it will need to be cleverer, to avoid
1294 * tripping over old apps that use MateClient or that use libSM
1295 * directly.
1296 */
1297
1298#include <X11/ICE/ICElib.h>
1299#include <fcntl.h>
1300
1301static void ice_error_handler (IceConn ice_conn,
1302 Boolint swap,
1303 int offending_minor_opcode,
1304 unsigned long offending_sequence,
1305 int error_class,
1306 int severity,
1307 IcePointer values);
1308static void ice_io_error_handler (IceConn ice_conn);
1309static void ice_connection_watch (IceConn ice_conn,
1310 IcePointer client_data,
1311 Boolint opening,
1312 IcePointer *watch_data);
1313
1314static void
1315ice_init (void)
1316{
1317 IceSetIOErrorHandler (ice_io_error_handler);
1318 IceSetErrorHandler (ice_error_handler);
1319 IceAddConnectionWatch (ice_connection_watch, NULL((void*)0));
1320}
1321
1322static gboolean
1323process_ice_messages (IceConn ice_conn)
1324{
1325 IceProcessMessagesStatus status;
1326 status = IceProcessMessages (ice_conn, NULL((void*)0), NULL((void*)0));
1327
1328 switch (status)
1329 {
1330 case IceProcessMessagesSuccess:
1331 return TRUE(!(0));
1332
1333 case IceProcessMessagesIOError:
1334 sm_client_xsmp_disconnect (IceGetConnectionContext (ice_conn));
1335 return FALSE(0);
1336
1337 case IceProcessMessagesConnectionClosed:
1338 return FALSE(0);
1339
1340 default:
1341 g_assert_not_reached ()do { g_assertion_message_expr ("EggSMClient", "eggsmclient-xsmp.c"
, 1341, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1342 }
1343}
1344
1345static gboolean
1346ice_iochannel_watch (GIOChannel *channel,
1347 GIOCondition condition,
1348 gpointer client_data)
1349{
1350 return process_ice_messages (client_data);
1351}
1352
1353static void
1354ice_connection_watch (IceConn ice_conn,
1355 IcePointer client_data,
1356 Boolint opening,
1357 IcePointer *watch_data)
1358{
1359 guint watch_id;
1360
1361 if (opening)
1362 {
1363 GIOChannel *channel;
1364 int fd = IceConnectionNumber (ice_conn);
1365
1366 fcntl (fd, F_SETFD2, fcntl (fd, F_GETFD1, 0) | FD_CLOEXEC1);
1367 channel = g_io_channel_unix_new (fd);
1368 watch_id = g_io_add_watch (channel, G_IO_IN | G_IO_ERR,
1369 ice_iochannel_watch, ice_conn);
1370 g_io_channel_unref (channel);
1371
1372 *watch_data = GUINT_TO_POINTER (watch_id)((gpointer) (gulong) (watch_id));
1373 }
1374 else
1375 {
1376 watch_id = GPOINTER_TO_UINT (*watch_data)((guint) (gulong) (*watch_data));
1377 g_source_remove (watch_id);
1378 }
1379}
1380
1381static void
1382ice_error_handler (IceConn ice_conn,
1383 Boolint swap,
1384 int offending_minor_opcode,
1385 unsigned long offending_sequence,
1386 int error_class,
1387 int severity,
1388 IcePointer values)
1389{
1390 /* Do nothing */
1391}
1392
1393static void
1394ice_io_error_handler (IceConn ice_conn)
1395{
1396 /* Do nothing */
1397}
1398
1399static void
1400smc_error_handler (SmcConn smc_conn,
1401 Boolint swap,
1402 int offending_minor_opcode,
1403 unsigned long offending_sequence,
1404 int error_class,
1405 int severity,
1406 SmPointer values)
1407{
1408 /* Do nothing */
1409}
diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/scanview.css b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2024-08-16-185447-5355-1@4e0906a4dd0d_master/sorttable.js b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2024-08-16-185447-5355-1@4e0906a4dd0d_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("