diff --git a/Makefile b/Makefile index 7e718ca..1dda004 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ run: exec.o #------------------------------------------------------------------------------# -# To study : can the following commands be removed ? # +# To study : how can the following commands be modified ? # #------------------------------------------------------------------------------# #SHELL = /bin/sh @@ -55,8 +55,8 @@ run: exec.o #OPTIMIZE = -O2 # in exec.o: -# $(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -# après les $(...), dans : warm.c -o $@ main.c le $@ peut être supprimé +# $(WARNINGS) $(DEBUG) $(OPTIMIZE) < ne sont pas indispensables +# si le $@ est supprimé, main.cest modifié #all: # exec diff --git a/Makefile_de_gem-graph-client b/Makefile_de_gem-graph-client deleted file mode 100644 index 7012b2b..0000000 --- a/Makefile_de_gem-graph-client +++ /dev/null @@ -1,132 +0,0 @@ -## -## Gem-graph OpenGL experiments -## -## Desc: Makefile -## -## Copyright (C) 2023 Arthur Menges -## Copyright (C) 2023 Adrien Bourmault -## -## This file is part of Gem-graph. -## -## This program is free software: you can redistribute it and/or modify -## it under the terms of the GNU Affero General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU Affero General Public License for more details. -## -## You should have received a copy of the GNU Affero General Public License -## along with this program. If not, see . -## - -.PHONY: all clean install run build_system -.DELETE_ON_ERROR: $(BINDIR)/gem-graph-client -.DEFAULT_GOAL := all - -# -# Color codes -# -CL='\033[0;32m' -CL2='\033[1;36m' -CL3='\033[0m' -NC='\033[1;37m' - -# -# Variables & constants -# -NTHREADS= $(shell nproc) - -CC=gcc -WARNINGS= -Wall -DEBUG= -ggdb -fno-omit-frame-pointer -fdiagnostics-color=always -fsanitize=bounds -fstack-check - #-fsanitize=address \ - #-fsanitize=pointer-compare -fsanitize=pointer-subtract \ - #-fsanitize=leak -fsanitize=undefined -fsanitize=null -fsanitize=bounds -OPTIMIZE= -O3 -INCLUDE= $(shell pkg-config --cflags glib-2.0 libxml-2.0 gtk4) -LIBS= $(shell pkg-config --libs glib-2.0 libxml-2.0 gtk4) -lGL -lGLU -lm -lepoxy -lX11 -lGLEW - -BINDIR=bin -BUILDDIR=build -SRCDIR=src -#vpath %.c $(SRCDIR) - -SOURCES= $(shell find $(SRCDIR) -type f -name "*.c") -BUILDBINS=$(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES)) -BUILDDEPS=$(patsubst %.c,$(BUILDDIR)/%.d,$(SOURCES)) - --include /etc/os-release - -# -# Directories -# -$(BUILDDIR): - @mkdir -p $@ - @echo -e ${CL2}[$@] ${CL}folder generated.${CL3} - -$(BINDIR): - @mkdir -p $@ - @echo -e ${CL2}[$@] ${CL}folder generated.${CL3} - -# -# Dependencies -# --include $(BUILDDEPS) - -$(BUILDDIR)/%.d: %.c | $(BUILDDIR) - @mkdir -p $(shell dirname $@) - @$(CC) -MM -MT $(@:%.d=%.o) -MF $@ $< - @echo -e ${CL2}[$@] ${CL}dependencies generated.${CL3} - -# -# Compilation -# -$(BINDIR)/gem-graph-client: $(BUILDBINS) | $(BINDIR) - @$(CC) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ $(INCLUDE) $(LIBS) - @echo -e ${CL2}[$@] ${CL}built.${CL3} - - -$(BUILDDIR)/%.o: %.c | $(BUILDDIR) - @mkdir -p $(shell dirname $@) - @$(CC) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $(INCLUDE) -c $< -o $@ - @echo -e ${CL2}[$@] ${CL}compiled.${CL3} - - -# -# Virtual recipes -# -clean: - @rm -rf $(BINDIR) - @rm -rf $(BUILDDIR) - @echo -e ${CL2}[$@] ${CL}done.${CL3} - -install: - echo "Installing is not supported" - -build_system: - @echo -e ${CL2}[$@] ${CL}building...${CL3} - @make $(BINDIR)/gem-graph-client -j $(NTHREADS) - @echo -e ${CL2}[$@] ${CL}done.${CL3} - -run: build_system - @echo -e ${CL2}[$@] ${CL}executing...${CL3} - @$(BINDIR)/gem-graph-client - @echo -e ${CL2}[$@] ${CL}done.${CL3} - -debug: build_system - @echo -e ${CL2}[$@] ${CL}executing...${CL3} - @gdb $(BINDIR)/gem-graph-client - @echo -e ${CL2}[$@] ${CL}done.${CL3} - -valgrind: build_system - @echo -e ${CL2}[$@] ${CL}executing...${CL3} - @valgrind $(BINDIR)/gem-graph-client - @echo -e ${CL2}[$@] ${CL}done.${CL3} - -all: build_system - @echo -e ${CL2}[$@] ${CL}done.${CL3} - - diff --git a/cold.c b/cold.c index 79e887e..46a10da 100644 --- a/cold.c +++ b/cold.c @@ -2,3 +2,28 @@ #include void print_text(GtkWidget *widget, gpointer data) {g_print (data);} + +void button_0(GtkWindow *window, GtkWidget *grid, int x, int y, int w, int h){ + GtkWidget *button_0 = gtk_button_new_with_label ("Quit"); + g_signal_connect (button_0, "clicked", G_CALLBACK (print_text), "bye !...\n"); + g_signal_connect_swapped (button_0, "clicked", G_CALLBACK (gtk_window_destroy), window); + gtk_grid_attach (GTK_GRID (grid), button_0, x, y, w, h); +} + +void button_1(GtkWidget *grid, int x, int y, int w, int h){ + GtkWidget *button_1 = gtk_button_new_with_label ("bouton (I)"); + g_signal_connect (button_1, "clicked", G_CALLBACK (print_text), "n°1\n"); + gtk_grid_attach (GTK_GRID (grid), button_1, x, y, w, h); +} + +void window_bar(GtkWindow *window, char *title){ + GtkWidget *titlebar = gtk_header_bar_new(); + gtk_window_set_title (window, title); + gtk_window_set_titlebar (window, titlebar); // header_bar +} + +void window_grid(GtkWindow *window){ + GtkWidget *grid = gtk_grid_new(); + gtk_window_set_child (window, grid); +} + diff --git a/cold.h b/cold.h index bae6424..240b5c7 100644 --- a/cold.h +++ b/cold.h @@ -2,13 +2,15 @@ #include void print_text(GtkWidget *widget, gpointer data); +void button_0(GtkWindow *window, GtkWidget *grid, int x, int y, int w, int h); +void button_1(GtkWidget *grid, int x, int y, int w, int h); +void window_bar(GtkWindow *window, char *title); +void window_grid(GtkWindow *window); /* - GtkWidget *button_0 = gtk_button_new_with_label ("Quit"); - GtkWidget *button_1 = gtk_button_new_with_label ("I"); - GtkWidget *button_2 = gtk_button_new_with_label ("II"); - GtkWidget *button_3 = gtk_button_new_with_label ("III"); - GtkWidget *button_4 = gtk_button_new_with_label ("IV"); - GtkWidget *button_5 = gtk_button_new_with_label ("V"); +GtkWidget *button_2 = gtk_button_new_with_label ("II"); +GtkWidget *button_3 = gtk_button_new_with_label ("III"); +GtkWidget *button_4 = gtk_button_new_with_label ("IV"); +GtkWidget *button_5 = gtk_button_new_with_label ("V"); */ // GtkToggleButton *tb1 = GTK_TOGGLE_BUTTON (gtk_button_new_with_label ("tb1")); diff --git a/exec.o b/exec.o index 9a622b7..aebdf04 100755 Binary files a/exec.o and b/exec.o differ diff --git a/main.c b/main.c old mode 100755 new mode 100644 index cf5c551..32e4ae0 --- a/main.c +++ b/main.c @@ -3,11 +3,9 @@ #include "warm.h" #include "cold.h" + static void activate (GtkApplication *app, gpointer user_data) { - GtkWidget *button_0 = gtk_button_new_with_label ("Quit"); - GtkWidget *button_1 = gtk_button_new_with_label ("bouton (I)"); - GtkWidget *window = gtk_application_window_new (app); - GtkWidget *titlebar = gtk_header_bar_new(); + GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app)); GtkWidget *switcher = gtk_stack_switcher_new(); // GtkWidget *sidebar = gtk_stack_sidebar_new(); GtkStack *stack = GTK_STACK (gtk_stack_new()); @@ -16,15 +14,10 @@ static void activate (GtkApplication *app, gpointer user_data) { GtkWidget *grid = gtk_grid_new(); GtkWidget *box_1 = gtk_box_new (0, 6); // 6 = spacing - gtk_window_set_title (GTK_WINDOW (window), "Window"); - gtk_window_set_titlebar (GTK_WINDOW (window), titlebar); // header_bar - gtk_window_set_child (GTK_WINDOW (window), grid); - - g_signal_connect (button_1, "clicked", G_CALLBACK (print_text), "n°1\n"); - gtk_grid_attach (GTK_GRID (grid), button_1, 0, 0, 1, 1); - g_signal_connect (button_0, "clicked", G_CALLBACK (print_text), "bye !...\n"); - g_signal_connect_swapped (button_0, "clicked", G_CALLBACK (gtk_window_destroy), window); - gtk_grid_attach (GTK_GRID (grid), button_0, 1, 0, 1, 1); + window_bar (window, "window"); + gtk_window_set_child (window, grid); + button_0 (window, grid, 1,0,1,1); + button_1 (grid, 0,0,1,1); gtk_stack_add_titled (stack, page_0, "n°0", "A"); gtk_stack_add_titled (stack, page_1, "n°1", "B");