arbre bricolé, certes... mais il est là.
This commit is contained in:
parent
b80e2a7fb1
commit
41c8a9091f
1
(notes)
1
(notes)
|
@ -7,6 +7,7 @@ https://docs.gtk.org/gtk4/drag-and-drop.html drag-and-drop
|
||||||
https://docs.gtk.org/gtk4/class.GestureZoom.html GtkGestureZoom
|
https://docs.gtk.org/gtk4/class.GestureZoom.html GtkGestureZoom
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
|
GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
|
||||||
|
|
||||||
g_signal_connect (button, "clicked", G_CALLBACK (printf("%s\n", text)), text);
|
g_signal_connect (button, "clicked", G_CALLBACK (printf("%s\n", text)), text);
|
||||||
|
|
35
contain.c
35
contain.c
|
@ -92,6 +92,41 @@ GtkWidget *get_edit_space_page_new(){
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
GtkWidget *get_selected_rules_vpaned_new(){
|
||||||
|
GtkPaned *V_selected_1_vs_2 = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL));
|
||||||
|
|
||||||
|
// GtkWidget *règle_sélectionnée_n_1 = gtk_frame_new ("(1)");
|
||||||
|
// GtkWidget *règle_sélectionnée_n_2 = gtk_frame_new ("(2)");
|
||||||
|
|
||||||
|
GtkBox *up_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
||||||
|
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMATE()));
|
||||||
|
gtk_box_append (up_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
||||||
|
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMINE()));
|
||||||
|
/*
|
||||||
|
GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
||||||
|
gtk_box_append (bottom_box, GTK_WIDGET (get_image_PHENYLALANINE()));
|
||||||
|
gtk_box_append (bottom_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
||||||
|
gtk_box_append (bottom_box, GTK_WIDGET (get_image_DOPAMINE()));
|
||||||
|
*/
|
||||||
|
GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
||||||
|
gtk_box_append (bottom_box, GTK_WIDGET (get_image_ATP()));
|
||||||
|
gtk_box_append (bottom_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
||||||
|
gtk_box_append (bottom_box, GTK_WIDGET (get_image_AMP()));
|
||||||
|
|
||||||
|
gtk_paned_set_start_child (V_selected_1_vs_2, GTK_WIDGET (up_box));
|
||||||
|
gtk_paned_set_end_child (V_selected_1_vs_2, GTK_WIDGET (bottom_box));
|
||||||
|
|
||||||
|
// gtk_paned_set_start_child (V_selected_1_vs_2, GTK_WIDGET (règle_sélectionnée_n_1));
|
||||||
|
// gtk_paned_set_end_child (V_selected_1_vs_2, GTK_WIDGET (règle_sélectionnée_n_2));
|
||||||
|
|
||||||
|
// gtk_box_append ( GTK_BOX(règle_sélectionnée_n_1), GTK_WIDGET (up_box));//, GTK_WIDGET (get_image_GLUTAMATE()));
|
||||||
|
// gtk_box_append ( GTK_BOX(règle_sélectionnée_n_2), GTK_WIDGET (bottom_box));//, GTK_WIDGET (get_image_GLUTAMATE()));
|
||||||
|
|
||||||
|
return GTK_WIDGET (V_selected_1_vs_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget *get_run_space_top_box(){
|
GtkWidget *get_run_space_top_box(){
|
||||||
GtkBox *top_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
GtkBox *top_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
||||||
gtk_box_append (top_box, GTK_WIDGET (get_ELAPSED_TIME_ProgressBar()));
|
gtk_box_append (top_box, GTK_WIDGET (get_ELAPSED_TIME_ProgressBar()));
|
||||||
|
|
|
@ -224,3 +224,4 @@ GtkWidget *get_OBJECTS_and_SITUATIONS(){
|
||||||
return objects_and_situations_horizontal_pane;
|
return objects_and_situations_horizontal_pane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
268
hot.c
268
hot.c
|
@ -15,44 +15,256 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget *get_selected_rules_vpaned_new(){
|
// Simplified TreeNode structure for demonstration purposes
|
||||||
GtkPaned *V_selected_1_vs_2 = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL));
|
// --------------------------------------------------------
|
||||||
|
|
||||||
// GtkWidget *règle_sélectionnée_n_1 = gtk_frame_new ("(1)");
|
|
||||||
// GtkWidget *règle_sélectionnée_n_2 = gtk_frame_new ("(2)");
|
|
||||||
|
|
||||||
GtkBox *up_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
|
||||||
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMATE()));
|
|
||||||
gtk_box_append (up_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
|
||||||
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMINE()));
|
|
||||||
/*
|
/*
|
||||||
GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
* Tree-related signals
|
||||||
gtk_box_append (bottom_box, GTK_WIDGET (get_image_PHENYLALANINE()));
|
*/
|
||||||
gtk_box_append (bottom_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
|
||||||
gtk_box_append (bottom_box, GTK_WIDGET (get_image_DOPAMINE()));
|
|
||||||
*/
|
|
||||||
GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
|
||||||
gtk_box_append (bottom_box, GTK_WIDGET (get_image_ATP()));
|
|
||||||
gtk_box_append (bottom_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
|
||||||
gtk_box_append (bottom_box, GTK_WIDGET (get_image_AMP()));
|
|
||||||
|
|
||||||
gtk_paned_set_start_child (V_selected_1_vs_2, GTK_WIDGET (up_box));
|
void on_tree_expander_toggled(GtkExpander *expander, gpointer user_data)
|
||||||
gtk_paned_set_end_child (V_selected_1_vs_2, GTK_WIDGET (bottom_box));
|
{
|
||||||
|
// This is a conceptual callback for when an expander is toggled
|
||||||
|
GtkTreeListRow *row = GTK_TREE_LIST_ROW(user_data);
|
||||||
|
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
||||||
|
gtk_tree_list_row_set_expanded(row, !is_expanded);
|
||||||
|
}
|
||||||
|
|
||||||
// gtk_paned_set_start_child (V_selected_1_vs_2, GTK_WIDGET (règle_sélectionnée_n_1));
|
void on_tree_setup_factory (GtkSignalListItemFactory *factory,
|
||||||
// gtk_paned_set_end_child (V_selected_1_vs_2, GTK_WIDGET (règle_sélectionnée_n_2));
|
GObject* object,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget* expander = gtk_expander_new (NULL);
|
||||||
|
gtk_list_item_set_child (GTK_LIST_ITEM(object), expander);
|
||||||
|
printf("[on_tree_setup_factory] here is an expander\n");
|
||||||
|
}
|
||||||
|
|
||||||
// gtk_box_append ( GTK_BOX(règle_sélectionnée_n_1), GTK_WIDGET (up_box));//, GTK_WIDGET (get_image_GLUTAMATE()));
|
void on_tree_bind_factory (GtkSignalListItemFactory *factory,
|
||||||
// gtk_box_append ( GTK_BOX(règle_sélectionnée_n_2), GTK_WIDGET (bottom_box));//, GTK_WIDGET (get_image_GLUTAMATE()));
|
GObject* object,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GObject *item;
|
||||||
|
const gchar *text;
|
||||||
|
GtkTreeListRow *row;
|
||||||
|
GtkListItem *list_item;
|
||||||
|
GtkWidget *expander;
|
||||||
|
|
||||||
return GTK_WIDGET (V_selected_1_vs_2);
|
list_item= GTK_LIST_ITEM(object);
|
||||||
|
row = gtk_list_item_get_item(list_item);
|
||||||
|
if (row != NULL) {
|
||||||
|
text = gtk_string_object_get_string(GTK_STRING_OBJECT(gtk_tree_list_row_get_item(row)));
|
||||||
|
expander = gtk_list_item_get_child(list_item);
|
||||||
|
gtk_expander_set_label(GTK_EXPANDER(expander), text);
|
||||||
|
|
||||||
|
// Disconnect previous signal handlers to avoid stacking them
|
||||||
|
g_signal_handlers_disconnect_by_func(expander, G_CALLBACK(on_tree_expander_toggled), row);
|
||||||
|
|
||||||
|
// Connect the signal handler
|
||||||
|
g_signal_connect(expander, "activate", G_CALLBACK(on_tree_expander_toggled), row);
|
||||||
|
|
||||||
|
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20);
|
||||||
|
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
||||||
|
printf("[on_tree_bind_factory] here is %s content and expander is %d\n",
|
||||||
|
text,
|
||||||
|
is_expanded);
|
||||||
|
} else {
|
||||||
|
printf("[on_tree_bind_factory] here is NON content\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_tree_selection_changed (GtkSelectionModel* self, guint position,
|
||||||
|
guint n_items, gpointer user_data)
|
||||||
|
{
|
||||||
|
printf("[on_tree_selection_changed]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TreeNode_t
|
||||||
|
{
|
||||||
|
gchar *text;
|
||||||
|
struct TreeNode_t *child;
|
||||||
|
struct TreeNode_t *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function to create a new TreeNode instance
|
||||||
|
static struct TreeNode_t *create_tree_node (const gchar* text)
|
||||||
|
{
|
||||||
|
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
|
||||||
|
node->text = g_strdup(text);
|
||||||
|
node->child = NULL;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to add a child node to a parent node
|
||||||
|
static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child)
|
||||||
|
{
|
||||||
|
struct TreeNode_t *cur;
|
||||||
|
|
||||||
|
if (parent->child) {
|
||||||
|
cur = parent->child;
|
||||||
|
while (cur && cur->next) {
|
||||||
|
cur = cur->next;
|
||||||
|
}
|
||||||
|
cur->next = child;
|
||||||
|
} else {
|
||||||
|
parent->child = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursive function to free a TreeNode and its children
|
||||||
|
static void free_tree_node (struct TreeNode_t *node)
|
||||||
|
{
|
||||||
|
struct TreeNode_t *cur;
|
||||||
|
struct TreeNode_t *tmp;
|
||||||
|
|
||||||
|
if (!node) return;
|
||||||
|
|
||||||
|
// free siblings
|
||||||
|
cur = node;
|
||||||
|
while (cur) {
|
||||||
|
tmp = cur->next;
|
||||||
|
g_free(cur);
|
||||||
|
cur = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// recursive free
|
||||||
|
free_tree_node(node->child);
|
||||||
|
g_free(node->text);
|
||||||
|
g_free(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to simulate getting a GListModel of children for a given TreeNode
|
||||||
|
GListModel* ui_tree_get_children_model (struct TreeNode_t *parent)
|
||||||
|
{
|
||||||
|
struct TreeNode_t *child;
|
||||||
|
|
||||||
|
GtkStringList *list = NULL;
|
||||||
|
|
||||||
|
if (parent) {
|
||||||
|
printf("[ui_tree_get_children_model] here is %s content : ", parent->text);
|
||||||
|
|
||||||
|
child = parent->child;
|
||||||
|
|
||||||
|
if (child) {
|
||||||
|
list = gtk_string_list_new(NULL);
|
||||||
|
}
|
||||||
|
while(child) {
|
||||||
|
gtk_string_list_append(list, child->text);
|
||||||
|
printf("%s ", child->text);
|
||||||
|
child = child->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return G_LIST_MODEL(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GtkTreeListModelCreateModelFunc callback implementation
|
||||||
|
GListModel* ui_tree_create_model_func(GObject *item, gpointer root)
|
||||||
|
{
|
||||||
|
struct TreeNode_t *cur = (struct TreeNode_t *)root;
|
||||||
|
struct TreeNode_t *parent = NULL;
|
||||||
|
|
||||||
|
gchar *string = gtk_string_object_get_string(GTK_STRING_OBJECT(item));
|
||||||
|
|
||||||
|
parent = root;
|
||||||
|
while (cur) {
|
||||||
|
if (strcmp(string, cur->text) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cur = cur->next;
|
||||||
|
if (cur == NULL) {
|
||||||
|
cur = parent->child;
|
||||||
|
parent = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("[ui_tree_create_model_func] looked for %s in %s item\n",
|
||||||
|
cur->text,
|
||||||
|
string);
|
||||||
|
|
||||||
|
return ui_tree_get_children_model(cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Application activation callback
|
||||||
|
static void ui_create_tree (GtkWidget *target_widget)
|
||||||
|
{
|
||||||
|
GtkStringList *model;
|
||||||
|
GtkTreeListModel *tree_model;
|
||||||
|
GtkSignalListItemFactory *factory;
|
||||||
|
GtkSingleSelection *selection_model;
|
||||||
|
GtkWidget *list_view;
|
||||||
|
GtkScrolledWindow *scrolled_window;
|
||||||
|
|
||||||
|
assert(target_widget);
|
||||||
|
|
||||||
|
// AD HOC XXX & no free()
|
||||||
|
struct TreeNode_t *tree_root = create_tree_node("Root");
|
||||||
|
struct TreeNode_t *ATP = create_tree_node("ATP");
|
||||||
|
struct TreeNode_t *ADP = create_tree_node("ADP");
|
||||||
|
struct TreeNode_t *AMP = create_tree_node("AMP");
|
||||||
|
struct TreeNode_t *adenine = create_tree_node("adénine");
|
||||||
|
struct TreeNode_t *ribose = create_tree_node("ribose");
|
||||||
|
struct TreeNode_t *PO4H3_1 = create_tree_node("phosphate 1");
|
||||||
|
struct TreeNode_t *PO4H3_2 = create_tree_node("phosphate 2");
|
||||||
|
struct TreeNode_t *PO4H3_3 = create_tree_node("phosphate 3");
|
||||||
|
|
||||||
|
add_child_node(tree_root, ATP);
|
||||||
|
add_child_node(tree_root, ADP);
|
||||||
|
add_child_node(tree_root, AMP);
|
||||||
|
add_child_node(ATP, adenine);
|
||||||
|
add_child_node(adenine, ribose);
|
||||||
|
add_child_node(ribose, PO4H3_1);
|
||||||
|
add_child_node(PO4H3_1, PO4H3_2);
|
||||||
|
add_child_node(PO4H3_3, PO4H3_3);
|
||||||
|
|
||||||
|
model = gtk_string_list_new(NULL);
|
||||||
|
gtk_string_list_append(model, tree_root->text);
|
||||||
|
|
||||||
|
// Create and setup the list view and item factory
|
||||||
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
|
g_signal_connect (factory, "setup", G_CALLBACK(on_tree_setup_factory), NULL);
|
||||||
|
g_signal_connect (factory, "bind", G_CALLBACK(on_tree_bind_factory), NULL);
|
||||||
|
|
||||||
|
// Create a GtkTreeListModel
|
||||||
|
tree_model = gtk_tree_list_model_new(
|
||||||
|
G_LIST_MODEL(model),
|
||||||
|
FALSE, // Passthrough - False in actual usage with dynamic children retrieval
|
||||||
|
FALSE, // autoexpand
|
||||||
|
(GtkTreeListModelCreateModelFunc)ui_tree_create_model_func,
|
||||||
|
tree_root,
|
||||||
|
NULL //(GDestroyNotify)free_tree_node
|
||||||
|
);
|
||||||
|
|
||||||
|
selection_model = gtk_single_selection_new (
|
||||||
|
G_LIST_MODEL (tree_model));
|
||||||
|
|
||||||
|
gtk_single_selection_set_autoselect (selection_model, FALSE);
|
||||||
|
gtk_single_selection_set_can_unselect (selection_model, TRUE);
|
||||||
|
/* g_signal_connect (selection_model, "selection-changed", */
|
||||||
|
/* G_CALLBACK(on_tree_selection_changed), NULL); */
|
||||||
|
|
||||||
|
list_view = gtk_list_view_new (selection_model, factory);
|
||||||
|
|
||||||
|
scrolled_window = gtk_scrolled_window_new();
|
||||||
|
gtk_scrolled_window_set_child(scrolled_window, list_view);
|
||||||
|
|
||||||
|
gtk_scrolled_window_set_policy (scrolled_window,
|
||||||
|
GTK_POLICY_AUTOMATIC,
|
||||||
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
gtk_widget_set_vexpand(GTK_WIDGET(scrolled_window), TRUE);
|
||||||
|
|
||||||
|
gtk_box_append(GTK_BOX(target_widget), GTK_WIDGET(scrolled_window));
|
||||||
|
gtk_widget_show(GTK_WIDGET(scrolled_window));
|
||||||
|
gtk_widget_show(GTK_WIDGET(list_view));
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkBox *get_rules_user_tree_new(){
|
GtkBox *get_rules_user_tree_new(){
|
||||||
GtkBox *tree_sketch = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
|
GtkBox *tree_sketch = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
|
||||||
gtk_box_append (tree_sketch, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
// gtk_box_append (tree_sketch, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
||||||
gtk_box_append (tree_sketch, GTK_WIDGET (get_user_tree()));
|
// gtk_box_append (tree_sketch, GTK_WIDGET (get_user_tree()));
|
||||||
gtk_box_append (tree_sketch, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
// gtk_box_append (tree_sketch, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
||||||
|
ui_create_tree(tree_sketch);
|
||||||
return tree_sketch;
|
return tree_sketch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in New Issue