WIP: using gtk_application_window_new() - in sand_box.c
This commit is contained in:
parent
c22187af45
commit
6039ebacd9
|
@ -58,6 +58,10 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
g_log_set_debug_enabled (TRUE);
|
||||
GtkDebugFlags my_flags = 1;
|
||||
gtk_set_debug_flags (my_flags);
|
||||
|
||||
g_autoptr(GemGraphClientApplication) app = NULL;
|
||||
int res;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ static void gem_graph_client_application_activate(GApplication *app)
|
|||
// 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);
|
||||
gtk_window_present(window);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,11 +28,28 @@
|
|||
#include "../../include/base.h"
|
||||
#include "../../include/ui.h"
|
||||
|
||||
static void just_use_gtk_application_window_new()
|
||||
{
|
||||
GtkApplication *app = gtk_application_new ("org.gtk.test", 0);
|
||||
GtkWidget *that_window = gtk_application_window_new (app);
|
||||
char *that_window_title = "Gloups ! Who am I ?";
|
||||
gtk_window_set_title (GTK_WINDOW(that_window), that_window_title);
|
||||
gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300);
|
||||
gtk_widget_show (that_window);
|
||||
}
|
||||
|
||||
|
||||
int n = 0;
|
||||
static void on_button_action (GtkWidget *widget, gpointer data){n++; g_print (data, n);}
|
||||
static void on_destroy (GtkWidget *widget, gpointer data) {if (data) g_print (data); exit(0);}
|
||||
|
||||
void on_activate_window_creation (GtkApplication *app, gpointer data) {
|
||||
|
||||
just_use_gtk_application_window_new();
|
||||
|
||||
GtkDebugFlags my_debug_flags = gtk_get_debug_flags ();
|
||||
if (0) printf("my_debug_flags %d\n", my_debug_flags); // << null // gtk_init (); < usefulness ?
|
||||
|
||||
GtkWidget *my_window;
|
||||
GtkWidget *my_box;
|
||||
GtkWidget *my_button;
|
||||
|
@ -54,7 +71,7 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) {
|
|||
|
||||
gtk_box_append(GTK_BOX (my_box), GTK_WIDGET(my_button)); // else : gtk_window_set_child (GTK_WINDOW (my_window), my_button);
|
||||
|
||||
if (data) {g_print (data); g_print (" and is displayed by [on_activate_window_creation()] in the sand_box window.\n");}
|
||||
if (data) {g_print (data); g_print (" and is displayed by [sand_box.c > on_activate_window_creation()] NB #define G_DEBUG_HERE (void) added\n");}
|
||||
printf("-------------------------------------------------------------------------------------------------------------------------------------------\n\
|
||||
[sand_box.c > on_activate_window_creation()] > widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo <\n");
|
||||
}
|
||||
|
@ -86,7 +103,18 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) {
|
|||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
/*
|
||||
https://gnome.pages.gitlab.gnome.org/gtk/gtk4/
|
||||
|
||||
Gtk – 4.0
|
||||
|
||||
Build Dependencies Related libraries Additional documentation
|
||||
Classes Interfaces Structs Aliases
|
||||
Enumerations Bitfields Error Domains Callbacks
|
||||
Functions Function Macros Constants
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "../../include/base.h"
|
||||
#include "../../include/ui.h"
|
||||
|
||||
// #define G_DEBUG_HERE (void) < attention: « G_DEBUG_HERE » redéfini
|
||||
|
||||
enum
|
||||
{
|
||||
STRING_COLUMN,
|
||||
|
@ -59,8 +61,10 @@ static void
|
|||
add_item () //(GtkWidget *button, gpointer data)
|
||||
{
|
||||
TreeItem foo;
|
||||
GtkTreeView *treeview = my_tree_view; // (GtkTreeView *)data;
|
||||
GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview);
|
||||
GtkTreeView *treeview = my_tree_view; // (GtkTreeView *)data; attention:
|
||||
// initialisation de « GtkTreeView * » depuis le type pointeur « GtkWidget * » qui est incompatible
|
||||
GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview); attention:
|
||||
// initialisation de « GtkTreeModel * » depuis le type pointeur « GListStore * » qui est incompatible
|
||||
GtkTreePath *path;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeIter current, iter;
|
||||
|
@ -69,7 +73,9 @@ add_item () //(GtkWidget *button, gpointer data)
|
|||
//model = gtk_tree_view_get_model (treeview);
|
||||
if (path)
|
||||
{
|
||||
gtk_tree_model_get_iter (my_list_model, ¤t, path);
|
||||
gtk_tree_model_get_iter (my_list_model, ¤t, path); // attention:
|
||||
// passage de l'argument 1 de « gtk_tree_model_get_iter » depuis un type pointeur incompatible
|
||||
// « GtkTreeModel * » attendu mais l'argument est de type « GListStore *
|
||||
printf("In 'tree.c' (line 73) add_item() path = %s depth = %d\n",
|
||||
gtk_tree_path_to_string (path),
|
||||
gtk_tree_path_get_depth (path)
|
||||
|
@ -82,8 +88,10 @@ remove_item (GtkWidget *widget, gpointer data)
|
|||
{
|
||||
printf("In 'tree-deprec.c' (line 83) remove item() > no item selected (or can't get it ?)\n");
|
||||
|
||||
GtkTreeView *treeview = my_tree_view; // (GtkTreeView *)data;
|
||||
GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview);
|
||||
GtkTreeView *treeview = my_tree_view; // (GtkTreeView *)data; attention:
|
||||
// initialisation de « GtkTreeView * » depuis le type pointeur « GtkWidget * » qui est incompatible
|
||||
GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview); attention:
|
||||
// initialisation de « GtkTreeModel * » depuis le type pointeur « GListStore * » qui est incompatible
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
|
||||
GtkTreeIter iter;
|
||||
}
|
||||
|
@ -94,7 +102,8 @@ cell_edited (GtkCellRendererText *cell,
|
|||
const char *new_text,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview);
|
||||
GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview); attention:
|
||||
// initialisation de « GtkTreeModel * » depuis le type pointeur « GListStore * » qui est incompatible
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
|
||||
GtkTreeIter iter;
|
||||
}
|
||||
|
@ -110,11 +119,16 @@ static GListStore *create_node_recursive (GListStore *model,
|
|||
|
||||
// warning: assignment to 'GListStore *' from incompatible pointer type 'GtkTreeStore *'
|
||||
if (model == NULL)
|
||||
model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
|
||||
model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING); // attention:
|
||||
// affectation à « GListStore * » depuis le type pointeur « GtkTreeStore * » qui est incompatible
|
||||
|
||||
while (current_item->label) {
|
||||
gtk_tree_store_append (model, &iter, iter_parent);
|
||||
gtk_tree_store_set (model, &iter, STRING_COLUMN, current_item->label, -1);
|
||||
gtk_tree_store_append (model, &iter, iter_parent); // attention:
|
||||
// passage de l'argument 1 de « gtk_tree_store_append » depuis un type pointeur incompatible
|
||||
// « GtkTreeStore * » attendu mais l'argument est de type « GListStore * »
|
||||
gtk_tree_store_set (model, &iter, STRING_COLUMN, current_item->label, -1); // attention:
|
||||
// passage de l'argument 1 de « gtk_tree_store_set » depuis un type pointeur incompatible
|
||||
// « GtkTreeStore * » attendu mais l'argument est de type « GListStore * »
|
||||
|
||||
if (current_item->children)
|
||||
create_node_recursive (model, current_item->children, &iter, depth + 1);
|
||||
|
@ -125,7 +139,7 @@ static GListStore *create_node_recursive (GListStore *model,
|
|||
}
|
||||
|
||||
if (depth == 0)
|
||||
return G_LIST_STORE(model); // Should we cast 'model' to GtkTreeStore ?
|
||||
return G_LIST_STORE(model); // GLib-GObject-WARNING invalid cast from 'GtkTreeStore' to 'GListStore'
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
@ -136,7 +150,9 @@ GtkWidget *create_my_deprec_tree_model(GtkBox *runlib_objects)
|
|||
GtkCellRenderer *my_renderer = NULL;
|
||||
|
||||
my_list_model = create_node_recursive (my_list_model, O, NULL, 0);
|
||||
my_tree_view = gtk_tree_view_new_with_model (my_list_model);
|
||||
my_tree_view = gtk_tree_view_new_with_model (my_list_model); // attention:
|
||||
// passage de l'argument 1 de « gtk_tree_view_new_with_model » depuis un type pointeur incompatible
|
||||
// « GtkTreeModel * » attendu mais l'argument est de type « GListStore * »
|
||||
|
||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (my_tree_view), FALSE);
|
||||
gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (my_tree_view), TRUE);
|
||||
|
|
Loading…
Reference in New Issue