Compare commits

...

2 Commits

Author SHA1 Message Date
Jean Sirmai 930eb27f8a
WIP: cleaning/namming sandbox 2024-01-20 12:54:15 +01:00
Jean Sirmai fe6c0298cb
WIP: cleaning... cleaning... cleaning... 2024-01-20 12:40:52 +01:00
4 changed files with 28 additions and 79 deletions

View File

@ -130,4 +130,4 @@ GtkWidget *create_my_list_view_test(GtkBox *runlib_objects);
GtkWidget *create_my_editable_cells (GtkBox *my_box);
GtkWidget *hello_it_s_me();
void on_activate_window_creation (GtkApplication *app);
void on_activate_window_creation (GtkApplication *app, gpointer data);

View File

@ -50,7 +50,7 @@
* La suite est décrite dans
* - application.c (activation / désactivation des actions, ajouts d'accélérateurs)
* - gemgraph.ui (description statique de la fenêtre)
* - window.c (description dynamique de la fenêtre)
* - window.c (initialisation, description dynamique de la fenêtre - pas de "free" ?)
* - events.c (description individuelle des actions élémentaires)
* - tree.c (description d'une structure particulière) (sera répartie ultérieurement ?)
* - base.h (définitions 'transversales'/(communes) utilisables par plusieurs ressources
@ -58,17 +58,21 @@
int main(int argc, char **argv)
{
GtkWidget *my_window = hello_it_s_me(); // in : "bac-à-sable.c"
g_autoptr(GemGraphClientApplication) app = NULL;
int res;
app = gem_graph_client_application_new("org.alec.gemgraph",
G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (on_activate_window_creation), "creating a new window\n");
// g_signal_connect (app, "activate", G_CALLBACK (on_activate), my_window);
// g_signal_connect (app, "activate", G_CALLBACK (on_activate), my_window);
g_signal_connect (app, "activate", G_CALLBACK (on_activate_window_creation), // in : "sand_box_2.c :"
"the signal comes from main.c and is displayed by sand_box_2 -> on_activate_window_creation()\n");
// Jean 2024-01-20 Je désactive la visualisation de la fenêtre principale
// pour travailler dans une fenêtre minimale (cf. sand_box)
//
// gtk_window_present(window); < cf. application.c ligne 122
res = g_application_run(G_APPLICATION(app), argc, argv);
return res;

View File

@ -112,7 +112,14 @@ static void gem_graph_client_application_activate(GApplication *app)
ui_enable_action("togglesidebar");
ui_set_stack("run");
gtk_window_present(window);
// XXX
//
// v
//
// Jean 2024-01-20 Je désactive la visualisation de cette fenêtre
// pour travailler dans une fenêtre minimale (cf. sand_box)
//
// gtk_window_present(window);
}
/*

View File

@ -30,9 +30,9 @@
#include "../../include/ui.h"
static void on_button_action (GtkWidget *widget, gpointer data) {if (data) g_print (data);}
static void on_destroy (GtkWidget *widget, gpointer data) { exit(0);}
static void on_destroy (GtkWidget *widget, gpointer data) { if (data) g_print (data); exit(0);}
enum { NAME_COLUMN };
static enum { NAME_COLUMN };
/* custom function to fill the model with data */
static GtkWidget populate_tree_model (my_store){
@ -53,7 +53,7 @@ static GtkWidget populate_tree_model (my_store){
void on_activate_window_creation (GtkApplication *app) {
void on_activate_window_creation (GtkApplication *app, gpointer data) {
GtkWidget *my_window_2;
GtkWidget *my_box_2;
GtkWidget *my_button_2;
@ -63,6 +63,7 @@ void on_activate_window_creation (GtkApplication *app) {
// Create a new window
// GtkWidget *window = gtk_application_window_new (app);
// gtk_init();
if (data) g_print (data);
my_window_2 = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW(my_window_2), my_window_title_2);
gtk_window_set_default_size (GTK_WINDOW(my_window_2), 400, 34);
@ -70,66 +71,19 @@ void on_activate_window_creation (GtkApplication *app) {
gtk_window_set_child(GTK_WINDOW(my_window_2), GTK_WIDGET(my_box_2));
gtk_widget_show (my_window_2);
// Create a new button
my_button_2 = gtk_button_new_with_label (my_button_title_2);
// When the button is clicked, close the window passed as an argument
g_signal_connect(G_OBJECT (my_button_2), "clicked", G_CALLBACK(on_button_action), "some data from window 2\n");
g_signal_connect_swapped (my_button_2, "clicked", G_CALLBACK (gtk_window_close), my_window_2);
// gtk_window_set_child (GTK_WINDOW (my_window_2), my_button_2); // < écrase
gtk_box_append(GTK_BOX(my_box_2), GTK_WIDGET(my_button_2));
g_signal_connect(G_OBJECT (my_window_2), "destroy", G_CALLBACK(on_destroy), "window 2 destruction ! (alone <> no exit(0) here)\n");
// gtk_window_set_child (GTK_WINDOW (my_window_2), my_button_2); // < écrase
gtk_box_append(GTK_BOX
(my_box_2), GTK_WIDGET(my_button_2));
// gtk_window_present (GTK_WINDOW (my_window));
}
GtkWidget *hello_it_s_me()
{
GtkWidget *my_window;
GtkWidget *my_box;
GtkWidget *my_button;
char *my_window_title = "Hello, it's me !";
char *my_button_title = "Yep ! I'm the button.";
GtkListStore *my_store;
GtkTreeIter my_iter_1, my_iter_2;
GtkWidget *my_tree;
/* GtkCellRenderer *my_renderer; */
/* GtkTreeViewColumn *my_column; */
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 ();
g_signal_connect(G_OBJECT (my_window), "destroy", G_CALLBACK(on_destroy), NULL);
gtk_window_set_title (GTK_WINDOW(my_window), my_window_title);
gtk_window_set_default_size (GTK_WINDOW(my_window), 200, 34);
my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
my_button = gtk_button_new_with_label (my_button_title);
g_signal_connect(G_OBJECT (my_button), "clicked", G_CALLBACK(on_button_action), "some data from window 1\n");
gtk_box_append(GTK_BOX(my_box), GTK_WIDGET(my_button));
// gtk_widget_show (my_button); < inutile (appels récursifs)
gtk_window_set_child(GTK_WINDOW(my_window), GTK_WIDGET(my_box));
my_store = gtk_list_store_new (1, G_TYPE_STRING); // G_TYPE_CHAR);
// store = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_LONG); << GTK 3 ?
*my_tree = populate_tree_model (my_store);
/* my_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (my_store)); */
/* my_renderer = gtk_cell_renderer_text_new (); */
g_object_unref (G_OBJECT (my_store));
gtk_widget_show (my_window);
printf("Window ('%s') with button ('%s') -[see the sand box]-\n",
my_window_title, my_button_title);
return my_window;
}
//------------------------------------------------------------------------------
// guix shell -m manifest.scm make clean && clear && time make run
@ -159,20 +113,4 @@ GtkWidget *hello_it_s_me()
//
//
//
/* Ce qui suit est compilable 2024-01-18 */
/* GHashTable *my_hash_table; */
/* guint my_hash_table_size; */
/* my_hash_table = g_hash_table_new(NULL, NULL); */
/* my_hash_table = g_hash_table_ref (my_hash_table); */
/* // gpointer my_key = ; gboolean my_bool = g_hash_table_add (my_hash_table, mykey); */
/* my_hash_table_size = g_hash_table_size(my_hash_table); */
/* int main (int argc, char *argv[]) { */
/* // Create a new application */
/* GtkApplication *app = gtk_application_new ("com.example.GtkApplication", */
/* G_APPLICATION_FLAGS_NONE); */
/* g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL); */
/* return g_application_run (G_APPLICATION (app), argc, argv); */
/* } */