From dbe087167d2052affea150f0456c0f22abf7adbc Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 2 Aug 2024 06:18:48 +0200 Subject: [PATCH] WIP: https://docs.gtk.org/gdk4/iface.Paintable.html GdkPaintable is a simple interface used by GTK to represent content that can be painted. --- src/widget/rules/tree_tools/compare.c | 39 +++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/widget/rules/tree_tools/compare.c b/src/widget/rules/tree_tools/compare.c index a62ccad..f6e744d 100644 --- a/src/widget/rules/tree_tools/compare.c +++ b/src/widget/rules/tree_tools/compare.c @@ -98,10 +98,10 @@ static GtkWidget *peek(Stack *stack) } // ----------------------------------------------------------- -// 2024-08-01 +// 2024-08-01 neox dixit : // GTK possède un espace mémoire où les widgets sont alloués/désalloués // Un widget ne conserve pas son pointeur. Son adresse peut changer. -// Donc créer une stack de widget avec un outil hors GTK n'est pas faisable >> +// Créer une stack de widget avec un outil hors GTK n'est pas faisable. Donc : // - soit tu traites les images hors de GTK, // - soit tu trouves un outil dans GTK pour ce type d'opération. // C'est le cas de toute bibliothèque externe que tu utilises : @@ -122,8 +122,22 @@ static GtkWidget *peek(Stack *stack) // Donc une application injective & non-surjective. // // https://docs.gtk.org/gio/iface.ListModel.html?q=icon << TODO +// https://docs.gtk.org/gtk4/class.Image.html +// Sometimes an application will want to avoid depending on external data files, +// such as image files. See the documentation of GResource inside GIO, for details. +// In this case, GtkImage:resource, gtk_image_new_from_resource(), +// and gtk_image_set_from_resource() should be used. +// GtkImage displays its image as an icon, with a size that is determined by the application. +// See GtkPicture if you want to show an image at is actual size. +// https://docs.gtk.org/gtk4/ctor.Image.new_from_resource.html +// The storage type (see gtk_image_get_storage_type()) of the returned image is not defined, +// it will be whatever is appropriate for displaying the file. +// https://docs.gtk.org/gdk4/iface.Paintable.html +// GdkPaintable is a simple interface used by GTK to represent content that can be painted. +// In order to implement Paintable, your type must inherit fromGObject. static void *push_images_onto_stack (Stack stack_b); +static GtkWidget *do_rtfd (Stack stack_b); void *get_an_impression_of_what_a_rules_comparator_could_be(){ @@ -136,6 +150,7 @@ void *get_an_impression_of_what_a_rules_comparator_could_be(){ initialize(&stack_b); // push_images_onto_stack (stack_b); + do_rtfd (stack_b); push(&stack_b, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/glutathione.png"))); @@ -171,9 +186,23 @@ void *get_an_impression_of_what_a_rules_comparator_could_be(){ - - - +static GtkWidget *do_rtfd (Stack stack) +{ + GtkImage *image_insuline = GTK_IMAGE (gtk_image_new_from_resource + ("/home/jean/Gem-Graph/gem-graph-client/data/image/insuline.png")); + gtk_image_set_from_resource (image_insuline, + "/home/jean/Gem-Graph/gem-graph-client/data/image/legumin.png"); + gtk_image_set_pixel_size (image_insuline, 256); + GtkImageType image_insuline_storage_type = gtk_image_get_storage_type (image_insuline); +// gtk_image_set_from_paintable (image_insuline, ? GdkPaintable* paintable); + GdkPaintable* paintable_insulin + = gdk_paintable_get_current_image (GDK_PAINTABLE (image_insuline)); + GtkWidget *widget_insuline = GTK_WIDGET (image_insuline); + if (image_insuline_storage_type == GTK_IMAGE_ICON_NAME) + printf("insuline image now at : %p storage_type : %s\n", + &image_insuline, "GTK_IMAGE_ICON_NAME"); + return widget_insuline; +}