quelquefois, la logique de la logique n'es pas logique...
This commit is contained in:
parent
de5106f0f6
commit
e4832aa623
42
hot.c
42
hot.c
|
@ -17,7 +17,7 @@ static struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;};
|
||||||
|
|
||||||
static struct TreeNode_t *create_user_tree_node (const gchar* text){
|
static struct TreeNode_t *create_user_tree_node (const gchar* text){
|
||||||
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
|
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
|
||||||
node->text = g_strdup(text);
|
node->text = g_strdup (text);
|
||||||
node->child = NULL; // if (0) printf("create_user_tree_node %s\n", text);
|
node->child = NULL; // if (0) printf("create_user_tree_node %s\n", text);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ static struct TreeNode_t *create_user_tree_node (const gchar* text){
|
||||||
void on_user_tree_expander_toggled(GtkExpander *expander, gpointer user_data)
|
void on_user_tree_expander_toggled(GtkExpander *expander, gpointer user_data)
|
||||||
{
|
{
|
||||||
// This is a conceptual callback for when an expander is toggled
|
// This is a conceptual callback for when an expander is toggled
|
||||||
GtkTreeListRow *row = GTK_TREE_LIST_ROW(user_data);
|
GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data);
|
||||||
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
||||||
gtk_tree_list_row_set_expanded(row, !is_expanded);
|
gtk_tree_list_row_set_expanded (row, !is_expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data){
|
static void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data){
|
||||||
|
@ -37,8 +37,8 @@ static void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObjec
|
||||||
const gchar *text = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row)));
|
const gchar *text = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row)));
|
||||||
GtkWidget *expander = gtk_list_item_get_child (list_item);
|
GtkWidget *expander = gtk_list_item_get_child (list_item);
|
||||||
gtk_expander_set_label (GTK_EXPANDER (expander), text);
|
gtk_expander_set_label (GTK_EXPANDER (expander), text);
|
||||||
g_signal_handlers_disconnect_by_func(expander, G_CALLBACK(on_user_tree_expander_toggled), row);
|
g_signal_handlers_disconnect_by_func(expander, G_CALLBACK (on_user_tree_expander_toggled), row);
|
||||||
g_signal_connect(expander, "activate", G_CALLBACK(on_user_tree_expander_toggled), row);
|
g_signal_connect(expander, "activate", G_CALLBACK (on_user_tree_expander_toggled), row);
|
||||||
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20);
|
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20);
|
||||||
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
||||||
if (0) printf("[on_bind_user_tree_factory] row content is [%s] and expander is [%d]\n", text, is_expanded);
|
if (0) printf("[on_bind_user_tree_factory] row content is [%s] and expander is [%d]\n", text, is_expanded);
|
||||||
|
@ -54,8 +54,7 @@ void on_setup_user_tree_factory (GtkSignalListItemFactory *factory,
|
||||||
|
|
||||||
static GListModel* get_user_tree_model_child (struct TreeNode_t *parent){
|
static GListModel* get_user_tree_model_child (struct TreeNode_t *parent){
|
||||||
GtkStringList *list = NULL;
|
GtkStringList *list = NULL;
|
||||||
assert (parent);
|
if (parent) {
|
||||||
// if (parent) {
|
|
||||||
if (0) printf("[get_user_tree_model_child] here is %s content : ", parent->text);
|
if (0) printf("[get_user_tree_model_child] here is %s content : ", parent->text);
|
||||||
struct TreeNode_t *child = parent->child;
|
struct TreeNode_t *child = parent->child;
|
||||||
if (child) {list = gtk_string_list_new(NULL);}
|
if (child) {list = gtk_string_list_new(NULL);}
|
||||||
|
@ -64,7 +63,7 @@ static GListModel* get_user_tree_model_child (struct TreeNode_t *parent){
|
||||||
if (0) printf("%s ", child->text);
|
if (0) printf("%s ", child->text);
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
// }
|
} else printf("hot.c GListModel* get_user_tree_model_child (struct TreeNode_t *parent) child = %d \n", parent);
|
||||||
if (0) printf("\n");
|
if (0) printf("\n");
|
||||||
return G_LIST_MODEL(list);
|
return G_LIST_MODEL(list);
|
||||||
}
|
}
|
||||||
|
@ -72,13 +71,14 @@ static GListModel* get_user_tree_model_child (struct TreeNode_t *parent){
|
||||||
GListModel* get_user_tree_model (GObject *item, gpointer root){
|
GListModel* get_user_tree_model (GObject *item, gpointer root){
|
||||||
struct TreeNode_t *cur = (struct TreeNode_t *)root;
|
struct TreeNode_t *cur = (struct TreeNode_t *)root;
|
||||||
struct TreeNode_t *parent = root;
|
struct TreeNode_t *parent = root;
|
||||||
const gchar *string = gtk_string_object_get_string (GTK_STRING_OBJECT(item));
|
const gchar *string = gtk_string_object_get_string (GTK_STRING_OBJECT (item));
|
||||||
while (cur) {
|
while (cur) {
|
||||||
if (strcmp(string, cur->text) == 0) break;
|
if (strcmp(string, cur->text) == 0) break;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
if (cur == NULL) {cur = parent->child; parent = cur;}
|
if (cur == NULL) {cur = parent->child; parent = cur;}
|
||||||
}
|
}
|
||||||
if (0) printf("[get_user_user_tree_model] looked for %s in %s item\n", cur->text, string);
|
if (0) printf("[get_user_user_tree_model] looked for %s in %s item\n", cur->text, string);
|
||||||
|
// ! WARNING ! TODO CUR EST L'ENFANT, MAINTENANT DONC, SI CUR EST UNE FEUILLE, JE N'ATTEINDRAI PAS SON ENFANT
|
||||||
return get_user_tree_model_child (cur);
|
return get_user_tree_model_child (cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,22 @@ GtkScrolledWindow *get_user_rules_tree (){
|
||||||
struct TreeNode_t *isole_1D = create_user_tree_node("isolated object move 1D"); add_child_node(isole, isole_1D);
|
struct TreeNode_t *isole_1D = create_user_tree_node("isolated object move 1D"); add_child_node(isole, isole_1D);
|
||||||
struct TreeNode_t *isole_2D = create_user_tree_node("isolated object move 2D"); add_child_node(isole, isole_2D);
|
struct TreeNode_t *isole_2D = create_user_tree_node("isolated object move 2D"); add_child_node(isole, isole_2D);
|
||||||
struct TreeNode_t *isole_3D = create_user_tree_node("isolated object move 3D"); add_child_node(isole, isole_3D);
|
struct TreeNode_t *isole_3D = create_user_tree_node("isolated object move 3D"); add_child_node(isole, isole_3D);
|
||||||
|
struct TreeNode_t *translat_2D = create_user_tree_node("translation"); add_child_node(isole_2D, translat_2D);
|
||||||
|
struct TreeNode_t *rotat_2D = create_user_tree_node("rotation"); add_child_node(isole_2D, rotat_2D);
|
||||||
|
struct TreeNode_t *rotat_X_2D = create_user_tree_node("rotation axe X"); add_child_node(rotat_2D, rotat_X_2D);
|
||||||
|
struct TreeNode_t *rotat_Y_2D = create_user_tree_node("rotation axe Y"); add_child_node(rotat_2D, rotat_Y_2D);
|
||||||
|
struct TreeNode_t *translat_3D = create_user_tree_node("translation"); add_child_node(isole_3D, translat_3D);
|
||||||
|
struct TreeNode_t *rotat_3D = create_user_tree_node("rotation"); add_child_node(isole_3D, rotat_3D);
|
||||||
|
struct TreeNode_t *rotat_X_3D = create_user_tree_node("rotation axe X"); add_child_node(rotat_3D, rotat_X_3D);
|
||||||
|
struct TreeNode_t *rotat_Y_3D = create_user_tree_node("rotation axe Y"); add_child_node(rotat_3D, rotat_Y_3D);
|
||||||
|
struct TreeNode_t *rotat_Z_3D = create_user_tree_node("rotation axe Z"); add_child_node(rotat_3D, rotat_Z_3D);
|
||||||
struct TreeNode_t *relie = create_user_tree_node("part of object"); add_child_node(move_random, relie);
|
struct TreeNode_t *relie = create_user_tree_node("part of object"); add_child_node(move_random, relie);
|
||||||
struct TreeNode_t *move_determ = create_user_tree_node("move determ"); add_child_node(tree_root, move_determ);
|
struct TreeNode_t *move_determ = create_user_tree_node("move determ"); add_child_node(tree_root, move_determ);
|
||||||
struct TreeNode_t *transport = create_user_tree_node("transport"); add_child_node(tree_root, transport);
|
struct TreeNode_t *transport = create_user_tree_node("transport"); add_child_node(tree_root, transport);
|
||||||
struct TreeNode_t *transform = create_user_tree_node("transform"); add_child_node(tree_root, transform);
|
struct TreeNode_t *transform = create_user_tree_node("transform"); add_child_node(tree_root, transform);
|
||||||
|
struct TreeNode_t *regulate = create_user_tree_node("regulate"); add_child_node(tree_root, regulate);
|
||||||
|
struct TreeNode_t *control = create_user_tree_node("negative feedback (control)"); add_child_node(regulate, control);
|
||||||
|
struct TreeNode_t *enhance = create_user_tree_node("positive feedback (enhance)"); add_child_node(regulate, enhance);
|
||||||
struct TreeNode_t *no_payload = create_user_tree_node("free"); add_child_node(transport, no_payload);
|
struct TreeNode_t *no_payload = create_user_tree_node("free"); add_child_node(transport, no_payload);
|
||||||
struct TreeNode_t *charged = create_user_tree_node("charged"); add_child_node(transport, charged);
|
struct TreeNode_t *charged = create_user_tree_node("charged"); add_child_node(transport, charged);
|
||||||
struct TreeNode_t *spontaneous = create_user_tree_node("spontaneous"); add_child_node(transform, spontaneous);
|
struct TreeNode_t *spontaneous = create_user_tree_node("spontaneous"); add_child_node(transform, spontaneous);
|
||||||
|
@ -115,7 +127,7 @@ GtkScrolledWindow *get_user_rules_tree (){
|
||||||
GtkTreeListModel *tree_model = gtk_tree_list_model_new(
|
GtkTreeListModel *tree_model = gtk_tree_list_model_new(
|
||||||
G_LIST_MODEL (model),
|
G_LIST_MODEL (model),
|
||||||
FALSE, // Passthrough - False in actual usage with dynamic children retrieval
|
FALSE, // Passthrough - False in actual usage with dynamic children retrieval
|
||||||
FALSE, // autoexpand
|
TRUE, // FALSE, // autoexpand
|
||||||
(GtkTreeListModelCreateModelFunc) &get_user_tree_model,
|
(GtkTreeListModelCreateModelFunc) &get_user_tree_model,
|
||||||
tree_root,
|
tree_root,
|
||||||
NULL // (GDestroyNotify) free_user_tree_node
|
NULL // (GDestroyNotify) free_user_tree_node
|
||||||
|
@ -126,10 +138,12 @@ GtkScrolledWindow *get_user_rules_tree (){
|
||||||
gtk_single_selection_set_can_unselect (selection_model, TRUE);
|
gtk_single_selection_set_can_unselect (selection_model, TRUE);
|
||||||
GtkWidget *list_view = gtk_list_view_new (GTK_SELECTION_MODEL (selection_model), GTK_LIST_ITEM_FACTORY (factory));
|
GtkWidget *list_view = gtk_list_view_new (GTK_SELECTION_MODEL (selection_model), GTK_LIST_ITEM_FACTORY (factory));
|
||||||
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new());
|
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new());
|
||||||
gtk_scrolled_window_set_child(scrolled_window, list_view);
|
// Allocation height too small. Tried to allocate 1922x1030, but GtkNotebook 0x25cd4c0 needs at least 1922x1064.
|
||||||
|
// even if I remove (comment) the next line :
|
||||||
|
gtk_scrolled_window_set_child (scrolled_window, list_view);
|
||||||
gtk_scrolled_window_set_policy (scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
gtk_scrolled_window_set_policy (scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
gtk_widget_set_vexpand(GTK_WIDGET(scrolled_window), TRUE);
|
gtk_widget_set_vexpand (GTK_WIDGET (scrolled_window), TRUE);
|
||||||
gtk_widget_set_visible(GTK_WIDGET(scrolled_window), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (scrolled_window), TRUE);
|
||||||
gtk_widget_set_visible(GTK_WIDGET(list_view), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (list_view), TRUE);
|
||||||
return scrolled_window;
|
return scrolled_window;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue