|
|
|
@ -4,11 +4,8 @@
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
#include "misc.h"
|
|
|
|
|
|
|
|
|
|
#define _(STRING) gettext(STRING)
|
|
|
|
|
#define TAX 1.111111111
|
|
|
|
|
#define VERSION "1.0.0"
|
|
|
|
|
#include "include/addtax.h"
|
|
|
|
|
#include "include/misc.h"
|
|
|
|
|
|
|
|
|
|
GtkLabel *calculated_value = NULL;
|
|
|
|
|
|
|
|
|
@ -18,7 +15,7 @@ void calculate_tax(GtkWidget *entry) {
|
|
|
|
|
const gchar *label_text;
|
|
|
|
|
entry_text = (char*) gtk_entry_get_text(GTK_ENTRY(entry));
|
|
|
|
|
money = atof(entry_text);
|
|
|
|
|
if (is_float(entry_text, money)) {
|
|
|
|
|
if (is_float(entry_text)) {
|
|
|
|
|
g_print("$%d * %f = ", (int) round(money), TAX);
|
|
|
|
|
money = money * TAX;
|
|
|
|
|
g_print("$%d\n", (int) round(money));
|
|
|
|
@ -56,7 +53,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
// Process arguments that are not options
|
|
|
|
|
while (optind < argc) {
|
|
|
|
|
money = atof(argv[optind]);
|
|
|
|
|
if (is_float(argv[optind++], money)) {
|
|
|
|
|
if (is_float(argv[optind++])) {
|
|
|
|
|
printf("$%d * %f = ", (int) round(money), TAX);
|
|
|
|
|
money = money * TAX;
|
|
|
|
|
printf("$%d\n", (int) round(money));
|
|
|
|
@ -71,11 +68,16 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
|
|
|
|
GtkBuilder *builder;
|
|
|
|
|
GtkWidget *window;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
gtk_init(&argc, &argv);
|
|
|
|
|
|
|
|
|
|
builder = gtk_builder_new();
|
|
|
|
|
gtk_builder_add_from_resource(builder, "/cl/cromer/addtax/window_main.glade", NULL);
|
|
|
|
|
gtk_builder_add_from_resource(builder, "/cl/cromer/addtax/window_main.glade", &error);
|
|
|
|
|
if (error != NULL) {
|
|
|
|
|
fprintf(stderr, "Error: %s\n", error->message);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window = GTK_WIDGET(gtk_builder_get_object(builder, "window_main"));
|
|
|
|
|
gtk_builder_connect_signals(builder, NULL);
|
|
|
|
@ -91,7 +93,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called when calculate is clicked
|
|
|
|
|
void on_button_calculate_clicked(GtkWidget *button, GtkWidget *entry) {
|
|
|
|
|
void on_button_calculate_clicked(__attribute__((unused)) GtkWidget *button, GtkWidget *entry) {
|
|
|
|
|
calculate_tax(entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|