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