File: | math-preferences.c |
Warning: | line 161, column 9 Value stored to 'valid' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | |
18 | enum { |
19 | PROP_0, |
20 | PROP_EQUATION |
21 | }; |
22 | |
23 | struct MathPreferencesDialogPrivate |
24 | { |
25 | MathEquation *equation; |
26 | CtkBuilder *ui; |
27 | }; |
28 | |
29 | G_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 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 = 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 ((&static_g_define_type_id ), (gsize) (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 | |
36 | MathPreferencesDialog * |
37 | math_preferences_dialog_new(MathEquation *equation) |
38 | { |
39 | return g_object_new(math_preferences_get_type(), "equation", equation, NULL((void*)0)); |
40 | } |
41 | |
42 | |
43 | static void |
44 | preferences_response_cb(CtkWidget *widget, gint id) |
45 | { |
46 | ctk_widget_hide(widget); |
47 | } |
48 | |
49 | |
50 | static gboolean |
51 | preferences_dialog_delete_cb(CtkWidget *widget, CdkEvent *event) |
52 | { |
53 | preferences_response_cb(widget, 0); |
54 | return TRUE(!(0)); |
55 | } |
56 | |
57 | |
58 | void number_format_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog); |
59 | G_MODULE_EXPORT__attribute__((visibility("default"))) |
60 | void |
61 | number_format_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog) |
62 | { |
63 | MpDisplayFormat value; |
64 | CtkTreeModel *model; |
65 | CtkTreeIter iter; |
66 | |
67 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
68 | 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); |
69 | ctk_tree_model_get(model, &iter, 1, &value, -1); |
70 | math_equation_set_number_format(dialog->priv->equation, value); |
71 | } |
72 | |
73 | |
74 | void angle_unit_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog); |
75 | G_MODULE_EXPORT__attribute__((visibility("default"))) |
76 | void |
77 | angle_unit_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog) |
78 | { |
79 | MPAngleUnit value; |
80 | CtkTreeModel *model; |
81 | CtkTreeIter iter; |
82 | |
83 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
84 | 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); |
85 | ctk_tree_model_get(model, &iter, 1, &value, -1); |
86 | math_equation_set_angle_units(dialog->priv->equation, value); |
87 | } |
88 | |
89 | |
90 | void word_size_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog); |
91 | G_MODULE_EXPORT__attribute__((visibility("default"))) |
92 | void |
93 | word_size_combobox_changed_cb(CtkWidget *combo, MathPreferencesDialog *dialog) |
94 | { |
95 | gint value; |
96 | CtkTreeModel *model; |
97 | CtkTreeIter iter; |
98 | |
99 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
100 | 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); |
101 | ctk_tree_model_get(model, &iter, 1, &value, -1); |
102 | math_equation_set_word_size(dialog->priv->equation, value); |
103 | } |
104 | |
105 | |
106 | void decimal_places_spin_change_value_cb(CtkWidget *spin, MathPreferencesDialog *dialog); |
107 | G_MODULE_EXPORT__attribute__((visibility("default"))) |
108 | void |
109 | decimal_places_spin_change_value_cb(CtkWidget *spin, MathPreferencesDialog *dialog) |
110 | { |
111 | gint value = 0; |
112 | |
113 | 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 ()))))))); |
114 | math_equation_set_accuracy(dialog->priv->equation, value); |
115 | } |
116 | |
117 | |
118 | void thousands_separator_check_toggled_cb(CtkWidget *check, MathPreferencesDialog *dialog); |
119 | G_MODULE_EXPORT__attribute__((visibility("default"))) |
120 | void |
121 | thousands_separator_check_toggled_cb(CtkWidget *check, MathPreferencesDialog *dialog) |
122 | { |
123 | gboolean value; |
124 | |
125 | value = ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON(check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((check)), ((ctk_toggle_button_get_type ()))))))); |
126 | math_equation_set_show_thousands_separators(dialog->priv->equation, value); |
127 | } |
128 | |
129 | |
130 | void trailing_zeroes_check_toggled_cb(CtkWidget *check, MathPreferencesDialog *dialog); |
131 | G_MODULE_EXPORT__attribute__((visibility("default"))) |
132 | void |
133 | trailing_zeroes_check_toggled_cb(CtkWidget *check, MathPreferencesDialog *dialog) |
134 | { |
135 | gboolean value; |
136 | |
137 | value = ctk_toggle_button_get_active(CTK_TOGGLE_BUTTON(check)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((check)), ((ctk_toggle_button_get_type ()))))))); |
138 | math_equation_set_show_trailing_zeroes(dialog->priv->equation, value); |
139 | } |
140 | |
141 | |
142 | static void |
143 | set_combo_box_from_int(CtkWidget *combo, int value) |
144 | { |
145 | CtkTreeModel *model; |
146 | CtkTreeIter iter; |
147 | gboolean valid; |
148 | |
149 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
150 | valid = ctk_tree_model_get_iter_first(model, &iter); |
151 | |
152 | while (valid) { |
153 | gint v; |
154 | |
155 | ctk_tree_model_get(model, &iter, 1, &v, -1); |
156 | if (v == value) |
157 | break; |
158 | valid = ctk_tree_model_iter_next(model, &iter); |
159 | } |
160 | if (!valid) |
161 | valid = ctk_tree_model_get_iter_first(model, &iter); |
Value stored to 'valid' is never read | |
162 | |
163 | 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); |
164 | } |
165 | |
166 | |
167 | static void |
168 | accuracy_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog) |
169 | { |
170 | 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 ())))))), |
171 | math_equation_get_accuracy(equation)); |
172 | g_settings_set_int(g_settings_var, "accuracy", math_equation_get_accuracy(equation)); |
173 | } |
174 | |
175 | |
176 | static void |
177 | show_thousands_separators_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog) |
178 | { |
179 | 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 ())))))), |
180 | math_equation_get_show_thousands_separators(equation)); |
181 | g_settings_set_boolean(g_settings_var, "show-thousands", math_equation_get_show_thousands_separators(equation)); |
182 | } |
183 | |
184 | |
185 | static void |
186 | show_trailing_zeroes_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog) |
187 | { |
188 | 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 ())))))), |
189 | math_equation_get_show_trailing_zeroes(equation)); |
190 | g_settings_set_boolean(g_settings_var, "show-zeroes", math_equation_get_show_trailing_zeroes(equation)); |
191 | } |
192 | |
193 | |
194 | static void |
195 | number_format_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog) |
196 | { |
197 | 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)); |
198 | g_settings_set_enum(g_settings_var, "number-format", math_equation_get_number_format(equation)); |
199 | } |
200 | |
201 | |
202 | static void |
203 | word_size_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog) |
204 | { |
205 | 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)); |
206 | g_settings_set_int(g_settings_var, "word-size", math_equation_get_word_size(equation)); |
207 | } |
208 | |
209 | |
210 | static void |
211 | angle_unit_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog) |
212 | { |
213 | 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)); |
214 | g_settings_set_enum(g_settings_var, "angle-units", math_equation_get_angle_units(equation)); |
215 | } |
216 | |
217 | |
218 | static void |
219 | create_gui(MathPreferencesDialog *dialog) |
220 | { |
221 | CtkWidget *widget; |
222 | CtkTreeModel *model; |
223 | CtkTreeIter iter; |
224 | CtkCellRenderer *renderer; |
225 | gchar *string, **tokens; |
226 | GError *error = NULL((void*)0); |
227 | static gchar *objects[] = { "preferences_table", "angle_unit_model", "number_format_model", |
228 | "word_size_model", "decimal_places_adjustment", "number_base_model", NULL((void*)0) }; |
229 | |
230 | // FIXME: Handle errors |
231 | dialog->priv->ui = ctk_builder_new(); |
232 | ctk_builder_add_objects_from_resource(dialog->priv->ui, UI_DIALOGS_RESOURCE_PATH"/org/cafe/calculator/ui/preferences.ui", objects, &error); |
233 | if (error) |
234 | g_warning("Error loading preferences UI: %s", error->message); |
235 | g_clear_error(&error); |
236 | |
237 | ctk_window_set_title(CTK_WINDOW(dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), |
238 | /* Title of preferences dialog */ |
239 | _("Preferences")gettext ("Preferences")); |
240 | ctk_container_set_border_width(CTK_CONTAINER(dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_container_get_type ())))))), 8); |
241 | ctk_dialog_add_button(CTK_DIALOG(dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
242 | /* Icon name on close button in preferences dialog */ |
243 | "ctk-close", CTK_RESPONSE_CLOSE); |
244 | |
245 | ctk_window_set_icon_name (CTK_WINDOW(dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), "accessories-calculator"); |
246 | |
247 | 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); |
248 | 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); |
249 | 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); |
250 | |
251 | 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 ())))))); |
252 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_combo_box_get_type ()))))))); |
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 degrees for trigonometric calculations */ |
256 | _("Degrees")gettext ("Degrees"), 1, MP_DEGREES, -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 radians for trigonometric calculations */ |
260 | _("Radians")gettext ("Radians"), 1, MP_RADIANS, -1); |
261 | ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), &iter); |
262 | ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), &iter, 0, |
263 | /* Preferences dialog: Angle unit combo box: Use gradians for trigonometric calculations */ |
264 | _("Gradians")gettext ("Gradians"), 1, MP_GRADIANS, -1); |
265 | renderer = ctk_cell_renderer_text_new(); |
266 | 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))); |
267 | 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); |
268 | |
269 | 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 ())))))); |
270 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_combo_box_get_type ()))))))); |
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: Automatic, e.g. 1234 (or scientific for large number 1.234×10^99) */ |
274 | _("Automatic")gettext ("Automatic"), 1, MP_DISPLAY_FORMAT_AUTOMATIC, -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: Fixed, e.g. 1234 */ |
278 | _("Fixed")gettext ("Fixed"), 1, MP_DISPLAY_FORMAT_FIXED, -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: Scientific, e.g. 1.234×10^3 */ |
282 | _("Scientific")gettext ("Scientific"), 1, MP_DISPLAY_FORMAT_SCIENTIFIC, -1); |
283 | ctk_list_store_append(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), &iter); |
284 | ctk_list_store_set(CTK_LIST_STORE(model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), &iter, 0, |
285 | /* Number display mode combo: Engineering, e.g. 1.234k */ |
286 | _("Engineering")gettext ("Engineering"), 1, MP_DISPLAY_FORMAT_ENGINEERING, -1); |
287 | renderer = ctk_cell_renderer_text_new(); |
288 | 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))); |
289 | 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); |
290 | |
291 | 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 ())))))); |
292 | renderer = ctk_cell_renderer_text_new(); |
293 | 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))); |
294 | 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); |
295 | |
296 | /* Label used in preferences dialog. The %d is replaced by a spinbutton */ |
297 | string = _("Show %d decimal _places")gettext ("Show %d decimal _places"); |
298 | tokens = g_strsplit(string, "%d", 2); |
299 | 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 ())))))); |
300 | if (tokens[0]) |
301 | string = g_strstrip(tokens[0])g_strchomp (g_strchug (tokens[0])); |
302 | else |
303 | string = ""; |
304 | if (string[0] != '\0') |
305 | ctk_label_set_text_with_mnemonic(CTK_LABEL(widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_label_get_type ())))))), string); |
306 | else |
307 | ctk_widget_hide(widget); |
308 | |
309 | 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 ())))))); |
310 | if (tokens[0] && tokens[1]) |
311 | string = g_strstrip(tokens[1])g_strchomp (g_strchug (tokens[1])); |
312 | else |
313 | string = ""; |
314 | if (string[0] != '\0') |
315 | ctk_label_set_text_with_mnemonic(CTK_LABEL(widget)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_label_get_type ())))))), string); |
316 | else |
317 | ctk_widget_hide(widget); |
318 | |
319 | g_strfreev(tokens); |
320 | |
321 | ctk_builder_connect_signals(dialog->priv->ui, dialog); |
322 | |
323 | 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); |
324 | 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); |
325 | 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); |
326 | 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); |
327 | 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); |
328 | 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); |
329 | |
330 | accuracy_cb(dialog->priv->equation, NULL((void*)0), dialog); |
331 | show_thousands_separators_cb(dialog->priv->equation, NULL((void*)0), dialog); |
332 | show_trailing_zeroes_cb(dialog->priv->equation, NULL((void*)0), dialog); |
333 | number_format_cb(dialog->priv->equation, NULL((void*)0), dialog); |
334 | word_size_cb(dialog->priv->equation, NULL((void*)0), dialog); |
335 | angle_unit_cb(dialog->priv->equation, NULL((void*)0), dialog); |
336 | } |
337 | |
338 | |
339 | static void |
340 | math_preferences_set_property(GObject *object, |
341 | guint prop_id, |
342 | const GValue *value, |
343 | GParamSpec *pspec) |
344 | { |
345 | MathPreferencesDialog *self; |
346 | |
347 | self = MATH_PREFERENCES(object)((((MathPreferencesDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), (math_preferences_get_type())) ))); |
348 | |
349 | switch (prop_id) { |
350 | case PROP_EQUATION: |
351 | self->priv->equation = g_value_get_object(value); |
352 | create_gui(self); |
353 | break; |
354 | default: |
355 | 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", 355, ("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); |
356 | break; |
357 | } |
358 | } |
359 | |
360 | |
361 | static void |
362 | math_preferences_get_property(GObject *object, |
363 | guint prop_id, |
364 | GValue *value, |
365 | GParamSpec *pspec) |
366 | { |
367 | MathPreferencesDialog *self; |
368 | |
369 | self = MATH_PREFERENCES(object)((((MathPreferencesDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), (math_preferences_get_type())) ))); |
370 | |
371 | switch (prop_id) { |
372 | case PROP_EQUATION: |
373 | g_value_set_object(value, self->priv->equation); |
374 | break; |
375 | default: |
376 | 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", 376, ("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); |
377 | break; |
378 | } |
379 | } |
380 | |
381 | |
382 | static void |
383 | math_preferences_class_init(MathPreferencesDialogClass *klass) |
384 | { |
385 | GObjectClass *object_class = G_OBJECT_CLASS(klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
386 | |
387 | object_class->get_property = math_preferences_get_property; |
388 | object_class->set_property = math_preferences_set_property; |
389 | |
390 | g_object_class_install_property(object_class, |
391 | PROP_EQUATION, |
392 | g_param_spec_object("equation", |
393 | "equation", |
394 | "Equation being configured", |
395 | math_equation_get_type(), |
396 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
397 | } |
398 | |
399 | |
400 | static void |
401 | math_preferences_init(MathPreferencesDialog *dialog) |
402 | { |
403 | dialog->priv = math_preferences_get_instance_private (dialog); |
404 | } |