From 30fe652caeb61c41de256d94f9d5b264bd8e6152 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Wed, 14 Feb 2024 00:09:13 +0000 Subject: Deploy mate-desktop/eom to github.com/mate-desktop/eom.git:gh-pages --- .../index.html | 164 + .../report-06e1b8.html | 864 +++ .../report-1384bf.html | 3069 +++++++++ .../report-270b7d.html | 1126 ++++ .../report-3abb1a.html | 1164 ++++ .../report-4a64f5.html | 1018 +++ .../report-56073d.html | 864 +++ .../report-7315f5.html | 1126 ++++ .../report-84f082.html | 1348 ++++ .../report-931eff.html | 1126 ++++ .../report-9380a6.html | 1126 ++++ .../report-97b21d.html | 1126 ++++ .../report-982ff6.html | 1183 ++++ .../report-b791a9.html | 3178 ++++++++++ .../report-d22e5d.html | 1812 ++++++ .../report-d71e34.html | 3069 +++++++++ .../report-d7f8ad.html | 1018 +++ .../report-e1a871.html | 6522 ++++++++++++++++++++ .../report-ebc41c.html | 1126 ++++ .../report-f15e81.html | 1659 +++++ .../report-f46d8d.html | 864 +++ .../report-f88495.html | 6522 ++++++++++++++++++++ .../report-f92f6b.html | 1126 ++++ .../scanview.css | 62 + .../sorttable.js | 492 ++ 25 files changed, 42754 insertions(+) create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/index.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-06e1b8.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-1384bf.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-270b7d.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-3abb1a.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-4a64f5.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-56073d.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-7315f5.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-84f082.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-931eff.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-9380a6.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-97b21d.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-982ff6.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-b791a9.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-d22e5d.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-d71e34.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-d7f8ad.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-e1a871.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-ebc41c.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f15e81.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f46d8d.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f88495.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f92f6b.html create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/scanview.css create mode 100644 2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/sorttable.js (limited to '2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0') diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/index.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/index.html new file mode 100644 index 0000000..63ecc8c --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/index.html @@ -0,0 +1,164 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@f45deb7dd7a9
Working Directory:/rootdir
Command Line:make -j 3
Clang Version:clang version 17.0.6 (Fedora 17.0.6-2.fc39) +
Date:Wed Feb 14 00:04:46 2024
+

Bug Summary

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

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
APIArgument with 'nonnull' attribute passed nullsrc/eom-image.ceom_image_real_load95625View Report
Logic errorCast from non-struct type to struct typesrc/eom-scroll-view.csv_rgba_to_string_mapping17941View Report
Logic errorCast from non-struct type to struct typesrc/eom-preferences-dialog.cpd_string_to_rgba_mapping781View Report
Logic errorCast from non-struct type to struct typesrc/eom-scroll-view.csv_string_to_rgba_mapping17741View Report
Logic errorCast from non-struct type to struct typesrc/eom-preferences-dialog.cpd_rgba_to_string_mapping991View Report
Logic errorCast from non-struct type to struct typesrc/eom-window.ceom_window_cmd_edit_toolbar25171View Report
Logic errorCast from non-struct type to struct typesrc/eom-window.ceom_window_cmd_edit_toolbar25151View Report
Unused codeDead assignmentcut-n-paste/toolbar-editor/egg-toolbar-editor.cupdate_editor_sheet6191View Report
Unused codeDead assignmentcut-n-paste/toolbar-editor/egg-toolbars-model.cegg_toolbars_model_to_xml1031View Report
Logic errorOut-of-bound accesssrc/eom-util.ceom_util_filename_get_extension2996View Report
Logic errorUninitialized argument valuesrc/eom-print-preview.ckey_press_event_cb7935View Report
Unused codeUnreachable codesrc/main.cmain1691View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type3981View Report
Unused codeUnreachable codesrc/eom-util.ceom_util_filename_get_extension3001View Report
Unused codeUnreachable codesrc/main.cmain1781View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4151View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4231View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4091View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type3931View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4031View Report
Unused codeUnreachable codesrc/main.c_print_version_and_exit651View Report
Unused codeUnreachable codesrc/eom-transform.ceom_transform_get_transform_type4311View Report
+ + diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-06e1b8.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-06e1b8.html new file mode 100644 index 0000000..bc15cca --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-06e1b8.html @@ -0,0 +1,864 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -I ../cut-n-paste/toolbar-editor -I /usr/include/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -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 -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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
49static EomStartupFlags flags;
50
51static gboolean fullscreen = FALSE(0);
52static gboolean slide_show = FALSE(0);
53static gboolean disable_collection = FALSE(0);
54static gboolean force_new_instance = FALSE(0);
55static gchar **startup_files = NULL((void*)0);
56
57static gboolean
58_print_version_and_exit (const gchar *option_name,
59 const gchar *value,
60 gpointer data,
61 GError **error)
62{
63 g_print("%s %s\n", _("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"), VERSION"1.28.0");
64 exit (EXIT_SUCCESS0);
65 return TRUE(!(0));
66}
67
68static const GOptionEntry goption_options[] =
69{
70 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) },
71 { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) },
72 { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) },
73 { "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) },
74 { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
75 _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)},
76 { NULL((void*)0) }
77};
78
79static void
80set_startup_flags (void)
81{
82 if (fullscreen)
83 flags |= EOM_STARTUP_FULLSCREEN;
84
85 if (disable_collection)
86 flags |= EOM_STARTUP_DISABLE_COLLECTION;
87
88 if (slide_show)
89 flags |= EOM_STARTUP_SLIDE_SHOW;
90}
91
92int
93main (int argc, char **argv)
94{
95 GError *error = NULL((void*)0);
96 GOptionContext *ctx;
97 GFile *css_file;
98 GtkCssProvider *provider;
99
100#ifdef ENABLE_NLS1
101 bindtextdomain (GETTEXT_PACKAGE"eom", EOM_LOCALE_DIR"/usr/local/share/locale");
102 bind_textdomain_codeset (GETTEXT_PACKAGE"eom", "UTF-8");
103 textdomain (GETTEXT_PACKAGE"eom");
104#endif /* ENABLE_NLS */
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 set_startup_flags ();
134
135#ifdef HAVE_EXEMPI1
136 xmp_init();
137#endif
138 eom_debug_init ();
139 eom_job_queue_init ();
140 eom_thumbnail_init ();
141
142 /* Load special style properties for EomThumbView's scrollbar */
143 css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
144 provider = gtk_css_provider_new ();
145 if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
146 css_file,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
147 &error))(!gtk_css_provider_load_from_file(provider, css_file, &error
))
)
148 {
149 g_critical ("Could not load CSS data: %s", error->message);
150 g_clear_error (&error);
151 } else {
152 gtk_style_context_add_provider_for_screen (
153 gdk_screen_get_default(),
154 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
155 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
156 }
157 g_object_unref (provider);
158 g_object_unref (css_file);
159
160 /* Add application specific icons to search path */
161 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
162 EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "icons");
163
164 gtk_window_set_default_icon_name ("eom");
165 g_set_application_name (_("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"));
166
167 EOM_APP(eom_application_get_instance ())->priv->flags = flags;
168 if (force_new_instance) {
169 GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
);
This statement is never executed
170 app_flags |= G_APPLICATION_NON_UNIQUE;
171 g_application_set_flags (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, app_flags);
172 }
173
174 g_application_run (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, argc, argv);
175 g_object_unref (EOM_APP(eom_application_get_instance ()));
176
177 if (startup_files)
178 g_strfreev (startup_files);
179
180#ifdef HAVE_EXEMPI1
181 xmp_terminate();
182#endif
183 return 0;
184}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-1384bf.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-1384bf.html new file mode 100644 index 0000000..3114d0c --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-1384bf.html @@ -0,0 +1,3069 @@ + + + +eom-scroll-view.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-util.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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
31#include <time.h>
32
33#include "eom-util.h"
34
35#include <errno(*__errno_location ()).h>
36#include <string.h>
37#include <glib.h>
38#include <glib/gprintf.h>
39#include <glib/gstdio.h>
40#include <gtk/gtk.h>
41#include <gio/gio.h>
42#include <glib/gi18n.h>
43
44void
45eom_util_show_help (const gchar *section, GtkWindow *parent)
46{
47 GError *error = NULL((void*)0);
48 gchar *uri = NULL((void*)0);
49
50 if (section)
51 uri = g_strdup_printf ("help:eom/%s", section);
52
53 gtk_show_uri_on_window (parent, ((uri != NULL((void*)0)) ? uri : "help:eom"),
54 gtk_get_current_event_time (), &error);
55
56 g_free (uri);
57
58 if (error) {
59 GtkWidget *dialog;
60
61 dialog = gtk_message_dialog_new (parent,
62 0,
63 GTK_MESSAGE_ERROR,
64 GTK_BUTTONS_OK,
65 _("Could not display help for Eye of MATE")gettext ("Could not display help for Eye of MATE"));
66
67 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
68 "%s", error->message);
69
70 g_signal_connect_swapped (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
71 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
72 dialog)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
;
73 gtk_widget_show (dialog);
74
75 g_error_free (error);
76 }
77}
78
79gchar *
80eom_util_make_valid_utf8 (const gchar *str)
81{
82 GString *string;
83 const char *remainder, *invalid;
84 int remaining_bytes, valid_bytes;
85
86 string = NULL((void*)0);
87 remainder = str;
88 remaining_bytes = strlen (str);
89
90 while (remaining_bytes != 0) {
91 if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
92 break;
93 }
94
95 valid_bytes = invalid - remainder;
96
97 if (string == NULL((void*)0)) {
98 string = g_string_sized_new (remaining_bytes);
99 }
100
101 g_string_append_len (string, remainder, valid_bytes)g_string_append_len_inline (string, remainder, valid_bytes);
102 g_string_append_c (string, '?')g_string_append_c_inline (string, '?');
103
104 remaining_bytes -= valid_bytes + 1;
105 remainder = invalid + 1;
106 }
107
108 if (string == NULL((void*)0)) {
109 return g_strdup (str)g_strdup_inline (str);
110 }
111
112 g_string_append (string, remainder)(__builtin_constant_p (remainder) ? __extension__ ({ const char
* const __val = (remainder); g_string_append_len_inline (string
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (string
, remainder, (gssize) -1))
;
113 g_string_append (string, _(" (invalid Unicode)"))(__builtin_constant_p (gettext (" (invalid Unicode)")) ? __extension__
({ const char * const __val = (gettext (" (invalid Unicode)"
)); g_string_append_len_inline (string, __val, (__val != ((void
*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize) -1)
; }) : g_string_append_len_inline (string, gettext (" (invalid Unicode)"
), (gssize) -1))
;
114
115 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", 115, ((const char
*) (__func__)), "g_utf8_validate (string->str, -1, NULL)")
; } while (0)
;
116
117 return g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
118}
119
120GSList*
121eom_util_parse_uri_string_list_to_file_list (const gchar *uri_list)
122{
123 GSList* file_list = NULL((void*)0);
124 gsize i = 0;
125 gchar **uris;
126
127 uris = g_uri_list_extract_uris (uri_list);
128
129 while (uris[i] != NULL((void*)0)) {
130 file_list = g_slist_append (file_list, g_file_new_for_uri (uris[i]));
131 i++;
132 }
133
134 g_strfreev (uris);
135
136 return file_list;
137}
138
139GSList*
140eom_util_string_list_to_file_list (GSList *string_list)
141{
142 GSList *it = NULL((void*)0);
143 GSList *file_list = NULL((void*)0);
144
145 for (it = string_list; it != NULL((void*)0); it = it->next) {
146 char *uri_str;
147
148 uri_str = (gchar *) it->data;
149
150 file_list = g_slist_prepend (file_list,
151 g_file_new_for_uri (uri_str));
152 }
153
154 return g_slist_reverse (file_list);
155}
156
157GSList*
158eom_util_strings_to_file_list (gchar **strings)
159{
160 int i;
161 GSList *file_list = NULL((void*)0);
162
163 for (i = 0; strings[i]; i++) {
164 file_list = g_slist_prepend (file_list,
165 g_file_new_for_uri (strings[i]));
166 }
167
168 return g_slist_reverse (file_list);
169}
170
171GSList*
172eom_util_string_array_to_list (const gchar **files, gboolean create_uri)
173{
174 gint i;
175 GSList *list = NULL((void*)0);
176
177 if (files == NULL((void*)0)) return list;
178
179 for (i = 0; files[i]; i++) {
180 char *str;
181
182 if (create_uri) {
183 GFile *file;
184
185 file = g_file_new_for_commandline_arg (files[i]);
186 str = g_file_get_uri (file);
187
188 g_object_unref (file);
189 } else {
190 str = g_strdup (files[i])g_strdup_inline (files[i]);
191 }
192
193 if (str) {
194 list = g_slist_prepend (list, g_strdup (str)g_strdup_inline (str));
195 g_free (str);
196 }
197 }
198
199 return g_slist_reverse (list);
200}
201
202gchar **
203eom_util_string_array_make_absolute (gchar **files)
204{
205 int i;
206 int size;
207 gchar **abs_files;
208 GFile *file;
209
210 if (files == NULL((void*)0))
211 return NULL((void*)0);
212
213 size = g_strv_length (files);
214
215 /* Ensure new list is NULL-terminated */
216 abs_files = g_new0 (gchar *, size+1)((gchar * *) g_malloc0_n ((size+1), sizeof (gchar *)));
217
218 for (i = 0; i < size; i++) {
219 file = g_file_new_for_commandline_arg (files[i]);
220 abs_files[i] = g_file_get_uri (file);
221
222 g_object_unref (file);
223 }
224
225 return abs_files;
226}
227
228static gchar *dot_dir = NULL((void*)0);
229
230static gboolean
231ensure_dir_exists (const char *dir)
232{
233 if (g_file_test (dir, G_FILE_TEST_IS_DIR))
234 return TRUE(!(0));
235
236 if (g_mkdir_with_parents (dir, 0700) == 0)
237 return TRUE(!(0));
238
239 if (errno(*__errno_location ()) == EEXIST17)
240 return g_file_test (dir, G_FILE_TEST_IS_DIR);
241
242 g_warning ("Failed to create directory %s: %s", dir, strerror (errno(*__errno_location ())));
243 return FALSE(0);
244}
245
246const gchar *
247eom_util_dot_dir (void)
248{
249 if (dot_dir == NULL((void*)0)) {
250 gboolean exists;
251
252 dot_dir = g_build_filename(g_get_user_config_dir(), "mate", "eom", NULL((void*)0));
253
254 exists = ensure_dir_exists (dot_dir);
255
256 if (G_UNLIKELY (!exists)(!exists)) {
257 static gboolean printed_warning = FALSE(0);
258
259 if (!printed_warning) {
260 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);
261 printed_warning = TRUE(!(0));
262 }
263 dot_dir = NULL((void*)0);
264 return NULL((void*)0);
265 }
266 }
267
268 return dot_dir;
269}
270
271/* Based on eel_filename_strip_extension() */
272
273/**
274 * eom_util_filename_get_extension:
275 * @filename: a filename
276 *
277 * Returns a reasonably good guess of the file extension of @filename.
278 *
279 * Returns: a newly allocated string with the file extension of @filename.
280 **/
281char *
282eom_util_filename_get_extension (const char * filename)
283{
284 char *begin, *begin2;
285
286 if (filename == NULL((void*)0)) {
287 return NULL((void*)0);
288 }
289
290 begin = strrchr (filename, '.');
291
292 if (begin && begin != filename) {
293 if (strcmp (begin, ".gz") == 0 ||
294 strcmp (begin, ".bz2") == 0 ||
295 strcmp (begin, ".sit") == 0 ||
296 strcmp (begin, ".Z") == 0) {
297 begin2 = begin - 1;
298 while (begin2 > filename &&
299 *begin2 != '.') {
300 begin2--;
This statement is never executed
301 }
302 if (begin2 != filename) {
303 begin = begin2;
304 }
305 }
306 begin ++;
307 } else {
308 return NULL((void*)0);
309 }
310
311 return g_strdup (begin)g_strdup_inline (begin);
312}
313
314/**
315 * eom_util_file_is_persistent:
316 * @file: a #GFile
317 *
318 * Checks whether @file is a non-removable local mount.
319 *
320 * Returns: %TRUE if @file is in a non-removable mount,
321 * %FALSE otherwise or when it is remote.
322 **/
323gboolean
324eom_util_file_is_persistent (GFile *file)
325{
326 GMount *mount;
327
328 if (!g_file_is_native (file))
329 return FALSE(0);
330
331 mount = g_file_find_enclosing_mount (file, NULL((void*)0), NULL((void*)0));
332 if (mount) {
333 if (g_mount_can_unmount (mount)) {
334 return FALSE(0);
335 }
336 }
337
338 return TRUE(!(0));
339}
340
341static void
342_eom_util_show_file_in_filemanager_fallback (GFile *file, GtkWindow *toplevel)
343{
344 gchar *uri = NULL((void*)0);
345 GError *error = NULL((void*)0);
346 guint32 timestamp = gtk_get_current_event_time ();
347
348 if (g_file_query_file_type (file, 0, NULL((void*)0)) == G_FILE_TYPE_DIRECTORY) {
349 uri = g_file_get_uri (file);
350 } else {
351 /* If input file is not a directory we must open it's
352 folder/parent to avoid opening the file itself */
353 GFile *parent_file;
354
355 parent_file = g_file_get_parent (file);
356 if (G_LIKELY (parent_file)(parent_file))
357 uri = g_file_get_uri (parent_file);
358 g_object_unref (parent_file);
359 }
360
361 if (uri && !gtk_show_uri_on_window (toplevel, uri, timestamp, &error)) {
362 g_warning ("Couldn't show containing folder \"%s\": %s", uri,
363 error->message);
364 g_error_free (error);
365 }
366
367 g_free (uri);
368}
369
370void
371eom_util_show_file_in_filemanager (GFile *file, GtkWindow *toplevel)
372{
373 GDBusProxy *proxy;
374 gboolean done = FALSE(0);
375
376 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)
;
377
378 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
379 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
380 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
381 NULL((void*)0), "org.freedesktop.FileManager1",
382 "/org/freedesktop/FileManager1",
383 "org.freedesktop.FileManager1",
384 NULL((void*)0), NULL((void*)0));
385
386 if (proxy) {
387 gchar *uri = g_file_get_uri (file);
388 gchar *startup_id;
389 GVariant *params, *result;
390 GVariantBuilder builder;
391
392 g_variant_builder_init (&builder,
393 G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
394 g_variant_builder_add (&builder, "s", uri);
395
396 /* This seems to be the expected format, as other values
397 cause the filemanager window not to get focus. */
398 startup_id = g_strdup_printf("_TIME%u",
399 gtk_get_current_event_time());
400
401 /* params is floating! */
402 params = g_variant_new ("(ass)", &builder, startup_id);
403
404 g_free (startup_id);
405 g_variant_builder_clear (&builder);
406
407 /* Floating params-GVariant is consumed here */
408 result = g_dbus_proxy_call_sync (proxy, "ShowItems",
409 params, G_DBUS_CALL_FLAGS_NONE,
410 -1, NULL((void*)0), NULL((void*)0));
411
412 /* Receiving a non-NULL result counts as a successful call. */
413 if (G_LIKELY (result != NULL)(result != ((void*)0))) {
414 done = TRUE(!(0));
415 g_variant_unref (result);
416 }
417
418 g_free (uri);
419 g_object_unref (proxy);
420 }
421
422 /* Fallback to gtk_show_uri() if launch over DBus is not possible */
423 if (!done)
424 _eom_util_show_file_in_filemanager_fallback (file, toplevel);
425}
426
427gboolean
428eom_notebook_scroll_event_cb (GtkWidget *widget,
429 GdkEventScroll *event)
430
431{
432 GtkNotebook *notebook = GTK_NOTEBOOK (widget)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_notebook_get_type ()))))))
;
433 GtkWidget *child, *event_widget, *action_widget;
434
435 child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
436 if (child == NULL((void*)0))
437 return FALSE(0);
438
439 event_widget = gtk_get_event_widget ((GdkEvent*) event);
440
441 /* Ignore scroll events from the content of the page */
442 if (event_widget == NULL((void*)0) || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
443 return FALSE(0);
444
445 /* And also from the action widgets */
446 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
447 if (event_widget == action_widget || (action_widget != NULL((void*)0) && gtk_widget_is_ancestor (event_widget, action_widget)))
448 return FALSE(0);
449
450 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
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 switch (event->direction) {
455 case GDK_SCROLL_RIGHT:
456 case GDK_SCROLL_DOWN:
457 gtk_notebook_next_page (notebook);
458 break;
459 case GDK_SCROLL_LEFT:
460 case GDK_SCROLL_UP:
461 gtk_notebook_prev_page (notebook);
462 break;
463 case GDK_SCROLL_SMOOTH:
464 switch (gtk_notebook_get_tab_pos (notebook)) {
465 case GTK_POS_LEFT:
466 case GTK_POS_RIGHT:
467 if (event->delta_y > 0)
468 gtk_notebook_next_page (notebook);
469 else if (event->delta_y < 0)
470 gtk_notebook_prev_page (notebook);
471 break;
472 case GTK_POS_TOP:
473 case GTK_POS_BOTTOM:
474 if (event->delta_x > 0)
475 gtk_notebook_next_page (notebook);
476 else if (event->delta_x < 0)
477 gtk_notebook_prev_page (notebook);
478 break;
479 }
480 break;
481 }
482
483 return TRUE(!(0));
484}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-4a64f5.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-4a64f5.html new file mode 100644 index 0000000..818ffc1 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-4a64f5.html @@ -0,0 +1,1018 @@ + + + +eom-preferences-dialog.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-preferences-dialog.c
Warning:line 78, 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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-preferences-dialog.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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_VALUE"GSETTINGS_VALUE" "GSETTINGS_VALUE"
42
43struct _EomPreferencesDialogPrivate {
44 GSettings *view_settings;
45 GSettings *ui_settings;
46 GSettings *fullscreen_settings;
47
48 GtkWidget *notebook;
49 GtkWidget *interpolate_check;
50 GtkWidget *extrapolate_check;
51 GtkWidget *autorotate_check;
52 GtkWidget *bg_color_check;
53 GtkWidget *bg_color_button;
54 GtkWidget *color_radio;
55 GtkWidget *checkpattern_radio;
56 GtkWidget *background_radio;
57 GtkWidget *transp_color_button;
58
59 GtkWidget *upscale_check;
60 GtkWidget *random_check;
61 GtkWidget *loop_check;
62 GtkWidget *seconds_spin;
63
64 GtkWidget *plugin_manager;
65};
66
67static GObject *instance = NULL((void*)0);
68
69G_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 gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_preferences_dialog_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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; }
;
70
71static gboolean
72pd_string_to_rgba_mapping (GValue *value,
73 GVariant *variant,
74 gpointer user_data)
75{
76 GdkRGBA color;
77
78 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
79
80 if (gdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) {
81 g_value_set_boxed (value, &color);
82 return TRUE(!(0));
83 }
84
85 return FALSE(0);
86}
87
88static GVariant*
89pd_rgba_to_string_mapping (const GValue *value,
90 const GVariantType *expected_type,
91 gpointer user_data)
92{
93
94 GVariant *variant = NULL((void*)0);
95 GdkRGBA *color;
96 gchar *hex_val;
97
98 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)
;
99 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)
;
100
101 color = g_value_get_boxed (value);
102 hex_val = gdk_rgba_to_string(color);
103
104 variant = g_variant_new_string (hex_val);
105 g_free (hex_val);
106
107 return variant;
108}
109
110static void
111pd_transp_radio_toggle_cb (GtkWidget *widget, gpointer data)
112{
113 gpointer value = NULL((void*)0);
114
115 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_toggle_button_get_type ()))))))
))
116 return;
117
118 value = g_object_get_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE");
119
120 g_settings_set_enum (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, EOM_CONF_VIEW_TRANSPARENCY"transparency",
121 GPOINTER_TO_INT (value)((gint) (glong) (value)));
122}
123
124static void
125random_change_cb (GSettings *settings, gchar *key, GtkWidget *widget)
126{
127 gtk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key));
128}
129
130static void
131eom_preferences_response_cb (GtkDialog *dlg, gint res_id, gpointer data)
132{
133 switch (res_id) {
134 case GTK_RESPONSE_HELP:
135 eom_util_show_help ("eom-prefs", NULL((void*)0));
136 break;
137 default:
138 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_widget_get_type ()))))))
);
139 instance = NULL((void*)0);
140 }
141}
142
143static void
144eom_preferences_dialog_class_init (EomPreferencesDialogClass *klass)
145{
146 GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
147
148 /* This should make sure the libpeas-gtk dependency isn't
149 * dropped by aggressive linkers (#739618) */
150 g_type_ensure (PEAS_GTK_TYPE_PLUGIN_MANAGER(peas_gtk_plugin_manager_get_type()));
151
152 gtk_widget_class_set_template_from_resource (widget_class,
153 "/org/mate/eom/ui/eom-preferences-dialog.ui");
154 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)))))
155 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
156 notebook)gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
;
157 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)))))
158 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
159 interpolate_check)gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
;
160 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)))))
161 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
162 extrapolate_check)gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
;
163 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)))))
164 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
165 autorotate_check)gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
;
166 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)))))
167 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
168 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)))))
;
169 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)))))
170 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
171 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)))))
;
172 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)))))
173 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
174 color_radio)gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
;
175 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)))))
176 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
177 checkpattern_radio)gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
;
178 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)))))
179 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
180 background_radio)gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
;
181 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)))))
182 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
183 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)))))
;
184
185 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)))))
186 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
187 upscale_check)gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
;
188 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)))))
189 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
190 random_check)gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
;
191 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)))))
192 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
193 loop_check)gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
;
194 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)))))
195 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
196 seconds_spin)gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
;
197
198 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)))))
199 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
200 plugin_manager)gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
;
201}
202
203static void
204eom_preferences_dialog_init (EomPreferencesDialog *pref_dlg)
205{
206 EomPreferencesDialogPrivate *priv;
207
208 pref_dlg->priv = eom_preferences_dialog_get_instance_private (pref_dlg);
209 priv = pref_dlg->priv;
210
211 gtk_widget_init_template (GTK_WIDGET (pref_dlg)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_dlg)), ((gtk_widget_get_type ()))))))
);
212
213 priv->view_settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
214 priv->fullscreen_settings = g_settings_new (EOM_CONF_FULLSCREEN"org.mate.eom"".full-screen");
215
216 g_signal_connect (pref_dlg, "response",g_signal_connect_data ((pref_dlg), ("response"), (((GCallback
) (eom_preferences_response_cb))), (pref_dlg), ((void*)0), (GConnectFlags
) 0)
217 G_CALLBACK (eom_preferences_response_cb),g_signal_connect_data ((pref_dlg), ("response"), (((GCallback
) (eom_preferences_response_cb))), (pref_dlg), ((void*)0), (GConnectFlags
) 0)
218 pref_dlg)g_signal_connect_data ((pref_dlg), ("response"), (((GCallback
) (eom_preferences_response_cb))), (pref_dlg), ((void*)0), (GConnectFlags
) 0)
;
219
220 g_settings_bind (priv->view_settings,
221 EOM_CONF_VIEW_INTERPOLATE"interpolate",
222 priv->interpolate_check, "active",
223 G_SETTINGS_BIND_DEFAULT);
224 g_settings_bind (priv->view_settings,
225 EOM_CONF_VIEW_EXTRAPOLATE"extrapolate",
226 priv->extrapolate_check, "active",
227 G_SETTINGS_BIND_DEFAULT);
228 g_settings_bind (priv->view_settings,
229 EOM_CONF_VIEW_AUTOROTATE"autorotate",
230 priv->autorotate_check, "active",
231 G_SETTINGS_BIND_DEFAULT);
232 g_settings_bind (priv->view_settings,
233 EOM_CONF_VIEW_USE_BG_COLOR"use-background-color",
234 priv->bg_color_check, "active",
235 G_SETTINGS_BIND_DEFAULT);
236
237 g_settings_bind_with_mapping (priv->view_settings,
238 EOM_CONF_VIEW_BACKGROUND_COLOR"background-color",
239 priv->bg_color_button, "rgba",
240 G_SETTINGS_BIND_DEFAULT,
241 pd_string_to_rgba_mapping,
242 pd_rgba_to_string_mapping,
243 NULL((void*)0), NULL((void*)0));
244 g_object_set_data (G_OBJECT (priv->color_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), (((GType) ((20) << (2)))))
)))
,
245 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
246 GINT_TO_POINTER (EOM_TRANSP_COLOR)((gpointer) (glong) (EOM_TRANSP_COLOR)));
247
248 g_signal_connect (priv->color_radio, "toggled",g_signal_connect_data ((priv->color_radio), ("toggled"), (
((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
249 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((priv->color_radio), ("toggled"), (
((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
250 priv->view_settings)g_signal_connect_data ((priv->color_radio), ("toggled"), (
((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
;
251
252 g_object_set_data (G_OBJECT (priv->checkpattern_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), (((GType) ((20) << (
2))))))))
,
253 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
254 GINT_TO_POINTER (EOM_TRANSP_CHECKED)((gpointer) (glong) (EOM_TRANSP_CHECKED)));
255
256 g_signal_connect (priv->checkpattern_radio, "toggled",g_signal_connect_data ((priv->checkpattern_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
257 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((priv->checkpattern_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
258 priv->view_settings)g_signal_connect_data ((priv->checkpattern_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
;
259
260 g_object_set_data (G_OBJECT (priv->background_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), (((GType) ((20) << (2
))))))))
,
261 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
262 GINT_TO_POINTER (EOM_TRANSP_BACKGROUND)((gpointer) (glong) (EOM_TRANSP_BACKGROUND)));
263
264 g_signal_connect (priv->background_radio, "toggled",g_signal_connect_data ((priv->background_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
265 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((priv->background_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
266 priv->view_settings)g_signal_connect_data ((priv->background_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
;
267
268 switch (g_settings_get_enum (priv->view_settings,
269 EOM_CONF_VIEW_TRANSPARENCY"transparency"))
270 {
271 case EOM_TRANSP_COLOR:
272 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->color_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), ((gtk_toggle_button_get_type ())
)))))
, TRUE(!(0)));
273 break;
274 case EOM_TRANSP_CHECKED:
275 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkpattern_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
276 break;
277 default:
278 // Log a warning and use EOM_TRANSP_BACKGROUND as fallback
279 g_warn_if_reached ()do { g_warn_message ("EOM", "eom-preferences-dialog.c", 279, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
280 case EOM_TRANSP_BACKGROUND:
281 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->background_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
282 break;
283 }
284
285 g_settings_bind_with_mapping (priv->view_settings,
286 EOM_CONF_VIEW_TRANS_COLOR"trans-color",
287 priv->transp_color_button, "rgba",
288 G_SETTINGS_BIND_DEFAULT,
289 pd_string_to_rgba_mapping,
290 pd_rgba_to_string_mapping,
291 NULL((void*)0), NULL((void*)0));
292
293 g_settings_bind (priv->fullscreen_settings, EOM_CONF_FULLSCREEN_UPSCALE"upscale",
294 priv->upscale_check, "active",
295 G_SETTINGS_BIND_DEFAULT);
296
297 g_settings_bind (priv->fullscreen_settings,
298 EOM_CONF_FULLSCREEN_LOOP"loop",
299 priv->loop_check, "active",
300 G_SETTINGS_BIND_DEFAULT);
301
302 g_settings_bind (priv->fullscreen_settings,
303 EOM_CONF_FULLSCREEN_RANDOM"random",
304 priv->random_check, "active",
305 G_SETTINGS_BIND_DEFAULT);
306 g_signal_connect (priv->fullscreen_settings, "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)
307 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)
308 priv->loop_check)g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
;
309 random_change_cb (priv->fullscreen_settings,
310 EOM_CONF_FULLSCREEN_RANDOM"random",
311 priv->loop_check);
312
313 g_settings_bind (priv->fullscreen_settings,
314 EOM_CONF_FULLSCREEN_SECONDS"seconds",
315 priv->seconds_spin, "value",
316 G_SETTINGS_BIND_DEFAULT);
317
318 gtk_widget_show_all (priv->plugin_manager);
319
320 /* Add tab scrolling support for GTK3 */
321 gtk_widget_add_events (priv->notebook, GDK_SCROLL_MASK);
322 g_signal_connect (priv->notebook, "scroll-event",g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
323 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)
324 NULL)g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
325}
326
327GtkWidget *eom_preferences_dialog_get_instance (GtkWindow *parent)
328{
329 if (instance == NULL((void*)0)) {
330 instance = g_object_new (EOM_TYPE_PREFERENCES_DIALOG(eom_preferences_dialog_get_type ()),
331 NULL((void*)0));
332 }
333
334 if (parent)
335 gtk_window_set_transient_for (GTK_WINDOW (instance)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((gtk_window_get_type ()))))))
, parent);
336
337 return GTK_WIDGET(instance)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((gtk_widget_get_type ()))))))
;
338}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-56073d.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-56073d.html new file mode 100644 index 0000000..3ad348e --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-56073d.html @@ -0,0 +1,864 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -I ../cut-n-paste/toolbar-editor -I /usr/include/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -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 -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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
49static EomStartupFlags flags;
50
51static gboolean fullscreen = FALSE(0);
52static gboolean slide_show = FALSE(0);
53static gboolean disable_collection = FALSE(0);
54static gboolean force_new_instance = FALSE(0);
55static gchar **startup_files = NULL((void*)0);
56
57static gboolean
58_print_version_and_exit (const gchar *option_name,
59 const gchar *value,
60 gpointer data,
61 GError **error)
62{
63 g_print("%s %s\n", _("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"), VERSION"1.28.0");
64 exit (EXIT_SUCCESS0);
65 return TRUE(!(0));
66}
67
68static const GOptionEntry goption_options[] =
69{
70 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) },
71 { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) },
72 { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) },
73 { "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) },
74 { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
75 _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)},
76 { NULL((void*)0) }
77};
78
79static void
80set_startup_flags (void)
81{
82 if (fullscreen)
83 flags |= EOM_STARTUP_FULLSCREEN;
84
85 if (disable_collection)
86 flags |= EOM_STARTUP_DISABLE_COLLECTION;
87
88 if (slide_show)
89 flags |= EOM_STARTUP_SLIDE_SHOW;
90}
91
92int
93main (int argc, char **argv)
94{
95 GError *error = NULL((void*)0);
96 GOptionContext *ctx;
97 GFile *css_file;
98 GtkCssProvider *provider;
99
100#ifdef ENABLE_NLS1
101 bindtextdomain (GETTEXT_PACKAGE"eom", EOM_LOCALE_DIR"/usr/local/share/locale");
102 bind_textdomain_codeset (GETTEXT_PACKAGE"eom", "UTF-8");
103 textdomain (GETTEXT_PACKAGE"eom");
104#endif /* ENABLE_NLS */
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 set_startup_flags ();
134
135#ifdef HAVE_EXEMPI1
136 xmp_init();
137#endif
138 eom_debug_init ();
139 eom_job_queue_init ();
140 eom_thumbnail_init ();
141
142 /* Load special style properties for EomThumbView's scrollbar */
143 css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
144 provider = gtk_css_provider_new ();
145 if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
146 css_file,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
147 &error))(!gtk_css_provider_load_from_file(provider, css_file, &error
))
)
148 {
149 g_critical ("Could not load CSS data: %s", error->message);
150 g_clear_error (&error);
151 } else {
152 gtk_style_context_add_provider_for_screen (
153 gdk_screen_get_default(),
154 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
155 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
156 }
157 g_object_unref (provider);
158 g_object_unref (css_file);
159
160 /* Add application specific icons to search path */
161 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
162 EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "icons");
163
164 gtk_window_set_default_icon_name ("eom");
165 g_set_application_name (_("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"));
166
167 EOM_APP(eom_application_get_instance ())->priv->flags = flags;
168 if (force_new_instance) {
169 GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
);
170 app_flags |= G_APPLICATION_NON_UNIQUE;
171 g_application_set_flags (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, app_flags);
172 }
173
174 g_application_run (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, argc, argv);
175 g_object_unref (EOM_APP(eom_application_get_instance ()));
176
177 if (startup_files)
178 g_strfreev (startup_files);
This statement is never executed
179
180#ifdef HAVE_EXEMPI1
181 xmp_terminate();
182#endif
183 return 0;
184}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-7315f5.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-7315f5.html new file mode 100644 index 0000000..f5533e6 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-7315f5.html @@ -0,0 +1,1126 @@ + + + +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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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 gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_transform_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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)((__typeof__ (pixbuf)) (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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-84f082.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-84f082.html new file mode 100644 index 0000000..33a48dd --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-84f082.html @@ -0,0 +1,1348 @@ + + + +egg-toolbar-editor.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

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

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-util.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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
31#include <time.h>
32
33#include "eom-util.h"
34
35#include <errno(*__errno_location ()).h>
36#include <string.h>
37#include <glib.h>
38#include <glib/gprintf.h>
39#include <glib/gstdio.h>
40#include <gtk/gtk.h>
41#include <gio/gio.h>
42#include <glib/gi18n.h>
43
44void
45eom_util_show_help (const gchar *section, GtkWindow *parent)
46{
47 GError *error = NULL((void*)0);
48 gchar *uri = NULL((void*)0);
49
50 if (section)
51 uri = g_strdup_printf ("help:eom/%s", section);
52
53 gtk_show_uri_on_window (parent, ((uri != NULL((void*)0)) ? uri : "help:eom"),
54 gtk_get_current_event_time (), &error);
55
56 g_free (uri);
57
58 if (error) {
59 GtkWidget *dialog;
60
61 dialog = gtk_message_dialog_new (parent,
62 0,
63 GTK_MESSAGE_ERROR,
64 GTK_BUTTONS_OK,
65 _("Could not display help for Eye of MATE")gettext ("Could not display help for Eye of MATE"));
66
67 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
68 "%s", error->message);
69
70 g_signal_connect_swapped (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
71 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
72 dialog)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (dialog), ((void*)0), G_CONNECT_SWAPPED
)
;
73 gtk_widget_show (dialog);
74
75 g_error_free (error);
76 }
77}
78
79gchar *
80eom_util_make_valid_utf8 (const gchar *str)
81{
82 GString *string;
83 const char *remainder, *invalid;
84 int remaining_bytes, valid_bytes;
85
86 string = NULL((void*)0);
87 remainder = str;
88 remaining_bytes = strlen (str);
89
90 while (remaining_bytes != 0) {
91 if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
92 break;
93 }
94
95 valid_bytes = invalid - remainder;
96
97 if (string == NULL((void*)0)) {
98 string = g_string_sized_new (remaining_bytes);
99 }
100
101 g_string_append_len (string, remainder, valid_bytes)g_string_append_len_inline (string, remainder, valid_bytes);
102 g_string_append_c (string, '?')g_string_append_c_inline (string, '?');
103
104 remaining_bytes -= valid_bytes + 1;
105 remainder = invalid + 1;
106 }
107
108 if (string == NULL((void*)0)) {
109 return g_strdup (str)g_strdup_inline (str);
110 }
111
112 g_string_append (string, remainder)(__builtin_constant_p (remainder) ? __extension__ ({ const char
* const __val = (remainder); g_string_append_len_inline (string
, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !
(__val))) : (gssize) -1); }) : g_string_append_len_inline (string
, remainder, (gssize) -1))
;
113 g_string_append (string, _(" (invalid Unicode)"))(__builtin_constant_p (gettext (" (invalid Unicode)")) ? __extension__
({ const char * const __val = (gettext (" (invalid Unicode)"
)); g_string_append_len_inline (string, __val, (__val != ((void
*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize) -1)
; }) : g_string_append_len_inline (string, gettext (" (invalid Unicode)"
), (gssize) -1))
;
114
115 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", 115, ((const char
*) (__func__)), "g_utf8_validate (string->str, -1, NULL)")
; } while (0)
;
116
117 return g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
118}
119
120GSList*
121eom_util_parse_uri_string_list_to_file_list (const gchar *uri_list)
122{
123 GSList* file_list = NULL((void*)0);
124 gsize i = 0;
125 gchar **uris;
126
127 uris = g_uri_list_extract_uris (uri_list);
128
129 while (uris[i] != NULL((void*)0)) {
130 file_list = g_slist_append (file_list, g_file_new_for_uri (uris[i]));
131 i++;
132 }
133
134 g_strfreev (uris);
135
136 return file_list;
137}
138
139GSList*
140eom_util_string_list_to_file_list (GSList *string_list)
141{
142 GSList *it = NULL((void*)0);
143 GSList *file_list = NULL((void*)0);
144
145 for (it = string_list; it != NULL((void*)0); it = it->next) {
146 char *uri_str;
147
148 uri_str = (gchar *) it->data;
149
150 file_list = g_slist_prepend (file_list,
151 g_file_new_for_uri (uri_str));
152 }
153
154 return g_slist_reverse (file_list);
155}
156
157GSList*
158eom_util_strings_to_file_list (gchar **strings)
159{
160 int i;
161 GSList *file_list = NULL((void*)0);
162
163 for (i = 0; strings[i]; i++) {
164 file_list = g_slist_prepend (file_list,
165 g_file_new_for_uri (strings[i]));
166 }
167
168 return g_slist_reverse (file_list);
169}
170
171GSList*
172eom_util_string_array_to_list (const gchar **files, gboolean create_uri)
173{
174 gint i;
175 GSList *list = NULL((void*)0);
176
177 if (files == NULL((void*)0)) return list;
178
179 for (i = 0; files[i]; i++) {
180 char *str;
181
182 if (create_uri) {
183 GFile *file;
184
185 file = g_file_new_for_commandline_arg (files[i]);
186 str = g_file_get_uri (file);
187
188 g_object_unref (file);
189 } else {
190 str = g_strdup (files[i])g_strdup_inline (files[i]);
191 }
192
193 if (str) {
194 list = g_slist_prepend (list, g_strdup (str)g_strdup_inline (str));
195 g_free (str);
196 }
197 }
198
199 return g_slist_reverse (list);
200}
201
202gchar **
203eom_util_string_array_make_absolute (gchar **files)
204{
205 int i;
206 int size;
207 gchar **abs_files;
208 GFile *file;
209
210 if (files == NULL((void*)0))
211 return NULL((void*)0);
212
213 size = g_strv_length (files);
214
215 /* Ensure new list is NULL-terminated */
216 abs_files = g_new0 (gchar *, size+1)((gchar * *) g_malloc0_n ((size+1), sizeof (gchar *)));
217
218 for (i = 0; i < size; i++) {
219 file = g_file_new_for_commandline_arg (files[i]);
220 abs_files[i] = g_file_get_uri (file);
221
222 g_object_unref (file);
223 }
224
225 return abs_files;
226}
227
228static gchar *dot_dir = NULL((void*)0);
229
230static gboolean
231ensure_dir_exists (const char *dir)
232{
233 if (g_file_test (dir, G_FILE_TEST_IS_DIR))
234 return TRUE(!(0));
235
236 if (g_mkdir_with_parents (dir, 0700) == 0)
237 return TRUE(!(0));
238
239 if (errno(*__errno_location ()) == EEXIST17)
240 return g_file_test (dir, G_FILE_TEST_IS_DIR);
241
242 g_warning ("Failed to create directory %s: %s", dir, strerror (errno(*__errno_location ())));
243 return FALSE(0);
244}
245
246const gchar *
247eom_util_dot_dir (void)
248{
249 if (dot_dir == NULL((void*)0)) {
250 gboolean exists;
251
252 dot_dir = g_build_filename(g_get_user_config_dir(), "mate", "eom", NULL((void*)0));
253
254 exists = ensure_dir_exists (dot_dir);
255
256 if (G_UNLIKELY (!exists)(!exists)) {
257 static gboolean printed_warning = FALSE(0);
258
259 if (!printed_warning) {
260 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);
261 printed_warning = TRUE(!(0));
262 }
263 dot_dir = NULL((void*)0);
264 return NULL((void*)0);
265 }
266 }
267
268 return dot_dir;
269}
270
271/* Based on eel_filename_strip_extension() */
272
273/**
274 * eom_util_filename_get_extension:
275 * @filename: a filename
276 *
277 * Returns a reasonably good guess of the file extension of @filename.
278 *
279 * Returns: a newly allocated string with the file extension of @filename.
280 **/
281char *
282eom_util_filename_get_extension (const char * filename)
283{
284 char *begin, *begin2;
285
286 if (filename == NULL((void*)0)) {
1
Assuming 'filename' is not equal to NULL
2
Taking false branch
287 return NULL((void*)0);
288 }
289
290 begin = strrchr (filename, '.');
291
292 if (begin && begin != filename) {
3
Assuming 'begin' is non-null
4
Assuming 'begin' is not equal to 'filename'
293 if (strcmp (begin, ".gz") == 0 ||
294 strcmp (begin, ".bz2") == 0 ||
295 strcmp (begin, ".sit") == 0 ||
296 strcmp (begin, ".Z") == 0) {
297 begin2 = begin - 1;
298 while (begin2 > filename &&
5
Assuming 'begin2' is > 'filename'
299 *begin2 != '.') {
6
Out of bound memory access (access exceeds upper limit of memory block)
300 begin2--;
301 }
302 if (begin2 != filename) {
303 begin = begin2;
304 }
305 }
306 begin ++;
307 } else {
308 return NULL((void*)0);
309 }
310
311 return g_strdup (begin)g_strdup_inline (begin);
312}
313
314/**
315 * eom_util_file_is_persistent:
316 * @file: a #GFile
317 *
318 * Checks whether @file is a non-removable local mount.
319 *
320 * Returns: %TRUE if @file is in a non-removable mount,
321 * %FALSE otherwise or when it is remote.
322 **/
323gboolean
324eom_util_file_is_persistent (GFile *file)
325{
326 GMount *mount;
327
328 if (!g_file_is_native (file))
329 return FALSE(0);
330
331 mount = g_file_find_enclosing_mount (file, NULL((void*)0), NULL((void*)0));
332 if (mount) {
333 if (g_mount_can_unmount (mount)) {
334 return FALSE(0);
335 }
336 }
337
338 return TRUE(!(0));
339}
340
341static void
342_eom_util_show_file_in_filemanager_fallback (GFile *file, GtkWindow *toplevel)
343{
344 gchar *uri = NULL((void*)0);
345 GError *error = NULL((void*)0);
346 guint32 timestamp = gtk_get_current_event_time ();
347
348 if (g_file_query_file_type (file, 0, NULL((void*)0)) == G_FILE_TYPE_DIRECTORY) {
349 uri = g_file_get_uri (file);
350 } else {
351 /* If input file is not a directory we must open it's
352 folder/parent to avoid opening the file itself */
353 GFile *parent_file;
354
355 parent_file = g_file_get_parent (file);
356 if (G_LIKELY (parent_file)(parent_file))
357 uri = g_file_get_uri (parent_file);
358 g_object_unref (parent_file);
359 }
360
361 if (uri && !gtk_show_uri_on_window (toplevel, uri, timestamp, &error)) {
362 g_warning ("Couldn't show containing folder \"%s\": %s", uri,
363 error->message);
364 g_error_free (error);
365 }
366
367 g_free (uri);
368}
369
370void
371eom_util_show_file_in_filemanager (GFile *file, GtkWindow *toplevel)
372{
373 GDBusProxy *proxy;
374 gboolean done = FALSE(0);
375
376 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)
;
377
378 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
379 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
380 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
381 NULL((void*)0), "org.freedesktop.FileManager1",
382 "/org/freedesktop/FileManager1",
383 "org.freedesktop.FileManager1",
384 NULL((void*)0), NULL((void*)0));
385
386 if (proxy) {
387 gchar *uri = g_file_get_uri (file);
388 gchar *startup_id;
389 GVariant *params, *result;
390 GVariantBuilder builder;
391
392 g_variant_builder_init (&builder,
393 G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
394 g_variant_builder_add (&builder, "s", uri);
395
396 /* This seems to be the expected format, as other values
397 cause the filemanager window not to get focus. */
398 startup_id = g_strdup_printf("_TIME%u",
399 gtk_get_current_event_time());
400
401 /* params is floating! */
402 params = g_variant_new ("(ass)", &builder, startup_id);
403
404 g_free (startup_id);
405 g_variant_builder_clear (&builder);
406
407 /* Floating params-GVariant is consumed here */
408 result = g_dbus_proxy_call_sync (proxy, "ShowItems",
409 params, G_DBUS_CALL_FLAGS_NONE,
410 -1, NULL((void*)0), NULL((void*)0));
411
412 /* Receiving a non-NULL result counts as a successful call. */
413 if (G_LIKELY (result != NULL)(result != ((void*)0))) {
414 done = TRUE(!(0));
415 g_variant_unref (result);
416 }
417
418 g_free (uri);
419 g_object_unref (proxy);
420 }
421
422 /* Fallback to gtk_show_uri() if launch over DBus is not possible */
423 if (!done)
424 _eom_util_show_file_in_filemanager_fallback (file, toplevel);
425}
426
427gboolean
428eom_notebook_scroll_event_cb (GtkWidget *widget,
429 GdkEventScroll *event)
430
431{
432 GtkNotebook *notebook = GTK_NOTEBOOK (widget)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_notebook_get_type ()))))))
;
433 GtkWidget *child, *event_widget, *action_widget;
434
435 child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
436 if (child == NULL((void*)0))
437 return FALSE(0);
438
439 event_widget = gtk_get_event_widget ((GdkEvent*) event);
440
441 /* Ignore scroll events from the content of the page */
442 if (event_widget == NULL((void*)0) || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
443 return FALSE(0);
444
445 /* And also from the action widgets */
446 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
447 if (event_widget == action_widget || (action_widget != NULL((void*)0) && gtk_widget_is_ancestor (event_widget, action_widget)))
448 return FALSE(0);
449
450 action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
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 switch (event->direction) {
455 case GDK_SCROLL_RIGHT:
456 case GDK_SCROLL_DOWN:
457 gtk_notebook_next_page (notebook);
458 break;
459 case GDK_SCROLL_LEFT:
460 case GDK_SCROLL_UP:
461 gtk_notebook_prev_page (notebook);
462 break;
463 case GDK_SCROLL_SMOOTH:
464 switch (gtk_notebook_get_tab_pos (notebook)) {
465 case GTK_POS_LEFT:
466 case GTK_POS_RIGHT:
467 if (event->delta_y > 0)
468 gtk_notebook_next_page (notebook);
469 else if (event->delta_y < 0)
470 gtk_notebook_prev_page (notebook);
471 break;
472 case GTK_POS_TOP:
473 case GTK_POS_BOTTOM:
474 if (event->delta_x > 0)
475 gtk_notebook_next_page (notebook);
476 else if (event->delta_x < 0)
477 gtk_notebook_prev_page (notebook);
478 break;
479 }
480 break;
481 }
482
483 return TRUE(!(0));
484}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-b791a9.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-b791a9.html new file mode 100644 index 0000000..d0cc139 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-b791a9.html @@ -0,0 +1,3178 @@ + + + +eom-image.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

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

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-print-preview.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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 gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_print_preview_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_drawing_area_new ())), ((gtk_widget_get_type ())))))
)
;
425
426 gtk_container_add (GTK_CONTAINER (preview)((((GtkContainer*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((eom_print_preview_new ())), ((eom_print_preview_get_type
()))))))
;
484
485 preview->priv->image = g_object_ref (pixbuf)((__typeof__ (pixbuf)) (g_object_ref) (pixbuf));
486
487 update_relative_sizes (preview);
488
489 return GTK_WIDGET (preview)((((GtkWidget*) (void *) 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*) (void *) 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 (area, "draw",g_signal_connect_data ((area), ("draw"), (((GCallback) (draw_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
525 G_CALLBACK (draw_cb),g_signal_connect_data ((area), ("draw"), (((GCallback) (draw_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
526 preview)g_signal_connect_data ((area), ("draw"), (((GCallback) (draw_cb
))), (preview), ((void*)0), (GConnectFlags) 0)
;
527
528 g_signal_connect (area, "motion-notify-event",g_signal_connect_data ((area), ("motion-notify-event"), (((GCallback
) (motion_notify_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
529 G_CALLBACK (motion_notify_event_cb),g_signal_connect_data ((area), ("motion-notify-event"), (((GCallback
) (motion_notify_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
530 preview)g_signal_connect_data ((area), ("motion-notify-event"), (((GCallback
) (motion_notify_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
;
531
532 g_signal_connect (area, "button-press-event",g_signal_connect_data ((area), ("button-press-event"), (((GCallback
) (button_press_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
533 G_CALLBACK (button_press_event_cb),g_signal_connect_data ((area), ("button-press-event"), (((GCallback
) (button_press_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
534 preview)g_signal_connect_data ((area), ("button-press-event"), (((GCallback
) (button_press_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
;
535
536 g_signal_connect (area, "button-release-event",g_signal_connect_data ((area), ("button-release-event"), (((GCallback
) (button_release_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
537 G_CALLBACK (button_release_event_cb),g_signal_connect_data ((area), ("button-release-event"), (((GCallback
) (button_release_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
538 preview)g_signal_connect_data ((area), ("button-release-event"), (((GCallback
) (button_release_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
;
539
540 g_signal_connect (area, "key-press-event",g_signal_connect_data ((area), ("key-press-event"), (((GCallback
) (key_press_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
541 G_CALLBACK (key_press_event_cb),g_signal_connect_data ((area), ("key-press-event"), (((GCallback
) (key_press_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
542 preview)g_signal_connect_data ((area), ("key-press-event"), (((GCallback
) (key_press_event_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
;
543
544 g_signal_connect (area, "size-allocate",g_signal_connect_data ((area), ("size-allocate"), (((GCallback
) (size_allocate_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
545 G_CALLBACK (size_allocate_cb),g_signal_connect_data ((area), ("size-allocate"), (((GCallback
) (size_allocate_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
546 preview)g_signal_connect_data ((area), ("size-allocate"), (((GCallback
) (size_allocate_cb))), (preview), ((void*)0), (GConnectFlags
) 0)
;
547
548 return GTK_WIDGET (preview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_widget_get_type ()))))))
;
549}
550
551static gboolean
552draw_cb (GtkDrawingArea *drawing_area,
553 cairo_t *cr,
554 gpointer user_data)
555{
556 update_relative_sizes (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
);
557
558 eom_print_preview_draw (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
, cr);
559
560 if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
561 fprintf (stderrstderr, "Cairo is unhappy: %s\n",
562 cairo_status_to_string (cairo_status (cr)));
563 }
564
565 return TRUE(!(0));
566}
567
568/**
569 * get_current_image_coordinates:
570 * @preview: an #EomPrintPreview
571 * @x0: A pointer where to store the x coordinate.
572 * @y0: A pointer where to store the y coordinate.
573 *
574 * This function returns the current image coordinates, according
575 * with the properties of the given @preview widget.
576 **/
577static void
578get_current_image_coordinates (EomPrintPreview *preview,
579 gint *x0, gint *y0)
580{
581 EomPrintPreviewPrivate *priv;
582 GtkAllocation allocation;
583
584 priv = preview->priv;
585 gtk_widget_get_allocation (GTK_WIDGET (priv->area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->area)), ((gtk_widget_get_type ()))))))
, &allocation);
586
587 *x0 = (gint)((1 - priv->image_x_align)*priv->l_rmargin + priv->image_x_align*(allocation.width - priv->r_rmargin - priv->r_width));
588 *y0 = (gint)((1 - priv->image_y_align)*priv->t_rmargin + priv->image_y_align*(allocation.height - priv->b_rmargin - priv->r_height));
589}
590
591/**
592 * press_inside_image_area:
593 * @preview: an #EomPrintPreview
594 * @x: the points x coordinate
595 * @y: the points y coordinate
596 *
597 * Returns whether the given point is inside the image area.
598 *
599 * Returns: %TRUE if the given point is inside of the image area,
600 * %FALSE otherwise.
601 **/
602static gboolean
603press_inside_image_area (EomPrintPreview *preview,
604 guint x,
605 guint y)
606{
607 EomPrintPreviewPrivate *priv;
608 gint x0, y0;
609
610 priv = preview->priv;
611 get_current_image_coordinates (preview, &x0, &y0);
612
613 if (x >= x0 && y >= y0 &&
614 x <= x0 + priv->r_width && y <= y0 + priv->r_height)
615 return TRUE(!(0));
616
617 return FALSE(0);
618}
619
620static void
621create_image_scaled (EomPrintPreview *preview)
622{
623 EomPrintPreviewPrivate *priv = preview->priv;
624
625 if (!priv->image_scaled) {
626 gint i_width, i_height;
627 GtkAllocation allocation;
628
629 gtk_widget_get_allocation (priv->area, &allocation);
630 i_width = gdk_pixbuf_get_width (priv->image);
631 i_height = gdk_pixbuf_get_height (priv->image);
632
633 if ((i_width > allocation.width) ||
634 (i_height > allocation.height)) {
635 gdouble scale;
636 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))
637 (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))
;
638 scale *= gtk_widget_get_scale_factor (GTK_WIDGET (priv->area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->area)), ((gtk_widget_get_type ()))))))
);
639 priv->image_scaled = gdk_pixbuf_scale_simple (priv->image,
640 i_width*scale,
641 i_height*scale,
642 GDK_INTERP_TILES);
643 } else {
644 priv->image_scaled = priv->image;
645 g_object_ref (priv->image_scaled)((__typeof__ (priv->image_scaled)) (g_object_ref) (priv->
image_scaled))
;
646 }
647 }
648}
649
650static GdkPixbuf *
651create_preview_buffer (EomPrintPreview *preview)
652{
653 GdkPixbuf *pixbuf;
654 gint width, height, widget_scale;
655 GdkInterpType type = GDK_INTERP_TILES;
656
657 if (preview->priv->image == NULL((void*)0)) {
658 return NULL((void*)0);
659 }
660
661 create_image_scaled (preview);
662
663 width = gdk_pixbuf_get_width (preview->priv->image);
664 height = gdk_pixbuf_get_height (preview->priv->image);
665 widget_scale = gtk_widget_get_scale_factor (GTK_WIDGET (preview->priv->area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview->priv->area)), ((gtk_widget_get_type ())))
)))
);
666
667 width *= preview->priv->i_scale * preview->priv->p_scale
668 * widget_scale;
669 height *= preview->priv->i_scale * preview->priv->p_scale
670 * widget_scale;
671
672 if (width < 1 || height < 1)
673 return NULL((void*)0);
674
675 /* to use GDK_INTERP_TILES for small pixbufs is expensive and unnecessary */
676 if (width < 25 || height < 25)
677 type = GDK_INTERP_NEAREST;
678
679 if (preview->priv->image_scaled) {
680 pixbuf = gdk_pixbuf_scale_simple (preview->priv->image_scaled,
681 width, height, type);
682 } else {
683 pixbuf = gdk_pixbuf_scale_simple (preview->priv->image,
684 width, height, type);
685 }
686
687 return pixbuf;
688}
689
690static void
691create_surface (EomPrintPreview *preview)
692{
693 EomPrintPreviewPrivate *priv = preview->priv;
694 GdkPixbuf *pixbuf;
695
696 if (priv->surface) {
697 cairo_surface_destroy (priv->surface);
698 priv->surface = NULL((void*)0);
699 }
700
701 pixbuf = create_preview_buffer (preview);
702 if (pixbuf) {
703 priv->surface =
704 gdk_cairo_surface_create_from_pixbuf (pixbuf, 0,
705 gtk_widget_get_window (GTK_WIDGET (preview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_widget_get_type ()))))))
));
706 g_object_unref (pixbuf);
707 }
708 priv->flag_create_surface = FALSE(0);
709}
710
711static gboolean
712create_surface_when_idle (EomPrintPreview *preview)
713{
714 create_surface (preview);
715
716 return FALSE(0);
717}
718
719static gboolean
720button_press_event_cb (GtkWidget *widget,
721 GdkEventButton *event,
722 gpointer user_data)
723{
724 EomPrintPreview *preview = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
;
725
726 preview->priv->cursorx = event->x;
727 preview->priv->cursory = event->y;
728
729 switch (event->button) {
730 case 1:
731 preview->priv->grabbed = press_inside_image_area (preview, event->x, event->y);
732 break;
733 }
734
735 if (preview->priv->grabbed) {
736 gtk_widget_queue_draw (GTK_WIDGET (preview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_widget_get_type ()))))))
);
737 }
738
739 gtk_widget_grab_focus (preview->priv->area);
740
741 return FALSE(0);
742}
743
744static gboolean
745button_release_event_cb (GtkWidget *widget,
746 GdkEventButton *event,
747 gpointer user_data)
748{
749 EomPrintPreview *preview = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
;
750
751 switch (event->button) {
752 case 1:
753 preview->priv->grabbed = FALSE(0);
754 preview->priv->r_dx = 0;
755 preview->priv->r_dy = 0;
756 gtk_widget_queue_draw (GTK_WIDGET (preview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_widget_get_type ()))))))
);
757
758 }
759 return FALSE(0);
760}
761
762static gboolean
763key_press_event_cb (GtkWidget *widget,
764 GdkEventKey *event,
765 gpointer user_data)
766{
767 gfloat delta, align;
768 gboolean stop_emission = FALSE(0);
769 const gchar *property;
1
'property' declared without an initial value
770
771 delta = 0;
772
773 switch (event->keyval) {
774 case GDK_KEY_Left0xff51:
775 property = "image-x-align";
776 delta = -0.01;
777 break;
778 case GDK_KEY_Right0xff53:
779 property = "image-x-align";
780 delta = 0.01;
781 break;
782 case GDK_KEY_Up0xff52:
783 property = "image-y-align";
784 delta = -0.01;
785 break;
786 case GDK_KEY_Down0xff54:
787 property = "image-y-align";
788 delta = 0.01;
789 break;
790 }
791
792 if (delta != 0) {
2
'Default' branch taken. Execution continues on line 792
3
Assuming 'delta' is not equal to 0
4
Taking true branch
793 g_object_get (G_OBJECT (user_data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (((GType) ((20) << (2))))))))
,
5
2nd function call argument is an uninitialized value
794 property, &align,
795 NULL((void*)0));
796
797 align += delta;
798 align = CLAMP (align, 0, 1)(((align) > (1)) ? (1) : (((align) < (0)) ? (0) : (align
)))
;
799 g_object_set (G_OBJECT (user_data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (((GType) ((20) << (2))))))))
,
800 property, align,
801 NULL((void*)0));
802
803 stop_emission = TRUE(!(0));
804 g_signal_emit (user_data, preview_signals[SIGNAL_IMAGE_MOVED], 0);
805 }
806
807 return stop_emission;
808}
809
810static gboolean
811motion_notify_event_cb (GtkWidget *widget,
812 GdkEventMotion *event,
813 gpointer user_data)
814{
815 EomPrintPreviewPrivate *priv = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
->priv;
816 gdouble dx, dy;
817 GtkAllocation allocation;
818
819 if (priv->grabbed) {
820 dx = event->x - priv->cursorx;
821 dy = event->y - priv->cursory;
822
823 gtk_widget_get_allocation (widget, &allocation);
824
825 /* Make sure the image stays inside the margins */
826
827 priv->image_x_align += (dx + priv->r_dx)/(allocation.width - priv->r_width - priv->l_rmargin - priv->r_rmargin);
828 if (priv->image_x_align < 0. || priv->image_x_align > 1.) {
829 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)))
;
830 priv->r_dx += dx;
831 }
832 else
833 priv->r_dx = 0;
834
835 priv->image_y_align += (dy + priv->r_dy)/(allocation.height - priv->r_height - priv->t_rmargin - priv->b_rmargin);
836 if (priv->image_y_align < 0. || priv->image_y_align > 1.) {
837 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)))
;
838 priv->r_dy += dy;
839 } else
840 priv->r_dy = 0;
841
842 /* we do this to correctly change the property values */
843 g_object_set (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
,
844 "image-x-align", priv->image_x_align,
845 "image-y-align", priv->image_y_align,
846 NULL((void*)0));
847
848 priv->cursorx = event->x;
849 priv->cursory = event->y;
850
851 g_signal_emit (user_data, preview_signals[SIGNAL_IMAGE_MOVED], 0);
852 } else {
853 if (press_inside_image_area (EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
, event->x, event->y)) {
854 GdkCursor *cursor;
855 cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
856 GDK_FLEUR);
857 gdk_window_set_cursor (gtk_widget_get_window (widget),
858 cursor);
859 g_object_unref (cursor);
860 } else {
861 gdk_window_set_cursor (gtk_widget_get_window (widget),
862 NULL((void*)0));
863 }
864 }
865 return FALSE(0);
866}
867
868static void
869size_allocate_cb (GtkWidget *widget,
870 GtkAllocation *allocation,
871 gpointer user_data)
872{
873 EomPrintPreview *preview;
874
875 preview = EOM_PRINT_PREVIEW (user_data)((((EomPrintPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_print_preview_get_type ()))))))
;
876 update_relative_sizes (preview);
877
878 preview->priv->flag_create_surface = TRUE(!(0));
879
880 if (preview->priv->image_scaled) {
881 g_object_unref (preview->priv->image_scaled);
882 preview->priv->image_scaled = NULL((void*)0);
883 }
884
885 g_idle_add ((GSourceFunc) create_surface_when_idle, preview);
886}
887
888static void
889eom_print_preview_draw (EomPrintPreview *preview, cairo_t *cr)
890{
891 EomPrintPreviewPrivate *priv;
892 GtkWidget *area;
893 GtkAllocation allocation;
894 gint x0, y0;
895 gboolean has_focus;
896
897 priv = preview->priv;
898 area = priv->area;
899
900 has_focus = gtk_widget_has_focus (area);
901
902 gtk_widget_get_allocation (area, &allocation);
903
904 /* draw the page */
905 cairo_set_source_rgb (cr, 1., 1., 1.);
906 cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
907 cairo_fill (cr);
908
909 /* draw the page margins */
910 cairo_set_source_rgb (cr, 0., 0., 0.);
911 cairo_set_line_width (cr, 0.1);
912 cairo_rectangle (cr,
913 priv->l_rmargin, priv->t_rmargin,
914 allocation.width - priv->l_rmargin - priv->r_rmargin,
915 allocation.height - priv->t_rmargin - priv->b_rmargin);
916 cairo_stroke (cr);
917
918 get_current_image_coordinates (preview, &x0, &y0);
919
920 if (priv->flag_create_surface) {
921 create_surface (preview);
922 }
923
924 if (priv->surface) {
925 cairo_set_source_surface (cr, priv->surface, x0, y0);
926 cairo_paint (cr);
927 } else if (priv->image_scaled) {
928 /* just in the remote case we don't have the surface */
929
930 /* adjust (x0, y0) to the new scale */
931 gdouble scale = priv->i_scale * priv->p_scale *
932 gdk_pixbuf_get_width (priv->image) / gdk_pixbuf_get_width (priv->image_scaled);
933 x0 /= scale;
934 y0 /= scale;
935
936 cairo_scale (cr, scale, scale);
937 gdk_cairo_set_source_pixbuf (cr, priv->image_scaled, x0, y0);
938 cairo_paint (cr);
939 } else if (priv->image) {
940 /* just in the remote case we don't have the surface */
941
942 /* adjust (x0, y0) to the new scale */
943 x0 /= priv->i_scale * priv->p_scale;
944 y0 /= priv->i_scale * priv->p_scale;
945
946 cairo_scale (cr, priv->i_scale*priv->p_scale, priv->i_scale*priv->p_scale);
947 gdk_cairo_set_source_pixbuf (cr, priv->image, x0, y0);
948 cairo_paint (cr);
949 }
950
951 if (has_focus) {
952 GtkStyleContext *ctx;
953
954 ctx = gtk_widget_get_style_context (area);
955 gtk_render_focus (ctx, cr, 0, 0,
956 allocation.width, allocation.height);
957 }
958}
959
960static void
961update_relative_sizes (EomPrintPreview *preview)
962{
963 EomPrintPreviewPrivate *priv;
964 GtkAllocation allocation;
965 gint i_width, i_height;
966
967 priv = preview->priv;
968
969 if (priv->image != NULL((void*)0)) {
970 i_width = gdk_pixbuf_get_width (priv->image);
971 i_height = gdk_pixbuf_get_height (priv->image);
972 } else {
973 i_width = i_height = 0;
974 }
975
976 gtk_widget_get_allocation (priv->area, &allocation);
977
978 priv->p_scale = (gfloat) allocation.width / (priv->p_width * 72.0);
979
980 priv->r_width = (gint) i_width * priv->i_scale * priv->p_scale;
981 priv->r_height = (gint) i_height * priv->i_scale * priv->p_scale;
982
983 priv->l_rmargin = (gint) (72. * priv->l_margin * priv->p_scale);
984 priv->r_rmargin = (gint) (72. * priv->r_margin * priv->p_scale);
985 priv->t_rmargin = (gint) (72. * priv->t_margin * priv->p_scale);
986 priv->b_rmargin = (gint) (72. * priv->b_margin * priv->p_scale);
987}
988
989/**
990 * eom_print_preview_set_page_margins:
991 * @preview: a #EomPrintPreview
992 * @l_margin: Left margin.
993 * @r_margin: Right margin.
994 * @t_margin: Top margin.
995 * @b_margin: Bottom margin.
996 *
997 * Manually set the margins, in inches.
998 **/
999void
1000eom_print_preview_set_page_margins (EomPrintPreview *preview,
1001 gfloat l_margin,
1002 gfloat r_margin,
1003 gfloat t_margin,
1004 gfloat b_margin)
1005{
1006 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)
;
1007
1008 g_object_set (G_OBJECT(preview)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), (((GType) ((20) << (2))))))))
,
1009 "page-left-margin", l_margin,
1010 "page-right-margin", r_margin,
1011 "page-top-margin", t_margin,
1012 "page-bottom-margin", r_margin,
1013 NULL((void*)0));
1014}
1015
1016/**
1017 * eom_print_preview_set_from_page_setup:
1018 * @preview: a #EomPrintPreview
1019 * @setup: a #GtkPageSetup to set the properties from
1020 *
1021 * Sets up the page properties from a #GtkPageSetup. Useful when using the
1022 * widget with the GtkPrint API.
1023 **/
1024void
1025eom_print_preview_set_from_page_setup (EomPrintPreview *preview,
1026 GtkPageSetup *setup)
1027{
1028 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)
;
1029 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)
;
1030
1031 g_object_set (G_OBJECT (preview)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), (((GType) ((20) << (2))))))))
,
1032 "page-left-margin", gtk_page_setup_get_left_margin (setup, GTK_UNIT_INCH),
1033 "page-right-margin", gtk_page_setup_get_right_margin (setup, GTK_UNIT_INCH),
1034 "page-top-margin", gtk_page_setup_get_top_margin (setup, GTK_UNIT_INCH),
1035 "page-bottom-margin", gtk_page_setup_get_bottom_margin (setup, GTK_UNIT_INCH),
1036 "paper-width", gtk_page_setup_get_paper_width (setup, GTK_UNIT_INCH),
1037 "paper-height", gtk_page_setup_get_paper_height (setup, GTK_UNIT_INCH),
1038 NULL((void*)0));
1039
1040}
1041
1042/**
1043 * eom_print_preview_get_image_position:
1044 * @preview: a #EomPrintPreview
1045 * @x: a pointer to a #gdouble, or %NULL to ignore it
1046 * @y: a pointer to a #gdouble, or %NULL to ignore it
1047 *
1048 * Gets current image position in inches, relative to the margins. A
1049 * (0, 0) position is the intersection between the left and top margins.
1050 **/
1051void
1052eom_print_preview_get_image_position (EomPrintPreview *preview,
1053 gdouble *x,
1054 gdouble *y)
1055{
1056 EomPrintPreviewPrivate *priv;
1057 gdouble width, height;
1058
1059 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)
;
1060
1061 priv = preview->priv;
1062
1063 if (x != NULL((void*)0)) {
1064 width = gdk_pixbuf_get_width (priv->image) * priv->i_scale / 72.;
1065 *x = priv->image_x_align * (priv->p_width - priv->l_margin - priv->r_margin - width);
1066 }
1067 if (y != NULL((void*)0)) {
1068 height = gdk_pixbuf_get_height (priv->image) * priv->i_scale / 72.;
1069 *y = priv->image_y_align * (priv->p_height - priv->t_margin - priv->b_margin - height);
1070 }
1071}
1072
1073/**
1074 * eom_print_preview_set_image_position:
1075 * @preview: a #EomPrintPreview
1076 * @x: The X coordinate, in inches, or -1 to ignore it.
1077 * @y: The Y coordinate, in inches, or -1 to ignore it.
1078 *
1079 * Sets the image position. You can pass -1 to one of the coordinates if you
1080 * only want to set the other.
1081 **/
1082void
1083eom_print_preview_set_image_position (EomPrintPreview *preview,
1084 gdouble x,
1085 gdouble y)
1086{
1087 EomPrintPreviewPrivate *priv;
1088 gfloat x_align, y_align;
1089 gdouble width, height;
1090
1091 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)
;
1092
1093 priv = preview->priv;
1094
1095 if (x != -1) {
1096 width = gdk_pixbuf_get_width (priv->image) * priv->i_scale / 72.;
1097 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
))))
;
1098 g_object_set (preview, "image-x-align", x_align, NULL((void*)0));
1099 }
1100
1101 if (y != -1) {
1102 height = gdk_pixbuf_get_height (priv->image) * priv->i_scale / 72.;
1103 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
))))
;
1104 g_object_set (preview, "image-y-align", y_align, NULL((void*)0));
1105 }
1106}
1107
1108/**
1109 * eom_print_preview_set_scale:
1110 * @preview: a #EomPrintPreview
1111 * @scale: a scale value, between 0 and 1.
1112 *
1113 * Sets the scale for the image.
1114 **/
1115void
1116eom_print_preview_set_scale (EomPrintPreview *preview,
1117 gfloat scale)
1118{
1119 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)
;
1120
1121 g_object_set (preview,
1122 "image-scale", scale,
1123 NULL((void*)0));
1124}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-d71e34.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-d71e34.html new file mode 100644 index 0000000..c7a23a5 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-d71e34.html @@ -0,0 +1,3069 @@ + + + +eom-scroll-view.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Bug Summary

+ + + + +
File:src/eom-preferences-dialog.c
Warning:line 99, 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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-preferences-dialog.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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_VALUE"GSETTINGS_VALUE" "GSETTINGS_VALUE"
42
43struct _EomPreferencesDialogPrivate {
44 GSettings *view_settings;
45 GSettings *ui_settings;
46 GSettings *fullscreen_settings;
47
48 GtkWidget *notebook;
49 GtkWidget *interpolate_check;
50 GtkWidget *extrapolate_check;
51 GtkWidget *autorotate_check;
52 GtkWidget *bg_color_check;
53 GtkWidget *bg_color_button;
54 GtkWidget *color_radio;
55 GtkWidget *checkpattern_radio;
56 GtkWidget *background_radio;
57 GtkWidget *transp_color_button;
58
59 GtkWidget *upscale_check;
60 GtkWidget *random_check;
61 GtkWidget *loop_check;
62 GtkWidget *seconds_spin;
63
64 GtkWidget *plugin_manager;
65};
66
67static GObject *instance = NULL((void*)0);
68
69G_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 gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_preferences_dialog_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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; }
;
70
71static gboolean
72pd_string_to_rgba_mapping (GValue *value,
73 GVariant *variant,
74 gpointer user_data)
75{
76 GdkRGBA color;
77
78 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)
;
79
80 if (gdk_rgba_parse (&color, g_variant_get_string (variant, NULL((void*)0)))) {
81 g_value_set_boxed (value, &color);
82 return TRUE(!(0));
83 }
84
85 return FALSE(0);
86}
87
88static GVariant*
89pd_rgba_to_string_mapping (const GValue *value,
90 const GVariantType *expected_type,
91 gpointer user_data)
92{
93
94 GVariant *variant = NULL((void*)0);
95 GdkRGBA *color;
96 gchar *hex_val;
97
98 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)
;
99 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
100
101 color = g_value_get_boxed (value);
102 hex_val = gdk_rgba_to_string(color);
103
104 variant = g_variant_new_string (hex_val);
105 g_free (hex_val);
106
107 return variant;
108}
109
110static void
111pd_transp_radio_toggle_cb (GtkWidget *widget, gpointer data)
112{
113 gpointer value = NULL((void*)0);
114
115 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_toggle_button_get_type ()))))))
))
116 return;
117
118 value = g_object_get_data (G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE");
119
120 g_settings_set_enum (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, EOM_CONF_VIEW_TRANSPARENCY"transparency",
121 GPOINTER_TO_INT (value)((gint) (glong) (value)));
122}
123
124static void
125random_change_cb (GSettings *settings, gchar *key, GtkWidget *widget)
126{
127 gtk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key));
128}
129
130static void
131eom_preferences_response_cb (GtkDialog *dlg, gint res_id, gpointer data)
132{
133 switch (res_id) {
134 case GTK_RESPONSE_HELP:
135 eom_util_show_help ("eom-prefs", NULL((void*)0));
136 break;
137 default:
138 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_widget_get_type ()))))))
);
139 instance = NULL((void*)0);
140 }
141}
142
143static void
144eom_preferences_dialog_class_init (EomPreferencesDialogClass *klass)
145{
146 GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
147
148 /* This should make sure the libpeas-gtk dependency isn't
149 * dropped by aggressive linkers (#739618) */
150 g_type_ensure (PEAS_GTK_TYPE_PLUGIN_MANAGER(peas_gtk_plugin_manager_get_type()));
151
152 gtk_widget_class_set_template_from_resource (widget_class,
153 "/org/mate/eom/ui/eom-preferences-dialog.ui");
154 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)))))
155 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
156 notebook)gtk_widget_class_bind_template_child_full (widget_class, "notebook"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, notebook)))))
;
157 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)))))
158 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
159 interpolate_check)gtk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, interpolate_check)))))
;
160 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)))))
161 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
162 extrapolate_check)gtk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, extrapolate_check)))))
;
163 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)))))
164 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
165 autorotate_check)gtk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, autorotate_check)))))
;
166 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)))))
167 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_check)))))
168 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)))))
;
169 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)))))
170 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, bg_color_button)))))
171 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)))))
;
172 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)))))
173 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
174 color_radio)gtk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, color_radio)))))
;
175 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)))))
176 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
177 checkpattern_radio)gtk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, checkpattern_radio)))))
;
178 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)))))
179 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
180 background_radio)gtk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, background_radio)))))
;
181 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)))))
182 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, transp_color_button)))))
183 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)))))
;
184
185 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)))))
186 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
187 upscale_check)gtk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, upscale_check)))))
;
188 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)))))
189 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
190 random_check)gtk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, random_check)))))
;
191 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)))))
192 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
193 loop_check)gtk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, loop_check)))))
;
194 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)))))
195 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
196 seconds_spin)gtk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, seconds_spin)))))
;
197
198 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)))))
199 EomPreferencesDialog,gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
200 plugin_manager)gtk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EomPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EomPreferencesDialogPrivate, plugin_manager)))))
;
201}
202
203static void
204eom_preferences_dialog_init (EomPreferencesDialog *pref_dlg)
205{
206 EomPreferencesDialogPrivate *priv;
207
208 pref_dlg->priv = eom_preferences_dialog_get_instance_private (pref_dlg);
209 priv = pref_dlg->priv;
210
211 gtk_widget_init_template (GTK_WIDGET (pref_dlg)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_dlg)), ((gtk_widget_get_type ()))))))
);
212
213 priv->view_settings = g_settings_new (EOM_CONF_VIEW"org.mate.eom"".view");
214 priv->fullscreen_settings = g_settings_new (EOM_CONF_FULLSCREEN"org.mate.eom"".full-screen");
215
216 g_signal_connect (pref_dlg, "response",g_signal_connect_data ((pref_dlg), ("response"), (((GCallback
) (eom_preferences_response_cb))), (pref_dlg), ((void*)0), (GConnectFlags
) 0)
217 G_CALLBACK (eom_preferences_response_cb),g_signal_connect_data ((pref_dlg), ("response"), (((GCallback
) (eom_preferences_response_cb))), (pref_dlg), ((void*)0), (GConnectFlags
) 0)
218 pref_dlg)g_signal_connect_data ((pref_dlg), ("response"), (((GCallback
) (eom_preferences_response_cb))), (pref_dlg), ((void*)0), (GConnectFlags
) 0)
;
219
220 g_settings_bind (priv->view_settings,
221 EOM_CONF_VIEW_INTERPOLATE"interpolate",
222 priv->interpolate_check, "active",
223 G_SETTINGS_BIND_DEFAULT);
224 g_settings_bind (priv->view_settings,
225 EOM_CONF_VIEW_EXTRAPOLATE"extrapolate",
226 priv->extrapolate_check, "active",
227 G_SETTINGS_BIND_DEFAULT);
228 g_settings_bind (priv->view_settings,
229 EOM_CONF_VIEW_AUTOROTATE"autorotate",
230 priv->autorotate_check, "active",
231 G_SETTINGS_BIND_DEFAULT);
232 g_settings_bind (priv->view_settings,
233 EOM_CONF_VIEW_USE_BG_COLOR"use-background-color",
234 priv->bg_color_check, "active",
235 G_SETTINGS_BIND_DEFAULT);
236
237 g_settings_bind_with_mapping (priv->view_settings,
238 EOM_CONF_VIEW_BACKGROUND_COLOR"background-color",
239 priv->bg_color_button, "rgba",
240 G_SETTINGS_BIND_DEFAULT,
241 pd_string_to_rgba_mapping,
242 pd_rgba_to_string_mapping,
243 NULL((void*)0), NULL((void*)0));
244 g_object_set_data (G_OBJECT (priv->color_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), (((GType) ((20) << (2)))))
)))
,
245 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
246 GINT_TO_POINTER (EOM_TRANSP_COLOR)((gpointer) (glong) (EOM_TRANSP_COLOR)));
247
248 g_signal_connect (priv->color_radio, "toggled",g_signal_connect_data ((priv->color_radio), ("toggled"), (
((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
249 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((priv->color_radio), ("toggled"), (
((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
250 priv->view_settings)g_signal_connect_data ((priv->color_radio), ("toggled"), (
((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
;
251
252 g_object_set_data (G_OBJECT (priv->checkpattern_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), (((GType) ((20) << (
2))))))))
,
253 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
254 GINT_TO_POINTER (EOM_TRANSP_CHECKED)((gpointer) (glong) (EOM_TRANSP_CHECKED)));
255
256 g_signal_connect (priv->checkpattern_radio, "toggled",g_signal_connect_data ((priv->checkpattern_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
257 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((priv->checkpattern_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
258 priv->view_settings)g_signal_connect_data ((priv->checkpattern_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
;
259
260 g_object_set_data (G_OBJECT (priv->background_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), (((GType) ((20) << (2
))))))))
,
261 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
262 GINT_TO_POINTER (EOM_TRANSP_BACKGROUND)((gpointer) (glong) (EOM_TRANSP_BACKGROUND)));
263
264 g_signal_connect (priv->background_radio, "toggled",g_signal_connect_data ((priv->background_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
265 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((priv->background_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
266 priv->view_settings)g_signal_connect_data ((priv->background_radio), ("toggled"
), (((GCallback) (pd_transp_radio_toggle_cb))), (priv->view_settings
), ((void*)0), (GConnectFlags) 0)
;
267
268 switch (g_settings_get_enum (priv->view_settings,
269 EOM_CONF_VIEW_TRANSPARENCY"transparency"))
270 {
271 case EOM_TRANSP_COLOR:
272 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->color_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), ((gtk_toggle_button_get_type ())
)))))
, TRUE(!(0)));
273 break;
274 case EOM_TRANSP_CHECKED:
275 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkpattern_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
276 break;
277 default:
278 // Log a warning and use EOM_TRANSP_BACKGROUND as fallback
279 g_warn_if_reached ()do { g_warn_message ("EOM", "eom-preferences-dialog.c", 279, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
280 case EOM_TRANSP_BACKGROUND:
281 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->background_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
282 break;
283 }
284
285 g_settings_bind_with_mapping (priv->view_settings,
286 EOM_CONF_VIEW_TRANS_COLOR"trans-color",
287 priv->transp_color_button, "rgba",
288 G_SETTINGS_BIND_DEFAULT,
289 pd_string_to_rgba_mapping,
290 pd_rgba_to_string_mapping,
291 NULL((void*)0), NULL((void*)0));
292
293 g_settings_bind (priv->fullscreen_settings, EOM_CONF_FULLSCREEN_UPSCALE"upscale",
294 priv->upscale_check, "active",
295 G_SETTINGS_BIND_DEFAULT);
296
297 g_settings_bind (priv->fullscreen_settings,
298 EOM_CONF_FULLSCREEN_LOOP"loop",
299 priv->loop_check, "active",
300 G_SETTINGS_BIND_DEFAULT);
301
302 g_settings_bind (priv->fullscreen_settings,
303 EOM_CONF_FULLSCREEN_RANDOM"random",
304 priv->random_check, "active",
305 G_SETTINGS_BIND_DEFAULT);
306 g_signal_connect (priv->fullscreen_settings, "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)
307 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)
308 priv->loop_check)g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
;
309 random_change_cb (priv->fullscreen_settings,
310 EOM_CONF_FULLSCREEN_RANDOM"random",
311 priv->loop_check);
312
313 g_settings_bind (priv->fullscreen_settings,
314 EOM_CONF_FULLSCREEN_SECONDS"seconds",
315 priv->seconds_spin, "value",
316 G_SETTINGS_BIND_DEFAULT);
317
318 gtk_widget_show_all (priv->plugin_manager);
319
320 /* Add tab scrolling support for GTK3 */
321 gtk_widget_add_events (priv->notebook, GDK_SCROLL_MASK);
322 g_signal_connect (priv->notebook, "scroll-event",g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
323 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)
324 NULL)g_signal_connect_data ((priv->notebook), ("scroll-event"),
(((GCallback) (eom_notebook_scroll_event_cb))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
325}
326
327GtkWidget *eom_preferences_dialog_get_instance (GtkWindow *parent)
328{
329 if (instance == NULL((void*)0)) {
330 instance = g_object_new (EOM_TYPE_PREFERENCES_DIALOG(eom_preferences_dialog_get_type ()),
331 NULL((void*)0));
332 }
333
334 if (parent)
335 gtk_window_set_transient_for (GTK_WINDOW (instance)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((gtk_window_get_type ()))))))
, parent);
336
337 return GTK_WIDGET(instance)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((gtk_widget_get_type ()))))))
;
338}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-e1a871.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-e1a871.html new file mode 100644 index 0000000..bd0f9ca --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-e1a871.html @@ -0,0 +1,6522 @@ + + + +eom-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-window.c
Warning:line 2517, 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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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 gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_window_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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)((__typeof__ (hpaned)) (g_object_ref) (hpaned));
263 g_object_ref (priv->nav)((__typeof__ (priv->nav)) (g_object_ref) (priv->nav));
264
265 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_container_get_type ()))))))
, hpaned);
266 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
353 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) 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")g_strdup_inline ("_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*) (void *) 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*) (void *) 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*) (void *) 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 {
501 if ( eom_image_has_data (priv->image, EOM_IMAGE_DATA_DIMENSION))
502 {
503 int zoom, width, height;
504 goffset bytes = 0;
505
506 zoom = floor (100 * eom_scroll_view_get_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
) + 0.5);
507
508 eom_image_get_size (priv->image, &width, &height);
509
510 bytes = eom_image_get_bytes (priv->image);
511
512 if ((width > 0) && (height > 0)) {
513 char *size_string;
514
515 size_string = g_format_size (bytes);
516
517 /* Translators: This is the string displayed in the statusbar
518 * The tokens are from left to right:
519 * - image width
520 * - image height
521 * - image size in bytes
522 * - zoom in percent */
523 str = g_strdup_printf (ngettext("%i × %i pixel %s %i%%",
524 "%i × %i pixels %s %i%%", height),
525 width,
526 height,
527 size_string,
528 zoom);
529
530 g_free (size_string);
531 }
532 }
533 update_image_pos (window);
534 }
535
536 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
537 priv->image_info_message_cid);
538
539 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
540 priv->image_info_message_cid, str ? str : "");
541
542 g_free (str);
543}
544
545static void
546eom_window_set_message_area (EomWindow *window,
547 GtkWidget *message_area)
548{
549 if (window->priv->message_area == message_area)
550 return;
551
552 if (window->priv->message_area != NULL((void*)0))
553 gtk_widget_destroy (window->priv->message_area);
554
555 window->priv->message_area = message_area;
556
557 if (message_area == NULL((void*)0)) return;
558
559 gtk_box_pack_start (GTK_BOX (window->priv->cbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->cbox)), ((gtk_box_get_type ()))))))
,
560 window->priv->message_area,
561 FALSE(0),
562 FALSE(0),
563 0);
564
565 g_object_add_weak_pointer (G_OBJECT (window->priv->message_area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->message_area)), (((GType) ((20) <<
(2))))))))
,
566 (void *) &window->priv->message_area);
567}
568
569static void
570update_action_groups_state (EomWindow *window)
571{
572 EomWindowPrivate *priv;
573 GtkAction *action_collection;
574 GtkAction *action_sidebar;
575 GtkAction *action_fscreen;
576 GtkAction *action_sshow;
577 GtkAction *action_print;
578 gboolean print_disabled = FALSE(0);
579 gint n_images = 0;
580
581 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)
;
582
583 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 583, ((const char*) (__func__
))
);
584
585 priv = window->priv;
586
587 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
588 action_collection =
589 gtk_action_group_get_action (priv->actions_window,
590 "ViewImageCollection");
591
592 action_sidebar =
593 gtk_action_group_get_action (priv->actions_window,
594 "ViewSidebar");
595
596 action_fscreen =
597 gtk_action_group_get_action (priv->actions_image,
598 "ViewFullscreen");
599
600 action_sshow =
601 gtk_action_group_get_action (priv->actions_collection,
602 "ViewSlideshow");
603
604 action_print =
605 gtk_action_group_get_action (priv->actions_image,
606 "ImagePrint");
607 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
608
609 g_assert (action_collection != NULL)do { if (action_collection != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 609, ((const char*) (__func__)), "action_collection != NULL"
); } while (0)
;
610 g_assert (action_sidebar != NULL)do { if (action_sidebar != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 610, ((const char*) (__func__)), "action_sidebar != NULL"
); } while (0)
;
611 g_assert (action_fscreen != NULL)do { if (action_fscreen != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 611, ((const char*) (__func__)), "action_fscreen != NULL"
); } while (0)
;
612 g_assert (action_sshow != NULL)do { if (action_sshow != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 612, ((const char*) (__func__)), "action_sshow != NULL"
); } while (0)
;
613 g_assert (action_print != NULL)do { if (action_print != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 613, ((const char*) (__func__)), "action_print != NULL"
); } while (0)
;
614
615 if (priv->store != NULL((void*)0)) {
616 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
617 }
618
619 if (n_images == 0) {
620 gtk_widget_hide (priv->layout);
621
622 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
623 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
624 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
625 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
626
627 gtk_action_set_sensitive (action_fscreen, FALSE(0));
628 gtk_action_set_sensitive (action_sshow, FALSE(0));
629 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
630
631 /* If there are no images on model, initialization
632 stops here. */
633 if (priv->status == EOM_WINDOW_STATUS_INIT) {
634 priv->status = EOM_WINDOW_STATUS_NORMAL;
635 }
636 } else {
637 gboolean show_image_collection;
638
639 if (priv->flags & EOM_STARTUP_DISABLE_COLLECTION) {
640 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", FALSE(0));
641
642 show_image_collection = FALSE(0);
643 } else {
644 show_image_collection =
645 g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection");
646 }
647
648 show_image_collection = show_image_collection &&
649 n_images > 1 &&
650 priv->mode != EOM_WINDOW_MODE_SLIDESHOW;
651
652 gtk_widget_show (priv->layout);
653
654 if (show_image_collection)
655 gtk_widget_show (priv->nav);
656
657 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
658 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_collection)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action_collection)), ((gtk_toggle_action_get_type ()))))
))
,
659 show_image_collection);
660
661 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
662 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
663
664 gtk_action_set_sensitive (action_fscreen, TRUE(!(0)));
665
666 if (n_images == 1) {
667 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
668 gtk_action_set_sensitive (action_collection, FALSE(0));
669 gtk_action_set_sensitive (action_sshow, FALSE(0));
670 } else {
671 gtk_action_group_set_sensitive (priv->actions_collection, TRUE(!(0)));
672 gtk_action_set_sensitive (action_sshow, TRUE(!(0)));
673 }
674 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
675
676 if (show_image_collection)
677 gtk_widget_grab_focus (priv->thumbview);
678 else
679 gtk_widget_grab_focus (priv->view);
680 }
681
682 print_disabled = g_settings_get_boolean (priv->lockdown_settings,
683 EOM_CONF_LOCKDOWN_CAN_PRINT"disable-printing");
684
685 if (print_disabled) {
686 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
687 gtk_action_set_sensitive (action_print, FALSE(0));
688 }
689
690 if (eom_sidebar_is_empty (EOM_SIDEBAR (priv->sidebar)((((EomSidebar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->sidebar)), ((eom_sidebar_get_type()))))))
)) {
691 gtk_action_set_sensitive (action_sidebar, FALSE(0));
692 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
693 gtk_widget_hide (priv->sidebar);
694 }
695}
696
697static void
698update_selection_ui_visibility (EomWindow *window)
699{
700 EomWindowPrivate *priv;
701 GtkAction *wallpaper_action;
702 gint n_selected;
703
704 priv = window->priv;
705
706 n_selected = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
707
708 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
709 wallpaper_action =
710 gtk_action_group_get_action (priv->actions_image,
711 "ImageSetAsWallpaper");
712
713 if (n_selected == 1) {
714 gtk_action_set_sensitive (wallpaper_action, TRUE(!(0)));
715 } else {
716 gtk_action_set_sensitive (wallpaper_action, FALSE(0));
717 }
718 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
719}
720
721static gboolean
722add_file_to_recent_files (GFile *file)
723{
724 gchar *text_uri;
725 GFileInfo *file_info;
726 GtkRecentData *recent_data;
727 static gchar *groups[2] = { EOM_RECENT_FILES_GROUP"Graphics" , NULL((void*)0) };
728
729 if (file == NULL((void*)0)) return FALSE(0);
730
731 /* The password gets stripped here because ~/.recently-used.xbel is
732 * readable by everyone (chmod 644). It also makes the workaround
733 * for the bug with gtk_recent_info_get_uri_display() easier
734 * (see the comment in eom_window_update_recent_files_menu()). */
735 text_uri = g_file_get_uri (file);
736
737 if (text_uri == NULL((void*)0))
738 return FALSE(0);
739
740 file_info = g_file_query_info (file,
741 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
742 0, NULL((void*)0), NULL((void*)0));
743 if (file_info == NULL((void*)0))
744 return FALSE(0);
745
746 recent_data = g_slice_new (GtkRecentData)((GtkRecentData*) g_slice_alloc (sizeof (GtkRecentData)));
747 recent_data->display_name = NULL((void*)0);
748 recent_data->description = NULL((void*)0);
749 recent_data->mime_type = (gchar *) g_file_info_get_content_type (file_info);
750 recent_data->app_name = EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer";
751 recent_data->app_exec = g_strjoin(" ", g_get_prgname (), "%u", NULL((void*)0));
752 recent_data->groups = groups;
753 recent_data->is_private = FALSE(0);
754
755 gtk_recent_manager_add_full (gtk_recent_manager_get_default (),
756 text_uri,
757 recent_data);
758
759 g_free (recent_data->app_exec);
760 g_free (text_uri);
761 g_object_unref (file_info);
762
763 g_slice_free (GtkRecentData, recent_data)do { if (1) g_slice_free1 (sizeof (GtkRecentData), (recent_data
)); else (void) ((GtkRecentData*) 0 == (recent_data)); } while
(0)
;
764
765 return FALSE(0);
766}
767
768static void
769image_thumb_changed_cb (EomImage *image, gpointer data)
770{
771 EomWindow *window;
772 EomWindowPrivate *priv;
773 GdkPixbuf *thumb;
774
775 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)
;
776
777 window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
778 priv = window->priv;
779
780 thumb = eom_image_get_thumbnail (image);
781
782 if (thumb != NULL((void*)0)) {
783 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, thumb);
784
785 if (window->priv->properties_dlg != NULL((void*)0)) {
786 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
787 image);
788 }
789
790 g_object_unref (thumb);
791 } else if (!gtk_widget_get_visible (window->priv->nav)) {
792 gint img_pos = eom_list_store_get_pos_by_image (window->priv->store, image);
793 GtkTreePath *path = gtk_tree_path_new_from_indices (img_pos,-1);
794 GtkTreeIter iter;
795
796 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), ((gtk_tree_model_get_type (
)))))))
, &iter, path);
797 eom_list_store_thumbnail_set (window->priv->store, &iter);
798 gtk_tree_path_free (path);
799 }
800}
801
802static void
803file_changed_info_bar_response (GtkInfoBar *info_bar,
804 gint response,
805 EomWindow *window)
806{
807 if (response == GTK_RESPONSE_YES) {
808 eom_window_reload_image (window);
809 }
810
811 window->priv->needs_reload_confirmation = TRUE(!(0));
812
813 eom_window_set_message_area (window, NULL((void*)0));
814}
815static void
816image_file_changed_cb (EomImage *img, EomWindow *window)
817{
818 GtkWidget *info_bar;
819 gchar *text, *markup;
820 GtkWidget *image;
821 GtkWidget *label;
822 GtkWidget *hbox;
823
824 if (window->priv->needs_reload_confirmation == FALSE(0))
825 return;
826
827 if (!eom_image_is_modified (img)) {
828 /* Auto-reload when image is unmodified */
829 eom_window_reload_image (window);
830 return;
831 }
832
833 window->priv->needs_reload_confirmation = FALSE(0);
834
835 info_bar = gtk_info_bar_new_with_buttons (_("_Reload")gettext ("_Reload"),
836 GTK_RESPONSE_YES,
837 C_("MessageArea", "Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
838 GTK_RESPONSE_NO, NULL((void*)0));
839 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))
,
840 GTK_MESSAGE_QUESTION);
841 image = gtk_image_new_from_icon_name ("dialog-question",
842 GTK_ICON_SIZE_DIALOG);
843 label = gtk_label_new (NULL((void*)0));
844
845 /* The newline character is currently necessary due to a problem
846 * with the automatic line break. */
847 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?")
848 "\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));
849 markup = g_markup_printf_escaped ("<b>%s</b>", text);
850 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, markup);
851 g_free (text);
852 g_free (markup);
853
854 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
855 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
856 gtk_widget_set_halign (image, GTK_ALIGN_START);
857 gtk_widget_set_valign (image, GTK_ALIGN_END);
858 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
859 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
860 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_info_bar_get_content_area (((((GtkInfoBar*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((info_bar)), (
(gtk_info_bar_get_type()))))))))), ((gtk_box_get_type ())))))
)
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
861 gtk_widget_show_all (hbox);
862 gtk_widget_show (info_bar);
863
864 eom_window_set_message_area (window, info_bar);
865 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
866 G_CALLBACK (file_changed_info_bar_response),g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
867 window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
;
868}
869
870static void
871eom_window_display_image (EomWindow *window, EomImage *image)
872{
873 EomWindowPrivate *priv;
874 GFile *file;
875
876 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)
;
877 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)
;
878
879 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 879, ((const char*) (__func__
))
);
880
881 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", 881, ((const
char*) (__func__)), "eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)"
); } while (0)
;
882
883 priv = window->priv;
884
885 if (image != NULL((void*)0)) {
886 g_signal_connect (image, "thumbnail_changed",g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
887 G_CALLBACK (image_thumb_changed_cb),g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
888 window)g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
889 g_signal_connect (image, "file-changed",g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
890 G_CALLBACK (image_file_changed_cb),g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
891 window)g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
892
893 image_thumb_changed_cb (image, window);
894 }
895
896 priv->needs_reload_confirmation = TRUE(!(0));
897
898 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, image);
899
900 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, eom_image_get_caption (image));
901
902 update_status_bar (window);
903
904 file = eom_image_get_file (image);
905 g_idle_add_full (G_PRIORITY_LOW300,
906 (GSourceFunc) add_file_to_recent_files,
907 file,
908 (GDestroyNotify) g_object_unref);
909
910 eom_window_update_openwith_menu (window, image);
911}
912
913static void
914open_with_launch_application_cb (GtkAction *action, gpointer data) {
915 EomImage *image;
916 GAppInfo *app;
917 GFile *file;
918 GList *files = NULL((void*)0);
919
920 image = EOM_IMAGE (data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_image_get_type ()))))))
;
921 file = eom_image_get_file (image);
922
923 app = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "app");
924 files = g_list_append (files, file);
925 g_app_info_launch (app,
926 files,
927 NULL((void*)0), NULL((void*)0));
928
929 g_object_unref (file);
930 g_list_free (files);
931}
932
933static void
934eom_window_update_openwith_menu (EomWindow *window, EomImage *image)
935{
936 gboolean edit_button_active;
937 GAppInfo *editor_app;
938 GFile *file;
939 GFileInfo *file_info;
940 GList *iter;
941 gchar *label, *tip;
942 const gchar *mime_type;
943 GtkAction *action;
944 EomWindowPrivate *priv;
945 GList *apps;
946 guint action_id = 0;
947 GIcon *app_icon;
948 char *path;
949 GtkWidget *menuitem;
950
951 priv = window->priv;
952
953 edit_button_active = FALSE(0);
954 editor_app = get_appinfo_for_editor (window);
955
956 file = eom_image_get_file (image);
957 file_info = g_file_query_info (file,
958 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
959 0, NULL((void*)0), NULL((void*)0));
960
961 if (file_info == NULL((void*)0))
962 return;
963 else {
964 mime_type = g_file_info_get_content_type (file_info);
965 }
966
967 if (priv->open_with_menu_id != 0) {
968 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->open_with_menu_id);
969 priv->open_with_menu_id = 0;
970 }
971
972 if (priv->actions_open_with != NULL((void*)0)) {
973 gtk_ui_manager_remove_action_group (priv->ui_mgr, priv->actions_open_with);
974 g_object_unref (priv->actions_open_with);
975 priv->actions_open_with = NULL((void*)0);
976 }
977
978 if (mime_type == NULL((void*)0)) {
979 g_object_unref (file_info);
980 return;
981 }
982
983 apps = g_app_info_get_all_for_type (mime_type);
984
985 g_object_unref (file_info);
986
987 if (!apps)
988 return;
989
990 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
991 priv->actions_open_with = gtk_action_group_new ("OpenWithActions");
992 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
993 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_open_with, -1);
994
995 priv->open_with_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
996
997 for (iter = apps; iter; iter = iter->next) {
998 GAppInfo *app = iter->data;
999 gchar name[64];
1000
1001 if (editor_app != NULL((void*)0) && g_app_info_equal (editor_app, app)) {
1002 edit_button_active = TRUE(!(0));
1003 }
1004
1005 /* Do not include eom itself */
1006 if (g_ascii_strcasecmp (g_app_info_get_executable (app),
1007 g_get_prgname ()) == 0) {
1008 g_object_unref (app);
1009 continue;
1010 }
1011
1012 g_snprintf (name, sizeof (name), "OpenWith%u", action_id++);
1013
1014 label = g_strdup (g_app_info_get_name (app))g_strdup_inline (g_app_info_get_name (app));
1015 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));
1016
1017 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1018 action = gtk_action_new (name, label, tip, NULL((void*)0));
1019 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1020
1021 app_icon = g_app_info_get_icon (app);
1022 if (G_LIKELY (app_icon != NULL)(app_icon != ((void*)0))) {
1023 g_object_ref (app_icon)((__typeof__ (app_icon)) (g_object_ref) (app_icon));
1024 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1025 gtk_action_set_gicon (action, app_icon);
1026 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1027 g_object_unref (app_icon);
1028 }
1029
1030 g_free (label);
1031 g_free (tip);
1032
1033 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "app", app,
1034 (GDestroyNotify) g_object_unref);
1035
1036 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1037 G_CALLBACK (open_with_launch_application_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1038 image)g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
;
1039
1040 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1041 gtk_action_group_add_action (priv->actions_open_with, action);
1042 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1043 g_object_unref (action);
1044
1045 gtk_ui_manager_add_ui (priv->ui_mgr,
1046 priv->open_with_menu_id,
1047 "/MainMenu/Image/ImageOpenWith/Applications Placeholder",
1048 name,
1049 name,
1050 GTK_UI_MANAGER_MENUITEM,
1051 FALSE(0));
1052
1053 gtk_ui_manager_add_ui (priv->ui_mgr,
1054 priv->open_with_menu_id,
1055 "/ThumbnailPopup/ImageOpenWith/Applications Placeholder",
1056 name,
1057 name,
1058 GTK_UI_MANAGER_MENUITEM,
1059 FALSE(0));
1060 gtk_ui_manager_add_ui (priv->ui_mgr,
1061 priv->open_with_menu_id,
1062 "/ViewPopup/ImageOpenWith/Applications Placeholder",
1063 name,
1064 name,
1065 GTK_UI_MANAGER_MENUITEM,
1066 FALSE(0));
1067
1068 path = g_strdup_printf ("/MainMenu/Image/ImageOpenWith/Applications Placeholder/%s", name);
1069
1070 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1071
1072 /* Only force displaying the icon if it is an application icon */
1073 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, app_icon != NULL((void*)0));
1074
1075 g_free (path);
1076
1077 path = g_strdup_printf ("/ThumbnailPopup/ImageOpenWith/Applications Placeholder/%s", name);
1078
1079 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1080
1081 /* Only force displaying the icon if it is an application icon */
1082 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, app_icon != NULL((void*)0));
1083
1084 g_free (path);
1085
1086 path = g_strdup_printf ("/ViewPopup/ImageOpenWith/Applications Placeholder/%s", name);
1087
1088 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1089
1090 /* Only force displaying the icon if it is an application icon */
1091 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, app_icon != NULL((void*)0));
1092
1093 g_free (path);
1094 }
1095
1096 g_list_free (apps);
1097
1098 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1099 action = gtk_action_group_get_action (window->priv->actions_image,
1100 "OpenEditor");
1101 if (action != NULL((void*)0)) {
1102 gtk_action_set_sensitive (action, edit_button_active);
1103 }
1104 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1105}
1106
1107static void
1108eom_window_clear_load_job (EomWindow *window)
1109{
1110 EomWindowPrivate *priv = window->priv;
1111
1112 if (priv->load_job != NULL((void*)0)) {
1113 if (!priv->load_job->finished)
1114 eom_job_queue_remove_job (priv->load_job);
1115
1116 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))
1117 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))
1118 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))
;
1119
1120 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))
1121 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))
1122 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))
;
1123
1124 eom_image_cancel_load (EOM_JOB_LOAD (priv->load_job)((((EomJobLoad*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->load_job)), ((eom_job_load_get_type()))))))
->image);
1125
1126 g_object_unref (priv->load_job);
1127 priv->load_job = NULL((void*)0);
1128
1129 /* Hide statusbar */
1130 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0);
1131 }
1132}
1133
1134static void
1135eom_job_progress_cb (EomJobLoad *job, float progress, gpointer user_data)
1136{
1137 EomWindow *window;
1138
1139 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)
;
1140
1141 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1142
1143 eom_statusbar_set_progress (EOM_STATUSBAR (window->priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((eom_statusbar_get_type
()))))))
,
1144 progress);
1145}
1146
1147static void
1148eom_job_save_progress_cb (EomJobSave *job, float progress, gpointer user_data)
1149{
1150 EomWindowPrivate *priv;
1151 EomWindow *window;
1152
1153 static EomImage *image = NULL((void*)0);
1154
1155 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)
;
1156
1157 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1158 priv = window->priv;
1159
1160 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
,
1161 progress);
1162
1163 if (image != job->current_image) {
1164 gchar *str_image, *status_message;
1165 guint n_images;
1166
1167 image = job->current_image;
1168
1169 n_images = g_list_length (job->images);
1170
1171 str_image = eom_image_get_uri_for_display (image);
1172
1173 /* Translators: This string is displayed in the statusbar
1174 * while saving images. The tokens are from left to right:
1175 * - the original filename
1176 * - the current image's position in the queue
1177 * - the total number of images queued for saving */
1178 status_message = g_strdup_printf (_("Saving image \"%s\" (%u/%u)")gettext ("Saving image \"%s\" (%u/%u)"),
1179 str_image,
1180 job->current_pos + 1,
1181 n_images);
1182 g_free (str_image);
1183
1184 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1185 priv->image_info_message_cid);
1186
1187 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1188 priv->image_info_message_cid,
1189 status_message);
1190
1191 g_free (status_message);
1192 }
1193
1194 if (progress == 1.0)
1195 image = NULL((void*)0);
1196}
1197
1198static void
1199eom_window_obtain_desired_size (EomImage *image,
1200 gint width,
1201 gint height,
1202 EomWindow *window)
1203{
1204 GdkScreen *screen;
1205 GdkDisplay *display;
1206 GdkRectangle monitor;
1207 GtkAllocation allocation;
1208 gint final_width, final_height;
1209 gint screen_width, screen_height;
1210 gint window_width, window_height;
1211 gint img_width, img_height;
1212 gint view_width, view_height;
1213 gint deco_width, deco_height;
1214
1215 update_action_groups_state (window);
1216
1217 img_width = width;
1218 img_height = height;
1219
1220 if (!gtk_widget_get_realized (window->priv->view)) {
1221 gtk_widget_realize (window->priv->view);
1222 }
1223
1224 gtk_widget_get_allocation (window->priv->view, &allocation);
1225 view_width = allocation.width;
1226 view_height = allocation.height;
1227
1228 if (!gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)) {
1229 gtk_widget_realize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1230 }
1231
1232 gtk_widget_get_allocation (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, &allocation);
1233 window_width = allocation.width;
1234 window_height = allocation.height;
1235
1236 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
1237 display = gdk_screen_get_display (screen);
1238
1239 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1240 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)),
1241 &monitor);
1242
1243 screen_width = monitor.width;
1244 screen_height = monitor.height;
1245
1246 deco_width = window_width - view_width;
1247 deco_height = window_height - view_height;
1248
1249 if (img_width > 0 && img_height > 0) {
1250 if ((img_width + deco_width > screen_width) ||
1251 (img_height + deco_height > screen_height))
1252 {
1253 double factor;
1254
1255 if (img_width > img_height) {
1256 factor = (screen_width * 0.75 - deco_width) / (double) img_width;
1257 } else {
1258 factor = (screen_height * 0.75 - deco_height) / (double) img_height;
1259 }
1260
1261 img_width = img_width * factor;
1262 img_height = img_height * factor;
1263 }
1264 }
1265
1266 final_width = MAX (EOM_WINDOW_MIN_WIDTH, img_width + deco_width)(((440) > (img_width + deco_width)) ? (440) : (img_width +
deco_width))
;
1267 final_height = MAX (EOM_WINDOW_MIN_HEIGHT, img_height + deco_height)(((350) > (img_height + deco_height)) ? (350) : (img_height
+ deco_height))
;
1268
1269 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1269, ((const char*) (__func__
))
, "Setting window size: %d x %d", final_width, final_height);
1270
1271 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, final_width, final_height);
1272
1273 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1274}
1275
1276static void
1277eom_window_error_message_area_response (GtkInfoBar *message_area,
1278 gint response_id,
1279 EomWindow *window)
1280{
1281 if (response_id != GTK_RESPONSE_OK) {
1282 eom_window_set_message_area (window, NULL((void*)0));
1283
1284 return;
1285 }
1286
1287 /* Trigger loading for current image again */
1288 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
1289 EOM_THUMB_VIEW_SELECT_CURRENT);
1290}
1291
1292static void
1293eom_job_load_cb (EomJobLoad *job, gpointer data)
1294{
1295 EomWindow *window;
1296 EomWindowPrivate *priv;
1297 GtkAction *action_undo, *action_save;
1298
1299 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)
;
1300
1301 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1301, ((const char*) (__func__
))
);
1302
1303 window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
1304 priv = window->priv;
1305
1306 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0.0);
1307
1308 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
1309 priv->image_info_message_cid);
1310
1311 if (priv->image != NULL((void*)0)) {
1312 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))
1313 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))
1314 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))
;
1315 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))
1316 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))
1317 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))
;
1318
1319 g_object_unref (priv->image);
1320 }
1321
1322 priv->image = g_object_ref (job->image)((__typeof__ (job->image)) (g_object_ref) (job->image));
1323
1324 if (EOM_JOB (job)((((EomJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((eom_job_get_type()))))))
->error == NULL((void*)0)) {
1325#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
1326 eom_image_apply_display_profile (job->image,
1327 priv->display_profile);
1328#endif
1329
1330 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1331 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
1332 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1333
1334 eom_window_display_image (window, job->image);
1335 } else {
1336 GtkWidget *message_area;
1337
1338 message_area = eom_image_load_error_message_area_new (
1339 eom_image_get_caption (job->image),
1340 EOM_JOB (job)((((EomJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((eom_job_get_type()))))))
->error);
1341
1342 g_signal_connect (message_area, "response",g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1343 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)
1344 window)g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
;
1345
1346 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, NULL((void*)0));
1347 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
1348 eom_image_get_caption (job->image));
1349
1350 eom_window_set_message_area (window, message_area);
1351
1352 gtk_info_bar_set_default_response (GTK_INFO_BAR (message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((message_area)), ((gtk_info_bar_get_type()))))))
,
1353 GTK_RESPONSE_CANCEL);
1354
1355 gtk_widget_show (message_area);
1356
1357 update_status_bar (window);
1358
1359 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
1360
1361 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1362 update_action_groups_state (window);
1363
1364 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1365 }
1366
1367 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1368 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
1369 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1370 }
1371
1372 eom_window_clear_load_job (window);
1373
1374 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1375 window->priv->status = EOM_WINDOW_STATUS_NORMAL;
1376
1377 g_signal_handlers_disconnect_by_func (job->image,g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_obtain_desired_size), (window))
1378 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), (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), (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*) (void *) 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*) (void *) 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, "finished",g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1459 G_CALLBACK (eom_job_transform_cb),g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1460 window)g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
1461
1462 g_signal_connect (priv->transform_job, "progress",g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1463 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1464 window)g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
1465
1466 eom_job_queue_add_job (priv->transform_job);
1467}
1468
1469static void
1470handle_image_selection_changed_cb (EomThumbView *thumbview, EomWindow *window)
1471{
1472 EomWindowPrivate *priv;
1473 EomImage *image;
1474 gchar *status_message;
1475 gchar *str_image;
1476
1477 priv = window->priv;
1478
1479 if (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0) {
1480 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
1481 g_get_application_name());
1482 gtk_statusbar_remove_all (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1483 priv->image_info_message_cid);
1484 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
1485 NULL((void*)0));
1486 }
1487
1488 if (eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
) == 0)
1489 return;
1490
1491 update_selection_ui_visibility (window);
1492
1493 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1494
1495 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", 1495, ((const
char*) (__func__)), "EOM_IS_IMAGE (image)"); } while (0)
;
1496
1497 eom_window_clear_load_job (window);
1498
1499 eom_window_set_message_area (window, NULL((void*)0));
1500
1501 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1502 priv->image_info_message_cid);
1503
1504 if (image == priv->image) {
1505 update_status_bar (window);
1506 return;
1507 }
1508
1509 if (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)) {
1510 if (priv->image != NULL((void*)0))
1511 g_object_unref (priv->image);
1512
1513 priv->image = image;
1514 eom_window_display_image (window, image);
1515 return;
1516 }
1517
1518 if (priv->status == EOM_WINDOW_STATUS_INIT) {
1519 g_signal_connect (image, "size-prepared",g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1520 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)
1521 window)g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
;
1522 }
1523
1524 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)
);
1525
1526 g_signal_connect (priv->load_job, "finished",g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1527 G_CALLBACK (eom_job_load_cb),g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1528 window)g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1529
1530 g_signal_connect (priv->load_job, "progress",g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1531 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1532 window)g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1533
1534 eom_job_queue_add_job (priv->load_job);
1535
1536 str_image = eom_image_get_uri_for_display (image);
1537
1538 status_message = g_strdup_printf (_("Opening image \"%s\"")gettext ("Opening image \"%s\""),
1539 str_image);
1540
1541 g_free (str_image);
1542
1543 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1544 priv->image_info_message_cid, status_message);
1545
1546 g_free (status_message);
1547}
1548
1549static void
1550view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
1551{
1552 EomWindow *window;
1553 GtkAction *action_zoom_in;
1554 GtkAction *action_zoom_out;
1555
1556 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)
;
1557
1558 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1559
1560 update_status_bar (window);
1561
1562 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1563 action_zoom_in =
1564 gtk_action_group_get_action (window->priv->actions_image,
1565 "ViewZoomIn");
1566
1567 action_zoom_out =
1568 gtk_action_group_get_action (window->priv->actions_image,
1569 "ViewZoomOut");
1570
1571 gtk_action_set_sensitive (action_zoom_in,
1572 !eom_scroll_view_get_zoom_is_max (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1573 gtk_action_set_sensitive (action_zoom_out,
1574 !eom_scroll_view_get_zoom_is_min (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1575 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1576}
1577
1578static void
1579eom_window_open_recent_cb (GtkAction *action, EomWindow *window)
1580{
1581 GtkRecentInfo *info;
1582 const gchar *uri;
1583 GSList *list = NULL((void*)0);
1584
1585 info = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info");
1586 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)
;
1587
1588 uri = gtk_recent_info_get_uri (info);
1589 list = g_slist_prepend (list, g_strdup (uri)g_strdup_inline (uri));
1590
1591 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1592 list,
1593 GDK_CURRENT_TIME0L,
1594 0,
1595 NULL((void*)0));
1596
1597 g_slist_free_full (list, g_free);
1598}
1599
1600static void
1601file_open_dialog_response_cb (GtkWidget *chooser,
1602 gint response_id,
1603 EomWindow *ev_window)
1604{
1605 if (response_id == GTK_RESPONSE_OK) {
1606 GSList *uris;
1607
1608 uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_file_chooser_get_type ()))))))
);
1609
1610 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1611 uris,
1612 GDK_CURRENT_TIME0L,
1613 0,
1614 NULL((void*)0));
1615
1616 g_slist_free_full (uris, g_free);
1617 }
1618
1619 gtk_widget_destroy (chooser);
1620}
1621
1622static void
1623eom_window_update_fullscreen_action (EomWindow *window)
1624{
1625 GtkAction *action;
1626
1627 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1628 action = gtk_action_group_get_action (window->priv->actions_image,
1629 "ViewFullscreen");
1630
1631 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_fullscreen), (window))
1632 eom_window_cmd_fullscreen,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_fullscreen), (window))
1633 window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_fullscreen), (window))
;
1634
1635 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1636 window->priv->mode == EOM_WINDOW_MODE_FULLSCREEN);
1637 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1638
1639 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_fullscreen), (window))
1640 eom_window_cmd_fullscreen,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_fullscreen), (window))
1641 window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_fullscreen), (window))
;
1642}
1643
1644static void
1645eom_window_update_slideshow_action (EomWindow *window)
1646{
1647 GtkAction *action;
1648
1649 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1650 action = gtk_action_group_get_action (window->priv->actions_collection,
1651 "ViewSlideshow");
1652
1653 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_slideshow), (window))
1654 eom_window_cmd_slideshow,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_slideshow), (window))
1655 window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_slideshow), (window))
;
1656
1657 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1658 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
1659 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1660
1661 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_slideshow), (window))
1662 eom_window_cmd_slideshow,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_slideshow), (window))
1663 window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_slideshow), (window))
;
1664}
1665
1666static void
1667eom_window_update_pause_slideshow_action (EomWindow *window)
1668{
1669 GtkAction *action;
1670
1671 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1672 action = gtk_action_group_get_action (window->priv->actions_image,
1673 "PauseSlideshow");
1674
1675 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_pause_slideshow), (window))
1676 eom_window_cmd_pause_slideshow,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_pause_slideshow), (window))
1677 window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_pause_slideshow), (window))
;
1678
1679 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) 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_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_pause_slideshow), (window))
1684 eom_window_cmd_pause_slideshow,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_pause_slideshow), (window))
1685 window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_pause_slideshow), (window))
;
1686}
1687
1688static void
1689eom_window_update_fullscreen_popup (EomWindow *window)
1690{
1691 GtkWidget *popup = window->priv->fullscreen_popup;
1692 GdkRectangle screen_rect;
1693 GdkScreen *screen;
1694 GdkDisplay *display;
1695
1696 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)
;
1697
1698 if (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
) == NULL((void*)0)) return;
1699
1700 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1701 display = gdk_screen_get_display (screen);
1702
1703 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1704 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)),
1705 &screen_rect);
1706
1707 gtk_widget_set_size_request (popup,
1708 screen_rect.width,
1709 -1);
1710
1711 gtk_window_move (GTK_WINDOW (popup)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_window_get_type ()))))))
, screen_rect.x, screen_rect.y);
1712}
1713
1714static void
1715screen_size_changed_cb (GdkScreen *screen, EomWindow *window)
1716{
1717 eom_window_update_fullscreen_popup (window);
1718}
1719
1720static gboolean
1721fullscreen_timeout_cb (gpointer data)
1722{
1723 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
1724
1725 gtk_widget_hide (window->priv->fullscreen_popup);
1726
1727 eom_scroll_view_hide_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1728
1729 fullscreen_clear_timeout (window);
1730
1731 return FALSE(0);
1732}
1733
1734static gboolean
1735slideshow_is_loop_end (EomWindow *window)
1736{
1737 EomWindowPrivate *priv = window->priv;
1738 EomImage *image = NULL((void*)0);
1739 gint pos;
1740
1741 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1742
1743 pos = eom_list_store_get_pos_by_image (priv->store, image);
1744
1745 return (pos == (eom_list_store_length (priv->store) - 1));
1746}
1747
1748static gboolean
1749slideshow_switch_cb (gpointer data)
1750{
1751 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
1752 EomWindowPrivate *priv = window->priv;
1753
1754 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1754, ((const char*) (__func__
))
);
1755
1756 if (priv->slideshow_random) {
1757 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1758 EOM_THUMB_VIEW_SELECT_RANDOM);
1759 return TRUE(!(0));
1760 }
1761
1762 if (!priv->slideshow_loop && slideshow_is_loop_end (window)) {
1763 eom_window_stop_fullscreen (window, TRUE(!(0)));
1764 return FALSE(0);
1765 }
1766
1767 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1768 EOM_THUMB_VIEW_SELECT_RIGHT);
1769
1770 return TRUE(!(0));
1771}
1772
1773static void
1774fullscreen_clear_timeout (EomWindow *window)
1775{
1776 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1776, ((const char*) (__func__
))
);
1777
1778 if (window->priv->fullscreen_timeout_source != NULL((void*)0)) {
1779 g_source_unref (window->priv->fullscreen_timeout_source);
1780 g_source_destroy (window->priv->fullscreen_timeout_source);
1781 }
1782
1783 window->priv->fullscreen_timeout_source = NULL((void*)0);
1784}
1785
1786static void
1787fullscreen_set_timeout (EomWindow *window)
1788{
1789 GSource *source;
1790
1791 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1791, ((const char*) (__func__
))
);
1792
1793 fullscreen_clear_timeout (window);
1794
1795 source = g_timeout_source_new (EOM_WINDOW_FULLSCREEN_TIMEOUT5 * 1000);
1796 g_source_set_callback (source, fullscreen_timeout_cb, window, NULL((void*)0));
1797
1798 g_source_attach (source, NULL((void*)0));
1799
1800 window->priv->fullscreen_timeout_source = source;
1801
1802 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1803}
1804
1805static void
1806slideshow_clear_timeout (EomWindow *window)
1807{
1808 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1808, ((const char*) (__func__
))
);
1809
1810 if (window->priv->slideshow_switch_source != NULL((void*)0)) {
1811 g_source_unref (window->priv->slideshow_switch_source);
1812 g_source_destroy (window->priv->slideshow_switch_source);
1813 }
1814
1815 window->priv->slideshow_switch_source = NULL((void*)0);
1816}
1817
1818static void
1819slideshow_set_timeout (EomWindow *window)
1820{
1821 GSource *source;
1822
1823 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1823, ((const char*) (__func__
))
);
1824
1825 slideshow_clear_timeout (window);
1826
1827 if (window->priv->slideshow_switch_timeout <= 0)
1828 return;
1829
1830 source = g_timeout_source_new (window->priv->slideshow_switch_timeout * 1000);
1831 g_source_set_callback (source, slideshow_switch_cb, window, NULL((void*)0));
1832
1833 g_source_attach (source, NULL((void*)0));
1834
1835 window->priv->slideshow_switch_source = source;
1836}
1837
1838static void
1839show_fullscreen_popup (EomWindow *window)
1840{
1841 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1841, ((const char*) (__func__
))
);
1842
1843 if (!gtk_widget_get_visible (window->priv->fullscreen_popup)) {
1844 gtk_widget_show_all (GTK_WIDGET (window->priv->fullscreen_popup)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->fullscreen_popup)), ((gtk_widget_get_type
()))))))
);
1845 }
1846
1847 fullscreen_set_timeout (window);
1848}
1849
1850static gboolean
1851fullscreen_motion_notify_cb (GtkWidget *widget,
1852 GdkEventMotion *event,
1853 gpointer user_data)
1854{
1855 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1856
1857 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1857, ((const char*) (__func__
))
);
1858
1859 if (event->y < EOM_WINDOW_FULLSCREEN_POPUP_THRESHOLD5) {
1860 show_fullscreen_popup (window);
1861 } else {
1862 fullscreen_set_timeout (window);
1863 }
1864
1865 return FALSE(0);
1866}
1867
1868static gboolean
1869fullscreen_leave_notify_cb (GtkWidget *widget,
1870 GdkEventCrossing *event,
1871 gpointer user_data)
1872{
1873 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1874
1875 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1875, ((const char*) (__func__
))
);
1876
1877 fullscreen_clear_timeout (window);
1878
1879 return FALSE(0);
1880}
1881
1882static void
1883exit_fullscreen_button_clicked_cb (GtkWidget *button, EomWindow *window)
1884{
1885 GtkAction *action;
1886
1887 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1887, ((const char*) (__func__
))
);
1888
1889 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1890 if (window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
1891 action = gtk_action_group_get_action (window->priv->actions_collection,
1892 "ViewSlideshow");
1893 } else {
1894 action = gtk_action_group_get_action (window->priv->actions_image,
1895 "ViewFullscreen");
1896 }
1897 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)
;
1898
1899 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, FALSE(0));
1900 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1901}
1902
1903static GtkWidget *
1904eom_window_get_exit_fullscreen_button (EomWindow *window)
1905{
1906 GtkWidget *button;
1907
1908 button = gtk_button_new_with_mnemonic (_("Leave Fullscreen")gettext ("Leave Fullscreen"));
1909 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("view-restore", GTK_ICON_SIZE_BUTTON));
1910
1911 g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1912 G_CALLBACK (exit_fullscreen_button_clicked_cb),g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1913 window)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
1914
1915 return button;
1916}
1917
1918static GtkWidget *
1919eom_window_create_fullscreen_popup (EomWindow *window)
1920{
1921 GtkWidget *popup;
1922 GtkWidget *hbox;
1923 GtkWidget *button;
1924 GtkWidget *toolbar;
1925 GdkScreen *screen;
1926
1927 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1927, ((const char*) (__func__
))
);
1928
1929 popup = gtk_window_new (GTK_WINDOW_POPUP);
1930
1931 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1932 gtk_container_add (GTK_CONTAINER (popup)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_container_get_type ()))))))
, hbox);
1933
1934 toolbar = gtk_ui_manager_get_widget (window->priv->ui_mgr,
1935 "/FullscreenToolbar");
1936 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", 1936, ((const
char*) (__func__)), "GTK_IS_WIDGET (toolbar)"); } while (0)
;
1937 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((gtk_toolbar_get_type ()))))))
, GTK_TOOLBAR_ICONS);
1938 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, toolbar, TRUE(!(0)), TRUE(!(0)), 0);
1939
1940 button = eom_window_get_exit_fullscreen_button (window);
1941 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, button, FALSE(0), FALSE(0), 0);
1942
1943 gtk_window_set_resizable (GTK_WINDOW (popup)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_window_get_type ()))))))
, FALSE(0));
1944
1945 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1946
1947 g_signal_connect_object (screen, "size-changed",
1948 G_CALLBACK (screen_size_changed_cb)((GCallback) (screen_size_changed_cb)),
1949 window, 0);
1950
1951 g_signal_connect (popup, "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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
,
2046 GTK_WINDOW (window)((((GtkWindow*) (void *) 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*) (void *) 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, "motion-notify-event",g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2100 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)
2101 window)g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2102
2103 g_signal_connect (priv->view, "leave-notify-event",g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2104 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)
2105 window)g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2106
2107 g_signal_connect (priv->thumbview, "motion-notify-event",g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2108 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)
2109 window)g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2110
2111 g_signal_connect (priv->thumbview, "leave-notify-event",g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2112 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)
2113 window)g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2114
2115 fullscreen_set_timeout (window);
2116
2117 if (slideshow) {
2118 priv->slideshow_random =
2119 g_settings_get_boolean (priv->fullscreen_settings,
2120 EOM_CONF_FULLSCREEN_RANDOM"random");
2121
2122 priv->slideshow_loop =
2123 g_settings_get_boolean (priv->fullscreen_settings,
2124 EOM_CONF_FULLSCREEN_LOOP"loop");
2125
2126 priv->slideshow_switch_timeout =
2127 g_settings_get_int (priv->fullscreen_settings,
2128 EOM_CONF_FULLSCREEN_SECONDS"seconds");
2129
2130 slideshow_set_timeout (window);
2131 }
2132
2133 upscale = g_settings_get_boolean (priv->fullscreen_settings,
2134 EOM_CONF_FULLSCREEN_UPSCALE"upscale");
2135
2136 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
2137 upscale);
2138
2139 gtk_widget_grab_focus (priv->view);
2140
2141 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2142 &black);
2143
2144 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2145 eom_window_update_fullscreen_popup (window);
2146
2147 eom_window_inhibit_screensaver (window);
2148
2149 /* Update both actions as we could've already been in one those modes */
2150 eom_window_update_slideshow_action (window);
2151 eom_window_update_fullscreen_action (window);
2152 eom_window_update_pause_slideshow_action (window);
2153}
2154
2155static void
2156eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow)
2157{
2158 EomWindowPrivate *priv;
2159 GtkWidget *menubar;
2160
2161 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2161, ((const char*) (__func__
))
);
2162
2163 priv = window->priv;
2164
2165 if (priv->mode != EOM_WINDOW_MODE_SLIDESHOW &&
2166 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2167
2168 priv->mode = EOM_WINDOW_MODE_NORMAL;
2169
2170 fullscreen_clear_timeout (window);
2171
2172 if (slideshow) {
2173 slideshow_clear_timeout (window);
2174 }
2175
2176 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), (fullscreen_motion_notify_cb), (window))
2177 fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (fullscreen_motion_notify_cb), (window))
2178 window)g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (fullscreen_motion_notify_cb), (window))
;
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), (fullscreen_leave_notify_cb), (window))
2181 fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (fullscreen_leave_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), (fullscreen_leave_notify_cb), (window))
;
2183
2184 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), (fullscreen_motion_notify_cb), (window))
2185 fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (fullscreen_motion_notify_cb), (window))
2186 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (fullscreen_motion_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), (fullscreen_leave_notify_cb), (window))
2189 fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (fullscreen_leave_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), (fullscreen_leave_notify_cb), (window))
;
2191
2192 update_ui_visibility (window);
2193
2194 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
2195 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", 2195, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
2196 gtk_widget_show (menubar);
2197
2198 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
2199
2200 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2201 NULL((void*)0));
2202 gtk_window_unfullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2203
2204 if (slideshow) {
2205 eom_window_update_slideshow_action (window);
2206 } else {
2207 eom_window_update_fullscreen_action (window);
2208 }
2209
2210 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
2211
2212 eom_window_uninhibit_screensaver (window);
2213}
2214
2215static void
2216eom_window_print (EomWindow *window)
2217{
2218 GtkWidget *dialog;
2219 GError *error = NULL((void*)0);
2220 GtkPrintOperation *print;
2221 GtkPrintOperationResult res;
2222 GtkPageSetup *page_setup;
2223 GtkPrintSettings *print_settings;
2224 gboolean page_setup_disabled = FALSE(0);
2225
2226 eom_debug (DEBUG_PRINTINGEOM_DEBUG_PRINTING, "eom-window.c", 2226, ((const char*) (__func__
))
);
2227
2228 print_settings = eom_print_get_print_settings ();
2229
2230 /* Make sure the window stays valid while printing */
2231 g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
2232
2233 if (window->priv->page_setup != NULL((void*)0))
2234 page_setup = g_object_ref (window->priv->page_setup)((__typeof__ (window->priv->page_setup)) (g_object_ref)
(window->priv->page_setup))
;
2235 else
2236 page_setup = eom_print_get_page_setup ();
2237
2238 print = eom_print_operation_new (window->priv->image,
2239 print_settings,
2240 page_setup);
2241
2242 // Disable page setup options if they are locked down
2243 page_setup_disabled = g_settings_get_boolean (window->priv->lockdown_settings,
2244 EOM_CONF_LOCKDOWN_CAN_SETUP_PAGE"disable-print-setup");
2245 if (page_setup_disabled)
2246 gtk_print_operation_set_embed_page_setup (print, FALSE(0));
2247
2248 res = gtk_print_operation_run (print,
2249 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
2250 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, &error);
2251
2252 if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
2253 dialog = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2254 GTK_DIALOG_DESTROY_WITH_PARENT,
2255 GTK_MESSAGE_ERROR,
2256 GTK_BUTTONS_CLOSE,
2257 _("Error printing file:\n%s")gettext ("Error printing file:\n%s"),
2258 error->message);
2259 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
2260 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
2261 NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
2262 gtk_widget_show (dialog);
2263 g_error_free (error);
2264 } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
2265 GtkPageSetup *new_page_setup;
2266 eom_print_set_print_settings (gtk_print_operation_get_print_settings (print));
2267 new_page_setup = gtk_print_operation_get_default_page_setup (print);
2268 if (window->priv->page_setup != NULL((void*)0))
2269 g_object_unref (window->priv->page_setup);
2270 window->priv->page_setup = g_object_ref (new_page_setup)((__typeof__ (new_page_setup)) (g_object_ref) (new_page_setup
))
;
2271 eom_print_set_page_setup (window->priv->page_setup);
2272 }
2273
2274 if (page_setup != NULL((void*)0))
2275 g_object_unref (page_setup);
2276 g_object_unref (print_settings);
2277 g_object_unref (window);
2278}
2279
2280static void
2281eom_window_cmd_file_open (GtkAction *action, gpointer user_data)
2282{
2283 EomWindow *window;
2284 EomWindowPrivate *priv;
2285 EomImage *current;
2286 GtkWidget *dlg;
2287
2288 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)
;
2289
2290 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2291
2292 priv = window->priv;
2293
2294 dlg = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_OPEN);
2295 gtk_window_set_transient_for (GTK_WINDOW (dlg)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_window_get_type ()))))))
, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2296
2297 current = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2298
2299 if (current != NULL((void*)0)) {
2300 gchar *dir_uri, *file_uri;
2301
2302 file_uri = eom_image_get_uri_for_display (current);
2303 dir_uri = g_path_get_dirname (file_uri);
2304
2305 gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2306 dir_uri);
2307 g_free (file_uri);
2308 g_free (dir_uri);
2309 g_object_unref (current);
2310 } else {
2311 /* If desired by the user,
2312 fallback to the XDG_PICTURES_DIR (if available) */
2313 const gchar *pics_dir;
2314 gboolean use_fallback;
2315
2316 use_fallback = g_settings_get_boolean (priv->ui_settings,
2317 EOM_CONF_UI_FILECHOOSER_XDG_FALLBACK"filechooser-xdg-fallback");
2318 pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
2319 if (use_fallback && pics_dir) {
2320 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2321 pics_dir);
2322 }
2323 }
2324
2325 g_signal_connect (dlg, "response",g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2326 G_CALLBACK (file_open_dialog_response_cb),g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2327 window)g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
2328
2329 gtk_widget_show_all (dlg);
2330}
2331
2332static void
2333eom_job_close_save_cb (EomJobSave *job, gpointer user_data)
2334{
2335 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2336
2337 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))
2338 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))
2339 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))
;
2340
2341 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2342}
2343
2344static void
2345close_confirmation_dialog_response_handler (EomCloseConfirmationDialog *dlg,
2346 gint response_id,
2347 EomWindow *window)
2348{
2349 GList *selected_images;
2350 EomWindowPrivate *priv;
2351
2352 priv = window->priv;
2353
2354 switch (response_id)
2355 {
2356 case GTK_RESPONSE_YES:
2357 /* save selected images */
2358 selected_images = eom_close_confirmation_dialog_get_selected_images (dlg);
2359 if (eom_window_save_images (window, selected_images)) {
2360 g_signal_connect (priv->save_job, "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2361 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)
2362 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
2363
2364 eom_job_queue_add_job (priv->save_job);
2365 }
2366
2367 break;
2368
2369 case GTK_RESPONSE_NO:
2370 /* dont save */
2371 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2372 break;
2373
2374 default:
2375 /* Cancel */
2376 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_widget_get_type ()))))))
);
2377 break;
2378 }
2379}
2380
2381static gboolean
2382eom_window_unsaved_images_confirm (EomWindow *window)
2383{
2384 EomWindowPrivate *priv;
2385 gboolean disabled;
2386 GtkWidget *dialog;
2387 GList *list;
2388 EomImage *image;
2389 GtkTreeIter iter;
2390
2391 priv = window->priv;
2392
2393 disabled = g_settings_get_boolean(priv->ui_settings,
2394 EOM_CONF_UI_DISABLE_CLOSE_CONFIRMATION"disable-close-confirmation");
2395 disabled |= window->priv->save_disabled;
2396 if (disabled || !priv->store) {
2397 return FALSE(0);
2398 }
2399
2400 list = NULL((void*)0);
2401 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter)) {
2402 do {
2403 gtk_tree_model_get (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter,
2404 EOM_LIST_STORE_EOM_IMAGE, &image,
2405 -1);
2406 if (!image)
2407 continue;
2408
2409 if (eom_image_is_modified (image)) {
2410 list = g_list_prepend (list, image);
2411 }
2412 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter));
2413 }
2414
2415 if (list) {
2416 list = g_list_reverse (list);
2417 dialog = eom_close_confirmation_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2418 list);
2419
2420 g_list_free (list);
2421 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2422 G_CALLBACK (close_confirmation_dialog_response_handler),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2423 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
;
2424 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2425
2426 gtk_widget_show (dialog);
2427 return TRUE(!(0));
2428
2429 }
2430 return FALSE(0);
2431}
2432
2433static void
2434eom_window_cmd_close_window (GtkAction *action, gpointer user_data)
2435{
2436 EomWindow *window;
2437 EomWindowPrivate *priv;
2438
2439 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)
;
2440
2441 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2442 priv = window->priv;
2443
2444 if (priv->save_job != NULL((void*)0)) {
2445 eom_window_finish_saving (window);
2446 }
2447
2448 if (!eom_window_unsaved_images_confirm (window)) {
2449 gtk_widget_destroy (GTK_WIDGET (user_data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_widget_get_type ()))))))
);
2450 }
2451}
2452
2453static void
2454eom_window_cmd_preferences (GtkAction *action, gpointer user_data)
2455{
2456 EomWindow *window;
2457 GtkWidget *pref_dlg;
2458
2459 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)
;
2460
2461 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2462
2463 pref_dlg = eom_preferences_dialog_get_instance (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2464
2465 gtk_widget_show (pref_dlg);
2466}
2467
2468#define EOM_TB_EDITOR_DLG_RESET_RESPONSE128 128
2469
2470static void
2471eom_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
2472{
2473 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
2474
2475 if (response == EOM_TB_EDITOR_DLG_RESET_RESPONSE128) {
2476 EggToolbarsModel *model;
2477 EggToolbarEditor *editor;
2478
2479 editor = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
,
2480 "EggToolbarEditor");
2481
2482 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)
;
2483
2484 egg_editable_toolbar_set_edit_mode
2485 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2486
2487 eom_application_reset_toolbars_model (EOM_APP(eom_application_get_instance ()));
2488 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
2489 egg_editable_toolbar_set_model
2490 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, model);
2491 egg_toolbar_editor_set_model (editor, model);
2492
2493 /* Toolbar would be uneditable now otherwise */
2494 egg_editable_toolbar_set_edit_mode
2495 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2496 } else if (response == GTK_RESPONSE_HELP) {
2497 eom_util_show_help ("eom-toolbareditor", NULL((void*)0));
2498 } else {
2499 egg_editable_toolbar_set_edit_mode
2500 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2501
2502 eom_application_save_toolbars_model (EOM_APP(eom_application_get_instance ()));
2503
2504 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
2505 }
2506}
2507
2508static void
2509eom_window_cmd_edit_toolbar (GtkAction *action, gpointer *user_data)
2510{
2511 EomWindow *window;
2512 GtkWidget *dialog;
2513 GtkWidget *editor;
2514
2515 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)
;
2516
2517 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) 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
2518
2519 dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor")gettext ("Toolbar Editor"),
2520 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2521 GTK_DIALOG_DESTROY_WITH_PARENT,
2522 _("_Reset to Default")gettext ("_Reset to Default"),
2523 EOM_TB_EDITOR_DLG_RESET_RESPONSE128,
2524 "gtk-close",
2525 GTK_RESPONSE_CLOSE,
2526 "gtk-help",
2527 GTK_RESPONSE_HELP,
2528 NULL((void*)0));
2529
2530 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
,
2531 GTK_RESPONSE_CLOSE);
2532
2533 gtk_container_set_border_width (GTK_CONTAINER (dialog)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_container_get_type ()))))))
, 5);
2534
2535 gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_box_get_type ()))))))
, 2);
2536
2537 gtk_window_set_default_size (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, 500, 400);
2538
2539 editor = egg_toolbar_editor_new (window->priv->ui_mgr,
2540 eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ())));
2541
2542 gtk_container_set_border_width (GTK_CONTAINER (editor)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_container_get_type ()))))))
, 5);
2543
2544 // Use as much vertical space as available
2545 gtk_widget_set_vexpand (GTK_WIDGET (editor)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
2546
2547 gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EggToolbarEditor*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((editor)), ((egg_toolbar_editor_get_type (
))))))))), ((gtk_box_get_type ()))))))
, 5);
2548
2549 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_container_get_type ()))))))
, editor);
2550
2551 egg_editable_toolbar_set_edit_mode
2552 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2553
2554 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "EggToolbarEditor", editor);
2555
2556 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2557 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)
2558 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2559
2560 gtk_widget_show_all (dialog);
2561}
2562
2563static void
2564eom_window_cmd_help (GtkAction *action, gpointer user_data)
2565{
2566 EomWindow *window;
2567
2568 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)
;
2569
2570 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2571
2572 eom_util_show_help (NULL((void*)0), GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2573}
2574
2575#define ABOUT_GROUP"About" "About"
2576#define EMAILIFY(string)(g_strdelimit ((string), "%", '@')) (g_strdelimit ((string), "%", '@'))
2577
2578static void
2579eom_window_cmd_about (GtkAction *action, gpointer user_data)
2580{
2581 EomWindow *window;
2582
2583 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)
;
2584
2585 const char *license[] = {
2586 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")
2587 "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")
2588 "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")
2589 "(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")
,
2590 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")
2591 "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")
2592 "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")
2593 "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")
,
2594 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."
)
2595 "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."
)
2596 "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."
)
2597 };
2598
2599 char *license_trans;
2600 GKeyFile *key_file;
2601 GBytes *bytes;
2602 const guint8 *data;
2603 gsize data_len;
2604 GError *error = NULL((void*)0);
2605 char **authors, **documenters;
2606 gsize n_authors = 0, n_documenters = 0 , i;
2607
2608 bytes = g_resources_lookup_data ("/org/mate/eom/ui/eom.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
2609 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2609, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2610
2611 data = g_bytes_get_data (bytes, &data_len);
2612 key_file = g_key_file_new ();
2613 g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
2614 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2614, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2615
2616 authors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Authors", &n_authors, NULL((void*)0));
2617 documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Documenters", &n_documenters, NULL((void*)0));
2618
2619 g_key_file_free (key_file);
2620 g_bytes_unref (bytes);
2621
2622 for (i = 0; i < n_authors; ++i)
2623 authors[i] = EMAILIFY (authors[i])(g_strdelimit ((authors[i]), "%", '@'));
2624 for (i = 0; i < n_documenters; ++i)
2625 documenters[i] = EMAILIFY (documenters[i])(g_strdelimit ((documenters[i]), "%", '@'));
2626
2627 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));
2628
2629 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2630
2631 gtk_show_about_dialog (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2632 "program-name", _("Eye of MATE")gettext ("Eye of MATE"),
2633 "title", _("About Eye of MATE")gettext ("About Eye of MATE"),
2634 "version", VERSION"1.28.0",
2635 "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-2021 MATE developers"
)
2636 "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-2021 MATE developers"
)
2637 "Copyright \xc2\xa9 2012-2021 MATE developers")gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2021 MATE developers"
)
,
2638 "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."
)
,
2639 "authors", authors,
2640 "documenters", documenters,
2641 "translator-credits", _("translator-credits")gettext ("translator-credits"),
2642 "website", PACKAGE_URL"https://mate-desktop.org",
2643 "logo-icon-name", "eom",
2644 "wrap-license", TRUE(!(0)),
2645 "license", license_trans,
2646 NULL((void*)0));
2647
2648 g_strfreev (authors);
2649 g_strfreev (documenters);
2650 g_free (license_trans);
2651}
2652
2653static void
2654eom_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
2655{
2656 EomWindow *window;
2657 EomWindowPrivate *priv;
2658 gboolean visible;
2659 const gchar *action_name;
2660
2661 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)
;
2662
2663 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2664 priv = window->priv;
2665
2666 if (priv->mode != EOM_WINDOW_MODE_NORMAL &&
2667 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2668
2669 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2670 visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
2671 action_name = gtk_action_get_name (action);
2672 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2673
2674 if (g_ascii_strcasecmp (action_name, "ViewToolbar") == 0) {
2675 g_object_set (G_OBJECT (priv->toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->toolbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2676
2677 if (priv->mode == EOM_WINDOW_MODE_NORMAL)
2678 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_TOOLBAR"toolbar", visible);
2679
2680 } else if (g_ascii_strcasecmp (action_name, "ViewStatusbar") == 0) {
2681 g_object_set (G_OBJECT (priv->statusbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), (((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_STATUSBAR"statusbar", visible);
2685
2686 } else if (g_ascii_strcasecmp (action_name, "ViewImageCollection") == 0) {
2687 if (visible) {
2688 /* Make sure the focus widget is realized to
2689 * avoid warnings on keypress events */
2690 if (!gtk_widget_get_realized (window->priv->thumbview))
2691 gtk_widget_realize (window->priv->thumbview);
2692
2693 gtk_widget_show (priv->nav);
2694 gtk_widget_grab_focus (priv->thumbview);
2695 } else {
2696 /* Make sure the focus widget is realized to
2697 * avoid warnings on keypress events.
2698 * Don't do it during init phase or the view
2699 * will get a bogus allocation. */
2700 if (!gtk_widget_get_realized (priv->view)
2701 && priv->status == EOM_WINDOW_STATUS_NORMAL)
2702 gtk_widget_realize (priv->view);
2703
2704 gtk_widget_hide (priv->nav);
2705
2706 if (gtk_widget_get_realized (priv->view))
2707 gtk_widget_grab_focus (priv->view);
2708 }
2709 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", visible);
2710
2711 } else if (g_ascii_strcasecmp (action_name, "ViewSidebar") == 0) {
2712 if (visible) {
2713 gtk_widget_show (priv->sidebar);
2714 } else {
2715 gtk_widget_hide (priv->sidebar);
2716 }
2717 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_SIDEBAR"sidebar", visible);
2718 }
2719}
2720
2721static void
2722wallpaper_info_bar_response (GtkInfoBar *bar, gint response, EomWindow *window)
2723{
2724 if (response == GTK_RESPONSE_YES) {
2725 GAppInfo *app_info;
2726 GError *error = NULL((void*)0);
2727
2728 app_info = g_app_info_create_from_commandline ("mate-appearance-properties --show-page=background",
2729 "mate-appearance-properties",
2730 G_APP_INFO_CREATE_NONE,
2731 &error);
2732
2733 if (error != NULL((void*)0)) {
2734 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2735 error->message);
2736 g_error_free (error);
2737 error = NULL((void*)0);
2738 }
2739
2740 if (app_info != NULL((void*)0)) {
2741 GdkAppLaunchContext *context;
2742 GdkDisplay *display;
2743
2744 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2745 context = gdk_display_get_app_launch_context (display);
2746 g_app_info_launch (app_info, NULL((void*)0), G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, &error);
2747
2748 if (error != NULL((void*)0)) {
2749 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2750 error->message);
2751 g_error_free (error);
2752 error = NULL((void*)0);
2753 }
2754
2755 g_object_unref (context);
2756 g_object_unref (app_info);
2757 }
2758 }
2759
2760 /* Close message area on every response */
2761 eom_window_set_message_area (window, NULL((void*)0));
2762}
2763
2764static void
2765eom_window_set_wallpaper (EomWindow *window, const gchar *filename, const gchar *visible_filename)
2766{
2767 GtkWidget *info_bar;
2768 GtkWidget *image;
2769 GtkWidget *label;
2770 GtkWidget *hbox;
2771 gchar *markup;
2772 gchar *text;
2773 gchar *basename;
2774 GSettings *wallpaper_settings;
2775
2776 wallpaper_settings = g_settings_new (EOM_CONF_BACKGROUND_SCHEMA"org.mate.background");
2777 g_settings_set_string (wallpaper_settings,
2778 EOM_CONF_BACKGROUND_FILE"picture-filename",
2779 filename);
2780 g_object_unref (wallpaper_settings);
2781
2782 /* I18N: When setting mnemonics for these strings, watch out to not
2783 clash with mnemonics from eom's menubar */
2784 info_bar = gtk_info_bar_new_with_buttons (_("_Open Background Preferences")gettext ("_Open Background Preferences"),
2785 GTK_RESPONSE_YES,
2786 C_("MessageArea","Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
2787 GTK_RESPONSE_NO, NULL((void*)0));
2788 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))
,
2789 GTK_MESSAGE_QUESTION);
2790
2791 image = gtk_image_new_from_icon_name ("dialog-question",
2792 GTK_ICON_SIZE_DIALOG);
2793 label = gtk_label_new (NULL((void*)0));
2794
2795 if (!visible_filename)
2796 basename = g_path_get_basename (filename);
2797
2798 /* The newline character is currently necessary due to a problem
2799 * with the automatic line break. */
2800 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?")
2801 "\nWould you like to modify its appearance?")gettext ("The image \"%s\" has been set as Desktop Background."
"\nWould you like to modify its appearance?")
,
2802 visible_filename ? visible_filename : basename);
2803 markup = g_markup_printf_escaped ("<b>%s</b>", text);
2804 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, markup);
2805 g_free (markup);
2806 g_free (text);
2807 if (!visible_filename)
2808 g_free (basename);
2809
2810 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
2811 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
2812 gtk_widget_set_halign (image, GTK_ALIGN_START);
2813 gtk_widget_set_valign (image, GTK_ALIGN_END);
2814 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
2815 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
2816 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_info_bar_get_content_area (((((GtkInfoBar*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((info_bar)), (
(gtk_info_bar_get_type()))))))))), ((gtk_box_get_type ())))))
)
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
2817 gtk_widget_show_all (hbox);
2818 gtk_widget_show (info_bar);
2819
2820 eom_window_set_message_area (window, info_bar);
2821 gtk_info_bar_set_default_response (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))
,
2822 GTK_RESPONSE_YES);
2823 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
2824 G_CALLBACK (wallpaper_info_bar_response),g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
2825 window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
;
2826}
2827
2828static void
2829eom_job_save_cb (EomJobSave *job, gpointer user_data)
2830{
2831 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2832 GtkAction *action_save;
2833
2834 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))
2835 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))
2836 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))
;
2837
2838 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))
2839 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))
2840 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))
;
2841
2842 g_object_unref (window->priv->save_job);
2843 window->priv->save_job = NULL((void*)0);
2844
2845 update_status_bar (window);
2846 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2847 action_save = gtk_action_group_get_action (window->priv->actions_image,
2848 "ImageSave");
2849 gtk_action_set_sensitive (action_save, FALSE(0));
2850 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2851}
2852
2853static void
2854eom_job_copy_cb (EomJobCopy *job, gpointer user_data)
2855{
2856 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2857 gchar *filepath, *basename, *filename, *extension;
2858 GtkAction *action;
2859 GFile *source_file, *dest_file;
2860
2861 /* Create source GFile */
2862 basename = g_file_get_basename (job->images->data);
2863 filepath = g_build_filename (job->dest, basename, NULL((void*)0));
2864 source_file = g_file_new_for_path (filepath);
2865 g_free (filepath);
2866
2867 /* Create destination GFile */
2868 extension = eom_util_filename_get_extension (basename);
2869 filename = g_strdup_printf ("%s.%s", EOM_WALLPAPER_FILENAME"eom-wallpaper", extension);
2870 filepath = g_build_filename (job->dest, filename, NULL((void*)0));
2871 dest_file = g_file_new_for_path (filepath);
2872 g_free (filename);
2873 g_free (extension);
2874
2875 /* Move the file */
2876 g_file_move (source_file, dest_file, G_FILE_COPY_OVERWRITE,
2877 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
2878
2879 /* Set the wallpaper */
2880 eom_window_set_wallpaper (window, filepath, basename);
2881 g_free (basename);
2882 g_free (filepath);
2883
2884 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
2885 window->priv->copy_file_cid);
2886 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2887 action = gtk_action_group_get_action (window->priv->actions_image,
2888 "ImageSetAsWallpaper");
2889 gtk_action_set_sensitive (action, TRUE(!(0)));
2890 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2891
2892 window->priv->copy_job = NULL((void*)0);
2893
2894 g_object_unref (source_file);
2895 g_object_unref (dest_file);
2896 g_object_unref (G_OBJECT (job->images->data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->images->data)), (((GType) ((20) << (2))
))))))
);
2897 g_list_free (job->images);
2898 g_object_unref (job);
2899}
2900
2901static gboolean
2902eom_window_save_images (EomWindow *window, GList *images)
2903{
2904 EomWindowPrivate *priv;
2905
2906 priv = window->priv;
2907
2908 if (window->priv->save_job != NULL((void*)0))
2909 return FALSE(0);
2910
2911 priv->save_job = eom_job_save_new (images);
2912
2913 g_signal_connect (priv->save_job, "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2914 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2915 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2916
2917 g_signal_connect (priv->save_job, "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2918 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)
2919 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
2920
2921 return TRUE(!(0));
2922}
2923
2924static void
2925eom_window_cmd_save (GtkAction *action, gpointer user_data)
2926{
2927 EomWindowPrivate *priv;
2928 EomWindow *window;
2929 GList *images;
2930
2931 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2932 priv = window->priv;
2933
2934 if (window->priv->save_job != NULL((void*)0))
2935 return;
2936
2937 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2938
2939 if (eom_window_save_images (window, images)) {
2940 eom_job_queue_add_job (priv->save_job);
2941 }
2942}
2943
2944static GFile*
2945eom_window_retrieve_save_as_file (EomWindow *window, EomImage *image)
2946{
2947 GtkWidget *dialog;
2948 GFile *save_file = NULL((void*)0);
2949 GFile *last_dest_folder;
2950 gint response;
2951
2952 g_assert (image != NULL)do { if (image != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2952, ((const char*) (__func__)), "image != NULL"
); } while (0)
;
2953
2954 dialog = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_SAVE);
2955
2956 last_dest_folder = window->priv->last_save_as_folder;
2957
2958 if (last_dest_folder && g_file_query_exists (last_dest_folder, NULL((void*)0))) {
2959 gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
, last_dest_folder, NULL((void*)0));
2960 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2961 eom_image_get_caption (image));
2962 } else {
2963 GFile *image_file;
2964
2965 image_file = eom_image_get_file (image);
2966 /* Setting the file will also navigate to its parent folder */
2967 gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2968 image_file, NULL((void*)0));
2969 g_object_unref (image_file);
2970 }
2971
2972 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
2973 gtk_widget_hide (dialog);
2974
2975 if (response == GTK_RESPONSE_OK) {
2976 save_file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
);
2977 if (window->priv->last_save_as_folder)
2978 g_object_unref (window->priv->last_save_as_folder);
2979 window->priv->last_save_as_folder = g_file_get_parent (save_file);
2980 }
2981 gtk_widget_destroy (dialog);
2982
2983 return save_file;
2984}
2985
2986static void
2987eom_window_cmd_save_as (GtkAction *action, gpointer user_data)
2988{
2989 EomWindowPrivate *priv;
2990 EomWindow *window;
2991 GList *images;
2992 guint n_images;
2993
2994 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2995 priv = window->priv;
2996
2997 if (window->priv->save_job != NULL((void*)0))
2998 return;
2999
3000 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3001 n_images = g_list_length (images);
3002
3003 if (n_images == 1) {
3004 GFile *file;
3005
3006 file = eom_window_retrieve_save_as_file (window, images->data);
3007
3008 if (!file) {
3009 g_list_free (images);
3010 return;
3011 }
3012
3013 priv->save_job = eom_job_save_as_new (images, NULL((void*)0), file);
3014
3015 g_object_unref (file);
3016 } else if (n_images > 1) {
3017 GFile *base_file;
3018 GtkWidget *dialog;
3019 gchar *basedir;
3020 EomURIConverter *converter;
3021
3022 basedir = g_get_current_dir ();
3023 base_file = g_file_new_for_path (basedir);
3024 g_free (basedir);
3025
3026 dialog = eom_save_as_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3027 images,
3028 base_file);
3029
3030 gtk_widget_show_all (dialog);
3031
3032 if (gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
) != GTK_RESPONSE_OK) {
3033 g_object_unref (base_file);
3034 g_list_free (images);
3035 gtk_widget_destroy (dialog);
3036
3037 return;
3038 }
3039
3040 converter = eom_save_as_dialog_get_converter (dialog);
3041
3042 g_assert (converter != NULL)do { if (converter != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3042, ((const char*) (__func__)), "converter != NULL"
); } while (0)
;
3043
3044 priv->save_job = eom_job_save_as_new (images, converter, NULL((void*)0));
3045
3046 gtk_widget_destroy (dialog);
3047
3048 g_object_unref (converter);
3049 g_object_unref (base_file);
3050 } else {
3051 /* n_images = 0 -- No Image selected */
3052 return;
3053 }
3054
3055 g_signal_connect (priv->save_job, "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3056 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3057 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3058
3059 g_signal_connect (priv->save_job, "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3060 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)
3061 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
3062
3063 eom_job_queue_add_job (priv->save_job);
3064}
3065
3066static void
3067eom_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
3068{
3069 EomWindowPrivate *priv;
3070
3071 GFile *file;
3072 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)
;
3073
3074 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3075
3076 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)
;
3077
3078 file = eom_image_get_file (priv->image);
3079
3080 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)
;
3081
3082 eom_util_show_file_in_filemanager (file,
3083 GTK_WINDOW (user_data)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_window_get_type ()))))))
);
3084}
3085
3086static void
3087eom_window_cmd_print (GtkAction *action, gpointer user_data)
3088{
3089 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3090
3091 eom_window_print (window);
3092}
3093
3094/**
3095 * eom_window_get_properties_dialog:
3096 * @window: a #EomWindow
3097 *
3098 * Gets the @window property dialog. The widget will be built on the first call to this function.
3099 *
3100 * Returns: (transfer none): a #GtkDialog.
3101 */
3102
3103GtkWidget*
3104eom_window_get_properties_dialog (EomWindow *window)
3105{
3106 EomWindowPrivate *priv;
3107
3108 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)
;
3109
3110 priv = window->priv;
3111
3112 if (priv->properties_dlg == NULL((void*)0)) {
3113 GtkAction *next_image_action, *previous_image_action;
3114
3115 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3116 next_image_action =
3117 gtk_action_group_get_action (priv->actions_collection,
3118 "GoNext");
3119
3120 previous_image_action =
3121 gtk_action_group_get_action (priv->actions_collection,
3122 "GoPrevious");
3123 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3124 priv->properties_dlg =
3125 eom_properties_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3126 EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3127 next_image_action,
3128 previous_image_action);
3129
3130 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
3131 priv->image);
3132 g_settings_bind (priv->ui_settings,
3133 EOM_CONF_UI_PROPSDIALOG_NETBOOK_MODE"propsdialog-netbook-mode",
3134 priv->properties_dlg, "netbook-mode",
3135 G_SETTINGS_BIND_GET);
3136 }
3137
3138 return priv->properties_dlg;
3139}
3140
3141static void
3142eom_window_cmd_properties (GtkAction *action, gpointer user_data)
3143{
3144 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3145 GtkWidget *dialog;
3146
3147 dialog = eom_window_get_properties_dialog (window);
3148 gtk_widget_show (dialog);
3149}
3150
3151static void
3152eom_window_cmd_undo (GtkAction *action, gpointer user_data)
3153{
3154 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)
;
3155
3156 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
, NULL((void*)0));
3157}
3158
3159static void
3160eom_window_cmd_flip_horizontal (GtkAction *action, gpointer user_data)
3161{
3162 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)
;
3163
3164 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3165 eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL));
3166}
3167
3168static void
3169eom_window_cmd_flip_vertical (GtkAction *action, gpointer user_data)
3170{
3171 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)
;
3172
3173 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3174 eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL));
3175}
3176
3177static void
3178eom_window_cmd_rotate_90 (GtkAction *action, gpointer user_data)
3179{
3180 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)
;
3181
3182 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3183 eom_transform_rotate_new (90));
3184}
3185
3186static void
3187eom_window_cmd_rotate_270 (GtkAction *action, gpointer user_data)
3188{
3189 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)
;
3190
3191 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3192 eom_transform_rotate_new (270));
3193}
3194
3195static void
3196eom_window_cmd_wallpaper (GtkAction *action, gpointer user_data)
3197{
3198 EomWindow *window;
3199 EomWindowPrivate *priv;
3200 EomImage *image;
3201 GFile *file;
3202 char *filename = NULL((void*)0);
3203
3204 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)
;
3205
3206 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3207 priv = window->priv;
3208
3209 /* If currently copying an image to set it as wallpaper, return. */
3210 if (priv->copy_job != NULL((void*)0))
3211 return;
3212
3213 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3214
3215 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)
;
3216
3217 file = eom_image_get_file (image);
3218
3219 filename = g_file_get_path (file);
3220
3221 /* Currently only local files can be set as wallpaper */
3222 if (filename == NULL((void*)0) || !eom_util_file_is_persistent (file))
3223 {
3224 GList *files = NULL((void*)0);
3225 GtkAction *action_set_as_wp;
3226
3227 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3228 action_set_as_wp = gtk_action_group_get_action (window->priv->actions_image,
3229 "ImageSetAsWallpaper");
3230 gtk_action_set_sensitive (action_set_as_wp, FALSE(0));
3231 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3232
3233 priv->copy_file_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3234 "copy_file_cid");
3235 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3236 priv->copy_file_cid,
3237 _("Saving image locally…")gettext ("Saving image locally…"));
3238
3239 files = g_list_append (files, eom_image_get_file (image));
3240 priv->copy_job = eom_job_copy_new (files, g_get_user_data_dir ());
3241 g_signal_connect (priv->copy_job, "finished",g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3242 G_CALLBACK (eom_job_copy_cb),g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3243 window)g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3244 g_signal_connect (priv->copy_job, "progress",g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3245 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3246 window)g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3247 eom_job_queue_add_job (priv->copy_job);
3248
3249 g_object_unref (file);
3250 g_free (filename);
3251 return;
3252 }
3253
3254 g_object_unref (file);
3255
3256 eom_window_set_wallpaper (window, filename, NULL((void*)0));
3257
3258 g_free (filename);
3259}
3260
3261static gboolean
3262eom_window_all_images_trasheable (GList *images)
3263{
3264 GFile *file;
3265 GFileInfo *file_info;
3266 GList *iter;
3267 EomImage *image;
3268 gboolean can_trash = TRUE(!(0));
3269
3270 for (iter = images; iter != NULL((void*)0); iter = g_list_next (iter)((iter) ? (((GList *)(iter))->next) : ((void*)0))) {
3271 image = (EomImage *) iter->data;
3272 file = eom_image_get_file (image);
3273 file_info = g_file_query_info (file,
3274 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3275 0, NULL((void*)0), NULL((void*)0));
3276 can_trash = g_file_info_get_attribute_boolean (file_info,
3277 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3278
3279 g_object_unref (file_info);
3280 g_object_unref (file);
3281
3282 if (can_trash == FALSE(0))
3283 break;
3284 }
3285
3286 return can_trash;
3287}
3288
3289static int
3290show_move_to_trash_confirm_dialog (EomWindow *window, GList *images, gboolean can_trash)
3291{
3292 GtkWidget *dlg;
3293 char *prompt;
3294 int response;
3295 int n_images;
3296 EomImage *image;
3297 static gboolean dontaskagain = FALSE(0);
3298 gboolean neverask = FALSE(0);
3299 GtkWidget* dontask_cbutton = NULL((void*)0);
3300
3301 /* Check if the user never wants to be bugged. */
3302 neverask = g_settings_get_boolean (window->priv->ui_settings,
3303 EOM_CONF_UI_DISABLE_TRASH_CONFIRMATION"disable-trash-confirmation");
3304
3305 /* Assume agreement, if the user doesn't want to be
3306 * asked and the trash is available */
3307 if (can_trash && (dontaskagain || neverask))
3308 return GTK_RESPONSE_OK;
3309
3310 n_images = g_list_length (images);
3311
3312 if (n_images == 1) {
3313 image = EOM_IMAGE (images->data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((images->data)), ((eom_image_get_type ()))))))
;
3314 if (can_trash) {
3315 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?"
)
,
3316 eom_image_get_caption (image));
3317 } else {
3318 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?")
3319 "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));
3320 }
3321 } else {
3322 if (can_trash) {
3323 prompt = g_strdup_printf (ngettext("Are you sure you want to move\n"
3324 "the %d selected image to the trash?",
3325 "Are you sure you want to move\n"
3326 "the %d selected images to the trash?", n_images), n_images);
3327 } else {
3328 prompt = g_strdup (_("Some of the selected images can't be moved to the trash "g_strdup_inline (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?"
))
3329 "and will be removed permanently. Are you sure you want "g_strdup_inline (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?"
))
3330 "to proceed?"))g_strdup_inline (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?"
))
;
3331 }
3332 }
3333
3334 dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3335 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3336 GTK_MESSAGE_WARNING,
3337 GTK_BUTTONS_NONE,
3338 "<span weight=\"bold\" size=\"larger\">%s</span>",
3339 prompt);
3340 g_free (prompt);
3341
3342 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-cancel", GTK_RESPONSE_CANCEL);
3343
3344 if (can_trash) {
3345 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, _("Move to _Trash")gettext ("Move to _Trash"), GTK_RESPONSE_OK);
3346
3347 dontask_cbutton = gtk_check_button_new_with_mnemonic (_("_Do not ask again during this session")gettext ("_Do not ask again during this session"));
3348 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
, FALSE(0));
3349
3350 gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dlg)), ((gtk_dialog_get_type ())))))))))
, ((gtk_box_get_type ()))))))
, dontask_cbutton, TRUE(!(0)), TRUE(!(0)), 0);
3351 } else {
3352 if (n_images == 1) {
3353 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-delete", GTK_RESPONSE_OK);
3354 } else {
3355 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-yes", GTK_RESPONSE_OK);
3356 }
3357 }
3358
3359 gtk_dialog_set_default_response (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
3360 gtk_window_set_title (GTK_WINDOW (dlg)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_window_get_type ()))))))
, "");
3361 gtk_widget_show_all (dlg);
3362
3363 response = gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
3364
3365 /* Only update the property if the user has accepted */
3366 if (can_trash && response == GTK_RESPONSE_OK)
3367 dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
);
3368
3369 /* The checkbutton is destroyed together with the dialog */
3370 gtk_widget_destroy (dlg);
3371
3372 return response;
3373}
3374
3375static gboolean
3376move_to_trash_real (EomImage *image, GError **error)
3377{
3378 GFile *file;
3379 GFileInfo *file_info;
3380 gboolean can_trash, result;
3381
3382 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)
;
3383
3384 file = eom_image_get_file (image);
3385 file_info = g_file_query_info (file,
3386 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3387 0, NULL((void*)0), NULL((void*)0));
3388 if (file_info == NULL((void*)0)) {
3389 g_set_error (error,
3390 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3391 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3392 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3393 return FALSE(0);
3394 }
3395
3396 can_trash = g_file_info_get_attribute_boolean (file_info,
3397 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3398 g_object_unref (file_info);
3399 if (can_trash)
3400 {
3401 result = g_file_trash (file, NULL((void*)0), NULL((void*)0));
3402 if (result == FALSE(0)) {
3403 g_set_error (error,
3404 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3405 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3406 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3407 }
3408 } else {
3409 result = g_file_delete (file, NULL((void*)0), NULL((void*)0));
3410 if (result == FALSE(0)) {
3411 g_set_error (error,
3412 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3413 EOM_WINDOW_ERROR_IO,
3414 _("Couldn't delete file")gettext ("Couldn't delete file"));
3415 }
3416 }
3417
3418 g_object_unref (file);
3419
3420 return result;
3421}
3422
3423static void
3424eom_window_cmd_copy_image (GtkAction *action, gpointer user_data)
3425{
3426 GtkClipboard *clipboard;
3427 EomWindow *window;
3428 EomWindowPrivate *priv;
3429 EomImage *image;
3430 EomClipboardHandler *cbhandler;
3431
3432 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)
;
3433
3434 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3435 priv = window->priv;
3436
3437 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3438
3439 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)
;
3440
3441 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD((GdkAtom)((gpointer) (gulong) (69))));
3442
3443 cbhandler = eom_clipboard_handler_new (image);
3444 // cbhandler will self-destruct when it's not needed anymore
3445 eom_clipboard_handler_copy_to_clipboard (cbhandler, clipboard);
3446
3447}
3448
3449static void
3450eom_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
3451{
3452 GList *images;
3453 GList *it;
3454 EomWindowPrivate *priv;
3455 EomListStore *list;
3456 int pos;
3457 EomImage *img;
3458 EomWindow *window;
3459 int response;
3460 int n_images;
3461 gboolean success;
3462 gboolean can_trash;
3463 const gchar *action_name;
3464
3465 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)
;
3466
3467 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3468 priv = window->priv;
3469 list = priv->store;
3470
3471 n_images = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3472
3473 if (n_images < 1) return;
3474
3475 /* save position of selected image after the deletion */
3476 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3477
3478 g_assert (images != NULL)do { if (images != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3478, ((const char*) (__func__)), "images != NULL"
); } while (0)
;
3479
3480 /* HACK: eom_list_store_get_n_selected return list in reverse order */
3481 images = g_list_reverse (images);
3482
3483 can_trash = eom_window_all_images_trasheable (images);
3484
3485 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3486 action_name = gtk_action_get_name (action);
3487 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3488
3489 if (g_ascii_strcasecmp (action_name, "Delete") == 0 ||
3490 can_trash == FALSE(0)) {
3491 response = show_move_to_trash_confirm_dialog (window, images, can_trash);
3492
3493 if (response != GTK_RESPONSE_OK) return;
3494 }
3495
3496 pos = eom_list_store_get_pos_by_image (list, EOM_IMAGE (images->data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((images->data)), ((eom_image_get_type ()))))))
);
3497
3498 /* FIXME: make a nice progress dialog */
3499 /* Do the work actually. First try to delete the image from the disk. If this
3500 * is successful, remove it from the screen. Otherwise show error dialog.
3501 */
3502 for (it = images; it != NULL((void*)0); it = it->next) {
3503 GError *error = NULL((void*)0);
3504 EomImage *image;
3505
3506 image = EOM_IMAGE (it->data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((it->data)), ((eom_image_get_type ()))))))
;
3507
3508 success = move_to_trash_real (image, &error);
3509
3510 if (success) {
3511 eom_list_store_remove_image (list, image);
3512 } else {
3513 char *header;
3514 GtkWidget *dlg;
3515
3516 header = g_strdup_printf (_("Error on deleting image %s")gettext ("Error on deleting image %s"),
3517 eom_image_get_caption (image));
3518
3519 dlg = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3520 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3521 GTK_MESSAGE_ERROR,
3522 GTK_BUTTONS_OK,
3523 "%s", header);
3524
3525 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dlg)), ((gtk_message_dialog_get_type ()))))
))
,
3526 "%s", error->message);
3527
3528 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
3529
3530 gtk_widget_destroy (dlg);
3531
3532 g_free (header);
3533 }
3534 }
3535
3536 /* free list */
3537 g_list_free_full (images, g_object_unref);
3538
3539 /* select image at previously saved position */
3540 pos = MIN (pos, eom_list_store_length (list) - 1)(((pos) < (eom_list_store_length (list) - 1)) ? (pos) : (eom_list_store_length
(list) - 1))
;
3541
3542 if (pos >= 0) {
3543 img = eom_list_store_get_image_by_pos (list, pos);
3544
3545 eom_thumb_view_set_current_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3546 img,
3547 TRUE(!(0)));
3548
3549 if (img != NULL((void*)0)) {
3550 g_object_unref (img);
3551 }
3552 }
3553}
3554
3555static void
3556eom_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
3557{
3558 EomWindow *window;
3559 gboolean fullscreen;
3560
3561 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)
;
3562
3563 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3563, ((const char*) (__func__
))
);
3564
3565 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3566
3567 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3568 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3569 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3570
3571 if (fullscreen) {
3572 eom_window_run_fullscreen (window, FALSE(0));
3573 } else {
3574 eom_window_stop_fullscreen (window, FALSE(0));
3575 }
3576}
3577
3578static void
3579eom_window_cmd_slideshow (GtkAction *action, gpointer user_data)
3580{
3581 EomWindow *window;
3582 gboolean slideshow;
3583
3584 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)
;
3585
3586 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3586, ((const char*) (__func__
))
);
3587
3588 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3589
3590 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3591 slideshow = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3592 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3593
3594 if (slideshow) {
3595 eom_window_run_fullscreen (window, TRUE(!(0)));
3596 } else {
3597 eom_window_stop_fullscreen (window, TRUE(!(0)));
3598 }
3599}
3600
3601static void
3602eom_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data)
3603{
3604 EomWindow *window;
3605 gboolean slideshow;
3606
3607 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)
;
3608
3609 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3609, ((const char*) (__func__
))
);
3610
3611 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3612
3613 slideshow = window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
3614
3615 if (!slideshow && window->priv->mode != EOM_WINDOW_MODE_FULLSCREEN)
3616 return;
3617
3618 eom_window_run_fullscreen (window, !slideshow);
3619}
3620
3621static void
3622eom_window_cmd_zoom_in (GtkAction *action, gpointer user_data)
3623{
3624 EomWindowPrivate *priv;
3625
3626 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)
;
3627
3628 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3628, ((const char*) (__func__
))
);
3629
3630 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3631
3632 if (priv->view) {
3633 eom_scroll_view_zoom_in (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3634 }
3635}
3636
3637static void
3638eom_window_cmd_zoom_out (GtkAction *action, gpointer user_data)
3639{
3640 EomWindowPrivate *priv;
3641
3642 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)
;
3643
3644 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3644, ((const char*) (__func__
))
);
3645
3646 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3647
3648 if (priv->view) {
3649 eom_scroll_view_zoom_out (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3650 }
3651}
3652
3653static void
3654eom_window_cmd_zoom_normal (GtkAction *action, gpointer user_data)
3655{
3656 EomWindowPrivate *priv;
3657
3658 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)
;
3659
3660 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3660, ((const char*) (__func__
))
);
3661
3662 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3663
3664 if (priv->view) {
3665 eom_scroll_view_set_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, 1.0);
3666 }
3667}
3668
3669static void
3670eom_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
3671{
3672 EomWindowPrivate *priv;
3673
3674 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)
;
3675
3676 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3676, ((const char*) (__func__
))
);
3677
3678 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3679
3680 if (priv->view) {
3681 eom_scroll_view_zoom_fit (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
3682 }
3683}
3684
3685static void
3686eom_window_cmd_go_prev (GtkAction *action, gpointer user_data)
3687{
3688 EomWindowPrivate *priv;
3689
3690 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)
;
3691
3692 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3692, ((const char*) (__func__
))
);
3693
3694 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3695
3696 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3697 EOM_THUMB_VIEW_SELECT_LEFT);
3698}
3699
3700static void
3701eom_window_cmd_go_next (GtkAction *action, gpointer user_data)
3702{
3703 EomWindowPrivate *priv;
3704
3705 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)
;
3706
3707 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3707, ((const char*) (__func__
))
);
3708
3709 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3710
3711 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3712 EOM_THUMB_VIEW_SELECT_RIGHT);
3713}
3714
3715static void
3716eom_window_cmd_go_first (GtkAction *action, gpointer user_data)
3717{
3718 EomWindowPrivate *priv;
3719
3720 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)
;
3721
3722 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3722, ((const char*) (__func__
))
);
3723
3724 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3725
3726 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3727 EOM_THUMB_VIEW_SELECT_FIRST);
3728}
3729
3730static void
3731eom_window_cmd_go_last (GtkAction *action, gpointer user_data)
3732{
3733 EomWindowPrivate *priv;
3734
3735 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)
;
3736
3737 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3737, ((const char*) (__func__
))
);
3738
3739 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3740
3741 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3742 EOM_THUMB_VIEW_SELECT_LAST);
3743}
3744
3745static void
3746eom_window_cmd_go_random (GtkAction *action, gpointer user_data)
3747{
3748 EomWindowPrivate *priv;
3749
3750 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)
;
3751
3752 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3752, ((const char*) (__func__
))
);
3753
3754 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3755
3756 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3757 EOM_THUMB_VIEW_SELECT_RANDOM);
3758}
3759
3760static const GtkActionEntry action_entries_window[] = {
3761 { "Image", NULL((void*)0), N_("_Image")("_Image"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3762 { "Edit", NULL((void*)0), N_("_Edit")("_Edit"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3763 { "View", NULL((void*)0), N_("_View")("_View"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3764 { "Go", NULL((void*)0), N_("_Go")("_Go"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3765 { "Tools", NULL((void*)0), N_("_Tools")("_Tools"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3766 { "Help", NULL((void*)0), N_("_Help")("_Help"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3767
3768 { "ImageOpen", "document-open", N_("_Open…")("_Open…"), "<control>O",
3769 N_("Open a file")("Open a file"),
3770 G_CALLBACK (eom_window_cmd_file_open)((GCallback) (eom_window_cmd_file_open)) },
3771 { "ImageClose", "window-close", N_("_Close")("_Close"), "<control>W",
3772 N_("Close window")("Close window"),
3773 G_CALLBACK (eom_window_cmd_close_window)((GCallback) (eom_window_cmd_close_window)) },
3774 { "EditToolbar", NULL((void*)0), N_("T_oolbar")("T_oolbar"), NULL((void*)0),
3775 N_("Edit the application toolbar")("Edit the application toolbar"),
3776 G_CALLBACK (eom_window_cmd_edit_toolbar)((GCallback) (eom_window_cmd_edit_toolbar)) },
3777 { "EditPreferences", "preferences-desktop", N_("Prefere_nces")("Prefere_nces"), NULL((void*)0),
3778 N_("Preferences for Eye of MATE")("Preferences for Eye of MATE"),
3779 G_CALLBACK (eom_window_cmd_preferences)((GCallback) (eom_window_cmd_preferences)) },
3780 { "HelpManual", "help-browser", N_("_Contents")("_Contents"), "F1",
3781 N_("Help on this application")("Help on this application"),
3782 G_CALLBACK (eom_window_cmd_help)((GCallback) (eom_window_cmd_help)) },
3783 { "HelpAbout", "help-about", N_("_About")("_About"), NULL((void*)0),
3784 N_("About this application")("About this application"),
3785 G_CALLBACK (eom_window_cmd_about)((GCallback) (eom_window_cmd_about)) }
3786};
3787
3788static const GtkToggleActionEntry toggle_entries_window[] = {
3789 { "ViewToolbar", NULL((void*)0), N_("_Toolbar")("_Toolbar"), NULL((void*)0),
3790 N_("Changes the visibility of the toolbar in the current window")("Changes the visibility of the toolbar in the current window"
)
,
3791 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3792 { "ViewStatusbar", NULL((void*)0), N_("_Statusbar")("_Statusbar"), NULL((void*)0),
3793 N_("Changes the visibility of the statusbar in the current window")("Changes the visibility of the statusbar in the current window"
)
,
3794 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3795 { "ViewImageCollection", "eom-image-collection", N_("_Image Collection")("_Image Collection"), "<control>F9",
3796 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"
)
,
3797 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3798 { "ViewSidebar", NULL((void*)0), N_("Side _Pane")("Side _Pane"), "F9",
3799 N_("Changes the visibility of the side pane in the current window")("Changes the visibility of the side pane in the current window"
)
,
3800 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3801};
3802
3803static const GtkActionEntry action_entries_image[] = {
3804 { "ImageSave", "document-save", N_("_Save")("_Save"), "<control>s",
3805 N_("Save changes in currently selected images")("Save changes in currently selected images"),
3806 G_CALLBACK (eom_window_cmd_save)((GCallback) (eom_window_cmd_save)) },
3807 { "ImageOpenWith", NULL((void*)0), N_("Open _with")("Open _with"), NULL((void*)0),
3808 N_("Open the selected image with a different application")("Open the selected image with a different application"),
3809 NULL((void*)0)},
3810 { "ImageSaveAs", "document-save-as", N_("Save _As…")("Save _As…"), "<control><shift>s",
3811 N_("Save the selected images with a different name")("Save the selected images with a different name"),
3812 G_CALLBACK (eom_window_cmd_save_as)((GCallback) (eom_window_cmd_save_as)) },
3813 { "ImageOpenContainingFolder", "folder", N_("Open Containing _Folder")("Open Containing _Folder"), NULL((void*)0),
3814 N_("Show the folder which contains this file in the file manager")("Show the folder which contains this file in the file manager"
)
,
3815 G_CALLBACK (eom_window_cmd_open_containing_folder)((GCallback) (eom_window_cmd_open_containing_folder)) },
3816 { "ImagePrint", "document-print", N_("_Print…")("_Print…"), "<control>p",
3817 N_("Print the selected image")("Print the selected image"),
3818 G_CALLBACK (eom_window_cmd_print)((GCallback) (eom_window_cmd_print)) },
3819 { "ImageProperties", "document-properties", N_("Prope_rties")("Prope_rties"), "<alt>Return",
3820 N_("Show the properties and metadata of the selected image")("Show the properties and metadata of the selected image"),
3821 G_CALLBACK (eom_window_cmd_properties)((GCallback) (eom_window_cmd_properties)) },
3822 { "EditUndo", "edit-undo", N_("_Undo")("_Undo"), "<control>z",
3823 N_("Undo the last change in the image")("Undo the last change in the image"),
3824 G_CALLBACK (eom_window_cmd_undo)((GCallback) (eom_window_cmd_undo)) },
3825 { "EditFlipHorizontal", "object-flip-horizontal", N_("Flip _Horizontal")("Flip _Horizontal"), NULL((void*)0),
3826 N_("Mirror the image horizontally")("Mirror the image horizontally"),
3827 G_CALLBACK (eom_window_cmd_flip_horizontal)((GCallback) (eom_window_cmd_flip_horizontal)) },
3828 { "EditFlipVertical", "object-flip-vertical", N_("Flip _Vertical")("Flip _Vertical"), NULL((void*)0),
3829 N_("Mirror the image vertically")("Mirror the image vertically"),
3830 G_CALLBACK (eom_window_cmd_flip_vertical)((GCallback) (eom_window_cmd_flip_vertical)) },
3831 { "EditRotate90", "object-rotate-right", N_("_Rotate Clockwise")("_Rotate Clockwise"), "<control>r",
3832 N_("Rotate the image 90 degrees to the right")("Rotate the image 90 degrees to the right"),
3833 G_CALLBACK (eom_window_cmd_rotate_90)((GCallback) (eom_window_cmd_rotate_90)) },
3834 { "EditRotate270", "object-rotate-left", N_("Rotate Counterc_lockwise")("Rotate Counterc_lockwise"), "<ctrl><shift>r",
3835 N_("Rotate the image 90 degrees to the left")("Rotate the image 90 degrees to the left"),
3836 G_CALLBACK (eom_window_cmd_rotate_270)((GCallback) (eom_window_cmd_rotate_270)) },
3837 { "ImageSetAsWallpaper", NULL((void*)0), N_("Set as _Desktop Background")("Set as _Desktop Background"),
3838 "<control>F8", N_("Set the selected image as the desktop background")("Set the selected image as the desktop background"),
3839 G_CALLBACK (eom_window_cmd_wallpaper)((GCallback) (eom_window_cmd_wallpaper)) },
3840 { "EditMoveToTrash", "user-trash", N_("Move to _Trash")("Move to _Trash"), NULL((void*)0),
3841 N_("Move the selected image to the trash folder")("Move the selected image to the trash folder"),
3842 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3843 { "EditCopyImage", "edit-copy", N_("_Copy")("_Copy"), "<control>C",
3844 N_("Copy the selected image to the clipboard")("Copy the selected image to the clipboard"),
3845 G_CALLBACK (eom_window_cmd_copy_image)((GCallback) (eom_window_cmd_copy_image)) },
3846 { "ViewZoomIn", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>plus",
3847 N_("Enlarge the image")("Enlarge the image"),
3848 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3849 { "ViewZoomOut", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>minus",
3850 N_("Shrink the image")("Shrink the image"),
3851 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3852 { "ViewZoomNormal", "zoom-original", N_("_Normal Size")("_Normal Size"), "<control>0",
3853 N_("Show the image at its normal size")("Show the image at its normal size"),
3854 G_CALLBACK (eom_window_cmd_zoom_normal)((GCallback) (eom_window_cmd_zoom_normal)) },
3855 { "ViewZoomFit", "zoom-fit-best", N_("_Best Fit")("_Best Fit"), "F",
3856 N_("Fit the image to the window")("Fit the image to the window"),
3857 G_CALLBACK (eom_window_cmd_zoom_fit)((GCallback) (eom_window_cmd_zoom_fit)) },
3858 { "ControlEqual", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>equal",
3859 N_("Enlarge the image")("Enlarge the image"),
3860 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3861 { "ControlKpAdd", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>KP_Add",
3862 N_("Shrink the image")("Shrink the image"),
3863 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3864 { "ControlKpSub", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>KP_Subtract",
3865 N_("Shrink the image")("Shrink the image"),
3866 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3867 { "Delete", NULL((void*)0), N_("Move to _Trash")("Move to _Trash"), "Delete",
3868 NULL((void*)0),
3869 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3870};
3871
3872static const GtkToggleActionEntry toggle_entries_image[] = {
3873 { "ViewFullscreen", "view-fullscreen", N_("_Fullscreen")("_Fullscreen"), "F11",
3874 N_("Show the current image in fullscreen mode")("Show the current image in fullscreen mode"),
3875 G_CALLBACK (eom_window_cmd_fullscreen)((GCallback) (eom_window_cmd_fullscreen)), FALSE(0) },
3876 { "PauseSlideshow", "media-playback-pause", N_("Pause Slideshow")("Pause Slideshow"),
3877 NULL((void*)0), N_("Pause or resume the slideshow")("Pause or resume the slideshow"),
3878 G_CALLBACK (eom_window_cmd_pause_slideshow)((GCallback) (eom_window_cmd_pause_slideshow)), FALSE(0) },
3879};
3880
3881static const GtkActionEntry action_entries_collection[] = {
3882 { "GoPrevious", "go-previous", N_("_Previous Image")("_Previous Image"), "<Alt>Left",
3883 N_("Go to the previous image of the collection")("Go to the previous image of the collection"),
3884 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3885 { "GoNext", "go-next", N_("_Next Image")("_Next Image"), "<Alt>Right",
3886 N_("Go to the next image of the collection")("Go to the next image of the collection"),
3887 G_CALLBACK (eom_window_cmd_go_next)((GCallback) (eom_window_cmd_go_next)) },
3888 { "GoFirst", "go-first", N_("_First Image")("_First Image"), "<Alt>Home",
3889 N_("Go to the first image of the collection")("Go to the first image of the collection"),
3890 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3891 { "GoLast", "go-last", N_("_Last Image")("_Last Image"), "<Alt>End",
3892 N_("Go to the last image of the collection")("Go to the last image of the collection"),
3893 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3894 { "GoRandom", NULL((void*)0), N_("_Random Image")("_Random Image"), "<control>M",
3895 N_("Go to a random image of the collection")("Go to a random image of the collection"),
3896 G_CALLBACK (eom_window_cmd_go_random)((GCallback) (eom_window_cmd_go_random)) },
3897 { "BackSpace", NULL((void*)0), N_("_Previous Image")("_Previous Image"), "BackSpace",
3898 NULL((void*)0),
3899 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3900 { "Home", NULL((void*)0), N_("_First Image")("_First Image"), "Home",
3901 NULL((void*)0),
3902 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3903 { "End", NULL((void*)0), N_("_Last Image")("_Last Image"), "End",
3904 NULL((void*)0),
3905 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3906};
3907
3908static const GtkToggleActionEntry toggle_entries_collection[] = {
3909 { "ViewSlideshow", "slideshow-play", N_("S_lideshow")("S_lideshow"), "F5",
3910 N_("Start a slideshow view of the images")("Start a slideshow view of the images"),
3911 G_CALLBACK (eom_window_cmd_slideshow)((GCallback) (eom_window_cmd_slideshow)), FALSE(0) },
3912};
3913
3914static void
3915menu_item_select_cb (GtkMenuItem *proxy, EomWindow *window)
3916{
3917 GtkAction *action;
3918 char *message;
3919
3920 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3921 action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)((((GtkActivatable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((gtk_activatable_get_type ()))))))
);
3922 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3923
3924 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)
;
3925
3926 g_object_get (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "tooltip", &message, NULL((void*)0));
3927
3928 if (message) {
3929 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3930 window->priv->tip_message_cid, message);
3931 g_free (message);
3932 }
3933}
3934
3935static void
3936menu_item_deselect_cb (GtkMenuItem *proxy, EomWindow *window)
3937{
3938 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3939 window->priv->tip_message_cid);
3940}
3941
3942static void
3943connect_proxy_cb (GtkUIManager *manager,
3944 GtkAction *action,
3945 GtkWidget *proxy,
3946 EomWindow *window)
3947{
3948 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; }))))
) {
3949 disconnect_proxy_cb (manager, action, proxy, window);
3950 g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
3951 G_CALLBACK (menu_item_select_cb),g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
3952 window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
3953 g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3954 G_CALLBACK (menu_item_deselect_cb),g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3955 window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3956 }
3957}
3958
3959static void
3960disconnect_proxy_cb (GtkUIManager *manager,
3961 GtkAction *action,
3962 GtkWidget *proxy,
3963 EomWindow *window)
3964{
3965 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; }))))
) {
3966 g_signal_handlers_disconnect_by_func (proxy,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_select_cb), (window))
3967 menu_item_select_cb,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_select_cb), (window))
3968 window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_select_cb), (window))
;
3969 g_signal_handlers_disconnect_by_func (proxy,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_deselect_cb), (window))
3970 menu_item_deselect_cb,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_deselect_cb), (window))
3971 window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_deselect_cb), (window))
;
3972 }
3973}
3974
3975static void
3976set_action_properties (GtkActionGroup *window_group,
3977 GtkActionGroup *image_group,
3978 GtkActionGroup *collection_group)
3979{
3980 GtkAction *action;
3981
3982 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3983 action = gtk_action_group_get_action (collection_group, "GoPrevious");
3984 g_object_set (action, "short_label", _("_Previous")gettext ("_Previous"), NULL((void*)0));
3985 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3986
3987 action = gtk_action_group_get_action (collection_group, "GoNext");
3988 g_object_set (action, "short_label", _("_Next")gettext ("_Next"), NULL((void*)0));
3989 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3990
3991 action = gtk_action_group_get_action (image_group, "EditRotate90");
3992 g_object_set (action, "short_label", _("Right")gettext ("Right"), NULL((void*)0));
3993
3994 action = gtk_action_group_get_action (image_group, "EditRotate270");
3995 g_object_set (action, "short_label", _("Left")gettext ("Left"), NULL((void*)0));
3996
3997 action = gtk_action_group_get_action (image_group, "ImageOpenContainingFolder");
3998 g_object_set (action, "short_label", _("Open Folder")gettext ("Open Folder"), NULL((void*)0));
3999
4000 action = gtk_action_group_get_action (image_group, "ViewZoomIn");
4001 g_object_set (action, "short_label", _("In")gettext ("In"), NULL((void*)0));
4002
4003 action = gtk_action_group_get_action (image_group, "ViewZoomOut");
4004 g_object_set (action, "short_label", _("Out")gettext ("Out"), NULL((void*)0));
4005
4006 action = gtk_action_group_get_action (image_group, "ViewZoomNormal");
4007 g_object_set (action, "short_label", _("Normal")gettext ("Normal"), NULL((void*)0));
4008
4009 action = gtk_action_group_get_action (image_group, "ViewZoomFit");
4010 g_object_set (action, "short_label", _("Fit")gettext ("Fit"), NULL((void*)0));
4011
4012 action = gtk_action_group_get_action (window_group, "ViewImageCollection");
4013 g_object_set (action, "short_label", _("Collection")gettext ("Collection"), NULL((void*)0));
4014
4015 action = gtk_action_group_get_action (image_group, "EditMoveToTrash");
4016 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));
4017 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4018}
4019
4020static gint
4021sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
4022{
4023 gboolean has_eom_a, has_eom_b;
4024
4025 /* We need to check this first as gtk_recent_info_get_application_info
4026 * will treat it as a non-fatal error when the GtkRecentInfo doesn't
4027 * have the application registered. */
4028 has_eom_a = gtk_recent_info_has_application (a,
4029 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4030 has_eom_b = gtk_recent_info_has_application (b,
4031 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4032 if (has_eom_a && has_eom_b) {
4033 time_t time_a, time_b;
4034
4035 /* These should not fail as we already checked that
4036 * the application is registered with the info objects */
4037 gtk_recent_info_get_application_info (a,
4038 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4039 NULL((void*)0),
4040 NULL((void*)0),
4041 &time_a);
4042 gtk_recent_info_get_application_info (b,
4043 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4044 NULL((void*)0),
4045 NULL((void*)0),
4046 &time_b);
4047
4048 return (time_b - time_a);
4049 } else if (has_eom_a) {
4050 return -1;
4051 } else if (has_eom_b) {
4052 return 1;
4053 }
4054
4055 return 0;
4056}
4057
4058static void
4059eom_window_update_recent_files_menu (EomWindow *window)
4060{
4061 EomWindowPrivate *priv;
4062 GList *actions = NULL((void*)0), *li = NULL((void*)0), *items = NULL((void*)0);
4063 guint count_recent = 0;
4064
4065 priv = window->priv;
4066
4067 if (priv->recent_menu_id != 0)
4068 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->recent_menu_id);
4069
4070 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4071 actions = gtk_action_group_list_actions (priv->actions_recent);
4072
4073 for (li = actions; li != NULL((void*)0); li = li->next) {
4074 g_signal_handlers_disconnect_by_func (li->data,g_signal_handlers_disconnect_matched ((li->data), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_open_recent_cb), (window))
4075 eom_window_open_recent_cb,g_signal_handlers_disconnect_matched ((li->data), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_open_recent_cb), (window))
4076 window)g_signal_handlers_disconnect_matched ((li->data), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_open_recent_cb), (window))
;
4077
4078 gtk_action_group_remove_action (priv->actions_recent,
4079 GTK_ACTION (li->data)((((GtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((li->data)), ((gtk_action_get_type ()))))))
);
4080 }
4081 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4082
4083 g_list_free (actions);
4084
4085 priv->recent_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
4086 items = gtk_recent_manager_get_items (gtk_recent_manager_get_default());
4087 items = g_list_sort (items, (GCompareFunc) sort_recents_mru);
4088
4089 for (li = items; li != NULL((void*)0) && count_recent < EOM_RECENT_FILES_LIMIT5; li = li->next) {
4090 gchar *action_name;
4091 gchar *label;
4092 gchar *tip;
4093 gchar **display_name;
4094 gchar *label_filename;
4095 GtkAction *action;
4096 GtkRecentInfo *info = li->data;
4097
4098 /* Sorting moves non-EOM files to the end of the list.
4099 * So no file of interest will follow if this test fails */
4100 if (!gtk_recent_info_has_application (info, EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer"))
4101 break;
4102
4103 count_recent++;
4104
4105 action_name = g_strdup_printf ("recent-info-%d", count_recent);
4106 display_name = g_strsplit (gtk_recent_info_get_display_name (info), "_", -1);
4107 label_filename = g_strjoinv ("__", display_name);
4108 label = g_strdup_printf ("%s_%d. %s",
4109 (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "\xE2\x80\x8F" : ""), count_recent, label_filename);
4110 g_free (label_filename);
4111 g_strfreev (display_name);
4112
4113 tip = gtk_recent_info_get_uri_display (info);
4114
4115 /* This is a workaround for a bug (#351945) regarding
4116 * gtk_recent_info_get_uri_display() and remote URIs.
4117 * mate_vfs_format_uri_for_display is sufficient here
4118 * since the password gets stripped when adding the
4119 * file to the recently used list. */
4120 if (tip == NULL((void*)0))
4121 tip = g_uri_unescape_string (gtk_recent_info_get_uri (info), NULL((void*)0));
4122
4123 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4124 action = gtk_action_new (action_name, label, tip, NULL((void*)0));
4125 gtk_action_set_always_show_image (action, TRUE(!(0)));
4126 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4127
4128 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info",
4129 gtk_recent_info_ref (info),
4130 (GDestroyNotify) gtk_recent_info_unref);
4131
4132 g_object_set (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "icon-name", "image-x-generic", NULL((void*)0));
4133
4134 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4135 G_CALLBACK (eom_window_open_recent_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4136 window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4137
4138 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4139 gtk_action_group_add_action (priv->actions_recent, action);
4140 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4141
4142 g_object_unref (action);
4143
4144 gtk_ui_manager_add_ui (priv->ui_mgr, priv->recent_menu_id,
4145 "/MainMenu/Image/RecentDocuments",
4146 action_name, action_name,
4147 GTK_UI_MANAGER_AUTO, FALSE(0));
4148
4149 g_free (action_name);
4150 g_free (label);
4151 g_free (tip);
4152 }
4153
4154 g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
4155}
4156
4157static void
4158eom_window_recent_manager_changed_cb (GtkRecentManager *manager, EomWindow *window)
4159{
4160 eom_window_update_recent_files_menu (window);
4161}
4162
4163static void
4164eom_window_drag_data_received (GtkWidget *widget,
4165 GdkDragContext *context,
4166 gint x, gint y,
4167 GtkSelectionData *selection_data,
4168 guint info, guint time)
4169{
4170 GSList *file_list;
4171 EomWindow *window;
4172 GdkAtom target;
4173 GtkWidget *src;
4174
4175 target = gtk_selection_data_get_target (selection_data);
4176
4177 if (!gtk_targets_include_uri (&target, 1))
4178 return;
4179
4180 /* if the request is from another process this will return NULL */
4181 src = gtk_drag_get_source_widget (context);
4182
4183 /* if the drag request originates from the current eom instance, ignore
4184 the request if the source window is the same as the dest window */
4185 if (src &&
4186 gtk_widget_get_toplevel (src) == gtk_widget_get_toplevel (widget))
4187 {
4188 gdk_drag_status (context, 0, time);
4189 return;
4190 }
4191
4192 if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_COPY) {
4193 window = EOM_WINDOW (widget)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))
;
4194
4195 file_list = eom_util_parse_uri_string_list_to_file_list ((const gchar *) gtk_selection_data_get_data (selection_data));
4196
4197 eom_window_open_file_list (window, file_list);
4198 }
4199}
4200
4201static void
4202eom_window_set_drag_dest (EomWindow *window)
4203{
4204 gtk_drag_dest_set (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
4205 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
4206 NULL((void*)0), 0,
4207 GDK_ACTION_COPY | GDK_ACTION_ASK);
4208 gtk_drag_dest_add_uri_targets (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
4209}
4210
4211static void
4212eom_window_sidebar_visibility_changed (GtkWidget *widget, EomWindow *window)
4213{
4214 GtkAction *action;
4215 gboolean visible;
4216
4217 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4218 visible = gtk_widget_get_visible (window->priv->sidebar);
4219
4220 action = gtk_action_group_get_action (window->priv->actions_window,
4221 "ViewSidebar");
4222
4223 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
) != visible)
4224 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
4225 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4226
4227 /* Focus the image */
4228 if (!visible && window->priv->image != NULL((void*)0))
4229 gtk_widget_grab_focus (window->priv->view);
4230}
4231
4232static void
4233eom_window_sidebar_page_added (EomSidebar *sidebar,
4234 GtkWidget *main_widget,
4235 EomWindow *window)
4236{
4237 if (eom_sidebar_get_n_pages (sidebar) == 1) {
4238 GtkAction *action;
4239 gboolean show;
4240
4241 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4242 action = gtk_action_group_get_action (window->priv->actions_window,
4243 "ViewSidebar");
4244
4245 gtk_action_set_sensitive (action, TRUE(!(0)));
4246
4247 show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
4248 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4249
4250 if (show)
4251 gtk_widget_show (GTK_WIDGET (sidebar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidebar)), ((gtk_widget_get_type ()))))))
);
4252 }
4253}
4254static void
4255eom_window_sidebar_page_removed (EomSidebar *sidebar,
4256 GtkWidget *main_widget,
4257 EomWindow *window)
4258{
4259 if (eom_sidebar_is_empty (sidebar)) {
4260 GtkAction *action;
4261
4262 gtk_widget_hide (GTK_WIDGET (sidebar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidebar)), ((gtk_widget_get_type ()))))))
);
4263
4264 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4265 action = gtk_action_group_get_action (window->priv->actions_window,
4266 "ViewSidebar");
4267
4268 gtk_action_set_sensitive (action, FALSE(0));
4269 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4270 }
4271}
4272
4273static void
4274eom_window_finish_saving (EomWindow *window)
4275{
4276 EomWindowPrivate *priv = window->priv;
4277
4278 gtk_widget_set_sensitive (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FALSE(0));
4279
4280 do {
4281 gtk_main_iteration ();
4282 } while (priv->save_job != NULL((void*)0));
4283}
4284
4285static GAppInfo *
4286get_appinfo_for_editor (EomWindow *window)
4287{
4288 /* We want this function to always return the same thing, not
4289 * just for performance reasons, but because if someone edits
4290 * GConf while eom is running, the application could get into an
4291 * inconsistent state. If the editor exists once, it gets added
4292 * to the "available" list of the EggToolbarsModel (for which
4293 * there is no API to remove it). If later the editor no longer
4294 * existed when constructing a new window, we'd be unable to
4295 * construct a GtkAction for the editor for that window, causing
4296 * assertion failures when viewing the "Edit Toolbars" dialog
4297 * (item is available, but can't find the GtkAction for it).
4298 *
4299 * By ensuring we keep the GAppInfo around, we avoid the
4300 * possibility of that situation occurring.
4301 */
4302 static GDesktopAppInfo *app_info = NULL((void*)0);
4303 static gboolean initialised;
4304
4305 if (!initialised) {
4306 gchar *editor;
4307
4308 editor = g_settings_get_string (window->priv->ui_settings,
4309 EOM_CONF_UI_EXTERNAL_EDITOR"external-editor");
4310
4311 if (editor != NULL((void*)0)) {
4312 app_info = g_desktop_app_info_new (editor);
4313 }
4314
4315 initialised = TRUE(!(0));
4316 g_free (editor);
4317 }
4318
4319 return (GAppInfo *) app_info;
4320}
4321
4322static void
4323eom_window_open_editor (GtkAction *action,
4324 EomWindow *window)
4325{
4326 GdkAppLaunchContext *context;
4327 GAppInfo *app_info;
4328 GList *files = NULL((void*)0);
4329 GFile *file;
4330
4331 app_info = get_appinfo_for_editor (window);
4332
4333 if (app_info == NULL((void*)0))
4334 return;
4335
4336 context = gdk_display_get_app_launch_context (
4337 gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
4338 gdk_app_launch_context_set_screen (context,
4339 gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
4340 gdk_app_launch_context_set_icon (context,
4341 g_app_info_get_icon (app_info));
4342 gdk_app_launch_context_set_timestamp (context,
4343 gtk_get_current_event_time ());
4344
4345 file = eom_image_get_file (window->priv->image);
4346 files = g_list_append (files, file);
4347
4348 g_app_info_launch (app_info, files,
4349 G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, NULL((void*)0));
4350
4351 g_list_free (files);
4352 g_object_unref (file);
4353 g_object_unref (context);
4354}
4355
4356static void
4357eom_window_add_open_editor_action (EomWindow *window)
4358{
4359 EggToolbarsModel *model;
4360 GAppInfo *app_info;
4361 GtkAction *action;
4362 gchar *tooltip;
4363
4364 app_info = get_appinfo_for_editor (window);
4365
4366 if (app_info == NULL((void*)0))
4367 return;
4368
4369 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
4370 egg_toolbars_model_set_name_flags (model, "OpenEditor",
4371 EGG_TB_MODEL_NAME_KNOWN);
4372
4373 tooltip = g_strdup_printf (_("Edit the current image using %s")gettext ("Edit the current image using %s"),
4374 g_app_info_get_name (app_info));
4375 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4376 action = gtk_action_new ("OpenEditor", _("Edit Image")gettext ("Edit Image"), tooltip, NULL((void*)0));
4377 gtk_action_set_gicon (action, g_app_info_get_icon (app_info));
4378 gtk_action_set_is_important (action, TRUE(!(0)));
4379
4380 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
4381 G_CALLBACK (eom_window_open_editor),g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
4382 window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
;
4383
4384 gtk_action_group_add_action (window->priv->actions_image, action);
4385 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4386
4387 g_object_unref (action);
4388 g_free (tooltip);
4389}
4390
4391static void
4392eom_window_construct_ui (EomWindow *window)
4393{
4394 EomWindowPrivate *priv;
4395
4396 GError *error = NULL((void*)0);
4397
4398 GtkWidget *menubar;
4399 GtkWidget *thumb_popup;
4400 GtkWidget *view_popup;
4401 GtkWidget *hpaned;
4402 GtkWidget *menuitem;
4403
4404 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)
;
4405
4406 priv = window->priv;
4407
4408 priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4409 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, priv->box);
4410 gtk_widget_show (priv->box);
4411
4412 priv->ui_mgr = gtk_ui_manager_new ();
4413
4414 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4415 priv->actions_window = gtk_action_group_new ("MenuActionsWindow");
4416
4417#ifdef ENABLE_NLS1
4418 gtk_action_group_set_translation_domain (priv->actions_window,
4419 GETTEXT_PACKAGE"eom");
4420#endif /* ENABLE_NLS */
4421
4422 gtk_action_group_add_actions (priv->actions_window,
4423 action_entries_window,
4424 G_N_ELEMENTS (action_entries_window)(sizeof (action_entries_window) / sizeof ((action_entries_window
)[0]))
,
4425 window);
4426
4427 gtk_action_group_add_toggle_actions (priv->actions_window,
4428 toggle_entries_window,
4429 G_N_ELEMENTS (toggle_entries_window)(sizeof (toggle_entries_window) / sizeof ((toggle_entries_window
)[0]))
,
4430 window);
4431 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4432
4433 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_window, 0);
4434
4435 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4436 priv->actions_image = gtk_action_group_new ("MenuActionsImage");
4437#ifdef ENABLE_NLS1
4438 gtk_action_group_set_translation_domain (priv->actions_image,
4439 GETTEXT_PACKAGE"eom");
4440#endif /* ENABLE_NLS */
4441
4442 gtk_action_group_add_actions (priv->actions_image,
4443 action_entries_image,
4444 G_N_ELEMENTS (action_entries_image)(sizeof (action_entries_image) / sizeof ((action_entries_image
)[0]))
,
4445 window);
4446
4447 eom_window_add_open_editor_action (window);
4448
4449 gtk_action_group_add_toggle_actions (priv->actions_image,
4450 toggle_entries_image,
4451 G_N_ELEMENTS (toggle_entries_image)(sizeof (toggle_entries_image) / sizeof ((toggle_entries_image
)[0]))
,
4452 window);
4453 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4454
4455 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_image, 0);
4456
4457 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4458 priv->actions_collection = gtk_action_group_new ("MenuActionsCollection");
4459#ifdef ENABLE_NLS1
4460 gtk_action_group_set_translation_domain (priv->actions_collection,
4461 GETTEXT_PACKAGE"eom");
4462#endif /* ENABLE_NLS */
4463
4464 gtk_action_group_add_actions (priv->actions_collection,
4465 action_entries_collection,
4466 G_N_ELEMENTS (action_entries_collection)(sizeof (action_entries_collection) / sizeof ((action_entries_collection
)[0]))
,
4467 window);
4468
4469 gtk_action_group_add_toggle_actions (priv->actions_collection,
4470 toggle_entries_collection,
4471 G_N_ELEMENTS (toggle_entries_collection)(sizeof (toggle_entries_collection) / sizeof ((toggle_entries_collection
)[0]))
,
4472 window);
4473 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4474
4475 set_action_properties (priv->actions_window,
4476 priv->actions_image,
4477 priv->actions_collection);
4478
4479 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_collection, 0);
4480
4481 if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
4482 "/org/mate/eom/ui/eom-ui.xml",
4483 &error)) {
4484 g_warning ("building menus failed: %s", error->message);
4485 g_error_free (error);
4486 }
4487
4488 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)
4489 G_CALLBACK (connect_proxy_cb),g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4490 window)g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4491
4492 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)
4493 G_CALLBACK (disconnect_proxy_cb),g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
4494 window)g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
4495
4496 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
4497 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", 4497, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
4498 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
, menubar, FALSE(0), FALSE(0), 0);
4499 gtk_widget_show (menubar);
4500
4501 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4502 "/MainMenu/Edit/EditFlipHorizontal");
4503 gtk_image_menu_item_set_always_show_image (
4504 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4505
4506 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4507 "/MainMenu/Edit/EditFlipVertical");
4508 gtk_image_menu_item_set_always_show_image (
4509 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4510
4511 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4512 "/MainMenu/Edit/EditRotate90");
4513 gtk_image_menu_item_set_always_show_image (
4514 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4515
4516 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4517 "/MainMenu/Edit/EditRotate270");
4518 gtk_image_menu_item_set_always_show_image (
4519 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4520
4521 priv->toolbar = GTK_WIDGET((((GtkWidget*) (void *) 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 (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,((((GtkWidget*) (void *) 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 "ui-manager", priv->ui_mgr,((((GtkWidget*) (void *) 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 "popup-path", "/ToolbarPopup",((((GtkWidget*) (void *) 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 "model", eom_application_get_toolbars_model (EOM_APP),((((GtkWidget*) (void *) 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
()))))))
4526 NULL))((((GtkWidget*) (void *) 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
()))))))
;
4527
4528 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (priv->toolbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->toolbar)), ((gtk_widget_get_type ()))))))
),
4529 GTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar");
4530
4531 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
,
4532 "Toolbar");
4533
4534 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
,
4535 priv->toolbar,
4536 FALSE(0),
4537 FALSE(0),
4538 0);
4539
4540 gtk_widget_show (priv->toolbar);
4541
4542 gtk_window_add_accel_group (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4543 gtk_ui_manager_get_accel_group (priv->ui_mgr));
4544
4545 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4546 priv->actions_recent = gtk_action_group_new ("RecentFilesActions");
4547#ifdef ENABLE_NLS1
4548 gtk_action_group_set_translation_domain (priv->actions_recent,
4549 GETTEXT_PACKAGE"eom");
4550#endif /* ENABLE_NLS */
4551 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4552
4553 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)
4554 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)
4555 window)g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4556
4557 eom_window_update_recent_files_menu (window);
4558
4559 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_recent, 0);
4560
4561 priv->cbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4562 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
, priv->cbox, TRUE(!(0)), TRUE(!(0)), 0);
4563 gtk_widget_show (priv->cbox);
4564
4565 priv->statusbar = eom_statusbar_new ();
4566 gtk_box_pack_end (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
,
4567 GTK_WIDGET (priv->statusbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_widget_get_type ()))))))
,
4568 FALSE(0), FALSE(0), 0);
4569 gtk_widget_show (priv->statusbar);
4570
4571 priv->image_info_message_cid =
4572 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4573 "image_info_message");
4574 priv->tip_message_cid =
4575 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4576 "tip_message");
4577
4578 priv->layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
4579
4580 hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
4581
4582 priv->sidebar = eom_sidebar_new ();
4583 /* The sidebar shouldn't be shown automatically on show_all(),
4584 but only when the user actually wants it. */
4585 gtk_widget_set_no_show_all (priv->sidebar, TRUE(!(0)));
4586
4587 gtk_widget_set_size_request (priv->sidebar, 210, -1);
4588
4589 g_signal_connect_after (priv->sidebar, "show",g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4590 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)
4591 window)g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4592
4593 g_signal_connect_after (priv->sidebar, "hide",g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4594 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)
4595 window)g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4596
4597 g_signal_connect_after (priv->sidebar, "page-added",g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4598 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)
4599 window)g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4600
4601 g_signal_connect_after (priv->sidebar, "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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((gtk_widget_get_type ()))))))
, 100, 100);
4612 g_signal_connect (priv->view, "zoom_changed",g_signal_connect_data ((priv->view), ("zoom_changed"), (((
GCallback) (view_zoom_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4613 G_CALLBACK (view_zoom_changed_cb),g_signal_connect_data ((priv->view), ("zoom_changed"), (((
GCallback) (view_zoom_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4614 window)g_signal_connect_data ((priv->view), ("zoom_changed"), (((
GCallback) (view_zoom_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4615
4616 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_SCROLL_WHEEL_ZOOM"scroll-wheel-zoom",
4617 priv->view, "scrollwheel-zoom", G_SETTINGS_BIND_GET);
4618 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_ZOOM_MULTIPLIER"zoom-multiplier",
4619 priv->view, "zoom-multiplier", G_SETTINGS_BIND_GET);
4620
4621 view_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ViewPopup");
4622 eom_scroll_view_set_popup (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
4623 GTK_MENU (view_popup)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view_popup)), ((gtk_menu_get_type ()))))))
);
4624
4625 gtk_paned_pack1 (GTK_PANED (hpaned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hpaned)), ((gtk_paned_get_type ()))))))
,
4626 priv->sidebar,
4627 FALSE(0),
4628 FALSE(0));
4629
4630 gtk_paned_pack2 (GTK_PANED (hpaned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hpaned)), ((gtk_paned_get_type ()))))))
,
4631 priv->view,
4632 TRUE(!(0)),
4633 FALSE(0));
4634
4635 gtk_widget_show_all (hpaned);
4636
4637 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
4638
4639 priv->thumbview = g_object_ref (eom_thumb_view_new ())((__typeof__ (eom_thumb_view_new ())) (g_object_ref) (eom_thumb_view_new
()))
;
4640
4641 /* giving shape to the view */
4642 gtk_icon_view_set_margin (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 4);
4643 gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 0);
4644
4645 g_signal_connect (priv->thumbview, "selection_changed",g_signal_connect_data ((priv->thumbview), ("selection_changed"
), (((GCallback) (handle_image_selection_changed_cb))), (window
), ((void*)0), (GConnectFlags) 0)
4646 G_CALLBACK (handle_image_selection_changed_cb),g_signal_connect_data ((priv->thumbview), ("selection_changed"
), (((GCallback) (handle_image_selection_changed_cb))), (window
), ((void*)0), (GConnectFlags) 0)
4647 window)g_signal_connect_data ((priv->thumbview), ("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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
4660 GTK_MENU (thumb_popup)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((thumb_popup)), ((gtk_menu_get_type ()))))))
);
4661
4662 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) (void *) 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*) (void *) 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#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4692 GdkScreen *screen;
4693#endif
4694 EomWindowPrivate *priv;
4695
4696 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 4696, ((const char*) (__func__
))
);
4697
4698 GtkStyleContext *context;
4699
4700 context = gtk_widget_get_style_context (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
4701 gtk_style_context_add_class (context, "eom-window");
4702
4703 hints.min_width = EOM_WINDOW_MIN_WIDTH440;
4704 hints.min_height = EOM_WINDOW_MIN_HEIGHT350;
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, "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)
4714 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)
4715 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)
;
4716
4717 window->priv->store = NULL((void*)0);
4718 window->priv->image = NULL((void*)0);
4719
4720 window->priv->fullscreen_popup = NULL((void*)0);
4721 window->priv->fullscreen_timeout_source = NULL((void*)0);
4722 window->priv->slideshow_random = FALSE(0);
4723 window->priv->slideshow_loop = FALSE(0);
4724 window->priv->slideshow_switch_timeout = 0;
4725 window->priv->slideshow_switch_source = NULL((void*)0);
4726 window->priv->fullscreen_idle_inhibit_cookie = 0;
4727
4728 gtk_window_set_geometry_hints (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4729 GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
4730 &hints,
4731 GDK_HINT_MIN_SIZE);
4732
4733 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4734 EOM_WINDOW_DEFAULT_WIDTH540,
4735 EOM_WINDOW_DEFAULT_HEIGHT450);
4736
4737 gtk_window_set_position (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER);
4738
4739 window->priv->mode = EOM_WINDOW_MODE_UNKNOWN;
4740 window->priv->status = EOM_WINDOW_STATUS_UNKNOWN;
4741
4742#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4743 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, GTK_APPLICATION (EOM_APP)((((GtkApplication*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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), (handle_image_selection_changed_cb), (window
))
4792 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), (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), (handle_image_selection_changed_cb), (window
))
;
4794 g_clear_object (&priv->thumbview)do { _Static_assert (sizeof *((&priv->thumbview)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->thumbview))) _pp = ((&priv->thumbview));
__typeof__ (*((&priv->thumbview))) _ptr = *_pp; *_pp =
((void*)0); if (_ptr) (g_object_unref) (_ptr); } 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), (eom_window_recent_manager_changed_cb), (
window))
4855 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), (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), (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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_FULLSCREEN || EOM_WINDOW (widget)((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))
, FALSE(0));
4970 } else if (EOM_WINDOW (widget)((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_window_get_type ()))))))
->priv;
5233
5234 eom_window_construct_ui (EOM_WINDOW (object)((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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),g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
5245 object)g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
;
5246 g_signal_connect (priv->extensions, "extension-removed",g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
5247 G_CALLBACK (on_extension_removed),g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
5248 object)g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
;
5249
5250 return object;
5251}
5252
5253static void
5254eom_window_class_init (EomWindowClass *class)
5255{
5256 GObjectClass *g_object_class = (GObjectClass *) class;
5257 GtkWidgetClass *widget_class = (GtkWidgetClass *) class;
5258
5259 g_object_class->constructor = eom_window_constructor;
5260 g_object_class->dispose = eom_window_dispose;
5261 g_object_class->set_property = eom_window_set_property;
5262 g_object_class->get_property = eom_window_get_property;
5263
5264 widget_class->delete_event = eom_window_delete;
5265 widget_class->key_press_event = eom_window_key_press;
5266 widget_class->button_press_event = eom_window_button_press;
5267 widget_class->drag_data_received = eom_window_drag_data_received;
5268 widget_class->focus_out_event = eom_window_focus_out_event;
5269
5270/**
5271 * EomWindow:collection-position:
5272 *
5273 * Determines the position of the image collection in the window
5274 * relative to the image.
5275 */
5276 g_object_class_install_property (
5277 g_object_class, PROP_COLLECTION_POS,
5278 g_param_spec_enum ("collection-position", NULL((void*)0), NULL((void*)0),
5279 EOM_TYPE_WINDOW_COLLECTION_POS(eom_window_collection_pos_get_type()),
5280 EOM_WINDOW_COLLECTION_POS_BOTTOM,
5281 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5282
5283/**
5284 * EomWindow:collection-resizable:
5285 *
5286 * If %TRUE the collection will be resizable by the user otherwise it will be
5287 * in single column/row mode.
5288 */
5289 g_object_class_install_property (
5290 g_object_class, PROP_COLLECTION_RESIZABLE,
5291 g_param_spec_boolean ("collection-resizable", NULL((void*)0), NULL((void*)0), FALSE(0),
5292 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5293
5294/**
5295 * EomWindow:startup-flags:
5296 *
5297 * A bitwise OR of #EomStartupFlags elements, indicating how the window
5298 * should behave upon creation.
5299 */
5300 g_object_class_install_property (g_object_class,
5301 PROP_STARTUP_FLAGS,
5302 g_param_spec_flags ("startup-flags",
5303 NULL((void*)0),
5304 NULL((void*)0),
5305 EOM_TYPE_STARTUP_FLAGS(eom_startup_flags_get_type()),
5306 0,
5307 G_PARAM_READWRITE |
5308 G_PARAM_CONSTRUCT_ONLY));
5309
5310/**
5311 * EomWindow::prepared:
5312 * @window: the object which received the signal.
5313 *
5314 * The #EomWindow::prepared signal is emitted when the @window is ready
5315 * to be shown.
5316 */
5317 signals [SIGNAL_PREPARED] =
5318 g_signal_new ("prepared",
5319 EOM_TYPE_WINDOW(eom_window_get_type ()),
5320 G_SIGNAL_RUN_LAST,
5321 G_STRUCT_OFFSET (EomWindowClass, prepared)((glong) __builtin_offsetof(EomWindowClass, prepared)),
5322 NULL((void*)0), NULL((void*)0),
5323 g_cclosure_marshal_VOID__VOID,
5324 G_TYPE_NONE((GType) ((1) << (2))), 0);
5325}
5326
5327/**
5328 * eom_window_new:
5329 * @flags: the initialization parameters for the new window.
5330 *
5331 *
5332 * Creates a new and empty #EomWindow. Use @flags to indicate
5333 * if the window should be initialized fullscreen, in slideshow mode,
5334 * and/or without the thumbnails collection visible. See #EomStartupFlags.
5335 *
5336 * Returns: a newly created #EomWindow.
5337 **/
5338GtkWidget*
5339eom_window_new (EomStartupFlags flags)
5340{
5341 EomWindow *window;
5342
5343 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5343, ((const char*) (__func__
))
);
5344
5345 window = EOM_WINDOW (g_object_new (EOM_TYPE_WINDOW,((((EomWindow*) (void *) 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 "type", GTK_WINDOW_TOPLEVEL,((((EomWindow*) (void *) 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 "application", EOM_APP,((((EomWindow*) (void *) 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 "show-menubar", FALSE,((((EomWindow*) (void *) 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 "startup-flags", flags,((((EomWindow*) (void *) 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
()))))))
5350 NULL))((((EomWindow*) (void *) 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
()))))))
;
5351
5352 return GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
5353}
5354
5355static void
5356eom_window_list_store_image_added (GtkTreeModel *tree_model,
5357 GtkTreePath *path,
5358 GtkTreeIter *iter,
5359 gpointer user_data)
5360{
5361 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
5362
5363 update_image_pos (window);
5364 update_action_groups_state (window);
5365}
5366
5367static void
5368eom_window_list_store_image_removed (GtkTreeModel *tree_model,
5369 GtkTreePath *path,
5370 gpointer user_data)
5371{
5372 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
5373
5374 update_image_pos (window);
5375 update_action_groups_state (window);
5376}
5377
5378static void
5379eom_job_model_cb (EomJobModel *job, gpointer data)
5380{
5381 EomWindow *window;
5382 EomWindowPrivate *priv;
5383 gint n_images;
5384
5385 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5385, ((const char*) (__func__
))
);
5386
5387#ifdef HAVE_EXIF1
5388 int i;
5389 EomImage *image;
5390#endif
5391
5392 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)
;
5393
5394 window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
5395 priv = window->priv;
5396
5397 if (priv->store != NULL((void*)0)) {
5398 g_object_unref (priv->store);
5399 priv->store = NULL((void*)0);
5400 }
5401
5402 priv->store = g_object_ref (job->store)((__typeof__ (job->store)) (g_object_ref) (job->store));
5403
5404 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
5405
5406#ifdef HAVE_EXIF1
5407 if (g_settings_get_boolean (priv->view_settings, EOM_CONF_VIEW_AUTOROTATE"autorotate")) {
5408 for (i = 0; i < n_images; i++) {
5409 image = eom_list_store_get_image_by_pos (priv->store, i);
5410 eom_image_autorotate (image);
5411 g_object_unref (image);
5412 }
5413 }
5414#endif
5415
5416 eom_thumb_view_set_model (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
, priv->store);
5417
5418 g_signal_connect (priv->store, "row-inserted",g_signal_connect_data ((priv->store), ("row-inserted"), ((
(GCallback) (eom_window_list_store_image_added))), (window), (
(void*)0), (GConnectFlags) 0)
5419 G_CALLBACK (eom_window_list_store_image_added),g_signal_connect_data ((priv->store), ("row-inserted"), ((
(GCallback) (eom_window_list_store_image_added))), (window), (
(void*)0), (GConnectFlags) 0)
5420 window)g_signal_connect_data ((priv->store), ("row-inserted"), ((
(GCallback) (eom_window_list_store_image_added))), (window), (
(void*)0), (GConnectFlags) 0)
;
5421
5422 g_signal_connect (priv->store, "row-deleted",g_signal_connect_data ((priv->store), ("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 ((priv->store), ("row-deleted"), (((
GCallback) (eom_window_list_store_image_removed))), (window),
((void*)0), (GConnectFlags) 0)
5424 window)g_signal_connect_data ((priv->store), ("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, "finished",g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5477 G_CALLBACK (eom_job_model_cb),g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5478 window)g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5479
5480 eom_job_queue_add_job (job);
5481 g_object_unref (job);
5482}
5483
5484/**
5485 * eom_window_get_ui_manager:
5486 * @window: An #EomWindow.
5487 *
5488 * Gets the #GtkUIManager that describes the UI of @window.
5489 *
5490 * Returns: (transfer none): A #GtkUIManager.
5491 **/
5492GtkUIManager *
5493eom_window_get_ui_manager (EomWindow *window)
5494{
5495 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)
;
5496
5497 return window->priv->ui_mgr;
5498}
5499
5500/**
5501 * eom_window_get_mode:
5502 * @window: An #EomWindow.
5503 *
5504 * Gets the mode of @window. See #EomWindowMode for details.
5505 *
5506 * Returns: An #EomWindowMode.
5507 **/
5508EomWindowMode
5509eom_window_get_mode (EomWindow *window)
5510{
5511 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)
;
5512
5513 return window->priv->mode;
5514}
5515
5516/**
5517 * eom_window_set_mode:
5518 * @window: an #EomWindow.
5519 * @mode: an #EomWindowMode value.
5520 *
5521 * Changes the mode of @window to normal, fullscreen, or slideshow.
5522 * See #EomWindowMode for details.
5523 **/
5524void
5525eom_window_set_mode (EomWindow *window, EomWindowMode mode)
5526{
5527 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)
;
5528
5529 if (window->priv->mode == mode)
5530 return;
5531
5532 switch (mode) {
5533 case EOM_WINDOW_MODE_NORMAL:
5534 eom_window_stop_fullscreen (window,
5535 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
5536 break;
5537 case EOM_WINDOW_MODE_FULLSCREEN:
5538 eom_window_run_fullscreen (window, FALSE(0));
5539 break;
5540 case EOM_WINDOW_MODE_SLIDESHOW:
5541 eom_window_run_fullscreen (window, TRUE(!(0)));
5542 break;
5543 case EOM_WINDOW_MODE_UNKNOWN:
5544 break;
5545 }
5546}
5547
5548/**
5549 * eom_window_get_store:
5550 * @window: An #EomWindow.
5551 *
5552 * Gets the #EomListStore that contains the images in the collection
5553 * of @window.
5554 *
5555 * Returns: (transfer none): an #EomListStore.
5556 **/
5557EomListStore *
5558eom_window_get_store (EomWindow *window)
5559{
5560 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)
;
5561
5562 return EOM_LIST_STORE (window->priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), (eom_list_store_get_type())
))))
;
5563}
5564
5565/**
5566 * eom_window_get_view:
5567 * @window: An #EomWindow.
5568 *
5569 * Gets the #EomScrollView in the window.
5570 *
5571 * Returns: (transfer none): the #EomScrollView.
5572 **/
5573GtkWidget *
5574eom_window_get_view (EomWindow *window)
5575{
5576 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)
;
5577
5578 return window->priv->view;
5579}
5580
5581/**
5582 * eom_window_get_sidebar:
5583 * @window: An #EomWindow.
5584 *
5585 * Gets the sidebar widget of @window.
5586 *
5587 * Returns: (transfer none): the #EomSidebar.
5588 **/
5589GtkWidget *
5590eom_window_get_sidebar (EomWindow *window)
5591{
5592 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)
;
5593
5594 return window->priv->sidebar;
5595}
5596
5597/**
5598 * eom_window_get_thumb_view:
5599 * @window: an #EomWindow.
5600 *
5601 * Gets the thumbnails view in @window.
5602 *
5603 * Returns: (transfer none): an #EomThumbView.
5604 **/
5605GtkWidget *
5606eom_window_get_thumb_view (EomWindow *window)
5607{
5608 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)
;
5609
5610 return window->priv->thumbview;
5611}
5612
5613/**
5614 * eom_window_get_thumb_nav:
5615 * @window: an #EomWindow.
5616 *
5617 * Gets the thumbnails navigation pane in @window.
5618 *
5619 * Returns: (transfer none): an #EomThumbNav.
5620 **/
5621GtkWidget *
5622eom_window_get_thumb_nav (EomWindow *window)
5623{
5624 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)
;
5625
5626 return window->priv->nav;
5627}
5628
5629/**
5630 * eom_window_get_statusbar:
5631 * @window: an #EomWindow.
5632 *
5633 * Gets the statusbar in @window.
5634 *
5635 * Returns: (transfer none): a #EomStatusBar.
5636 **/
5637GtkWidget *
5638eom_window_get_statusbar (EomWindow *window)
5639{
5640 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)
;
5641
5642 return window->priv->statusbar;
5643}
5644
5645/**
5646 * eom_window_get_image:
5647 * @window: an #EomWindow.
5648 *
5649 * Gets the image currently displayed in @window or %NULL if
5650 * no image is being displayed.
5651 *
5652 * Returns: (transfer none): an #EomImage.
5653 **/
5654EomImage *
5655eom_window_get_image (EomWindow *window)
5656{
5657 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)
;
5658
5659 return window->priv->image;
5660}
5661
5662/**
5663 * eom_window_is_empty:
5664 * @window: an #EomWindow.
5665 *
5666 * Tells whether @window is currently empty or not.
5667 *
5668 * Returns: %TRUE if @window has no images, %FALSE otherwise.
5669 **/
5670gboolean
5671eom_window_is_empty (EomWindow *window)
5672{
5673 EomWindowPrivate *priv;
5674 gboolean empty = TRUE(!(0));
5675
5676 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5676, ((const char*) (__func__
))
);
5677
5678 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)
;
5679
5680 priv = window->priv;
5681
5682 if (priv->store != NULL((void*)0)) {
5683 empty = (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0);
5684 }
5685
5686 return empty;
5687}
5688
5689void
5690eom_window_reload_image (EomWindow *window)
5691{
5692 GtkWidget *view;
5693
5694 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)
;
5695
5696 if (window->priv->image == NULL((void*)0))
5697 return;
5698
5699 g_object_unref (window->priv->image);
5700 window->priv->image = NULL((void*)0);
5701
5702 view = eom_window_get_view (window);
5703 eom_scroll_view_set_image (EOM_SCROLL_VIEW (view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
5704
5705 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5706 EOM_THUMB_VIEW_SELECT_CURRENT);
5707}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-ebc41c.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-ebc41c.html new file mode 100644 index 0000000..5a256a9 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-ebc41c.html @@ -0,0 +1,1126 @@ + + + +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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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 gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_transform_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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)((__typeof__ (pixbuf)) (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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f15e81.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f15e81.html new file mode 100644 index 0000000..a84011a --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f15e81.html @@ -0,0 +1,1659 @@ + + + +egg-toolbars-model.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name egg-toolbars-model.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/cut-n-paste/toolbar-editor -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I ../.. -I ../../lib/egg -I /usr/include/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -I /usr/include/libxml2 -D CURSOR_DIR="/usr/local/share/eom" -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/cut-n-paste/toolbar-editor -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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/globals.h>
31#include <libxml/parser.h>
32#include <libxml/tree.h>
33#include <gdk/gdk.h>
34
35static void egg_toolbars_model_finalize (GObject *object);
36
37enum
38{
39 ITEM_ADDED,
40 ITEM_REMOVED,
41 TOOLBAR_ADDED,
42 TOOLBAR_CHANGED,
43 TOOLBAR_REMOVED,
44 LAST_SIGNAL
45};
46
47typedef struct
48{
49 char *name;
50 EggTbModelFlags flags;
51} EggToolbarsToolbar;
52
53typedef struct
54{
55 char *name;
56} EggToolbarsItem;
57
58static guint signals[LAST_SIGNAL] = { 0 };
59
60struct EggToolbarsModelPrivate
61{
62 GNode *toolbars;
63 GList *types;
64 GHashTable *flags;
65};
66
67G_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 gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = egg_toolbars_model_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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; }
68
69static xmlDocPtr
70egg_toolbars_model_to_xml (EggToolbarsModel *model)
71{
72 GNode *l1, *l2, *tl;
73 GList *l3;
74 xmlDocPtr doc;
75
76 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)
;
77
78 tl = model->priv->toolbars;
79
80 xmlIndentTreeOutput(*(__xmlIndentTreeOutput())) = TRUE(!(0));
81 doc = xmlNewDoc ((const xmlChar*) "1.0");
82 doc->children = xmlNewDocNode (doc, NULL((void*)0), (const xmlChar*) "toolbars", NULL((void*)0));
83
84 for (l1 = tl->children; l1 != NULL((void*)0); l1 = l1->next)
85 {
86 xmlNodePtr tnode;
87 EggToolbarsToolbar *toolbar = l1->data;
88
89 tnode = xmlNewChild (doc->children, NULL((void*)0), (const xmlChar*) "toolbar", NULL((void*)0));
90 xmlSetProp (tnode, (const xmlChar*) "name", (const xmlChar*) toolbar->name);
91 xmlSetProp (tnode, (const xmlChar*) "hidden",
92 (toolbar->flags&EGG_TB_MODEL_HIDDEN) ? (const xmlChar*) "true" : (const xmlChar*) "false");
93 xmlSetProp (tnode, (const xmlChar*) "editable",
94 (toolbar->flags&EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar*) "false" : (const xmlChar*) "true");
95
96 for (l2 = l1->children; l2 != NULL((void*)0); l2 = l2->next)
97 {
98 xmlNodePtr node;
99 EggToolbarsItem *item = l2->data;
100
101 if (strcmp (item->name, "_separator") == 0)
102 {
103 node = xmlNewChild (tnode, NULL((void*)0), (const xmlChar*) "separator", NULL((void*)0));
Value stored to 'node' is never read
104 continue;
105 }
106
107 node = xmlNewChild (tnode, NULL((void*)0), (const xmlChar*) "toolitem", NULL((void*)0));
108 xmlSetProp (node, (const xmlChar*) "name", (const xmlChar*) item->name);
109
110 /* Add 'data' nodes for each data type which can be written out for this
111 * item. Only write types which can be used to restore the data. */
112 for (l3 = model->priv->types; l3 != NULL((void*)0); l3 = l3->next)
113 {
114 EggToolbarsItemType *type = l3->data;
115 if (type->get_name != NULL((void*)0) && type->get_data != NULL((void*)0))
116 {
117 xmlNodePtr dnode;
118 char *tmp;
119
120 tmp = type->get_data (type, item->name);
121 if (tmp != NULL((void*)0))
122 {
123 dnode = xmlNewTextChild (node, NULL((void*)0), (const xmlChar*) "data", (const xmlChar*) tmp);
124 g_free (tmp);
125
126 tmp = gdk_atom_name (type->type);
127 xmlSetProp (dnode, (const xmlChar*) "type", (const xmlChar*) tmp);
128 g_free (tmp);
129 }
130 }
131 }
132 }
133 }
134
135 return doc;
136}
137
138static gboolean
139safe_save_xml (const char *xml_file, xmlDocPtr doc)
140{
141 char *tmp_file;
142 char *old_file;
143 gboolean old_exist;
144 gboolean retval = TRUE(!(0));
145
146 tmp_file = g_strconcat (xml_file, ".tmp", NULL((void*)0));
147 old_file = g_strconcat (xml_file, ".old", NULL((void*)0));
148
149 if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
150 {
151 g_warning ("Failed to write XML data to %s", tmp_file);
152 goto failed;
153 }
154
155 old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
156
157 if (old_exist)
158 {
159 if (rename (xml_file, old_file) < 0)
160 {
161 g_warning ("Failed to rename %s to %s", xml_file, old_file);
162 retval = FALSE(0);
163 goto failed;
164 }
165 }
166
167 if (rename (tmp_file, xml_file) < 0)
168 {
169 g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
170
171 if (rename (old_file, xml_file) < 0)
172 {
173 g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
174 }
175 retval = FALSE(0);
176 goto failed;
177 }
178
179 if (old_exist)
180 {
181 if (unlink (old_file) < 0)
182 {
183 g_warning ("Failed to delete old file %s", old_file);
184 }
185 }
186
187 failed:
188 g_free (old_file);
189 g_free (tmp_file);
190
191 return retval;
192}
193
194void
195egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
196 const char *xml_file,
197 const char *version)
198{
199 xmlDocPtr doc;
200 xmlNodePtr root;
201
202 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)
;
203
204 doc = egg_toolbars_model_to_xml (model);
205 root = xmlDocGetRootElement (doc);
206 xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) version);
207 safe_save_xml (xml_file, doc);
208 xmlFreeDoc (doc);
209}
210
211static gboolean
212is_unique (EggToolbarsModel *model,
213 EggToolbarsItem *idata)
214{
215 EggToolbarsItem *idata2;
216 GNode *toolbar, *item;
217
218 for(toolbar = g_node_first_child (model->priv->toolbars)((model->priv->toolbars) ? ((GNode*) (model->priv->
toolbars))->children : ((void*)0))
;
219 toolbar != NULL((void*)0); toolbar = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0)))
220 {
221 for(item = g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0));
222 item != NULL((void*)0); item = g_node_next_sibling (item)((item) ? ((GNode*) (item))->next : ((void*)0)))
223 {
224 idata2 = item->data;
225
226 if (idata != idata2 && strcmp (idata->name, idata2->name) == 0)
227 {
228 return FALSE(0);
229 }
230 }
231 }
232
233 return TRUE(!(0));
234}
235
236static GNode *
237toolbar_node_new (const char *name)
238{
239 EggToolbarsToolbar *toolbar;
240
241 toolbar = g_new (EggToolbarsToolbar, 1)((EggToolbarsToolbar *) g_malloc_n ((1), sizeof (EggToolbarsToolbar
)))
;
242 toolbar->name = g_strdup (name)g_strdup_inline (name);
243 toolbar->flags = 0;
244
245 return g_node_new (toolbar);
246}
247
248static GNode *
249item_node_new (const char *name, EggToolbarsModel *model)
250{
251 EggToolbarsItem *item;
252 int flags;
253
254 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)
;
255
256 item = g_new (EggToolbarsItem, 1)((EggToolbarsItem *) g_malloc_n ((1), sizeof (EggToolbarsItem
)))
;
257 item->name = g_strdup (name)g_strdup_inline (name);
258
259 flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, item->name)))
;
260 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
261 g_hash_table_insert (model->priv->flags,
262 g_strdup (item->name)g_strdup_inline (item->name),
263 GINT_TO_POINTER (flags | EGG_TB_MODEL_NAME_USED)((gpointer) (glong) (flags | EGG_TB_MODEL_NAME_USED)));
264
265 return g_node_new (item);
266}
267
268static void
269item_node_free (GNode *item_node, EggToolbarsModel *model)
270{
271 EggToolbarsItem *item = item_node->data;
272 int flags;
273
274 flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, item->name)))
;
275 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0 && is_unique (model, item))
276 g_hash_table_insert (model->priv->flags,
277 g_strdup (item->name)g_strdup_inline (item->name),
278 GINT_TO_POINTER (flags & ~EGG_TB_MODEL_NAME_USED)((gpointer) (glong) (flags & ~EGG_TB_MODEL_NAME_USED)));
279
280 g_free (item->name);
281 g_free (item);
282
283 g_node_destroy (item_node);
284}
285
286static void
287toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
288{
289 EggToolbarsToolbar *toolbar = toolbar_node->data;
290
291 g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
292 (GNodeForeachFunc) item_node_free, model);
293
294 g_free (toolbar->name);
295 g_free (toolbar);
296
297 g_node_destroy (toolbar_node);
298}
299
300EggTbModelFlags
301egg_toolbars_model_get_flags (EggToolbarsModel *model,
302 int toolbar_position)
303{
304 GNode *toolbar_node;
305 EggToolbarsToolbar *toolbar;
306
307 toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
308 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)
;
309
310 toolbar = toolbar_node->data;
311
312 return toolbar->flags;
313}
314
315void
316egg_toolbars_model_set_flags (EggToolbarsModel *model,
317 int toolbar_position,
318 EggTbModelFlags flags)
319{
320 GNode *toolbar_node;
321 EggToolbarsToolbar *toolbar;
322
323 toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
324 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)
;
325
326 toolbar = toolbar_node->data;
327
328 toolbar->flags = flags;
329
330 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_CHANGED],
331 0, toolbar_position);
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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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)g_strdup_inline (name), GINT_TO_POINTER (flags)((gpointer) (glong) (flags)));
979}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f46d8d.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f46d8d.html new file mode 100644 index 0000000..c22cda7 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f46d8d.html @@ -0,0 +1,864 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

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

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -I ../cut-n-paste/toolbar-editor -I /usr/include/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -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 -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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
49static EomStartupFlags flags;
50
51static gboolean fullscreen = FALSE(0);
52static gboolean slide_show = FALSE(0);
53static gboolean disable_collection = FALSE(0);
54static gboolean force_new_instance = FALSE(0);
55static gchar **startup_files = NULL((void*)0);
56
57static gboolean
58_print_version_and_exit (const gchar *option_name,
59 const gchar *value,
60 gpointer data,
61 GError **error)
62{
63 g_print("%s %s\n", _("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"), VERSION"1.28.0");
64 exit (EXIT_SUCCESS0);
65 return TRUE(!(0));
This statement is never executed
66}
67
68static const GOptionEntry goption_options[] =
69{
70 { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen, N_("Open in fullscreen mode")("Open in fullscreen mode"), NULL((void*)0) },
71 { "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection")("Disable image collection"), NULL((void*)0) },
72 { "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode")("Open in slideshow mode"), NULL((void*)0) },
73 { "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) },
74 { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
75 _print_version_and_exit, N_("Show the application's version")("Show the application's version"), NULL((void*)0)},
76 { NULL((void*)0) }
77};
78
79static void
80set_startup_flags (void)
81{
82 if (fullscreen)
83 flags |= EOM_STARTUP_FULLSCREEN;
84
85 if (disable_collection)
86 flags |= EOM_STARTUP_DISABLE_COLLECTION;
87
88 if (slide_show)
89 flags |= EOM_STARTUP_SLIDE_SHOW;
90}
91
92int
93main (int argc, char **argv)
94{
95 GError *error = NULL((void*)0);
96 GOptionContext *ctx;
97 GFile *css_file;
98 GtkCssProvider *provider;
99
100#ifdef ENABLE_NLS1
101 bindtextdomain (GETTEXT_PACKAGE"eom", EOM_LOCALE_DIR"/usr/local/share/locale");
102 bind_textdomain_codeset (GETTEXT_PACKAGE"eom", "UTF-8");
103 textdomain (GETTEXT_PACKAGE"eom");
104#endif /* ENABLE_NLS */
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 set_startup_flags ();
134
135#ifdef HAVE_EXEMPI1
136 xmp_init();
137#endif
138 eom_debug_init ();
139 eom_job_queue_init ();
140 eom_thumbnail_init ();
141
142 /* Load special style properties for EomThumbView's scrollbar */
143 css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
144 provider = gtk_css_provider_new ();
145 if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
146 css_file,(!gtk_css_provider_load_from_file(provider, css_file, &error
))
147 &error))(!gtk_css_provider_load_from_file(provider, css_file, &error
))
)
148 {
149 g_critical ("Could not load CSS data: %s", error->message);
150 g_clear_error (&error);
151 } else {
152 gtk_style_context_add_provider_for_screen (
153 gdk_screen_get_default(),
154 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
155 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
156 }
157 g_object_unref (provider);
158 g_object_unref (css_file);
159
160 /* Add application specific icons to search path */
161 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
162 EOM_DATA_DIR"/usr/local/share/eom" G_DIR_SEPARATOR_S"/" "icons");
163
164 gtk_window_set_default_icon_name ("eom");
165 g_set_application_name (_("Eye of MATE Image Viewer")gettext ("Eye of MATE Image Viewer"));
166
167 EOM_APP(eom_application_get_instance ())->priv->flags = flags;
168 if (force_new_instance) {
169 GApplicationFlags app_flags = g_application_get_flags (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
);
170 app_flags |= G_APPLICATION_NON_UNIQUE;
171 g_application_set_flags (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, app_flags);
172 }
173
174 g_application_run (G_APPLICATION (EOM_APP)((((GApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((g_application_get_type
()))))))
, argc, argv);
175 g_object_unref (EOM_APP(eom_application_get_instance ()));
176
177 if (startup_files)
178 g_strfreev (startup_files);
179
180#ifdef HAVE_EXEMPI1
181 xmp_terminate();
182#endif
183 return 0;
184}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f88495.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f88495.html new file mode 100644 index 0000000..f9ac92b --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f88495.html @@ -0,0 +1,6522 @@ + + + +eom-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:src/eom-window.c
Warning:line 2515, 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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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 gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_window_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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)((__typeof__ (hpaned)) (g_object_ref) (hpaned));
263 g_object_ref (priv->nav)((__typeof__ (priv->nav)) (g_object_ref) (priv->nav));
264
265 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_container_get_type ()))))))
, hpaned);
266 gtk_container_remove (GTK_CONTAINER (priv->layout)((((GtkContainer*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
353 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) 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")g_strdup_inline ("_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*) (void *) 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*) (void *) 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*) (void *) 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 {
501 if ( eom_image_has_data (priv->image, EOM_IMAGE_DATA_DIMENSION))
502 {
503 int zoom, width, height;
504 goffset bytes = 0;
505
506 zoom = floor (100 * eom_scroll_view_get_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
) + 0.5);
507
508 eom_image_get_size (priv->image, &width, &height);
509
510 bytes = eom_image_get_bytes (priv->image);
511
512 if ((width > 0) && (height > 0)) {
513 char *size_string;
514
515 size_string = g_format_size (bytes);
516
517 /* Translators: This is the string displayed in the statusbar
518 * The tokens are from left to right:
519 * - image width
520 * - image height
521 * - image size in bytes
522 * - zoom in percent */
523 str = g_strdup_printf (ngettext("%i × %i pixel %s %i%%",
524 "%i × %i pixels %s %i%%", height),
525 width,
526 height,
527 size_string,
528 zoom);
529
530 g_free (size_string);
531 }
532 }
533 update_image_pos (window);
534 }
535
536 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
537 priv->image_info_message_cid);
538
539 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
540 priv->image_info_message_cid, str ? str : "");
541
542 g_free (str);
543}
544
545static void
546eom_window_set_message_area (EomWindow *window,
547 GtkWidget *message_area)
548{
549 if (window->priv->message_area == message_area)
550 return;
551
552 if (window->priv->message_area != NULL((void*)0))
553 gtk_widget_destroy (window->priv->message_area);
554
555 window->priv->message_area = message_area;
556
557 if (message_area == NULL((void*)0)) return;
558
559 gtk_box_pack_start (GTK_BOX (window->priv->cbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->cbox)), ((gtk_box_get_type ()))))))
,
560 window->priv->message_area,
561 FALSE(0),
562 FALSE(0),
563 0);
564
565 g_object_add_weak_pointer (G_OBJECT (window->priv->message_area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->message_area)), (((GType) ((20) <<
(2))))))))
,
566 (void *) &window->priv->message_area);
567}
568
569static void
570update_action_groups_state (EomWindow *window)
571{
572 EomWindowPrivate *priv;
573 GtkAction *action_collection;
574 GtkAction *action_sidebar;
575 GtkAction *action_fscreen;
576 GtkAction *action_sshow;
577 GtkAction *action_print;
578 gboolean print_disabled = FALSE(0);
579 gint n_images = 0;
580
581 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)
;
582
583 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 583, ((const char*) (__func__
))
);
584
585 priv = window->priv;
586
587 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
588 action_collection =
589 gtk_action_group_get_action (priv->actions_window,
590 "ViewImageCollection");
591
592 action_sidebar =
593 gtk_action_group_get_action (priv->actions_window,
594 "ViewSidebar");
595
596 action_fscreen =
597 gtk_action_group_get_action (priv->actions_image,
598 "ViewFullscreen");
599
600 action_sshow =
601 gtk_action_group_get_action (priv->actions_collection,
602 "ViewSlideshow");
603
604 action_print =
605 gtk_action_group_get_action (priv->actions_image,
606 "ImagePrint");
607 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
608
609 g_assert (action_collection != NULL)do { if (action_collection != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 609, ((const char*) (__func__)), "action_collection != NULL"
); } while (0)
;
610 g_assert (action_sidebar != NULL)do { if (action_sidebar != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 610, ((const char*) (__func__)), "action_sidebar != NULL"
); } while (0)
;
611 g_assert (action_fscreen != NULL)do { if (action_fscreen != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 611, ((const char*) (__func__)), "action_fscreen != NULL"
); } while (0)
;
612 g_assert (action_sshow != NULL)do { if (action_sshow != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 612, ((const char*) (__func__)), "action_sshow != NULL"
); } while (0)
;
613 g_assert (action_print != NULL)do { if (action_print != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 613, ((const char*) (__func__)), "action_print != NULL"
); } while (0)
;
614
615 if (priv->store != NULL((void*)0)) {
616 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
617 }
618
619 if (n_images == 0) {
620 gtk_widget_hide (priv->layout);
621
622 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
623 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
624 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
625 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
626
627 gtk_action_set_sensitive (action_fscreen, FALSE(0));
628 gtk_action_set_sensitive (action_sshow, FALSE(0));
629 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
630
631 /* If there are no images on model, initialization
632 stops here. */
633 if (priv->status == EOM_WINDOW_STATUS_INIT) {
634 priv->status = EOM_WINDOW_STATUS_NORMAL;
635 }
636 } else {
637 gboolean show_image_collection;
638
639 if (priv->flags & EOM_STARTUP_DISABLE_COLLECTION) {
640 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", FALSE(0));
641
642 show_image_collection = FALSE(0);
643 } else {
644 show_image_collection =
645 g_settings_get_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection");
646 }
647
648 show_image_collection = show_image_collection &&
649 n_images > 1 &&
650 priv->mode != EOM_WINDOW_MODE_SLIDESHOW;
651
652 gtk_widget_show (priv->layout);
653
654 if (show_image_collection)
655 gtk_widget_show (priv->nav);
656
657 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
658 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_collection)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action_collection)), ((gtk_toggle_action_get_type ()))))
))
,
659 show_image_collection);
660
661 gtk_action_group_set_sensitive (priv->actions_window, TRUE(!(0)));
662 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
663
664 gtk_action_set_sensitive (action_fscreen, TRUE(!(0)));
665
666 if (n_images == 1) {
667 gtk_action_group_set_sensitive (priv->actions_collection, FALSE(0));
668 gtk_action_set_sensitive (action_collection, FALSE(0));
669 gtk_action_set_sensitive (action_sshow, FALSE(0));
670 } else {
671 gtk_action_group_set_sensitive (priv->actions_collection, TRUE(!(0)));
672 gtk_action_set_sensitive (action_sshow, TRUE(!(0)));
673 }
674 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
675
676 if (show_image_collection)
677 gtk_widget_grab_focus (priv->thumbview);
678 else
679 gtk_widget_grab_focus (priv->view);
680 }
681
682 print_disabled = g_settings_get_boolean (priv->lockdown_settings,
683 EOM_CONF_LOCKDOWN_CAN_PRINT"disable-printing");
684
685 if (print_disabled) {
686 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
687 gtk_action_set_sensitive (action_print, FALSE(0));
688 }
689
690 if (eom_sidebar_is_empty (EOM_SIDEBAR (priv->sidebar)((((EomSidebar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->sidebar)), ((eom_sidebar_get_type()))))))
)) {
691 gtk_action_set_sensitive (action_sidebar, FALSE(0));
692 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
693 gtk_widget_hide (priv->sidebar);
694 }
695}
696
697static void
698update_selection_ui_visibility (EomWindow *window)
699{
700 EomWindowPrivate *priv;
701 GtkAction *wallpaper_action;
702 gint n_selected;
703
704 priv = window->priv;
705
706 n_selected = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
707
708 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
709 wallpaper_action =
710 gtk_action_group_get_action (priv->actions_image,
711 "ImageSetAsWallpaper");
712
713 if (n_selected == 1) {
714 gtk_action_set_sensitive (wallpaper_action, TRUE(!(0)));
715 } else {
716 gtk_action_set_sensitive (wallpaper_action, FALSE(0));
717 }
718 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
719}
720
721static gboolean
722add_file_to_recent_files (GFile *file)
723{
724 gchar *text_uri;
725 GFileInfo *file_info;
726 GtkRecentData *recent_data;
727 static gchar *groups[2] = { EOM_RECENT_FILES_GROUP"Graphics" , NULL((void*)0) };
728
729 if (file == NULL((void*)0)) return FALSE(0);
730
731 /* The password gets stripped here because ~/.recently-used.xbel is
732 * readable by everyone (chmod 644). It also makes the workaround
733 * for the bug with gtk_recent_info_get_uri_display() easier
734 * (see the comment in eom_window_update_recent_files_menu()). */
735 text_uri = g_file_get_uri (file);
736
737 if (text_uri == NULL((void*)0))
738 return FALSE(0);
739
740 file_info = g_file_query_info (file,
741 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
742 0, NULL((void*)0), NULL((void*)0));
743 if (file_info == NULL((void*)0))
744 return FALSE(0);
745
746 recent_data = g_slice_new (GtkRecentData)((GtkRecentData*) g_slice_alloc (sizeof (GtkRecentData)));
747 recent_data->display_name = NULL((void*)0);
748 recent_data->description = NULL((void*)0);
749 recent_data->mime_type = (gchar *) g_file_info_get_content_type (file_info);
750 recent_data->app_name = EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer";
751 recent_data->app_exec = g_strjoin(" ", g_get_prgname (), "%u", NULL((void*)0));
752 recent_data->groups = groups;
753 recent_data->is_private = FALSE(0);
754
755 gtk_recent_manager_add_full (gtk_recent_manager_get_default (),
756 text_uri,
757 recent_data);
758
759 g_free (recent_data->app_exec);
760 g_free (text_uri);
761 g_object_unref (file_info);
762
763 g_slice_free (GtkRecentData, recent_data)do { if (1) g_slice_free1 (sizeof (GtkRecentData), (recent_data
)); else (void) ((GtkRecentData*) 0 == (recent_data)); } while
(0)
;
764
765 return FALSE(0);
766}
767
768static void
769image_thumb_changed_cb (EomImage *image, gpointer data)
770{
771 EomWindow *window;
772 EomWindowPrivate *priv;
773 GdkPixbuf *thumb;
774
775 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)
;
776
777 window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
778 priv = window->priv;
779
780 thumb = eom_image_get_thumbnail (image);
781
782 if (thumb != NULL((void*)0)) {
783 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, thumb);
784
785 if (window->priv->properties_dlg != NULL((void*)0)) {
786 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
787 image);
788 }
789
790 g_object_unref (thumb);
791 } else if (!gtk_widget_get_visible (window->priv->nav)) {
792 gint img_pos = eom_list_store_get_pos_by_image (window->priv->store, image);
793 GtkTreePath *path = gtk_tree_path_new_from_indices (img_pos,-1);
794 GtkTreeIter iter;
795
796 gtk_tree_model_get_iter (GTK_TREE_MODEL (window->priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), ((gtk_tree_model_get_type (
)))))))
, &iter, path);
797 eom_list_store_thumbnail_set (window->priv->store, &iter);
798 gtk_tree_path_free (path);
799 }
800}
801
802static void
803file_changed_info_bar_response (GtkInfoBar *info_bar,
804 gint response,
805 EomWindow *window)
806{
807 if (response == GTK_RESPONSE_YES) {
808 eom_window_reload_image (window);
809 }
810
811 window->priv->needs_reload_confirmation = TRUE(!(0));
812
813 eom_window_set_message_area (window, NULL((void*)0));
814}
815static void
816image_file_changed_cb (EomImage *img, EomWindow *window)
817{
818 GtkWidget *info_bar;
819 gchar *text, *markup;
820 GtkWidget *image;
821 GtkWidget *label;
822 GtkWidget *hbox;
823
824 if (window->priv->needs_reload_confirmation == FALSE(0))
825 return;
826
827 if (!eom_image_is_modified (img)) {
828 /* Auto-reload when image is unmodified */
829 eom_window_reload_image (window);
830 return;
831 }
832
833 window->priv->needs_reload_confirmation = FALSE(0);
834
835 info_bar = gtk_info_bar_new_with_buttons (_("_Reload")gettext ("_Reload"),
836 GTK_RESPONSE_YES,
837 C_("MessageArea", "Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
838 GTK_RESPONSE_NO, NULL((void*)0));
839 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))
,
840 GTK_MESSAGE_QUESTION);
841 image = gtk_image_new_from_icon_name ("dialog-question",
842 GTK_ICON_SIZE_DIALOG);
843 label = gtk_label_new (NULL((void*)0));
844
845 /* The newline character is currently necessary due to a problem
846 * with the automatic line break. */
847 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?")
848 "\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));
849 markup = g_markup_printf_escaped ("<b>%s</b>", text);
850 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, markup);
851 g_free (text);
852 g_free (markup);
853
854 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
855 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
856 gtk_widget_set_halign (image, GTK_ALIGN_START);
857 gtk_widget_set_valign (image, GTK_ALIGN_END);
858 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
859 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
860 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_info_bar_get_content_area (((((GtkInfoBar*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((info_bar)), (
(gtk_info_bar_get_type()))))))))), ((gtk_box_get_type ())))))
)
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
861 gtk_widget_show_all (hbox);
862 gtk_widget_show (info_bar);
863
864 eom_window_set_message_area (window, info_bar);
865 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
866 G_CALLBACK (file_changed_info_bar_response),g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
867 window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (file_changed_info_bar_response))), (window), ((void*)0), (
GConnectFlags) 0)
;
868}
869
870static void
871eom_window_display_image (EomWindow *window, EomImage *image)
872{
873 EomWindowPrivate *priv;
874 GFile *file;
875
876 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)
;
877 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)
;
878
879 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 879, ((const char*) (__func__
))
);
880
881 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", 881, ((const
char*) (__func__)), "eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)"
); } while (0)
;
882
883 priv = window->priv;
884
885 if (image != NULL((void*)0)) {
886 g_signal_connect (image, "thumbnail_changed",g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
887 G_CALLBACK (image_thumb_changed_cb),g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
888 window)g_signal_connect_data ((image), ("thumbnail_changed"), (((GCallback
) (image_thumb_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
889 g_signal_connect (image, "file-changed",g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
890 G_CALLBACK (image_file_changed_cb),g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
891 window)g_signal_connect_data ((image), ("file-changed"), (((GCallback
) (image_file_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
892
893 image_thumb_changed_cb (image, window);
894 }
895
896 priv->needs_reload_confirmation = TRUE(!(0));
897
898 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, image);
899
900 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, eom_image_get_caption (image));
901
902 update_status_bar (window);
903
904 file = eom_image_get_file (image);
905 g_idle_add_full (G_PRIORITY_LOW300,
906 (GSourceFunc) add_file_to_recent_files,
907 file,
908 (GDestroyNotify) g_object_unref);
909
910 eom_window_update_openwith_menu (window, image);
911}
912
913static void
914open_with_launch_application_cb (GtkAction *action, gpointer data) {
915 EomImage *image;
916 GAppInfo *app;
917 GFile *file;
918 GList *files = NULL((void*)0);
919
920 image = EOM_IMAGE (data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_image_get_type ()))))))
;
921 file = eom_image_get_file (image);
922
923 app = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "app");
924 files = g_list_append (files, file);
925 g_app_info_launch (app,
926 files,
927 NULL((void*)0), NULL((void*)0));
928
929 g_object_unref (file);
930 g_list_free (files);
931}
932
933static void
934eom_window_update_openwith_menu (EomWindow *window, EomImage *image)
935{
936 gboolean edit_button_active;
937 GAppInfo *editor_app;
938 GFile *file;
939 GFileInfo *file_info;
940 GList *iter;
941 gchar *label, *tip;
942 const gchar *mime_type;
943 GtkAction *action;
944 EomWindowPrivate *priv;
945 GList *apps;
946 guint action_id = 0;
947 GIcon *app_icon;
948 char *path;
949 GtkWidget *menuitem;
950
951 priv = window->priv;
952
953 edit_button_active = FALSE(0);
954 editor_app = get_appinfo_for_editor (window);
955
956 file = eom_image_get_file (image);
957 file_info = g_file_query_info (file,
958 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type",
959 0, NULL((void*)0), NULL((void*)0));
960
961 if (file_info == NULL((void*)0))
962 return;
963 else {
964 mime_type = g_file_info_get_content_type (file_info);
965 }
966
967 if (priv->open_with_menu_id != 0) {
968 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->open_with_menu_id);
969 priv->open_with_menu_id = 0;
970 }
971
972 if (priv->actions_open_with != NULL((void*)0)) {
973 gtk_ui_manager_remove_action_group (priv->ui_mgr, priv->actions_open_with);
974 g_object_unref (priv->actions_open_with);
975 priv->actions_open_with = NULL((void*)0);
976 }
977
978 if (mime_type == NULL((void*)0)) {
979 g_object_unref (file_info);
980 return;
981 }
982
983 apps = g_app_info_get_all_for_type (mime_type);
984
985 g_object_unref (file_info);
986
987 if (!apps)
988 return;
989
990 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
991 priv->actions_open_with = gtk_action_group_new ("OpenWithActions");
992 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
993 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_open_with, -1);
994
995 priv->open_with_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
996
997 for (iter = apps; iter; iter = iter->next) {
998 GAppInfo *app = iter->data;
999 gchar name[64];
1000
1001 if (editor_app != NULL((void*)0) && g_app_info_equal (editor_app, app)) {
1002 edit_button_active = TRUE(!(0));
1003 }
1004
1005 /* Do not include eom itself */
1006 if (g_ascii_strcasecmp (g_app_info_get_executable (app),
1007 g_get_prgname ()) == 0) {
1008 g_object_unref (app);
1009 continue;
1010 }
1011
1012 g_snprintf (name, sizeof (name), "OpenWith%u", action_id++);
1013
1014 label = g_strdup (g_app_info_get_name (app))g_strdup_inline (g_app_info_get_name (app));
1015 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));
1016
1017 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1018 action = gtk_action_new (name, label, tip, NULL((void*)0));
1019 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1020
1021 app_icon = g_app_info_get_icon (app);
1022 if (G_LIKELY (app_icon != NULL)(app_icon != ((void*)0))) {
1023 g_object_ref (app_icon)((__typeof__ (app_icon)) (g_object_ref) (app_icon));
1024 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1025 gtk_action_set_gicon (action, app_icon);
1026 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1027 g_object_unref (app_icon);
1028 }
1029
1030 g_free (label);
1031 g_free (tip);
1032
1033 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "app", app,
1034 (GDestroyNotify) g_object_unref);
1035
1036 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1037 G_CALLBACK (open_with_launch_application_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
1038 image)g_signal_connect_data ((action), ("activate"), (((GCallback) (
open_with_launch_application_cb))), (image), ((void*)0), (GConnectFlags
) 0)
;
1039
1040 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1041 gtk_action_group_add_action (priv->actions_open_with, action);
1042 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1043 g_object_unref (action);
1044
1045 gtk_ui_manager_add_ui (priv->ui_mgr,
1046 priv->open_with_menu_id,
1047 "/MainMenu/Image/ImageOpenWith/Applications Placeholder",
1048 name,
1049 name,
1050 GTK_UI_MANAGER_MENUITEM,
1051 FALSE(0));
1052
1053 gtk_ui_manager_add_ui (priv->ui_mgr,
1054 priv->open_with_menu_id,
1055 "/ThumbnailPopup/ImageOpenWith/Applications Placeholder",
1056 name,
1057 name,
1058 GTK_UI_MANAGER_MENUITEM,
1059 FALSE(0));
1060 gtk_ui_manager_add_ui (priv->ui_mgr,
1061 priv->open_with_menu_id,
1062 "/ViewPopup/ImageOpenWith/Applications Placeholder",
1063 name,
1064 name,
1065 GTK_UI_MANAGER_MENUITEM,
1066 FALSE(0));
1067
1068 path = g_strdup_printf ("/MainMenu/Image/ImageOpenWith/Applications Placeholder/%s", name);
1069
1070 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1071
1072 /* Only force displaying the icon if it is an application icon */
1073 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, app_icon != NULL((void*)0));
1074
1075 g_free (path);
1076
1077 path = g_strdup_printf ("/ThumbnailPopup/ImageOpenWith/Applications Placeholder/%s", name);
1078
1079 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1080
1081 /* Only force displaying the icon if it is an application icon */
1082 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, app_icon != NULL((void*)0));
1083
1084 g_free (path);
1085
1086 path = g_strdup_printf ("/ViewPopup/ImageOpenWith/Applications Placeholder/%s", name);
1087
1088 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr, path);
1089
1090 /* Only force displaying the icon if it is an application icon */
1091 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, app_icon != NULL((void*)0));
1092
1093 g_free (path);
1094 }
1095
1096 g_list_free (apps);
1097
1098 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1099 action = gtk_action_group_get_action (window->priv->actions_image,
1100 "OpenEditor");
1101 if (action != NULL((void*)0)) {
1102 gtk_action_set_sensitive (action, edit_button_active);
1103 }
1104 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1105}
1106
1107static void
1108eom_window_clear_load_job (EomWindow *window)
1109{
1110 EomWindowPrivate *priv = window->priv;
1111
1112 if (priv->load_job != NULL((void*)0)) {
1113 if (!priv->load_job->finished)
1114 eom_job_queue_remove_job (priv->load_job);
1115
1116 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))
1117 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))
1118 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))
;
1119
1120 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))
1121 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))
1122 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))
;
1123
1124 eom_image_cancel_load (EOM_JOB_LOAD (priv->load_job)((((EomJobLoad*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->load_job)), ((eom_job_load_get_type()))))))
->image);
1125
1126 g_object_unref (priv->load_job);
1127 priv->load_job = NULL((void*)0);
1128
1129 /* Hide statusbar */
1130 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0);
1131 }
1132}
1133
1134static void
1135eom_job_progress_cb (EomJobLoad *job, float progress, gpointer user_data)
1136{
1137 EomWindow *window;
1138
1139 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)
;
1140
1141 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1142
1143 eom_statusbar_set_progress (EOM_STATUSBAR (window->priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((eom_statusbar_get_type
()))))))
,
1144 progress);
1145}
1146
1147static void
1148eom_job_save_progress_cb (EomJobSave *job, float progress, gpointer user_data)
1149{
1150 EomWindowPrivate *priv;
1151 EomWindow *window;
1152
1153 static EomImage *image = NULL((void*)0);
1154
1155 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)
;
1156
1157 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1158 priv = window->priv;
1159
1160 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
,
1161 progress);
1162
1163 if (image != job->current_image) {
1164 gchar *str_image, *status_message;
1165 guint n_images;
1166
1167 image = job->current_image;
1168
1169 n_images = g_list_length (job->images);
1170
1171 str_image = eom_image_get_uri_for_display (image);
1172
1173 /* Translators: This string is displayed in the statusbar
1174 * while saving images. The tokens are from left to right:
1175 * - the original filename
1176 * - the current image's position in the queue
1177 * - the total number of images queued for saving */
1178 status_message = g_strdup_printf (_("Saving image \"%s\" (%u/%u)")gettext ("Saving image \"%s\" (%u/%u)"),
1179 str_image,
1180 job->current_pos + 1,
1181 n_images);
1182 g_free (str_image);
1183
1184 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1185 priv->image_info_message_cid);
1186
1187 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1188 priv->image_info_message_cid,
1189 status_message);
1190
1191 g_free (status_message);
1192 }
1193
1194 if (progress == 1.0)
1195 image = NULL((void*)0);
1196}
1197
1198static void
1199eom_window_obtain_desired_size (EomImage *image,
1200 gint width,
1201 gint height,
1202 EomWindow *window)
1203{
1204 GdkScreen *screen;
1205 GdkDisplay *display;
1206 GdkRectangle monitor;
1207 GtkAllocation allocation;
1208 gint final_width, final_height;
1209 gint screen_width, screen_height;
1210 gint window_width, window_height;
1211 gint img_width, img_height;
1212 gint view_width, view_height;
1213 gint deco_width, deco_height;
1214
1215 update_action_groups_state (window);
1216
1217 img_width = width;
1218 img_height = height;
1219
1220 if (!gtk_widget_get_realized (window->priv->view)) {
1221 gtk_widget_realize (window->priv->view);
1222 }
1223
1224 gtk_widget_get_allocation (window->priv->view, &allocation);
1225 view_width = allocation.width;
1226 view_height = allocation.height;
1227
1228 if (!gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)) {
1229 gtk_widget_realize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1230 }
1231
1232 gtk_widget_get_allocation (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, &allocation);
1233 window_width = allocation.width;
1234 window_height = allocation.height;
1235
1236 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
1237 display = gdk_screen_get_display (screen);
1238
1239 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1240 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)),
1241 &monitor);
1242
1243 screen_width = monitor.width;
1244 screen_height = monitor.height;
1245
1246 deco_width = window_width - view_width;
1247 deco_height = window_height - view_height;
1248
1249 if (img_width > 0 && img_height > 0) {
1250 if ((img_width + deco_width > screen_width) ||
1251 (img_height + deco_height > screen_height))
1252 {
1253 double factor;
1254
1255 if (img_width > img_height) {
1256 factor = (screen_width * 0.75 - deco_width) / (double) img_width;
1257 } else {
1258 factor = (screen_height * 0.75 - deco_height) / (double) img_height;
1259 }
1260
1261 img_width = img_width * factor;
1262 img_height = img_height * factor;
1263 }
1264 }
1265
1266 final_width = MAX (EOM_WINDOW_MIN_WIDTH, img_width + deco_width)(((440) > (img_width + deco_width)) ? (440) : (img_width +
deco_width))
;
1267 final_height = MAX (EOM_WINDOW_MIN_HEIGHT, img_height + deco_height)(((350) > (img_height + deco_height)) ? (350) : (img_height
+ deco_height))
;
1268
1269 eom_debug_message (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1269, ((const char*) (__func__
))
, "Setting window size: %d x %d", final_width, final_height);
1270
1271 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, final_width, final_height);
1272
1273 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1274}
1275
1276static void
1277eom_window_error_message_area_response (GtkInfoBar *message_area,
1278 gint response_id,
1279 EomWindow *window)
1280{
1281 if (response_id != GTK_RESPONSE_OK) {
1282 eom_window_set_message_area (window, NULL((void*)0));
1283
1284 return;
1285 }
1286
1287 /* Trigger loading for current image again */
1288 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
1289 EOM_THUMB_VIEW_SELECT_CURRENT);
1290}
1291
1292static void
1293eom_job_load_cb (EomJobLoad *job, gpointer data)
1294{
1295 EomWindow *window;
1296 EomWindowPrivate *priv;
1297 GtkAction *action_undo, *action_save;
1298
1299 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)
;
1300
1301 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1301, ((const char*) (__func__
))
);
1302
1303 window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
1304 priv = window->priv;
1305
1306 eom_statusbar_set_progress (EOM_STATUSBAR (priv->statusbar)((((EomStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((eom_statusbar_get_type ()))))))
, 0.0);
1307
1308 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
1309 priv->image_info_message_cid);
1310
1311 if (priv->image != NULL((void*)0)) {
1312 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))
1313 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))
1314 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))
;
1315 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))
1316 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))
1317 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))
;
1318
1319 g_object_unref (priv->image);
1320 }
1321
1322 priv->image = g_object_ref (job->image)((__typeof__ (job->image)) (g_object_ref) (job->image));
1323
1324 if (EOM_JOB (job)((((EomJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((eom_job_get_type()))))))
->error == NULL((void*)0)) {
1325#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
1326 eom_image_apply_display_profile (job->image,
1327 priv->display_profile);
1328#endif
1329
1330 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1331 gtk_action_group_set_sensitive (priv->actions_image, TRUE(!(0)));
1332 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1333
1334 eom_window_display_image (window, job->image);
1335 } else {
1336 GtkWidget *message_area;
1337
1338 message_area = eom_image_load_error_message_area_new (
1339 eom_image_get_caption (job->image),
1340 EOM_JOB (job)((((EomJob*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job)), ((eom_job_get_type()))))))
->error);
1341
1342 g_signal_connect (message_area, "response",g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
1343 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)
1344 window)g_signal_connect_data ((message_area), ("response"), (((GCallback
) (eom_window_error_message_area_response))), (window), ((void
*)0), (GConnectFlags) 0)
;
1345
1346 gtk_window_set_icon (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, NULL((void*)0));
1347 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
1348 eom_image_get_caption (job->image));
1349
1350 eom_window_set_message_area (window, message_area);
1351
1352 gtk_info_bar_set_default_response (GTK_INFO_BAR (message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((message_area)), ((gtk_info_bar_get_type()))))))
,
1353 GTK_RESPONSE_CANCEL);
1354
1355 gtk_widget_show (message_area);
1356
1357 update_status_bar (window);
1358
1359 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
1360
1361 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1362 update_action_groups_state (window);
1363
1364 g_signal_emit (window, signals[SIGNAL_PREPARED], 0);
1365 }
1366
1367 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1368 gtk_action_group_set_sensitive (priv->actions_image, FALSE(0));
1369 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1370 }
1371
1372 eom_window_clear_load_job (window);
1373
1374 if (window->priv->status == EOM_WINDOW_STATUS_INIT) {
1375 window->priv->status = EOM_WINDOW_STATUS_NORMAL;
1376
1377 g_signal_handlers_disconnect_by_func (job->image,g_signal_handlers_disconnect_matched ((job->image), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_obtain_desired_size), (window))
1378 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), (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), (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*) (void *) 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*) (void *) 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, "finished",g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1459 G_CALLBACK (eom_job_transform_cb),g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
1460 window)g_signal_connect_data ((priv->transform_job), ("finished")
, (((GCallback) (eom_job_transform_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
1461
1462 g_signal_connect (priv->transform_job, "progress",g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1463 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
1464 window)g_signal_connect_data ((priv->transform_job), ("progress")
, (((GCallback) (eom_job_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
1465
1466 eom_job_queue_add_job (priv->transform_job);
1467}
1468
1469static void
1470handle_image_selection_changed_cb (EomThumbView *thumbview, EomWindow *window)
1471{
1472 EomWindowPrivate *priv;
1473 EomImage *image;
1474 gchar *status_message;
1475 gchar *str_image;
1476
1477 priv = window->priv;
1478
1479 if (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0) {
1480 gtk_window_set_title (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
1481 g_get_application_name());
1482 gtk_statusbar_remove_all (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1483 priv->image_info_message_cid);
1484 eom_scroll_view_set_image (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
1485 NULL((void*)0));
1486 }
1487
1488 if (eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
) == 0)
1489 return;
1490
1491 update_selection_ui_visibility (window);
1492
1493 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1494
1495 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", 1495, ((const
char*) (__func__)), "EOM_IS_IMAGE (image)"); } while (0)
;
1496
1497 eom_window_clear_load_job (window);
1498
1499 eom_window_set_message_area (window, NULL((void*)0));
1500
1501 gtk_statusbar_pop (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1502 priv->image_info_message_cid);
1503
1504 if (image == priv->image) {
1505 update_status_bar (window);
1506 return;
1507 }
1508
1509 if (eom_image_has_data (image, EOM_IMAGE_DATA_IMAGE)) {
1510 if (priv->image != NULL((void*)0))
1511 g_object_unref (priv->image);
1512
1513 priv->image = image;
1514 eom_window_display_image (window, image);
1515 return;
1516 }
1517
1518 if (priv->status == EOM_WINDOW_STATUS_INIT) {
1519 g_signal_connect (image, "size-prepared",g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
1520 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)
1521 window)g_signal_connect_data ((image), ("size-prepared"), (((GCallback
) (eom_window_obtain_desired_size))), (window), ((void*)0), (
GConnectFlags) 0)
;
1522 }
1523
1524 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)
);
1525
1526 g_signal_connect (priv->load_job, "finished",g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1527 G_CALLBACK (eom_job_load_cb),g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1528 window)g_signal_connect_data ((priv->load_job), ("finished"), (((
GCallback) (eom_job_load_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1529
1530 g_signal_connect (priv->load_job, "progress",g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1531 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
1532 window)g_signal_connect_data ((priv->load_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
1533
1534 eom_job_queue_add_job (priv->load_job);
1535
1536 str_image = eom_image_get_uri_for_display (image);
1537
1538 status_message = g_strdup_printf (_("Opening image \"%s\"")gettext ("Opening image \"%s\""),
1539 str_image);
1540
1541 g_free (str_image);
1542
1543 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
1544 priv->image_info_message_cid, status_message);
1545
1546 g_free (status_message);
1547}
1548
1549static void
1550view_zoom_changed_cb (GtkWidget *widget, double zoom, gpointer user_data)
1551{
1552 EomWindow *window;
1553 GtkAction *action_zoom_in;
1554 GtkAction *action_zoom_out;
1555
1556 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)
;
1557
1558 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1559
1560 update_status_bar (window);
1561
1562 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1563 action_zoom_in =
1564 gtk_action_group_get_action (window->priv->actions_image,
1565 "ViewZoomIn");
1566
1567 action_zoom_out =
1568 gtk_action_group_get_action (window->priv->actions_image,
1569 "ViewZoomOut");
1570
1571 gtk_action_set_sensitive (action_zoom_in,
1572 !eom_scroll_view_get_zoom_is_max (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1573 gtk_action_set_sensitive (action_zoom_out,
1574 !eom_scroll_view_get_zoom_is_min (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
));
1575 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1576}
1577
1578static void
1579eom_window_open_recent_cb (GtkAction *action, EomWindow *window)
1580{
1581 GtkRecentInfo *info;
1582 const gchar *uri;
1583 GSList *list = NULL((void*)0);
1584
1585 info = g_object_get_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info");
1586 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)
;
1587
1588 uri = gtk_recent_info_get_uri (info);
1589 list = g_slist_prepend (list, g_strdup (uri)g_strdup_inline (uri));
1590
1591 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1592 list,
1593 GDK_CURRENT_TIME0L,
1594 0,
1595 NULL((void*)0));
1596
1597 g_slist_free_full (list, g_free);
1598}
1599
1600static void
1601file_open_dialog_response_cb (GtkWidget *chooser,
1602 gint response_id,
1603 EomWindow *ev_window)
1604{
1605 if (response_id == GTK_RESPONSE_OK) {
1606 GSList *uris;
1607
1608 uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_file_chooser_get_type ()))))))
);
1609
1610 eom_application_open_uri_list (EOM_APP(eom_application_get_instance ()),
1611 uris,
1612 GDK_CURRENT_TIME0L,
1613 0,
1614 NULL((void*)0));
1615
1616 g_slist_free_full (uris, g_free);
1617 }
1618
1619 gtk_widget_destroy (chooser);
1620}
1621
1622static void
1623eom_window_update_fullscreen_action (EomWindow *window)
1624{
1625 GtkAction *action;
1626
1627 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1628 action = gtk_action_group_get_action (window->priv->actions_image,
1629 "ViewFullscreen");
1630
1631 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_fullscreen), (window))
1632 eom_window_cmd_fullscreen,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_fullscreen), (window))
1633 window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_fullscreen), (window))
;
1634
1635 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1636 window->priv->mode == EOM_WINDOW_MODE_FULLSCREEN);
1637 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1638
1639 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_fullscreen), (window))
1640 eom_window_cmd_fullscreen,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_fullscreen), (window))
1641 window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_fullscreen), (window))
;
1642}
1643
1644static void
1645eom_window_update_slideshow_action (EomWindow *window)
1646{
1647 GtkAction *action;
1648
1649 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1650 action = gtk_action_group_get_action (window->priv->actions_collection,
1651 "ViewSlideshow");
1652
1653 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_slideshow), (window))
1654 eom_window_cmd_slideshow,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_slideshow), (window))
1655 window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_slideshow), (window))
;
1656
1657 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
,
1658 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
1659 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1660
1661 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_slideshow), (window))
1662 eom_window_cmd_slideshow,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_slideshow), (window))
1663 window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_slideshow), (window))
;
1664}
1665
1666static void
1667eom_window_update_pause_slideshow_action (EomWindow *window)
1668{
1669 GtkAction *action;
1670
1671 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1672 action = gtk_action_group_get_action (window->priv->actions_image,
1673 "PauseSlideshow");
1674
1675 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_pause_slideshow), (window))
1676 eom_window_cmd_pause_slideshow,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_pause_slideshow), (window))
1677 window)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (eom_window_cmd_pause_slideshow), (window))
;
1678
1679 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) 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_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_pause_slideshow), (window))
1684 eom_window_cmd_pause_slideshow,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_pause_slideshow), (window))
1685 window)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_cmd_pause_slideshow), (window))
;
1686}
1687
1688static void
1689eom_window_update_fullscreen_popup (EomWindow *window)
1690{
1691 GtkWidget *popup = window->priv->fullscreen_popup;
1692 GdkRectangle screen_rect;
1693 GdkScreen *screen;
1694 GdkDisplay *display;
1695
1696 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)
;
1697
1698 if (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
) == NULL((void*)0)) return;
1699
1700 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1701 display = gdk_screen_get_display (screen);
1702
1703 gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
1704 gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)),
1705 &screen_rect);
1706
1707 gtk_widget_set_size_request (popup,
1708 screen_rect.width,
1709 -1);
1710
1711 gtk_window_move (GTK_WINDOW (popup)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_window_get_type ()))))))
, screen_rect.x, screen_rect.y);
1712}
1713
1714static void
1715screen_size_changed_cb (GdkScreen *screen, EomWindow *window)
1716{
1717 eom_window_update_fullscreen_popup (window);
1718}
1719
1720static gboolean
1721fullscreen_timeout_cb (gpointer data)
1722{
1723 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
1724
1725 gtk_widget_hide (window->priv->fullscreen_popup);
1726
1727 eom_scroll_view_hide_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1728
1729 fullscreen_clear_timeout (window);
1730
1731 return FALSE(0);
1732}
1733
1734static gboolean
1735slideshow_is_loop_end (EomWindow *window)
1736{
1737 EomWindowPrivate *priv = window->priv;
1738 EomImage *image = NULL((void*)0);
1739 gint pos;
1740
1741 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
1742
1743 pos = eom_list_store_get_pos_by_image (priv->store, image);
1744
1745 return (pos == (eom_list_store_length (priv->store) - 1));
1746}
1747
1748static gboolean
1749slideshow_switch_cb (gpointer data)
1750{
1751 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
1752 EomWindowPrivate *priv = window->priv;
1753
1754 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1754, ((const char*) (__func__
))
);
1755
1756 if (priv->slideshow_random) {
1757 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1758 EOM_THUMB_VIEW_SELECT_RANDOM);
1759 return TRUE(!(0));
1760 }
1761
1762 if (!priv->slideshow_loop && slideshow_is_loop_end (window)) {
1763 eom_window_stop_fullscreen (window, TRUE(!(0)));
1764 return FALSE(0);
1765 }
1766
1767 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
1768 EOM_THUMB_VIEW_SELECT_RIGHT);
1769
1770 return TRUE(!(0));
1771}
1772
1773static void
1774fullscreen_clear_timeout (EomWindow *window)
1775{
1776 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1776, ((const char*) (__func__
))
);
1777
1778 if (window->priv->fullscreen_timeout_source != NULL((void*)0)) {
1779 g_source_unref (window->priv->fullscreen_timeout_source);
1780 g_source_destroy (window->priv->fullscreen_timeout_source);
1781 }
1782
1783 window->priv->fullscreen_timeout_source = NULL((void*)0);
1784}
1785
1786static void
1787fullscreen_set_timeout (EomWindow *window)
1788{
1789 GSource *source;
1790
1791 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1791, ((const char*) (__func__
))
);
1792
1793 fullscreen_clear_timeout (window);
1794
1795 source = g_timeout_source_new (EOM_WINDOW_FULLSCREEN_TIMEOUT5 * 1000);
1796 g_source_set_callback (source, fullscreen_timeout_cb, window, NULL((void*)0));
1797
1798 g_source_attach (source, NULL((void*)0));
1799
1800 window->priv->fullscreen_timeout_source = source;
1801
1802 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
);
1803}
1804
1805static void
1806slideshow_clear_timeout (EomWindow *window)
1807{
1808 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1808, ((const char*) (__func__
))
);
1809
1810 if (window->priv->slideshow_switch_source != NULL((void*)0)) {
1811 g_source_unref (window->priv->slideshow_switch_source);
1812 g_source_destroy (window->priv->slideshow_switch_source);
1813 }
1814
1815 window->priv->slideshow_switch_source = NULL((void*)0);
1816}
1817
1818static void
1819slideshow_set_timeout (EomWindow *window)
1820{
1821 GSource *source;
1822
1823 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1823, ((const char*) (__func__
))
);
1824
1825 slideshow_clear_timeout (window);
1826
1827 if (window->priv->slideshow_switch_timeout <= 0)
1828 return;
1829
1830 source = g_timeout_source_new (window->priv->slideshow_switch_timeout * 1000);
1831 g_source_set_callback (source, slideshow_switch_cb, window, NULL((void*)0));
1832
1833 g_source_attach (source, NULL((void*)0));
1834
1835 window->priv->slideshow_switch_source = source;
1836}
1837
1838static void
1839show_fullscreen_popup (EomWindow *window)
1840{
1841 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1841, ((const char*) (__func__
))
);
1842
1843 if (!gtk_widget_get_visible (window->priv->fullscreen_popup)) {
1844 gtk_widget_show_all (GTK_WIDGET (window->priv->fullscreen_popup)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->fullscreen_popup)), ((gtk_widget_get_type
()))))))
);
1845 }
1846
1847 fullscreen_set_timeout (window);
1848}
1849
1850static gboolean
1851fullscreen_motion_notify_cb (GtkWidget *widget,
1852 GdkEventMotion *event,
1853 gpointer user_data)
1854{
1855 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1856
1857 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1857, ((const char*) (__func__
))
);
1858
1859 if (event->y < EOM_WINDOW_FULLSCREEN_POPUP_THRESHOLD5) {
1860 show_fullscreen_popup (window);
1861 } else {
1862 fullscreen_set_timeout (window);
1863 }
1864
1865 return FALSE(0);
1866}
1867
1868static gboolean
1869fullscreen_leave_notify_cb (GtkWidget *widget,
1870 GdkEventCrossing *event,
1871 gpointer user_data)
1872{
1873 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
1874
1875 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1875, ((const char*) (__func__
))
);
1876
1877 fullscreen_clear_timeout (window);
1878
1879 return FALSE(0);
1880}
1881
1882static void
1883exit_fullscreen_button_clicked_cb (GtkWidget *button, EomWindow *window)
1884{
1885 GtkAction *action;
1886
1887 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1887, ((const char*) (__func__
))
);
1888
1889 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
1890 if (window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW) {
1891 action = gtk_action_group_get_action (window->priv->actions_collection,
1892 "ViewSlideshow");
1893 } else {
1894 action = gtk_action_group_get_action (window->priv->actions_image,
1895 "ViewFullscreen");
1896 }
1897 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)
;
1898
1899 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, FALSE(0));
1900 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
1901}
1902
1903static GtkWidget *
1904eom_window_get_exit_fullscreen_button (EomWindow *window)
1905{
1906 GtkWidget *button;
1907
1908 button = gtk_button_new_with_mnemonic (_("Leave Fullscreen")gettext ("Leave Fullscreen"));
1909 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("view-restore", GTK_ICON_SIZE_BUTTON));
1910
1911 g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1912 G_CALLBACK (exit_fullscreen_button_clicked_cb),g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
1913 window)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
exit_fullscreen_button_clicked_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
1914
1915 return button;
1916}
1917
1918static GtkWidget *
1919eom_window_create_fullscreen_popup (EomWindow *window)
1920{
1921 GtkWidget *popup;
1922 GtkWidget *hbox;
1923 GtkWidget *button;
1924 GtkWidget *toolbar;
1925 GdkScreen *screen;
1926
1927 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 1927, ((const char*) (__func__
))
);
1928
1929 popup = gtk_window_new (GTK_WINDOW_POPUP);
1930
1931 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1932 gtk_container_add (GTK_CONTAINER (popup)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_container_get_type ()))))))
, hbox);
1933
1934 toolbar = gtk_ui_manager_get_widget (window->priv->ui_mgr,
1935 "/FullscreenToolbar");
1936 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", 1936, ((const
char*) (__func__)), "GTK_IS_WIDGET (toolbar)"); } while (0)
;
1937 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar)((((GtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toolbar)), ((gtk_toolbar_get_type ()))))))
, GTK_TOOLBAR_ICONS);
1938 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, toolbar, TRUE(!(0)), TRUE(!(0)), 0);
1939
1940 button = eom_window_get_exit_fullscreen_button (window);
1941 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, button, FALSE(0), FALSE(0), 0);
1942
1943 gtk_window_set_resizable (GTK_WINDOW (popup)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((gtk_window_get_type ()))))))
, FALSE(0));
1944
1945 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1946
1947 g_signal_connect_object (screen, "size-changed",
1948 G_CALLBACK (screen_size_changed_cb)((GCallback) (screen_size_changed_cb)),
1949 window, 0);
1950
1951 g_signal_connect (popup, "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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((eom_application_get_instance ()))), ((gtk_application_get_type
()))))))
,
2046 GTK_WINDOW (window)((((GtkWindow*) (void *) 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*) (void *) 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, "motion-notify-event",g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2100 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)
2101 window)g_signal_connect_data ((priv->view), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2102
2103 g_signal_connect (priv->view, "leave-notify-event",g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2104 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)
2105 window)g_signal_connect_data ((priv->view), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2106
2107 g_signal_connect (priv->thumbview, "motion-notify-event",g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
2108 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)
2109 window)g_signal_connect_data ((priv->thumbview), ("motion-notify-event"
), (((GCallback) (fullscreen_motion_notify_cb))), (window), (
(void*)0), (GConnectFlags) 0)
;
2110
2111 g_signal_connect (priv->thumbview, "leave-notify-event",g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
2112 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)
2113 window)g_signal_connect_data ((priv->thumbview), ("leave-notify-event"
), (((GCallback) (fullscreen_leave_notify_cb))), (window), ((
void*)0), (GConnectFlags) 0)
;
2114
2115 fullscreen_set_timeout (window);
2116
2117 if (slideshow) {
2118 priv->slideshow_random =
2119 g_settings_get_boolean (priv->fullscreen_settings,
2120 EOM_CONF_FULLSCREEN_RANDOM"random");
2121
2122 priv->slideshow_loop =
2123 g_settings_get_boolean (priv->fullscreen_settings,
2124 EOM_CONF_FULLSCREEN_LOOP"loop");
2125
2126 priv->slideshow_switch_timeout =
2127 g_settings_get_int (priv->fullscreen_settings,
2128 EOM_CONF_FULLSCREEN_SECONDS"seconds");
2129
2130 slideshow_set_timeout (window);
2131 }
2132
2133 upscale = g_settings_get_boolean (priv->fullscreen_settings,
2134 EOM_CONF_FULLSCREEN_UPSCALE"upscale");
2135
2136 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
2137 upscale);
2138
2139 gtk_widget_grab_focus (priv->view);
2140
2141 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2142 &black);
2143
2144 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2145 eom_window_update_fullscreen_popup (window);
2146
2147 eom_window_inhibit_screensaver (window);
2148
2149 /* Update both actions as we could've already been in one those modes */
2150 eom_window_update_slideshow_action (window);
2151 eom_window_update_fullscreen_action (window);
2152 eom_window_update_pause_slideshow_action (window);
2153}
2154
2155static void
2156eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow)
2157{
2158 EomWindowPrivate *priv;
2159 GtkWidget *menubar;
2160
2161 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 2161, ((const char*) (__func__
))
);
2162
2163 priv = window->priv;
2164
2165 if (priv->mode != EOM_WINDOW_MODE_SLIDESHOW &&
2166 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2167
2168 priv->mode = EOM_WINDOW_MODE_NORMAL;
2169
2170 fullscreen_clear_timeout (window);
2171
2172 if (slideshow) {
2173 slideshow_clear_timeout (window);
2174 }
2175
2176 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), (fullscreen_motion_notify_cb), (window))
2177 fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (fullscreen_motion_notify_cb), (window))
2178 window)g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (fullscreen_motion_notify_cb), (window))
;
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), (fullscreen_leave_notify_cb), (window))
2181 fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->view), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (fullscreen_leave_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), (fullscreen_leave_notify_cb), (window))
;
2183
2184 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), (fullscreen_motion_notify_cb), (window))
2185 fullscreen_motion_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (fullscreen_motion_notify_cb), (window))
2186 window)g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (fullscreen_motion_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), (fullscreen_leave_notify_cb), (window))
2189 fullscreen_leave_notify_cb,g_signal_handlers_disconnect_matched ((priv->thumbview), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (fullscreen_leave_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), (fullscreen_leave_notify_cb), (window))
;
2191
2192 update_ui_visibility (window);
2193
2194 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
2195 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", 2195, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
2196 gtk_widget_show (menubar);
2197
2198 eom_scroll_view_set_zoom_upscale (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
2199
2200 eom_scroll_view_override_bg_color (EOM_SCROLL_VIEW (window->priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->view)), ((eom_scroll_view_get_type (
)))))))
,
2201 NULL((void*)0));
2202 gtk_window_unfullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2203
2204 if (slideshow) {
2205 eom_window_update_slideshow_action (window);
2206 } else {
2207 eom_window_update_fullscreen_action (window);
2208 }
2209
2210 eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
2211
2212 eom_window_uninhibit_screensaver (window);
2213}
2214
2215static void
2216eom_window_print (EomWindow *window)
2217{
2218 GtkWidget *dialog;
2219 GError *error = NULL((void*)0);
2220 GtkPrintOperation *print;
2221 GtkPrintOperationResult res;
2222 GtkPageSetup *page_setup;
2223 GtkPrintSettings *print_settings;
2224 gboolean page_setup_disabled = FALSE(0);
2225
2226 eom_debug (DEBUG_PRINTINGEOM_DEBUG_PRINTING, "eom-window.c", 2226, ((const char*) (__func__
))
);
2227
2228 print_settings = eom_print_get_print_settings ();
2229
2230 /* Make sure the window stays valid while printing */
2231 g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
2232
2233 if (window->priv->page_setup != NULL((void*)0))
2234 page_setup = g_object_ref (window->priv->page_setup)((__typeof__ (window->priv->page_setup)) (g_object_ref)
(window->priv->page_setup))
;
2235 else
2236 page_setup = eom_print_get_page_setup ();
2237
2238 print = eom_print_operation_new (window->priv->image,
2239 print_settings,
2240 page_setup);
2241
2242 // Disable page setup options if they are locked down
2243 page_setup_disabled = g_settings_get_boolean (window->priv->lockdown_settings,
2244 EOM_CONF_LOCKDOWN_CAN_SETUP_PAGE"disable-print-setup");
2245 if (page_setup_disabled)
2246 gtk_print_operation_set_embed_page_setup (print, FALSE(0));
2247
2248 res = gtk_print_operation_run (print,
2249 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
2250 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, &error);
2251
2252 if (res == GTK_PRINT_OPERATION_RESULT_ERROR) {
2253 dialog = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2254 GTK_DIALOG_DESTROY_WITH_PARENT,
2255 GTK_MESSAGE_ERROR,
2256 GTK_BUTTONS_CLOSE,
2257 _("Error printing file:\n%s")gettext ("Error printing file:\n%s"),
2258 error->message);
2259 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
2260 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
2261 NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
2262 gtk_widget_show (dialog);
2263 g_error_free (error);
2264 } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
2265 GtkPageSetup *new_page_setup;
2266 eom_print_set_print_settings (gtk_print_operation_get_print_settings (print));
2267 new_page_setup = gtk_print_operation_get_default_page_setup (print);
2268 if (window->priv->page_setup != NULL((void*)0))
2269 g_object_unref (window->priv->page_setup);
2270 window->priv->page_setup = g_object_ref (new_page_setup)((__typeof__ (new_page_setup)) (g_object_ref) (new_page_setup
))
;
2271 eom_print_set_page_setup (window->priv->page_setup);
2272 }
2273
2274 if (page_setup != NULL((void*)0))
2275 g_object_unref (page_setup);
2276 g_object_unref (print_settings);
2277 g_object_unref (window);
2278}
2279
2280static void
2281eom_window_cmd_file_open (GtkAction *action, gpointer user_data)
2282{
2283 EomWindow *window;
2284 EomWindowPrivate *priv;
2285 EomImage *current;
2286 GtkWidget *dlg;
2287
2288 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)
;
2289
2290 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2291
2292 priv = window->priv;
2293
2294 dlg = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_OPEN);
2295 gtk_window_set_transient_for (GTK_WINDOW (dlg)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_window_get_type ()))))))
, GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2296
2297 current = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2298
2299 if (current != NULL((void*)0)) {
2300 gchar *dir_uri, *file_uri;
2301
2302 file_uri = eom_image_get_uri_for_display (current);
2303 dir_uri = g_path_get_dirname (file_uri);
2304
2305 gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2306 dir_uri);
2307 g_free (file_uri);
2308 g_free (dir_uri);
2309 g_object_unref (current);
2310 } else {
2311 /* If desired by the user,
2312 fallback to the XDG_PICTURES_DIR (if available) */
2313 const gchar *pics_dir;
2314 gboolean use_fallback;
2315
2316 use_fallback = g_settings_get_boolean (priv->ui_settings,
2317 EOM_CONF_UI_FILECHOOSER_XDG_FALLBACK"filechooser-xdg-fallback");
2318 pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
2319 if (use_fallback && pics_dir) {
2320 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlg)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_file_chooser_get_type ()))))))
,
2321 pics_dir);
2322 }
2323 }
2324
2325 g_signal_connect (dlg, "response",g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2326 G_CALLBACK (file_open_dialog_response_cb),g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
2327 window)g_signal_connect_data ((dlg), ("response"), (((GCallback) (file_open_dialog_response_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
2328
2329 gtk_widget_show_all (dlg);
2330}
2331
2332static void
2333eom_job_close_save_cb (EomJobSave *job, gpointer user_data)
2334{
2335 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2336
2337 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))
2338 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))
2339 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))
;
2340
2341 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2342}
2343
2344static void
2345close_confirmation_dialog_response_handler (EomCloseConfirmationDialog *dlg,
2346 gint response_id,
2347 EomWindow *window)
2348{
2349 GList *selected_images;
2350 EomWindowPrivate *priv;
2351
2352 priv = window->priv;
2353
2354 switch (response_id)
2355 {
2356 case GTK_RESPONSE_YES:
2357 /* save selected images */
2358 selected_images = eom_close_confirmation_dialog_get_selected_images (dlg);
2359 if (eom_window_save_images (window, selected_images)) {
2360 g_signal_connect (priv->save_job, "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
2361 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)
2362 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_close_save_cb))), (window), ((void*)0), (
GConnectFlags) 0)
;
2363
2364 eom_job_queue_add_job (priv->save_job);
2365 }
2366
2367 break;
2368
2369 case GTK_RESPONSE_NO:
2370 /* dont save */
2371 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2372 break;
2373
2374 default:
2375 /* Cancel */
2376 gtk_widget_destroy (GTK_WIDGET (dlg)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_widget_get_type ()))))))
);
2377 break;
2378 }
2379}
2380
2381static gboolean
2382eom_window_unsaved_images_confirm (EomWindow *window)
2383{
2384 EomWindowPrivate *priv;
2385 gboolean disabled;
2386 GtkWidget *dialog;
2387 GList *list;
2388 EomImage *image;
2389 GtkTreeIter iter;
2390
2391 priv = window->priv;
2392
2393 disabled = g_settings_get_boolean(priv->ui_settings,
2394 EOM_CONF_UI_DISABLE_CLOSE_CONFIRMATION"disable-close-confirmation");
2395 disabled |= window->priv->save_disabled;
2396 if (disabled || !priv->store) {
2397 return FALSE(0);
2398 }
2399
2400 list = NULL((void*)0);
2401 if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter)) {
2402 do {
2403 gtk_tree_model_get (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter,
2404 EOM_LIST_STORE_EOM_IMAGE, &image,
2405 -1);
2406 if (!image)
2407 continue;
2408
2409 if (eom_image_is_modified (image)) {
2410 list = g_list_prepend (list, image);
2411 }
2412 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), ((gtk_tree_model_get_type ()))))))
, &iter));
2413 }
2414
2415 if (list) {
2416 list = g_list_reverse (list);
2417 dialog = eom_close_confirmation_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2418 list);
2419
2420 g_list_free (list);
2421 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2422 G_CALLBACK (close_confirmation_dialog_response_handler),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
2423 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
close_confirmation_dialog_response_handler))), (window), ((void
*)0), (GConnectFlags) 0)
;
2424 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2425
2426 gtk_widget_show (dialog);
2427 return TRUE(!(0));
2428
2429 }
2430 return FALSE(0);
2431}
2432
2433static void
2434eom_window_cmd_close_window (GtkAction *action, gpointer user_data)
2435{
2436 EomWindow *window;
2437 EomWindowPrivate *priv;
2438
2439 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)
;
2440
2441 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2442 priv = window->priv;
2443
2444 if (priv->save_job != NULL((void*)0)) {
2445 eom_window_finish_saving (window);
2446 }
2447
2448 if (!eom_window_unsaved_images_confirm (window)) {
2449 gtk_widget_destroy (GTK_WIDGET (user_data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_widget_get_type ()))))))
);
2450 }
2451}
2452
2453static void
2454eom_window_cmd_preferences (GtkAction *action, gpointer user_data)
2455{
2456 EomWindow *window;
2457 GtkWidget *pref_dlg;
2458
2459 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)
;
2460
2461 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2462
2463 pref_dlg = eom_preferences_dialog_get_instance (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2464
2465 gtk_widget_show (pref_dlg);
2466}
2467
2468#define EOM_TB_EDITOR_DLG_RESET_RESPONSE128 128
2469
2470static void
2471eom_window_cmd_edit_toolbar_cb (GtkDialog *dialog, gint response, gpointer data)
2472{
2473 EomWindow *window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
2474
2475 if (response == EOM_TB_EDITOR_DLG_RESET_RESPONSE128) {
2476 EggToolbarsModel *model;
2477 EggToolbarEditor *editor;
2478
2479 editor = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
,
2480 "EggToolbarEditor");
2481
2482 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)
;
2483
2484 egg_editable_toolbar_set_edit_mode
2485 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2486
2487 eom_application_reset_toolbars_model (EOM_APP(eom_application_get_instance ()));
2488 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
2489 egg_editable_toolbar_set_model
2490 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, model);
2491 egg_toolbar_editor_set_model (editor, model);
2492
2493 /* Toolbar would be uneditable now otherwise */
2494 egg_editable_toolbar_set_edit_mode
2495 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2496 } else if (response == GTK_RESPONSE_HELP) {
2497 eom_util_show_help ("eom-toolbareditor", NULL((void*)0));
2498 } else {
2499 egg_editable_toolbar_set_edit_mode
2500 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, FALSE(0));
2501
2502 eom_application_save_toolbars_model (EOM_APP(eom_application_get_instance ()));
2503
2504 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
2505 }
2506}
2507
2508static void
2509eom_window_cmd_edit_toolbar (GtkAction *action, gpointer *user_data)
2510{
2511 EomWindow *window;
2512 GtkWidget *dialog;
2513 GtkWidget *editor;
2514
2515 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
2516
2517 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2518
2519 dialog = gtk_dialog_new_with_buttons (_("Toolbar Editor")gettext ("Toolbar Editor"),
2520 GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2521 GTK_DIALOG_DESTROY_WITH_PARENT,
2522 _("_Reset to Default")gettext ("_Reset to Default"),
2523 EOM_TB_EDITOR_DLG_RESET_RESPONSE128,
2524 "gtk-close",
2525 GTK_RESPONSE_CLOSE,
2526 "gtk-help",
2527 GTK_RESPONSE_HELP,
2528 NULL((void*)0));
2529
2530 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
,
2531 GTK_RESPONSE_CLOSE);
2532
2533 gtk_container_set_border_width (GTK_CONTAINER (dialog)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_container_get_type ()))))))
, 5);
2534
2535 gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_box_get_type ()))))))
, 2);
2536
2537 gtk_window_set_default_size (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, 500, 400);
2538
2539 editor = egg_toolbar_editor_new (window->priv->ui_mgr,
2540 eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ())));
2541
2542 gtk_container_set_border_width (GTK_CONTAINER (editor)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_container_get_type ()))))))
, 5);
2543
2544 // Use as much vertical space as available
2545 gtk_widget_set_vexpand (GTK_WIDGET (editor)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editor)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
2546
2547 gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EggToolbarEditor*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((editor)), ((egg_toolbar_editor_get_type (
))))))))), ((gtk_box_get_type ()))))))
, 5);
2548
2549 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((gtk_dialog_get_type ()))))))
))), ((gtk_container_get_type ()))))))
, editor);
2550
2551 egg_editable_toolbar_set_edit_mode
2552 (EGG_EDITABLE_TOOLBAR (window->priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window->priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
, TRUE(!(0)));
2553
2554 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "EggToolbarEditor", editor);
2555
2556 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2557 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)
2558 window)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
eom_window_cmd_edit_toolbar_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2559
2560 gtk_widget_show_all (dialog);
2561}
2562
2563static void
2564eom_window_cmd_help (GtkAction *action, gpointer user_data)
2565{
2566 EomWindow *window;
2567
2568 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)
;
2569
2570 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2571
2572 eom_util_show_help (NULL((void*)0), GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2573}
2574
2575#define ABOUT_GROUP"About" "About"
2576#define EMAILIFY(string)(g_strdelimit ((string), "%", '@')) (g_strdelimit ((string), "%", '@'))
2577
2578static void
2579eom_window_cmd_about (GtkAction *action, gpointer user_data)
2580{
2581 EomWindow *window;
2582
2583 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)
;
2584
2585 const char *license[] = {
2586 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")
2587 "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")
2588 "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")
2589 "(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")
,
2590 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")
2591 "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")
2592 "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")
2593 "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")
,
2594 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."
)
2595 "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."
)
2596 "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."
)
2597 };
2598
2599 char *license_trans;
2600 GKeyFile *key_file;
2601 GBytes *bytes;
2602 const guint8 *data;
2603 gsize data_len;
2604 GError *error = NULL((void*)0);
2605 char **authors, **documenters;
2606 gsize n_authors = 0, n_documenters = 0 , i;
2607
2608 bytes = g_resources_lookup_data ("/org/mate/eom/ui/eom.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
2609 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2609, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2610
2611 data = g_bytes_get_data (bytes, &data_len);
2612 key_file = g_key_file_new ();
2613 g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
2614 g_assert_no_error (error)do { if (error) g_assertion_message_error ("EOM", "eom-window.c"
, 2614, ((const char*) (__func__)), "error", error, 0, 0); } while
(0)
;
2615
2616 authors = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Authors", &n_authors, NULL((void*)0));
2617 documenters = g_key_file_get_string_list (key_file, ABOUT_GROUP"About", "Documenters", &n_documenters, NULL((void*)0));
2618
2619 g_key_file_free (key_file);
2620 g_bytes_unref (bytes);
2621
2622 for (i = 0; i < n_authors; ++i)
2623 authors[i] = EMAILIFY (authors[i])(g_strdelimit ((authors[i]), "%", '@'));
2624 for (i = 0; i < n_documenters; ++i)
2625 documenters[i] = EMAILIFY (documenters[i])(g_strdelimit ((documenters[i]), "%", '@'));
2626
2627 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));
2628
2629 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2630
2631 gtk_show_about_dialog (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
2632 "program-name", _("Eye of MATE")gettext ("Eye of MATE"),
2633 "title", _("About Eye of MATE")gettext ("About Eye of MATE"),
2634 "version", VERSION"1.28.0",
2635 "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-2021 MATE developers"
)
2636 "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-2021 MATE developers"
)
2637 "Copyright \xc2\xa9 2012-2021 MATE developers")gettext ("Copyright \xc2\xa9 2000-2010 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2011 Perberos\n" "Copyright \xc2\xa9 2012-2021 MATE developers"
)
,
2638 "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."
)
,
2639 "authors", authors,
2640 "documenters", documenters,
2641 "translator-credits", _("translator-credits")gettext ("translator-credits"),
2642 "website", PACKAGE_URL"https://mate-desktop.org",
2643 "logo-icon-name", "eom",
2644 "wrap-license", TRUE(!(0)),
2645 "license", license_trans,
2646 NULL((void*)0));
2647
2648 g_strfreev (authors);
2649 g_strfreev (documenters);
2650 g_free (license_trans);
2651}
2652
2653static void
2654eom_window_cmd_show_hide_bar (GtkAction *action, gpointer user_data)
2655{
2656 EomWindow *window;
2657 EomWindowPrivate *priv;
2658 gboolean visible;
2659 const gchar *action_name;
2660
2661 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)
;
2662
2663 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2664 priv = window->priv;
2665
2666 if (priv->mode != EOM_WINDOW_MODE_NORMAL &&
2667 priv->mode != EOM_WINDOW_MODE_FULLSCREEN) return;
2668
2669 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2670 visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
2671 action_name = gtk_action_get_name (action);
2672 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2673
2674 if (g_ascii_strcasecmp (action_name, "ViewToolbar") == 0) {
2675 g_object_set (G_OBJECT (priv->toolbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->toolbar)), (((GType) ((20) << (2))))))))
, "visible", visible, NULL((void*)0));
2676
2677 if (priv->mode == EOM_WINDOW_MODE_NORMAL)
2678 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_TOOLBAR"toolbar", visible);
2679
2680 } else if (g_ascii_strcasecmp (action_name, "ViewStatusbar") == 0) {
2681 g_object_set (G_OBJECT (priv->statusbar)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), (((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_STATUSBAR"statusbar", visible);
2685
2686 } else if (g_ascii_strcasecmp (action_name, "ViewImageCollection") == 0) {
2687 if (visible) {
2688 /* Make sure the focus widget is realized to
2689 * avoid warnings on keypress events */
2690 if (!gtk_widget_get_realized (window->priv->thumbview))
2691 gtk_widget_realize (window->priv->thumbview);
2692
2693 gtk_widget_show (priv->nav);
2694 gtk_widget_grab_focus (priv->thumbview);
2695 } else {
2696 /* Make sure the focus widget is realized to
2697 * avoid warnings on keypress events.
2698 * Don't do it during init phase or the view
2699 * will get a bogus allocation. */
2700 if (!gtk_widget_get_realized (priv->view)
2701 && priv->status == EOM_WINDOW_STATUS_NORMAL)
2702 gtk_widget_realize (priv->view);
2703
2704 gtk_widget_hide (priv->nav);
2705
2706 if (gtk_widget_get_realized (priv->view))
2707 gtk_widget_grab_focus (priv->view);
2708 }
2709 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_IMAGE_COLLECTION"image-collection", visible);
2710
2711 } else if (g_ascii_strcasecmp (action_name, "ViewSidebar") == 0) {
2712 if (visible) {
2713 gtk_widget_show (priv->sidebar);
2714 } else {
2715 gtk_widget_hide (priv->sidebar);
2716 }
2717 g_settings_set_boolean (priv->ui_settings, EOM_CONF_UI_SIDEBAR"sidebar", visible);
2718 }
2719}
2720
2721static void
2722wallpaper_info_bar_response (GtkInfoBar *bar, gint response, EomWindow *window)
2723{
2724 if (response == GTK_RESPONSE_YES) {
2725 GAppInfo *app_info;
2726 GError *error = NULL((void*)0);
2727
2728 app_info = g_app_info_create_from_commandline ("mate-appearance-properties --show-page=background",
2729 "mate-appearance-properties",
2730 G_APP_INFO_CREATE_NONE,
2731 &error);
2732
2733 if (error != NULL((void*)0)) {
2734 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2735 error->message);
2736 g_error_free (error);
2737 error = NULL((void*)0);
2738 }
2739
2740 if (app_info != NULL((void*)0)) {
2741 GdkAppLaunchContext *context;
2742 GdkDisplay *display;
2743
2744 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
2745 context = gdk_display_get_app_launch_context (display);
2746 g_app_info_launch (app_info, NULL((void*)0), G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, &error);
2747
2748 if (error != NULL((void*)0)) {
2749 g_warning ("%s%s", _("Error launching appearance preferences dialog: ")gettext ("Error launching appearance preferences dialog: "),
2750 error->message);
2751 g_error_free (error);
2752 error = NULL((void*)0);
2753 }
2754
2755 g_object_unref (context);
2756 g_object_unref (app_info);
2757 }
2758 }
2759
2760 /* Close message area on every response */
2761 eom_window_set_message_area (window, NULL((void*)0));
2762}
2763
2764static void
2765eom_window_set_wallpaper (EomWindow *window, const gchar *filename, const gchar *visible_filename)
2766{
2767 GtkWidget *info_bar;
2768 GtkWidget *image;
2769 GtkWidget *label;
2770 GtkWidget *hbox;
2771 gchar *markup;
2772 gchar *text;
2773 gchar *basename;
2774 GSettings *wallpaper_settings;
2775
2776 wallpaper_settings = g_settings_new (EOM_CONF_BACKGROUND_SCHEMA"org.mate.background");
2777 g_settings_set_string (wallpaper_settings,
2778 EOM_CONF_BACKGROUND_FILE"picture-filename",
2779 filename);
2780 g_object_unref (wallpaper_settings);
2781
2782 /* I18N: When setting mnemonics for these strings, watch out to not
2783 clash with mnemonics from eom's menubar */
2784 info_bar = gtk_info_bar_new_with_buttons (_("_Open Background Preferences")gettext ("_Open Background Preferences"),
2785 GTK_RESPONSE_YES,
2786 C_("MessageArea","Hi_de")g_dpgettext (((void*)0), "MessageArea" "\004" "Hi_de", strlen
("MessageArea") + 1)
,
2787 GTK_RESPONSE_NO, NULL((void*)0));
2788 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))
,
2789 GTK_MESSAGE_QUESTION);
2790
2791 image = gtk_image_new_from_icon_name ("dialog-question",
2792 GTK_ICON_SIZE_DIALOG);
2793 label = gtk_label_new (NULL((void*)0));
2794
2795 if (!visible_filename)
2796 basename = g_path_get_basename (filename);
2797
2798 /* The newline character is currently necessary due to a problem
2799 * with the automatic line break. */
2800 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?")
2801 "\nWould you like to modify its appearance?")gettext ("The image \"%s\" has been set as Desktop Background."
"\nWould you like to modify its appearance?")
,
2802 visible_filename ? visible_filename : basename);
2803 markup = g_markup_printf_escaped ("<b>%s</b>", text);
2804 gtk_label_set_markup (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, markup);
2805 g_free (markup);
2806 g_free (text);
2807 if (!visible_filename)
2808 g_free (basename);
2809
2810 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
2811 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
2812 gtk_widget_set_halign (image, GTK_ALIGN_START);
2813 gtk_widget_set_valign (image, GTK_ALIGN_END);
2814 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, label, TRUE(!(0)), TRUE(!(0)), 0);
2815 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
2816 gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_info_bar_get_content_area (((((GtkInfoBar*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((info_bar)), (
(gtk_info_bar_get_type()))))))))), ((gtk_box_get_type ())))))
)
, hbox, TRUE(!(0)), TRUE(!(0)), 0);
2817 gtk_widget_show_all (hbox);
2818 gtk_widget_show (info_bar);
2819
2820 eom_window_set_message_area (window, info_bar);
2821 gtk_info_bar_set_default_response (GTK_INFO_BAR (info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info_bar)), ((gtk_info_bar_get_type()))))))
,
2822 GTK_RESPONSE_YES);
2823 g_signal_connect (info_bar, "response",g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
2824 G_CALLBACK (wallpaper_info_bar_response),g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
2825 window)g_signal_connect_data ((info_bar), ("response"), (((GCallback
) (wallpaper_info_bar_response))), (window), ((void*)0), (GConnectFlags
) 0)
;
2826}
2827
2828static void
2829eom_job_save_cb (EomJobSave *job, gpointer user_data)
2830{
2831 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2832 GtkAction *action_save;
2833
2834 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))
2835 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))
2836 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))
;
2837
2838 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))
2839 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))
2840 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))
;
2841
2842 g_object_unref (window->priv->save_job);
2843 window->priv->save_job = NULL((void*)0);
2844
2845 update_status_bar (window);
2846 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2847 action_save = gtk_action_group_get_action (window->priv->actions_image,
2848 "ImageSave");
2849 gtk_action_set_sensitive (action_save, FALSE(0));
2850 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2851}
2852
2853static void
2854eom_job_copy_cb (EomJobCopy *job, gpointer user_data)
2855{
2856 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2857 gchar *filepath, *basename, *filename, *extension;
2858 GtkAction *action;
2859 GFile *source_file, *dest_file;
2860
2861 /* Create source GFile */
2862 basename = g_file_get_basename (job->images->data);
2863 filepath = g_build_filename (job->dest, basename, NULL((void*)0));
2864 source_file = g_file_new_for_path (filepath);
2865 g_free (filepath);
2866
2867 /* Create destination GFile */
2868 extension = eom_util_filename_get_extension (basename);
2869 filename = g_strdup_printf ("%s.%s", EOM_WALLPAPER_FILENAME"eom-wallpaper", extension);
2870 filepath = g_build_filename (job->dest, filename, NULL((void*)0));
2871 dest_file = g_file_new_for_path (filepath);
2872 g_free (filename);
2873 g_free (extension);
2874
2875 /* Move the file */
2876 g_file_move (source_file, dest_file, G_FILE_COPY_OVERWRITE,
2877 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
2878
2879 /* Set the wallpaper */
2880 eom_window_set_wallpaper (window, filepath, basename);
2881 g_free (basename);
2882 g_free (filepath);
2883
2884 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
2885 window->priv->copy_file_cid);
2886 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
2887 action = gtk_action_group_get_action (window->priv->actions_image,
2888 "ImageSetAsWallpaper");
2889 gtk_action_set_sensitive (action, TRUE(!(0)));
2890 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
2891
2892 window->priv->copy_job = NULL((void*)0);
2893
2894 g_object_unref (source_file);
2895 g_object_unref (dest_file);
2896 g_object_unref (G_OBJECT (job->images->data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((job->images->data)), (((GType) ((20) << (2))
))))))
);
2897 g_list_free (job->images);
2898 g_object_unref (job);
2899}
2900
2901static gboolean
2902eom_window_save_images (EomWindow *window, GList *images)
2903{
2904 EomWindowPrivate *priv;
2905
2906 priv = window->priv;
2907
2908 if (window->priv->save_job != NULL((void*)0))
2909 return FALSE(0);
2910
2911 priv->save_job = eom_job_save_new (images);
2912
2913 g_signal_connect (priv->save_job, "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2914 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
2915 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
2916
2917 g_signal_connect (priv->save_job, "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
2918 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)
2919 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
2920
2921 return TRUE(!(0));
2922}
2923
2924static void
2925eom_window_cmd_save (GtkAction *action, gpointer user_data)
2926{
2927 EomWindowPrivate *priv;
2928 EomWindow *window;
2929 GList *images;
2930
2931 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2932 priv = window->priv;
2933
2934 if (window->priv->save_job != NULL((void*)0))
2935 return;
2936
2937 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
2938
2939 if (eom_window_save_images (window, images)) {
2940 eom_job_queue_add_job (priv->save_job);
2941 }
2942}
2943
2944static GFile*
2945eom_window_retrieve_save_as_file (EomWindow *window, EomImage *image)
2946{
2947 GtkWidget *dialog;
2948 GFile *save_file = NULL((void*)0);
2949 GFile *last_dest_folder;
2950 gint response;
2951
2952 g_assert (image != NULL)do { if (image != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 2952, ((const char*) (__func__)), "image != NULL"
); } while (0)
;
2953
2954 dialog = eom_file_chooser_new (GTK_FILE_CHOOSER_ACTION_SAVE);
2955
2956 last_dest_folder = window->priv->last_save_as_folder;
2957
2958 if (last_dest_folder && g_file_query_exists (last_dest_folder, NULL((void*)0))) {
2959 gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
, last_dest_folder, NULL((void*)0));
2960 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2961 eom_image_get_caption (image));
2962 } else {
2963 GFile *image_file;
2964
2965 image_file = eom_image_get_file (image);
2966 /* Setting the file will also navigate to its parent folder */
2967 gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
,
2968 image_file, NULL((void*)0));
2969 g_object_unref (image_file);
2970 }
2971
2972 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
2973 gtk_widget_hide (dialog);
2974
2975 if (response == GTK_RESPONSE_OK) {
2976 save_file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_file_chooser_get_type ()))))))
);
2977 if (window->priv->last_save_as_folder)
2978 g_object_unref (window->priv->last_save_as_folder);
2979 window->priv->last_save_as_folder = g_file_get_parent (save_file);
2980 }
2981 gtk_widget_destroy (dialog);
2982
2983 return save_file;
2984}
2985
2986static void
2987eom_window_cmd_save_as (GtkAction *action, gpointer user_data)
2988{
2989 EomWindowPrivate *priv;
2990 EomWindow *window;
2991 GList *images;
2992 guint n_images;
2993
2994 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
2995 priv = window->priv;
2996
2997 if (window->priv->save_job != NULL((void*)0))
2998 return;
2999
3000 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3001 n_images = g_list_length (images);
3002
3003 if (n_images == 1) {
3004 GFile *file;
3005
3006 file = eom_window_retrieve_save_as_file (window, images->data);
3007
3008 if (!file) {
3009 g_list_free (images);
3010 return;
3011 }
3012
3013 priv->save_job = eom_job_save_as_new (images, NULL((void*)0), file);
3014
3015 g_object_unref (file);
3016 } else if (n_images > 1) {
3017 GFile *base_file;
3018 GtkWidget *dialog;
3019 gchar *basedir;
3020 EomURIConverter *converter;
3021
3022 basedir = g_get_current_dir ();
3023 base_file = g_file_new_for_path (basedir);
3024 g_free (basedir);
3025
3026 dialog = eom_save_as_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3027 images,
3028 base_file);
3029
3030 gtk_widget_show_all (dialog);
3031
3032 if (gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
) != GTK_RESPONSE_OK) {
3033 g_object_unref (base_file);
3034 g_list_free (images);
3035 gtk_widget_destroy (dialog);
3036
3037 return;
3038 }
3039
3040 converter = eom_save_as_dialog_get_converter (dialog);
3041
3042 g_assert (converter != NULL)do { if (converter != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3042, ((const char*) (__func__)), "converter != NULL"
); } while (0)
;
3043
3044 priv->save_job = eom_job_save_as_new (images, converter, NULL((void*)0));
3045
3046 gtk_widget_destroy (dialog);
3047
3048 g_object_unref (converter);
3049 g_object_unref (base_file);
3050 } else {
3051 /* n_images = 0 -- No Image selected */
3052 return;
3053 }
3054
3055 g_signal_connect (priv->save_job, "finished",g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3056 G_CALLBACK (eom_job_save_cb),g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3057 window)g_signal_connect_data ((priv->save_job), ("finished"), (((
GCallback) (eom_job_save_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3058
3059 g_signal_connect (priv->save_job, "progress",g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
3060 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)
3061 window)g_signal_connect_data ((priv->save_job), ("progress"), (((
GCallback) (eom_job_save_progress_cb))), (window), ((void*)0)
, (GConnectFlags) 0)
;
3062
3063 eom_job_queue_add_job (priv->save_job);
3064}
3065
3066static void
3067eom_window_cmd_open_containing_folder (GtkAction *action, gpointer user_data)
3068{
3069 EomWindowPrivate *priv;
3070
3071 GFile *file;
3072 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)
;
3073
3074 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3075
3076 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)
;
3077
3078 file = eom_image_get_file (priv->image);
3079
3080 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)
;
3081
3082 eom_util_show_file_in_filemanager (file,
3083 GTK_WINDOW (user_data)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_window_get_type ()))))))
);
3084}
3085
3086static void
3087eom_window_cmd_print (GtkAction *action, gpointer user_data)
3088{
3089 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3090
3091 eom_window_print (window);
3092}
3093
3094/**
3095 * eom_window_get_properties_dialog:
3096 * @window: a #EomWindow
3097 *
3098 * Gets the @window property dialog. The widget will be built on the first call to this function.
3099 *
3100 * Returns: (transfer none): a #GtkDialog.
3101 */
3102
3103GtkWidget*
3104eom_window_get_properties_dialog (EomWindow *window)
3105{
3106 EomWindowPrivate *priv;
3107
3108 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)
;
3109
3110 priv = window->priv;
3111
3112 if (priv->properties_dlg == NULL((void*)0)) {
3113 GtkAction *next_image_action, *previous_image_action;
3114
3115 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3116 next_image_action =
3117 gtk_action_group_get_action (priv->actions_collection,
3118 "GoNext");
3119
3120 previous_image_action =
3121 gtk_action_group_get_action (priv->actions_collection,
3122 "GoPrevious");
3123 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3124 priv->properties_dlg =
3125 eom_properties_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3126 EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3127 next_image_action,
3128 previous_image_action);
3129
3130 eom_properties_dialog_update (EOM_PROPERTIES_DIALOG (priv->properties_dlg)((((EomPropertiesDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->properties_dlg)), ((eom_properties_dialog_get_type
()))))))
,
3131 priv->image);
3132 g_settings_bind (priv->ui_settings,
3133 EOM_CONF_UI_PROPSDIALOG_NETBOOK_MODE"propsdialog-netbook-mode",
3134 priv->properties_dlg, "netbook-mode",
3135 G_SETTINGS_BIND_GET);
3136 }
3137
3138 return priv->properties_dlg;
3139}
3140
3141static void
3142eom_window_cmd_properties (GtkAction *action, gpointer user_data)
3143{
3144 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3145 GtkWidget *dialog;
3146
3147 dialog = eom_window_get_properties_dialog (window);
3148 gtk_widget_show (dialog);
3149}
3150
3151static void
3152eom_window_cmd_undo (GtkAction *action, gpointer user_data)
3153{
3154 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)
;
3155
3156 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
, NULL((void*)0));
3157}
3158
3159static void
3160eom_window_cmd_flip_horizontal (GtkAction *action, gpointer user_data)
3161{
3162 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)
;
3163
3164 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3165 eom_transform_flip_new (EOM_TRANSFORM_FLIP_HORIZONTAL));
3166}
3167
3168static void
3169eom_window_cmd_flip_vertical (GtkAction *action, gpointer user_data)
3170{
3171 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)
;
3172
3173 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3174 eom_transform_flip_new (EOM_TRANSFORM_FLIP_VERTICAL));
3175}
3176
3177static void
3178eom_window_cmd_rotate_90 (GtkAction *action, gpointer user_data)
3179{
3180 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)
;
3181
3182 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3183 eom_transform_rotate_new (90));
3184}
3185
3186static void
3187eom_window_cmd_rotate_270 (GtkAction *action, gpointer user_data)
3188{
3189 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)
;
3190
3191 apply_transformation (EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
,
3192 eom_transform_rotate_new (270));
3193}
3194
3195static void
3196eom_window_cmd_wallpaper (GtkAction *action, gpointer user_data)
3197{
3198 EomWindow *window;
3199 EomWindowPrivate *priv;
3200 EomImage *image;
3201 GFile *file;
3202 char *filename = NULL((void*)0);
3203
3204 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)
;
3205
3206 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3207 priv = window->priv;
3208
3209 /* If currently copying an image to set it as wallpaper, return. */
3210 if (priv->copy_job != NULL((void*)0))
3211 return;
3212
3213 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3214
3215 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)
;
3216
3217 file = eom_image_get_file (image);
3218
3219 filename = g_file_get_path (file);
3220
3221 /* Currently only local files can be set as wallpaper */
3222 if (filename == NULL((void*)0) || !eom_util_file_is_persistent (file))
3223 {
3224 GList *files = NULL((void*)0);
3225 GtkAction *action_set_as_wp;
3226
3227 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3228 action_set_as_wp = gtk_action_group_get_action (window->priv->actions_image,
3229 "ImageSetAsWallpaper");
3230 gtk_action_set_sensitive (action_set_as_wp, FALSE(0));
3231 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3232
3233 priv->copy_file_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3234 "copy_file_cid");
3235 gtk_statusbar_push (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
3236 priv->copy_file_cid,
3237 _("Saving image locally…")gettext ("Saving image locally…"));
3238
3239 files = g_list_append (files, eom_image_get_file (image));
3240 priv->copy_job = eom_job_copy_new (files, g_get_user_data_dir ());
3241 g_signal_connect (priv->copy_job, "finished",g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3242 G_CALLBACK (eom_job_copy_cb),g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3243 window)g_signal_connect_data ((priv->copy_job), ("finished"), (((
GCallback) (eom_job_copy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3244 g_signal_connect (priv->copy_job, "progress",g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3245 G_CALLBACK (eom_job_progress_cb),g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3246 window)g_signal_connect_data ((priv->copy_job), ("progress"), (((
GCallback) (eom_job_progress_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3247 eom_job_queue_add_job (priv->copy_job);
3248
3249 g_object_unref (file);
3250 g_free (filename);
3251 return;
3252 }
3253
3254 g_object_unref (file);
3255
3256 eom_window_set_wallpaper (window, filename, NULL((void*)0));
3257
3258 g_free (filename);
3259}
3260
3261static gboolean
3262eom_window_all_images_trasheable (GList *images)
3263{
3264 GFile *file;
3265 GFileInfo *file_info;
3266 GList *iter;
3267 EomImage *image;
3268 gboolean can_trash = TRUE(!(0));
3269
3270 for (iter = images; iter != NULL((void*)0); iter = g_list_next (iter)((iter) ? (((GList *)(iter))->next) : ((void*)0))) {
3271 image = (EomImage *) iter->data;
3272 file = eom_image_get_file (image);
3273 file_info = g_file_query_info (file,
3274 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3275 0, NULL((void*)0), NULL((void*)0));
3276 can_trash = g_file_info_get_attribute_boolean (file_info,
3277 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3278
3279 g_object_unref (file_info);
3280 g_object_unref (file);
3281
3282 if (can_trash == FALSE(0))
3283 break;
3284 }
3285
3286 return can_trash;
3287}
3288
3289static int
3290show_move_to_trash_confirm_dialog (EomWindow *window, GList *images, gboolean can_trash)
3291{
3292 GtkWidget *dlg;
3293 char *prompt;
3294 int response;
3295 int n_images;
3296 EomImage *image;
3297 static gboolean dontaskagain = FALSE(0);
3298 gboolean neverask = FALSE(0);
3299 GtkWidget* dontask_cbutton = NULL((void*)0);
3300
3301 /* Check if the user never wants to be bugged. */
3302 neverask = g_settings_get_boolean (window->priv->ui_settings,
3303 EOM_CONF_UI_DISABLE_TRASH_CONFIRMATION"disable-trash-confirmation");
3304
3305 /* Assume agreement, if the user doesn't want to be
3306 * asked and the trash is available */
3307 if (can_trash && (dontaskagain || neverask))
3308 return GTK_RESPONSE_OK;
3309
3310 n_images = g_list_length (images);
3311
3312 if (n_images == 1) {
3313 image = EOM_IMAGE (images->data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((images->data)), ((eom_image_get_type ()))))))
;
3314 if (can_trash) {
3315 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?"
)
,
3316 eom_image_get_caption (image));
3317 } else {
3318 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?")
3319 "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));
3320 }
3321 } else {
3322 if (can_trash) {
3323 prompt = g_strdup_printf (ngettext("Are you sure you want to move\n"
3324 "the %d selected image to the trash?",
3325 "Are you sure you want to move\n"
3326 "the %d selected images to the trash?", n_images), n_images);
3327 } else {
3328 prompt = g_strdup (_("Some of the selected images can't be moved to the trash "g_strdup_inline (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?"
))
3329 "and will be removed permanently. Are you sure you want "g_strdup_inline (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?"
))
3330 "to proceed?"))g_strdup_inline (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?"
))
;
3331 }
3332 }
3333
3334 dlg = gtk_message_dialog_new_with_markup (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3335 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3336 GTK_MESSAGE_WARNING,
3337 GTK_BUTTONS_NONE,
3338 "<span weight=\"bold\" size=\"larger\">%s</span>",
3339 prompt);
3340 g_free (prompt);
3341
3342 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-cancel", GTK_RESPONSE_CANCEL);
3343
3344 if (can_trash) {
3345 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, _("Move to _Trash")gettext ("Move to _Trash"), GTK_RESPONSE_OK);
3346
3347 dontask_cbutton = gtk_check_button_new_with_mnemonic (_("_Do not ask again during this session")gettext ("_Do not ask again during this session"));
3348 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
, FALSE(0));
3349
3350 gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dlg)), ((gtk_dialog_get_type ())))))))))
, ((gtk_box_get_type ()))))))
, dontask_cbutton, TRUE(!(0)), TRUE(!(0)), 0);
3351 } else {
3352 if (n_images == 1) {
3353 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-delete", GTK_RESPONSE_OK);
3354 } else {
3355 gtk_dialog_add_button (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, "gtk-yes", GTK_RESPONSE_OK);
3356 }
3357 }
3358
3359 gtk_dialog_set_default_response (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
3360 gtk_window_set_title (GTK_WINDOW (dlg)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_window_get_type ()))))))
, "");
3361 gtk_widget_show_all (dlg);
3362
3363 response = gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
3364
3365 /* Only update the property if the user has accepted */
3366 if (can_trash && response == GTK_RESPONSE_OK)
3367 dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dontask_cbutton)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dontask_cbutton)), ((gtk_toggle_button_get_type ()))))))
);
3368
3369 /* The checkbutton is destroyed together with the dialog */
3370 gtk_widget_destroy (dlg);
3371
3372 return response;
3373}
3374
3375static gboolean
3376move_to_trash_real (EomImage *image, GError **error)
3377{
3378 GFile *file;
3379 GFileInfo *file_info;
3380 gboolean can_trash, result;
3381
3382 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)
;
3383
3384 file = eom_image_get_file (image);
3385 file_info = g_file_query_info (file,
3386 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash",
3387 0, NULL((void*)0), NULL((void*)0));
3388 if (file_info == NULL((void*)0)) {
3389 g_set_error (error,
3390 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3391 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3392 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3393 return FALSE(0);
3394 }
3395
3396 can_trash = g_file_info_get_attribute_boolean (file_info,
3397 G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH"access::can-trash");
3398 g_object_unref (file_info);
3399 if (can_trash)
3400 {
3401 result = g_file_trash (file, NULL((void*)0), NULL((void*)0));
3402 if (result == FALSE(0)) {
3403 g_set_error (error,
3404 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3405 EOM_WINDOW_ERROR_TRASH_NOT_FOUND,
3406 _("Couldn't access trash.")gettext ("Couldn't access trash."));
3407 }
3408 } else {
3409 result = g_file_delete (file, NULL((void*)0), NULL((void*)0));
3410 if (result == FALSE(0)) {
3411 g_set_error (error,
3412 EOM_WINDOW_ERROR(eom_window_error_quark ()),
3413 EOM_WINDOW_ERROR_IO,
3414 _("Couldn't delete file")gettext ("Couldn't delete file"));
3415 }
3416 }
3417
3418 g_object_unref (file);
3419
3420 return result;
3421}
3422
3423static void
3424eom_window_cmd_copy_image (GtkAction *action, gpointer user_data)
3425{
3426 GtkClipboard *clipboard;
3427 EomWindow *window;
3428 EomWindowPrivate *priv;
3429 EomImage *image;
3430 EomClipboardHandler *cbhandler;
3431
3432 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)
;
3433
3434 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3435 priv = window->priv;
3436
3437 image = eom_thumb_view_get_first_selected_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3438
3439 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)
;
3440
3441 clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD((GdkAtom)((gpointer) (gulong) (69))));
3442
3443 cbhandler = eom_clipboard_handler_new (image);
3444 // cbhandler will self-destruct when it's not needed anymore
3445 eom_clipboard_handler_copy_to_clipboard (cbhandler, clipboard);
3446
3447}
3448
3449static void
3450eom_window_cmd_move_to_trash (GtkAction *action, gpointer user_data)
3451{
3452 GList *images;
3453 GList *it;
3454 EomWindowPrivate *priv;
3455 EomListStore *list;
3456 int pos;
3457 EomImage *img;
3458 EomWindow *window;
3459 int response;
3460 int n_images;
3461 gboolean success;
3462 gboolean can_trash;
3463 const gchar *action_name;
3464
3465 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)
;
3466
3467 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3468 priv = window->priv;
3469 list = priv->store;
3470
3471 n_images = eom_thumb_view_get_n_selected (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3472
3473 if (n_images < 1) return;
3474
3475 /* save position of selected image after the deletion */
3476 images = eom_thumb_view_get_selected_images (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
);
3477
3478 g_assert (images != NULL)do { if (images != ((void*)0)) ; else g_assertion_message_expr
("EOM", "eom-window.c", 3478, ((const char*) (__func__)), "images != NULL"
); } while (0)
;
3479
3480 /* HACK: eom_list_store_get_n_selected return list in reverse order */
3481 images = g_list_reverse (images);
3482
3483 can_trash = eom_window_all_images_trasheable (images);
3484
3485 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3486 action_name = gtk_action_get_name (action);
3487 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3488
3489 if (g_ascii_strcasecmp (action_name, "Delete") == 0 ||
3490 can_trash == FALSE(0)) {
3491 response = show_move_to_trash_confirm_dialog (window, images, can_trash);
3492
3493 if (response != GTK_RESPONSE_OK) return;
3494 }
3495
3496 pos = eom_list_store_get_pos_by_image (list, EOM_IMAGE (images->data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((images->data)), ((eom_image_get_type ()))))))
);
3497
3498 /* FIXME: make a nice progress dialog */
3499 /* Do the work actually. First try to delete the image from the disk. If this
3500 * is successful, remove it from the screen. Otherwise show error dialog.
3501 */
3502 for (it = images; it != NULL((void*)0); it = it->next) {
3503 GError *error = NULL((void*)0);
3504 EomImage *image;
3505
3506 image = EOM_IMAGE (it->data)((((EomImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((it->data)), ((eom_image_get_type ()))))))
;
3507
3508 success = move_to_trash_real (image, &error);
3509
3510 if (success) {
3511 eom_list_store_remove_image (list, image);
3512 } else {
3513 char *header;
3514 GtkWidget *dlg;
3515
3516 header = g_strdup_printf (_("Error on deleting image %s")gettext ("Error on deleting image %s"),
3517 eom_image_get_caption (image));
3518
3519 dlg = gtk_message_dialog_new (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
3520 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
3521 GTK_MESSAGE_ERROR,
3522 GTK_BUTTONS_OK,
3523 "%s", header);
3524
3525 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dlg)), ((gtk_message_dialog_get_type ()))))
))
,
3526 "%s", error->message);
3527
3528 gtk_dialog_run (GTK_DIALOG (dlg)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((gtk_dialog_get_type ()))))))
);
3529
3530 gtk_widget_destroy (dlg);
3531
3532 g_free (header);
3533 }
3534 }
3535
3536 /* free list */
3537 g_list_free_full (images, g_object_unref);
3538
3539 /* select image at previously saved position */
3540 pos = MIN (pos, eom_list_store_length (list) - 1)(((pos) < (eom_list_store_length (list) - 1)) ? (pos) : (eom_list_store_length
(list) - 1))
;
3541
3542 if (pos >= 0) {
3543 img = eom_list_store_get_image_by_pos (list, pos);
3544
3545 eom_thumb_view_set_current_image (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3546 img,
3547 TRUE(!(0)));
3548
3549 if (img != NULL((void*)0)) {
3550 g_object_unref (img);
3551 }
3552 }
3553}
3554
3555static void
3556eom_window_cmd_fullscreen (GtkAction *action, gpointer user_data)
3557{
3558 EomWindow *window;
3559 gboolean fullscreen;
3560
3561 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)
;
3562
3563 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3563, ((const char*) (__func__
))
);
3564
3565 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3566
3567 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3568 fullscreen = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3569 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3570
3571 if (fullscreen) {
3572 eom_window_run_fullscreen (window, FALSE(0));
3573 } else {
3574 eom_window_stop_fullscreen (window, FALSE(0));
3575 }
3576}
3577
3578static void
3579eom_window_cmd_slideshow (GtkAction *action, gpointer user_data)
3580{
3581 EomWindow *window;
3582 gboolean slideshow;
3583
3584 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)
;
3585
3586 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3586, ((const char*) (__func__
))
);
3587
3588 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3589
3590 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3591 slideshow = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
3592 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3593
3594 if (slideshow) {
3595 eom_window_run_fullscreen (window, TRUE(!(0)));
3596 } else {
3597 eom_window_stop_fullscreen (window, TRUE(!(0)));
3598 }
3599}
3600
3601static void
3602eom_window_cmd_pause_slideshow (GtkAction *action, gpointer user_data)
3603{
3604 EomWindow *window;
3605 gboolean slideshow;
3606
3607 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)
;
3608
3609 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3609, ((const char*) (__func__
))
);
3610
3611 window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
3612
3613 slideshow = window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW;
3614
3615 if (!slideshow && window->priv->mode != EOM_WINDOW_MODE_FULLSCREEN)
3616 return;
3617
3618 eom_window_run_fullscreen (window, !slideshow);
3619}
3620
3621static void
3622eom_window_cmd_zoom_in (GtkAction *action, gpointer user_data)
3623{
3624 EomWindowPrivate *priv;
3625
3626 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)
;
3627
3628 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3628, ((const char*) (__func__
))
);
3629
3630 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3631
3632 if (priv->view) {
3633 eom_scroll_view_zoom_in (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3634 }
3635}
3636
3637static void
3638eom_window_cmd_zoom_out (GtkAction *action, gpointer user_data)
3639{
3640 EomWindowPrivate *priv;
3641
3642 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)
;
3643
3644 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3644, ((const char*) (__func__
))
);
3645
3646 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3647
3648 if (priv->view) {
3649 eom_scroll_view_zoom_out (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, FALSE(0));
3650 }
3651}
3652
3653static void
3654eom_window_cmd_zoom_normal (GtkAction *action, gpointer user_data)
3655{
3656 EomWindowPrivate *priv;
3657
3658 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)
;
3659
3660 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3660, ((const char*) (__func__
))
);
3661
3662 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3663
3664 if (priv->view) {
3665 eom_scroll_view_set_zoom (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
, 1.0);
3666 }
3667}
3668
3669static void
3670eom_window_cmd_zoom_fit (GtkAction *action, gpointer user_data)
3671{
3672 EomWindowPrivate *priv;
3673
3674 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)
;
3675
3676 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3676, ((const char*) (__func__
))
);
3677
3678 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3679
3680 if (priv->view) {
3681 eom_scroll_view_zoom_fit (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
);
3682 }
3683}
3684
3685static void
3686eom_window_cmd_go_prev (GtkAction *action, gpointer user_data)
3687{
3688 EomWindowPrivate *priv;
3689
3690 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)
;
3691
3692 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3692, ((const char*) (__func__
))
);
3693
3694 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3695
3696 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3697 EOM_THUMB_VIEW_SELECT_LEFT);
3698}
3699
3700static void
3701eom_window_cmd_go_next (GtkAction *action, gpointer user_data)
3702{
3703 EomWindowPrivate *priv;
3704
3705 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)
;
3706
3707 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3707, ((const char*) (__func__
))
);
3708
3709 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3710
3711 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3712 EOM_THUMB_VIEW_SELECT_RIGHT);
3713}
3714
3715static void
3716eom_window_cmd_go_first (GtkAction *action, gpointer user_data)
3717{
3718 EomWindowPrivate *priv;
3719
3720 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)
;
3721
3722 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3722, ((const char*) (__func__
))
);
3723
3724 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3725
3726 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3727 EOM_THUMB_VIEW_SELECT_FIRST);
3728}
3729
3730static void
3731eom_window_cmd_go_last (GtkAction *action, gpointer user_data)
3732{
3733 EomWindowPrivate *priv;
3734
3735 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)
;
3736
3737 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3737, ((const char*) (__func__
))
);
3738
3739 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3740
3741 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3742 EOM_THUMB_VIEW_SELECT_LAST);
3743}
3744
3745static void
3746eom_window_cmd_go_random (GtkAction *action, gpointer user_data)
3747{
3748 EomWindowPrivate *priv;
3749
3750 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)
;
3751
3752 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 3752, ((const char*) (__func__
))
);
3753
3754 priv = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
->priv;
3755
3756 eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
3757 EOM_THUMB_VIEW_SELECT_RANDOM);
3758}
3759
3760static const GtkActionEntry action_entries_window[] = {
3761 { "Image", NULL((void*)0), N_("_Image")("_Image"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3762 { "Edit", NULL((void*)0), N_("_Edit")("_Edit"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3763 { "View", NULL((void*)0), N_("_View")("_View"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3764 { "Go", NULL((void*)0), N_("_Go")("_Go"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3765 { "Tools", NULL((void*)0), N_("_Tools")("_Tools"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3766 { "Help", NULL((void*)0), N_("_Help")("_Help"), NULL((void*)0), NULL((void*)0), NULL((void*)0) },
3767
3768 { "ImageOpen", "document-open", N_("_Open…")("_Open…"), "<control>O",
3769 N_("Open a file")("Open a file"),
3770 G_CALLBACK (eom_window_cmd_file_open)((GCallback) (eom_window_cmd_file_open)) },
3771 { "ImageClose", "window-close", N_("_Close")("_Close"), "<control>W",
3772 N_("Close window")("Close window"),
3773 G_CALLBACK (eom_window_cmd_close_window)((GCallback) (eom_window_cmd_close_window)) },
3774 { "EditToolbar", NULL((void*)0), N_("T_oolbar")("T_oolbar"), NULL((void*)0),
3775 N_("Edit the application toolbar")("Edit the application toolbar"),
3776 G_CALLBACK (eom_window_cmd_edit_toolbar)((GCallback) (eom_window_cmd_edit_toolbar)) },
3777 { "EditPreferences", "preferences-desktop", N_("Prefere_nces")("Prefere_nces"), NULL((void*)0),
3778 N_("Preferences for Eye of MATE")("Preferences for Eye of MATE"),
3779 G_CALLBACK (eom_window_cmd_preferences)((GCallback) (eom_window_cmd_preferences)) },
3780 { "HelpManual", "help-browser", N_("_Contents")("_Contents"), "F1",
3781 N_("Help on this application")("Help on this application"),
3782 G_CALLBACK (eom_window_cmd_help)((GCallback) (eom_window_cmd_help)) },
3783 { "HelpAbout", "help-about", N_("_About")("_About"), NULL((void*)0),
3784 N_("About this application")("About this application"),
3785 G_CALLBACK (eom_window_cmd_about)((GCallback) (eom_window_cmd_about)) }
3786};
3787
3788static const GtkToggleActionEntry toggle_entries_window[] = {
3789 { "ViewToolbar", NULL((void*)0), N_("_Toolbar")("_Toolbar"), NULL((void*)0),
3790 N_("Changes the visibility of the toolbar in the current window")("Changes the visibility of the toolbar in the current window"
)
,
3791 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3792 { "ViewStatusbar", NULL((void*)0), N_("_Statusbar")("_Statusbar"), NULL((void*)0),
3793 N_("Changes the visibility of the statusbar in the current window")("Changes the visibility of the statusbar in the current window"
)
,
3794 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3795 { "ViewImageCollection", "eom-image-collection", N_("_Image Collection")("_Image Collection"), "<control>F9",
3796 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"
)
,
3797 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3798 { "ViewSidebar", NULL((void*)0), N_("Side _Pane")("Side _Pane"), "F9",
3799 N_("Changes the visibility of the side pane in the current window")("Changes the visibility of the side pane in the current window"
)
,
3800 G_CALLBACK (eom_window_cmd_show_hide_bar)((GCallback) (eom_window_cmd_show_hide_bar)), TRUE(!(0)) },
3801};
3802
3803static const GtkActionEntry action_entries_image[] = {
3804 { "ImageSave", "document-save", N_("_Save")("_Save"), "<control>s",
3805 N_("Save changes in currently selected images")("Save changes in currently selected images"),
3806 G_CALLBACK (eom_window_cmd_save)((GCallback) (eom_window_cmd_save)) },
3807 { "ImageOpenWith", NULL((void*)0), N_("Open _with")("Open _with"), NULL((void*)0),
3808 N_("Open the selected image with a different application")("Open the selected image with a different application"),
3809 NULL((void*)0)},
3810 { "ImageSaveAs", "document-save-as", N_("Save _As…")("Save _As…"), "<control><shift>s",
3811 N_("Save the selected images with a different name")("Save the selected images with a different name"),
3812 G_CALLBACK (eom_window_cmd_save_as)((GCallback) (eom_window_cmd_save_as)) },
3813 { "ImageOpenContainingFolder", "folder", N_("Open Containing _Folder")("Open Containing _Folder"), NULL((void*)0),
3814 N_("Show the folder which contains this file in the file manager")("Show the folder which contains this file in the file manager"
)
,
3815 G_CALLBACK (eom_window_cmd_open_containing_folder)((GCallback) (eom_window_cmd_open_containing_folder)) },
3816 { "ImagePrint", "document-print", N_("_Print…")("_Print…"), "<control>p",
3817 N_("Print the selected image")("Print the selected image"),
3818 G_CALLBACK (eom_window_cmd_print)((GCallback) (eom_window_cmd_print)) },
3819 { "ImageProperties", "document-properties", N_("Prope_rties")("Prope_rties"), "<alt>Return",
3820 N_("Show the properties and metadata of the selected image")("Show the properties and metadata of the selected image"),
3821 G_CALLBACK (eom_window_cmd_properties)((GCallback) (eom_window_cmd_properties)) },
3822 { "EditUndo", "edit-undo", N_("_Undo")("_Undo"), "<control>z",
3823 N_("Undo the last change in the image")("Undo the last change in the image"),
3824 G_CALLBACK (eom_window_cmd_undo)((GCallback) (eom_window_cmd_undo)) },
3825 { "EditFlipHorizontal", "object-flip-horizontal", N_("Flip _Horizontal")("Flip _Horizontal"), NULL((void*)0),
3826 N_("Mirror the image horizontally")("Mirror the image horizontally"),
3827 G_CALLBACK (eom_window_cmd_flip_horizontal)((GCallback) (eom_window_cmd_flip_horizontal)) },
3828 { "EditFlipVertical", "object-flip-vertical", N_("Flip _Vertical")("Flip _Vertical"), NULL((void*)0),
3829 N_("Mirror the image vertically")("Mirror the image vertically"),
3830 G_CALLBACK (eom_window_cmd_flip_vertical)((GCallback) (eom_window_cmd_flip_vertical)) },
3831 { "EditRotate90", "object-rotate-right", N_("_Rotate Clockwise")("_Rotate Clockwise"), "<control>r",
3832 N_("Rotate the image 90 degrees to the right")("Rotate the image 90 degrees to the right"),
3833 G_CALLBACK (eom_window_cmd_rotate_90)((GCallback) (eom_window_cmd_rotate_90)) },
3834 { "EditRotate270", "object-rotate-left", N_("Rotate Counterc_lockwise")("Rotate Counterc_lockwise"), "<ctrl><shift>r",
3835 N_("Rotate the image 90 degrees to the left")("Rotate the image 90 degrees to the left"),
3836 G_CALLBACK (eom_window_cmd_rotate_270)((GCallback) (eom_window_cmd_rotate_270)) },
3837 { "ImageSetAsWallpaper", NULL((void*)0), N_("Set as _Desktop Background")("Set as _Desktop Background"),
3838 "<control>F8", N_("Set the selected image as the desktop background")("Set the selected image as the desktop background"),
3839 G_CALLBACK (eom_window_cmd_wallpaper)((GCallback) (eom_window_cmd_wallpaper)) },
3840 { "EditMoveToTrash", "user-trash", N_("Move to _Trash")("Move to _Trash"), NULL((void*)0),
3841 N_("Move the selected image to the trash folder")("Move the selected image to the trash folder"),
3842 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3843 { "EditCopyImage", "edit-copy", N_("_Copy")("_Copy"), "<control>C",
3844 N_("Copy the selected image to the clipboard")("Copy the selected image to the clipboard"),
3845 G_CALLBACK (eom_window_cmd_copy_image)((GCallback) (eom_window_cmd_copy_image)) },
3846 { "ViewZoomIn", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>plus",
3847 N_("Enlarge the image")("Enlarge the image"),
3848 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3849 { "ViewZoomOut", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>minus",
3850 N_("Shrink the image")("Shrink the image"),
3851 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3852 { "ViewZoomNormal", "zoom-original", N_("_Normal Size")("_Normal Size"), "<control>0",
3853 N_("Show the image at its normal size")("Show the image at its normal size"),
3854 G_CALLBACK (eom_window_cmd_zoom_normal)((GCallback) (eom_window_cmd_zoom_normal)) },
3855 { "ViewZoomFit", "zoom-fit-best", N_("_Best Fit")("_Best Fit"), "F",
3856 N_("Fit the image to the window")("Fit the image to the window"),
3857 G_CALLBACK (eom_window_cmd_zoom_fit)((GCallback) (eom_window_cmd_zoom_fit)) },
3858 { "ControlEqual", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>equal",
3859 N_("Enlarge the image")("Enlarge the image"),
3860 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3861 { "ControlKpAdd", "zoom-in", N_("_Zoom In")("_Zoom In"), "<control>KP_Add",
3862 N_("Shrink the image")("Shrink the image"),
3863 G_CALLBACK (eom_window_cmd_zoom_in)((GCallback) (eom_window_cmd_zoom_in)) },
3864 { "ControlKpSub", "zoom-out", N_("Zoom _Out")("Zoom _Out"), "<control>KP_Subtract",
3865 N_("Shrink the image")("Shrink the image"),
3866 G_CALLBACK (eom_window_cmd_zoom_out)((GCallback) (eom_window_cmd_zoom_out)) },
3867 { "Delete", NULL((void*)0), N_("Move to _Trash")("Move to _Trash"), "Delete",
3868 NULL((void*)0),
3869 G_CALLBACK (eom_window_cmd_move_to_trash)((GCallback) (eom_window_cmd_move_to_trash)) },
3870};
3871
3872static const GtkToggleActionEntry toggle_entries_image[] = {
3873 { "ViewFullscreen", "view-fullscreen", N_("_Fullscreen")("_Fullscreen"), "F11",
3874 N_("Show the current image in fullscreen mode")("Show the current image in fullscreen mode"),
3875 G_CALLBACK (eom_window_cmd_fullscreen)((GCallback) (eom_window_cmd_fullscreen)), FALSE(0) },
3876 { "PauseSlideshow", "media-playback-pause", N_("Pause Slideshow")("Pause Slideshow"),
3877 NULL((void*)0), N_("Pause or resume the slideshow")("Pause or resume the slideshow"),
3878 G_CALLBACK (eom_window_cmd_pause_slideshow)((GCallback) (eom_window_cmd_pause_slideshow)), FALSE(0) },
3879};
3880
3881static const GtkActionEntry action_entries_collection[] = {
3882 { "GoPrevious", "go-previous", N_("_Previous Image")("_Previous Image"), "<Alt>Left",
3883 N_("Go to the previous image of the collection")("Go to the previous image of the collection"),
3884 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3885 { "GoNext", "go-next", N_("_Next Image")("_Next Image"), "<Alt>Right",
3886 N_("Go to the next image of the collection")("Go to the next image of the collection"),
3887 G_CALLBACK (eom_window_cmd_go_next)((GCallback) (eom_window_cmd_go_next)) },
3888 { "GoFirst", "go-first", N_("_First Image")("_First Image"), "<Alt>Home",
3889 N_("Go to the first image of the collection")("Go to the first image of the collection"),
3890 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3891 { "GoLast", "go-last", N_("_Last Image")("_Last Image"), "<Alt>End",
3892 N_("Go to the last image of the collection")("Go to the last image of the collection"),
3893 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3894 { "GoRandom", NULL((void*)0), N_("_Random Image")("_Random Image"), "<control>M",
3895 N_("Go to a random image of the collection")("Go to a random image of the collection"),
3896 G_CALLBACK (eom_window_cmd_go_random)((GCallback) (eom_window_cmd_go_random)) },
3897 { "BackSpace", NULL((void*)0), N_("_Previous Image")("_Previous Image"), "BackSpace",
3898 NULL((void*)0),
3899 G_CALLBACK (eom_window_cmd_go_prev)((GCallback) (eom_window_cmd_go_prev)) },
3900 { "Home", NULL((void*)0), N_("_First Image")("_First Image"), "Home",
3901 NULL((void*)0),
3902 G_CALLBACK (eom_window_cmd_go_first)((GCallback) (eom_window_cmd_go_first)) },
3903 { "End", NULL((void*)0), N_("_Last Image")("_Last Image"), "End",
3904 NULL((void*)0),
3905 G_CALLBACK (eom_window_cmd_go_last)((GCallback) (eom_window_cmd_go_last)) },
3906};
3907
3908static const GtkToggleActionEntry toggle_entries_collection[] = {
3909 { "ViewSlideshow", "slideshow-play", N_("S_lideshow")("S_lideshow"), "F5",
3910 N_("Start a slideshow view of the images")("Start a slideshow view of the images"),
3911 G_CALLBACK (eom_window_cmd_slideshow)((GCallback) (eom_window_cmd_slideshow)), FALSE(0) },
3912};
3913
3914static void
3915menu_item_select_cb (GtkMenuItem *proxy, EomWindow *window)
3916{
3917 GtkAction *action;
3918 char *message;
3919
3920 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3921 action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)((((GtkActivatable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((gtk_activatable_get_type ()))))))
);
3922 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
3923
3924 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)
;
3925
3926 g_object_get (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "tooltip", &message, NULL((void*)0));
3927
3928 if (message) {
3929 gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3930 window->priv->tip_message_cid, message);
3931 g_free (message);
3932 }
3933}
3934
3935static void
3936menu_item_deselect_cb (GtkMenuItem *proxy, EomWindow *window)
3937{
3938 gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->statusbar)), ((gtk_statusbar_get_type
()))))))
,
3939 window->priv->tip_message_cid);
3940}
3941
3942static void
3943connect_proxy_cb (GtkUIManager *manager,
3944 GtkAction *action,
3945 GtkWidget *proxy,
3946 EomWindow *window)
3947{
3948 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; }))))
) {
3949 disconnect_proxy_cb (manager, action, proxy, window);
3950 g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
3951 G_CALLBACK (menu_item_select_cb),g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
3952 window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
3953 g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3954 G_CALLBACK (menu_item_deselect_cb),g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
3955 window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) (
menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
3956 }
3957}
3958
3959static void
3960disconnect_proxy_cb (GtkUIManager *manager,
3961 GtkAction *action,
3962 GtkWidget *proxy,
3963 EomWindow *window)
3964{
3965 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; }))))
) {
3966 g_signal_handlers_disconnect_by_func (proxy,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_select_cb), (window))
3967 menu_item_select_cb,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_select_cb), (window))
3968 window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_select_cb), (window))
;
3969 g_signal_handlers_disconnect_by_func (proxy,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_deselect_cb), (window))
3970 menu_item_deselect_cb,g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_deselect_cb), (window))
3971 window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (menu_item_deselect_cb), (window))
;
3972 }
3973}
3974
3975static void
3976set_action_properties (GtkActionGroup *window_group,
3977 GtkActionGroup *image_group,
3978 GtkActionGroup *collection_group)
3979{
3980 GtkAction *action;
3981
3982 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
3983 action = gtk_action_group_get_action (collection_group, "GoPrevious");
3984 g_object_set (action, "short_label", _("_Previous")gettext ("_Previous"), NULL((void*)0));
3985 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3986
3987 action = gtk_action_group_get_action (collection_group, "GoNext");
3988 g_object_set (action, "short_label", _("_Next")gettext ("_Next"), NULL((void*)0));
3989 g_object_set (action, "is-important", TRUE(!(0)), NULL((void*)0));
3990
3991 action = gtk_action_group_get_action (image_group, "EditRotate90");
3992 g_object_set (action, "short_label", _("Right")gettext ("Right"), NULL((void*)0));
3993
3994 action = gtk_action_group_get_action (image_group, "EditRotate270");
3995 g_object_set (action, "short_label", _("Left")gettext ("Left"), NULL((void*)0));
3996
3997 action = gtk_action_group_get_action (image_group, "ImageOpenContainingFolder");
3998 g_object_set (action, "short_label", _("Open Folder")gettext ("Open Folder"), NULL((void*)0));
3999
4000 action = gtk_action_group_get_action (image_group, "ViewZoomIn");
4001 g_object_set (action, "short_label", _("In")gettext ("In"), NULL((void*)0));
4002
4003 action = gtk_action_group_get_action (image_group, "ViewZoomOut");
4004 g_object_set (action, "short_label", _("Out")gettext ("Out"), NULL((void*)0));
4005
4006 action = gtk_action_group_get_action (image_group, "ViewZoomNormal");
4007 g_object_set (action, "short_label", _("Normal")gettext ("Normal"), NULL((void*)0));
4008
4009 action = gtk_action_group_get_action (image_group, "ViewZoomFit");
4010 g_object_set (action, "short_label", _("Fit")gettext ("Fit"), NULL((void*)0));
4011
4012 action = gtk_action_group_get_action (window_group, "ViewImageCollection");
4013 g_object_set (action, "short_label", _("Collection")gettext ("Collection"), NULL((void*)0));
4014
4015 action = gtk_action_group_get_action (image_group, "EditMoveToTrash");
4016 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));
4017 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4018}
4019
4020static gint
4021sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
4022{
4023 gboolean has_eom_a, has_eom_b;
4024
4025 /* We need to check this first as gtk_recent_info_get_application_info
4026 * will treat it as a non-fatal error when the GtkRecentInfo doesn't
4027 * have the application registered. */
4028 has_eom_a = gtk_recent_info_has_application (a,
4029 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4030 has_eom_b = gtk_recent_info_has_application (b,
4031 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer");
4032 if (has_eom_a && has_eom_b) {
4033 time_t time_a, time_b;
4034
4035 /* These should not fail as we already checked that
4036 * the application is registered with the info objects */
4037 gtk_recent_info_get_application_info (a,
4038 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4039 NULL((void*)0),
4040 NULL((void*)0),
4041 &time_a);
4042 gtk_recent_info_get_application_info (b,
4043 EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer",
4044 NULL((void*)0),
4045 NULL((void*)0),
4046 &time_b);
4047
4048 return (time_b - time_a);
4049 } else if (has_eom_a) {
4050 return -1;
4051 } else if (has_eom_b) {
4052 return 1;
4053 }
4054
4055 return 0;
4056}
4057
4058static void
4059eom_window_update_recent_files_menu (EomWindow *window)
4060{
4061 EomWindowPrivate *priv;
4062 GList *actions = NULL((void*)0), *li = NULL((void*)0), *items = NULL((void*)0);
4063 guint count_recent = 0;
4064
4065 priv = window->priv;
4066
4067 if (priv->recent_menu_id != 0)
4068 gtk_ui_manager_remove_ui (priv->ui_mgr, priv->recent_menu_id);
4069
4070 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4071 actions = gtk_action_group_list_actions (priv->actions_recent);
4072
4073 for (li = actions; li != NULL((void*)0); li = li->next) {
4074 g_signal_handlers_disconnect_by_func (li->data,g_signal_handlers_disconnect_matched ((li->data), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_open_recent_cb), (window))
4075 eom_window_open_recent_cb,g_signal_handlers_disconnect_matched ((li->data), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_open_recent_cb), (window))
4076 window)g_signal_handlers_disconnect_matched ((li->data), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (eom_window_open_recent_cb), (window))
;
4077
4078 gtk_action_group_remove_action (priv->actions_recent,
4079 GTK_ACTION (li->data)((((GtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((li->data)), ((gtk_action_get_type ()))))))
);
4080 }
4081 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4082
4083 g_list_free (actions);
4084
4085 priv->recent_menu_id = gtk_ui_manager_new_merge_id (priv->ui_mgr);
4086 items = gtk_recent_manager_get_items (gtk_recent_manager_get_default());
4087 items = g_list_sort (items, (GCompareFunc) sort_recents_mru);
4088
4089 for (li = items; li != NULL((void*)0) && count_recent < EOM_RECENT_FILES_LIMIT5; li = li->next) {
4090 gchar *action_name;
4091 gchar *label;
4092 gchar *tip;
4093 gchar **display_name;
4094 gchar *label_filename;
4095 GtkAction *action;
4096 GtkRecentInfo *info = li->data;
4097
4098 /* Sorting moves non-EOM files to the end of the list.
4099 * So no file of interest will follow if this test fails */
4100 if (!gtk_recent_info_has_application (info, EOM_RECENT_FILES_APP_NAME"Eye of MATE Image Viewer"))
4101 break;
4102
4103 count_recent++;
4104
4105 action_name = g_strdup_printf ("recent-info-%d", count_recent);
4106 display_name = g_strsplit (gtk_recent_info_get_display_name (info), "_", -1);
4107 label_filename = g_strjoinv ("__", display_name);
4108 label = g_strdup_printf ("%s_%d. %s",
4109 (is_rtl(gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "\xE2\x80\x8F" : ""), count_recent, label_filename);
4110 g_free (label_filename);
4111 g_strfreev (display_name);
4112
4113 tip = gtk_recent_info_get_uri_display (info);
4114
4115 /* This is a workaround for a bug (#351945) regarding
4116 * gtk_recent_info_get_uri_display() and remote URIs.
4117 * mate_vfs_format_uri_for_display is sufficient here
4118 * since the password gets stripped when adding the
4119 * file to the recently used list. */
4120 if (tip == NULL((void*)0))
4121 tip = g_uri_unescape_string (gtk_recent_info_get_uri (info), NULL((void*)0));
4122
4123 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4124 action = gtk_action_new (action_name, label, tip, NULL((void*)0));
4125 gtk_action_set_always_show_image (action, TRUE(!(0)));
4126 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4127
4128 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "gtk-recent-info",
4129 gtk_recent_info_ref (info),
4130 (GDestroyNotify) gtk_recent_info_unref);
4131
4132 g_object_set (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "icon-name", "image-x-generic", NULL((void*)0));
4133
4134 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4135 G_CALLBACK (eom_window_open_recent_cb),g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4136 window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_recent_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4137
4138 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4139 gtk_action_group_add_action (priv->actions_recent, action);
4140 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4141
4142 g_object_unref (action);
4143
4144 gtk_ui_manager_add_ui (priv->ui_mgr, priv->recent_menu_id,
4145 "/MainMenu/Image/RecentDocuments",
4146 action_name, action_name,
4147 GTK_UI_MANAGER_AUTO, FALSE(0));
4148
4149 g_free (action_name);
4150 g_free (label);
4151 g_free (tip);
4152 }
4153
4154 g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
4155}
4156
4157static void
4158eom_window_recent_manager_changed_cb (GtkRecentManager *manager, EomWindow *window)
4159{
4160 eom_window_update_recent_files_menu (window);
4161}
4162
4163static void
4164eom_window_drag_data_received (GtkWidget *widget,
4165 GdkDragContext *context,
4166 gint x, gint y,
4167 GtkSelectionData *selection_data,
4168 guint info, guint time)
4169{
4170 GSList *file_list;
4171 EomWindow *window;
4172 GdkAtom target;
4173 GtkWidget *src;
4174
4175 target = gtk_selection_data_get_target (selection_data);
4176
4177 if (!gtk_targets_include_uri (&target, 1))
4178 return;
4179
4180 /* if the request is from another process this will return NULL */
4181 src = gtk_drag_get_source_widget (context);
4182
4183 /* if the drag request originates from the current eom instance, ignore
4184 the request if the source window is the same as the dest window */
4185 if (src &&
4186 gtk_widget_get_toplevel (src) == gtk_widget_get_toplevel (widget))
4187 {
4188 gdk_drag_status (context, 0, time);
4189 return;
4190 }
4191
4192 if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_COPY) {
4193 window = EOM_WINDOW (widget)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))
;
4194
4195 file_list = eom_util_parse_uri_string_list_to_file_list ((const gchar *) gtk_selection_data_get_data (selection_data));
4196
4197 eom_window_open_file_list (window, file_list);
4198 }
4199}
4200
4201static void
4202eom_window_set_drag_dest (EomWindow *window)
4203{
4204 gtk_drag_dest_set (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
4205 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
4206 NULL((void*)0), 0,
4207 GDK_ACTION_COPY | GDK_ACTION_ASK);
4208 gtk_drag_dest_add_uri_targets (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
4209}
4210
4211static void
4212eom_window_sidebar_visibility_changed (GtkWidget *widget, EomWindow *window)
4213{
4214 GtkAction *action;
4215 gboolean visible;
4216
4217 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4218 visible = gtk_widget_get_visible (window->priv->sidebar);
4219
4220 action = gtk_action_group_get_action (window->priv->actions_window,
4221 "ViewSidebar");
4222
4223 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
) != visible)
4224 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, visible);
4225 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4226
4227 /* Focus the image */
4228 if (!visible && window->priv->image != NULL((void*)0))
4229 gtk_widget_grab_focus (window->priv->view);
4230}
4231
4232static void
4233eom_window_sidebar_page_added (EomSidebar *sidebar,
4234 GtkWidget *main_widget,
4235 EomWindow *window)
4236{
4237 if (eom_sidebar_get_n_pages (sidebar) == 1) {
4238 GtkAction *action;
4239 gboolean show;
4240
4241 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4242 action = gtk_action_group_get_action (window->priv->actions_window,
4243 "ViewSidebar");
4244
4245 gtk_action_set_sensitive (action, TRUE(!(0)));
4246
4247 show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
4248 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4249
4250 if (show)
4251 gtk_widget_show (GTK_WIDGET (sidebar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidebar)), ((gtk_widget_get_type ()))))))
);
4252 }
4253}
4254static void
4255eom_window_sidebar_page_removed (EomSidebar *sidebar,
4256 GtkWidget *main_widget,
4257 EomWindow *window)
4258{
4259 if (eom_sidebar_is_empty (sidebar)) {
4260 GtkAction *action;
4261
4262 gtk_widget_hide (GTK_WIDGET (sidebar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sidebar)), ((gtk_widget_get_type ()))))))
);
4263
4264 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4265 action = gtk_action_group_get_action (window->priv->actions_window,
4266 "ViewSidebar");
4267
4268 gtk_action_set_sensitive (action, FALSE(0));
4269 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4270 }
4271}
4272
4273static void
4274eom_window_finish_saving (EomWindow *window)
4275{
4276 EomWindowPrivate *priv = window->priv;
4277
4278 gtk_widget_set_sensitive (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, FALSE(0));
4279
4280 do {
4281 gtk_main_iteration ();
4282 } while (priv->save_job != NULL((void*)0));
4283}
4284
4285static GAppInfo *
4286get_appinfo_for_editor (EomWindow *window)
4287{
4288 /* We want this function to always return the same thing, not
4289 * just for performance reasons, but because if someone edits
4290 * GConf while eom is running, the application could get into an
4291 * inconsistent state. If the editor exists once, it gets added
4292 * to the "available" list of the EggToolbarsModel (for which
4293 * there is no API to remove it). If later the editor no longer
4294 * existed when constructing a new window, we'd be unable to
4295 * construct a GtkAction for the editor for that window, causing
4296 * assertion failures when viewing the "Edit Toolbars" dialog
4297 * (item is available, but can't find the GtkAction for it).
4298 *
4299 * By ensuring we keep the GAppInfo around, we avoid the
4300 * possibility of that situation occurring.
4301 */
4302 static GDesktopAppInfo *app_info = NULL((void*)0);
4303 static gboolean initialised;
4304
4305 if (!initialised) {
4306 gchar *editor;
4307
4308 editor = g_settings_get_string (window->priv->ui_settings,
4309 EOM_CONF_UI_EXTERNAL_EDITOR"external-editor");
4310
4311 if (editor != NULL((void*)0)) {
4312 app_info = g_desktop_app_info_new (editor);
4313 }
4314
4315 initialised = TRUE(!(0));
4316 g_free (editor);
4317 }
4318
4319 return (GAppInfo *) app_info;
4320}
4321
4322static void
4323eom_window_open_editor (GtkAction *action,
4324 EomWindow *window)
4325{
4326 GdkAppLaunchContext *context;
4327 GAppInfo *app_info;
4328 GList *files = NULL((void*)0);
4329 GFile *file;
4330
4331 app_info = get_appinfo_for_editor (window);
4332
4333 if (app_info == NULL((void*)0))
4334 return;
4335
4336 context = gdk_display_get_app_launch_context (
4337 gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
4338 gdk_app_launch_context_set_screen (context,
4339 gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
4340 gdk_app_launch_context_set_icon (context,
4341 g_app_info_get_icon (app_info));
4342 gdk_app_launch_context_set_timestamp (context,
4343 gtk_get_current_event_time ());
4344
4345 file = eom_image_get_file (window->priv->image);
4346 files = g_list_append (files, file);
4347
4348 g_app_info_launch (app_info, files,
4349 G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
, NULL((void*)0));
4350
4351 g_list_free (files);
4352 g_object_unref (file);
4353 g_object_unref (context);
4354}
4355
4356static void
4357eom_window_add_open_editor_action (EomWindow *window)
4358{
4359 EggToolbarsModel *model;
4360 GAppInfo *app_info;
4361 GtkAction *action;
4362 gchar *tooltip;
4363
4364 app_info = get_appinfo_for_editor (window);
4365
4366 if (app_info == NULL((void*)0))
4367 return;
4368
4369 model = eom_application_get_toolbars_model (EOM_APP(eom_application_get_instance ()));
4370 egg_toolbars_model_set_name_flags (model, "OpenEditor",
4371 EGG_TB_MODEL_NAME_KNOWN);
4372
4373 tooltip = g_strdup_printf (_("Edit the current image using %s")gettext ("Edit the current image using %s"),
4374 g_app_info_get_name (app_info));
4375 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4376 action = gtk_action_new ("OpenEditor", _("Edit Image")gettext ("Edit Image"), tooltip, NULL((void*)0));
4377 gtk_action_set_gicon (action, g_app_info_get_icon (app_info));
4378 gtk_action_set_is_important (action, TRUE(!(0)));
4379
4380 g_signal_connect (action, "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
4381 G_CALLBACK (eom_window_open_editor),g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
4382 window)g_signal_connect_data ((action), ("activate"), (((GCallback) (
eom_window_open_editor))), (window), ((void*)0), (GConnectFlags
) 0)
;
4383
4384 gtk_action_group_add_action (window->priv->actions_image, action);
4385 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4386
4387 g_object_unref (action);
4388 g_free (tooltip);
4389}
4390
4391static void
4392eom_window_construct_ui (EomWindow *window)
4393{
4394 EomWindowPrivate *priv;
4395
4396 GError *error = NULL((void*)0);
4397
4398 GtkWidget *menubar;
4399 GtkWidget *thumb_popup;
4400 GtkWidget *view_popup;
4401 GtkWidget *hpaned;
4402 GtkWidget *menuitem;
4403
4404 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)
;
4405
4406 priv = window->priv;
4407
4408 priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4409 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, priv->box);
4410 gtk_widget_show (priv->box);
4411
4412 priv->ui_mgr = gtk_ui_manager_new ();
4413
4414 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4415 priv->actions_window = gtk_action_group_new ("MenuActionsWindow");
4416
4417#ifdef ENABLE_NLS1
4418 gtk_action_group_set_translation_domain (priv->actions_window,
4419 GETTEXT_PACKAGE"eom");
4420#endif /* ENABLE_NLS */
4421
4422 gtk_action_group_add_actions (priv->actions_window,
4423 action_entries_window,
4424 G_N_ELEMENTS (action_entries_window)(sizeof (action_entries_window) / sizeof ((action_entries_window
)[0]))
,
4425 window);
4426
4427 gtk_action_group_add_toggle_actions (priv->actions_window,
4428 toggle_entries_window,
4429 G_N_ELEMENTS (toggle_entries_window)(sizeof (toggle_entries_window) / sizeof ((toggle_entries_window
)[0]))
,
4430 window);
4431 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4432
4433 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_window, 0);
4434
4435 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4436 priv->actions_image = gtk_action_group_new ("MenuActionsImage");
4437#ifdef ENABLE_NLS1
4438 gtk_action_group_set_translation_domain (priv->actions_image,
4439 GETTEXT_PACKAGE"eom");
4440#endif /* ENABLE_NLS */
4441
4442 gtk_action_group_add_actions (priv->actions_image,
4443 action_entries_image,
4444 G_N_ELEMENTS (action_entries_image)(sizeof (action_entries_image) / sizeof ((action_entries_image
)[0]))
,
4445 window);
4446
4447 eom_window_add_open_editor_action (window);
4448
4449 gtk_action_group_add_toggle_actions (priv->actions_image,
4450 toggle_entries_image,
4451 G_N_ELEMENTS (toggle_entries_image)(sizeof (toggle_entries_image) / sizeof ((toggle_entries_image
)[0]))
,
4452 window);
4453 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4454
4455 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_image, 0);
4456
4457 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4458 priv->actions_collection = gtk_action_group_new ("MenuActionsCollection");
4459#ifdef ENABLE_NLS1
4460 gtk_action_group_set_translation_domain (priv->actions_collection,
4461 GETTEXT_PACKAGE"eom");
4462#endif /* ENABLE_NLS */
4463
4464 gtk_action_group_add_actions (priv->actions_collection,
4465 action_entries_collection,
4466 G_N_ELEMENTS (action_entries_collection)(sizeof (action_entries_collection) / sizeof ((action_entries_collection
)[0]))
,
4467 window);
4468
4469 gtk_action_group_add_toggle_actions (priv->actions_collection,
4470 toggle_entries_collection,
4471 G_N_ELEMENTS (toggle_entries_collection)(sizeof (toggle_entries_collection) / sizeof ((toggle_entries_collection
)[0]))
,
4472 window);
4473 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4474
4475 set_action_properties (priv->actions_window,
4476 priv->actions_image,
4477 priv->actions_collection);
4478
4479 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_collection, 0);
4480
4481 if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
4482 "/org/mate/eom/ui/eom-ui.xml",
4483 &error)) {
4484 g_warning ("building menus failed: %s", error->message);
4485 g_error_free (error);
4486 }
4487
4488 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)
4489 G_CALLBACK (connect_proxy_cb),g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4490 window)g_signal_connect_data ((priv->ui_mgr), ("connect_proxy"), (
((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4491
4492 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)
4493 G_CALLBACK (disconnect_proxy_cb),g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
4494 window)g_signal_connect_data ((priv->ui_mgr), ("disconnect_proxy"
), (((GCallback) (disconnect_proxy_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
4495
4496 menubar = gtk_ui_manager_get_widget (priv->ui_mgr, "/MainMenu");
4497 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", 4497, ((const
char*) (__func__)), "GTK_IS_WIDGET (menubar)"); } while (0)
;
4498 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
, menubar, FALSE(0), FALSE(0), 0);
4499 gtk_widget_show (menubar);
4500
4501 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4502 "/MainMenu/Edit/EditFlipHorizontal");
4503 gtk_image_menu_item_set_always_show_image (
4504 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4505
4506 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4507 "/MainMenu/Edit/EditFlipVertical");
4508 gtk_image_menu_item_set_always_show_image (
4509 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4510
4511 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4512 "/MainMenu/Edit/EditRotate90");
4513 gtk_image_menu_item_set_always_show_image (
4514 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4515
4516 menuitem = gtk_ui_manager_get_widget (priv->ui_mgr,
4517 "/MainMenu/Edit/EditRotate270");
4518 gtk_image_menu_item_set_always_show_image (
4519 GTK_IMAGE_MENU_ITEM (menuitem)((((GtkImageMenuItem*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((menuitem)), ((gtk_image_menu_item_get_type (
)))))))
, TRUE(!(0)));
4520
4521 priv->toolbar = GTK_WIDGET((((GtkWidget*) (void *) 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 (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,((((GtkWidget*) (void *) 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 "ui-manager", priv->ui_mgr,((((GtkWidget*) (void *) 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 "popup-path", "/ToolbarPopup",((((GtkWidget*) (void *) 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 "model", eom_application_get_toolbars_model (EOM_APP),((((GtkWidget*) (void *) 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
()))))))
4526 NULL))((((GtkWidget*) (void *) 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
()))))))
;
4527
4528 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (priv->toolbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->toolbar)), ((gtk_widget_get_type ()))))))
),
4529 GTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar");
4530
4531 egg_editable_toolbar_show (EGG_EDITABLE_TOOLBAR (priv->toolbar)((((EggEditableToolbar*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((priv->toolbar)), ((egg_editable_toolbar_get_type
()))))))
,
4532 "Toolbar");
4533
4534 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
,
4535 priv->toolbar,
4536 FALSE(0),
4537 FALSE(0),
4538 0);
4539
4540 gtk_widget_show (priv->toolbar);
4541
4542 gtk_window_add_accel_group (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4543 gtk_ui_manager_get_accel_group (priv->ui_mgr));
4544
4545 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push + clang diagnostic ignored "-Wdeprecated-declarations"
+
;
4546 priv->actions_recent = gtk_action_group_new ("RecentFilesActions");
4547#ifdef ENABLE_NLS1
4548 gtk_action_group_set_translation_domain (priv->actions_recent,
4549 GETTEXT_PACKAGE"eom");
4550#endif /* ENABLE_NLS */
4551 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop +;
4552
4553 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)
4554 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)
4555 window)g_signal_connect_data ((gtk_recent_manager_get_default ()), (
"changed"), (((GCallback) (eom_window_recent_manager_changed_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
4556
4557 eom_window_update_recent_files_menu (window);
4558
4559 gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_recent, 0);
4560
4561 priv->cbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
4562 gtk_box_pack_start (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
, priv->cbox, TRUE(!(0)), TRUE(!(0)), 0);
4563 gtk_widget_show (priv->cbox);
4564
4565 priv->statusbar = eom_statusbar_new ();
4566 gtk_box_pack_end (GTK_BOX (priv->box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->box)), ((gtk_box_get_type ()))))))
,
4567 GTK_WIDGET (priv->statusbar)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_widget_get_type ()))))))
,
4568 FALSE(0), FALSE(0), 0);
4569 gtk_widget_show (priv->statusbar);
4570
4571 priv->image_info_message_cid =
4572 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4573 "image_info_message");
4574 priv->tip_message_cid =
4575 gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar)((((GtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->statusbar)), ((gtk_statusbar_get_type ()))))))
,
4576 "tip_message");
4577
4578 priv->layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
4579
4580 hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
4581
4582 priv->sidebar = eom_sidebar_new ();
4583 /* The sidebar shouldn't be shown automatically on show_all(),
4584 but only when the user actually wants it. */
4585 gtk_widget_set_no_show_all (priv->sidebar, TRUE(!(0)));
4586
4587 gtk_widget_set_size_request (priv->sidebar, 210, -1);
4588
4589 g_signal_connect_after (priv->sidebar, "show",g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4590 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)
4591 window)g_signal_connect_data ((priv->sidebar), ("show"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4592
4593 g_signal_connect_after (priv->sidebar, "hide",g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
4594 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)
4595 window)g_signal_connect_data ((priv->sidebar), ("hide"), (((GCallback
) (eom_window_sidebar_visibility_changed))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4596
4597 g_signal_connect_after (priv->sidebar, "page-added",g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
4598 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)
4599 window)g_signal_connect_data ((priv->sidebar), ("page-added"), ((
(GCallback) (eom_window_sidebar_page_added))), (window), ((void
*)0), G_CONNECT_AFTER)
;
4600
4601 g_signal_connect_after (priv->sidebar, "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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((gtk_widget_get_type ()))))))
, 100, 100);
4612 g_signal_connect (priv->view, "zoom_changed",g_signal_connect_data ((priv->view), ("zoom_changed"), (((
GCallback) (view_zoom_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4613 G_CALLBACK (view_zoom_changed_cb),g_signal_connect_data ((priv->view), ("zoom_changed"), (((
GCallback) (view_zoom_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
4614 window)g_signal_connect_data ((priv->view), ("zoom_changed"), (((
GCallback) (view_zoom_changed_cb))), (window), ((void*)0), (GConnectFlags
) 0)
;
4615
4616 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_SCROLL_WHEEL_ZOOM"scroll-wheel-zoom",
4617 priv->view, "scrollwheel-zoom", G_SETTINGS_BIND_GET);
4618 g_settings_bind (priv->view_settings, EOM_CONF_VIEW_ZOOM_MULTIPLIER"zoom-multiplier",
4619 priv->view, "zoom-multiplier", G_SETTINGS_BIND_GET);
4620
4621 view_popup = gtk_ui_manager_get_widget (priv->ui_mgr, "/ViewPopup");
4622 eom_scroll_view_set_popup (EOM_SCROLL_VIEW (priv->view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->view)), ((eom_scroll_view_get_type ()))))))
,
4623 GTK_MENU (view_popup)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view_popup)), ((gtk_menu_get_type ()))))))
);
4624
4625 gtk_paned_pack1 (GTK_PANED (hpaned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hpaned)), ((gtk_paned_get_type ()))))))
,
4626 priv->sidebar,
4627 FALSE(0),
4628 FALSE(0));
4629
4630 gtk_paned_pack2 (GTK_PANED (hpaned)((((GtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hpaned)), ((gtk_paned_get_type ()))))))
,
4631 priv->view,
4632 TRUE(!(0)),
4633 FALSE(0));
4634
4635 gtk_widget_show_all (hpaned);
4636
4637 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->layout)), ((gtk_box_get_type ()))))))
, hpaned, TRUE(!(0)), TRUE(!(0)), 0);
4638
4639 priv->thumbview = g_object_ref (eom_thumb_view_new ())((__typeof__ (eom_thumb_view_new ())) (g_object_ref) (eom_thumb_view_new
()))
;
4640
4641 /* giving shape to the view */
4642 gtk_icon_view_set_margin (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 4);
4643 gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (priv->thumbview)((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((gtk_icon_view_get_type ()))))))
, 0);
4644
4645 g_signal_connect (priv->thumbview, "selection_changed",g_signal_connect_data ((priv->thumbview), ("selection_changed"
), (((GCallback) (handle_image_selection_changed_cb))), (window
), ((void*)0), (GConnectFlags) 0)
4646 G_CALLBACK (handle_image_selection_changed_cb),g_signal_connect_data ((priv->thumbview), ("selection_changed"
), (((GCallback) (handle_image_selection_changed_cb))), (window
), ((void*)0), (GConnectFlags) 0)
4647 window)g_signal_connect_data ((priv->thumbview), ("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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
,
4660 GTK_MENU (thumb_popup)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((thumb_popup)), ((gtk_menu_get_type ()))))))
);
4661
4662 gtk_box_pack_start (GTK_BOX (priv->layout)((((GtkBox*) (void *) 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*) (void *) 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#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4692 GdkScreen *screen;
4693#endif
4694 EomWindowPrivate *priv;
4695
4696 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 4696, ((const char*) (__func__
))
);
4697
4698 GtkStyleContext *context;
4699
4700 context = gtk_widget_get_style_context (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
4701 gtk_style_context_add_class (context, "eom-window");
4702
4703 hints.min_width = EOM_WINDOW_MIN_WIDTH440;
4704 hints.min_height = EOM_WINDOW_MIN_HEIGHT350;
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, "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)
4714 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)
4715 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)
;
4716
4717 window->priv->store = NULL((void*)0);
4718 window->priv->image = NULL((void*)0);
4719
4720 window->priv->fullscreen_popup = NULL((void*)0);
4721 window->priv->fullscreen_timeout_source = NULL((void*)0);
4722 window->priv->slideshow_random = FALSE(0);
4723 window->priv->slideshow_loop = FALSE(0);
4724 window->priv->slideshow_switch_timeout = 0;
4725 window->priv->slideshow_switch_source = NULL((void*)0);
4726 window->priv->fullscreen_idle_inhibit_cookie = 0;
4727
4728 gtk_window_set_geometry_hints (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4729 GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
4730 &hints,
4731 GDK_HINT_MIN_SIZE);
4732
4733 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
4734 EOM_WINDOW_DEFAULT_WIDTH540,
4735 EOM_WINDOW_DEFAULT_HEIGHT450);
4736
4737 gtk_window_set_position (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER);
4738
4739 window->priv->mode = EOM_WINDOW_MODE_UNKNOWN;
4740 window->priv->status = EOM_WINDOW_STATUS_UNKNOWN;
4741
4742#if defined(HAVE_LCMS1) && defined(GDK_WINDOWING_X11)
4743 screen = gtk_widget_get_screen (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, GTK_APPLICATION (EOM_APP)((((GtkApplication*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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), (handle_image_selection_changed_cb), (window
))
4792 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), (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), (handle_image_selection_changed_cb), (window
))
;
4794 g_clear_object (&priv->thumbview)do { _Static_assert (sizeof *((&priv->thumbview)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->thumbview))) _pp = ((&priv->thumbview));
__typeof__ (*((&priv->thumbview))) _ptr = *_pp; *_pp =
((void*)0); if (_ptr) (g_object_unref) (_ptr); } 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), (eom_window_recent_manager_changed_cb), (
window))
4855 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), (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), (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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))
->priv->mode == EOM_WINDOW_MODE_FULLSCREEN || EOM_WINDOW (widget)((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eom_window_get_type ()))))))
, FALSE(0));
4970 } else if (EOM_WINDOW (widget)((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eom_window_get_type ()))))))
->priv;
5233
5234 eom_window_construct_ui (EOM_WINDOW (object)((((EomWindow*) (void *) 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*) (void *) 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*) (void *) 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),g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
5245 object)g_signal_connect_data ((priv->extensions), ("extension-added"
), (((GCallback) (on_extension_added))), (object), ((void*)0)
, (GConnectFlags) 0)
;
5246 g_signal_connect (priv->extensions, "extension-removed",g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
5247 G_CALLBACK (on_extension_removed),g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
5248 object)g_signal_connect_data ((priv->extensions), ("extension-removed"
), (((GCallback) (on_extension_removed))), (object), ((void*)
0), (GConnectFlags) 0)
;
5249
5250 return object;
5251}
5252
5253static void
5254eom_window_class_init (EomWindowClass *class)
5255{
5256 GObjectClass *g_object_class = (GObjectClass *) class;
5257 GtkWidgetClass *widget_class = (GtkWidgetClass *) class;
5258
5259 g_object_class->constructor = eom_window_constructor;
5260 g_object_class->dispose = eom_window_dispose;
5261 g_object_class->set_property = eom_window_set_property;
5262 g_object_class->get_property = eom_window_get_property;
5263
5264 widget_class->delete_event = eom_window_delete;
5265 widget_class->key_press_event = eom_window_key_press;
5266 widget_class->button_press_event = eom_window_button_press;
5267 widget_class->drag_data_received = eom_window_drag_data_received;
5268 widget_class->focus_out_event = eom_window_focus_out_event;
5269
5270/**
5271 * EomWindow:collection-position:
5272 *
5273 * Determines the position of the image collection in the window
5274 * relative to the image.
5275 */
5276 g_object_class_install_property (
5277 g_object_class, PROP_COLLECTION_POS,
5278 g_param_spec_enum ("collection-position", NULL((void*)0), NULL((void*)0),
5279 EOM_TYPE_WINDOW_COLLECTION_POS(eom_window_collection_pos_get_type()),
5280 EOM_WINDOW_COLLECTION_POS_BOTTOM,
5281 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5282
5283/**
5284 * EomWindow:collection-resizable:
5285 *
5286 * If %TRUE the collection will be resizable by the user otherwise it will be
5287 * in single column/row mode.
5288 */
5289 g_object_class_install_property (
5290 g_object_class, PROP_COLLECTION_RESIZABLE,
5291 g_param_spec_boolean ("collection-resizable", NULL((void*)0), NULL((void*)0), FALSE(0),
5292 G_PARAM_READWRITE | G_PARAM_STATIC_NAME));
5293
5294/**
5295 * EomWindow:startup-flags:
5296 *
5297 * A bitwise OR of #EomStartupFlags elements, indicating how the window
5298 * should behave upon creation.
5299 */
5300 g_object_class_install_property (g_object_class,
5301 PROP_STARTUP_FLAGS,
5302 g_param_spec_flags ("startup-flags",
5303 NULL((void*)0),
5304 NULL((void*)0),
5305 EOM_TYPE_STARTUP_FLAGS(eom_startup_flags_get_type()),
5306 0,
5307 G_PARAM_READWRITE |
5308 G_PARAM_CONSTRUCT_ONLY));
5309
5310/**
5311 * EomWindow::prepared:
5312 * @window: the object which received the signal.
5313 *
5314 * The #EomWindow::prepared signal is emitted when the @window is ready
5315 * to be shown.
5316 */
5317 signals [SIGNAL_PREPARED] =
5318 g_signal_new ("prepared",
5319 EOM_TYPE_WINDOW(eom_window_get_type ()),
5320 G_SIGNAL_RUN_LAST,
5321 G_STRUCT_OFFSET (EomWindowClass, prepared)((glong) __builtin_offsetof(EomWindowClass, prepared)),
5322 NULL((void*)0), NULL((void*)0),
5323 g_cclosure_marshal_VOID__VOID,
5324 G_TYPE_NONE((GType) ((1) << (2))), 0);
5325}
5326
5327/**
5328 * eom_window_new:
5329 * @flags: the initialization parameters for the new window.
5330 *
5331 *
5332 * Creates a new and empty #EomWindow. Use @flags to indicate
5333 * if the window should be initialized fullscreen, in slideshow mode,
5334 * and/or without the thumbnails collection visible. See #EomStartupFlags.
5335 *
5336 * Returns: a newly created #EomWindow.
5337 **/
5338GtkWidget*
5339eom_window_new (EomStartupFlags flags)
5340{
5341 EomWindow *window;
5342
5343 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5343, ((const char*) (__func__
))
);
5344
5345 window = EOM_WINDOW (g_object_new (EOM_TYPE_WINDOW,((((EomWindow*) (void *) 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 "type", GTK_WINDOW_TOPLEVEL,((((EomWindow*) (void *) 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 "application", EOM_APP,((((EomWindow*) (void *) 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 "show-menubar", FALSE,((((EomWindow*) (void *) 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 "startup-flags", flags,((((EomWindow*) (void *) 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
()))))))
5350 NULL))((((EomWindow*) (void *) 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
()))))))
;
5351
5352 return GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
5353}
5354
5355static void
5356eom_window_list_store_image_added (GtkTreeModel *tree_model,
5357 GtkTreePath *path,
5358 GtkTreeIter *iter,
5359 gpointer user_data)
5360{
5361 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
5362
5363 update_image_pos (window);
5364 update_action_groups_state (window);
5365}
5366
5367static void
5368eom_window_list_store_image_removed (GtkTreeModel *tree_model,
5369 GtkTreePath *path,
5370 gpointer user_data)
5371{
5372 EomWindow *window = EOM_WINDOW (user_data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((eom_window_get_type ()))))))
;
5373
5374 update_image_pos (window);
5375 update_action_groups_state (window);
5376}
5377
5378static void
5379eom_job_model_cb (EomJobModel *job, gpointer data)
5380{
5381 EomWindow *window;
5382 EomWindowPrivate *priv;
5383 gint n_images;
5384
5385 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5385, ((const char*) (__func__
))
);
5386
5387#ifdef HAVE_EXIF1
5388 int i;
5389 EomImage *image;
5390#endif
5391
5392 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)
;
5393
5394 window = EOM_WINDOW (data)((((EomWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eom_window_get_type ()))))))
;
5395 priv = window->priv;
5396
5397 if (priv->store != NULL((void*)0)) {
5398 g_object_unref (priv->store);
5399 priv->store = NULL((void*)0);
5400 }
5401
5402 priv->store = g_object_ref (job->store)((__typeof__ (job->store)) (g_object_ref) (job->store));
5403
5404 n_images = eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
);
5405
5406#ifdef HAVE_EXIF1
5407 if (g_settings_get_boolean (priv->view_settings, EOM_CONF_VIEW_AUTOROTATE"autorotate")) {
5408 for (i = 0; i < n_images; i++) {
5409 image = eom_list_store_get_image_by_pos (priv->store, i);
5410 eom_image_autorotate (image);
5411 g_object_unref (image);
5412 }
5413 }
5414#endif
5415
5416 eom_thumb_view_set_model (EOM_THUMB_VIEW (priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->thumbview)), ((eom_thumb_view_get_type ()))))))
, priv->store);
5417
5418 g_signal_connect (priv->store, "row-inserted",g_signal_connect_data ((priv->store), ("row-inserted"), ((
(GCallback) (eom_window_list_store_image_added))), (window), (
(void*)0), (GConnectFlags) 0)
5419 G_CALLBACK (eom_window_list_store_image_added),g_signal_connect_data ((priv->store), ("row-inserted"), ((
(GCallback) (eom_window_list_store_image_added))), (window), (
(void*)0), (GConnectFlags) 0)
5420 window)g_signal_connect_data ((priv->store), ("row-inserted"), ((
(GCallback) (eom_window_list_store_image_added))), (window), (
(void*)0), (GConnectFlags) 0)
;
5421
5422 g_signal_connect (priv->store, "row-deleted",g_signal_connect_data ((priv->store), ("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 ((priv->store), ("row-deleted"), (((
GCallback) (eom_window_list_store_image_removed))), (window),
((void*)0), (GConnectFlags) 0)
5424 window)g_signal_connect_data ((priv->store), ("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, "finished",g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5477 G_CALLBACK (eom_job_model_cb),g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
5478 window)g_signal_connect_data ((job), ("finished"), (((GCallback) (eom_job_model_cb
))), (window), ((void*)0), (GConnectFlags) 0)
;
5479
5480 eom_job_queue_add_job (job);
5481 g_object_unref (job);
5482}
5483
5484/**
5485 * eom_window_get_ui_manager:
5486 * @window: An #EomWindow.
5487 *
5488 * Gets the #GtkUIManager that describes the UI of @window.
5489 *
5490 * Returns: (transfer none): A #GtkUIManager.
5491 **/
5492GtkUIManager *
5493eom_window_get_ui_manager (EomWindow *window)
5494{
5495 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)
;
5496
5497 return window->priv->ui_mgr;
5498}
5499
5500/**
5501 * eom_window_get_mode:
5502 * @window: An #EomWindow.
5503 *
5504 * Gets the mode of @window. See #EomWindowMode for details.
5505 *
5506 * Returns: An #EomWindowMode.
5507 **/
5508EomWindowMode
5509eom_window_get_mode (EomWindow *window)
5510{
5511 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)
;
5512
5513 return window->priv->mode;
5514}
5515
5516/**
5517 * eom_window_set_mode:
5518 * @window: an #EomWindow.
5519 * @mode: an #EomWindowMode value.
5520 *
5521 * Changes the mode of @window to normal, fullscreen, or slideshow.
5522 * See #EomWindowMode for details.
5523 **/
5524void
5525eom_window_set_mode (EomWindow *window, EomWindowMode mode)
5526{
5527 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)
;
5528
5529 if (window->priv->mode == mode)
5530 return;
5531
5532 switch (mode) {
5533 case EOM_WINDOW_MODE_NORMAL:
5534 eom_window_stop_fullscreen (window,
5535 window->priv->mode == EOM_WINDOW_MODE_SLIDESHOW);
5536 break;
5537 case EOM_WINDOW_MODE_FULLSCREEN:
5538 eom_window_run_fullscreen (window, FALSE(0));
5539 break;
5540 case EOM_WINDOW_MODE_SLIDESHOW:
5541 eom_window_run_fullscreen (window, TRUE(!(0)));
5542 break;
5543 case EOM_WINDOW_MODE_UNKNOWN:
5544 break;
5545 }
5546}
5547
5548/**
5549 * eom_window_get_store:
5550 * @window: An #EomWindow.
5551 *
5552 * Gets the #EomListStore that contains the images in the collection
5553 * of @window.
5554 *
5555 * Returns: (transfer none): an #EomListStore.
5556 **/
5557EomListStore *
5558eom_window_get_store (EomWindow *window)
5559{
5560 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)
;
5561
5562 return EOM_LIST_STORE (window->priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->store)), (eom_list_store_get_type())
))))
;
5563}
5564
5565/**
5566 * eom_window_get_view:
5567 * @window: An #EomWindow.
5568 *
5569 * Gets the #EomScrollView in the window.
5570 *
5571 * Returns: (transfer none): the #EomScrollView.
5572 **/
5573GtkWidget *
5574eom_window_get_view (EomWindow *window)
5575{
5576 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)
;
5577
5578 return window->priv->view;
5579}
5580
5581/**
5582 * eom_window_get_sidebar:
5583 * @window: An #EomWindow.
5584 *
5585 * Gets the sidebar widget of @window.
5586 *
5587 * Returns: (transfer none): the #EomSidebar.
5588 **/
5589GtkWidget *
5590eom_window_get_sidebar (EomWindow *window)
5591{
5592 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)
;
5593
5594 return window->priv->sidebar;
5595}
5596
5597/**
5598 * eom_window_get_thumb_view:
5599 * @window: an #EomWindow.
5600 *
5601 * Gets the thumbnails view in @window.
5602 *
5603 * Returns: (transfer none): an #EomThumbView.
5604 **/
5605GtkWidget *
5606eom_window_get_thumb_view (EomWindow *window)
5607{
5608 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)
;
5609
5610 return window->priv->thumbview;
5611}
5612
5613/**
5614 * eom_window_get_thumb_nav:
5615 * @window: an #EomWindow.
5616 *
5617 * Gets the thumbnails navigation pane in @window.
5618 *
5619 * Returns: (transfer none): an #EomThumbNav.
5620 **/
5621GtkWidget *
5622eom_window_get_thumb_nav (EomWindow *window)
5623{
5624 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)
;
5625
5626 return window->priv->nav;
5627}
5628
5629/**
5630 * eom_window_get_statusbar:
5631 * @window: an #EomWindow.
5632 *
5633 * Gets the statusbar in @window.
5634 *
5635 * Returns: (transfer none): a #EomStatusBar.
5636 **/
5637GtkWidget *
5638eom_window_get_statusbar (EomWindow *window)
5639{
5640 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)
;
5641
5642 return window->priv->statusbar;
5643}
5644
5645/**
5646 * eom_window_get_image:
5647 * @window: an #EomWindow.
5648 *
5649 * Gets the image currently displayed in @window or %NULL if
5650 * no image is being displayed.
5651 *
5652 * Returns: (transfer none): an #EomImage.
5653 **/
5654EomImage *
5655eom_window_get_image (EomWindow *window)
5656{
5657 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)
;
5658
5659 return window->priv->image;
5660}
5661
5662/**
5663 * eom_window_is_empty:
5664 * @window: an #EomWindow.
5665 *
5666 * Tells whether @window is currently empty or not.
5667 *
5668 * Returns: %TRUE if @window has no images, %FALSE otherwise.
5669 **/
5670gboolean
5671eom_window_is_empty (EomWindow *window)
5672{
5673 EomWindowPrivate *priv;
5674 gboolean empty = TRUE(!(0));
5675
5676 eom_debug (DEBUG_WINDOWEOM_DEBUG_WINDOW, "eom-window.c", 5676, ((const char*) (__func__
))
);
5677
5678 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)
;
5679
5680 priv = window->priv;
5681
5682 if (priv->store != NULL((void*)0)) {
5683 empty = (eom_list_store_length (EOM_LIST_STORE (priv->store)((((EomListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->store)), (eom_list_store_get_type())))))
) == 0);
5684 }
5685
5686 return empty;
5687}
5688
5689void
5690eom_window_reload_image (EomWindow *window)
5691{
5692 GtkWidget *view;
5693
5694 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)
;
5695
5696 if (window->priv->image == NULL((void*)0))
5697 return;
5698
5699 g_object_unref (window->priv->image);
5700 window->priv->image = NULL((void*)0);
5701
5702 view = eom_window_get_view (window);
5703 eom_scroll_view_set_image (EOM_SCROLL_VIEW (view)((((EomScrollView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((eom_scroll_view_get_type ()))))))
, NULL((void*)0));
5704
5705 eom_thumb_view_select_single (EOM_THUMB_VIEW (window->priv->thumbview)((((EomThumbView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->thumbview)), ((eom_thumb_view_get_type
()))))))
,
5706 EOM_THUMB_VIEW_SELECT_CURRENT);
5707}
diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f92f6b.html b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f92f6b.html new file mode 100644 index 0000000..d57cc4c --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/report-f92f6b.html @@ -0,0 +1,1126 @@ + + + +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 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eom-transform.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -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/librsvg-2.0 -I /usr/include/exempi-2.0 -I /usr/include/libpeas-1.0 -I /usr/include/gtk-3.0/unix-print -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/cairo -I /usr/include/gobject-introspection-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/atk-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/dconf -I /usr/include/at-spi-2.0 -I /usr/include/blkid -I /usr/include/pixman-1 -I /usr/include/libxml2 -I /usr/include/libmount -I /usr/include/fribidi -I /usr/include/libpng16 -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-14-000446-6452-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 gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = eom_transform_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __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)((__typeof__ (pixbuf)) (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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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*) (void *) 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/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/scanview.css b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/sorttable.js b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2024-02-14-000446-6452-1@a2ffc585b0d4_v1.28.0/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("