WIP: a minimal sand box cleaned

This commit is contained in:
Jean Sirmai 2024-01-18 17:00:41 +01:00
parent fadd5f256f
commit e47bd2b0dc
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 31 additions and 9 deletions

View File

@ -58,7 +58,7 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
hello_it_s_me(); // in bac-à-sable hello_it_s_me(); // in : "bac-à-sable.c"
g_autoptr(GemGraphClientApplication) app = NULL; g_autoptr(GemGraphClientApplication) app = NULL;
int res; int res;

View File

@ -23,6 +23,7 @@
#include <unistd.h> #include <unistd.h>
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib-2.0/glib.h> #include <glib-2.0/glib.h>
#include "../../include/base.h" #include "../../include/base.h"
@ -30,7 +31,6 @@
static void on_button_action (GtkWidget *widget, gpointer data) { g_print ("Hello, it's me ! (again)\n");} static void on_button_action (GtkWidget *widget, gpointer data) { g_print ("Hello, it's me ! (again)\n");}
static void on_destroy (GtkWidget *widget, gpointer data) { exit(0);} static void on_destroy (GtkWidget *widget, gpointer data) { exit(0);}
void hello_it_s_me() void hello_it_s_me()
@ -38,28 +38,50 @@ void hello_it_s_me()
GtkWidget *my_window; GtkWidget *my_window;
GtkWidget *my_box; GtkWidget *my_box;
GtkWidget *my_button; GtkWidget *my_button;
char *my_title = "Hello, it's me !"; char *my_window_title = "Hello, it's me !";
char *my_button_title = "And I'm the button."; char *my_button_title = "And I'm the button.";
gtk_init(); gtk_init(); // < nécessaire ici car, pour ne pas désorganiser l'écriture de main(),
// hello_it_s_me() est appelé avant l'initialisation de l'application
my_window = gtk_window_new (); my_window = gtk_window_new ();
g_signal_connect(G_OBJECT (my_window), "on_destroy::", G_CALLBACK(on_destroy), NULL); g_signal_connect(G_OBJECT (my_window), "destroy", G_CALLBACK(on_destroy), NULL);
gtk_window_set_title (GTK_WINDOW(my_window), my_title); gtk_window_set_title (GTK_WINDOW(my_window), my_window_title);
gtk_window_set_default_size (GTK_WINDOW(my_window), 200, 34); gtk_window_set_default_size (GTK_WINDOW(my_window), 200, 34);
my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
my_button = gtk_button_new_with_label (my_button_title); my_button = gtk_button_new_with_label (my_button_title);
g_signal_connect(G_OBJECT (my_button), "on_button_action::", G_CALLBACK(on_button_action), NULL); g_signal_connect(G_OBJECT (my_button), "clicked", G_CALLBACK(on_button_action), NULL);
gtk_box_append(GTK_BOX(my_box), GTK_WIDGET(my_button)); gtk_box_append(GTK_BOX(my_box), GTK_WIDGET(my_button));
// gtk_widget_show (my_button); // gtk_widget_show (my_button); < inutile (appels récursifs)
gtk_window_set_child(GTK_WINDOW(my_window), GTK_WIDGET(my_box)); gtk_window_set_child(GTK_WINDOW(my_window), GTK_WIDGET(my_box));
gtk_widget_show (my_window); gtk_widget_show (my_window);
printf("A little window is created in bac-a-sable with title : %s\n", my_title); printf("A little window is created in bac-a-sable with title : %s\n", my_window_title);
} }
//------------------------------------------------------------------------------
// guix shell -m manifest.scm make clean && clear && time make run
// GOBJECT_DEBUG=instance_count Gio Gnome input output
// https://docs.gtk.org/
// https://docs.gtk.org/gtk4/
// https://docs.gtk.org/glib/
// https://docs.gtk.org/gio/
//
// https://docs.gtk.org/gtk4/question_index.html
// https://docs.gtk.org/gtk4/running.html
//
// https://blog.gtk.org/2020/09/05/a-primer-on-gtklistview/ <<< Factory mechanism
// https://docs.gtk.org/gtk4/class.ListItemFactory.html <<<
// https://www.typeerror.org/docs/gtk~4.0/gtksignallistitemfactory
// https://developer-old.gnome.org/gtk4/stable/GtkListView.html <<< copy that !
// https://docs.gtk.org/gtk4/ctor.TreeListModel.new.html ***
// https://blog.gtk.org/2020/06/08/more-on-lists-in-gtk-4/ ***