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