From 0f65f32062e794bbc102036722db571bc96ddfd2 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Tue, 4 Aug 2020 11:01:33 +0000 Subject: Deploy mate-desktop/eom to github.com/mate-desktop/eom.git:gh-pages --- .../index.html | 165 + .../report-00fa08.html | 841 +++ .../report-01e2ed.html | 532 ++ .../report-146e41.html | 6190 ++++++++++++++++++++ .../report-1c08b7.html | 532 ++ .../report-2e99e6.html | 692 +++ .../report-398af3.html | 793 +++ .../report-3a0b24.html | 532 ++ .../report-47a5b9.html | 793 +++ .../report-604cce.html | 793 +++ .../report-607f9b.html | 2816 +++++++++ .../report-684c0b.html | 835 +++ .../report-6ac3ab.html | 2717 +++++++++ .../report-8bd366.html | 793 +++ .../report-920264.html | 2717 +++++++++ .../report-ab6a99.html | 1016 ++++ .../report-b3e0cd.html | 692 +++ .../report-b5c354.html | 1326 +++++ .../report-be481a.html | 793 +++ .../report-d1edab.html | 6190 ++++++++++++++++++++ .../report-e15c69.html | 793 +++ .../report-e7a236.html | 793 +++ .../report-eac485.html | 1474 +++++ .../scanview.css | 62 + .../sorttable.js | 492 ++ 25 files changed, 35372 insertions(+) create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/index.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-00fa08.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-01e2ed.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-146e41.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-1c08b7.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-2e99e6.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-398af3.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-3a0b24.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-47a5b9.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-604cce.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-607f9b.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-684c0b.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-6ac3ab.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-8bd366.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-920264.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-ab6a99.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b3e0cd.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b5c354.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-be481a.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-d1edab.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e15c69.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e7a236.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-eac485.html create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/scanview.css create mode 100644 2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/sorttable.js (limited to '2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH') diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/index.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/index.html new file mode 100644 index 0000000..f73b7ee --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/index.html @@ -0,0 +1,165 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@2dcc8d69e214
Working Directory:/rootdir
Command Line:make -j 3
Clang Version:clang version 10.0.0 (Fedora 10.0.0-2.fc32) +
Date:Mon Jul 13 08:57:35 2020
+

Bug Summary

+ + + + + + + + + + + + +
Bug TypeQuantityDisplay?
All Bugs22
API
Argument with 'nonnull' attribute passed null1
Dead code
Unreachable code11
Dead store
Dead assignment2
Logic error
Cast from non-struct type to struct type6
Out-of-bound access1
Uninitialized argument value1
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
APIArgument with 'nonnull' attribute passed nullsrc/eom-image.ceom_image_real_load96326View Report
Logic errorCast from non-struct type to struct typesrc/eom-preferences-dialog.cpd_rgba_to_string_mapping1001View Report
Logic errorCast from non-struct type to struct typesrc/eom-window.ceom_window_cmd_edit_toolbar25221View Report
Logic errorCast from non-struct type to struct typesrc/eom-preferences-dialog.cpd_string_to_rgba_mapping791View Report
Logic errorCast from non-struct type to struct typesrc/eom-window.ceom_window_cmd_edit_toolbar25201View Report
Logic errorCast from non-struct type to struct typesrc/eom-scroll-view.csv_string_to_rgba_mapping17761View Report
Logic errorCast from non-struct type to struct typesrc/eom-scroll-view.csv_rgba_to_string_mapping17961View Report
Dead storeDead assignmentcut-n-paste/toolbar-editor/egg-toolbars-model.cegg_toolbars_model_to_xml1011View Report
Dead storeDead assignmentcut-n-paste/toolbar-editor/egg-toolbar-editor.cupdate_editor_sheet6201View Report
Logic errorOut-of-bound accesssrc/eom-util.ceom_util_filename_get_extension3027View Report
Logic errorUninitialized argument valuesrc/eom-print-preview.ckey_press_event_cb7885View Report
Dead codeUnreachable codesrc/eom-util.ceom_util_filename_get_extension3031View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type3931View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4091View Report
Dead codeUnreachable codesrc/main.cmain1791View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4311View Report
Dead codeUnreachable codesrc/main.cmain1701View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4151View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4231View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4031View Report
Dead codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type3981View Report
Dead codeUnreachable codesrc/main.c_print_version_and_exit671View Report
+ + diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-00fa08.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-00fa08.html new file mode 100644 index 0000000..5709308 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-00fa08.html @@ -0,0 +1,841 @@ + + + +eom-util.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-util.c
Warning:line 302, column 11
Out of bound memory access (access exceeds upper limit of memory block)
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-util.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-util.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - General Utilities
2 *
3 * Copyright (C) 2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Jens Finke <jens@gnome.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25#ifdef HAVE_CONFIG_H1
26#include "config.h"
27#endif
28
29#include <sys/time.h>
30#ifdef HAVE_STRPTIME1
31#define _XOPEN_SOURCE
32#endif /* HAVE_STRPTIME */
33
34#include <time.h>
35
36#include "eom-util.h"
37
38#include <errno(*__errno_location ()).h>
39#include <string.h>
40#include <glib.h>
41#include <glib/gprintf.h>
42#include <glib/gstdio.h>
43#include <gtk/gtk.h>
44#include <gio/gio.h>
45#include <glib/gi18n.h>
46
47void
48eom_util_show_help (const gchar *section, GtkWindow *parent)
49{
50 GError *error = NULL((void*)0);
51 gchar *uri = NULL((void*)0);
52
53 if (section)
54 uri = g_strdup_printf ("help:eom/%s", section);
55
56 gtk_show_uri_on_window (parent, ((uri != NULL((void*)0)) ? uri : "help:eom"),
57 gtk_get_current_event_time (), &error);
58
59 g_free (uri);
60
61 if (error) {
62 GtkWidget *dialog;
63
64 dialog = gtk_message_dialog_new (parent,
65 0,
66 GTK_MESSAGE_ERROR,
67 GTK_BUTTONS_OK,
68 _("Could not display help for Eye of MATE")gettext ("Could not display help for Eye of MATE"));
69
70 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_message_dialog_get_type ()))))))
,
71 "%s", error->message);
72
73 g_signal_connect_swapped (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
74 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
75 dialog)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
;
76 gtk_widget_show (dialog);
77
78 g_error_free (error);
79 }
80}
81
82gchar *
83eom_util_make_valid_utf8 (const gchar *str)
84{
85 GString *string;
86 const char *remainder, *invalid;
87 int remaining_bytes, valid_bytes;
88
89 string = NULL((void*)0);
90 remainder = str;
91 remaining_bytes = strlen (str);
92
93 while (remaining_bytes != 0) {
94 if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
95 break;
96 }
97
98 valid_bytes = invalid - remainder;
99
100 if (string == NULL((void*)0)) {
101 string = g_string_sized_new (remaining_bytes);
102 }
103
104 g_string_append_len (string, remainder, valid_bytes);
105 g_string_append_c (string, '?')g_string_append_c_inline (string, '?');
106
107 remaining_bytes -= valid_bytes + 1;
108 remainder = invalid + 1;
109 }
110
111 if (string == NULL((void*)0)) {
112 return g_strdup (str);
113 }
114
115 g_string_append (string, remainder);
116 g_string_append (string, _(" (invalid Unicode)")gettext (" (invalid Unicode)"));
117
118 g_assert (g_utf8_validate (string->str, -1, NULL))do { if (g_utf8_validate (string->str, -1, ((void*)0))) ; else
g_assertion_message_expr ("EOM", "eom-util.c", 118, ((const char
*) (__func__)), "g_utf8_validate (string->str, -1, NULL)")
; } while (0)
;
119
120 return g_string_free (string, FALSE(0));
121}
122
123GSList*
124eom_util_parse_uri_string_list_to_file_list (const gchar *uri_list)
125{
126 GSList* file_list = NULL((void*)0);
127 gsize i = 0;
128 gchar **uris;
129
130 uris = g_uri_list_extract_uris (uri_list);
131
132 while (uris[i] != NULL((void*)0)) {
133 file_list = g_slist_append (file_list, g_file_new_for_uri (uris[i]));
134 i++;
135 }
136
137 g_strfreev (uris);
138
139 return file_list;
140}
141
142GSList*
143eom_util_string_list_to_file_list (GSList *string_list)
144{
145 GSList *it = NULL((void*)0);
146 GSList *file_list = NULL((void*)0);
147
148 for (it = string_list; it != NULL((void*)0); it = it->next) {
149 char *uri_str;
150
151 uri_str = (gchar *) it->data;
152
153 file_list = g_slist_prepend (file_list,
154 g_file_new_for_uri (uri_str));
155 }
156
157 return g_slist_reverse (file_list);
158}
159
160GSList*
161eom_util_strings_to_file_list (gchar **strings)
162{
163 int i;
164 GSList *file_list = NULL((void*)0);
165
166 for (i = 0; strings[i]; i++) {
167 file_list = g_slist_prepend (file_list,
168 g_file_new_for_uri (strings[i]));
169 }
170
171 return g_slist_reverse (file_list);
172}
173
174GSList*
175eom_util_string_array_to_list (const gchar **files, gboolean create_uri)
176{
177 gint i;
178 GSList *list = NULL((void*)0);
179
180 if (files == NULL((void*)0)) return list;
181
182 for (i = 0; files[i]; i++) {
183 char *str;
184
185 if (create_uri) {
186 GFile *file;
187
188 file = g_file_new_for_commandline_arg (files[i]);
189 str = g_file_get_uri (file);
190
191 g_object_unref (file);
192 } else {
193 str = g_strdup (files[i]);
194 }
195
196 if (str) {
197 list = g_slist_prepend (list, g_strdup (str));
198 g_free (str);
199 }
200 }
201
202 return g_slist_reverse (list);
203}
204
205gchar **
206eom_util_string_array_make_absolute (gchar **files)
207{
208 int i;
209 int size;
210 gchar **abs_files;
211 GFile *file;
212
213 if (files == NULL((void*)0))
214 return NULL((void*)0);
215
216 size = g_strv_length (files);
217
218 /* Ensure new list is NULL-terminated */
219 abs_files = g_new0 (gchar *, size+1)((gchar * *) g_malloc0_n ((size+1), sizeof (gchar *)));
220
221 for (i = 0; i < size; i++) {
222 file = g_file_new_for_commandline_arg (files[i]);
223 abs_files[i] = g_file_get_uri (file);
224
225 g_object_unref (file);
226 }
227
228 return abs_files;
229}
230
231static gchar *dot_dir = NULL((void*)0);
232
233static gboolean
234ensure_dir_exists (const char *dir)
235{
236 if (g_file_test (dir, G_FILE_TEST_IS_DIR))
237 return TRUE(!(0));
238
239 if (g_mkdir_with_parents (dir, 0700) == 0)
240 return TRUE(!(0));
241
242 if (errno(*__errno_location ()) == EEXIST17)
243 return g_file_test (dir, G_FILE_TEST_IS_DIR);
244
245 g_warning ("Failed to create directory %s: %s", dir, strerror (errno(*__errno_location ())));
246 return FALSE(0);
247}
248
249const gchar *
250eom_util_dot_dir (void)
251{
252 if (dot_dir == NULL((void*)0)) {
253 gboolean exists;
254
255 dot_dir = g_build_filename(g_get_user_config_dir(), "mate", "eom", NULL((void*)0));
256
257 exists = ensure_dir_exists (dot_dir);
258
259 if (G_UNLIKELY (!exists)(!exists)) {
260 static gboolean printed_warning = FALSE(0);
261
262 if (!printed_warning) {
263 g_warning ("EOM could not save some of your preferences in its settings directory due to a file with the same name (%s) blocking its creation. Please remove that file, or move it away.", dot_dir);
264 printed_warning = TRUE(!(0));
265 }
266 dot_dir = NULL((void*)0);
267 return NULL((void*)0);
268 }
269 }
270
271 return dot_dir;
272}
273
274/* Based on eel_filename_strip_extension() */
275
276/**
277 * eom_util_filename_get_extension:
278 * @filename: a filename
279 *
280 * Returns a reasonably good guess of the file extension of @filename.
281 *
282 * Returns: a newly allocated string with the file extension of @filename.
283 **/
284char *
285eom_util_filename_get_extension (const char * filename)
286{
287 char *begin, *begin2;
288
289 if (filename == NULL((void*)0)) {
1
Assuming 'filename' is not equal to NULL
2
Taking false branch
290 return NULL((void*)0);
291 }
292
293 begin = strrchr (filename, '.');
294
295 if (begin && begin != filename) {
3
Assuming 'begin' is non-null
4
Assuming 'begin' is not equal to 'filename'
5
Taking true branch
296 if (strcmp (begin, ".gz") == 0 ||
297 strcmp (begin, ".bz2") == 0 ||
298 strcmp (begin, ".sit") == 0 ||
299 strcmp (begin, ".Z") == 0) {
300 begin2 = begin - 1;
301 while (begin2 > filename &&
6
Assuming 'begin2' is > 'filename'
302 *begin2 != '.') {
7
Out of bound memory access (access exceeds upper limit of memory block)
303 begin2--;
304 }
305 if (begin2 != filename) {
306 begin = begin2;
307 }
308 }
309 begin ++;
310 } else {
311 return NULL((void*)0);
312 }
313
314 return g_strdup (begin);
315}
316
317
318/**
319 * eom_util_file_is_persistent:
320 * @file: a #GFile
321 *
322 * Checks whether @file is a non-removable local mount.
323 *
324 * Returns: %TRUE if @file is in a non-removable mount,
325 * %FALSE otherwise or when it is remote.
326 **/
327gboolean
328eom_util_file_is_persistent (GFile *file)
329{
330 GMount *mount;
331
332 if (!g_file_is_native (file))
333 return FALSE(0);
334
335 mount = g_file_find_enclosing_mount (file, NULL((void*)0), NULL((void*)0));
336 if (mount) {
337 if (g_mount_can_unmount (mount)) {
338 return FALSE(0);
339 }
340 }
341
342 return TRUE(!(0));
343}
344
345static void
346_eom_util_show_file_in_filemanager_fallback (GFile *file, GtkWindow *toplevel)
347{
348 gchar *uri = NULL((void*)0);
349 GError *error = NULL((void*)0);
350 guint32 timestamp = gtk_get_current_event_time ();
351
352 if (g_file_query_file_type (file, 0, NULL((void*)0)) == G_FILE_TYPE_DIRECTORY) {
353 uri = g_file_get_uri (file);
354 } else {
355 /* If input file is not a directory we must open it's
356 folder/parent to avoid opening the file itself */
357 GFile *parent_file;
358
359 parent_file = g_file_get_parent (file);
360 if (G_LIKELY (parent_file)(parent_file))
361 uri = g_file_get_uri (parent_file);
362 g_object_unref (parent_file);
363 }
364
365 if (uri && !gtk_show_uri_on_window (toplevel, uri, timestamp, &error)) {
366 g_warning ("Couldn't show containing folder \"%s\": %s", uri,
367 error->message);
368 g_error_free (error);
369 }
370
371 g_free (uri);
372}
373
374void
375eom_util_show_file_in_filemanager (GFile *file, GtkWindow *toplevel)
376{
377 GDBusProxy *proxy;
378 gboolean done = FALSE(0);
379
380 g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "file != NULL"); return;
} } while (0)
;
381
382 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
383 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
384 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
385 NULL((void*)0), "org.freedesktop.FileManager1",
386 "/org/freedesktop/FileManager1",
387 "org.freedesktop.FileManager1",
388 NULL((void*)0), NULL((void*)0));
389
390 if (proxy) {
391 gchar *uri = g_file_get_uri (file);
392 gchar *startup_id;
393 GVariant *params, *result;
394 GVariantBuilder builder;
395
396 g_variant_builder_init (&builder,
397 G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
398 g_variant_builder_add (&builder, "s", uri);
399
400 /* This seems to be the expected format, as other values
401 cause the filemanager window not to get focus. */
402 startup_id = g_strdup_printf("_TIME%u",
403 gtk_get_current_event_time());
404
405 /* params is floating! */
406 params = g_variant_new ("(ass)", &builder, startup_id);
407
408 g_free (startup_id);
409 g_variant_builder_clear (&builder);
410
411 /* Floating params-GVariant is consumed here */
412 result = g_dbus_proxy_call_sync (proxy, "ShowItems",
413 params, G_DBUS_CALL_FLAGS_NONE,
414 -1, NULL((void*)0), NULL((void*)0));
415
416 /* Receiving a non-NULL result counts as a successful call. */
417 if (G_LIKELY (result != NULL)(result != ((void*)0))) {
418 done = TRUE(!(0));
419 g_variant_unref (result);
420 }
421
422 g_free (uri);
423 g_object_unref (proxy);
424 }
425
426 /* Fallback to gtk_show_uri() if launch over DBus is not possible */
427 if (!done)
428 _eom_util_show_file_in_filemanager_fallback (file, toplevel);
429}
430
431gboolean
432eom_notebook_scroll_event_cb (GtkWidget *widget,
433 GdkEventScroll *event)
434
435{
436 GtkNotebook *notebook = GTK_NOTEBOOK (widget)((((GtkNotebook*) g_type_check_instance_cast ((GTypeInstance*
) ((widget)), ((gtk_notebook_get_type ()))))))
;
437 GtkWidget *child, *event_widget, *action_widget;
438
439 child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
440 if (child == NULL((void*)0))
441 return FALSE(0);
442
443 event_widget = gtk_get_event_widget ((GdkEvent*) event);
444
445 /* Ignore scroll events from the content of the page */
446 if (event_widget == NULL((void*)0) || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
447 return FALSE(0);
448
449 /* And also from the action widgets */
450 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
451 if (event_widget == action_widget || (action_widget != NULL((void*)0) && gtk_widget_is_ancestor (event_widget, action_widget)))
452 return FALSE(0);
453
454 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
455 if (event_widget == action_widget || (action_widget != NULL((void*)0) && gtk_widget_is_ancestor (event_widget, action_widget)))
456 return FALSE(0);
457
458 switch (event->direction) {
459 case GDK_SCROLL_RIGHT:
460 case GDK_SCROLL_DOWN:
461 gtk_notebook_next_page (notebook);
462 break;
463 case GDK_SCROLL_LEFT:
464 case GDK_SCROLL_UP:
465 gtk_notebook_prev_page (notebook);
466 break;
467 case GDK_SCROLL_SMOOTH:
468 switch (gtk_notebook_get_tab_pos (notebook)) {
469 case GTK_POS_LEFT:
470 case GTK_POS_RIGHT:
471 if (event->delta_y > 0)
472 gtk_notebook_next_page (notebook);
473 else if (event->delta_y < 0)
474 gtk_notebook_prev_page (notebook);
475 break;
476 case GTK_POS_TOP:
477 case GTK_POS_BOTTOM:
478 if (event->delta_x > 0)
479 gtk_notebook_next_page (notebook);
480 else if (event->delta_x < 0)
481 gtk_notebook_prev_page (notebook);
482 break;
483 }
484 break;
485 }
486
487 return TRUE(!(0));
488}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-01e2ed.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-01e2ed.html new file mode 100644 index 0000000..87a6ad5 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-01e2ed.html @@ -0,0 +1,532 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/main.c
Warning:line 67, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I ../cut-n-paste/toolbar-editor -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -I /usr/include/gobject-introspection-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - Main
2 *
3 * Copyright (C) 2000-2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Federico Mena-Quintero <federico@gnu.org>
9 * - Jens Finke <jens@gnome.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
24 */
25
26#ifdef HAVE_CONFIG_H1
27#include "config.h"
28#endif
29#ifdef HAVE_INTROSPECTION1
30#include <girepository.h>
31#endif
32
33#include "eom-session.h"
34#include "eom-debug.h"
35#include "eom-thumbnail.h"
36#include "eom-job-queue.h"
37#include "eom-application.h"
38#include "eom-application-internal.h"
39#include "eom-util.h"
40
41#include <string.h>
42#include <stdlib.h>
43#include <glib/gi18n.h>
44
45#if HAVE_EXEMPI1
46#include <exempi/xmp.h>
47#endif
48
49#define EOM_CSS_FILE_PATH"/usr/local/share/eom" "/" "eom.css" EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "eom.css"
50
51static EomStartupFlags flags;
52
53static gboolean fullscreen = FALSE(0);
54static gboolean slide_show = FALSE(0);
55static gboolean disable_collection = FALSE(0);
56static gboolean force_new_instance = FALSE(0);
57static gchar **startup_files = NULL((void*)0);
58
59static gboolean
60_print_version_and_exit (const gchar *option_name,
61 const gchar *value,
62 gpointer data,
63 GError **error)
64{
65 g_print("%s %s\n", _("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"), VERSION"1.24.0");
66 exit (EXIT_SUCCESS0);
67 return TRUE(!(0));
This statement is never executed
68}
69
70static const GOptionEntry goption_options[] =
71{
72 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) },
73 { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) },
74 { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) },
75 { "new-instance", 'n', 0, G_OPTION_ARG_NONE, &force_new_instance, N_("Start a new instance instead of reusing an existing one")("Start a new instance instead of reusing an existing one"), NULL((void*)0) },
76 { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
77 _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)},
78 { NULL((void*)0) }
79};
80
81static void
82set_startup_flags (void)
83{
84 if (fullscreen)
85 flags |= EOM_STARTUP_FULLSCREEN;
86
87 if (disable_collection)
88 flags |= EOM_STARTUP_DISABLE_COLLECTION;
89
90 if (slide_show)
91 flags |= EOM_STARTUP_SLIDE_SHOW;
92}
93
94int
95main (int argc, char **argv)
96{
97 GError *error = NULL((void*)0);
98 GOptionContext *ctx;
99 GFile *css_file;
100 GtkCssProvider *provider;
101
102 bindtextdomain (GETTEXT_PACKAGE"eom", EOM_LOCALE_DIR"/usr/local/share/locale");
103 bind_textdomain_codeset (GETTEXT_PACKAGE"eom", "UTF-8");
104 textdomain (GETTEXT_PACKAGE"eom");
105
106 gdk_set_allowed_backends ("wayland,x11");
107
108 ctx = g_option_context_new (_("[FILE…]")gettext ("[FILE…]"));
109 g_option_context_add_main_entries (ctx, goption_options, PACKAGE"eom");
110 /* Option groups are free'd together with the context
111 * Using gtk_get_option_group here initializes gtk during parsing */
112 g_option_context_add_group (ctx, gtk_get_option_group (TRUE(!(0))));
113#ifdef HAVE_INTROSPECTION1
114 g_option_context_add_group (ctx, g_irepository_get_option_group ());
115#endif
116
117 if (!g_option_context_parse (ctx, &argc, &argv, &error)) {
118 gchar *help_msg;
119
120 /* I18N: The '%s' is replaced with eom's command name. */
121 help_msg = g_strdup_printf (_("Run '%s --help' to see a full "gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
122 "list of available command line "gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
123 "options.")gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
, argv[0]);
124 g_printerr ("%s\n%s\n", error->message, help_msg);
125 g_error_free (error);
126 g_free (help_msg);
127 g_option_context_free (ctx);
128
129 return 1;
130 }
131 g_option_context_free (ctx);
132
133
134 set_startup_flags ();
135
136#ifdef HAVE_EXEMPI1
137 xmp_init();
138#endif
139 eom_debug_init ();
140 eom_job_queue_init ();
141 eom_thumbnail_init ();
142
143 /* Load special style properties for EomThumbView's scrollbar */
144 css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
145 provider = gtk_css_provider_new ();
146 if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
147 css_file,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
148 &error))(!gtk_css_provider_load_from_file(provider, css_file, &error
))
)
149 {
150 g_critical ("Could not load CSS data: %s", error->message);
151 g_clear_error (&error);
152 } else {
153 gtk_style_context_add_provider_for_screen (
154 gdk_screen_get_default(),
155 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) g_type_check_instance_cast ((GTypeInstance
*) ((provider)), ((gtk_style_provider_get_type ()))))))
,
156 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
157 }
158 g_object_unref (provider);
159 g_object_unref (css_file);
160
161 /* Add application specific icons to search path */
162 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
163 EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "icons");
164
165 gtk_window_set_default_icon_name ("eom");
166 g_set_application_name (_("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"));
167
168 EOM_APP(eom_application_get_instance ())->priv->flags = flags;
169 if (force_new_instance) {
170 GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
);
171 app_flags |= G_APPLICATION_NON_UNIQUE;
172 g_application_set_flags (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, app_flags);
173 }
174
175 g_application_run (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, argc, argv);
176 g_object_unref (EOM_APP(eom_application_get_instance ()));
177
178 if (startup_files)
179 g_strfreev (startup_files);
180
181#ifdef HAVE_EXEMPI1
182 xmp_terminate();
183#endif
184 return 0;
185}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-146e41.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-146e41.html new file mode 100644 index 0000000..9f19d9b --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-146e41.html @@ -0,0 +1,6190 @@ + + + +eom-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-window.c
Warning:line 2522, column 11
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 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-window.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-window.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - Main Window
2 *
3 * Copyright (C) 2000-2008 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Federico Mena-Quintero <federico@gnu.org>
9 * - Jens Finke <jens@gnome.org>
10 * Based on evince code (shell/ev-window.c) by:
11 * - Martin Kretzschmar <martink@gnome.org>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27
28#ifdef HAVE_CONFIG_H1
29#include "config.h"
30#endif
31
32#include <math.h>
33
34#include "eom-window.h"
35#include "eom-scroll-view.h"
36#include "eom-debug.h"
37#include "eom-file-chooser.h"
38#include "eom-thumb-view.h"
39#include "eom-list-store.h"
40#include "eom-sidebar.h"
41#include "eom-statusbar.h"
42#include "eom-preferences-dialog.h"
43#include "eom-properties-dialog.h"
44#include "eom-print.h"
45#include "eom-error-message-area.h"
46#include "eom-application.h"
47#include "eom-application-internal.h"
48#include "eom-thumb-nav.h"
49#include "eom-config-keys.h"
50#include "eom-job-queue.h"
51#include "eom-jobs.h"
52#include "eom-util.h"
53#include "eom-save-as-dialog-helper.h"
54#include "eom-close-confirmation-dialog.h"
55#include "eom-clipboard-handler.h"
56#include "eom-window-activatable.h"
57#include "eom-metadata-sidebar.h"
58
59#include "eom-enum-types.h"
60
61#include "egg-toolbar-editor.h"
62#include "egg-editable-toolbar.h"
63#include "egg-toolbars-model.h"
64
65#include <glib.h>
66#include <glib-object.h>
67#include <glib/gi18n.h>
68#include <gio/gio.h>
69#include <gdk/gdkkeysyms.h>
70#include <gio/gdesktopappinfo.h>
71#include <gtk/gtk.h>
72
73#include <libpeas/peas-extension-set.h>
74#include <libpeas/peas-activatable.h>
75
76#if HAVE_LCMS1
77#include <X11/Xlib.h>
78#include <X11/Xatom.h>
79#ifdef GDK_WINDOWING_X11
80#include <gdk/gdkx.h>
81#endif
82#include <lcms2.h>
83#endif
84
85#define MATE_DESKTOP_USE_UNSTABLE_API
86#include <libmate-desktop/mate-desktop-utils.h>
87
88#define EOM_WINDOW_MIN_WIDTH440 440
89#define EOM_WINDOW_MIN_HEIGHT350 350
90
91#define EOM_WINDOW_DEFAULT_WIDTH540 540
92#define EOM_WINDOW_DEFAULT_HEIGHT450 450
93
94#define EOM_WINDOW_FULLSCREEN_TIMEOUT5 * 1000 5 * 1000
95#define EOM_WINDOW_FULLSCREEN_POPUP_THRESHOLD5 5
96
97#define EOM_RECENT_FILES_GROUP"Graphics" "Graphics"
98#define EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer" "Eye of MATE Image Viewer"
99#define EOM_RECENT_FILES_LIMIT5 5
100
101#define EOM_WALLPAPER_FILENAME"eom-wallpaper" "eom-wallpaper"
102
103#define is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
104
105typedef enum {
106 EOM_WINDOW_STATUS_UNKNOWN,
107 EOM_WINDOW_STATUS_INIT,
108 EOM_WINDOW_STATUS_NORMAL
109} EomWindowStatus;
110
111enum {
112 PROP_0,
113 PROP_COLLECTION_POS,
114 PROP_COLLECTION_RESIZABLE,
115 PROP_STARTUP_FLAGS
116};
117
118enum {
119 SIGNAL_PREPARED,
120 SIGNAL_LAST
121};
122
123static guint signals[SIGNAL_LAST] = { 0 };
124
125struct _EomWindowPrivate {
126 GSettings *view_settings;
127 GSettings *ui_settings;
128 GSettings *fullscreen_settings;
129 GSettings *lockdown_settings;
130
131 EomListStore *store;
132 EomImage *image;
133 EomWindowMode mode;
134 EomWindowStatus status;
135
136 GtkUIManager *ui_mgr;
137 GtkWidget *box;
138 GtkWidget *layout;
139 GtkWidget *cbox;
140 GtkWidget *view;
141 GtkWidget *sidebar;
142 GtkWidget *thumbview;
143 GtkWidget *statusbar;
144 GtkWidget *nav;
145 GtkWidget *message_area;
146 GtkWidget *toolbar;
147 GtkWidget *properties_dlg;
148
149 GtkActionGroup *actions_window;
150 GtkActionGroup *actions_image;
151 GtkActionGroup *actions_collection;
152 GtkActionGroup *actions_recent;
153
154 GtkWidget *fullscreen_popup;
155 GSource *fullscreen_timeout_source;
156
157 gboolean slideshow_random;
158 gboolean slideshow_loop;
159 gint slideshow_switch_timeout;
160 GSource *slideshow_switch_source;
161
162 guint fullscreen_idle_inhibit_cookie;
163
164 guint recent_menu_id;
165
166 EomJob *load_job;
167 EomJob *transform_job;
168 EomJob *save_job;
169 GFile *last_save_as_folder;
170 EomJob *copy_job;
171
172 guint image_info_message_cid;
173 guint tip_message_cid;
174 guint copy_file_cid;
175
176 EomStartupFlags flags;
177 GSList *file_list;
178
179 EomWindowCollectionPos collection_position;
180 gboolean collection_resizable;
181
182 GtkActionGroup *actions_open_with;
183 guint open_with_menu_id;
184
185 gboolean save_disabled;
186 gboolean needs_reload_confirmation;
187
188 GtkPageSetup *page_setup;
189
190 PeasExtensionSet *extensions;
191
192#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
193 cmsHPROFILE *display_profile;
194#endif
195};
196
197G_DEFINE_TYPE_WITH_PRIVATE (EomWindow, eom_window, GTK_TYPE_APPLICATION_WINDOW)static void eom_window_init (EomWindow *self); static void eom_window_class_init
(EomWindowClass *klass); static GType eom_window_get_type_once
(void); static gpointer eom_window_parent_class = ((void*)0)
; static gint EomWindow_private_offset; static void eom_window_class_intern_init
(gpointer klass) { eom_window_parent_class = g_type_class_peek_parent
(klass); if (EomWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomWindow_private_offset); eom_window_class_init
((EomWindowClass*) klass); } __attribute__((__unused__)) static
inline gpointer eom_window_get_instance_private (EomWindow *
self) { return (((gpointer) ((guint8*) (self) + (glong) (EomWindow_private_offset
)))); } GType eom_window_get_type (void) { static volatile gsize
g_define_type_id__volatile = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer
), "Expression evaluates to false"); (void) (0 ? (gpointer) *
(&g_define_type_id__volatile) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_window_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_application_window_get_type ()), g_intern_static_string
("EomWindow"), sizeof (EomWindowClass), (GClassInitFunc)(void
(*)(void)) eom_window_class_intern_init, sizeof (EomWindow),
(GInstanceInitFunc)(void (*)(void)) eom_window_init, (GTypeFlags
) 0); { {{ EomWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EomWindowPrivate)); };} } return g_define_type_id
; }
;
198
199static void eom_window_cmd_fullscreen (GtkAction *action, gpointer user_data);
200static void eom_window_run_fullscreen (EomWindow *window, gboolean slideshow);
201static void eom_window_cmd_slideshow (GtkAction *action, gpointer user_data);
202static void eom_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data);
203static void eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow);
204static void eom_job_load_cb (EomJobLoad *job, gpointer data);
205static void eom_job_save_progress_cb (EomJobSave *job, float progress, gpointer data);
206static void eom_job_progress_cb (EomJobLoad *job, float progress, gpointer data);
207static void eom_job_transform_cb (EomJobTransform *job, gpointer data);
208static void fullscreen_set_timeout (EomWindow *window);
209static void fullscreen_clear_timeout (EomWindow *window);
210static void update_action_groups_state (EomWindow *window);
211static void open_with_launch_application_cb (GtkAction *action, gpointer callback_data);
212static void eom_window_update_openwith_menu (EomWindow *window, EomImage *image);
213static void eom_window_list_store_image_added (GtkTreeModel *tree_model,
214 GtkTreePath *path,
215 GtkTreeIter *iter,
216 gpointer user_data);
217static void eom_window_list_store_image_removed (GtkTreeModel *tree_model,
218 GtkTreePath *path,
219 gpointer user_data);
220static void eom_window_set_wallpaper (EomWindow *window, const gchar *filename, const gchar *visible_filename);
221static gboolean eom_window_save_images (EomWindow *window, GList *images);
222static void disconnect_proxy_cb (GtkUIManager *manager,
223 GtkAction *action,
224 GtkWidget *proxy,
225 EomWindow *window);
226static void eom_window_finish_saving (EomWindow *window);
227static GAppInfo *get_appinfo_for_editor (EomWindow *window);
228
229static GQuark
230eom_window_error_quark (void)
231{
232 static GQuark q = 0;
233
234 if (q == 0)
235 q = g_quark_from_static_string ("eom-window-error-quark");
236
237 return q;
238}
239
240static void
241eom_window_set_collection_mode (EomWindow *window, EomWindowCollectionPos position, gboolean resizable)
242{
243 EomWindowPrivate *priv;
244 GtkWidget *hpaned;
245 EomThumbNavMode mode = EOM_THUMB_NAV_MODE_ONE_ROW;
246
247 eom_debug (DEBUG_PREFERENCESEOM_DEBUG_PREFERENCES, "eom-window.c", 247, ((const char*) (__func__
))
);
248
249 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
250
251 priv = window->priv;
252
253 if (priv->collection_position == position &&
254 priv->collection_resizable == resizable)
255 return;
256
257 priv->collection_position = position;
258 priv->collection_resizable = resizable;
259
260 hpaned = gtk_widget_get_parent (priv->sidebar);
261
262 g_object_ref (hpaned);
263 g_object_ref (priv->nav);
264
265 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_container_get_type ()))))))
, hpaned);
266 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_container_get_type ()))))))
, priv->nav);
267
268 gtk_widget_destroy (priv->layout);
269
270 switch (position) {
271 case EOM_WINDOW_COLLECTION_POS_BOTTOM:
272 case EOM_WINDOW_COLLECTION_POS_TOP:
273 if (resizable) {
274 mode = EOM_THUMB_NAV_MODE_MULTIPLE_ROWS;
275
276 priv->layout = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
277
278 if (position == EOM_WINDOW_COLLECTION_POS_BOTTOM) {
279 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
280 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
281 } else {
282 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
283 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
284 }
285 } else {
286 mode = EOM_THUMB_NAV_MODE_ONE_ROW;
287
288 priv->layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
289
290 if (position == EOM_WINDOW_COLLECTION_POS_BOTTOM) {
291 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
292 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
293 } else {
294 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
295 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
296 }
297 }
298 break;
299
300 case EOM_WINDOW_COLLECTION_POS_LEFT:
301 case EOM_WINDOW_COLLECTION_POS_RIGHT:
302 if (resizable) {
303 mode = EOM_THUMB_NAV_MODE_MULTIPLE_COLUMNS;
304
305 priv->layout = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
306
307 if (position == EOM_WINDOW_COLLECTION_POS_LEFT) {
308 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
309 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
310 } else {
311 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
312 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
313 }
314 } else {
315 mode = EOM_THUMB_NAV_MODE_ONE_COLUMN;
316
317 priv->layout = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
318
319 if (position == EOM_WINDOW_COLLECTION_POS_LEFT) {
320 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
321 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
322 } else {
323 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
324 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
325 }
326 }
327
328 break;
329 }
330
331 gtk_box_pack_end (GTK_BOX (priv->cbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->cbox)), ((gtk_box_get_type ()))))))
, priv->layout, TRUE(!(0)), TRUE(!(0)), 0);
332
333 eom_thumb_nav_set_mode (EOM_THUMB_NAV (priv->nav)((((EomThumbNav*) g_type_check_instance_cast ((GTypeInstance*
) ((priv->nav)), ((eom_thumb_nav_get_type ()))))))
, mode);
334
335 if (priv->mode != EOM_WINDOW_MODE_UNKNOWN) {
336 update_action_groups_state (window);
337 }
338}
339
340static void
341eom_window_can_save_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
342{
343 EomWindowPrivate *priv;
344 EomWindow *window;
345 gboolean save_disabled = FALSE(0);
346 GtkAction *action_save, *action_save_as;
347
348 eom_debug (DEBUG_PREFERENCESEOM_DEBUG_PREFERENCES, "eom-window.c", 348, ((const char*) (__func__
))
);
349
350 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
351
352 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
353 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
354
355 save_disabled = g_settings_get_boolean (settings, key);
356
357 priv->save_disabled = save_disabled;
358
359 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
360 action_save =
361 gtk_action_group_get_action (priv->actions_image, "ImageSave");
362 action_save_as =
363 gtk_action_group_get_action (priv->actions_image, "ImageSaveAs");
364
365 if (priv->save_disabled) {
366 gtk_action_set_sensitive (action_save, FALSE(0));
367 gtk_action_set_sensitive (action_save_as, FALSE(0));
368 } else {
369 EomImage *image = eom_window_get_image (window);
370
371 if (EOM_IS_IMAGE (image)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(image)); GType __t = ((eom_image_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; }))))
) {
372 gtk_action_set_sensitive (action_save,
373 eom_image_is_modified (image));
374
375 gtk_action_set_sensitive (action_save_as, TRUE(!(0)));
376 }
377 }
378 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
379}
380
381#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
382static cmsHPROFILE *
383eom_window_get_display_profile (GdkScreen *screen)
384{
385 Display *dpy;
386 Atom icc_atom, type;
387 int format;
388 gulong nitems;
389 gulong bytes_after;
390 gulong length;
391 guchar *str;
392 int result;
393 cmsHPROFILE *profile = NULL((void*)0);
394 char *atom_name;
395
396 if (!GDK_IS_X11_SCREEN (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((gdk_x11_screen_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; }))))
) {
397 return NULL((void*)0);
398 }
399
400 dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen))(gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen
)))
;
401
402 if (gdk_x11_screen_get_screen_number (screen) > 0)
403 atom_name = g_strdup_printf ("_ICC_PROFILE_%d", gdk_x11_screen_get_screen_number (screen));
404 else
405 atom_name = g_strdup ("_ICC_PROFILE");
406
407 icc_atom = gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen), atom_name);
408
409 g_free (atom_name);
410
411 result = XGetWindowProperty (dpy,
412 GDK_WINDOW_XID (gdk_screen_get_root_window (screen))(gdk_x11_window_get_xid (gdk_screen_get_root_window (screen))
)
,
413 icc_atom,
414 0,
415 G_MAXLONG9223372036854775807L,
416 False0,
417 XA_CARDINAL((Atom) 6),
418 &type,
419 &format,
420 &nitems,
421 &bytes_after,
422 (guchar **)&str);
423
424 /* TODO: handle bytes_after != 0 */
425
426 if ((result == Success0) && (type == XA_CARDINAL((Atom) 6)) && (nitems > 0)) {
427 switch (format)
428 {
429 case 8:
430 length = nitems;
431 break;
432 case 16:
433 length = sizeof(short) * nitems;
434 break;
435 case 32:
436 length = sizeof(long) * nitems;
437 break;
438 default:
439 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-window.c", 439, ((const char*) (__func__
))
, "Unable to read profile, not correcting");
440
441 XFree (str);
442 return NULL((void*)0);
443 }
444
445 profile = cmsOpenProfileFromMem (str, length);
446
447 if (G_UNLIKELY (profile == NULL)(profile == ((void*)0))) {
448 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-window.c", 448, ((const char*) (__func__
))
,
449 "Invalid display profile set, "
450 "not using it");
451 }
452
453 XFree (str);
454 }
455
456 if (profile == NULL((void*)0)) {
457 profile = cmsCreate_sRGBProfile ();
458 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-window.c", 458, ((const char*) (__func__
))
,
459 "No valid display profile set, assuming sRGB");
460 }
461
462 return profile;
463}
464#endif
465
466static void
467update_image_pos (EomWindow *window)
468{
469 EomWindowPrivate *priv;
470 gint pos = -1, n_images = 0;
471
472 priv = window->priv;
473
474 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
475
476 if (n_images > 0) {
477 pos = eom_list_store_get_pos_by_image (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
,
478 priv->image);
479 }
480 /* Images: (image pos) / (n_total_images) */
481 eom_statusbar_set_image_number (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
,
482 pos + 1,
483 n_images);
484
485}
486
487static void
488update_status_bar (EomWindow *window)
489{
490 EomWindowPrivate *priv;
491 char *str = NULL((void*)0);
492
493 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
494
495 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 495, ((const char*) (__func__
))
);
496
497 priv = window->priv;
498
499 if (priv->image != NULL((void*)0) &&
500 eom_image_has_data (priv->image, EOM_IMAGE_DATA_DIMENSION)) {
501 int zoom, width, height;
502 goffset bytes = 0;
503
504 zoom = floor (100 * eom_scroll_view_get_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
) + 0.5);
505
506 eom_image_get_size (priv->image, &width, &height);
507
508 bytes = eom_image_get_bytes (priv->image);
509
510 if ((width > 0) && (height > 0)) {
511 char *size_string;
512
513 size_string = g_format_size (bytes);
514
515 /* Translators: This is the string displayed in the statusbar
516 * The tokens are from left to right:
517 * - image width
518 * - image height
519 * - image size in bytes
520 * - zoom in percent */
521 str = g_strdup_printf (ngettext("%i × %i pixel %s %i%%",
522 "%i × %i pixels %s %i%%", height),
523 width,
524 height,
525 size_string,
526 zoom);
527
528 g_free (size_string);
529 }
530
531 update_image_pos (window);
532 }
533
534 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
535 priv->image_info_message_cid);
536
537 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
538 priv->image_info_message_cid, str ? str : "");
539
540 g_free (str);
541}
542
543static void
544eom_window_set_message_area (EomWindow *window,
545 GtkWidget *message_area)
546{
547 if (window->priv->message_area == message_area)
548 return;
549
550 if (window->priv->message_area != NULL((void*)0))
551 gtk_widget_destroy (window->priv->message_area);
552
553 window->priv->message_area = message_area;
554
555 if (message_area == NULL((void*)0)) return;
556
557 gtk_box_pack_start (GTK_BOX (window->priv->cbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((window
->priv->cbox)), ((gtk_box_get_type ()))))))
,
558 window->priv->message_area,
559 FALSE(0),
560 FALSE(0),
561 0);
562
563 g_object_add_weak_pointer (G_OBJECT (window->priv->message_area)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
window->priv->message_area)), (((GType) ((20) << (
2))))))))
,
564 (void *) &window->priv->message_area);
565}
566
567static void
568update_action_groups_state (EomWindow *window)
569{
570 EomWindowPrivate *priv;
571 GtkAction *action_collection;
572 GtkAction *action_sidebar;
573 GtkAction *action_fscreen;
574 GtkAction *action_sshow;
575 GtkAction *action_print;
576 gboolean print_disabled = FALSE(0);
577 gboolean show_image_collection = FALSE(0);
578 gint n_images = 0;
579
580 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
581
582 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 582, ((const char*) (__func__
))
);
583
584 priv = window->priv;
585
586 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
587 action_collection =
588 gtk_action_group_get_action (priv->actions_window,
589 "ViewImageCollection");
590
591 action_sidebar =
592 gtk_action_group_get_action (priv->actions_window,
593 "ViewSidebar");
594
595 action_fscreen =
596 gtk_action_group_get_action (priv->actions_image,
597 "ViewFullscreen");
598
599 action_sshow =
600 gtk_action_group_get_action (priv->actions_collection,
601 "ViewSlideshow");
602
603 action_print =
604 gtk_action_group_get_action (priv->actions_image,
605 "ImagePrint");
606 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
607
608 g_assert (action_collection != NULL)do { if (action_collection != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 608, ((const char*) (__func__)), "action_collection != NULL"
); } while (0)
;
609 g_assert (action_sidebar != NULL)do { if (action_sidebar != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 609, ((const char*) (__func__)), "action_sidebar != NULL"
); } while (0)
;
610 g_assert (action_fscreen != NULL)do { if (action_fscreen != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 610, ((const char*) (__func__)), "action_fscreen != NULL"
); } while (0)
;
611 g_assert (action_sshow != NULL)do { if (action_sshow != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 611, ((const char*) (__func__)), "action_sshow != NULL"
); } while (0)
;
612 g_assert (action_print != NULL)do { if (action_print != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 612, ((const char*) (__func__)), "action_print != NULL"
); } while (0)
;
613
614 if (priv->store != NULL((void*)0)) {
615 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
616 }
617
618 if (n_images == 0) {
619 gtk_widget_hide (priv->layout);
620
621 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
622 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
623 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
624 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
625
626 gtk_action_set_sensitive (action_fscreen, FALSE(0));
627 gtk_action_set_sensitive (action_sshow, FALSE(0));
628 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
629
630 /* If there are no images on model, initialization
631 stops here. */
632 if (priv->status == EOM_WINDOW_STATUS_INIT) {
633 priv->status = EOM_WINDOW_STATUS_NORMAL;
634 }
635 } else {
636 if (priv->flags & EOM_STARTUP_DISABLE_COLLECTION) {
637 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", FALSE(0));
638
639 show_image_collection = FALSE(0);
640 } else {
641 show_image_collection =
642 g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection");
643 }
644
645 show_image_collection = show_image_collection &&
646 n_images > 1 &&
647 priv->mode != EOM_WINDOW_MODE_SLIDESHOW;
648
649 gtk_widget_show (priv->layout);
650
651 if (show_image_collection)
652 gtk_widget_show (priv->nav);
653
654 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
655 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_collection)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action_collection)), ((gtk_toggle_action_get_type ()))))
))
,
656 show_image_collection);
657
658 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
659 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
660
661 gtk_action_set_sensitive (action_fscreen, TRUE(!(0)));
662
663 if (n_images == 1) {
664 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
665 gtk_action_set_sensitive (action_collection, FALSE(0));
666 gtk_action_set_sensitive (action_sshow, FALSE(0));
667 } else {
668 gtk_action_group_set_sensitive (priv->actions_collection, TRUE(!(0)));
669 gtk_action_set_sensitive (action_sshow, TRUE(!(0)));
670 }
671 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
672
673 if (show_image_collection)
674 gtk_widget_grab_focus (priv->thumbview);
675 else
676 gtk_widget_grab_focus (priv->view);
677 }
678
679 print_disabled = g_settings_get_boolean (priv->lockdown_settings,
680 EOM_CONF_LOCKDOWN_CAN_PRINT"disable-printing");
681
682 if (print_disabled) {
683 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
684 gtk_action_set_sensitive (action_print, FALSE(0));
685 }
686
687 if (eom_sidebar_is_empty (EOM_SIDEBAR (priv->sidebar)((((EomSidebar*) g_type_check_instance_cast ((GTypeInstance*)
((priv->sidebar)), ((eom_sidebar_get_type()))))))
)) {
688 gtk_action_set_sensitive (action_sidebar, FALSE(0));
689 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
690 gtk_widget_hide (priv->sidebar);
691 }
692}
693
694static void
695update_selection_ui_visibility (EomWindow *window)
696{
697 EomWindowPrivate *priv;
698 GtkAction *wallpaper_action;
699 gint n_selected;
700
701 priv = window->priv;
702
703 n_selected = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
704
705 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
706 wallpaper_action =
707 gtk_action_group_get_action (priv->actions_image,
708 "ImageSetAsWallpaper");
709
710 if (n_selected == 1) {
711 gtk_action_set_sensitive (wallpaper_action, TRUE(!(0)));
712 } else {
713 gtk_action_set_sensitive (wallpaper_action, FALSE(0));
714 }
715 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
716}
717
718static gboolean
719add_file_to_recent_files (GFile *file)
720{
721 gchar *text_uri;
722 GFileInfo *file_info;
723 GtkRecentData *recent_data;
724 static gchar *groups[2] = { EOM_RECENT_FILES_GROUP"Graphics" , NULL((void*)0) };
725
726 if (file == NULL((void*)0)) return FALSE(0);
727
728 /* The password gets stripped here because ~/.recently-used.xbel is
729 * readable by everyone (chmod 644). It also makes the workaround
730 * for the bug with gtk_recent_info_get_uri_display() easier
731 * (see the comment in eom_window_update_recent_files_menu()). */
732 text_uri = g_file_get_uri (file);
733
734 if (text_uri == NULL((void*)0))
735 return FALSE(0);
736
737 file_info = g_file_query_info (file,
738 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
739 0, NULL((void*)0), NULL((void*)0));
740 if (file_info == NULL((void*)0))
741 return FALSE(0);
742
743 recent_data = g_slice_new (GtkRecentData)((GtkRecentData*) g_slice_alloc (sizeof (GtkRecentData)));
744 recent_data->display_name = NULL((void*)0);
745 recent_data->description = NULL((void*)0);
746 recent_data->mime_type = (gchar *) g_file_info_get_content_type (file_info);
747 recent_data->app_name = EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer";
748 recent_data->app_exec = g_strjoin(" ", g_get_prgname (), "%u", NULL((void*)0));
749 recent_data->groups = groups;
750 recent_data->is_private = FALSE(0);
751
752 gtk_recent_manager_add_full (gtk_recent_manager_get_default (),
753 text_uri,
754 recent_data);
755
756 g_free (recent_data->app_exec);
757 g_free (text_uri);
758 g_object_unref (file_info);
759
760 g_slice_free (GtkRecentData, recent_data)do { if (1) g_slice_free1 (sizeof (GtkRecentData), (recent_data
)); else (void) ((GtkRecentData*) 0 == (recent_data)); } while
(0)
;
761
762 return FALSE(0);
763}
764
765static void
766image_thumb_changed_cb (EomImage *image, gpointer data)
767{
768 EomWindow *window;
769 EomWindowPrivate *priv;
770 GdkPixbuf *thumb;
771
772 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
773
774 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
775 priv = window->priv;
776
777 thumb = eom_image_get_thumbnail (image);
778
779 if (thumb != NULL((void*)0)) {
780 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, thumb);
781
782 if (window->priv->properties_dlg != NULL((void*)0)) {
783 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
784 image);
785 }
786
787 g_object_unref (thumb);
788 } else if (!gtk_widget_get_visible (window->priv->nav)) {
789 gint img_pos = eom_list_store_get_pos_by_image (window->priv->store, image);
790 GtkTreePath *path = gtk_tree_path_new_from_indices (img_pos,-1);
791 GtkTreeIter iter;
792
793 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), ((gtk_tree_model_get_type (
)))))))
, &iter, path);
794 eom_list_store_thumbnail_set (window->priv->store, &iter);
795 gtk_tree_path_free (path);
796 }
797}
798
799static void
800file_changed_info_bar_response (GtkInfoBar *info_bar,
801 gint response,
802 EomWindow *window)
803{
804 if (response == GTK_RESPONSE_YES) {
805 eom_window_reload_image (window);
806 }
807
808 window->priv->needs_reload_confirmation = TRUE(!(0));
809
810 eom_window_set_message_area (window, NULL((void*)0));
811}
812static void
813image_file_changed_cb (EomImage *img, EomWindow *window)
814{
815 GtkWidget *info_bar;
816 gchar *text, *markup;
817 GtkWidget *image;
818 GtkWidget *label;
819 GtkWidget *hbox;
820
821 if (window->priv->needs_reload_confirmation == FALSE(0))
822 return;
823
824 if (!eom_image_is_modified (img)) {
825 /* Auto-reload when image is unmodified */
826 eom_window_reload_image (window);
827 return;
828 }
829
830 window->priv->needs_reload_confirmation = FALSE(0);
831
832 info_bar = gtk_info_bar_new_with_buttons (_("_Reload")gettext ("_Reload"),
833 GTK_RESPONSE_YES,
834 C_("MessageArea", "Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
835 GTK_RESPONSE_NO, NULL((void*)0));
836 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((info_bar)), ((gtk_info_bar_get_type()))))))
,
837 GTK_MESSAGE_QUESTION);
838 image = gtk_image_new_from_icon_name ("dialog-question",
839 GTK_ICON_SIZE_DIALOG);
840 label = gtk_label_new (NULL((void*)0));
841
842 /* The newline character is currently necessary due to a problem
843 * with the automatic line break. */
844 text = g_strdup_printf (_("The image \"%s\" has been modified by an external application."gettext ("The image \"%s\" has been modified by an external application."
"\nWould you like to reload it?")
845 "\nWould you like to reload it?")gettext ("The image \"%s\" has been modified by an external application."
"\nWould you like to reload it?")
, eom_image_get_caption (img));
846 markup = g_markup_printf_escaped ("<b>%s</b>", text);
847 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, markup);
848 g_free (text);
849 g_free (markup);
850
851 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
852 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
853 gtk_widget_set_halign (image, GTK_ALIGN_START);
854 gtk_widget_set_valign (image, GTK_ALIGN_END);
855 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
856 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, 0.0);
857 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_info_bar_get_content_area
(((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))))), ((gtk_box_get_type
()))))))
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
858 gtk_widget_show_all (hbox);
859 gtk_widget_show (info_bar);
860
861 eom_window_set_message_area (window, info_bar);
862 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
863 G_CALLBACK (file_changed_info_bar_response), window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
;
864}
865
866static void
867eom_window_display_image (EomWindow *window, EomImage *image)
868{
869 EomWindowPrivate *priv;
870 GFile *file;
871
872 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
873 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
874
875 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 875, ((const char*) (__func__
))
);
876
877 g_assert (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE))do { if (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)) ; else
g_assertion_message_expr ("EOM", "eom-window.c", 877, ((const
char*) (__func__)), "eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)"
); } while (0)
;
878
879 priv = window->priv;
880
881 if (image != NULL((void*)0)) {
882 g_signal_connect (image,g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
883 "thumbnail_changed",g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
884 G_CALLBACK (image_thumb_changed_cb),g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
885 window)g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
886 g_signal_connect (image, "file-changed",g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
887 G_CALLBACK (image_file_changed_cb),g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
888 window)g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
889
890 image_thumb_changed_cb (image, window);
891 }
892
893 priv->needs_reload_confirmation = TRUE(!(0));
894
895 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, image);
896
897 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, eom_image_get_caption (image));
898
899 update_status_bar (window);
900
901 file = eom_image_get_file (image);
902 g_idle_add_full (G_PRIORITY_LOW300,
903 (GSourceFunc) add_file_to_recent_files,
904 file,
905 (GDestroyNotify) g_object_unref);
906
907 eom_window_update_openwith_menu (window, image);
908}
909
910static void
911open_with_launch_application_cb (GtkAction *action, gpointer data) {
912 EomImage *image;
913 GAppInfo *app;
914 GFile *file;
915 GList *files = NULL((void*)0);
916
917 image = EOM_IMAGE (data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_image_get_type ()))))))
;
918 file = eom_image_get_file (image);
919
920 app = g_object_get_data (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "app");
921 files = g_list_append (files, file);
922 g_app_info_launch (app,
923 files,
924 NULL((void*)0), NULL((void*)0));
925
926 g_object_unref (file);
927 g_list_free (files);
928}
929
930static void
931eom_window_update_openwith_menu (EomWindow *window, EomImage *image)
932{
933 gboolean edit_button_active;
934 GAppInfo *editor_app;
935 GFile *file;
936 GFileInfo *file_info;
937 GList *iter;
938 gchar *label, *tip;
939 const gchar *mime_type;
940 GtkAction *action;
941 EomWindowPrivate *priv;
942 GList *apps;
943 guint action_id = 0;
944 GIcon *app_icon;
945 char *path;
946 GtkWidget *menuitem;
947
948 priv = window->priv;
949
950 edit_button_active = FALSE(0);
951 editor_app = get_appinfo_for_editor (window);
952
953 file = eom_image_get_file (image);
954 file_info = g_file_query_info (file,
955 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
956 0, NULL((void*)0), NULL((void*)0));
957
958 if (file_info == NULL((void*)0))
959 return;
960 else {
961 mime_type = g_file_info_get_content_type (file_info);
962 }
963
964 if (priv->open_with_menu_id != 0) {
965 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->open_with_menu_id);
966 priv->open_with_menu_id = 0;
967 }
968
969 if (priv->actions_open_with != NULL((void*)0)) {
970 gtk_ui_manager_remove_action_group (priv->ui_mgr, priv->actions_open_with);
971 g_object_unref (priv->actions_open_with);
972 priv->actions_open_with = NULL((void*)0);
973 }
974
975 if (mime_type == NULL((void*)0)) {
976 g_object_unref (file_info);
977 return;
978 }
979
980 apps = g_app_info_get_all_for_type (mime_type);
981
982 g_object_unref (file_info);
983
984 if (!apps)
985 return;
986
987 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
988 priv->actions_open_with = gtk_action_group_new ("OpenWithActions");
989 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
990 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_open_with, -1);
991
992 priv->open_with_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
993
994 for (iter = apps; iter; iter = iter->next) {
995 GAppInfo *app = iter->data;
996 gchar name[64];
997
998 if (editor_app != NULL((void*)0) && g_app_info_equal (editor_app, app)) {
999 edit_button_active = TRUE(!(0));
1000 }
1001
1002 /* Do not include eom itself */
1003 if (g_ascii_strcasecmp (g_app_info_get_executable (app),
1004 g_get_prgname ()) == 0) {
1005 g_object_unref (app);
1006 continue;
1007 }
1008
1009 g_snprintf (name, sizeof (name), "OpenWith%u", action_id++);
1010
1011 label = g_strdup (g_app_info_get_name (app));
1012 tip = g_strdup_printf (_("Use \"%s\" to open the selected image")gettext ("Use \"%s\" to open the selected image"), g_app_info_get_name (app));
1013
1014 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1015 action = gtk_action_new (name, label, tip, NULL((void*)0));
1016 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1017
1018 app_icon = g_app_info_get_icon (app);
1019 if (G_LIKELY (app_icon != NULL)(app_icon != ((void*)0))) {
1020 g_object_ref (app_icon);
1021 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1022 gtk_action_set_gicon (action, app_icon);
1023 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1024 g_object_unref (app_icon);
1025 }
1026
1027 g_free (label);
1028 g_free (tip);
1029
1030 g_object_set_data_full (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "app", app,
1031 (GDestroyNotify) g_object_unref);
1032
1033 g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1034 "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1035 G_CALLBACK (open_with_launch_application_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1036 image)g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
;
1037
1038 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1039 gtk_action_group_add_action (priv->actions_open_with, action);
1040 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1041 g_object_unref (action);
1042
1043 gtk_ui_manager_add_ui (priv->ui_mgr,
1044 priv->open_with_menu_id,
1045 "/MainMenu/Image/ImageOpenWith/Applications Placeholder",
1046 name,
1047 name,
1048 GTK_UI_MANAGER_MENUITEM,
1049 FALSE(0));
1050
1051 gtk_ui_manager_add_ui (priv->ui_mgr,
1052 priv->open_with_menu_id,
1053 "/ThumbnailPopup/ImageOpenWith/Applications Placeholder",
1054 name,
1055 name,
1056 GTK_UI_MANAGER_MENUITEM,
1057 FALSE(0));
1058 gtk_ui_manager_add_ui (priv->ui_mgr,
1059 priv->open_with_menu_id,
1060 "/ViewPopup/ImageOpenWith/Applications Placeholder",
1061 name,
1062 name,
1063 GTK_UI_MANAGER_MENUITEM,
1064 FALSE(0));
1065
1066 path = g_strdup_printf ("/MainMenu/Image/ImageOpenWith/Applications Placeholder/%s", name);
1067
1068 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1069
1070 /* Only force displaying the icon if it is an application icon */
1071 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, app_icon != NULL((void*)0));
1072
1073 g_free (path);
1074
1075 path = g_strdup_printf ("/ThumbnailPopup/ImageOpenWith/Applications Placeholder/%s", name);
1076
1077 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1078
1079 /* Only force displaying the icon if it is an application icon */
1080 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, app_icon != NULL((void*)0));
1081
1082 g_free (path);
1083
1084 path = g_strdup_printf ("/ViewPopup/ImageOpenWith/Applications Placeholder/%s", name);
1085
1086 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1087
1088 /* Only force displaying the icon if it is an application icon */
1089 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, app_icon != NULL((void*)0));
1090
1091 g_free (path);
1092 }
1093
1094 g_list_free (apps);
1095
1096 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1097 action = gtk_action_group_get_action (window->priv->actions_image,
1098 "OpenEditor");
1099 if (action != NULL((void*)0)) {
1100 gtk_action_set_sensitive (action, edit_button_active);
1101 }
1102 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1103}
1104
1105static void
1106eom_window_clear_load_job (EomWindow *window)
1107{
1108 EomWindowPrivate *priv = window->priv;
1109
1110 if (priv->load_job != NULL((void*)0)) {
1111 if (!priv->load_job->finished)
1112 eom_job_queue_remove_job (priv->load_job);
1113
1114 g_signal_handlers_disconnect_by_func (priv->load_job,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_progress_cb), (window))
1115 eom_job_progress_cb,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_progress_cb), (window))
1116 window)g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_progress_cb), (window))
;
1117
1118 g_signal_handlers_disconnect_by_func (priv->load_job,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_load_cb), (window))
1119 eom_job_load_cb,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_load_cb), (window))
1120 window)g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_load_cb), (window))
;
1121
1122 eom_image_cancel_load (EOM_JOB_LOAD (priv->load_job)((((EomJobLoad*) g_type_check_instance_cast ((GTypeInstance*)
((priv->load_job)), ((eom_job_load_get_type()))))))
->image);
1123
1124 g_object_unref (priv->load_job);
1125 priv->load_job = NULL((void*)0);
1126
1127 /* Hide statusbar */
1128 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0);
1129 }
1130}
1131
1132static void
1133eom_job_progress_cb (EomJobLoad *job, float progress, gpointer user_data)
1134{
1135 EomWindow *window;
1136
1137 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
1138
1139 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1140
1141 eom_statusbar_set_progress (EOM_STATUSBAR (window->priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((eom_statusbar_get_type
()))))))
,
1142 progress);
1143}
1144
1145static void
1146eom_job_save_progress_cb (EomJobSave *job, float progress, gpointer user_data)
1147{
1148 EomWindowPrivate *priv;
1149 EomWindow *window;
1150
1151 static EomImage *image = NULL((void*)0);
1152
1153 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
1154
1155 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1156 priv = window->priv;
1157
1158 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
,
1159 progress);
1160
1161 if (image != job->current_image) {
1162 gchar *str_image, *status_message;
1163 guint n_images;
1164
1165 image = job->current_image;
1166
1167 n_images = g_list_length (job->images);
1168
1169 str_image = eom_image_get_uri_for_display (image);
1170
1171 /* Translators: This string is displayed in the statusbar
1172 * while saving images. The tokens are from left to right:
1173 * - the original filename
1174 * - the current image's position in the queue
1175 * - the total number of images queued for saving */
1176 status_message = g_strdup_printf (_("Saving image \"%s\" (%u/%u)")gettext ("Saving image \"%s\" (%u/%u)"),
1177 str_image,
1178 job->current_pos + 1,
1179 n_images);
1180 g_free (str_image);
1181
1182 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1183 priv->image_info_message_cid);
1184
1185 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1186 priv->image_info_message_cid,
1187 status_message);
1188
1189 g_free (status_message);
1190 }
1191
1192 if (progress == 1.0)
1193 image = NULL((void*)0);
1194}
1195
1196static void
1197eom_window_obtain_desired_size (EomImage *image,
1198 gint width,
1199 gint height,
1200 EomWindow *window)
1201{
1202 GdkScreen *screen;
1203 GdkDisplay *display;
1204 GdkRectangle monitor;
1205 GtkAllocation allocation;
1206 gint final_width, final_height;
1207 gint screen_width, screen_height;
1208 gint window_width, window_height;
1209 gint img_width, img_height;
1210 gint view_width, view_height;
1211 gint deco_width, deco_height;
1212
1213 update_action_groups_state (window);
1214
1215 img_width = width;
1216 img_height = height;
1217
1218 if (!gtk_widget_get_realized (window->priv->view)) {
1219 gtk_widget_realize (window->priv->view);
1220 }
1221
1222 gtk_widget_get_allocation (window->priv->view, &allocation);
1223 view_width = allocation.width;
1224 view_height = allocation.height;
1225
1226 if (!gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
)) {
1227 gtk_widget_realize (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
1228 }
1229
1230 gtk_widget_get_allocation (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
, &allocation);
1231 window_width = allocation.width;
1232 window_height = allocation.height;
1233
1234 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
1235 display = gdk_screen_get_display (screen);
1236
1237 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1238 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
)),
1239 &monitor);
1240
1241 screen_width = monitor.width;
1242 screen_height = monitor.height;
1243
1244 deco_width = window_width - view_width;
1245 deco_height = window_height - view_height;
1246
1247 if (img_width > 0 && img_height > 0) {
1248 if ((img_width + deco_width > screen_width) ||
1249 (img_height + deco_height > screen_height))
1250 {
1251 double factor;
1252
1253 if (img_width > img_height) {
1254 factor = (screen_width * 0.75 - deco_width) / (double) img_width;
1255 } else {
1256 factor = (screen_height * 0.75 - deco_height) / (double) img_height;
1257 }
1258
1259 img_width = img_width * factor;
1260 img_height = img_height * factor;
1261 }
1262 }
1263
1264 final_width = MAX (EOM_WINDOW_MIN_WIDTH, img_width + deco_width)(((440) > (img_width + deco_width)) ? (440) : (img_width +
deco_width))
;
1265 final_height = MAX (EOM_WINDOW_MIN_HEIGHT, img_height + deco_height)(((350) > (img_height + deco_height)) ? (350) : (img_height
+ deco_height))
;
1266
1267 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1267, ((const char*) (__func__
))
, "Setting window size: %d x %d", final_width, final_height);
1268
1269 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, final_width, final_height);
1270
1271 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1272}
1273
1274static void
1275eom_window_error_message_area_response (GtkInfoBar *message_area,
1276 gint response_id,
1277 EomWindow *window)
1278{
1279 if (response_id != GTK_RESPONSE_OK) {
1280 eom_window_set_message_area (window, NULL((void*)0));
1281
1282 return;
1283 }
1284
1285 /* Trigger loading for current image again */
1286 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
1287 EOM_THUMB_VIEW_SELECT_CURRENT);
1288}
1289
1290static void
1291eom_job_load_cb (EomJobLoad *job, gpointer data)
1292{
1293 EomWindow *window;
1294 EomWindowPrivate *priv;
1295 GtkAction *action_undo, *action_save;
1296
1297 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
1298
1299 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1299, ((const char*) (__func__
))
);
1300
1301 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1302 priv = window->priv;
1303
1304 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0.0);
1305
1306 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
1307 priv->image_info_message_cid);
1308
1309 if (priv->image != NULL((void*)0)) {
1310 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
1311 image_thumb_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
1312 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
;
1313 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
1314 image_file_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
1315 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
;
1316
1317 g_object_unref (priv->image);
1318 }
1319
1320 priv->image = g_object_ref (job->image);
1321
1322 if (EOM_JOB (job)((((EomJob*) g_type_check_instance_cast ((GTypeInstance*) ((job
)), ((eom_job_get_type()))))))
->error == NULL((void*)0)) {
1323#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
1324 eom_image_apply_display_profile (job->image,
1325 priv->display_profile);
1326#endif
1327
1328 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1329 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
1330 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1331
1332 eom_window_display_image (window, job->image);
1333 } else {
1334 GtkWidget *message_area;
1335
1336 message_area = eom_image_load_error_message_area_new (
1337 eom_image_get_caption (job->image),
1338 EOM_JOB (job)((((EomJob*) g_type_check_instance_cast ((GTypeInstance*) ((job
)), ((eom_job_get_type()))))))
->error);
1339
1340 g_signal_connect (message_area,g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1341 "response",g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1342 G_CALLBACK (eom_window_error_message_area_response),g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1343 window)g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
;
1344
1345 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, NULL((void*)0));
1346 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
1347 eom_image_get_caption (job->image));
1348
1349 eom_window_set_message_area (window, message_area);
1350
1351 gtk_info_bar_set_default_response (GTK_INFO_BAR (message_area)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((message_area)), ((gtk_info_bar_get_type()))))))
,
1352 GTK_RESPONSE_CANCEL);
1353
1354 gtk_widget_show (message_area);
1355
1356 update_status_bar (window);
1357
1358 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
1359
1360 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1361 update_action_groups_state (window);
1362
1363 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1364 }
1365
1366 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1367 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
1368 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1369 }
1370
1371 eom_window_clear_load_job (window);
1372
1373 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1374 window->priv->status = EOM_WINDOW_STATUS_NORMAL;
1375
1376 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
1377 (job->image,g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
1378 G_CALLBACK (eom_window_obtain_desired_size),g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
1379 window)g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
;
1380 }
1381
1382 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1383 action_save = gtk_action_group_get_action (priv->actions_image, "ImageSave");
1384 action_undo = gtk_action_group_get_action (priv->actions_image, "EditUndo");
1385
1386 /* Set Save and Undo sensitive according to image state.
1387 * Respect lockdown in case of Save.*/
1388 gtk_action_set_sensitive (action_save, (!priv->save_disabled && eom_image_is_modified (job->image)));
1389 gtk_action_set_sensitive (action_undo, eom_image_is_modified (job->image));
1390 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1391
1392 g_object_unref (job->image);
1393}
1394
1395static void
1396eom_window_clear_transform_job (EomWindow *window)
1397{
1398 EomWindowPrivate *priv = window->priv;
1399
1400 if (priv->transform_job != NULL((void*)0)) {
1401 if (!priv->transform_job->finished)
1402 eom_job_queue_remove_job (priv->transform_job);
1403
1404 g_signal_handlers_disconnect_by_func (priv->transform_job,g_signal_handlers_disconnect_matched ((priv->transform_job
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (eom_job_transform_cb), (window))
1405 eom_job_transform_cb,g_signal_handlers_disconnect_matched ((priv->transform_job
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (eom_job_transform_cb), (window))
1406 window)g_signal_handlers_disconnect_matched ((priv->transform_job
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (eom_job_transform_cb), (window))
;
1407 g_object_unref (priv->transform_job);
1408 priv->transform_job = NULL((void*)0);
1409 }
1410}
1411
1412static void
1413eom_job_transform_cb (EomJobTransform *job, gpointer data)
1414{
1415 EomWindow *window;
1416 GtkAction *action_undo, *action_save;
1417 EomImage *image;
1418
1419 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
1420
1421 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1422
1423 eom_window_clear_transform_job (window);
1424
1425 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1426 action_undo =
1427 gtk_action_group_get_action (window->priv->actions_image, "EditUndo");
1428 action_save =
1429 gtk_action_group_get_action (window->priv->actions_image, "ImageSave");
1430
1431 image = eom_window_get_image (window);
1432
1433 gtk_action_set_sensitive (action_undo, eom_image_is_modified (image));
1434
1435 if (!window->priv->save_disabled)
1436 {
1437 gtk_action_set_sensitive (action_save, eom_image_is_modified (image));
1438 }
1439 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1440}
1441
1442static void
1443apply_transformation (EomWindow *window, EomTransform *trans)
1444{
1445 EomWindowPrivate *priv;
1446 GList *images;
1447
1448 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
1449
1450 priv = window->priv;
1451
1452 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1453
1454 eom_window_clear_transform_job (window);
1455
1456 priv->transform_job = eom_job_transform_new (images, trans);
1457
1458 g_signal_connect (priv->transform_job,g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1459 "finished",g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1460 G_CALLBACK (eom_job_transform_cb),g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1461 window)g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
1462
1463 g_signal_connect (priv->transform_job,g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1464 "progress",g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1465 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1466 window)g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
1467
1468 eom_job_queue_add_job (priv->transform_job);
1469}
1470
1471static void
1472handle_image_selection_changed_cb (EomThumbView *thumbview, EomWindow *window)
1473{
1474 EomWindowPrivate *priv;
1475 EomImage *image;
1476 gchar *status_message;
1477 gchar *str_image;
1478
1479 priv = window->priv;
1480
1481 if (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0) {
1482 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
1483 g_get_application_name());
1484 gtk_statusbar_remove_all (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1485 priv->image_info_message_cid);
1486 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
1487 NULL((void*)0));
1488 }
1489
1490 if (eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
) == 0)
1491 return;
1492
1493 update_selection_ui_visibility (window);
1494
1495 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1496
1497 g_assert (EOM_IS_IMAGE (image))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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_assertion_message_expr ("EOM", "eom-window.c", 1497, ((const
char*) (__func__)), "EOM_IS_IMAGE (image)"); } while (0)
;
1498
1499 eom_window_clear_load_job (window);
1500
1501 eom_window_set_message_area (window, NULL((void*)0));
1502
1503 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1504 priv->image_info_message_cid);
1505
1506 if (image == priv->image) {
1507 update_status_bar (window);
1508 return;
1509 }
1510
1511 if (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)) {
1512 if (priv->image != NULL((void*)0))
1513 g_object_unref (priv->image);
1514
1515 priv->image = image;
1516 eom_window_display_image (window, image);
1517 return;
1518 }
1519
1520 if (priv->status == EOM_WINDOW_STATUS_INIT) {
1521 g_signal_connect (image,g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1522 "size-prepared",g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1523 G_CALLBACK (eom_window_obtain_desired_size),g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1524 window)g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
;
1525 }
1526
1527 priv->load_job = eom_job_load_new (image, EOM_IMAGE_DATA_ALL(EOM_IMAGE_DATA_IMAGE | EOM_IMAGE_DATA_DIMENSION | EOM_IMAGE_DATA_EXIF
| EOM_IMAGE_DATA_XMP)
);
1528
1529 g_signal_connect (priv->load_job,g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1530 "finished",g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1531 G_CALLBACK (eom_job_load_cb),g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1532 window)g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1533
1534 g_signal_connect (priv->load_job,g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1535 "progress",g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1536 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1537 window)g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1538
1539 eom_job_queue_add_job (priv->load_job);
1540
1541 str_image = eom_image_get_uri_for_display (image);
1542
1543 status_message = g_strdup_printf (_("Opening image \"%s\"")gettext ("Opening image \"%s\""),
1544 str_image);
1545
1546 g_free (str_image);
1547
1548 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1549 priv->image_info_message_cid, status_message);
1550
1551 g_free (status_message);
1552}
1553
1554static void
1555view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
1556{
1557 EomWindow *window;
1558 GtkAction *action_zoom_in;
1559 GtkAction *action_zoom_out;
1560
1561 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
1562
1563 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1564
1565 update_status_bar (window);
1566
1567 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1568 action_zoom_in =
1569 gtk_action_group_get_action (window->priv->actions_image,
1570 "ViewZoomIn");
1571
1572 action_zoom_out =
1573 gtk_action_group_get_action (window->priv->actions_image,
1574 "ViewZoomOut");
1575
1576 gtk_action_set_sensitive (action_zoom_in,
1577 !eom_scroll_view_get_zoom_is_max (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1578 gtk_action_set_sensitive (action_zoom_out,
1579 !eom_scroll_view_get_zoom_is_min (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1580 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1581}
1582
1583static void
1584eom_window_open_recent_cb (GtkAction *action, EomWindow *window)
1585{
1586 GtkRecentInfo *info;
1587 const gchar *uri;
1588 GSList *list = NULL((void*)0);
1589
1590 info = g_object_get_data (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info");
1591 g_return_if_fail (info != NULL)do { if ((info != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "info != NULL"); return;
} } while (0)
;
1592
1593 uri = gtk_recent_info_get_uri (info);
1594 list = g_slist_prepend (list, g_strdup (uri));
1595
1596 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1597 list,
1598 GDK_CURRENT_TIME0L,
1599 0,
1600 NULL((void*)0));
1601
1602 g_slist_free_full (list, g_free);
1603}
1604
1605static void
1606file_open_dialog_response_cb (GtkWidget *chooser,
1607 gint response_id,
1608 EomWindow *ev_window)
1609{
1610 if (response_id == GTK_RESPONSE_OK) {
1611 GSList *uris;
1612
1613 uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_file_chooser_get_type ()))))))
);
1614
1615 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1616 uris,
1617 GDK_CURRENT_TIME0L,
1618 0,
1619 NULL((void*)0));
1620
1621 g_slist_free_full (uris, g_free);
1622 }
1623
1624 gtk_widget_destroy (chooser);
1625}
1626
1627static void
1628eom_window_update_fullscreen_action (EomWindow *window)
1629{
1630 GtkAction *action;
1631
1632 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1633 action = gtk_action_group_get_action (window->priv->actions_image,
1634 "ViewFullscreen");
1635
1636 g_signal_handlers_block_by_funcg_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_fullscreen))), (window))
1637 (action, G_CALLBACK (eom_window_cmd_fullscreen), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_fullscreen))), (window))
;
1638
1639 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1640 window->priv->mode == EOM_WINDOW_MODE_FULLSCREEN);
1641 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1642
1643 g_signal_handlers_unblock_by_funcg_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_fullscreen))), (window))
1644 (action, G_CALLBACK (eom_window_cmd_fullscreen), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_fullscreen))), (window))
;
1645}
1646
1647static void
1648eom_window_update_slideshow_action (EomWindow *window)
1649{
1650 GtkAction *action;
1651
1652 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1653 action = gtk_action_group_get_action (window->priv->actions_collection,
1654 "ViewSlideshow");
1655
1656 g_signal_handlers_block_by_funcg_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_slideshow))), (window))
1657 (action, G_CALLBACK (eom_window_cmd_slideshow), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_slideshow))), (window))
;
1658
1659 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1660 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
1661 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1662
1663 g_signal_handlers_unblock_by_funcg_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_slideshow))), (window))
1664 (action, G_CALLBACK (eom_window_cmd_slideshow), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_slideshow))), (window))
;
1665}
1666
1667static void
1668eom_window_update_pause_slideshow_action (EomWindow *window)
1669{
1670 GtkAction *action;
1671
1672 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1673 action = gtk_action_group_get_action (window->priv->actions_image,
1674 "PauseSlideshow");
1675
1676 g_signal_handlers_block_by_funcg_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_pause_slideshow))), (window)
)
1677 (action, G_CALLBACK (eom_window_cmd_pause_slideshow), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_pause_slideshow))), (window)
)
;
1678
1679 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1680 window->priv->mode != EOM_WINDOW_MODE_SLIDESHOW);
1681 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1682
1683 g_signal_handlers_unblock_by_funcg_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_pause_slideshow))), (window
))
1684 (action, G_CALLBACK (eom_window_cmd_pause_slideshow), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_pause_slideshow))), (window
))
;
1685}
1686
1687static void
1688eom_window_update_fullscreen_popup (EomWindow *window)
1689{
1690 GtkWidget *popup = window->priv->fullscreen_popup;
1691 GdkRectangle screen_rect;
1692 GdkScreen *screen;
1693 GdkDisplay *display;
1694
1695 g_return_if_fail (popup != NULL)do { if ((popup != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "popup != NULL"); return
; } } while (0)
;
1696
1697 if (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
) == NULL((void*)0)) return;
1698
1699 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
1700 display = gdk_screen_get_display (screen);
1701
1702 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1703 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
)),
1704 &screen_rect);
1705
1706 gtk_widget_set_size_request (popup,
1707 screen_rect.width,
1708 -1);
1709
1710 gtk_window_move (GTK_WINDOW (popup)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(popup)), ((gtk_window_get_type ()))))))
, screen_rect.x, screen_rect.y);
1711}
1712
1713static void
1714screen_size_changed_cb (GdkScreen *screen, EomWindow *window)
1715{
1716 eom_window_update_fullscreen_popup (window);
1717}
1718
1719static gboolean
1720fullscreen_timeout_cb (gpointer data)
1721{
1722 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1723
1724 gtk_widget_hide (window->priv->fullscreen_popup);
1725
1726 eom_scroll_view_hide_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1727
1728 fullscreen_clear_timeout (window);
1729
1730 return FALSE(0);
1731}
1732
1733static gboolean
1734slideshow_is_loop_end (EomWindow *window)
1735{
1736 EomWindowPrivate *priv = window->priv;
1737 EomImage *image = NULL((void*)0);
1738 gint pos;
1739
1740 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1741
1742 pos = eom_list_store_get_pos_by_image (priv->store, image);
1743
1744 return (pos == (eom_list_store_length (priv->store) - 1));
1745}
1746
1747static gboolean
1748slideshow_switch_cb (gpointer data)
1749{
1750 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1751 EomWindowPrivate *priv = window->priv;
1752
1753 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1753, ((const char*) (__func__
))
);
1754
1755 if (priv->slideshow_random) {
1756 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1757 EOM_THUMB_VIEW_SELECT_RANDOM);
1758 return TRUE(!(0));
1759 }
1760
1761 if (!priv->slideshow_loop && slideshow_is_loop_end (window)) {
1762 eom_window_stop_fullscreen (window, TRUE(!(0)));
1763 return FALSE(0);
1764 }
1765
1766 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1767 EOM_THUMB_VIEW_SELECT_RIGHT);
1768
1769 return TRUE(!(0));
1770}
1771
1772static void
1773fullscreen_clear_timeout (EomWindow *window)
1774{
1775 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1775, ((const char*) (__func__
))
);
1776
1777 if (window->priv->fullscreen_timeout_source != NULL((void*)0)) {
1778 g_source_unref (window->priv->fullscreen_timeout_source);
1779 g_source_destroy (window->priv->fullscreen_timeout_source);
1780 }
1781
1782 window->priv->fullscreen_timeout_source = NULL((void*)0);
1783}
1784
1785static void
1786fullscreen_set_timeout (EomWindow *window)
1787{
1788 GSource *source;
1789
1790 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1790, ((const char*) (__func__
))
);
1791
1792 fullscreen_clear_timeout (window);
1793
1794 source = g_timeout_source_new (EOM_WINDOW_FULLSCREEN_TIMEOUT5 * 1000);
1795 g_source_set_callback (source, fullscreen_timeout_cb, window, NULL((void*)0));
1796
1797 g_source_attach (source, NULL((void*)0));
1798
1799 window->priv->fullscreen_timeout_source = source;
1800
1801 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1802}
1803
1804static void
1805slideshow_clear_timeout (EomWindow *window)
1806{
1807 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1807, ((const char*) (__func__
))
);
1808
1809 if (window->priv->slideshow_switch_source != NULL((void*)0)) {
1810 g_source_unref (window->priv->slideshow_switch_source);
1811 g_source_destroy (window->priv->slideshow_switch_source);
1812 }
1813
1814 window->priv->slideshow_switch_source = NULL((void*)0);
1815}
1816
1817static void
1818slideshow_set_timeout (EomWindow *window)
1819{
1820 GSource *source;
1821
1822 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1822, ((const char*) (__func__
))
);
1823
1824 slideshow_clear_timeout (window);
1825
1826 if (window->priv->slideshow_switch_timeout <= 0)
1827 return;
1828
1829 source = g_timeout_source_new (window->priv->slideshow_switch_timeout * 1000);
1830 g_source_set_callback (source, slideshow_switch_cb, window, NULL((void*)0));
1831
1832 g_source_attach (source, NULL((void*)0));
1833
1834 window->priv->slideshow_switch_source = source;
1835}
1836
1837static void
1838show_fullscreen_popup (EomWindow *window)
1839{
1840 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1840, ((const char*) (__func__
))
);
1841
1842 if (!gtk_widget_get_visible (window->priv->fullscreen_popup)) {
1843 gtk_widget_show_all (GTK_WIDGET (window->priv->fullscreen_popup)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window->priv->fullscreen_popup)), ((gtk_widget_get_type
()))))))
);
1844 }
1845
1846 fullscreen_set_timeout (window);
1847}
1848
1849static gboolean
1850fullscreen_motion_notify_cb (GtkWidget *widget,
1851 GdkEventMotion *event,
1852 gpointer user_data)
1853{
1854 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1855
1856 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1856, ((const char*) (__func__
))
);
1857
1858 if (event->y < EOM_WINDOW_FULLSCREEN_POPUP_THRESHOLD5) {
1859 show_fullscreen_popup (window);
1860 } else {
1861 fullscreen_set_timeout (window);
1862 }
1863
1864 return FALSE(0);
1865}
1866
1867static gboolean
1868fullscreen_leave_notify_cb (GtkWidget *widget,
1869 GdkEventCrossing *event,
1870 gpointer user_data)
1871{
1872 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1873
1874 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1874, ((const char*) (__func__
))
);
1875
1876 fullscreen_clear_timeout (window);
1877
1878 return FALSE(0);
1879}
1880
1881static void
1882exit_fullscreen_button_clicked_cb (GtkWidget *button, EomWindow *window)
1883{
1884 GtkAction *action;
1885
1886 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1886, ((const char*) (__func__
))
);
1887
1888 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1889 if (window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
1890 action = gtk_action_group_get_action (window->priv->actions_collection,
1891 "ViewSlideshow");
1892 } else {
1893 action = gtk_action_group_get_action (window->priv->actions_image,
1894 "ViewFullscreen");
1895 }
1896 g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "action != NULL"); return
; } } while (0)
;
1897
1898 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, FALSE(0));
1899 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1900}
1901
1902static GtkWidget *
1903eom_window_get_exit_fullscreen_button (EomWindow *window)
1904{
1905 GtkWidget *button;
1906
1907 button = gtk_button_new_with_mnemonic (_("Leave Fullscreen")gettext ("Leave Fullscreen"));
1908 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) g_type_check_instance_cast ((GTypeInstance*) (
(button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("view-restore", GTK_ICON_SIZE_BUTTON));
1909
1910 g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1911 G_CALLBACK (exit_fullscreen_button_clicked_cb),g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1912 window)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
1913
1914 return button;
1915}
1916
1917static GtkWidget *
1918eom_window_create_fullscreen_popup (EomWindow *window)
1919{
1920 GtkWidget *popup;
1921 GtkWidget *hbox;
1922 GtkWidget *button;
1923 GtkWidget *toolbar;
1924 GdkScreen *screen;
1925
1926 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1926, ((const char*) (__func__
))
);
1927
1928 popup = gtk_window_new (GTK_WINDOW_POPUP);
1929
1930 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1931 gtk_container_add (GTK_CONTAINER (popup)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_container_get_type ()))))))
, hbox);
1932
1933 toolbar = gtk_ui_manager_get_widget (window->priv->ui_mgr,
1934 "/FullscreenToolbar");
1935 g_assert (GTK_IS_WIDGET (toolbar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); 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_assertion_message_expr ("EOM", "eom-window.c", 1935, ((const
char*) (__func__)), "GTK_IS_WIDGET (toolbar)"); } while (0)
;
1936 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar)((((GtkToolbar*) g_type_check_instance_cast ((GTypeInstance*)
((toolbar)), ((gtk_toolbar_get_type ()))))))
, GTK_TOOLBAR_ICONS);
1937 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, toolbar, TRUE(!(0)), TRUE(!(0)), 0);
1938
1939 button = eom_window_get_exit_fullscreen_button (window);
1940 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, button, FALSE(0), FALSE(0), 0);
1941
1942 gtk_window_set_resizable (GTK_WINDOW (popup)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(popup)), ((gtk_window_get_type ()))))))
, FALSE(0));
1943
1944 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
1945
1946 g_signal_connect_object (screen, "size-changed",
1947 G_CALLBACK (screen_size_changed_cb)((GCallback) (screen_size_changed_cb)),
1948 window, 0);
1949
1950 g_signal_connect (popup,g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1951 "enter-notify-event",g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1952 G_CALLBACK (fullscreen_leave_notify_cb),g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1953 window)g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1954
1955 gtk_window_set_screen (GTK_WINDOW (popup)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(popup)), ((gtk_window_get_type ()))))))
, screen);
1956
1957 return popup;
1958}
1959
1960static void
1961update_ui_visibility (EomWindow *window)
1962{
1963 EomWindowPrivate *priv;
1964
1965 GtkAction *action;
1966 GtkWidget *menubar;
1967
1968 gboolean fullscreen_mode, visible;
1969
1970 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
1971
1972 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1972, ((const char*) (__func__
))
);
1973
1974 priv = window->priv;
1975
1976 fullscreen_mode = priv->mode == EOM_WINDOW_MODE_FULLSCREEN ||
1977 priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
1978
1979 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
1980 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 1980, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
1981
1982 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_TOOLBAR"toolbar");
1983 visible = visible && !fullscreen_mode;
1984
1985 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/ToolbarToggle");
1986 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 1986, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
1987 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1988 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
1989 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1990 g_object_set (G_OBJECT (priv->toolbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->toolbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
1991
1992 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_STATUSBAR"statusbar");
1993 visible = visible && !fullscreen_mode;
1994
1995 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/StatusbarToggle");
1996 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 1996, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
1997 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1998 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
1999 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2000 g_object_set (G_OBJECT (priv->statusbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->statusbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2001
2002 if (priv->status != EOM_WINDOW_STATUS_INIT) {
2003 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection");
2004 visible = visible && priv->mode != EOM_WINDOW_MODE_SLIDESHOW;
2005 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/ImageCollectionToggle");
2006 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2006, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
2007 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2008 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
2009 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2010 if (visible) {
2011 gtk_widget_show (priv->nav);
2012 } else {
2013 gtk_widget_hide (priv->nav);
2014 }
2015 }
2016
2017 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_SIDEBAR"sidebar");
2018 visible = visible && !fullscreen_mode;
2019 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/SidebarToggle");
2020 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2020, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
2021 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2022 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
2023 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2024 if (visible) {
2025 gtk_widget_show (priv->sidebar);
2026 } else {
2027 gtk_widget_hide (priv->sidebar);
2028 }
2029
2030 if (priv->fullscreen_popup != NULL((void*)0)) {
2031 gtk_widget_hide (priv->fullscreen_popup);
2032 }
2033}
2034
2035static void
2036eom_window_inhibit_screensaver (EomWindow *window)
2037{
2038 EomWindowPrivate *priv = window->priv;
2039
2040 g_return_if_fail (priv->fullscreen_idle_inhibit_cookie == 0)do { if ((priv->fullscreen_idle_inhibit_cookie == 0)) { } else
{ g_return_if_fail_warning ("EOM", ((const char*) (__func__)
), "priv->fullscreen_idle_inhibit_cookie == 0"); return; }
} while (0)
;
2041
2042 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2042, ((const char*) (__func__
))
);
2043
2044 window->priv->fullscreen_idle_inhibit_cookie =
2045 gtk_application_inhibit (GTK_APPLICATION (EOM_APP)((((GtkApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
,
2046 GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2047 GTK_APPLICATION_INHIBIT_IDLE,
2048 _("Viewing a slideshow")gettext ("Viewing a slideshow"));
2049}
2050
2051static void
2052eom_window_uninhibit_screensaver (EomWindow *window)
2053{
2054 EomWindowPrivate *priv = window->priv;
2055
2056 if (G_UNLIKELY (priv->fullscreen_idle_inhibit_cookie == 0)(priv->fullscreen_idle_inhibit_cookie == 0))
2057 return;
2058
2059 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2059, ((const char*) (__func__
))
);
2060
2061 gtk_application_uninhibit (GTK_APPLICATION (EOM_APP)((((GtkApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
,
2062 priv->fullscreen_idle_inhibit_cookie);
2063 priv->fullscreen_idle_inhibit_cookie = 0;
2064}
2065
2066static void
2067eom_window_run_fullscreen (EomWindow *window, gboolean slideshow)
2068{
2069 static const GdkRGBA black = { 0., 0., 0., 1.};
2070
2071 EomWindowPrivate *priv;
2072 GtkWidget *menubar;
2073 gboolean upscale;
2074
2075 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2075, ((const char*) (__func__
))
);
2076
2077 priv = window->priv;
2078
2079 if (slideshow) {
2080 priv->mode = EOM_WINDOW_MODE_SLIDESHOW;
2081 } else {
2082 /* Stop the timer if we come from slideshowing */
2083 if (priv->mode == EOM_WINDOW_MODE_SLIDESHOW)
2084 slideshow_clear_timeout (window);
2085
2086 priv->mode = EOM_WINDOW_MODE_FULLSCREEN;
2087 }
2088
2089 if (window->priv->fullscreen_popup == NULL((void*)0))
2090 priv->fullscreen_popup
2091 = eom_window_create_fullscreen_popup (window);
2092
2093 update_ui_visibility (window);
2094
2095 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
2096 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 2096, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
2097 gtk_widget_hide (menubar);
2098
2099 g_signal_connect (priv->view,g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2100 "motion-notify-event",g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2101 G_CALLBACK (fullscreen_motion_notify_cb),g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2102 window)g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2103
2104 g_signal_connect (priv->view,g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2105 "leave-notify-event",g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2106 G_CALLBACK (fullscreen_leave_notify_cb),g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2107 window)g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2108
2109 g_signal_connect (priv->thumbview,g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2110 "motion-notify-event",g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2111 G_CALLBACK (fullscreen_motion_notify_cb),g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2112 window)g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2113
2114 g_signal_connect (priv->thumbview,g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2115 "leave-notify-event",g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2116 G_CALLBACK (fullscreen_leave_notify_cb),g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2117 window)g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2118
2119 fullscreen_set_timeout (window);
2120
2121 if (slideshow) {
2122 priv->slideshow_random =
2123 g_settings_get_boolean (priv->fullscreen_settings,
2124 EOM_CONF_FULLSCREEN_RANDOM"random");
2125
2126 priv->slideshow_loop =
2127 g_settings_get_boolean (priv->fullscreen_settings,
2128 EOM_CONF_FULLSCREEN_LOOP"loop");
2129
2130 priv->slideshow_switch_timeout =
2131 g_settings_get_int (priv->fullscreen_settings,
2132 EOM_CONF_FULLSCREEN_SECONDS"seconds");
2133
2134 slideshow_set_timeout (window);
2135 }
2136
2137 upscale = g_settings_get_boolean (priv->fullscreen_settings,
2138 EOM_CONF_FULLSCREEN_UPSCALE"upscale");
2139
2140 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
2141 upscale);
2142
2143 gtk_widget_grab_focus (priv->view);
2144
2145 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2146 &black);
2147
2148 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2149 eom_window_update_fullscreen_popup (window);
2150
2151 eom_window_inhibit_screensaver (window);
2152
2153 /* Update both actions as we could've already been in one those modes */
2154 eom_window_update_slideshow_action (window);
2155 eom_window_update_fullscreen_action (window);
2156 eom_window_update_pause_slideshow_action (window);
2157}
2158
2159static void
2160eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow)
2161{
2162 EomWindowPrivate *priv;
2163 GtkWidget *menubar;
2164
2165 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2165, ((const char*) (__func__
))
);
2166
2167 priv = window->priv;
2168
2169 if (priv->mode != EOM_WINDOW_MODE_SLIDESHOW &&
2170 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2171
2172 priv->mode = EOM_WINDOW_MODE_NORMAL;
2173
2174 fullscreen_clear_timeout (window);
2175
2176 if (slideshow) {
2177 slideshow_clear_timeout (window);
2178 }
2179
2180 g_signal_handlers_disconnect_by_func (priv->view,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_motion_notify_cb), (window))
2181 (gpointer) fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_motion_notify_cb), (window))
2182 window)g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_motion_notify_cb), (window))
;
2183
2184 g_signal_handlers_disconnect_by_func (priv->view,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_leave_notify_cb), (window))
2185 (gpointer) fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_leave_notify_cb), (window))
2186 window)g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_leave_notify_cb), (window))
;
2187
2188 g_signal_handlers_disconnect_by_func (priv->thumbview,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_motion_notify_cb),
(window))
2189 (gpointer) fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_motion_notify_cb),
(window))
2190 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_motion_notify_cb),
(window))
;
2191
2192 g_signal_handlers_disconnect_by_func (priv->thumbview,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_leave_notify_cb), (
window))
2193 (gpointer) fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_leave_notify_cb), (
window))
2194 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_leave_notify_cb), (
window))
;
2195
2196 update_ui_visibility (window);
2197
2198 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
2199 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 2199, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
2200 gtk_widget_show (menubar);
2201
2202 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
2203
2204 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2205 NULL((void*)0));
2206 gtk_window_unfullscreen (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2207
2208 if (slideshow) {
2209 eom_window_update_slideshow_action (window);
2210 } else {
2211 eom_window_update_fullscreen_action (window);
2212 }
2213
2214 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
2215
2216 eom_window_uninhibit_screensaver (window);
2217}
2218
2219static void
2220eom_window_print (EomWindow *window)
2221{
2222 GtkWidget *dialog;
2223 GError *error = NULL((void*)0);
2224 GtkPrintOperation *print;
2225 GtkPrintOperationResult res;
2226 GtkPageSetup *page_setup;
2227 GtkPrintSettings *print_settings;
2228 gboolean page_setup_disabled = FALSE(0);
2229
2230 eom_debug (DEBUG_PRINTINGEOM_DEBUG_PRINTING, "eom-window.c", 2230, ((const char*) (__func__
))
);
2231
2232 print_settings = eom_print_get_print_settings ();
2233
2234 /* Make sure the window stays valid while printing */
2235 g_object_ref (window);
2236
2237 if (window->priv->page_setup != NULL((void*)0))
2238 page_setup = g_object_ref (window->priv->page_setup);
2239 else
2240 page_setup = eom_print_get_page_setup ();
2241
2242 print = eom_print_operation_new (window->priv->image,
2243 print_settings,
2244 page_setup);
2245
2246 // Disable page setup options if they are locked down
2247 page_setup_disabled = g_settings_get_boolean (window->priv->lockdown_settings,
2248 EOM_CONF_LOCKDOWN_CAN_SETUP_PAGE"disable-print-setup");
2249 if (page_setup_disabled)
2250 gtk_print_operation_set_embed_page_setup (print, FALSE(0));
2251
2252 res = gtk_print_operation_run (print,
2253 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
2254 GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, &error);
2255
2256 if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
2257 dialog = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2258 GTK_DIALOG_DESTROY_WITH_PARENT,
2259 GTK_MESSAGE_ERROR,
2260 GTK_BUTTONS_CLOSE,
2261 _("Error printing file:\n%s")gettext ("Error printing file:\n%s"),
2262 error->message);
2263 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
2264 G_CALLBACK (gtk_widget_destroy), NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
2265 gtk_widget_show (dialog);
2266 g_error_free (error);
2267 } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
2268 GtkPageSetup *new_page_setup;
2269 eom_print_set_print_settings (gtk_print_operation_get_print_settings (print));
2270 new_page_setup = gtk_print_operation_get_default_page_setup (print);
2271 if (window->priv->page_setup != NULL((void*)0))
2272 g_object_unref (window->priv->page_setup);
2273 window->priv->page_setup = g_object_ref (new_page_setup);
2274 eom_print_set_page_setup (window->priv->page_setup);
2275 }
2276
2277 if (page_setup != NULL((void*)0))
2278 g_object_unref (page_setup);
2279 g_object_unref (print_settings);
2280 g_object_unref (window);
2281}
2282
2283static void
2284eom_window_cmd_file_open (GtkAction *action, gpointer user_data)
2285{
2286 EomWindow *window;
2287 EomWindowPrivate *priv;
2288 EomImage *current;
2289 GtkWidget *dlg;
2290
2291 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2292
2293 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2294
2295 priv = window->priv;
2296
2297 dlg = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_OPEN);
2298 gtk_window_set_transient_for (GTK_WINDOW (dlg)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_window_get_type ()))))))
, GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2299
2300 current = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2301
2302 if (current != NULL((void*)0)) {
2303 gchar *dir_uri, *file_uri;
2304
2305 file_uri = eom_image_get_uri_for_display (current);
2306 dir_uri = g_path_get_dirname (file_uri);
2307
2308 gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2309 dir_uri);
2310 g_free (file_uri);
2311 g_free (dir_uri);
2312 g_object_unref (current);
2313 } else {
2314 /* If desired by the user,
2315 fallback to the XDG_PICTURES_DIR (if available) */
2316 const gchar *pics_dir;
2317 gboolean use_fallback;
2318
2319 use_fallback = g_settings_get_boolean (priv->ui_settings,
2320 EOM_CONF_UI_FILECHOOSER_XDG_FALLBACK"filechooser-xdg-fallback");
2321 pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
2322 if (use_fallback && pics_dir) {
2323 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2324 pics_dir);
2325 }
2326 }
2327
2328 g_signal_connect (dlg, "response",g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2329 G_CALLBACK (file_open_dialog_response_cb),g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2330 window)g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
2331
2332 gtk_widget_show_all (dlg);
2333}
2334
2335static void
2336eom_job_close_save_cb (EomJobSave *job, gpointer user_data)
2337{
2338 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2339
2340 g_signal_handlers_disconnect_by_func (job,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_close_save_cb), (window))
2341 eom_job_close_save_cb,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_close_save_cb), (window))
2342 window)g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_close_save_cb), (window))
;
2343
2344 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
2345}
2346
2347static void
2348close_confirmation_dialog_response_handler (EomCloseConfirmationDialog *dlg,
2349 gint response_id,
2350 EomWindow *window)
2351{
2352 GList *selected_images;
2353 EomWindowPrivate *priv;
2354
2355 priv = window->priv;
2356
2357 switch (response_id)
2358 {
2359 case GTK_RESPONSE_YES:
2360 /* save selected images */
2361 selected_images = eom_close_confirmation_dialog_get_selected_images (dlg);
2362 if (eom_window_save_images (window, selected_images)) {
2363 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2364 "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2365 G_CALLBACK (eom_job_close_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2366 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
2367
2368 eom_job_queue_add_job (priv->save_job);
2369 }
2370
2371 break;
2372
2373 case GTK_RESPONSE_NO:
2374 /* dont save */
2375 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
2376 break;
2377
2378 default:
2379 /* Cancel */
2380 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_widget_get_type ()))))))
);
2381 break;
2382 }
2383}
2384
2385static gboolean
2386eom_window_unsaved_images_confirm (EomWindow *window)
2387{
2388 EomWindowPrivate *priv;
2389 gboolean disabled;
2390 GtkWidget *dialog;
2391 GList *list;
2392 EomImage *image;
2393 GtkTreeIter iter;
2394
2395 priv = window->priv;
2396
2397 disabled = g_settings_get_boolean(priv->ui_settings,
2398 EOM_CONF_UI_DISABLE_CLOSE_CONFIRMATION"disable-close-confirmation");
2399 disabled |= window->priv->save_disabled;
2400 if (disabled || !priv->store) {
2401 return FALSE(0);
2402 }
2403
2404 list = NULL((void*)0);
2405 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter)) {
2406 do {
2407 gtk_tree_model_get (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter,
2408 EOM_LIST_STORE_EOM_IMAGE, &image,
2409 -1);
2410 if (!image)
2411 continue;
2412
2413 if (eom_image_is_modified (image)) {
2414 list = g_list_prepend (list, image);
2415 }
2416 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter));
2417 }
2418
2419 if (list) {
2420 list = g_list_reverse (list);
2421 dialog = eom_close_confirmation_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2422 list);
2423
2424 g_list_free (list);
2425 g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2426 "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2427 G_CALLBACK (close_confirmation_dialog_response_handler),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2428 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
;
2429 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2430
2431 gtk_widget_show (dialog);
2432 return TRUE(!(0));
2433
2434 }
2435 return FALSE(0);
2436}
2437
2438static void
2439eom_window_cmd_close_window (GtkAction *action, gpointer user_data)
2440{
2441 EomWindow *window;
2442 EomWindowPrivate *priv;
2443
2444 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2445
2446 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2447 priv = window->priv;
2448
2449 if (priv->save_job != NULL((void*)0)) {
2450 eom_window_finish_saving (window);
2451 }
2452
2453 if (!eom_window_unsaved_images_confirm (window)) {
2454 gtk_widget_destroy (GTK_WIDGET (user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
);
2455 }
2456}
2457
2458static void
2459eom_window_cmd_preferences (GtkAction *action, gpointer user_data)
2460{
2461 EomWindow *window;
2462 GtkWidget *pref_dlg;
2463
2464 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2465
2466 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2467
2468 pref_dlg = eom_preferences_dialog_get_instance (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2469
2470 gtk_widget_show (pref_dlg);
2471}
2472
2473#define EOM_TB_EDITOR_DLG_RESET_RESPONSE128 128
2474
2475static void
2476eom_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
2477{
2478 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
2479
2480 if (response == EOM_TB_EDITOR_DLG_RESET_RESPONSE128) {
2481 EggToolbarsModel *model;
2482 EggToolbarEditor *editor;
2483
2484 editor = g_object_get_data (G_OBJECT (dialog)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
dialog)), (((GType) ((20) << (2))))))))
,
2485 "EggToolbarEditor");
2486
2487 g_return_if_fail (editor != NULL)do { if ((editor != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "editor != NULL"); return
; } } while (0)
;
2488
2489 egg_editable_toolbar_set_edit_mode
2490 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2491
2492 eom_application_reset_toolbars_model (EOM_APP(eom_application_get_instance ()));
2493 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
2494 egg_editable_toolbar_set_model
2495 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, model);
2496 egg_toolbar_editor_set_model (editor, model);
2497
2498 /* Toolbar would be uneditable now otherwise */
2499 egg_editable_toolbar_set_edit_mode
2500 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2501 } else if (response == GTK_RESPONSE_HELP) {
2502 eom_util_show_help ("eom-toolbareditor", NULL((void*)0));
2503 } else {
2504 egg_editable_toolbar_set_edit_mode
2505 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2506
2507 eom_application_save_toolbars_model (EOM_APP(eom_application_get_instance ()));
2508
2509 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_widget_get_type ()))))))
);
2510 }
2511}
2512
2513static void
2514eom_window_cmd_edit_toolbar (GtkAction *action, gpointer *user_data)
2515{
2516 EomWindow *window;
2517 GtkWidget *dialog;
2518 GtkWidget *editor;
2519
2520 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2521
2522 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
2523
2524 dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor")gettext ("Toolbar Editor"),
2525 GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2526 GTK_DIALOG_DESTROY_WITH_PARENT,
2527 _("_Reset to Default")gettext ("_Reset to Default"),
2528 EOM_TB_EDITOR_DLG_RESET_RESPONSE128,
2529 "gtk-close",
2530 GTK_RESPONSE_CLOSE,
2531 "gtk-help",
2532 GTK_RESPONSE_HELP,
2533 NULL((void*)0));
2534
2535 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_dialog_get_type ()))))))
,
2536 GTK_RESPONSE_CLOSE);
2537
2538 gtk_container_set_border_width (GTK_CONTAINER (dialog)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_container_get_type ()))))))
, 5);
2539
2540 gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_dialog_get_content_area
(((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*
) ((dialog)), ((gtk_dialog_get_type ()))))))))), ((gtk_box_get_type
()))))))
, 2);
2541
2542 gtk_window_set_default_size (GTK_WINDOW (dialog)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_window_get_type ()))))))
, 500, 400);
2543
2544 editor = egg_toolbar_editor_new (window->priv->ui_mgr,
2545 eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ())));
2546
2547 gtk_container_set_border_width (GTK_CONTAINER (editor)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_container_get_type ()))))))
, 5);
2548
2549 // Use as much vertical space as available
2550 gtk_widget_set_vexpand (GTK_WIDGET (editor)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(editor)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
2551
2552 gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) (((
(((EggToolbarEditor*) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((egg_toolbar_editor_get_type ())))))))), ((gtk_box_get_type
()))))))
, 5);
2553
2554 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_container_get_type ()))))))
, editor);
2555
2556 egg_editable_toolbar_set_edit_mode
2557 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2558
2559 g_object_set_data (G_OBJECT (dialog)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
dialog)), (((GType) ((20) << (2))))))))
, "EggToolbarEditor", editor);
2560
2561 g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2562 "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2563 G_CALLBACK (eom_window_cmd_edit_toolbar_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2564 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2565
2566 gtk_widget_show_all (dialog);
2567}
2568
2569static void
2570eom_window_cmd_help (GtkAction *action, gpointer user_data)
2571{
2572 EomWindow *window;
2573
2574 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2575
2576 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2577
2578 eom_util_show_help (NULL((void*)0), GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2579}
2580
2581#define ABOUT_GROUP"About" "About"
2582#define EMAILIFY(string)(g_strdelimit ((string), "%", '@')) (g_strdelimit ((string), "%", '@'))
2583
2584static void
2585eom_window_cmd_about (GtkAction *action, gpointer user_data)
2586{
2587 EomWindow *window;
2588
2589 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2590
2591 const char *license[] = {
2592 N_("This program is free software; you can redistribute it and/or modify "("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
2593 "it under the terms of the GNU General Public License as published by "("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
2594 "the Free Software Foundation; either version 2 of the License, or "("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
2595 "(at your option) any later version.\n")("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
,
2596 N_("This program is distributed in the hope that it will be useful, "("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
2597 "but WITHOUT ANY WARRANTY; without even the implied warranty of "("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
2598 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
2599 "GNU General Public License for more details.\n")("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
,
2600 N_("You should have received a copy of the GNU General Public License "("You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
)
2601 "along with this program; if not, write to the Free Software "("You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
)
2602 "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.")("You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
)
2603 };
2604
2605 char *license_trans;
2606 GKeyFile *key_file;
2607 GBytes *bytes;
2608 const guint8 *data;
2609 gsize data_len;
2610 GError *error = NULL((void*)0);
2611 char **authors, **documenters;
2612 gsize n_authors = 0, n_documenters = 0 , i;
2613
2614 bytes = g_resources_lookup_data ("/org/mate/eom/ui/eom.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
2615 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2615, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2616
2617 data = g_bytes_get_data (bytes, &data_len);
2618 key_file = g_key_file_new ();
2619 g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
2620 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2620, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2621
2622 authors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Authors", &n_authors, NULL((void*)0));
2623 documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Documenters", &n_documenters, NULL((void*)0));
2624
2625 g_key_file_free (key_file);
2626 g_bytes_unref (bytes);
2627
2628 for (i = 0; i < n_authors; ++i)
2629 authors[i] = EMAILIFY (authors[i])(g_strdelimit ((authors[i]), "%", '@'));
2630 for (i = 0; i < n_documenters; ++i)
2631 documenters[i] = EMAILIFY (documenters[i])(g_strdelimit ((documenters[i]), "%", '@'));
2632
2633 license_trans = g_strconcat (_(license[0])gettext (license[0]), "\n", _(license[1])gettext (license[1]), "\n", _(license[2])gettext (license[2]), "\n", NULL((void*)0));
2634
2635 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2636
2637 gtk_show_about_dialog (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2638 "program-name", _("Eye of MATE")gettext ("Eye of MATE"),
2639 "title", _("About Eye of MATE")gettext ("About Eye of MATE"),
2640 "version", VERSION"1.24.0",
2641 "copyright", _("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers"
)
2642 "Copyright \xc2\xa9 2011 Perberos\n"gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers"
)
2643 "Copyright \xc2\xa9 2012-2020 MATE developers")gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers"
)
,
2644 "comments",_("Eye of MATE is a simple graphics viewer for the MATE Desktop Environment.")gettext ("Eye of MATE is a simple graphics viewer for the MATE Desktop Environment."
)
,
2645 "authors", authors,
2646 "documenters", documenters,
2647 "translator-credits", _("translator-credits")gettext ("translator-credits"),
2648 "website", "http://www.mate-desktop.org/",
2649 "logo-icon-name", "eom",
2650 "wrap-license", TRUE(!(0)),
2651 "license", license_trans,
2652 NULL((void*)0));
2653
2654 g_strfreev (authors);
2655 g_strfreev (documenters);
2656 g_free (license_trans);
2657}
2658
2659static void
2660eom_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
2661{
2662 EomWindow *window;
2663 EomWindowPrivate *priv;
2664 gboolean visible;
2665 const gchar *action_name;
2666
2667 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2668
2669 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2670 priv = window->priv;
2671
2672 if (priv->mode != EOM_WINDOW_MODE_NORMAL &&
2673 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2674
2675 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2676 visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
2677 action_name = gtk_action_get_name (action);
2678 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2679
2680 if (g_ascii_strcasecmp (action_name, "ViewToolbar") == 0) {
2681 g_object_set (G_OBJECT (priv->toolbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->toolbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2682
2683 if (priv->mode == EOM_WINDOW_MODE_NORMAL)
2684 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_TOOLBAR"toolbar", visible);
2685
2686 } else if (g_ascii_strcasecmp (action_name, "ViewStatusbar") == 0) {
2687 g_object_set (G_OBJECT (priv->statusbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->statusbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2688
2689 if (priv->mode == EOM_WINDOW_MODE_NORMAL)
2690 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_STATUSBAR"statusbar", visible);
2691
2692 } else if (g_ascii_strcasecmp (action_name, "ViewImageCollection") == 0) {
2693 if (visible) {
2694 /* Make sure the focus widget is realized to
2695 * avoid warnings on keypress events */
2696 if (!gtk_widget_get_realized (window->priv->thumbview))
2697 gtk_widget_realize (window->priv->thumbview);
2698
2699 gtk_widget_show (priv->nav);
2700 gtk_widget_grab_focus (priv->thumbview);
2701 } else {
2702 /* Make sure the focus widget is realized to
2703 * avoid warnings on keypress events.
2704 * Don't do it during init phase or the view
2705 * will get a bogus allocation. */
2706 if (!gtk_widget_get_realized (priv->view)
2707 && priv->status == EOM_WINDOW_STATUS_NORMAL)
2708 gtk_widget_realize (priv->view);
2709
2710 gtk_widget_hide (priv->nav);
2711
2712 if (gtk_widget_get_realized (priv->view))
2713 gtk_widget_grab_focus (priv->view);
2714 }
2715 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", visible);
2716
2717 } else if (g_ascii_strcasecmp (action_name, "ViewSidebar") == 0) {
2718 if (visible) {
2719 gtk_widget_show (priv->sidebar);
2720 } else {
2721 gtk_widget_hide (priv->sidebar);
2722 }
2723 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_SIDEBAR"sidebar", visible);
2724 }
2725}
2726
2727static void
2728wallpaper_info_bar_response (GtkInfoBar *bar, gint response, EomWindow *window)
2729{
2730 if (response == GTK_RESPONSE_YES) {
2731 GAppInfo *app_info;
2732 GError *error = NULL((void*)0);
2733
2734 app_info = g_app_info_create_from_commandline ("mate-appearance-properties --show-page=background",
2735 "mate-appearance-properties",
2736 G_APP_INFO_CREATE_NONE,
2737 &error);
2738
2739 if (error != NULL((void*)0)) {
2740 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2741 error->message);
2742 g_error_free (error);
2743 error = NULL((void*)0);
2744 }
2745
2746 if (app_info != NULL((void*)0)) {
2747 GdkAppLaunchContext *context;
2748 GdkDisplay *display;
2749
2750 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
2751 context = gdk_display_get_app_launch_context (display);
2752 g_app_info_launch (app_info, NULL((void*)0), G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) g_type_check_instance_cast ((GTypeInstance
*) ((context)), ((g_app_launch_context_get_type ()))))))
, &error);
2753
2754 if (error != NULL((void*)0)) {
2755 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2756 error->message);
2757 g_error_free (error);
2758 error = NULL((void*)0);
2759 }
2760
2761 g_object_unref (context);
2762 g_object_unref (app_info);
2763 }
2764 }
2765
2766 /* Close message area on every response */
2767 eom_window_set_message_area (window, NULL((void*)0));
2768}
2769
2770static void
2771eom_window_set_wallpaper (EomWindow *window, const gchar *filename, const gchar *visible_filename)
2772{
2773 GtkWidget *info_bar;
2774 GtkWidget *image;
2775 GtkWidget *label;
2776 GtkWidget *hbox;
2777 gchar *markup;
2778 gchar *text;
2779 gchar *basename;
2780 GSettings *wallpaper_settings;
2781
2782 wallpaper_settings = g_settings_new (EOM_CONF_BACKGROUND_SCHEMA"org.mate.background");
2783 g_settings_set_string (wallpaper_settings,
2784 EOM_CONF_BACKGROUND_FILE"picture-filename",
2785 filename);
2786 g_object_unref (wallpaper_settings);
2787
2788 /* I18N: When setting mnemonics for these strings, watch out to not
2789 clash with mnemonics from eom's menubar */
2790 info_bar = gtk_info_bar_new_with_buttons (_("_Open Background Preferences")gettext ("_Open Background Preferences"),
2791 GTK_RESPONSE_YES,
2792 C_("MessageArea","Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
2793 GTK_RESPONSE_NO, NULL((void*)0));
2794 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((info_bar)), ((gtk_info_bar_get_type()))))))
,
2795 GTK_MESSAGE_QUESTION);
2796
2797 image = gtk_image_new_from_icon_name ("dialog-question",
2798 GTK_ICON_SIZE_DIALOG);
2799 label = gtk_label_new (NULL((void*)0));
2800
2801 if (!visible_filename)
2802 basename = g_path_get_basename (filename);
2803
2804 /* The newline character is currently necessary due to a problem
2805 * with the automatic line break. */
2806 text = g_strdup_printf (_("The image \"%s\" has been set as Desktop Background."gettext ("The image \"%s\" has been set as Desktop Background."
"\nWould you like to modify its appearance?")
2807 "\nWould you like to modify its appearance?")gettext ("The image \"%s\" has been set as Desktop Background."
"\nWould you like to modify its appearance?")
,
2808 visible_filename ? visible_filename : basename);
2809 markup = g_markup_printf_escaped ("<b>%s</b>", text);
2810 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, markup);
2811 g_free (markup);
2812 g_free (text);
2813 if (!visible_filename)
2814 g_free (basename);
2815
2816 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
2817 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
2818 gtk_widget_set_halign (image, GTK_ALIGN_START);
2819 gtk_widget_set_valign (image, GTK_ALIGN_END);
2820 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
2821 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, 0.0);
2822 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_info_bar_get_content_area
(((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))))), ((gtk_box_get_type
()))))))
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
2823 gtk_widget_show_all (hbox);
2824 gtk_widget_show (info_bar);
2825
2826
2827 eom_window_set_message_area (window, info_bar);
2828 gtk_info_bar_set_default_response (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((info_bar)), ((gtk_info_bar_get_type()))))))
,
2829 GTK_RESPONSE_YES);
2830 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
2831 G_CALLBACK (wallpaper_info_bar_response), window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
;
2832}
2833
2834static void
2835eom_job_save_cb (EomJobSave *job, gpointer user_data)
2836{
2837 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2838 GtkAction *action_save;
2839
2840 g_signal_handlers_disconnect_by_func (job,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_cb), (window))
2841 eom_job_save_cb,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_cb), (window))
2842 window)g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_cb), (window))
;
2843
2844 g_signal_handlers_disconnect_by_func (job,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_progress_cb), (window))
2845 eom_job_save_progress_cb,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_progress_cb), (window))
2846 window)g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_progress_cb), (window))
;
2847
2848 g_object_unref (window->priv->save_job);
2849 window->priv->save_job = NULL((void*)0);
2850
2851 update_status_bar (window);
2852 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2853 action_save = gtk_action_group_get_action (window->priv->actions_image,
2854 "ImageSave");
2855 gtk_action_set_sensitive (action_save, FALSE(0));
2856 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2857}
2858
2859static void
2860eom_job_copy_cb (EomJobCopy *job, gpointer user_data)
2861{
2862 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2863 gchar *filepath, *basename, *filename, *extension;
2864 GtkAction *action;
2865 GFile *source_file, *dest_file;
2866
2867 /* Create source GFile */
2868 basename = g_file_get_basename (job->images->data);
2869 filepath = g_build_filename (job->dest, basename, NULL((void*)0));
2870 source_file = g_file_new_for_path (filepath);
2871 g_free (filepath);
2872
2873 /* Create destination GFile */
2874 extension = eom_util_filename_get_extension (basename);
2875 filename = g_strdup_printf ("%s.%s", EOM_WALLPAPER_FILENAME"eom-wallpaper", extension);
2876 filepath = g_build_filename (job->dest, filename, NULL((void*)0));
2877 dest_file = g_file_new_for_path (filepath);
2878 g_free (filename);
2879 g_free (extension);
2880
2881 /* Move the file */
2882 g_file_move (source_file, dest_file, G_FILE_COPY_OVERWRITE,
2883 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
2884
2885 /* Set the wallpaper */
2886 eom_window_set_wallpaper (window, filepath, basename);
2887 g_free (basename);
2888 g_free (filepath);
2889
2890 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
2891 window->priv->copy_file_cid);
2892 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2893 action = gtk_action_group_get_action (window->priv->actions_image,
2894 "ImageSetAsWallpaper");
2895 gtk_action_set_sensitive (action, TRUE(!(0)));
2896 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2897
2898 window->priv->copy_job = NULL((void*)0);
2899
2900 g_object_unref (source_file);
2901 g_object_unref (dest_file);
2902 g_object_unref (G_OBJECT (job->images->data)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
job->images->data)), (((GType) ((20) << (2)))))))
)
);
2903 g_list_free (job->images);
2904 g_object_unref (job);
2905}
2906
2907static gboolean
2908eom_window_save_images (EomWindow *window, GList *images)
2909{
2910 EomWindowPrivate *priv;
2911
2912 priv = window->priv;
2913
2914 if (window->priv->save_job != NULL((void*)0))
2915 return FALSE(0);
2916
2917 priv->save_job = eom_job_save_new (images);
2918
2919 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2920 "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2921 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2922 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2923
2924 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2925 "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2926 G_CALLBACK (eom_job_save_progress_cb),g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2927 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
2928
2929 return TRUE(!(0));
2930}
2931
2932static void
2933eom_window_cmd_save (GtkAction *action, gpointer user_data)
2934{
2935 EomWindowPrivate *priv;
2936 EomWindow *window;
2937 GList *images;
2938
2939 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2940 priv = window->priv;
2941
2942 if (window->priv->save_job != NULL((void*)0))
2943 return;
2944
2945 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2946
2947 if (eom_window_save_images (window, images)) {
2948 eom_job_queue_add_job (priv->save_job);
2949 }
2950}
2951
2952static GFile*
2953eom_window_retrieve_save_as_file (EomWindow *window, EomImage *image)
2954{
2955 GtkWidget *dialog;
2956 GFile *save_file = NULL((void*)0);
2957 GFile *last_dest_folder;
2958 gint response;
2959
2960 g_assert (image != NULL)do { if (image != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2960, ((const char*) (__func__)), "image != NULL"
); } while (0)
;
2961
2962 dialog = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_SAVE);
2963
2964 last_dest_folder = window->priv->last_save_as_folder;
2965
2966 if (last_dest_folder && g_file_query_exists (last_dest_folder, NULL((void*)0))) {
2967 gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
, last_dest_folder, NULL((void*)0));
2968 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2969 eom_image_get_caption (image));
2970 } else {
2971 GFile *image_file;
2972
2973 image_file = eom_image_get_file (image);
2974 /* Setting the file will also navigate to its parent folder */
2975 gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2976 image_file, NULL((void*)0));
2977 g_object_unref (image_file);
2978 }
2979
2980 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_dialog_get_type ()))))))
);
2981 gtk_widget_hide (dialog);
2982
2983 if (response == GTK_RESPONSE_OK) {
2984 save_file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
);
2985 if (window->priv->last_save_as_folder)
2986 g_object_unref (window->priv->last_save_as_folder);
2987 window->priv->last_save_as_folder = g_file_get_parent (save_file);
2988 }
2989 gtk_widget_destroy (dialog);
2990
2991 return save_file;
2992}
2993
2994static void
2995eom_window_cmd_save_as (GtkAction *action, gpointer user_data)
2996{
2997 EomWindowPrivate *priv;
2998 EomWindow *window;
2999 GList *images;
3000 guint n_images;
3001
3002 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3003 priv = window->priv;
3004
3005 if (window->priv->save_job != NULL((void*)0))
3006 return;
3007
3008 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3009 n_images = g_list_length (images);
3010
3011 if (n_images == 1) {
3012 GFile *file;
3013
3014 file = eom_window_retrieve_save_as_file (window, images->data);
3015
3016 if (!file) {
3017 g_list_free (images);
3018 return;
3019 }
3020
3021 priv->save_job = eom_job_save_as_new (images, NULL((void*)0), file);
3022
3023 g_object_unref (file);
3024 } else if (n_images > 1) {
3025 GFile *base_file;
3026 GtkWidget *dialog;
3027 gchar *basedir;
3028 EomURIConverter *converter;
3029
3030 basedir = g_get_current_dir ();
3031 base_file = g_file_new_for_path (basedir);
3032 g_free (basedir);
3033
3034 dialog = eom_save_as_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3035 images,
3036 base_file);
3037
3038 gtk_widget_show_all (dialog);
3039
3040 if (gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_dialog_get_type ()))))))
) != GTK_RESPONSE_OK) {
3041 g_object_unref (base_file);
3042 g_list_free (images);
3043 gtk_widget_destroy (dialog);
3044
3045 return;
3046 }
3047
3048 converter = eom_save_as_dialog_get_converter (dialog);
3049
3050 g_assert (converter != NULL)do { if (converter != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3050, ((const char*) (__func__)), "converter != NULL"
); } while (0)
;
3051
3052 priv->save_job = eom_job_save_as_new (images, converter, NULL((void*)0));
3053
3054 gtk_widget_destroy (dialog);
3055
3056 g_object_unref (converter);
3057 g_object_unref (base_file);
3058 } else {
3059 /* n_images = 0 -- No Image selected */
3060 return;
3061 }
3062
3063 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3064 "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3065 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3066 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3067
3068 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3069 "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3070 G_CALLBACK (eom_job_save_progress_cb),g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3071 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
3072
3073 eom_job_queue_add_job (priv->save_job);
3074}
3075
3076static void
3077eom_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
3078{
3079 EomWindowPrivate *priv;
3080
3081 GFile *file;
3082 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3083
3084 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3085
3086 g_return_if_fail (priv->image != NULL)do { if ((priv->image != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "priv->image != NULL"
); return; } } while (0)
;
3087
3088 file = eom_image_get_file (priv->image);
3089
3090 g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "file != NULL"); return;
} } while (0)
;
3091
3092 eom_util_show_file_in_filemanager (file,
3093 GTK_WINDOW (user_data)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_window_get_type ()))))))
);
3094}
3095
3096static void
3097eom_window_cmd_print (GtkAction *action, gpointer user_data)
3098{
3099 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3100
3101 eom_window_print (window);
3102}
3103
3104/**
3105 * eom_window_get_properties_dialog:
3106 * @window: a #EomWindow
3107 *
3108 * Gets the @window property dialog. The widget will be built on the first call to this function.
3109 *
3110 * Returns: (transfer none): a #GtkDialog.
3111 */
3112
3113GtkWidget*
3114eom_window_get_properties_dialog (EomWindow *window)
3115{
3116 EomWindowPrivate *priv;
3117
3118 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
3119
3120 priv = window->priv;
3121
3122 if (priv->properties_dlg == NULL((void*)0)) {
3123 GtkAction *next_image_action, *previous_image_action;
3124
3125 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3126 next_image_action =
3127 gtk_action_group_get_action (priv->actions_collection,
3128 "GoNext");
3129
3130 previous_image_action =
3131 gtk_action_group_get_action (priv->actions_collection,
3132 "GoPrevious");
3133 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3134 priv->properties_dlg =
3135 eom_properties_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3136 EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3137 next_image_action,
3138 previous_image_action);
3139
3140 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
3141 priv->image);
3142 g_settings_bind (priv->ui_settings,
3143 EOM_CONF_UI_PROPSDIALOG_NETBOOK_MODE"propsdialog-netbook-mode",
3144 priv->properties_dlg, "netbook-mode",
3145 G_SETTINGS_BIND_GET);
3146 }
3147
3148 return priv->properties_dlg;
3149}
3150
3151static void
3152eom_window_cmd_properties (GtkAction *action, gpointer user_data)
3153{
3154 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3155 GtkWidget *dialog;
3156
3157 dialog = eom_window_get_properties_dialog (window);
3158 gtk_widget_show (dialog);
3159}
3160
3161static void
3162eom_window_cmd_undo (GtkAction *action, gpointer user_data)
3163{
3164 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3165
3166 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
, NULL((void*)0));
3167}
3168
3169static void
3170eom_window_cmd_flip_horizontal (GtkAction *action, gpointer user_data)
3171{
3172 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3173
3174 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3175 eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL));
3176}
3177
3178static void
3179eom_window_cmd_flip_vertical (GtkAction *action, gpointer user_data)
3180{
3181 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3182
3183 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3184 eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL));
3185}
3186
3187static void
3188eom_window_cmd_rotate_90 (GtkAction *action, gpointer user_data)
3189{
3190 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3191
3192 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3193 eom_transform_rotate_new (90));
3194}
3195
3196static void
3197eom_window_cmd_rotate_270 (GtkAction *action, gpointer user_data)
3198{
3199 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3200
3201 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3202 eom_transform_rotate_new (270));
3203}
3204
3205static void
3206eom_window_cmd_wallpaper (GtkAction *action, gpointer user_data)
3207{
3208 EomWindow *window;
3209 EomWindowPrivate *priv;
3210 EomImage *image;
3211 GFile *file;
3212 char *filename = NULL((void*)0);
3213
3214 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3215
3216 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3217 priv = window->priv;
3218
3219 /* If currently copying an image to set it as wallpaper, return. */
3220 if (priv->copy_job != NULL((void*)0))
3221 return;
3222
3223 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3224
3225 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
3226
3227 file = eom_image_get_file (image);
3228
3229 filename = g_file_get_path (file);
3230
3231 /* Currently only local files can be set as wallpaper */
3232 if (filename == NULL((void*)0) || !eom_util_file_is_persistent (file))
3233 {
3234 GList *files = NULL((void*)0);
3235 GtkAction *action;
3236
3237 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3238 action = gtk_action_group_get_action (window->priv->actions_image,
3239 "ImageSetAsWallpaper");
3240 gtk_action_set_sensitive (action, FALSE(0));
3241 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3242
3243 priv->copy_file_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3244 "copy_file_cid");
3245 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3246 priv->copy_file_cid,
3247 _("Saving image locally…")gettext ("Saving image locally…"));
3248
3249 files = g_list_append (files, eom_image_get_file (image));
3250 priv->copy_job = eom_job_copy_new (files, g_get_user_data_dir ());
3251 g_signal_connect (priv->copy_job,g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3252 "finished",g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3253 G_CALLBACK (eom_job_copy_cb),g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3254 window)g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3255 g_signal_connect (priv->copy_job,g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3256 "progress",g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3257 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3258 window)g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3259 eom_job_queue_add_job (priv->copy_job);
3260
3261 g_object_unref (file);
3262 g_free (filename);
3263 return;
3264 }
3265
3266 g_object_unref (file);
3267
3268 eom_window_set_wallpaper (window, filename, NULL((void*)0));
3269
3270 g_free (filename);
3271}
3272
3273static gboolean
3274eom_window_all_images_trasheable (GList *images)
3275{
3276 GFile *file;
3277 GFileInfo *file_info;
3278 GList *iter;
3279 EomImage *image;
3280 gboolean can_trash = TRUE(!(0));
3281
3282 for (iter = images; iter != NULL((void*)0); iter = g_list_next (iter)((iter) ? (((GList *)(iter))->next) : ((void*)0))) {
3283 image = (EomImage *) iter->data;
3284 file = eom_image_get_file (image);
3285 file_info = g_file_query_info (file,
3286 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3287 0, NULL((void*)0), NULL((void*)0));
3288 can_trash = g_file_info_get_attribute_boolean (file_info,
3289 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3290
3291 g_object_unref (file_info);
3292 g_object_unref (file);
3293
3294 if (can_trash == FALSE(0))
3295 break;
3296 }
3297
3298 return can_trash;
3299}
3300
3301static int
3302show_move_to_trash_confirm_dialog (EomWindow *window, GList *images, gboolean can_trash)
3303{
3304 GtkWidget *dlg;
3305 char *prompt;
3306 int response;
3307 int n_images;
3308 EomImage *image;
3309 static gboolean dontaskagain = FALSE(0);
3310 gboolean neverask = FALSE(0);
3311 GtkWidget* dontask_cbutton = NULL((void*)0);
3312
3313 /* Check if the user never wants to be bugged. */
3314 neverask = g_settings_get_boolean (window->priv->ui_settings,
3315 EOM_CONF_UI_DISABLE_TRASH_CONFIRMATION"disable-trash-confirmation");
3316
3317 /* Assume agreement, if the user doesn't want to be
3318 * asked and the trash is available */
3319 if (can_trash && (dontaskagain || neverask))
3320 return GTK_RESPONSE_OK;
3321
3322 n_images = g_list_length (images);
3323
3324 if (n_images == 1) {
3325 image = EOM_IMAGE (images->data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(images->data)), ((eom_image_get_type ()))))))
;
3326 if (can_trash) {
3327 prompt = g_strdup_printf (_("Are you sure you want to move\n\"%s\" to the trash?")gettext ("Are you sure you want to move\n\"%s\" to the trash?"
)
,
3328 eom_image_get_caption (image));
3329 } else {
3330 prompt = g_strdup_printf (_("A trash for \"%s\" couldn't be found. Do you want to remove "gettext ("A trash for \"%s\" couldn't be found. Do you want to remove "
"this image permanently?")
3331 "this image permanently?")gettext ("A trash for \"%s\" couldn't be found. Do you want to remove "
"this image permanently?")
, eom_image_get_caption (image));
3332 }
3333 } else {
3334 if (can_trash) {
3335 prompt = g_strdup_printf (ngettext("Are you sure you want to move\n"
3336 "the %d selected image to the trash?",
3337 "Are you sure you want to move\n"
3338 "the %d selected images to the trash?", n_images), n_images);
3339 } else {
3340 prompt = g_strdup (_("Some of the selected images can't be moved to the trash "gettext ("Some of the selected images can't be moved to the trash "
"and will be removed permanently. Are you sure you want " "to proceed?"
)
3341 "and will be removed permanently. Are you sure you want "gettext ("Some of the selected images can't be moved to the trash "
"and will be removed permanently. Are you sure you want " "to proceed?"
)
3342 "to proceed?")gettext ("Some of the selected images can't be moved to the trash "
"and will be removed permanently. Are you sure you want " "to proceed?"
)
);
3343 }
3344 }
3345
3346 dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3347 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3348 GTK_MESSAGE_WARNING,
3349 GTK_BUTTONS_NONE,
3350 "<span weight=\"bold\" size=\"larger\">%s</span>",
3351 prompt);
3352 g_free (prompt);
3353
3354 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-cancel", GTK_RESPONSE_CANCEL);
3355
3356 if (can_trash) {
3357 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, _("Move to _Trash")gettext ("Move to _Trash"), GTK_RESPONSE_OK);
3358
3359 dontask_cbutton = gtk_check_button_new_with_mnemonic (_("_Do not ask again during this session")gettext ("_Do not ask again during this session"));
3360 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
, FALSE(0));
3361
3362 gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_dialog_get_content_area
(((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*
) ((dlg)), ((gtk_dialog_get_type ()))))))))), ((gtk_box_get_type
()))))))
, dontask_cbutton, TRUE(!(0)), TRUE(!(0)), 0);
3363 } else {
3364 if (n_images == 1) {
3365 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-delete", GTK_RESPONSE_OK);
3366 } else {
3367 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-yes", GTK_RESPONSE_OK);
3368 }
3369 }
3370
3371 gtk_dialog_set_default_response (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
3372 gtk_window_set_title (GTK_WINDOW (dlg)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_window_get_type ()))))))
, "");
3373 gtk_widget_show_all (dlg);
3374
3375 response = gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
);
3376
3377 /* Only update the property if the user has accepted */
3378 if (can_trash && response == GTK_RESPONSE_OK)
3379 dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
);
3380
3381 /* The checkbutton is destroyed together with the dialog */
3382 gtk_widget_destroy (dlg);
3383
3384 return response;
3385}
3386
3387static gboolean
3388move_to_trash_real (EomImage *image, GError **error)
3389{
3390 GFile *file;
3391 GFileInfo *file_info;
3392 gboolean can_trash, result;
3393
3394 g_return_val_if_fail (EOM_IS_IMAGE (image), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return ((0)); } } while (0)
;
3395
3396 file = eom_image_get_file (image);
3397 file_info = g_file_query_info (file,
3398 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3399 0, NULL((void*)0), NULL((void*)0));
3400 if (file_info == NULL((void*)0)) {
3401 g_set_error (error,
3402 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3403 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3404 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3405 return FALSE(0);
3406 }
3407
3408 can_trash = g_file_info_get_attribute_boolean (file_info,
3409 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3410 g_object_unref (file_info);
3411 if (can_trash)
3412 {
3413 result = g_file_trash (file, NULL((void*)0), NULL((void*)0));
3414 if (result == FALSE(0)) {
3415 g_set_error (error,
3416 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3417 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3418 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3419 }
3420 } else {
3421 result = g_file_delete (file, NULL((void*)0), NULL((void*)0));
3422 if (result == FALSE(0)) {
3423 g_set_error (error,
3424 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3425 EOM_WINDOW_ERROR_IO,
3426 _("Couldn't delete file")gettext ("Couldn't delete file"));
3427 }
3428 }
3429
3430 g_object_unref (file);
3431
3432 return result;
3433}
3434
3435static void
3436eom_window_cmd_copy_image (GtkAction *action, gpointer user_data)
3437{
3438 GtkClipboard *clipboard;
3439 EomWindow *window;
3440 EomWindowPrivate *priv;
3441 EomImage *image;
3442 EomClipboardHandler *cbhandler;
3443
3444 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3445
3446 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3447 priv = window->priv;
3448
3449 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3450
3451 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
3452
3453 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD((GdkAtom)((gpointer) (gulong) (69))));
3454
3455 cbhandler = eom_clipboard_handler_new (image);
3456 // cbhandler will self-destruct when it's not needed anymore
3457 eom_clipboard_handler_copy_to_clipboard (cbhandler, clipboard);
3458
3459}
3460
3461static void
3462eom_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
3463{
3464 GList *images;
3465 GList *it;
3466 EomWindowPrivate *priv;
3467 EomListStore *list;
3468 int pos;
3469 EomImage *img;
3470 EomWindow *window;
3471 int response;
3472 int n_images;
3473 gboolean success;
3474 gboolean can_trash;
3475 const gchar *action_name;
3476
3477 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3478
3479 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3480 priv = window->priv;
3481 list = priv->store;
3482
3483 n_images = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3484
3485 if (n_images < 1) return;
3486
3487 /* save position of selected image after the deletion */
3488 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3489
3490 g_assert (images != NULL)do { if (images != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3490, ((const char*) (__func__)), "images != NULL"
); } while (0)
;
3491
3492 /* HACK: eom_list_store_get_n_selected return list in reverse order */
3493 images = g_list_reverse (images);
3494
3495 can_trash = eom_window_all_images_trasheable (images);
3496
3497 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3498 action_name = gtk_action_get_name (action);
3499 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3500
3501 if (g_ascii_strcasecmp (action_name, "Delete") == 0 ||
3502 can_trash == FALSE(0)) {
3503 response = show_move_to_trash_confirm_dialog (window, images, can_trash);
3504
3505 if (response != GTK_RESPONSE_OK) return;
3506 }
3507
3508 pos = eom_list_store_get_pos_by_image (list, EOM_IMAGE (images->data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(images->data)), ((eom_image_get_type ()))))))
);
3509
3510 /* FIXME: make a nice progress dialog */
3511 /* Do the work actually. First try to delete the image from the disk. If this
3512 * is successful, remove it from the screen. Otherwise show error dialog.
3513 */
3514 for (it = images; it != NULL((void*)0); it = it->next) {
3515 GError *error = NULL((void*)0);
3516 EomImage *image;
3517
3518 image = EOM_IMAGE (it->data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(it->data)), ((eom_image_get_type ()))))))
;
3519
3520 success = move_to_trash_real (image, &error);
3521
3522 if (success) {
3523 eom_list_store_remove_image (list, image);
3524 } else {
3525 char *header;
3526 GtkWidget *dlg;
3527
3528 header = g_strdup_printf (_("Error on deleting image %s")gettext ("Error on deleting image %s"),
3529 eom_image_get_caption (image));
3530
3531 dlg = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3532 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3533 GTK_MESSAGE_ERROR,
3534 GTK_BUTTONS_OK,
3535 "%s", header);
3536
3537 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg)((((GtkMessageDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_message_dialog_get_type ()))))))
,
3538 "%s", error->message);
3539
3540 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
);
3541
3542 gtk_widget_destroy (dlg);
3543
3544 g_free (header);
3545 }
3546 }
3547
3548 /* free list */
3549 g_list_free_full (images, g_object_unref);
3550
3551 /* select image at previously saved position */
3552 pos = MIN (pos, eom_list_store_length (list) - 1)(((pos) < (eom_list_store_length (list) - 1)) ? (pos) : (eom_list_store_length
(list) - 1))
;
3553
3554 if (pos >= 0) {
3555 img = eom_list_store_get_image_by_pos (list, pos);
3556
3557 eom_thumb_view_set_current_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3558 img,
3559 TRUE(!(0)));
3560
3561 if (img != NULL((void*)0)) {
3562 g_object_unref (img);
3563 }
3564 }
3565}
3566
3567static void
3568eom_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
3569{
3570 EomWindow *window;
3571 gboolean fullscreen;
3572
3573 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3574
3575 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3575, ((const char*) (__func__
))
);
3576
3577 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3578
3579 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3580 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3581 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3582
3583 if (fullscreen) {
3584 eom_window_run_fullscreen (window, FALSE(0));
3585 } else {
3586 eom_window_stop_fullscreen (window, FALSE(0));
3587 }
3588}
3589
3590static void
3591eom_window_cmd_slideshow (GtkAction *action, gpointer user_data)
3592{
3593 EomWindow *window;
3594 gboolean slideshow;
3595
3596 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3597
3598 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3598, ((const char*) (__func__
))
);
3599
3600 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3601
3602 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3603 slideshow = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3604 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3605
3606 if (slideshow) {
3607 eom_window_run_fullscreen (window, TRUE(!(0)));
3608 } else {
3609 eom_window_stop_fullscreen (window, TRUE(!(0)));
3610 }
3611}
3612
3613static void
3614eom_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data)
3615{
3616 EomWindow *window;
3617 gboolean slideshow;
3618
3619 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3620
3621 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3621, ((const char*) (__func__
))
);
3622
3623 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3624
3625 slideshow = window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
3626
3627 if (!slideshow && window->priv->mode != EOM_WINDOW_MODE_FULLSCREEN)
3628 return;
3629
3630 eom_window_run_fullscreen (window, !slideshow);
3631}
3632
3633static void
3634eom_window_cmd_zoom_in (GtkAction *action, gpointer user_data)
3635{
3636 EomWindowPrivate *priv;
3637
3638 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3639
3640 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3640, ((const char*) (__func__
))
);
3641
3642 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3643
3644 if (priv->view) {
3645 eom_scroll_view_zoom_in (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3646 }
3647}
3648
3649static void
3650eom_window_cmd_zoom_out (GtkAction *action, gpointer user_data)
3651{
3652 EomWindowPrivate *priv;
3653
3654 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3655
3656 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3656, ((const char*) (__func__
))
);
3657
3658 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3659
3660 if (priv->view) {
3661 eom_scroll_view_zoom_out (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3662 }
3663}
3664
3665static void
3666eom_window_cmd_zoom_normal (GtkAction *action, gpointer user_data)
3667{
3668 EomWindowPrivate *priv;
3669
3670 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3671
3672 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3672, ((const char*) (__func__
))
);
3673
3674 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3675
3676 if (priv->view) {
3677 eom_scroll_view_set_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, 1.0);
3678 }
3679}
3680
3681static void
3682eom_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
3683{
3684 EomWindowPrivate *priv;
3685
3686 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3687
3688 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3688, ((const char*) (__func__
))
);
3689
3690 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3691
3692 if (priv->view) {
3693 eom_scroll_view_zoom_fit (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
3694 }
3695}
3696
3697static void
3698eom_window_cmd_go_prev (GtkAction *action, gpointer user_data)
3699{
3700 EomWindowPrivate *priv;
3701
3702 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3703
3704 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3704, ((const char*) (__func__
))
);
3705
3706 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3707
3708 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3709 EOM_THUMB_VIEW_SELECT_LEFT);
3710}
3711
3712static void
3713eom_window_cmd_go_next (GtkAction *action, gpointer user_data)
3714{
3715 EomWindowPrivate *priv;
3716
3717 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3718
3719 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3719, ((const char*) (__func__
))
);
3720
3721 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3722
3723 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3724 EOM_THUMB_VIEW_SELECT_RIGHT);
3725}
3726
3727static void
3728eom_window_cmd_go_first (GtkAction *action, gpointer user_data)
3729{
3730 EomWindowPrivate *priv;
3731
3732 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3733
3734 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3734, ((const char*) (__func__
))
);
3735
3736 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3737
3738 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3739 EOM_THUMB_VIEW_SELECT_FIRST);
3740}
3741
3742static void
3743eom_window_cmd_go_last (GtkAction *action, gpointer user_data)
3744{
3745 EomWindowPrivate *priv;
3746
3747 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3748
3749 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3749, ((const char*) (__func__
))
);
3750
3751 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3752
3753 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3754 EOM_THUMB_VIEW_SELECT_LAST);
3755}
3756
3757static void
3758eom_window_cmd_go_random (GtkAction *action, gpointer user_data)
3759{
3760 EomWindowPrivate *priv;
3761
3762 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3763
3764 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3764, ((const char*) (__func__
))
);
3765
3766 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3767
3768 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3769 EOM_THUMB_VIEW_SELECT_RANDOM);
3770}
3771
3772static const GtkActionEntry action_entries_window[] = {
3773 { "Image", NULL((void*)0), N_("_Image")("_Image") },
3774 { "Edit", NULL((void*)0), N_("_Edit")("_Edit") },
3775 { "View", NULL((void*)0), N_("_View")("_View") },
3776 { "Go", NULL((void*)0), N_("_Go")("_Go") },
3777 { "Tools", NULL((void*)0), N_("_Tools")("_Tools") },
3778 { "Help", NULL((void*)0), N_("_Help")("_Help") },
3779
3780 { "ImageOpen", "document-open", N_("_Open…")("_Open…"), "<control>O",
3781 N_("Open a file")("Open a file"),
3782 G_CALLBACK (eom_window_cmd_file_open)((GCallback) (eom_window_cmd_file_open)) },
3783 { "ImageClose", "window-close", N_("_Close")("_Close"), "<control>W",
3784 N_("Close window")("Close window"),
3785 G_CALLBACK (eom_window_cmd_close_window)((GCallback) (eom_window_cmd_close_window)) },
3786 { "EditToolbar", NULL((void*)0), N_("T_oolbar")("T_oolbar"), NULL((void*)0),
3787 N_("Edit the application toolbar")("Edit the application toolbar"),
3788 G_CALLBACK (eom_window_cmd_edit_toolbar)((GCallback) (eom_window_cmd_edit_toolbar)) },
3789 { "EditPreferences", "preferences-desktop", N_("Prefere_nces")("Prefere_nces"), NULL((void*)0),
3790 N_("Preferences for Eye of MATE")("Preferences for Eye of MATE"),
3791 G_CALLBACK (eom_window_cmd_preferences)((GCallback) (eom_window_cmd_preferences)) },
3792 { "HelpManual", "help-browser", N_("_Contents")("_Contents"), "F1",
3793 N_("Help on this application")("Help on this application"),
3794 G_CALLBACK (eom_window_cmd_help)((GCallback) (eom_window_cmd_help)) },
3795 { "HelpAbout", "help-about", N_("_About")("_About"), NULL((void*)0),
3796 N_("About this application")("About this application"),
3797 G_CALLBACK (eom_window_cmd_about)((GCallback) (eom_window_cmd_about)) }
3798};
3799
3800static const GtkToggleActionEntry toggle_entries_window[] = {
3801 { "ViewToolbar", NULL((void*)0), N_("_Toolbar")("_Toolbar"), NULL((void*)0),
3802 N_("Changes the visibility of the toolbar in the current window")("Changes the visibility of the toolbar in the current window"
)
,
3803 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3804 { "ViewStatusbar", NULL((void*)0), N_("_Statusbar")("_Statusbar"), NULL((void*)0),
3805 N_("Changes the visibility of the statusbar in the current window")("Changes the visibility of the statusbar in the current window"
)
,
3806 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3807 { "ViewImageCollection", "eom-image-collection", N_("_Image Collection")("_Image Collection"), "<control>F9",
3808 N_("Changes the visibility of the image collection pane in the current window")("Changes the visibility of the image collection pane in the current window"
)
,
3809 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3810 { "ViewSidebar", NULL((void*)0), N_("Side _Pane")("Side _Pane"), "F9",
3811 N_("Changes the visibility of the side pane in the current window")("Changes the visibility of the side pane in the current window"
)
,
3812 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3813};
3814
3815static const GtkActionEntry action_entries_image[] = {
3816 { "ImageSave", "document-save", N_("_Save")("_Save"), "<control>s",
3817 N_("Save changes in currently selected images")("Save changes in currently selected images"),
3818 G_CALLBACK (eom_window_cmd_save)((GCallback) (eom_window_cmd_save)) },
3819 { "ImageOpenWith", NULL((void*)0), N_("Open _with")("Open _with"), NULL((void*)0),
3820 N_("Open the selected image with a different application")("Open the selected image with a different application"),
3821 NULL((void*)0)},
3822 { "ImageSaveAs", "document-save-as", N_("Save _As…")("Save _As…"), "<control><shift>s",
3823 N_("Save the selected images with a different name")("Save the selected images with a different name"),
3824 G_CALLBACK (eom_window_cmd_save_as)((GCallback) (eom_window_cmd_save_as)) },
3825 { "ImageOpenContainingFolder", "folder", N_("Open Containing _Folder")("Open Containing _Folder"), NULL((void*)0),
3826 N_("Show the folder which contains this file in the file manager")("Show the folder which contains this file in the file manager"
)
,
3827 G_CALLBACK (eom_window_cmd_open_containing_folder)((GCallback) (eom_window_cmd_open_containing_folder)) },
3828 { "ImagePrint", "document-print", N_("_Print…")("_Print…"), "<control>p",
3829 N_("Print the selected image")("Print the selected image"),
3830 G_CALLBACK (eom_window_cmd_print)((GCallback) (eom_window_cmd_print)) },
3831 { "ImageProperties", "document-properties", N_("Prope_rties")("Prope_rties"), "<alt>Return",
3832 N_("Show the properties and metadata of the selected image")("Show the properties and metadata of the selected image"),
3833 G_CALLBACK (eom_window_cmd_properties)((GCallback) (eom_window_cmd_properties)) },
3834 { "EditUndo", "edit-undo", N_("_Undo")("_Undo"), "<control>z",
3835 N_("Undo the last change in the image")("Undo the last change in the image"),
3836 G_CALLBACK (eom_window_cmd_undo)((GCallback) (eom_window_cmd_undo)) },
3837 { "EditFlipHorizontal", "object-flip-horizontal", N_("Flip _Horizontal")("Flip _Horizontal"), NULL((void*)0),
3838 N_("Mirror the image horizontally")("Mirror the image horizontally"),
3839 G_CALLBACK (eom_window_cmd_flip_horizontal)((GCallback) (eom_window_cmd_flip_horizontal)) },
3840 { "EditFlipVertical", "object-flip-vertical", N_("Flip _Vertical")("Flip _Vertical"), NULL((void*)0),
3841 N_("Mirror the image vertically")("Mirror the image vertically"),
3842 G_CALLBACK (eom_window_cmd_flip_vertical)((GCallback) (eom_window_cmd_flip_vertical)) },
3843 { "EditRotate90", "object-rotate-right", N_("_Rotate Clockwise")("_Rotate Clockwise"), "<control>r",
3844 N_("Rotate the image 90 degrees to the right")("Rotate the image 90 degrees to the right"),
3845 G_CALLBACK (eom_window_cmd_rotate_90)((GCallback) (eom_window_cmd_rotate_90)) },
3846 { "EditRotate270", "object-rotate-left", N_("Rotate Counterc_lockwise")("Rotate Counterc_lockwise"), "<ctrl><shift>r",
3847 N_("Rotate the image 90 degrees to the left")("Rotate the image 90 degrees to the left"),
3848 G_CALLBACK (eom_window_cmd_rotate_270)((GCallback) (eom_window_cmd_rotate_270)) },
3849 { "ImageSetAsWallpaper", NULL((void*)0), N_("Set as _Desktop Background")("Set as _Desktop Background"),
3850 "<control>F8", N_("Set the selected image as the desktop background")("Set the selected image as the desktop background"),
3851 G_CALLBACK (eom_window_cmd_wallpaper)((GCallback) (eom_window_cmd_wallpaper)) },
3852 { "EditMoveToTrash", "user-trash", N_("Move to _Trash")("Move to _Trash"), NULL((void*)0),
3853 N_("Move the selected image to the trash folder")("Move the selected image to the trash folder"),
3854 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3855 { "EditCopyImage", "edit-copy", N_("_Copy")("_Copy"), "<control>C",
3856 N_("Copy the selected image to the clipboard")("Copy the selected image to the clipboard"),
3857 G_CALLBACK (eom_window_cmd_copy_image)((GCallback) (eom_window_cmd_copy_image)) },
3858 { "ViewZoomIn", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>plus",
3859 N_("Enlarge the image")("Enlarge the image"),
3860 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3861 { "ViewZoomOut", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>minus",
3862 N_("Shrink the image")("Shrink the image"),
3863 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3864 { "ViewZoomNormal", "zoom-original", N_("_Normal Size")("_Normal Size"), "<control>0",
3865 N_("Show the image at its normal size")("Show the image at its normal size"),
3866 G_CALLBACK (eom_window_cmd_zoom_normal)((GCallback) (eom_window_cmd_zoom_normal)) },
3867 { "ViewZoomFit", "zoom-fit-best", N_("_Best Fit")("_Best Fit"), "F",
3868 N_("Fit the image to the window")("Fit the image to the window"),
3869 G_CALLBACK (eom_window_cmd_zoom_fit)((GCallback) (eom_window_cmd_zoom_fit)) },
3870 { "ControlEqual", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>equal",
3871 N_("Enlarge the image")("Enlarge the image"),
3872 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3873 { "ControlKpAdd", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>KP_Add",
3874 N_("Shrink the image")("Shrink the image"),
3875 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3876 { "ControlKpSub", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>KP_Subtract",
3877 N_("Shrink the image")("Shrink the image"),
3878 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3879 { "Delete", NULL((void*)0), N_("Move to _Trash")("Move to _Trash"), "Delete",
3880 NULL((void*)0),
3881 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3882};
3883
3884static const GtkToggleActionEntry toggle_entries_image[] = {
3885 { "ViewFullscreen", "view-fullscreen", N_("_Fullscreen")("_Fullscreen"), "F11",
3886 N_("Show the current image in fullscreen mode")("Show the current image in fullscreen mode"),
3887 G_CALLBACK (eom_window_cmd_fullscreen)((GCallback) (eom_window_cmd_fullscreen)), FALSE(0) },
3888 { "PauseSlideshow", "media-playback-pause", N_("Pause Slideshow")("Pause Slideshow"),
3889 NULL((void*)0), N_("Pause or resume the slideshow")("Pause or resume the slideshow"),
3890 G_CALLBACK (eom_window_cmd_pause_slideshow)((GCallback) (eom_window_cmd_pause_slideshow)), FALSE(0) },
3891};
3892
3893static const GtkActionEntry action_entries_collection[] = {
3894 { "GoPrevious", "go-previous", N_("_Previous Image")("_Previous Image"), "<Alt>Left",
3895 N_("Go to the previous image of the collection")("Go to the previous image of the collection"),
3896 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3897 { "GoNext", "go-next", N_("_Next Image")("_Next Image"), "<Alt>Right",
3898 N_("Go to the next image of the collection")("Go to the next image of the collection"),
3899 G_CALLBACK (eom_window_cmd_go_next)((GCallback) (eom_window_cmd_go_next)) },
3900 { "GoFirst", "go-first", N_("_First Image")("_First Image"), "<Alt>Home",
3901 N_("Go to the first image of the collection")("Go to the first image of the collection"),
3902 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3903 { "GoLast", "go-last", N_("_Last Image")("_Last Image"), "<Alt>End",
3904 N_("Go to the last image of the collection")("Go to the last image of the collection"),
3905 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3906 { "GoRandom", NULL((void*)0), N_("_Random Image")("_Random Image"), "<control>M",
3907 N_("Go to a random image of the collection")("Go to a random image of the collection"),
3908 G_CALLBACK (eom_window_cmd_go_random)((GCallback) (eom_window_cmd_go_random)) },
3909 { "BackSpace", NULL((void*)0), N_("_Previous Image")("_Previous Image"), "BackSpace",
3910 NULL((void*)0),
3911 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3912 { "Home", NULL((void*)0), N_("_First Image")("_First Image"), "Home",
3913 NULL((void*)0),
3914 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3915 { "End", NULL((void*)0), N_("_Last Image")("_Last Image"), "End",
3916 NULL((void*)0),
3917 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3918};
3919
3920static const GtkToggleActionEntry toggle_entries_collection[] = {
3921 { "ViewSlideshow", "slideshow-play", N_("S_lideshow")("S_lideshow"), "F5",
3922 N_("Start a slideshow view of the images")("Start a slideshow view of the images"),
3923 G_CALLBACK (eom_window_cmd_slideshow)((GCallback) (eom_window_cmd_slideshow)), FALSE(0) },
3924};
3925
3926static void
3927menu_item_select_cb (GtkMenuItem *proxy, EomWindow *window)
3928{
3929 GtkAction *action;
3930 char *message;
3931
3932 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3933 action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)((((GtkActivatable*) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((gtk_activatable_get_type ()))))))
);
3934 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3935
3936 g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "action != NULL"); return
; } } while (0)
;
3937
3938 g_object_get (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "tooltip", &message, NULL((void*)0));
3939
3940 if (message) {
3941 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3942 window->priv->tip_message_cid, message);
3943 g_free (message);
3944 }
3945}
3946
3947static void
3948menu_item_deselect_cb (GtkMenuItem *proxy, EomWindow *window)
3949{
3950 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3951 window->priv->tip_message_cid);
3952}
3953
3954static void
3955connect_proxy_cb (GtkUIManager *manager,
3956 GtkAction *action,
3957 GtkWidget *proxy,
3958 EomWindow *window)
3959{
3960 if (GTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(proxy)); GType __t = ((gtk_menu_item_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; }))))
) {
3961 disconnect_proxy_cb (manager, action, proxy, window);
3962 g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
3963 G_CALLBACK (menu_item_select_cb), window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
3964 g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3965 G_CALLBACK (menu_item_deselect_cb), window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3966 }
3967}
3968
3969static void
3970disconnect_proxy_cb (GtkUIManager *manager,
3971 GtkAction *action,
3972 GtkWidget *proxy,
3973 EomWindow *window)
3974{
3975 if (GTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(proxy)); GType __t = ((gtk_menu_item_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; }))))
) {
3976 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_select_cb))), (window))
3977 (proxy, G_CALLBACK (menu_item_select_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_select_cb))), (window))
;
3978 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_deselect_cb))), (window))
3979 (proxy, G_CALLBACK (menu_item_deselect_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_deselect_cb))), (window))
;
3980 }
3981}
3982
3983static void
3984set_action_properties (GtkActionGroup *window_group,
3985 GtkActionGroup *image_group,
3986 GtkActionGroup *collection_group)
3987{
3988 GtkAction *action;
3989
3990 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3991 action = gtk_action_group_get_action (collection_group, "GoPrevious");
3992 g_object_set (action, "short_label", _("Previous")gettext ("Previous"), NULL((void*)0));
3993 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3994
3995 action = gtk_action_group_get_action (collection_group, "GoNext");
3996 g_object_set (action, "short_label", _("Next")gettext ("Next"), NULL((void*)0));
3997 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3998
3999 action = gtk_action_group_get_action (image_group, "EditRotate90");
4000 g_object_set (action, "short_label", _("Right")gettext ("Right"), NULL((void*)0));
4001
4002 action = gtk_action_group_get_action (image_group, "EditRotate270");
4003 g_object_set (action, "short_label", _("Left")gettext ("Left"), NULL((void*)0));
4004
4005 action = gtk_action_group_get_action (image_group, "ImageOpenContainingFolder");
4006 g_object_set (action, "short_label", _("Open Folder")gettext ("Open Folder"), NULL((void*)0));
4007
4008 action = gtk_action_group_get_action (image_group, "ViewZoomIn");
4009 g_object_set (action, "short_label", _("In")gettext ("In"), NULL((void*)0));
4010
4011 action = gtk_action_group_get_action (image_group, "ViewZoomOut");
4012 g_object_set (action, "short_label", _("Out")gettext ("Out"), NULL((void*)0));
4013
4014 action = gtk_action_group_get_action (image_group, "ViewZoomNormal");
4015 g_object_set (action, "short_label", _("Normal")gettext ("Normal"), NULL((void*)0));
4016
4017 action = gtk_action_group_get_action (image_group, "ViewZoomFit");
4018 g_object_set (action, "short_label", _("Fit")gettext ("Fit"), NULL((void*)0));
4019
4020 action = gtk_action_group_get_action (window_group, "ViewImageCollection");
4021 g_object_set (action, "short_label", _("Collection")gettext ("Collection"), NULL((void*)0));
4022
4023 action = gtk_action_group_get_action (image_group, "EditMoveToTrash");
4024 g_object_set (action, "short_label", C_("action (to trash)", "Trash")g_dpgettext (((void*)0), "action (to trash)" "\004" "Trash", strlen
("action (to trash)") + 1)
, NULL((void*)0));
4025 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4026}
4027
4028static gint
4029sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
4030{
4031 gboolean has_eom_a, has_eom_b;
4032
4033 /* We need to check this first as gtk_recent_info_get_application_info
4034 * will treat it as a non-fatal error when the GtkRecentInfo doesn't
4035 * have the application registered. */
4036 has_eom_a = gtk_recent_info_has_application (a,
4037 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4038 has_eom_b = gtk_recent_info_has_application (b,
4039 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4040 if (has_eom_a && has_eom_b) {
4041 time_t time_a, time_b;
4042
4043 /* These should not fail as we already checked that
4044 * the application is registered with the info objects */
4045 gtk_recent_info_get_application_info (a,
4046 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4047 NULL((void*)0),
4048 NULL((void*)0),
4049 &time_a);
4050 gtk_recent_info_get_application_info (b,
4051 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4052 NULL((void*)0),
4053 NULL((void*)0),
4054 &time_b);
4055
4056 return (time_b - time_a);
4057 } else if (has_eom_a) {
4058 return -1;
4059 } else if (has_eom_b) {
4060 return 1;
4061 }
4062
4063 return 0;
4064}
4065
4066static void
4067eom_window_update_recent_files_menu (EomWindow *window)
4068{
4069 EomWindowPrivate *priv;
4070 GList *actions = NULL((void*)0), *li = NULL((void*)0), *items = NULL((void*)0);
4071 guint count_recent = 0;
4072
4073 priv = window->priv;
4074
4075 if (priv->recent_menu_id != 0)
4076 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->recent_menu_id);
4077
4078 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4079 actions = gtk_action_group_list_actions (priv->actions_recent);
4080
4081 for (li = actions; li != NULL((void*)0); li = li->next) {
4082 g_signal_handlers_disconnect_by_func (GTK_ACTION (li->data),g_signal_handlers_disconnect_matched ((((((GtkAction*) g_type_check_instance_cast
((GTypeInstance*) ((li->data)), ((gtk_action_get_type ())
)))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_open_recent_cb
))), (window))
4083 G_CALLBACK(eom_window_open_recent_cb),g_signal_handlers_disconnect_matched ((((((GtkAction*) g_type_check_instance_cast
((GTypeInstance*) ((li->data)), ((gtk_action_get_type ())
)))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_open_recent_cb
))), (window))
4084 window)g_signal_handlers_disconnect_matched ((((((GtkAction*) g_type_check_instance_cast
((GTypeInstance*) ((li->data)), ((gtk_action_get_type ())
)))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_open_recent_cb
))), (window))
;
4085
4086 gtk_action_group_remove_action (priv->actions_recent,
4087 GTK_ACTION (li->data)((((GtkAction*) g_type_check_instance_cast ((GTypeInstance*) (
(li->data)), ((gtk_action_get_type ()))))))
);
4088 }
4089 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4090
4091 g_list_free (actions);
4092
4093 priv->recent_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
4094 items = gtk_recent_manager_get_items (gtk_recent_manager_get_default());
4095 items = g_list_sort (items, (GCompareFunc) sort_recents_mru);
4096
4097 for (li = items; li != NULL((void*)0) && count_recent < EOM_RECENT_FILES_LIMIT5; li = li->next) {
4098 gchar *action_name;
4099 gchar *label;
4100 gchar *tip;
4101 gchar **display_name;
4102 gchar *label_filename;
4103 GtkAction *action;
4104 GtkRecentInfo *info = li->data;
4105
4106 /* Sorting moves non-EOM files to the end of the list.
4107 * So no file of interest will follow if this test fails */
4108 if (!gtk_recent_info_has_application (info, EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer"))
4109 break;
4110
4111 count_recent++;
4112
4113 action_name = g_strdup_printf ("recent-info-%d", count_recent);
4114 display_name = g_strsplit (gtk_recent_info_get_display_name (info), "_", -1);
4115 label_filename = g_strjoinv ("__", display_name);
4116 label = g_strdup_printf ("%s_%d. %s",
4117 (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "\xE2\x80\x8F" : ""), count_recent, label_filename);
4118 g_free (label_filename);
4119 g_strfreev (display_name);
4120
4121 tip = gtk_recent_info_get_uri_display (info);
4122
4123 /* This is a workaround for a bug (#351945) regarding
4124 * gtk_recent_info_get_uri_display() and remote URIs.
4125 * mate_vfs_format_uri_for_display is sufficient here
4126 * since the password gets stripped when adding the
4127 * file to the recently used list. */
4128 if (tip == NULL((void*)0))
4129 tip = g_uri_unescape_string (gtk_recent_info_get_uri (info), NULL((void*)0));
4130
4131 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4132 action = gtk_action_new (action_name, label, tip, NULL((void*)0));
4133 gtk_action_set_always_show_image (action, TRUE(!(0)));
4134 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4135
4136 g_object_set_data_full (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info",
4137 gtk_recent_info_ref (info),
4138 (GDestroyNotify) gtk_recent_info_unref);
4139
4140 g_object_set (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "icon-name", "image-x-generic", NULL((void*)0));
4141
4142 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4143 G_CALLBACK (eom_window_open_recent_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4144 window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4145
4146 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4147 gtk_action_group_add_action (priv->actions_recent, action);
4148 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4149
4150 g_object_unref (action);
4151
4152 gtk_ui_manager_add_ui (priv->ui_mgr, priv->recent_menu_id,
4153 "/MainMenu/Image/RecentDocuments",
4154 action_name, action_name,
4155 GTK_UI_MANAGER_AUTO, FALSE(0));
4156
4157 g_free (action_name);
4158 g_free (label);
4159 g_free (tip);
4160 }
4161
4162 g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
4163}
4164
4165static void
4166eom_window_recent_manager_changed_cb (GtkRecentManager *manager, EomWindow *window)
4167{
4168 eom_window_update_recent_files_menu (window);
4169}
4170
4171static void
4172eom_window_drag_data_received (GtkWidget *widget,
4173 GdkDragContext *context,
4174 gint x, gint y,
4175 GtkSelectionData *selection_data,
4176 guint info, guint time)
4177{
4178 GSList *file_list;
4179 EomWindow *window;
4180 GdkAtom target;
4181 GtkWidget *src;
4182
4183 target = gtk_selection_data_get_target (selection_data);
4184
4185 if (!gtk_targets_include_uri (&target, 1))
4186 return;
4187
4188 /* if the request is from another process this will return NULL */
4189 src = gtk_drag_get_source_widget (context);
4190
4191 /* if the drag request originates from the current eom instance, ignore
4192 the request if the source window is the same as the dest window */
4193 if (src &&
4194 gtk_widget_get_toplevel (src) == gtk_widget_get_toplevel (widget))
4195 {
4196 gdk_drag_status (context, 0, time);
4197 return;
4198 }
4199
4200 if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_COPY) {
4201 window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
4202
4203 file_list = eom_util_parse_uri_string_list_to_file_list ((const gchar *) gtk_selection_data_get_data (selection_data));
4204
4205 eom_window_open_file_list (window, file_list);
4206 }
4207}
4208
4209static void
4210eom_window_set_drag_dest (EomWindow *window)
4211{
4212 gtk_drag_dest_set (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
,
4213 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
4214 NULL((void*)0), 0,
4215 GDK_ACTION_COPY | GDK_ACTION_ASK);
4216 gtk_drag_dest_add_uri_targets (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
4217}
4218
4219static void
4220eom_window_sidebar_visibility_changed (GtkWidget *widget, EomWindow *window)
4221{
4222 GtkAction *action;
4223 gboolean visible;
4224
4225 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4226 visible = gtk_widget_get_visible (window->priv->sidebar);
4227
4228 action = gtk_action_group_get_action (window->priv->actions_window,
4229 "ViewSidebar");
4230
4231 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
) != visible)
4232 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
4233 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4234
4235 /* Focus the image */
4236 if (!visible && window->priv->image != NULL((void*)0))
4237 gtk_widget_grab_focus (window->priv->view);
4238}
4239
4240static void
4241eom_window_sidebar_page_added (EomSidebar *sidebar,
4242 GtkWidget *main_widget,
4243 EomWindow *window)
4244{
4245 if (eom_sidebar_get_n_pages (sidebar) == 1) {
4246 GtkAction *action;
4247 gboolean show;
4248
4249 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4250 action = gtk_action_group_get_action (window->priv->actions_window,
4251 "ViewSidebar");
4252
4253 gtk_action_set_sensitive (action, TRUE(!(0)));
4254
4255 show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
4256 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4257
4258 if (show)
4259 gtk_widget_show (GTK_WIDGET (sidebar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(sidebar)), ((gtk_widget_get_type ()))))))
);
4260 }
4261}
4262static void
4263eom_window_sidebar_page_removed (EomSidebar *sidebar,
4264 GtkWidget *main_widget,
4265 EomWindow *window)
4266{
4267 if (eom_sidebar_is_empty (sidebar)) {
4268 GtkAction *action;
4269
4270 gtk_widget_hide (GTK_WIDGET (sidebar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(sidebar)), ((gtk_widget_get_type ()))))))
);
4271
4272 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4273 action = gtk_action_group_get_action (window->priv->actions_window,
4274 "ViewSidebar");
4275
4276 gtk_action_set_sensitive (action, FALSE(0));
4277 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4278 }
4279}
4280
4281static void
4282eom_window_finish_saving (EomWindow *window)
4283{
4284 EomWindowPrivate *priv = window->priv;
4285
4286 gtk_widget_set_sensitive (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
, FALSE(0));
4287
4288 do {
4289 gtk_main_iteration ();
4290 } while (priv->save_job != NULL((void*)0));
4291}
4292
4293static GAppInfo *
4294get_appinfo_for_editor (EomWindow *window)
4295{
4296 /* We want this function to always return the same thing, not
4297 * just for performance reasons, but because if someone edits
4298 * GConf while eom is running, the application could get into an
4299 * inconsistent state. If the editor exists once, it gets added
4300 * to the "available" list of the EggToolbarsModel (for which
4301 * there is no API to remove it). If later the editor no longer
4302 * existed when constructing a new window, we'd be unable to
4303 * construct a GtkAction for the editor for that window, causing
4304 * assertion failures when viewing the "Edit Toolbars" dialog
4305 * (item is available, but can't find the GtkAction for it).
4306 *
4307 * By ensuring we keep the GAppInfo around, we avoid the
4308 * possibility of that situation occurring.
4309 */
4310 static GDesktopAppInfo *app_info = NULL((void*)0);
4311 static gboolean initialised;
4312
4313 if (!initialised) {
4314 gchar *editor;
4315
4316 editor = g_settings_get_string (window->priv->ui_settings,
4317 EOM_CONF_UI_EXTERNAL_EDITOR"external-editor");
4318
4319 if (editor != NULL((void*)0)) {
4320 app_info = g_desktop_app_info_new (editor);
4321 }
4322
4323 initialised = TRUE(!(0));
4324 g_free (editor);
4325 }
4326
4327 return (GAppInfo *) app_info;
4328}
4329
4330static void
4331eom_window_open_editor (GtkAction *action,
4332 EomWindow *window)
4333{
4334 GdkAppLaunchContext *context;
4335 GAppInfo *app_info;
4336 GList files;
4337
4338 app_info = get_appinfo_for_editor (window);
4339
4340 if (app_info == NULL((void*)0))
4341 return;
4342
4343 context = gdk_display_get_app_launch_context (
4344 gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
));
4345 gdk_app_launch_context_set_screen (context,
4346 gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
));
4347 gdk_app_launch_context_set_icon (context,
4348 g_app_info_get_icon (app_info));
4349 gdk_app_launch_context_set_timestamp (context,
4350 gtk_get_current_event_time ());
4351
4352 {
4353 GList f = { eom_image_get_file (window->priv->image) };
4354 files = f;
4355 }
4356
4357 g_app_info_launch (app_info, &files,
4358 G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) g_type_check_instance_cast ((GTypeInstance
*) ((context)), ((g_app_launch_context_get_type ()))))))
, NULL((void*)0));
4359
4360 g_object_unref (files.data);
4361 g_object_unref (context);
4362}
4363
4364static void
4365eom_window_add_open_editor_action (EomWindow *window)
4366{
4367 EggToolbarsModel *model;
4368 GAppInfo *app_info;
4369 GtkAction *action;
4370 gchar *tooltip;
4371
4372 app_info = get_appinfo_for_editor (window);
4373
4374 if (app_info == NULL((void*)0))
4375 return;
4376
4377 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
4378 egg_toolbars_model_set_name_flags (model, "OpenEditor",
4379 EGG_TB_MODEL_NAME_KNOWN);
4380
4381 tooltip = g_strdup_printf (_("Edit the current image using %s")gettext ("Edit the current image using %s"),
4382 g_app_info_get_name (app_info));
4383 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4384 action = gtk_action_new ("OpenEditor", _("Edit Image")gettext ("Edit Image"), tooltip, NULL((void*)0));
4385 gtk_action_set_gicon (action, g_app_info_get_icon (app_info));
4386 gtk_action_set_is_important (action, TRUE(!(0)));
4387
4388 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
4389 G_CALLBACK (eom_window_open_editor), window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
;
4390
4391 gtk_action_group_add_action (window->priv->actions_image, action);
4392 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4393
4394 g_object_unref (action);
4395 g_free (tooltip);
4396}
4397
4398static void
4399eom_window_construct_ui (EomWindow *window)
4400{
4401 EomWindowPrivate *priv;
4402
4403 GError *error = NULL((void*)0);
4404
4405 GtkWidget *menubar;
4406 GtkWidget *thumb_popup;
4407 GtkWidget *view_popup;
4408 GtkWidget *hpaned;
4409 GtkWidget *menuitem;
4410
4411 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
4412
4413 priv = window->priv;
4414
4415 priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4416 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, priv->box);
4417 gtk_widget_show (priv->box);
4418
4419 priv->ui_mgr = gtk_ui_manager_new ();
4420
4421 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4422 priv->actions_window = gtk_action_group_new ("MenuActionsWindow");
4423
4424 gtk_action_group_set_translation_domain (priv->actions_window,
4425 GETTEXT_PACKAGE"eom");
4426
4427 gtk_action_group_add_actions (priv->actions_window,
4428 action_entries_window,
4429 G_N_ELEMENTS (action_entries_window)(sizeof (action_entries_window) / sizeof ((action_entries_window
)[0]))
,
4430 window);
4431
4432 gtk_action_group_add_toggle_actions (priv->actions_window,
4433 toggle_entries_window,
4434 G_N_ELEMENTS (toggle_entries_window)(sizeof (toggle_entries_window) / sizeof ((toggle_entries_window
)[0]))
,
4435 window);
4436 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4437
4438 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_window, 0);
4439
4440 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4441 priv->actions_image = gtk_action_group_new ("MenuActionsImage");
4442 gtk_action_group_set_translation_domain (priv->actions_image,
4443 GETTEXT_PACKAGE"eom");
4444
4445 gtk_action_group_add_actions (priv->actions_image,
4446 action_entries_image,
4447 G_N_ELEMENTS (action_entries_image)(sizeof (action_entries_image) / sizeof ((action_entries_image
)[0]))
,
4448 window);
4449
4450 eom_window_add_open_editor_action (window);
4451
4452 gtk_action_group_add_toggle_actions (priv->actions_image,
4453 toggle_entries_image,
4454 G_N_ELEMENTS (toggle_entries_image)(sizeof (toggle_entries_image) / sizeof ((toggle_entries_image
)[0]))
,
4455 window);
4456 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4457
4458 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_image, 0);
4459
4460 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4461 priv->actions_collection = gtk_action_group_new ("MenuActionsCollection");
4462 gtk_action_group_set_translation_domain (priv->actions_collection,
4463 GETTEXT_PACKAGE"eom");
4464
4465 gtk_action_group_add_actions (priv->actions_collection,
4466 action_entries_collection,
4467 G_N_ELEMENTS (action_entries_collection)(sizeof (action_entries_collection) / sizeof ((action_entries_collection
)[0]))
,
4468 window);
4469
4470 gtk_action_group_add_toggle_actions (priv->actions_collection,
4471 toggle_entries_collection,
4472 G_N_ELEMENTS (toggle_entries_collection)(sizeof (toggle_entries_collection) / sizeof ((toggle_entries_collection
)[0]))
,
4473 window);
4474 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4475
4476 set_action_properties (priv->actions_window,
4477 priv->actions_image,
4478 priv->actions_collection);
4479
4480 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_collection, 0);
4481
4482 if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
4483 "/org/mate/eom/ui/eom-ui.xml",
4484 &error)) {
4485 g_warning ("building menus failed: %s", error->message);
4486 g_error_free (error);
4487 }
4488
4489 g_signal_connect (priv->ui_mgr, "connect_proxy",g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4490 G_CALLBACK (connect_proxy_cb), window)g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4491 g_signal_connect (priv->ui_mgr, "disconnect_proxy",g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
4492 G_CALLBACK (disconnect_proxy_cb), window)g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
4493
4494 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
4495 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 4495, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
4496 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
, menubar, FALSE(0), FALSE(0), 0);
4497 gtk_widget_show (menubar);
4498
4499 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4500 "/MainMenu/Edit/EditFlipHorizontal");
4501 gtk_image_menu_item_set_always_show_image (
4502 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4503
4504 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4505 "/MainMenu/Edit/EditFlipVertical");
4506 gtk_image_menu_item_set_always_show_image (
4507 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4508
4509 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4510 "/MainMenu/Edit/EditRotate90");
4511 gtk_image_menu_item_set_always_show_image (
4512 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4513
4514 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4515 "/MainMenu/Edit/EditRotate270");
4516 gtk_image_menu_item_set_always_show_image (
4517 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4518
4519 priv->toolbar = GTK_WIDGET((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4520 (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4521 "ui-manager", priv->ui_mgr,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4522 "popup-path", "/ToolbarPopup",((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4523 "model", eom_application_get_toolbars_model (EOM_APP),((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4524 NULL))((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
;
4525
4526 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (priv->toolbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->toolbar)), ((gtk_widget_get_type ()))))))
),
4527 GTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar");
4528
4529 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->toolbar)), ((egg_editable_toolbar_get_type ()))
))))
,
4530 "Toolbar");
4531
4532 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
,
4533 priv->toolbar,
4534 FALSE(0),
4535 FALSE(0),
4536 0);
4537
4538 gtk_widget_show (priv->toolbar);
4539
4540 gtk_window_add_accel_group (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
4541 gtk_ui_manager_get_accel_group (priv->ui_mgr));
4542
4543 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4544 priv->actions_recent = gtk_action_group_new ("RecentFilesActions");
4545 gtk_action_group_set_translation_domain (priv->actions_recent,
4546 GETTEXT_PACKAGE"eom");
4547 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4548
4549 g_signal_connect (gtk_recent_manager_get_default (), "changed",g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4550 G_CALLBACK (eom_window_recent_manager_changed_cb),g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4551 window)g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4552
4553 eom_window_update_recent_files_menu (window);
4554
4555 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_recent, 0);
4556
4557 priv->cbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4558 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
, priv->cbox, TRUE(!(0)), TRUE(!(0)), 0);
4559 gtk_widget_show (priv->cbox);
4560
4561 priv->statusbar = eom_statusbar_new ();
4562 gtk_box_pack_end (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
,
4563 GTK_WIDGET (priv->statusbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->statusbar)), ((gtk_widget_get_type ()))))))
,
4564 FALSE(0), FALSE(0), 0);
4565 gtk_widget_show (priv->statusbar);
4566
4567 priv->image_info_message_cid =
4568 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4569 "image_info_message");
4570 priv->tip_message_cid =
4571 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4572 "tip_message");
4573
4574 priv->layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
4575
4576 hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
4577
4578 priv->sidebar = eom_sidebar_new ();
4579 /* The sidebar shouldn't be shown automatically on show_all(),
4580 but only when the user actually wants it. */
4581 gtk_widget_set_no_show_all (priv->sidebar, TRUE(!(0)));
4582
4583 gtk_widget_set_size_request (priv->sidebar, 210, -1);
4584
4585 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4586 "show",g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4587 G_CALLBACK (eom_window_sidebar_visibility_changed),g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4588 window)g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4589
4590 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4591 "hide",g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4592 G_CALLBACK (eom_window_sidebar_visibility_changed),g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4593 window)g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4594
4595 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4596 "page-added",g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4597 G_CALLBACK (eom_window_sidebar_page_added),g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4598 window)g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4599
4600 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
4601 "page-removed",g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
4602 G_CALLBACK (eom_window_sidebar_page_removed),g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
4603 window)g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
;
4604
4605 priv->view = eom_scroll_view_new ();
4606
4607 eom_sidebar_add_page (EOM_SIDEBAR (priv->sidebar)((((EomSidebar*) g_type_check_instance_cast ((GTypeInstance*)
((priv->sidebar)), ((eom_sidebar_get_type()))))))
,
4608 _("Properties")gettext ("Properties"),
4609 GTK_WIDGET (eom_metadata_sidebar_new (window))((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(eom_metadata_sidebar_new (window))), ((gtk_widget_get_type (
)))))))
);
4610
4611 gtk_widget_set_size_request (GTK_WIDGET (priv->view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->view)), ((gtk_widget_get_type ()))))))
, 100, 100);
4612 g_signal_connect (G_OBJECT (priv->view),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4613 "zoom_changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4614 G_CALLBACK (view_zoom_changed_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4615 window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4616
4617 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_SCROLL_WHEEL_ZOOM"scroll-wheel-zoom",
4618 priv->view, "scrollwheel-zoom", G_SETTINGS_BIND_GET);
4619 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_ZOOM_MULTIPLIER"zoom-multiplier",
4620 priv->view, "zoom-multiplier", G_SETTINGS_BIND_GET);
4621
4622 view_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ViewPopup");
4623 eom_scroll_view_set_popup (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
4624 GTK_MENU (view_popup)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
view_popup)), ((gtk_menu_get_type ()))))))
);
4625
4626 gtk_paned_pack1 (GTK_PANED (hpaned)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(hpaned)), ((gtk_paned_get_type ()))))))
,
4627 priv->sidebar,
4628 FALSE(0),
4629 FALSE(0));
4630
4631 gtk_paned_pack2 (GTK_PANED (hpaned)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(hpaned)), ((gtk_paned_get_type ()))))))
,
4632 priv->view,
4633 TRUE(!(0)),
4634 FALSE(0));
4635
4636 gtk_widget_show_all (hpaned);
4637
4638 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
4639
4640 priv->thumbview = g_object_ref (eom_thumb_view_new ());
4641
4642 /* giving shape to the view */
4643 gtk_icon_view_set_margin (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) g_type_check_instance_cast ((GTypeInstance*
) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 4);
4644 gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) g_type_check_instance_cast ((GTypeInstance*
) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 0);
4645
4646 g_signal_connect (G_OBJECT (priv->thumbview), "selection_changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->thumbview)), (((GType) ((20) <<
(2))))))))), ("selection_changed"), (((GCallback) (handle_image_selection_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4647 G_CALLBACK (handle_image_selection_changed_cb), window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->thumbview)), (((GType) ((20) <<
(2))))))))), ("selection_changed"), (((GCallback) (handle_image_selection_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4648
4649 priv->nav = eom_thumb_nav_new (priv->thumbview,
4650 EOM_THUMB_NAV_MODE_ONE_ROW,
4651 g_settings_get_boolean (priv->ui_settings,
4652 EOM_CONF_UI_SCROLL_BUTTONS"scroll-buttons"));
4653
4654 // Bind the scroll buttons to their GSettings key
4655 g_settings_bind (priv->ui_settings, EOM_CONF_UI_SCROLL_BUTTONS"scroll-buttons",
4656 priv->nav, "show-buttons", G_SETTINGS_BIND_GET);
4657
4658 thumb_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ThumbnailPopup");
4659 eom_thumb_view_set_thumbnail_popup (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
4660 GTK_MENU (thumb_popup)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
thumb_popup)), ((gtk_menu_get_type ()))))))
);
4661
4662 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
4663
4664 gtk_box_pack_end (GTK_BOX (priv->cbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->cbox)), ((gtk_box_get_type ()))))))
, priv->layout, TRUE(!(0)), TRUE(!(0)), 0);
4665
4666 eom_window_can_save_changed_cb (priv->lockdown_settings,
4667 EOM_CONF_LOCKDOWN_CAN_SAVE"disable-save-to-disk",
4668 window);
4669 g_settings_bind (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION_POSITION"image-collection-position",
4670 window, "collection-position", G_SETTINGS_BIND_GET);
4671 g_settings_bind (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION_RESIZABLE"image-collection-resizable",
4672 window, "collection-resizable", G_SETTINGS_BIND_GET);
4673
4674 update_action_groups_state (window);
4675
4676 if ((priv->flags & EOM_STARTUP_FULLSCREEN) ||
4677 (priv->flags & EOM_STARTUP_SLIDE_SHOW)) {
4678 eom_window_run_fullscreen (window, (priv->flags & EOM_STARTUP_SLIDE_SHOW));
4679 } else {
4680 priv->mode = EOM_WINDOW_MODE_NORMAL;
4681 update_ui_visibility (window);
4682 }
4683
4684 eom_window_set_drag_dest (window);
4685}
4686
4687static void
4688eom_window_init (EomWindow *window)
4689{
4690 GdkGeometry hints;
4691 GdkScreen *screen;
4692 EomWindowPrivate *priv;
4693
4694 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 4694, ((const char*) (__func__
))
);
4695
4696 GtkStyleContext *context;
4697
4698 context = gtk_widget_get_style_context (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
4699 gtk_style_context_add_class (context, "eom-window");
4700
4701 hints.min_width = EOM_WINDOW_MIN_WIDTH440;
4702 hints.min_height = EOM_WINDOW_MIN_HEIGHT350;
4703
4704 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
4705
4706 priv = window->priv = eom_window_get_instance_private (window);
4707
4708 priv->view_settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
4709 priv->ui_settings = g_settings_new (EOM_CONF_UI"org.mate.eom"".ui");
4710 priv->fullscreen_settings = g_settings_new (EOM_CONF_FULLSCREEN"org.mate.eom"".full-screen");
4711 priv->lockdown_settings = g_settings_new (EOM_CONF_LOCKDOWN_SCHEMA"org.mate.lockdown");
4712
4713 g_signal_connect (priv->lockdown_settings,g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4714 "changed::" EOM_CONF_LOCKDOWN_CAN_SAVE,g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4715 G_CALLBACK (eom_window_can_save_changed_cb),g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4716 window)g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4717
4718 window->priv->store = NULL((void*)0);
4719 window->priv->image = NULL((void*)0);
4720
4721 window->priv->fullscreen_popup = NULL((void*)0);
4722 window->priv->fullscreen_timeout_source = NULL((void*)0);
4723 window->priv->slideshow_random = FALSE(0);
4724 window->priv->slideshow_loop = FALSE(0);
4725 window->priv->slideshow_switch_timeout = 0;
4726 window->priv->slideshow_switch_source = NULL((void*)0);
4727 window->priv->fullscreen_idle_inhibit_cookie = 0;
4728
4729 gtk_window_set_geometry_hints (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
4730 GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
,
4731 &hints,
4732 GDK_HINT_MIN_SIZE);
4733
4734 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
4735 EOM_WINDOW_DEFAULT_WIDTH540,
4736 EOM_WINDOW_DEFAULT_HEIGHT450);
4737
4738 gtk_window_set_position (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER);
4739
4740 window->priv->mode = EOM_WINDOW_MODE_UNKNOWN;
4741 window->priv->status = EOM_WINDOW_STATUS_UNKNOWN;
4742
4743#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4744 window->priv->display_profile =
4745 eom_window_get_display_profile (screen);
4746#endif
4747
4748 window->priv->recent_menu_id = 0;
4749
4750 window->priv->collection_position = 0;
4751 window->priv->collection_resizable = FALSE(0);
4752
4753 window->priv->save_disabled = FALSE(0);
4754
4755 window->priv->page_setup = NULL((void*)0);
4756
4757 gtk_window_set_application (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, GTK_APPLICATION (EOM_APP)((((GtkApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
);
4758}
4759
4760static void
4761eom_window_dispose (GObject *object)
4762{
4763 EomWindow *window;
4764 EomWindowPrivate *priv;
4765
4766 g_return_if_fail (object != NULL)do { if ((object != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "object != NULL"); return
; } } while (0)
;
4767 g_return_if_fail (EOM_IS_WINDOW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (object)"); return; } } while (0)
;
4768
4769 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 4769, ((const char*) (__func__
))
);
4770
4771 window = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
;
4772 priv = window->priv;
4773
4774 peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
);
4775
4776 if (priv->extensions != NULL((void*)0)) {
4777 g_object_unref (priv->extensions);
4778 priv->extensions = NULL((void*)0);
4779 peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
);
4780 }
4781
4782 if (priv->page_setup != NULL((void*)0)) {
4783 g_object_unref (priv->page_setup);
4784 priv->page_setup = NULL((void*)0);
4785 }
4786
4787 if (priv->thumbview)
4788 {
4789 /* Disconnect so we don't get any unwanted callbacks
4790 * when the thumb view is disposed. */
4791 g_signal_handlers_disconnect_by_func (priv->thumbview,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (handle_image_selection_changed_cb
))), (window))
4792 G_CALLBACK (handle_image_selection_changed_cb),g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (handle_image_selection_changed_cb
))), (window))
4793 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (handle_image_selection_changed_cb
))), (window))
;
4794 g_clear_object (&priv->thumbview)do { _Static_assert (sizeof *((&priv->thumbview)) == sizeof
(gpointer), "Expression evaluates to false"); union { char *
in; gpointer *out; } _pp; gpointer _p; GDestroyNotify _destroy
= (GDestroyNotify) (g_object_unref); _pp.in = (char *) ((&
priv->thumbview)); _p = *_pp.out; if (_p) { *_pp.out = ((void
*)0); _destroy (_p); } } while (0)
;
4795 }
4796
4797 if (priv->store != NULL((void*)0)) {
4798 g_signal_handlers_disconnect_by_func (priv->store,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_added), (window))
4799 eom_window_list_store_image_added,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_added), (window))
4800 window)g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_added), (window))
;
4801 g_signal_handlers_disconnect_by_func (priv->store,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_removed), (window))
4802 eom_window_list_store_image_removed,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_removed), (window))
4803 window)g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_removed), (window))
;
4804 g_object_unref (priv->store);
4805 priv->store = NULL((void*)0);
4806 }
4807
4808 if (priv->image != NULL((void*)0)) {
4809 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
4810 image_thumb_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
4811 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
;
4812 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
4813 image_file_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
4814 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
;
4815 g_object_unref (priv->image);
4816 priv->image = NULL((void*)0);
4817 }
4818
4819 if (priv->actions_window != NULL((void*)0)) {
4820 g_object_unref (priv->actions_window);
4821 priv->actions_window = NULL((void*)0);
4822 }
4823
4824 if (priv->actions_image != NULL((void*)0)) {
4825 g_object_unref (priv->actions_image);
4826 priv->actions_image = NULL((void*)0);
4827 }
4828
4829 if (priv->actions_collection != NULL((void*)0)) {
4830 g_object_unref (priv->actions_collection);
4831 priv->actions_collection = NULL((void*)0);
4832 }
4833
4834 if (priv->actions_recent != NULL((void*)0)) {
4835 g_object_unref (priv->actions_recent);
4836 priv->actions_recent = NULL((void*)0);
4837 }
4838
4839 if (priv->actions_open_with != NULL((void*)0)) {
4840 g_object_unref (priv->actions_open_with);
4841 priv->actions_open_with = NULL((void*)0);
4842 }
4843
4844 fullscreen_clear_timeout (window);
4845
4846 if (window->priv->fullscreen_popup != NULL((void*)0)) {
4847 gtk_widget_destroy (priv->fullscreen_popup);
4848 priv->fullscreen_popup = NULL((void*)0);
4849 }
4850
4851 slideshow_clear_timeout (window);
4852 eom_window_uninhibit_screensaver (window);
4853
4854 g_signal_handlers_disconnect_by_func (gtk_recent_manager_get_default (),g_signal_handlers_disconnect_matched ((gtk_recent_manager_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window))
4855 G_CALLBACK (eom_window_recent_manager_changed_cb),g_signal_handlers_disconnect_matched ((gtk_recent_manager_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window))
4856 window)g_signal_handlers_disconnect_matched ((gtk_recent_manager_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window))
;
4857
4858 priv->recent_menu_id = 0;
4859
4860 eom_window_clear_load_job (window);
4861
4862 eom_window_clear_transform_job (window);
4863
4864 if (priv->view_settings) {
4865 g_object_unref (priv->view_settings);
4866 priv->view_settings = NULL((void*)0);
4867 }
4868 if (priv->ui_settings) {
4869 g_object_unref (priv->ui_settings);
4870 priv->ui_settings = NULL((void*)0);
4871 }
4872 if (priv->fullscreen_settings) {
4873 g_object_unref (priv->fullscreen_settings);
4874 priv->fullscreen_settings = NULL((void*)0);
4875 }
4876 if (priv->lockdown_settings) {
4877 g_object_unref (priv->lockdown_settings);
4878 priv->lockdown_settings = NULL((void*)0);
4879 }
4880
4881 if (priv->file_list != NULL((void*)0)) {
4882 g_slist_free_full (priv->file_list, g_object_unref);
4883 priv->file_list = NULL((void*)0);
4884 }
4885
4886#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4887 if (priv->display_profile != NULL((void*)0)) {
4888 cmsCloseProfile (priv->display_profile);
4889 priv->display_profile = NULL((void*)0);
4890 }
4891#endif
4892
4893 if (priv->last_save_as_folder != NULL((void*)0)) {
4894 g_object_unref (priv->last_save_as_folder);
4895 priv->last_save_as_folder = NULL((void*)0);
4896 }
4897
4898 peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
);
4899
4900 G_OBJECT_CLASS (eom_window_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_window_parent_class
)), (((GType) ((20) << (2))))))))
->dispose (object);
4901}
4902
4903static gint
4904eom_window_delete (GtkWidget *widget, GdkEventAny *event)
4905{
4906 EomWindow *window;
4907 EomWindowPrivate *priv;
4908
4909 g_return_val_if_fail (EOM_IS_WINDOW (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (widget)"); return ((0)); } } while (0)
;
4910
4911 window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
4912 priv = window->priv;
4913
4914 if (priv->save_job != NULL((void*)0)) {
4915 eom_window_finish_saving (window);
4916 }
4917
4918 if (eom_window_unsaved_images_confirm (window)) {
4919 return TRUE(!(0));
4920 }
4921
4922 gtk_widget_destroy (widget);
4923
4924 return TRUE(!(0));
4925}
4926
4927static gint
4928eom_window_key_press (GtkWidget *widget, GdkEventKey *event)
4929{
4930 GtkContainer *tbcontainer = GTK_CONTAINER ((EOM_WINDOW (widget)->priv->toolbar))((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) (((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->toolbar
))), ((gtk_container_get_type ()))))))
;
4931 gint result = FALSE(0);
4932 gboolean handle_selection = FALSE(0);
4933
4934 switch (event->keyval) {
4935 case GDK_KEY_space0x020:
4936 if (event->state & GDK_CONTROL_MASK) {
4937 handle_selection = TRUE(!(0));
4938 break;
4939 }
4940 case GDK_KEY_Return0xff0d:
4941 if (gtk_container_get_focus_child (tbcontainer) == NULL((void*)0)) {
4942 /* Image properties dialog case */
4943 if (event->state & GDK_MOD1_MASK) {
4944 result = FALSE(0);
4945 break;
4946 }
4947
4948 if (event->state & GDK_SHIFT_MASK) {
4949 eom_window_cmd_go_prev (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4950 } else {
4951 eom_window_cmd_go_next (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4952 }
4953 result = TRUE(!(0));
4954 }
4955 break;
4956 case GDK_KEY_p0x070:
4957 case GDK_KEY_P0x050:
4958 if (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_FULLSCREEN || EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
4959 gboolean slideshow;
4960
4961 slideshow = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
4962 eom_window_run_fullscreen (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
, !slideshow);
4963 }
4964 break;
4965 case GDK_KEY_Q0x051:
4966 case GDK_KEY_q0x071:
4967 case GDK_KEY_Escape0xff1b:
4968 if (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_FULLSCREEN) {
4969 eom_window_stop_fullscreen (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
, FALSE(0));
4970 } else if (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
4971 eom_window_stop_fullscreen (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
, TRUE(!(0)));
4972 } else {
4973 eom_window_cmd_close_window (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4974 return TRUE(!(0));
4975 }
4976 break;
4977 case GDK_KEY_Left0xff51:
4978 if (event->state & GDK_MOD1_MASK) {
4979 /* Alt+Left moves to previous image */
4980 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)) { /* move to next in RTL mode */
4981 eom_window_cmd_go_next (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4982 } else {
4983 eom_window_cmd_go_prev (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4984 }
4985 result = TRUE(!(0));
4986 break;
4987 } /* else fall-trough is intended */
4988 case GDK_KEY_Up0xff52:
4989 if (eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
4990 /* break to let scrollview handle the key */
4991 break;
4992 }
4993 if (gtk_container_get_focus_child (tbcontainer) != NULL((void*)0))
4994 break;
4995 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
4996 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) && event->keyval == GDK_KEY_Left0xff51) {
4997 /* handle RTL fall-through,
4998 * need to behave like GDK_Down then */
4999 eom_window_cmd_go_next (NULL((void*)0),
5000 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5001 } else {
5002 eom_window_cmd_go_prev (NULL((void*)0),
5003 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5004 }
5005 result = TRUE(!(0));
5006 break;
5007 }
5008 case GDK_KEY_Right0xff53:
5009 if (event->state & GDK_MOD1_MASK) {
5010 /* Alt+Right moves to next image */
5011 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)) { /* move to previous in RTL mode */
5012 eom_window_cmd_go_prev (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5013 } else {
5014 eom_window_cmd_go_next (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5015 }
5016 result = TRUE(!(0));
5017 break;
5018 } /* else fall-trough is intended */
5019 case GDK_KEY_Down0xff54:
5020 if (eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
5021 /* break to let scrollview handle the key */
5022 break;
5023 }
5024 if (gtk_container_get_focus_child (tbcontainer) != NULL((void*)0))
5025 break;
5026 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
5027 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) && event->keyval == GDK_KEY_Right0xff53) {
5028 /* handle RTL fall-through,
5029 * need to behave like GDK_Up then */
5030 eom_window_cmd_go_prev (NULL((void*)0),
5031 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5032 } else {
5033 eom_window_cmd_go_next (NULL((void*)0),
5034 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5035 }
5036 result = TRUE(!(0));
5037 break;
5038 }
5039 case GDK_KEY_Page_Up0xff55:
5040 if (!eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
5041 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
5042 /* If the iconview is not visible skip to the
5043 * previous image manually as it won't handle
5044 * the keypress then. */
5045 eom_window_cmd_go_prev (NULL((void*)0),
5046 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5047 result = TRUE(!(0));
5048 } else
5049 handle_selection = TRUE(!(0));
5050 }
5051 break;
5052 case GDK_KEY_Page_Down0xff56:
5053 if (!eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
5054 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
5055 /* If the iconview is not visible skip to the
5056 * next image manually as it won't handle
5057 * the keypress then. */
5058 eom_window_cmd_go_next (NULL((void*)0),
5059 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5060 result = TRUE(!(0));
5061 } else
5062 handle_selection = TRUE(!(0));
5063 }
5064 break;
5065 }
5066
5067 /* Update slideshow timeout */
5068 if (result && (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW)) {
5069 slideshow_set_timeout (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5070 }
5071
5072 if (handle_selection == TRUE(!(0)) && result == FALSE(0)) {
5073 gtk_widget_grab_focus (GTK_WIDGET (EOM_WINDOW (widget)->priv->thumbview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->thumbview
)), ((gtk_widget_get_type ()))))))
);
5074
5075 result = gtk_widget_event (GTK_WIDGET (EOM_WINDOW (widget)->priv->thumbview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->thumbview
)), ((gtk_widget_get_type ()))))))
,
5076 (GdkEvent *) event);
5077 }
5078
5079 /* If the focus is not in the toolbar and we still haven't handled the
5080 event, give the scrollview a chance to do it. */
5081 if (!gtk_container_get_focus_child (tbcontainer) && result == FALSE(0) &&
5082 gtk_widget_get_realized (GTK_WIDGET (EOM_WINDOW (widget)->priv->view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((gtk_widget_get_type ()))))))
)) {
5083 result = gtk_widget_event (GTK_WIDGET (EOM_WINDOW (widget)->priv->view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((gtk_widget_get_type ()))))))
,
5084 (GdkEvent *) event);
5085 }
5086
5087 if (result == FALSE(0) && GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event) {
5088 result = (* GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event) (widget, event);
5089 }
5090
5091 return result;
5092}
5093
5094static gint
5095eom_window_button_press (GtkWidget *widget, GdkEventButton *event)
5096{
5097 EomWindow *window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
5098 gint result = FALSE(0);
5099
5100 if (event->type == GDK_BUTTON_PRESS) {
5101 switch (event->button) {
5102 case 6:
5103 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5104 EOM_THUMB_VIEW_SELECT_LEFT);
5105 result = TRUE(!(0));
5106 break;
5107 case 7:
5108 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5109 EOM_THUMB_VIEW_SELECT_RIGHT);
5110 result = TRUE(!(0));
5111 break;
5112 }
5113 }
5114
5115 if (result == FALSE(0) && GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->button_press_event) {
5116 result = (* GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->button_press_event) (widget, event);
5117 }
5118
5119 return result;
5120}
5121
5122static gboolean
5123eom_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
5124{
5125 EomWindow *window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
5126 EomWindowPrivate *priv = window->priv;
5127 gboolean fullscreen;
5128
5129 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5129, ((const char*) (__func__
))
);
5130
5131 fullscreen = priv->mode == EOM_WINDOW_MODE_FULLSCREEN ||
5132 priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
5133
5134 if (fullscreen) {
5135 gtk_widget_hide (priv->fullscreen_popup);
5136 }
5137
5138 return GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->focus_out_event (widget, event);
5139}
5140
5141static void
5142eom_window_set_property (GObject *object,
5143 guint property_id,
5144 const GValue *value,
5145 GParamSpec *pspec)
5146{
5147 EomWindow *window;
5148 EomWindowPrivate *priv;
5149
5150 g_return_if_fail (EOM_IS_WINDOW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (object)"); return; } } while (0)
;
5151
5152 window = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
;
5153 priv = window->priv;
5154
5155 switch (property_id) {
5156 case PROP_COLLECTION_POS:
5157 eom_window_set_collection_mode (window, g_value_get_enum (value),
5158 priv->collection_resizable);
5159 break;
5160 case PROP_COLLECTION_RESIZABLE:
5161 eom_window_set_collection_mode (window, priv->collection_position,
5162 g_value_get_boolean (value));
5163 break;
5164 case PROP_STARTUP_FLAGS:
5165 priv->flags = g_value_get_flags (value);
5166 break;
5167
5168 default:
5169 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-window.c", 5169, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
5170 }
5171}
5172
5173static void
5174eom_window_get_property (GObject *object,
5175 guint property_id,
5176 GValue *value,
5177 GParamSpec *pspec)
5178{
5179 EomWindow *window;
5180 EomWindowPrivate *priv;
5181
5182 g_return_if_fail (EOM_IS_WINDOW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (object)"); return; } } while (0)
;
5183
5184 window = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
;
5185 priv = window->priv;
5186
5187 switch (property_id) {
5188 case PROP_COLLECTION_POS:
5189 g_value_set_enum (value, priv->collection_position);
5190 break;
5191 case PROP_COLLECTION_RESIZABLE:
5192 g_value_set_boolean (value, priv->collection_resizable);
5193 break;
5194 case PROP_STARTUP_FLAGS:
5195 g_value_set_flags (value, priv->flags);
5196 break;
5197
5198 default:
5199 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-window.c", 5199, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
5200 }
5201}
5202
5203static void
5204on_extension_added (PeasExtensionSet *set,
5205 PeasPluginInfo *info,
5206 PeasExtension *exten,
5207 GtkWindow *window)
5208{
5209 peas_extension_call (exten, "activate", window);
5210}
5211
5212static void
5213on_extension_removed (PeasExtensionSet *set,
5214 PeasPluginInfo *info,
5215 PeasExtension *exten,
5216 GtkWindow *window)
5217{
5218 peas_extension_call (exten, "deactivate", window);
5219}
5220
5221static GObject *
5222eom_window_constructor (GType type,
5223 guint n_construct_properties,
5224 GObjectConstructParam *construct_params)
5225{
5226 GObject *object;
5227 EomWindowPrivate *priv;
5228
5229 object = G_OBJECT_CLASS (eom_window_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_window_parent_class
)), (((GType) ((20) << (2))))))))
->constructor
5230 (type, n_construct_properties, construct_params);
5231
5232 priv = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
->priv;
5233
5234 eom_window_construct_ui (EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
);
5235
5236 priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
,
5237 EOM_TYPE_WINDOW_ACTIVATABLE(eom_window_activatable_get_type ()),
5238 "window",
5239 EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
, NULL((void*)0));
5240
5241 peas_extension_set_call (priv->extensions, "activate");
5242
5243 g_signal_connect (priv->extensions, "extension-added",g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
5244 G_CALLBACK (on_extension_added), object)g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
;
5245 g_signal_connect (priv->extensions, "extension-removed",g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
5246 G_CALLBACK (on_extension_removed), object)g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
;
5247
5248 return object;
5249}
5250
5251static void
5252eom_window_class_init (EomWindowClass *class)
5253{
5254 GObjectClass *g_object_class = (GObjectClass *) class;
5255 GtkWidgetClass *widget_class = (GtkWidgetClass *) class;
5256
5257 g_object_class->constructor = eom_window_constructor;
5258 g_object_class->dispose = eom_window_dispose;
5259 g_object_class->set_property = eom_window_set_property;
5260 g_object_class->get_property = eom_window_get_property;
5261
5262 widget_class->delete_event = eom_window_delete;
5263 widget_class->key_press_event = eom_window_key_press;
5264 widget_class->button_press_event = eom_window_button_press;
5265 widget_class->drag_data_received = eom_window_drag_data_received;
5266 widget_class->focus_out_event = eom_window_focus_out_event;
5267
5268/**
5269 * EomWindow:collection-position:
5270 *
5271 * Determines the position of the image collection in the window
5272 * relative to the image.
5273 */
5274 g_object_class_install_property (
5275 g_object_class, PROP_COLLECTION_POS,
5276 g_param_spec_enum ("collection-position", NULL((void*)0), NULL((void*)0),
5277 EOM_TYPE_WINDOW_COLLECTION_POS(eom_window_collection_pos_get_type()),
5278 EOM_WINDOW_COLLECTION_POS_BOTTOM,
5279 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5280
5281/**
5282 * EomWindow:collection-resizable:
5283 *
5284 * If %TRUE the collection will be resizable by the user otherwise it will be
5285 * in single column/row mode.
5286 */
5287 g_object_class_install_property (
5288 g_object_class, PROP_COLLECTION_RESIZABLE,
5289 g_param_spec_boolean ("collection-resizable", NULL((void*)0), NULL((void*)0), FALSE(0),
5290 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5291
5292/**
5293 * EomWindow:startup-flags:
5294 *
5295 * A bitwise OR of #EomStartupFlags elements, indicating how the window
5296 * should behave upon creation.
5297 */
5298 g_object_class_install_property (g_object_class,
5299 PROP_STARTUP_FLAGS,
5300 g_param_spec_flags ("startup-flags",
5301 NULL((void*)0),
5302 NULL((void*)0),
5303 EOM_TYPE_STARTUP_FLAGS(eom_startup_flags_get_type()),
5304 0,
5305 G_PARAM_READWRITE |
5306 G_PARAM_CONSTRUCT_ONLY));
5307
5308/**
5309 * EomWindow::prepared:
5310 * @window: the object which received the signal.
5311 *
5312 * The #EomWindow::prepared signal is emitted when the @window is ready
5313 * to be shown.
5314 */
5315 signals [SIGNAL_PREPARED] =
5316 g_signal_new ("prepared",
5317 EOM_TYPE_WINDOW(eom_window_get_type ()),
5318 G_SIGNAL_RUN_LAST,
5319 G_STRUCT_OFFSET (EomWindowClass, prepared)((glong) __builtin_offsetof(EomWindowClass, prepared)),
5320 NULL((void*)0), NULL((void*)0),
5321 g_cclosure_marshal_VOID__VOID,
5322 G_TYPE_NONE((GType) ((1) << (2))), 0);
5323}
5324
5325/**
5326 * eom_window_new:
5327 * @flags: the initialization parameters for the new window.
5328 *
5329 *
5330 * Creates a new and empty #EomWindow. Use @flags to indicate
5331 * if the window should be initialized fullscreen, in slideshow mode,
5332 * and/or without the thumbnails collection visible. See #EomStartupFlags.
5333 *
5334 * Returns: a newly created #EomWindow.
5335 **/
5336GtkWidget*
5337eom_window_new (EomStartupFlags flags)
5338{
5339 EomWindow *window;
5340
5341 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5341, ((const char*) (__func__
))
);
5342
5343 window = EOM_WINDOW (g_object_new (EOM_TYPE_WINDOW,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5344 "type", GTK_WINDOW_TOPLEVEL,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5345 "application", EOM_APP,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5346 "show-menubar", FALSE,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5347 "startup-flags", flags,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5348 NULL))((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
;
5349
5350 return GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
;
5351}
5352
5353static void
5354eom_window_list_store_image_added (GtkTreeModel *tree_model,
5355 GtkTreePath *path,
5356 GtkTreeIter *iter,
5357 gpointer user_data)
5358{
5359 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
5360
5361 update_image_pos (window);
5362 update_action_groups_state (window);
5363}
5364
5365static void
5366eom_window_list_store_image_removed (GtkTreeModel *tree_model,
5367 GtkTreePath *path,
5368 gpointer user_data)
5369{
5370 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
5371
5372 update_image_pos (window);
5373 update_action_groups_state (window);
5374}
5375
5376static void
5377eom_job_model_cb (EomJobModel *job, gpointer data)
5378{
5379 EomWindow *window;
5380 EomWindowPrivate *priv;
5381 gint n_images;
5382
5383 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5383, ((const char*) (__func__
))
);
5384
5385#ifdef HAVE_EXIF1
5386 int i;
5387 EomImage *image;
5388#endif
5389
5390 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
5391
5392 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
5393 priv = window->priv;
5394
5395 if (priv->store != NULL((void*)0)) {
5396 g_object_unref (priv->store);
5397 priv->store = NULL((void*)0);
5398 }
5399
5400 priv->store = g_object_ref (job->store);
5401
5402 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
5403
5404#ifdef HAVE_EXIF1
5405 if (g_settings_get_boolean (priv->view_settings, EOM_CONF_VIEW_AUTOROTATE"autorotate")) {
5406 for (i = 0; i < n_images; i++) {
5407 image = eom_list_store_get_image_by_pos (priv->store, i);
5408 eom_image_autorotate (image);
5409 g_object_unref (image);
5410 }
5411 }
5412#endif
5413
5414 eom_thumb_view_set_model (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
, priv->store);
5415
5416 g_signal_connect (G_OBJECT (priv->store),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
5417 "row-inserted",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
5418 G_CALLBACK (eom_window_list_store_image_added),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
5419 window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
;
5420
5421 g_signal_connect (G_OBJECT (priv->store),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
5422 "row-deleted",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
5423 G_CALLBACK (eom_window_list_store_image_removed),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
5424 window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5425
5426 if (n_images == 0) {
5427 gint n_files;
5428
5429 priv->status = EOM_WINDOW_STATUS_NORMAL;
5430 update_action_groups_state (window);
5431
5432 n_files = g_slist_length (priv->file_list);
5433
5434 if (n_files > 0) {
5435 GtkWidget *message_area;
5436 GFile *file = NULL((void*)0);
5437
5438 if (n_files == 1) {
5439 file = (GFile *) priv->file_list->data;
5440 }
5441
5442 message_area = eom_no_images_error_message_area_new (file);
5443
5444 eom_window_set_message_area (window, message_area);
5445
5446 gtk_widget_show (message_area);
5447 }
5448
5449 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
5450 }
5451}
5452
5453/**
5454 * eom_window_open_file_list:
5455 * @window: An #EomWindow.
5456 * @file_list: (element-type GFile): A %NULL-terminated list of #GFile's.
5457 *
5458 * Opens a list of files, adding them to the collection in @window.
5459 * Files will be checked to be readable and later filtered according
5460 * with eom_list_store_add_files().
5461 **/
5462void
5463eom_window_open_file_list (EomWindow *window, GSList *file_list)
5464{
5465 EomJob *job;
5466
5467 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5467, ((const char*) (__func__
))
);
5468
5469 window->priv->status = EOM_WINDOW_STATUS_INIT;
5470
5471 g_slist_foreach (file_list, (GFunc) g_object_ref, NULL((void*)0));
5472 window->priv->file_list = file_list;
5473
5474 job = eom_job_model_new (file_list);
5475
5476 g_signal_connect (job,g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5477 "finished",g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5478 G_CALLBACK (eom_job_model_cb),g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5479 window)g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5480
5481 eom_job_queue_add_job (job);
5482 g_object_unref (job);
5483}
5484
5485/**
5486 * eom_window_get_ui_manager:
5487 * @window: An #EomWindow.
5488 *
5489 * Gets the #GtkUIManager that describes the UI of @window.
5490 *
5491 * Returns: (transfer none): A #GtkUIManager.
5492 **/
5493GtkUIManager *
5494eom_window_get_ui_manager (EomWindow *window)
5495{
5496 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5497
5498 return window->priv->ui_mgr;
5499}
5500
5501/**
5502 * eom_window_get_mode:
5503 * @window: An #EomWindow.
5504 *
5505 * Gets the mode of @window. See #EomWindowMode for details.
5506 *
5507 * Returns: An #EomWindowMode.
5508 **/
5509EomWindowMode
5510eom_window_get_mode (EomWindow *window)
5511{
5512 g_return_val_if_fail (EOM_IS_WINDOW (window), EOM_WINDOW_MODE_UNKNOWN)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (EOM_WINDOW_MODE_UNKNOWN
); } } while (0)
;
5513
5514 return window->priv->mode;
5515}
5516
5517/**
5518 * eom_window_set_mode:
5519 * @window: an #EomWindow.
5520 * @mode: an #EomWindowMode value.
5521 *
5522 * Changes the mode of @window to normal, fullscreen, or slideshow.
5523 * See #EomWindowMode for details.
5524 **/
5525void
5526eom_window_set_mode (EomWindow *window, EomWindowMode mode)
5527{
5528 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
5529
5530 if (window->priv->mode == mode)
5531 return;
5532
5533 switch (mode) {
5534 case EOM_WINDOW_MODE_NORMAL:
5535 eom_window_stop_fullscreen (window,
5536 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
5537 break;
5538 case EOM_WINDOW_MODE_FULLSCREEN:
5539 eom_window_run_fullscreen (window, FALSE(0));
5540 break;
5541 case EOM_WINDOW_MODE_SLIDESHOW:
5542 eom_window_run_fullscreen (window, TRUE(!(0)));
5543 break;
5544 case EOM_WINDOW_MODE_UNKNOWN:
5545 break;
5546 }
5547}
5548
5549/**
5550 * eom_window_get_store:
5551 * @window: An #EomWindow.
5552 *
5553 * Gets the #EomListStore that contains the images in the collection
5554 * of @window.
5555 *
5556 * Returns: (transfer none): an #EomListStore.
5557 **/
5558EomListStore *
5559eom_window_get_store (EomWindow *window)
5560{
5561 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5562
5563 return EOM_LIST_STORE (window->priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), (eom_list_store_get_type())
))))
;
5564}
5565
5566/**
5567 * eom_window_get_view:
5568 * @window: An #EomWindow.
5569 *
5570 * Gets the #EomScrollView in the window.
5571 *
5572 * Returns: (transfer none): the #EomScrollView.
5573 **/
5574GtkWidget *
5575eom_window_get_view (EomWindow *window)
5576{
5577 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5578
5579 return window->priv->view;
5580}
5581
5582/**
5583 * eom_window_get_sidebar:
5584 * @window: An #EomWindow.
5585 *
5586 * Gets the sidebar widget of @window.
5587 *
5588 * Returns: (transfer none): the #EomSidebar.
5589 **/
5590GtkWidget *
5591eom_window_get_sidebar (EomWindow *window)
5592{
5593 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5594
5595 return window->priv->sidebar;
5596}
5597
5598/**
5599 * eom_window_get_thumb_view:
5600 * @window: an #EomWindow.
5601 *
5602 * Gets the thumbnails view in @window.
5603 *
5604 * Returns: (transfer none): an #EomThumbView.
5605 **/
5606GtkWidget *
5607eom_window_get_thumb_view (EomWindow *window)
5608{
5609 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5610
5611 return window->priv->thumbview;
5612}
5613
5614/**
5615 * eom_window_get_thumb_nav:
5616 * @window: an #EomWindow.
5617 *
5618 * Gets the thumbnails navigation pane in @window.
5619 *
5620 * Returns: (transfer none): an #EomThumbNav.
5621 **/
5622GtkWidget *
5623eom_window_get_thumb_nav (EomWindow *window)
5624{
5625 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5626
5627 return window->priv->nav;
5628}
5629
5630/**
5631 * eom_window_get_statusbar:
5632 * @window: an #EomWindow.
5633 *
5634 * Gets the statusbar in @window.
5635 *
5636 * Returns: (transfer none): a #EomStatusBar.
5637 **/
5638GtkWidget *
5639eom_window_get_statusbar (EomWindow *window)
5640{
5641 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5642
5643 return window->priv->statusbar;
5644}
5645
5646/**
5647 * eom_window_get_image:
5648 * @window: an #EomWindow.
5649 *
5650 * Gets the image currently displayed in @window or %NULL if
5651 * no image is being displayed.
5652 *
5653 * Returns: (transfer none): an #EomImage.
5654 **/
5655EomImage *
5656eom_window_get_image (EomWindow *window)
5657{
5658 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5659
5660 return window->priv->image;
5661}
5662
5663/**
5664 * eom_window_is_empty:
5665 * @window: an #EomWindow.
5666 *
5667 * Tells whether @window is currently empty or not.
5668 *
5669 * Returns: %TRUE if @window has no images, %FALSE otherwise.
5670 **/
5671gboolean
5672eom_window_is_empty (EomWindow *window)
5673{
5674 EomWindowPrivate *priv;
5675 gboolean empty = TRUE(!(0));
5676
5677 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5677, ((const char*) (__func__
))
);
5678
5679 g_return_val_if_fail (EOM_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return ((0)); } } while (0)
;
5680
5681 priv = window->priv;
5682
5683 if (priv->store != NULL((void*)0)) {
5684 empty = (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0);
5685 }
5686
5687 return empty;
5688}
5689
5690void
5691eom_window_reload_image (EomWindow *window)
5692{
5693 GtkWidget *view;
5694
5695 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
5696
5697 if (window->priv->image == NULL((void*)0))
5698 return;
5699
5700 g_object_unref (window->priv->image);
5701 window->priv->image = NULL((void*)0);
5702
5703 view = eom_window_get_view (window);
5704 eom_scroll_view_set_image (EOM_SCROLL_VIEW (view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
5705
5706 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5707 EOM_THUMB_VIEW_SELECT_CURRENT);
5708}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-1c08b7.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-1c08b7.html new file mode 100644 index 0000000..43a8120 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-1c08b7.html @@ -0,0 +1,532 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/main.c
Warning:line 179, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I ../cut-n-paste/toolbar-editor -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -I /usr/include/gobject-introspection-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - Main
2 *
3 * Copyright (C) 2000-2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Federico Mena-Quintero <federico@gnu.org>
9 * - Jens Finke <jens@gnome.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
24 */
25
26#ifdef HAVE_CONFIG_H1
27#include "config.h"
28#endif
29#ifdef HAVE_INTROSPECTION1
30#include <girepository.h>
31#endif
32
33#include "eom-session.h"
34#include "eom-debug.h"
35#include "eom-thumbnail.h"
36#include "eom-job-queue.h"
37#include "eom-application.h"
38#include "eom-application-internal.h"
39#include "eom-util.h"
40
41#include <string.h>
42#include <stdlib.h>
43#include <glib/gi18n.h>
44
45#if HAVE_EXEMPI1
46#include <exempi/xmp.h>
47#endif
48
49#define EOM_CSS_FILE_PATH"/usr/local/share/eom" "/" "eom.css" EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "eom.css"
50
51static EomStartupFlags flags;
52
53static gboolean fullscreen = FALSE(0);
54static gboolean slide_show = FALSE(0);
55static gboolean disable_collection = FALSE(0);
56static gboolean force_new_instance = FALSE(0);
57static gchar **startup_files = NULL((void*)0);
58
59static gboolean
60_print_version_and_exit (const gchar *option_name,
61 const gchar *value,
62 gpointer data,
63 GError **error)
64{
65 g_print("%s %s\n", _("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"), VERSION"1.24.0");
66 exit (EXIT_SUCCESS0);
67 return TRUE(!(0));
68}
69
70static const GOptionEntry goption_options[] =
71{
72 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) },
73 { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) },
74 { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) },
75 { "new-instance", 'n', 0, G_OPTION_ARG_NONE, &force_new_instance, N_("Start a new instance instead of reusing an existing one")("Start a new instance instead of reusing an existing one"), NULL((void*)0) },
76 { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
77 _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)},
78 { NULL((void*)0) }
79};
80
81static void
82set_startup_flags (void)
83{
84 if (fullscreen)
85 flags |= EOM_STARTUP_FULLSCREEN;
86
87 if (disable_collection)
88 flags |= EOM_STARTUP_DISABLE_COLLECTION;
89
90 if (slide_show)
91 flags |= EOM_STARTUP_SLIDE_SHOW;
92}
93
94int
95main (int argc, char **argv)
96{
97 GError *error = NULL((void*)0);
98 GOptionContext *ctx;
99 GFile *css_file;
100 GtkCssProvider *provider;
101
102 bindtextdomain (GETTEXT_PACKAGE"eom", EOM_LOCALE_DIR"/usr/local/share/locale");
103 bind_textdomain_codeset (GETTEXT_PACKAGE"eom", "UTF-8");
104 textdomain (GETTEXT_PACKAGE"eom");
105
106 gdk_set_allowed_backends ("wayland,x11");
107
108 ctx = g_option_context_new (_("[FILE…]")gettext ("[FILE…]"));
109 g_option_context_add_main_entries (ctx, goption_options, PACKAGE"eom");
110 /* Option groups are free'd together with the context
111 * Using gtk_get_option_group here initializes gtk during parsing */
112 g_option_context_add_group (ctx, gtk_get_option_group (TRUE(!(0))));
113#ifdef HAVE_INTROSPECTION1
114 g_option_context_add_group (ctx, g_irepository_get_option_group ());
115#endif
116
117 if (!g_option_context_parse (ctx, &argc, &argv, &error)) {
118 gchar *help_msg;
119
120 /* I18N: The '%s' is replaced with eom's command name. */
121 help_msg = g_strdup_printf (_("Run '%s --help' to see a full "gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
122 "list of available command line "gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
123 "options.")gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
, argv[0]);
124 g_printerr ("%s\n%s\n", error->message, help_msg);
125 g_error_free (error);
126 g_free (help_msg);
127 g_option_context_free (ctx);
128
129 return 1;
130 }
131 g_option_context_free (ctx);
132
133
134 set_startup_flags ();
135
136#ifdef HAVE_EXEMPI1
137 xmp_init();
138#endif
139 eom_debug_init ();
140 eom_job_queue_init ();
141 eom_thumbnail_init ();
142
143 /* Load special style properties for EomThumbView's scrollbar */
144 css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
145 provider = gtk_css_provider_new ();
146 if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
147 css_file,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
148 &error))(!gtk_css_provider_load_from_file(provider, css_file, &error
))
)
149 {
150 g_critical ("Could not load CSS data: %s", error->message);
151 g_clear_error (&error);
152 } else {
153 gtk_style_context_add_provider_for_screen (
154 gdk_screen_get_default(),
155 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) g_type_check_instance_cast ((GTypeInstance
*) ((provider)), ((gtk_style_provider_get_type ()))))))
,
156 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
157 }
158 g_object_unref (provider);
159 g_object_unref (css_file);
160
161 /* Add application specific icons to search path */
162 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
163 EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "icons");
164
165 gtk_window_set_default_icon_name ("eom");
166 g_set_application_name (_("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"));
167
168 EOM_APP(eom_application_get_instance ())->priv->flags = flags;
169 if (force_new_instance) {
170 GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
);
171 app_flags |= G_APPLICATION_NON_UNIQUE;
172 g_application_set_flags (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, app_flags);
173 }
174
175 g_application_run (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, argc, argv);
176 g_object_unref (EOM_APP(eom_application_get_instance ()));
177
178 if (startup_files)
179 g_strfreev (startup_files);
This statement is never executed
180
181#ifdef HAVE_EXEMPI1
182 xmp_terminate();
183#endif
184 return 0;
185}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-2e99e6.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-2e99e6.html new file mode 100644 index 0000000..ed60ffe --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-2e99e6.html @@ -0,0 +1,692 @@ + + + +eom-preferences-dialog.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-preferences-dialog.c
Warning:line 100, column 2
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 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-preferences-dialog.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-preferences-dialog.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - EOM Preferences Dialog
2 *
3 * Copyright (C) 2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Jens Finke <jens@gnome.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25#ifdef HAVE_CONFIG_H1
26#include "config.h"
27#endif
28
29#include "eom-preferences-dialog.h"
30#include "eom-scroll-view.h"
31#include "eom-util.h"
32#include "eom-config-keys.h"
33
34#include <glib.h>
35#include <glib/gi18n.h>
36#include <glib-object.h>
37#include <gtk/gtk.h>
38#include <gio/gio.h>
39#include <libpeas-gtk/peas-gtk-plugin-manager.h>
40
41#define GSETTINGS_OBJECT_KEY"GSETTINGS_KEY" "GSETTINGS_KEY"
42#define GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE" "GSETTINGS_VALUE"
43
44struct _EomPreferencesDialogPrivate {
45 GSettings *view_settings;
46 GSettings *ui_settings;
47 GSettings *fullscreen_settings;
48
49 GtkWidget *notebook;
50 GtkWidget *interpolate_check;
51 GtkWidget *extrapolate_check;
52 GtkWidget *autorotate_check;
53 GtkWidget *bg_color_check;
54 GtkWidget *bg_color_button;
55 GtkWidget *color_radio;
56 GtkWidget *checkpattern_radio;
57 GtkWidget *background_radio;
58 GtkWidget *transp_color_button;
59
60 GtkWidget *upscale_check;
61 GtkWidget *random_check;
62 GtkWidget *loop_check;
63 GtkWidget *seconds_spin;
64
65 GtkWidget *plugin_manager;
66};
67
68static GObject *instance = NULL((void*)0);
69
70G_DEFINE_TYPE_WITH_PRIVATE (EomPreferencesDialog, eom_preferences_dialog, GTK_TYPE_DIALOG)static void eom_preferences_dialog_init (EomPreferencesDialog
*self); static void eom_preferences_dialog_class_init (EomPreferencesDialogClass
*klass); static GType eom_preferences_dialog_get_type_once (
void); static gpointer eom_preferences_dialog_parent_class = (
(void*)0); static gint EomPreferencesDialog_private_offset; static
void eom_preferences_dialog_class_intern_init (gpointer klass
) { eom_preferences_dialog_parent_class = g_type_class_peek_parent
(klass); if (EomPreferencesDialog_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomPreferencesDialog_private_offset); eom_preferences_dialog_class_init
((EomPreferencesDialogClass*) klass); } __attribute__((__unused__
)) static inline gpointer eom_preferences_dialog_get_instance_private
(EomPreferencesDialog *self) { return (((gpointer) ((guint8*
) (self) + (glong) (EomPreferencesDialog_private_offset)))); }
GType eom_preferences_dialog_get_type (void) { static volatile
gsize g_define_type_id__volatile = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer
), "Expression evaluates to false"); (void) (0 ? (gpointer) *
(&g_define_type_id__volatile) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_preferences_dialog_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_preferences_dialog_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_dialog_get_type ()), g_intern_static_string ("EomPreferencesDialog"
), sizeof (EomPreferencesDialogClass), (GClassInitFunc)(void (
*)(void)) eom_preferences_dialog_class_intern_init, sizeof (EomPreferencesDialog
), (GInstanceInitFunc)(void (*)(void)) eom_preferences_dialog_init
, (GTypeFlags) 0); { {{ EomPreferencesDialog_private_offset =
g_type_add_instance_private (g_define_type_id, sizeof (EomPreferencesDialogPrivate
)); };} } return g_define_type_id; }
;
71
72static gboolean
73pd_string_to_rgba_mapping (GValue *value,
74 GVariant *variant,
75 gpointer user_data)
76{
77 GdkRGBA color;
78
79 g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING), FALSE)do { if ((g_variant_is_of_type (variant, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)"
); return ((0)); } } while (0)
;
80
81 if (gdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) {
82 g_value_set_boxed (value, &color);
83 return TRUE(!(0));
84 }
85
86 return FALSE(0);
87}
88
89static GVariant*
90pd_rgba_to_string_mapping (const GValue *value,
91 const GVariantType *expected_type,
92 gpointer user_data)
93{
94
95 GVariant *variant = NULL((void*)0);
96 GdkRGBA *color;
97 gchar *hex_val;
98
99 g_return_val_if_fail (G_VALUE_TYPE (value) == GDK_TYPE_RGBA, NULL)do { if (((((GValue*) (value))->g_type) == (gdk_rgba_get_type
()))) { } else { g_return_if_fail_warning ("EOM", ((const char
*) (__func__)), "G_VALUE_TYPE (value) == GDK_TYPE_RGBA"); return
(((void*)0)); } } while (0)
;
100 g_return_val_if_fail (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING), NULL)do { if ((g_variant_type_equal (expected_type, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING)"
); return (((void*)0)); } } while (0)
;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
101
102 color = g_value_get_boxed (value);
103 hex_val = gdk_rgba_to_string(color);
104
105 variant = g_variant_new_string (hex_val);
106 g_free (hex_val);
107
108 return variant;
109}
110
111static void
112pd_transp_radio_toggle_cb (GtkWidget *widget, gpointer data)
113{
114 gpointer value = NULL((void*)0);
115
116 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_toggle_button_get_type ()))))))
))
117 return;
118
119 value = g_object_get_data (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE");
120
121 g_settings_set_enum (G_SETTINGS (data)((((GSettings*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((g_settings_get_type ()))))))
, EOM_CONF_VIEW_TRANSPARENCY"transparency",
122 GPOINTER_TO_INT (value)((gint) (glong) (value)));
123}
124
125static void
126random_change_cb (GSettings *settings, gchar *key, GtkWidget *widget)
127{
128 gtk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key));
129}
130
131static void
132eom_preferences_response_cb (GtkDialog *dlg, gint res_id, gpointer data)
133{
134 switch (res_id) {
135 case GTK_RESPONSE_HELP:
136 eom_util_show_help ("eom-prefs", NULL((void*)0));
137 break;
138 default:
139 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_widget_get_type ()))))))
);
140 instance = NULL((void*)0);
141 }
142}
143
144static void
145eom_preferences_dialog_class_init (EomPreferencesDialogClass *klass)
146{
147 GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
148
149 /* This should make sure the libpeas-gtk dependency isn't
150 * dropped by aggressive linkers (#739618) */
151 g_type_ensure (PEAS_GTK_TYPE_PLUGIN_MANAGER(peas_gtk_plugin_manager_get_type()));
152
153 gtk_widget_class_set_template_from_resource (widget_class,
154 "/org/mate/eom/ui/eom-preferences-dialog.ui");
155 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
156 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
157 notebook)gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
;
158 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
159 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
160 interpolate_check)gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
;
161 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
162 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
163 extrapolate_check)gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
;
164 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
165 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
166 autorotate_check)gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
;
167 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
168 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
169 bg_color_check)gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
;
170 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
171 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
172 bg_color_button)gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
;
173 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
174 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
175 color_radio)gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
;
176 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
177 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
178 checkpattern_radio)gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
;
179 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
180 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
181 background_radio)gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
;
182 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
183 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
184 transp_color_button)gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
;
185
186 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
187 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
188 upscale_check)gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
;
189 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
190 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
191 random_check)gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
;
192 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
193 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
194 loop_check)gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
;
195 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
196 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
197 seconds_spin)gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
;
198
199 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
200 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
201 plugin_manager)gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
;
202}
203
204static void
205eom_preferences_dialog_init (EomPreferencesDialog *pref_dlg)
206{
207 EomPreferencesDialogPrivate *priv;
208
209 pref_dlg->priv = eom_preferences_dialog_get_instance_private (pref_dlg);
210 priv = pref_dlg->priv;
211
212 gtk_widget_init_template (GTK_WIDGET (pref_dlg)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(pref_dlg)), ((gtk_widget_get_type ()))))))
);
213
214 priv->view_settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
215 priv->fullscreen_settings = g_settings_new (EOM_CONF_FULLSCREEN"org.mate.eom"".full-screen");
216
217 g_signal_connect (G_OBJECT (pref_dlg),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
218 "response",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
219 G_CALLBACK (eom_preferences_response_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
220 pref_dlg)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
;
221
222 g_settings_bind (priv->view_settings,
223 EOM_CONF_VIEW_INTERPOLATE"interpolate",
224 priv->interpolate_check, "active",
225 G_SETTINGS_BIND_DEFAULT);
226 g_settings_bind (priv->view_settings,
227 EOM_CONF_VIEW_EXTRAPOLATE"extrapolate",
228 priv->extrapolate_check, "active",
229 G_SETTINGS_BIND_DEFAULT);
230 g_settings_bind (priv->view_settings,
231 EOM_CONF_VIEW_AUTOROTATE"autorotate",
232 priv->autorotate_check, "active",
233 G_SETTINGS_BIND_DEFAULT);
234 g_settings_bind (priv->view_settings,
235 EOM_CONF_VIEW_USE_BG_COLOR"use-background-color",
236 priv->bg_color_check, "active",
237 G_SETTINGS_BIND_DEFAULT);
238
239 g_settings_bind_with_mapping (priv->view_settings,
240 EOM_CONF_VIEW_BACKGROUND_COLOR"background-color",
241 priv->bg_color_button, "rgba",
242 G_SETTINGS_BIND_DEFAULT,
243 pd_string_to_rgba_mapping,
244 pd_rgba_to_string_mapping,
245 NULL((void*)0), NULL((void*)0));
246 g_object_set_data (G_OBJECT (priv->color_radio)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->color_radio)), (((GType) ((20) << (2))))))))
,
247 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
248 GINT_TO_POINTER (EOM_TRANSP_COLOR)((gpointer) (glong) (EOM_TRANSP_COLOR)));
249
250 g_signal_connect (G_OBJECT (priv->color_radio),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
251 "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
252 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
253 priv->view_settings)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
254
255 g_object_set_data (G_OBJECT (priv->checkpattern_radio)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->checkpattern_radio)), (((GType) ((20) << (2)))
)))))
,
256 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
257 GINT_TO_POINTER (EOM_TRANSP_CHECKED)((gpointer) (glong) (EOM_TRANSP_CHECKED)));
258
259 g_signal_connect (G_OBJECT (priv->checkpattern_radio),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
260 "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
261 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
262 priv->view_settings)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
263
264 g_object_set_data (G_OBJECT (priv->background_radio)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->background_radio)), (((GType) ((20) << (2)))))
)))
,
265 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
266 GINT_TO_POINTER (EOM_TRANSP_BACKGROUND)((gpointer) (glong) (EOM_TRANSP_BACKGROUND)));
267
268 g_signal_connect (G_OBJECT (priv->background_radio),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
269 "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
270 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
271 priv->view_settings)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
272
273 switch (g_settings_get_enum (priv->view_settings,
274 EOM_CONF_VIEW_TRANSPARENCY"transparency"))
275 {
276 case EOM_TRANSP_COLOR:
277 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->color_radio)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), ((gtk_toggle_button_get_type ())
)))))
, TRUE(!(0)));
278 break;
279 case EOM_TRANSP_CHECKED:
280 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkpattern_radio)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
281 break;
282 default:
283 // Log a warning and use EOM_TRANSP_BACKGROUND as fallback
284 g_warn_if_reached ()do { g_warn_message ("EOM", "eom-preferences-dialog.c", 284, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
285 case EOM_TRANSP_BACKGROUND:
286 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->background_radio)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
287 break;
288 }
289
290 g_settings_bind_with_mapping (priv->view_settings,
291 EOM_CONF_VIEW_TRANS_COLOR"trans-color",
292 priv->transp_color_button, "rgba",
293 G_SETTINGS_BIND_DEFAULT,
294 pd_string_to_rgba_mapping,
295 pd_rgba_to_string_mapping,
296 NULL((void*)0), NULL((void*)0));
297
298 g_settings_bind (priv->fullscreen_settings, EOM_CONF_FULLSCREEN_UPSCALE"upscale",
299 priv->upscale_check, "active",
300 G_SETTINGS_BIND_DEFAULT);
301
302 g_settings_bind (priv->fullscreen_settings,
303 EOM_CONF_FULLSCREEN_LOOP"loop",
304 priv->loop_check, "active",
305 G_SETTINGS_BIND_DEFAULT);
306
307 g_settings_bind (priv->fullscreen_settings,
308 EOM_CONF_FULLSCREEN_RANDOM"random",
309 priv->random_check, "active",
310 G_SETTINGS_BIND_DEFAULT);
311 g_signal_connect (priv->fullscreen_settings,g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
312 "changed::" EOM_CONF_FULLSCREEN_RANDOM,g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
313 G_CALLBACK (random_change_cb),g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
314 priv->loop_check)g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
;
315 random_change_cb (priv->fullscreen_settings,
316 EOM_CONF_FULLSCREEN_RANDOM"random",
317 priv->loop_check);
318
319 g_settings_bind (priv->fullscreen_settings,
320 EOM_CONF_FULLSCREEN_SECONDS"seconds",
321 priv->seconds_spin, "value",
322 G_SETTINGS_BIND_DEFAULT);
323
324 gtk_widget_show_all (priv->plugin_manager);
325
326 /* Add tab scrolling support for GTK3 */
327 gtk_widget_add_events (priv->notebook, GDK_SCROLL_MASK);
328 g_signal_connect (priv->notebook,g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
329 "scroll-event",g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
330 G_CALLBACK (eom_notebook_scroll_event_cb),g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
331 NULL)g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
332}
333
334GtkWidget *eom_preferences_dialog_get_instance (GtkWindow *parent)
335{
336 if (instance == NULL((void*)0)) {
337 instance = g_object_new (EOM_TYPE_PREFERENCES_DIALOG(eom_preferences_dialog_get_type ()),
338 NULL((void*)0));
339 }
340
341 if (parent)
342 gtk_window_set_transient_for (GTK_WINDOW (instance)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(instance)), ((gtk_window_get_type ()))))))
, parent);
343
344 return GTK_WIDGET(instance)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(instance)), ((gtk_widget_get_type ()))))))
;
345}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-398af3.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-398af3.html new file mode 100644 index 0000000..827487c --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-398af3.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 409, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
This statement is never executed
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-3a0b24.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-3a0b24.html new file mode 100644 index 0000000..7dd503c --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-3a0b24.html @@ -0,0 +1,532 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/main.c
Warning:line 170, column 33
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I ../cut-n-paste/toolbar-editor -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -I /usr/include/gobject-introspection-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - Main
2 *
3 * Copyright (C) 2000-2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Federico Mena-Quintero <federico@gnu.org>
9 * - Jens Finke <jens@gnome.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
24 */
25
26#ifdef HAVE_CONFIG_H1
27#include "config.h"
28#endif
29#ifdef HAVE_INTROSPECTION1
30#include <girepository.h>
31#endif
32
33#include "eom-session.h"
34#include "eom-debug.h"
35#include "eom-thumbnail.h"
36#include "eom-job-queue.h"
37#include "eom-application.h"
38#include "eom-application-internal.h"
39#include "eom-util.h"
40
41#include <string.h>
42#include <stdlib.h>
43#include <glib/gi18n.h>
44
45#if HAVE_EXEMPI1
46#include <exempi/xmp.h>
47#endif
48
49#define EOM_CSS_FILE_PATH"/usr/local/share/eom" "/" "eom.css" EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "eom.css"
50
51static EomStartupFlags flags;
52
53static gboolean fullscreen = FALSE(0);
54static gboolean slide_show = FALSE(0);
55static gboolean disable_collection = FALSE(0);
56static gboolean force_new_instance = FALSE(0);
57static gchar **startup_files = NULL((void*)0);
58
59static gboolean
60_print_version_and_exit (const gchar *option_name,
61 const gchar *value,
62 gpointer data,
63 GError **error)
64{
65 g_print("%s %s\n", _("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"), VERSION"1.24.0");
66 exit (EXIT_SUCCESS0);
67 return TRUE(!(0));
68}
69
70static const GOptionEntry goption_options[] =
71{
72 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) },
73 { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) },
74 { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) },
75 { "new-instance", 'n', 0, G_OPTION_ARG_NONE, &force_new_instance, N_("Start a new instance instead of reusing an existing one")("Start a new instance instead of reusing an existing one"), NULL((void*)0) },
76 { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
77 _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)},
78 { NULL((void*)0) }
79};
80
81static void
82set_startup_flags (void)
83{
84 if (fullscreen)
85 flags |= EOM_STARTUP_FULLSCREEN;
86
87 if (disable_collection)
88 flags |= EOM_STARTUP_DISABLE_COLLECTION;
89
90 if (slide_show)
91 flags |= EOM_STARTUP_SLIDE_SHOW;
92}
93
94int
95main (int argc, char **argv)
96{
97 GError *error = NULL((void*)0);
98 GOptionContext *ctx;
99 GFile *css_file;
100 GtkCssProvider *provider;
101
102 bindtextdomain (GETTEXT_PACKAGE"eom", EOM_LOCALE_DIR"/usr/local/share/locale");
103 bind_textdomain_codeset (GETTEXT_PACKAGE"eom", "UTF-8");
104 textdomain (GETTEXT_PACKAGE"eom");
105
106 gdk_set_allowed_backends ("wayland,x11");
107
108 ctx = g_option_context_new (_("[FILE…]")gettext ("[FILE…]"));
109 g_option_context_add_main_entries (ctx, goption_options, PACKAGE"eom");
110 /* Option groups are free'd together with the context
111 * Using gtk_get_option_group here initializes gtk during parsing */
112 g_option_context_add_group (ctx, gtk_get_option_group (TRUE(!(0))));
113#ifdef HAVE_INTROSPECTION1
114 g_option_context_add_group (ctx, g_irepository_get_option_group ());
115#endif
116
117 if (!g_option_context_parse (ctx, &argc, &argv, &error)) {
118 gchar *help_msg;
119
120 /* I18N: The '%s' is replaced with eom's command name. */
121 help_msg = g_strdup_printf (_("Run '%s --help' to see a full "gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
122 "list of available command line "gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
123 "options.")gettext ("Run '%s --help' to see a full " "list of available command line "
"options.")
, argv[0]);
124 g_printerr ("%s\n%s\n", error->message, help_msg);
125 g_error_free (error);
126 g_free (help_msg);
127 g_option_context_free (ctx);
128
129 return 1;
130 }
131 g_option_context_free (ctx);
132
133
134 set_startup_flags ();
135
136#ifdef HAVE_EXEMPI1
137 xmp_init();
138#endif
139 eom_debug_init ();
140 eom_job_queue_init ();
141 eom_thumbnail_init ();
142
143 /* Load special style properties for EomThumbView's scrollbar */
144 css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
145 provider = gtk_css_provider_new ();
146 if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
147 css_file,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
148 &error))(!gtk_css_provider_load_from_file(provider, css_file, &error
))
)
149 {
150 g_critical ("Could not load CSS data: %s", error->message);
151 g_clear_error (&error);
152 } else {
153 gtk_style_context_add_provider_for_screen (
154 gdk_screen_get_default(),
155 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) g_type_check_instance_cast ((GTypeInstance
*) ((provider)), ((gtk_style_provider_get_type ()))))))
,
156 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
157 }
158 g_object_unref (provider);
159 g_object_unref (css_file);
160
161 /* Add application specific icons to search path */
162 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
163 EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "icons");
164
165 gtk_window_set_default_icon_name ("eom");
166 g_set_application_name (_("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"));
167
168 EOM_APP(eom_application_get_instance ())->priv->flags = flags;
169 if (force_new_instance) {
170 GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
);
This statement is never executed
171 app_flags |= G_APPLICATION_NON_UNIQUE;
172 g_application_set_flags (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, app_flags);
173 }
174
175 g_application_run (G_APPLICATION (EOM_APP)((((GApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, argc, argv);
176 g_object_unref (EOM_APP(eom_application_get_instance ()));
177
178 if (startup_files)
179 g_strfreev (startup_files);
180
181#ifdef HAVE_EXEMPI1
182 xmp_terminate();
183#endif
184 return 0;
185}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-47a5b9.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-47a5b9.html new file mode 100644 index 0000000..c1a88ed --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-47a5b9.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 403, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
This statement is never executed
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-604cce.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-604cce.html new file mode 100644 index 0000000..9f6b831 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-604cce.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 398, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
This statement is never executed
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-607f9b.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-607f9b.html new file mode 100644 index 0000000..c75f2e9 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-607f9b.html @@ -0,0 +1,2816 @@ + + + +eom-image.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-image.c
Warning:line 963, column 8
Null pointer passed to 1st parameter expecting 'nonnull'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-image.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-image.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - Image
2 *
3 * Copyright (C) 2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include "config.h"
24#endif
25
26#define GDK_PIXBUF_ENABLE_BACKEND
27#include <gdk/gdkx.h>
28
29#include "eom-image.h"
30#include "eom-image-private.h"
31#include "eom-debug.h"
32
33#ifdef HAVE_JPEG1
34#include "eom-image-jpeg.h"
35#endif
36
37#include "eom-marshal.h"
38#include "eom-pixbuf-util.h"
39#include "eom-metadata-reader.h"
40#include "eom-image-save-info.h"
41#include "eom-transform.h"
42#include "eom-util.h"
43#include "eom-jobs.h"
44#include "eom-thumbnail.h"
45
46#include <unistd.h>
47#include <string.h>
48
49#include <glib.h>
50#include <glib-object.h>
51#include <glib/gi18n.h>
52#include <gtk/gtk.h>
53#include <gdk-pixbuf/gdk-pixbuf.h>
54
55#ifdef HAVE_EXIF1
56#include "eom-exif-util.h"
57#include <libexif/exif-data.h>
58#include <libexif/exif-utils.h>
59#include <libexif/exif-loader.h>
60#endif
61
62#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
63#include <lcms2.h>
64#ifndef EXIF_TAG_GAMMA0xa500
65#define EXIF_TAG_GAMMA0xa500 0xa500
66#endif
67#endif
68
69#ifdef HAVE_RSVG1
70#include <librsvg/rsvg.h>
71#endif
72
73G_DEFINE_TYPE_WITH_PRIVATE (EomImage, eom_image, G_TYPE_OBJECT)static void eom_image_init (EomImage *self); static void eom_image_class_init
(EomImageClass *klass); static GType eom_image_get_type_once
(void); static gpointer eom_image_parent_class = ((void*)0);
static gint EomImage_private_offset; static void eom_image_class_intern_init
(gpointer klass) { eom_image_parent_class = g_type_class_peek_parent
(klass); if (EomImage_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomImage_private_offset); eom_image_class_init (
(EomImageClass*) klass); } __attribute__((__unused__)) static
inline gpointer eom_image_get_instance_private (EomImage *self
) { return (((gpointer) ((guint8*) (self) + (glong) (EomImage_private_offset
)))); } GType eom_image_get_type (void) { static volatile gsize
g_define_type_id__volatile = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer
), "Expression evaluates to false"); (void) (0 ? (gpointer) *
(&g_define_type_id__volatile) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_image_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_image_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomImage"
), sizeof (EomImageClass), (GClassInitFunc)(void (*)(void)) eom_image_class_intern_init
, sizeof (EomImage), (GInstanceInitFunc)(void (*)(void)) eom_image_init
, (GTypeFlags) 0); { {{ EomImage_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EomImagePrivate)); };} } return g_define_type_id
; }
74
75enum {
76 SIGNAL_CHANGED,
77 SIGNAL_SIZE_PREPARED,
78 SIGNAL_THUMBNAIL_CHANGED,
79 SIGNAL_SAVE_PROGRESS,
80 SIGNAL_NEXT_FRAME,
81 SIGNAL_FILE_CHANGED,
82 SIGNAL_LAST
83};
84
85static guint signals[SIGNAL_LAST] = { 0 };
86
87static GList *supported_mime_types = NULL((void*)0);
88
89#define EOM_IMAGE_READ_BUFFER_SIZE65535 65535
90
91static void
92eom_image_free_mem_private (EomImage *image)
93{
94 EomImagePrivate *priv;
95
96 priv = image->priv;
97
98 if (priv->status == EOM_IMAGE_STATUS_LOADING) {
99 eom_image_cancel_load (image);
100 } else {
101 if (priv->anim_iter != NULL((void*)0)) {
102 g_object_unref (priv->anim_iter);
103 priv->anim_iter = NULL((void*)0);
104 }
105
106 if (priv->anim != NULL((void*)0)) {
107 g_object_unref (priv->anim);
108 priv->anim = NULL((void*)0);
109 }
110
111 priv->is_playing = FALSE(0);
112
113 if (priv->image != NULL((void*)0)) {
114 g_object_unref (priv->image);
115 priv->image = NULL((void*)0);
116 }
117
118#ifdef HAVE_RSVG1
119 if (priv->svg != NULL((void*)0)) {
120 g_object_unref (priv->svg);
121 priv->svg = NULL((void*)0);
122 }
123#endif
124
125#ifdef HAVE_EXIF1
126 if (priv->exif != NULL((void*)0)) {
127 exif_data_unref (priv->exif);
128 priv->exif = NULL((void*)0);
129 }
130#endif
131
132 if (priv->exif_chunk != NULL((void*)0)) {
133 g_free (priv->exif_chunk);
134 priv->exif_chunk = NULL((void*)0);
135 }
136
137 priv->exif_chunk_len = 0;
138
139#ifdef HAVE_EXEMPI1
140 if (priv->xmp != NULL((void*)0)) {
141 xmp_free (priv->xmp);
142 priv->xmp = NULL((void*)0);
143 }
144#endif
145
146#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
147 if (priv->profile != NULL((void*)0)) {
148 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; }))))
) {
149 cmsCloseProfile (priv->profile);
150 }
151 priv->profile = NULL((void*)0);
152 }
153#endif
154
155 priv->status = EOM_IMAGE_STATUS_UNKNOWN;
156 priv->metadata_status = EOM_IMAGE_METADATA_NOT_READ;
157 }
158}
159
160static void
161eom_image_dispose (GObject *object)
162{
163 EomImagePrivate *priv;
164
165 priv = EOM_IMAGE (object)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_image_get_type ()))))))
->priv;
166
167 eom_image_free_mem_private (EOM_IMAGE (object)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_image_get_type ()))))))
);
168
169 if (priv->file) {
170 g_object_unref (priv->file);
171 priv->file = NULL((void*)0);
172 }
173
174 if (priv->caption) {
175 g_free (priv->caption);
176 priv->caption = NULL((void*)0);
177 }
178
179 if (priv->collate_key) {
180 g_free (priv->collate_key);
181 priv->collate_key = NULL((void*)0);
182 }
183
184 if (priv->file_type) {
185 g_free (priv->file_type);
186 priv->file_type = NULL((void*)0);
187 }
188
189 g_mutex_clear (&priv->status_mutex);
190
191 if (priv->trans) {
192 g_object_unref (priv->trans);
193 priv->trans = NULL((void*)0);
194 }
195
196 if (priv->trans_autorotate) {
197 g_object_unref (priv->trans_autorotate);
198 priv->trans_autorotate = NULL((void*)0);
199 }
200
201 if (priv->undo_stack) {
202 g_slist_free_full (priv->undo_stack, g_object_unref);
203 priv->undo_stack = NULL((void*)0);
204 }
205
206 G_OBJECT_CLASS (eom_image_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_image_parent_class
)), (((GType) ((20) << (2))))))))
->dispose (object);
207}
208
209static void
210eom_image_class_init (EomImageClass *klass)
211{
212 GObjectClass *object_class = (GObjectClass*) klass;
213
214 object_class->dispose = eom_image_dispose;
215
216 signals[SIGNAL_SIZE_PREPARED] =
217 g_signal_new ("size-prepared",
218 EOM_TYPE_IMAGE(eom_image_get_type ()),
219 G_SIGNAL_RUN_LAST,
220 G_STRUCT_OFFSET (EomImageClass, size_prepared)((glong) __builtin_offsetof(EomImageClass, size_prepared)),
221 NULL((void*)0), NULL((void*)0),
222 eom_marshal_VOID__INT_INT,
223 G_TYPE_NONE((GType) ((1) << (2))), 2,
224 G_TYPE_INT((GType) ((6) << (2))),
225 G_TYPE_INT((GType) ((6) << (2))));
226
227 signals[SIGNAL_CHANGED] =
228 g_signal_new ("changed",
229 EOM_TYPE_IMAGE(eom_image_get_type ()),
230 G_SIGNAL_RUN_LAST,
231 G_STRUCT_OFFSET (EomImageClass, changed)((glong) __builtin_offsetof(EomImageClass, changed)),
232 NULL((void*)0), NULL((void*)0),
233 g_cclosure_marshal_VOID__VOID,
234 G_TYPE_NONE((GType) ((1) << (2))), 0);
235
236 signals[SIGNAL_THUMBNAIL_CHANGED] =
237 g_signal_new ("thumbnail-changed",
238 EOM_TYPE_IMAGE(eom_image_get_type ()),
239 G_SIGNAL_RUN_LAST,
240 G_STRUCT_OFFSET (EomImageClass, thumbnail_changed)((glong) __builtin_offsetof(EomImageClass, thumbnail_changed)
)
,
241 NULL((void*)0), NULL((void*)0),
242 g_cclosure_marshal_VOID__VOID,
243 G_TYPE_NONE((GType) ((1) << (2))), 0);
244
245 signals[SIGNAL_SAVE_PROGRESS] =
246 g_signal_new ("save-progress",
247 EOM_TYPE_IMAGE(eom_image_get_type ()),
248 G_SIGNAL_RUN_LAST,
249 G_STRUCT_OFFSET (EomImageClass, save_progress)((glong) __builtin_offsetof(EomImageClass, save_progress)),
250 NULL((void*)0), NULL((void*)0),
251 g_cclosure_marshal_VOID__FLOAT,
252 G_TYPE_NONE((GType) ((1) << (2))), 1,
253 G_TYPE_FLOAT((GType) ((14) << (2))));
254 /**
255 * EomImage::next-frame:
256 * @img: the object which received the signal.
257 * @delay: number of milliseconds the current frame will be displayed.
258 *
259 * The ::next-frame signal will be emitted each time an animated image
260 * advances to the next frame.
261 */
262 signals[SIGNAL_NEXT_FRAME] =
263 g_signal_new ("next-frame",
264 EOM_TYPE_IMAGE(eom_image_get_type ()),
265 G_SIGNAL_RUN_LAST,
266 G_STRUCT_OFFSET (EomImageClass, next_frame)((glong) __builtin_offsetof(EomImageClass, next_frame)),
267 NULL((void*)0), NULL((void*)0),
268 g_cclosure_marshal_VOID__INT,
269 G_TYPE_NONE((GType) ((1) << (2))), 1,
270 G_TYPE_INT((GType) ((6) << (2))));
271
272 signals[SIGNAL_FILE_CHANGED] = g_signal_new ("file-changed",
273 EOM_TYPE_IMAGE(eom_image_get_type ()),
274 G_SIGNAL_RUN_LAST,
275 G_STRUCT_OFFSET (EomImageClass, file_changed)((glong) __builtin_offsetof(EomImageClass, file_changed)),
276 NULL((void*)0), NULL((void*)0),
277 g_cclosure_marshal_VOID__VOID,
278 G_TYPE_NONE((GType) ((1) << (2))), 0);
279}
280
281static void
282eom_image_init (EomImage *img)
283{
284 img->priv = eom_image_get_instance_private (img);
285
286 img->priv->file = NULL((void*)0);
287 img->priv->image = NULL((void*)0);
288 img->priv->anim = NULL((void*)0);
289 img->priv->anim_iter = NULL((void*)0);
290 img->priv->is_playing = FALSE(0);
291 img->priv->thumbnail = NULL((void*)0);
292 img->priv->width = -1;
293 img->priv->height = -1;
294 img->priv->modified = FALSE(0);
295 img->priv->file_is_changed = FALSE(0);
296 g_mutex_init (&img->priv->status_mutex);
297 img->priv->status = EOM_IMAGE_STATUS_UNKNOWN;
298 img->priv->metadata_status = EOM_IMAGE_METADATA_NOT_READ;
299 img->priv->undo_stack = NULL((void*)0);
300 img->priv->trans = NULL((void*)0);
301 img->priv->trans_autorotate = NULL((void*)0);
302 img->priv->data_ref_count = 0;
303#ifdef HAVE_EXIF1
304 img->priv->orientation = 0;
305 img->priv->autorotate = FALSE(0);
306 img->priv->exif = NULL((void*)0);
307#endif
308#ifdef HAVE_EXEMPI1
309 img->priv->xmp = NULL((void*)0);
310#endif
311#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
312 img->priv->profile = NULL((void*)0);
313#endif
314#ifdef HAVE_RSVG1
315 img->priv->svg = NULL((void*)0);
316#endif
317}
318
319EomImage *
320eom_image_new_file (GFile *file, const gchar *caption)
321{
322 EomImage *img;
323
324 img = EOM_IMAGE (g_object_new (EOM_TYPE_IMAGE, NULL))((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_image_get_type ()), ((void*)0)))), ((eom_image_get_type
()))))))
;
325
326 img->priv->file = g_object_ref (file);
327 img->priv->caption = g_strdup (caption);
328
329 return img;
330}
331
332GQuark
333eom_image_error_quark (void)
334{
335 static GQuark q = 0;
336
337 if (q == 0) {
338 q = g_quark_from_static_string ("eom-image-error-quark");
339 }
340
341 return q;
342}
343
344static void
345eom_image_update_exif_data (EomImage *image)
346{
347#ifdef HAVE_EXIF1
348 EomImagePrivate *priv;
349 ExifEntry *entry;
350 ExifByteOrder bo;
351
352 eom_debug (DEBUG_IMAGE_DATAEOM_DEBUG_IMAGE_DATA, "eom-image.c", 352, ((const char*) (__func__
))
);
353
354 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
355
356 priv = image->priv;
357
358 if (priv->exif == NULL((void*)0)) return;
359
360 bo = exif_data_get_byte_order (priv->exif);
361
362 /* Update image width */
363 entry = exif_data_get_entry (priv->exif, EXIF_TAG_PIXEL_X_DIMENSION)(exif_content_get_entry(priv->exif->ifd[EXIF_IFD_0],EXIF_TAG_PIXEL_X_DIMENSION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_0],
EXIF_TAG_PIXEL_X_DIMENSION) : exif_content_get_entry(priv->
exif->ifd[EXIF_IFD_1],EXIF_TAG_PIXEL_X_DIMENSION) ? exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_1],EXIF_TAG_PIXEL_X_DIMENSION
) : exif_content_get_entry(priv->exif->ifd[EXIF_IFD_EXIF
],EXIF_TAG_PIXEL_X_DIMENSION) ? exif_content_get_entry(priv->
exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_PIXEL_X_DIMENSION) : exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_GPS],EXIF_TAG_PIXEL_X_DIMENSION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_GPS
],EXIF_TAG_PIXEL_X_DIMENSION) : exif_content_get_entry(priv->
exif->ifd[EXIF_IFD_INTEROPERABILITY],EXIF_TAG_PIXEL_X_DIMENSION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_INTEROPERABILITY
],EXIF_TAG_PIXEL_X_DIMENSION) : ((void*)0))
;
364 if (entry != NULL((void*)0) && (priv->width >= 0)) {
365 if (entry->format == EXIF_FORMAT_LONG)
366 exif_set_long (entry->data, bo, priv->width);
367 else if (entry->format == EXIF_FORMAT_SHORT)
368 exif_set_short (entry->data, bo, priv->width);
369 else
370 g_warning ("Exif entry has unsupported size");
371 }
372
373 /* Update image height */
374 entry = exif_data_get_entry (priv->exif, EXIF_TAG_PIXEL_Y_DIMENSION)(exif_content_get_entry(priv->exif->ifd[EXIF_IFD_0],EXIF_TAG_PIXEL_Y_DIMENSION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_0],
EXIF_TAG_PIXEL_Y_DIMENSION) : exif_content_get_entry(priv->
exif->ifd[EXIF_IFD_1],EXIF_TAG_PIXEL_Y_DIMENSION) ? exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_1],EXIF_TAG_PIXEL_Y_DIMENSION
) : exif_content_get_entry(priv->exif->ifd[EXIF_IFD_EXIF
],EXIF_TAG_PIXEL_Y_DIMENSION) ? exif_content_get_entry(priv->
exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_PIXEL_Y_DIMENSION) : exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_GPS],EXIF_TAG_PIXEL_Y_DIMENSION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_GPS
],EXIF_TAG_PIXEL_Y_DIMENSION) : exif_content_get_entry(priv->
exif->ifd[EXIF_IFD_INTEROPERABILITY],EXIF_TAG_PIXEL_Y_DIMENSION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_INTEROPERABILITY
],EXIF_TAG_PIXEL_Y_DIMENSION) : ((void*)0))
;
375 if (entry != NULL((void*)0) && (priv->height >= 0)) {
376 if (entry->format == EXIF_FORMAT_LONG)
377 exif_set_long (entry->data, bo, priv->height);
378 else if (entry->format == EXIF_FORMAT_SHORT)
379 exif_set_short (entry->data, bo, priv->height);
380 else
381 g_warning ("Exif entry has unsupported size");
382 }
383
384 /* Update image orientation */
385 entry = exif_data_get_entry (priv->exif, EXIF_TAG_ORIENTATION)(exif_content_get_entry(priv->exif->ifd[EXIF_IFD_0],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_0],
EXIF_TAG_ORIENTATION) : exif_content_get_entry(priv->exif->
ifd[EXIF_IFD_1],EXIF_TAG_ORIENTATION) ? exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_1],EXIF_TAG_ORIENTATION) : exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_ORIENTATION) ?
exif_content_get_entry(priv->exif->ifd[EXIF_IFD_EXIF],
EXIF_TAG_ORIENTATION) : exif_content_get_entry(priv->exif->
ifd[EXIF_IFD_GPS],EXIF_TAG_ORIENTATION) ? exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_GPS],EXIF_TAG_ORIENTATION) : exif_content_get_entry
(priv->exif->ifd[EXIF_IFD_INTEROPERABILITY],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(priv->exif->ifd[EXIF_IFD_INTEROPERABILITY
],EXIF_TAG_ORIENTATION) : ((void*)0))
;
386 if (entry != NULL((void*)0)) {
387 if (entry->format == EXIF_FORMAT_LONG)
388 exif_set_long (entry->data, bo, 1);
389 else if (entry->format == EXIF_FORMAT_SHORT)
390 exif_set_short (entry->data, bo, 1);
391 else
392 g_warning ("Exif entry has unsupported size");
393
394 priv->orientation = 1;
395 }
396#endif
397}
398
399static void
400eom_image_real_transform (EomImage *img,
401 EomTransform *trans,
402 gboolean is_undo,
403 EomJob *job)
404{
405 EomImagePrivate *priv;
406 GdkPixbuf *transformed;
407 gboolean modified = FALSE(0);
408
409 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
410 g_return_if_fail (EOM_IS_TRANSFORM (trans))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return; } } while (0)
;
411
412 priv = img->priv;
413
414 if (priv->image != NULL((void*)0)) {
415 transformed = eom_transform_apply (trans, priv->image, job);
416
417 g_object_unref (priv->image);
418 priv->image = transformed;
419
420 priv->width = gdk_pixbuf_get_width (transformed);
421 priv->height = gdk_pixbuf_get_height (transformed);
422
423 modified = TRUE(!(0));
424 }
425
426 if (priv->thumbnail != NULL((void*)0)) {
427 transformed = eom_transform_apply (trans, priv->thumbnail, NULL((void*)0));
428
429 g_object_unref (priv->thumbnail);
430 priv->thumbnail = transformed;
431
432 modified = TRUE(!(0));
433 }
434
435 if (modified) {
436 priv->modified = TRUE(!(0));
437 eom_image_update_exif_data (img);
438 }
439
440 if (priv->trans == NULL((void*)0)) {
441 g_object_ref (trans);
442 priv->trans = trans;
443 } else {
444 EomTransform *composition;
445
446 composition = eom_transform_compose (priv->trans, trans);
447
448 g_object_unref (priv->trans);
449
450 priv->trans = composition;
451 }
452
453 if (!is_undo) {
454 g_object_ref (trans);
455 priv->undo_stack = g_slist_prepend (priv->undo_stack, trans);
456 }
457}
458
459static gboolean
460do_emit_size_prepared_signal (EomImage *img)
461{
462 g_signal_emit (img, signals[SIGNAL_SIZE_PREPARED], 0,
463 img->priv->width, img->priv->height);
464 return FALSE(0);
465}
466
467static void
468eom_image_emit_size_prepared (EomImage *img)
469{
470 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200,
471 (GSourceFunc) do_emit_size_prepared_signal,
472 g_object_ref (img), g_object_unref);
473}
474
475static void
476eom_image_size_prepared (GdkPixbufLoader *loader,
477 gint width,
478 gint height,
479 gpointer data)
480{
481 EomImage *img;
482
483 eom_debug (DEBUG_IMAGE_LOADEOM_DEBUG_IMAGE_LOAD, "eom-image.c", 483, ((const char*) (__func__
))
);
484
485 g_return_if_fail (EOM_IS_IMAGE (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (data)"); return; } } while (0)
;
486
487 img = EOM_IMAGE (data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_image_get_type ()))))))
;
488
489 g_mutex_lock (&img->priv->status_mutex);
490
491 img->priv->width = width;
492 img->priv->height = height;
493
494 g_mutex_unlock (&img->priv->status_mutex);
495
496#ifdef HAVE_EXIF1
497 if (!img->priv->autorotate || img->priv->exif)
498#endif
499 eom_image_emit_size_prepared (img);
500}
501
502static EomMetadataReader*
503check_for_metadata_img_format (EomImage *img, guchar *buffer, guint bytes_read)
504{
505 EomMetadataReader *md_reader = NULL((void*)0);
506
507 eom_debug_message (DEBUG_IMAGE_DATAEOM_DEBUG_IMAGE_DATA, "eom-image.c", 507, ((const char*) (__func__
))
, "Check image format for jpeg: %x%x - length: %i",
508 buffer[0], buffer[1], bytes_read);
509
510 if (bytes_read >= 2) {
511 /* SOI (start of image) marker for JPEGs is 0xFFD8 */
512 if ((buffer[0] == 0xFF) && (buffer[1] == 0xD8)) {
513 md_reader = eom_metadata_reader_new (EOM_METADATA_JPEG);
514 }
515 if (bytes_read >= 8 &&
516 memcmp (buffer, "\x89PNG\x0D\x0A\x1a\x0A", 8) == 0) {
517 md_reader = eom_metadata_reader_new (EOM_METADATA_PNG);
518 }
519 }
520
521 return md_reader;
522}
523
524static gboolean
525eom_image_needs_transformation (EomImage *img)
526{
527 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
528
529 return (img->priv->trans != NULL((void*)0) || img->priv->trans_autorotate != NULL((void*)0));
530}
531
532static gboolean
533eom_image_apply_transformations (EomImage *img, GError **error)
534{
535 GdkPixbuf *transformed = NULL((void*)0);
536 EomTransform *composition = NULL((void*)0);
537 EomImagePrivate *priv;
538
539 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
540
541 priv = img->priv;
542
543 if (priv->trans == NULL((void*)0) && priv->trans_autorotate == NULL((void*)0)) {
544 return TRUE(!(0));
545 }
546
547 if (priv->image == NULL((void*)0)) {
548 g_set_error (error,
549 EOM_IMAGE_ERROReom_image_error_quark (),
550 EOM_IMAGE_ERROR_NOT_LOADED,
551 _("Transformation on unloaded image.")gettext ("Transformation on unloaded image."));
552
553 return FALSE(0);
554 }
555
556 if (priv->trans != NULL((void*)0) && priv->trans_autorotate != NULL((void*)0)) {
557 composition = eom_transform_compose (priv->trans,
558 priv->trans_autorotate);
559 } else if (priv->trans != NULL((void*)0)) {
560 composition = g_object_ref (priv->trans);
561 } else if (priv->trans_autorotate != NULL((void*)0)) {
562 composition = g_object_ref (priv->trans_autorotate);
563 }
564
565 if (composition != NULL((void*)0)) {
566 transformed = eom_transform_apply (composition, priv->image, NULL((void*)0));
567 }
568
569 g_object_unref (priv->image);
570 priv->image = transformed;
571
572 if (transformed != NULL((void*)0)) {
573 priv->width = gdk_pixbuf_get_width (priv->image);
574 priv->height = gdk_pixbuf_get_height (priv->image);
575 } else {
576 g_set_error (error,
577 EOM_IMAGE_ERROReom_image_error_quark (),
578 EOM_IMAGE_ERROR_GENERIC,
579 _("Transformation failed.")gettext ("Transformation failed."));
580 }
581
582 g_object_unref (composition);
583
584 return (transformed != NULL((void*)0));
585}
586
587static void
588eom_image_get_file_info (EomImage *img,
589 goffset *bytes,
590 gchar **mime_type,
591 GError **error)
592{
593 GFileInfo *file_info;
594
595 file_info = g_file_query_info (img->priv->file,
596 G_FILE_ATTRIBUTE_STANDARD_SIZE"standard::size" ","
597 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
598 0, NULL((void*)0), error);
599
600 if (file_info == NULL((void*)0)) {
9
Assuming 'file_info' is equal to NULL
10
Taking true branch
601 if (bytes
10.1
'bytes' is non-null
)
11
Taking true branch
602 *bytes = 0;
603
604 if (mime_type
11.1
'mime_type' is non-null
)
12
Taking true branch
605 *mime_type = NULL((void*)0);
13
Null pointer value stored to 'mime_type'
606
607 g_set_error (error,
608 EOM_IMAGE_ERROReom_image_error_quark (),
609 EOM_IMAGE_ERROR_VFS,
610 "Error in getting image file info");
611 } else {
612 if (bytes)
613 *bytes = g_file_info_get_size (file_info);
614
615 if (mime_type)
616 *mime_type = g_strdup (g_file_info_get_content_type (file_info));
617 g_object_unref (file_info);
618 }
619}
620
621#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
622void
623eom_image_apply_display_profile (EomImage *img, cmsHPROFILE screen)
624{
625 EomImagePrivate *priv;
626 cmsHTRANSFORM transform;
627 gint row, width, rows, stride;
628 guchar *p;
629
630 g_return_if_fail (img != NULL)do { if ((img != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "img != NULL"); return; }
} while (0)
;
631
632 priv = img->priv;
633
634 if (screen == NULL((void*)0)) return;
635 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; }))))
) {
636 return;
637 }
638
639 if (priv->profile == NULL((void*)0)) {
640 /* Check whether GdkPixbuf was able to extract a profile */
641 const char* data = gdk_pixbuf_get_option (priv->image,
642 "icc-profile");
643
644 if(data) {
645 gsize profile_size = 0;
646 guchar *profile_data = g_base64_decode(data,
647 &profile_size);
648
649 if (profile_data && profile_size > 0) {
650 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-image.c", 650, ((const char*) (__func__)
)
,
651 "Using ICC profile "
652 "extracted by GdkPixbuf");
653 priv->profile =
654 cmsOpenProfileFromMem(profile_data,
655 profile_size);
656 g_free(profile_data);
657 }
658 }
659
660 if(priv->profile == NULL((void*)0)) {
661 /* Assume sRGB color space for images without ICC profile */
662 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-image.c", 662, ((const char*) (__func__)
)
, "Image has no ICC profile. "
663 "Assuming sRGB.");
664 priv->profile = cmsCreate_sRGBProfile ();
665 }
666 }
667
668 /* TODO: support other colorspaces than RGB */
669 if (cmsGetColorSpace (priv->profile) != cmsSigRgbData ||
670 cmsGetColorSpace (screen) != cmsSigRgbData) {
671 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-image.c", 671, ((const char*) (__func__)
)
, "One or both ICC profiles not in RGB colorspace; not correcting");
672 return;
673 }
674
675 cmsUInt32Number color_type = TYPE_RGB_8(((4) << 16)|((3) << 3)|(1));
676
677 if (gdk_pixbuf_get_has_alpha (priv->image))
678 color_type = TYPE_RGBA_8(((4) << 16)|((1) << 7)|((3) << 3)|(1));
679
680 transform = cmsCreateTransform (priv->profile,
681 color_type,
682 screen,
683 color_type,
684 INTENT_PERCEPTUAL0,
685 0);
686
687 if (G_LIKELY (transform != NULL)(transform != ((void*)0))) {
688 rows = gdk_pixbuf_get_height (priv->image);
689 width = gdk_pixbuf_get_width (priv->image);
690 stride = gdk_pixbuf_get_rowstride (priv->image);
691 p = gdk_pixbuf_get_pixels (priv->image);
692
693 for (row = 0; row < rows; ++row) {
694 cmsDoTransform (transform, p, p, width);
695 p += stride;
696 }
697 cmsDeleteTransform (transform);
698 }
699}
700
701static void
702eom_image_set_icc_data (EomImage *img, EomMetadataReader *md_reader)
703{
704 EomImagePrivate *priv = img->priv;
705
706 priv->profile = eom_metadata_reader_get_icc_profile (md_reader);
707
708
709}
710#endif
711
712static void
713eom_image_set_orientation (EomImage *img)
714{
715 EomImagePrivate *priv;
716#ifdef HAVE_EXIF1
717 ExifData* exif;
718#endif
719
720 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
721
722 priv = img->priv;
723
724#ifdef HAVE_EXIF1
725 exif = (ExifData*) eom_image_get_exif_info (img);
726
727 if (exif != NULL((void*)0)) {
728 ExifByteOrder o = exif_data_get_byte_order (exif);
729
730 ExifEntry *entry = exif_data_get_entry (exif,(exif_content_get_entry(exif->ifd[EXIF_IFD_0],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_0],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_1],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_1],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_GPS],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_GPS],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_INTEROPERABILITY
],EXIF_TAG_ORIENTATION) ? exif_content_get_entry(exif->ifd
[EXIF_IFD_INTEROPERABILITY],EXIF_TAG_ORIENTATION) : ((void*)0
))
731 EXIF_TAG_ORIENTATION)(exif_content_get_entry(exif->ifd[EXIF_IFD_0],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_0],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_1],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_1],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_EXIF],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_GPS],EXIF_TAG_ORIENTATION
) ? exif_content_get_entry(exif->ifd[EXIF_IFD_GPS],EXIF_TAG_ORIENTATION
) : exif_content_get_entry(exif->ifd[EXIF_IFD_INTEROPERABILITY
],EXIF_TAG_ORIENTATION) ? exif_content_get_entry(exif->ifd
[EXIF_IFD_INTEROPERABILITY],EXIF_TAG_ORIENTATION) : ((void*)0
))
;
732
733 if (entry && entry->data != NULL((void*)0)) {
734 priv->orientation = exif_get_short (entry->data, o);
735 }
736 exif_data_unref (exif);
737 } else
738#endif
739 {
740 GdkPixbuf *pbuf;
741
742 pbuf = eom_image_get_pixbuf (img);
743
744 if (pbuf) {
745 const gchar *o_str;
746
747 o_str = gdk_pixbuf_get_option (pbuf, "orientation");
748 if (o_str) {
749 short t = (short) g_ascii_strtoll (o_str,
750 NULL((void*)0), 10);
751 if (t >= 0 && t < 9)
752 priv->orientation = t;
753 }
754 g_object_unref (pbuf);
755 }
756 }
757
758 if (priv->orientation > 4 &&
759 priv->orientation < 9) {
760 gint tmp;
761
762 tmp = priv->width;
763 priv->width = priv->height;
764 priv->height = tmp;
765 }
766}
767
768static void
769eom_image_real_autorotate (EomImage *img)
770{
771 static const EomTransformType lookup[8] = {EOM_TRANSFORM_NONE,
772 EOM_TRANSFORM_FLIP_HORIZONTAL,
773 EOM_TRANSFORM_ROT_180,
774 EOM_TRANSFORM_FLIP_VERTICAL,
775 EOM_TRANSFORM_TRANSPOSE,
776 EOM_TRANSFORM_ROT_90,
777 EOM_TRANSFORM_TRANSVERSE,
778 EOM_TRANSFORM_ROT_270};
779 EomImagePrivate *priv;
780 EomTransformType type;
781
782 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
783
784 priv = img->priv;
785
786 type = (priv->orientation >= 1 && priv->orientation <= 8 ?
787 lookup[priv->orientation - 1] : EOM_TRANSFORM_NONE);
788
789 if (type != EOM_TRANSFORM_NONE) {
790 img->priv->trans_autorotate = eom_transform_new (type);
791 }
792
793 /* Disable auto orientation for next loads */
794 priv->autorotate = FALSE(0);
795}
796
797void
798eom_image_autorotate (EomImage *img)
799{
800 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
801
802 /* Schedule auto orientation */
803 img->priv->autorotate = TRUE(!(0));
804}
805
806#ifdef HAVE_EXEMPI1
807static void
808eom_image_set_xmp_data (EomImage *img, EomMetadataReader *md_reader)
809{
810 EomImagePrivate *priv;
811
812 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
813
814 priv = img->priv;
815
816 if (priv->xmp) {
817 xmp_free (priv->xmp);
818 }
819 priv->xmp = eom_metadata_reader_get_xmp_data (md_reader);
820}
821#endif
822
823static void
824eom_image_set_exif_data (EomImage *img, EomMetadataReader *md_reader)
825{
826 EomImagePrivate *priv;
827
828 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
829
830 priv = img->priv;
831
832#ifdef HAVE_EXIF1
833 g_mutex_lock (&priv->status_mutex);
834 if (priv->exif) {
835 exif_data_unref (priv->exif);
836 }
837 priv->exif = eom_metadata_reader_get_exif_data (md_reader);
838 g_mutex_unlock (&priv->status_mutex);
839
840 priv->exif_chunk = NULL((void*)0);
841 priv->exif_chunk_len = 0;
842
843 /* EXIF data is already available, set the image orientation */
844 if (priv->autorotate) {
845 eom_image_set_orientation (img);
846
847 /* Emit size prepared signal if we have the size */
848 if (priv->width > 0 &&
849 priv->height > 0) {
850 eom_image_emit_size_prepared (img);
851 }
852 }
853#else
854 if (priv->exif_chunk) {
855 g_free (priv->exif_chunk);
856 }
857 eom_metadata_reader_get_exif_chunk (md_reader,
858 &priv->exif_chunk,
859 &priv->exif_chunk_len);
860#endif
861}
862
863/*
864 * Attempts to get the image dimensions from the thumbnail.
865 * Returns FALSE if this information is not found.
866 **/
867static gboolean
868eom_image_get_dimension_from_thumbnail (EomImage *image,
869 gint *width,
870 gint *height)
871{
872 if (image->priv->thumbnail == NULL((void*)0))
873 return FALSE(0);
874
875 *width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image->priv->thumbnail),((gint) (glong) (g_object_get_data (((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((image->priv->thumbnail)), (((GType
) ((20) << (2)))))))), "eom-thumbnail-orig-width")))
876 EOM_THUMBNAIL_ORIGINAL_WIDTH))((gint) (glong) (g_object_get_data (((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((image->priv->thumbnail)), (((GType
) ((20) << (2)))))))), "eom-thumbnail-orig-width")))
;
877 *height = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (image->priv->thumbnail),((gint) (glong) (g_object_get_data (((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((image->priv->thumbnail)), (((GType
) ((20) << (2)))))))), "eom-thumbnail-orig-height")))
878 EOM_THUMBNAIL_ORIGINAL_HEIGHT))((gint) (glong) (g_object_get_data (((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((image->priv->thumbnail)), (((GType
) ((20) << (2)))))))), "eom-thumbnail-orig-height")))
;
879
880 return (*width || *height);
881}
882
883static gboolean
884eom_image_real_load (EomImage *img,
885 guint data2read,
886 EomJob *job,
887 GError **error)
888{
889 EomImagePrivate *priv;
890 GFileInputStream *input_stream;
891 EomMetadataReader *md_reader = NULL((void*)0);
892 GdkPixbufFormat *format;
893 gchar *mime_type;
894 GdkPixbufLoader *loader = NULL((void*)0);
895 guchar *buffer;
896 goffset bytes_read, bytes_read_total = 0;
897 gboolean failed = FALSE(0);
898 gboolean first_run = TRUE(!(0));
899 gboolean set_metadata = TRUE(!(0));
900 gboolean use_rsvg = FALSE(0);
901 gboolean read_image_data = (data2read & EOM_IMAGE_DATA_IMAGE);
902 gboolean read_only_dimension = (data2read & EOM_IMAGE_DATA_DIMENSION) &&
1
Assuming the condition is false
903 ((data2read ^ EOM_IMAGE_DATA_DIMENSION) == 0);
904
905
906 priv = img->priv;
907
908 g_assert (!read_image_data || priv->image == NULL)do { if (!read_image_data || priv->image == ((void*)0)) ; else
g_assertion_message_expr ("EOM", "eom-image.c", 908, ((const
char*) (__func__)), "!read_image_data || priv->image == NULL"
); } while (0)
;
2
Assuming 'read_image_data' is not equal to 0
3
Assuming field 'image' is equal to null
4
Taking true branch
5
Loop condition is false. Exiting loop
909
910 if (read_image_data
5.1
'read_image_data' is not equal to 0
&& priv->file_type != NULL((void*)0)) {
6
Assuming field 'file_type' is equal to NULL
7
Taking false branch
911 g_free (priv->file_type);
912 priv->file_type = NULL((void*)0);
913 }
914
915 eom_image_get_file_info (img, &priv->bytes, &mime_type, error);
8
Calling 'eom_image_get_file_info'
14
Returning from 'eom_image_get_file_info'
916
917 if (error && *error) {
15
Assuming 'error' is null
918 g_free (mime_type);
919 return FALSE(0);
920 }
921
922 if (read_only_dimension
15.1
'read_only_dimension' is 0
) {
16
Taking false branch
923 gint width, height;
924 gboolean done;
925
926 done = eom_image_get_dimension_from_thumbnail (img,
927 &width,
928 &height);
929
930 if (done) {
931 priv->width = width;
932 priv->height = height;
933
934 g_free (mime_type);
935 return TRUE(!(0));
936 }
937 }
938
939 input_stream = g_file_read (priv->file, NULL((void*)0), error);
940
941 if (input_stream == NULL((void*)0)) {
17
Assuming 'input_stream' is not equal to NULL
18
Taking false branch
942 g_free (mime_type);
943
944 if (error != NULL((void*)0)) {
945 g_clear_error (error);
946 g_set_error (error,
947 EOM_IMAGE_ERROReom_image_error_quark (),
948 EOM_IMAGE_ERROR_VFS,
949 "Failed to open input stream for file");
950 }
951 return FALSE(0);
952 }
953
954 buffer = g_new0 (guchar, EOM_IMAGE_READ_BUFFER_SIZE)((guchar *) g_malloc0_n ((65535), sizeof (guchar)));
955
956 if (read_image_data
18.1
'read_image_data' is not equal to 0
|| read_only_dimension) {
957#ifdef HAVE_RSVG1
958 if (priv->svg != NULL((void*)0)) {
19
Assuming field 'svg' is equal to NULL
20
Taking false branch
959 g_object_unref (priv->svg);
960 priv->svg = NULL((void*)0);
961 }
962
963 if (!strcmp (mime_type, "image/svg+xml")
21
Null pointer passed to 1st parameter expecting 'nonnull'
964#if LIBRSVG_CHECK_FEATURE(SVGZ)(defined(((!(0)))) && ((!(0))))
965 || !strcmp (mime_type, "image/svg+xml-compressed")
966#endif
967 ) {
968 gchar *file_path;
969 /* Keep the object for rendering */
970 priv->svg = rsvg_handle_new ();
971 use_rsvg = (priv->svg != NULL((void*)0));
972 file_path = g_file_get_path (priv->file);
973 rsvg_handle_set_base_uri (priv->svg, file_path);
974 g_free (file_path);
975 }
976#endif
977
978 if (!use_rsvg) {
979 loader = gdk_pixbuf_loader_new_with_mime_type (mime_type, error);
980
981 if (error && *error) {
982 g_error_free (*error);
983 *error = NULL((void*)0);
984
985 loader = gdk_pixbuf_loader_new ();
986 }
987
988 g_signal_connect_object (G_OBJECT (loader)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
loader)), (((GType) ((20) << (2))))))))
,
989 "size-prepared",
990 G_CALLBACK (eom_image_size_prepared)((GCallback) (eom_image_size_prepared)),
991 img,
992 0);
993 }
994 }
995 g_free (mime_type);
996
997 while (!priv->cancel_loading) {
998 /* FIXME: make this async */
999 bytes_read = g_input_stream_read (G_INPUT_STREAM (input_stream)((((GInputStream*) g_type_check_instance_cast ((GTypeInstance
*) ((input_stream)), ((g_input_stream_get_type ()))))))
,
1000 buffer,
1001 EOM_IMAGE_READ_BUFFER_SIZE65535,
1002 NULL((void*)0), error);
1003
1004 if (bytes_read == 0) {
1005 /* End of the file */
1006 break;
1007 } else if (bytes_read == -1) {
1008 failed = TRUE(!(0));
1009
1010 g_set_error (error,
1011 EOM_IMAGE_ERROReom_image_error_quark (),
1012 EOM_IMAGE_ERROR_VFS,
1013 "Failed to read from input stream");
1014
1015 break;
1016 }
1017
1018 if ((read_image_data || read_only_dimension)) {
1019#ifdef HAVE_RSVG1
1020 if (use_rsvg) {
1021 gboolean res;
1022
1023 res = rsvg_handle_write (priv->svg, buffer,
1024 bytes_read, error);
1025
1026 if (G_UNLIKELY (!res)(!res)) {
1027 failed = TRUE(!(0));
1028 break;
1029 }
1030 } else
1031#endif
1032 if (!gdk_pixbuf_loader_write (loader, buffer, bytes_read, error)) {
1033 failed = TRUE(!(0));
1034 break;
1035 }
1036 }
1037
1038 bytes_read_total += bytes_read;
1039
1040 if (job != NULL((void*)0)) {
1041 float progress = (float) bytes_read_total / (float) priv->bytes;
1042 eom_job_set_progress (job, progress);
1043 }
1044
1045 if (first_run) {
1046 md_reader = check_for_metadata_img_format (img, buffer, bytes_read);
1047
1048 if (md_reader == NULL((void*)0)) {
1049 if (data2read == EOM_IMAGE_DATA_EXIF) {
1050 g_set_error (error,
1051 EOM_IMAGE_ERROReom_image_error_quark (),
1052 EOM_IMAGE_ERROR_GENERIC,
1053 _("EXIF not supported for this file format.")gettext ("EXIF not supported for this file format."));
1054 break;
1055 }
1056
1057 priv->metadata_status = EOM_IMAGE_METADATA_NOT_AVAILABLE;
1058 }
1059
1060 first_run = FALSE(0);
1061 }
1062
1063 if (md_reader != NULL((void*)0)) {
1064 eom_metadata_reader_consume (md_reader, buffer, bytes_read);
1065
1066 if (eom_metadata_reader_finished (md_reader)) {
1067 if (set_metadata) {
1068 eom_image_set_exif_data (img, md_reader);
1069
1070#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
1071 eom_image_set_icc_data (img, md_reader);
1072#endif
1073
1074#ifdef HAVE_EXEMPI1
1075 eom_image_set_xmp_data (img, md_reader);
1076#endif
1077 set_metadata = FALSE(0);
1078 priv->metadata_status = EOM_IMAGE_METADATA_READY;
1079 }
1080
1081 if (data2read == EOM_IMAGE_DATA_EXIF)
1082 break;
1083 }
1084 }
1085
1086 if (read_only_dimension &&
1087 eom_image_has_data (img, EOM_IMAGE_DATA_DIMENSION)) {
1088 break;
1089 }
1090 }
1091
1092 if (read_image_data || read_only_dimension) {
1093#ifdef HAVE_RSVG1
1094 if (use_rsvg) {
1095 /* Ignore the error if loading failed earlier
1096 * as the error will already be set in that case */
1097 rsvg_handle_close (priv->svg,
1098 (failed ? NULL((void*)0) : error));
1099 } else
1100#endif
1101 if (failed) {
1102 gdk_pixbuf_loader_close (loader, NULL((void*)0));
1103 } else if (!gdk_pixbuf_loader_close (loader, error)) {
1104 if (gdk_pixbuf_loader_get_pixbuf (loader) != NULL((void*)0)) {
1105 /* Clear error in order to support partial
1106 * images as well. */
1107 g_clear_error (error);
1108 }
1109 }
1110 }
1111
1112 g_free (buffer);
1113
1114 g_object_unref (G_OBJECT (input_stream)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
input_stream)), (((GType) ((20) << (2))))))))
);
1115
1116 failed = (failed ||
1117 priv->cancel_loading ||
1118 bytes_read_total == 0 ||
1119 (error && *error != NULL((void*)0)));
1120
1121 if (failed) {
1122 if (priv->cancel_loading) {
1123 priv->cancel_loading = FALSE(0);
1124 priv->status = EOM_IMAGE_STATUS_UNKNOWN;
1125 } else {
1126 priv->status = EOM_IMAGE_STATUS_FAILED;
1127 }
1128 } else if (read_image_data) {
1129 if (priv->image != NULL((void*)0)) {
1130 g_object_unref (priv->image);
1131 }
1132
1133#ifdef HAVE_RSVG1
1134 if (use_rsvg) {
1135 priv->image = rsvg_handle_get_pixbuf (priv->svg);
1136 } else
1137#endif
1138
1139 {
1140
1141 priv->anim = gdk_pixbuf_loader_get_animation (loader);
1142
1143 if (gdk_pixbuf_animation_is_static_image (priv->anim)) {
1144 priv->image = gdk_pixbuf_animation_get_static_image (priv->anim);
1145 priv->anim = NULL((void*)0);
1146 } else {
1147 priv->anim_iter = gdk_pixbuf_animation_get_iter (priv->anim,NULL((void*)0));
1148 priv->image = gdk_pixbuf_animation_iter_get_pixbuf (priv->anim_iter);
1149 }
1150
1151 }
1152
1153 if (G_LIKELY (priv->image != NULL)(priv->image != ((void*)0))) {
1154 if (!use_rsvg)
1155 g_object_ref (priv->image);
1156
1157 priv->width = gdk_pixbuf_get_width (priv->image);
1158 priv->height = gdk_pixbuf_get_height (priv->image);
1159
1160 if (use_rsvg) {
1161 format = NULL((void*)0);
1162 priv->file_type = g_strdup ("svg");
1163 } else {
1164 format = gdk_pixbuf_loader_get_format (loader);
1165 }
1166
1167 if (format != NULL((void*)0)) {
1168 priv->file_type = gdk_pixbuf_format_get_name (format);
1169 }
1170
1171 priv->file_is_changed = FALSE(0);
1172
1173 /* Set orientation again for safety, eg. if we don't
1174 * have Exif data or HAVE_EXIF is undefined. */
1175 if (priv->autorotate) {
1176 eom_image_set_orientation (img);
1177 eom_image_emit_size_prepared (img);
1178 }
1179
1180 } else {
1181 /* Some loaders don't report errors correctly.
1182 * Error will be set below. */
1183 failed = TRUE(!(0));
1184 priv->status = EOM_IMAGE_STATUS_FAILED;
1185 }
1186 }
1187
1188 if (loader != NULL((void*)0)) {
1189 g_object_unref (loader);
1190 }
1191
1192 if (md_reader != NULL((void*)0)) {
1193 g_object_unref (md_reader);
1194 md_reader = NULL((void*)0);
1195 }
1196
1197 /* Catch-all in case of poor-error reporting */
1198 if (failed && error && *error == NULL((void*)0)) {
1199 g_set_error (error,
1200 EOM_IMAGE_ERROReom_image_error_quark (),
1201 EOM_IMAGE_ERROR_GENERIC,
1202 _("Image loading failed.")gettext ("Image loading failed."));
1203 }
1204
1205 return !failed;
1206}
1207
1208gboolean
1209eom_image_has_data (EomImage *img, EomImageData req_data)
1210{
1211 EomImagePrivate *priv;
1212 gboolean has_data = TRUE(!(0));
1213
1214 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
1215
1216 priv = img->priv;
1217
1218 if ((req_data & EOM_IMAGE_DATA_IMAGE) > 0) {
1219 req_data = (req_data & ~EOM_IMAGE_DATA_IMAGE);
1220 has_data = has_data && (priv->image != NULL((void*)0));
1221 }
1222
1223 if ((req_data & EOM_IMAGE_DATA_DIMENSION) > 0 ) {
1224 req_data = (req_data & ~EOM_IMAGE_DATA_DIMENSION);
1225 has_data = has_data && (priv->width >= 0) && (priv->height >= 0);
1226 }
1227
1228 if ((req_data & EOM_IMAGE_DATA_EXIF) > 0) {
1229 req_data = (req_data & ~EOM_IMAGE_DATA_EXIF);
1230#ifdef HAVE_EXIF1
1231 has_data = has_data && (priv->exif != NULL((void*)0));
1232#else
1233 has_data = has_data && (priv->exif_chunk != NULL((void*)0));
1234#endif
1235 }
1236
1237 if ((req_data & EOM_IMAGE_DATA_XMP) > 0) {
1238 req_data = (req_data & ~EOM_IMAGE_DATA_XMP);
1239#ifdef HAVE_EXEMPI1
1240 has_data = has_data && (priv->xmp != NULL((void*)0));
1241#endif
1242 }
1243
1244 if (req_data != 0) {
1245 g_warning ("Asking for unknown data, remaining: %i\n", req_data);
1246 has_data = FALSE(0);
1247 }
1248
1249 return has_data;
1250}
1251
1252gboolean
1253eom_image_load (EomImage *img, EomImageData data2read, EomJob *job, GError **error)
1254{
1255 EomImagePrivate *priv;
1256 gboolean success = FALSE(0);
1257
1258 eom_debug (DEBUG_IMAGE_LOADEOM_DEBUG_IMAGE_LOAD, "eom-image.c", 1258, ((const char*) (__func__
))
);
1259
1260 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
1261
1262 priv = EOM_IMAGE (img)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(img)), ((eom_image_get_type ()))))))
->priv;
1263
1264 if (data2read == 0) {
1265 return TRUE(!(0));
1266 }
1267
1268 if (eom_image_has_data (img, data2read)) {
1269 return TRUE(!(0));
1270 }
1271
1272 priv->status = EOM_IMAGE_STATUS_LOADING;
1273
1274 success = eom_image_real_load (img, data2read, job, error);
1275
1276 /* Check that the metadata was loaded at least once before
1277 * trying to autorotate. Also only an imatge load job should try to
1278 * autorotate and image */
1279 if (priv->autorotate &&
1280#ifdef HAVE_EXIF1
1281 priv->metadata_status != EOM_IMAGE_METADATA_NOT_READ &&
1282#endif
1283 data2read & EOM_IMAGE_DATA_IMAGE) {
1284 eom_image_real_autorotate (img);
1285 }
1286
1287 if (success && eom_image_needs_transformation (img)) {
1288 success = eom_image_apply_transformations (img, error);
1289 }
1290
1291 if (success) {
1292 priv->status = EOM_IMAGE_STATUS_LOADED;
1293 } else {
1294 priv->status = EOM_IMAGE_STATUS_FAILED;
1295 }
1296
1297 return success;
1298}
1299
1300void
1301eom_image_set_thumbnail (EomImage *img, GdkPixbuf *thumbnail)
1302{
1303 EomImagePrivate *priv;
1304
1305 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
1306 g_return_if_fail (GDK_IS_PIXBUF (thumbnail) || thumbnail == NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((thumbnail)); GType __t = ((gdk_pixbuf_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; })))) || thumbnail
== ((void*)0))) { } else { g_return_if_fail_warning ("EOM", (
(const char*) (__func__)), "GDK_IS_PIXBUF (thumbnail) || thumbnail == NULL"
); return; } } while (0)
;
1307
1308 priv = img->priv;
1309
1310 if (priv->thumbnail != NULL((void*)0)) {
1311 g_object_unref (priv->thumbnail);
1312 priv->thumbnail = NULL((void*)0);
1313 }
1314
1315 if (thumbnail != NULL((void*)0) && priv->trans != NULL((void*)0)) {
1316 priv->thumbnail = eom_transform_apply (priv->trans, thumbnail, NULL((void*)0));
1317 } else {
1318 priv->thumbnail = thumbnail;
1319
1320 if (thumbnail != NULL((void*)0)) {
1321 g_object_ref (priv->thumbnail);
1322 }
1323 }
1324
1325 if (priv->thumbnail != NULL((void*)0)) {
1326 g_signal_emit (img, signals[SIGNAL_THUMBNAIL_CHANGED], 0);
1327 }
1328}
1329
1330/**
1331 * eom_image_get_pixbuf:
1332 * @img: a #EomImage
1333 *
1334 * Gets the #GdkPixbuf of the image
1335 *
1336 * Returns: (transfer full): a #GdkPixbuf
1337 **/
1338GdkPixbuf *
1339eom_image_get_pixbuf (EomImage *img)
1340{
1341 GdkPixbuf *image = NULL((void*)0);
1342
1343 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
1344
1345 g_mutex_lock (&img->priv->status_mutex);
1346 image = img->priv->image;
1347 g_mutex_unlock (&img->priv->status_mutex);
1348
1349 if (image != NULL((void*)0)) {
1350 g_object_ref (image);
1351 }
1352
1353 return image;
1354}
1355
1356#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
1357cmsHPROFILE
1358eom_image_get_profile (EomImage *img)
1359{
1360 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
1361
1362 return img->priv->profile;
1363}
1364#endif
1365
1366/**
1367 * eom_image_get_thumbnail:
1368 * @img: a #EomImage
1369 *
1370 * Gets the thumbnail pixbuf for @img
1371 *
1372 * Returns: (transfer full): a #GdkPixbuf with a thumbnail
1373 **/
1374GdkPixbuf *
1375eom_image_get_thumbnail (EomImage *img)
1376{
1377 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
1378
1379 if (img->priv->thumbnail != NULL((void*)0)) {
1380 return g_object_ref (img->priv->thumbnail);
1381 }
1382
1383 return NULL((void*)0);
1384}
1385
1386void
1387eom_image_get_size (EomImage *img, int *width, int *height)
1388{
1389 EomImagePrivate *priv;
1390
1391 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
1392
1393 priv = img->priv;
1394
1395 *width = priv->width;
1396 *height = priv->height;
1397}
1398
1399void
1400eom_image_transform (EomImage *img, EomTransform *trans, EomJob *job)
1401{
1402 eom_image_real_transform (img, trans, FALSE(0), job);
1403}
1404
1405void
1406eom_image_undo (EomImage *img)
1407{
1408 EomImagePrivate *priv;
1409 EomTransform *trans;
1410 EomTransform *inverse;
1411
1412 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
1413
1414 priv = img->priv;
1415
1416 if (priv->undo_stack != NULL((void*)0)) {
1417 trans = EOM_TRANSFORM (priv->undo_stack->data)((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->undo_stack->data)), ((eom_transform_get_type
()))))))
;
1418
1419 inverse = eom_transform_reverse (trans);
1420
1421 eom_image_real_transform (img, inverse, TRUE(!(0)), NULL((void*)0));
1422
1423 priv->undo_stack = g_slist_delete_link (priv->undo_stack, priv->undo_stack);
1424
1425 g_object_unref (trans);
1426 g_object_unref (inverse);
1427
1428 if (eom_transform_is_identity (priv->trans)) {
1429 g_object_unref (priv->trans);
1430 priv->trans = NULL((void*)0);
1431 }
1432 }
1433
1434 priv->modified = (priv->undo_stack != NULL((void*)0));
1435}
1436
1437static GFile *
1438tmp_file_get (void)
1439{
1440 GFile *tmp_file;
1441 char *tmp_file_path;
1442 gint fd;
1443
1444 tmp_file_path = g_build_filename (g_get_tmp_dir (), "eom-save-XXXXXX", NULL((void*)0));
1445 fd = g_mkstemp (tmp_file_path);
1446 if (fd == -1) {
1447 g_free (tmp_file_path);
1448 return NULL((void*)0);
1449 }
1450 else {
1451 tmp_file = g_file_new_for_path (tmp_file_path);
1452 g_free (tmp_file_path);
1453 return tmp_file;
1454 }
1455}
1456
1457static void
1458transfer_progress_cb (goffset cur_bytes,
1459 goffset total_bytes,
1460 gpointer user_data)
1461{
1462 EomImage *image = EOM_IMAGE (user_data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_image_get_type ()))))))
;
1463
1464 if (cur_bytes > 0) {
1465 g_signal_emit (G_OBJECT(image)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
image)), (((GType) ((20) << (2))))))))
,
1466 signals[SIGNAL_SAVE_PROGRESS],
1467 0,
1468 (gfloat) cur_bytes / (gfloat) total_bytes);
1469 }
1470}
1471
1472static void
1473tmp_file_restore_unix_attributes (GFile *temp_file,
1474 GFile *target_file)
1475{
1476 GFileInfo *file_info;
1477 guint uid;
1478 guint gid;
1479 guint mode;
1480 guint mode_mask = 00600;
1481
1482 GError *error = NULL((void*)0);
1483
1484 g_return_if_fail (G_IS_FILE (temp_file))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((temp_file)); GType __t = ((g_file_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 ("EOM", ((const char*) (__func__
)), "G_IS_FILE (temp_file)"); return; } } while (0)
;
1485 g_return_if_fail (G_IS_FILE (target_file))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((target_file)); GType __t = ((g_file_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 ("EOM", ((const char*) (__func__
)), "G_IS_FILE (target_file)"); return; } } while (0)
;
1486
1487 /* check if file exists */
1488 if (!g_file_query_exists (target_file, NULL((void*)0))) {
1489 eom_debug_message (DEBUG_IMAGE_SAVEEOM_DEBUG_IMAGE_SAVE, "eom-image.c", 1489, ((const char*) (__func__
))
,
1490 "Target file doesn't exist. Setting default attributes.");
1491 return;
1492 }
1493
1494 /* retrieve UID, GID, and MODE of the original file info */
1495 file_info = g_file_query_info (target_file,
1496 "unix::uid,unix::gid,unix::mode",
1497 G_FILE_QUERY_INFO_NONE,
1498 NULL((void*)0),
1499 &error);
1500
1501 /* check that there aren't any error */
1502 if (error != NULL((void*)0)) {
1503 eom_debug_message (DEBUG_IMAGE_SAVEEOM_DEBUG_IMAGE_SAVE, "eom-image.c", 1503, ((const char*) (__func__
))
,
1504 "File information not available. Setting default attributes.");
1505
1506 /* free objects */
1507 g_object_unref (file_info);
1508 g_clear_error (&error);
1509
1510 return;
1511 }
1512
1513 /* save UID, GID and MODE values */
1514 uid = g_file_info_get_attribute_uint32 (file_info,
1515 G_FILE_ATTRIBUTE_UNIX_UID"unix::uid");
1516
1517 gid = g_file_info_get_attribute_uint32 (file_info,
1518 G_FILE_ATTRIBUTE_UNIX_GID"unix::gid");
1519
1520 mode = g_file_info_get_attribute_uint32 (file_info,
1521 G_FILE_ATTRIBUTE_UNIX_MODE"unix::mode");
1522
1523 /* apply default mode mask to file mode */
1524 mode |= mode_mask;
1525
1526 /* restore original UID, GID, and MODE into the temporal file */
1527 g_file_set_attribute_uint32 (temp_file,
1528 G_FILE_ATTRIBUTE_UNIX_UID"unix::uid",
1529 uid,
1530 G_FILE_QUERY_INFO_NONE,
1531 NULL((void*)0),
1532 &error);
1533
1534 /* check that there aren't any error */
1535 if (error != NULL((void*)0)) {
1536 eom_debug_message (DEBUG_IMAGE_SAVEEOM_DEBUG_IMAGE_SAVE, "eom-image.c", 1536, ((const char*) (__func__
))
,
1537 "You do not have the permissions necessary to change the file UID.");
1538
1539 g_clear_error (&error);
1540 }
1541
1542 g_file_set_attribute_uint32 (temp_file,
1543 G_FILE_ATTRIBUTE_UNIX_GID"unix::gid",
1544 gid,
1545 G_FILE_QUERY_INFO_NONE,
1546 NULL((void*)0),
1547 &error);
1548
1549 /* check that there aren't any error */
1550 if (error != NULL((void*)0)) {
1551 eom_debug_message (DEBUG_IMAGE_SAVEEOM_DEBUG_IMAGE_SAVE, "eom-image.c", 1551, ((const char*) (__func__
))
,
1552 "You do not have the permissions necessary to change the file GID. Setting user default GID.");
1553
1554 g_clear_error (&error);
1555 }
1556
1557 g_file_set_attribute_uint32 (temp_file,
1558 G_FILE_ATTRIBUTE_UNIX_MODE"unix::mode",
1559 mode,
1560 G_FILE_QUERY_INFO_NONE,
1561 NULL((void*)0),
1562 &error);
1563
1564 /* check that there aren't any error */
1565 if (error != NULL((void*)0)) {
1566 eom_debug_message (DEBUG_IMAGE_SAVEEOM_DEBUG_IMAGE_SAVE, "eom-image.c", 1566, ((const char*) (__func__
))
,
1567 "You do not have the permissions necessary to change the file MODE.");
1568
1569 g_clear_error (&error);
1570 }
1571
1572 /* free objects */
1573 g_object_unref (file_info);
1574}
1575
1576static gboolean
1577tmp_file_move_to_uri (EomImage *image,
1578 GFile *tmpfile,
1579 GFile *file,
1580 gboolean overwrite,
1581 GError **error)
1582{
1583 gboolean result;
1584 GError *ioerror = NULL((void*)0);
1585
1586 /* try to restore target file unix attributes */
1587 tmp_file_restore_unix_attributes (tmpfile, file);
1588
1589 /* replace target file with temporal file */
1590 result = g_file_move (tmpfile,
1591 file,
1592 (overwrite ? G_FILE_COPY_OVERWRITE : 0) |
1593 G_FILE_COPY_ALL_METADATA,
1594 NULL((void*)0),
1595 (GFileProgressCallback) transfer_progress_cb,
1596 image,
1597 &ioerror);
1598
1599 if (result == FALSE(0)) {
1600 if (g_error_matches (ioerror, G_IO_ERRORg_io_error_quark(),
1601 G_IO_ERROR_EXISTS)) {
1602 g_set_error (error, EOM_IMAGE_ERROReom_image_error_quark (),
1603 EOM_IMAGE_ERROR_FILE_EXISTS,
1604 "File exists");
1605 } else {
1606 g_set_error (error, EOM_IMAGE_ERROReom_image_error_quark (),
1607 EOM_IMAGE_ERROR_VFS,
1608 "VFS error moving the temp file");
1609 }
1610 g_clear_error (&ioerror);
1611 }
1612
1613 return result;
1614}
1615
1616static gboolean
1617tmp_file_delete (GFile *tmpfile)
1618{
1619 gboolean result;
1620 GError *err = NULL((void*)0);
1621
1622 if (tmpfile == NULL((void*)0)) return FALSE(0);
1623
1624 result = g_file_delete (tmpfile, NULL((void*)0), &err);
1625 if (result == FALSE(0)) {
1626 char *tmpfile_path;
1627 if (err != NULL((void*)0)) {
1628 if (err->code == G_IO_ERROR_NOT_FOUND) {
1629 g_error_free (err);
1630 return TRUE(!(0));
1631 }
1632 g_error_free (err);
1633 }
1634 tmpfile_path = g_file_get_path (tmpfile);
1635 g_warning ("Couldn't delete temporary file: %s", tmpfile_path);
1636 g_free (tmpfile_path);
1637 }
1638
1639 return result;
1640}
1641
1642static void
1643eom_image_reset_modifications (EomImage *image)
1644{
1645 EomImagePrivate *priv;
1646
1647 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
1648
1649 priv = image->priv;
1650
1651 g_slist_free_full (priv->undo_stack, g_object_unref);
1652 priv->undo_stack = NULL((void*)0);
1653
1654 if (priv->trans != NULL((void*)0)) {
1655 g_object_unref (priv->trans);
1656 priv->trans = NULL((void*)0);
1657 }
1658
1659 if (priv->trans_autorotate != NULL((void*)0)) {
1660 g_object_unref (priv->trans_autorotate);
1661 priv->trans_autorotate = NULL((void*)0);
1662 }
1663
1664 priv->modified = FALSE(0);
1665}
1666
1667static void
1668eom_image_link_with_target (EomImage *image, EomImageSaveInfo *target)
1669{
1670 EomImagePrivate *priv;
1671
1672 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
1673 g_return_if_fail (EOM_IS_IMAGE_SAVE_INFO (target))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((target)); GType __t = ((eom_image_save_info_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 ("EOM", ((const
char*) (__func__)), "EOM_IS_IMAGE_SAVE_INFO (target)"); return
; } } while (0)
;
1674
1675 priv = image->priv;
1676
1677 /* update file location */
1678 if (priv->file != NULL((void*)0)) {
1679 g_object_unref (priv->file);
1680 }
1681 priv->file = g_object_ref (target->file);
1682
1683 /* Clear caption and caption key, these will be
1684 * updated on next eom_image_get_caption call.
1685 */
1686 if (priv->caption != NULL((void*)0)) {
1687 g_free (priv->caption);
1688 priv->caption = NULL((void*)0);
1689 }
1690 if (priv->collate_key != NULL((void*)0)) {
1691 g_free (priv->collate_key);
1692 priv->collate_key = NULL((void*)0);
1693 }
1694
1695 /* update file format */
1696 if (priv->file_type != NULL((void*)0)) {
1697 g_free (priv->file_type);
1698 }
1699 priv->file_type = g_strdup (target->format);
1700}
1701
1702gboolean
1703eom_image_save_by_info (EomImage *img, EomImageSaveInfo *source, GError **error)
1704{
1705 EomImagePrivate *priv;
1706 EomImageStatus prev_status;
1707 gboolean success = FALSE(0);
1708 GFile *tmp_file;
1709 char *tmp_file_path;
1710
1711 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
1712 g_return_val_if_fail (EOM_IS_IMAGE_SAVE_INFO (source), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((source)); GType __t = ((eom_image_save_info_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 ("EOM", ((const
char*) (__func__)), "EOM_IS_IMAGE_SAVE_INFO (source)"); return
((0)); } } while (0)
;
1713
1714 priv = img->priv;
1715
1716 prev_status = priv->status;
1717
1718 /* Image is now being saved */
1719 priv->status = EOM_IMAGE_STATUS_SAVING;
1720
1721 /* see if we need any saving at all */
1722 if (source->exists && !source->modified) {
1723 return TRUE(!(0));
1724 }
1725
1726 /* fail if there is no image to save */
1727 if (priv->image == NULL((void*)0)) {
1728 g_set_error (error, EOM_IMAGE_ERROReom_image_error_quark (),
1729 EOM_IMAGE_ERROR_NOT_LOADED,
1730 _("No image loaded.")gettext ("No image loaded."));
1731 return FALSE(0);
1732 }
1733
1734 /* generate temporary file */
1735 tmp_file = tmp_file_get ();
1736
1737 if (tmp_file == NULL((void*)0)) {
1738 g_set_error (error, EOM_IMAGE_ERROReom_image_error_quark (),
1739 EOM_IMAGE_ERROR_TMP_FILE_FAILED,
1740 _("Temporary file creation failed.")gettext ("Temporary file creation failed."));
1741 return FALSE(0);
1742 }
1743
1744 tmp_file_path = g_file_get_path (tmp_file);
1745
1746#ifdef HAVE_JPEG1
1747 /* determine kind of saving */
1748 if ((g_ascii_strcasecmp (source->format, EOM_FILE_FORMAT_JPEG"jpeg") == 0) &&
1749 source->exists && source->modified)
1750 {
1751 success = eom_image_jpeg_save_file (img, tmp_file_path, source, NULL((void*)0), error);
1752 }
1753#endif
1754
1755 if (!success && (*error == NULL((void*)0))) {
1756 success = gdk_pixbuf_save (priv->image, tmp_file_path, source->format, error, NULL((void*)0));
1757 }
1758
1759 if (success) {
1760 /* try to move result file to target uri */
1761 success = tmp_file_move_to_uri (img, tmp_file, priv->file, TRUE(!(0)) /*overwrite*/, error);
1762 }
1763
1764 if (success) {
1765 eom_image_reset_modifications (img);
1766 }
1767
1768 tmp_file_delete (tmp_file);
1769
1770 g_free (tmp_file_path);
1771 g_object_unref (tmp_file);
1772
1773 priv->status = prev_status;
1774
1775 return success;
1776}
1777
1778static gboolean
1779eom_image_copy_file (EomImage *image, EomImageSaveInfo *source, EomImageSaveInfo *target, GError **error)
1780{
1781 gboolean result;
1782 GError *ioerror = NULL((void*)0);
1783
1784 g_return_val_if_fail (EOM_IS_IMAGE_SAVE_INFO (source), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((source)); GType __t = ((eom_image_save_info_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 ("EOM", ((const
char*) (__func__)), "EOM_IS_IMAGE_SAVE_INFO (source)"); return
((0)); } } while (0)
;
1785 g_return_val_if_fail (EOM_IS_IMAGE_SAVE_INFO (target), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((target)); GType __t = ((eom_image_save_info_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 ("EOM", ((const
char*) (__func__)), "EOM_IS_IMAGE_SAVE_INFO (target)"); return
((0)); } } while (0)
;
1786
1787 result = g_file_copy (source->file,
1788 target->file,
1789 (target->overwrite ? G_FILE_COPY_OVERWRITE : 0) |
1790 G_FILE_COPY_ALL_METADATA,
1791 NULL((void*)0),
1792 EOM_IS_IMAGE (image)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(image)); GType __t = ((eom_image_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; }))))
? transfer_progress_cb :NULL((void*)0),
1793 image,
1794 &ioerror);
1795
1796 if (result == FALSE(0)) {
1797 if (ioerror->code == G_IO_ERROR_EXISTS) {
1798 g_set_error (error, EOM_IMAGE_ERROReom_image_error_quark (),
1799 EOM_IMAGE_ERROR_FILE_EXISTS,
1800 "%s", ioerror->message);
1801 } else {
1802 g_set_error (error, EOM_IMAGE_ERROReom_image_error_quark (),
1803 EOM_IMAGE_ERROR_VFS,
1804 "%s", ioerror->message);
1805 }
1806 g_error_free (ioerror);
1807 }
1808
1809 return result;
1810}
1811
1812gboolean
1813eom_image_save_as_by_info (EomImage *img, EomImageSaveInfo *source, EomImageSaveInfo *target, GError **error)
1814{
1815 EomImagePrivate *priv;
1816 gboolean success = FALSE(0);
1817 char *tmp_file_path;
1818 GFile *tmp_file;
1819 gboolean direct_copy = FALSE(0);
1820
1821 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
1822 g_return_val_if_fail (EOM_IS_IMAGE_SAVE_INFO (source), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((source)); GType __t = ((eom_image_save_info_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 ("EOM", ((const
char*) (__func__)), "EOM_IS_IMAGE_SAVE_INFO (source)"); return
((0)); } } while (0)
;
1823 g_return_val_if_fail (EOM_IS_IMAGE_SAVE_INFO (target), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((target)); GType __t = ((eom_image_save_info_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 ("EOM", ((const
char*) (__func__)), "EOM_IS_IMAGE_SAVE_INFO (target)"); return
((0)); } } while (0)
;
1824
1825 priv = img->priv;
1826
1827 /* fail if there is no image to save */
1828 if (priv->image == NULL((void*)0)) {
1829 g_set_error (error,
1830 EOM_IMAGE_ERROReom_image_error_quark (),
1831 EOM_IMAGE_ERROR_NOT_LOADED,
1832 _("No image loaded.")gettext ("No image loaded."));
1833
1834 return FALSE(0);
1835 }
1836
1837 /* generate temporary file name */
1838 tmp_file = tmp_file_get ();
1839
1840 if (tmp_file == NULL((void*)0)) {
1841 g_set_error (error,
1842 EOM_IMAGE_ERROReom_image_error_quark (),
1843 EOM_IMAGE_ERROR_TMP_FILE_FAILED,
1844 _("Temporary file creation failed.")gettext ("Temporary file creation failed."));
1845
1846 return FALSE(0);
1847 }
1848 tmp_file_path = g_file_get_path (tmp_file);
1849
1850 /* determine kind of saving */
1851 if (g_ascii_strcasecmp (source->format, target->format) == 0 && !source->modified) {
1852 success = eom_image_copy_file (img, source, target, error);
1853 direct_copy = success;
1854 }
1855
1856#ifdef HAVE_JPEG1
1857 else if ((g_ascii_strcasecmp (source->format, EOM_FILE_FORMAT_JPEG"jpeg") == 0 && source->exists) ||
1858 (g_ascii_strcasecmp (target->format, EOM_FILE_FORMAT_JPEG"jpeg") == 0))
1859 {
1860 success = eom_image_jpeg_save_file (img, tmp_file_path, source, target, error);
1861 }
1862#endif
1863
1864 if (!success && (*error == NULL((void*)0))) {
1865 success = gdk_pixbuf_save (priv->image, tmp_file_path, target->format, error, NULL((void*)0));
1866 }
1867
1868 if (success && !direct_copy) { /* not required if we alredy copied the file directly */
1869 /* try to move result file to target uri */
1870 success = tmp_file_move_to_uri (img, tmp_file, target->file, target->overwrite, error);
1871 }
1872
1873 if (success) {
1874 /* update image information to new uri */
1875 eom_image_reset_modifications (img);
1876 eom_image_link_with_target (img, target);
1877 }
1878
1879 tmp_file_delete (tmp_file);
1880 g_object_unref (tmp_file);
1881 g_free (tmp_file_path);
1882
1883 priv->status = EOM_IMAGE_STATUS_UNKNOWN;
1884
1885 return success;
1886}
1887
1888
1889/*
1890 * This function is extracted from
1891 * File: caja/libcaja-private/caja-file.c
1892 * Revision: 1.309
1893 * Author: Darin Adler <darin@bentspoon.com>
1894 */
1895static gboolean
1896have_broken_filenames (void)
1897{
1898 static gboolean initialized = FALSE(0);
1899 static gboolean broken;
1900
1901 if (initialized) {
1902 return broken;
1903 }
1904
1905 broken = g_getenv ("G_BROKEN_FILENAMES") != NULL((void*)0);
1906
1907 initialized = TRUE(!(0));
1908
1909 return broken;
1910}
1911
1912/*
1913 * This function is inspired by
1914 * caja/libcaja-private/caja-file.c:caja_file_get_display_name_nocopy
1915 * Revision: 1.309
1916 * Author: Darin Adler <darin@bentspoon.com>
1917 */
1918const gchar*
1919eom_image_get_caption (EomImage *img)
1920{
1921 EomImagePrivate *priv;
1922 char *name;
1923 char *utf8_name;
1924 char *scheme;
1925 gboolean validated = FALSE(0);
1926 gboolean broken_filenames;
1927
1928 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
1929
1930 priv = img->priv;
1931
1932 if (priv->file == NULL((void*)0)) return NULL((void*)0);
1933
1934 if (priv->caption != NULL((void*)0))
1935 /* Use cached caption string */
1936 return priv->caption;
1937
1938 name = g_file_get_basename (priv->file);
1939 scheme = g_file_get_uri_scheme (priv->file);
1940
1941 if (name != NULL((void*)0) && g_ascii_strcasecmp (scheme, "file") == 0) {
1942 /* Support the G_BROKEN_FILENAMES feature of
1943 * glib by using g_filename_to_utf8 to convert
1944 * local filenames to UTF-8. Also do the same
1945 * thing with any local filename that does not
1946 * validate as good UTF-8.
1947 */
1948 broken_filenames = have_broken_filenames ();
1949
1950 if (broken_filenames || !g_utf8_validate (name, -1, NULL((void*)0))) {
1951 utf8_name = g_locale_to_utf8 (name, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
1952 if (utf8_name != NULL((void*)0)) {
1953 g_free (name);
1954 name = utf8_name;
1955 /* Guaranteed to be correct utf8 here */
1956 validated = TRUE(!(0));
1957 }
1958 } else if (!broken_filenames) {
1959 /* name was valid, no need to re-validate */
1960 validated = TRUE(!(0));
1961 }
1962 }
1963
1964 if (!validated && !g_utf8_validate (name, -1, NULL((void*)0))) {
1965 if (name == NULL((void*)0)) {
1966 name = g_strdup ("[Invalid Unicode]");
1967 } else {
1968 utf8_name = eom_util_make_valid_utf8 (name);
1969 g_free (name);
1970 name = utf8_name;
1971 }
1972 }
1973
1974 priv->caption = name;
1975
1976 if (priv->caption == NULL((void*)0)) {
1977 char *short_str;
1978
1979 short_str = g_file_get_basename (priv->file);
1980 if (g_utf8_validate (short_str, -1, NULL((void*)0))) {
1981 priv->caption = g_strdup (short_str);
1982 } else {
1983 priv->caption = g_filename_to_utf8 (short_str, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0));
1984 }
1985 g_free (short_str);
1986 }
1987 g_free (scheme);
1988
1989 return priv->caption;
1990}
1991
1992const gchar*
1993eom_image_get_collate_key (EomImage *img)
1994{
1995 EomImagePrivate *priv;
1996
1997 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
1998
1999 priv = img->priv;
2000
2001 if (priv->collate_key == NULL((void*)0)) {
2002 const char *caption;
2003
2004 caption = eom_image_get_caption (img);
2005
2006 priv->collate_key = g_utf8_collate_key_for_filename (caption, -1);
2007 }
2008
2009 return priv->collate_key;
2010}
2011
2012void
2013eom_image_cancel_load (EomImage *img)
2014{
2015 EomImagePrivate *priv;
2016
2017 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
2018
2019 priv = img->priv;
2020
2021 g_mutex_lock (&priv->status_mutex);
2022
2023 if (priv->status == EOM_IMAGE_STATUS_LOADING) {
2024 priv->cancel_loading = TRUE(!(0));
2025 }
2026
2027 g_mutex_unlock (&priv->status_mutex);
2028}
2029
2030#ifdef HAVE_EXIF1
2031ExifData *
2032eom_image_get_exif_info (EomImage *img)
2033{
2034 EomImagePrivate *priv;
2035 ExifData *data = NULL((void*)0);
2036
2037 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2038
2039 priv = img->priv;
2040
2041 g_mutex_lock (&priv->status_mutex);
2042
2043 exif_data_ref (priv->exif);
2044 data = priv->exif;
2045
2046 g_mutex_unlock (&priv->status_mutex);
2047
2048 return data;
2049}
2050#endif
2051
2052/**
2053 * eom_image_get_xmp_info:
2054 * @img: a #EomImage
2055 *
2056 * Gets the XMP info for @img or NULL if compiled without
2057 * libexempi support.
2058 *
2059 * Returns: (transfer full): the xmp data
2060 **/
2061gpointer
2062eom_image_get_xmp_info (EomImage *img)
2063{
2064 gpointer data = NULL((void*)0);
2065
2066 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2067
2068#ifdef HAVE_EXEMPI1
2069 EomImagePrivate *priv;
2070 priv = img->priv;
2071
2072 g_mutex_lock (&priv->status_mutex);
2073 data = (gpointer) xmp_copy (priv->xmp);
2074 g_mutex_unlock (&priv->status_mutex);
2075#endif
2076
2077 return data;
2078}
2079
2080
2081/**
2082 * eom_image_get_file:
2083 * @img: a #EomImage
2084 *
2085 * Gets the #GFile associated with @img
2086 *
2087 * Returns: (transfer full): a #GFile
2088 **/
2089GFile *
2090eom_image_get_file (EomImage *img)
2091{
2092 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2093
2094 return g_object_ref (img->priv->file);
2095}
2096
2097gboolean
2098eom_image_is_modified (EomImage *img)
2099{
2100 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
2101
2102 return img->priv->modified;
2103}
2104
2105goffset
2106eom_image_get_bytes (EomImage *img)
2107{
2108 g_return_val_if_fail (EOM_IS_IMAGE (img), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (0); } } while (0)
;
2109
2110 return img->priv->bytes;
2111}
2112
2113void
2114eom_image_modified (EomImage *img)
2115{
2116 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
2117
2118 g_signal_emit (G_OBJECT (img)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
img)), (((GType) ((20) << (2))))))))
, signals[SIGNAL_CHANGED], 0);
2119}
2120
2121gchar*
2122eom_image_get_uri_for_display (EomImage *img)
2123{
2124 EomImagePrivate *priv;
2125 gchar *uri_str = NULL((void*)0);
2126 gchar *str = NULL((void*)0);
2127
2128 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2129
2130 priv = img->priv;
2131
2132 if (priv->file != NULL((void*)0)) {
2133 uri_str = g_file_get_uri (priv->file);
2134
2135 if (uri_str != NULL((void*)0)) {
2136 str = g_uri_unescape_string (uri_str, NULL((void*)0));
2137 g_free (uri_str);
2138 }
2139 }
2140
2141 return str;
2142}
2143
2144EomImageStatus
2145eom_image_get_status (EomImage *img)
2146{
2147 g_return_val_if_fail (EOM_IS_IMAGE (img), EOM_IMAGE_STATUS_UNKNOWN)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (EOM_IMAGE_STATUS_UNKNOWN);
} } while (0)
;
2148
2149 return img->priv->status;
2150}
2151
2152/**
2153 * eom_image_get_metadata_status:
2154 * @img: a #EomImage
2155 *
2156 * Returns the current status of the image metadata, that is,
2157 * whether the metadata has not been read yet, is ready, or not available at all.
2158 *
2159 * Returns: one of #EomImageMetadataStatus
2160 **/
2161EomImageMetadataStatus
2162eom_image_get_metadata_status (EomImage *img)
2163{
2164 g_return_val_if_fail (EOM_IS_IMAGE (img), EOM_IMAGE_METADATA_NOT_AVAILABLE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (EOM_IMAGE_METADATA_NOT_AVAILABLE
); } } while (0)
;
2165
2166 return img->priv->metadata_status;
2167}
2168
2169void
2170eom_image_data_ref (EomImage *img)
2171{
2172 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
2173
2174 g_object_ref (G_OBJECT (img)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
img)), (((GType) ((20) << (2))))))))
);
2175 img->priv->data_ref_count++;
2176
2177 g_assert (img->priv->data_ref_count <= G_OBJECT (img)->ref_count)do { if (img->priv->data_ref_count <= ((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((img)), (((GType) ((20) << (2))))))
))->ref_count) ; else g_assertion_message_expr ("EOM", "eom-image.c"
, 2177, ((const char*) (__func__)), "img->priv->data_ref_count <= G_OBJECT (img)->ref_count"
); } while (0)
;
2178}
2179
2180void
2181eom_image_data_unref (EomImage *img)
2182{
2183 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
2184
2185 if (img->priv->data_ref_count > 0) {
2186 img->priv->data_ref_count--;
2187 } else {
2188 g_warning ("More image data unrefs than refs.");
2189 }
2190
2191 if (img->priv->data_ref_count == 0) {
2192 eom_image_free_mem_private (img);
2193 }
2194
2195 g_object_unref (G_OBJECT (img)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
img)), (((GType) ((20) << (2))))))))
);
2196
2197 g_assert (img->priv->data_ref_count <= G_OBJECT (img)->ref_count)do { if (img->priv->data_ref_count <= ((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((img)), (((GType) ((20) << (2))))))
))->ref_count) ; else g_assertion_message_expr ("EOM", "eom-image.c"
, 2197, ((const char*) (__func__)), "img->priv->data_ref_count <= G_OBJECT (img)->ref_count"
); } while (0)
;
2198}
2199
2200static gint
2201compare_quarks (gconstpointer a, gconstpointer b)
2202{
2203 GQuark quark;
2204
2205 quark = g_quark_from_string ((const gchar *) a);
2206
2207 return quark - GPOINTER_TO_INT (b)((gint) (glong) (b));
2208}
2209
2210/**
2211 * eom_image_get_supported_mime_types:
2212 *
2213 * Gets the list of supported mimetypes
2214 *
2215 * Returns: (transfer none)(element-type utf8): a #GList of supported mimetypes
2216 **/
2217GList *
2218eom_image_get_supported_mime_types (void)
2219{
2220 GSList *format_list, *it;
2221 gchar **mime_types;
2222 int i;
2223
2224 if (!supported_mime_types) {
2225 format_list = gdk_pixbuf_get_formats ();
2226
2227 for (it = format_list; it != NULL((void*)0); it = it->next) {
2228 mime_types =
2229 gdk_pixbuf_format_get_mime_types ((GdkPixbufFormat *) it->data);
2230
2231 for (i = 0; mime_types[i] != NULL((void*)0); i++) {
2232 supported_mime_types =
2233 g_list_prepend (supported_mime_types,
2234 g_strdup (mime_types[i]));
2235 }
2236
2237 g_strfreev (mime_types);
2238 }
2239
2240 supported_mime_types = g_list_sort (supported_mime_types,
2241 (GCompareFunc) compare_quarks);
2242
2243 g_slist_free (format_list);
2244 }
2245
2246 return supported_mime_types;
2247}
2248
2249gboolean
2250eom_image_is_supported_mime_type (const char *mime_type)
2251{
2252 GList *supported_mime_types, *result;
2253 GQuark quark;
2254
2255 if (mime_type == NULL((void*)0)) {
2256 return FALSE(0);
2257 }
2258
2259 supported_mime_types = eom_image_get_supported_mime_types ();
2260
2261 quark = g_quark_from_string (mime_type);
2262
2263 result = g_list_find_custom (supported_mime_types,
2264 GINT_TO_POINTER (quark)((gpointer) (glong) (quark)),
2265 (GCompareFunc) compare_quarks);
2266
2267 return (result != NULL((void*)0));
2268}
2269
2270static gboolean
2271eom_image_iter_advance (EomImage *img)
2272{
2273 EomImagePrivate *priv;
2274 gboolean new_frame;
2275
2276 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
2277 g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION_ITER (img->priv->anim_iter), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img->priv->anim_iter)); GType __t = ((gdk_pixbuf_animation_iter_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 ("EOM", ((const
char*) (__func__)), "GDK_IS_PIXBUF_ANIMATION_ITER (img->priv->anim_iter)"
); return ((0)); } } while (0)
;
2278
2279 priv = img->priv;
2280
2281 if ((new_frame = gdk_pixbuf_animation_iter_advance (img->priv->anim_iter, NULL((void*)0))) == TRUE(!(0))) {
2282 g_mutex_lock (&priv->status_mutex);
2283 g_object_unref (priv->image);
2284 priv->image = gdk_pixbuf_animation_iter_get_pixbuf (priv->anim_iter);
2285 g_object_ref (priv->image);
2286 /* keep the transformation over time */
2287 if (EOM_IS_TRANSFORM (priv->trans)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(priv->trans)); GType __t = ((eom_transform_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; }
))))
) {
2288 GdkPixbuf* transformed = eom_transform_apply (priv->trans, priv->image, NULL((void*)0));
2289 g_object_unref (priv->image);
2290 priv->image = transformed;
2291 priv->width = gdk_pixbuf_get_width (transformed);
2292 priv->height = gdk_pixbuf_get_height (transformed);
2293 }
2294 g_mutex_unlock (&priv->status_mutex);
2295 /* Emit next frame signal so we can update the display */
2296 g_signal_emit (img, signals[SIGNAL_NEXT_FRAME], 0,
2297 gdk_pixbuf_animation_iter_get_delay_time (priv->anim_iter));
2298 }
2299
2300 return new_frame;
2301}
2302
2303/**
2304 * eom_image_is_animation:
2305 * @img: a #EomImage
2306 *
2307 * Checks whether a given image is animated.
2308 *
2309 * Returns: #TRUE if it is an animated image, #FALSE otherwise.
2310 *
2311 **/
2312gboolean
2313eom_image_is_animation (EomImage *img)
2314{
2315 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
2316 return img->priv->anim != NULL((void*)0);
2317}
2318
2319static gboolean
2320private_timeout (gpointer data)
2321{
2322 EomImage *img = EOM_IMAGE (data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_image_get_type ()))))))
;
2323 EomImagePrivate *priv = img->priv;
2324
2325 if (eom_image_is_animation (img) &&
2326 !g_source_is_destroyed (g_main_current_source ()) &&
2327 priv->is_playing) {
2328 while (eom_image_iter_advance (img) != TRUE(!(0))) {}; /* cpu-sucking ? */
2329 g_timeout_add (gdk_pixbuf_animation_iter_get_delay_time (priv->anim_iter), private_timeout, img);
2330 return FALSE(0);
2331 }
2332 priv->is_playing = FALSE(0);
2333 return FALSE(0); /* stop playing */
2334}
2335
2336/**
2337 * eom_image_start_animation:
2338 * @img: a #EomImage
2339 *
2340 * Starts playing an animated image.
2341 *
2342 * Returns: %TRUE on success, %FALSE if @img is already playing or isn't an animated image.
2343 **/
2344gboolean
2345eom_image_start_animation (EomImage *img)
2346{
2347 EomImagePrivate *priv;
2348
2349 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
2350 priv = img->priv;
2351
2352 if (!eom_image_is_animation (img) || priv->is_playing)
2353 return FALSE(0);
2354
2355 g_mutex_lock (&priv->status_mutex);
2356 g_object_ref (priv->anim_iter);
2357 priv->is_playing = TRUE(!(0));
2358 g_mutex_unlock (&priv->status_mutex);
2359
2360 g_timeout_add (gdk_pixbuf_animation_iter_get_delay_time (priv->anim_iter), private_timeout, img);
2361
2362 return TRUE(!(0));
2363}
2364
2365#ifdef HAVE_RSVG1
2366gboolean
2367eom_image_is_svg (EomImage *img)
2368{
2369 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
2370
2371 return (img->priv->svg != NULL((void*)0));
2372}
2373
2374RsvgHandle *
2375eom_image_get_svg (EomImage *img)
2376{
2377 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2378
2379 return img->priv->svg;
2380}
2381
2382#endif
2383
2384/**
2385 * eom_image_get_transform:
2386 * @img: a #EomImage
2387 *
2388 * Get @img transform.
2389 *
2390 * Returns: (transfer none): A #EomTransform.
2391 */
2392
2393EomTransform *
2394eom_image_get_transform (EomImage *img)
2395{
2396 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2397
2398 return img->priv->trans;
2399}
2400
2401/**
2402 * eom_image_get_autorotate_transform:
2403 * @img: a #EomImage
2404 *
2405 * Get @img autorotate transform.
2406 *
2407 * Returns: (transfer none): A #EomTransform.
2408 */
2409
2410EomTransform*
2411eom_image_get_autorotate_transform (EomImage *img)
2412{
2413 g_return_val_if_fail (EOM_IS_IMAGE (img), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return (((void*)0)); } } while (0)
;
2414
2415 return img->priv->trans_autorotate;
2416}
2417
2418/**
2419 * eom_image_file_changed:
2420 * @img: a #EomImage
2421 *
2422 * Marks the image files contents as changed. Also, emits
2423 * EomImage::file-changed signal
2424 **/
2425void
2426eom_image_file_changed (EomImage *img)
2427{
2428 g_return_if_fail (EOM_IS_IMAGE (img))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return; } } while (0)
;
2429
2430 img->priv->file_is_changed = TRUE(!(0));
2431 g_signal_emit (img, signals[SIGNAL_FILE_CHANGED], 0);
2432}
2433
2434gboolean
2435eom_image_is_file_changed (EomImage *img)
2436{
2437 g_return_val_if_fail (EOM_IS_IMAGE (img), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((!(0))); } } while (0)
;
2438
2439 return img->priv->file_is_changed;
2440}
2441
2442gboolean
2443eom_image_is_jpeg (EomImage *img)
2444{
2445 g_return_val_if_fail (EOM_IS_IMAGE (img), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((img)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (img)"); return ((0)); } } while (0)
;
2446
2447 return ((img->priv->file_type != NULL((void*)0)) && (g_ascii_strcasecmp (img->priv->file_type, EOM_FILE_FORMAT_JPEG"jpeg") == 0));
2448}
2449
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-684c0b.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-684c0b.html new file mode 100644 index 0000000..f25dae1 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-684c0b.html @@ -0,0 +1,835 @@ + + + +eom-util.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-util.c
Warning:line 303, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-util.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-util.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - General Utilities
2 *
3 * Copyright (C) 2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Jens Finke <jens@gnome.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25#ifdef HAVE_CONFIG_H1
26#include "config.h"
27#endif
28
29#include <sys/time.h>
30#ifdef HAVE_STRPTIME1
31#define _XOPEN_SOURCE
32#endif /* HAVE_STRPTIME */
33
34#include <time.h>
35
36#include "eom-util.h"
37
38#include <errno(*__errno_location ()).h>
39#include <string.h>
40#include <glib.h>
41#include <glib/gprintf.h>
42#include <glib/gstdio.h>
43#include <gtk/gtk.h>
44#include <gio/gio.h>
45#include <glib/gi18n.h>
46
47void
48eom_util_show_help (const gchar *section, GtkWindow *parent)
49{
50 GError *error = NULL((void*)0);
51 gchar *uri = NULL((void*)0);
52
53 if (section)
54 uri = g_strdup_printf ("help:eom/%s", section);
55
56 gtk_show_uri_on_window (parent, ((uri != NULL((void*)0)) ? uri : "help:eom"),
57 gtk_get_current_event_time (), &error);
58
59 g_free (uri);
60
61 if (error) {
62 GtkWidget *dialog;
63
64 dialog = gtk_message_dialog_new (parent,
65 0,
66 GTK_MESSAGE_ERROR,
67 GTK_BUTTONS_OK,
68 _("Could not display help for Eye of MATE")gettext ("Could not display help for Eye of MATE"));
69
70 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_message_dialog_get_type ()))))))
,
71 "%s", error->message);
72
73 g_signal_connect_swapped (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
74 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
75 dialog)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
;
76 gtk_widget_show (dialog);
77
78 g_error_free (error);
79 }
80}
81
82gchar *
83eom_util_make_valid_utf8 (const gchar *str)
84{
85 GString *string;
86 const char *remainder, *invalid;
87 int remaining_bytes, valid_bytes;
88
89 string = NULL((void*)0);
90 remainder = str;
91 remaining_bytes = strlen (str);
92
93 while (remaining_bytes != 0) {
94 if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
95 break;
96 }
97
98 valid_bytes = invalid - remainder;
99
100 if (string == NULL((void*)0)) {
101 string = g_string_sized_new (remaining_bytes);
102 }
103
104 g_string_append_len (string, remainder, valid_bytes);
105 g_string_append_c (string, '?')g_string_append_c_inline (string, '?');
106
107 remaining_bytes -= valid_bytes + 1;
108 remainder = invalid + 1;
109 }
110
111 if (string == NULL((void*)0)) {
112 return g_strdup (str);
113 }
114
115 g_string_append (string, remainder);
116 g_string_append (string, _(" (invalid Unicode)")gettext (" (invalid Unicode)"));
117
118 g_assert (g_utf8_validate (string->str, -1, NULL))do { if (g_utf8_validate (string->str, -1, ((void*)0))) ; else
g_assertion_message_expr ("EOM", "eom-util.c", 118, ((const char
*) (__func__)), "g_utf8_validate (string->str, -1, NULL)")
; } while (0)
;
119
120 return g_string_free (string, FALSE(0));
121}
122
123GSList*
124eom_util_parse_uri_string_list_to_file_list (const gchar *uri_list)
125{
126 GSList* file_list = NULL((void*)0);
127 gsize i = 0;
128 gchar **uris;
129
130 uris = g_uri_list_extract_uris (uri_list);
131
132 while (uris[i] != NULL((void*)0)) {
133 file_list = g_slist_append (file_list, g_file_new_for_uri (uris[i]));
134 i++;
135 }
136
137 g_strfreev (uris);
138
139 return file_list;
140}
141
142GSList*
143eom_util_string_list_to_file_list (GSList *string_list)
144{
145 GSList *it = NULL((void*)0);
146 GSList *file_list = NULL((void*)0);
147
148 for (it = string_list; it != NULL((void*)0); it = it->next) {
149 char *uri_str;
150
151 uri_str = (gchar *) it->data;
152
153 file_list = g_slist_prepend (file_list,
154 g_file_new_for_uri (uri_str));
155 }
156
157 return g_slist_reverse (file_list);
158}
159
160GSList*
161eom_util_strings_to_file_list (gchar **strings)
162{
163 int i;
164 GSList *file_list = NULL((void*)0);
165
166 for (i = 0; strings[i]; i++) {
167 file_list = g_slist_prepend (file_list,
168 g_file_new_for_uri (strings[i]));
169 }
170
171 return g_slist_reverse (file_list);
172}
173
174GSList*
175eom_util_string_array_to_list (const gchar **files, gboolean create_uri)
176{
177 gint i;
178 GSList *list = NULL((void*)0);
179
180 if (files == NULL((void*)0)) return list;
181
182 for (i = 0; files[i]; i++) {
183 char *str;
184
185 if (create_uri) {
186 GFile *file;
187
188 file = g_file_new_for_commandline_arg (files[i]);
189 str = g_file_get_uri (file);
190
191 g_object_unref (file);
192 } else {
193 str = g_strdup (files[i]);
194 }
195
196 if (str) {
197 list = g_slist_prepend (list, g_strdup (str));
198 g_free (str);
199 }
200 }
201
202 return g_slist_reverse (list);
203}
204
205gchar **
206eom_util_string_array_make_absolute (gchar **files)
207{
208 int i;
209 int size;
210 gchar **abs_files;
211 GFile *file;
212
213 if (files == NULL((void*)0))
214 return NULL((void*)0);
215
216 size = g_strv_length (files);
217
218 /* Ensure new list is NULL-terminated */
219 abs_files = g_new0 (gchar *, size+1)((gchar * *) g_malloc0_n ((size+1), sizeof (gchar *)));
220
221 for (i = 0; i < size; i++) {
222 file = g_file_new_for_commandline_arg (files[i]);
223 abs_files[i] = g_file_get_uri (file);
224
225 g_object_unref (file);
226 }
227
228 return abs_files;
229}
230
231static gchar *dot_dir = NULL((void*)0);
232
233static gboolean
234ensure_dir_exists (const char *dir)
235{
236 if (g_file_test (dir, G_FILE_TEST_IS_DIR))
237 return TRUE(!(0));
238
239 if (g_mkdir_with_parents (dir, 0700) == 0)
240 return TRUE(!(0));
241
242 if (errno(*__errno_location ()) == EEXIST17)
243 return g_file_test (dir, G_FILE_TEST_IS_DIR);
244
245 g_warning ("Failed to create directory %s: %s", dir, strerror (errno(*__errno_location ())));
246 return FALSE(0);
247}
248
249const gchar *
250eom_util_dot_dir (void)
251{
252 if (dot_dir == NULL((void*)0)) {
253 gboolean exists;
254
255 dot_dir = g_build_filename(g_get_user_config_dir(), "mate", "eom", NULL((void*)0));
256
257 exists = ensure_dir_exists (dot_dir);
258
259 if (G_UNLIKELY (!exists)(!exists)) {
260 static gboolean printed_warning = FALSE(0);
261
262 if (!printed_warning) {
263 g_warning ("EOM could not save some of your preferences in its settings directory due to a file with the same name (%s) blocking its creation. Please remove that file, or move it away.", dot_dir);
264 printed_warning = TRUE(!(0));
265 }
266 dot_dir = NULL((void*)0);
267 return NULL((void*)0);
268 }
269 }
270
271 return dot_dir;
272}
273
274/* Based on eel_filename_strip_extension() */
275
276/**
277 * eom_util_filename_get_extension:
278 * @filename: a filename
279 *
280 * Returns a reasonably good guess of the file extension of @filename.
281 *
282 * Returns: a newly allocated string with the file extension of @filename.
283 **/
284char *
285eom_util_filename_get_extension (const char * filename)
286{
287 char *begin, *begin2;
288
289 if (filename == NULL((void*)0)) {
290 return NULL((void*)0);
291 }
292
293 begin = strrchr (filename, '.');
294
295 if (begin && begin != filename) {
296 if (strcmp (begin, ".gz") == 0 ||
297 strcmp (begin, ".bz2") == 0 ||
298 strcmp (begin, ".sit") == 0 ||
299 strcmp (begin, ".Z") == 0) {
300 begin2 = begin - 1;
301 while (begin2 > filename &&
302 *begin2 != '.') {
303 begin2--;
This statement is never executed
304 }
305 if (begin2 != filename) {
306 begin = begin2;
307 }
308 }
309 begin ++;
310 } else {
311 return NULL((void*)0);
312 }
313
314 return g_strdup (begin);
315}
316
317
318/**
319 * eom_util_file_is_persistent:
320 * @file: a #GFile
321 *
322 * Checks whether @file is a non-removable local mount.
323 *
324 * Returns: %TRUE if @file is in a non-removable mount,
325 * %FALSE otherwise or when it is remote.
326 **/
327gboolean
328eom_util_file_is_persistent (GFile *file)
329{
330 GMount *mount;
331
332 if (!g_file_is_native (file))
333 return FALSE(0);
334
335 mount = g_file_find_enclosing_mount (file, NULL((void*)0), NULL((void*)0));
336 if (mount) {
337 if (g_mount_can_unmount (mount)) {
338 return FALSE(0);
339 }
340 }
341
342 return TRUE(!(0));
343}
344
345static void
346_eom_util_show_file_in_filemanager_fallback (GFile *file, GtkWindow *toplevel)
347{
348 gchar *uri = NULL((void*)0);
349 GError *error = NULL((void*)0);
350 guint32 timestamp = gtk_get_current_event_time ();
351
352 if (g_file_query_file_type (file, 0, NULL((void*)0)) == G_FILE_TYPE_DIRECTORY) {
353 uri = g_file_get_uri (file);
354 } else {
355 /* If input file is not a directory we must open it's
356 folder/parent to avoid opening the file itself */
357 GFile *parent_file;
358
359 parent_file = g_file_get_parent (file);
360 if (G_LIKELY (parent_file)(parent_file))
361 uri = g_file_get_uri (parent_file);
362 g_object_unref (parent_file);
363 }
364
365 if (uri && !gtk_show_uri_on_window (toplevel, uri, timestamp, &error)) {
366 g_warning ("Couldn't show containing folder \"%s\": %s", uri,
367 error->message);
368 g_error_free (error);
369 }
370
371 g_free (uri);
372}
373
374void
375eom_util_show_file_in_filemanager (GFile *file, GtkWindow *toplevel)
376{
377 GDBusProxy *proxy;
378 gboolean done = FALSE(0);
379
380 g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "file != NULL"); return;
} } while (0)
;
381
382 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
383 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
384 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
385 NULL((void*)0), "org.freedesktop.FileManager1",
386 "/org/freedesktop/FileManager1",
387 "org.freedesktop.FileManager1",
388 NULL((void*)0), NULL((void*)0));
389
390 if (proxy) {
391 gchar *uri = g_file_get_uri (file);
392 gchar *startup_id;
393 GVariant *params, *result;
394 GVariantBuilder builder;
395
396 g_variant_builder_init (&builder,
397 G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
398 g_variant_builder_add (&builder, "s", uri);
399
400 /* This seems to be the expected format, as other values
401 cause the filemanager window not to get focus. */
402 startup_id = g_strdup_printf("_TIME%u",
403 gtk_get_current_event_time());
404
405 /* params is floating! */
406 params = g_variant_new ("(ass)", &builder, startup_id);
407
408 g_free (startup_id);
409 g_variant_builder_clear (&builder);
410
411 /* Floating params-GVariant is consumed here */
412 result = g_dbus_proxy_call_sync (proxy, "ShowItems",
413 params, G_DBUS_CALL_FLAGS_NONE,
414 -1, NULL((void*)0), NULL((void*)0));
415
416 /* Receiving a non-NULL result counts as a successful call. */
417 if (G_LIKELY (result != NULL)(result != ((void*)0))) {
418 done = TRUE(!(0));
419 g_variant_unref (result);
420 }
421
422 g_free (uri);
423 g_object_unref (proxy);
424 }
425
426 /* Fallback to gtk_show_uri() if launch over DBus is not possible */
427 if (!done)
428 _eom_util_show_file_in_filemanager_fallback (file, toplevel);
429}
430
431gboolean
432eom_notebook_scroll_event_cb (GtkWidget *widget,
433 GdkEventScroll *event)
434
435{
436 GtkNotebook *notebook = GTK_NOTEBOOK (widget)((((GtkNotebook*) g_type_check_instance_cast ((GTypeInstance*
) ((widget)), ((gtk_notebook_get_type ()))))))
;
437 GtkWidget *child, *event_widget, *action_widget;
438
439 child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
440 if (child == NULL((void*)0))
441 return FALSE(0);
442
443 event_widget = gtk_get_event_widget ((GdkEvent*) event);
444
445 /* Ignore scroll events from the content of the page */
446 if (event_widget == NULL((void*)0) || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
447 return FALSE(0);
448
449 /* And also from the action widgets */
450 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
451 if (event_widget == action_widget || (action_widget != NULL((void*)0) && gtk_widget_is_ancestor (event_widget, action_widget)))
452 return FALSE(0);
453
454 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
455 if (event_widget == action_widget || (action_widget != NULL((void*)0) && gtk_widget_is_ancestor (event_widget, action_widget)))
456 return FALSE(0);
457
458 switch (event->direction) {
459 case GDK_SCROLL_RIGHT:
460 case GDK_SCROLL_DOWN:
461 gtk_notebook_next_page (notebook);
462 break;
463 case GDK_SCROLL_LEFT:
464 case GDK_SCROLL_UP:
465 gtk_notebook_prev_page (notebook);
466 break;
467 case GDK_SCROLL_SMOOTH:
468 switch (gtk_notebook_get_tab_pos (notebook)) {
469 case GTK_POS_LEFT:
470 case GTK_POS_RIGHT:
471 if (event->delta_y > 0)
472 gtk_notebook_next_page (notebook);
473 else if (event->delta_y < 0)
474 gtk_notebook_prev_page (notebook);
475 break;
476 case GTK_POS_TOP:
477 case GTK_POS_BOTTOM:
478 if (event->delta_x > 0)
479 gtk_notebook_next_page (notebook);
480 else if (event->delta_x < 0)
481 gtk_notebook_prev_page (notebook);
482 break;
483 }
484 break;
485 }
486
487 return TRUE(!(0));
488}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-6ac3ab.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-6ac3ab.html new file mode 100644 index 0000000..558e10e --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-6ac3ab.html @@ -0,0 +1,2717 @@ + + + +eom-scroll-view.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-scroll-view.c
Warning:line 1776, column 2
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 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-scroll-view.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-scroll-view.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#ifdef HAVE_CONFIG_H1
2#include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <math.h>
7#include <gdk-pixbuf/gdk-pixbuf.h>
8#include <gdk/gdkkeysyms.h>
9#ifdef HAVE_RSVG1
10#include <librsvg/rsvg.h>
11#endif
12
13#include "eom-config-keys.h"
14#include "eom-enum-types.h"
15#include "eom-marshal.h"
16#include "eom-scroll-view.h"
17#include "eom-debug.h"
18#include "zoom.h"
19
20#include <gdk/gdk.h>
21
22/* Maximum size of delayed repaint rectangles */
23#define PAINT_RECT_WIDTH128 128
24#define PAINT_RECT_HEIGHT128 128
25
26/* Scroll step increment */
27#define SCROLL_STEP_SIZE32 32
28
29/* Maximum zoom factor */
30#define MAX_ZOOM_FACTOR20 20
31#define MIN_ZOOM_FACTOR0.02 0.02
32
33#define CHECK_MEDIUM8 8
34#define CHECK_BLACK"#000000" "#000000"
35#define CHECK_DARK"#555555" "#555555"
36#define CHECK_GRAY"#808080" "#808080"
37#define CHECK_LIGHT"#cccccc" "#cccccc"
38#define CHECK_WHITE"#ffffff" "#ffffff"
39
40/* Default increment for zooming. The current zoom factor is multiplied or
41 * divided by this amount on every zooming step. For consistency, you should
42 * use the same value elsewhere in the program.
43 */
44#define IMAGE_VIEW_ZOOM_MULTIPLIER1.05 1.05
45
46/* States for automatically adjusting the zoom factor */
47typedef enum {
48 ZOOM_MODE_FIT, /* Image is fitted to scroll view even if the latter changes size */
49 ZOOM_MODE_FREE /* The image remains at its current zoom factor even if the scrollview changes size */
50} ZoomMode;
51
52/* Signal IDs */
53enum {
54 SIGNAL_ZOOM_CHANGED,
55 SIGNAL_LAST
56};
57
58static guint view_signals [SIGNAL_LAST] = { 0 };
59
60typedef enum {
61 EOM_SCROLL_VIEW_CURSOR_NORMAL,
62 EOM_SCROLL_VIEW_CURSOR_HIDDEN,
63 EOM_SCROLL_VIEW_CURSOR_DRAG
64} EomScrollViewCursor;
65
66/* Drag 'n Drop */
67static GtkTargetEntry target_table[] = {
68 { "text/uri-list", 0, 0},
69};
70
71enum {
72 PROP_0,
73 PROP_ANTIALIAS_IN,
74 PROP_ANTIALIAS_OUT,
75 PROP_BACKGROUND_COLOR,
76 PROP_IMAGE,
77 PROP_SCROLLWHEEL_ZOOM,
78 PROP_TRANSP_COLOR,
79 PROP_TRANSPARENCY_STYLE,
80 PROP_USE_BG_COLOR,
81 PROP_ZOOM_MULTIPLIER
82};
83
84/* Private part of the EomScrollView structure */
85struct _EomScrollViewPrivate {
86 /* some widgets we rely on */
87 GtkWidget *display;
88 GtkAdjustment *hadj;
89 GtkAdjustment *vadj;
90 GtkWidget *hbar;
91 GtkWidget *vbar;
92 GtkWidget *menu;
93
94 /* actual image */
95 EomImage *image;
96 guint image_changed_id;
97 guint frame_changed_id;
98 GdkPixbuf *pixbuf;
99 cairo_surface_t *surface;
100
101 /* scale factor */
102 gint scale;
103
104 /* zoom mode, either ZOOM_MODE_FIT or ZOOM_MODE_FREE */
105 ZoomMode zoom_mode;
106
107 /* whether to allow zoom > 1.0 on zoom fit */
108 gboolean upscale;
109
110 /* the actual zoom factor */
111 double zoom;
112
113 /* the minimum possible (reasonable) zoom factor */
114 double min_zoom;
115
116 /* Current scrolling offsets */
117 int xofs, yofs;
118
119 /* handler ID for paint idle callback */
120 guint idle_id;
121
122 /* Interpolation type when zoomed in*/
123 cairo_filter_t interp_type_in;
124
125 /* Interpolation type when zoomed out*/
126 cairo_filter_t interp_type_out;
127
128 /* Scroll wheel zoom */
129 gboolean scroll_wheel_zoom;
130
131 /* Scroll wheel zoom */
132 gdouble zoom_multiplier;
133
134 /* dragging stuff */
135 int drag_anchor_x, drag_anchor_y;
136 int drag_ofs_x, drag_ofs_y;
137 guint dragging : 1;
138
139 /* how to indicate transparency in images */
140 EomTransparencyStyle transp_style;
141 GdkRGBA transp_color;
142
143 /* the type of the cursor we are currently showing */
144 EomScrollViewCursor cursor;
145
146 gboolean use_bg_color;
147 GdkRGBA *background_color;
148 GdkRGBA *override_bg_color;
149
150 cairo_surface_t *background_surface;
151
152 /* Two-pass filtering */
153 GSource *hq_redraw_timeout_source;
154 gboolean force_unfiltered;
155};
156
157static void scroll_by (EomScrollView *view, int xofs, int yofs);
158static void set_zoom_fit (EomScrollView *view);
159/* static void request_paint_area (EomScrollView *view, GdkRectangle *area); */
160static void set_minimum_zoom_factor (EomScrollView *view);
161static void view_on_drag_begin_cb (GtkWidget *widget, GdkDragContext *context,
162 gpointer user_data);
163static void view_on_drag_data_get_cb (GtkWidget *widget,
164 GdkDragContext*drag_context,
165 GtkSelectionData *data, guint info,
166 guint time, gpointer user_data);
167
168static gboolean _eom_gdk_rgba_equal0 (const GdkRGBA *a, const GdkRGBA *b);
169
170G_DEFINE_TYPE_WITH_PRIVATE (EomScrollView, eom_scroll_view, GTK_TYPE_GRID)static void eom_scroll_view_init (EomScrollView *self); static
void eom_scroll_view_class_init (EomScrollViewClass *klass);
static GType eom_scroll_view_get_type_once (void); static gpointer
eom_scroll_view_parent_class = ((void*)0); static gint EomScrollView_private_offset
; static void eom_scroll_view_class_intern_init (gpointer klass
) { eom_scroll_view_parent_class = g_type_class_peek_parent (
klass); if (EomScrollView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomScrollView_private_offset); eom_scroll_view_class_init
((EomScrollViewClass*) klass); } __attribute__((__unused__))
static inline gpointer eom_scroll_view_get_instance_private (
EomScrollView *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EomScrollView_private_offset)))); } GType eom_scroll_view_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_scroll_view_get_type_once (); (
__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_scroll_view_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_grid_get_type ()), g_intern_static_string ("EomScrollView"
), sizeof (EomScrollViewClass), (GClassInitFunc)(void (*)(void
)) eom_scroll_view_class_intern_init, sizeof (EomScrollView),
(GInstanceInitFunc)(void (*)(void)) eom_scroll_view_init, (GTypeFlags
) 0); { {{ EomScrollView_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EomScrollViewPrivate)); };} } return
g_define_type_id; }
171
172/*===================================
173 widget size changing handler &
174 util functions
175 ---------------------------------*/
176
177static cairo_surface_t *
178create_surface_from_pixbuf (EomScrollView *view, GdkPixbuf *pixbuf)
179{
180 cairo_surface_t *surface;
181
182 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf,
183 view->priv->scale,
184 gtk_widget_get_window (view->priv->display));
185
186 return surface;
187}
188
189/* Disconnects from the EomImage and removes references to it */
190static void
191free_image_resources (EomScrollView *view)
192{
193 EomScrollViewPrivate *priv;
194
195 priv = view->priv;
196
197 if (priv->image_changed_id > 0) {
198 g_signal_handler_disconnect (G_OBJECT (priv->image)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->image)), (((GType) ((20) << (2))))))))
, priv->image_changed_id);
199 priv->image_changed_id = 0;
200 }
201
202 if (priv->frame_changed_id > 0) {
203 g_signal_handler_disconnect (G_OBJECT (priv->image)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->image)), (((GType) ((20) << (2))))))))
, priv->frame_changed_id);
204 priv->frame_changed_id = 0;
205 }
206
207 if (priv->image != NULL((void*)0)) {
208 eom_image_data_unref (priv->image);
209 priv->image = NULL((void*)0);
210 }
211
212 if (priv->pixbuf != NULL((void*)0)) {
213 g_object_unref (priv->pixbuf);
214 priv->pixbuf = NULL((void*)0);
215 }
216
217 if (priv->surface !=NULL((void*)0)) {
218 cairo_surface_destroy (priv->surface);
219 priv->surface = NULL((void*)0);
220 }
221}
222
223/* Computes the size in pixels of the scaled image */
224static void
225compute_scaled_size (EomScrollView *view, double zoom, int *width, int *height)
226{
227 EomScrollViewPrivate *priv;
228
229 priv = view->priv;
230
231 if (priv->pixbuf) {
232 *width = floor (gdk_pixbuf_get_width (priv->pixbuf) / priv->scale * zoom + 0.5);
233 *height = floor (gdk_pixbuf_get_height (priv->pixbuf) / priv->scale * zoom + 0.5);
234 } else
235 *width = *height = 0;
236}
237
238/* Computes the offsets for the new zoom value so that they keep the image
239 * centered on the view.
240 */
241static void
242compute_center_zoom_offsets (EomScrollView *view,
243 double old_zoom, double new_zoom,
244 int width, int height,
245 double zoom_x_anchor, double zoom_y_anchor,
246 int *xofs, int *yofs)
247{
248 EomScrollViewPrivate *priv;
249 int old_scaled_width, old_scaled_height;
250 int new_scaled_width, new_scaled_height;
251 double view_cx, view_cy;
252
253 priv = view->priv;
254
255 compute_scaled_size (view, old_zoom,
256 &old_scaled_width, &old_scaled_height);
257
258 if (old_scaled_width < width)
259 view_cx = (zoom_x_anchor * old_scaled_width) / old_zoom;
260 else
261 view_cx = (priv->xofs + zoom_x_anchor * width) / old_zoom;
262
263 if (old_scaled_height < height)
264 view_cy = (zoom_y_anchor * old_scaled_height) / old_zoom;
265 else
266 view_cy = (priv->yofs + zoom_y_anchor * height) / old_zoom;
267
268 compute_scaled_size (view, new_zoom,
269 &new_scaled_width, &new_scaled_height);
270
271 if (new_scaled_width < width)
272 *xofs = 0;
273 else {
274 *xofs = floor (view_cx * new_zoom - zoom_x_anchor * width + 0.5);
275 if (*xofs < 0)
276 *xofs = 0;
277 }
278
279 if (new_scaled_height < height)
280 *yofs = 0;
281 else {
282 *yofs = floor (view_cy * new_zoom - zoom_y_anchor * height + 0.5);
283 if (*yofs < 0)
284 *yofs = 0;
285 }
286}
287
288/* Sets the scrollbar values based on the current scrolling offset */
289static void
290update_scrollbar_values (EomScrollView *view)
291{
292 EomScrollViewPrivate *priv;
293 int scaled_width, scaled_height;
294 gdouble page_size,page_increment,step_increment;
295 gdouble lower, upper;
296 GtkAllocation allocation;
297
298 priv = view->priv;
299
300 if (!gtk_widget_get_visible (GTK_WIDGET (priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->hbar)), ((gtk_widget_get_type ()))))))
)
301 && !gtk_widget_get_visible (GTK_WIDGET (priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->vbar)), ((gtk_widget_get_type ()))))))
))
302 return;
303
304 compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
305 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
306
307 if (gtk_widget_get_visible (GTK_WIDGET (priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->hbar)), ((gtk_widget_get_type ()))))))
)) {
308 /* Set scroll increments */
309 page_size = MIN (scaled_width, allocation.width)(((scaled_width) < (allocation.width)) ? (scaled_width) : (
allocation.width))
;
310
311 page_increment = allocation.width / 2;
312 step_increment = SCROLL_STEP_SIZE32;
313
314 /* Set scroll bounds and new offsets */
315 lower = 0;
316 upper = scaled_width;
317 priv->xofs = CLAMP (priv->xofs, 0, upper - page_size)(((priv->xofs) > (upper - page_size)) ? (upper - page_size
) : (((priv->xofs) < (0)) ? (0) : (priv->xofs)))
;
318
319 g_signal_handlers_block_matched (
320 priv->hadj, G_SIGNAL_MATCH_DATA,
321 0, 0, NULL((void*)0), NULL((void*)0), view);
322
323 gtk_adjustment_configure (priv->hadj, priv->xofs, lower,
324 upper, step_increment,
325 page_increment, page_size);
326
327 g_signal_handlers_unblock_matched (
328 priv->hadj, G_SIGNAL_MATCH_DATA,
329 0, 0, NULL((void*)0), NULL((void*)0), view);
330 }
331
332 if (gtk_widget_get_visible (GTK_WIDGET (priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->vbar)), ((gtk_widget_get_type ()))))))
)) {
333 page_size = MIN (scaled_height, allocation.height)(((scaled_height) < (allocation.height)) ? (scaled_height)
: (allocation.height))
;
334 page_increment = allocation.height / 2;
335 step_increment = SCROLL_STEP_SIZE32;
336
337 lower = 0;
338 upper = scaled_height;
339 priv->yofs = CLAMP (priv->yofs, 0, upper - page_size)(((priv->yofs) > (upper - page_size)) ? (upper - page_size
) : (((priv->yofs) < (0)) ? (0) : (priv->yofs)))
;
340
341 g_signal_handlers_block_matched (
342 priv->vadj, G_SIGNAL_MATCH_DATA,
343 0, 0, NULL((void*)0), NULL((void*)0), view);
344
345 gtk_adjustment_configure (priv->vadj, priv->yofs, lower,
346 upper, step_increment,
347 page_increment, page_size);
348
349 g_signal_handlers_unblock_matched (
350 priv->vadj, G_SIGNAL_MATCH_DATA,
351 0, 0, NULL((void*)0), NULL((void*)0), view);
352 }
353}
354
355static void
356eom_scroll_view_set_cursor (EomScrollView *view, EomScrollViewCursor new_cursor)
357{
358 GdkCursor *cursor = NULL((void*)0);
359 GdkDisplay *display;
360 GtkWidget *widget;
361
362 if (view->priv->cursor == new_cursor) {
363 return;
364 }
365
366 widget = gtk_widget_get_toplevel (GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
);
367 display = gtk_widget_get_display (widget);
368 view->priv->cursor = new_cursor;
369
370 switch (new_cursor) {
371 case EOM_SCROLL_VIEW_CURSOR_NORMAL:
372 gdk_window_set_cursor (gtk_widget_get_window (widget), NULL((void*)0));
373 break;
374 case EOM_SCROLL_VIEW_CURSOR_HIDDEN:
375 cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
376 break;
377 case EOM_SCROLL_VIEW_CURSOR_DRAG:
378 cursor = gdk_cursor_new_for_display (display, GDK_FLEUR);
379 break;
380 }
381
382 if (cursor) {
383 gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
384 g_object_unref (cursor);
385 gdk_display_flush (display);
386 }
387}
388
389/* Changes visibility of the scrollbars based on the zoom factor and the
390 * specified allocation, or the current allocation if NULL is specified.
391 */
392static void
393check_scrollbar_visibility (EomScrollView *view, GtkAllocation *alloc)
394{
395 EomScrollViewPrivate *priv;
396 int bar_height;
397 int bar_width;
398 int img_width;
399 int img_height;
400 GtkRequisition req;
401 int width, height;
402 gboolean hbar_visible, vbar_visible;
403
404 priv = view->priv;
405
406 if (alloc) {
407 width = alloc->width;
408 height = alloc->height;
409 } else {
410 GtkAllocation allocation;
411
412 gtk_widget_get_allocation (GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
, &allocation);
413 width = allocation.width;
414 height = allocation.height;
415 }
416
417 compute_scaled_size (view, priv->zoom, &img_width, &img_height);
418
419 /* this should work fairly well in this special case for scrollbars */
420 gtk_widget_get_preferred_size (priv->hbar, &req, NULL((void*)0));
421 bar_height = req.height;
422 gtk_widget_get_preferred_size (priv->vbar, &req, NULL((void*)0));
423 bar_width = req.width;
424
425 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-scroll-view.c", 425, ((const char*) (__func__
))
, "Widget Size allocate: %i, %i Bar: %i, %i\n",
426 width, height, bar_width, bar_height);
427
428 hbar_visible = vbar_visible = FALSE(0);
429 if (priv->zoom_mode == ZOOM_MODE_FIT)
430 hbar_visible = vbar_visible = FALSE(0);
431 else if (img_width <= width && img_height <= height)
432 hbar_visible = vbar_visible = FALSE(0);
433 else if (img_width > width && img_height > height)
434 hbar_visible = vbar_visible = TRUE(!(0));
435 else if (img_width > width) {
436 hbar_visible = TRUE(!(0));
437 if (img_height <= (height - bar_height))
438 vbar_visible = FALSE(0);
439 else
440 vbar_visible = TRUE(!(0));
441 }
442 else if (img_height > height) {
443 vbar_visible = TRUE(!(0));
444 if (img_width <= (width - bar_width))
445 hbar_visible = FALSE(0);
446 else
447 hbar_visible = TRUE(!(0));
448 }
449
450 if (hbar_visible != gtk_widget_get_visible (GTK_WIDGET (priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->hbar)), ((gtk_widget_get_type ()))))))
))
451 g_object_set (G_OBJECT (priv->hbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->hbar)), (((GType) ((20) << (2))))))))
, "visible", hbar_visible, NULL((void*)0));
452
453 if (vbar_visible != gtk_widget_get_visible (GTK_WIDGET (priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->vbar)), ((gtk_widget_get_type ()))))))
))
454 g_object_set (G_OBJECT (priv->vbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->vbar)), (((GType) ((20) << (2))))))))
, "visible", vbar_visible, NULL((void*)0));
455}
456
457#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
458#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
459
460/* Returns whether the image is zoomed in */
461static gboolean
462is_zoomed_in (EomScrollView *view)
463{
464 EomScrollViewPrivate *priv;
465
466 priv = view->priv;
467 return priv->zoom - 1.0 > DOUBLE_EQUAL_MAX_DIFF1e-6;
468}
469
470/* Returns whether the image is zoomed out */
471static gboolean
472is_zoomed_out (EomScrollView *view)
473{
474 EomScrollViewPrivate *priv;
475
476 priv = view->priv;
477 return DOUBLE_EQUAL_MAX_DIFF1e-6 + priv->zoom - 1.0 < 0.0;
478}
479
480/* Returns wether the image is movable, that means if it is larger then
481 * the actual visible area.
482 */
483static gboolean
484is_image_movable (EomScrollView *view)
485{
486 EomScrollViewPrivate *priv;
487
488 priv = view->priv;
489
490 return (gtk_widget_get_visible (priv->hbar) || gtk_widget_get_visible (priv->vbar));
491}
492
493/*===================================
494 drawing core
495 ---------------------------------*/
496
497static void
498get_transparency_params (EomScrollView *view, int *size, GdkRGBA *color1, GdkRGBA *color2)
499{
500 EomScrollViewPrivate *priv;
501
502 priv = view->priv;
503
504 /* Compute transparency parameters */
505 switch (priv->transp_style) {
506 case EOM_TRANSP_BACKGROUND: {
507 /* Simply return fully transparent color */
508 color1->red = color1->green = color1->blue = color1->alpha = 0.0;
509 color2->red = color2->green = color2->blue = color2->alpha = 0.0;
510 break;
511 }
512
513 case EOM_TRANSP_CHECKED:
514 g_warn_if_fail (gdk_rgba_parse (color1, CHECK_GRAY))do { if (gdk_rgba_parse (color1, "#808080")) ; else g_warn_message
("EOM", "eom-scroll-view.c", 514, ((const char*) (__func__))
, "gdk_rgba_parse (color1, CHECK_GRAY)"); } while (0)
;
515 g_warn_if_fail (gdk_rgba_parse (color2, CHECK_LIGHT))do { if (gdk_rgba_parse (color2, "#cccccc")) ; else g_warn_message
("EOM", "eom-scroll-view.c", 515, ((const char*) (__func__))
, "gdk_rgba_parse (color2, CHECK_LIGHT)"); } while (0)
;
516 break;
517
518 case EOM_TRANSP_COLOR:
519 *color1 = *color2 = priv->transp_color;
520 break;
521
522 default:
523 g_assert_not_reached ()do { g_assertion_message_expr ("EOM", "eom-scroll-view.c", 523
, ((const char*) (__func__)), ((void*)0)); } while (0)
;
524 };
525
526 *size = CHECK_MEDIUM8;
527}
528
529static cairo_surface_t *
530create_background_surface (EomScrollView *view)
531{
532 int check_size;
533 GdkRGBA check_1;
534 GdkRGBA check_2;
535 cairo_surface_t *surface;
536
537 get_transparency_params (view, &check_size, &check_1, &check_2);
538 surface = gdk_window_create_similar_surface (gtk_widget_get_window (view->priv->display),
539 CAIRO_CONTENT_COLOR_ALPHA,
540 check_size * 2, check_size * 2);
541 cairo_t* cr = cairo_create (surface);
542
543 /* Use source operator to make fully transparent work */
544 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
545
546 gdk_cairo_set_source_rgba(cr, &check_1);
547 cairo_rectangle (cr, 0, 0, check_size, check_size);
548 cairo_rectangle (cr, check_size, check_size, check_size, check_size);
549 cairo_fill (cr);
550
551 gdk_cairo_set_source_rgba(cr, &check_2);
552 cairo_rectangle (cr, 0, check_size, check_size, check_size);
553 cairo_rectangle (cr, check_size, 0, check_size, check_size);
554 cairo_fill (cr);
555
556 cairo_destroy (cr);
557
558 return surface;
559}
560
561/* =======================================
562
563 scrolling stuff
564
565 --------------------------------------*/
566
567
568/* Scrolls the view to the specified offsets. */
569static void
570scroll_to (EomScrollView *view, int x, int y, gboolean change_adjustments)
571{
572 EomScrollViewPrivate *priv;
573 GtkAllocation allocation;
574 int xofs, yofs;
575 GdkWindow *window;
576
577 priv = view->priv;
578
579 /* Check bounds & Compute offsets */
580 if (gtk_widget_get_visible (priv->hbar)) {
581 x = CLAMP (x, 0, gtk_adjustment_get_upper (priv->hadj)(((x) > (gtk_adjustment_get_upper (priv->hadj) - gtk_adjustment_get_page_size
(priv->hadj))) ? (gtk_adjustment_get_upper (priv->hadj
) - gtk_adjustment_get_page_size (priv->hadj)) : (((x) <
(0)) ? (0) : (x)))
582 - gtk_adjustment_get_page_size (priv->hadj))(((x) > (gtk_adjustment_get_upper (priv->hadj) - gtk_adjustment_get_page_size
(priv->hadj))) ? (gtk_adjustment_get_upper (priv->hadj
) - gtk_adjustment_get_page_size (priv->hadj)) : (((x) <
(0)) ? (0) : (x)))
;
583 xofs = x - priv->xofs;
584 } else
585 xofs = 0;
586
587 if (gtk_widget_get_visible (priv->vbar)) {
588 y = CLAMP (y, 0, gtk_adjustment_get_upper (priv->vadj)(((y) > (gtk_adjustment_get_upper (priv->vadj) - gtk_adjustment_get_page_size
(priv->vadj))) ? (gtk_adjustment_get_upper (priv->vadj
) - gtk_adjustment_get_page_size (priv->vadj)) : (((y) <
(0)) ? (0) : (y)))
589 - gtk_adjustment_get_page_size (priv->vadj))(((y) > (gtk_adjustment_get_upper (priv->vadj) - gtk_adjustment_get_page_size
(priv->vadj))) ? (gtk_adjustment_get_upper (priv->vadj
) - gtk_adjustment_get_page_size (priv->vadj)) : (((y) <
(0)) ? (0) : (y)))
;
590 yofs = y - priv->yofs;
591 } else
592 yofs = 0;
593
594 if (xofs == 0 && yofs == 0)
595 return;
596
597 priv->xofs = x;
598 priv->yofs = y;
599
600 if (!gtk_widget_is_drawable (priv->display))
601 goto out;
602
603 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
604
605 if (abs (xofs) >= allocation.width || abs (yofs) >= allocation.height) {
606 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
607 goto out;
608 }
609
610 window = gtk_widget_get_window (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
611
612 gdk_window_scroll (window, -xofs, -yofs);
613
614 out:
615 if (!change_adjustments)
616 return;
617
618 g_signal_handlers_block_matched (
619 priv->hadj, G_SIGNAL_MATCH_DATA,
620 0, 0, NULL((void*)0), NULL((void*)0), view);
621 g_signal_handlers_block_matched (
622 priv->vadj, G_SIGNAL_MATCH_DATA,
623 0, 0, NULL((void*)0), NULL((void*)0), view);
624
625 gtk_adjustment_set_value (priv->hadj, x);
626 gtk_adjustment_set_value (priv->vadj, y);
627
628 g_signal_handlers_unblock_matched (
629 priv->hadj, G_SIGNAL_MATCH_DATA,
630 0, 0, NULL((void*)0), NULL((void*)0), view);
631 g_signal_handlers_unblock_matched (
632 priv->vadj, G_SIGNAL_MATCH_DATA,
633 0, 0, NULL((void*)0), NULL((void*)0), view);
634}
635
636/* Scrolls the image view by the specified offsets. Notifies the adjustments
637 * about their new values.
638 */
639static void
640scroll_by (EomScrollView *view, int xofs, int yofs)
641{
642 EomScrollViewPrivate *priv;
643
644 priv = view->priv;
645
646 scroll_to (view, priv->xofs + xofs, priv->yofs + yofs, TRUE(!(0)));
647}
648
649
650/* Callback used when an adjustment is changed */
651static void
652adjustment_changed_cb (GtkAdjustment *adj, gpointer data)
653{
654 EomScrollView *view;
655 EomScrollViewPrivate *priv;
656
657 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
658 priv = view->priv;
659
660 scroll_to (view, gtk_adjustment_get_value (priv->hadj),
661 gtk_adjustment_get_value (priv->vadj), FALSE(0));
662}
663
664
665/* Drags the image to the specified position */
666static void
667drag_to (EomScrollView *view, int x, int y)
668{
669 EomScrollViewPrivate *priv;
670 int dx, dy;
671
672 priv = view->priv;
673
674 dx = priv->drag_anchor_x - x;
675 dy = priv->drag_anchor_y - y;
676
677 x = priv->drag_ofs_x + dx;
678 y = priv->drag_ofs_y + dy;
679
680 scroll_to (view, x, y, TRUE(!(0)));
681}
682
683static void
684set_minimum_zoom_factor (EomScrollView *view)
685{
686 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
687
688 view->priv->min_zoom = MAX (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view->priv->scale,(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view
->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view
->priv->pixbuf) / view->priv->scale) > (0.02))
? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width
(view->priv->pixbuf) / view->priv->scale) : ((((
1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height
(view->priv->pixbuf) / view->priv->scale) : (0.02
))))
689 MAX(1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view->priv->scale,(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view
->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view
->priv->pixbuf) / view->priv->scale) > (0.02))
? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width
(view->priv->pixbuf) / view->priv->scale) : ((((
1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height
(view->priv->pixbuf) / view->priv->scale) : (0.02
))))
690 MIN_ZOOM_FACTOR) )(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view
->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view
->priv->pixbuf) / view->priv->scale) > (0.02))
? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width
(view->priv->pixbuf) / view->priv->scale) : ((((
1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height
(view->priv->pixbuf) / view->priv->scale) : (0.02
))))
;
691 return;
692}
693
694/**
695 * set_zoom:
696 * @view: A scroll view.
697 * @zoom: Zoom factor.
698 * @have_anchor: Whether the anchor point specified by (@anchorx, @anchory)
699 * should be used.
700 * @anchorx: Horizontal anchor point in pixels.
701 * @anchory: Vertical anchor point in pixels.
702 *
703 * Sets the zoom factor for an image view. The anchor point can be used to
704 * specify the point that stays fixed when the image is zoomed. If @have_anchor
705 * is %TRUE, then (@anchorx, @anchory) specify the point relative to the image
706 * view widget's allocation that will stay fixed when zooming. If @have_anchor
707 * is %FALSE, then the center point of the image view will be used.
708 **/
709static void
710set_zoom (EomScrollView *view, double zoom,
711 gboolean have_anchor, int anchorx, int anchory)
712{
713 EomScrollViewPrivate *priv;
714 GtkAllocation allocation;
715 int xofs, yofs;
716 double x_rel, y_rel;
717
718 priv = view->priv;
719
720 if (priv->pixbuf == NULL((void*)0))
721 return;
722
723 if (zoom > MAX_ZOOM_FACTOR20)
724 zoom = MAX_ZOOM_FACTOR20;
725 else if (zoom < MIN_ZOOM_FACTOR0.02)
726 zoom = MIN_ZOOM_FACTOR0.02;
727
728 if (DOUBLE_EQUAL (priv->zoom, zoom)(fabs (priv->zoom - zoom) < 1e-6))
729 return;
730 if (DOUBLE_EQUAL (priv->zoom, priv->min_zoom)(fabs (priv->zoom - priv->min_zoom) < 1e-6) && zoom < priv->zoom)
731 return;
732
733 priv->zoom_mode = ZOOM_MODE_FREE;
734
735 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
736
737 /* compute new xofs/yofs values */
738 if (have_anchor) {
739 x_rel = (double) anchorx / allocation.width;
740 y_rel = (double) anchory / allocation.height;
741 } else {
742 x_rel = 0.5;
743 y_rel = 0.5;
744 }
745
746 compute_center_zoom_offsets (view, priv->zoom, zoom,
747 allocation.width, allocation.height,
748 x_rel, y_rel,
749 &xofs, &yofs);
750
751 /* set new values */
752 priv->xofs = xofs; /* (img_width * x_rel * zoom) - anchorx; */
753 priv->yofs = yofs; /* (img_height * y_rel * zoom) - anchory; */
754#if 0
755 g_print ("xofs: %i yofs: %i\n", priv->xofs, priv->yofs);
756#endif
757 if (zoom <= priv->min_zoom)
758 priv->zoom = priv->min_zoom;
759 else
760 priv->zoom = zoom;
761
762 /* we make use of the new values here */
763 check_scrollbar_visibility (view, NULL((void*)0));
764 update_scrollbar_values (view);
765
766 /* repaint the whole image */
767 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
768
769 g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom);
770}
771
772/* Zooms the image to fit the available allocation */
773static void
774set_zoom_fit (EomScrollView *view)
775{
776 EomScrollViewPrivate *priv;
777 GtkAllocation allocation;
778 double new_zoom;
779
780 priv = view->priv;
781
782 priv->zoom_mode = ZOOM_MODE_FIT;
783
784 if (!gtk_widget_get_mapped (GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
))
785 return;
786
787 if (priv->pixbuf == NULL((void*)0))
788 return;
789
790 gtk_widget_get_allocation (GTK_WIDGET(priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
791
792 new_zoom = zoom_fit_scale (allocation.width, allocation.height,
793 gdk_pixbuf_get_width (priv->pixbuf) / priv->scale,
794 gdk_pixbuf_get_height (priv->pixbuf) / priv->scale,
795 priv->upscale);
796
797 if (new_zoom > MAX_ZOOM_FACTOR20)
798 new_zoom = MAX_ZOOM_FACTOR20;
799 else if (new_zoom < MIN_ZOOM_FACTOR0.02)
800 new_zoom = MIN_ZOOM_FACTOR0.02;
801
802 priv->zoom = new_zoom;
803 priv->xofs = 0;
804 priv->yofs = 0;
805
806 g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom);
807}
808
809/*===================================
810
811 internal signal callbacks
812
813 ---------------------------------*/
814
815/* Key press event handler for the image view */
816static gboolean
817display_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
818{
819 EomScrollView *view;
820 EomScrollViewPrivate *priv;
821 GtkAllocation allocation;
822 gboolean do_zoom;
823 double zoom;
824 gboolean do_scroll;
825 int xofs, yofs;
826
827 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
828 priv = view->priv;
829
830 do_zoom = FALSE(0);
831 do_scroll = FALSE(0);
832 xofs = yofs = 0;
833 zoom = 1.0;
834
835 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
836
837 /* EomScrollView doesn't handle/have any Alt+Key combos */
838 if (event->state & GDK_MOD1_MASK) {
839 return FALSE(0);
840 }
841
842 switch (event->keyval) {
843 case GDK_KEY_Up0xff52:
844 do_scroll = TRUE(!(0));
845 xofs = 0;
846 yofs = -SCROLL_STEP_SIZE32;
847 break;
848
849 case GDK_KEY_Page_Up0xff55:
850 do_scroll = TRUE(!(0));
851 if (event->state & GDK_CONTROL_MASK) {
852 xofs = -(allocation.width * 3) / 4;
853 yofs = 0;
854 } else {
855 xofs = 0;
856 yofs = -(allocation.height * 3) / 4;
857 }
858 break;
859
860 case GDK_KEY_Down0xff54:
861 do_scroll = TRUE(!(0));
862 xofs = 0;
863 yofs = SCROLL_STEP_SIZE32;
864 break;
865
866 case GDK_KEY_Page_Down0xff56:
867 do_scroll = TRUE(!(0));
868 if (event->state & GDK_CONTROL_MASK) {
869 xofs = (allocation.width * 3) / 4;
870 yofs = 0;
871 } else {
872 xofs = 0;
873 yofs = (allocation.height * 3) / 4;
874 }
875 break;
876
877 case GDK_KEY_Left0xff51:
878 do_scroll = TRUE(!(0));
879 xofs = -SCROLL_STEP_SIZE32;
880 yofs = 0;
881 break;
882
883 case GDK_KEY_Right0xff53:
884 do_scroll = TRUE(!(0));
885 xofs = SCROLL_STEP_SIZE32;
886 yofs = 0;
887 break;
888
889 case GDK_KEY_plus0x02b:
890 case GDK_KEY_equal0x03d:
891 case GDK_KEY_KP_Add0xffab:
892 do_zoom = TRUE(!(0));
893 zoom = priv->zoom * priv->zoom_multiplier;
894 break;
895
896 case GDK_KEY_minus0x02d:
897 case GDK_KEY_KP_Subtract0xffad:
898 do_zoom = TRUE(!(0));
899 zoom = priv->zoom / priv->zoom_multiplier;
900 break;
901
902 case GDK_KEY_10x031:
903 do_zoom = TRUE(!(0));
904 zoom = 1.0;
905 break;
906
907 default:
908 return FALSE(0);
909 }
910
911 if (do_zoom) {
912 GdkSeat *seat;
913 GdkDevice *device;
914 gint x, y;
915
916 seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
917 device = gdk_seat_get_pointer (seat);
918
919 gdk_window_get_device_position (gtk_widget_get_window (widget), device,
920 &x, &y, NULL((void*)0));
921 set_zoom (view, zoom, TRUE(!(0)), x, y);
922 }
923
924 if (do_scroll)
925 scroll_by (view, xofs, yofs);
926
927 return TRUE(!(0));
928}
929
930
931/* Button press event handler for the image view */
932static gboolean
933eom_scroll_view_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
934{
935 EomScrollView *view;
936 EomScrollViewPrivate *priv;
937
938 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
939 priv = view->priv;
940
941 if (!gtk_widget_has_focus (priv->display))
942 gtk_widget_grab_focus (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
943
944 if (priv->dragging)
945 return FALSE(0);
946
947 switch (event->button) {
948 case 1:
949 case 2:
950 if (event->button == 1 && !priv->scroll_wheel_zoom &&
951 !(event->state & GDK_CONTROL_MASK))
952 break;
953
954 if (is_image_movable (view)) {
955 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_DRAG);
956
957 priv->dragging = TRUE(!(0));
958 priv->drag_anchor_x = event->x;
959 priv->drag_anchor_y = event->y;
960
961 priv->drag_ofs_x = priv->xofs;
962 priv->drag_ofs_y = priv->yofs;
963
964 return TRUE(!(0));
965 }
966 default:
967 break;
968 }
969
970 return FALSE(0);
971}
972
973/* Button release event handler for the image view */
974static gboolean
975eom_scroll_view_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
976{
977 EomScrollView *view;
978 EomScrollViewPrivate *priv;
979
980 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
981 priv = view->priv;
982
983 if (!priv->dragging)
984 return FALSE(0);
985
986 switch (event->button) {
987 case 1:
988 case 2:
989 drag_to (view, event->x, event->y);
990 priv->dragging = FALSE(0);
991
992 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_NORMAL);
993 break;
994
995 default:
996 break;
997 }
998
999 return TRUE(!(0));
1000}
1001
1002/* Scroll event handler for the image view. We zoom with an event without
1003 * modifiers rather than scroll; we use the Shift modifier to scroll.
1004 * Rationale: images are not primarily vertical, and in EOM you scan scroll by
1005 * dragging the image with button 1 anyways.
1006 */
1007static gboolean
1008eom_scroll_view_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer data)
1009{
1010 EomScrollView *view;
1011 EomScrollViewPrivate *priv;
1012 double zoom_factor;
1013 int xofs, yofs;
1014
1015 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1016 priv = view->priv;
1017
1018 /* Compute zoom factor and scrolling offsets; we'll only use either of them */
1019 /* same as in gtkscrolledwindow.c */
1020 xofs = gtk_adjustment_get_page_increment (priv->hadj) / 2;
1021 yofs = gtk_adjustment_get_page_increment (priv->vadj) / 2;
1022
1023 switch (event->direction) {
1024 case GDK_SCROLL_UP:
1025 zoom_factor = priv->zoom_multiplier;
1026 xofs = 0;
1027 yofs = -yofs;
1028 break;
1029
1030 case GDK_SCROLL_LEFT:
1031 zoom_factor = 1.0 / priv->zoom_multiplier;
1032 xofs = -xofs;
1033 yofs = 0;
1034 break;
1035
1036 case GDK_SCROLL_DOWN:
1037 zoom_factor = 1.0 / priv->zoom_multiplier;
1038 xofs = 0;
1039 yofs = yofs;
1040 break;
1041
1042 case GDK_SCROLL_RIGHT:
1043 zoom_factor = priv->zoom_multiplier;
1044 xofs = xofs;
1045 yofs = 0;
1046 break;
1047
1048 default:
1049 g_assert_not_reached ()do { g_assertion_message_expr ("EOM", "eom-scroll-view.c", 1049
, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1050 return FALSE(0);
1051 }
1052
1053 if (priv->scroll_wheel_zoom) {
1054 if (event->state & GDK_SHIFT_MASK)
1055 scroll_by (view, yofs, xofs);
1056 else if (event->state & GDK_CONTROL_MASK)
1057 scroll_by (view, xofs, yofs);
1058 else
1059 set_zoom (view, priv->zoom * zoom_factor,
1060 TRUE(!(0)), event->x, event->y);
1061 } else {
1062 if (event->state & GDK_SHIFT_MASK)
1063 scroll_by (view, yofs, xofs);
1064 else if (event->state & GDK_CONTROL_MASK)
1065 set_zoom (view, priv->zoom * zoom_factor,
1066 TRUE(!(0)), event->x, event->y);
1067 else
1068 scroll_by (view, xofs, yofs);
1069 }
1070
1071 return TRUE(!(0));
1072}
1073
1074/* Motion event handler for the image view */
1075static gboolean
1076eom_scroll_view_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
1077{
1078 EomScrollView *view;
1079 EomScrollViewPrivate *priv;
1080 gint x, y;
1081 GdkModifierType mods;
1082
1083 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1084 priv = view->priv;
1085
1086 if (!priv->dragging)
1087 return FALSE(0);
1088
1089 if (event->is_hint)
1090 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
), event->device, &x, &y, &mods);
1091 else {
1092 x = event->x;
1093 y = event->y;
1094 }
1095
1096 drag_to (view, x, y);
1097 return TRUE(!(0));
1098}
1099
1100static void
1101display_map_event (GtkWidget *widget, GdkEvent *event, gpointer data)
1102{
1103 EomScrollView *view;
1104 EomScrollViewPrivate *priv;
1105
1106 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1107 priv = view->priv;
1108
1109 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-scroll-view.c", 1109, ((const char*) (
__func__))
);
1110
1111 set_zoom_fit (view);
1112 check_scrollbar_visibility (view, NULL((void*)0));
1113 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1114}
1115
1116static void
1117eom_scroll_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc)
1118{
1119 EomScrollView *view;
1120
1121 view = EOM_SCROLL_VIEW (widget)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_scroll_view_get_type ()))))))
;
1122 check_scrollbar_visibility (view, alloc);
1123
1124 GTK_WIDGET_CLASS (eom_scroll_view_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_scroll_view_parent_class)), ((gtk_widget_get_type ()))))
))
->size_allocate (widget
1125 ,alloc);
1126}
1127
1128static void
1129display_size_change (GtkWidget *widget, GdkEventConfigure *event, gpointer data)
1130{
1131 EomScrollView *view;
1132 EomScrollViewPrivate *priv;
1133
1134 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1135 priv = view->priv;
1136
1137 if (priv->zoom_mode == ZOOM_MODE_FIT) {
1138 GtkAllocation alloc;
1139
1140 alloc.width = event->width;
1141 alloc.height = event->height;
1142
1143 set_zoom_fit (view);
1144 check_scrollbar_visibility (view, &alloc);
1145 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1146 } else {
1147 int scaled_width, scaled_height;
1148 int x_offset = 0;
1149 int y_offset = 0;
1150
1151 compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
1152
1153 if (priv->xofs + event->width > scaled_width)
1154 x_offset = scaled_width - event->width - priv->xofs;
1155
1156 if (priv->yofs + event->height > scaled_height)
1157 y_offset = scaled_height - event->height - priv->yofs;
1158
1159 scroll_by (view, x_offset, y_offset);
1160 }
1161
1162 update_scrollbar_values (view);
1163}
1164
1165
1166static gboolean
1167eom_scroll_view_focus_in_event (GtkWidget *widget,
1168 GdkEventFocus *event,
1169 gpointer data)
1170{
1171 g_signal_stop_emission_by_name (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "focus_in_event");
1172 return FALSE(0);
1173}
1174
1175static gboolean
1176eom_scroll_view_focus_out_event (GtkWidget *widget,
1177 GdkEventFocus *event,
1178 gpointer data)
1179{
1180 g_signal_stop_emission_by_name (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "focus_out_event");
1181 return FALSE(0);
1182}
1183
1184static gboolean _hq_redraw_cb (gpointer user_data)
1185{
1186 EomScrollViewPrivate *priv = EOM_SCROLL_VIEW (user_data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_scroll_view_get_type ()))))))
->priv;
1187
1188 priv->force_unfiltered = FALSE(0);
1189 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1190
1191 priv->hq_redraw_timeout_source = NULL((void*)0);
1192 return G_SOURCE_REMOVE(0);
1193}
1194
1195static void
1196_clear_hq_redraw_timeout (EomScrollView *view)
1197{
1198 EomScrollViewPrivate *priv = view->priv;
1199
1200 if (priv->hq_redraw_timeout_source != NULL((void*)0)) {
1201 g_source_unref (priv->hq_redraw_timeout_source);
1202 g_source_destroy (priv->hq_redraw_timeout_source);
1203 }
1204
1205 priv->hq_redraw_timeout_source = NULL((void*)0);
1206}
1207
1208static void
1209_set_hq_redraw_timeout (EomScrollView *view)
1210{
1211 GSource *source;
1212
1213 _clear_hq_redraw_timeout (view);
1214
1215 source = g_timeout_source_new (200);
1216 g_source_set_callback (source, &_hq_redraw_cb, view, NULL((void*)0));
1217
1218 g_source_attach (source, NULL((void*)0));
1219
1220 view->priv->hq_redraw_timeout_source = source;
1221}
1222
1223static gboolean
1224display_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
1225{
1226 const GdkRGBA *background_color = NULL((void*)0);
1227 EomScrollView *view;
1228 EomScrollViewPrivate *priv;
1229 GtkAllocation allocation;
1230 int scaled_width, scaled_height;
1231 int xofs, yofs;
1232
1233 g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_drawing_area_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 ("EOM", ((const char*) (__func__
)), "GTK_IS_DRAWING_AREA (widget)"); return ((0)); } } while (
0)
;
1234 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (data), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (data)"); return ((0)); } } while (0)
;
1235
1236 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1237
1238 priv = view->priv;
1239
1240 if (priv->pixbuf == NULL((void*)0))
1241 return TRUE(!(0));
1242
1243 compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
1244
1245 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
1246
1247 /* Compute image offsets with respect to the window */
1248
1249 if (scaled_width <= allocation.width)
1250 xofs = (allocation.width - scaled_width) / 2;
1251 else
1252 xofs = -priv->xofs;
1253
1254 if (scaled_height <= allocation.height)
1255 yofs = (allocation.height - scaled_height) / 2;
1256 else
1257 yofs = -priv->yofs;
1258
1259 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-scroll-view.c", 1259, ((const char*) (
__func__))
, "zoom %.2f, xofs: %i, yofs: %i scaled w: %i h: %i\n",
1260 priv->zoom, xofs, yofs, scaled_width, scaled_height);
1261
1262 /* Paint the background */
1263 cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
1264 if (priv->transp_style != EOM_TRANSP_BACKGROUND)
1265 cairo_rectangle (cr, MAX (0, xofs)(((0) > (xofs)) ? (0) : (xofs)), MAX (0, yofs)(((0) > (yofs)) ? (0) : (yofs)),
1266 scaled_width, scaled_height);
1267 if (priv->override_bg_color != NULL((void*)0))
1268 background_color = priv->override_bg_color;
1269 else if (priv->use_bg_color)
1270 background_color = priv->background_color;
1271 if (background_color != NULL((void*)0))
1272 cairo_set_source_rgba (cr,
1273 background_color->red,
1274 background_color->green,
1275 background_color->blue,
1276 background_color->alpha);
1277 else
1278 cairo_set_source (cr, gdk_window_get_background_pattern (gtk_widget_get_window (priv->display)));
1279 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1280 cairo_fill (cr);
1281
1282 if (gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
1283 if (priv->background_surface == NULL((void*)0)) {
1284 priv->background_surface = create_background_surface (view);
1285 }
1286 cairo_set_source_surface (cr, priv->background_surface, xofs, yofs);
1287 cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
1288 cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height);
1289 cairo_fill (cr);
1290 }
1291
1292 /* Make sure the image is only drawn as large as needed.
1293 * This is especially necessary for SVGs where there might
1294 * be more image data available outside the image boundaries.
1295 */
1296 cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height);
1297 cairo_clip (cr);
1298
1299#ifdef HAVE_RSVG1
1300 if (eom_image_is_svg (view->priv->image)) {
1301 cairo_matrix_t matrix, translate, scale, original;
1302 EomTransform *transform = eom_image_get_transform (priv->image);
1303 cairo_matrix_init_identity (&matrix);
1304 if (transform) {
1305 cairo_matrix_t affine;
1306 double image_offset_x = 0., image_offset_y = 0.;
1307
1308 eom_transform_get_affine (transform, &affine);
1309 cairo_matrix_multiply (&matrix, &affine, &matrix);
1310
1311 switch (eom_transform_get_transform_type (transform)) {
1312 case EOM_TRANSFORM_ROT_90:
1313 case EOM_TRANSFORM_FLIP_HORIZONTAL:
1314 image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf);
1315 break;
1316 case EOM_TRANSFORM_ROT_270:
1317 case EOM_TRANSFORM_FLIP_VERTICAL:
1318 image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf);
1319 break;
1320 case EOM_TRANSFORM_ROT_180:
1321 case EOM_TRANSFORM_TRANSPOSE:
1322 case EOM_TRANSFORM_TRANSVERSE:
1323 image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf);
1324 image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf);
1325 break;
1326 case EOM_TRANSFORM_NONE:
1327 default:
1328 break;
1329 }
1330 cairo_matrix_init_translate (&translate, image_offset_x, image_offset_y);
1331 cairo_matrix_multiply (&matrix, &matrix, &translate);
1332 }
1333 /* Zoom factor for SVGs is already scaled, so scale back to application pixels. */
1334 cairo_matrix_init_scale (&scale, priv->zoom / priv->scale, priv->zoom / priv->scale);
1335 cairo_matrix_multiply (&matrix, &matrix, &scale);
1336 cairo_matrix_init_translate (&translate, xofs, yofs);
1337 cairo_matrix_multiply (&matrix, &matrix, &translate);
1338
1339 cairo_get_matrix (cr, &original);
1340 cairo_matrix_multiply (&matrix, &matrix, &original);
1341 cairo_set_matrix (cr, &matrix);
1342
1343 rsvg_handle_render_cairo (eom_image_get_svg (priv->image), cr);
1344
1345 } else
1346#endif /* HAVE_RSVG */
1347 {
1348 cairo_filter_t interp_type;
1349
1350 if(!DOUBLE_EQUAL(priv->zoom, 1.0)(fabs (priv->zoom - 1.0) < 1e-6) && priv->force_unfiltered)
1351 {
1352 interp_type = CAIRO_FILTER_NEAREST;
1353 _set_hq_redraw_timeout(view);
1354 }
1355 else
1356 {
1357 if (is_zoomed_in (view))
1358 interp_type = priv->interp_type_in;
1359 else
1360 interp_type = priv->interp_type_out;
1361
1362 _clear_hq_redraw_timeout (view);
1363 priv->force_unfiltered = TRUE(!(0));
1364 }
1365 cairo_scale (cr, priv->zoom, priv->zoom);
1366 cairo_set_source_surface (cr, priv->surface, xofs/priv->zoom, yofs/priv->zoom);
1367 cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
1368 if (is_zoomed_in (view) || is_zoomed_out (view))
1369 cairo_pattern_set_filter (cairo_get_source (cr), interp_type);
1370
1371 cairo_paint (cr);
1372 }
1373
1374 return TRUE(!(0));
1375}
1376
1377
1378/*==================================
1379
1380 image loading callbacks
1381
1382 -----------------------------------*/
1383
1384/* Use when the pixbuf in the view is changed, to keep a
1385 reference to it and create its cairo surface. */
1386static void
1387update_pixbuf (EomScrollView *view, GdkPixbuf *pixbuf)
1388{
1389 EomScrollViewPrivate *priv;
1390
1391 priv = view->priv;
1392
1393 if (priv->pixbuf != NULL((void*)0)) {
1394 g_object_unref (priv->pixbuf);
1395 priv->pixbuf = NULL((void*)0);
1396 }
1397
1398 priv->pixbuf = pixbuf;
1399
1400 if (priv->surface) {
1401 cairo_surface_destroy (priv->surface);
1402 }
1403 priv->surface = create_surface_from_pixbuf (view, priv->pixbuf);
1404}
1405
1406static void
1407image_changed_cb (EomImage *img, gpointer data)
1408{
1409 EomScrollViewPrivate *priv;
1410
1411 priv = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
->priv;
1412
1413 update_pixbuf (EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
, eom_image_get_pixbuf (img));
1414
1415 set_zoom_fit (EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
);
1416 check_scrollbar_visibility (EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
1417
1418 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1419}
1420
1421/*===================================
1422 public API
1423 ---------------------------------*/
1424
1425void
1426eom_scroll_view_hide_cursor (EomScrollView *view)
1427{
1428 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_HIDDEN);
1429}
1430
1431void
1432eom_scroll_view_show_cursor (EomScrollView *view)
1433{
1434 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_NORMAL);
1435}
1436
1437/* general properties */
1438void
1439eom_scroll_view_set_zoom_upscale (EomScrollView *view, gboolean upscale)
1440{
1441 EomScrollViewPrivate *priv;
1442
1443 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1444
1445 priv = view->priv;
1446
1447 if (priv->upscale != upscale) {
1448 priv->upscale = upscale;
1449
1450 if (priv->zoom_mode == ZOOM_MODE_FIT) {
1451 set_zoom_fit (view);
1452 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1453 }
1454 }
1455}
1456
1457void
1458eom_scroll_view_set_antialiasing_in (EomScrollView *view, gboolean state)
1459{
1460 EomScrollViewPrivate *priv;
1461 cairo_filter_t new_interp_type;
1462
1463 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1464
1465 priv = view->priv;
1466
1467 new_interp_type = state ? CAIRO_FILTER_GOOD : CAIRO_FILTER_NEAREST;
1468
1469 if (priv->interp_type_in != new_interp_type) {
1470 priv->interp_type_in = new_interp_type;
1471 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1472 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "antialiasing-in");
1473 }
1474}
1475
1476void
1477eom_scroll_view_set_antialiasing_out (EomScrollView *view, gboolean state)
1478{
1479 EomScrollViewPrivate *priv;
1480 cairo_filter_t new_interp_type;
1481
1482 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1483
1484 priv = view->priv;
1485
1486 new_interp_type = state ? CAIRO_FILTER_GOOD : CAIRO_FILTER_NEAREST;
1487
1488 if (priv->interp_type_out != new_interp_type) {
1489 priv->interp_type_out = new_interp_type;
1490 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1491 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "antialiasing-out");
1492
1493 }
1494}
1495
1496static void
1497_transp_background_changed (EomScrollView *view)
1498{
1499 EomScrollViewPrivate *priv = view->priv;
1500
1501 if (priv->pixbuf != NULL((void*)0) && gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
1502 if (priv->background_surface) {
1503 cairo_surface_destroy (priv->background_surface);
1504 /* Will be recreated if needed during redraw */
1505 priv->background_surface = NULL((void*)0);
1506 }
1507 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1508 }
1509
1510}
1511
1512void
1513eom_scroll_view_set_transparency_color (EomScrollView *view, GdkRGBA *color)
1514{
1515 EomScrollViewPrivate *priv;
1516
1517 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1518
1519 priv = view->priv;
1520
1521 if (!_eom_gdk_rgba_equal0 (&priv->transp_color, color)) {
1522 priv->transp_color = *color;
1523 if (priv->transp_style == EOM_TRANSP_COLOR)
1524 _transp_background_changed (view);
1525
1526 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "transparency-color");
1527 }
1528}
1529
1530void
1531eom_scroll_view_set_transparency (EomScrollView *view,
1532 EomTransparencyStyle style)
1533{
1534 EomScrollViewPrivate *priv;
1535
1536 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1537
1538 priv = view->priv;
1539
1540 if (priv->transp_style != style) {
1541 priv->transp_style = style;
1542 _transp_background_changed (view);
1543 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "transparency-style");
1544 }
1545}
1546
1547/* zoom api */
1548
1549static double preferred_zoom_levels[] = {
1550 1.0 / 100, 1.0 / 50, 1.0 / 20,
1551 1.0 / 10.0, 1.0 / 5.0, 1.0 / 3.0, 1.0 / 2.0, 1.0 / 1.5,
1552 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
1553 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0
1554};
1555static const gint n_zoom_levels = (sizeof (preferred_zoom_levels) / sizeof (double));
1556
1557void
1558eom_scroll_view_zoom_in (EomScrollView *view, gboolean smooth)
1559{
1560 EomScrollViewPrivate *priv;
1561 double zoom;
1562
1563 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1564
1565 priv = view->priv;
1566
1567 if (smooth) {
1568 zoom = priv->zoom * priv->zoom_multiplier;
1569 }
1570 else {
1571 int i;
1572 int index = -1;
1573
1574 for (i = 0; i < n_zoom_levels; i++) {
1575 if (preferred_zoom_levels [i] - priv->zoom
1576 > DOUBLE_EQUAL_MAX_DIFF1e-6) {
1577 index = i;
1578 break;
1579 }
1580 }
1581
1582 if (index == -1) {
1583 zoom = priv->zoom;
1584 }
1585 else {
1586 zoom = preferred_zoom_levels [i];
1587 }
1588 }
1589 set_zoom (view, zoom, FALSE(0), 0, 0);
1590
1591}
1592
1593void
1594eom_scroll_view_zoom_out (EomScrollView *view, gboolean smooth)
1595{
1596 EomScrollViewPrivate *priv;
1597 double zoom;
1598
1599 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1600
1601 priv = view->priv;
1602
1603 if (smooth) {
1604 zoom = priv->zoom / priv->zoom_multiplier;
1605 }
1606 else {
1607 int i;
1608 int index = -1;
1609
1610 for (i = n_zoom_levels - 1; i >= 0; i--) {
1611 if (priv->zoom - preferred_zoom_levels [i]
1612 > DOUBLE_EQUAL_MAX_DIFF1e-6) {
1613 index = i;
1614 break;
1615 }
1616 }
1617 if (index == -1) {
1618 zoom = priv->zoom;
1619 }
1620 else {
1621 zoom = preferred_zoom_levels [i];
1622 }
1623 }
1624 set_zoom (view, zoom, FALSE(0), 0, 0);
1625}
1626
1627void
1628eom_scroll_view_zoom_fit (EomScrollView *view)
1629{
1630 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1631
1632 set_zoom_fit (view);
1633 check_scrollbar_visibility (view, NULL((void*)0));
1634 gtk_widget_queue_draw (GTK_WIDGET (view->priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view->priv->display)), ((gtk_widget_get_type ()))))))
);
1635}
1636
1637void
1638eom_scroll_view_set_zoom (EomScrollView *view, double zoom)
1639{
1640 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1641
1642 set_zoom (view, zoom, FALSE(0), 0, 0);
1643}
1644
1645double
1646eom_scroll_view_get_zoom (EomScrollView *view)
1647{
1648 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), 0.0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return (0.0); } } while (0)
;
1649
1650 return view->priv->zoom;
1651}
1652
1653gboolean
1654eom_scroll_view_get_zoom_is_min (EomScrollView *view)
1655{
1656 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return ((0)); } } while (0)
;
1657
1658 set_minimum_zoom_factor (view);
1659
1660 return DOUBLE_EQUAL (view->priv->zoom, MIN_ZOOM_FACTOR)(fabs (view->priv->zoom - 0.02) < 1e-6) ||
1661 DOUBLE_EQUAL (view->priv->zoom, view->priv->min_zoom)(fabs (view->priv->zoom - view->priv->min_zoom) <
1e-6)
;
1662}
1663
1664gboolean
1665eom_scroll_view_get_zoom_is_max (EomScrollView *view)
1666{
1667 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return ((0)); } } while (0)
;
1668
1669 return DOUBLE_EQUAL (view->priv->zoom, MAX_ZOOM_FACTOR)(fabs (view->priv->zoom - 20) < 1e-6);
1670}
1671
1672static void
1673display_next_frame_cb (EomImage *image, gint delay, gpointer data)
1674{
1675 EomScrollViewPrivate *priv;
1676 EomScrollView *view;
1677
1678 if (!EOM_IS_SCROLL_VIEW (data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data)); GType __t = ((eom_scroll_view_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; }))))
)
1679 return;
1680
1681 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1682 priv = view->priv;
1683
1684 update_pixbuf (view, eom_image_get_pixbuf (image));
1685 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1686}
1687
1688void
1689eom_scroll_view_set_image (EomScrollView *view, EomImage *image)
1690{
1691 EomScrollViewPrivate *priv;
1692
1693 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1694
1695 priv = view->priv;
1696
1697 if (priv->image == image) {
1698 return;
1699 }
1700
1701 if (priv->image != NULL((void*)0)) {
1702 free_image_resources (view);
1703 }
1704 g_assert (priv->image == NULL)do { if (priv->image == ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-scroll-view.c", 1704, ((const char*) (__func__)
), "priv->image == NULL"); } while (0)
;
1705 g_assert (priv->pixbuf == NULL)do { if (priv->pixbuf == ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-scroll-view.c", 1705, ((const char*) (__func__)
), "priv->pixbuf == NULL"); } while (0)
;
1706
1707 if (image != NULL((void*)0)) {
1708 eom_image_data_ref (image);
1709
1710 if (priv->pixbuf == NULL((void*)0)) {
1711 update_pixbuf (view, eom_image_get_pixbuf (image));
1712 set_zoom_fit (view);
1713 check_scrollbar_visibility (view, NULL((void*)0));
1714 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1715
1716 }
1717
1718 priv->image_changed_id = g_signal_connect (image, "changed",g_signal_connect_data ((image), ("changed"), ((GCallback) image_changed_cb
), (view), ((void*)0), (GConnectFlags) 0)
1719 (GCallback) image_changed_cb, view)g_signal_connect_data ((image), ("changed"), ((GCallback) image_changed_cb
), (view), ((void*)0), (GConnectFlags) 0)
;
1720 if (eom_image_is_animation (image) == TRUE(!(0)) ) {
1721 eom_image_start_animation (image);
1722 priv->frame_changed_id = g_signal_connect (image, "next-frame",g_signal_connect_data ((image), ("next-frame"), ((GCallback) display_next_frame_cb
), (view), ((void*)0), (GConnectFlags) 0)
1723 (GCallback) display_next_frame_cb, view)g_signal_connect_data ((image), ("next-frame"), ((GCallback) display_next_frame_cb
), (view), ((void*)0), (GConnectFlags) 0)
;
1724 }
1725 }
1726
1727 priv->image = image;
1728
1729 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "image");
1730}
1731
1732/**
1733 * eom_scroll_view_get_image:
1734 * @view: An #EomScrollView.
1735 *
1736 * Gets the the currently displayed #EomImage.
1737 *
1738 * Returns: (transfer full): An #EomImage.
1739 **/
1740EomImage*
1741eom_scroll_view_get_image (EomScrollView *view)
1742{
1743 EomImage *img;
1744
1745 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return (((void*)0)); } } while
(0)
;
1746
1747 img = view->priv->image;
1748
1749 if (img != NULL((void*)0))
1750 g_object_ref (img);
1751
1752 return img;
1753}
1754
1755gboolean
1756eom_scroll_view_scrollbars_visible (EomScrollView *view)
1757{
1758 if (!gtk_widget_get_visible (GTK_WIDGET (view->priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view->priv->hbar)), ((gtk_widget_get_type ()))))))
) &&
1759 !gtk_widget_get_visible (GTK_WIDGET (view->priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view->priv->vbar)), ((gtk_widget_get_type ()))))))
))
1760 return FALSE(0);
1761
1762 return TRUE(!(0));
1763}
1764
1765/*===================================
1766 object creation/freeing
1767 ---------------------------------*/
1768
1769static gboolean
1770sv_string_to_rgba_mapping (GValue *value,
1771 GVariant *variant,
1772 gpointer user_data)
1773{
1774 GdkRGBA color;
1775
1776 g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING), FALSE)do { if ((g_variant_is_of_type (variant, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)"
); return ((0)); } } while (0)
;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1777
1778 if (gdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) {
1779 g_value_set_boxed (value, &color);
1780 return TRUE(!(0));
1781 }
1782
1783 return FALSE(0);
1784}
1785
1786static GVariant*
1787sv_rgba_to_string_mapping (const GValue *value,
1788 const GVariantType *expected_type,
1789 gpointer user_data)
1790{
1791 GVariant *variant = NULL((void*)0);
1792 GdkRGBA *color;
1793 gchar *hex_val;
1794
1795 g_return_val_if_fail (G_VALUE_TYPE (value) == GDK_TYPE_RGBA, NULL)do { if (((((GValue*) (value))->g_type) == (gdk_rgba_get_type
()))) { } else { g_return_if_fail_warning ("EOM", ((const char
*) (__func__)), "G_VALUE_TYPE (value) == GDK_TYPE_RGBA"); return
(((void*)0)); } } while (0)
;
1796 g_return_val_if_fail (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING), NULL)do { if ((g_variant_type_equal (expected_type, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING)"
); return (((void*)0)); } } while (0)
;
1797
1798 color = g_value_get_boxed (value);
1799 hex_val = gdk_rgba_to_string(color);
1800 variant = g_variant_new_string (hex_val);
1801 g_free (hex_val);
1802
1803 return variant;
1804}
1805
1806static void
1807eom_scroll_view_init (EomScrollView *view)
1808{
1809 GSettings *settings;
1810 EomScrollViewPrivate *priv;
1811
1812 priv = view->priv = eom_scroll_view_get_instance_private (view);
1813 settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
1814
1815 priv->zoom = 1.0;
1816 priv->min_zoom = MIN_ZOOM_FACTOR0.02;
1817 priv->zoom_mode = ZOOM_MODE_FIT;
1818 priv->upscale = FALSE(0);
1819 priv->interp_type_in = CAIRO_FILTER_GOOD;
1820 priv->interp_type_out = CAIRO_FILTER_GOOD;
1821 priv->scroll_wheel_zoom = FALSE(0);
1822 priv->zoom_multiplier = IMAGE_VIEW_ZOOM_MULTIPLIER1.05;
1823 priv->image = NULL((void*)0);
1824 priv->pixbuf = NULL((void*)0);
1825 priv->surface = NULL((void*)0);
1826 priv->transp_style = EOM_TRANSP_BACKGROUND;
1827 g_warn_if_fail (gdk_rgba_parse(&priv->transp_color, CHECK_BLACK))do { if (gdk_rgba_parse(&priv->transp_color, "#000000"
)) ; else g_warn_message ("EOM", "eom-scroll-view.c", 1827, (
(const char*) (__func__)), "gdk_rgba_parse(&priv->transp_color, CHECK_BLACK)"
); } while (0)
;
1828 priv->cursor = EOM_SCROLL_VIEW_CURSOR_NORMAL;
1829 priv->menu = NULL((void*)0);
1830 priv->background_color = NULL((void*)0);
1831
1832 priv->hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 100, 0, 10, 10, 100))((((GtkAdjustment*) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_adjustment_new (0, 100, 0, 10, 10, 100))), ((gtk_adjustment_get_type
()))))))
;
1833 g_signal_connect (priv->hadj, "value_changed",g_signal_connect_data ((priv->hadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1834 G_CALLBACK (adjustment_changed_cb),g_signal_connect_data ((priv->hadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1835 view)g_signal_connect_data ((priv->hadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
;
1836
1837 priv->hbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, priv->hadj);
1838 priv->vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 100, 0, 10, 10, 100))((((GtkAdjustment*) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_adjustment_new (0, 100, 0, 10, 10, 100))), ((gtk_adjustment_get_type
()))))))
;
1839 g_signal_connect (priv->vadj, "value_changed",g_signal_connect_data ((priv->vadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1840 G_CALLBACK (adjustment_changed_cb),g_signal_connect_data ((priv->vadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1841 view)g_signal_connect_data ((priv->vadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
;
1842
1843 priv->vbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, priv->vadj);
1844 priv->display = g_object_new (GTK_TYPE_DRAWING_AREA(gtk_drawing_area_get_type ()),
1845 "can-focus", TRUE(!(0)),
1846 NULL((void*)0));
1847 priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1848
1849 gtk_widget_add_events (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
,
1850 GDK_EXPOSURE_MASK
1851 | GDK_BUTTON_PRESS_MASK
1852 | GDK_BUTTON_RELEASE_MASK
1853 | GDK_POINTER_MOTION_MASK
1854 | GDK_POINTER_MOTION_HINT_MASK
1855 | GDK_SCROLL_MASK
1856 | GDK_KEY_PRESS_MASK);
1857 g_signal_connect (G_OBJECT (priv->display), "configure_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("configure_event"), (((GCallback) (display_size_change
))), (view), ((void*)0), (GConnectFlags) 0)
1858 G_CALLBACK (display_size_change), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("configure_event"), (((GCallback) (display_size_change
))), (view), ((void*)0), (GConnectFlags) 0)
;
1859 g_signal_connect (G_OBJECT (priv->display), "draw", G_CALLBACK (display_draw), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("draw"), (((GCallback) (display_draw))), (view
), ((void*)0), (GConnectFlags) 0)
;
1860 g_signal_connect (G_OBJECT (priv->display), "map_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("map_event"), (((GCallback) (display_map_event
))), (view), ((void*)0), (GConnectFlags) 0)
1861 G_CALLBACK (display_map_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("map_event"), (((GCallback) (display_map_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1862 g_signal_connect (G_OBJECT (priv->display), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (eom_scroll_view_button_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
1863 G_CALLBACK (eom_scroll_view_button_press_event),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (eom_scroll_view_button_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
1864 view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (eom_scroll_view_button_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1865 g_signal_connect (G_OBJECT (priv->display), "motion_notify_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("motion_notify_event"), (((GCallback) (eom_scroll_view_motion_event
))), (view), ((void*)0), (GConnectFlags) 0)
1866 G_CALLBACK (eom_scroll_view_motion_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("motion_notify_event"), (((GCallback) (eom_scroll_view_motion_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1867 g_signal_connect (G_OBJECT (priv->display), "button_release_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_release_event"), (((GCallback) (eom_scroll_view_button_release_event
))), (view), ((void*)0), (GConnectFlags) 0)
1868 G_CALLBACK (eom_scroll_view_button_release_event),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_release_event"), (((GCallback) (eom_scroll_view_button_release_event
))), (view), ((void*)0), (GConnectFlags) 0)
1869 view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_release_event"), (((GCallback) (eom_scroll_view_button_release_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1870 g_signal_connect (G_OBJECT (priv->display), "scroll_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("scroll_event"), (((GCallback) (eom_scroll_view_scroll_event
))), (view), ((void*)0), (GConnectFlags) 0)
1871 G_CALLBACK (eom_scroll_view_scroll_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("scroll_event"), (((GCallback) (eom_scroll_view_scroll_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1872 g_signal_connect (G_OBJECT (priv->display), "focus_in_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_in_event"), (((GCallback) (eom_scroll_view_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1873 G_CALLBACK (eom_scroll_view_focus_in_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_in_event"), (((GCallback) (eom_scroll_view_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1874 g_signal_connect (G_OBJECT (priv->display), "focus_out_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_out_event"), (((GCallback) (eom_scroll_view_focus_out_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1875 G_CALLBACK (eom_scroll_view_focus_out_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_out_event"), (((GCallback) (eom_scroll_view_focus_out_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1876
1877 g_signal_connect (G_OBJECT (view), "key_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("key_press_event"), (((GCallback) (display_key_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
1878 G_CALLBACK (display_key_press_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("key_press_event"), (((GCallback) (display_key_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1879
1880 gtk_drag_source_set (priv->display, GDK_BUTTON1_MASK,
1881 target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])),
1882 GDK_ACTION_COPY | GDK_ACTION_MOVE |
1883 GDK_ACTION_LINK | GDK_ACTION_ASK);
1884 g_signal_connect (G_OBJECT (priv->display), "drag-data-get",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-data-get"), (((GCallback) (view_on_drag_data_get_cb
))), (view), ((void*)0), (GConnectFlags) 0)
1885 G_CALLBACK (view_on_drag_data_get_cb), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-data-get"), (((GCallback) (view_on_drag_data_get_cb
))), (view), ((void*)0), (GConnectFlags) 0)
;
1886 g_signal_connect (G_OBJECT (priv->display), "drag-begin",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-begin"), (((GCallback) (view_on_drag_begin_cb
))), (view), ((void*)0), (GConnectFlags) 0)
1887 G_CALLBACK (view_on_drag_begin_cb), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-begin"), (((GCallback) (view_on_drag_begin_cb
))), (view), ((void*)0), (GConnectFlags) 0)
;
1888
1889 gtk_grid_attach (GTK_GRID (view)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), ((gtk_grid_get_type ()))))))
, priv->display,
1890 0, 0, 1, 1);
1891 gtk_widget_set_hexpand (priv->display, TRUE(!(0)));
1892 gtk_widget_set_vexpand (priv->display, TRUE(!(0)));
1893 gtk_grid_attach (GTK_GRID (view)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), ((gtk_grid_get_type ()))))))
, priv->hbar,
1894 0, 1, 1, 1);
1895 gtk_widget_set_hexpand (priv->hbar, TRUE(!(0)));
1896 gtk_grid_attach (GTK_GRID (view)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), ((gtk_grid_get_type ()))))))
, priv->vbar,
1897 1, 0, 1, 1);
1898 gtk_widget_set_vexpand (priv->vbar, TRUE(!(0)));
1899
1900 g_settings_bind (settings, EOM_CONF_VIEW_USE_BG_COLOR"use-background-color", view,
1901 "use-background-color", G_SETTINGS_BIND_DEFAULT);
1902 g_settings_bind_with_mapping (settings, EOM_CONF_VIEW_BACKGROUND_COLOR"background-color",
1903 view, "background-color",
1904 G_SETTINGS_BIND_DEFAULT,
1905 sv_string_to_rgba_mapping,
1906 sv_rgba_to_string_mapping, NULL((void*)0), NULL((void*)0));
1907 g_settings_bind (settings, EOM_CONF_VIEW_EXTRAPOLATE"extrapolate", view,
1908 "antialiasing-in", G_SETTINGS_BIND_GET);
1909 g_settings_bind (settings, EOM_CONF_VIEW_INTERPOLATE"interpolate", view,
1910 "antialiasing-out", G_SETTINGS_BIND_GET);
1911 g_settings_bind_with_mapping (settings, EOM_CONF_VIEW_TRANS_COLOR"trans-color",
1912 view, "transparency-color",
1913 G_SETTINGS_BIND_GET,
1914 sv_string_to_rgba_mapping,
1915 sv_rgba_to_string_mapping, NULL((void*)0), NULL((void*)0));
1916 g_settings_bind (settings, EOM_CONF_VIEW_TRANSPARENCY"transparency", view,
1917 "transparency-style", G_SETTINGS_BIND_GET);
1918
1919 g_object_unref (settings);
1920
1921 priv->override_bg_color = NULL((void*)0);
1922 priv->background_surface = NULL((void*)0);
1923}
1924
1925static void
1926eom_scroll_view_dispose (GObject *object)
1927{
1928 EomScrollView *view;
1929 EomScrollViewPrivate *priv;
1930
1931 g_return_if_fail (EOM_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (object)"); return; } } while (0)
;
1932
1933 view = EOM_SCROLL_VIEW (object)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_scroll_view_get_type ()))))))
;
1934 priv = view->priv;
1935
1936 _clear_hq_redraw_timeout (view);
1937
1938 if (priv->idle_id != 0) {
1939 g_source_remove (priv->idle_id);
1940 priv->idle_id = 0;
1941 }
1942
1943 if (priv->background_color != NULL((void*)0)) {
1944 gdk_rgba_free (priv->background_color);
1945 priv->background_color = NULL((void*)0);
1946 }
1947
1948 if (priv->override_bg_color != NULL((void*)0)) {
1949 gdk_rgba_free (priv->override_bg_color);
1950 priv->override_bg_color = NULL((void*)0);
1951 }
1952
1953 if (priv->background_surface != NULL((void*)0)) {
1954 cairo_surface_destroy (priv->background_surface);
1955 priv->background_surface = NULL((void*)0);
1956 }
1957
1958 free_image_resources (view);
1959
1960 G_OBJECT_CLASS (eom_scroll_view_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_scroll_view_parent_class
)), (((GType) ((20) << (2))))))))
->dispose (object);
1961}
1962
1963static void
1964eom_scroll_view_get_property (GObject *object, guint property_id,
1965 GValue *value, GParamSpec *pspec)
1966{
1967 EomScrollView *view;
1968 EomScrollViewPrivate *priv;
1969
1970 g_return_if_fail (EOM_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (object)"); return; } } while (0)
;
1971
1972 view = EOM_SCROLL_VIEW (object)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_scroll_view_get_type ()))))))
;
1973 priv = view->priv;
1974
1975 switch (property_id) {
1976 case PROP_ANTIALIAS_IN:
1977 {
1978 gboolean filter = (priv->interp_type_in != CAIRO_FILTER_NEAREST);
1979 g_value_set_boolean (value, filter);
1980 break;
1981 }
1982 case PROP_ANTIALIAS_OUT:
1983 {
1984 gboolean filter = (priv->interp_type_out != CAIRO_FILTER_NEAREST);
1985 g_value_set_boolean (value, filter);
1986 break;
1987 }
1988 case PROP_USE_BG_COLOR:
1989 g_value_set_boolean (value, priv->use_bg_color);
1990 break;
1991 case PROP_BACKGROUND_COLOR:
1992 //FIXME: This doesn't really handle the NULL color.
1993 g_value_set_boxed (value, priv->background_color);
1994 break;
1995 case PROP_SCROLLWHEEL_ZOOM:
1996 g_value_set_boolean (value, priv->scroll_wheel_zoom);
1997 break;
1998 case PROP_TRANSPARENCY_STYLE:
1999 g_value_set_enum (value, priv->transp_style);
2000 break;
2001 case PROP_ZOOM_MULTIPLIER:
2002 g_value_set_double (value, priv->zoom_multiplier);
2003 break;
2004 case PROP_IMAGE:
2005 g_value_set_object (value, priv->image);
2006 break;
2007 default:
2008 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-scroll-view.c", 2008, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2009 }
2010}
2011
2012static void
2013eom_scroll_view_set_property (GObject *object, guint property_id,
2014 const GValue *value, GParamSpec *pspec)
2015{
2016 EomScrollView *view;
2017
2018 g_return_if_fail (EOM_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (object)"); return; } } while (0)
;
2019
2020 view = EOM_SCROLL_VIEW (object)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_scroll_view_get_type ()))))))
;
2021
2022 switch (property_id) {
2023 case PROP_ANTIALIAS_IN:
2024 eom_scroll_view_set_antialiasing_in (view, g_value_get_boolean (value));
2025 break;
2026 case PROP_ANTIALIAS_OUT:
2027 eom_scroll_view_set_antialiasing_out (view, g_value_get_boolean (value));
2028 break;
2029 case PROP_USE_BG_COLOR:
2030 eom_scroll_view_set_use_bg_color (view, g_value_get_boolean (value));
2031 break;
2032 case PROP_BACKGROUND_COLOR:
2033 {
2034 const GdkRGBA *color = g_value_get_boxed (value);
2035 eom_scroll_view_set_background_color (view, color);
2036 break;
2037 }
2038 case PROP_SCROLLWHEEL_ZOOM:
2039 eom_scroll_view_set_scroll_wheel_zoom (view, g_value_get_boolean (value));
2040 break;
2041 case PROP_TRANSP_COLOR:
2042 eom_scroll_view_set_transparency_color (view, g_value_get_boxed (value));
2043 break;
2044 case PROP_TRANSPARENCY_STYLE:
2045 eom_scroll_view_set_transparency (view, g_value_get_enum (value));
2046 break;
2047 case PROP_ZOOM_MULTIPLIER:
2048 eom_scroll_view_set_zoom_multiplier (view, g_value_get_double (value));
2049 break;
2050 case PROP_IMAGE:
2051 eom_scroll_view_set_image (view, g_value_get_object (value));
2052 break;
2053 default:
2054 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-scroll-view.c", 2054, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2055 }
2056}
2057
2058
2059static void
2060eom_scroll_view_class_init (EomScrollViewClass *klass)
2061{
2062 GObjectClass *gobject_class;
2063 GtkWidgetClass *widget_class;
2064
2065 gobject_class = (GObjectClass*) klass;
2066 widget_class = (GtkWidgetClass*) klass;
2067
2068 gobject_class->dispose = eom_scroll_view_dispose;
2069 gobject_class->set_property = eom_scroll_view_set_property;
2070 gobject_class->get_property = eom_scroll_view_get_property;
2071
2072 g_object_class_install_property (
2073 gobject_class, PROP_ANTIALIAS_IN,
2074 g_param_spec_boolean ("antialiasing-in", NULL((void*)0), NULL((void*)0), TRUE(!(0)),
2075 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2076
2077 g_object_class_install_property (
2078 gobject_class, PROP_ANTIALIAS_OUT,
2079 g_param_spec_boolean ("antialiasing-out", NULL((void*)0), NULL((void*)0), TRUE(!(0)),
2080 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2081
2082 /**
2083 * EomScrollView:background-color:
2084 *
2085 * This is the default background color used for painting the background
2086 * of the image view. If set to %NULL the color is determined by the
2087 * active GTK theme.
2088 */
2089 g_object_class_install_property (
2090 gobject_class, PROP_BACKGROUND_COLOR,
2091 g_param_spec_boxed ("background-color", NULL((void*)0), NULL((void*)0),
2092 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2093 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2094
2095 g_object_class_install_property (
2096 gobject_class, PROP_USE_BG_COLOR,
2097 g_param_spec_boolean ("use-background-color", NULL((void*)0), NULL((void*)0), FALSE(0),
2098 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2099
2100 /**
2101 * EomScrollView:zoom-multiplier:
2102 *
2103 * The current zoom factor is multiplied with this value + 1.0 when
2104 * scrolling with the scrollwheel to determine the next zoom factor.
2105 */
2106 g_object_class_install_property (
2107 gobject_class, PROP_ZOOM_MULTIPLIER,
2108 g_param_spec_double ("zoom-multiplier", NULL((void*)0), NULL((void*)0),
2109 -G_MAXDOUBLE1.7976931348623157e+308, G_MAXDOUBLE1.7976931348623157e+308 -1.0, 0.05,
2110 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2111
2112 /**
2113 * EomScrollView:scrollwheel-zoom:
2114 *
2115 * If %TRUE the scrollwheel will zoom the view, otherwise it will be
2116 * used for scrolling a zoomed image.
2117 */
2118 g_object_class_install_property (
2119 gobject_class, PROP_SCROLLWHEEL_ZOOM,
2120 g_param_spec_boolean ("scrollwheel-zoom", NULL((void*)0), NULL((void*)0), TRUE(!(0)),
2121 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2122
2123 /**
2124 * EomScrollView:image:
2125 *
2126 * This is the currently display #EomImage.
2127 */
2128 g_object_class_install_property (
2129 gobject_class, PROP_IMAGE,
2130 g_param_spec_object ("image", NULL((void*)0), NULL((void*)0), EOM_TYPE_IMAGE(eom_image_get_type ()),
2131 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2132
2133 /**
2134 * EomScrollView:transparency-color:
2135 *
2136 * This is the color used to fill the transparent parts of an image
2137 * if :transparency-style is set to use a custom color.
2138 */
2139 g_object_class_install_property (
2140 gobject_class, PROP_TRANSP_COLOR,
2141 g_param_spec_boxed ("transparency-color", NULL((void*)0), NULL((void*)0),
2142 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2143 G_PARAM_WRITABLE | G_PARAM_STATIC_NAME));
2144
2145 /**
2146 * EomScrollView:transparency-style:
2147 *
2148 * Determines how to fill the shown image's transparent areas.
2149 */
2150 g_object_class_install_property (
2151 gobject_class, PROP_TRANSPARENCY_STYLE,
2152 g_param_spec_enum ("transparency-style", NULL((void*)0), NULL((void*)0),
2153 EOM_TYPE_TRANSPARENCY_STYLE(eom_transparency_style_get_type()),
2154 EOM_TRANSP_CHECKED,
2155 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2156
2157 view_signals [SIGNAL_ZOOM_CHANGED] =
2158 g_signal_new ("zoom_changed",
2159 EOM_TYPE_SCROLL_VIEW(eom_scroll_view_get_type ()),
2160 G_SIGNAL_RUN_LAST,
2161 G_STRUCT_OFFSET (EomScrollViewClass, zoom_changed)((glong) __builtin_offsetof(EomScrollViewClass, zoom_changed)
)
,
2162 NULL((void*)0), NULL((void*)0),
2163 eom_marshal_VOID__DOUBLEg_cclosure_marshal_VOID__DOUBLE,
2164 G_TYPE_NONE((GType) ((1) << (2))), 1,
2165 G_TYPE_DOUBLE((GType) ((15) << (2))));
2166
2167 widget_class->size_allocate = eom_scroll_view_size_allocate;
2168}
2169
2170static void
2171view_on_drag_begin_cb (GtkWidget *widget,
2172 GdkDragContext *context,
2173 gpointer user_data)
2174{
2175 EomScrollView *view;
2176 EomImage *image;
2177 GdkPixbuf *thumbnail;
2178 gint width, height;
2179
2180 view = EOM_SCROLL_VIEW (user_data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_scroll_view_get_type ()))))))
;
2181 image = view->priv->image;
2182
2183 thumbnail = eom_image_get_thumbnail (image);
2184
2185 if (thumbnail) {
2186 width = gdk_pixbuf_get_width (thumbnail) / view->priv->scale;
2187 height = gdk_pixbuf_get_height (thumbnail) / view->priv->scale;
2188 gtk_drag_set_icon_pixbuf (context, thumbnail, width/2, height/2);
2189 g_object_unref (thumbnail);
2190 }
2191}
2192
2193static void
2194view_on_drag_data_get_cb (GtkWidget *widget,
2195 GdkDragContext *drag_context,
2196 GtkSelectionData *data,
2197 guint info,
2198 guint time,
2199 gpointer user_data)
2200{
2201 EomScrollView *view;
2202 EomImage *image;
2203 gchar *uris[2];
2204 GFile *file;
2205
2206 view = EOM_SCROLL_VIEW (user_data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_scroll_view_get_type ()))))))
;
2207
2208 image = view->priv->image;
2209
2210 file = eom_image_get_file (image);
2211 uris[0] = g_file_get_uri (file);
2212 uris[1] = NULL((void*)0);
2213
2214 gtk_selection_data_set_uris (data, uris);
2215
2216 g_free (uris[0]);
2217 g_object_unref (file);
2218}
2219
2220GtkWidget*
2221eom_scroll_view_new (void)
2222{
2223 GtkWidget *widget;
2224
2225 widget = g_object_new (EOM_TYPE_SCROLL_VIEW(eom_scroll_view_get_type ()),
2226 "can-focus", TRUE(!(0)),
2227 "row-homogeneous", FALSE(0),
2228 "column-homogeneous", FALSE(0),
2229 NULL((void*)0));
2230
2231
2232 return widget;
2233}
2234
2235static gboolean
2236view_on_button_press_event_cb (GtkWidget *widget, GdkEventButton *event,
2237 gpointer user_data)
2238{
2239 EomScrollView *view = EOM_SCROLL_VIEW (widget)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_scroll_view_get_type ()))))))
;
2240
2241 /* Ignore double-clicks and triple-clicks */
2242 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
2243 {
2244 gtk_menu_popup_at_pointer (GTK_MENU (view->priv->menu)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
view->priv->menu)), ((gtk_menu_get_type ()))))))
,
2245 (const GdkEvent*) event);
2246
2247 return TRUE(!(0));
2248 }
2249
2250 return FALSE(0);
2251}
2252
2253void
2254eom_scroll_view_set_popup (EomScrollView *view,
2255 GtkMenu *menu)
2256{
2257 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2258 g_return_if_fail (view->priv->menu == NULL)do { if ((view->priv->menu == ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "view->priv->menu == NULL"
); return; } } while (0)
;
2259
2260 view->priv->menu = g_object_ref (GTK_WIDGET (menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menu)), ((gtk_widget_get_type ()))))))
);
2261
2262 gtk_menu_attach_to_widget (GTK_MENU (view->priv->menu)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
view->priv->menu)), ((gtk_menu_get_type ()))))))
,
2263 GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
,
2264 NULL((void*)0));
2265
2266 g_signal_connect (G_OBJECT (view), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("button_press_event"), (((GCallback) (view_on_button_press_event_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
2267 G_CALLBACK (view_on_button_press_event_cb), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("button_press_event"), (((GCallback) (view_on_button_press_event_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
2268}
2269
2270static gboolean
2271_eom_gdk_rgba_equal0 (const GdkRGBA *a, const GdkRGBA *b)
2272{
2273 if (a == NULL((void*)0) || b == NULL((void*)0))
2274 return (a == b);
2275
2276 return gdk_rgba_equal (a, b);
2277}
2278
2279static gboolean
2280_eom_replace_gdk_rgba (GdkRGBA **dest, const GdkRGBA *src)
2281{
2282 GdkRGBA *old = *dest;
2283
2284 if (_eom_gdk_rgba_equal0 (old, src))
2285 return FALSE(0);
2286
2287 if (old != NULL((void*)0))
2288 gdk_rgba_free (old);
2289
2290 *dest = (src) ? gdk_rgba_copy (src) : NULL((void*)0);
2291
2292 return TRUE(!(0));
2293}
2294
2295static void
2296_eom_scroll_view_update_bg_color (EomScrollView *view)
2297{
2298 EomScrollViewPrivate *priv = view->priv;
2299
2300 if (priv->transp_style == EOM_TRANSP_BACKGROUND
2301 && priv->background_surface != NULL((void*)0)) {
2302 /* Delete the SVG background to have it recreated with
2303 * the correct color during the next SVG redraw */
2304 cairo_surface_destroy (priv->background_surface);
2305 priv->background_surface = NULL((void*)0);
2306 }
2307
2308 gtk_widget_queue_draw (priv->display);
2309}
2310
2311void
2312eom_scroll_view_set_background_color (EomScrollView *view,
2313 const GdkRGBA *color)
2314{
2315 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2316
2317 if (_eom_replace_gdk_rgba (&view->priv->background_color, color))
2318 _eom_scroll_view_update_bg_color (view);
2319}
2320
2321void
2322eom_scroll_view_override_bg_color (EomScrollView *view,
2323 const GdkRGBA *color)
2324{
2325 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2326
2327 if (_eom_replace_gdk_rgba (&view->priv->override_bg_color, color))
2328 _eom_scroll_view_update_bg_color (view);
2329}
2330
2331void
2332eom_scroll_view_set_use_bg_color (EomScrollView *view, gboolean use)
2333{
2334 EomScrollViewPrivate *priv;
2335
2336 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2337
2338 priv = view->priv;
2339
2340 if (use != priv->use_bg_color) {
2341 priv->use_bg_color = use;
2342
2343 _eom_scroll_view_update_bg_color (view);
2344
2345 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "use-background-color");
2346 }
2347}
2348
2349void
2350eom_scroll_view_set_scroll_wheel_zoom (EomScrollView *view,
2351 gboolean scroll_wheel_zoom)
2352{
2353 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2354
2355 if (view->priv->scroll_wheel_zoom != scroll_wheel_zoom) {
2356 view->priv->scroll_wheel_zoom = scroll_wheel_zoom;
2357 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "scrollwheel-zoom");
2358 }
2359}
2360
2361void
2362eom_scroll_view_set_zoom_multiplier (EomScrollView *view,
2363 gdouble zoom_multiplier)
2364{
2365 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2366
2367 view->priv->zoom_multiplier = 1.0 + zoom_multiplier;
2368
2369 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "zoom-multiplier");
2370}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-8bd366.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-8bd366.html new file mode 100644 index 0000000..22db4dd --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-8bd366.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 393, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
This statement is never executed
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-920264.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-920264.html new file mode 100644 index 0000000..d853d54 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-920264.html @@ -0,0 +1,2717 @@ + + + +eom-scroll-view.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-scroll-view.c
Warning:line 1796, column 2
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 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-scroll-view.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-scroll-view.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#ifdef HAVE_CONFIG_H1
2#include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <math.h>
7#include <gdk-pixbuf/gdk-pixbuf.h>
8#include <gdk/gdkkeysyms.h>
9#ifdef HAVE_RSVG1
10#include <librsvg/rsvg.h>
11#endif
12
13#include "eom-config-keys.h"
14#include "eom-enum-types.h"
15#include "eom-marshal.h"
16#include "eom-scroll-view.h"
17#include "eom-debug.h"
18#include "zoom.h"
19
20#include <gdk/gdk.h>
21
22/* Maximum size of delayed repaint rectangles */
23#define PAINT_RECT_WIDTH128 128
24#define PAINT_RECT_HEIGHT128 128
25
26/* Scroll step increment */
27#define SCROLL_STEP_SIZE32 32
28
29/* Maximum zoom factor */
30#define MAX_ZOOM_FACTOR20 20
31#define MIN_ZOOM_FACTOR0.02 0.02
32
33#define CHECK_MEDIUM8 8
34#define CHECK_BLACK"#000000" "#000000"
35#define CHECK_DARK"#555555" "#555555"
36#define CHECK_GRAY"#808080" "#808080"
37#define CHECK_LIGHT"#cccccc" "#cccccc"
38#define CHECK_WHITE"#ffffff" "#ffffff"
39
40/* Default increment for zooming. The current zoom factor is multiplied or
41 * divided by this amount on every zooming step. For consistency, you should
42 * use the same value elsewhere in the program.
43 */
44#define IMAGE_VIEW_ZOOM_MULTIPLIER1.05 1.05
45
46/* States for automatically adjusting the zoom factor */
47typedef enum {
48 ZOOM_MODE_FIT, /* Image is fitted to scroll view even if the latter changes size */
49 ZOOM_MODE_FREE /* The image remains at its current zoom factor even if the scrollview changes size */
50} ZoomMode;
51
52/* Signal IDs */
53enum {
54 SIGNAL_ZOOM_CHANGED,
55 SIGNAL_LAST
56};
57
58static guint view_signals [SIGNAL_LAST] = { 0 };
59
60typedef enum {
61 EOM_SCROLL_VIEW_CURSOR_NORMAL,
62 EOM_SCROLL_VIEW_CURSOR_HIDDEN,
63 EOM_SCROLL_VIEW_CURSOR_DRAG
64} EomScrollViewCursor;
65
66/* Drag 'n Drop */
67static GtkTargetEntry target_table[] = {
68 { "text/uri-list", 0, 0},
69};
70
71enum {
72 PROP_0,
73 PROP_ANTIALIAS_IN,
74 PROP_ANTIALIAS_OUT,
75 PROP_BACKGROUND_COLOR,
76 PROP_IMAGE,
77 PROP_SCROLLWHEEL_ZOOM,
78 PROP_TRANSP_COLOR,
79 PROP_TRANSPARENCY_STYLE,
80 PROP_USE_BG_COLOR,
81 PROP_ZOOM_MULTIPLIER
82};
83
84/* Private part of the EomScrollView structure */
85struct _EomScrollViewPrivate {
86 /* some widgets we rely on */
87 GtkWidget *display;
88 GtkAdjustment *hadj;
89 GtkAdjustment *vadj;
90 GtkWidget *hbar;
91 GtkWidget *vbar;
92 GtkWidget *menu;
93
94 /* actual image */
95 EomImage *image;
96 guint image_changed_id;
97 guint frame_changed_id;
98 GdkPixbuf *pixbuf;
99 cairo_surface_t *surface;
100
101 /* scale factor */
102 gint scale;
103
104 /* zoom mode, either ZOOM_MODE_FIT or ZOOM_MODE_FREE */
105 ZoomMode zoom_mode;
106
107 /* whether to allow zoom > 1.0 on zoom fit */
108 gboolean upscale;
109
110 /* the actual zoom factor */
111 double zoom;
112
113 /* the minimum possible (reasonable) zoom factor */
114 double min_zoom;
115
116 /* Current scrolling offsets */
117 int xofs, yofs;
118
119 /* handler ID for paint idle callback */
120 guint idle_id;
121
122 /* Interpolation type when zoomed in*/
123 cairo_filter_t interp_type_in;
124
125 /* Interpolation type when zoomed out*/
126 cairo_filter_t interp_type_out;
127
128 /* Scroll wheel zoom */
129 gboolean scroll_wheel_zoom;
130
131 /* Scroll wheel zoom */
132 gdouble zoom_multiplier;
133
134 /* dragging stuff */
135 int drag_anchor_x, drag_anchor_y;
136 int drag_ofs_x, drag_ofs_y;
137 guint dragging : 1;
138
139 /* how to indicate transparency in images */
140 EomTransparencyStyle transp_style;
141 GdkRGBA transp_color;
142
143 /* the type of the cursor we are currently showing */
144 EomScrollViewCursor cursor;
145
146 gboolean use_bg_color;
147 GdkRGBA *background_color;
148 GdkRGBA *override_bg_color;
149
150 cairo_surface_t *background_surface;
151
152 /* Two-pass filtering */
153 GSource *hq_redraw_timeout_source;
154 gboolean force_unfiltered;
155};
156
157static void scroll_by (EomScrollView *view, int xofs, int yofs);
158static void set_zoom_fit (EomScrollView *view);
159/* static void request_paint_area (EomScrollView *view, GdkRectangle *area); */
160static void set_minimum_zoom_factor (EomScrollView *view);
161static void view_on_drag_begin_cb (GtkWidget *widget, GdkDragContext *context,
162 gpointer user_data);
163static void view_on_drag_data_get_cb (GtkWidget *widget,
164 GdkDragContext*drag_context,
165 GtkSelectionData *data, guint info,
166 guint time, gpointer user_data);
167
168static gboolean _eom_gdk_rgba_equal0 (const GdkRGBA *a, const GdkRGBA *b);
169
170G_DEFINE_TYPE_WITH_PRIVATE (EomScrollView, eom_scroll_view, GTK_TYPE_GRID)static void eom_scroll_view_init (EomScrollView *self); static
void eom_scroll_view_class_init (EomScrollViewClass *klass);
static GType eom_scroll_view_get_type_once (void); static gpointer
eom_scroll_view_parent_class = ((void*)0); static gint EomScrollView_private_offset
; static void eom_scroll_view_class_intern_init (gpointer klass
) { eom_scroll_view_parent_class = g_type_class_peek_parent (
klass); if (EomScrollView_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomScrollView_private_offset); eom_scroll_view_class_init
((EomScrollViewClass*) klass); } __attribute__((__unused__))
static inline gpointer eom_scroll_view_get_instance_private (
EomScrollView *self) { return (((gpointer) ((guint8*) (self) +
(glong) (EomScrollView_private_offset)))); } GType eom_scroll_view_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_scroll_view_get_type_once (); (
__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_scroll_view_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_grid_get_type ()), g_intern_static_string ("EomScrollView"
), sizeof (EomScrollViewClass), (GClassInitFunc)(void (*)(void
)) eom_scroll_view_class_intern_init, sizeof (EomScrollView),
(GInstanceInitFunc)(void (*)(void)) eom_scroll_view_init, (GTypeFlags
) 0); { {{ EomScrollView_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EomScrollViewPrivate)); };} } return
g_define_type_id; }
171
172/*===================================
173 widget size changing handler &
174 util functions
175 ---------------------------------*/
176
177static cairo_surface_t *
178create_surface_from_pixbuf (EomScrollView *view, GdkPixbuf *pixbuf)
179{
180 cairo_surface_t *surface;
181
182 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf,
183 view->priv->scale,
184 gtk_widget_get_window (view->priv->display));
185
186 return surface;
187}
188
189/* Disconnects from the EomImage and removes references to it */
190static void
191free_image_resources (EomScrollView *view)
192{
193 EomScrollViewPrivate *priv;
194
195 priv = view->priv;
196
197 if (priv->image_changed_id > 0) {
198 g_signal_handler_disconnect (G_OBJECT (priv->image)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->image)), (((GType) ((20) << (2))))))))
, priv->image_changed_id);
199 priv->image_changed_id = 0;
200 }
201
202 if (priv->frame_changed_id > 0) {
203 g_signal_handler_disconnect (G_OBJECT (priv->image)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->image)), (((GType) ((20) << (2))))))))
, priv->frame_changed_id);
204 priv->frame_changed_id = 0;
205 }
206
207 if (priv->image != NULL((void*)0)) {
208 eom_image_data_unref (priv->image);
209 priv->image = NULL((void*)0);
210 }
211
212 if (priv->pixbuf != NULL((void*)0)) {
213 g_object_unref (priv->pixbuf);
214 priv->pixbuf = NULL((void*)0);
215 }
216
217 if (priv->surface !=NULL((void*)0)) {
218 cairo_surface_destroy (priv->surface);
219 priv->surface = NULL((void*)0);
220 }
221}
222
223/* Computes the size in pixels of the scaled image */
224static void
225compute_scaled_size (EomScrollView *view, double zoom, int *width, int *height)
226{
227 EomScrollViewPrivate *priv;
228
229 priv = view->priv;
230
231 if (priv->pixbuf) {
232 *width = floor (gdk_pixbuf_get_width (priv->pixbuf) / priv->scale * zoom + 0.5);
233 *height = floor (gdk_pixbuf_get_height (priv->pixbuf) / priv->scale * zoom + 0.5);
234 } else
235 *width = *height = 0;
236}
237
238/* Computes the offsets for the new zoom value so that they keep the image
239 * centered on the view.
240 */
241static void
242compute_center_zoom_offsets (EomScrollView *view,
243 double old_zoom, double new_zoom,
244 int width, int height,
245 double zoom_x_anchor, double zoom_y_anchor,
246 int *xofs, int *yofs)
247{
248 EomScrollViewPrivate *priv;
249 int old_scaled_width, old_scaled_height;
250 int new_scaled_width, new_scaled_height;
251 double view_cx, view_cy;
252
253 priv = view->priv;
254
255 compute_scaled_size (view, old_zoom,
256 &old_scaled_width, &old_scaled_height);
257
258 if (old_scaled_width < width)
259 view_cx = (zoom_x_anchor * old_scaled_width) / old_zoom;
260 else
261 view_cx = (priv->xofs + zoom_x_anchor * width) / old_zoom;
262
263 if (old_scaled_height < height)
264 view_cy = (zoom_y_anchor * old_scaled_height) / old_zoom;
265 else
266 view_cy = (priv->yofs + zoom_y_anchor * height) / old_zoom;
267
268 compute_scaled_size (view, new_zoom,
269 &new_scaled_width, &new_scaled_height);
270
271 if (new_scaled_width < width)
272 *xofs = 0;
273 else {
274 *xofs = floor (view_cx * new_zoom - zoom_x_anchor * width + 0.5);
275 if (*xofs < 0)
276 *xofs = 0;
277 }
278
279 if (new_scaled_height < height)
280 *yofs = 0;
281 else {
282 *yofs = floor (view_cy * new_zoom - zoom_y_anchor * height + 0.5);
283 if (*yofs < 0)
284 *yofs = 0;
285 }
286}
287
288/* Sets the scrollbar values based on the current scrolling offset */
289static void
290update_scrollbar_values (EomScrollView *view)
291{
292 EomScrollViewPrivate *priv;
293 int scaled_width, scaled_height;
294 gdouble page_size,page_increment,step_increment;
295 gdouble lower, upper;
296 GtkAllocation allocation;
297
298 priv = view->priv;
299
300 if (!gtk_widget_get_visible (GTK_WIDGET (priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->hbar)), ((gtk_widget_get_type ()))))))
)
301 && !gtk_widget_get_visible (GTK_WIDGET (priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->vbar)), ((gtk_widget_get_type ()))))))
))
302 return;
303
304 compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
305 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
306
307 if (gtk_widget_get_visible (GTK_WIDGET (priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->hbar)), ((gtk_widget_get_type ()))))))
)) {
308 /* Set scroll increments */
309 page_size = MIN (scaled_width, allocation.width)(((scaled_width) < (allocation.width)) ? (scaled_width) : (
allocation.width))
;
310
311 page_increment = allocation.width / 2;
312 step_increment = SCROLL_STEP_SIZE32;
313
314 /* Set scroll bounds and new offsets */
315 lower = 0;
316 upper = scaled_width;
317 priv->xofs = CLAMP (priv->xofs, 0, upper - page_size)(((priv->xofs) > (upper - page_size)) ? (upper - page_size
) : (((priv->xofs) < (0)) ? (0) : (priv->xofs)))
;
318
319 g_signal_handlers_block_matched (
320 priv->hadj, G_SIGNAL_MATCH_DATA,
321 0, 0, NULL((void*)0), NULL((void*)0), view);
322
323 gtk_adjustment_configure (priv->hadj, priv->xofs, lower,
324 upper, step_increment,
325 page_increment, page_size);
326
327 g_signal_handlers_unblock_matched (
328 priv->hadj, G_SIGNAL_MATCH_DATA,
329 0, 0, NULL((void*)0), NULL((void*)0), view);
330 }
331
332 if (gtk_widget_get_visible (GTK_WIDGET (priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->vbar)), ((gtk_widget_get_type ()))))))
)) {
333 page_size = MIN (scaled_height, allocation.height)(((scaled_height) < (allocation.height)) ? (scaled_height)
: (allocation.height))
;
334 page_increment = allocation.height / 2;
335 step_increment = SCROLL_STEP_SIZE32;
336
337 lower = 0;
338 upper = scaled_height;
339 priv->yofs = CLAMP (priv->yofs, 0, upper - page_size)(((priv->yofs) > (upper - page_size)) ? (upper - page_size
) : (((priv->yofs) < (0)) ? (0) : (priv->yofs)))
;
340
341 g_signal_handlers_block_matched (
342 priv->vadj, G_SIGNAL_MATCH_DATA,
343 0, 0, NULL((void*)0), NULL((void*)0), view);
344
345 gtk_adjustment_configure (priv->vadj, priv->yofs, lower,
346 upper, step_increment,
347 page_increment, page_size);
348
349 g_signal_handlers_unblock_matched (
350 priv->vadj, G_SIGNAL_MATCH_DATA,
351 0, 0, NULL((void*)0), NULL((void*)0), view);
352 }
353}
354
355static void
356eom_scroll_view_set_cursor (EomScrollView *view, EomScrollViewCursor new_cursor)
357{
358 GdkCursor *cursor = NULL((void*)0);
359 GdkDisplay *display;
360 GtkWidget *widget;
361
362 if (view->priv->cursor == new_cursor) {
363 return;
364 }
365
366 widget = gtk_widget_get_toplevel (GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
);
367 display = gtk_widget_get_display (widget);
368 view->priv->cursor = new_cursor;
369
370 switch (new_cursor) {
371 case EOM_SCROLL_VIEW_CURSOR_NORMAL:
372 gdk_window_set_cursor (gtk_widget_get_window (widget), NULL((void*)0));
373 break;
374 case EOM_SCROLL_VIEW_CURSOR_HIDDEN:
375 cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
376 break;
377 case EOM_SCROLL_VIEW_CURSOR_DRAG:
378 cursor = gdk_cursor_new_for_display (display, GDK_FLEUR);
379 break;
380 }
381
382 if (cursor) {
383 gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
384 g_object_unref (cursor);
385 gdk_display_flush (display);
386 }
387}
388
389/* Changes visibility of the scrollbars based on the zoom factor and the
390 * specified allocation, or the current allocation if NULL is specified.
391 */
392static void
393check_scrollbar_visibility (EomScrollView *view, GtkAllocation *alloc)
394{
395 EomScrollViewPrivate *priv;
396 int bar_height;
397 int bar_width;
398 int img_width;
399 int img_height;
400 GtkRequisition req;
401 int width, height;
402 gboolean hbar_visible, vbar_visible;
403
404 priv = view->priv;
405
406 if (alloc) {
407 width = alloc->width;
408 height = alloc->height;
409 } else {
410 GtkAllocation allocation;
411
412 gtk_widget_get_allocation (GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
, &allocation);
413 width = allocation.width;
414 height = allocation.height;
415 }
416
417 compute_scaled_size (view, priv->zoom, &img_width, &img_height);
418
419 /* this should work fairly well in this special case for scrollbars */
420 gtk_widget_get_preferred_size (priv->hbar, &req, NULL((void*)0));
421 bar_height = req.height;
422 gtk_widget_get_preferred_size (priv->vbar, &req, NULL((void*)0));
423 bar_width = req.width;
424
425 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-scroll-view.c", 425, ((const char*) (__func__
))
, "Widget Size allocate: %i, %i Bar: %i, %i\n",
426 width, height, bar_width, bar_height);
427
428 hbar_visible = vbar_visible = FALSE(0);
429 if (priv->zoom_mode == ZOOM_MODE_FIT)
430 hbar_visible = vbar_visible = FALSE(0);
431 else if (img_width <= width && img_height <= height)
432 hbar_visible = vbar_visible = FALSE(0);
433 else if (img_width > width && img_height > height)
434 hbar_visible = vbar_visible = TRUE(!(0));
435 else if (img_width > width) {
436 hbar_visible = TRUE(!(0));
437 if (img_height <= (height - bar_height))
438 vbar_visible = FALSE(0);
439 else
440 vbar_visible = TRUE(!(0));
441 }
442 else if (img_height > height) {
443 vbar_visible = TRUE(!(0));
444 if (img_width <= (width - bar_width))
445 hbar_visible = FALSE(0);
446 else
447 hbar_visible = TRUE(!(0));
448 }
449
450 if (hbar_visible != gtk_widget_get_visible (GTK_WIDGET (priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->hbar)), ((gtk_widget_get_type ()))))))
))
451 g_object_set (G_OBJECT (priv->hbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->hbar)), (((GType) ((20) << (2))))))))
, "visible", hbar_visible, NULL((void*)0));
452
453 if (vbar_visible != gtk_widget_get_visible (GTK_WIDGET (priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->vbar)), ((gtk_widget_get_type ()))))))
))
454 g_object_set (G_OBJECT (priv->vbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->vbar)), (((GType) ((20) << (2))))))))
, "visible", vbar_visible, NULL((void*)0));
455}
456
457#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
458#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
459
460/* Returns whether the image is zoomed in */
461static gboolean
462is_zoomed_in (EomScrollView *view)
463{
464 EomScrollViewPrivate *priv;
465
466 priv = view->priv;
467 return priv->zoom - 1.0 > DOUBLE_EQUAL_MAX_DIFF1e-6;
468}
469
470/* Returns whether the image is zoomed out */
471static gboolean
472is_zoomed_out (EomScrollView *view)
473{
474 EomScrollViewPrivate *priv;
475
476 priv = view->priv;
477 return DOUBLE_EQUAL_MAX_DIFF1e-6 + priv->zoom - 1.0 < 0.0;
478}
479
480/* Returns wether the image is movable, that means if it is larger then
481 * the actual visible area.
482 */
483static gboolean
484is_image_movable (EomScrollView *view)
485{
486 EomScrollViewPrivate *priv;
487
488 priv = view->priv;
489
490 return (gtk_widget_get_visible (priv->hbar) || gtk_widget_get_visible (priv->vbar));
491}
492
493/*===================================
494 drawing core
495 ---------------------------------*/
496
497static void
498get_transparency_params (EomScrollView *view, int *size, GdkRGBA *color1, GdkRGBA *color2)
499{
500 EomScrollViewPrivate *priv;
501
502 priv = view->priv;
503
504 /* Compute transparency parameters */
505 switch (priv->transp_style) {
506 case EOM_TRANSP_BACKGROUND: {
507 /* Simply return fully transparent color */
508 color1->red = color1->green = color1->blue = color1->alpha = 0.0;
509 color2->red = color2->green = color2->blue = color2->alpha = 0.0;
510 break;
511 }
512
513 case EOM_TRANSP_CHECKED:
514 g_warn_if_fail (gdk_rgba_parse (color1, CHECK_GRAY))do { if (gdk_rgba_parse (color1, "#808080")) ; else g_warn_message
("EOM", "eom-scroll-view.c", 514, ((const char*) (__func__))
, "gdk_rgba_parse (color1, CHECK_GRAY)"); } while (0)
;
515 g_warn_if_fail (gdk_rgba_parse (color2, CHECK_LIGHT))do { if (gdk_rgba_parse (color2, "#cccccc")) ; else g_warn_message
("EOM", "eom-scroll-view.c", 515, ((const char*) (__func__))
, "gdk_rgba_parse (color2, CHECK_LIGHT)"); } while (0)
;
516 break;
517
518 case EOM_TRANSP_COLOR:
519 *color1 = *color2 = priv->transp_color;
520 break;
521
522 default:
523 g_assert_not_reached ()do { g_assertion_message_expr ("EOM", "eom-scroll-view.c", 523
, ((const char*) (__func__)), ((void*)0)); } while (0)
;
524 };
525
526 *size = CHECK_MEDIUM8;
527}
528
529static cairo_surface_t *
530create_background_surface (EomScrollView *view)
531{
532 int check_size;
533 GdkRGBA check_1;
534 GdkRGBA check_2;
535 cairo_surface_t *surface;
536
537 get_transparency_params (view, &check_size, &check_1, &check_2);
538 surface = gdk_window_create_similar_surface (gtk_widget_get_window (view->priv->display),
539 CAIRO_CONTENT_COLOR_ALPHA,
540 check_size * 2, check_size * 2);
541 cairo_t* cr = cairo_create (surface);
542
543 /* Use source operator to make fully transparent work */
544 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
545
546 gdk_cairo_set_source_rgba(cr, &check_1);
547 cairo_rectangle (cr, 0, 0, check_size, check_size);
548 cairo_rectangle (cr, check_size, check_size, check_size, check_size);
549 cairo_fill (cr);
550
551 gdk_cairo_set_source_rgba(cr, &check_2);
552 cairo_rectangle (cr, 0, check_size, check_size, check_size);
553 cairo_rectangle (cr, check_size, 0, check_size, check_size);
554 cairo_fill (cr);
555
556 cairo_destroy (cr);
557
558 return surface;
559}
560
561/* =======================================
562
563 scrolling stuff
564
565 --------------------------------------*/
566
567
568/* Scrolls the view to the specified offsets. */
569static void
570scroll_to (EomScrollView *view, int x, int y, gboolean change_adjustments)
571{
572 EomScrollViewPrivate *priv;
573 GtkAllocation allocation;
574 int xofs, yofs;
575 GdkWindow *window;
576
577 priv = view->priv;
578
579 /* Check bounds & Compute offsets */
580 if (gtk_widget_get_visible (priv->hbar)) {
581 x = CLAMP (x, 0, gtk_adjustment_get_upper (priv->hadj)(((x) > (gtk_adjustment_get_upper (priv->hadj) - gtk_adjustment_get_page_size
(priv->hadj))) ? (gtk_adjustment_get_upper (priv->hadj
) - gtk_adjustment_get_page_size (priv->hadj)) : (((x) <
(0)) ? (0) : (x)))
582 - gtk_adjustment_get_page_size (priv->hadj))(((x) > (gtk_adjustment_get_upper (priv->hadj) - gtk_adjustment_get_page_size
(priv->hadj))) ? (gtk_adjustment_get_upper (priv->hadj
) - gtk_adjustment_get_page_size (priv->hadj)) : (((x) <
(0)) ? (0) : (x)))
;
583 xofs = x - priv->xofs;
584 } else
585 xofs = 0;
586
587 if (gtk_widget_get_visible (priv->vbar)) {
588 y = CLAMP (y, 0, gtk_adjustment_get_upper (priv->vadj)(((y) > (gtk_adjustment_get_upper (priv->vadj) - gtk_adjustment_get_page_size
(priv->vadj))) ? (gtk_adjustment_get_upper (priv->vadj
) - gtk_adjustment_get_page_size (priv->vadj)) : (((y) <
(0)) ? (0) : (y)))
589 - gtk_adjustment_get_page_size (priv->vadj))(((y) > (gtk_adjustment_get_upper (priv->vadj) - gtk_adjustment_get_page_size
(priv->vadj))) ? (gtk_adjustment_get_upper (priv->vadj
) - gtk_adjustment_get_page_size (priv->vadj)) : (((y) <
(0)) ? (0) : (y)))
;
590 yofs = y - priv->yofs;
591 } else
592 yofs = 0;
593
594 if (xofs == 0 && yofs == 0)
595 return;
596
597 priv->xofs = x;
598 priv->yofs = y;
599
600 if (!gtk_widget_is_drawable (priv->display))
601 goto out;
602
603 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
604
605 if (abs (xofs) >= allocation.width || abs (yofs) >= allocation.height) {
606 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
607 goto out;
608 }
609
610 window = gtk_widget_get_window (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
611
612 gdk_window_scroll (window, -xofs, -yofs);
613
614 out:
615 if (!change_adjustments)
616 return;
617
618 g_signal_handlers_block_matched (
619 priv->hadj, G_SIGNAL_MATCH_DATA,
620 0, 0, NULL((void*)0), NULL((void*)0), view);
621 g_signal_handlers_block_matched (
622 priv->vadj, G_SIGNAL_MATCH_DATA,
623 0, 0, NULL((void*)0), NULL((void*)0), view);
624
625 gtk_adjustment_set_value (priv->hadj, x);
626 gtk_adjustment_set_value (priv->vadj, y);
627
628 g_signal_handlers_unblock_matched (
629 priv->hadj, G_SIGNAL_MATCH_DATA,
630 0, 0, NULL((void*)0), NULL((void*)0), view);
631 g_signal_handlers_unblock_matched (
632 priv->vadj, G_SIGNAL_MATCH_DATA,
633 0, 0, NULL((void*)0), NULL((void*)0), view);
634}
635
636/* Scrolls the image view by the specified offsets. Notifies the adjustments
637 * about their new values.
638 */
639static void
640scroll_by (EomScrollView *view, int xofs, int yofs)
641{
642 EomScrollViewPrivate *priv;
643
644 priv = view->priv;
645
646 scroll_to (view, priv->xofs + xofs, priv->yofs + yofs, TRUE(!(0)));
647}
648
649
650/* Callback used when an adjustment is changed */
651static void
652adjustment_changed_cb (GtkAdjustment *adj, gpointer data)
653{
654 EomScrollView *view;
655 EomScrollViewPrivate *priv;
656
657 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
658 priv = view->priv;
659
660 scroll_to (view, gtk_adjustment_get_value (priv->hadj),
661 gtk_adjustment_get_value (priv->vadj), FALSE(0));
662}
663
664
665/* Drags the image to the specified position */
666static void
667drag_to (EomScrollView *view, int x, int y)
668{
669 EomScrollViewPrivate *priv;
670 int dx, dy;
671
672 priv = view->priv;
673
674 dx = priv->drag_anchor_x - x;
675 dy = priv->drag_anchor_y - y;
676
677 x = priv->drag_ofs_x + dx;
678 y = priv->drag_ofs_y + dy;
679
680 scroll_to (view, x, y, TRUE(!(0)));
681}
682
683static void
684set_minimum_zoom_factor (EomScrollView *view)
685{
686 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
687
688 view->priv->min_zoom = MAX (1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view->priv->scale,(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view
->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view
->priv->pixbuf) / view->priv->scale) > (0.02))
? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width
(view->priv->pixbuf) / view->priv->scale) : ((((
1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height
(view->priv->pixbuf) / view->priv->scale) : (0.02
))))
689 MAX(1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view->priv->scale,(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view
->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view
->priv->pixbuf) / view->priv->scale) > (0.02))
? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width
(view->priv->pixbuf) / view->priv->scale) : ((((
1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height
(view->priv->pixbuf) / view->priv->scale) : (0.02
))))
690 MIN_ZOOM_FACTOR) )(((1.0 / gdk_pixbuf_get_width (view->priv->pixbuf) / view
->priv->scale) > ((((1.0 / gdk_pixbuf_get_height (view
->priv->pixbuf) / view->priv->scale) > (0.02))
? (1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) : (0.02)))) ? (1.0 / gdk_pixbuf_get_width
(view->priv->pixbuf) / view->priv->scale) : ((((
1.0 / gdk_pixbuf_get_height (view->priv->pixbuf) / view
->priv->scale) > (0.02)) ? (1.0 / gdk_pixbuf_get_height
(view->priv->pixbuf) / view->priv->scale) : (0.02
))))
;
691 return;
692}
693
694/**
695 * set_zoom:
696 * @view: A scroll view.
697 * @zoom: Zoom factor.
698 * @have_anchor: Whether the anchor point specified by (@anchorx, @anchory)
699 * should be used.
700 * @anchorx: Horizontal anchor point in pixels.
701 * @anchory: Vertical anchor point in pixels.
702 *
703 * Sets the zoom factor for an image view. The anchor point can be used to
704 * specify the point that stays fixed when the image is zoomed. If @have_anchor
705 * is %TRUE, then (@anchorx, @anchory) specify the point relative to the image
706 * view widget's allocation that will stay fixed when zooming. If @have_anchor
707 * is %FALSE, then the center point of the image view will be used.
708 **/
709static void
710set_zoom (EomScrollView *view, double zoom,
711 gboolean have_anchor, int anchorx, int anchory)
712{
713 EomScrollViewPrivate *priv;
714 GtkAllocation allocation;
715 int xofs, yofs;
716 double x_rel, y_rel;
717
718 priv = view->priv;
719
720 if (priv->pixbuf == NULL((void*)0))
721 return;
722
723 if (zoom > MAX_ZOOM_FACTOR20)
724 zoom = MAX_ZOOM_FACTOR20;
725 else if (zoom < MIN_ZOOM_FACTOR0.02)
726 zoom = MIN_ZOOM_FACTOR0.02;
727
728 if (DOUBLE_EQUAL (priv->zoom, zoom)(fabs (priv->zoom - zoom) < 1e-6))
729 return;
730 if (DOUBLE_EQUAL (priv->zoom, priv->min_zoom)(fabs (priv->zoom - priv->min_zoom) < 1e-6) && zoom < priv->zoom)
731 return;
732
733 priv->zoom_mode = ZOOM_MODE_FREE;
734
735 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
736
737 /* compute new xofs/yofs values */
738 if (have_anchor) {
739 x_rel = (double) anchorx / allocation.width;
740 y_rel = (double) anchory / allocation.height;
741 } else {
742 x_rel = 0.5;
743 y_rel = 0.5;
744 }
745
746 compute_center_zoom_offsets (view, priv->zoom, zoom,
747 allocation.width, allocation.height,
748 x_rel, y_rel,
749 &xofs, &yofs);
750
751 /* set new values */
752 priv->xofs = xofs; /* (img_width * x_rel * zoom) - anchorx; */
753 priv->yofs = yofs; /* (img_height * y_rel * zoom) - anchory; */
754#if 0
755 g_print ("xofs: %i yofs: %i\n", priv->xofs, priv->yofs);
756#endif
757 if (zoom <= priv->min_zoom)
758 priv->zoom = priv->min_zoom;
759 else
760 priv->zoom = zoom;
761
762 /* we make use of the new values here */
763 check_scrollbar_visibility (view, NULL((void*)0));
764 update_scrollbar_values (view);
765
766 /* repaint the whole image */
767 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
768
769 g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom);
770}
771
772/* Zooms the image to fit the available allocation */
773static void
774set_zoom_fit (EomScrollView *view)
775{
776 EomScrollViewPrivate *priv;
777 GtkAllocation allocation;
778 double new_zoom;
779
780 priv = view->priv;
781
782 priv->zoom_mode = ZOOM_MODE_FIT;
783
784 if (!gtk_widget_get_mapped (GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
))
785 return;
786
787 if (priv->pixbuf == NULL((void*)0))
788 return;
789
790 gtk_widget_get_allocation (GTK_WIDGET(priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
791
792 new_zoom = zoom_fit_scale (allocation.width, allocation.height,
793 gdk_pixbuf_get_width (priv->pixbuf) / priv->scale,
794 gdk_pixbuf_get_height (priv->pixbuf) / priv->scale,
795 priv->upscale);
796
797 if (new_zoom > MAX_ZOOM_FACTOR20)
798 new_zoom = MAX_ZOOM_FACTOR20;
799 else if (new_zoom < MIN_ZOOM_FACTOR0.02)
800 new_zoom = MIN_ZOOM_FACTOR0.02;
801
802 priv->zoom = new_zoom;
803 priv->xofs = 0;
804 priv->yofs = 0;
805
806 g_signal_emit (view, view_signals [SIGNAL_ZOOM_CHANGED], 0, priv->zoom);
807}
808
809/*===================================
810
811 internal signal callbacks
812
813 ---------------------------------*/
814
815/* Key press event handler for the image view */
816static gboolean
817display_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
818{
819 EomScrollView *view;
820 EomScrollViewPrivate *priv;
821 GtkAllocation allocation;
822 gboolean do_zoom;
823 double zoom;
824 gboolean do_scroll;
825 int xofs, yofs;
826
827 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
828 priv = view->priv;
829
830 do_zoom = FALSE(0);
831 do_scroll = FALSE(0);
832 xofs = yofs = 0;
833 zoom = 1.0;
834
835 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
836
837 /* EomScrollView doesn't handle/have any Alt+Key combos */
838 if (event->state & GDK_MOD1_MASK) {
839 return FALSE(0);
840 }
841
842 switch (event->keyval) {
843 case GDK_KEY_Up0xff52:
844 do_scroll = TRUE(!(0));
845 xofs = 0;
846 yofs = -SCROLL_STEP_SIZE32;
847 break;
848
849 case GDK_KEY_Page_Up0xff55:
850 do_scroll = TRUE(!(0));
851 if (event->state & GDK_CONTROL_MASK) {
852 xofs = -(allocation.width * 3) / 4;
853 yofs = 0;
854 } else {
855 xofs = 0;
856 yofs = -(allocation.height * 3) / 4;
857 }
858 break;
859
860 case GDK_KEY_Down0xff54:
861 do_scroll = TRUE(!(0));
862 xofs = 0;
863 yofs = SCROLL_STEP_SIZE32;
864 break;
865
866 case GDK_KEY_Page_Down0xff56:
867 do_scroll = TRUE(!(0));
868 if (event->state & GDK_CONTROL_MASK) {
869 xofs = (allocation.width * 3) / 4;
870 yofs = 0;
871 } else {
872 xofs = 0;
873 yofs = (allocation.height * 3) / 4;
874 }
875 break;
876
877 case GDK_KEY_Left0xff51:
878 do_scroll = TRUE(!(0));
879 xofs = -SCROLL_STEP_SIZE32;
880 yofs = 0;
881 break;
882
883 case GDK_KEY_Right0xff53:
884 do_scroll = TRUE(!(0));
885 xofs = SCROLL_STEP_SIZE32;
886 yofs = 0;
887 break;
888
889 case GDK_KEY_plus0x02b:
890 case GDK_KEY_equal0x03d:
891 case GDK_KEY_KP_Add0xffab:
892 do_zoom = TRUE(!(0));
893 zoom = priv->zoom * priv->zoom_multiplier;
894 break;
895
896 case GDK_KEY_minus0x02d:
897 case GDK_KEY_KP_Subtract0xffad:
898 do_zoom = TRUE(!(0));
899 zoom = priv->zoom / priv->zoom_multiplier;
900 break;
901
902 case GDK_KEY_10x031:
903 do_zoom = TRUE(!(0));
904 zoom = 1.0;
905 break;
906
907 default:
908 return FALSE(0);
909 }
910
911 if (do_zoom) {
912 GdkSeat *seat;
913 GdkDevice *device;
914 gint x, y;
915
916 seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
917 device = gdk_seat_get_pointer (seat);
918
919 gdk_window_get_device_position (gtk_widget_get_window (widget), device,
920 &x, &y, NULL((void*)0));
921 set_zoom (view, zoom, TRUE(!(0)), x, y);
922 }
923
924 if (do_scroll)
925 scroll_by (view, xofs, yofs);
926
927 return TRUE(!(0));
928}
929
930
931/* Button press event handler for the image view */
932static gboolean
933eom_scroll_view_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
934{
935 EomScrollView *view;
936 EomScrollViewPrivate *priv;
937
938 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
939 priv = view->priv;
940
941 if (!gtk_widget_has_focus (priv->display))
942 gtk_widget_grab_focus (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
943
944 if (priv->dragging)
945 return FALSE(0);
946
947 switch (event->button) {
948 case 1:
949 case 2:
950 if (event->button == 1 && !priv->scroll_wheel_zoom &&
951 !(event->state & GDK_CONTROL_MASK))
952 break;
953
954 if (is_image_movable (view)) {
955 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_DRAG);
956
957 priv->dragging = TRUE(!(0));
958 priv->drag_anchor_x = event->x;
959 priv->drag_anchor_y = event->y;
960
961 priv->drag_ofs_x = priv->xofs;
962 priv->drag_ofs_y = priv->yofs;
963
964 return TRUE(!(0));
965 }
966 default:
967 break;
968 }
969
970 return FALSE(0);
971}
972
973/* Button release event handler for the image view */
974static gboolean
975eom_scroll_view_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
976{
977 EomScrollView *view;
978 EomScrollViewPrivate *priv;
979
980 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
981 priv = view->priv;
982
983 if (!priv->dragging)
984 return FALSE(0);
985
986 switch (event->button) {
987 case 1:
988 case 2:
989 drag_to (view, event->x, event->y);
990 priv->dragging = FALSE(0);
991
992 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_NORMAL);
993 break;
994
995 default:
996 break;
997 }
998
999 return TRUE(!(0));
1000}
1001
1002/* Scroll event handler for the image view. We zoom with an event without
1003 * modifiers rather than scroll; we use the Shift modifier to scroll.
1004 * Rationale: images are not primarily vertical, and in EOM you scan scroll by
1005 * dragging the image with button 1 anyways.
1006 */
1007static gboolean
1008eom_scroll_view_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer data)
1009{
1010 EomScrollView *view;
1011 EomScrollViewPrivate *priv;
1012 double zoom_factor;
1013 int xofs, yofs;
1014
1015 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1016 priv = view->priv;
1017
1018 /* Compute zoom factor and scrolling offsets; we'll only use either of them */
1019 /* same as in gtkscrolledwindow.c */
1020 xofs = gtk_adjustment_get_page_increment (priv->hadj) / 2;
1021 yofs = gtk_adjustment_get_page_increment (priv->vadj) / 2;
1022
1023 switch (event->direction) {
1024 case GDK_SCROLL_UP:
1025 zoom_factor = priv->zoom_multiplier;
1026 xofs = 0;
1027 yofs = -yofs;
1028 break;
1029
1030 case GDK_SCROLL_LEFT:
1031 zoom_factor = 1.0 / priv->zoom_multiplier;
1032 xofs = -xofs;
1033 yofs = 0;
1034 break;
1035
1036 case GDK_SCROLL_DOWN:
1037 zoom_factor = 1.0 / priv->zoom_multiplier;
1038 xofs = 0;
1039 yofs = yofs;
1040 break;
1041
1042 case GDK_SCROLL_RIGHT:
1043 zoom_factor = priv->zoom_multiplier;
1044 xofs = xofs;
1045 yofs = 0;
1046 break;
1047
1048 default:
1049 g_assert_not_reached ()do { g_assertion_message_expr ("EOM", "eom-scroll-view.c", 1049
, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1050 return FALSE(0);
1051 }
1052
1053 if (priv->scroll_wheel_zoom) {
1054 if (event->state & GDK_SHIFT_MASK)
1055 scroll_by (view, yofs, xofs);
1056 else if (event->state & GDK_CONTROL_MASK)
1057 scroll_by (view, xofs, yofs);
1058 else
1059 set_zoom (view, priv->zoom * zoom_factor,
1060 TRUE(!(0)), event->x, event->y);
1061 } else {
1062 if (event->state & GDK_SHIFT_MASK)
1063 scroll_by (view, yofs, xofs);
1064 else if (event->state & GDK_CONTROL_MASK)
1065 set_zoom (view, priv->zoom * zoom_factor,
1066 TRUE(!(0)), event->x, event->y);
1067 else
1068 scroll_by (view, xofs, yofs);
1069 }
1070
1071 return TRUE(!(0));
1072}
1073
1074/* Motion event handler for the image view */
1075static gboolean
1076eom_scroll_view_motion_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
1077{
1078 EomScrollView *view;
1079 EomScrollViewPrivate *priv;
1080 gint x, y;
1081 GdkModifierType mods;
1082
1083 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1084 priv = view->priv;
1085
1086 if (!priv->dragging)
1087 return FALSE(0);
1088
1089 if (event->is_hint)
1090 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
), event->device, &x, &y, &mods);
1091 else {
1092 x = event->x;
1093 y = event->y;
1094 }
1095
1096 drag_to (view, x, y);
1097 return TRUE(!(0));
1098}
1099
1100static void
1101display_map_event (GtkWidget *widget, GdkEvent *event, gpointer data)
1102{
1103 EomScrollView *view;
1104 EomScrollViewPrivate *priv;
1105
1106 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1107 priv = view->priv;
1108
1109 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-scroll-view.c", 1109, ((const char*) (
__func__))
);
1110
1111 set_zoom_fit (view);
1112 check_scrollbar_visibility (view, NULL((void*)0));
1113 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1114}
1115
1116static void
1117eom_scroll_view_size_allocate (GtkWidget *widget, GtkAllocation *alloc)
1118{
1119 EomScrollView *view;
1120
1121 view = EOM_SCROLL_VIEW (widget)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_scroll_view_get_type ()))))))
;
1122 check_scrollbar_visibility (view, alloc);
1123
1124 GTK_WIDGET_CLASS (eom_scroll_view_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_scroll_view_parent_class)), ((gtk_widget_get_type ()))))
))
->size_allocate (widget
1125 ,alloc);
1126}
1127
1128static void
1129display_size_change (GtkWidget *widget, GdkEventConfigure *event, gpointer data)
1130{
1131 EomScrollView *view;
1132 EomScrollViewPrivate *priv;
1133
1134 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1135 priv = view->priv;
1136
1137 if (priv->zoom_mode == ZOOM_MODE_FIT) {
1138 GtkAllocation alloc;
1139
1140 alloc.width = event->width;
1141 alloc.height = event->height;
1142
1143 set_zoom_fit (view);
1144 check_scrollbar_visibility (view, &alloc);
1145 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1146 } else {
1147 int scaled_width, scaled_height;
1148 int x_offset = 0;
1149 int y_offset = 0;
1150
1151 compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
1152
1153 if (priv->xofs + event->width > scaled_width)
1154 x_offset = scaled_width - event->width - priv->xofs;
1155
1156 if (priv->yofs + event->height > scaled_height)
1157 y_offset = scaled_height - event->height - priv->yofs;
1158
1159 scroll_by (view, x_offset, y_offset);
1160 }
1161
1162 update_scrollbar_values (view);
1163}
1164
1165
1166static gboolean
1167eom_scroll_view_focus_in_event (GtkWidget *widget,
1168 GdkEventFocus *event,
1169 gpointer data)
1170{
1171 g_signal_stop_emission_by_name (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "focus_in_event");
1172 return FALSE(0);
1173}
1174
1175static gboolean
1176eom_scroll_view_focus_out_event (GtkWidget *widget,
1177 GdkEventFocus *event,
1178 gpointer data)
1179{
1180 g_signal_stop_emission_by_name (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "focus_out_event");
1181 return FALSE(0);
1182}
1183
1184static gboolean _hq_redraw_cb (gpointer user_data)
1185{
1186 EomScrollViewPrivate *priv = EOM_SCROLL_VIEW (user_data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_scroll_view_get_type ()))))))
->priv;
1187
1188 priv->force_unfiltered = FALSE(0);
1189 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1190
1191 priv->hq_redraw_timeout_source = NULL((void*)0);
1192 return G_SOURCE_REMOVE(0);
1193}
1194
1195static void
1196_clear_hq_redraw_timeout (EomScrollView *view)
1197{
1198 EomScrollViewPrivate *priv = view->priv;
1199
1200 if (priv->hq_redraw_timeout_source != NULL((void*)0)) {
1201 g_source_unref (priv->hq_redraw_timeout_source);
1202 g_source_destroy (priv->hq_redraw_timeout_source);
1203 }
1204
1205 priv->hq_redraw_timeout_source = NULL((void*)0);
1206}
1207
1208static void
1209_set_hq_redraw_timeout (EomScrollView *view)
1210{
1211 GSource *source;
1212
1213 _clear_hq_redraw_timeout (view);
1214
1215 source = g_timeout_source_new (200);
1216 g_source_set_callback (source, &_hq_redraw_cb, view, NULL((void*)0));
1217
1218 g_source_attach (source, NULL((void*)0));
1219
1220 view->priv->hq_redraw_timeout_source = source;
1221}
1222
1223static gboolean
1224display_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
1225{
1226 const GdkRGBA *background_color = NULL((void*)0);
1227 EomScrollView *view;
1228 EomScrollViewPrivate *priv;
1229 GtkAllocation allocation;
1230 int scaled_width, scaled_height;
1231 int xofs, yofs;
1232
1233 g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_drawing_area_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 ("EOM", ((const char*) (__func__
)), "GTK_IS_DRAWING_AREA (widget)"); return ((0)); } } while (
0)
;
1234 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (data), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (data)"); return ((0)); } } while (0)
;
1235
1236 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1237
1238 priv = view->priv;
1239
1240 if (priv->pixbuf == NULL((void*)0))
1241 return TRUE(!(0));
1242
1243 compute_scaled_size (view, priv->zoom, &scaled_width, &scaled_height);
1244
1245 gtk_widget_get_allocation (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
, &allocation);
1246
1247 /* Compute image offsets with respect to the window */
1248
1249 if (scaled_width <= allocation.width)
1250 xofs = (allocation.width - scaled_width) / 2;
1251 else
1252 xofs = -priv->xofs;
1253
1254 if (scaled_height <= allocation.height)
1255 yofs = (allocation.height - scaled_height) / 2;
1256 else
1257 yofs = -priv->yofs;
1258
1259 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-scroll-view.c", 1259, ((const char*) (
__func__))
, "zoom %.2f, xofs: %i, yofs: %i scaled w: %i h: %i\n",
1260 priv->zoom, xofs, yofs, scaled_width, scaled_height);
1261
1262 /* Paint the background */
1263 cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
1264 if (priv->transp_style != EOM_TRANSP_BACKGROUND)
1265 cairo_rectangle (cr, MAX (0, xofs)(((0) > (xofs)) ? (0) : (xofs)), MAX (0, yofs)(((0) > (yofs)) ? (0) : (yofs)),
1266 scaled_width, scaled_height);
1267 if (priv->override_bg_color != NULL((void*)0))
1268 background_color = priv->override_bg_color;
1269 else if (priv->use_bg_color)
1270 background_color = priv->background_color;
1271 if (background_color != NULL((void*)0))
1272 cairo_set_source_rgba (cr,
1273 background_color->red,
1274 background_color->green,
1275 background_color->blue,
1276 background_color->alpha);
1277 else
1278 cairo_set_source (cr, gdk_window_get_background_pattern (gtk_widget_get_window (priv->display)));
1279 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1280 cairo_fill (cr);
1281
1282 if (gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
1283 if (priv->background_surface == NULL((void*)0)) {
1284 priv->background_surface = create_background_surface (view);
1285 }
1286 cairo_set_source_surface (cr, priv->background_surface, xofs, yofs);
1287 cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
1288 cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height);
1289 cairo_fill (cr);
1290 }
1291
1292 /* Make sure the image is only drawn as large as needed.
1293 * This is especially necessary for SVGs where there might
1294 * be more image data available outside the image boundaries.
1295 */
1296 cairo_rectangle (cr, xofs, yofs, scaled_width, scaled_height);
1297 cairo_clip (cr);
1298
1299#ifdef HAVE_RSVG1
1300 if (eom_image_is_svg (view->priv->image)) {
1301 cairo_matrix_t matrix, translate, scale, original;
1302 EomTransform *transform = eom_image_get_transform (priv->image);
1303 cairo_matrix_init_identity (&matrix);
1304 if (transform) {
1305 cairo_matrix_t affine;
1306 double image_offset_x = 0., image_offset_y = 0.;
1307
1308 eom_transform_get_affine (transform, &affine);
1309 cairo_matrix_multiply (&matrix, &affine, &matrix);
1310
1311 switch (eom_transform_get_transform_type (transform)) {
1312 case EOM_TRANSFORM_ROT_90:
1313 case EOM_TRANSFORM_FLIP_HORIZONTAL:
1314 image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf);
1315 break;
1316 case EOM_TRANSFORM_ROT_270:
1317 case EOM_TRANSFORM_FLIP_VERTICAL:
1318 image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf);
1319 break;
1320 case EOM_TRANSFORM_ROT_180:
1321 case EOM_TRANSFORM_TRANSPOSE:
1322 case EOM_TRANSFORM_TRANSVERSE:
1323 image_offset_x = (double) gdk_pixbuf_get_width (priv->pixbuf);
1324 image_offset_y = (double) gdk_pixbuf_get_height (priv->pixbuf);
1325 break;
1326 case EOM_TRANSFORM_NONE:
1327 default:
1328 break;
1329 }
1330 cairo_matrix_init_translate (&translate, image_offset_x, image_offset_y);
1331 cairo_matrix_multiply (&matrix, &matrix, &translate);
1332 }
1333 /* Zoom factor for SVGs is already scaled, so scale back to application pixels. */
1334 cairo_matrix_init_scale (&scale, priv->zoom / priv->scale, priv->zoom / priv->scale);
1335 cairo_matrix_multiply (&matrix, &matrix, &scale);
1336 cairo_matrix_init_translate (&translate, xofs, yofs);
1337 cairo_matrix_multiply (&matrix, &matrix, &translate);
1338
1339 cairo_get_matrix (cr, &original);
1340 cairo_matrix_multiply (&matrix, &matrix, &original);
1341 cairo_set_matrix (cr, &matrix);
1342
1343 rsvg_handle_render_cairo (eom_image_get_svg (priv->image), cr);
1344
1345 } else
1346#endif /* HAVE_RSVG */
1347 {
1348 cairo_filter_t interp_type;
1349
1350 if(!DOUBLE_EQUAL(priv->zoom, 1.0)(fabs (priv->zoom - 1.0) < 1e-6) && priv->force_unfiltered)
1351 {
1352 interp_type = CAIRO_FILTER_NEAREST;
1353 _set_hq_redraw_timeout(view);
1354 }
1355 else
1356 {
1357 if (is_zoomed_in (view))
1358 interp_type = priv->interp_type_in;
1359 else
1360 interp_type = priv->interp_type_out;
1361
1362 _clear_hq_redraw_timeout (view);
1363 priv->force_unfiltered = TRUE(!(0));
1364 }
1365 cairo_scale (cr, priv->zoom, priv->zoom);
1366 cairo_set_source_surface (cr, priv->surface, xofs/priv->zoom, yofs/priv->zoom);
1367 cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
1368 if (is_zoomed_in (view) || is_zoomed_out (view))
1369 cairo_pattern_set_filter (cairo_get_source (cr), interp_type);
1370
1371 cairo_paint (cr);
1372 }
1373
1374 return TRUE(!(0));
1375}
1376
1377
1378/*==================================
1379
1380 image loading callbacks
1381
1382 -----------------------------------*/
1383
1384/* Use when the pixbuf in the view is changed, to keep a
1385 reference to it and create its cairo surface. */
1386static void
1387update_pixbuf (EomScrollView *view, GdkPixbuf *pixbuf)
1388{
1389 EomScrollViewPrivate *priv;
1390
1391 priv = view->priv;
1392
1393 if (priv->pixbuf != NULL((void*)0)) {
1394 g_object_unref (priv->pixbuf);
1395 priv->pixbuf = NULL((void*)0);
1396 }
1397
1398 priv->pixbuf = pixbuf;
1399
1400 if (priv->surface) {
1401 cairo_surface_destroy (priv->surface);
1402 }
1403 priv->surface = create_surface_from_pixbuf (view, priv->pixbuf);
1404}
1405
1406static void
1407image_changed_cb (EomImage *img, gpointer data)
1408{
1409 EomScrollViewPrivate *priv;
1410
1411 priv = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
->priv;
1412
1413 update_pixbuf (EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
, eom_image_get_pixbuf (img));
1414
1415 set_zoom_fit (EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
);
1416 check_scrollbar_visibility (EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
1417
1418 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1419}
1420
1421/*===================================
1422 public API
1423 ---------------------------------*/
1424
1425void
1426eom_scroll_view_hide_cursor (EomScrollView *view)
1427{
1428 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_HIDDEN);
1429}
1430
1431void
1432eom_scroll_view_show_cursor (EomScrollView *view)
1433{
1434 eom_scroll_view_set_cursor (view, EOM_SCROLL_VIEW_CURSOR_NORMAL);
1435}
1436
1437/* general properties */
1438void
1439eom_scroll_view_set_zoom_upscale (EomScrollView *view, gboolean upscale)
1440{
1441 EomScrollViewPrivate *priv;
1442
1443 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1444
1445 priv = view->priv;
1446
1447 if (priv->upscale != upscale) {
1448 priv->upscale = upscale;
1449
1450 if (priv->zoom_mode == ZOOM_MODE_FIT) {
1451 set_zoom_fit (view);
1452 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1453 }
1454 }
1455}
1456
1457void
1458eom_scroll_view_set_antialiasing_in (EomScrollView *view, gboolean state)
1459{
1460 EomScrollViewPrivate *priv;
1461 cairo_filter_t new_interp_type;
1462
1463 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1464
1465 priv = view->priv;
1466
1467 new_interp_type = state ? CAIRO_FILTER_GOOD : CAIRO_FILTER_NEAREST;
1468
1469 if (priv->interp_type_in != new_interp_type) {
1470 priv->interp_type_in = new_interp_type;
1471 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1472 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "antialiasing-in");
1473 }
1474}
1475
1476void
1477eom_scroll_view_set_antialiasing_out (EomScrollView *view, gboolean state)
1478{
1479 EomScrollViewPrivate *priv;
1480 cairo_filter_t new_interp_type;
1481
1482 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1483
1484 priv = view->priv;
1485
1486 new_interp_type = state ? CAIRO_FILTER_GOOD : CAIRO_FILTER_NEAREST;
1487
1488 if (priv->interp_type_out != new_interp_type) {
1489 priv->interp_type_out = new_interp_type;
1490 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1491 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "antialiasing-out");
1492
1493 }
1494}
1495
1496static void
1497_transp_background_changed (EomScrollView *view)
1498{
1499 EomScrollViewPrivate *priv = view->priv;
1500
1501 if (priv->pixbuf != NULL((void*)0) && gdk_pixbuf_get_has_alpha (priv->pixbuf)) {
1502 if (priv->background_surface) {
1503 cairo_surface_destroy (priv->background_surface);
1504 /* Will be recreated if needed during redraw */
1505 priv->background_surface = NULL((void*)0);
1506 }
1507 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1508 }
1509
1510}
1511
1512void
1513eom_scroll_view_set_transparency_color (EomScrollView *view, GdkRGBA *color)
1514{
1515 EomScrollViewPrivate *priv;
1516
1517 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1518
1519 priv = view->priv;
1520
1521 if (!_eom_gdk_rgba_equal0 (&priv->transp_color, color)) {
1522 priv->transp_color = *color;
1523 if (priv->transp_style == EOM_TRANSP_COLOR)
1524 _transp_background_changed (view);
1525
1526 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "transparency-color");
1527 }
1528}
1529
1530void
1531eom_scroll_view_set_transparency (EomScrollView *view,
1532 EomTransparencyStyle style)
1533{
1534 EomScrollViewPrivate *priv;
1535
1536 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1537
1538 priv = view->priv;
1539
1540 if (priv->transp_style != style) {
1541 priv->transp_style = style;
1542 _transp_background_changed (view);
1543 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "transparency-style");
1544 }
1545}
1546
1547/* zoom api */
1548
1549static double preferred_zoom_levels[] = {
1550 1.0 / 100, 1.0 / 50, 1.0 / 20,
1551 1.0 / 10.0, 1.0 / 5.0, 1.0 / 3.0, 1.0 / 2.0, 1.0 / 1.5,
1552 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
1553 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0
1554};
1555static const gint n_zoom_levels = (sizeof (preferred_zoom_levels) / sizeof (double));
1556
1557void
1558eom_scroll_view_zoom_in (EomScrollView *view, gboolean smooth)
1559{
1560 EomScrollViewPrivate *priv;
1561 double zoom;
1562
1563 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1564
1565 priv = view->priv;
1566
1567 if (smooth) {
1568 zoom = priv->zoom * priv->zoom_multiplier;
1569 }
1570 else {
1571 int i;
1572 int index = -1;
1573
1574 for (i = 0; i < n_zoom_levels; i++) {
1575 if (preferred_zoom_levels [i] - priv->zoom
1576 > DOUBLE_EQUAL_MAX_DIFF1e-6) {
1577 index = i;
1578 break;
1579 }
1580 }
1581
1582 if (index == -1) {
1583 zoom = priv->zoom;
1584 }
1585 else {
1586 zoom = preferred_zoom_levels [i];
1587 }
1588 }
1589 set_zoom (view, zoom, FALSE(0), 0, 0);
1590
1591}
1592
1593void
1594eom_scroll_view_zoom_out (EomScrollView *view, gboolean smooth)
1595{
1596 EomScrollViewPrivate *priv;
1597 double zoom;
1598
1599 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1600
1601 priv = view->priv;
1602
1603 if (smooth) {
1604 zoom = priv->zoom / priv->zoom_multiplier;
1605 }
1606 else {
1607 int i;
1608 int index = -1;
1609
1610 for (i = n_zoom_levels - 1; i >= 0; i--) {
1611 if (priv->zoom - preferred_zoom_levels [i]
1612 > DOUBLE_EQUAL_MAX_DIFF1e-6) {
1613 index = i;
1614 break;
1615 }
1616 }
1617 if (index == -1) {
1618 zoom = priv->zoom;
1619 }
1620 else {
1621 zoom = preferred_zoom_levels [i];
1622 }
1623 }
1624 set_zoom (view, zoom, FALSE(0), 0, 0);
1625}
1626
1627void
1628eom_scroll_view_zoom_fit (EomScrollView *view)
1629{
1630 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1631
1632 set_zoom_fit (view);
1633 check_scrollbar_visibility (view, NULL((void*)0));
1634 gtk_widget_queue_draw (GTK_WIDGET (view->priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view->priv->display)), ((gtk_widget_get_type ()))))))
);
1635}
1636
1637void
1638eom_scroll_view_set_zoom (EomScrollView *view, double zoom)
1639{
1640 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1641
1642 set_zoom (view, zoom, FALSE(0), 0, 0);
1643}
1644
1645double
1646eom_scroll_view_get_zoom (EomScrollView *view)
1647{
1648 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), 0.0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return (0.0); } } while (0)
;
1649
1650 return view->priv->zoom;
1651}
1652
1653gboolean
1654eom_scroll_view_get_zoom_is_min (EomScrollView *view)
1655{
1656 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return ((0)); } } while (0)
;
1657
1658 set_minimum_zoom_factor (view);
1659
1660 return DOUBLE_EQUAL (view->priv->zoom, MIN_ZOOM_FACTOR)(fabs (view->priv->zoom - 0.02) < 1e-6) ||
1661 DOUBLE_EQUAL (view->priv->zoom, view->priv->min_zoom)(fabs (view->priv->zoom - view->priv->min_zoom) <
1e-6)
;
1662}
1663
1664gboolean
1665eom_scroll_view_get_zoom_is_max (EomScrollView *view)
1666{
1667 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return ((0)); } } while (0)
;
1668
1669 return DOUBLE_EQUAL (view->priv->zoom, MAX_ZOOM_FACTOR)(fabs (view->priv->zoom - 20) < 1e-6);
1670}
1671
1672static void
1673display_next_frame_cb (EomImage *image, gint delay, gpointer data)
1674{
1675 EomScrollViewPrivate *priv;
1676 EomScrollView *view;
1677
1678 if (!EOM_IS_SCROLL_VIEW (data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(data)); GType __t = ((eom_scroll_view_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; }))))
)
1679 return;
1680
1681 view = EOM_SCROLL_VIEW (data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_scroll_view_get_type ()))))))
;
1682 priv = view->priv;
1683
1684 update_pixbuf (view, eom_image_get_pixbuf (image));
1685 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1686}
1687
1688void
1689eom_scroll_view_set_image (EomScrollView *view, EomImage *image)
1690{
1691 EomScrollViewPrivate *priv;
1692
1693 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
1694
1695 priv = view->priv;
1696
1697 if (priv->image == image) {
1698 return;
1699 }
1700
1701 if (priv->image != NULL((void*)0)) {
1702 free_image_resources (view);
1703 }
1704 g_assert (priv->image == NULL)do { if (priv->image == ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-scroll-view.c", 1704, ((const char*) (__func__)
), "priv->image == NULL"); } while (0)
;
1705 g_assert (priv->pixbuf == NULL)do { if (priv->pixbuf == ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-scroll-view.c", 1705, ((const char*) (__func__)
), "priv->pixbuf == NULL"); } while (0)
;
1706
1707 if (image != NULL((void*)0)) {
1708 eom_image_data_ref (image);
1709
1710 if (priv->pixbuf == NULL((void*)0)) {
1711 update_pixbuf (view, eom_image_get_pixbuf (image));
1712 set_zoom_fit (view);
1713 check_scrollbar_visibility (view, NULL((void*)0));
1714 gtk_widget_queue_draw (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1715
1716 }
1717
1718 priv->image_changed_id = g_signal_connect (image, "changed",g_signal_connect_data ((image), ("changed"), ((GCallback) image_changed_cb
), (view), ((void*)0), (GConnectFlags) 0)
1719 (GCallback) image_changed_cb, view)g_signal_connect_data ((image), ("changed"), ((GCallback) image_changed_cb
), (view), ((void*)0), (GConnectFlags) 0)
;
1720 if (eom_image_is_animation (image) == TRUE(!(0)) ) {
1721 eom_image_start_animation (image);
1722 priv->frame_changed_id = g_signal_connect (image, "next-frame",g_signal_connect_data ((image), ("next-frame"), ((GCallback) display_next_frame_cb
), (view), ((void*)0), (GConnectFlags) 0)
1723 (GCallback) display_next_frame_cb, view)g_signal_connect_data ((image), ("next-frame"), ((GCallback) display_next_frame_cb
), (view), ((void*)0), (GConnectFlags) 0)
;
1724 }
1725 }
1726
1727 priv->image = image;
1728
1729 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "image");
1730}
1731
1732/**
1733 * eom_scroll_view_get_image:
1734 * @view: An #EomScrollView.
1735 *
1736 * Gets the the currently displayed #EomImage.
1737 *
1738 * Returns: (transfer full): An #EomImage.
1739 **/
1740EomImage*
1741eom_scroll_view_get_image (EomScrollView *view)
1742{
1743 EomImage *img;
1744
1745 g_return_val_if_fail (EOM_IS_SCROLL_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return (((void*)0)); } } while
(0)
;
1746
1747 img = view->priv->image;
1748
1749 if (img != NULL((void*)0))
1750 g_object_ref (img);
1751
1752 return img;
1753}
1754
1755gboolean
1756eom_scroll_view_scrollbars_visible (EomScrollView *view)
1757{
1758 if (!gtk_widget_get_visible (GTK_WIDGET (view->priv->hbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view->priv->hbar)), ((gtk_widget_get_type ()))))))
) &&
1759 !gtk_widget_get_visible (GTK_WIDGET (view->priv->vbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view->priv->vbar)), ((gtk_widget_get_type ()))))))
))
1760 return FALSE(0);
1761
1762 return TRUE(!(0));
1763}
1764
1765/*===================================
1766 object creation/freeing
1767 ---------------------------------*/
1768
1769static gboolean
1770sv_string_to_rgba_mapping (GValue *value,
1771 GVariant *variant,
1772 gpointer user_data)
1773{
1774 GdkRGBA color;
1775
1776 g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING), FALSE)do { if ((g_variant_is_of_type (variant, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)"
); return ((0)); } } while (0)
;
1777
1778 if (gdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) {
1779 g_value_set_boxed (value, &color);
1780 return TRUE(!(0));
1781 }
1782
1783 return FALSE(0);
1784}
1785
1786static GVariant*
1787sv_rgba_to_string_mapping (const GValue *value,
1788 const GVariantType *expected_type,
1789 gpointer user_data)
1790{
1791 GVariant *variant = NULL((void*)0);
1792 GdkRGBA *color;
1793 gchar *hex_val;
1794
1795 g_return_val_if_fail (G_VALUE_TYPE (value) == GDK_TYPE_RGBA, NULL)do { if (((((GValue*) (value))->g_type) == (gdk_rgba_get_type
()))) { } else { g_return_if_fail_warning ("EOM", ((const char
*) (__func__)), "G_VALUE_TYPE (value) == GDK_TYPE_RGBA"); return
(((void*)0)); } } while (0)
;
1796 g_return_val_if_fail (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING), NULL)do { if ((g_variant_type_equal (expected_type, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING)"
); return (((void*)0)); } } while (0)
;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1797
1798 color = g_value_get_boxed (value);
1799 hex_val = gdk_rgba_to_string(color);
1800 variant = g_variant_new_string (hex_val);
1801 g_free (hex_val);
1802
1803 return variant;
1804}
1805
1806static void
1807eom_scroll_view_init (EomScrollView *view)
1808{
1809 GSettings *settings;
1810 EomScrollViewPrivate *priv;
1811
1812 priv = view->priv = eom_scroll_view_get_instance_private (view);
1813 settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
1814
1815 priv->zoom = 1.0;
1816 priv->min_zoom = MIN_ZOOM_FACTOR0.02;
1817 priv->zoom_mode = ZOOM_MODE_FIT;
1818 priv->upscale = FALSE(0);
1819 priv->interp_type_in = CAIRO_FILTER_GOOD;
1820 priv->interp_type_out = CAIRO_FILTER_GOOD;
1821 priv->scroll_wheel_zoom = FALSE(0);
1822 priv->zoom_multiplier = IMAGE_VIEW_ZOOM_MULTIPLIER1.05;
1823 priv->image = NULL((void*)0);
1824 priv->pixbuf = NULL((void*)0);
1825 priv->surface = NULL((void*)0);
1826 priv->transp_style = EOM_TRANSP_BACKGROUND;
1827 g_warn_if_fail (gdk_rgba_parse(&priv->transp_color, CHECK_BLACK))do { if (gdk_rgba_parse(&priv->transp_color, "#000000"
)) ; else g_warn_message ("EOM", "eom-scroll-view.c", 1827, (
(const char*) (__func__)), "gdk_rgba_parse(&priv->transp_color, CHECK_BLACK)"
); } while (0)
;
1828 priv->cursor = EOM_SCROLL_VIEW_CURSOR_NORMAL;
1829 priv->menu = NULL((void*)0);
1830 priv->background_color = NULL((void*)0);
1831
1832 priv->hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 100, 0, 10, 10, 100))((((GtkAdjustment*) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_adjustment_new (0, 100, 0, 10, 10, 100))), ((gtk_adjustment_get_type
()))))))
;
1833 g_signal_connect (priv->hadj, "value_changed",g_signal_connect_data ((priv->hadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1834 G_CALLBACK (adjustment_changed_cb),g_signal_connect_data ((priv->hadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1835 view)g_signal_connect_data ((priv->hadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
;
1836
1837 priv->hbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, priv->hadj);
1838 priv->vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 100, 0, 10, 10, 100))((((GtkAdjustment*) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_adjustment_new (0, 100, 0, 10, 10, 100))), ((gtk_adjustment_get_type
()))))))
;
1839 g_signal_connect (priv->vadj, "value_changed",g_signal_connect_data ((priv->vadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1840 G_CALLBACK (adjustment_changed_cb),g_signal_connect_data ((priv->vadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
1841 view)g_signal_connect_data ((priv->vadj), ("value_changed"), ((
(GCallback) (adjustment_changed_cb))), (view), ((void*)0), (GConnectFlags
) 0)
;
1842
1843 priv->vbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, priv->vadj);
1844 priv->display = g_object_new (GTK_TYPE_DRAWING_AREA(gtk_drawing_area_get_type ()),
1845 "can-focus", TRUE(!(0)),
1846 NULL((void*)0));
1847 priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
);
1848
1849 gtk_widget_add_events (GTK_WIDGET (priv->display)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->display)), ((gtk_widget_get_type ()))))))
,
1850 GDK_EXPOSURE_MASK
1851 | GDK_BUTTON_PRESS_MASK
1852 | GDK_BUTTON_RELEASE_MASK
1853 | GDK_POINTER_MOTION_MASK
1854 | GDK_POINTER_MOTION_HINT_MASK
1855 | GDK_SCROLL_MASK
1856 | GDK_KEY_PRESS_MASK);
1857 g_signal_connect (G_OBJECT (priv->display), "configure_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("configure_event"), (((GCallback) (display_size_change
))), (view), ((void*)0), (GConnectFlags) 0)
1858 G_CALLBACK (display_size_change), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("configure_event"), (((GCallback) (display_size_change
))), (view), ((void*)0), (GConnectFlags) 0)
;
1859 g_signal_connect (G_OBJECT (priv->display), "draw", G_CALLBACK (display_draw), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("draw"), (((GCallback) (display_draw))), (view
), ((void*)0), (GConnectFlags) 0)
;
1860 g_signal_connect (G_OBJECT (priv->display), "map_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("map_event"), (((GCallback) (display_map_event
))), (view), ((void*)0), (GConnectFlags) 0)
1861 G_CALLBACK (display_map_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("map_event"), (((GCallback) (display_map_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1862 g_signal_connect (G_OBJECT (priv->display), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (eom_scroll_view_button_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
1863 G_CALLBACK (eom_scroll_view_button_press_event),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (eom_scroll_view_button_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
1864 view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (eom_scroll_view_button_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1865 g_signal_connect (G_OBJECT (priv->display), "motion_notify_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("motion_notify_event"), (((GCallback) (eom_scroll_view_motion_event
))), (view), ((void*)0), (GConnectFlags) 0)
1866 G_CALLBACK (eom_scroll_view_motion_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("motion_notify_event"), (((GCallback) (eom_scroll_view_motion_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1867 g_signal_connect (G_OBJECT (priv->display), "button_release_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_release_event"), (((GCallback) (eom_scroll_view_button_release_event
))), (view), ((void*)0), (GConnectFlags) 0)
1868 G_CALLBACK (eom_scroll_view_button_release_event),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_release_event"), (((GCallback) (eom_scroll_view_button_release_event
))), (view), ((void*)0), (GConnectFlags) 0)
1869 view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("button_release_event"), (((GCallback) (eom_scroll_view_button_release_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1870 g_signal_connect (G_OBJECT (priv->display), "scroll_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("scroll_event"), (((GCallback) (eom_scroll_view_scroll_event
))), (view), ((void*)0), (GConnectFlags) 0)
1871 G_CALLBACK (eom_scroll_view_scroll_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("scroll_event"), (((GCallback) (eom_scroll_view_scroll_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1872 g_signal_connect (G_OBJECT (priv->display), "focus_in_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_in_event"), (((GCallback) (eom_scroll_view_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1873 G_CALLBACK (eom_scroll_view_focus_in_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_in_event"), (((GCallback) (eom_scroll_view_focus_in_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1874 g_signal_connect (G_OBJECT (priv->display), "focus_out_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_out_event"), (((GCallback) (eom_scroll_view_focus_out_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1875 G_CALLBACK (eom_scroll_view_focus_out_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("focus_out_event"), (((GCallback) (eom_scroll_view_focus_out_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1876
1877 g_signal_connect (G_OBJECT (view), "key_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("key_press_event"), (((GCallback) (display_key_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
1878 G_CALLBACK (display_key_press_event), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("key_press_event"), (((GCallback) (display_key_press_event
))), (view), ((void*)0), (GConnectFlags) 0)
;
1879
1880 gtk_drag_source_set (priv->display, GDK_BUTTON1_MASK,
1881 target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])),
1882 GDK_ACTION_COPY | GDK_ACTION_MOVE |
1883 GDK_ACTION_LINK | GDK_ACTION_ASK);
1884 g_signal_connect (G_OBJECT (priv->display), "drag-data-get",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-data-get"), (((GCallback) (view_on_drag_data_get_cb
))), (view), ((void*)0), (GConnectFlags) 0)
1885 G_CALLBACK (view_on_drag_data_get_cb), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-data-get"), (((GCallback) (view_on_drag_data_get_cb
))), (view), ((void*)0), (GConnectFlags) 0)
;
1886 g_signal_connect (G_OBJECT (priv->display), "drag-begin",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-begin"), (((GCallback) (view_on_drag_begin_cb
))), (view), ((void*)0), (GConnectFlags) 0)
1887 G_CALLBACK (view_on_drag_begin_cb), view)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->display)), (((GType) ((20) <<
(2))))))))), ("drag-begin"), (((GCallback) (view_on_drag_begin_cb
))), (view), ((void*)0), (GConnectFlags) 0)
;
1888
1889 gtk_grid_attach (GTK_GRID (view)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), ((gtk_grid_get_type ()))))))
, priv->display,
1890 0, 0, 1, 1);
1891 gtk_widget_set_hexpand (priv->display, TRUE(!(0)));
1892 gtk_widget_set_vexpand (priv->display, TRUE(!(0)));
1893 gtk_grid_attach (GTK_GRID (view)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), ((gtk_grid_get_type ()))))))
, priv->hbar,
1894 0, 1, 1, 1);
1895 gtk_widget_set_hexpand (priv->hbar, TRUE(!(0)));
1896 gtk_grid_attach (GTK_GRID (view)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), ((gtk_grid_get_type ()))))))
, priv->vbar,
1897 1, 0, 1, 1);
1898 gtk_widget_set_vexpand (priv->vbar, TRUE(!(0)));
1899
1900 g_settings_bind (settings, EOM_CONF_VIEW_USE_BG_COLOR"use-background-color", view,
1901 "use-background-color", G_SETTINGS_BIND_DEFAULT);
1902 g_settings_bind_with_mapping (settings, EOM_CONF_VIEW_BACKGROUND_COLOR"background-color",
1903 view, "background-color",
1904 G_SETTINGS_BIND_DEFAULT,
1905 sv_string_to_rgba_mapping,
1906 sv_rgba_to_string_mapping, NULL((void*)0), NULL((void*)0));
1907 g_settings_bind (settings, EOM_CONF_VIEW_EXTRAPOLATE"extrapolate", view,
1908 "antialiasing-in", G_SETTINGS_BIND_GET);
1909 g_settings_bind (settings, EOM_CONF_VIEW_INTERPOLATE"interpolate", view,
1910 "antialiasing-out", G_SETTINGS_BIND_GET);
1911 g_settings_bind_with_mapping (settings, EOM_CONF_VIEW_TRANS_COLOR"trans-color",
1912 view, "transparency-color",
1913 G_SETTINGS_BIND_GET,
1914 sv_string_to_rgba_mapping,
1915 sv_rgba_to_string_mapping, NULL((void*)0), NULL((void*)0));
1916 g_settings_bind (settings, EOM_CONF_VIEW_TRANSPARENCY"transparency", view,
1917 "transparency-style", G_SETTINGS_BIND_GET);
1918
1919 g_object_unref (settings);
1920
1921 priv->override_bg_color = NULL((void*)0);
1922 priv->background_surface = NULL((void*)0);
1923}
1924
1925static void
1926eom_scroll_view_dispose (GObject *object)
1927{
1928 EomScrollView *view;
1929 EomScrollViewPrivate *priv;
1930
1931 g_return_if_fail (EOM_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (object)"); return; } } while (0)
;
1932
1933 view = EOM_SCROLL_VIEW (object)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_scroll_view_get_type ()))))))
;
1934 priv = view->priv;
1935
1936 _clear_hq_redraw_timeout (view);
1937
1938 if (priv->idle_id != 0) {
1939 g_source_remove (priv->idle_id);
1940 priv->idle_id = 0;
1941 }
1942
1943 if (priv->background_color != NULL((void*)0)) {
1944 gdk_rgba_free (priv->background_color);
1945 priv->background_color = NULL((void*)0);
1946 }
1947
1948 if (priv->override_bg_color != NULL((void*)0)) {
1949 gdk_rgba_free (priv->override_bg_color);
1950 priv->override_bg_color = NULL((void*)0);
1951 }
1952
1953 if (priv->background_surface != NULL((void*)0)) {
1954 cairo_surface_destroy (priv->background_surface);
1955 priv->background_surface = NULL((void*)0);
1956 }
1957
1958 free_image_resources (view);
1959
1960 G_OBJECT_CLASS (eom_scroll_view_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_scroll_view_parent_class
)), (((GType) ((20) << (2))))))))
->dispose (object);
1961}
1962
1963static void
1964eom_scroll_view_get_property (GObject *object, guint property_id,
1965 GValue *value, GParamSpec *pspec)
1966{
1967 EomScrollView *view;
1968 EomScrollViewPrivate *priv;
1969
1970 g_return_if_fail (EOM_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (object)"); return; } } while (0)
;
1971
1972 view = EOM_SCROLL_VIEW (object)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_scroll_view_get_type ()))))))
;
1973 priv = view->priv;
1974
1975 switch (property_id) {
1976 case PROP_ANTIALIAS_IN:
1977 {
1978 gboolean filter = (priv->interp_type_in != CAIRO_FILTER_NEAREST);
1979 g_value_set_boolean (value, filter);
1980 break;
1981 }
1982 case PROP_ANTIALIAS_OUT:
1983 {
1984 gboolean filter = (priv->interp_type_out != CAIRO_FILTER_NEAREST);
1985 g_value_set_boolean (value, filter);
1986 break;
1987 }
1988 case PROP_USE_BG_COLOR:
1989 g_value_set_boolean (value, priv->use_bg_color);
1990 break;
1991 case PROP_BACKGROUND_COLOR:
1992 //FIXME: This doesn't really handle the NULL color.
1993 g_value_set_boxed (value, priv->background_color);
1994 break;
1995 case PROP_SCROLLWHEEL_ZOOM:
1996 g_value_set_boolean (value, priv->scroll_wheel_zoom);
1997 break;
1998 case PROP_TRANSPARENCY_STYLE:
1999 g_value_set_enum (value, priv->transp_style);
2000 break;
2001 case PROP_ZOOM_MULTIPLIER:
2002 g_value_set_double (value, priv->zoom_multiplier);
2003 break;
2004 case PROP_IMAGE:
2005 g_value_set_object (value, priv->image);
2006 break;
2007 default:
2008 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-scroll-view.c", 2008, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2009 }
2010}
2011
2012static void
2013eom_scroll_view_set_property (GObject *object, guint property_id,
2014 const GValue *value, GParamSpec *pspec)
2015{
2016 EomScrollView *view;
2017
2018 g_return_if_fail (EOM_IS_SCROLL_VIEW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (object)"); return; } } while (0)
;
2019
2020 view = EOM_SCROLL_VIEW (object)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_scroll_view_get_type ()))))))
;
2021
2022 switch (property_id) {
2023 case PROP_ANTIALIAS_IN:
2024 eom_scroll_view_set_antialiasing_in (view, g_value_get_boolean (value));
2025 break;
2026 case PROP_ANTIALIAS_OUT:
2027 eom_scroll_view_set_antialiasing_out (view, g_value_get_boolean (value));
2028 break;
2029 case PROP_USE_BG_COLOR:
2030 eom_scroll_view_set_use_bg_color (view, g_value_get_boolean (value));
2031 break;
2032 case PROP_BACKGROUND_COLOR:
2033 {
2034 const GdkRGBA *color = g_value_get_boxed (value);
2035 eom_scroll_view_set_background_color (view, color);
2036 break;
2037 }
2038 case PROP_SCROLLWHEEL_ZOOM:
2039 eom_scroll_view_set_scroll_wheel_zoom (view, g_value_get_boolean (value));
2040 break;
2041 case PROP_TRANSP_COLOR:
2042 eom_scroll_view_set_transparency_color (view, g_value_get_boxed (value));
2043 break;
2044 case PROP_TRANSPARENCY_STYLE:
2045 eom_scroll_view_set_transparency (view, g_value_get_enum (value));
2046 break;
2047 case PROP_ZOOM_MULTIPLIER:
2048 eom_scroll_view_set_zoom_multiplier (view, g_value_get_double (value));
2049 break;
2050 case PROP_IMAGE:
2051 eom_scroll_view_set_image (view, g_value_get_object (value));
2052 break;
2053 default:
2054 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-scroll-view.c", 2054, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2055 }
2056}
2057
2058
2059static void
2060eom_scroll_view_class_init (EomScrollViewClass *klass)
2061{
2062 GObjectClass *gobject_class;
2063 GtkWidgetClass *widget_class;
2064
2065 gobject_class = (GObjectClass*) klass;
2066 widget_class = (GtkWidgetClass*) klass;
2067
2068 gobject_class->dispose = eom_scroll_view_dispose;
2069 gobject_class->set_property = eom_scroll_view_set_property;
2070 gobject_class->get_property = eom_scroll_view_get_property;
2071
2072 g_object_class_install_property (
2073 gobject_class, PROP_ANTIALIAS_IN,
2074 g_param_spec_boolean ("antialiasing-in", NULL((void*)0), NULL((void*)0), TRUE(!(0)),
2075 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2076
2077 g_object_class_install_property (
2078 gobject_class, PROP_ANTIALIAS_OUT,
2079 g_param_spec_boolean ("antialiasing-out", NULL((void*)0), NULL((void*)0), TRUE(!(0)),
2080 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2081
2082 /**
2083 * EomScrollView:background-color:
2084 *
2085 * This is the default background color used for painting the background
2086 * of the image view. If set to %NULL the color is determined by the
2087 * active GTK theme.
2088 */
2089 g_object_class_install_property (
2090 gobject_class, PROP_BACKGROUND_COLOR,
2091 g_param_spec_boxed ("background-color", NULL((void*)0), NULL((void*)0),
2092 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2093 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2094
2095 g_object_class_install_property (
2096 gobject_class, PROP_USE_BG_COLOR,
2097 g_param_spec_boolean ("use-background-color", NULL((void*)0), NULL((void*)0), FALSE(0),
2098 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2099
2100 /**
2101 * EomScrollView:zoom-multiplier:
2102 *
2103 * The current zoom factor is multiplied with this value + 1.0 when
2104 * scrolling with the scrollwheel to determine the next zoom factor.
2105 */
2106 g_object_class_install_property (
2107 gobject_class, PROP_ZOOM_MULTIPLIER,
2108 g_param_spec_double ("zoom-multiplier", NULL((void*)0), NULL((void*)0),
2109 -G_MAXDOUBLE1.7976931348623157e+308, G_MAXDOUBLE1.7976931348623157e+308 -1.0, 0.05,
2110 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2111
2112 /**
2113 * EomScrollView:scrollwheel-zoom:
2114 *
2115 * If %TRUE the scrollwheel will zoom the view, otherwise it will be
2116 * used for scrolling a zoomed image.
2117 */
2118 g_object_class_install_property (
2119 gobject_class, PROP_SCROLLWHEEL_ZOOM,
2120 g_param_spec_boolean ("scrollwheel-zoom", NULL((void*)0), NULL((void*)0), TRUE(!(0)),
2121 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2122
2123 /**
2124 * EomScrollView:image:
2125 *
2126 * This is the currently display #EomImage.
2127 */
2128 g_object_class_install_property (
2129 gobject_class, PROP_IMAGE,
2130 g_param_spec_object ("image", NULL((void*)0), NULL((void*)0), EOM_TYPE_IMAGE(eom_image_get_type ()),
2131 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2132
2133 /**
2134 * EomScrollView:transparency-color:
2135 *
2136 * This is the color used to fill the transparent parts of an image
2137 * if :transparency-style is set to use a custom color.
2138 */
2139 g_object_class_install_property (
2140 gobject_class, PROP_TRANSP_COLOR,
2141 g_param_spec_boxed ("transparency-color", NULL((void*)0), NULL((void*)0),
2142 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2143 G_PARAM_WRITABLE | G_PARAM_STATIC_NAME));
2144
2145 /**
2146 * EomScrollView:transparency-style:
2147 *
2148 * Determines how to fill the shown image's transparent areas.
2149 */
2150 g_object_class_install_property (
2151 gobject_class, PROP_TRANSPARENCY_STYLE,
2152 g_param_spec_enum ("transparency-style", NULL((void*)0), NULL((void*)0),
2153 EOM_TYPE_TRANSPARENCY_STYLE(eom_transparency_style_get_type()),
2154 EOM_TRANSP_CHECKED,
2155 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
2156
2157 view_signals [SIGNAL_ZOOM_CHANGED] =
2158 g_signal_new ("zoom_changed",
2159 EOM_TYPE_SCROLL_VIEW(eom_scroll_view_get_type ()),
2160 G_SIGNAL_RUN_LAST,
2161 G_STRUCT_OFFSET (EomScrollViewClass, zoom_changed)((glong) __builtin_offsetof(EomScrollViewClass, zoom_changed)
)
,
2162 NULL((void*)0), NULL((void*)0),
2163 eom_marshal_VOID__DOUBLEg_cclosure_marshal_VOID__DOUBLE,
2164 G_TYPE_NONE((GType) ((1) << (2))), 1,
2165 G_TYPE_DOUBLE((GType) ((15) << (2))));
2166
2167 widget_class->size_allocate = eom_scroll_view_size_allocate;
2168}
2169
2170static void
2171view_on_drag_begin_cb (GtkWidget *widget,
2172 GdkDragContext *context,
2173 gpointer user_data)
2174{
2175 EomScrollView *view;
2176 EomImage *image;
2177 GdkPixbuf *thumbnail;
2178 gint width, height;
2179
2180 view = EOM_SCROLL_VIEW (user_data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_scroll_view_get_type ()))))))
;
2181 image = view->priv->image;
2182
2183 thumbnail = eom_image_get_thumbnail (image);
2184
2185 if (thumbnail) {
2186 width = gdk_pixbuf_get_width (thumbnail) / view->priv->scale;
2187 height = gdk_pixbuf_get_height (thumbnail) / view->priv->scale;
2188 gtk_drag_set_icon_pixbuf (context, thumbnail, width/2, height/2);
2189 g_object_unref (thumbnail);
2190 }
2191}
2192
2193static void
2194view_on_drag_data_get_cb (GtkWidget *widget,
2195 GdkDragContext *drag_context,
2196 GtkSelectionData *data,
2197 guint info,
2198 guint time,
2199 gpointer user_data)
2200{
2201 EomScrollView *view;
2202 EomImage *image;
2203 gchar *uris[2];
2204 GFile *file;
2205
2206 view = EOM_SCROLL_VIEW (user_data)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_scroll_view_get_type ()))))))
;
2207
2208 image = view->priv->image;
2209
2210 file = eom_image_get_file (image);
2211 uris[0] = g_file_get_uri (file);
2212 uris[1] = NULL((void*)0);
2213
2214 gtk_selection_data_set_uris (data, uris);
2215
2216 g_free (uris[0]);
2217 g_object_unref (file);
2218}
2219
2220GtkWidget*
2221eom_scroll_view_new (void)
2222{
2223 GtkWidget *widget;
2224
2225 widget = g_object_new (EOM_TYPE_SCROLL_VIEW(eom_scroll_view_get_type ()),
2226 "can-focus", TRUE(!(0)),
2227 "row-homogeneous", FALSE(0),
2228 "column-homogeneous", FALSE(0),
2229 NULL((void*)0));
2230
2231
2232 return widget;
2233}
2234
2235static gboolean
2236view_on_button_press_event_cb (GtkWidget *widget, GdkEventButton *event,
2237 gpointer user_data)
2238{
2239 EomScrollView *view = EOM_SCROLL_VIEW (widget)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_scroll_view_get_type ()))))))
;
2240
2241 /* Ignore double-clicks and triple-clicks */
2242 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
2243 {
2244 gtk_menu_popup_at_pointer (GTK_MENU (view->priv->menu)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
view->priv->menu)), ((gtk_menu_get_type ()))))))
,
2245 (const GdkEvent*) event);
2246
2247 return TRUE(!(0));
2248 }
2249
2250 return FALSE(0);
2251}
2252
2253void
2254eom_scroll_view_set_popup (EomScrollView *view,
2255 GtkMenu *menu)
2256{
2257 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2258 g_return_if_fail (view->priv->menu == NULL)do { if ((view->priv->menu == ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "view->priv->menu == NULL"
); return; } } while (0)
;
2259
2260 view->priv->menu = g_object_ref (GTK_WIDGET (menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menu)), ((gtk_widget_get_type ()))))))
);
2261
2262 gtk_menu_attach_to_widget (GTK_MENU (view->priv->menu)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
view->priv->menu)), ((gtk_menu_get_type ()))))))
,
2263 GTK_WIDGET (view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(view)), ((gtk_widget_get_type ()))))))
,
2264 NULL((void*)0));
2265
2266 g_signal_connect (G_OBJECT (view), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("button_press_event"), (((GCallback) (view_on_button_press_event_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
2267 G_CALLBACK (view_on_button_press_event_cb), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((view)), (((GType) ((20) << (2)))))
)))), ("button_press_event"), (((GCallback) (view_on_button_press_event_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
2268}
2269
2270static gboolean
2271_eom_gdk_rgba_equal0 (const GdkRGBA *a, const GdkRGBA *b)
2272{
2273 if (a == NULL((void*)0) || b == NULL((void*)0))
2274 return (a == b);
2275
2276 return gdk_rgba_equal (a, b);
2277}
2278
2279static gboolean
2280_eom_replace_gdk_rgba (GdkRGBA **dest, const GdkRGBA *src)
2281{
2282 GdkRGBA *old = *dest;
2283
2284 if (_eom_gdk_rgba_equal0 (old, src))
2285 return FALSE(0);
2286
2287 if (old != NULL((void*)0))
2288 gdk_rgba_free (old);
2289
2290 *dest = (src) ? gdk_rgba_copy (src) : NULL((void*)0);
2291
2292 return TRUE(!(0));
2293}
2294
2295static void
2296_eom_scroll_view_update_bg_color (EomScrollView *view)
2297{
2298 EomScrollViewPrivate *priv = view->priv;
2299
2300 if (priv->transp_style == EOM_TRANSP_BACKGROUND
2301 && priv->background_surface != NULL((void*)0)) {
2302 /* Delete the SVG background to have it recreated with
2303 * the correct color during the next SVG redraw */
2304 cairo_surface_destroy (priv->background_surface);
2305 priv->background_surface = NULL((void*)0);
2306 }
2307
2308 gtk_widget_queue_draw (priv->display);
2309}
2310
2311void
2312eom_scroll_view_set_background_color (EomScrollView *view,
2313 const GdkRGBA *color)
2314{
2315 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2316
2317 if (_eom_replace_gdk_rgba (&view->priv->background_color, color))
2318 _eom_scroll_view_update_bg_color (view);
2319}
2320
2321void
2322eom_scroll_view_override_bg_color (EomScrollView *view,
2323 const GdkRGBA *color)
2324{
2325 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2326
2327 if (_eom_replace_gdk_rgba (&view->priv->override_bg_color, color))
2328 _eom_scroll_view_update_bg_color (view);
2329}
2330
2331void
2332eom_scroll_view_set_use_bg_color (EomScrollView *view, gboolean use)
2333{
2334 EomScrollViewPrivate *priv;
2335
2336 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2337
2338 priv = view->priv;
2339
2340 if (use != priv->use_bg_color) {
2341 priv->use_bg_color = use;
2342
2343 _eom_scroll_view_update_bg_color (view);
2344
2345 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "use-background-color");
2346 }
2347}
2348
2349void
2350eom_scroll_view_set_scroll_wheel_zoom (EomScrollView *view,
2351 gboolean scroll_wheel_zoom)
2352{
2353 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2354
2355 if (view->priv->scroll_wheel_zoom != scroll_wheel_zoom) {
2356 view->priv->scroll_wheel_zoom = scroll_wheel_zoom;
2357 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "scrollwheel-zoom");
2358 }
2359}
2360
2361void
2362eom_scroll_view_set_zoom_multiplier (EomScrollView *view,
2363 gdouble zoom_multiplier)
2364{
2365 g_return_if_fail (EOM_IS_SCROLL_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((view)); GType __t = ((eom_scroll_view_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_SCROLL_VIEW (view)"); return; } } while (0)
;
2366
2367 view->priv->zoom_multiplier = 1.0 + zoom_multiplier;
2368
2369 g_object_notify (G_OBJECT (view)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
view)), (((GType) ((20) << (2))))))))
, "zoom-multiplier");
2370}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-ab6a99.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-ab6a99.html new file mode 100644 index 0000000..d5739d9 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-ab6a99.html @@ -0,0 +1,1016 @@ + + + +egg-toolbar-editor.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:cut-n-paste/toolbar-editor/egg-toolbar-editor.c
Warning:line 620, column 3
Value stored to 'y' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name egg-toolbar-editor.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I ../.. -I ../../lib/egg -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -I /usr/include/libxml2 -D CURSOR_DIR="/usr/local/share/eom" -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/cut-n-paste/toolbar-editor -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c egg-toolbar-editor.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2003 Marco Pesenti Gritti
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 * $Id: egg-toolbar-editor.c 929 2009-02-19 14:49:56Z friemann $
19 */
20
21#include "config.h"
22
23#include "egg-toolbar-editor.h"
24#include "egg-editable-toolbar.h"
25
26#include <string.h>
27#include <libxml/tree.h>
28#include <gtk/gtk.h>
29#include <glib/gi18n.h>
30
31static const GtkTargetEntry dest_drag_types[] = {
32 {EGG_TOOLBAR_ITEM_TYPE"application/x-toolbar-item", GTK_TARGET_SAME_APP, 0},
33};
34
35static const GtkTargetEntry source_drag_types[] = {
36 {EGG_TOOLBAR_ITEM_TYPE"application/x-toolbar-item", GTK_TARGET_SAME_APP, 0},
37};
38
39
40static void egg_toolbar_editor_finalize (GObject *object);
41static void update_editor_sheet (EggToolbarEditor *editor);
42
43enum
44{
45 PROP_0,
46 PROP_UI_MANAGER,
47 PROP_TOOLBARS_MODEL
48};
49
50enum
51{
52 SIGNAL_HANDLER_ITEM_ADDED,
53 SIGNAL_HANDLER_ITEM_REMOVED,
54 SIGNAL_HANDLER_TOOLBAR_REMOVED,
55 SIGNAL_HANDLER_LIST_SIZE /* Array size */
56};
57
58struct EggToolbarEditorPrivate
59{
60 GtkUIManager *manager;
61 EggToolbarsModel *model;
62
63 GtkWidget *grid;
64 GtkWidget *scrolled_window;
65 GList *actions_list;
66 GList *factory_list;
67
68 /* These handlers need to be sanely disconnected when switching models */
69 gulong sig_handlers[SIGNAL_HANDLER_LIST_SIZE];
70};
71
72G_DEFINE_TYPE_WITH_PRIVATE (EggToolbarEditor, egg_toolbar_editor, GTK_TYPE_BOX)static void egg_toolbar_editor_init (EggToolbarEditor *self);
static void egg_toolbar_editor_class_init (EggToolbarEditorClass
*klass); static GType egg_toolbar_editor_get_type_once (void
); static gpointer egg_toolbar_editor_parent_class = ((void*)
0); static gint EggToolbarEditor_private_offset; static void egg_toolbar_editor_class_intern_init
(gpointer klass) { egg_toolbar_editor_parent_class = g_type_class_peek_parent
(klass); if (EggToolbarEditor_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggToolbarEditor_private_offset); egg_toolbar_editor_class_init
((EggToolbarEditorClass*) klass); } __attribute__((__unused__
)) static inline gpointer egg_toolbar_editor_get_instance_private
(EggToolbarEditor *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggToolbarEditor_private_offset)))); } GType egg_toolbar_editor_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = egg_toolbar_editor_get_type_once ()
; (__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType egg_toolbar_editor_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_box_get_type ()), g_intern_static_string ("EggToolbarEditor"
), sizeof (EggToolbarEditorClass), (GClassInitFunc)(void (*)(
void)) egg_toolbar_editor_class_intern_init, sizeof (EggToolbarEditor
), (GInstanceInitFunc)(void (*)(void)) egg_toolbar_editor_init
, (GTypeFlags) 0); { {{ EggToolbarEditor_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EggToolbarEditorPrivate)); };} } return
g_define_type_id; }
73
74static gint
75compare_items (gconstpointer a,
76 gconstpointer b)
77{
78 const GtkWidget *item1 = a;
79 const GtkWidget *item2 = b;
80
81 char *key1 = g_object_get_data (G_OBJECT (item1)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item1)), (((GType) ((20) << (2))))))))
,
82 "egg-collate-key");
83 char *key2 = g_object_get_data (G_OBJECT (item2)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item2)), (((GType) ((20) << (2))))))))
,
84 "egg-collate-key");
85
86 return strcmp (key1, key2);
87}
88
89static GtkAction *
90find_action (EggToolbarEditor *t,
91 const char *name)
92{
93 GList *l;
94 GtkAction *action = NULL((void*)0);
95
96 l = gtk_ui_manager_get_action_groups (t->priv->manager);
97
98 g_return_val_if_fail (EGG_IS_TOOLBAR_EDITOR (t), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((t)); GType __t = ((egg_toolbar_editor_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__)), "EGG_IS_TOOLBAR_EDITOR (t)"); return (((void*)
0)); } } while (0)
;
99 g_return_val_if_fail (name != NULL, NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
(((void*)0)); } } while (0)
;
100
101 for (; l != NULL((void*)0); l = l->next)
102 {
103 GtkAction *tmp;
104
105 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
106 tmp = gtk_action_group_get_action (GTK_ACTION_GROUP (l->data)((((GtkActionGroup*) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), ((gtk_action_group_get_type ()))))))
, name);
107 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
108 if (tmp)
109 action = tmp;
110 }
111
112 return action;
113}
114
115static void
116egg_toolbar_editor_set_ui_manager (EggToolbarEditor *t,
117 GtkUIManager *manager)
118{
119 g_return_if_fail (GTK_IS_UI_MANAGER (manager))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((manager)); GType __t = ((gtk_ui_manager_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_UI_MANAGER (manager)"); return; } } while
(0)
;
120
121 t->priv->manager = g_object_ref (manager);
122}
123
124static void
125item_added_or_removed_cb (EggToolbarsModel *model,
126 int tpos,
127 int ipos,
128 EggToolbarEditor *editor)
129{
130 update_editor_sheet (editor);
131}
132
133static void
134toolbar_removed_cb (EggToolbarsModel *model,
135 int position,
136 EggToolbarEditor *editor)
137{
138 update_editor_sheet (editor);
139}
140
141static void
142egg_toolbar_editor_disconnect_model (EggToolbarEditor *t)
143{
144 EggToolbarEditorPrivate *priv = t->priv;
145 EggToolbarsModel *model = priv->model;
146 gulong handler;
147 int i;
148
149 for (i = 0; i < SIGNAL_HANDLER_LIST_SIZE; i++)
150 {
151 handler = priv->sig_handlers[i];
152
153 if (handler != 0)
154 {
155 if (g_signal_handler_is_connected (model, handler))
156 {
157 g_signal_handler_disconnect (model, handler);
158 }
159
160 priv->sig_handlers[i] = 0;
161 }
162 }
163}
164
165void
166egg_toolbar_editor_set_model (EggToolbarEditor *t,
167 EggToolbarsModel *model)
168{
169 EggToolbarEditorPrivate *priv;
170
171 g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (t))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((t)); GType __t = ((egg_toolbar_editor_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__)), "EGG_IS_TOOLBAR_EDITOR (t)"); return; } } while
(0)
;
172 g_return_if_fail (model != NULL)do { if ((model != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "model != NULL");
return; } } while (0)
;
173
174 priv = t->priv;
175
176 if (priv->model)
177 {
178 if (G_UNLIKELY (priv->model == model)(priv->model == model)) return;
179
180 egg_toolbar_editor_disconnect_model (t);
181 g_object_unref (priv->model);
182 }
183
184 priv->model = g_object_ref (model);
185
186 update_editor_sheet (t);
187
188 priv->sig_handlers[SIGNAL_HANDLER_ITEM_ADDED] =
189 g_signal_connect_object (model, "item_added",
190 G_CALLBACK (item_added_or_removed_cb)((GCallback) (item_added_or_removed_cb)), t, 0);
191 priv->sig_handlers[SIGNAL_HANDLER_ITEM_REMOVED] =
192 g_signal_connect_object (model, "item_removed",
193 G_CALLBACK (item_added_or_removed_cb)((GCallback) (item_added_or_removed_cb)), t, 0);
194 priv->sig_handlers[SIGNAL_HANDLER_TOOLBAR_REMOVED] =
195 g_signal_connect_object (model, "toolbar_removed",
196 G_CALLBACK (toolbar_removed_cb)((GCallback) (toolbar_removed_cb)), t, 0);
197}
198
199static void
200egg_toolbar_editor_set_property (GObject *object,
201 guint prop_id,
202 const GValue *value,
203 GParamSpec *pspec)
204{
205 EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object)((((EggToolbarEditor*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((egg_toolbar_editor_get_type ()))))))
;
206
207 switch (prop_id)
208 {
209 case PROP_UI_MANAGER:
210 egg_toolbar_editor_set_ui_manager (t, g_value_get_object (value));
211 break;
212 case PROP_TOOLBARS_MODEL:
213 egg_toolbar_editor_set_model (t, g_value_get_object (value));
214 break;
215 }
216}
217
218static void
219egg_toolbar_editor_get_property (GObject *object,
220 guint prop_id,
221 GValue *value,
222 GParamSpec *pspec)
223{
224 EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object)((((EggToolbarEditor*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((egg_toolbar_editor_get_type ()))))))
;
225
226 switch (prop_id)
227 {
228 case PROP_UI_MANAGER:
229 g_value_set_object (value, t->priv->manager);
230 break;
231 case PROP_TOOLBARS_MODEL:
232 g_value_set_object (value, t->priv->model);
233 break;
234 }
235}
236
237static void
238egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
239{
240 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((klass
)), (((GType) ((20) << (2))))))))
;
241
242 object_class->finalize = egg_toolbar_editor_finalize;
243 object_class->set_property = egg_toolbar_editor_set_property;
244 object_class->get_property = egg_toolbar_editor_get_property;
245
246 g_object_class_install_property (object_class,
247 PROP_UI_MANAGER,
248 g_param_spec_object ("ui-manager",
249 "UI-Manager",
250 "UI Manager",
251 GTK_TYPE_UI_MANAGER(gtk_ui_manager_get_type ()),
252 G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
253 G_PARAM_CONSTRUCT_ONLY));
254 g_object_class_install_property (object_class,
255 PROP_TOOLBARS_MODEL,
256 g_param_spec_object ("model",
257 "Model",
258 "Toolbars Model",
259 EGG_TYPE_TOOLBARS_MODEL(egg_toolbars_model_get_type ()),
260 G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
261 G_PARAM_CONSTRUCT));
262
263 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(klass)), ((gtk_widget_get_type ()))))))
;
264 gtk_widget_class_set_css_name (widget_class, "EggToolbarEditor");
265}
266
267static void
268egg_toolbar_editor_finalize (GObject *object)
269{
270 EggToolbarEditor *editor = EGG_TOOLBAR_EDITOR (object)((((EggToolbarEditor*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((egg_toolbar_editor_get_type ()))))))
;
271
272 if (editor->priv->manager)
273 {
274 g_object_unref (editor->priv->manager);
275 }
276
277 if (editor->priv->model)
278 {
279 egg_toolbar_editor_disconnect_model (editor);
280 g_object_unref (editor->priv->model);
281 }
282
283 g_list_free (editor->priv->actions_list);
284 g_list_free (editor->priv->factory_list);
285
286 G_OBJECT_CLASS (egg_toolbar_editor_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((egg_toolbar_editor_parent_class
)), (((GType) ((20) << (2))))))))
->finalize (object);
287}
288
289GtkWidget *
290egg_toolbar_editor_new (GtkUIManager *manager,
291 EggToolbarsModel *model)
292{
293 return GTK_WIDGET (g_object_new (EGG_TYPE_TOOLBAR_EDITOR,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_toolbar_editor_get_type ()), "ui-manager"
, manager, "model", model, ((void*)0)))), ((gtk_widget_get_type
()))))))
294 "ui-manager", manager,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_toolbar_editor_get_type ()), "ui-manager"
, manager, "model", model, ((void*)0)))), ((gtk_widget_get_type
()))))))
295 "model", model,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_toolbar_editor_get_type ()), "ui-manager"
, manager, "model", model, ((void*)0)))), ((gtk_widget_get_type
()))))))
296 NULL))((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_toolbar_editor_get_type ()), "ui-manager"
, manager, "model", model, ((void*)0)))), ((gtk_widget_get_type
()))))))
;
297}
298
299static void
300drag_begin_cb (GtkWidget *widget,
301 GdkDragContext *context)
302{
303 gtk_widget_hide (widget);
304}
305
306static void
307drag_end_cb (GtkWidget *widget,
308 GdkDragContext *context)
309{
310 gtk_widget_show (widget);
311}
312
313static void
314drag_data_get_cb (GtkWidget *widget,
315 GdkDragContext *context,
316 GtkSelectionData *selection_data,
317 guint info,
318 guint32 time,
319 EggToolbarEditor *editor)
320{
321 const char *target;
322
323 target = g_object_get_data (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "egg-item-name");
324 g_return_if_fail (target != NULL)do { if ((target != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "target != NULL")
; return; } } while (0)
;
325
326 gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data), 8,
327 (const guchar *) target, strlen (target));
328}
329
330static gchar *
331elide_underscores (const gchar *original)
332{
333 gchar *q, *result;
334 const gchar *p;
335 gboolean last_underscore;
336
337 q = result = g_malloc (strlen (original) + 1);
338 last_underscore = FALSE(0);
339
340 for (p = original; *p; p++)
341 {
342 if (!last_underscore && *p == '_')
343 last_underscore = TRUE(!(0));
344 else
345 {
346 last_underscore = FALSE(0);
347 *q++ = *p;
348 }
349 }
350
351 *q = '\0';
352
353 return result;
354}
355
356static void
357set_drag_cursor (GtkWidget *widget)
358{
359 GdkCursor *cursor;
360 GdkScreen *screen;
361
362 screen = gtk_widget_get_screen (widget);
363
364 cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen),
365 GDK_HAND2);
366 gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
367 g_object_unref (cursor);
368}
369
370static void
371event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
372{
373 GtkImageType type;
374
375 set_drag_cursor (widget);
376
377 type = gtk_image_get_storage_type (icon);
378 if (type == GTK_IMAGE_STOCK)
379 {
380 gchar *stock_id;
381 GdkPixbuf *pixbuf;
382
383 gtk_image_get_stock (icon, &stock_id, NULL((void*)0));
384 pixbuf = gtk_widget_render_icon (widget, stock_id,
385 GTK_ICON_SIZE_LARGE_TOOLBAR, NULL((void*)0));
386 gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
387 g_object_unref (pixbuf);
388 }
389 else if (type == GTK_IMAGE_ICON_NAME)
390 {
391 const gchar *icon_name;
392 GdkScreen *screen;
393 GtkIconTheme *icon_theme;
394 gint width, height;
395 GdkPixbuf *pixbuf;
396
397 gtk_image_get_icon_name (icon, &icon_name, NULL((void*)0));
398 screen = gtk_widget_get_screen (widget);
399 icon_theme = gtk_icon_theme_get_for_screen (screen);
400
401 if (!gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR,
402 &width, &height))
403 {
404 width = height = 24;
405 }
406
407 pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
408 MIN (width, height)(((width) < (height)) ? (width) : (height)), 0, NULL((void*)0));
409 if (G_UNLIKELY (!pixbuf)(!pixbuf))
410 return;
411
412 gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
413 g_object_unref (pixbuf);
414
415 }
416 else if (type == GTK_IMAGE_PIXBUF)
417 {
418 GdkPixbuf *pixbuf = gtk_image_get_pixbuf (icon);
419 gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
420 }
421}
422
423static GtkWidget *
424editor_create_item (EggToolbarEditor *editor,
425 GtkImage *icon,
426 const char *label_text,
427 GdkDragAction action)
428{
429 GtkWidget *event_box;
430 GtkWidget *vbox;
431 GtkWidget *label;
432 gchar *label_no_mnemonic = NULL((void*)0);
433
434 event_box = gtk_event_box_new ();
435 gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box)((((GtkEventBox*) g_type_check_instance_cast ((GTypeInstance*
) ((event_box)), ((gtk_event_box_get_type ()))))))
, FALSE(0));
436 gtk_widget_show (event_box);
437 gtk_drag_source_set (event_box,
438 GDK_BUTTON1_MASK,
439 source_drag_types, G_N_ELEMENTS (source_drag_types)(sizeof (source_drag_types) / sizeof ((source_drag_types)[0])
)
, action);
440 g_signal_connect (event_box, "drag_data_get",g_signal_connect_data ((event_box), ("drag_data_get"), (((GCallback
) (drag_data_get_cb))), (editor), ((void*)0), (GConnectFlags)
0)
441 G_CALLBACK (drag_data_get_cb), editor)g_signal_connect_data ((event_box), ("drag_data_get"), (((GCallback
) (drag_data_get_cb))), (editor), ((void*)0), (GConnectFlags)
0)
;
442 g_signal_connect_after (event_box, "realize",g_signal_connect_data ((event_box), ("realize"), (((GCallback
) (event_box_realize_cb))), (icon), ((void*)0), G_CONNECT_AFTER
)
443 G_CALLBACK (event_box_realize_cb), icon)g_signal_connect_data ((event_box), ("realize"), (((GCallback
) (event_box_realize_cb))), (icon), ((void*)0), G_CONNECT_AFTER
)
;
444
445 if (action == GDK_ACTION_MOVE)
446 {
447 g_signal_connect (event_box, "drag_begin",g_signal_connect_data ((event_box), ("drag_begin"), (((GCallback
) (drag_begin_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
448 G_CALLBACK (drag_begin_cb), NULL)g_signal_connect_data ((event_box), ("drag_begin"), (((GCallback
) (drag_begin_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
449 g_signal_connect (event_box, "drag_end",g_signal_connect_data ((event_box), ("drag_end"), (((GCallback
) (drag_end_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0
)
450 G_CALLBACK (drag_end_cb), NULL)g_signal_connect_data ((event_box), ("drag_end"), (((GCallback
) (drag_end_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0
)
;
451 }
452
453 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
454 gtk_widget_show (vbox);
455 gtk_container_add (GTK_CONTAINER (event_box)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((event_box)), ((gtk_container_get_type ()))))))
, vbox);
456
457 gtk_widget_show (GTK_WIDGET (icon)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(icon)), ((gtk_widget_get_type ()))))))
);
458 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET (icon)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(icon)), ((gtk_widget_get_type ()))))))
, FALSE(0), TRUE(!(0)), 0);
459 label_no_mnemonic = elide_underscores (label_text);
460 label = gtk_label_new (label_no_mnemonic);
461 g_free (label_no_mnemonic);
462 gtk_widget_show (label);
463 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, label, FALSE(0), TRUE(!(0)), 0);
464
465 return event_box;
466}
467
468static GtkWidget *
469editor_create_item_from_name (EggToolbarEditor *editor,
470 const char * name,
471 GdkDragAction drag_action)
472{
473 GtkWidget *item;
474 const char *item_name;
475 char *short_label;
476 const char *collate_key;
477
478 if (strcmp (name, "_separator") == 0)
479 {
480 GtkWidget *icon;
481
482 icon = _egg_editable_toolbar_new_separator_image ();
483 short_label = _("Separator")gettext ("Separator");
484 item_name = g_strdup (name);
485 collate_key = g_utf8_collate_key (short_label, -1);
486 item = editor_create_item (editor, GTK_IMAGE (icon)((((GtkImage*) g_type_check_instance_cast ((GTypeInstance*) (
(icon)), ((gtk_image_get_type ()))))))
,
487 short_label, drag_action);
488 }
489 else
490 {
491 GtkAction *action;
492 GtkWidget *icon;
493 char *stock_id, *icon_name = NULL((void*)0);
494
495 action = find_action (editor, name);
496 g_return_val_if_fail (action != NULL, NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "action != NULL")
; return (((void*)0)); } } while (0)
;
497
498 g_object_get (action,
499 "icon-name", &icon_name,
500 "stock-id", &stock_id,
501 "short-label", &short_label,
502 NULL((void*)0));
503
504 /* This is a workaround to catch named icons. */
505 if (icon_name)
506 icon = gtk_image_new_from_icon_name (icon_name,
507 GTK_ICON_SIZE_LARGE_TOOLBAR);
508 else
509 icon = gtk_image_new_from_icon_name (stock_id ? stock_id : "gtk-dnd",
510 GTK_ICON_SIZE_LARGE_TOOLBAR);
511
512 item_name = g_strdup (name);
513 collate_key = g_utf8_collate_key (short_label, -1);
514 item = editor_create_item (editor, GTK_IMAGE (icon)((((GtkImage*) g_type_check_instance_cast ((GTypeInstance*) (
(icon)), ((gtk_image_get_type ()))))))
,
515 short_label, drag_action);
516
517 g_free (short_label);
518 g_free (stock_id);
519 g_free (icon_name);
520 }
521
522 g_object_set_data_full (G_OBJECT (item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
, "egg-collate-key",
523 (gpointer) collate_key, g_free);
524 g_object_set_data_full (G_OBJECT (item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
, "egg-item-name",
525 (gpointer) item_name, g_free);
526
527 return item;
528}
529
530static gint
531append_grid (GtkGrid *grid, GList *items, gint y, gint width)
532{
533 if (items != NULL((void*)0))
534 {
535 gint x = 0;
536 GtkWidget *item;
537
538 if (y > 0)
539 {
540 item = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
541 gtk_widget_set_hexpand (item, TRUE(!(0)));
542 gtk_widget_set_vexpand (item, FALSE(0));
543 gtk_widget_show (item);
544
545 gtk_grid_attach (grid, item, 0, y, width, 1);
546 y++;
547 }
548
549 for (; items != NULL((void*)0); items = items->next)
550 {
551 item = items->data;
552 gtk_widget_set_hexpand (item, FALSE(0));
553 gtk_widget_set_vexpand (item, FALSE(0));
554 gtk_widget_show (item);
555
556 if (x >= width)
557 {
558 x = 0;
559 y++;
560 }
561 gtk_grid_attach (grid, item, x, y, 1, 1);
562 x++;
563 }
564
565 y++;
566 }
567 return y;
568}
569
570static void
571update_editor_sheet (EggToolbarEditor *editor)
572{
573 gint y;
574 GPtrArray *items;
575 GList *to_move = NULL((void*)0), *to_copy = NULL((void*)0);
576 GtkWidget *grid;
577 GtkWidget *viewport;
578
579 g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((editor)); GType __t = ((egg_toolbar_editor_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__)), "EGG_IS_TOOLBAR_EDITOR (editor)"); return
; } } while (0)
;
580
581 /* Create new grid. */
582 grid = gtk_grid_new ();
583 editor->priv->grid = grid;
584 gtk_container_set_border_width (GTK_CONTAINER (grid)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((grid)), ((gtk_container_get_type ()))))))
, 12);
585 gtk_grid_set_row_spacing (GTK_GRID (grid)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
grid)), ((gtk_grid_get_type ()))))))
, 24);
586 gtk_widget_show (grid);
587 gtk_drag_dest_set (grid, GTK_DEST_DEFAULT_ALL,
588 dest_drag_types, G_N_ELEMENTS (dest_drag_types)(sizeof (dest_drag_types) / sizeof ((dest_drag_types)[0])),
589 GDK_ACTION_MOVE | GDK_ACTION_COPY);
590
591 /* Build two lists of items (one for copying, one for moving). */
592 items = egg_toolbars_model_get_name_avail (editor->priv->model);
593 while (items->len > 0)
594 {
595 GtkWidget *item;
596 const char *name;
597 gint flags;
598
599 name = g_ptr_array_index (items, 0)((items)->pdata)[0];
600 g_ptr_array_remove_index_fast (items, 0);
601
602 flags = egg_toolbars_model_get_name_flags (editor->priv->model, name);
603 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
604 {
605 item = editor_create_item_from_name (editor, name, GDK_ACTION_MOVE);
606 if (item != NULL((void*)0))
607 to_move = g_list_insert_sorted (to_move, item, compare_items);
608 }
609 else
610 {
611 item = editor_create_item_from_name (editor, name, GDK_ACTION_COPY);
612 if (item != NULL((void*)0))
613 to_copy = g_list_insert_sorted (to_copy, item, compare_items);
614 }
615 }
616
617 /* Add them to the sheet. */
618 y = 0;
619 y = append_grid (GTK_GRID (grid)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
grid)), ((gtk_grid_get_type ()))))))
, to_move, y, 4);
620 y = append_grid (GTK_GRID (grid)((((GtkGrid*) g_type_check_instance_cast ((GTypeInstance*) ((
grid)), ((gtk_grid_get_type ()))))))
, to_copy, y, 4)
;
Value stored to 'y' is never read
621
622 g_list_free (to_move);
623 g_list_free (to_copy);
624 g_ptr_array_free (items, TRUE(!(0)));
625
626 /* Delete old table/grid. */
627 viewport = gtk_bin_get_child (GTK_BIN (editor->priv->scrolled_window)((((GtkBin*) g_type_check_instance_cast ((GTypeInstance*) ((editor
->priv->scrolled_window)), ((gtk_bin_get_type ()))))))
);
628 if (viewport)
629 {
630 gtk_container_remove (GTK_CONTAINER (viewport)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((viewport)), ((gtk_container_get_type ()))))))
,
631 gtk_bin_get_child (GTK_BIN (viewport)((((GtkBin*) g_type_check_instance_cast ((GTypeInstance*) ((viewport
)), ((gtk_bin_get_type ()))))))
));
632 }
633
634 /* Add grid to window. */
635 gtk_scrolled_window_add_with_viewport
636 (GTK_SCROLLED_WINDOW (editor->priv->scrolled_window)((((GtkScrolledWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((editor->priv->scrolled_window)), ((gtk_scrolled_window_get_type
()))))))
, grid);
637}
638
639static void
640setup_editor (EggToolbarEditor *editor)
641{
642 GtkWidget *scrolled_window;
643
644 gtk_orientable_set_orientation (GTK_ORIENTABLE (editor)((((GtkOrientable*) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_orientable_get_type ()))))))
,
645 GTK_ORIENTATION_VERTICAL);
646
647 gtk_container_set_border_width (GTK_CONTAINER (editor)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_container_get_type ()))))))
, 12);
648 scrolled_window = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
649 editor->priv->scrolled_window = scrolled_window;
650 gtk_widget_show (scrolled_window);
651 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window)((((GtkScrolledWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled_window)), ((gtk_scrolled_window_get_type ()))))
))
,
652 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
653 gtk_box_pack_start (GTK_BOX (editor)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((editor
)), ((gtk_box_get_type ()))))))
, scrolled_window, TRUE(!(0)), TRUE(!(0)), 0);
654}
655
656static void
657egg_toolbar_editor_init (EggToolbarEditor *t)
658{
659 t->priv = egg_toolbar_editor_get_instance_private (t);
660
661 t->priv->manager = NULL((void*)0);
662 t->priv->actions_list = NULL((void*)0);
663
664 setup_editor (t);
665}
666
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b3e0cd.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b3e0cd.html new file mode 100644 index 0000000..d9c45de --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b3e0cd.html @@ -0,0 +1,692 @@ + + + +eom-preferences-dialog.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-preferences-dialog.c
Warning:line 79, column 2
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 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-preferences-dialog.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-preferences-dialog.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - EOM Preferences Dialog
2 *
3 * Copyright (C) 2006 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Jens Finke <jens@gnome.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25#ifdef HAVE_CONFIG_H1
26#include "config.h"
27#endif
28
29#include "eom-preferences-dialog.h"
30#include "eom-scroll-view.h"
31#include "eom-util.h"
32#include "eom-config-keys.h"
33
34#include <glib.h>
35#include <glib/gi18n.h>
36#include <glib-object.h>
37#include <gtk/gtk.h>
38#include <gio/gio.h>
39#include <libpeas-gtk/peas-gtk-plugin-manager.h>
40
41#define GSETTINGS_OBJECT_KEY"GSETTINGS_KEY" "GSETTINGS_KEY"
42#define GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE" "GSETTINGS_VALUE"
43
44struct _EomPreferencesDialogPrivate {
45 GSettings *view_settings;
46 GSettings *ui_settings;
47 GSettings *fullscreen_settings;
48
49 GtkWidget *notebook;
50 GtkWidget *interpolate_check;
51 GtkWidget *extrapolate_check;
52 GtkWidget *autorotate_check;
53 GtkWidget *bg_color_check;
54 GtkWidget *bg_color_button;
55 GtkWidget *color_radio;
56 GtkWidget *checkpattern_radio;
57 GtkWidget *background_radio;
58 GtkWidget *transp_color_button;
59
60 GtkWidget *upscale_check;
61 GtkWidget *random_check;
62 GtkWidget *loop_check;
63 GtkWidget *seconds_spin;
64
65 GtkWidget *plugin_manager;
66};
67
68static GObject *instance = NULL((void*)0);
69
70G_DEFINE_TYPE_WITH_PRIVATE (EomPreferencesDialog, eom_preferences_dialog, GTK_TYPE_DIALOG)static void eom_preferences_dialog_init (EomPreferencesDialog
*self); static void eom_preferences_dialog_class_init (EomPreferencesDialogClass
*klass); static GType eom_preferences_dialog_get_type_once (
void); static gpointer eom_preferences_dialog_parent_class = (
(void*)0); static gint EomPreferencesDialog_private_offset; static
void eom_preferences_dialog_class_intern_init (gpointer klass
) { eom_preferences_dialog_parent_class = g_type_class_peek_parent
(klass); if (EomPreferencesDialog_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomPreferencesDialog_private_offset); eom_preferences_dialog_class_init
((EomPreferencesDialogClass*) klass); } __attribute__((__unused__
)) static inline gpointer eom_preferences_dialog_get_instance_private
(EomPreferencesDialog *self) { return (((gpointer) ((guint8*
) (self) + (glong) (EomPreferencesDialog_private_offset)))); }
GType eom_preferences_dialog_get_type (void) { static volatile
gsize g_define_type_id__volatile = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer
), "Expression evaluates to false"); (void) (0 ? (gpointer) *
(&g_define_type_id__volatile) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_preferences_dialog_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_preferences_dialog_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_dialog_get_type ()), g_intern_static_string ("EomPreferencesDialog"
), sizeof (EomPreferencesDialogClass), (GClassInitFunc)(void (
*)(void)) eom_preferences_dialog_class_intern_init, sizeof (EomPreferencesDialog
), (GInstanceInitFunc)(void (*)(void)) eom_preferences_dialog_init
, (GTypeFlags) 0); { {{ EomPreferencesDialog_private_offset =
g_type_add_instance_private (g_define_type_id, sizeof (EomPreferencesDialogPrivate
)); };} } return g_define_type_id; }
;
71
72static gboolean
73pd_string_to_rgba_mapping (GValue *value,
74 GVariant *variant,
75 gpointer user_data)
76{
77 GdkRGBA color;
78
79 g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING), FALSE)do { if ((g_variant_is_of_type (variant, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)"
); return ((0)); } } while (0)
;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
80
81 if (gdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) {
82 g_value_set_boxed (value, &color);
83 return TRUE(!(0));
84 }
85
86 return FALSE(0);
87}
88
89static GVariant*
90pd_rgba_to_string_mapping (const GValue *value,
91 const GVariantType *expected_type,
92 gpointer user_data)
93{
94
95 GVariant *variant = NULL((void*)0);
96 GdkRGBA *color;
97 gchar *hex_val;
98
99 g_return_val_if_fail (G_VALUE_TYPE (value) == GDK_TYPE_RGBA, NULL)do { if (((((GValue*) (value))->g_type) == (gdk_rgba_get_type
()))) { } else { g_return_if_fail_warning ("EOM", ((const char
*) (__func__)), "G_VALUE_TYPE (value) == GDK_TYPE_RGBA"); return
(((void*)0)); } } while (0)
;
100 g_return_val_if_fail (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING), NULL)do { if ((g_variant_type_equal (expected_type, ((const GVariantType
*) "s")))) { } else { g_return_if_fail_warning ("EOM", ((const
char*) (__func__)), "g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING)"
); return (((void*)0)); } } while (0)
;
101
102 color = g_value_get_boxed (value);
103 hex_val = gdk_rgba_to_string(color);
104
105 variant = g_variant_new_string (hex_val);
106 g_free (hex_val);
107
108 return variant;
109}
110
111static void
112pd_transp_radio_toggle_cb (GtkWidget *widget, gpointer data)
113{
114 gpointer value = NULL((void*)0);
115
116 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_toggle_button_get_type ()))))))
))
117 return;
118
119 value = g_object_get_data (G_OBJECT (widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE");
120
121 g_settings_set_enum (G_SETTINGS (data)((((GSettings*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((g_settings_get_type ()))))))
, EOM_CONF_VIEW_TRANSPARENCY"transparency",
122 GPOINTER_TO_INT (value)((gint) (glong) (value)));
123}
124
125static void
126random_change_cb (GSettings *settings, gchar *key, GtkWidget *widget)
127{
128 gtk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key));
129}
130
131static void
132eom_preferences_response_cb (GtkDialog *dlg, gint res_id, gpointer data)
133{
134 switch (res_id) {
135 case GTK_RESPONSE_HELP:
136 eom_util_show_help ("eom-prefs", NULL((void*)0));
137 break;
138 default:
139 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_widget_get_type ()))))))
);
140 instance = NULL((void*)0);
141 }
142}
143
144static void
145eom_preferences_dialog_class_init (EomPreferencesDialogClass *klass)
146{
147 GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
148
149 /* This should make sure the libpeas-gtk dependency isn't
150 * dropped by aggressive linkers (#739618) */
151 g_type_ensure (PEAS_GTK_TYPE_PLUGIN_MANAGER(peas_gtk_plugin_manager_get_type()));
152
153 gtk_widget_class_set_template_from_resource (widget_class,
154 "/org/mate/eom/ui/eom-preferences-dialog.ui");
155 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
156 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
157 notebook)gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
;
158 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
159 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
160 interpolate_check)gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
;
161 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
162 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
163 extrapolate_check)gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
;
164 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
165 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
166 autorotate_check)gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
;
167 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
168 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
169 bg_color_check)gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
;
170 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
171 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
172 bg_color_button)gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
;
173 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
174 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
175 color_radio)gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
;
176 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
177 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
178 checkpattern_radio)gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
;
179 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
180 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
181 background_radio)gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
;
182 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
183 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
184 transp_color_button)gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
;
185
186 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
187 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
188 upscale_check)gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
;
189 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
190 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
191 random_check)gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
;
192 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
193 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
194 loop_check)gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
;
195 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
196 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
197 seconds_spin)gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
;
198
199 gtk_widget_class_bind_template_child_private (widget_class,gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
200 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
201 plugin_manager)gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
;
202}
203
204static void
205eom_preferences_dialog_init (EomPreferencesDialog *pref_dlg)
206{
207 EomPreferencesDialogPrivate *priv;
208
209 pref_dlg->priv = eom_preferences_dialog_get_instance_private (pref_dlg);
210 priv = pref_dlg->priv;
211
212 gtk_widget_init_template (GTK_WIDGET (pref_dlg)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(pref_dlg)), ((gtk_widget_get_type ()))))))
);
213
214 priv->view_settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
215 priv->fullscreen_settings = g_settings_new (EOM_CONF_FULLSCREEN"org.mate.eom"".full-screen");
216
217 g_signal_connect (G_OBJECT (pref_dlg),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
218 "response",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
219 G_CALLBACK (eom_preferences_response_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
220 pref_dlg)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eom_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
;
221
222 g_settings_bind (priv->view_settings,
223 EOM_CONF_VIEW_INTERPOLATE"interpolate",
224 priv->interpolate_check, "active",
225 G_SETTINGS_BIND_DEFAULT);
226 g_settings_bind (priv->view_settings,
227 EOM_CONF_VIEW_EXTRAPOLATE"extrapolate",
228 priv->extrapolate_check, "active",
229 G_SETTINGS_BIND_DEFAULT);
230 g_settings_bind (priv->view_settings,
231 EOM_CONF_VIEW_AUTOROTATE"autorotate",
232 priv->autorotate_check, "active",
233 G_SETTINGS_BIND_DEFAULT);
234 g_settings_bind (priv->view_settings,
235 EOM_CONF_VIEW_USE_BG_COLOR"use-background-color",
236 priv->bg_color_check, "active",
237 G_SETTINGS_BIND_DEFAULT);
238
239 g_settings_bind_with_mapping (priv->view_settings,
240 EOM_CONF_VIEW_BACKGROUND_COLOR"background-color",
241 priv->bg_color_button, "rgba",
242 G_SETTINGS_BIND_DEFAULT,
243 pd_string_to_rgba_mapping,
244 pd_rgba_to_string_mapping,
245 NULL((void*)0), NULL((void*)0));
246 g_object_set_data (G_OBJECT (priv->color_radio)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->color_radio)), (((GType) ((20) << (2))))))))
,
247 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
248 GINT_TO_POINTER (EOM_TRANSP_COLOR)((gpointer) (glong) (EOM_TRANSP_COLOR)));
249
250 g_signal_connect (G_OBJECT (priv->color_radio),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
251 "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
252 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
253 priv->view_settings)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
254
255 g_object_set_data (G_OBJECT (priv->checkpattern_radio)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->checkpattern_radio)), (((GType) ((20) << (2)))
)))))
,
256 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
257 GINT_TO_POINTER (EOM_TRANSP_CHECKED)((gpointer) (glong) (EOM_TRANSP_CHECKED)));
258
259 g_signal_connect (G_OBJECT (priv->checkpattern_radio),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
260 "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
261 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
262 priv->view_settings)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
263
264 g_object_set_data (G_OBJECT (priv->background_radio)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->background_radio)), (((GType) ((20) << (2)))))
)))
,
265 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
266 GINT_TO_POINTER (EOM_TRANSP_BACKGROUND)((gpointer) (glong) (EOM_TRANSP_BACKGROUND)));
267
268 g_signal_connect (G_OBJECT (priv->background_radio),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
269 "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
270 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
271 priv->view_settings)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
272
273 switch (g_settings_get_enum (priv->view_settings,
274 EOM_CONF_VIEW_TRANSPARENCY"transparency"))
275 {
276 case EOM_TRANSP_COLOR:
277 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->color_radio)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), ((gtk_toggle_button_get_type ())
)))))
, TRUE(!(0)));
278 break;
279 case EOM_TRANSP_CHECKED:
280 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkpattern_radio)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
281 break;
282 default:
283 // Log a warning and use EOM_TRANSP_BACKGROUND as fallback
284 g_warn_if_reached ()do { g_warn_message ("EOM", "eom-preferences-dialog.c", 284, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
285 case EOM_TRANSP_BACKGROUND:
286 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->background_radio)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
287 break;
288 }
289
290 g_settings_bind_with_mapping (priv->view_settings,
291 EOM_CONF_VIEW_TRANS_COLOR"trans-color",
292 priv->transp_color_button, "rgba",
293 G_SETTINGS_BIND_DEFAULT,
294 pd_string_to_rgba_mapping,
295 pd_rgba_to_string_mapping,
296 NULL((void*)0), NULL((void*)0));
297
298 g_settings_bind (priv->fullscreen_settings, EOM_CONF_FULLSCREEN_UPSCALE"upscale",
299 priv->upscale_check, "active",
300 G_SETTINGS_BIND_DEFAULT);
301
302 g_settings_bind (priv->fullscreen_settings,
303 EOM_CONF_FULLSCREEN_LOOP"loop",
304 priv->loop_check, "active",
305 G_SETTINGS_BIND_DEFAULT);
306
307 g_settings_bind (priv->fullscreen_settings,
308 EOM_CONF_FULLSCREEN_RANDOM"random",
309 priv->random_check, "active",
310 G_SETTINGS_BIND_DEFAULT);
311 g_signal_connect (priv->fullscreen_settings,g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
312 "changed::" EOM_CONF_FULLSCREEN_RANDOM,g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
313 G_CALLBACK (random_change_cb),g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
314 priv->loop_check)g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
;
315 random_change_cb (priv->fullscreen_settings,
316 EOM_CONF_FULLSCREEN_RANDOM"random",
317 priv->loop_check);
318
319 g_settings_bind (priv->fullscreen_settings,
320 EOM_CONF_FULLSCREEN_SECONDS"seconds",
321 priv->seconds_spin, "value",
322 G_SETTINGS_BIND_DEFAULT);
323
324 gtk_widget_show_all (priv->plugin_manager);
325
326 /* Add tab scrolling support for GTK3 */
327 gtk_widget_add_events (priv->notebook, GDK_SCROLL_MASK);
328 g_signal_connect (priv->notebook,g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
329 "scroll-event",g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
330 G_CALLBACK (eom_notebook_scroll_event_cb),g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
331 NULL)g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
332}
333
334GtkWidget *eom_preferences_dialog_get_instance (GtkWindow *parent)
335{
336 if (instance == NULL((void*)0)) {
337 instance = g_object_new (EOM_TYPE_PREFERENCES_DIALOG(eom_preferences_dialog_get_type ()),
338 NULL((void*)0));
339 }
340
341 if (parent)
342 gtk_window_set_transient_for (GTK_WINDOW (instance)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(instance)), ((gtk_window_get_type ()))))))
, parent);
343
344 return GTK_WIDGET(instance)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(instance)), ((gtk_widget_get_type ()))))))
;
345}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b5c354.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b5c354.html new file mode 100644 index 0000000..a52de57 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-b5c354.html @@ -0,0 +1,1326 @@ + + + +egg-toolbars-model.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:cut-n-paste/toolbar-editor/egg-toolbars-model.c
Warning:line 101, column 15
Value stored to 'node' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name egg-toolbars-model.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I ../.. -I ../../lib/egg -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -I /usr/include/libxml2 -D CURSOR_DIR="/usr/local/share/eom" -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/cut-n-paste/toolbar-editor -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c egg-toolbars-model.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2002-2004 Marco Pesenti Gritti
3 * Copyright (C) 2004 Christian Persch
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * $Id: egg-toolbars-model.c 929 2009-02-19 14:49:56Z friemann $
20 */
21
22#include "config.h"
23
24#include "egg-toolbars-model.h"
25#include "eggtypebuiltins.h"
26#include "eggmarshalers.h"
27
28#include <unistd.h>
29#include <string.h>
30#include <libxml/tree.h>
31#include <gdk/gdk.h>
32
33static void egg_toolbars_model_finalize (GObject *object);
34
35enum
36{
37 ITEM_ADDED,
38 ITEM_REMOVED,
39 TOOLBAR_ADDED,
40 TOOLBAR_CHANGED,
41 TOOLBAR_REMOVED,
42 LAST_SIGNAL
43};
44
45typedef struct
46{
47 char *name;
48 EggTbModelFlags flags;
49} EggToolbarsToolbar;
50
51typedef struct
52{
53 char *name;
54} EggToolbarsItem;
55
56static guint signals[LAST_SIGNAL] = { 0 };
57
58struct EggToolbarsModelPrivate
59{
60 GNode *toolbars;
61 GList *types;
62 GHashTable *flags;
63};
64
65G_DEFINE_TYPE_WITH_PRIVATE (EggToolbarsModel, egg_toolbars_model, G_TYPE_OBJECT)static void egg_toolbars_model_init (EggToolbarsModel *self);
static void egg_toolbars_model_class_init (EggToolbarsModelClass
*klass); static GType egg_toolbars_model_get_type_once (void
); static gpointer egg_toolbars_model_parent_class = ((void*)
0); static gint EggToolbarsModel_private_offset; static void egg_toolbars_model_class_intern_init
(gpointer klass) { egg_toolbars_model_parent_class = g_type_class_peek_parent
(klass); if (EggToolbarsModel_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggToolbarsModel_private_offset); egg_toolbars_model_class_init
((EggToolbarsModelClass*) klass); } __attribute__((__unused__
)) static inline gpointer egg_toolbars_model_get_instance_private
(EggToolbarsModel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggToolbarsModel_private_offset)))); } GType egg_toolbars_model_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = egg_toolbars_model_get_type_once ()
; (__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType egg_toolbars_model_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EggToolbarsModel"
), sizeof (EggToolbarsModelClass), (GClassInitFunc)(void (*)(
void)) egg_toolbars_model_class_intern_init, sizeof (EggToolbarsModel
), (GInstanceInitFunc)(void (*)(void)) egg_toolbars_model_init
, (GTypeFlags) 0); { {{ EggToolbarsModel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EggToolbarsModelPrivate)); };} } return
g_define_type_id; }
66
67static xmlDocPtr
68egg_toolbars_model_to_xml (EggToolbarsModel *model)
69{
70 GNode *l1, *l2, *tl;
71 GList *l3;
72 xmlDocPtr doc;
73
74 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
(((void*)0)); } } while (0)
;
75
76 tl = model->priv->toolbars;
77
78 xmlIndentTreeOutput(*(__xmlIndentTreeOutput())) = TRUE(!(0));
79 doc = xmlNewDoc ((const xmlChar*) "1.0");
80 doc->children = xmlNewDocNode (doc, NULL((void*)0), (const xmlChar*) "toolbars", NULL((void*)0));
81
82 for (l1 = tl->children; l1 != NULL((void*)0); l1 = l1->next)
83 {
84 xmlNodePtr tnode;
85 EggToolbarsToolbar *toolbar = l1->data;
86
87 tnode = xmlNewChild (doc->children, NULL((void*)0), (const xmlChar*) "toolbar", NULL((void*)0));
88 xmlSetProp (tnode, (const xmlChar*) "name", (const xmlChar*) toolbar->name);
89 xmlSetProp (tnode, (const xmlChar*) "hidden",
90 (toolbar->flags&EGG_TB_MODEL_HIDDEN) ? (const xmlChar*) "true" : (const xmlChar*) "false");
91 xmlSetProp (tnode, (const xmlChar*) "editable",
92 (toolbar->flags&EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar*) "false" : (const xmlChar*) "true");
93
94 for (l2 = l1->children; l2 != NULL((void*)0); l2 = l2->next)
95 {
96 xmlNodePtr node;
97 EggToolbarsItem *item = l2->data;
98
99 if (strcmp (item->name, "_separator") == 0)
100 {
101 node = xmlNewChild (tnode, NULL((void*)0), (const xmlChar*) "separator", NULL((void*)0));
Value stored to 'node' is never read
102 continue;
103 }
104
105 node = xmlNewChild (tnode, NULL((void*)0), (const xmlChar*) "toolitem", NULL((void*)0));
106 xmlSetProp (node, (const xmlChar*) "name", (const xmlChar*) item->name);
107
108 /* Add 'data' nodes for each data type which can be written out for this
109 * item. Only write types which can be used to restore the data. */
110 for (l3 = model->priv->types; l3 != NULL((void*)0); l3 = l3->next)
111 {
112 EggToolbarsItemType *type = l3->data;
113 if (type->get_name != NULL((void*)0) && type->get_data != NULL((void*)0))
114 {
115 xmlNodePtr dnode;
116 char *tmp;
117
118 tmp = type->get_data (type, item->name);
119 if (tmp != NULL((void*)0))
120 {
121 dnode = xmlNewTextChild (node, NULL((void*)0), (const xmlChar*) "data", (const xmlChar*) tmp);
122 g_free (tmp);
123
124 tmp = gdk_atom_name (type->type);
125 xmlSetProp (dnode, (const xmlChar*) "type", (const xmlChar*) tmp);
126 g_free (tmp);
127 }
128 }
129 }
130 }
131 }
132
133 return doc;
134}
135
136static gboolean
137safe_save_xml (const char *xml_file, xmlDocPtr doc)
138{
139 char *tmp_file;
140 char *old_file;
141 gboolean old_exist;
142 gboolean retval = TRUE(!(0));
143
144 tmp_file = g_strconcat (xml_file, ".tmp", NULL((void*)0));
145 old_file = g_strconcat (xml_file, ".old", NULL((void*)0));
146
147 if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
148 {
149 g_warning ("Failed to write XML data to %s", tmp_file);
150 goto failed;
151 }
152
153 old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
154
155 if (old_exist)
156 {
157 if (rename (xml_file, old_file) < 0)
158 {
159 g_warning ("Failed to rename %s to %s", xml_file, old_file);
160 retval = FALSE(0);
161 goto failed;
162 }
163 }
164
165 if (rename (tmp_file, xml_file) < 0)
166 {
167 g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
168
169 if (rename (old_file, xml_file) < 0)
170 {
171 g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
172 }
173 retval = FALSE(0);
174 goto failed;
175 }
176
177 if (old_exist)
178 {
179 if (unlink (old_file) < 0)
180 {
181 g_warning ("Failed to delete old file %s", old_file);
182 }
183 }
184
185 failed:
186 g_free (old_file);
187 g_free (tmp_file);
188
189 return retval;
190}
191
192void
193egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
194 const char *xml_file,
195 const char *version)
196{
197 xmlDocPtr doc;
198 xmlNodePtr root;
199
200 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
201
202 doc = egg_toolbars_model_to_xml (model);
203 root = xmlDocGetRootElement (doc);
204 xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) version);
205 safe_save_xml (xml_file, doc);
206 xmlFreeDoc (doc);
207}
208
209static gboolean
210is_unique (EggToolbarsModel *model,
211 EggToolbarsItem *idata)
212{
213 EggToolbarsItem *idata2;
214 GNode *toolbar, *item;
215
216
217 for(toolbar = g_node_first_child (model->priv->toolbars)((model->priv->toolbars) ? ((GNode*) (model->priv->
toolbars))->children : ((void*)0))
;
218 toolbar != NULL((void*)0); toolbar = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0)))
219 {
220 for(item = g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0));
221 item != NULL((void*)0); item = g_node_next_sibling (item)((item) ? ((GNode*) (item))->next : ((void*)0)))
222 {
223 idata2 = item->data;
224
225 if (idata != idata2 && strcmp (idata->name, idata2->name) == 0)
226 {
227 return FALSE(0);
228 }
229 }
230 }
231
232 return TRUE(!(0));
233}
234
235static GNode *
236toolbar_node_new (const char *name)
237{
238 EggToolbarsToolbar *toolbar;
239
240 toolbar = g_new (EggToolbarsToolbar, 1)((EggToolbarsToolbar *) g_malloc_n ((1), sizeof (EggToolbarsToolbar
)))
;
241 toolbar->name = g_strdup (name);
242 toolbar->flags = 0;
243
244 return g_node_new (toolbar);
245}
246
247static GNode *
248item_node_new (const char *name, EggToolbarsModel *model)
249{
250 EggToolbarsItem *item;
251 int flags;
252
253 g_return_val_if_fail (name != NULL, NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
(((void*)0)); } } while (0)
;
254
255 item = g_new (EggToolbarsItem, 1)((EggToolbarsItem *) g_malloc_n ((1), sizeof (EggToolbarsItem
)))
;
256 item->name = g_strdup (name);
257
258 flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, item->name)))
;
259 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
260 g_hash_table_insert (model->priv->flags,
261 g_strdup (item->name),
262 GINT_TO_POINTER (flags | EGG_TB_MODEL_NAME_USED)((gpointer) (glong) (flags | EGG_TB_MODEL_NAME_USED)));
263
264 return g_node_new (item);
265}
266
267static void
268item_node_free (GNode *item_node, EggToolbarsModel *model)
269{
270 EggToolbarsItem *item = item_node->data;
271 int flags;
272
273 flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, item->name)))
;
274 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0 && is_unique (model, item))
275 g_hash_table_insert (model->priv->flags,
276 g_strdup (item->name),
277 GINT_TO_POINTER (flags & ~EGG_TB_MODEL_NAME_USED)((gpointer) (glong) (flags & ~EGG_TB_MODEL_NAME_USED)));
278
279 g_free (item->name);
280 g_free (item);
281
282 g_node_destroy (item_node);
283}
284
285static void
286toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
287{
288 EggToolbarsToolbar *toolbar = toolbar_node->data;
289
290 g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
291 (GNodeForeachFunc) item_node_free, model);
292
293 g_free (toolbar->name);
294 g_free (toolbar);
295
296 g_node_destroy (toolbar_node);
297}
298
299EggTbModelFlags
300egg_toolbars_model_get_flags (EggToolbarsModel *model,
301 int toolbar_position)
302{
303 GNode *toolbar_node;
304 EggToolbarsToolbar *toolbar;
305
306 toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
307 g_return_val_if_fail (toolbar_node != NULL, 0)do { if ((toolbar_node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar_node != NULL"
); return (0); } } while (0)
;
308
309 toolbar = toolbar_node->data;
310
311 return toolbar->flags;
312}
313
314void
315egg_toolbars_model_set_flags (EggToolbarsModel *model,
316 int toolbar_position,
317 EggTbModelFlags flags)
318{
319 GNode *toolbar_node;
320 EggToolbarsToolbar *toolbar;
321
322 toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
323 g_return_if_fail (toolbar_node != NULL)do { if ((toolbar_node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar_node != NULL"
); return; } } while (0)
;
324
325 toolbar = toolbar_node->data;
326
327 toolbar->flags = flags;
328
329 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_CHANGED],
330 0, toolbar_position);
331}
332
333
334char *
335egg_toolbars_model_get_data (EggToolbarsModel *model,
336 GdkAtom type,
337 const char *name)
338{
339 EggToolbarsItemType *t;
340 char *data = NULL((void*)0);
341 GList *l;
342
343 if (type == GDK_NONE((GdkAtom)((gpointer) (gulong) (0))) || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE"application/x-toolbar-item", FALSE(0)))
344 {
345 g_return_val_if_fail (name != NULL, NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
(((void*)0)); } } while (0)
;
346 g_return_val_if_fail (*name != 0, NULL)do { if ((*name != 0)) { } else { g_return_if_fail_warning ((
(gchar*) 0), ((const char*) (__func__)), "*name != 0"); return
(((void*)0)); } } while (0)
;
347 return strdup (name);
348 }
349
350 for (l = model->priv->types; l != NULL((void*)0); l = l->next)
351 {
352 t = l->data;
353 if (t->type == type && t->get_data != NULL((void*)0))
354 {
355 data = t->get_data (t, name);
356 if (data != NULL((void*)0)) break;
357 }
358 }
359
360 return data;
361}
362
363char *
364egg_toolbars_model_get_name (EggToolbarsModel *model,
365 GdkAtom type,
366 const char *data,
367 gboolean create)
368{
369 EggToolbarsItemType *t;
370 char *name = NULL((void*)0);
371 GList *l;
372
373 if (type == GDK_NONE((GdkAtom)((gpointer) (gulong) (0))) || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE"application/x-toolbar-item", FALSE(0)))
374 {
375 g_return_val_if_fail (data, NULL)do { if ((data)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "data"); return (((void*)0
)); } } while (0)
;
376 g_return_val_if_fail (*data, NULL)do { if ((*data)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "*data"); return (((void*)
0)); } } while (0)
;
377 return strdup (data);
378 }
379
380 if (create)
381 {
382 for (l = model->priv->types; name == NULL((void*)0) && l != NULL((void*)0); l = l->next)
383 {
384 t = l->data;
385 if (t->type == type && t->new_name != NULL((void*)0))
386 name = t->new_name (t, data);
387 }
388
389 return name;
390 }
391 else
392 {
393 for (l = model->priv->types; name == NULL((void*)0) && l != NULL((void*)0); l = l->next)
394 {
395 t = l->data;
396 if (t->type == type && t->get_name != NULL((void*)0))
397 name = t->get_name (t, data);
398 }
399
400 return name;
401 }
402}
403
404static gboolean
405impl_add_item (EggToolbarsModel *model,
406 int toolbar_position,
407 int position,
408 const char *name)
409{
410 GNode *parent_node;
411 GNode *child_node;
412 int real_position;
413
414 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
((0)); } } while (0)
;
415 g_return_val_if_fail (name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
((0)); } } while (0)
;
416
417 parent_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
418 child_node = item_node_new (name, model);
419 g_node_insert (parent_node, position, child_node);
420
421 real_position = g_node_child_position (parent_node, child_node);
422
423 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[ITEM_ADDED], 0,
424 toolbar_position, real_position);
425
426 return TRUE(!(0));
427}
428
429gboolean
430egg_toolbars_model_add_item (EggToolbarsModel *model,
431 int toolbar_position,
432 int position,
433 const char *name)
434{
435 EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (model)((((EggToolbarsModelClass*) (((GTypeInstance*) ((model)))->
g_class))))
;
436 return klass->add_item (model, toolbar_position, position, name);
437}
438
439int
440egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
441 int position,
442 const char *name)
443{
444 GNode *node;
445 int real_position;
446
447 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
(-1); } } while (0)
;
448
449 node = toolbar_node_new (name);
450 g_node_insert (model->priv->toolbars, position, node);
451
452 real_position = g_node_child_position (model->priv->toolbars, node);
453
454 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_ADDED],
455 0, real_position);
456
457 return g_node_child_position (model->priv->toolbars, node);
458}
459
460static char *
461parse_data_list (EggToolbarsModel *model,
462 xmlNodePtr child,
463 gboolean create)
464{
465 char *name = NULL((void*)0);
466 while (child && name == NULL((void*)0))
467 {
468 if (xmlStrEqual (child->name, (const xmlChar*) "data"))
469 {
470 xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
471 xmlChar *data = xmlNodeGetContent (child);
472
473 if (type != NULL((void*)0))
474 {
475 GdkAtom atom = gdk_atom_intern ((const char*) type, TRUE(!(0)));
476 name = egg_toolbars_model_get_name (model, atom, (const char*) data, create);
477 }
478
479 xmlFree (type);
480 xmlFree (data);
481 }
482
483 child = child->next;
484 }
485
486 return name;
487}
488
489static void
490parse_item_list (EggToolbarsModel *model,
491 xmlNodePtr child,
492 int position)
493{
494 while (child)
495 {
496 if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
497 {
498 char *name;
499
500 /* Try to get the name using the data elements first,
501 as they are more 'portable' or 'persistent'. */
502 name = parse_data_list (model, child->children, FALSE(0));
503 if (name == NULL((void*)0))
504 {
505 name = parse_data_list (model, child->children, TRUE(!(0)));
506 }
507
508 /* If that fails, try to use the name. */
509 if (name == NULL((void*)0))
510 {
511 xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
512 xmlChar *data = xmlGetProp (child, (const xmlChar*) "name");
513 GdkAtom atom = type ? gdk_atom_intern ((const char*) type, TRUE(!(0))) : GDK_NONE((GdkAtom)((gpointer) (gulong) (0)));
514
515 /* If an old format, try to use it. */
516 name = egg_toolbars_model_get_name (model, atom, (const char*) data, FALSE(0));
517 if (name == NULL((void*)0))
518 {
519 name = egg_toolbars_model_get_name (model, atom, (const char*) data, TRUE(!(0)));
520 }
521
522 xmlFree (type);
523 xmlFree (data);
524 }
525
526 if (name != NULL((void*)0))
527 {
528 egg_toolbars_model_add_item (model, position, -1, name);
529 g_free (name);
530 }
531 }
532 else if (xmlStrEqual (child->name, (const xmlChar*) "separator"))
533 {
534 egg_toolbars_model_add_item (model, position, -1, "_separator");
535 }
536
537 child = child->next;
538 }
539}
540
541static void
542parse_toolbars (EggToolbarsModel *model,
543 xmlNodePtr child)
544{
545 while (child)
546 {
547 if (xmlStrEqual (child->name, (const xmlChar*) "toolbar"))
548 {
549 xmlChar *string;
550 int position;
551 EggTbModelFlags flags;
552
553 string = xmlGetProp (child, (const xmlChar*) "name");
554 position = egg_toolbars_model_add_toolbar (model, -1, (const char*) string);
555 flags = egg_toolbars_model_get_flags (model, position);
556 xmlFree (string);
557
558 string = xmlGetProp (child, (const xmlChar*) "editable");
559 if (string && xmlStrEqual (string, (const xmlChar*) "false"))
560 flags |= EGG_TB_MODEL_NOT_EDITABLE;
561 xmlFree (string);
562
563 string = xmlGetProp (child, (const xmlChar*) "hidden");
564 if (string && xmlStrEqual (string, (const xmlChar*) "true"))
565 flags |= EGG_TB_MODEL_HIDDEN;
566 xmlFree (string);
567
568 string = xmlGetProp (child, (const xmlChar*) "style");
569 if (string && xmlStrEqual (string, (const xmlChar*) "icons-only"))
570 flags |= EGG_TB_MODEL_ICONS;
571 xmlFree (string);
572
573 egg_toolbars_model_set_flags (model, position, flags);
574
575 parse_item_list (model, child->children, position);
576 }
577
578 child = child->next;
579 }
580}
581
582gboolean
583egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
584 const char *xml_file)
585{
586 xmlDocPtr doc;
587 xmlNodePtr root;
588
589 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
((0)); } } while (0)
;
590
591 if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE(0);
592
593 doc = xmlParseFile (xml_file);
594 if (doc == NULL((void*)0))
595 {
596 g_warning ("Failed to load XML data from %s", xml_file);
597 return FALSE(0);
598 }
599 root = xmlDocGetRootElement (doc);
600
601 parse_toolbars (model, root->children);
602
603 xmlFreeDoc (doc);
604
605 return TRUE(!(0));
606}
607
608static void
609parse_available_list (EggToolbarsModel *model,
610 xmlNodePtr child)
611{
612 gint flags;
613
614 while (child)
615 {
616 if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
617 {
618 xmlChar *name;
619
620 name = xmlGetProp (child, (const xmlChar*) "name");
621 flags = egg_toolbars_model_get_name_flags
622 (model, (const char*)name);
623 egg_toolbars_model_set_name_flags
624 (model, (const char*)name, flags | EGG_TB_MODEL_NAME_KNOWN);
625 xmlFree (name);
626 }
627 child = child->next;
628 }
629}
630
631static void
632parse_names (EggToolbarsModel *model,
633 xmlNodePtr child)
634{
635 while (child)
636 {
637 if (xmlStrEqual (child->name, (const xmlChar*) "available"))
638 {
639 parse_available_list (model, child->children);
640 }
641
642 child = child->next;
643 }
644}
645
646gboolean
647egg_toolbars_model_load_names (EggToolbarsModel *model,
648 const char *xml_file)
649{
650 xmlDocPtr doc;
651 xmlNodePtr root;
652
653 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
((0)); } } while (0)
;
654
655 if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE(0);
656
657 doc = xmlParseFile (xml_file);
658 if (doc == NULL((void*)0))
659 {
660 g_warning ("Failed to load XML data from %s", xml_file);
661 return FALSE(0);
662 }
663 root = xmlDocGetRootElement (doc);
664
665 parse_names (model, root->children);
666
667 xmlFreeDoc (doc);
668
669 return TRUE(!(0));
670}
671
672static void
673egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
674{
675 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((klass
)), (((GType) ((20) << (2))))))))
;
676
677 object_class->finalize = egg_toolbars_model_finalize;
678
679 klass->add_item = impl_add_item;
680
681 signals[ITEM_ADDED] =
682 g_signal_new ("item_added",
683 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
684 G_SIGNAL_RUN_LAST,
685 G_STRUCT_OFFSET (EggToolbarsModelClass, item_added)((glong) __builtin_offsetof(EggToolbarsModelClass, item_added
))
,
686 NULL((void*)0), NULL((void*)0), _egg_marshal_VOID__INT_INT,
687 G_TYPE_NONE((GType) ((1) << (2))), 2, G_TYPE_INT((GType) ((6) << (2))), G_TYPE_INT((GType) ((6) << (2))));
688 signals[TOOLBAR_ADDED] =
689 g_signal_new ("toolbar_added",
690 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
691 G_SIGNAL_RUN_LAST,
692 G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_added)((glong) __builtin_offsetof(EggToolbarsModelClass, toolbar_added
))
,
693 NULL((void*)0), NULL((void*)0), g_cclosure_marshal_VOID__INT,
694 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_INT((GType) ((6) << (2))));
695 signals[ITEM_REMOVED] =
696 g_signal_new ("item_removed",
697 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
698 G_SIGNAL_RUN_LAST,
699 G_STRUCT_OFFSET (EggToolbarsModelClass, item_removed)((glong) __builtin_offsetof(EggToolbarsModelClass, item_removed
))
,
700 NULL((void*)0), NULL((void*)0), _egg_marshal_VOID__INT_INT,
701 G_TYPE_NONE((GType) ((1) << (2))), 2, G_TYPE_INT((GType) ((6) << (2))), G_TYPE_INT((GType) ((6) << (2))));
702 signals[TOOLBAR_REMOVED] =
703 g_signal_new ("toolbar_removed",
704 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
705 G_SIGNAL_RUN_LAST,
706 G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_removed)((glong) __builtin_offsetof(EggToolbarsModelClass, toolbar_removed
))
,
707 NULL((void*)0), NULL((void*)0), g_cclosure_marshal_VOID__INT,
708 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_INT((GType) ((6) << (2))));
709 signals[TOOLBAR_CHANGED] =
710 g_signal_new ("toolbar_changed",
711 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
712 G_SIGNAL_RUN_LAST,
713 G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_changed)((glong) __builtin_offsetof(EggToolbarsModelClass, toolbar_changed
))
,
714 NULL((void*)0), NULL((void*)0), g_cclosure_marshal_VOID__INT,
715 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_INT((GType) ((6) << (2))));
716}
717
718static void
719egg_toolbars_model_init (EggToolbarsModel *model)
720{
721 model->priv = egg_toolbars_model_get_instance_private (model);
722
723 model->priv->toolbars = g_node_new (NULL((void*)0));
724 model->priv->flags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
725 egg_toolbars_model_set_name_flags (model, "_separator",
726 EGG_TB_MODEL_NAME_KNOWN |
727 EGG_TB_MODEL_NAME_INFINITE);
728}
729
730static void
731egg_toolbars_model_finalize (GObject *object)
732{
733 EggToolbarsModel *model = EGG_TOOLBARS_MODEL (object)((((EggToolbarsModel*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((egg_toolbars_model_get_type ()))))))
;
734
735 g_node_children_foreach (model->priv->toolbars, G_TRAVERSE_ALL,
736 (GNodeForeachFunc) toolbar_node_free, model);
737 g_node_destroy (model->priv->toolbars);
738 g_hash_table_destroy (model->priv->flags);
739
740 G_OBJECT_CLASS (egg_toolbars_model_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((egg_toolbars_model_parent_class
)), (((GType) ((20) << (2))))))))
->finalize (object);
741}
742
743EggToolbarsModel *
744egg_toolbars_model_new (void)
745{
746 return EGG_TOOLBARS_MODEL (g_object_new (EGG_TYPE_TOOLBARS_MODEL, NULL))((((EggToolbarsModel*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((egg_toolbars_model_get_type ()), ((void*)
0)))), ((egg_toolbars_model_get_type ()))))))
;
747}
748
749void
750egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
751 int position)
752{
753 GNode *node;
754 EggTbModelFlags flags;
755
756 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
757
758 flags = egg_toolbars_model_get_flags (model, position);
759
760 if (!(flags & EGG_TB_MODEL_NOT_REMOVABLE))
761 {
762 node = g_node_nth_child (model->priv->toolbars, position);
763 g_return_if_fail (node != NULL)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "node != NULL"); return
; } } while (0)
;
764
765 toolbar_node_free (node, model);
766
767 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_REMOVED],
768 0, position);
769 }
770}
771
772void
773egg_toolbars_model_remove_item (EggToolbarsModel *model,
774 int toolbar_position,
775 int position)
776{
777 GNode *node, *toolbar;
778
779 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
780
781 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
782 g_return_if_fail (toolbar != NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return; } } while (0)
;
783
784 node = g_node_nth_child (toolbar, position);
785 g_return_if_fail (node != NULL)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "node != NULL"); return
; } } while (0)
;
786
787 item_node_free (node, model);
788
789 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[ITEM_REMOVED], 0,
790 toolbar_position, position);
791}
792
793void
794egg_toolbars_model_move_item (EggToolbarsModel *model,
795 int toolbar_position,
796 int position,
797 int new_toolbar_position,
798 int new_position)
799{
800 GNode *node, *toolbar, *new_toolbar;
801
802 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
803
804 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
805 g_return_if_fail (toolbar != NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return; } } while (0)
;
806
807 new_toolbar = g_node_nth_child (model->priv->toolbars, new_toolbar_position);
808 g_return_if_fail (new_toolbar != NULL)do { if ((new_toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "new_toolbar != NULL"
); return; } } while (0)
;
809
810 node = g_node_nth_child (toolbar, position);
811 g_return_if_fail (node != NULL)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "node != NULL"); return
; } } while (0)
;
812
813 g_node_unlink (node);
814
815 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[ITEM_REMOVED], 0,
816 toolbar_position, position);
817
818 g_node_insert (new_toolbar, new_position, node);
819
820 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
, signals[ITEM_ADDED], 0,
821 new_toolbar_position, new_position);
822}
823
824void
825egg_toolbars_model_delete_item (EggToolbarsModel *model,
826 const char *name)
827{
828 EggToolbarsItem *idata;
829 EggToolbarsToolbar *tdata;
830 GNode *toolbar, *item, *next;
831 int tpos, ipos;
832
833 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
834
835 toolbar = g_node_first_child (model->priv->toolbars)((model->priv->toolbars) ? ((GNode*) (model->priv->
toolbars))->children : ((void*)0))
;
836 tpos = 0;
837
838 while (toolbar != NULL((void*)0))
839 {
840 item = g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0));
841 ipos = 0;
842
843 /* Don't delete toolbars that were already empty */
844 if (item == NULL((void*)0))
845 {
846 toolbar = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0));
847 continue;
848 }
849
850 while (item != NULL((void*)0))
851 {
852 next = g_node_next_sibling (item)((item) ? ((GNode*) (item))->next : ((void*)0));
853 idata = item->data;
854 if (strcmp (idata->name, name) == 0)
855 {
856 item_node_free (item, model);
857 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
,
858 signals[ITEM_REMOVED],
859 0, tpos, ipos);
860 }
861 else
862 {
863 ipos++;
864 }
865
866 item = next;
867 }
868
869 next = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0));
870 tdata = toolbar->data;
871 if (!(tdata->flags & EGG_TB_MODEL_NOT_REMOVABLE) &&
872 g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0)) == NULL((void*)0))
873 {
874 toolbar_node_free (toolbar, model);
875
876 g_signal_emit (G_OBJECT (model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
,
877 signals[TOOLBAR_REMOVED],
878 0, tpos);
879 }
880 else
881 {
882 tpos++;
883 }
884
885 toolbar = next;
886 }
887}
888
889int
890egg_toolbars_model_n_items (EggToolbarsModel *model,
891 int toolbar_position)
892{
893 GNode *toolbar;
894
895 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
896 g_return_val_if_fail (toolbar != NULL, -1)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return (-1); } } while (0)
;
897
898 return g_node_n_children (toolbar);
899}
900
901const char *
902egg_toolbars_model_item_nth (EggToolbarsModel *model,
903 int toolbar_position,
904 int position)
905{
906 GNode *toolbar;
907 GNode *item;
908 EggToolbarsItem *idata;
909
910 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
911 g_return_val_if_fail (toolbar != NULL, NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return (((void*)0)); } } while (0)
;
912
913 item = g_node_nth_child (toolbar, position);
914 g_return_val_if_fail (item != NULL, NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "item != NULL"); return
(((void*)0)); } } while (0)
;
915
916 idata = item->data;
917 return idata->name;
918}
919
920int
921egg_toolbars_model_n_toolbars (EggToolbarsModel *model)
922{
923 return g_node_n_children (model->priv->toolbars);
924}
925
926const char *
927egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
928 int position)
929{
930 GNode *toolbar;
931 EggToolbarsToolbar *tdata;
932
933 toolbar = g_node_nth_child (model->priv->toolbars, position);
934 g_return_val_if_fail (toolbar != NULL, NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return (((void*)0)); } } while (0)
;
935
936 tdata = toolbar->data;
937
938 return tdata->name;
939}
940
941GList *
942egg_toolbars_model_get_types (EggToolbarsModel *model)
943{
944 return model->priv->types;
945}
946
947void
948egg_toolbars_model_set_types (EggToolbarsModel *model, GList *types)
949{
950 model->priv->types = types;
951}
952
953static void
954fill_avail_array (gpointer key, gpointer value, GPtrArray *array)
955{
956 int flags = GPOINTER_TO_INT (value)((gint) (glong) (value));
957 if ((flags & EGG_TB_MODEL_NAME_KNOWN) && !(flags & EGG_TB_MODEL_NAME_USED))
958 g_ptr_array_add (array, key);
959}
960
961GPtrArray *
962egg_toolbars_model_get_name_avail (EggToolbarsModel *model)
963{
964 GPtrArray *array = g_ptr_array_new ();
965 g_hash_table_foreach (model->priv->flags, (GHFunc) fill_avail_array, array);
966 return array;
967}
968
969gint
970egg_toolbars_model_get_name_flags (EggToolbarsModel *model, const char *name)
971{
972 return GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, name)))
;
973}
974
975void
976egg_toolbars_model_set_name_flags (EggToolbarsModel *model, const char *name, gint flags)
977{
978 g_hash_table_insert (model->priv->flags, g_strdup (name), GINT_TO_POINTER (flags)((gpointer) (glong) (flags)));
979}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-be481a.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-be481a.html new file mode 100644 index 0000000..b3c0d6e --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-be481a.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 423, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
This statement is never executed
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-d1edab.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-d1edab.html new file mode 100644 index 0000000..0627284 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-d1edab.html @@ -0,0 +1,6190 @@ + + + +eom-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-window.c
Warning:line 2520, column 2
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 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-window.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-window.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of Mate - Main Window
2 *
3 * Copyright (C) 2000-2008 The Free Software Foundation
4 *
5 * Author: Lucas Rocha <lucasr@gnome.org>
6 *
7 * Based on code by:
8 * - Federico Mena-Quintero <federico@gnu.org>
9 * - Jens Finke <jens@gnome.org>
10 * Based on evince code (shell/ev-window.c) by:
11 * - Martin Kretzschmar <martink@gnome.org>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27
28#ifdef HAVE_CONFIG_H1
29#include "config.h"
30#endif
31
32#include <math.h>
33
34#include "eom-window.h"
35#include "eom-scroll-view.h"
36#include "eom-debug.h"
37#include "eom-file-chooser.h"
38#include "eom-thumb-view.h"
39#include "eom-list-store.h"
40#include "eom-sidebar.h"
41#include "eom-statusbar.h"
42#include "eom-preferences-dialog.h"
43#include "eom-properties-dialog.h"
44#include "eom-print.h"
45#include "eom-error-message-area.h"
46#include "eom-application.h"
47#include "eom-application-internal.h"
48#include "eom-thumb-nav.h"
49#include "eom-config-keys.h"
50#include "eom-job-queue.h"
51#include "eom-jobs.h"
52#include "eom-util.h"
53#include "eom-save-as-dialog-helper.h"
54#include "eom-close-confirmation-dialog.h"
55#include "eom-clipboard-handler.h"
56#include "eom-window-activatable.h"
57#include "eom-metadata-sidebar.h"
58
59#include "eom-enum-types.h"
60
61#include "egg-toolbar-editor.h"
62#include "egg-editable-toolbar.h"
63#include "egg-toolbars-model.h"
64
65#include <glib.h>
66#include <glib-object.h>
67#include <glib/gi18n.h>
68#include <gio/gio.h>
69#include <gdk/gdkkeysyms.h>
70#include <gio/gdesktopappinfo.h>
71#include <gtk/gtk.h>
72
73#include <libpeas/peas-extension-set.h>
74#include <libpeas/peas-activatable.h>
75
76#if HAVE_LCMS1
77#include <X11/Xlib.h>
78#include <X11/Xatom.h>
79#ifdef GDK_WINDOWING_X11
80#include <gdk/gdkx.h>
81#endif
82#include <lcms2.h>
83#endif
84
85#define MATE_DESKTOP_USE_UNSTABLE_API
86#include <libmate-desktop/mate-desktop-utils.h>
87
88#define EOM_WINDOW_MIN_WIDTH440 440
89#define EOM_WINDOW_MIN_HEIGHT350 350
90
91#define EOM_WINDOW_DEFAULT_WIDTH540 540
92#define EOM_WINDOW_DEFAULT_HEIGHT450 450
93
94#define EOM_WINDOW_FULLSCREEN_TIMEOUT5 * 1000 5 * 1000
95#define EOM_WINDOW_FULLSCREEN_POPUP_THRESHOLD5 5
96
97#define EOM_RECENT_FILES_GROUP"Graphics" "Graphics"
98#define EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer" "Eye of MATE Image Viewer"
99#define EOM_RECENT_FILES_LIMIT5 5
100
101#define EOM_WALLPAPER_FILENAME"eom-wallpaper" "eom-wallpaper"
102
103#define is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
104
105typedef enum {
106 EOM_WINDOW_STATUS_UNKNOWN,
107 EOM_WINDOW_STATUS_INIT,
108 EOM_WINDOW_STATUS_NORMAL
109} EomWindowStatus;
110
111enum {
112 PROP_0,
113 PROP_COLLECTION_POS,
114 PROP_COLLECTION_RESIZABLE,
115 PROP_STARTUP_FLAGS
116};
117
118enum {
119 SIGNAL_PREPARED,
120 SIGNAL_LAST
121};
122
123static guint signals[SIGNAL_LAST] = { 0 };
124
125struct _EomWindowPrivate {
126 GSettings *view_settings;
127 GSettings *ui_settings;
128 GSettings *fullscreen_settings;
129 GSettings *lockdown_settings;
130
131 EomListStore *store;
132 EomImage *image;
133 EomWindowMode mode;
134 EomWindowStatus status;
135
136 GtkUIManager *ui_mgr;
137 GtkWidget *box;
138 GtkWidget *layout;
139 GtkWidget *cbox;
140 GtkWidget *view;
141 GtkWidget *sidebar;
142 GtkWidget *thumbview;
143 GtkWidget *statusbar;
144 GtkWidget *nav;
145 GtkWidget *message_area;
146 GtkWidget *toolbar;
147 GtkWidget *properties_dlg;
148
149 GtkActionGroup *actions_window;
150 GtkActionGroup *actions_image;
151 GtkActionGroup *actions_collection;
152 GtkActionGroup *actions_recent;
153
154 GtkWidget *fullscreen_popup;
155 GSource *fullscreen_timeout_source;
156
157 gboolean slideshow_random;
158 gboolean slideshow_loop;
159 gint slideshow_switch_timeout;
160 GSource *slideshow_switch_source;
161
162 guint fullscreen_idle_inhibit_cookie;
163
164 guint recent_menu_id;
165
166 EomJob *load_job;
167 EomJob *transform_job;
168 EomJob *save_job;
169 GFile *last_save_as_folder;
170 EomJob *copy_job;
171
172 guint image_info_message_cid;
173 guint tip_message_cid;
174 guint copy_file_cid;
175
176 EomStartupFlags flags;
177 GSList *file_list;
178
179 EomWindowCollectionPos collection_position;
180 gboolean collection_resizable;
181
182 GtkActionGroup *actions_open_with;
183 guint open_with_menu_id;
184
185 gboolean save_disabled;
186 gboolean needs_reload_confirmation;
187
188 GtkPageSetup *page_setup;
189
190 PeasExtensionSet *extensions;
191
192#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
193 cmsHPROFILE *display_profile;
194#endif
195};
196
197G_DEFINE_TYPE_WITH_PRIVATE (EomWindow, eom_window, GTK_TYPE_APPLICATION_WINDOW)static void eom_window_init (EomWindow *self); static void eom_window_class_init
(EomWindowClass *klass); static GType eom_window_get_type_once
(void); static gpointer eom_window_parent_class = ((void*)0)
; static gint EomWindow_private_offset; static void eom_window_class_intern_init
(gpointer klass) { eom_window_parent_class = g_type_class_peek_parent
(klass); if (EomWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomWindow_private_offset); eom_window_class_init
((EomWindowClass*) klass); } __attribute__((__unused__)) static
inline gpointer eom_window_get_instance_private (EomWindow *
self) { return (((gpointer) ((guint8*) (self) + (glong) (EomWindow_private_offset
)))); } GType eom_window_get_type (void) { static volatile gsize
g_define_type_id__volatile = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer
), "Expression evaluates to false"); (void) (0 ? (gpointer) *
(&g_define_type_id__volatile) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_window_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_application_window_get_type ()), g_intern_static_string
("EomWindow"), sizeof (EomWindowClass), (GClassInitFunc)(void
(*)(void)) eom_window_class_intern_init, sizeof (EomWindow),
(GInstanceInitFunc)(void (*)(void)) eom_window_init, (GTypeFlags
) 0); { {{ EomWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EomWindowPrivate)); };} } return g_define_type_id
; }
;
198
199static void eom_window_cmd_fullscreen (GtkAction *action, gpointer user_data);
200static void eom_window_run_fullscreen (EomWindow *window, gboolean slideshow);
201static void eom_window_cmd_slideshow (GtkAction *action, gpointer user_data);
202static void eom_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data);
203static void eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow);
204static void eom_job_load_cb (EomJobLoad *job, gpointer data);
205static void eom_job_save_progress_cb (EomJobSave *job, float progress, gpointer data);
206static void eom_job_progress_cb (EomJobLoad *job, float progress, gpointer data);
207static void eom_job_transform_cb (EomJobTransform *job, gpointer data);
208static void fullscreen_set_timeout (EomWindow *window);
209static void fullscreen_clear_timeout (EomWindow *window);
210static void update_action_groups_state (EomWindow *window);
211static void open_with_launch_application_cb (GtkAction *action, gpointer callback_data);
212static void eom_window_update_openwith_menu (EomWindow *window, EomImage *image);
213static void eom_window_list_store_image_added (GtkTreeModel *tree_model,
214 GtkTreePath *path,
215 GtkTreeIter *iter,
216 gpointer user_data);
217static void eom_window_list_store_image_removed (GtkTreeModel *tree_model,
218 GtkTreePath *path,
219 gpointer user_data);
220static void eom_window_set_wallpaper (EomWindow *window, const gchar *filename, const gchar *visible_filename);
221static gboolean eom_window_save_images (EomWindow *window, GList *images);
222static void disconnect_proxy_cb (GtkUIManager *manager,
223 GtkAction *action,
224 GtkWidget *proxy,
225 EomWindow *window);
226static void eom_window_finish_saving (EomWindow *window);
227static GAppInfo *get_appinfo_for_editor (EomWindow *window);
228
229static GQuark
230eom_window_error_quark (void)
231{
232 static GQuark q = 0;
233
234 if (q == 0)
235 q = g_quark_from_static_string ("eom-window-error-quark");
236
237 return q;
238}
239
240static void
241eom_window_set_collection_mode (EomWindow *window, EomWindowCollectionPos position, gboolean resizable)
242{
243 EomWindowPrivate *priv;
244 GtkWidget *hpaned;
245 EomThumbNavMode mode = EOM_THUMB_NAV_MODE_ONE_ROW;
246
247 eom_debug (DEBUG_PREFERENCESEOM_DEBUG_PREFERENCES, "eom-window.c", 247, ((const char*) (__func__
))
);
248
249 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
250
251 priv = window->priv;
252
253 if (priv->collection_position == position &&
254 priv->collection_resizable == resizable)
255 return;
256
257 priv->collection_position = position;
258 priv->collection_resizable = resizable;
259
260 hpaned = gtk_widget_get_parent (priv->sidebar);
261
262 g_object_ref (hpaned);
263 g_object_ref (priv->nav);
264
265 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_container_get_type ()))))))
, hpaned);
266 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_container_get_type ()))))))
, priv->nav);
267
268 gtk_widget_destroy (priv->layout);
269
270 switch (position) {
271 case EOM_WINDOW_COLLECTION_POS_BOTTOM:
272 case EOM_WINDOW_COLLECTION_POS_TOP:
273 if (resizable) {
274 mode = EOM_THUMB_NAV_MODE_MULTIPLE_ROWS;
275
276 priv->layout = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
277
278 if (position == EOM_WINDOW_COLLECTION_POS_BOTTOM) {
279 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
280 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
281 } else {
282 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
283 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
284 }
285 } else {
286 mode = EOM_THUMB_NAV_MODE_ONE_ROW;
287
288 priv->layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
289
290 if (position == EOM_WINDOW_COLLECTION_POS_BOTTOM) {
291 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
292 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
293 } else {
294 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
295 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
296 }
297 }
298 break;
299
300 case EOM_WINDOW_COLLECTION_POS_LEFT:
301 case EOM_WINDOW_COLLECTION_POS_RIGHT:
302 if (resizable) {
303 mode = EOM_THUMB_NAV_MODE_MULTIPLE_COLUMNS;
304
305 priv->layout = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
306
307 if (position == EOM_WINDOW_COLLECTION_POS_LEFT) {
308 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
309 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
310 } else {
311 gtk_paned_pack1 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, hpaned, TRUE(!(0)), FALSE(0));
312 gtk_paned_pack2 (GTK_PANED (priv->layout)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->layout)), ((gtk_paned_get_type ()))))))
, priv->nav, FALSE(0), TRUE(!(0)));
313 }
314 } else {
315 mode = EOM_THUMB_NAV_MODE_ONE_COLUMN;
316
317 priv->layout = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
318
319 if (position == EOM_WINDOW_COLLECTION_POS_LEFT) {
320 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
321 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
322 } else {
323 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
324 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
325 }
326 }
327
328 break;
329 }
330
331 gtk_box_pack_end (GTK_BOX (priv->cbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->cbox)), ((gtk_box_get_type ()))))))
, priv->layout, TRUE(!(0)), TRUE(!(0)), 0);
332
333 eom_thumb_nav_set_mode (EOM_THUMB_NAV (priv->nav)((((EomThumbNav*) g_type_check_instance_cast ((GTypeInstance*
) ((priv->nav)), ((eom_thumb_nav_get_type ()))))))
, mode);
334
335 if (priv->mode != EOM_WINDOW_MODE_UNKNOWN) {
336 update_action_groups_state (window);
337 }
338}
339
340static void
341eom_window_can_save_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
342{
343 EomWindowPrivate *priv;
344 EomWindow *window;
345 gboolean save_disabled = FALSE(0);
346 GtkAction *action_save, *action_save_as;
347
348 eom_debug (DEBUG_PREFERENCESEOM_DEBUG_PREFERENCES, "eom-window.c", 348, ((const char*) (__func__
))
);
349
350 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
351
352 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
353 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
354
355 save_disabled = g_settings_get_boolean (settings, key);
356
357 priv->save_disabled = save_disabled;
358
359 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
360 action_save =
361 gtk_action_group_get_action (priv->actions_image, "ImageSave");
362 action_save_as =
363 gtk_action_group_get_action (priv->actions_image, "ImageSaveAs");
364
365 if (priv->save_disabled) {
366 gtk_action_set_sensitive (action_save, FALSE(0));
367 gtk_action_set_sensitive (action_save_as, FALSE(0));
368 } else {
369 EomImage *image = eom_window_get_image (window);
370
371 if (EOM_IS_IMAGE (image)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(image)); GType __t = ((eom_image_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; }))))
) {
372 gtk_action_set_sensitive (action_save,
373 eom_image_is_modified (image));
374
375 gtk_action_set_sensitive (action_save_as, TRUE(!(0)));
376 }
377 }
378 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
379}
380
381#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
382static cmsHPROFILE *
383eom_window_get_display_profile (GdkScreen *screen)
384{
385 Display *dpy;
386 Atom icc_atom, type;
387 int format;
388 gulong nitems;
389 gulong bytes_after;
390 gulong length;
391 guchar *str;
392 int result;
393 cmsHPROFILE *profile = NULL((void*)0);
394 char *atom_name;
395
396 if (!GDK_IS_X11_SCREEN (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((gdk_x11_screen_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; }))))
) {
397 return NULL((void*)0);
398 }
399
400 dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen))(gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen
)))
;
401
402 if (gdk_x11_screen_get_screen_number (screen) > 0)
403 atom_name = g_strdup_printf ("_ICC_PROFILE_%d", gdk_x11_screen_get_screen_number (screen));
404 else
405 atom_name = g_strdup ("_ICC_PROFILE");
406
407 icc_atom = gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen), atom_name);
408
409 g_free (atom_name);
410
411 result = XGetWindowProperty (dpy,
412 GDK_WINDOW_XID (gdk_screen_get_root_window (screen))(gdk_x11_window_get_xid (gdk_screen_get_root_window (screen))
)
,
413 icc_atom,
414 0,
415 G_MAXLONG9223372036854775807L,
416 False0,
417 XA_CARDINAL((Atom) 6),
418 &type,
419 &format,
420 &nitems,
421 &bytes_after,
422 (guchar **)&str);
423
424 /* TODO: handle bytes_after != 0 */
425
426 if ((result == Success0) && (type == XA_CARDINAL((Atom) 6)) && (nitems > 0)) {
427 switch (format)
428 {
429 case 8:
430 length = nitems;
431 break;
432 case 16:
433 length = sizeof(short) * nitems;
434 break;
435 case 32:
436 length = sizeof(long) * nitems;
437 break;
438 default:
439 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-window.c", 439, ((const char*) (__func__
))
, "Unable to read profile, not correcting");
440
441 XFree (str);
442 return NULL((void*)0);
443 }
444
445 profile = cmsOpenProfileFromMem (str, length);
446
447 if (G_UNLIKELY (profile == NULL)(profile == ((void*)0))) {
448 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-window.c", 448, ((const char*) (__func__
))
,
449 "Invalid display profile set, "
450 "not using it");
451 }
452
453 XFree (str);
454 }
455
456 if (profile == NULL((void*)0)) {
457 profile = cmsCreate_sRGBProfile ();
458 eom_debug_message (DEBUG_LCMSEOM_DEBUG_LCMS, "eom-window.c", 458, ((const char*) (__func__
))
,
459 "No valid display profile set, assuming sRGB");
460 }
461
462 return profile;
463}
464#endif
465
466static void
467update_image_pos (EomWindow *window)
468{
469 EomWindowPrivate *priv;
470 gint pos = -1, n_images = 0;
471
472 priv = window->priv;
473
474 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
475
476 if (n_images > 0) {
477 pos = eom_list_store_get_pos_by_image (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
,
478 priv->image);
479 }
480 /* Images: (image pos) / (n_total_images) */
481 eom_statusbar_set_image_number (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
,
482 pos + 1,
483 n_images);
484
485}
486
487static void
488update_status_bar (EomWindow *window)
489{
490 EomWindowPrivate *priv;
491 char *str = NULL((void*)0);
492
493 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
494
495 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 495, ((const char*) (__func__
))
);
496
497 priv = window->priv;
498
499 if (priv->image != NULL((void*)0) &&
500 eom_image_has_data (priv->image, EOM_IMAGE_DATA_DIMENSION)) {
501 int zoom, width, height;
502 goffset bytes = 0;
503
504 zoom = floor (100 * eom_scroll_view_get_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
) + 0.5);
505
506 eom_image_get_size (priv->image, &width, &height);
507
508 bytes = eom_image_get_bytes (priv->image);
509
510 if ((width > 0) && (height > 0)) {
511 char *size_string;
512
513 size_string = g_format_size (bytes);
514
515 /* Translators: This is the string displayed in the statusbar
516 * The tokens are from left to right:
517 * - image width
518 * - image height
519 * - image size in bytes
520 * - zoom in percent */
521 str = g_strdup_printf (ngettext("%i × %i pixel %s %i%%",
522 "%i × %i pixels %s %i%%", height),
523 width,
524 height,
525 size_string,
526 zoom);
527
528 g_free (size_string);
529 }
530
531 update_image_pos (window);
532 }
533
534 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
535 priv->image_info_message_cid);
536
537 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
538 priv->image_info_message_cid, str ? str : "");
539
540 g_free (str);
541}
542
543static void
544eom_window_set_message_area (EomWindow *window,
545 GtkWidget *message_area)
546{
547 if (window->priv->message_area == message_area)
548 return;
549
550 if (window->priv->message_area != NULL((void*)0))
551 gtk_widget_destroy (window->priv->message_area);
552
553 window->priv->message_area = message_area;
554
555 if (message_area == NULL((void*)0)) return;
556
557 gtk_box_pack_start (GTK_BOX (window->priv->cbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((window
->priv->cbox)), ((gtk_box_get_type ()))))))
,
558 window->priv->message_area,
559 FALSE(0),
560 FALSE(0),
561 0);
562
563 g_object_add_weak_pointer (G_OBJECT (window->priv->message_area)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
window->priv->message_area)), (((GType) ((20) << (
2))))))))
,
564 (void *) &window->priv->message_area);
565}
566
567static void
568update_action_groups_state (EomWindow *window)
569{
570 EomWindowPrivate *priv;
571 GtkAction *action_collection;
572 GtkAction *action_sidebar;
573 GtkAction *action_fscreen;
574 GtkAction *action_sshow;
575 GtkAction *action_print;
576 gboolean print_disabled = FALSE(0);
577 gboolean show_image_collection = FALSE(0);
578 gint n_images = 0;
579
580 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
581
582 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 582, ((const char*) (__func__
))
);
583
584 priv = window->priv;
585
586 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
587 action_collection =
588 gtk_action_group_get_action (priv->actions_window,
589 "ViewImageCollection");
590
591 action_sidebar =
592 gtk_action_group_get_action (priv->actions_window,
593 "ViewSidebar");
594
595 action_fscreen =
596 gtk_action_group_get_action (priv->actions_image,
597 "ViewFullscreen");
598
599 action_sshow =
600 gtk_action_group_get_action (priv->actions_collection,
601 "ViewSlideshow");
602
603 action_print =
604 gtk_action_group_get_action (priv->actions_image,
605 "ImagePrint");
606 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
607
608 g_assert (action_collection != NULL)do { if (action_collection != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 608, ((const char*) (__func__)), "action_collection != NULL"
); } while (0)
;
609 g_assert (action_sidebar != NULL)do { if (action_sidebar != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 609, ((const char*) (__func__)), "action_sidebar != NULL"
); } while (0)
;
610 g_assert (action_fscreen != NULL)do { if (action_fscreen != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 610, ((const char*) (__func__)), "action_fscreen != NULL"
); } while (0)
;
611 g_assert (action_sshow != NULL)do { if (action_sshow != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 611, ((const char*) (__func__)), "action_sshow != NULL"
); } while (0)
;
612 g_assert (action_print != NULL)do { if (action_print != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 612, ((const char*) (__func__)), "action_print != NULL"
); } while (0)
;
613
614 if (priv->store != NULL((void*)0)) {
615 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
616 }
617
618 if (n_images == 0) {
619 gtk_widget_hide (priv->layout);
620
621 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
622 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
623 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
624 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
625
626 gtk_action_set_sensitive (action_fscreen, FALSE(0));
627 gtk_action_set_sensitive (action_sshow, FALSE(0));
628 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
629
630 /* If there are no images on model, initialization
631 stops here. */
632 if (priv->status == EOM_WINDOW_STATUS_INIT) {
633 priv->status = EOM_WINDOW_STATUS_NORMAL;
634 }
635 } else {
636 if (priv->flags & EOM_STARTUP_DISABLE_COLLECTION) {
637 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", FALSE(0));
638
639 show_image_collection = FALSE(0);
640 } else {
641 show_image_collection =
642 g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection");
643 }
644
645 show_image_collection = show_image_collection &&
646 n_images > 1 &&
647 priv->mode != EOM_WINDOW_MODE_SLIDESHOW;
648
649 gtk_widget_show (priv->layout);
650
651 if (show_image_collection)
652 gtk_widget_show (priv->nav);
653
654 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
655 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_collection)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action_collection)), ((gtk_toggle_action_get_type ()))))
))
,
656 show_image_collection);
657
658 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
659 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
660
661 gtk_action_set_sensitive (action_fscreen, TRUE(!(0)));
662
663 if (n_images == 1) {
664 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
665 gtk_action_set_sensitive (action_collection, FALSE(0));
666 gtk_action_set_sensitive (action_sshow, FALSE(0));
667 } else {
668 gtk_action_group_set_sensitive (priv->actions_collection, TRUE(!(0)));
669 gtk_action_set_sensitive (action_sshow, TRUE(!(0)));
670 }
671 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
672
673 if (show_image_collection)
674 gtk_widget_grab_focus (priv->thumbview);
675 else
676 gtk_widget_grab_focus (priv->view);
677 }
678
679 print_disabled = g_settings_get_boolean (priv->lockdown_settings,
680 EOM_CONF_LOCKDOWN_CAN_PRINT"disable-printing");
681
682 if (print_disabled) {
683 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
684 gtk_action_set_sensitive (action_print, FALSE(0));
685 }
686
687 if (eom_sidebar_is_empty (EOM_SIDEBAR (priv->sidebar)((((EomSidebar*) g_type_check_instance_cast ((GTypeInstance*)
((priv->sidebar)), ((eom_sidebar_get_type()))))))
)) {
688 gtk_action_set_sensitive (action_sidebar, FALSE(0));
689 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
690 gtk_widget_hide (priv->sidebar);
691 }
692}
693
694static void
695update_selection_ui_visibility (EomWindow *window)
696{
697 EomWindowPrivate *priv;
698 GtkAction *wallpaper_action;
699 gint n_selected;
700
701 priv = window->priv;
702
703 n_selected = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
704
705 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
706 wallpaper_action =
707 gtk_action_group_get_action (priv->actions_image,
708 "ImageSetAsWallpaper");
709
710 if (n_selected == 1) {
711 gtk_action_set_sensitive (wallpaper_action, TRUE(!(0)));
712 } else {
713 gtk_action_set_sensitive (wallpaper_action, FALSE(0));
714 }
715 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
716}
717
718static gboolean
719add_file_to_recent_files (GFile *file)
720{
721 gchar *text_uri;
722 GFileInfo *file_info;
723 GtkRecentData *recent_data;
724 static gchar *groups[2] = { EOM_RECENT_FILES_GROUP"Graphics" , NULL((void*)0) };
725
726 if (file == NULL((void*)0)) return FALSE(0);
727
728 /* The password gets stripped here because ~/.recently-used.xbel is
729 * readable by everyone (chmod 644). It also makes the workaround
730 * for the bug with gtk_recent_info_get_uri_display() easier
731 * (see the comment in eom_window_update_recent_files_menu()). */
732 text_uri = g_file_get_uri (file);
733
734 if (text_uri == NULL((void*)0))
735 return FALSE(0);
736
737 file_info = g_file_query_info (file,
738 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
739 0, NULL((void*)0), NULL((void*)0));
740 if (file_info == NULL((void*)0))
741 return FALSE(0);
742
743 recent_data = g_slice_new (GtkRecentData)((GtkRecentData*) g_slice_alloc (sizeof (GtkRecentData)));
744 recent_data->display_name = NULL((void*)0);
745 recent_data->description = NULL((void*)0);
746 recent_data->mime_type = (gchar *) g_file_info_get_content_type (file_info);
747 recent_data->app_name = EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer";
748 recent_data->app_exec = g_strjoin(" ", g_get_prgname (), "%u", NULL((void*)0));
749 recent_data->groups = groups;
750 recent_data->is_private = FALSE(0);
751
752 gtk_recent_manager_add_full (gtk_recent_manager_get_default (),
753 text_uri,
754 recent_data);
755
756 g_free (recent_data->app_exec);
757 g_free (text_uri);
758 g_object_unref (file_info);
759
760 g_slice_free (GtkRecentData, recent_data)do { if (1) g_slice_free1 (sizeof (GtkRecentData), (recent_data
)); else (void) ((GtkRecentData*) 0 == (recent_data)); } while
(0)
;
761
762 return FALSE(0);
763}
764
765static void
766image_thumb_changed_cb (EomImage *image, gpointer data)
767{
768 EomWindow *window;
769 EomWindowPrivate *priv;
770 GdkPixbuf *thumb;
771
772 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
773
774 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
775 priv = window->priv;
776
777 thumb = eom_image_get_thumbnail (image);
778
779 if (thumb != NULL((void*)0)) {
780 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, thumb);
781
782 if (window->priv->properties_dlg != NULL((void*)0)) {
783 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
784 image);
785 }
786
787 g_object_unref (thumb);
788 } else if (!gtk_widget_get_visible (window->priv->nav)) {
789 gint img_pos = eom_list_store_get_pos_by_image (window->priv->store, image);
790 GtkTreePath *path = gtk_tree_path_new_from_indices (img_pos,-1);
791 GtkTreeIter iter;
792
793 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), ((gtk_tree_model_get_type (
)))))))
, &iter, path);
794 eom_list_store_thumbnail_set (window->priv->store, &iter);
795 gtk_tree_path_free (path);
796 }
797}
798
799static void
800file_changed_info_bar_response (GtkInfoBar *info_bar,
801 gint response,
802 EomWindow *window)
803{
804 if (response == GTK_RESPONSE_YES) {
805 eom_window_reload_image (window);
806 }
807
808 window->priv->needs_reload_confirmation = TRUE(!(0));
809
810 eom_window_set_message_area (window, NULL((void*)0));
811}
812static void
813image_file_changed_cb (EomImage *img, EomWindow *window)
814{
815 GtkWidget *info_bar;
816 gchar *text, *markup;
817 GtkWidget *image;
818 GtkWidget *label;
819 GtkWidget *hbox;
820
821 if (window->priv->needs_reload_confirmation == FALSE(0))
822 return;
823
824 if (!eom_image_is_modified (img)) {
825 /* Auto-reload when image is unmodified */
826 eom_window_reload_image (window);
827 return;
828 }
829
830 window->priv->needs_reload_confirmation = FALSE(0);
831
832 info_bar = gtk_info_bar_new_with_buttons (_("_Reload")gettext ("_Reload"),
833 GTK_RESPONSE_YES,
834 C_("MessageArea", "Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
835 GTK_RESPONSE_NO, NULL((void*)0));
836 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((info_bar)), ((gtk_info_bar_get_type()))))))
,
837 GTK_MESSAGE_QUESTION);
838 image = gtk_image_new_from_icon_name ("dialog-question",
839 GTK_ICON_SIZE_DIALOG);
840 label = gtk_label_new (NULL((void*)0));
841
842 /* The newline character is currently necessary due to a problem
843 * with the automatic line break. */
844 text = g_strdup_printf (_("The image \"%s\" has been modified by an external application."gettext ("The image \"%s\" has been modified by an external application."
"\nWould you like to reload it?")
845 "\nWould you like to reload it?")gettext ("The image \"%s\" has been modified by an external application."
"\nWould you like to reload it?")
, eom_image_get_caption (img));
846 markup = g_markup_printf_escaped ("<b>%s</b>", text);
847 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, markup);
848 g_free (text);
849 g_free (markup);
850
851 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
852 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
853 gtk_widget_set_halign (image, GTK_ALIGN_START);
854 gtk_widget_set_valign (image, GTK_ALIGN_END);
855 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
856 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, 0.0);
857 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_info_bar_get_content_area
(((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))))), ((gtk_box_get_type
()))))))
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
858 gtk_widget_show_all (hbox);
859 gtk_widget_show (info_bar);
860
861 eom_window_set_message_area (window, info_bar);
862 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
863 G_CALLBACK (file_changed_info_bar_response), window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
;
864}
865
866static void
867eom_window_display_image (EomWindow *window, EomImage *image)
868{
869 EomWindowPrivate *priv;
870 GFile *file;
871
872 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
873 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
874
875 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 875, ((const char*) (__func__
))
);
876
877 g_assert (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE))do { if (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)) ; else
g_assertion_message_expr ("EOM", "eom-window.c", 877, ((const
char*) (__func__)), "eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)"
); } while (0)
;
878
879 priv = window->priv;
880
881 if (image != NULL((void*)0)) {
882 g_signal_connect (image,g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
883 "thumbnail_changed",g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
884 G_CALLBACK (image_thumb_changed_cb),g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
885 window)g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
886 g_signal_connect (image, "file-changed",g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
887 G_CALLBACK (image_file_changed_cb),g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
888 window)g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
889
890 image_thumb_changed_cb (image, window);
891 }
892
893 priv->needs_reload_confirmation = TRUE(!(0));
894
895 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, image);
896
897 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, eom_image_get_caption (image));
898
899 update_status_bar (window);
900
901 file = eom_image_get_file (image);
902 g_idle_add_full (G_PRIORITY_LOW300,
903 (GSourceFunc) add_file_to_recent_files,
904 file,
905 (GDestroyNotify) g_object_unref);
906
907 eom_window_update_openwith_menu (window, image);
908}
909
910static void
911open_with_launch_application_cb (GtkAction *action, gpointer data) {
912 EomImage *image;
913 GAppInfo *app;
914 GFile *file;
915 GList *files = NULL((void*)0);
916
917 image = EOM_IMAGE (data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_image_get_type ()))))))
;
918 file = eom_image_get_file (image);
919
920 app = g_object_get_data (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "app");
921 files = g_list_append (files, file);
922 g_app_info_launch (app,
923 files,
924 NULL((void*)0), NULL((void*)0));
925
926 g_object_unref (file);
927 g_list_free (files);
928}
929
930static void
931eom_window_update_openwith_menu (EomWindow *window, EomImage *image)
932{
933 gboolean edit_button_active;
934 GAppInfo *editor_app;
935 GFile *file;
936 GFileInfo *file_info;
937 GList *iter;
938 gchar *label, *tip;
939 const gchar *mime_type;
940 GtkAction *action;
941 EomWindowPrivate *priv;
942 GList *apps;
943 guint action_id = 0;
944 GIcon *app_icon;
945 char *path;
946 GtkWidget *menuitem;
947
948 priv = window->priv;
949
950 edit_button_active = FALSE(0);
951 editor_app = get_appinfo_for_editor (window);
952
953 file = eom_image_get_file (image);
954 file_info = g_file_query_info (file,
955 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
956 0, NULL((void*)0), NULL((void*)0));
957
958 if (file_info == NULL((void*)0))
959 return;
960 else {
961 mime_type = g_file_info_get_content_type (file_info);
962 }
963
964 if (priv->open_with_menu_id != 0) {
965 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->open_with_menu_id);
966 priv->open_with_menu_id = 0;
967 }
968
969 if (priv->actions_open_with != NULL((void*)0)) {
970 gtk_ui_manager_remove_action_group (priv->ui_mgr, priv->actions_open_with);
971 g_object_unref (priv->actions_open_with);
972 priv->actions_open_with = NULL((void*)0);
973 }
974
975 if (mime_type == NULL((void*)0)) {
976 g_object_unref (file_info);
977 return;
978 }
979
980 apps = g_app_info_get_all_for_type (mime_type);
981
982 g_object_unref (file_info);
983
984 if (!apps)
985 return;
986
987 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
988 priv->actions_open_with = gtk_action_group_new ("OpenWithActions");
989 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
990 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_open_with, -1);
991
992 priv->open_with_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
993
994 for (iter = apps; iter; iter = iter->next) {
995 GAppInfo *app = iter->data;
996 gchar name[64];
997
998 if (editor_app != NULL((void*)0) && g_app_info_equal (editor_app, app)) {
999 edit_button_active = TRUE(!(0));
1000 }
1001
1002 /* Do not include eom itself */
1003 if (g_ascii_strcasecmp (g_app_info_get_executable (app),
1004 g_get_prgname ()) == 0) {
1005 g_object_unref (app);
1006 continue;
1007 }
1008
1009 g_snprintf (name, sizeof (name), "OpenWith%u", action_id++);
1010
1011 label = g_strdup (g_app_info_get_name (app));
1012 tip = g_strdup_printf (_("Use \"%s\" to open the selected image")gettext ("Use \"%s\" to open the selected image"), g_app_info_get_name (app));
1013
1014 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1015 action = gtk_action_new (name, label, tip, NULL((void*)0));
1016 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1017
1018 app_icon = g_app_info_get_icon (app);
1019 if (G_LIKELY (app_icon != NULL)(app_icon != ((void*)0))) {
1020 g_object_ref (app_icon);
1021 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1022 gtk_action_set_gicon (action, app_icon);
1023 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1024 g_object_unref (app_icon);
1025 }
1026
1027 g_free (label);
1028 g_free (tip);
1029
1030 g_object_set_data_full (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "app", app,
1031 (GDestroyNotify) g_object_unref);
1032
1033 g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1034 "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1035 G_CALLBACK (open_with_launch_application_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1036 image)g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
;
1037
1038 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1039 gtk_action_group_add_action (priv->actions_open_with, action);
1040 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1041 g_object_unref (action);
1042
1043 gtk_ui_manager_add_ui (priv->ui_mgr,
1044 priv->open_with_menu_id,
1045 "/MainMenu/Image/ImageOpenWith/Applications Placeholder",
1046 name,
1047 name,
1048 GTK_UI_MANAGER_MENUITEM,
1049 FALSE(0));
1050
1051 gtk_ui_manager_add_ui (priv->ui_mgr,
1052 priv->open_with_menu_id,
1053 "/ThumbnailPopup/ImageOpenWith/Applications Placeholder",
1054 name,
1055 name,
1056 GTK_UI_MANAGER_MENUITEM,
1057 FALSE(0));
1058 gtk_ui_manager_add_ui (priv->ui_mgr,
1059 priv->open_with_menu_id,
1060 "/ViewPopup/ImageOpenWith/Applications Placeholder",
1061 name,
1062 name,
1063 GTK_UI_MANAGER_MENUITEM,
1064 FALSE(0));
1065
1066 path = g_strdup_printf ("/MainMenu/Image/ImageOpenWith/Applications Placeholder/%s", name);
1067
1068 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1069
1070 /* Only force displaying the icon if it is an application icon */
1071 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, app_icon != NULL((void*)0));
1072
1073 g_free (path);
1074
1075 path = g_strdup_printf ("/ThumbnailPopup/ImageOpenWith/Applications Placeholder/%s", name);
1076
1077 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1078
1079 /* Only force displaying the icon if it is an application icon */
1080 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, app_icon != NULL((void*)0));
1081
1082 g_free (path);
1083
1084 path = g_strdup_printf ("/ViewPopup/ImageOpenWith/Applications Placeholder/%s", name);
1085
1086 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1087
1088 /* Only force displaying the icon if it is an application icon */
1089 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, app_icon != NULL((void*)0));
1090
1091 g_free (path);
1092 }
1093
1094 g_list_free (apps);
1095
1096 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1097 action = gtk_action_group_get_action (window->priv->actions_image,
1098 "OpenEditor");
1099 if (action != NULL((void*)0)) {
1100 gtk_action_set_sensitive (action, edit_button_active);
1101 }
1102 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1103}
1104
1105static void
1106eom_window_clear_load_job (EomWindow *window)
1107{
1108 EomWindowPrivate *priv = window->priv;
1109
1110 if (priv->load_job != NULL((void*)0)) {
1111 if (!priv->load_job->finished)
1112 eom_job_queue_remove_job (priv->load_job);
1113
1114 g_signal_handlers_disconnect_by_func (priv->load_job,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_progress_cb), (window))
1115 eom_job_progress_cb,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_progress_cb), (window))
1116 window)g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_progress_cb), (window))
;
1117
1118 g_signal_handlers_disconnect_by_func (priv->load_job,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_load_cb), (window))
1119 eom_job_load_cb,g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_load_cb), (window))
1120 window)g_signal_handlers_disconnect_matched ((priv->load_job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_load_cb), (window))
;
1121
1122 eom_image_cancel_load (EOM_JOB_LOAD (priv->load_job)((((EomJobLoad*) g_type_check_instance_cast ((GTypeInstance*)
((priv->load_job)), ((eom_job_load_get_type()))))))
->image);
1123
1124 g_object_unref (priv->load_job);
1125 priv->load_job = NULL((void*)0);
1126
1127 /* Hide statusbar */
1128 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0);
1129 }
1130}
1131
1132static void
1133eom_job_progress_cb (EomJobLoad *job, float progress, gpointer user_data)
1134{
1135 EomWindow *window;
1136
1137 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
1138
1139 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1140
1141 eom_statusbar_set_progress (EOM_STATUSBAR (window->priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((eom_statusbar_get_type
()))))))
,
1142 progress);
1143}
1144
1145static void
1146eom_job_save_progress_cb (EomJobSave *job, float progress, gpointer user_data)
1147{
1148 EomWindowPrivate *priv;
1149 EomWindow *window;
1150
1151 static EomImage *image = NULL((void*)0);
1152
1153 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
1154
1155 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1156 priv = window->priv;
1157
1158 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
,
1159 progress);
1160
1161 if (image != job->current_image) {
1162 gchar *str_image, *status_message;
1163 guint n_images;
1164
1165 image = job->current_image;
1166
1167 n_images = g_list_length (job->images);
1168
1169 str_image = eom_image_get_uri_for_display (image);
1170
1171 /* Translators: This string is displayed in the statusbar
1172 * while saving images. The tokens are from left to right:
1173 * - the original filename
1174 * - the current image's position in the queue
1175 * - the total number of images queued for saving */
1176 status_message = g_strdup_printf (_("Saving image \"%s\" (%u/%u)")gettext ("Saving image \"%s\" (%u/%u)"),
1177 str_image,
1178 job->current_pos + 1,
1179 n_images);
1180 g_free (str_image);
1181
1182 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1183 priv->image_info_message_cid);
1184
1185 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1186 priv->image_info_message_cid,
1187 status_message);
1188
1189 g_free (status_message);
1190 }
1191
1192 if (progress == 1.0)
1193 image = NULL((void*)0);
1194}
1195
1196static void
1197eom_window_obtain_desired_size (EomImage *image,
1198 gint width,
1199 gint height,
1200 EomWindow *window)
1201{
1202 GdkScreen *screen;
1203 GdkDisplay *display;
1204 GdkRectangle monitor;
1205 GtkAllocation allocation;
1206 gint final_width, final_height;
1207 gint screen_width, screen_height;
1208 gint window_width, window_height;
1209 gint img_width, img_height;
1210 gint view_width, view_height;
1211 gint deco_width, deco_height;
1212
1213 update_action_groups_state (window);
1214
1215 img_width = width;
1216 img_height = height;
1217
1218 if (!gtk_widget_get_realized (window->priv->view)) {
1219 gtk_widget_realize (window->priv->view);
1220 }
1221
1222 gtk_widget_get_allocation (window->priv->view, &allocation);
1223 view_width = allocation.width;
1224 view_height = allocation.height;
1225
1226 if (!gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
)) {
1227 gtk_widget_realize (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
1228 }
1229
1230 gtk_widget_get_allocation (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
, &allocation);
1231 window_width = allocation.width;
1232 window_height = allocation.height;
1233
1234 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
1235 display = gdk_screen_get_display (screen);
1236
1237 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1238 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
)),
1239 &monitor);
1240
1241 screen_width = monitor.width;
1242 screen_height = monitor.height;
1243
1244 deco_width = window_width - view_width;
1245 deco_height = window_height - view_height;
1246
1247 if (img_width > 0 && img_height > 0) {
1248 if ((img_width + deco_width > screen_width) ||
1249 (img_height + deco_height > screen_height))
1250 {
1251 double factor;
1252
1253 if (img_width > img_height) {
1254 factor = (screen_width * 0.75 - deco_width) / (double) img_width;
1255 } else {
1256 factor = (screen_height * 0.75 - deco_height) / (double) img_height;
1257 }
1258
1259 img_width = img_width * factor;
1260 img_height = img_height * factor;
1261 }
1262 }
1263
1264 final_width = MAX (EOM_WINDOW_MIN_WIDTH, img_width + deco_width)(((440) > (img_width + deco_width)) ? (440) : (img_width +
deco_width))
;
1265 final_height = MAX (EOM_WINDOW_MIN_HEIGHT, img_height + deco_height)(((350) > (img_height + deco_height)) ? (350) : (img_height
+ deco_height))
;
1266
1267 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1267, ((const char*) (__func__
))
, "Setting window size: %d x %d", final_width, final_height);
1268
1269 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, final_width, final_height);
1270
1271 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1272}
1273
1274static void
1275eom_window_error_message_area_response (GtkInfoBar *message_area,
1276 gint response_id,
1277 EomWindow *window)
1278{
1279 if (response_id != GTK_RESPONSE_OK) {
1280 eom_window_set_message_area (window, NULL((void*)0));
1281
1282 return;
1283 }
1284
1285 /* Trigger loading for current image again */
1286 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
1287 EOM_THUMB_VIEW_SELECT_CURRENT);
1288}
1289
1290static void
1291eom_job_load_cb (EomJobLoad *job, gpointer data)
1292{
1293 EomWindow *window;
1294 EomWindowPrivate *priv;
1295 GtkAction *action_undo, *action_save;
1296
1297 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
1298
1299 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1299, ((const char*) (__func__
))
);
1300
1301 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1302 priv = window->priv;
1303
1304 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0.0);
1305
1306 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
1307 priv->image_info_message_cid);
1308
1309 if (priv->image != NULL((void*)0)) {
1310 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
1311 image_thumb_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
1312 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
;
1313 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
1314 image_file_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
1315 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
;
1316
1317 g_object_unref (priv->image);
1318 }
1319
1320 priv->image = g_object_ref (job->image);
1321
1322 if (EOM_JOB (job)((((EomJob*) g_type_check_instance_cast ((GTypeInstance*) ((job
)), ((eom_job_get_type()))))))
->error == NULL((void*)0)) {
1323#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
1324 eom_image_apply_display_profile (job->image,
1325 priv->display_profile);
1326#endif
1327
1328 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1329 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
1330 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1331
1332 eom_window_display_image (window, job->image);
1333 } else {
1334 GtkWidget *message_area;
1335
1336 message_area = eom_image_load_error_message_area_new (
1337 eom_image_get_caption (job->image),
1338 EOM_JOB (job)((((EomJob*) g_type_check_instance_cast ((GTypeInstance*) ((job
)), ((eom_job_get_type()))))))
->error);
1339
1340 g_signal_connect (message_area,g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1341 "response",g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1342 G_CALLBACK (eom_window_error_message_area_response),g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1343 window)g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
;
1344
1345 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, NULL((void*)0));
1346 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
1347 eom_image_get_caption (job->image));
1348
1349 eom_window_set_message_area (window, message_area);
1350
1351 gtk_info_bar_set_default_response (GTK_INFO_BAR (message_area)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((message_area)), ((gtk_info_bar_get_type()))))))
,
1352 GTK_RESPONSE_CANCEL);
1353
1354 gtk_widget_show (message_area);
1355
1356 update_status_bar (window);
1357
1358 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
1359
1360 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1361 update_action_groups_state (window);
1362
1363 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1364 }
1365
1366 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1367 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
1368 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1369 }
1370
1371 eom_window_clear_load_job (window);
1372
1373 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1374 window->priv->status = EOM_WINDOW_STATUS_NORMAL;
1375
1376 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
1377 (job->image,g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
1378 G_CALLBACK (eom_window_obtain_desired_size),g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
1379 window)g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_obtain_desired_size))), (window
))
;
1380 }
1381
1382 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1383 action_save = gtk_action_group_get_action (priv->actions_image, "ImageSave");
1384 action_undo = gtk_action_group_get_action (priv->actions_image, "EditUndo");
1385
1386 /* Set Save and Undo sensitive according to image state.
1387 * Respect lockdown in case of Save.*/
1388 gtk_action_set_sensitive (action_save, (!priv->save_disabled && eom_image_is_modified (job->image)));
1389 gtk_action_set_sensitive (action_undo, eom_image_is_modified (job->image));
1390 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1391
1392 g_object_unref (job->image);
1393}
1394
1395static void
1396eom_window_clear_transform_job (EomWindow *window)
1397{
1398 EomWindowPrivate *priv = window->priv;
1399
1400 if (priv->transform_job != NULL((void*)0)) {
1401 if (!priv->transform_job->finished)
1402 eom_job_queue_remove_job (priv->transform_job);
1403
1404 g_signal_handlers_disconnect_by_func (priv->transform_job,g_signal_handlers_disconnect_matched ((priv->transform_job
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (eom_job_transform_cb), (window))
1405 eom_job_transform_cb,g_signal_handlers_disconnect_matched ((priv->transform_job
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (eom_job_transform_cb), (window))
1406 window)g_signal_handlers_disconnect_matched ((priv->transform_job
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (eom_job_transform_cb), (window))
;
1407 g_object_unref (priv->transform_job);
1408 priv->transform_job = NULL((void*)0);
1409 }
1410}
1411
1412static void
1413eom_job_transform_cb (EomJobTransform *job, gpointer data)
1414{
1415 EomWindow *window;
1416 GtkAction *action_undo, *action_save;
1417 EomImage *image;
1418
1419 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
1420
1421 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1422
1423 eom_window_clear_transform_job (window);
1424
1425 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1426 action_undo =
1427 gtk_action_group_get_action (window->priv->actions_image, "EditUndo");
1428 action_save =
1429 gtk_action_group_get_action (window->priv->actions_image, "ImageSave");
1430
1431 image = eom_window_get_image (window);
1432
1433 gtk_action_set_sensitive (action_undo, eom_image_is_modified (image));
1434
1435 if (!window->priv->save_disabled)
1436 {
1437 gtk_action_set_sensitive (action_save, eom_image_is_modified (image));
1438 }
1439 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1440}
1441
1442static void
1443apply_transformation (EomWindow *window, EomTransform *trans)
1444{
1445 EomWindowPrivate *priv;
1446 GList *images;
1447
1448 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
1449
1450 priv = window->priv;
1451
1452 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1453
1454 eom_window_clear_transform_job (window);
1455
1456 priv->transform_job = eom_job_transform_new (images, trans);
1457
1458 g_signal_connect (priv->transform_job,g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1459 "finished",g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1460 G_CALLBACK (eom_job_transform_cb),g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1461 window)g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
1462
1463 g_signal_connect (priv->transform_job,g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1464 "progress",g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1465 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1466 window)g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
1467
1468 eom_job_queue_add_job (priv->transform_job);
1469}
1470
1471static void
1472handle_image_selection_changed_cb (EomThumbView *thumbview, EomWindow *window)
1473{
1474 EomWindowPrivate *priv;
1475 EomImage *image;
1476 gchar *status_message;
1477 gchar *str_image;
1478
1479 priv = window->priv;
1480
1481 if (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0) {
1482 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
1483 g_get_application_name());
1484 gtk_statusbar_remove_all (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1485 priv->image_info_message_cid);
1486 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
1487 NULL((void*)0));
1488 }
1489
1490 if (eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
) == 0)
1491 return;
1492
1493 update_selection_ui_visibility (window);
1494
1495 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1496
1497 g_assert (EOM_IS_IMAGE (image))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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_assertion_message_expr ("EOM", "eom-window.c", 1497, ((const
char*) (__func__)), "EOM_IS_IMAGE (image)"); } while (0)
;
1498
1499 eom_window_clear_load_job (window);
1500
1501 eom_window_set_message_area (window, NULL((void*)0));
1502
1503 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1504 priv->image_info_message_cid);
1505
1506 if (image == priv->image) {
1507 update_status_bar (window);
1508 return;
1509 }
1510
1511 if (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)) {
1512 if (priv->image != NULL((void*)0))
1513 g_object_unref (priv->image);
1514
1515 priv->image = image;
1516 eom_window_display_image (window, image);
1517 return;
1518 }
1519
1520 if (priv->status == EOM_WINDOW_STATUS_INIT) {
1521 g_signal_connect (image,g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1522 "size-prepared",g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1523 G_CALLBACK (eom_window_obtain_desired_size),g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1524 window)g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
;
1525 }
1526
1527 priv->load_job = eom_job_load_new (image, EOM_IMAGE_DATA_ALL(EOM_IMAGE_DATA_IMAGE | EOM_IMAGE_DATA_DIMENSION | EOM_IMAGE_DATA_EXIF
| EOM_IMAGE_DATA_XMP)
);
1528
1529 g_signal_connect (priv->load_job,g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1530 "finished",g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1531 G_CALLBACK (eom_job_load_cb),g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1532 window)g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1533
1534 g_signal_connect (priv->load_job,g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1535 "progress",g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1536 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1537 window)g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1538
1539 eom_job_queue_add_job (priv->load_job);
1540
1541 str_image = eom_image_get_uri_for_display (image);
1542
1543 status_message = g_strdup_printf (_("Opening image \"%s\"")gettext ("Opening image \"%s\""),
1544 str_image);
1545
1546 g_free (str_image);
1547
1548 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1549 priv->image_info_message_cid, status_message);
1550
1551 g_free (status_message);
1552}
1553
1554static void
1555view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
1556{
1557 EomWindow *window;
1558 GtkAction *action_zoom_in;
1559 GtkAction *action_zoom_out;
1560
1561 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
1562
1563 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1564
1565 update_status_bar (window);
1566
1567 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1568 action_zoom_in =
1569 gtk_action_group_get_action (window->priv->actions_image,
1570 "ViewZoomIn");
1571
1572 action_zoom_out =
1573 gtk_action_group_get_action (window->priv->actions_image,
1574 "ViewZoomOut");
1575
1576 gtk_action_set_sensitive (action_zoom_in,
1577 !eom_scroll_view_get_zoom_is_max (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1578 gtk_action_set_sensitive (action_zoom_out,
1579 !eom_scroll_view_get_zoom_is_min (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1580 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1581}
1582
1583static void
1584eom_window_open_recent_cb (GtkAction *action, EomWindow *window)
1585{
1586 GtkRecentInfo *info;
1587 const gchar *uri;
1588 GSList *list = NULL((void*)0);
1589
1590 info = g_object_get_data (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info");
1591 g_return_if_fail (info != NULL)do { if ((info != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "info != NULL"); return;
} } while (0)
;
1592
1593 uri = gtk_recent_info_get_uri (info);
1594 list = g_slist_prepend (list, g_strdup (uri));
1595
1596 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1597 list,
1598 GDK_CURRENT_TIME0L,
1599 0,
1600 NULL((void*)0));
1601
1602 g_slist_free_full (list, g_free);
1603}
1604
1605static void
1606file_open_dialog_response_cb (GtkWidget *chooser,
1607 gint response_id,
1608 EomWindow *ev_window)
1609{
1610 if (response_id == GTK_RESPONSE_OK) {
1611 GSList *uris;
1612
1613 uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_file_chooser_get_type ()))))))
);
1614
1615 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1616 uris,
1617 GDK_CURRENT_TIME0L,
1618 0,
1619 NULL((void*)0));
1620
1621 g_slist_free_full (uris, g_free);
1622 }
1623
1624 gtk_widget_destroy (chooser);
1625}
1626
1627static void
1628eom_window_update_fullscreen_action (EomWindow *window)
1629{
1630 GtkAction *action;
1631
1632 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1633 action = gtk_action_group_get_action (window->priv->actions_image,
1634 "ViewFullscreen");
1635
1636 g_signal_handlers_block_by_funcg_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_fullscreen))), (window))
1637 (action, G_CALLBACK (eom_window_cmd_fullscreen), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_fullscreen))), (window))
;
1638
1639 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1640 window->priv->mode == EOM_WINDOW_MODE_FULLSCREEN);
1641 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1642
1643 g_signal_handlers_unblock_by_funcg_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_fullscreen))), (window))
1644 (action, G_CALLBACK (eom_window_cmd_fullscreen), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_fullscreen))), (window))
;
1645}
1646
1647static void
1648eom_window_update_slideshow_action (EomWindow *window)
1649{
1650 GtkAction *action;
1651
1652 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1653 action = gtk_action_group_get_action (window->priv->actions_collection,
1654 "ViewSlideshow");
1655
1656 g_signal_handlers_block_by_funcg_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_slideshow))), (window))
1657 (action, G_CALLBACK (eom_window_cmd_slideshow), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_slideshow))), (window))
;
1658
1659 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1660 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
1661 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1662
1663 g_signal_handlers_unblock_by_funcg_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_slideshow))), (window))
1664 (action, G_CALLBACK (eom_window_cmd_slideshow), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_slideshow))), (window))
;
1665}
1666
1667static void
1668eom_window_update_pause_slideshow_action (EomWindow *window)
1669{
1670 GtkAction *action;
1671
1672 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1673 action = gtk_action_group_get_action (window->priv->actions_image,
1674 "PauseSlideshow");
1675
1676 g_signal_handlers_block_by_funcg_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_pause_slideshow))), (window)
)
1677 (action, G_CALLBACK (eom_window_cmd_pause_slideshow), window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (((GCallback) (eom_window_cmd_pause_slideshow))), (window)
)
;
1678
1679 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1680 window->priv->mode != EOM_WINDOW_MODE_SLIDESHOW);
1681 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1682
1683 g_signal_handlers_unblock_by_funcg_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_pause_slideshow))), (window
))
1684 (action, G_CALLBACK (eom_window_cmd_pause_slideshow), window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (eom_window_cmd_pause_slideshow))), (window
))
;
1685}
1686
1687static void
1688eom_window_update_fullscreen_popup (EomWindow *window)
1689{
1690 GtkWidget *popup = window->priv->fullscreen_popup;
1691 GdkRectangle screen_rect;
1692 GdkScreen *screen;
1693 GdkDisplay *display;
1694
1695 g_return_if_fail (popup != NULL)do { if ((popup != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "popup != NULL"); return
; } } while (0)
;
1696
1697 if (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
) == NULL((void*)0)) return;
1698
1699 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
1700 display = gdk_screen_get_display (screen);
1701
1702 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1703 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
)),
1704 &screen_rect);
1705
1706 gtk_widget_set_size_request (popup,
1707 screen_rect.width,
1708 -1);
1709
1710 gtk_window_move (GTK_WINDOW (popup)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(popup)), ((gtk_window_get_type ()))))))
, screen_rect.x, screen_rect.y);
1711}
1712
1713static void
1714screen_size_changed_cb (GdkScreen *screen, EomWindow *window)
1715{
1716 eom_window_update_fullscreen_popup (window);
1717}
1718
1719static gboolean
1720fullscreen_timeout_cb (gpointer data)
1721{
1722 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1723
1724 gtk_widget_hide (window->priv->fullscreen_popup);
1725
1726 eom_scroll_view_hide_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1727
1728 fullscreen_clear_timeout (window);
1729
1730 return FALSE(0);
1731}
1732
1733static gboolean
1734slideshow_is_loop_end (EomWindow *window)
1735{
1736 EomWindowPrivate *priv = window->priv;
1737 EomImage *image = NULL((void*)0);
1738 gint pos;
1739
1740 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1741
1742 pos = eom_list_store_get_pos_by_image (priv->store, image);
1743
1744 return (pos == (eom_list_store_length (priv->store) - 1));
1745}
1746
1747static gboolean
1748slideshow_switch_cb (gpointer data)
1749{
1750 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
1751 EomWindowPrivate *priv = window->priv;
1752
1753 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1753, ((const char*) (__func__
))
);
1754
1755 if (priv->slideshow_random) {
1756 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1757 EOM_THUMB_VIEW_SELECT_RANDOM);
1758 return TRUE(!(0));
1759 }
1760
1761 if (!priv->slideshow_loop && slideshow_is_loop_end (window)) {
1762 eom_window_stop_fullscreen (window, TRUE(!(0)));
1763 return FALSE(0);
1764 }
1765
1766 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1767 EOM_THUMB_VIEW_SELECT_RIGHT);
1768
1769 return TRUE(!(0));
1770}
1771
1772static void
1773fullscreen_clear_timeout (EomWindow *window)
1774{
1775 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1775, ((const char*) (__func__
))
);
1776
1777 if (window->priv->fullscreen_timeout_source != NULL((void*)0)) {
1778 g_source_unref (window->priv->fullscreen_timeout_source);
1779 g_source_destroy (window->priv->fullscreen_timeout_source);
1780 }
1781
1782 window->priv->fullscreen_timeout_source = NULL((void*)0);
1783}
1784
1785static void
1786fullscreen_set_timeout (EomWindow *window)
1787{
1788 GSource *source;
1789
1790 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1790, ((const char*) (__func__
))
);
1791
1792 fullscreen_clear_timeout (window);
1793
1794 source = g_timeout_source_new (EOM_WINDOW_FULLSCREEN_TIMEOUT5 * 1000);
1795 g_source_set_callback (source, fullscreen_timeout_cb, window, NULL((void*)0));
1796
1797 g_source_attach (source, NULL((void*)0));
1798
1799 window->priv->fullscreen_timeout_source = source;
1800
1801 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1802}
1803
1804static void
1805slideshow_clear_timeout (EomWindow *window)
1806{
1807 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1807, ((const char*) (__func__
))
);
1808
1809 if (window->priv->slideshow_switch_source != NULL((void*)0)) {
1810 g_source_unref (window->priv->slideshow_switch_source);
1811 g_source_destroy (window->priv->slideshow_switch_source);
1812 }
1813
1814 window->priv->slideshow_switch_source = NULL((void*)0);
1815}
1816
1817static void
1818slideshow_set_timeout (EomWindow *window)
1819{
1820 GSource *source;
1821
1822 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1822, ((const char*) (__func__
))
);
1823
1824 slideshow_clear_timeout (window);
1825
1826 if (window->priv->slideshow_switch_timeout <= 0)
1827 return;
1828
1829 source = g_timeout_source_new (window->priv->slideshow_switch_timeout * 1000);
1830 g_source_set_callback (source, slideshow_switch_cb, window, NULL((void*)0));
1831
1832 g_source_attach (source, NULL((void*)0));
1833
1834 window->priv->slideshow_switch_source = source;
1835}
1836
1837static void
1838show_fullscreen_popup (EomWindow *window)
1839{
1840 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1840, ((const char*) (__func__
))
);
1841
1842 if (!gtk_widget_get_visible (window->priv->fullscreen_popup)) {
1843 gtk_widget_show_all (GTK_WIDGET (window->priv->fullscreen_popup)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window->priv->fullscreen_popup)), ((gtk_widget_get_type
()))))))
);
1844 }
1845
1846 fullscreen_set_timeout (window);
1847}
1848
1849static gboolean
1850fullscreen_motion_notify_cb (GtkWidget *widget,
1851 GdkEventMotion *event,
1852 gpointer user_data)
1853{
1854 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1855
1856 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1856, ((const char*) (__func__
))
);
1857
1858 if (event->y < EOM_WINDOW_FULLSCREEN_POPUP_THRESHOLD5) {
1859 show_fullscreen_popup (window);
1860 } else {
1861 fullscreen_set_timeout (window);
1862 }
1863
1864 return FALSE(0);
1865}
1866
1867static gboolean
1868fullscreen_leave_notify_cb (GtkWidget *widget,
1869 GdkEventCrossing *event,
1870 gpointer user_data)
1871{
1872 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
1873
1874 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1874, ((const char*) (__func__
))
);
1875
1876 fullscreen_clear_timeout (window);
1877
1878 return FALSE(0);
1879}
1880
1881static void
1882exit_fullscreen_button_clicked_cb (GtkWidget *button, EomWindow *window)
1883{
1884 GtkAction *action;
1885
1886 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1886, ((const char*) (__func__
))
);
1887
1888 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1889 if (window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
1890 action = gtk_action_group_get_action (window->priv->actions_collection,
1891 "ViewSlideshow");
1892 } else {
1893 action = gtk_action_group_get_action (window->priv->actions_image,
1894 "ViewFullscreen");
1895 }
1896 g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "action != NULL"); return
; } } while (0)
;
1897
1898 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, FALSE(0));
1899 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1900}
1901
1902static GtkWidget *
1903eom_window_get_exit_fullscreen_button (EomWindow *window)
1904{
1905 GtkWidget *button;
1906
1907 button = gtk_button_new_with_mnemonic (_("Leave Fullscreen")gettext ("Leave Fullscreen"));
1908 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) g_type_check_instance_cast ((GTypeInstance*) (
(button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("view-restore", GTK_ICON_SIZE_BUTTON));
1909
1910 g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1911 G_CALLBACK (exit_fullscreen_button_clicked_cb),g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1912 window)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
1913
1914 return button;
1915}
1916
1917static GtkWidget *
1918eom_window_create_fullscreen_popup (EomWindow *window)
1919{
1920 GtkWidget *popup;
1921 GtkWidget *hbox;
1922 GtkWidget *button;
1923 GtkWidget *toolbar;
1924 GdkScreen *screen;
1925
1926 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1926, ((const char*) (__func__
))
);
1927
1928 popup = gtk_window_new (GTK_WINDOW_POPUP);
1929
1930 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1931 gtk_container_add (GTK_CONTAINER (popup)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_container_get_type ()))))))
, hbox);
1932
1933 toolbar = gtk_ui_manager_get_widget (window->priv->ui_mgr,
1934 "/FullscreenToolbar");
1935 g_assert (GTK_IS_WIDGET (toolbar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toolbar)); 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_assertion_message_expr ("EOM", "eom-window.c", 1935, ((const
char*) (__func__)), "GTK_IS_WIDGET (toolbar)"); } while (0)
;
1936 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar)((((GtkToolbar*) g_type_check_instance_cast ((GTypeInstance*)
((toolbar)), ((gtk_toolbar_get_type ()))))))
, GTK_TOOLBAR_ICONS);
1937 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, toolbar, TRUE(!(0)), TRUE(!(0)), 0);
1938
1939 button = eom_window_get_exit_fullscreen_button (window);
1940 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, button, FALSE(0), FALSE(0), 0);
1941
1942 gtk_window_set_resizable (GTK_WINDOW (popup)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(popup)), ((gtk_window_get_type ()))))))
, FALSE(0));
1943
1944 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
1945
1946 g_signal_connect_object (screen, "size-changed",
1947 G_CALLBACK (screen_size_changed_cb)((GCallback) (screen_size_changed_cb)),
1948 window, 0);
1949
1950 g_signal_connect (popup,g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1951 "enter-notify-event",g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1952 G_CALLBACK (fullscreen_leave_notify_cb),g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1953 window)g_signal_connect_data ((popup), ("enter-notify-event"), (((GCallback
) (fullscreen_leave_notify_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1954
1955 gtk_window_set_screen (GTK_WINDOW (popup)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(popup)), ((gtk_window_get_type ()))))))
, screen);
1956
1957 return popup;
1958}
1959
1960static void
1961update_ui_visibility (EomWindow *window)
1962{
1963 EomWindowPrivate *priv;
1964
1965 GtkAction *action;
1966 GtkWidget *menubar;
1967
1968 gboolean fullscreen_mode, visible;
1969
1970 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
1971
1972 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1972, ((const char*) (__func__
))
);
1973
1974 priv = window->priv;
1975
1976 fullscreen_mode = priv->mode == EOM_WINDOW_MODE_FULLSCREEN ||
1977 priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
1978
1979 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
1980 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 1980, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
1981
1982 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_TOOLBAR"toolbar");
1983 visible = visible && !fullscreen_mode;
1984
1985 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/ToolbarToggle");
1986 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 1986, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
1987 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1988 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
1989 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1990 g_object_set (G_OBJECT (priv->toolbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->toolbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
1991
1992 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_STATUSBAR"statusbar");
1993 visible = visible && !fullscreen_mode;
1994
1995 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/StatusbarToggle");
1996 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 1996, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
1997 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1998 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
1999 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2000 g_object_set (G_OBJECT (priv->statusbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->statusbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2001
2002 if (priv->status != EOM_WINDOW_STATUS_INIT) {
2003 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection");
2004 visible = visible && priv->mode != EOM_WINDOW_MODE_SLIDESHOW;
2005 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/ImageCollectionToggle");
2006 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2006, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
2007 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2008 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
2009 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2010 if (visible) {
2011 gtk_widget_show (priv->nav);
2012 } else {
2013 gtk_widget_hide (priv->nav);
2014 }
2015 }
2016
2017 visible = g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_SIDEBAR"sidebar");
2018 visible = visible && !fullscreen_mode;
2019 action = gtk_ui_manager_get_action (priv->ui_mgr, "/MainMenu/View/SidebarToggle");
2020 g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2020, ((const char*) (__func__)), "action != NULL"
); } while (0)
;
2021 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2022 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
2023 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2024 if (visible) {
2025 gtk_widget_show (priv->sidebar);
2026 } else {
2027 gtk_widget_hide (priv->sidebar);
2028 }
2029
2030 if (priv->fullscreen_popup != NULL((void*)0)) {
2031 gtk_widget_hide (priv->fullscreen_popup);
2032 }
2033}
2034
2035static void
2036eom_window_inhibit_screensaver (EomWindow *window)
2037{
2038 EomWindowPrivate *priv = window->priv;
2039
2040 g_return_if_fail (priv->fullscreen_idle_inhibit_cookie == 0)do { if ((priv->fullscreen_idle_inhibit_cookie == 0)) { } else
{ g_return_if_fail_warning ("EOM", ((const char*) (__func__)
), "priv->fullscreen_idle_inhibit_cookie == 0"); return; }
} while (0)
;
2041
2042 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2042, ((const char*) (__func__
))
);
2043
2044 window->priv->fullscreen_idle_inhibit_cookie =
2045 gtk_application_inhibit (GTK_APPLICATION (EOM_APP)((((GtkApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
,
2046 GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2047 GTK_APPLICATION_INHIBIT_IDLE,
2048 _("Viewing a slideshow")gettext ("Viewing a slideshow"));
2049}
2050
2051static void
2052eom_window_uninhibit_screensaver (EomWindow *window)
2053{
2054 EomWindowPrivate *priv = window->priv;
2055
2056 if (G_UNLIKELY (priv->fullscreen_idle_inhibit_cookie == 0)(priv->fullscreen_idle_inhibit_cookie == 0))
2057 return;
2058
2059 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2059, ((const char*) (__func__
))
);
2060
2061 gtk_application_uninhibit (GTK_APPLICATION (EOM_APP)((((GtkApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
,
2062 priv->fullscreen_idle_inhibit_cookie);
2063 priv->fullscreen_idle_inhibit_cookie = 0;
2064}
2065
2066static void
2067eom_window_run_fullscreen (EomWindow *window, gboolean slideshow)
2068{
2069 static const GdkRGBA black = { 0., 0., 0., 1.};
2070
2071 EomWindowPrivate *priv;
2072 GtkWidget *menubar;
2073 gboolean upscale;
2074
2075 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2075, ((const char*) (__func__
))
);
2076
2077 priv = window->priv;
2078
2079 if (slideshow) {
2080 priv->mode = EOM_WINDOW_MODE_SLIDESHOW;
2081 } else {
2082 /* Stop the timer if we come from slideshowing */
2083 if (priv->mode == EOM_WINDOW_MODE_SLIDESHOW)
2084 slideshow_clear_timeout (window);
2085
2086 priv->mode = EOM_WINDOW_MODE_FULLSCREEN;
2087 }
2088
2089 if (window->priv->fullscreen_popup == NULL((void*)0))
2090 priv->fullscreen_popup
2091 = eom_window_create_fullscreen_popup (window);
2092
2093 update_ui_visibility (window);
2094
2095 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
2096 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 2096, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
2097 gtk_widget_hide (menubar);
2098
2099 g_signal_connect (priv->view,g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2100 "motion-notify-event",g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2101 G_CALLBACK (fullscreen_motion_notify_cb),g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2102 window)g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2103
2104 g_signal_connect (priv->view,g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2105 "leave-notify-event",g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2106 G_CALLBACK (fullscreen_leave_notify_cb),g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2107 window)g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2108
2109 g_signal_connect (priv->thumbview,g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2110 "motion-notify-event",g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2111 G_CALLBACK (fullscreen_motion_notify_cb),g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2112 window)g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2113
2114 g_signal_connect (priv->thumbview,g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2115 "leave-notify-event",g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2116 G_CALLBACK (fullscreen_leave_notify_cb),g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2117 window)g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2118
2119 fullscreen_set_timeout (window);
2120
2121 if (slideshow) {
2122 priv->slideshow_random =
2123 g_settings_get_boolean (priv->fullscreen_settings,
2124 EOM_CONF_FULLSCREEN_RANDOM"random");
2125
2126 priv->slideshow_loop =
2127 g_settings_get_boolean (priv->fullscreen_settings,
2128 EOM_CONF_FULLSCREEN_LOOP"loop");
2129
2130 priv->slideshow_switch_timeout =
2131 g_settings_get_int (priv->fullscreen_settings,
2132 EOM_CONF_FULLSCREEN_SECONDS"seconds");
2133
2134 slideshow_set_timeout (window);
2135 }
2136
2137 upscale = g_settings_get_boolean (priv->fullscreen_settings,
2138 EOM_CONF_FULLSCREEN_UPSCALE"upscale");
2139
2140 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
2141 upscale);
2142
2143 gtk_widget_grab_focus (priv->view);
2144
2145 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2146 &black);
2147
2148 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2149 eom_window_update_fullscreen_popup (window);
2150
2151 eom_window_inhibit_screensaver (window);
2152
2153 /* Update both actions as we could've already been in one those modes */
2154 eom_window_update_slideshow_action (window);
2155 eom_window_update_fullscreen_action (window);
2156 eom_window_update_pause_slideshow_action (window);
2157}
2158
2159static void
2160eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow)
2161{
2162 EomWindowPrivate *priv;
2163 GtkWidget *menubar;
2164
2165 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2165, ((const char*) (__func__
))
);
2166
2167 priv = window->priv;
2168
2169 if (priv->mode != EOM_WINDOW_MODE_SLIDESHOW &&
2170 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2171
2172 priv->mode = EOM_WINDOW_MODE_NORMAL;
2173
2174 fullscreen_clear_timeout (window);
2175
2176 if (slideshow) {
2177 slideshow_clear_timeout (window);
2178 }
2179
2180 g_signal_handlers_disconnect_by_func (priv->view,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_motion_notify_cb), (window))
2181 (gpointer) fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_motion_notify_cb), (window))
2182 window)g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_motion_notify_cb), (window))
;
2183
2184 g_signal_handlers_disconnect_by_func (priv->view,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_leave_notify_cb), (window))
2185 (gpointer) fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_leave_notify_cb), (window))
2186 window)g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), ((gpointer) fullscreen_leave_notify_cb), (window))
;
2187
2188 g_signal_handlers_disconnect_by_func (priv->thumbview,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_motion_notify_cb),
(window))
2189 (gpointer) fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_motion_notify_cb),
(window))
2190 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_motion_notify_cb),
(window))
;
2191
2192 g_signal_handlers_disconnect_by_func (priv->thumbview,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_leave_notify_cb), (
window))
2193 (gpointer) fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_leave_notify_cb), (
window))
2194 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), ((gpointer) fullscreen_leave_notify_cb), (
window))
;
2195
2196 update_ui_visibility (window);
2197
2198 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
2199 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 2199, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
2200 gtk_widget_show (menubar);
2201
2202 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
2203
2204 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2205 NULL((void*)0));
2206 gtk_window_unfullscreen (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2207
2208 if (slideshow) {
2209 eom_window_update_slideshow_action (window);
2210 } else {
2211 eom_window_update_fullscreen_action (window);
2212 }
2213
2214 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
2215
2216 eom_window_uninhibit_screensaver (window);
2217}
2218
2219static void
2220eom_window_print (EomWindow *window)
2221{
2222 GtkWidget *dialog;
2223 GError *error = NULL((void*)0);
2224 GtkPrintOperation *print;
2225 GtkPrintOperationResult res;
2226 GtkPageSetup *page_setup;
2227 GtkPrintSettings *print_settings;
2228 gboolean page_setup_disabled = FALSE(0);
2229
2230 eom_debug (DEBUG_PRINTINGEOM_DEBUG_PRINTING, "eom-window.c", 2230, ((const char*) (__func__
))
);
2231
2232 print_settings = eom_print_get_print_settings ();
2233
2234 /* Make sure the window stays valid while printing */
2235 g_object_ref (window);
2236
2237 if (window->priv->page_setup != NULL((void*)0))
2238 page_setup = g_object_ref (window->priv->page_setup);
2239 else
2240 page_setup = eom_print_get_page_setup ();
2241
2242 print = eom_print_operation_new (window->priv->image,
2243 print_settings,
2244 page_setup);
2245
2246 // Disable page setup options if they are locked down
2247 page_setup_disabled = g_settings_get_boolean (window->priv->lockdown_settings,
2248 EOM_CONF_LOCKDOWN_CAN_SETUP_PAGE"disable-print-setup");
2249 if (page_setup_disabled)
2250 gtk_print_operation_set_embed_page_setup (print, FALSE(0));
2251
2252 res = gtk_print_operation_run (print,
2253 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
2254 GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, &error);
2255
2256 if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
2257 dialog = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2258 GTK_DIALOG_DESTROY_WITH_PARENT,
2259 GTK_MESSAGE_ERROR,
2260 GTK_BUTTONS_CLOSE,
2261 _("Error printing file:\n%s")gettext ("Error printing file:\n%s"),
2262 error->message);
2263 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
2264 G_CALLBACK (gtk_widget_destroy), NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
2265 gtk_widget_show (dialog);
2266 g_error_free (error);
2267 } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
2268 GtkPageSetup *new_page_setup;
2269 eom_print_set_print_settings (gtk_print_operation_get_print_settings (print));
2270 new_page_setup = gtk_print_operation_get_default_page_setup (print);
2271 if (window->priv->page_setup != NULL((void*)0))
2272 g_object_unref (window->priv->page_setup);
2273 window->priv->page_setup = g_object_ref (new_page_setup);
2274 eom_print_set_page_setup (window->priv->page_setup);
2275 }
2276
2277 if (page_setup != NULL((void*)0))
2278 g_object_unref (page_setup);
2279 g_object_unref (print_settings);
2280 g_object_unref (window);
2281}
2282
2283static void
2284eom_window_cmd_file_open (GtkAction *action, gpointer user_data)
2285{
2286 EomWindow *window;
2287 EomWindowPrivate *priv;
2288 EomImage *current;
2289 GtkWidget *dlg;
2290
2291 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2292
2293 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2294
2295 priv = window->priv;
2296
2297 dlg = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_OPEN);
2298 gtk_window_set_transient_for (GTK_WINDOW (dlg)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_window_get_type ()))))))
, GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2299
2300 current = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2301
2302 if (current != NULL((void*)0)) {
2303 gchar *dir_uri, *file_uri;
2304
2305 file_uri = eom_image_get_uri_for_display (current);
2306 dir_uri = g_path_get_dirname (file_uri);
2307
2308 gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2309 dir_uri);
2310 g_free (file_uri);
2311 g_free (dir_uri);
2312 g_object_unref (current);
2313 } else {
2314 /* If desired by the user,
2315 fallback to the XDG_PICTURES_DIR (if available) */
2316 const gchar *pics_dir;
2317 gboolean use_fallback;
2318
2319 use_fallback = g_settings_get_boolean (priv->ui_settings,
2320 EOM_CONF_UI_FILECHOOSER_XDG_FALLBACK"filechooser-xdg-fallback");
2321 pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
2322 if (use_fallback && pics_dir) {
2323 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2324 pics_dir);
2325 }
2326 }
2327
2328 g_signal_connect (dlg, "response",g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2329 G_CALLBACK (file_open_dialog_response_cb),g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2330 window)g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
2331
2332 gtk_widget_show_all (dlg);
2333}
2334
2335static void
2336eom_job_close_save_cb (EomJobSave *job, gpointer user_data)
2337{
2338 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2339
2340 g_signal_handlers_disconnect_by_func (job,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_close_save_cb), (window))
2341 eom_job_close_save_cb,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_close_save_cb), (window))
2342 window)g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_close_save_cb), (window))
;
2343
2344 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
2345}
2346
2347static void
2348close_confirmation_dialog_response_handler (EomCloseConfirmationDialog *dlg,
2349 gint response_id,
2350 EomWindow *window)
2351{
2352 GList *selected_images;
2353 EomWindowPrivate *priv;
2354
2355 priv = window->priv;
2356
2357 switch (response_id)
2358 {
2359 case GTK_RESPONSE_YES:
2360 /* save selected images */
2361 selected_images = eom_close_confirmation_dialog_get_selected_images (dlg);
2362 if (eom_window_save_images (window, selected_images)) {
2363 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2364 "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2365 G_CALLBACK (eom_job_close_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2366 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
2367
2368 eom_job_queue_add_job (priv->save_job);
2369 }
2370
2371 break;
2372
2373 case GTK_RESPONSE_NO:
2374 /* dont save */
2375 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
2376 break;
2377
2378 default:
2379 /* Cancel */
2380 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_widget_get_type ()))))))
);
2381 break;
2382 }
2383}
2384
2385static gboolean
2386eom_window_unsaved_images_confirm (EomWindow *window)
2387{
2388 EomWindowPrivate *priv;
2389 gboolean disabled;
2390 GtkWidget *dialog;
2391 GList *list;
2392 EomImage *image;
2393 GtkTreeIter iter;
2394
2395 priv = window->priv;
2396
2397 disabled = g_settings_get_boolean(priv->ui_settings,
2398 EOM_CONF_UI_DISABLE_CLOSE_CONFIRMATION"disable-close-confirmation");
2399 disabled |= window->priv->save_disabled;
2400 if (disabled || !priv->store) {
2401 return FALSE(0);
2402 }
2403
2404 list = NULL((void*)0);
2405 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter)) {
2406 do {
2407 gtk_tree_model_get (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter,
2408 EOM_LIST_STORE_EOM_IMAGE, &image,
2409 -1);
2410 if (!image)
2411 continue;
2412
2413 if (eom_image_is_modified (image)) {
2414 list = g_list_prepend (list, image);
2415 }
2416 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter));
2417 }
2418
2419 if (list) {
2420 list = g_list_reverse (list);
2421 dialog = eom_close_confirmation_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2422 list);
2423
2424 g_list_free (list);
2425 g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2426 "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2427 G_CALLBACK (close_confirmation_dialog_response_handler),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2428 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
;
2429 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2430
2431 gtk_widget_show (dialog);
2432 return TRUE(!(0));
2433
2434 }
2435 return FALSE(0);
2436}
2437
2438static void
2439eom_window_cmd_close_window (GtkAction *action, gpointer user_data)
2440{
2441 EomWindow *window;
2442 EomWindowPrivate *priv;
2443
2444 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2445
2446 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2447 priv = window->priv;
2448
2449 if (priv->save_job != NULL((void*)0)) {
2450 eom_window_finish_saving (window);
2451 }
2452
2453 if (!eom_window_unsaved_images_confirm (window)) {
2454 gtk_widget_destroy (GTK_WIDGET (user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
);
2455 }
2456}
2457
2458static void
2459eom_window_cmd_preferences (GtkAction *action, gpointer user_data)
2460{
2461 EomWindow *window;
2462 GtkWidget *pref_dlg;
2463
2464 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2465
2466 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2467
2468 pref_dlg = eom_preferences_dialog_get_instance (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2469
2470 gtk_widget_show (pref_dlg);
2471}
2472
2473#define EOM_TB_EDITOR_DLG_RESET_RESPONSE128 128
2474
2475static void
2476eom_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
2477{
2478 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
2479
2480 if (response == EOM_TB_EDITOR_DLG_RESET_RESPONSE128) {
2481 EggToolbarsModel *model;
2482 EggToolbarEditor *editor;
2483
2484 editor = g_object_get_data (G_OBJECT (dialog)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
dialog)), (((GType) ((20) << (2))))))))
,
2485 "EggToolbarEditor");
2486
2487 g_return_if_fail (editor != NULL)do { if ((editor != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "editor != NULL"); return
; } } while (0)
;
2488
2489 egg_editable_toolbar_set_edit_mode
2490 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2491
2492 eom_application_reset_toolbars_model (EOM_APP(eom_application_get_instance ()));
2493 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
2494 egg_editable_toolbar_set_model
2495 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, model);
2496 egg_toolbar_editor_set_model (editor, model);
2497
2498 /* Toolbar would be uneditable now otherwise */
2499 egg_editable_toolbar_set_edit_mode
2500 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2501 } else if (response == GTK_RESPONSE_HELP) {
2502 eom_util_show_help ("eom-toolbareditor", NULL((void*)0));
2503 } else {
2504 egg_editable_toolbar_set_edit_mode
2505 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2506
2507 eom_application_save_toolbars_model (EOM_APP(eom_application_get_instance ()));
2508
2509 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_widget_get_type ()))))))
);
2510 }
2511}
2512
2513static void
2514eom_window_cmd_edit_toolbar (GtkAction *action, gpointer *user_data)
2515{
2516 EomWindow *window;
2517 GtkWidget *dialog;
2518 GtkWidget *editor;
2519
2520 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
2521
2522 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2523
2524 dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor")gettext ("Toolbar Editor"),
2525 GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2526 GTK_DIALOG_DESTROY_WITH_PARENT,
2527 _("_Reset to Default")gettext ("_Reset to Default"),
2528 EOM_TB_EDITOR_DLG_RESET_RESPONSE128,
2529 "gtk-close",
2530 GTK_RESPONSE_CLOSE,
2531 "gtk-help",
2532 GTK_RESPONSE_HELP,
2533 NULL((void*)0));
2534
2535 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_dialog_get_type ()))))))
,
2536 GTK_RESPONSE_CLOSE);
2537
2538 gtk_container_set_border_width (GTK_CONTAINER (dialog)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_container_get_type ()))))))
, 5);
2539
2540 gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_dialog_get_content_area
(((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*
) ((dialog)), ((gtk_dialog_get_type ()))))))))), ((gtk_box_get_type
()))))))
, 2);
2541
2542 gtk_window_set_default_size (GTK_WINDOW (dialog)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_window_get_type ()))))))
, 500, 400);
2543
2544 editor = egg_toolbar_editor_new (window->priv->ui_mgr,
2545 eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ())));
2546
2547 gtk_container_set_border_width (GTK_CONTAINER (editor)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_container_get_type ()))))))
, 5);
2548
2549 // Use as much vertical space as available
2550 gtk_widget_set_vexpand (GTK_WIDGET (editor)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(editor)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
2551
2552 gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) (((
(((EggToolbarEditor*) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((egg_toolbar_editor_get_type ())))))))), ((gtk_box_get_type
()))))))
, 5);
2553
2554 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_container_get_type ()))))))
, editor);
2555
2556 egg_editable_toolbar_set_edit_mode
2557 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2558
2559 g_object_set_data (G_OBJECT (dialog)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
dialog)), (((GType) ((20) << (2))))))))
, "EggToolbarEditor", editor);
2560
2561 g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2562 "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2563 G_CALLBACK (eom_window_cmd_edit_toolbar_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2564 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2565
2566 gtk_widget_show_all (dialog);
2567}
2568
2569static void
2570eom_window_cmd_help (GtkAction *action, gpointer user_data)
2571{
2572 EomWindow *window;
2573
2574 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2575
2576 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2577
2578 eom_util_show_help (NULL((void*)0), GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
);
2579}
2580
2581#define ABOUT_GROUP"About" "About"
2582#define EMAILIFY(string)(g_strdelimit ((string), "%", '@')) (g_strdelimit ((string), "%", '@'))
2583
2584static void
2585eom_window_cmd_about (GtkAction *action, gpointer user_data)
2586{
2587 EomWindow *window;
2588
2589 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2590
2591 const char *license[] = {
2592 N_("This program is free software; you can redistribute it and/or modify "("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
2593 "it under the terms of the GNU General Public License as published by "("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
2594 "the Free Software Foundation; either version 2 of the License, or "("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
2595 "(at your option) any later version.\n")("This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n")
,
2596 N_("This program is distributed in the hope that it will be useful, "("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
2597 "but WITHOUT ANY WARRANTY; without even the implied warranty of "("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
2598 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
2599 "GNU General Public License for more details.\n")("This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n")
,
2600 N_("You should have received a copy of the GNU General Public License "("You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
)
2601 "along with this program; if not, write to the Free Software "("You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
)
2602 "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.")("You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA."
)
2603 };
2604
2605 char *license_trans;
2606 GKeyFile *key_file;
2607 GBytes *bytes;
2608 const guint8 *data;
2609 gsize data_len;
2610 GError *error = NULL((void*)0);
2611 char **authors, **documenters;
2612 gsize n_authors = 0, n_documenters = 0 , i;
2613
2614 bytes = g_resources_lookup_data ("/org/mate/eom/ui/eom.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
2615 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2615, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2616
2617 data = g_bytes_get_data (bytes, &data_len);
2618 key_file = g_key_file_new ();
2619 g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
2620 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2620, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2621
2622 authors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Authors", &n_authors, NULL((void*)0));
2623 documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Documenters", &n_documenters, NULL((void*)0));
2624
2625 g_key_file_free (key_file);
2626 g_bytes_unref (bytes);
2627
2628 for (i = 0; i < n_authors; ++i)
2629 authors[i] = EMAILIFY (authors[i])(g_strdelimit ((authors[i]), "%", '@'));
2630 for (i = 0; i < n_documenters; ++i)
2631 documenters[i] = EMAILIFY (documenters[i])(g_strdelimit ((documenters[i]), "%", '@'));
2632
2633 license_trans = g_strconcat (_(license[0])gettext (license[0]), "\n", _(license[1])gettext (license[1]), "\n", _(license[2])gettext (license[2]), "\n", NULL((void*)0));
2634
2635 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2636
2637 gtk_show_about_dialog (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
2638 "program-name", _("Eye of MATE")gettext ("Eye of MATE"),
2639 "title", _("About Eye of MATE")gettext ("About Eye of MATE"),
2640 "version", VERSION"1.24.0",
2641 "copyright", _("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers"
)
2642 "Copyright \xc2\xa9 2011 Perberos\n"gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers"
)
2643 "Copyright \xc2\xa9 2012-2020 MATE developers")gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2020 MATE developers"
)
,
2644 "comments",_("Eye of MATE is a simple graphics viewer for the MATE Desktop Environment.")gettext ("Eye of MATE is a simple graphics viewer for the MATE Desktop Environment."
)
,
2645 "authors", authors,
2646 "documenters", documenters,
2647 "translator-credits", _("translator-credits")gettext ("translator-credits"),
2648 "website", "http://www.mate-desktop.org/",
2649 "logo-icon-name", "eom",
2650 "wrap-license", TRUE(!(0)),
2651 "license", license_trans,
2652 NULL((void*)0));
2653
2654 g_strfreev (authors);
2655 g_strfreev (documenters);
2656 g_free (license_trans);
2657}
2658
2659static void
2660eom_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
2661{
2662 EomWindow *window;
2663 EomWindowPrivate *priv;
2664 gboolean visible;
2665 const gchar *action_name;
2666
2667 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
2668
2669 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2670 priv = window->priv;
2671
2672 if (priv->mode != EOM_WINDOW_MODE_NORMAL &&
2673 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2674
2675 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2676 visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
2677 action_name = gtk_action_get_name (action);
2678 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2679
2680 if (g_ascii_strcasecmp (action_name, "ViewToolbar") == 0) {
2681 g_object_set (G_OBJECT (priv->toolbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->toolbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2682
2683 if (priv->mode == EOM_WINDOW_MODE_NORMAL)
2684 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_TOOLBAR"toolbar", visible);
2685
2686 } else if (g_ascii_strcasecmp (action_name, "ViewStatusbar") == 0) {
2687 g_object_set (G_OBJECT (priv->statusbar)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
priv->statusbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2688
2689 if (priv->mode == EOM_WINDOW_MODE_NORMAL)
2690 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_STATUSBAR"statusbar", visible);
2691
2692 } else if (g_ascii_strcasecmp (action_name, "ViewImageCollection") == 0) {
2693 if (visible) {
2694 /* Make sure the focus widget is realized to
2695 * avoid warnings on keypress events */
2696 if (!gtk_widget_get_realized (window->priv->thumbview))
2697 gtk_widget_realize (window->priv->thumbview);
2698
2699 gtk_widget_show (priv->nav);
2700 gtk_widget_grab_focus (priv->thumbview);
2701 } else {
2702 /* Make sure the focus widget is realized to
2703 * avoid warnings on keypress events.
2704 * Don't do it during init phase or the view
2705 * will get a bogus allocation. */
2706 if (!gtk_widget_get_realized (priv->view)
2707 && priv->status == EOM_WINDOW_STATUS_NORMAL)
2708 gtk_widget_realize (priv->view);
2709
2710 gtk_widget_hide (priv->nav);
2711
2712 if (gtk_widget_get_realized (priv->view))
2713 gtk_widget_grab_focus (priv->view);
2714 }
2715 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", visible);
2716
2717 } else if (g_ascii_strcasecmp (action_name, "ViewSidebar") == 0) {
2718 if (visible) {
2719 gtk_widget_show (priv->sidebar);
2720 } else {
2721 gtk_widget_hide (priv->sidebar);
2722 }
2723 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_SIDEBAR"sidebar", visible);
2724 }
2725}
2726
2727static void
2728wallpaper_info_bar_response (GtkInfoBar *bar, gint response, EomWindow *window)
2729{
2730 if (response == GTK_RESPONSE_YES) {
2731 GAppInfo *app_info;
2732 GError *error = NULL((void*)0);
2733
2734 app_info = g_app_info_create_from_commandline ("mate-appearance-properties --show-page=background",
2735 "mate-appearance-properties",
2736 G_APP_INFO_CREATE_NONE,
2737 &error);
2738
2739 if (error != NULL((void*)0)) {
2740 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2741 error->message);
2742 g_error_free (error);
2743 error = NULL((void*)0);
2744 }
2745
2746 if (app_info != NULL((void*)0)) {
2747 GdkAppLaunchContext *context;
2748 GdkDisplay *display;
2749
2750 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
2751 context = gdk_display_get_app_launch_context (display);
2752 g_app_info_launch (app_info, NULL((void*)0), G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) g_type_check_instance_cast ((GTypeInstance
*) ((context)), ((g_app_launch_context_get_type ()))))))
, &error);
2753
2754 if (error != NULL((void*)0)) {
2755 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2756 error->message);
2757 g_error_free (error);
2758 error = NULL((void*)0);
2759 }
2760
2761 g_object_unref (context);
2762 g_object_unref (app_info);
2763 }
2764 }
2765
2766 /* Close message area on every response */
2767 eom_window_set_message_area (window, NULL((void*)0));
2768}
2769
2770static void
2771eom_window_set_wallpaper (EomWindow *window, const gchar *filename, const gchar *visible_filename)
2772{
2773 GtkWidget *info_bar;
2774 GtkWidget *image;
2775 GtkWidget *label;
2776 GtkWidget *hbox;
2777 gchar *markup;
2778 gchar *text;
2779 gchar *basename;
2780 GSettings *wallpaper_settings;
2781
2782 wallpaper_settings = g_settings_new (EOM_CONF_BACKGROUND_SCHEMA"org.mate.background");
2783 g_settings_set_string (wallpaper_settings,
2784 EOM_CONF_BACKGROUND_FILE"picture-filename",
2785 filename);
2786 g_object_unref (wallpaper_settings);
2787
2788 /* I18N: When setting mnemonics for these strings, watch out to not
2789 clash with mnemonics from eom's menubar */
2790 info_bar = gtk_info_bar_new_with_buttons (_("_Open Background Preferences")gettext ("_Open Background Preferences"),
2791 GTK_RESPONSE_YES,
2792 C_("MessageArea","Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
2793 GTK_RESPONSE_NO, NULL((void*)0));
2794 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((info_bar)), ((gtk_info_bar_get_type()))))))
,
2795 GTK_MESSAGE_QUESTION);
2796
2797 image = gtk_image_new_from_icon_name ("dialog-question",
2798 GTK_ICON_SIZE_DIALOG);
2799 label = gtk_label_new (NULL((void*)0));
2800
2801 if (!visible_filename)
2802 basename = g_path_get_basename (filename);
2803
2804 /* The newline character is currently necessary due to a problem
2805 * with the automatic line break. */
2806 text = g_strdup_printf (_("The image \"%s\" has been set as Desktop Background."gettext ("The image \"%s\" has been set as Desktop Background."
"\nWould you like to modify its appearance?")
2807 "\nWould you like to modify its appearance?")gettext ("The image \"%s\" has been set as Desktop Background."
"\nWould you like to modify its appearance?")
,
2808 visible_filename ? visible_filename : basename);
2809 markup = g_markup_printf_escaped ("<b>%s</b>", text);
2810 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, markup);
2811 g_free (markup);
2812 g_free (text);
2813 if (!visible_filename)
2814 g_free (basename);
2815
2816 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
2817 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
2818 gtk_widget_set_halign (image, GTK_ALIGN_START);
2819 gtk_widget_set_valign (image, GTK_ALIGN_END);
2820 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
2821 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(label)), ((gtk_label_get_type ()))))))
, 0.0);
2822 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_info_bar_get_content_area
(((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))))), ((gtk_box_get_type
()))))))
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
2823 gtk_widget_show_all (hbox);
2824 gtk_widget_show (info_bar);
2825
2826
2827 eom_window_set_message_area (window, info_bar);
2828 gtk_info_bar_set_default_response (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) g_type_check_instance_cast ((GTypeInstance*)
((info_bar)), ((gtk_info_bar_get_type()))))))
,
2829 GTK_RESPONSE_YES);
2830 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
2831 G_CALLBACK (wallpaper_info_bar_response), window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
;
2832}
2833
2834static void
2835eom_job_save_cb (EomJobSave *job, gpointer user_data)
2836{
2837 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2838 GtkAction *action_save;
2839
2840 g_signal_handlers_disconnect_by_func (job,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_cb), (window))
2841 eom_job_save_cb,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_cb), (window))
2842 window)g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_cb), (window))
;
2843
2844 g_signal_handlers_disconnect_by_func (job,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_progress_cb), (window))
2845 eom_job_save_progress_cb,g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_progress_cb), (window))
2846 window)g_signal_handlers_disconnect_matched ((job), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_job_save_progress_cb), (window))
;
2847
2848 g_object_unref (window->priv->save_job);
2849 window->priv->save_job = NULL((void*)0);
2850
2851 update_status_bar (window);
2852 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2853 action_save = gtk_action_group_get_action (window->priv->actions_image,
2854 "ImageSave");
2855 gtk_action_set_sensitive (action_save, FALSE(0));
2856 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2857}
2858
2859static void
2860eom_job_copy_cb (EomJobCopy *job, gpointer user_data)
2861{
2862 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2863 gchar *filepath, *basename, *filename, *extension;
2864 GtkAction *action;
2865 GFile *source_file, *dest_file;
2866
2867 /* Create source GFile */
2868 basename = g_file_get_basename (job->images->data);
2869 filepath = g_build_filename (job->dest, basename, NULL((void*)0));
2870 source_file = g_file_new_for_path (filepath);
2871 g_free (filepath);
2872
2873 /* Create destination GFile */
2874 extension = eom_util_filename_get_extension (basename);
2875 filename = g_strdup_printf ("%s.%s", EOM_WALLPAPER_FILENAME"eom-wallpaper", extension);
2876 filepath = g_build_filename (job->dest, filename, NULL((void*)0));
2877 dest_file = g_file_new_for_path (filepath);
2878 g_free (filename);
2879 g_free (extension);
2880
2881 /* Move the file */
2882 g_file_move (source_file, dest_file, G_FILE_COPY_OVERWRITE,
2883 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
2884
2885 /* Set the wallpaper */
2886 eom_window_set_wallpaper (window, filepath, basename);
2887 g_free (basename);
2888 g_free (filepath);
2889
2890 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
2891 window->priv->copy_file_cid);
2892 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2893 action = gtk_action_group_get_action (window->priv->actions_image,
2894 "ImageSetAsWallpaper");
2895 gtk_action_set_sensitive (action, TRUE(!(0)));
2896 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2897
2898 window->priv->copy_job = NULL((void*)0);
2899
2900 g_object_unref (source_file);
2901 g_object_unref (dest_file);
2902 g_object_unref (G_OBJECT (job->images->data)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
job->images->data)), (((GType) ((20) << (2)))))))
)
);
2903 g_list_free (job->images);
2904 g_object_unref (job);
2905}
2906
2907static gboolean
2908eom_window_save_images (EomWindow *window, GList *images)
2909{
2910 EomWindowPrivate *priv;
2911
2912 priv = window->priv;
2913
2914 if (window->priv->save_job != NULL((void*)0))
2915 return FALSE(0);
2916
2917 priv->save_job = eom_job_save_new (images);
2918
2919 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2920 "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2921 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2922 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2923
2924 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2925 "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2926 G_CALLBACK (eom_job_save_progress_cb),g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2927 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
2928
2929 return TRUE(!(0));
2930}
2931
2932static void
2933eom_window_cmd_save (GtkAction *action, gpointer user_data)
2934{
2935 EomWindowPrivate *priv;
2936 EomWindow *window;
2937 GList *images;
2938
2939 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
2940 priv = window->priv;
2941
2942 if (window->priv->save_job != NULL((void*)0))
2943 return;
2944
2945 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2946
2947 if (eom_window_save_images (window, images)) {
2948 eom_job_queue_add_job (priv->save_job);
2949 }
2950}
2951
2952static GFile*
2953eom_window_retrieve_save_as_file (EomWindow *window, EomImage *image)
2954{
2955 GtkWidget *dialog;
2956 GFile *save_file = NULL((void*)0);
2957 GFile *last_dest_folder;
2958 gint response;
2959
2960 g_assert (image != NULL)do { if (image != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2960, ((const char*) (__func__)), "image != NULL"
); } while (0)
;
2961
2962 dialog = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_SAVE);
2963
2964 last_dest_folder = window->priv->last_save_as_folder;
2965
2966 if (last_dest_folder && g_file_query_exists (last_dest_folder, NULL((void*)0))) {
2967 gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
, last_dest_folder, NULL((void*)0));
2968 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2969 eom_image_get_caption (image));
2970 } else {
2971 GFile *image_file;
2972
2973 image_file = eom_image_get_file (image);
2974 /* Setting the file will also navigate to its parent folder */
2975 gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2976 image_file, NULL((void*)0));
2977 g_object_unref (image_file);
2978 }
2979
2980 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_dialog_get_type ()))))))
);
2981 gtk_widget_hide (dialog);
2982
2983 if (response == GTK_RESPONSE_OK) {
2984 save_file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
);
2985 if (window->priv->last_save_as_folder)
2986 g_object_unref (window->priv->last_save_as_folder);
2987 window->priv->last_save_as_folder = g_file_get_parent (save_file);
2988 }
2989 gtk_widget_destroy (dialog);
2990
2991 return save_file;
2992}
2993
2994static void
2995eom_window_cmd_save_as (GtkAction *action, gpointer user_data)
2996{
2997 EomWindowPrivate *priv;
2998 EomWindow *window;
2999 GList *images;
3000 guint n_images;
3001
3002 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3003 priv = window->priv;
3004
3005 if (window->priv->save_job != NULL((void*)0))
3006 return;
3007
3008 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3009 n_images = g_list_length (images);
3010
3011 if (n_images == 1) {
3012 GFile *file;
3013
3014 file = eom_window_retrieve_save_as_file (window, images->data);
3015
3016 if (!file) {
3017 g_list_free (images);
3018 return;
3019 }
3020
3021 priv->save_job = eom_job_save_as_new (images, NULL((void*)0), file);
3022
3023 g_object_unref (file);
3024 } else if (n_images > 1) {
3025 GFile *base_file;
3026 GtkWidget *dialog;
3027 gchar *basedir;
3028 EomURIConverter *converter;
3029
3030 basedir = g_get_current_dir ();
3031 base_file = g_file_new_for_path (basedir);
3032 g_free (basedir);
3033
3034 dialog = eom_save_as_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3035 images,
3036 base_file);
3037
3038 gtk_widget_show_all (dialog);
3039
3040 if (gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dialog)), ((gtk_dialog_get_type ()))))))
) != GTK_RESPONSE_OK) {
3041 g_object_unref (base_file);
3042 g_list_free (images);
3043 gtk_widget_destroy (dialog);
3044
3045 return;
3046 }
3047
3048 converter = eom_save_as_dialog_get_converter (dialog);
3049
3050 g_assert (converter != NULL)do { if (converter != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3050, ((const char*) (__func__)), "converter != NULL"
); } while (0)
;
3051
3052 priv->save_job = eom_job_save_as_new (images, converter, NULL((void*)0));
3053
3054 gtk_widget_destroy (dialog);
3055
3056 g_object_unref (converter);
3057 g_object_unref (base_file);
3058 } else {
3059 /* n_images = 0 -- No Image selected */
3060 return;
3061 }
3062
3063 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3064 "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3065 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3066 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3067
3068 g_signal_connect (priv->save_job,g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3069 "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3070 G_CALLBACK (eom_job_save_progress_cb),g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3071 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
3072
3073 eom_job_queue_add_job (priv->save_job);
3074}
3075
3076static void
3077eom_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
3078{
3079 EomWindowPrivate *priv;
3080
3081 GFile *file;
3082 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3083
3084 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3085
3086 g_return_if_fail (priv->image != NULL)do { if ((priv->image != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "priv->image != NULL"
); return; } } while (0)
;
3087
3088 file = eom_image_get_file (priv->image);
3089
3090 g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "file != NULL"); return;
} } while (0)
;
3091
3092 eom_util_show_file_in_filemanager (file,
3093 GTK_WINDOW (user_data)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_window_get_type ()))))))
);
3094}
3095
3096static void
3097eom_window_cmd_print (GtkAction *action, gpointer user_data)
3098{
3099 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3100
3101 eom_window_print (window);
3102}
3103
3104/**
3105 * eom_window_get_properties_dialog:
3106 * @window: a #EomWindow
3107 *
3108 * Gets the @window property dialog. The widget will be built on the first call to this function.
3109 *
3110 * Returns: (transfer none): a #GtkDialog.
3111 */
3112
3113GtkWidget*
3114eom_window_get_properties_dialog (EomWindow *window)
3115{
3116 EomWindowPrivate *priv;
3117
3118 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
3119
3120 priv = window->priv;
3121
3122 if (priv->properties_dlg == NULL((void*)0)) {
3123 GtkAction *next_image_action, *previous_image_action;
3124
3125 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3126 next_image_action =
3127 gtk_action_group_get_action (priv->actions_collection,
3128 "GoNext");
3129
3130 previous_image_action =
3131 gtk_action_group_get_action (priv->actions_collection,
3132 "GoPrevious");
3133 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3134 priv->properties_dlg =
3135 eom_properties_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3136 EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3137 next_image_action,
3138 previous_image_action);
3139
3140 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
3141 priv->image);
3142 g_settings_bind (priv->ui_settings,
3143 EOM_CONF_UI_PROPSDIALOG_NETBOOK_MODE"propsdialog-netbook-mode",
3144 priv->properties_dlg, "netbook-mode",
3145 G_SETTINGS_BIND_GET);
3146 }
3147
3148 return priv->properties_dlg;
3149}
3150
3151static void
3152eom_window_cmd_properties (GtkAction *action, gpointer user_data)
3153{
3154 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3155 GtkWidget *dialog;
3156
3157 dialog = eom_window_get_properties_dialog (window);
3158 gtk_widget_show (dialog);
3159}
3160
3161static void
3162eom_window_cmd_undo (GtkAction *action, gpointer user_data)
3163{
3164 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3165
3166 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
, NULL((void*)0));
3167}
3168
3169static void
3170eom_window_cmd_flip_horizontal (GtkAction *action, gpointer user_data)
3171{
3172 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3173
3174 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3175 eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL));
3176}
3177
3178static void
3179eom_window_cmd_flip_vertical (GtkAction *action, gpointer user_data)
3180{
3181 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3182
3183 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3184 eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL));
3185}
3186
3187static void
3188eom_window_cmd_rotate_90 (GtkAction *action, gpointer user_data)
3189{
3190 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3191
3192 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3193 eom_transform_rotate_new (90));
3194}
3195
3196static void
3197eom_window_cmd_rotate_270 (GtkAction *action, gpointer user_data)
3198{
3199 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3200
3201 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
,
3202 eom_transform_rotate_new (270));
3203}
3204
3205static void
3206eom_window_cmd_wallpaper (GtkAction *action, gpointer user_data)
3207{
3208 EomWindow *window;
3209 EomWindowPrivate *priv;
3210 EomImage *image;
3211 GFile *file;
3212 char *filename = NULL((void*)0);
3213
3214 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3215
3216 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3217 priv = window->priv;
3218
3219 /* If currently copying an image to set it as wallpaper, return. */
3220 if (priv->copy_job != NULL((void*)0))
3221 return;
3222
3223 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3224
3225 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
3226
3227 file = eom_image_get_file (image);
3228
3229 filename = g_file_get_path (file);
3230
3231 /* Currently only local files can be set as wallpaper */
3232 if (filename == NULL((void*)0) || !eom_util_file_is_persistent (file))
3233 {
3234 GList *files = NULL((void*)0);
3235 GtkAction *action;
3236
3237 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3238 action = gtk_action_group_get_action (window->priv->actions_image,
3239 "ImageSetAsWallpaper");
3240 gtk_action_set_sensitive (action, FALSE(0));
3241 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3242
3243 priv->copy_file_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3244 "copy_file_cid");
3245 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3246 priv->copy_file_cid,
3247 _("Saving image locally…")gettext ("Saving image locally…"));
3248
3249 files = g_list_append (files, eom_image_get_file (image));
3250 priv->copy_job = eom_job_copy_new (files, g_get_user_data_dir ());
3251 g_signal_connect (priv->copy_job,g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3252 "finished",g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3253 G_CALLBACK (eom_job_copy_cb),g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3254 window)g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3255 g_signal_connect (priv->copy_job,g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3256 "progress",g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3257 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3258 window)g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3259 eom_job_queue_add_job (priv->copy_job);
3260
3261 g_object_unref (file);
3262 g_free (filename);
3263 return;
3264 }
3265
3266 g_object_unref (file);
3267
3268 eom_window_set_wallpaper (window, filename, NULL((void*)0));
3269
3270 g_free (filename);
3271}
3272
3273static gboolean
3274eom_window_all_images_trasheable (GList *images)
3275{
3276 GFile *file;
3277 GFileInfo *file_info;
3278 GList *iter;
3279 EomImage *image;
3280 gboolean can_trash = TRUE(!(0));
3281
3282 for (iter = images; iter != NULL((void*)0); iter = g_list_next (iter)((iter) ? (((GList *)(iter))->next) : ((void*)0))) {
3283 image = (EomImage *) iter->data;
3284 file = eom_image_get_file (image);
3285 file_info = g_file_query_info (file,
3286 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3287 0, NULL((void*)0), NULL((void*)0));
3288 can_trash = g_file_info_get_attribute_boolean (file_info,
3289 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3290
3291 g_object_unref (file_info);
3292 g_object_unref (file);
3293
3294 if (can_trash == FALSE(0))
3295 break;
3296 }
3297
3298 return can_trash;
3299}
3300
3301static int
3302show_move_to_trash_confirm_dialog (EomWindow *window, GList *images, gboolean can_trash)
3303{
3304 GtkWidget *dlg;
3305 char *prompt;
3306 int response;
3307 int n_images;
3308 EomImage *image;
3309 static gboolean dontaskagain = FALSE(0);
3310 gboolean neverask = FALSE(0);
3311 GtkWidget* dontask_cbutton = NULL((void*)0);
3312
3313 /* Check if the user never wants to be bugged. */
3314 neverask = g_settings_get_boolean (window->priv->ui_settings,
3315 EOM_CONF_UI_DISABLE_TRASH_CONFIRMATION"disable-trash-confirmation");
3316
3317 /* Assume agreement, if the user doesn't want to be
3318 * asked and the trash is available */
3319 if (can_trash && (dontaskagain || neverask))
3320 return GTK_RESPONSE_OK;
3321
3322 n_images = g_list_length (images);
3323
3324 if (n_images == 1) {
3325 image = EOM_IMAGE (images->data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(images->data)), ((eom_image_get_type ()))))))
;
3326 if (can_trash) {
3327 prompt = g_strdup_printf (_("Are you sure you want to move\n\"%s\" to the trash?")gettext ("Are you sure you want to move\n\"%s\" to the trash?"
)
,
3328 eom_image_get_caption (image));
3329 } else {
3330 prompt = g_strdup_printf (_("A trash for \"%s\" couldn't be found. Do you want to remove "gettext ("A trash for \"%s\" couldn't be found. Do you want to remove "
"this image permanently?")
3331 "this image permanently?")gettext ("A trash for \"%s\" couldn't be found. Do you want to remove "
"this image permanently?")
, eom_image_get_caption (image));
3332 }
3333 } else {
3334 if (can_trash) {
3335 prompt = g_strdup_printf (ngettext("Are you sure you want to move\n"
3336 "the %d selected image to the trash?",
3337 "Are you sure you want to move\n"
3338 "the %d selected images to the trash?", n_images), n_images);
3339 } else {
3340 prompt = g_strdup (_("Some of the selected images can't be moved to the trash "gettext ("Some of the selected images can't be moved to the trash "
"and will be removed permanently. Are you sure you want " "to proceed?"
)
3341 "and will be removed permanently. Are you sure you want "gettext ("Some of the selected images can't be moved to the trash "
"and will be removed permanently. Are you sure you want " "to proceed?"
)
3342 "to proceed?")gettext ("Some of the selected images can't be moved to the trash "
"and will be removed permanently. Are you sure you want " "to proceed?"
)
);
3343 }
3344 }
3345
3346 dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3347 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3348 GTK_MESSAGE_WARNING,
3349 GTK_BUTTONS_NONE,
3350 "<span weight=\"bold\" size=\"larger\">%s</span>",
3351 prompt);
3352 g_free (prompt);
3353
3354 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-cancel", GTK_RESPONSE_CANCEL);
3355
3356 if (can_trash) {
3357 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, _("Move to _Trash")gettext ("Move to _Trash"), GTK_RESPONSE_OK);
3358
3359 dontask_cbutton = gtk_check_button_new_with_mnemonic (_("_Do not ask again during this session")gettext ("_Do not ask again during this session"));
3360 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
, FALSE(0));
3361
3362 gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)))((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gtk_dialog_get_content_area
(((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*
) ((dlg)), ((gtk_dialog_get_type ()))))))))), ((gtk_box_get_type
()))))))
, dontask_cbutton, TRUE(!(0)), TRUE(!(0)), 0);
3363 } else {
3364 if (n_images == 1) {
3365 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-delete", GTK_RESPONSE_OK);
3366 } else {
3367 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-yes", GTK_RESPONSE_OK);
3368 }
3369 }
3370
3371 gtk_dialog_set_default_response (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
3372 gtk_window_set_title (GTK_WINDOW (dlg)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_window_get_type ()))))))
, "");
3373 gtk_widget_show_all (dlg);
3374
3375 response = gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
);
3376
3377 /* Only update the property if the user has accepted */
3378 if (can_trash && response == GTK_RESPONSE_OK)
3379 dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
);
3380
3381 /* The checkbutton is destroyed together with the dialog */
3382 gtk_widget_destroy (dlg);
3383
3384 return response;
3385}
3386
3387static gboolean
3388move_to_trash_real (EomImage *image, GError **error)
3389{
3390 GFile *file;
3391 GFileInfo *file_info;
3392 gboolean can_trash, result;
3393
3394 g_return_val_if_fail (EOM_IS_IMAGE (image), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return ((0)); } } while (0)
;
3395
3396 file = eom_image_get_file (image);
3397 file_info = g_file_query_info (file,
3398 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3399 0, NULL((void*)0), NULL((void*)0));
3400 if (file_info == NULL((void*)0)) {
3401 g_set_error (error,
3402 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3403 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3404 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3405 return FALSE(0);
3406 }
3407
3408 can_trash = g_file_info_get_attribute_boolean (file_info,
3409 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3410 g_object_unref (file_info);
3411 if (can_trash)
3412 {
3413 result = g_file_trash (file, NULL((void*)0), NULL((void*)0));
3414 if (result == FALSE(0)) {
3415 g_set_error (error,
3416 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3417 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3418 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3419 }
3420 } else {
3421 result = g_file_delete (file, NULL((void*)0), NULL((void*)0));
3422 if (result == FALSE(0)) {
3423 g_set_error (error,
3424 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3425 EOM_WINDOW_ERROR_IO,
3426 _("Couldn't delete file")gettext ("Couldn't delete file"));
3427 }
3428 }
3429
3430 g_object_unref (file);
3431
3432 return result;
3433}
3434
3435static void
3436eom_window_cmd_copy_image (GtkAction *action, gpointer user_data)
3437{
3438 GtkClipboard *clipboard;
3439 EomWindow *window;
3440 EomWindowPrivate *priv;
3441 EomImage *image;
3442 EomClipboardHandler *cbhandler;
3443
3444 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3445
3446 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3447 priv = window->priv;
3448
3449 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3450
3451 g_return_if_fail (EOM_IS_IMAGE (image))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((image)); GType __t = ((eom_image_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_IMAGE (image)"); return; } } while (0)
;
3452
3453 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD((GdkAtom)((gpointer) (gulong) (69))));
3454
3455 cbhandler = eom_clipboard_handler_new (image);
3456 // cbhandler will self-destruct when it's not needed anymore
3457 eom_clipboard_handler_copy_to_clipboard (cbhandler, clipboard);
3458
3459}
3460
3461static void
3462eom_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
3463{
3464 GList *images;
3465 GList *it;
3466 EomWindowPrivate *priv;
3467 EomListStore *list;
3468 int pos;
3469 EomImage *img;
3470 EomWindow *window;
3471 int response;
3472 int n_images;
3473 gboolean success;
3474 gboolean can_trash;
3475 const gchar *action_name;
3476
3477 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3478
3479 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3480 priv = window->priv;
3481 list = priv->store;
3482
3483 n_images = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3484
3485 if (n_images < 1) return;
3486
3487 /* save position of selected image after the deletion */
3488 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3489
3490 g_assert (images != NULL)do { if (images != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3490, ((const char*) (__func__)), "images != NULL"
); } while (0)
;
3491
3492 /* HACK: eom_list_store_get_n_selected return list in reverse order */
3493 images = g_list_reverse (images);
3494
3495 can_trash = eom_window_all_images_trasheable (images);
3496
3497 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3498 action_name = gtk_action_get_name (action);
3499 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3500
3501 if (g_ascii_strcasecmp (action_name, "Delete") == 0 ||
3502 can_trash == FALSE(0)) {
3503 response = show_move_to_trash_confirm_dialog (window, images, can_trash);
3504
3505 if (response != GTK_RESPONSE_OK) return;
3506 }
3507
3508 pos = eom_list_store_get_pos_by_image (list, EOM_IMAGE (images->data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(images->data)), ((eom_image_get_type ()))))))
);
3509
3510 /* FIXME: make a nice progress dialog */
3511 /* Do the work actually. First try to delete the image from the disk. If this
3512 * is successful, remove it from the screen. Otherwise show error dialog.
3513 */
3514 for (it = images; it != NULL((void*)0); it = it->next) {
3515 GError *error = NULL((void*)0);
3516 EomImage *image;
3517
3518 image = EOM_IMAGE (it->data)((((EomImage*) g_type_check_instance_cast ((GTypeInstance*) (
(it->data)), ((eom_image_get_type ()))))))
;
3519
3520 success = move_to_trash_real (image, &error);
3521
3522 if (success) {
3523 eom_list_store_remove_image (list, image);
3524 } else {
3525 char *header;
3526 GtkWidget *dlg;
3527
3528 header = g_strdup_printf (_("Error on deleting image %s")gettext ("Error on deleting image %s"),
3529 eom_image_get_caption (image));
3530
3531 dlg = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
3532 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3533 GTK_MESSAGE_ERROR,
3534 GTK_BUTTONS_OK,
3535 "%s", header);
3536
3537 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg)((((GtkMessageDialog*) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_message_dialog_get_type ()))))))
,
3538 "%s", error->message);
3539
3540 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(dlg)), ((gtk_dialog_get_type ()))))))
);
3541
3542 gtk_widget_destroy (dlg);
3543
3544 g_free (header);
3545 }
3546 }
3547
3548 /* free list */
3549 g_list_free_full (images, g_object_unref);
3550
3551 /* select image at previously saved position */
3552 pos = MIN (pos, eom_list_store_length (list) - 1)(((pos) < (eom_list_store_length (list) - 1)) ? (pos) : (eom_list_store_length
(list) - 1))
;
3553
3554 if (pos >= 0) {
3555 img = eom_list_store_get_image_by_pos (list, pos);
3556
3557 eom_thumb_view_set_current_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3558 img,
3559 TRUE(!(0)));
3560
3561 if (img != NULL((void*)0)) {
3562 g_object_unref (img);
3563 }
3564 }
3565}
3566
3567static void
3568eom_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
3569{
3570 EomWindow *window;
3571 gboolean fullscreen;
3572
3573 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3574
3575 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3575, ((const char*) (__func__
))
);
3576
3577 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3578
3579 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3580 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3581 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3582
3583 if (fullscreen) {
3584 eom_window_run_fullscreen (window, FALSE(0));
3585 } else {
3586 eom_window_stop_fullscreen (window, FALSE(0));
3587 }
3588}
3589
3590static void
3591eom_window_cmd_slideshow (GtkAction *action, gpointer user_data)
3592{
3593 EomWindow *window;
3594 gboolean slideshow;
3595
3596 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3597
3598 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3598, ((const char*) (__func__
))
);
3599
3600 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3601
3602 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3603 slideshow = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3604 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3605
3606 if (slideshow) {
3607 eom_window_run_fullscreen (window, TRUE(!(0)));
3608 } else {
3609 eom_window_stop_fullscreen (window, TRUE(!(0)));
3610 }
3611}
3612
3613static void
3614eom_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data)
3615{
3616 EomWindow *window;
3617 gboolean slideshow;
3618
3619 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3620
3621 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3621, ((const char*) (__func__
))
);
3622
3623 window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
3624
3625 slideshow = window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
3626
3627 if (!slideshow && window->priv->mode != EOM_WINDOW_MODE_FULLSCREEN)
3628 return;
3629
3630 eom_window_run_fullscreen (window, !slideshow);
3631}
3632
3633static void
3634eom_window_cmd_zoom_in (GtkAction *action, gpointer user_data)
3635{
3636 EomWindowPrivate *priv;
3637
3638 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3639
3640 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3640, ((const char*) (__func__
))
);
3641
3642 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3643
3644 if (priv->view) {
3645 eom_scroll_view_zoom_in (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3646 }
3647}
3648
3649static void
3650eom_window_cmd_zoom_out (GtkAction *action, gpointer user_data)
3651{
3652 EomWindowPrivate *priv;
3653
3654 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3655
3656 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3656, ((const char*) (__func__
))
);
3657
3658 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3659
3660 if (priv->view) {
3661 eom_scroll_view_zoom_out (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3662 }
3663}
3664
3665static void
3666eom_window_cmd_zoom_normal (GtkAction *action, gpointer user_data)
3667{
3668 EomWindowPrivate *priv;
3669
3670 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3671
3672 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3672, ((const char*) (__func__
))
);
3673
3674 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3675
3676 if (priv->view) {
3677 eom_scroll_view_set_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, 1.0);
3678 }
3679}
3680
3681static void
3682eom_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
3683{
3684 EomWindowPrivate *priv;
3685
3686 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3687
3688 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3688, ((const char*) (__func__
))
);
3689
3690 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3691
3692 if (priv->view) {
3693 eom_scroll_view_zoom_fit (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
3694 }
3695}
3696
3697static void
3698eom_window_cmd_go_prev (GtkAction *action, gpointer user_data)
3699{
3700 EomWindowPrivate *priv;
3701
3702 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3703
3704 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3704, ((const char*) (__func__
))
);
3705
3706 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3707
3708 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3709 EOM_THUMB_VIEW_SELECT_LEFT);
3710}
3711
3712static void
3713eom_window_cmd_go_next (GtkAction *action, gpointer user_data)
3714{
3715 EomWindowPrivate *priv;
3716
3717 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3718
3719 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3719, ((const char*) (__func__
))
);
3720
3721 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3722
3723 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3724 EOM_THUMB_VIEW_SELECT_RIGHT);
3725}
3726
3727static void
3728eom_window_cmd_go_first (GtkAction *action, gpointer user_data)
3729{
3730 EomWindowPrivate *priv;
3731
3732 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3733
3734 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3734, ((const char*) (__func__
))
);
3735
3736 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3737
3738 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3739 EOM_THUMB_VIEW_SELECT_FIRST);
3740}
3741
3742static void
3743eom_window_cmd_go_last (GtkAction *action, gpointer user_data)
3744{
3745 EomWindowPrivate *priv;
3746
3747 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3748
3749 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3749, ((const char*) (__func__
))
);
3750
3751 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3752
3753 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3754 EOM_THUMB_VIEW_SELECT_LAST);
3755}
3756
3757static void
3758eom_window_cmd_go_random (GtkAction *action, gpointer user_data)
3759{
3760 EomWindowPrivate *priv;
3761
3762 g_return_if_fail (EOM_IS_WINDOW (user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (user_data)"); return; } } while (0)
;
3763
3764 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3764, ((const char*) (__func__
))
);
3765
3766 priv = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
->priv;
3767
3768 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3769 EOM_THUMB_VIEW_SELECT_RANDOM);
3770}
3771
3772static const GtkActionEntry action_entries_window[] = {
3773 { "Image", NULL((void*)0), N_("_Image")("_Image") },
3774 { "Edit", NULL((void*)0), N_("_Edit")("_Edit") },
3775 { "View", NULL((void*)0), N_("_View")("_View") },
3776 { "Go", NULL((void*)0), N_("_Go")("_Go") },
3777 { "Tools", NULL((void*)0), N_("_Tools")("_Tools") },
3778 { "Help", NULL((void*)0), N_("_Help")("_Help") },
3779
3780 { "ImageOpen", "document-open", N_("_Open…")("_Open…"), "<control>O",
3781 N_("Open a file")("Open a file"),
3782 G_CALLBACK (eom_window_cmd_file_open)((GCallback) (eom_window_cmd_file_open)) },
3783 { "ImageClose", "window-close", N_("_Close")("_Close"), "<control>W",
3784 N_("Close window")("Close window"),
3785 G_CALLBACK (eom_window_cmd_close_window)((GCallback) (eom_window_cmd_close_window)) },
3786 { "EditToolbar", NULL((void*)0), N_("T_oolbar")("T_oolbar"), NULL((void*)0),
3787 N_("Edit the application toolbar")("Edit the application toolbar"),
3788 G_CALLBACK (eom_window_cmd_edit_toolbar)((GCallback) (eom_window_cmd_edit_toolbar)) },
3789 { "EditPreferences", "preferences-desktop", N_("Prefere_nces")("Prefere_nces"), NULL((void*)0),
3790 N_("Preferences for Eye of MATE")("Preferences for Eye of MATE"),
3791 G_CALLBACK (eom_window_cmd_preferences)((GCallback) (eom_window_cmd_preferences)) },
3792 { "HelpManual", "help-browser", N_("_Contents")("_Contents"), "F1",
3793 N_("Help on this application")("Help on this application"),
3794 G_CALLBACK (eom_window_cmd_help)((GCallback) (eom_window_cmd_help)) },
3795 { "HelpAbout", "help-about", N_("_About")("_About"), NULL((void*)0),
3796 N_("About this application")("About this application"),
3797 G_CALLBACK (eom_window_cmd_about)((GCallback) (eom_window_cmd_about)) }
3798};
3799
3800static const GtkToggleActionEntry toggle_entries_window[] = {
3801 { "ViewToolbar", NULL((void*)0), N_("_Toolbar")("_Toolbar"), NULL((void*)0),
3802 N_("Changes the visibility of the toolbar in the current window")("Changes the visibility of the toolbar in the current window"
)
,
3803 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3804 { "ViewStatusbar", NULL((void*)0), N_("_Statusbar")("_Statusbar"), NULL((void*)0),
3805 N_("Changes the visibility of the statusbar in the current window")("Changes the visibility of the statusbar in the current window"
)
,
3806 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3807 { "ViewImageCollection", "eom-image-collection", N_("_Image Collection")("_Image Collection"), "<control>F9",
3808 N_("Changes the visibility of the image collection pane in the current window")("Changes the visibility of the image collection pane in the current window"
)
,
3809 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3810 { "ViewSidebar", NULL((void*)0), N_("Side _Pane")("Side _Pane"), "F9",
3811 N_("Changes the visibility of the side pane in the current window")("Changes the visibility of the side pane in the current window"
)
,
3812 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3813};
3814
3815static const GtkActionEntry action_entries_image[] = {
3816 { "ImageSave", "document-save", N_("_Save")("_Save"), "<control>s",
3817 N_("Save changes in currently selected images")("Save changes in currently selected images"),
3818 G_CALLBACK (eom_window_cmd_save)((GCallback) (eom_window_cmd_save)) },
3819 { "ImageOpenWith", NULL((void*)0), N_("Open _with")("Open _with"), NULL((void*)0),
3820 N_("Open the selected image with a different application")("Open the selected image with a different application"),
3821 NULL((void*)0)},
3822 { "ImageSaveAs", "document-save-as", N_("Save _As…")("Save _As…"), "<control><shift>s",
3823 N_("Save the selected images with a different name")("Save the selected images with a different name"),
3824 G_CALLBACK (eom_window_cmd_save_as)((GCallback) (eom_window_cmd_save_as)) },
3825 { "ImageOpenContainingFolder", "folder", N_("Open Containing _Folder")("Open Containing _Folder"), NULL((void*)0),
3826 N_("Show the folder which contains this file in the file manager")("Show the folder which contains this file in the file manager"
)
,
3827 G_CALLBACK (eom_window_cmd_open_containing_folder)((GCallback) (eom_window_cmd_open_containing_folder)) },
3828 { "ImagePrint", "document-print", N_("_Print…")("_Print…"), "<control>p",
3829 N_("Print the selected image")("Print the selected image"),
3830 G_CALLBACK (eom_window_cmd_print)((GCallback) (eom_window_cmd_print)) },
3831 { "ImageProperties", "document-properties", N_("Prope_rties")("Prope_rties"), "<alt>Return",
3832 N_("Show the properties and metadata of the selected image")("Show the properties and metadata of the selected image"),
3833 G_CALLBACK (eom_window_cmd_properties)((GCallback) (eom_window_cmd_properties)) },
3834 { "EditUndo", "edit-undo", N_("_Undo")("_Undo"), "<control>z",
3835 N_("Undo the last change in the image")("Undo the last change in the image"),
3836 G_CALLBACK (eom_window_cmd_undo)((GCallback) (eom_window_cmd_undo)) },
3837 { "EditFlipHorizontal", "object-flip-horizontal", N_("Flip _Horizontal")("Flip _Horizontal"), NULL((void*)0),
3838 N_("Mirror the image horizontally")("Mirror the image horizontally"),
3839 G_CALLBACK (eom_window_cmd_flip_horizontal)((GCallback) (eom_window_cmd_flip_horizontal)) },
3840 { "EditFlipVertical", "object-flip-vertical", N_("Flip _Vertical")("Flip _Vertical"), NULL((void*)0),
3841 N_("Mirror the image vertically")("Mirror the image vertically"),
3842 G_CALLBACK (eom_window_cmd_flip_vertical)((GCallback) (eom_window_cmd_flip_vertical)) },
3843 { "EditRotate90", "object-rotate-right", N_("_Rotate Clockwise")("_Rotate Clockwise"), "<control>r",
3844 N_("Rotate the image 90 degrees to the right")("Rotate the image 90 degrees to the right"),
3845 G_CALLBACK (eom_window_cmd_rotate_90)((GCallback) (eom_window_cmd_rotate_90)) },
3846 { "EditRotate270", "object-rotate-left", N_("Rotate Counterc_lockwise")("Rotate Counterc_lockwise"), "<ctrl><shift>r",
3847 N_("Rotate the image 90 degrees to the left")("Rotate the image 90 degrees to the left"),
3848 G_CALLBACK (eom_window_cmd_rotate_270)((GCallback) (eom_window_cmd_rotate_270)) },
3849 { "ImageSetAsWallpaper", NULL((void*)0), N_("Set as _Desktop Background")("Set as _Desktop Background"),
3850 "<control>F8", N_("Set the selected image as the desktop background")("Set the selected image as the desktop background"),
3851 G_CALLBACK (eom_window_cmd_wallpaper)((GCallback) (eom_window_cmd_wallpaper)) },
3852 { "EditMoveToTrash", "user-trash", N_("Move to _Trash")("Move to _Trash"), NULL((void*)0),
3853 N_("Move the selected image to the trash folder")("Move the selected image to the trash folder"),
3854 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3855 { "EditCopyImage", "edit-copy", N_("_Copy")("_Copy"), "<control>C",
3856 N_("Copy the selected image to the clipboard")("Copy the selected image to the clipboard"),
3857 G_CALLBACK (eom_window_cmd_copy_image)((GCallback) (eom_window_cmd_copy_image)) },
3858 { "ViewZoomIn", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>plus",
3859 N_("Enlarge the image")("Enlarge the image"),
3860 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3861 { "ViewZoomOut", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>minus",
3862 N_("Shrink the image")("Shrink the image"),
3863 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3864 { "ViewZoomNormal", "zoom-original", N_("_Normal Size")("_Normal Size"), "<control>0",
3865 N_("Show the image at its normal size")("Show the image at its normal size"),
3866 G_CALLBACK (eom_window_cmd_zoom_normal)((GCallback) (eom_window_cmd_zoom_normal)) },
3867 { "ViewZoomFit", "zoom-fit-best", N_("_Best Fit")("_Best Fit"), "F",
3868 N_("Fit the image to the window")("Fit the image to the window"),
3869 G_CALLBACK (eom_window_cmd_zoom_fit)((GCallback) (eom_window_cmd_zoom_fit)) },
3870 { "ControlEqual", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>equal",
3871 N_("Enlarge the image")("Enlarge the image"),
3872 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3873 { "ControlKpAdd", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>KP_Add",
3874 N_("Shrink the image")("Shrink the image"),
3875 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3876 { "ControlKpSub", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>KP_Subtract",
3877 N_("Shrink the image")("Shrink the image"),
3878 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3879 { "Delete", NULL((void*)0), N_("Move to _Trash")("Move to _Trash"), "Delete",
3880 NULL((void*)0),
3881 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3882};
3883
3884static const GtkToggleActionEntry toggle_entries_image[] = {
3885 { "ViewFullscreen", "view-fullscreen", N_("_Fullscreen")("_Fullscreen"), "F11",
3886 N_("Show the current image in fullscreen mode")("Show the current image in fullscreen mode"),
3887 G_CALLBACK (eom_window_cmd_fullscreen)((GCallback) (eom_window_cmd_fullscreen)), FALSE(0) },
3888 { "PauseSlideshow", "media-playback-pause", N_("Pause Slideshow")("Pause Slideshow"),
3889 NULL((void*)0), N_("Pause or resume the slideshow")("Pause or resume the slideshow"),
3890 G_CALLBACK (eom_window_cmd_pause_slideshow)((GCallback) (eom_window_cmd_pause_slideshow)), FALSE(0) },
3891};
3892
3893static const GtkActionEntry action_entries_collection[] = {
3894 { "GoPrevious", "go-previous", N_("_Previous Image")("_Previous Image"), "<Alt>Left",
3895 N_("Go to the previous image of the collection")("Go to the previous image of the collection"),
3896 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3897 { "GoNext", "go-next", N_("_Next Image")("_Next Image"), "<Alt>Right",
3898 N_("Go to the next image of the collection")("Go to the next image of the collection"),
3899 G_CALLBACK (eom_window_cmd_go_next)((GCallback) (eom_window_cmd_go_next)) },
3900 { "GoFirst", "go-first", N_("_First Image")("_First Image"), "<Alt>Home",
3901 N_("Go to the first image of the collection")("Go to the first image of the collection"),
3902 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3903 { "GoLast", "go-last", N_("_Last Image")("_Last Image"), "<Alt>End",
3904 N_("Go to the last image of the collection")("Go to the last image of the collection"),
3905 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3906 { "GoRandom", NULL((void*)0), N_("_Random Image")("_Random Image"), "<control>M",
3907 N_("Go to a random image of the collection")("Go to a random image of the collection"),
3908 G_CALLBACK (eom_window_cmd_go_random)((GCallback) (eom_window_cmd_go_random)) },
3909 { "BackSpace", NULL((void*)0), N_("_Previous Image")("_Previous Image"), "BackSpace",
3910 NULL((void*)0),
3911 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3912 { "Home", NULL((void*)0), N_("_First Image")("_First Image"), "Home",
3913 NULL((void*)0),
3914 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3915 { "End", NULL((void*)0), N_("_Last Image")("_Last Image"), "End",
3916 NULL((void*)0),
3917 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3918};
3919
3920static const GtkToggleActionEntry toggle_entries_collection[] = {
3921 { "ViewSlideshow", "slideshow-play", N_("S_lideshow")("S_lideshow"), "F5",
3922 N_("Start a slideshow view of the images")("Start a slideshow view of the images"),
3923 G_CALLBACK (eom_window_cmd_slideshow)((GCallback) (eom_window_cmd_slideshow)), FALSE(0) },
3924};
3925
3926static void
3927menu_item_select_cb (GtkMenuItem *proxy, EomWindow *window)
3928{
3929 GtkAction *action;
3930 char *message;
3931
3932 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3933 action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)((((GtkActivatable*) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((gtk_activatable_get_type ()))))))
);
3934 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3935
3936 g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "action != NULL"); return
; } } while (0)
;
3937
3938 g_object_get (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "tooltip", &message, NULL((void*)0));
3939
3940 if (message) {
3941 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3942 window->priv->tip_message_cid, message);
3943 g_free (message);
3944 }
3945}
3946
3947static void
3948menu_item_deselect_cb (GtkMenuItem *proxy, EomWindow *window)
3949{
3950 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3951 window->priv->tip_message_cid);
3952}
3953
3954static void
3955connect_proxy_cb (GtkUIManager *manager,
3956 GtkAction *action,
3957 GtkWidget *proxy,
3958 EomWindow *window)
3959{
3960 if (GTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(proxy)); GType __t = ((gtk_menu_item_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; }))))
) {
3961 disconnect_proxy_cb (manager, action, proxy, window);
3962 g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
3963 G_CALLBACK (menu_item_select_cb), window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
3964 g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3965 G_CALLBACK (menu_item_deselect_cb), window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3966 }
3967}
3968
3969static void
3970disconnect_proxy_cb (GtkUIManager *manager,
3971 GtkAction *action,
3972 GtkWidget *proxy,
3973 EomWindow *window)
3974{
3975 if (GTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(proxy)); GType __t = ((gtk_menu_item_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; }))))
) {
3976 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_select_cb))), (window))
3977 (proxy, G_CALLBACK (menu_item_select_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_select_cb))), (window))
;
3978 g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_deselect_cb))), (window))
3979 (proxy, G_CALLBACK (menu_item_deselect_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (menu_item_deselect_cb))), (window))
;
3980 }
3981}
3982
3983static void
3984set_action_properties (GtkActionGroup *window_group,
3985 GtkActionGroup *image_group,
3986 GtkActionGroup *collection_group)
3987{
3988 GtkAction *action;
3989
3990 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3991 action = gtk_action_group_get_action (collection_group, "GoPrevious");
3992 g_object_set (action, "short_label", _("Previous")gettext ("Previous"), NULL((void*)0));
3993 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3994
3995 action = gtk_action_group_get_action (collection_group, "GoNext");
3996 g_object_set (action, "short_label", _("Next")gettext ("Next"), NULL((void*)0));
3997 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3998
3999 action = gtk_action_group_get_action (image_group, "EditRotate90");
4000 g_object_set (action, "short_label", _("Right")gettext ("Right"), NULL((void*)0));
4001
4002 action = gtk_action_group_get_action (image_group, "EditRotate270");
4003 g_object_set (action, "short_label", _("Left")gettext ("Left"), NULL((void*)0));
4004
4005 action = gtk_action_group_get_action (image_group, "ImageOpenContainingFolder");
4006 g_object_set (action, "short_label", _("Open Folder")gettext ("Open Folder"), NULL((void*)0));
4007
4008 action = gtk_action_group_get_action (image_group, "ViewZoomIn");
4009 g_object_set (action, "short_label", _("In")gettext ("In"), NULL((void*)0));
4010
4011 action = gtk_action_group_get_action (image_group, "ViewZoomOut");
4012 g_object_set (action, "short_label", _("Out")gettext ("Out"), NULL((void*)0));
4013
4014 action = gtk_action_group_get_action (image_group, "ViewZoomNormal");
4015 g_object_set (action, "short_label", _("Normal")gettext ("Normal"), NULL((void*)0));
4016
4017 action = gtk_action_group_get_action (image_group, "ViewZoomFit");
4018 g_object_set (action, "short_label", _("Fit")gettext ("Fit"), NULL((void*)0));
4019
4020 action = gtk_action_group_get_action (window_group, "ViewImageCollection");
4021 g_object_set (action, "short_label", _("Collection")gettext ("Collection"), NULL((void*)0));
4022
4023 action = gtk_action_group_get_action (image_group, "EditMoveToTrash");
4024 g_object_set (action, "short_label", C_("action (to trash)", "Trash")g_dpgettext (((void*)0), "action (to trash)" "\004" "Trash", strlen
("action (to trash)") + 1)
, NULL((void*)0));
4025 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4026}
4027
4028static gint
4029sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
4030{
4031 gboolean has_eom_a, has_eom_b;
4032
4033 /* We need to check this first as gtk_recent_info_get_application_info
4034 * will treat it as a non-fatal error when the GtkRecentInfo doesn't
4035 * have the application registered. */
4036 has_eom_a = gtk_recent_info_has_application (a,
4037 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4038 has_eom_b = gtk_recent_info_has_application (b,
4039 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4040 if (has_eom_a && has_eom_b) {
4041 time_t time_a, time_b;
4042
4043 /* These should not fail as we already checked that
4044 * the application is registered with the info objects */
4045 gtk_recent_info_get_application_info (a,
4046 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4047 NULL((void*)0),
4048 NULL((void*)0),
4049 &time_a);
4050 gtk_recent_info_get_application_info (b,
4051 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4052 NULL((void*)0),
4053 NULL((void*)0),
4054 &time_b);
4055
4056 return (time_b - time_a);
4057 } else if (has_eom_a) {
4058 return -1;
4059 } else if (has_eom_b) {
4060 return 1;
4061 }
4062
4063 return 0;
4064}
4065
4066static void
4067eom_window_update_recent_files_menu (EomWindow *window)
4068{
4069 EomWindowPrivate *priv;
4070 GList *actions = NULL((void*)0), *li = NULL((void*)0), *items = NULL((void*)0);
4071 guint count_recent = 0;
4072
4073 priv = window->priv;
4074
4075 if (priv->recent_menu_id != 0)
4076 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->recent_menu_id);
4077
4078 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4079 actions = gtk_action_group_list_actions (priv->actions_recent);
4080
4081 for (li = actions; li != NULL((void*)0); li = li->next) {
4082 g_signal_handlers_disconnect_by_func (GTK_ACTION (li->data),g_signal_handlers_disconnect_matched ((((((GtkAction*) g_type_check_instance_cast
((GTypeInstance*) ((li->data)), ((gtk_action_get_type ())
)))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_open_recent_cb
))), (window))
4083 G_CALLBACK(eom_window_open_recent_cb),g_signal_handlers_disconnect_matched ((((((GtkAction*) g_type_check_instance_cast
((GTypeInstance*) ((li->data)), ((gtk_action_get_type ())
)))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_open_recent_cb
))), (window))
4084 window)g_signal_handlers_disconnect_matched ((((((GtkAction*) g_type_check_instance_cast
((GTypeInstance*) ((li->data)), ((gtk_action_get_type ())
)))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_open_recent_cb
))), (window))
;
4085
4086 gtk_action_group_remove_action (priv->actions_recent,
4087 GTK_ACTION (li->data)((((GtkAction*) g_type_check_instance_cast ((GTypeInstance*) (
(li->data)), ((gtk_action_get_type ()))))))
);
4088 }
4089 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4090
4091 g_list_free (actions);
4092
4093 priv->recent_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
4094 items = gtk_recent_manager_get_items (gtk_recent_manager_get_default());
4095 items = g_list_sort (items, (GCompareFunc) sort_recents_mru);
4096
4097 for (li = items; li != NULL((void*)0) && count_recent < EOM_RECENT_FILES_LIMIT5; li = li->next) {
4098 gchar *action_name;
4099 gchar *label;
4100 gchar *tip;
4101 gchar **display_name;
4102 gchar *label_filename;
4103 GtkAction *action;
4104 GtkRecentInfo *info = li->data;
4105
4106 /* Sorting moves non-EOM files to the end of the list.
4107 * So no file of interest will follow if this test fails */
4108 if (!gtk_recent_info_has_application (info, EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer"))
4109 break;
4110
4111 count_recent++;
4112
4113 action_name = g_strdup_printf ("recent-info-%d", count_recent);
4114 display_name = g_strsplit (gtk_recent_info_get_display_name (info), "_", -1);
4115 label_filename = g_strjoinv ("__", display_name);
4116 label = g_strdup_printf ("%s_%d. %s",
4117 (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "\xE2\x80\x8F" : ""), count_recent, label_filename);
4118 g_free (label_filename);
4119 g_strfreev (display_name);
4120
4121 tip = gtk_recent_info_get_uri_display (info);
4122
4123 /* This is a workaround for a bug (#351945) regarding
4124 * gtk_recent_info_get_uri_display() and remote URIs.
4125 * mate_vfs_format_uri_for_display is sufficient here
4126 * since the password gets stripped when adding the
4127 * file to the recently used list. */
4128 if (tip == NULL((void*)0))
4129 tip = g_uri_unescape_string (gtk_recent_info_get_uri (info), NULL((void*)0));
4130
4131 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4132 action = gtk_action_new (action_name, label, tip, NULL((void*)0));
4133 gtk_action_set_always_show_image (action, TRUE(!(0)));
4134 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4135
4136 g_object_set_data_full (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info",
4137 gtk_recent_info_ref (info),
4138 (GDestroyNotify) gtk_recent_info_unref);
4139
4140 g_object_set (G_OBJECT (action)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
action)), (((GType) ((20) << (2))))))))
, "icon-name", "image-x-generic", NULL((void*)0));
4141
4142 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4143 G_CALLBACK (eom_window_open_recent_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4144 window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4145
4146 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4147 gtk_action_group_add_action (priv->actions_recent, action);
4148 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4149
4150 g_object_unref (action);
4151
4152 gtk_ui_manager_add_ui (priv->ui_mgr, priv->recent_menu_id,
4153 "/MainMenu/Image/RecentDocuments",
4154 action_name, action_name,
4155 GTK_UI_MANAGER_AUTO, FALSE(0));
4156
4157 g_free (action_name);
4158 g_free (label);
4159 g_free (tip);
4160 }
4161
4162 g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
4163}
4164
4165static void
4166eom_window_recent_manager_changed_cb (GtkRecentManager *manager, EomWindow *window)
4167{
4168 eom_window_update_recent_files_menu (window);
4169}
4170
4171static void
4172eom_window_drag_data_received (GtkWidget *widget,
4173 GdkDragContext *context,
4174 gint x, gint y,
4175 GtkSelectionData *selection_data,
4176 guint info, guint time)
4177{
4178 GSList *file_list;
4179 EomWindow *window;
4180 GdkAtom target;
4181 GtkWidget *src;
4182
4183 target = gtk_selection_data_get_target (selection_data);
4184
4185 if (!gtk_targets_include_uri (&target, 1))
4186 return;
4187
4188 /* if the request is from another process this will return NULL */
4189 src = gtk_drag_get_source_widget (context);
4190
4191 /* if the drag request originates from the current eom instance, ignore
4192 the request if the source window is the same as the dest window */
4193 if (src &&
4194 gtk_widget_get_toplevel (src) == gtk_widget_get_toplevel (widget))
4195 {
4196 gdk_drag_status (context, 0, time);
4197 return;
4198 }
4199
4200 if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_COPY) {
4201 window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
4202
4203 file_list = eom_util_parse_uri_string_list_to_file_list ((const gchar *) gtk_selection_data_get_data (selection_data));
4204
4205 eom_window_open_file_list (window, file_list);
4206 }
4207}
4208
4209static void
4210eom_window_set_drag_dest (EomWindow *window)
4211{
4212 gtk_drag_dest_set (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
,
4213 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
4214 NULL((void*)0), 0,
4215 GDK_ACTION_COPY | GDK_ACTION_ASK);
4216 gtk_drag_dest_add_uri_targets (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
4217}
4218
4219static void
4220eom_window_sidebar_visibility_changed (GtkWidget *widget, EomWindow *window)
4221{
4222 GtkAction *action;
4223 gboolean visible;
4224
4225 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4226 visible = gtk_widget_get_visible (window->priv->sidebar);
4227
4228 action = gtk_action_group_get_action (window->priv->actions_window,
4229 "ViewSidebar");
4230
4231 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
) != visible)
4232 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
4233 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4234
4235 /* Focus the image */
4236 if (!visible && window->priv->image != NULL((void*)0))
4237 gtk_widget_grab_focus (window->priv->view);
4238}
4239
4240static void
4241eom_window_sidebar_page_added (EomSidebar *sidebar,
4242 GtkWidget *main_widget,
4243 EomWindow *window)
4244{
4245 if (eom_sidebar_get_n_pages (sidebar) == 1) {
4246 GtkAction *action;
4247 gboolean show;
4248
4249 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4250 action = gtk_action_group_get_action (window->priv->actions_window,
4251 "ViewSidebar");
4252
4253 gtk_action_set_sensitive (action, TRUE(!(0)));
4254
4255 show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
4256 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4257
4258 if (show)
4259 gtk_widget_show (GTK_WIDGET (sidebar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(sidebar)), ((gtk_widget_get_type ()))))))
);
4260 }
4261}
4262static void
4263eom_window_sidebar_page_removed (EomSidebar *sidebar,
4264 GtkWidget *main_widget,
4265 EomWindow *window)
4266{
4267 if (eom_sidebar_is_empty (sidebar)) {
4268 GtkAction *action;
4269
4270 gtk_widget_hide (GTK_WIDGET (sidebar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(sidebar)), ((gtk_widget_get_type ()))))))
);
4271
4272 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4273 action = gtk_action_group_get_action (window->priv->actions_window,
4274 "ViewSidebar");
4275
4276 gtk_action_set_sensitive (action, FALSE(0));
4277 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4278 }
4279}
4280
4281static void
4282eom_window_finish_saving (EomWindow *window)
4283{
4284 EomWindowPrivate *priv = window->priv;
4285
4286 gtk_widget_set_sensitive (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
, FALSE(0));
4287
4288 do {
4289 gtk_main_iteration ();
4290 } while (priv->save_job != NULL((void*)0));
4291}
4292
4293static GAppInfo *
4294get_appinfo_for_editor (EomWindow *window)
4295{
4296 /* We want this function to always return the same thing, not
4297 * just for performance reasons, but because if someone edits
4298 * GConf while eom is running, the application could get into an
4299 * inconsistent state. If the editor exists once, it gets added
4300 * to the "available" list of the EggToolbarsModel (for which
4301 * there is no API to remove it). If later the editor no longer
4302 * existed when constructing a new window, we'd be unable to
4303 * construct a GtkAction for the editor for that window, causing
4304 * assertion failures when viewing the "Edit Toolbars" dialog
4305 * (item is available, but can't find the GtkAction for it).
4306 *
4307 * By ensuring we keep the GAppInfo around, we avoid the
4308 * possibility of that situation occurring.
4309 */
4310 static GDesktopAppInfo *app_info = NULL((void*)0);
4311 static gboolean initialised;
4312
4313 if (!initialised) {
4314 gchar *editor;
4315
4316 editor = g_settings_get_string (window->priv->ui_settings,
4317 EOM_CONF_UI_EXTERNAL_EDITOR"external-editor");
4318
4319 if (editor != NULL((void*)0)) {
4320 app_info = g_desktop_app_info_new (editor);
4321 }
4322
4323 initialised = TRUE(!(0));
4324 g_free (editor);
4325 }
4326
4327 return (GAppInfo *) app_info;
4328}
4329
4330static void
4331eom_window_open_editor (GtkAction *action,
4332 EomWindow *window)
4333{
4334 GdkAppLaunchContext *context;
4335 GAppInfo *app_info;
4336 GList files;
4337
4338 app_info = get_appinfo_for_editor (window);
4339
4340 if (app_info == NULL((void*)0))
4341 return;
4342
4343 context = gdk_display_get_app_launch_context (
4344 gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
));
4345 gdk_app_launch_context_set_screen (context,
4346 gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
));
4347 gdk_app_launch_context_set_icon (context,
4348 g_app_info_get_icon (app_info));
4349 gdk_app_launch_context_set_timestamp (context,
4350 gtk_get_current_event_time ());
4351
4352 {
4353 GList f = { eom_image_get_file (window->priv->image) };
4354 files = f;
4355 }
4356
4357 g_app_info_launch (app_info, &files,
4358 G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) g_type_check_instance_cast ((GTypeInstance
*) ((context)), ((g_app_launch_context_get_type ()))))))
, NULL((void*)0));
4359
4360 g_object_unref (files.data);
4361 g_object_unref (context);
4362}
4363
4364static void
4365eom_window_add_open_editor_action (EomWindow *window)
4366{
4367 EggToolbarsModel *model;
4368 GAppInfo *app_info;
4369 GtkAction *action;
4370 gchar *tooltip;
4371
4372 app_info = get_appinfo_for_editor (window);
4373
4374 if (app_info == NULL((void*)0))
4375 return;
4376
4377 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
4378 egg_toolbars_model_set_name_flags (model, "OpenEditor",
4379 EGG_TB_MODEL_NAME_KNOWN);
4380
4381 tooltip = g_strdup_printf (_("Edit the current image using %s")gettext ("Edit the current image using %s"),
4382 g_app_info_get_name (app_info));
4383 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4384 action = gtk_action_new ("OpenEditor", _("Edit Image")gettext ("Edit Image"), tooltip, NULL((void*)0));
4385 gtk_action_set_gicon (action, g_app_info_get_icon (app_info));
4386 gtk_action_set_is_important (action, TRUE(!(0)));
4387
4388 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
4389 G_CALLBACK (eom_window_open_editor), window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
;
4390
4391 gtk_action_group_add_action (window->priv->actions_image, action);
4392 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4393
4394 g_object_unref (action);
4395 g_free (tooltip);
4396}
4397
4398static void
4399eom_window_construct_ui (EomWindow *window)
4400{
4401 EomWindowPrivate *priv;
4402
4403 GError *error = NULL((void*)0);
4404
4405 GtkWidget *menubar;
4406 GtkWidget *thumb_popup;
4407 GtkWidget *view_popup;
4408 GtkWidget *hpaned;
4409 GtkWidget *menuitem;
4410
4411 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
4412
4413 priv = window->priv;
4414
4415 priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4416 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, priv->box);
4417 gtk_widget_show (priv->box);
4418
4419 priv->ui_mgr = gtk_ui_manager_new ();
4420
4421 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4422 priv->actions_window = gtk_action_group_new ("MenuActionsWindow");
4423
4424 gtk_action_group_set_translation_domain (priv->actions_window,
4425 GETTEXT_PACKAGE"eom");
4426
4427 gtk_action_group_add_actions (priv->actions_window,
4428 action_entries_window,
4429 G_N_ELEMENTS (action_entries_window)(sizeof (action_entries_window) / sizeof ((action_entries_window
)[0]))
,
4430 window);
4431
4432 gtk_action_group_add_toggle_actions (priv->actions_window,
4433 toggle_entries_window,
4434 G_N_ELEMENTS (toggle_entries_window)(sizeof (toggle_entries_window) / sizeof ((toggle_entries_window
)[0]))
,
4435 window);
4436 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4437
4438 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_window, 0);
4439
4440 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4441 priv->actions_image = gtk_action_group_new ("MenuActionsImage");
4442 gtk_action_group_set_translation_domain (priv->actions_image,
4443 GETTEXT_PACKAGE"eom");
4444
4445 gtk_action_group_add_actions (priv->actions_image,
4446 action_entries_image,
4447 G_N_ELEMENTS (action_entries_image)(sizeof (action_entries_image) / sizeof ((action_entries_image
)[0]))
,
4448 window);
4449
4450 eom_window_add_open_editor_action (window);
4451
4452 gtk_action_group_add_toggle_actions (priv->actions_image,
4453 toggle_entries_image,
4454 G_N_ELEMENTS (toggle_entries_image)(sizeof (toggle_entries_image) / sizeof ((toggle_entries_image
)[0]))
,
4455 window);
4456 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4457
4458 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_image, 0);
4459
4460 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4461 priv->actions_collection = gtk_action_group_new ("MenuActionsCollection");
4462 gtk_action_group_set_translation_domain (priv->actions_collection,
4463 GETTEXT_PACKAGE"eom");
4464
4465 gtk_action_group_add_actions (priv->actions_collection,
4466 action_entries_collection,
4467 G_N_ELEMENTS (action_entries_collection)(sizeof (action_entries_collection) / sizeof ((action_entries_collection
)[0]))
,
4468 window);
4469
4470 gtk_action_group_add_toggle_actions (priv->actions_collection,
4471 toggle_entries_collection,
4472 G_N_ELEMENTS (toggle_entries_collection)(sizeof (toggle_entries_collection) / sizeof ((toggle_entries_collection
)[0]))
,
4473 window);
4474 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4475
4476 set_action_properties (priv->actions_window,
4477 priv->actions_image,
4478 priv->actions_collection);
4479
4480 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_collection, 0);
4481
4482 if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
4483 "/org/mate/eom/ui/eom-ui.xml",
4484 &error)) {
4485 g_warning ("building menus failed: %s", error->message);
4486 g_error_free (error);
4487 }
4488
4489 g_signal_connect (priv->ui_mgr, "connect_proxy",g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4490 G_CALLBACK (connect_proxy_cb), window)g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4491 g_signal_connect (priv->ui_mgr, "disconnect_proxy",g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
4492 G_CALLBACK (disconnect_proxy_cb), window)g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
4493
4494 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
4495 g_assert (GTK_IS_WIDGET (menubar))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((menubar)); 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_assertion_message_expr ("EOM", "eom-window.c", 4495, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
4496 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
, menubar, FALSE(0), FALSE(0), 0);
4497 gtk_widget_show (menubar);
4498
4499 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4500 "/MainMenu/Edit/EditFlipHorizontal");
4501 gtk_image_menu_item_set_always_show_image (
4502 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4503
4504 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4505 "/MainMenu/Edit/EditFlipVertical");
4506 gtk_image_menu_item_set_always_show_image (
4507 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4508
4509 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4510 "/MainMenu/Edit/EditRotate90");
4511 gtk_image_menu_item_set_always_show_image (
4512 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4513
4514 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4515 "/MainMenu/Edit/EditRotate270");
4516 gtk_image_menu_item_set_always_show_image (
4517 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_image_menu_item_get_type ()))))))
, TRUE(!(0)));
4518
4519 priv->toolbar = GTK_WIDGET((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4520 (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4521 "ui-manager", priv->ui_mgr,((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4522 "popup-path", "/ToolbarPopup",((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4523 "model", eom_application_get_toolbars_model (EOM_APP),((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
4524 NULL))((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((egg_editable_toolbar_get_type ()), "ui-manager"
, priv->ui_mgr, "popup-path", "/ToolbarPopup", "model", eom_application_get_toolbars_model
((eom_application_get_instance ())), ((void*)0)))), ((gtk_widget_get_type
()))))))
;
4525
4526 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (priv->toolbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->toolbar)), ((gtk_widget_get_type ()))))))
),
4527 GTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar");
4528
4529 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (priv->toolbar)((((EggEditableToolbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->toolbar)), ((egg_editable_toolbar_get_type ()))
))))
,
4530 "Toolbar");
4531
4532 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
,
4533 priv->toolbar,
4534 FALSE(0),
4535 FALSE(0),
4536 0);
4537
4538 gtk_widget_show (priv->toolbar);
4539
4540 gtk_window_add_accel_group (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
4541 gtk_ui_manager_get_accel_group (priv->ui_mgr));
4542
4543 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4544 priv->actions_recent = gtk_action_group_new ("RecentFilesActions");
4545 gtk_action_group_set_translation_domain (priv->actions_recent,
4546 GETTEXT_PACKAGE"eom");
4547 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4548
4549 g_signal_connect (gtk_recent_manager_get_default (), "changed",g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4550 G_CALLBACK (eom_window_recent_manager_changed_cb),g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4551 window)g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4552
4553 eom_window_update_recent_files_menu (window);
4554
4555 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_recent, 0);
4556
4557 priv->cbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4558 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
, priv->cbox, TRUE(!(0)), TRUE(!(0)), 0);
4559 gtk_widget_show (priv->cbox);
4560
4561 priv->statusbar = eom_statusbar_new ();
4562 gtk_box_pack_end (GTK_BOX (priv->box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->box)), ((gtk_box_get_type ()))))))
,
4563 GTK_WIDGET (priv->statusbar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->statusbar)), ((gtk_widget_get_type ()))))))
,
4564 FALSE(0), FALSE(0), 0);
4565 gtk_widget_show (priv->statusbar);
4566
4567 priv->image_info_message_cid =
4568 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4569 "image_info_message");
4570 priv->tip_message_cid =
4571 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4572 "tip_message");
4573
4574 priv->layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
4575
4576 hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
4577
4578 priv->sidebar = eom_sidebar_new ();
4579 /* The sidebar shouldn't be shown automatically on show_all(),
4580 but only when the user actually wants it. */
4581 gtk_widget_set_no_show_all (priv->sidebar, TRUE(!(0)));
4582
4583 gtk_widget_set_size_request (priv->sidebar, 210, -1);
4584
4585 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4586 "show",g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4587 G_CALLBACK (eom_window_sidebar_visibility_changed),g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4588 window)g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4589
4590 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4591 "hide",g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4592 G_CALLBACK (eom_window_sidebar_visibility_changed),g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4593 window)g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4594
4595 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4596 "page-added",g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4597 G_CALLBACK (eom_window_sidebar_page_added),g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4598 window)g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4599
4600 g_signal_connect_after (priv->sidebar,g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
4601 "page-removed",g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
4602 G_CALLBACK (eom_window_sidebar_page_removed),g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
4603 window)g_signal_connect_data ((priv->sidebar), ("page-removed"), (
((GCallback) (eom_window_sidebar_page_removed))), (window), (
(void*)0), G_CONNECT_AFTER)
;
4604
4605 priv->view = eom_scroll_view_new ();
4606
4607 eom_sidebar_add_page (EOM_SIDEBAR (priv->sidebar)((((EomSidebar*) g_type_check_instance_cast ((GTypeInstance*)
((priv->sidebar)), ((eom_sidebar_get_type()))))))
,
4608 _("Properties")gettext ("Properties"),
4609 GTK_WIDGET (eom_metadata_sidebar_new (window))((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(eom_metadata_sidebar_new (window))), ((gtk_widget_get_type (
)))))))
);
4610
4611 gtk_widget_set_size_request (GTK_WIDGET (priv->view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->view)), ((gtk_widget_get_type ()))))))
, 100, 100);
4612 g_signal_connect (G_OBJECT (priv->view),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4613 "zoom_changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4614 G_CALLBACK (view_zoom_changed_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4615 window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->view)), (((GType) ((20) <<
(2))))))))), ("zoom_changed"), (((GCallback) (view_zoom_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4616
4617 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_SCROLL_WHEEL_ZOOM"scroll-wheel-zoom",
4618 priv->view, "scrollwheel-zoom", G_SETTINGS_BIND_GET);
4619 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_ZOOM_MULTIPLIER"zoom-multiplier",
4620 priv->view, "zoom-multiplier", G_SETTINGS_BIND_GET);
4621
4622 view_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ViewPopup");
4623 eom_scroll_view_set_popup (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
4624 GTK_MENU (view_popup)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
view_popup)), ((gtk_menu_get_type ()))))))
);
4625
4626 gtk_paned_pack1 (GTK_PANED (hpaned)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(hpaned)), ((gtk_paned_get_type ()))))))
,
4627 priv->sidebar,
4628 FALSE(0),
4629 FALSE(0));
4630
4631 gtk_paned_pack2 (GTK_PANED (hpaned)((((GtkPaned*) g_type_check_instance_cast ((GTypeInstance*) (
(hpaned)), ((gtk_paned_get_type ()))))))
,
4632 priv->view,
4633 TRUE(!(0)),
4634 FALSE(0));
4635
4636 gtk_widget_show_all (hpaned);
4637
4638 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
4639
4640 priv->thumbview = g_object_ref (eom_thumb_view_new ());
4641
4642 /* giving shape to the view */
4643 gtk_icon_view_set_margin (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) g_type_check_instance_cast ((GTypeInstance*
) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 4);
4644 gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) g_type_check_instance_cast ((GTypeInstance*
) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 0);
4645
4646 g_signal_connect (G_OBJECT (priv->thumbview), "selection_changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->thumbview)), (((GType) ((20) <<
(2))))))))), ("selection_changed"), (((GCallback) (handle_image_selection_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4647 G_CALLBACK (handle_image_selection_changed_cb), window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->thumbview)), (((GType) ((20) <<
(2))))))))), ("selection_changed"), (((GCallback) (handle_image_selection_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4648
4649 priv->nav = eom_thumb_nav_new (priv->thumbview,
4650 EOM_THUMB_NAV_MODE_ONE_ROW,
4651 g_settings_get_boolean (priv->ui_settings,
4652 EOM_CONF_UI_SCROLL_BUTTONS"scroll-buttons"));
4653
4654 // Bind the scroll buttons to their GSettings key
4655 g_settings_bind (priv->ui_settings, EOM_CONF_UI_SCROLL_BUTTONS"scroll-buttons",
4656 priv->nav, "show-buttons", G_SETTINGS_BIND_GET);
4657
4658 thumb_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ThumbnailPopup");
4659 eom_thumb_view_set_thumbnail_popup (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
4660 GTK_MENU (thumb_popup)((((GtkMenu*) g_type_check_instance_cast ((GTypeInstance*) ((
thumb_popup)), ((gtk_menu_get_type ()))))))
);
4661
4662 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->layout)), ((gtk_box_get_type ()))))))
, priv->nav, FALSE(0), FALSE(0), 0);
4663
4664 gtk_box_pack_end (GTK_BOX (priv->cbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((priv
->cbox)), ((gtk_box_get_type ()))))))
, priv->layout, TRUE(!(0)), TRUE(!(0)), 0);
4665
4666 eom_window_can_save_changed_cb (priv->lockdown_settings,
4667 EOM_CONF_LOCKDOWN_CAN_SAVE"disable-save-to-disk",
4668 window);
4669 g_settings_bind (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION_POSITION"image-collection-position",
4670 window, "collection-position", G_SETTINGS_BIND_GET);
4671 g_settings_bind (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION_RESIZABLE"image-collection-resizable",
4672 window, "collection-resizable", G_SETTINGS_BIND_GET);
4673
4674 update_action_groups_state (window);
4675
4676 if ((priv->flags & EOM_STARTUP_FULLSCREEN) ||
4677 (priv->flags & EOM_STARTUP_SLIDE_SHOW)) {
4678 eom_window_run_fullscreen (window, (priv->flags & EOM_STARTUP_SLIDE_SHOW));
4679 } else {
4680 priv->mode = EOM_WINDOW_MODE_NORMAL;
4681 update_ui_visibility (window);
4682 }
4683
4684 eom_window_set_drag_dest (window);
4685}
4686
4687static void
4688eom_window_init (EomWindow *window)
4689{
4690 GdkGeometry hints;
4691 GdkScreen *screen;
4692 EomWindowPrivate *priv;
4693
4694 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 4694, ((const char*) (__func__
))
);
4695
4696 GtkStyleContext *context;
4697
4698 context = gtk_widget_get_style_context (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
4699 gtk_style_context_add_class (context, "eom-window");
4700
4701 hints.min_width = EOM_WINDOW_MIN_WIDTH440;
4702 hints.min_height = EOM_WINDOW_MIN_HEIGHT350;
4703
4704 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
);
4705
4706 priv = window->priv = eom_window_get_instance_private (window);
4707
4708 priv->view_settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
4709 priv->ui_settings = g_settings_new (EOM_CONF_UI"org.mate.eom"".ui");
4710 priv->fullscreen_settings = g_settings_new (EOM_CONF_FULLSCREEN"org.mate.eom"".full-screen");
4711 priv->lockdown_settings = g_settings_new (EOM_CONF_LOCKDOWN_SCHEMA"org.mate.lockdown");
4712
4713 g_signal_connect (priv->lockdown_settings,g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4714 "changed::" EOM_CONF_LOCKDOWN_CAN_SAVE,g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4715 G_CALLBACK (eom_window_can_save_changed_cb),g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
4716 window)g_signal_connect_data ((priv->lockdown_settings), ("changed::"
"disable-save-to-disk"), (((GCallback) (eom_window_can_save_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4717
4718 window->priv->store = NULL((void*)0);
4719 window->priv->image = NULL((void*)0);
4720
4721 window->priv->fullscreen_popup = NULL((void*)0);
4722 window->priv->fullscreen_timeout_source = NULL((void*)0);
4723 window->priv->slideshow_random = FALSE(0);
4724 window->priv->slideshow_loop = FALSE(0);
4725 window->priv->slideshow_switch_timeout = 0;
4726 window->priv->slideshow_switch_source = NULL((void*)0);
4727 window->priv->fullscreen_idle_inhibit_cookie = 0;
4728
4729 gtk_window_set_geometry_hints (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
4730 GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
,
4731 &hints,
4732 GDK_HINT_MIN_SIZE);
4733
4734 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
,
4735 EOM_WINDOW_DEFAULT_WIDTH540,
4736 EOM_WINDOW_DEFAULT_HEIGHT450);
4737
4738 gtk_window_set_position (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER);
4739
4740 window->priv->mode = EOM_WINDOW_MODE_UNKNOWN;
4741 window->priv->status = EOM_WINDOW_STATUS_UNKNOWN;
4742
4743#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4744 window->priv->display_profile =
4745 eom_window_get_display_profile (screen);
4746#endif
4747
4748 window->priv->recent_menu_id = 0;
4749
4750 window->priv->collection_position = 0;
4751 window->priv->collection_resizable = FALSE(0);
4752
4753 window->priv->save_disabled = FALSE(0);
4754
4755 window->priv->page_setup = NULL((void*)0);
4756
4757 gtk_window_set_application (GTK_WINDOW (window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_window_get_type ()))))))
, GTK_APPLICATION (EOM_APP)((((GtkApplication*) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
);
4758}
4759
4760static void
4761eom_window_dispose (GObject *object)
4762{
4763 EomWindow *window;
4764 EomWindowPrivate *priv;
4765
4766 g_return_if_fail (object != NULL)do { if ((object != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "object != NULL"); return
; } } while (0)
;
4767 g_return_if_fail (EOM_IS_WINDOW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (object)"); return; } } while (0)
;
4768
4769 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 4769, ((const char*) (__func__
))
);
4770
4771 window = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
;
4772 priv = window->priv;
4773
4774 peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
);
4775
4776 if (priv->extensions != NULL((void*)0)) {
4777 g_object_unref (priv->extensions);
4778 priv->extensions = NULL((void*)0);
4779 peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
);
4780 }
4781
4782 if (priv->page_setup != NULL((void*)0)) {
4783 g_object_unref (priv->page_setup);
4784 priv->page_setup = NULL((void*)0);
4785 }
4786
4787 if (priv->thumbview)
4788 {
4789 /* Disconnect so we don't get any unwanted callbacks
4790 * when the thumb view is disposed. */
4791 g_signal_handlers_disconnect_by_func (priv->thumbview,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (handle_image_selection_changed_cb
))), (window))
4792 G_CALLBACK (handle_image_selection_changed_cb),g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (handle_image_selection_changed_cb
))), (window))
4793 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (handle_image_selection_changed_cb
))), (window))
;
4794 g_clear_object (&priv->thumbview)do { _Static_assert (sizeof *((&priv->thumbview)) == sizeof
(gpointer), "Expression evaluates to false"); union { char *
in; gpointer *out; } _pp; gpointer _p; GDestroyNotify _destroy
= (GDestroyNotify) (g_object_unref); _pp.in = (char *) ((&
priv->thumbview)); _p = *_pp.out; if (_p) { *_pp.out = ((void
*)0); _destroy (_p); } } while (0)
;
4795 }
4796
4797 if (priv->store != NULL((void*)0)) {
4798 g_signal_handlers_disconnect_by_func (priv->store,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_added), (window))
4799 eom_window_list_store_image_added,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_added), (window))
4800 window)g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_added), (window))
;
4801 g_signal_handlers_disconnect_by_func (priv->store,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_removed), (window))
4802 eom_window_list_store_image_removed,g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_removed), (window))
4803 window)g_signal_handlers_disconnect_matched ((priv->store), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_list_store_image_removed), (window))
;
4804 g_object_unref (priv->store);
4805 priv->store = NULL((void*)0);
4806 }
4807
4808 if (priv->image != NULL((void*)0)) {
4809 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
4810 image_thumb_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
4811 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_thumb_changed_cb), (window))
;
4812 g_signal_handlers_disconnect_by_func (priv->image,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
4813 image_file_changed_cb,g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
4814 window)g_signal_handlers_disconnect_matched ((priv->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (image_file_changed_cb), (window))
;
4815 g_object_unref (priv->image);
4816 priv->image = NULL((void*)0);
4817 }
4818
4819 if (priv->actions_window != NULL((void*)0)) {
4820 g_object_unref (priv->actions_window);
4821 priv->actions_window = NULL((void*)0);
4822 }
4823
4824 if (priv->actions_image != NULL((void*)0)) {
4825 g_object_unref (priv->actions_image);
4826 priv->actions_image = NULL((void*)0);
4827 }
4828
4829 if (priv->actions_collection != NULL((void*)0)) {
4830 g_object_unref (priv->actions_collection);
4831 priv->actions_collection = NULL((void*)0);
4832 }
4833
4834 if (priv->actions_recent != NULL((void*)0)) {
4835 g_object_unref (priv->actions_recent);
4836 priv->actions_recent = NULL((void*)0);
4837 }
4838
4839 if (priv->actions_open_with != NULL((void*)0)) {
4840 g_object_unref (priv->actions_open_with);
4841 priv->actions_open_with = NULL((void*)0);
4842 }
4843
4844 fullscreen_clear_timeout (window);
4845
4846 if (window->priv->fullscreen_popup != NULL((void*)0)) {
4847 gtk_widget_destroy (priv->fullscreen_popup);
4848 priv->fullscreen_popup = NULL((void*)0);
4849 }
4850
4851 slideshow_clear_timeout (window);
4852 eom_window_uninhibit_screensaver (window);
4853
4854 g_signal_handlers_disconnect_by_func (gtk_recent_manager_get_default (),g_signal_handlers_disconnect_matched ((gtk_recent_manager_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window))
4855 G_CALLBACK (eom_window_recent_manager_changed_cb),g_signal_handlers_disconnect_matched ((gtk_recent_manager_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window))
4856 window)g_signal_handlers_disconnect_matched ((gtk_recent_manager_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window))
;
4857
4858 priv->recent_menu_id = 0;
4859
4860 eom_window_clear_load_job (window);
4861
4862 eom_window_clear_transform_job (window);
4863
4864 if (priv->view_settings) {
4865 g_object_unref (priv->view_settings);
4866 priv->view_settings = NULL((void*)0);
4867 }
4868 if (priv->ui_settings) {
4869 g_object_unref (priv->ui_settings);
4870 priv->ui_settings = NULL((void*)0);
4871 }
4872 if (priv->fullscreen_settings) {
4873 g_object_unref (priv->fullscreen_settings);
4874 priv->fullscreen_settings = NULL((void*)0);
4875 }
4876 if (priv->lockdown_settings) {
4877 g_object_unref (priv->lockdown_settings);
4878 priv->lockdown_settings = NULL((void*)0);
4879 }
4880
4881 if (priv->file_list != NULL((void*)0)) {
4882 g_slist_free_full (priv->file_list, g_object_unref);
4883 priv->file_list = NULL((void*)0);
4884 }
4885
4886#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4887 if (priv->display_profile != NULL((void*)0)) {
4888 cmsCloseProfile (priv->display_profile);
4889 priv->display_profile = NULL((void*)0);
4890 }
4891#endif
4892
4893 if (priv->last_save_as_folder != NULL((void*)0)) {
4894 g_object_unref (priv->last_save_as_folder);
4895 priv->last_save_as_folder = NULL((void*)0);
4896 }
4897
4898 peas_engine_garbage_collect (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
);
4899
4900 G_OBJECT_CLASS (eom_window_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_window_parent_class
)), (((GType) ((20) << (2))))))))
->dispose (object);
4901}
4902
4903static gint
4904eom_window_delete (GtkWidget *widget, GdkEventAny *event)
4905{
4906 EomWindow *window;
4907 EomWindowPrivate *priv;
4908
4909 g_return_val_if_fail (EOM_IS_WINDOW (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (widget)"); return ((0)); } } while (0)
;
4910
4911 window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
4912 priv = window->priv;
4913
4914 if (priv->save_job != NULL((void*)0)) {
4915 eom_window_finish_saving (window);
4916 }
4917
4918 if (eom_window_unsaved_images_confirm (window)) {
4919 return TRUE(!(0));
4920 }
4921
4922 gtk_widget_destroy (widget);
4923
4924 return TRUE(!(0));
4925}
4926
4927static gint
4928eom_window_key_press (GtkWidget *widget, GdkEventKey *event)
4929{
4930 GtkContainer *tbcontainer = GTK_CONTAINER ((EOM_WINDOW (widget)->priv->toolbar))((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) (((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->toolbar
))), ((gtk_container_get_type ()))))))
;
4931 gint result = FALSE(0);
4932 gboolean handle_selection = FALSE(0);
4933
4934 switch (event->keyval) {
4935 case GDK_KEY_space0x020:
4936 if (event->state & GDK_CONTROL_MASK) {
4937 handle_selection = TRUE(!(0));
4938 break;
4939 }
4940 case GDK_KEY_Return0xff0d:
4941 if (gtk_container_get_focus_child (tbcontainer) == NULL((void*)0)) {
4942 /* Image properties dialog case */
4943 if (event->state & GDK_MOD1_MASK) {
4944 result = FALSE(0);
4945 break;
4946 }
4947
4948 if (event->state & GDK_SHIFT_MASK) {
4949 eom_window_cmd_go_prev (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4950 } else {
4951 eom_window_cmd_go_next (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4952 }
4953 result = TRUE(!(0));
4954 }
4955 break;
4956 case GDK_KEY_p0x070:
4957 case GDK_KEY_P0x050:
4958 if (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_FULLSCREEN || EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
4959 gboolean slideshow;
4960
4961 slideshow = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
4962 eom_window_run_fullscreen (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
, !slideshow);
4963 }
4964 break;
4965 case GDK_KEY_Q0x051:
4966 case GDK_KEY_q0x071:
4967 case GDK_KEY_Escape0xff1b:
4968 if (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_FULLSCREEN) {
4969 eom_window_stop_fullscreen (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
, FALSE(0));
4970 } else if (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
4971 eom_window_stop_fullscreen (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
, TRUE(!(0)));
4972 } else {
4973 eom_window_cmd_close_window (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4974 return TRUE(!(0));
4975 }
4976 break;
4977 case GDK_KEY_Left0xff51:
4978 if (event->state & GDK_MOD1_MASK) {
4979 /* Alt+Left moves to previous image */
4980 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)) { /* move to next in RTL mode */
4981 eom_window_cmd_go_next (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4982 } else {
4983 eom_window_cmd_go_prev (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
4984 }
4985 result = TRUE(!(0));
4986 break;
4987 } /* else fall-trough is intended */
4988 case GDK_KEY_Up0xff52:
4989 if (eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
4990 /* break to let scrollview handle the key */
4991 break;
4992 }
4993 if (gtk_container_get_focus_child (tbcontainer) != NULL((void*)0))
4994 break;
4995 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
4996 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) && event->keyval == GDK_KEY_Left0xff51) {
4997 /* handle RTL fall-through,
4998 * need to behave like GDK_Down then */
4999 eom_window_cmd_go_next (NULL((void*)0),
5000 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5001 } else {
5002 eom_window_cmd_go_prev (NULL((void*)0),
5003 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5004 }
5005 result = TRUE(!(0));
5006 break;
5007 }
5008 case GDK_KEY_Right0xff53:
5009 if (event->state & GDK_MOD1_MASK) {
5010 /* Alt+Right moves to next image */
5011 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)) { /* move to previous in RTL mode */
5012 eom_window_cmd_go_prev (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5013 } else {
5014 eom_window_cmd_go_next (NULL((void*)0), EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5015 }
5016 result = TRUE(!(0));
5017 break;
5018 } /* else fall-trough is intended */
5019 case GDK_KEY_Down0xff54:
5020 if (eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
5021 /* break to let scrollview handle the key */
5022 break;
5023 }
5024 if (gtk_container_get_focus_child (tbcontainer) != NULL((void*)0))
5025 break;
5026 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
5027 if (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) && event->keyval == GDK_KEY_Right0xff53) {
5028 /* handle RTL fall-through,
5029 * need to behave like GDK_Up then */
5030 eom_window_cmd_go_prev (NULL((void*)0),
5031 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5032 } else {
5033 eom_window_cmd_go_next (NULL((void*)0),
5034 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5035 }
5036 result = TRUE(!(0));
5037 break;
5038 }
5039 case GDK_KEY_Page_Up0xff55:
5040 if (!eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
5041 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
5042 /* If the iconview is not visible skip to the
5043 * previous image manually as it won't handle
5044 * the keypress then. */
5045 eom_window_cmd_go_prev (NULL((void*)0),
5046 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5047 result = TRUE(!(0));
5048 } else
5049 handle_selection = TRUE(!(0));
5050 }
5051 break;
5052 case GDK_KEY_Page_Down0xff56:
5053 if (!eom_scroll_view_scrollbars_visible (EOM_SCROLL_VIEW (EOM_WINDOW (widget)->priv->view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((eom_scroll_view_get_type ()))))))
)) {
5054 if (!gtk_widget_get_visible (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->nav)) {
5055 /* If the iconview is not visible skip to the
5056 * next image manually as it won't handle
5057 * the keypress then. */
5058 eom_window_cmd_go_next (NULL((void*)0),
5059 EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5060 result = TRUE(!(0));
5061 } else
5062 handle_selection = TRUE(!(0));
5063 }
5064 break;
5065 }
5066
5067 /* Update slideshow timeout */
5068 if (result && (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_SLIDESHOW)) {
5069 slideshow_set_timeout (EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
);
5070 }
5071
5072 if (handle_selection == TRUE(!(0)) && result == FALSE(0)) {
5073 gtk_widget_grab_focus (GTK_WIDGET (EOM_WINDOW (widget)->priv->thumbview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->thumbview
)), ((gtk_widget_get_type ()))))))
);
5074
5075 result = gtk_widget_event (GTK_WIDGET (EOM_WINDOW (widget)->priv->thumbview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->thumbview
)), ((gtk_widget_get_type ()))))))
,
5076 (GdkEvent *) event);
5077 }
5078
5079 /* If the focus is not in the toolbar and we still haven't handled the
5080 event, give the scrollview a chance to do it. */
5081 if (!gtk_container_get_focus_child (tbcontainer) && result == FALSE(0) &&
5082 gtk_widget_get_realized (GTK_WIDGET (EOM_WINDOW (widget)->priv->view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((gtk_widget_get_type ()))))))
)) {
5083 result = gtk_widget_event (GTK_WIDGET (EOM_WINDOW (widget)->priv->view)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*)
((widget)), ((eom_window_get_type ()))))))->priv->view
)), ((gtk_widget_get_type ()))))))
,
5084 (GdkEvent *) event);
5085 }
5086
5087 if (result == FALSE(0) && GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event) {
5088 result = (* GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event) (widget, event);
5089 }
5090
5091 return result;
5092}
5093
5094static gint
5095eom_window_button_press (GtkWidget *widget, GdkEventButton *event)
5096{
5097 EomWindow *window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
5098 gint result = FALSE(0);
5099
5100 if (event->type == GDK_BUTTON_PRESS) {
5101 switch (event->button) {
5102 case 6:
5103 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5104 EOM_THUMB_VIEW_SELECT_LEFT);
5105 result = TRUE(!(0));
5106 break;
5107 case 7:
5108 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5109 EOM_THUMB_VIEW_SELECT_RIGHT);
5110 result = TRUE(!(0));
5111 break;
5112 }
5113 }
5114
5115 if (result == FALSE(0) && GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->button_press_event) {
5116 result = (* GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->button_press_event) (widget, event);
5117 }
5118
5119 return result;
5120}
5121
5122static gboolean
5123eom_window_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
5124{
5125 EomWindow *window = EOM_WINDOW (widget)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(widget)), ((eom_window_get_type ()))))))
;
5126 EomWindowPrivate *priv = window->priv;
5127 gboolean fullscreen;
5128
5129 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5129, ((const char*) (__func__
))
);
5130
5131 fullscreen = priv->mode == EOM_WINDOW_MODE_FULLSCREEN ||
5132 priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
5133
5134 if (fullscreen) {
5135 gtk_widget_hide (priv->fullscreen_popup);
5136 }
5137
5138 return GTK_WIDGET_CLASS (eom_window_parent_class)((((GtkWidgetClass*) g_type_check_class_cast ((GTypeClass*) (
(eom_window_parent_class)), ((gtk_widget_get_type ()))))))
->focus_out_event (widget, event);
5139}
5140
5141static void
5142eom_window_set_property (GObject *object,
5143 guint property_id,
5144 const GValue *value,
5145 GParamSpec *pspec)
5146{
5147 EomWindow *window;
5148 EomWindowPrivate *priv;
5149
5150 g_return_if_fail (EOM_IS_WINDOW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (object)"); return; } } while (0)
;
5151
5152 window = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
;
5153 priv = window->priv;
5154
5155 switch (property_id) {
5156 case PROP_COLLECTION_POS:
5157 eom_window_set_collection_mode (window, g_value_get_enum (value),
5158 priv->collection_resizable);
5159 break;
5160 case PROP_COLLECTION_RESIZABLE:
5161 eom_window_set_collection_mode (window, priv->collection_position,
5162 g_value_get_boolean (value));
5163 break;
5164 case PROP_STARTUP_FLAGS:
5165 priv->flags = g_value_get_flags (value);
5166 break;
5167
5168 default:
5169 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-window.c", 5169, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
5170 }
5171}
5172
5173static void
5174eom_window_get_property (GObject *object,
5175 guint property_id,
5176 GValue *value,
5177 GParamSpec *pspec)
5178{
5179 EomWindow *window;
5180 EomWindowPrivate *priv;
5181
5182 g_return_if_fail (EOM_IS_WINDOW (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (object)"); return; } } while (0)
;
5183
5184 window = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
;
5185 priv = window->priv;
5186
5187 switch (property_id) {
5188 case PROP_COLLECTION_POS:
5189 g_value_set_enum (value, priv->collection_position);
5190 break;
5191 case PROP_COLLECTION_RESIZABLE:
5192 g_value_set_boolean (value, priv->collection_resizable);
5193 break;
5194 case PROP_STARTUP_FLAGS:
5195 g_value_set_flags (value, priv->flags);
5196 break;
5197
5198 default:
5199 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-window.c", 5199, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
5200 }
5201}
5202
5203static void
5204on_extension_added (PeasExtensionSet *set,
5205 PeasPluginInfo *info,
5206 PeasExtension *exten,
5207 GtkWindow *window)
5208{
5209 peas_extension_call (exten, "activate", window);
5210}
5211
5212static void
5213on_extension_removed (PeasExtensionSet *set,
5214 PeasPluginInfo *info,
5215 PeasExtension *exten,
5216 GtkWindow *window)
5217{
5218 peas_extension_call (exten, "deactivate", window);
5219}
5220
5221static GObject *
5222eom_window_constructor (GType type,
5223 guint n_construct_properties,
5224 GObjectConstructParam *construct_params)
5225{
5226 GObject *object;
5227 EomWindowPrivate *priv;
5228
5229 object = G_OBJECT_CLASS (eom_window_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_window_parent_class
)), (((GType) ((20) << (2))))))))
->constructor
5230 (type, n_construct_properties, construct_params);
5231
5232 priv = EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
->priv;
5233
5234 eom_window_construct_ui (EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
);
5235
5236 priv->extensions = peas_extension_set_new (PEAS_ENGINE (EOM_APP->priv->plugin_engine)((((PeasEngine*) g_type_check_instance_cast ((GTypeInstance*)
(((eom_application_get_instance ())->priv->plugin_engine
)), ((peas_engine_get_type ()))))))
,
5237 EOM_TYPE_WINDOW_ACTIVATABLE(eom_window_activatable_get_type ()),
5238 "window",
5239 EOM_WINDOW (object)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(object)), ((eom_window_get_type ()))))))
, NULL((void*)0));
5240
5241 peas_extension_set_call (priv->extensions, "activate");
5242
5243 g_signal_connect (priv->extensions, "extension-added",g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
5244 G_CALLBACK (on_extension_added), object)g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
;
5245 g_signal_connect (priv->extensions, "extension-removed",g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
5246 G_CALLBACK (on_extension_removed), object)g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
;
5247
5248 return object;
5249}
5250
5251static void
5252eom_window_class_init (EomWindowClass *class)
5253{
5254 GObjectClass *g_object_class = (GObjectClass *) class;
5255 GtkWidgetClass *widget_class = (GtkWidgetClass *) class;
5256
5257 g_object_class->constructor = eom_window_constructor;
5258 g_object_class->dispose = eom_window_dispose;
5259 g_object_class->set_property = eom_window_set_property;
5260 g_object_class->get_property = eom_window_get_property;
5261
5262 widget_class->delete_event = eom_window_delete;
5263 widget_class->key_press_event = eom_window_key_press;
5264 widget_class->button_press_event = eom_window_button_press;
5265 widget_class->drag_data_received = eom_window_drag_data_received;
5266 widget_class->focus_out_event = eom_window_focus_out_event;
5267
5268/**
5269 * EomWindow:collection-position:
5270 *
5271 * Determines the position of the image collection in the window
5272 * relative to the image.
5273 */
5274 g_object_class_install_property (
5275 g_object_class, PROP_COLLECTION_POS,
5276 g_param_spec_enum ("collection-position", NULL((void*)0), NULL((void*)0),
5277 EOM_TYPE_WINDOW_COLLECTION_POS(eom_window_collection_pos_get_type()),
5278 EOM_WINDOW_COLLECTION_POS_BOTTOM,
5279 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5280
5281/**
5282 * EomWindow:collection-resizable:
5283 *
5284 * If %TRUE the collection will be resizable by the user otherwise it will be
5285 * in single column/row mode.
5286 */
5287 g_object_class_install_property (
5288 g_object_class, PROP_COLLECTION_RESIZABLE,
5289 g_param_spec_boolean ("collection-resizable", NULL((void*)0), NULL((void*)0), FALSE(0),
5290 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5291
5292/**
5293 * EomWindow:startup-flags:
5294 *
5295 * A bitwise OR of #EomStartupFlags elements, indicating how the window
5296 * should behave upon creation.
5297 */
5298 g_object_class_install_property (g_object_class,
5299 PROP_STARTUP_FLAGS,
5300 g_param_spec_flags ("startup-flags",
5301 NULL((void*)0),
5302 NULL((void*)0),
5303 EOM_TYPE_STARTUP_FLAGS(eom_startup_flags_get_type()),
5304 0,
5305 G_PARAM_READWRITE |
5306 G_PARAM_CONSTRUCT_ONLY));
5307
5308/**
5309 * EomWindow::prepared:
5310 * @window: the object which received the signal.
5311 *
5312 * The #EomWindow::prepared signal is emitted when the @window is ready
5313 * to be shown.
5314 */
5315 signals [SIGNAL_PREPARED] =
5316 g_signal_new ("prepared",
5317 EOM_TYPE_WINDOW(eom_window_get_type ()),
5318 G_SIGNAL_RUN_LAST,
5319 G_STRUCT_OFFSET (EomWindowClass, prepared)((glong) __builtin_offsetof(EomWindowClass, prepared)),
5320 NULL((void*)0), NULL((void*)0),
5321 g_cclosure_marshal_VOID__VOID,
5322 G_TYPE_NONE((GType) ((1) << (2))), 0);
5323}
5324
5325/**
5326 * eom_window_new:
5327 * @flags: the initialization parameters for the new window.
5328 *
5329 *
5330 * Creates a new and empty #EomWindow. Use @flags to indicate
5331 * if the window should be initialized fullscreen, in slideshow mode,
5332 * and/or without the thumbnails collection visible. See #EomStartupFlags.
5333 *
5334 * Returns: a newly created #EomWindow.
5335 **/
5336GtkWidget*
5337eom_window_new (EomStartupFlags flags)
5338{
5339 EomWindow *window;
5340
5341 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5341, ((const char*) (__func__
))
);
5342
5343 window = EOM_WINDOW (g_object_new (EOM_TYPE_WINDOW,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5344 "type", GTK_WINDOW_TOPLEVEL,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5345 "application", EOM_APP,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5346 "show-menubar", FALSE,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5347 "startup-flags", flags,((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
5348 NULL))((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(g_object_new ((eom_window_get_type ()), "type", GTK_WINDOW_TOPLEVEL
, "application", (eom_application_get_instance ()), "show-menubar"
, (0), "startup-flags", flags, ((void*)0)))), ((eom_window_get_type
()))))))
;
5349
5350 return GTK_WIDGET (window)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(window)), ((gtk_widget_get_type ()))))))
;
5351}
5352
5353static void
5354eom_window_list_store_image_added (GtkTreeModel *tree_model,
5355 GtkTreePath *path,
5356 GtkTreeIter *iter,
5357 gpointer user_data)
5358{
5359 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
5360
5361 update_image_pos (window);
5362 update_action_groups_state (window);
5363}
5364
5365static void
5366eom_window_list_store_image_removed (GtkTreeModel *tree_model,
5367 GtkTreePath *path,
5368 gpointer user_data)
5369{
5370 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((eom_window_get_type ()))))))
;
5371
5372 update_image_pos (window);
5373 update_action_groups_state (window);
5374}
5375
5376static void
5377eom_job_model_cb (EomJobModel *job, gpointer data)
5378{
5379 EomWindow *window;
5380 EomWindowPrivate *priv;
5381 gint n_images;
5382
5383 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5383, ((const char*) (__func__
))
);
5384
5385#ifdef HAVE_EXIF1
5386 int i;
5387 EomImage *image;
5388#endif
5389
5390 g_return_if_fail (EOM_IS_WINDOW (data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (data)"); return; } } while (0)
;
5391
5392 window = EOM_WINDOW (data)((((EomWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(data)), ((eom_window_get_type ()))))))
;
5393 priv = window->priv;
5394
5395 if (priv->store != NULL((void*)0)) {
5396 g_object_unref (priv->store);
5397 priv->store = NULL((void*)0);
5398 }
5399
5400 priv->store = g_object_ref (job->store);
5401
5402 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
5403
5404#ifdef HAVE_EXIF1
5405 if (g_settings_get_boolean (priv->view_settings, EOM_CONF_VIEW_AUTOROTATE"autorotate")) {
5406 for (i = 0; i < n_images; i++) {
5407 image = eom_list_store_get_image_by_pos (priv->store, i);
5408 eom_image_autorotate (image);
5409 g_object_unref (image);
5410 }
5411 }
5412#endif
5413
5414 eom_thumb_view_set_model (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
, priv->store);
5415
5416 g_signal_connect (G_OBJECT (priv->store),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
5417 "row-inserted",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
5418 G_CALLBACK (eom_window_list_store_image_added),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
5419 window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-inserted"), (((GCallback) (eom_window_list_store_image_added
))), (window), ((void*)0), (GConnectFlags) 0)
;
5420
5421 g_signal_connect (G_OBJECT (priv->store),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
5422 "row-deleted",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
5423 G_CALLBACK (eom_window_list_store_image_removed),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
5424 window)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((priv->store)), (((GType) ((20) <<
(2))))))))), ("row-deleted"), (((GCallback) (eom_window_list_store_image_removed
))), (window), ((void*)0), (GConnectFlags) 0)
;
5425
5426 if (n_images == 0) {
5427 gint n_files;
5428
5429 priv->status = EOM_WINDOW_STATUS_NORMAL;
5430 update_action_groups_state (window);
5431
5432 n_files = g_slist_length (priv->file_list);
5433
5434 if (n_files > 0) {
5435 GtkWidget *message_area;
5436 GFile *file = NULL((void*)0);
5437
5438 if (n_files == 1) {
5439 file = (GFile *) priv->file_list->data;
5440 }
5441
5442 message_area = eom_no_images_error_message_area_new (file);
5443
5444 eom_window_set_message_area (window, message_area);
5445
5446 gtk_widget_show (message_area);
5447 }
5448
5449 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
5450 }
5451}
5452
5453/**
5454 * eom_window_open_file_list:
5455 * @window: An #EomWindow.
5456 * @file_list: (element-type GFile): A %NULL-terminated list of #GFile's.
5457 *
5458 * Opens a list of files, adding them to the collection in @window.
5459 * Files will be checked to be readable and later filtered according
5460 * with eom_list_store_add_files().
5461 **/
5462void
5463eom_window_open_file_list (EomWindow *window, GSList *file_list)
5464{
5465 EomJob *job;
5466
5467 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5467, ((const char*) (__func__
))
);
5468
5469 window->priv->status = EOM_WINDOW_STATUS_INIT;
5470
5471 g_slist_foreach (file_list, (GFunc) g_object_ref, NULL((void*)0));
5472 window->priv->file_list = file_list;
5473
5474 job = eom_job_model_new (file_list);
5475
5476 g_signal_connect (job,g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5477 "finished",g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5478 G_CALLBACK (eom_job_model_cb),g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5479 window)g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5480
5481 eom_job_queue_add_job (job);
5482 g_object_unref (job);
5483}
5484
5485/**
5486 * eom_window_get_ui_manager:
5487 * @window: An #EomWindow.
5488 *
5489 * Gets the #GtkUIManager that describes the UI of @window.
5490 *
5491 * Returns: (transfer none): A #GtkUIManager.
5492 **/
5493GtkUIManager *
5494eom_window_get_ui_manager (EomWindow *window)
5495{
5496 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5497
5498 return window->priv->ui_mgr;
5499}
5500
5501/**
5502 * eom_window_get_mode:
5503 * @window: An #EomWindow.
5504 *
5505 * Gets the mode of @window. See #EomWindowMode for details.
5506 *
5507 * Returns: An #EomWindowMode.
5508 **/
5509EomWindowMode
5510eom_window_get_mode (EomWindow *window)
5511{
5512 g_return_val_if_fail (EOM_IS_WINDOW (window), EOM_WINDOW_MODE_UNKNOWN)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (EOM_WINDOW_MODE_UNKNOWN
); } } while (0)
;
5513
5514 return window->priv->mode;
5515}
5516
5517/**
5518 * eom_window_set_mode:
5519 * @window: an #EomWindow.
5520 * @mode: an #EomWindowMode value.
5521 *
5522 * Changes the mode of @window to normal, fullscreen, or slideshow.
5523 * See #EomWindowMode for details.
5524 **/
5525void
5526eom_window_set_mode (EomWindow *window, EomWindowMode mode)
5527{
5528 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
5529
5530 if (window->priv->mode == mode)
5531 return;
5532
5533 switch (mode) {
5534 case EOM_WINDOW_MODE_NORMAL:
5535 eom_window_stop_fullscreen (window,
5536 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
5537 break;
5538 case EOM_WINDOW_MODE_FULLSCREEN:
5539 eom_window_run_fullscreen (window, FALSE(0));
5540 break;
5541 case EOM_WINDOW_MODE_SLIDESHOW:
5542 eom_window_run_fullscreen (window, TRUE(!(0)));
5543 break;
5544 case EOM_WINDOW_MODE_UNKNOWN:
5545 break;
5546 }
5547}
5548
5549/**
5550 * eom_window_get_store:
5551 * @window: An #EomWindow.
5552 *
5553 * Gets the #EomListStore that contains the images in the collection
5554 * of @window.
5555 *
5556 * Returns: (transfer none): an #EomListStore.
5557 **/
5558EomListStore *
5559eom_window_get_store (EomWindow *window)
5560{
5561 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5562
5563 return EOM_LIST_STORE (window->priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), (eom_list_store_get_type())
))))
;
5564}
5565
5566/**
5567 * eom_window_get_view:
5568 * @window: An #EomWindow.
5569 *
5570 * Gets the #EomScrollView in the window.
5571 *
5572 * Returns: (transfer none): the #EomScrollView.
5573 **/
5574GtkWidget *
5575eom_window_get_view (EomWindow *window)
5576{
5577 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5578
5579 return window->priv->view;
5580}
5581
5582/**
5583 * eom_window_get_sidebar:
5584 * @window: An #EomWindow.
5585 *
5586 * Gets the sidebar widget of @window.
5587 *
5588 * Returns: (transfer none): the #EomSidebar.
5589 **/
5590GtkWidget *
5591eom_window_get_sidebar (EomWindow *window)
5592{
5593 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5594
5595 return window->priv->sidebar;
5596}
5597
5598/**
5599 * eom_window_get_thumb_view:
5600 * @window: an #EomWindow.
5601 *
5602 * Gets the thumbnails view in @window.
5603 *
5604 * Returns: (transfer none): an #EomThumbView.
5605 **/
5606GtkWidget *
5607eom_window_get_thumb_view (EomWindow *window)
5608{
5609 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5610
5611 return window->priv->thumbview;
5612}
5613
5614/**
5615 * eom_window_get_thumb_nav:
5616 * @window: an #EomWindow.
5617 *
5618 * Gets the thumbnails navigation pane in @window.
5619 *
5620 * Returns: (transfer none): an #EomThumbNav.
5621 **/
5622GtkWidget *
5623eom_window_get_thumb_nav (EomWindow *window)
5624{
5625 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5626
5627 return window->priv->nav;
5628}
5629
5630/**
5631 * eom_window_get_statusbar:
5632 * @window: an #EomWindow.
5633 *
5634 * Gets the statusbar in @window.
5635 *
5636 * Returns: (transfer none): a #EomStatusBar.
5637 **/
5638GtkWidget *
5639eom_window_get_statusbar (EomWindow *window)
5640{
5641 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5642
5643 return window->priv->statusbar;
5644}
5645
5646/**
5647 * eom_window_get_image:
5648 * @window: an #EomWindow.
5649 *
5650 * Gets the image currently displayed in @window or %NULL if
5651 * no image is being displayed.
5652 *
5653 * Returns: (transfer none): an #EomImage.
5654 **/
5655EomImage *
5656eom_window_get_image (EomWindow *window)
5657{
5658 g_return_val_if_fail (EOM_IS_WINDOW (window), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return (((void*)0)); } } while
(0)
;
5659
5660 return window->priv->image;
5661}
5662
5663/**
5664 * eom_window_is_empty:
5665 * @window: an #EomWindow.
5666 *
5667 * Tells whether @window is currently empty or not.
5668 *
5669 * Returns: %TRUE if @window has no images, %FALSE otherwise.
5670 **/
5671gboolean
5672eom_window_is_empty (EomWindow *window)
5673{
5674 EomWindowPrivate *priv;
5675 gboolean empty = TRUE(!(0));
5676
5677 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5677, ((const char*) (__func__
))
);
5678
5679 g_return_val_if_fail (EOM_IS_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return ((0)); } } while (0)
;
5680
5681 priv = window->priv;
5682
5683 if (priv->store != NULL((void*)0)) {
5684 empty = (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0);
5685 }
5686
5687 return empty;
5688}
5689
5690void
5691eom_window_reload_image (EomWindow *window)
5692{
5693 GtkWidget *view;
5694
5695 g_return_if_fail (EOM_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((eom_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_WINDOW (window)"); return; } } while (0)
;
5696
5697 if (window->priv->image == NULL((void*)0))
5698 return;
5699
5700 g_object_unref (window->priv->image);
5701 window->priv->image = NULL((void*)0);
5702
5703 view = eom_window_get_view (window);
5704 eom_scroll_view_set_image (EOM_SCROLL_VIEW (view)((((EomScrollView*) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
5705
5706 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5707 EOM_THUMB_VIEW_SELECT_CURRENT);
5708}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e15c69.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e15c69.html new file mode 100644 index 0000000..a79f8af --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e15c69.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 415, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
This statement is never executed
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e7a236.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e7a236.html new file mode 100644 index 0000000..a206957 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-e7a236.html @@ -0,0 +1,793 @@ + + + +eom-transform.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-transform.c
Warning:line 431, column 10
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-transform.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Affine Transformations
2 *
3 * Copyright (C) 2003-2009 The Free Software Foundation
4 *
5 * Portions based on code from libart_lgpl by Raph Levien.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <time.h>
27#include <stdlib.h>
28#include <math.h>
29#include <gtk/gtk.h>
30#include <cairo/cairo.h>
31
32#include "eom-transform.h"
33#include "eom-jobs.h"
34
35/* The number of progress updates per transformation */
36#define EOM_TRANSFORM_N_PROG_UPDATES20 20
37
38struct _EomTransformPrivate {
39 cairo_matrix_t affine;
40};
41
42typedef struct {
43 gdouble x;
44 gdouble y;
45} EomPoint;
46
47/* Convert degrees into radians */
48#define EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
((degree) * (G_PI3.1415926535897932384626433832795028841971693993751/180.0))
49
50G_DEFINE_TYPE_WITH_PRIVATE (EomTransform, eom_transform, G_TYPE_OBJECT)static void eom_transform_init (EomTransform *self); static void
eom_transform_class_init (EomTransformClass *klass); static GType
eom_transform_get_type_once (void); static gpointer eom_transform_parent_class
= ((void*)0); static gint EomTransform_private_offset; static
void eom_transform_class_intern_init (gpointer klass) { eom_transform_parent_class
= g_type_class_peek_parent (klass); if (EomTransform_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EomTransform_private_offset
); eom_transform_class_init ((EomTransformClass*) klass); } __attribute__
((__unused__)) static inline gpointer eom_transform_get_instance_private
(EomTransform *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (EomTransform_private_offset)))); } GType eom_transform_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_transform_get_type_once (); (__extension__
({ _Static_assert (sizeof *(&g_define_type_id__volatile)
== sizeof (gpointer), "Expression evaluates to false"); 0 ? (
void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_transform_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EomTransform"
), sizeof (EomTransformClass), (GClassInitFunc)(void (*)(void
)) eom_transform_class_intern_init, sizeof (EomTransform), (GInstanceInitFunc
)(void (*)(void)) eom_transform_init, (GTypeFlags) 0); { {{ EomTransform_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (EomTransformPrivate
)); };} } return g_define_type_id; }
51
52static void
53eom_transform_init (EomTransform *trans)
54{
55 trans->priv = eom_transform_get_instance_private (trans);
56}
57
58static void
59eom_transform_class_init (EomTransformClass *klass)
60{
61
62}
63
64/**
65 * eom_transform_apply:
66 * @trans: a #EomTransform
67 * @pixbuf: a #GdkPixbuf
68 * @job: a #EomJob
69 *
70 * Applies the transformation in @trans to @pixbuf, setting its progress in @job.
71 *
72 * Returns: (transfer full): A new #GdkPixbuf with the transformation applied.
73 **/
74GdkPixbuf*
75eom_transform_apply (EomTransform *trans, GdkPixbuf *pixbuf, EomJob *job)
76{
77 EomPoint dest_top_left;
78 EomPoint dest_bottom_right;
79 EomPoint vertices[4] = { {0, 0}, {1, 0}, {1, 1}, {0, 1} };
80 double r_det;
81 int inverted [6];
82 EomPoint dest;
83
84 int src_width;
85 int src_height;
86 int src_rowstride;
87 int src_n_channels;
88 guchar *src_buffer;
89
90 GdkPixbuf *dest_pixbuf;
91 int dest_width;
92 int dest_height;
93 int dest_rowstride;
94 int dest_n_channels;
95 guchar *dest_buffer;
96
97 guchar *src_pos;
98 guchar *dest_pos;
99 int dx, dy, sx, sy;
100 int i, x, y;
101
102 int progress_delta;
103
104 g_return_val_if_fail (pixbuf != NULL, NULL)do { if ((pixbuf != ((void*)0))) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "pixbuf != NULL"); return
(((void*)0)); } } while (0)
;
105
106 g_object_ref (pixbuf);
107
108 src_width = gdk_pixbuf_get_width (pixbuf);
109 src_height = gdk_pixbuf_get_height (pixbuf);
110 src_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
111 src_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
112 src_buffer = gdk_pixbuf_get_pixels (pixbuf);
113
114 /* find out the dimension of the destination pixbuf */
115 dest_top_left.x = 100000;
116 dest_top_left.y = 100000;
117 dest_bottom_right.x = -100000;
118 dest_bottom_right.y = -100000;
119
120 for (i = 0; i < 4; i++) {
121 dest.x = vertices[i].x * (src_width - 1);
122 dest.y = vertices[i].y * (src_height -1);
123
124 cairo_matrix_transform_point (&trans->priv->affine,
125 &dest.x, &dest.y);
126
127 dest_top_left.x = MIN (dest_top_left.x, dest.x)(((dest_top_left.x) < (dest.x)) ? (dest_top_left.x) : (dest
.x))
;
128 dest_top_left.y = MIN (dest_top_left.y, dest.y)(((dest_top_left.y) < (dest.y)) ? (dest_top_left.y) : (dest
.y))
;
129
130 dest_bottom_right.x = MAX (dest_bottom_right.x, dest.x)(((dest_bottom_right.x) > (dest.x)) ? (dest_bottom_right.x
) : (dest.x))
;
131 dest_bottom_right.y = MAX (dest_bottom_right.y, dest.y)(((dest_bottom_right.y) > (dest.y)) ? (dest_bottom_right.y
) : (dest.y))
;
132 }
133
134 /* create the resulting pixbuf */
135 dest_width = abs ((int) (dest_bottom_right.x - dest_top_left.x + 1));
136 dest_height = abs ((int) (dest_bottom_right.y - dest_top_left.y + 1));
137
138 dest_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
139 gdk_pixbuf_get_has_alpha (pixbuf),
140 gdk_pixbuf_get_bits_per_sample (pixbuf),
141 dest_width,
142 dest_height);
143 dest_rowstride = gdk_pixbuf_get_rowstride (dest_pixbuf);
144 dest_n_channels = gdk_pixbuf_get_n_channels (dest_pixbuf);
145 dest_buffer = gdk_pixbuf_get_pixels (dest_pixbuf);
146
147 /* invert the matrix so that we can compute the source pixel
148 from the target pixel and convert the values to integer
149 ones (faster!) FIXME: Maybe we can do some more
150 improvements by using special mmx/3dnow features if
151 available.
152 */
153 r_det = 1.0 / (trans->priv->affine.xx * trans->priv->affine.yy - trans->priv->affine.yx * trans->priv->affine.xy);
154 inverted[0] = trans->priv->affine.yy * r_det;
155 inverted[1] = -trans->priv->affine.yx * r_det;
156 inverted[2] = -trans->priv->affine.xy * r_det;
157 inverted[3] = trans->priv->affine.xx * r_det;
158 inverted[4] = -trans->priv->affine.x0 * inverted[0] - trans->priv->affine.y0 * inverted[2];
159 inverted[5] = -trans->priv->affine.x0 * inverted[1] - trans->priv->affine.y0 * inverted[3];
160
161 progress_delta = MAX (1, dest_height / EOM_TRANSFORM_N_PROG_UPDATES)(((1) > (dest_height / 20)) ? (1) : (dest_height / 20));
162
163 /*
164 * for every destination pixel (dx,dy) compute the source pixel (sx, sy)
165 * and copy the color values
166 */
167 for (y = 0, dy = dest_top_left.y; y < dest_height; y++, dy++) {
168 for (x = 0, dx = dest_top_left.x; x < dest_width; x++, dx++) {
169
170 sx = dx * inverted[0] + dy * inverted[2] + inverted[4];
171 sy = dx * inverted[1] + dy * inverted[3] + inverted[5];
172
173 if (sx >= 0 && sx < src_width && sy >= 0 && sy < src_height) {
174 src_pos = src_buffer + sy * src_rowstride + sx * src_n_channels;
175 dest_pos = dest_buffer + y * dest_rowstride + x * dest_n_channels;
176
177 for (i = 0; i < src_n_channels; i++) {
178 dest_pos[i] = src_pos[i];
179 }
180 }
181 }
182
183 if (job != NULL((void*)0) && y % progress_delta == 0) {
184 gfloat progress;
185
186 progress = (gfloat) (y + 1.0) / (gfloat) dest_height;
187
188 eom_job_set_progress (job, progress);
189 }
190 }
191
192 g_object_unref (pixbuf);
193
194 if (job != NULL((void*)0)) {
195 eom_job_set_progress (job, 1.0);
196 }
197
198 return dest_pixbuf;
199}
200
201static void
202_eom_cairo_matrix_copy (const cairo_matrix_t *src, cairo_matrix_t *dest)
203{
204 cairo_matrix_init (dest, src->xx, src->yx, src->xy, src->yy, src->x0, src->y0);
205}
206
207#define DOUBLE_EQUAL_MAX_DIFF1e-6 1e-6
208#define DOUBLE_EQUAL(a,b)(fabs (a - b) < 1e-6) (fabs (a - b) < DOUBLE_EQUAL_MAX_DIFF1e-6)
209/* art_affine_equal modified to work with cairo_matrix_t */
210static gboolean
211_eom_cairo_matrix_equal (const cairo_matrix_t *a, const cairo_matrix_t *b)
212{
213 return (DOUBLE_EQUAL (a->xx, b->xx)(fabs (a->xx - b->xx) < 1e-6) && DOUBLE_EQUAL (a->yx, b->yx)(fabs (a->yx - b->yx) < 1e-6) &&
214 DOUBLE_EQUAL (a->xy, b->xy)(fabs (a->xy - b->xy) < 1e-6) && DOUBLE_EQUAL (a->yy, b->yy)(fabs (a->yy - b->yy) < 1e-6) &&
215 DOUBLE_EQUAL (a->x0, b->x0)(fabs (a->x0 - b->x0) < 1e-6) && DOUBLE_EQUAL (a->y0, b->y0)(fabs (a->y0 - b->y0) < 1e-6) );
216}
217
218/* art_affine_flip modified to work with cairo_matrix_t */
219static void
220_eom_cairo_matrix_flip (cairo_matrix_t *dst, const cairo_matrix_t *src, gboolean horiz, gboolean vert)
221{
222 dst->xx = horiz ? -src->xx : src->xx;
223 dst->yx = horiz ? -src->yx : src->yx;
224 dst->xy = vert ? -src->xy : src->xy;
225 dst->yy = vert ? -src->yy : src->yy;
226 dst->x0 = horiz ? -src->x0 : src->x0;
227 dst->y0 = vert ? -src->y0 : src->y0;
228}
229
230/**
231 * eom_transform_reverse:
232 * @trans: a #EomTransform
233 *
234 * Creates the reverse transformation of @trans
235 *
236 * Returns: (transfer full): a new transformation
237 **/
238EomTransform*
239eom_transform_reverse (EomTransform *trans)
240{
241 EomTransform *reverse;
242
243 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
244
245 reverse = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
246
247 _eom_cairo_matrix_copy (&trans->priv->affine, &reverse->priv->affine);
248
249 g_return_val_if_fail (cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS, reverse)do { if ((cairo_matrix_invert (&reverse->priv->affine
) == CAIRO_STATUS_SUCCESS)) { } else { g_return_if_fail_warning
("EOM", ((const char*) (__func__)), "cairo_matrix_invert (&reverse->priv->affine) == CAIRO_STATUS_SUCCESS"
); return (reverse); } } while (0)
;
250
251 return reverse;
252}
253
254/**
255 * eom_transform_compose:
256 * @trans: a #EomTransform
257 * @compose: another #EomTransform
258 *
259 *
260 *
261 * Returns: (transfer full): a new transform
262 **/
263EomTransform*
264eom_transform_compose (EomTransform *trans, EomTransform *compose)
265{
266 EomTransform *composition;
267
268 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (((void*)0)); } } while
(0)
;
269 g_return_val_if_fail (EOM_IS_TRANSFORM (compose), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((compose)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (compose)"); return (((void*)0)); } } while
(0)
;
270
271 composition = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
272
273 cairo_matrix_multiply (&composition->priv->affine,
274 &trans->priv->affine,
275 &compose->priv->affine);
276
277 return composition;
278}
279
280gboolean
281eom_transform_is_identity (EomTransform *trans)
282{
283 static const cairo_matrix_t identity = { 1, 0, 0, 1, 0, 0 };
284
285 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
286
287 return _eom_cairo_matrix_equal (&identity, &trans->priv->affine);
288}
289
290EomTransform*
291eom_transform_identity_new (void)
292{
293 EomTransform *trans;
294
295 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
296
297 cairo_matrix_init_identity (&trans->priv->affine);
298
299 return trans;
300}
301
302EomTransform*
303eom_transform_rotate_new (int degree)
304{
305 EomTransform *trans;
306
307 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
308
309 cairo_matrix_init_rotate (&trans->priv->affine, EOM_DEG_TO_RAD(degree)((degree) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
310
311 return trans;
312}
313
314EomTransform*
315eom_transform_flip_new (EomTransformType type)
316{
317 EomTransform *trans;
318 gboolean horiz, vert;
319
320 trans = EOM_TRANSFORM (g_object_new (EOM_TYPE_TRANSFORM, NULL))((((EomTransform*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((eom_transform_get_type ()), ((void*)0))))
, ((eom_transform_get_type ()))))))
;
321
322 cairo_matrix_init_identity (&trans->priv->affine);
323
324 horiz = (type == EOM_TRANSFORM_FLIP_HORIZONTAL);
325 vert = (type == EOM_TRANSFORM_FLIP_VERTICAL);
326
327 _eom_cairo_matrix_flip (&trans->priv->affine,
328 &trans->priv->affine,
329 horiz, vert);
330
331 return trans;
332}
333
334EomTransform*
335eom_transform_new (EomTransformType type)
336{
337 EomTransform *trans = NULL((void*)0);
338 EomTransform *temp1 = NULL((void*)0), *temp2 = NULL((void*)0);
339
340 switch (type) {
341 case EOM_TRANSFORM_NONE:
342 trans = eom_transform_identity_new ();
343 break;
344 case EOM_TRANSFORM_FLIP_HORIZONTAL:
345 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
346 break;
347 case EOM_TRANSFORM_ROT_180:
348 trans = eom_transform_rotate_new (180);
349 break;
350 case EOM_TRANSFORM_FLIP_VERTICAL:
351 trans = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
352 break;
353 case EOM_TRANSFORM_TRANSPOSE:
354 temp1 = eom_transform_rotate_new (90);
355 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL);
356 trans = eom_transform_compose (temp1, temp2);
357 g_object_unref (temp1);
358 g_object_unref (temp2);
359 break;
360 case EOM_TRANSFORM_ROT_90:
361 trans = eom_transform_rotate_new (90);
362 break;
363 case EOM_TRANSFORM_TRANSVERSE:
364 temp1 = eom_transform_rotate_new (90);
365 temp2 = eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL);
366 trans = eom_transform_compose (temp1, temp2);
367 g_object_unref (temp1);
368 g_object_unref (temp2);
369 break;
370 case EOM_TRANSFORM_ROT_270:
371 trans = eom_transform_rotate_new (270);
372 break;
373 default:
374 trans = eom_transform_identity_new ();
375 break;
376 }
377
378 return trans;
379}
380
381EomTransformType
382eom_transform_get_transform_type (EomTransform *trans)
383{
384 cairo_matrix_t affine, a1, a2;
385 EomTransformPrivate *priv;
386
387 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), EOM_TRANSFORM_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return (EOM_TRANSFORM_NONE);
} } while (0)
;
388
389 priv = trans->priv;
390
391 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
392 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
393 return EOM_TRANSFORM_ROT_90;
394 }
395
396 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
397 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
398 return EOM_TRANSFORM_ROT_180;
399 }
400
401 cairo_matrix_init_rotate (&affine, EOM_DEG_TO_RAD(270)((270) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
402 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
403 return EOM_TRANSFORM_ROT_270;
404 }
405
406 cairo_matrix_init_identity (&affine);
407 _eom_cairo_matrix_flip (&affine, &affine, TRUE(!(0)), FALSE(0));
408 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
409 return EOM_TRANSFORM_FLIP_HORIZONTAL;
410 }
411
412 cairo_matrix_init_identity (&affine);
413 _eom_cairo_matrix_flip (&affine, &affine, FALSE(0), TRUE(!(0)));
414 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
415 return EOM_TRANSFORM_FLIP_VERTICAL;
416 }
417
418 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(90)((90) * (3.1415926535897932384626433832795028841971693993751/
180.0))
);
419 cairo_matrix_init_identity (&a2);
420 _eom_cairo_matrix_flip (&a2, &a2, TRUE(!(0)), FALSE(0));
421 cairo_matrix_multiply(&affine, &a1, &a2);
422 if (_eom_cairo_matrix_equal (&affine, &priv->affine)) {
423 return EOM_TRANSFORM_TRANSPOSE;
424 }
425
426 /* A transversion is a 180° rotation followed by a transposition */
427 /* Reuse the transposition from the previous step for this. */
428 cairo_matrix_init_rotate (&a1, EOM_DEG_TO_RAD(180)((180) * (3.1415926535897932384626433832795028841971693993751
/180.0))
);
429 cairo_matrix_multiply(&a2, &a1, &affine);
430 if (_eom_cairo_matrix_equal (&a2, &priv->affine)) {
431 return EOM_TRANSFORM_TRANSVERSE;
This statement is never executed
432 }
433
434 return EOM_TRANSFORM_NONE;
435}
436
437gboolean
438eom_transform_get_affine (EomTransform *trans, cairo_matrix_t *affine)
439{
440 g_return_val_if_fail (EOM_IS_TRANSFORM (trans), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((trans)); GType __t = ((eom_transform_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 ("EOM", ((const char*) (__func__
)), "EOM_IS_TRANSFORM (trans)"); return ((0)); } } while (0)
;
441
442 _eom_cairo_matrix_copy (&trans->priv->affine, affine);
443
444 return TRUE(!(0));
445}
446
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-eac485.html b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-eac485.html new file mode 100644 index 0000000..30b1b94 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/report-eac485.html @@ -0,0 +1,1474 @@ + + + +eom-print-preview.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-print-preview.c
Warning:line 788, column 3
2nd function call argument is an uninitialized value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name eom-print-preview.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/10.0.0 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOM" -D EOM_DATA_DIR="/usr/local/share/eom" -D EOM_LOCALE_DIR="/usr/local/share/locale" -D EOM_PLUGIN_DIR="/usr/local/lib/eom/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/gtk-3.0/unix-print -I /usr/include/libpeas-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/10.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-07-13-085735-5574-1 -x c eom-print-preview.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Eye Of MATE -- Print Preview Widget
2 *
3 * Copyright (C) 2006-2008 The Free Software Foundation
4 *
5 * Author: Claudio Saavedra <csaavedra@gnome.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <gtk/gtk.h>
23#include <cairo.h>
24#include <gdk/gdkkeysyms.h>
25
26#include "eom-image.h"
27#include "eom-print-preview.h"
28
29struct _EomPrintPreviewPrivate {
30 GtkWidget *area;
31 GdkPixbuf *image;
32 GdkPixbuf *image_scaled;
33
34 /* The surface to set to the cairo context, created from the image */
35 cairo_surface_t *surface;
36
37 /* Flag whether we have to create surface */
38 gboolean flag_create_surface;
39
40 /* the alignment of the image in the page */
41 gfloat image_x_align, image_y_align;
42
43 /* real paper size, in inches */
44 gfloat p_width, p_height;
45
46 /* page margins, in inches */
47 gfloat l_margin, r_margin, t_margin, b_margin;
48
49 /* page margins, relatives to the widget size */
50 gint l_rmargin, r_rmargin, t_rmargin, b_rmargin;
51
52 /* image width, relative to the widget size */
53 gint r_width, r_height;
54
55 /* scale of the image, as defined by the user */
56 gfloat i_scale;
57
58 /* scale of the page, relative to the widget size */
59 gfloat p_scale;
60
61 /* whether we are currently grabbing the image */
62 gboolean grabbed;
63
64 /* the last cursor position */
65 gdouble cursorx, cursory;
66
67 /* if we reject to move the image,
68 store the delta here */
69 gdouble r_dx, r_dy;
70};
71
72/* Signal IDs */
73enum {
74 SIGNAL_IMAGE_MOVED,
75 SIGNAL_LAST
76};
77
78static guint preview_signals [SIGNAL_LAST] = { 0 };
79
80enum {
81 PROP_0,
82 PROP_IMAGE,
83 PROP_IMAGE_X_ALIGN,
84 PROP_IMAGE_Y_ALIGN,
85 PROP_IMAGE_SCALE,
86 PROP_PAPER_WIDTH,
87 PROP_PAPER_HEIGHT,
88 PROP_PAGE_LEFT_MARGIN,
89 PROP_PAGE_RIGHT_MARGIN,
90 PROP_PAGE_TOP_MARGIN,
91 PROP_PAGE_BOTTOM_MARGIN
92};
93
94G_DEFINE_TYPE_WITH_PRIVATE (EomPrintPreview, eom_print_preview, GTK_TYPE_ASPECT_FRAME)static void eom_print_preview_init (EomPrintPreview *self); static
void eom_print_preview_class_init (EomPrintPreviewClass *klass
); static GType eom_print_preview_get_type_once (void); static
gpointer eom_print_preview_parent_class = ((void*)0); static
gint EomPrintPreview_private_offset; static void eom_print_preview_class_intern_init
(gpointer klass) { eom_print_preview_parent_class = g_type_class_peek_parent
(klass); if (EomPrintPreview_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EomPrintPreview_private_offset); eom_print_preview_class_init
((EomPrintPreviewClass*) klass); } __attribute__((__unused__
)) static inline gpointer eom_print_preview_get_instance_private
(EomPrintPreview *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EomPrintPreview_private_offset)))); } GType eom_print_preview_get_type
(void) { static volatile gsize g_define_type_id__volatile = 0
; if ((__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&g_define_type_id__volatile) : ((void
*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); gpointer
gapg_temp_newval; gpointer *gapg_temp_atomic = (gpointer *)(
&g_define_type_id__volatile); __atomic_load (gapg_temp_atomic
, &gapg_temp_newval, 5); gapg_temp_newval; })) &&
g_once_init_enter (&g_define_type_id__volatile)); }))) {
GType g_define_type_id = eom_print_preview_get_type_once ();
(__extension__ ({ _Static_assert (sizeof *(&g_define_type_id__volatile
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&g_define_type_id__volatile) = (g_define_type_id
)) : (void) 0; g_once_init_leave ((&g_define_type_id__volatile
), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile
; } __attribute__((noinline)) static GType eom_print_preview_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_aspect_frame_get_type ()), g_intern_static_string ("EomPrintPreview"
), sizeof (EomPrintPreviewClass), (GClassInitFunc)(void (*)(void
)) eom_print_preview_class_intern_init, sizeof (EomPrintPreview
), (GInstanceInitFunc)(void (*)(void)) eom_print_preview_init
, (GTypeFlags) 0); { {{ EomPrintPreview_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EomPrintPreviewPrivate)); };} } return
g_define_type_id; }
95
96static void eom_print_preview_draw (EomPrintPreview *preview, cairo_t *cr);
97static void eom_print_preview_finalize (GObject *object);
98static void update_relative_sizes (EomPrintPreview *preview);
99static void create_surface (EomPrintPreview *preview);
100static void create_image_scaled (EomPrintPreview *preview);
101static gboolean create_surface_when_idle (EomPrintPreview *preview);
102
103static void
104eom_print_preview_get_property (GObject *object,
105 guint prop_id,
106 GValue *value,
107 GParamSpec *pspec)
108{
109 EomPrintPreviewPrivate *priv = EOM_PRINT_PREVIEW (object)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_print_preview_get_type ()))))))
->priv;
110
111 switch (prop_id) {
112 case PROP_IMAGE:
113 g_value_set_object (value, priv->image);
114 break;
115 case PROP_IMAGE_X_ALIGN:
116 g_value_set_float (value, priv->image_x_align);
117 break;
118 case PROP_IMAGE_Y_ALIGN:
119 g_value_set_float (value, priv->image_y_align);
120 break;
121 case PROP_IMAGE_SCALE:
122 g_value_set_float (value, priv->i_scale);
123 break;
124 case PROP_PAPER_WIDTH:
125 g_value_set_float (value, priv->p_width);
126 break;
127 case PROP_PAPER_HEIGHT:
128 g_value_set_float (value, priv->p_height);
129 break;
130 case PROP_PAGE_LEFT_MARGIN:
131 g_value_set_float (value, priv->l_margin);
132 break;
133 case PROP_PAGE_RIGHT_MARGIN:
134 g_value_set_float (value, priv->r_margin);
135 break;
136 case PROP_PAGE_TOP_MARGIN:
137 g_value_set_float (value, priv->t_margin);
138 break;
139 case PROP_PAGE_BOTTOM_MARGIN:
140 g_value_set_float (value, priv->b_margin);
141 break;
142 default:
143 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-print-preview.c", 143, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
144 }
145}
146
147static void
148eom_print_preview_set_property (GObject *object,
149 guint prop_id,
150 const GValue *value,
151 GParamSpec *pspec)
152{
153 EomPrintPreviewPrivate *priv = EOM_PRINT_PREVIEW (object)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_print_preview_get_type ()))))))
->priv;
154 gboolean paper_size_changed = FALSE(0);
155
156 switch (prop_id) {
157 case PROP_IMAGE:
158 if (priv->image) {
159 g_object_unref (priv->image);
160 }
161 priv->image = GDK_PIXBUF (g_value_dup_object (value))((((GdkPixbuf*) g_type_check_instance_cast ((GTypeInstance*) (
(g_value_dup_object (value))), ((gdk_pixbuf_get_type ()))))))
;
162
163 if (priv->image_scaled) {
164 g_object_unref (priv->image_scaled);
165 priv->image_scaled = NULL((void*)0);
166 }
167
168 priv->flag_create_surface = TRUE(!(0));
169 break;
170 case PROP_IMAGE_X_ALIGN:
171 priv->image_x_align = g_value_get_float (value);
172 break;
173 case PROP_IMAGE_Y_ALIGN:
174 priv->image_y_align = g_value_get_float (value);
175 break;
176 case PROP_IMAGE_SCALE:
177 priv->i_scale = g_value_get_float (value);
178 priv->flag_create_surface = TRUE(!(0));
179 break;
180 case PROP_PAPER_WIDTH:
181 priv->p_width = g_value_get_float (value);
182 paper_size_changed = TRUE(!(0));
183 break;
184 case PROP_PAPER_HEIGHT:
185 priv->p_height = g_value_get_float (value);
186 paper_size_changed = TRUE(!(0));
187 break;
188 case PROP_PAGE_LEFT_MARGIN:
189 priv->l_margin = g_value_get_float (value);
190 break;
191 case PROP_PAGE_RIGHT_MARGIN:
192 priv->r_margin = g_value_get_float (value);
193 break;
194 case PROP_PAGE_TOP_MARGIN:
195 priv->t_margin = g_value_get_float (value);
196 break;
197 case PROP_PAGE_BOTTOM_MARGIN:
198 priv->b_margin = g_value_get_float (value);
199 break;
200 default:
201 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eom-print-preview.c", 201, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
202 }
203
204 if (paper_size_changed) {
205 g_object_set (object,
206 "ratio", priv->p_width/priv->p_height,
207 NULL((void*)0));
208 }
209
210 update_relative_sizes (EOM_PRINT_PREVIEW (object)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_print_preview_get_type ()))))))
);
211 gtk_widget_queue_draw (priv->area);
212}
213
214static void
215eom_print_preview_class_init (EomPrintPreviewClass *klass)
216{
217 GObjectClass *gobject_class;
218
219 gobject_class = (GObjectClass*) klass;
220
221 gobject_class->get_property = eom_print_preview_get_property;
222 gobject_class->set_property = eom_print_preview_set_property;
223 gobject_class->finalize = eom_print_preview_finalize;
224
225/**
226 * EomPrintPreview:image:
227 *
228 * The "image" property defines the image that is previewed
229 * in the widget.
230 */
231 g_object_class_install_property (gobject_class,
232 PROP_IMAGE,
233 g_param_spec_object ("image",
234 "Image to show in the preview",
235 "",
236 G_TYPE_OBJECT((GType) ((20) << (2))),
237 G_PARAM_READWRITE));
238
239/**
240 * EomPrintPreview:image-x-align:
241 *
242 * The "image-x-align" property defines the horizontal alignment
243 * of the image in the widget.
244 */
245 g_object_class_install_property (gobject_class,
246 PROP_IMAGE_X_ALIGN,
247 g_param_spec_float ("image-x-align",
248 "Horizontal alignment for the image",
249 "",
250 0,
251 1,
252 0.5,
253 G_PARAM_READWRITE));
254
255/**
256 * EomPrintPreview:image-y-align:
257 *
258 * The "image-y-align" property defines the horizontal alignment
259 * of the image in the widget.
260 */
261 g_object_class_install_property (gobject_class,
262 PROP_IMAGE_Y_ALIGN,
263 g_param_spec_float ("image-y-align",
264 "Vertical alignment for the image",
265 "",
266 0,
267 1,
268 0.5,
269 G_PARAM_READWRITE));
270
271/**
272 * EomPrintPreview:image-scale:
273 *
274 * The "image-scale" property defines the scaling of the image
275 * that the user wants for the printing.
276 */
277 g_object_class_install_property (gobject_class,
278 PROP_IMAGE_SCALE,
279 g_param_spec_float ("image-scale",
280 "The scale for the image",
281 "",
282 0,
283 1,
284 1,
285 G_PARAM_READWRITE));
286
287/**
288 * EomPrintPreview:paper-width:
289 *
290 * The width of the previewed paper, in inches.
291 */
292 g_object_class_install_property (gobject_class,
293 PROP_PAPER_WIDTH,
294 g_param_spec_float ("paper-width",
295 "Real paper width in inches",
296 "",
297 0,
298 100,
299 8.5,
300 G_PARAM_READWRITE));
301
302/**
303 * EomPrintPreview:paper-height:
304 *
305 * The height of the previewed paper, in inches.
306 */
307 g_object_class_install_property (gobject_class,
308 PROP_PAPER_HEIGHT,
309 g_param_spec_float ("paper-height",
310 "Real paper height in inches",
311 "",
312 0,
313 200,
314 11,
315 G_PARAM_READWRITE));
316
317/**
318 * EomPrintPreview:page-left-margin:
319 *
320 * The size of the page's left margin, in inches.
321 */
322 g_object_class_install_property (gobject_class,
323 PROP_PAGE_LEFT_MARGIN,
324 g_param_spec_float ("page-left-margin",
325 "Left margin of the page in inches",
326 "",
327 0,
328 100,
329 0.25,
330 G_PARAM_READWRITE));
331
332/**
333 * EomPrintPreview:page-right-margin:
334 *
335 * The size of the page's right margin, in inches.
336 */
337 g_object_class_install_property (gobject_class,
338 PROP_PAGE_RIGHT_MARGIN,
339 g_param_spec_float ("page-right-margin",
340 "Right margin of the page in inches",
341 "",
342 0,
343 200,
344 0.25,
345 G_PARAM_READWRITE));
346/**
347 * EomPrintPreview:page-top-margin:
348 *
349 * The size of the page's top margin, in inches.
350 */
351 g_object_class_install_property (gobject_class,
352 PROP_PAGE_TOP_MARGIN,
353 g_param_spec_float ("page-top-margin",
354 "Top margin of the page in inches",
355 "",
356 0,
357 100,
358 0.25,
359 G_PARAM_READWRITE));
360
361/**
362 * EomPrintPreview:page-bottom-margin:
363 *
364 * The size of the page's bottom margin, in inches.
365 */
366 g_object_class_install_property (gobject_class,
367 PROP_PAGE_BOTTOM_MARGIN,
368 g_param_spec_float ("page-bottom-margin",
369 "Bottom margin of the page in inches",
370 "",
371 0,
372 200,
373 0.56,
374 G_PARAM_READWRITE));
375
376/**
377 * EomPrintPreview::image-moved:
378 * @preview: the object which received the signal
379 *
380 * The #EomPrintPreview::image-moved signal is emitted when the position
381 * of the image is changed.
382 */
383 preview_signals [SIGNAL_IMAGE_MOVED] =
384 g_signal_new ("image_moved",
385 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
386 G_SIGNAL_RUN_FIRST, 0, NULL((void*)0), NULL((void*)0),
387 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE((GType) ((1) << (2))),
388 0, NULL((void*)0));
389}
390
391static void
392eom_print_preview_finalize (GObject *object)
393{
394 EomPrintPreviewPrivate *priv;
395
396 priv = EOM_PRINT_PREVIEW (object)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_print_preview_get_type ()))))))
->priv;
397
398 if (priv->image) {
399 g_object_unref (priv->image);
400 priv->image = NULL((void*)0);
401 }
402
403 if (priv->image_scaled) {
404 g_object_unref (priv->image_scaled);
405 priv->image_scaled = NULL((void*)0);
406 }
407
408 if (priv->surface) {
409 cairo_surface_destroy (priv->surface);
410 priv->surface = NULL((void*)0);
411 }
412
413 G_OBJECT_CLASS (eom_print_preview_parent_class)((((GObjectClass*) g_type_check_class_cast ((GTypeClass*) ((eom_print_preview_parent_class
)), (((GType) ((20) << (2))))))))
->finalize (object);
414}
415
416static void
417eom_print_preview_init (EomPrintPreview *preview)
418{
419 EomPrintPreviewPrivate *priv;
420 gfloat ratio;
421
422 priv = preview->priv = eom_print_preview_get_instance_private (preview);
423
424 priv->area = GTK_WIDGET (gtk_drawing_area_new ())((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(gtk_drawing_area_new ())), ((gtk_widget_get_type ()))))))
;
425
426 gtk_container_add (GTK_CONTAINER (preview)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_container_get_type ()))))))
, priv->area);
427
428 priv->p_width = 8.5;
429 priv->p_height = 11.0;
430
431 ratio = priv->p_width/priv->p_height;
432
433 gtk_aspect_frame_set (GTK_ASPECT_FRAME (preview)((((GtkAspectFrame*) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_aspect_frame_get_type ()))))))
,
434 0.5, 0.5, ratio, FALSE(0));
435
436 priv->image = NULL((void*)0);
437 priv->image_scaled = NULL((void*)0);
438 priv->image_x_align = 0.5;
439 priv->image_y_align = 0.5;
440 priv->i_scale = 1;
441
442 priv->surface = NULL((void*)0);
443 priv->flag_create_surface = TRUE(!(0));
444
445 priv->p_scale = 0;
446
447 priv->l_margin = 0.25;
448 priv->r_margin = 0.25;
449 priv->t_margin = 0.25;
450 priv->b_margin = 0.56;
451
452 priv->grabbed = FALSE(0);
453 priv->cursorx = 0;
454 priv->cursory = 0;
455 priv->r_dx = 0;
456 priv->r_dy = 0;
457}
458
459static gboolean button_press_event_cb (GtkWidget *widget, GdkEventButton *bev, gpointer user_data);
460static gboolean button_release_event_cb (GtkWidget *widget, GdkEventButton *bev, gpointer user_data);
461static gboolean motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *mev, gpointer user_data);
462static gboolean key_press_event_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
463
464static gboolean draw_cb (GtkDrawingArea *drawing_area, cairo_t *cr, gpointer user_data);
465static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data);
466
467/**
468 * eom_print_preview_new_with_pixbuf:
469 * @pixbuf: a #GdkPixbuf
470 *
471 * Creates a new #EomPrintPreview widget, and sets the #GdkPixbuf to preview
472 * on it.
473 *
474 * Returns: A new #EomPrintPreview widget.
475 **/
476GtkWidget *
477eom_print_preview_new_with_pixbuf (GdkPixbuf *pixbuf)
478{
479 EomPrintPreview *preview;
480
481 g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pixbuf)); GType __t = ((gdk_pixbuf_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 ("EOM", ((const char*) (__func__
)), "GDK_IS_PIXBUF (pixbuf)"); return (((void*)0)); } } while
(0)
;
482
483 preview = EOM_PRINT_PREVIEW (eom_print_preview_new ())((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((eom_print_preview_new ())), ((eom_print_preview_get_type
()))))))
;
484
485 preview->priv->image = g_object_ref (pixbuf);
486
487 update_relative_sizes (preview);
488
489 return GTK_WIDGET (preview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(preview)), ((gtk_widget_get_type ()))))))
;
490}
491
492/**
493 * eom_print_preview_new:
494 *
495 * Creates a new #EomPrintPreview widget, setting it to the default values,
496 * and leaving the page empty. You still need to set the #EomPrintPreview:image
497 * property to make it useful.
498 *
499 * Returns: A new and empty #EomPrintPreview widget.
500 **/
501GtkWidget *
502eom_print_preview_new (void)
503{
504 EomPrintPreview *preview;
505 GtkWidget *area;
506
507 preview = g_object_new (EOM_TYPE_PRINT_PREVIEW(eom_print_preview_get_type ()), NULL((void*)0));
508
509 area = preview->priv->area;
510
511 gtk_widget_set_events (area,
512 GDK_EXPOSURE_MASK |
513 GDK_POINTER_MOTION_MASK |
514 GDK_BUTTON_PRESS_MASK |
515 GDK_BUTTON_RELEASE_MASK |
516 GDK_KEY_PRESS_MASK);
517
518 g_object_set (G_OBJECT (area)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
area)), (((GType) ((20) << (2))))))))
,
519 "can-focus", TRUE(!(0)),
520 NULL((void*)0));
521
522/* update_relative_sizes (preview); */
523
524 g_signal_connect (G_OBJECT (area),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("draw"), (((GCallback) (draw_cb))), (preview), ((void*
)0), (GConnectFlags) 0)
525 "draw", G_CALLBACK (draw_cb),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("draw"), (((GCallback) (draw_cb))), (preview), ((void*
)0), (GConnectFlags) 0)
526 preview)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("draw"), (((GCallback) (draw_cb))), (preview), ((void*
)0), (GConnectFlags) 0)
;
527
528 g_signal_connect (G_OBJECT (area), "motion-notify-event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("motion-notify-event"), (((GCallback) (motion_notify_event_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
529 G_CALLBACK (motion_notify_event_cb), preview)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("motion-notify-event"), (((GCallback) (motion_notify_event_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
;
530
531 g_signal_connect (G_OBJECT (area), "button-press-event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("button-press-event"), (((GCallback) (button_press_event_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
532 G_CALLBACK (button_press_event_cb), preview)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("button-press-event"), (((GCallback) (button_press_event_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
;
533
534 g_signal_connect (G_OBJECT (area), "button-release-event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("button-release-event"), (((GCallback) (button_release_event_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
535 G_CALLBACK (button_release_event_cb), preview)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("button-release-event"), (((GCallback) (button_release_event_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
;
536
537 g_signal_connect (G_OBJECT (area), "key-press-event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("key-press-event"), (((GCallback) (key_press_event_cb)
)), (preview), ((void*)0), (GConnectFlags) 0)
538 G_CALLBACK (key_press_event_cb), preview)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((area)), (((GType) ((20) << (2)))))
)))), ("key-press-event"), (((GCallback) (key_press_event_cb)
)), (preview), ((void*)0), (GConnectFlags) 0)
;
539
540 g_signal_connect (area, "size-allocate",g_signal_connect_data ((area), ("size-allocate"), (((GCallback
) (size_allocate_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
541 G_CALLBACK (size_allocate_cb), preview)g_signal_connect_data ((area), ("size-allocate"), (((GCallback
) (size_allocate_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
;
542
543 return GTK_WIDGET (preview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(preview)), ((gtk_widget_get_type ()))))))
;
544}
545
546static gboolean
547draw_cb (GtkDrawingArea *drawing_area,
548 cairo_t *cr,
549 gpointer user_data)
550{
551 update_relative_sizes (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
);
552
553 eom_print_preview_draw (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
, cr);
554
555 if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
556 fprintf (stderrstderr, "Cairo is unhappy: %s\n",
557 cairo_status_to_string (cairo_status (cr)));
558 }
559
560 return TRUE(!(0));
561}
562
563/**
564 * get_current_image_coordinates:
565 * @preview: an #EomPrintPreview
566 * @x0: A pointer where to store the x coordinate.
567 * @y0: A pointer where to store the y coordinate.
568 *
569 * This function returns the current image coordinates, according
570 * with the properties of the given @preview widget.
571 **/
572static void
573get_current_image_coordinates (EomPrintPreview *preview,
574 gint *x0, gint *y0)
575{
576 EomPrintPreviewPrivate *priv;
577 GtkAllocation allocation;
578
579 priv = preview->priv;
580 gtk_widget_get_allocation (GTK_WIDGET (priv->area)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->area)), ((gtk_widget_get_type ()))))))
, &allocation);
581
582 *x0 = (gint)((1 - priv->image_x_align)*priv->l_rmargin + priv->image_x_align*(allocation.width - priv->r_rmargin - priv->r_width));
583 *y0 = (gint)((1 - priv->image_y_align)*priv->t_rmargin + priv->image_y_align*(allocation.height - priv->b_rmargin - priv->r_height));
584}
585
586/**
587 * press_inside_image_area:
588 * @preview: an #EomPrintPreview
589 * @x: the points x coordinate
590 * @y: the points y coordinate
591 *
592 * Returns whether the given point is inside the image area.
593 *
594 * Returns: %TRUE if the given point is inside of the image area,
595 * %FALSE otherwise.
596 **/
597static gboolean
598press_inside_image_area (EomPrintPreview *preview,
599 guint x,
600 guint y)
601{
602 EomPrintPreviewPrivate *priv;
603 gint x0, y0;
604
605 priv = preview->priv;
606 get_current_image_coordinates (preview, &x0, &y0);
607
608 if (x >= x0 && y >= y0 &&
609 x <= x0 + priv->r_width && y <= y0 + priv->r_height)
610 return TRUE(!(0));
611
612 return FALSE(0);
613}
614
615static void
616create_image_scaled (EomPrintPreview *preview)
617{
618 EomPrintPreviewPrivate *priv = preview->priv;
619
620 if (!priv->image_scaled) {
621 gint i_width, i_height;
622 GtkAllocation allocation;
623
624 gtk_widget_get_allocation (priv->area, &allocation);
625 i_width = gdk_pixbuf_get_width (priv->image);
626 i_height = gdk_pixbuf_get_height (priv->image);
627
628 if ((i_width > allocation.width) ||
629 (i_height > allocation.height)) {
630 gdouble scale;
631 scale = MIN ((gdouble) allocation.width/i_width,((((gdouble) allocation.width/i_width) < ((gdouble) allocation
.height/i_height)) ? ((gdouble) allocation.width/i_width) : (
(gdouble) allocation.height/i_height))
632 (gdouble) allocation.height/i_height)((((gdouble) allocation.width/i_width) < ((gdouble) allocation
.height/i_height)) ? ((gdouble) allocation.width/i_width) : (
(gdouble) allocation.height/i_height))
;
633 scale *= gtk_widget_get_scale_factor (GTK_WIDGET (priv->area)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(priv->area)), ((gtk_widget_get_type ()))))))
);
634 priv->image_scaled = gdk_pixbuf_scale_simple (priv->image,
635 i_width*scale,
636 i_height*scale,
637 GDK_INTERP_TILES);
638 } else {
639 priv->image_scaled = priv->image;
640 g_object_ref (priv->image_scaled);
641 }
642 }
643}
644
645static GdkPixbuf *
646create_preview_buffer (EomPrintPreview *preview)
647{
648 GdkPixbuf *pixbuf;
649 gint width, height, widget_scale;
650 GdkInterpType type = GDK_INTERP_TILES;
651
652 if (preview->priv->image == NULL((void*)0)) {
653 return NULL((void*)0);
654 }
655
656 create_image_scaled (preview);
657
658 width = gdk_pixbuf_get_width (preview->priv->image);
659 height = gdk_pixbuf_get_height (preview->priv->image);
660 widget_scale = gtk_widget_get_scale_factor (GTK_WIDGET (preview->priv->area)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(preview->priv->area)), ((gtk_widget_get_type ()))))))
);
661
662 width *= preview->priv->i_scale * preview->priv->p_scale
663 * widget_scale;
664 height *= preview->priv->i_scale * preview->priv->p_scale
665 * widget_scale;
666
667 if (width < 1 || height < 1)
668 return NULL((void*)0);
669
670 /* to use GDK_INTERP_TILES for small pixbufs is expensive and unnecessary */
671 if (width < 25 || height < 25)
672 type = GDK_INTERP_NEAREST;
673
674 if (preview->priv->image_scaled) {
675 pixbuf = gdk_pixbuf_scale_simple (preview->priv->image_scaled,
676 width, height, type);
677 } else {
678 pixbuf = gdk_pixbuf_scale_simple (preview->priv->image,
679 width, height, type);
680 }
681
682 return pixbuf;
683}
684
685static void
686create_surface (EomPrintPreview *preview)
687{
688 EomPrintPreviewPrivate *priv = preview->priv;
689 GdkPixbuf *pixbuf;
690
691 if (priv->surface) {
692 cairo_surface_destroy (priv->surface);
693 priv->surface = NULL((void*)0);
694 }
695
696 pixbuf = create_preview_buffer (preview);
697 if (pixbuf) {
698 priv->surface =
699 gdk_cairo_surface_create_from_pixbuf (pixbuf, 0,
700 gtk_widget_get_window (GTK_WIDGET (preview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(preview)), ((gtk_widget_get_type ()))))))
));
701 g_object_unref (pixbuf);
702 }
703 priv->flag_create_surface = FALSE(0);
704}
705
706static gboolean
707create_surface_when_idle (EomPrintPreview *preview)
708{
709 create_surface (preview);
710
711 return FALSE(0);
712}
713
714static gboolean
715button_press_event_cb (GtkWidget *widget,
716 GdkEventButton *event,
717 gpointer user_data)
718{
719 EomPrintPreview *preview = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
;
720
721 preview->priv->cursorx = event->x;
722 preview->priv->cursory = event->y;
723
724 switch (event->button) {
725 case 1:
726 preview->priv->grabbed = press_inside_image_area (preview, event->x, event->y);
727 break;
728 }
729
730 if (preview->priv->grabbed) {
731 gtk_widget_queue_draw (GTK_WIDGET (preview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(preview)), ((gtk_widget_get_type ()))))))
);
732 }
733
734 gtk_widget_grab_focus (preview->priv->area);
735
736 return FALSE(0);
737}
738
739static gboolean
740button_release_event_cb (GtkWidget *widget,
741 GdkEventButton *event,
742 gpointer user_data)
743{
744 EomPrintPreview *preview = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
;
745
746 switch (event->button) {
747 case 1:
748 preview->priv->grabbed = FALSE(0);
749 preview->priv->r_dx = 0;
750 preview->priv->r_dy = 0;
751 gtk_widget_queue_draw (GTK_WIDGET (preview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(preview)), ((gtk_widget_get_type ()))))))
);
752
753 }
754 return FALSE(0);
755}
756
757static gboolean
758key_press_event_cb (GtkWidget *widget,
759 GdkEventKey *event,
760 gpointer user_data)
761{
762 gfloat delta, align;
763 gboolean stop_emission = FALSE(0);
764 const gchar *property;
1
'property' declared without an initial value
765
766 delta = 0;
767
768 switch (event->keyval) {
2
'Default' branch taken. Execution continues on line 787
769 case GDK_KEY_Left0xff51:
770 property = "image-x-align";
771 delta = -0.01;
772 break;
773 case GDK_KEY_Right0xff53:
774 property = "image-x-align";
775 delta = 0.01;
776 break;
777 case GDK_KEY_Up0xff52:
778 property = "image-y-align";
779 delta = -0.01;
780 break;
781 case GDK_KEY_Down0xff54:
782 property = "image-y-align";
783 delta = 0.01;
784 break;
785 }
786
787 if (delta != 0) {
3
Assuming 'delta' is not equal to 0
4
Taking true branch
788 g_object_get (G_OBJECT (user_data)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
user_data)), (((GType) ((20) << (2))))))))
,
5
2nd function call argument is an uninitialized value
789 property, &align,
790 NULL((void*)0));
791
792 align += delta;
793 align = CLAMP (align, 0, 1)(((align) > (1)) ? (1) : (((align) < (0)) ? (0) : (align
)))
;
794 g_object_set (G_OBJECT (user_data)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
user_data)), (((GType) ((20) << (2))))))))
,
795 property, align,
796 NULL((void*)0));
797
798 stop_emission = TRUE(!(0));
799 g_signal_emit (G_OBJECT (user_data)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
user_data)), (((GType) ((20) << (2))))))))
,
800 preview_signals
801 [SIGNAL_IMAGE_MOVED], 0);
802 }
803
804 return stop_emission;
805}
806
807static gboolean
808motion_notify_event_cb (GtkWidget *widget,
809 GdkEventMotion *event,
810 gpointer user_data)
811{
812 EomPrintPreviewPrivate *priv = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
->priv;
813 gdouble dx, dy;
814 GtkAllocation allocation;
815
816 if (priv->grabbed) {
817 dx = event->x - priv->cursorx;
818 dy = event->y - priv->cursory;
819
820 gtk_widget_get_allocation (widget, &allocation);
821
822 /* Make sure the image stays inside the margins */
823
824 priv->image_x_align += (dx + priv->r_dx)/(allocation.width - priv->r_width - priv->l_rmargin - priv->r_rmargin);
825 if (priv->image_x_align < 0. || priv->image_x_align > 1.) {
826 priv->image_x_align = CLAMP (priv->image_x_align, 0., 1.)(((priv->image_x_align) > (1.)) ? (1.) : (((priv->image_x_align
) < (0.)) ? (0.) : (priv->image_x_align)))
;
827 priv->r_dx += dx;
828 }
829 else
830 priv->r_dx = 0;
831
832 priv->image_y_align += (dy + priv->r_dy)/(allocation.height - priv->r_height - priv->t_rmargin - priv->b_rmargin);
833 if (priv->image_y_align < 0. || priv->image_y_align > 1.) {
834 priv->image_y_align = CLAMP (priv->image_y_align, 0., 1.)(((priv->image_y_align) > (1.)) ? (1.) : (((priv->image_y_align
) < (0.)) ? (0.) : (priv->image_y_align)))
;
835 priv->r_dy += dy;
836 } else
837 priv->r_dy = 0;
838
839 /* we do this to correctly change the property values */
840 g_object_set (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
,
841 "image-x-align", priv->image_x_align,
842 "image-y-align", priv->image_y_align,
843 NULL((void*)0));
844
845 priv->cursorx = event->x;
846 priv->cursory = event->y;
847
848 g_signal_emit (G_OBJECT (user_data)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
user_data)), (((GType) ((20) << (2))))))))
,
849 preview_signals
850 [SIGNAL_IMAGE_MOVED], 0);
851 } else {
852 if (press_inside_image_area (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
, event->x, event->y)) {
853 GdkCursor *cursor;
854 cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
855 GDK_FLEUR);
856 gdk_window_set_cursor (gtk_widget_get_window (widget),
857 cursor);
858 g_object_unref (cursor);
859 } else {
860 gdk_window_set_cursor (gtk_widget_get_window (widget),
861 NULL((void*)0));
862 }
863 }
864 return FALSE(0);
865}
866
867static void
868size_allocate_cb (GtkWidget *widget,
869 GtkAllocation *allocation,
870 gpointer user_data)
871{
872 EomPrintPreview *preview;
873
874 preview = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
;
875 update_relative_sizes (preview);
876
877 preview->priv->flag_create_surface = TRUE(!(0));
878
879 if (preview->priv->image_scaled) {
880 g_object_unref (preview->priv->image_scaled);
881 preview->priv->image_scaled = NULL((void*)0);
882 }
883
884 g_idle_add ((GSourceFunc) create_surface_when_idle, preview);
885}
886
887static void
888eom_print_preview_draw (EomPrintPreview *preview, cairo_t *cr)
889{
890 EomPrintPreviewPrivate *priv;
891 GtkWidget *area;
892 GtkAllocation allocation;
893 gint x0, y0;
894 gboolean has_focus;
895
896 priv = preview->priv;
897 area = priv->area;
898
899 has_focus = gtk_widget_has_focus (area);
900
901 gtk_widget_get_allocation (area, &allocation);
902
903 /* draw the page */
904 cairo_set_source_rgb (cr, 1., 1., 1.);
905 cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
906 cairo_fill (cr);
907
908 /* draw the page margins */
909 cairo_set_source_rgb (cr, 0., 0., 0.);
910 cairo_set_line_width (cr, 0.1);
911 cairo_rectangle (cr,
912 priv->l_rmargin, priv->t_rmargin,
913 allocation.width - priv->l_rmargin - priv->r_rmargin,
914 allocation.height - priv->t_rmargin - priv->b_rmargin);
915 cairo_stroke (cr);
916
917 get_current_image_coordinates (preview, &x0, &y0);
918
919 if (priv->flag_create_surface) {
920 create_surface (preview);
921 }
922
923 if (priv->surface) {
924 cairo_set_source_surface (cr, priv->surface, x0, y0);
925 cairo_paint (cr);
926 } else if (priv->image_scaled) {
927 /* just in the remote case we don't have the surface */
928
929 /* adjust (x0, y0) to the new scale */
930 gdouble scale = priv->i_scale * priv->p_scale *
931 gdk_pixbuf_get_width (priv->image) / gdk_pixbuf_get_width (priv->image_scaled);
932 x0 /= scale;
933 y0 /= scale;
934
935 cairo_scale (cr, scale, scale);
936 gdk_cairo_set_source_pixbuf (cr, priv->image_scaled, x0, y0);
937 cairo_paint (cr);
938 } else if (priv->image) {
939 /* just in the remote case we don't have the surface */
940
941 /* adjust (x0, y0) to the new scale */
942 x0 /= priv->i_scale * priv->p_scale;
943 y0 /= priv->i_scale * priv->p_scale;
944
945 cairo_scale (cr, priv->i_scale*priv->p_scale, priv->i_scale*priv->p_scale);
946 gdk_cairo_set_source_pixbuf (cr, priv->image, x0, y0);
947 cairo_paint (cr);
948 }
949
950 if (has_focus) {
951 GtkStyleContext *ctx;
952
953 ctx = gtk_widget_get_style_context (area);
954 gtk_render_focus (ctx, cr, 0, 0,
955 allocation.width, allocation.height);
956 }
957}
958
959static void
960update_relative_sizes (EomPrintPreview *preview)
961{
962 EomPrintPreviewPrivate *priv;
963 GtkAllocation allocation;
964 gint i_width, i_height;
965
966 priv = preview->priv;
967
968 if (priv->image != NULL((void*)0)) {
969 i_width = gdk_pixbuf_get_width (priv->image);
970 i_height = gdk_pixbuf_get_height (priv->image);
971 } else {
972 i_width = i_height = 0;
973 }
974
975 gtk_widget_get_allocation (priv->area, &allocation);
976
977 priv->p_scale = (gfloat) allocation.width / (priv->p_width * 72.0);
978
979 priv->r_width = (gint) i_width * priv->i_scale * priv->p_scale;
980 priv->r_height = (gint) i_height * priv->i_scale * priv->p_scale;
981
982 priv->l_rmargin = (gint) (72. * priv->l_margin * priv->p_scale);
983 priv->r_rmargin = (gint) (72. * priv->r_margin * priv->p_scale);
984 priv->t_rmargin = (gint) (72. * priv->t_margin * priv->p_scale);
985 priv->b_rmargin = (gint) (72. * priv->b_margin * priv->p_scale);
986}
987
988/**
989 * eom_print_preview_set_page_margins:
990 * @preview: a #EomPrintPreview
991 * @l_margin: Left margin.
992 * @r_margin: Right margin.
993 * @t_margin: Top margin.
994 * @b_margin: Bottom margin.
995 *
996 * Manually set the margins, in inches.
997 **/
998void
999eom_print_preview_set_page_margins (EomPrintPreview *preview,
1000 gfloat l_margin,
1001 gfloat r_margin,
1002 gfloat t_margin,
1003 gfloat b_margin)
1004{
1005 g_return_if_fail (EOM_IS_PRINT_PREVIEW (preview))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((preview)); GType __t = ((eom_print_preview_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 ("EOM", ((const char
*) (__func__)), "EOM_IS_PRINT_PREVIEW (preview)"); return; } }
while (0)
;
1006
1007 g_object_set (G_OBJECT(preview)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
preview)), (((GType) ((20) << (2))))))))
,
1008 "page-left-margin", l_margin,
1009 "page-right-margin", r_margin,
1010 "page-top-margin", t_margin,
1011 "page-bottom-margin", r_margin,
1012 NULL((void*)0));
1013}
1014
1015/**
1016 * eom_print_preview_set_from_page_setup:
1017 * @preview: a #EomPrintPreview
1018 * @setup: a #GtkPageSetup to set the properties from
1019 *
1020 * Sets up the page properties from a #GtkPageSetup. Useful when using the
1021 * widget with the GtkPrint API.
1022 **/
1023void
1024eom_print_preview_set_from_page_setup (EomPrintPreview *preview,
1025 GtkPageSetup *setup)
1026{
1027 g_return_if_fail (EOM_IS_PRINT_PREVIEW (preview))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((preview)); GType __t = ((eom_print_preview_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 ("EOM", ((const char
*) (__func__)), "EOM_IS_PRINT_PREVIEW (preview)"); return; } }
while (0)
;
1028 g_return_if_fail (GTK_IS_PAGE_SETUP (setup))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((setup)); GType __t = ((gtk_page_setup_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 ("EOM", ((const char*) (__func__
)), "GTK_IS_PAGE_SETUP (setup)"); return; } } while (0)
;
1029
1030 g_object_set (G_OBJECT (preview)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
preview)), (((GType) ((20) << (2))))))))
,
1031 "page-left-margin", gtk_page_setup_get_left_margin (setup, GTK_UNIT_INCH),
1032 "page-right-margin", gtk_page_setup_get_right_margin (setup, GTK_UNIT_INCH),
1033 "page-top-margin", gtk_page_setup_get_top_margin (setup, GTK_UNIT_INCH),
1034 "page-bottom-margin", gtk_page_setup_get_bottom_margin (setup, GTK_UNIT_INCH),
1035 "paper-width", gtk_page_setup_get_paper_width (setup, GTK_UNIT_INCH),
1036 "paper-height", gtk_page_setup_get_paper_height (setup, GTK_UNIT_INCH),
1037 NULL((void*)0));
1038
1039}
1040
1041/**
1042 * eom_print_preview_get_image_position:
1043 * @preview: a #EomPrintPreview
1044 * @x: a pointer to a #gdouble, or %NULL to ignore it
1045 * @y: a pointer to a #gdouble, or %NULL to ignore it
1046 *
1047 * Gets current image position in inches, relative to the margins. A
1048 * (0, 0) position is the intersection between the left and top margins.
1049 **/
1050void
1051eom_print_preview_get_image_position (EomPrintPreview *preview,
1052 gdouble *x,
1053 gdouble *y)
1054{
1055 EomPrintPreviewPrivate *priv;
1056 gdouble width, height;
1057
1058 g_return_if_fail (EOM_IS_PRINT_PREVIEW (preview))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((preview)); GType __t = ((eom_print_preview_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 ("EOM", ((const char
*) (__func__)), "EOM_IS_PRINT_PREVIEW (preview)"); return; } }
while (0)
;
1059
1060 priv = preview->priv;
1061
1062 if (x != NULL((void*)0)) {
1063 width = gdk_pixbuf_get_width (priv->image) * priv->i_scale / 72.;
1064 *x = priv->image_x_align * (priv->p_width - priv->l_margin - priv->r_margin - width);
1065 }
1066 if (y != NULL((void*)0)) {
1067 height = gdk_pixbuf_get_height (priv->image) * priv->i_scale / 72.;
1068 *y = priv->image_y_align * (priv->p_height - priv->t_margin - priv->b_margin - height);
1069 }
1070}
1071
1072/**
1073 * eom_print_preview_set_image_position:
1074 * @preview: a #EomPrintPreview
1075 * @x: The X coordinate, in inches, or -1 to ignore it.
1076 * @y: The Y coordinate, in inches, or -1 to ignore it.
1077 *
1078 * Sets the image position. You can pass -1 to one of the coordinates if you
1079 * only want to set the other.
1080 **/
1081void
1082eom_print_preview_set_image_position (EomPrintPreview *preview,
1083 gdouble x,
1084 gdouble y)
1085{
1086 EomPrintPreviewPrivate *priv;
1087 gfloat x_align, y_align;
1088 gdouble width, height;
1089
1090 g_return_if_fail (EOM_IS_PRINT_PREVIEW (preview))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((preview)); GType __t = ((eom_print_preview_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 ("EOM", ((const char
*) (__func__)), "EOM_IS_PRINT_PREVIEW (preview)"); return; } }
while (0)
;
1091
1092 priv = preview->priv;
1093
1094 if (x != -1) {
1095 width = gdk_pixbuf_get_width (priv->image) * priv->i_scale / 72.;
1096 x_align = CLAMP (x/(priv->p_width - priv->l_margin - priv->r_margin - width), 0, 1)(((x/(priv->p_width - priv->l_margin - priv->r_margin
- width)) > (1)) ? (1) : (((x/(priv->p_width - priv->
l_margin - priv->r_margin - width)) < (0)) ? (0) : (x/(
priv->p_width - priv->l_margin - priv->r_margin - width
))))
;
1097 g_object_set (preview, "image-x-align", x_align, NULL((void*)0));
1098 }
1099
1100 if (y != -1) {
1101 height = gdk_pixbuf_get_height (priv->image) * priv->i_scale / 72.;
1102 y_align = CLAMP (y/(priv->p_height - priv->t_margin - priv->b_margin - height), 0, 1)(((y/(priv->p_height - priv->t_margin - priv->b_margin
- height)) > (1)) ? (1) : (((y/(priv->p_height - priv->
t_margin - priv->b_margin - height)) < (0)) ? (0) : (y/
(priv->p_height - priv->t_margin - priv->b_margin - height
))))
;
1103 g_object_set (preview, "image-y-align", y_align, NULL((void*)0));
1104 }
1105}
1106
1107/**
1108 * eom_print_preview_set_scale:
1109 * @preview: a #EomPrintPreview
1110 * @scale: a scale value, between 0 and 1.
1111 *
1112 * Sets the scale for the image.
1113 **/
1114void
1115eom_print_preview_set_scale (EomPrintPreview *preview,
1116 gfloat scale)
1117{
1118 g_return_if_fail (EOM_IS_PRINT_PREVIEW (preview))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((preview)); GType __t = ((eom_print_preview_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 ("EOM", ((const char
*) (__func__)), "EOM_IS_PRINT_PREVIEW (preview)"); return; } }
while (0)
;
1119
1120 g_object_set (preview,
1121 "image-scale", scale,
1122 NULL((void*)0));
1123}
diff --git a/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/scanview.css b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/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/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/sorttable.js b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2020-07-13-085735-5574-1@3caa58950c41_GDK_SCROLL_SMOOTH/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("