ébauche de structuration
This commit is contained in:
parent
6a2f0fd2ca
commit
f10b52e7dd
16
Makefile
16
Makefile
|
@ -15,20 +15,22 @@ OPTIMIZE = -O2
|
|||
all:
|
||||
exec
|
||||
|
||||
exec.o: main.c Makefile
|
||||
$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -o $@ main.c
|
||||
exec.o:
|
||||
$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) warm.c -o $@ main.c
|
||||
|
||||
clean:
|
||||
rm -f exec.o
|
||||
|
||||
# Builder will call this to install the application before running.
|
||||
install:
|
||||
echo "Installing is not supported"
|
||||
|
||||
# Builder uses this target to run your application.
|
||||
run: exec.o
|
||||
run:
|
||||
./exec.o
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# gcc $( pkg-config --cflags gtk4 ) -o exec main.c $( pkg-config --libs gtk4 )
|
||||
|
||||
# https://www.gnu.org/software/make/manual/
|
||||
|
@ -79,7 +81,5 @@ run: exec.o
|
|||
# A target can also be the name of an action to carry out, such as ‘clean’
|
||||
|
||||
|
||||
|
||||
# https://blog.stephane-robert.info/docs/makefile/
|
||||
# https://blog.stephane-robert.info/docs/task/
|
||||
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/
|
||||
|
||||
|
|
42
main.c
42
main.c
|
@ -1,66 +1,36 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include "./warm.h"
|
||||
|
||||
static void print (GtkWidget *widget, gpointer data) {g_print (data);}
|
||||
#include "warm.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 ("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");
|
||||
|
||||
char *text = "niofnein";
|
||||
printf("in main.c : %s\n", text);
|
||||
// print_text(text);
|
||||
|
||||
GtkWidget *button_1 = gtk_button_new_with_label ("bouton (I)");
|
||||
GtkWidget *window = gtk_application_window_new (app);
|
||||
GtkWidget *titlebar = gtk_header_bar_new();
|
||||
|
||||
GtkWidget *switcher = gtk_stack_switcher_new();
|
||||
// GtkWidget *sidebar = gtk_stack_sidebar_new();
|
||||
GtkStack *stack = GTK_STACK (gtk_stack_new());
|
||||
GtkWidget *page_0 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
||||
GtkWidget *page_1 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
||||
GtkWidget *grid = gtk_grid_new();
|
||||
// GtkWidget *grid_1 = gtk_grid_new();
|
||||
GtkWidget *box = gtk_box_new (0, 6); // 6 = spacing
|
||||
GtkWidget *box_1 = gtk_box_new (0, 6); // 6 = spacing
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Window");
|
||||
gtk_widget_set_size_request (window, 60, 0);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), titlebar); // header_bar
|
||||
// gtk_window_set_overlay (GTK_WINDOW (window), overlay); // overlay
|
||||
gtk_window_set_child (GTK_WINDOW (window), grid);
|
||||
|
||||
g_signal_connect (button_1, "clicked", G_CALLBACK (print), "I'm n°1\n");
|
||||
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_2, "clicked", G_CALLBACK (print), "I'm n°2\n");
|
||||
gtk_grid_attach (GTK_GRID (grid), button_2, 1, 0, 1, 1);
|
||||
g_signal_connect (button_0, "clicked", G_CALLBACK (print), "bye !...\n");
|
||||
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, 0, 1, 2, 1);
|
||||
gtk_box_append (GTK_BOX (box), button_3);
|
||||
gtk_box_append (GTK_BOX (box), button_4);
|
||||
gtk_box_append (GTK_BOX (box_1), button_5);
|
||||
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), box, 0, 2, 2, 1);
|
||||
|
||||
// https://developer-old.gnome.org/gtk4/stable/GtkStack.html
|
||||
// https://developer.gnome.org/documentation/index.html
|
||||
// https://docs.gtk.org/gtk4/enum.AccessibleRole.html
|
||||
gtk_grid_attach (GTK_GRID (grid), button_0, 1, 0, 1, 1);
|
||||
|
||||
gtk_stack_add_titled (stack, page_0, "n°0", "A");
|
||||
gtk_stack_add_titled (stack, page_1, "n°1", "B");
|
||||
GtkStackPage *page_2 = gtk_stack_add_titled (stack, box_1, "any name", "C");
|
||||
gtk_stack_page_set_name (page_2, "n°2");
|
||||
|
||||
|
||||
// gtk_grid_attach (GTK_GRID (grid_1), button_5, 0, 0, 1, 1);
|
||||
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_VERTICAL);
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
|
@ -74,7 +44,7 @@ static void activate (GtkApplication *app, gpointer user_data) {
|
|||
gtk_stack_get_visible_child_name (stack));
|
||||
// gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 3, 2, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 2, 2, 1);
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
|
|
8
warm.c
8
warm.c
|
@ -1,15 +1,15 @@
|
|||
#pragma once
|
||||
//#pragma once
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
|
||||
button_0 = gtk_button_new_with_label ("Quit");
|
||||
/* 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_5 = gtk_button_new_with_label ("V");*/
|
||||
|
||||
// GtkToggleButton *tb1 = GTK_TOGGLE_BUTTON (gtk_button_new_with_label ("tb1"));
|
||||
|
||||
void print_text(char *text) {printf("in warm.c : %s\n", text);}
|
||||
void print_text(GtkWidget *widget, gpointer data) {g_print (data);}
|
||||
|
|
Loading…
Reference in New Issue