Bug Summary

File:math-preferences.c
Warning:line 145, column 9
Value stored to 'valid' is never read

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 math-preferences.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 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib/llvm-19/lib/clang/19 -D HAVE_CONFIG_H -I . -I .. -D VERSION="1.25.0" -D LOCALE_DIR="/usr/share/locale" -D GETTEXT_PACKAGE="cafe-calc" -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/sysprof-6 -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/webp -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/libxml2 -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.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/2025-08-16-224422-15323-1 -x c math-preferences.c
1/*
2 * Copyright (C) 2008-2011 Robert Ancell
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation, either version 2 of the License, or (at your option) any later
7 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
8 * license.
9 */
10
11#include <glib/gi18n.h>
12#include <ctk/ctk.h>
13
14#include "math-preferences.h"
15#include "utility.h"
16
17
18enum {
19 PROP_0,
20 PROP_EQUATION
21};
22
23struct MathPreferencesDialogPrivate
24{
25 MathEquation *equation;
26 CtkBuilder *ui;
27};
28
29G_DEFINE_TYPE_WITH_PRIVATE (MathPreferencesDialog, math_preferences, CTK_TYPE_DIALOG)static void math_preferences_init (MathPreferencesDialog *self
); static void math_preferences_class_init (MathPreferencesDialogClass
*klass); static GType math_preferences_get_type_once (void);
static gpointer math_preferences_parent_class = ((void*)0); static
gint MathPreferencesDialog_private_offset; static void math_preferences_class_intern_init
(gpointer klass) { math_preferences_parent_class = g_type_class_peek_parent
(klass); if (MathPreferencesDialog_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MathPreferencesDialog_private_offset); math_preferences_class_init
((MathPreferencesDialogClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer math_preferences_get_instance_private
(MathPreferencesDialog *self) { return (((gpointer) ((guint8
*) (self) + (glong) (MathPreferencesDialog_private_offset))))
; } GType math_preferences_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= math_preferences_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType math_preferences_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((ctk_dialog_get_type ()), g_intern_static_string ("MathPreferencesDialog"
), sizeof (MathPreferencesDialogClass), (GClassInitFunc)(void
(*)(void)) math_preferences_class_intern_init, sizeof (MathPreferencesDialog
), (GInstanceInitFunc)(void (*)(void)) math_preferences_init,
(GTypeFlags) 0); { {{ MathPreferencesDialog_private_offset =
g_type_add_instance_private (g_define_type_id, sizeof (MathPreferencesDialogPrivate
)); };} } return g_define_type_id; }
;
30
31#define UI_DIALOGS_RESOURCE_PATH"/org/cafe/calculator/ui/preferences.ui" "/org/cafe/calculator/ui/preferences.ui"
32#define GET_WIDGET(ui, name)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(ui, name))), ((ctk_widget_get_type
()))))))
\
33 CTK_WIDGET(ctk_builder_get_object(ui, name))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(ui, name))), ((ctk_widget_get_type
()))))))
34
35
36MathPreferencesDialog *
37math_preferences_dialog_new(MathEquation *equation)
38{
39 return g_object_new(math_preferences_get_type(), "equation", equation, NULL((void*)0));
40}
41
42
43static void
44preferences_response_cb (CtkWidget *widget,
45 gint id G_GNUC_UNUSED__attribute__ ((__unused__)))
46{
47 ctk_widget_hide(widget);
48}
49
50
51static gboolean
52preferences_dialog_delete_cb (CtkWidget *widget,
53 CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)))
54{
55 preferences_response_cb(widget, 0);
56 return TRUE(!(0));
57}
58
59
60static void number_format_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog)
61{
62 MpDisplayFormat value;
63 CtkTreeModel *model;
64 CtkTreeIter iter;
65
66 model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
);
67 ctk_combo_box_get_active_iter(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
, &iter);
68 ctk_tree_model_get(model, &iter, 1, &value, -1);
69 math_equation_set_number_format(dialog->priv->equation, value);
70}
71
72
73static void angle_unit_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog)
74{
75 MPAngleUnit value;
76 CtkTreeModel *model;
77 CtkTreeIter iter;
78
79 model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
);
80 ctk_combo_box_get_active_iter(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
, &iter);
81 ctk_tree_model_get(model, &iter, 1, &value, -1);
82 math_equation_set_angle_units(dialog->priv->equation, value);
83}
84
85
86static void word_size_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog)
87{
88 gint value;
89 CtkTreeModel *model;
90 CtkTreeIter iter;
91
92 model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
);
93 ctk_combo_box_get_active_iter(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
, &iter);
94 ctk_tree_model_get(model, &iter, 1, &value, -1);
95 math_equation_set_word_size(dialog->priv->equation, value);
96}
97
98
99static void decimal_places_spin_change_value_cb(CtkWidget *spin, MathPreferencesDialog *dialog)
100{
101 gint value = 0;
102
103 value = ctk_spin_button_get_value_as_int(CTK_SPIN_BUTTON(spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((spin)), ((ctk_spin_button_get_type ()))))))
);
104 math_equation_set_accuracy(dialog->priv->equation, value);
105}
106
107
108static void thousands_separator_check_toggled_cb(CtkWidget *check, MathPreferencesDialog *dialog)
109{
110 gboolean value;
111
112 value = ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON(check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((check)), ((ctk_toggle_button_get_type ()))))))
);
113 math_equation_set_show_thousands_separators(dialog->priv->equation, value);
114}
115
116
117static void trailing_zeroes_check_toggled_cb(CtkWidget *check, MathPreferencesDialog *dialog)
118{
119 gboolean value;
120
121 value = ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON(check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((check)), ((ctk_toggle_button_get_type ()))))))
);
122 math_equation_set_show_trailing_zeroes(dialog->priv->equation, value);
123}
124
125
126static void
127set_combo_box_from_int(CtkWidget *combo, int value)
128{
129 CtkTreeModel *model;
130 CtkTreeIter iter;
131 gboolean valid;
132
133 model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
);
134 valid = ctk_tree_model_get_iter_first(model, &iter);
135
136 while (valid) {
137 gint v;
138
139 ctk_tree_model_get(model, &iter, 1, &v, -1);
140 if (v == value)
141 break;
142 valid = ctk_tree_model_iter_next(model, &iter);
143 }
144 if (!valid)
145 valid = ctk_tree_model_get_iter_first(model, &iter);
Value stored to 'valid' is never read
146
147 ctk_combo_box_set_active_iter(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo)), ((ctk_combo_box_get_type ()))))))
, &iter);
148}
149
150
151static void
152accuracy_cb (MathEquation *equation,
153 GParamSpec *spec G_GNUC_UNUSED__attribute__ ((__unused__)),
154 MathPreferencesDialog *dialog)
155{
156 ctk_spin_button_set_value(CTK_SPIN_BUTTON(ctk_builder_get_object(dialog->priv->ui, "decimal_places_spin"))((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "decimal_places_spin"
))), ((ctk_spin_button_get_type ()))))))
,
157 math_equation_get_accuracy(equation));
158 g_settings_set_int(g_settings_var, "accuracy", math_equation_get_accuracy(equation));
159}
160
161
162static void
163show_thousands_separators_cb (MathEquation *equation,
164 GParamSpec *spec G_GNUC_UNUSED__attribute__ ((__unused__)),
165 MathPreferencesDialog *dialog)
166{
167 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON(ctk_builder_get_object(dialog->priv->ui, "thousands_separator_check"))((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "thousands_separator_check"
))), ((ctk_toggle_button_get_type ()))))))
,
168 math_equation_get_show_thousands_separators(equation));
169 g_settings_set_boolean(g_settings_var, "show-thousands", math_equation_get_show_thousands_separators(equation));
170}
171
172
173static void
174show_trailing_zeroes_cb (MathEquation *equation,
175 GParamSpec *spec G_GNUC_UNUSED__attribute__ ((__unused__)),
176 MathPreferencesDialog *dialog)
177{
178 ctk_toggle_button_set_active(CTK_TOGGLE_BUTTON(ctk_builder_get_object(dialog->priv->ui, "trailing_zeroes_check"))((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "trailing_zeroes_check"
))), ((ctk_toggle_button_get_type ()))))))
,
179 math_equation_get_show_trailing_zeroes(equation));
180 g_settings_set_boolean(g_settings_var, "show-zeroes", math_equation_get_show_trailing_zeroes(equation));
181}
182
183
184static void
185number_format_cb (MathEquation *equation,
186 GParamSpec *spec G_GNUC_UNUSED__attribute__ ((__unused__)),
187 MathPreferencesDialog *dialog)
188{
189 set_combo_box_from_int(GET_WIDGET(dialog->priv->ui, "number_format_combobox")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "number_format_combobox"
))), ((ctk_widget_get_type ()))))))
, math_equation_get_number_format(equation));
190 g_settings_set_enum(g_settings_var, "number-format", math_equation_get_number_format(equation));
191}
192
193
194static void
195word_size_cb (MathEquation *equation,
196 GParamSpec *spec G_GNUC_UNUSED__attribute__ ((__unused__)),
197 MathPreferencesDialog *dialog)
198{
199 set_combo_box_from_int(GET_WIDGET(dialog->priv->ui, "word_size_combobox")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "word_size_combobox"
))), ((ctk_widget_get_type ()))))))
, math_equation_get_word_size(equation));
200 g_settings_set_int(g_settings_var, "word-size", math_equation_get_word_size(equation));
201}
202
203
204static void
205angle_unit_cb (MathEquation *equation,
206 GParamSpec *spec G_GNUC_UNUSED__attribute__ ((__unused__)),
207 MathPreferencesDialog *dialog)
208{
209 set_combo_box_from_int(GET_WIDGET(dialog->priv->ui, "angle_unit_combobox")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "angle_unit_combobox"
))), ((ctk_widget_get_type ()))))))
, math_equation_get_angle_units(equation));
210 g_settings_set_enum(g_settings_var, "angle-units", math_equation_get_angle_units(equation));
211}
212
213
214static void
215create_gui(MathPreferencesDialog *dialog)
216{
217 CtkWidget *widget;
218 CtkTreeModel *model;
219 CtkTreeIter iter;
220 CtkCellRenderer *renderer;
221 gchar *string, **tokens;
222 GError *error = NULL((void*)0);
223 static gchar *objects[] = { "preferences_table", "angle_unit_model", "number_format_model",
224 "word_size_model", "decimal_places_adjustment", "number_base_model", NULL((void*)0) };
225
226 // FIXME: Handle errors
227 dialog->priv->ui = ctk_builder_new();
228 ctk_builder_add_objects_from_resource(dialog->priv->ui, UI_DIALOGS_RESOURCE_PATH"/org/cafe/calculator/ui/preferences.ui", objects, &error);
229 if (error)
230 g_warning("Error loading preferences UI: %s", error->message);
231 g_clear_error(&error);
232
233 ctk_window_set_title(CTK_WINDOW(dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
,
234 /* Title of preferences dialog */
235 _("Preferences")gettext ("Preferences"));
236 ctk_container_set_border_width(CTK_CONTAINER(dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_container_get_type ()))))))
, 8);
237 ctk_dialog_add_button(CTK_DIALOG(dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
238 /* Icon name on close button in preferences dialog */
239 "ctk-close", CTK_RESPONSE_CLOSE);
240
241 ctk_window_set_icon_name (CTK_WINDOW(dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, "accessories-calculator");
242
243 g_signal_connect(dialog, "response", G_CALLBACK(preferences_response_cb), NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
preferences_response_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
244 g_signal_connect(dialog, "delete-event", G_CALLBACK(preferences_dialog_delete_cb), NULL)g_signal_connect_data ((dialog), ("delete-event"), (((GCallback
) (preferences_dialog_delete_cb))), (((void*)0)), ((void*)0),
(GConnectFlags) 0)
;
245 ctk_box_pack_start(CTK_BOX(ctk_dialog_get_content_area(CTK_DIALOG(dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_dialog_get_content_area(((((CtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ()))))))
))), ((ctk_box_get_type ()))))))
, GET_WIDGET(dialog->priv->ui, "preferences_table")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "preferences_table"
))), ((ctk_widget_get_type ()))))))
, TRUE(!(0)), TRUE(!(0)), 0);
246
247 widget = GET_WIDGET(dialog->priv->ui, "angle_unit_combobox")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "angle_unit_combobox"
))), ((ctk_widget_get_type ()))))))
;
248 model = ctk_combo_box_get_model(CTK_COMBO_BOX(widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_combo_box_get_type ()))))))
);
249 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
250 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
251 /* Preferences dialog: Angle unit combo box: Use degrees for trigonometric calculations */
252 _("Degrees")gettext ("Degrees"), 1, MP_DEGREES, -1);
253 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
254 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
255 /* Preferences dialog: Angle unit combo box: Use radians for trigonometric calculations */
256 _("Radians")gettext ("Radians"), 1, MP_RADIANS, -1);
257 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
258 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
259 /* Preferences dialog: Angle unit combo box: Use gradians for trigonometric calculations */
260 _("Gradians")gettext ("Gradians"), 1, MP_GRADIANS, -1);
261 renderer = ctk_cell_renderer_text_new();
262 ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(widget)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_cell_layout_get_type ()))))))
, renderer, TRUE(!(0)));
263 ctk_cell_layout_add_attribute(CTK_CELL_LAYOUT(widget)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_cell_layout_get_type ()))))))
, renderer, "text", 0);
264
265 widget = GET_WIDGET(dialog->priv->ui, "number_format_combobox")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "number_format_combobox"
))), ((ctk_widget_get_type ()))))))
;
266 model = ctk_combo_box_get_model(CTK_COMBO_BOX(widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_combo_box_get_type ()))))))
);
267 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
268 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
269 /* Number display mode combo: Automatic, e.g. 1234 (or scientific for large number 1.234×10^99) */
270 _("Automatic")gettext ("Automatic"), 1, MP_DISPLAY_FORMAT_AUTOMATIC, -1);
271 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
272 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
273 /* Number display mode combo: Fixed, e.g. 1234 */
274 _("Fixed")gettext ("Fixed"), 1, MP_DISPLAY_FORMAT_FIXED, -1);
275 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
276 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
277 /* Number display mode combo: Scientific, e.g. 1.234×10^3 */
278 _("Scientific")gettext ("Scientific"), 1, MP_DISPLAY_FORMAT_SCIENTIFIC, -1);
279 ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter);
280 ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((ctk_list_store_get_type ()))))))
, &iter, 0,
281 /* Number display mode combo: Engineering, e.g. 1.234k */
282 _("Engineering")gettext ("Engineering"), 1, MP_DISPLAY_FORMAT_ENGINEERING, -1);
283 renderer = ctk_cell_renderer_text_new();
284 ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(widget)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_cell_layout_get_type ()))))))
, renderer, TRUE(!(0)));
285 ctk_cell_layout_add_attribute(CTK_CELL_LAYOUT(widget)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_cell_layout_get_type ()))))))
, renderer, "text", 0);
286
287 widget = GET_WIDGET(dialog->priv->ui, "word_size_combobox")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "word_size_combobox"
))), ((ctk_widget_get_type ()))))))
;
288 renderer = ctk_cell_renderer_text_new();
289 ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(widget)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_cell_layout_get_type ()))))))
, renderer, TRUE(!(0)));
290 ctk_cell_layout_add_attribute(CTK_CELL_LAYOUT(widget)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_cell_layout_get_type ()))))))
, renderer, "text", 0);
291
292 /* Label used in preferences dialog. The %d is replaced by a spinbutton */
293 string = _("Show %d decimal _places")gettext ("Show %d decimal _places");
294 tokens = g_strsplit(string, "%d", 2);
295 widget = GET_WIDGET(dialog->priv->ui, "decimal_places_label1")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "decimal_places_label1"
))), ((ctk_widget_get_type ()))))))
;
296 if (tokens[0])
297 string = g_strstrip(tokens[0])g_strchomp (g_strchug (tokens[0]));
298 else
299 string = "";
300 if (string[0] != '\0')
301 ctk_label_set_text_with_mnemonic(CTK_LABEL(widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_label_get_type ()))))))
, string);
302 else
303 ctk_widget_hide(widget);
304
305 widget = GET_WIDGET(dialog->priv->ui, "decimal_places_label2")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ctk_builder_get_object(dialog->priv->ui, "decimal_places_label2"
))), ((ctk_widget_get_type ()))))))
;
306 if (tokens[0] && tokens[1])
307 string = g_strstrip(tokens[1])g_strchomp (g_strchug (tokens[1]));
308 else
309 string = "";
310 if (string[0] != '\0')
311 ctk_label_set_text_with_mnemonic(CTK_LABEL(widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_label_get_type ()))))))
, string);
312 else
313 ctk_widget_hide(widget);
314
315 g_strfreev(tokens);
316
317 ctk_builder_connect_signals(dialog->priv->ui, dialog);
318
319 g_signal_connect(dialog->priv->equation, "notify::accuracy", G_CALLBACK(accuracy_cb), dialog)g_signal_connect_data ((dialog->priv->equation), ("notify::accuracy"
), (((GCallback) (accuracy_cb))), (dialog), ((void*)0), (GConnectFlags
) 0)
;
320 g_signal_connect(dialog->priv->equation, "notify::show-thousands-separators", G_CALLBACK(show_thousands_separators_cb), dialog)g_signal_connect_data ((dialog->priv->equation), ("notify::show-thousands-separators"
), (((GCallback) (show_thousands_separators_cb))), (dialog), (
(void*)0), (GConnectFlags) 0)
;
321 g_signal_connect(dialog->priv->equation, "notify::show-trailing_zeroes", G_CALLBACK(show_trailing_zeroes_cb), dialog)g_signal_connect_data ((dialog->priv->equation), ("notify::show-trailing_zeroes"
), (((GCallback) (show_trailing_zeroes_cb))), (dialog), ((void
*)0), (GConnectFlags) 0)
;
322 g_signal_connect(dialog->priv->equation, "notify::number-format", G_CALLBACK(number_format_cb), dialog)g_signal_connect_data ((dialog->priv->equation), ("notify::number-format"
), (((GCallback) (number_format_cb))), (dialog), ((void*)0), (
GConnectFlags) 0)
;
323 g_signal_connect(dialog->priv->equation, "notify::word-size", G_CALLBACK(word_size_cb), dialog)g_signal_connect_data ((dialog->priv->equation), ("notify::word-size"
), (((GCallback) (word_size_cb))), (dialog), ((void*)0), (GConnectFlags
) 0)
;
324 g_signal_connect(dialog->priv->equation, "notify::angle-units", G_CALLBACK(angle_unit_cb), dialog)g_signal_connect_data ((dialog->priv->equation), ("notify::angle-units"
), (((GCallback) (angle_unit_cb))), (dialog), ((void*)0), (GConnectFlags
) 0)
;
325
326 accuracy_cb(dialog->priv->equation, NULL((void*)0), dialog);
327 show_thousands_separators_cb(dialog->priv->equation, NULL((void*)0), dialog);
328 show_trailing_zeroes_cb(dialog->priv->equation, NULL((void*)0), dialog);
329 number_format_cb(dialog->priv->equation, NULL((void*)0), dialog);
330 word_size_cb(dialog->priv->equation, NULL((void*)0), dialog);
331 angle_unit_cb(dialog->priv->equation, NULL((void*)0), dialog);
332}
333
334
335static void
336math_preferences_set_property(GObject *object,
337 guint prop_id,
338 const GValue *value,
339 GParamSpec *pspec)
340{
341 MathPreferencesDialog *self;
342
343 self = MATH_PREFERENCES(object)((((MathPreferencesDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), (math_preferences_get_type()))
)))
;
344
345 switch (prop_id) {
346 case PROP_EQUATION:
347 self->priv->equation = g_value_get_object(value);
348 create_gui(self);
349 break;
350 default:
351 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'"
, "math-preferences.c", 351, ("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)
;
352 break;
353 }
354}
355
356
357static void
358math_preferences_get_property(GObject *object,
359 guint prop_id,
360 GValue *value,
361 GParamSpec *pspec)
362{
363 MathPreferencesDialog *self;
364
365 self = MATH_PREFERENCES(object)((((MathPreferencesDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), (math_preferences_get_type()))
)))
;
366
367 switch (prop_id) {
368 case PROP_EQUATION:
369 g_value_set_object(value, self->priv->equation);
370 break;
371 default:
372 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'"
, "math-preferences.c", 372, ("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)
;
373 break;
374 }
375}
376
377
378static void
379math_preferences_class_init(MathPreferencesDialogClass *klass)
380{
381 GObjectClass *object_class = G_OBJECT_CLASS(klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
382
383 object_class->get_property = math_preferences_get_property;
384 object_class->set_property = math_preferences_set_property;
385
386 g_object_class_install_property(object_class,
387 PROP_EQUATION,
388 g_param_spec_object("equation",
389 "equation",
390 "Equation being configured",
391 math_equation_get_type(),
392 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
393}
394
395
396static void
397math_preferences_init(MathPreferencesDialog *dialog)
398{
399 dialog->priv = math_preferences_get_instance_private (dialog);
400}