diff --git a/Makefile b/Makefile index 8399348..d08b524 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ TARGET = matemateak CFLAGS = -std=c17 -Wall -Wextra -Wpedantic -Wconversion LFLAGS = -lm +CFLAGS += $(shell pkg-config --cflags gtk+-2.0) +LFLAGS += $(shell pkg-config --libs gtk+-2.0) + C_FILES = $(shell find src/ -name *.c) HEADER_FILES = $(shell find src/ -name *.h) diff --git a/src/main.c b/src/main.c index d43fd5b..2a55811 100644 --- a/src/main.c +++ b/src/main.c @@ -1,10 +1,11 @@ #include "lexer.h" #include "parser.h" +#include #include #include #include -int main(void) +void test_lexer_parser(void) { char* text = "2 * (3 + 4)"; @@ -28,3 +29,47 @@ int main(void) free(ast_string); free_expr(ast); } + +int main(int argc, char** argv) +{ + GtkWidget* window; + GtkWidget* vbox; + + GtkWidget* menubar; + GtkWidget* fileMenu; + GtkWidget* fileMi; + GtkWidget* quitMi; + + gtk_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_window_set_default_size(GTK_WINDOW(window), 300, 200); + gtk_window_set_title(GTK_WINDOW(window), "Simple menu"); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), vbox); + + menubar = gtk_menu_bar_new(); + fileMenu = gtk_menu_new(); + + fileMi = gtk_menu_item_new_with_label("File"); + quitMi = gtk_menu_item_new_with_label("Quit"); + + gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileMi), fileMenu); + gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), quitMi); + gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi); + gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); + + g_signal_connect( + G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL + ); + + g_signal_connect( + G_OBJECT(quitMi), "activate", G_CALLBACK(gtk_main_quit), NULL + ); + + gtk_widget_show_all(window); + + gtk_main(); +} diff --git a/src/parser.c b/src/parser.c index aea069d..c544c31 100644 --- a/src/parser.c +++ b/src/parser.c @@ -266,7 +266,6 @@ const char* binary_expr_type_to_string(BinaryExprType type) char* expr_to_string(const Expr* expr) { - printf("expr->type == %d\n", expr->type); switch (expr->type) { case ExprTypeError: { char formattet[65536];