try add gtk2
This commit is contained in:
parent
9177a1cd24
commit
e6edf7bb42
3
Makefile
3
Makefile
@ -6,6 +6,9 @@ TARGET = matemateak
|
|||||||
CFLAGS = -std=c17 -Wall -Wextra -Wpedantic -Wconversion
|
CFLAGS = -std=c17 -Wall -Wextra -Wpedantic -Wconversion
|
||||||
LFLAGS = -lm
|
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)
|
C_FILES = $(shell find src/ -name *.c)
|
||||||
HEADER_FILES = $(shell find src/ -name *.h)
|
HEADER_FILES = $(shell find src/ -name *.h)
|
||||||
|
|
||||||
|
47
src/main.c
47
src/main.c
@ -1,10 +1,11 @@
|
|||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
#include <gtk/gtk.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int main(void)
|
void test_lexer_parser(void)
|
||||||
{
|
{
|
||||||
char* text = "2 * (3 + 4)";
|
char* text = "2 * (3 + 4)";
|
||||||
|
|
||||||
@ -28,3 +29,47 @@ int main(void)
|
|||||||
free(ast_string);
|
free(ast_string);
|
||||||
free_expr(ast);
|
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();
|
||||||
|
}
|
||||||
|
@ -266,7 +266,6 @@ const char* binary_expr_type_to_string(BinaryExprType type)
|
|||||||
|
|
||||||
char* expr_to_string(const Expr* expr)
|
char* expr_to_string(const Expr* expr)
|
||||||
{
|
{
|
||||||
printf("expr->type == %d\n", expr->type);
|
|
||||||
switch (expr->type) {
|
switch (expr->type) {
|
||||||
case ExprTypeError: {
|
case ExprTypeError: {
|
||||||
char formattet[65536];
|
char formattet[65536];
|
||||||
|
Loading…
Reference in New Issue
Block a user