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