Bug Summary

File:src/eoc-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-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eoc-preferences-dialog.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -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/lib/llvm-14/lib/clang/14.0.6 -D HAVE_CONFIG_H -I . -I .. -I . -I .. -I ../jpegutils -I ../cut-n-paste/toolbar-editor -D G_LOG_DOMAIN="EOC" -D EOC_DATA_DIR="/usr/local/share/eoc" -D EOC_LOCALE_DIR="/usr/local/share/locale" -D EOC_PLUGIN_DIR="/usr/local/lib/eoc/plugins" -D LIBDIR="/usr/local/lib" -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/ctk-3.0/unix-print -I /usr/local/include/libbean-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -D PIC -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -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-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-06-11-120157-31414-1 -x c eoc-preferences-dialog.c
1/* Eye Of Cafe - EOC 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 "eoc-preferences-dialog.h"
30#include "eoc-scroll-view.h"
31#include "eoc-util.h"
32#include "eoc-config-keys.h"
33
34#include <glib.h>
35#include <glib/gi18n.h>
36#include <glib-object.h>
37#include <ctk/ctk.h>
38#include <gio/gio.h>
39#include <libbean-ctk/bean-ctk-plugin-manager.h>
40
41#define GSETTINGS_OBJECT_KEY"GSETTINGS_KEY" "GSETTINGS_KEY"
42#define GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE" "GSETTINGS_VALUE"
43
44struct _EocPreferencesDialogPrivate {
45 GSettings *view_settings;
46 GSettings *ui_settings;
47 GSettings *fullscreen_settings;
48
49 CtkWidget *interpolate_check;
50 CtkWidget *extrapolate_check;
51 CtkWidget *autorotate_check;
52 CtkWidget *bg_color_check;
53 CtkWidget *bg_color_button;
54 CtkWidget *color_radio;
55 CtkWidget *checkpattern_radio;
56 CtkWidget *background_radio;
57 CtkWidget *transp_color_button;
58
59 CtkWidget *upscale_check;
60 CtkWidget *random_check;
61 CtkWidget *loop_check;
62 CtkWidget *seconds_spin;
63
64 CtkWidget *plugin_manager;
65};
66
67static GObject *instance = NULL((void*)0);
68
69G_DEFINE_TYPE_WITH_PRIVATE (EocPreferencesDialog, eoc_preferences_dialog, CTK_TYPE_DIALOG)static void eoc_preferences_dialog_init (EocPreferencesDialog
*self); static void eoc_preferences_dialog_class_init (EocPreferencesDialogClass
*klass); static GType eoc_preferences_dialog_get_type_once (
void); static gpointer eoc_preferences_dialog_parent_class = (
(void*)0); static gint EocPreferencesDialog_private_offset; static
void eoc_preferences_dialog_class_intern_init (gpointer klass
) { eoc_preferences_dialog_parent_class = g_type_class_peek_parent
(klass); if (EocPreferencesDialog_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EocPreferencesDialog_private_offset); eoc_preferences_dialog_class_init
((EocPreferencesDialogClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer eoc_preferences_dialog_get_instance_private
(EocPreferencesDialog *self) { return (((gpointer) ((guint8*
) (self) + (glong) (EocPreferencesDialog_private_offset)))); }
GType eoc_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 = eoc_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 eoc_preferences_dialog_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ctk_dialog_get_type ()), g_intern_static_string ("EocPreferencesDialog"
), sizeof (EocPreferencesDialogClass), (GClassInitFunc)(void (
*)(void)) eoc_preferences_dialog_class_intern_init, sizeof (EocPreferencesDialog
), (GInstanceInitFunc)(void (*)(void)) eoc_preferences_dialog_init
, (GTypeFlags) 0); { {{ EocPreferencesDialog_private_offset =
g_type_add_instance_private (g_define_type_id, sizeof (EocPreferencesDialogPrivate
)); };} } return g_define_type_id; }
;
70
71static gboolean
72pd_string_to_rgba_mapping (GValue *value,
73 GVariant *variant,
74 gpointer user_data)
75{
76 CdkRGBA 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 ("EOC", ((const
char*) (__func__)), "g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)"
); return ((0)); } } while (0)
;
79
80 if (cdk_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 CdkRGBA *color;
96 gchar *hex_val;
97
98 g_return_val_if_fail (G_VALUE_TYPE (value) == CDK_TYPE_RGBA, NULL)do { if (((((GValue*) (value))->g_type) == (cdk_rgba_get_type
()))) { } else { g_return_if_fail_warning ("EOC", ((const char
*) (__func__)), "G_VALUE_TYPE (value) == CDK_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 ("EOC", ((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 = cdk_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 (CtkWidget *widget, gpointer data)
112{
113 gpointer value = NULL((void*)0);
114
115 if (!ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (widget)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_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 ()))))))
, EOC_CONF_VIEW_TRANSPARENCY"transparency",
121 GPOINTER_TO_INT (value)((gint) (glong) (value)));
122}
123
124static void
125random_change_cb (GSettings *settings, gchar *key, CtkWidget *widget)
126{
127 ctk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key));
128}
129
130static void
131eoc_preferences_response_cb (CtkDialog *dlg, gint res_id, gpointer data)
132{
133 switch (res_id) {
134 case CTK_RESPONSE_HELP:
135 eoc_util_show_help ("eoc-prefs", NULL((void*)0));
136 break;
137 default:
138 ctk_widget_destroy (CTK_WIDGET (dlg)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dlg)), ((ctk_widget_get_type ()))))))
);
139 instance = NULL((void*)0);
140 }
141}
142
143static void
144eoc_preferences_dialog_class_init (EocPreferencesDialogClass *klass)
145{
146 CtkWidgetClass *widget_class = (CtkWidgetClass*) klass;
147
148 /* This should make sure the libbean-ctk dependency isn't
149 * dropped by aggressive linkers (#739618) */
150 g_type_ensure (BEAN_CTK_TYPE_PLUGIN_MANAGER(bean_ctk_plugin_manager_get_type()));
151
152 ctk_widget_class_set_template_from_resource (widget_class,
153 "/org/cafe/eoc/ui/eoc-preferences-dialog.ui");
154 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, interpolate_check)))))
155 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, interpolate_check)))))
156 interpolate_check)ctk_widget_class_bind_template_child_full (widget_class, "interpolate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, interpolate_check)))))
;
157 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, extrapolate_check)))))
158 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, extrapolate_check)))))
159 extrapolate_check)ctk_widget_class_bind_template_child_full (widget_class, "extrapolate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, extrapolate_check)))))
;
160 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, autorotate_check)))))
161 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, autorotate_check)))))
162 autorotate_check)ctk_widget_class_bind_template_child_full (widget_class, "autorotate_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, autorotate_check)))))
;
163 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, bg_color_check)))))
164 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, bg_color_check)))))
165 bg_color_check)ctk_widget_class_bind_template_child_full (widget_class, "bg_color_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, bg_color_check)))))
;
166 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, bg_color_button)))))
167 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, bg_color_button)))))
168 bg_color_button)ctk_widget_class_bind_template_child_full (widget_class, "bg_color_button"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, bg_color_button)))))
;
169 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, color_radio)))))
170 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, color_radio)))))
171 color_radio)ctk_widget_class_bind_template_child_full (widget_class, "color_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, color_radio)))))
;
172 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, checkpattern_radio)))))
173 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, checkpattern_radio)))))
174 checkpattern_radio)ctk_widget_class_bind_template_child_full (widget_class, "checkpattern_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, checkpattern_radio)))))
;
175 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, background_radio)))))
176 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, background_radio)))))
177 background_radio)ctk_widget_class_bind_template_child_full (widget_class, "background_radio"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, background_radio)))))
;
178 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, transp_color_button)))))
179 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, transp_color_button)))))
180 transp_color_button)ctk_widget_class_bind_template_child_full (widget_class, "transp_color_button"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, transp_color_button)))))
;
181
182 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, upscale_check)))))
183 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, upscale_check)))))
184 upscale_check)ctk_widget_class_bind_template_child_full (widget_class, "upscale_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, upscale_check)))))
;
185 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, random_check)))))
186 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, random_check)))))
187 random_check)ctk_widget_class_bind_template_child_full (widget_class, "random_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, random_check)))))
;
188 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, loop_check)))))
189 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, loop_check)))))
190 loop_check)ctk_widget_class_bind_template_child_full (widget_class, "loop_check"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, loop_check)))))
;
191 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, seconds_spin)))))
192 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, seconds_spin)))))
193 seconds_spin)ctk_widget_class_bind_template_child_full (widget_class, "seconds_spin"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, seconds_spin)))))
;
194
195 ctk_widget_class_bind_template_child_private (widget_class,ctk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, plugin_manager)))))
196 EocPreferencesDialog,ctk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, plugin_manager)))))
197 plugin_manager)ctk_widget_class_bind_template_child_full (widget_class, "plugin_manager"
, (0), (EocPreferencesDialog_private_offset + (((glong) __builtin_offsetof
(EocPreferencesDialogPrivate, plugin_manager)))))
;
198}
199
200static void
201eoc_preferences_dialog_init (EocPreferencesDialog *pref_dlg)
202{
203 EocPreferencesDialogPrivate *priv;
204
205 pref_dlg->priv = eoc_preferences_dialog_get_instance_private (pref_dlg);
206 priv = pref_dlg->priv;
207
208 ctk_widget_init_template (CTK_WIDGET (pref_dlg)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pref_dlg)), ((ctk_widget_get_type ()))))))
);
209
210 priv->view_settings = g_settings_new (EOC_CONF_VIEW"org.cafe.eoc"".view");
211 priv->fullscreen_settings = g_settings_new (EOC_CONF_FULLSCREEN"org.cafe.eoc"".full-screen");
212
213 g_signal_connect (G_OBJECT (pref_dlg),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eoc_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
214 "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eoc_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
215 G_CALLBACK (eoc_preferences_response_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eoc_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
216 pref_dlg)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pref_dlg)), (((GType) ((20) << (2)
)))))))), ("response"), (((GCallback) (eoc_preferences_response_cb
))), (pref_dlg), ((void*)0), (GConnectFlags) 0)
;
217
218 g_settings_bind (priv->view_settings,
219 EOC_CONF_VIEW_INTERPOLATE"interpolate",
220 priv->interpolate_check, "active",
221 G_SETTINGS_BIND_DEFAULT);
222 g_settings_bind (priv->view_settings,
223 EOC_CONF_VIEW_EXTRAPOLATE"extrapolate",
224 priv->extrapolate_check, "active",
225 G_SETTINGS_BIND_DEFAULT);
226 g_settings_bind (priv->view_settings,
227 EOC_CONF_VIEW_AUTOROTATE"autorotate",
228 priv->autorotate_check, "active",
229 G_SETTINGS_BIND_DEFAULT);
230 g_settings_bind (priv->view_settings,
231 EOC_CONF_VIEW_USE_BG_COLOR"use-background-color",
232 priv->bg_color_check, "active",
233 G_SETTINGS_BIND_DEFAULT);
234
235 g_settings_bind_with_mapping (priv->view_settings,
236 EOC_CONF_VIEW_BACKGROUND_COLOR"background-color",
237 priv->bg_color_button, "rgba",
238 G_SETTINGS_BIND_DEFAULT,
239 pd_string_to_rgba_mapping,
240 pd_rgba_to_string_mapping,
241 NULL((void*)0), NULL((void*)0));
242 g_object_set_data (G_OBJECT (priv->color_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), (((GType) ((20) << (2)))))
)))
,
243 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
244 GINT_TO_POINTER (EOC_TRANSP_COLOR)((gpointer) (glong) (EOC_TRANSP_COLOR)));
245
246 g_signal_connect (G_OBJECT (priv->color_radio),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
247 "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
248 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
249 priv->view_settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->color_radio)), (((GType) ((20) <<
(2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
250
251 g_object_set_data (G_OBJECT (priv->checkpattern_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), (((GType) ((20) << (
2))))))))
,
252 GSETTINGS_OBJECT_VALUE"GSETTINGS_VALUE",
253 GINT_TO_POINTER (EOC_TRANSP_CHECKED)((gpointer) (glong) (EOC_TRANSP_CHECKED)));
254
255 g_signal_connect (G_OBJECT (priv->checkpattern_radio),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
256 "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
257 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
258 priv->view_settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->checkpattern_radio)), (((GType)
((20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
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 (EOC_TRANSP_BACKGROUND)((gpointer) (glong) (EOC_TRANSP_BACKGROUND)));
263
264 g_signal_connect (G_OBJECT (priv->background_radio),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
265 "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
266 G_CALLBACK (pd_transp_radio_toggle_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
267 priv->view_settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((priv->background_radio)), (((GType) (
(20) << (2))))))))), ("toggled"), (((GCallback) (pd_transp_radio_toggle_cb
))), (priv->view_settings), ((void*)0), (GConnectFlags) 0)
;
268
269 switch (g_settings_get_enum (priv->view_settings,
270 EOC_CONF_VIEW_TRANSPARENCY"transparency"))
271 {
272 case EOC_TRANSP_COLOR:
273 ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->color_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->color_radio)), ((ctk_toggle_button_get_type ())
)))))
, TRUE(!(0)));
274 break;
275 case EOC_TRANSP_CHECKED:
276 ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->checkpattern_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->checkpattern_radio)), ((ctk_toggle_button_get_type
()))))))
, TRUE(!(0)));
277 break;
278 default:
279 // Log a warning and use EOC_TRANSP_BACKGROUND as fallback
280 g_warn_if_reached ()do { g_warn_message ("EOC", "eoc-preferences-dialog.c", 280, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
281 case EOC_TRANSP_BACKGROUND:
282 ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (priv->background_radio)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->background_radio)), ((ctk_toggle_button_get_type
()))))))
, TRUE(!(0)));
283 break;
284 }
285
286 g_settings_bind_with_mapping (priv->view_settings,
287 EOC_CONF_VIEW_TRANS_COLOR"trans-color",
288 priv->transp_color_button, "rgba",
289 G_SETTINGS_BIND_DEFAULT,
290 pd_string_to_rgba_mapping,
291 pd_rgba_to_string_mapping,
292 NULL((void*)0), NULL((void*)0));
293
294 g_settings_bind (priv->fullscreen_settings, EOC_CONF_FULLSCREEN_UPSCALE"upscale",
295 priv->upscale_check, "active",
296 G_SETTINGS_BIND_DEFAULT);
297
298 g_settings_bind (priv->fullscreen_settings,
299 EOC_CONF_FULLSCREEN_LOOP"loop",
300 priv->loop_check, "active",
301 G_SETTINGS_BIND_DEFAULT);
302
303 g_settings_bind (priv->fullscreen_settings,
304 EOC_CONF_FULLSCREEN_RANDOM"random",
305 priv->random_check, "active",
306 G_SETTINGS_BIND_DEFAULT);
307 g_signal_connect (priv->fullscreen_settings,g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
308 "changed::" EOC_CONF_FULLSCREEN_RANDOM,g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
309 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)
310 priv->loop_check)g_signal_connect_data ((priv->fullscreen_settings), ("changed::"
"random"), (((GCallback) (random_change_cb))), (priv->loop_check
), ((void*)0), (GConnectFlags) 0)
;
311 random_change_cb (priv->fullscreen_settings,
312 EOC_CONF_FULLSCREEN_RANDOM"random",
313 priv->loop_check);
314
315 g_settings_bind (priv->fullscreen_settings,
316 EOC_CONF_FULLSCREEN_SECONDS"seconds",
317 priv->seconds_spin, "value",
318 G_SETTINGS_BIND_DEFAULT);
319
320 ctk_widget_show_all (priv->plugin_manager);
321}
322
323CtkWidget *eoc_preferences_dialog_get_instance (CtkWindow *parent)
324{
325 if (instance == NULL((void*)0)) {
326 instance = g_object_new (EOC_TYPE_PREFERENCES_DIALOG(eoc_preferences_dialog_get_type ()),
327 NULL((void*)0));
328 }
329
330 if (parent)
331 ctk_window_set_transient_for (CTK_WINDOW (instance)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((ctk_window_get_type ()))))))
, parent);
332
333 return CTK_WIDGET(instance)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instance)), ((ctk_widget_get_type ()))))))
;
334}