int main(int argc, char **argv) { MathEquation *equation; int accuracy = 9, word_size = 64, base = 10; gboolean show_tsep = FALSE, show_zeroes = FALSE; DisplayFormat number_format; MPAngleUnit angle_units; ButtonMode button_mode; gchar *source_currency, *target_currency; g_type_init(); bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); /* Seed random number generator. */ srand48((long) time((time_t *) 0)); get_options(argc, argv); settings = g_settings_new ("org.mate.calc"); accuracy = g_settings_get_int(settings, "accuracy"); word_size = g_settings_get_int(settings, "word-size"); base = g_settings_get_int(settings, "base"); show_tsep = g_settings_get_boolean(settings, "show-thousands"); show_zeroes = g_settings_get_boolean(settings, "show-zeroes"); number_format = g_settings_get_enum(settings, "number-format"); angle_units = g_settings_get_enum(settings, "angle-units"); button_mode = g_settings_get_enum(settings, "button-mode"); source_currency = g_settings_get_string(settings, "source-currency"); target_currency = g_settings_get_string(settings, "target-currency"); equation = math_equation_new(); math_equation_set_accuracy(equation, accuracy); math_equation_set_word_size(equation, word_size); math_equation_set_show_thousands_separators(equation, show_tsep); math_equation_set_show_trailing_zeroes(equation, show_zeroes); math_equation_set_number_format(equation, number_format); math_equation_set_angle_units(equation, angle_units); math_equation_set_source_currency(equation, source_currency); math_equation_set_target_currency(equation, target_currency); g_free(source_currency); g_free(target_currency); gtk_init(&argc, &argv); window = math_window_new(equation); g_signal_connect(G_OBJECT(window), "quit", G_CALLBACK(quit_cb), NULL); math_buttons_set_programming_base(math_window_get_buttons(window), base); math_buttons_set_mode(math_window_get_buttons(window), button_mode); // FIXME: We load the basic buttons even if we immediately switch to the next type gtk_widget_show(GTK_WIDGET(window)); gtk_main(); return(0); }
G_MODULE_EXPORT void angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog) { MPAngleUnit value; GtkTreeModel *model; GtkTreeIter iter; model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter); gtk_tree_model_get(model, &iter, 1, &value, -1); math_equation_set_angle_units(dialog->priv->equation, value); }
static void startup_cb(GApplication *application) { MathEquation *equation; MathButtons *buttons; int accuracy = 9, word_size = 64, base = 10; gboolean show_tsep = FALSE, show_zeroes = FALSE; MpDisplayFormat number_format; MPAngleUnit angle_units; ButtonMode button_mode; gchar *source_currency, *target_currency; gchar *source_units, *target_units; settings = g_settings_new ("org.gnome.gcalctool"); accuracy = g_settings_get_int(settings, "accuracy"); word_size = g_settings_get_int(settings, "word-size"); base = g_settings_get_int(settings, "base"); show_tsep = g_settings_get_boolean(settings, "show-thousands"); show_zeroes = g_settings_get_boolean(settings, "show-zeroes"); number_format = g_settings_get_enum(settings, "number-format"); angle_units = g_settings_get_enum(settings, "angle-units"); button_mode = g_settings_get_enum(settings, "button-mode"); source_currency = g_settings_get_string(settings, "source-currency"); target_currency = g_settings_get_string(settings, "target-currency"); source_units = g_settings_get_string(settings, "source-units"); target_units = g_settings_get_string(settings, "target-units"); equation = math_equation_new(); math_equation_set_accuracy(equation, accuracy); math_equation_set_word_size(equation, word_size); math_equation_set_show_thousands_separators(equation, show_tsep); math_equation_set_show_trailing_zeroes(equation, show_zeroes); math_equation_set_number_format(equation, number_format); math_equation_set_angle_units(equation, angle_units); math_equation_set_source_currency(equation, source_currency); math_equation_set_target_currency(equation, target_currency); math_equation_set_source_units(equation, source_units); math_equation_set_target_units(equation, target_units); g_free(source_currency); g_free(target_currency); g_free(source_units); g_free(target_units); g_signal_connect(equation, "notify::accuracy", G_CALLBACK(accuracy_cb), NULL); g_signal_connect(equation, "notify::word-size", G_CALLBACK(word_size_cb), NULL); g_signal_connect(equation, "notify::show-thousands-separators", G_CALLBACK(show_thousands_separators_cb), NULL); g_signal_connect(equation, "notify::show-trailing-zeroes", G_CALLBACK(show_trailing_zeroes_cb), NULL); g_signal_connect(equation, "notify::number-format", G_CALLBACK(number_format_cb), NULL); g_signal_connect(equation, "notify::angle-units", G_CALLBACK(angle_unit_cb), NULL); g_signal_connect(equation, "notify::source-currency", G_CALLBACK(source_currency_cb), NULL); g_signal_connect(equation, "notify::target-currency", G_CALLBACK(target_currency_cb), NULL); g_signal_connect(equation, "notify::source-units", G_CALLBACK(source_units_cb), NULL); g_signal_connect(equation, "notify::target-units", G_CALLBACK(target_units_cb), NULL); window = math_window_new(GTK_APPLICATION(application), equation); buttons = math_window_get_buttons(window); math_buttons_set_programming_base(buttons, base); math_buttons_set_mode(buttons, button_mode); // FIXME: We load the basic buttons even if we immediately switch to the next type g_signal_connect(buttons, "notify::programming-base", G_CALLBACK(programming_base_cb), NULL); g_signal_connect(buttons, "notify::mode", G_CALLBACK(mode_cb), NULL); gtk_widget_show(GTK_WIDGET(window)); }