diff --git a/contain.o b/contain.o index ee58ac1..1c53542 100644 Binary files a/contain.o and b/contain.o differ diff --git a/display.c b/display.c index 72c8196..a68c42d 100644 --- a/display.c +++ b/display.c @@ -1,6 +1,7 @@ #include #include +#include "hot.h" #include "cold.h" #include "display.h" #include "contain.h" @@ -251,6 +252,23 @@ GtkBox *get_rules_comparator_new(){ return comparator; } +GtkBox *get_experimental_box_new(){ + GtkBox *experimental_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + gtk_widget_set_size_request (GTK_WIDGET (experimental_box), 0, 400); + gtk_box_append (experimental_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (experimental_box, GTK_WIDGET(gtk_label_new ("\n\n"))); + create_experimental_tree(experimental_box); + gtk_box_append (experimental_box, GTK_WIDGET(gtk_label_new ("\n\n"))); + return experimental_box; +} + +GtkBox *get_rules_user_tree_new(){ + GtkBox *tree_sketch_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + gtk_box_append (tree_sketch_box, GTK_WIDGET (get_experimental_box_new())); + ui_create_tree (GTK_WIDGET (tree_sketch_box)); + return tree_sketch_box; +} + GtkWidget *get_rules_tree_hpaned_new(){ GtkPaned *H_tree_vs_comparison = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); diff --git a/display.d b/display.d index b8614e1..8677eb2 100644 --- a/display.d +++ b/display.d @@ -1 +1,3 @@ -display.o: display.c cold.h display.h contain.h texts.h tree.h +display.o: display.c hot.h warm.h \ + /gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib.h \ + cold.h display.h contain.h texts.h tree.h diff --git a/display.h b/display.h index 6c33748..9367a1a 100644 --- a/display.h +++ b/display.h @@ -10,6 +10,7 @@ GtkWidget *get_text_view(); GtkFrame *get_frame_with_label(); GtkWidget *get_run_rules_page_new(); +GtkBox *get_rules_user_tree_new(); GtkWidget *get_image_ALL_SPACE(); GtkWidget *get_image_GLUTAMATE(); diff --git a/display.o b/display.o index 1be9540..0d06204 100644 Binary files a/display.o and b/display.o differ diff --git a/hot.c b/hot.c index 98626b3..c82db18 100644 --- a/hot.c +++ b/hot.c @@ -13,16 +13,28 @@ // GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL +static void on_experimental_tree_bind_factory (GtkSignalListItemFactory *factory, + GObject* object, + gpointer user_data); + static void on_experimental_expander_toggled(GtkExpander *expander, gpointer user_data){ gtk_expander_set_expanded (expander, gtk_expander_get_expanded (expander)); printf("> %s\n", gtk_expander_get_label (user_data)); } -GtkBox *get_experimental_box_new(){ - GtkBox *experimental_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); - gtk_widget_set_size_request (GTK_WIDGET (experimental_box), 0, 400); - gtk_box_append (experimental_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_box_append (experimental_box, GTK_WIDGET(gtk_label_new ("\n\n"))); +void on_experimental_tree_setup_factory (GtkSignalListItemFactory *factory, + GObject* object, + gpointer user_data) +{ + GtkWidget* expander = gtk_expander_new (NULL); + gtk_list_item_set_child (GTK_LIST_ITEM(object), expander); + printf("[on_experimental_tree_setup_factory] here is an expander\n"); +} + +void create_experimental_tree (GtkBox *experimental_box){ + GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new ()); + g_signal_connect (factory, "setup", G_CALLBACK(on_experimental_tree_setup_factory), NULL); + g_signal_connect (factory, "bind", G_CALLBACK(on_experimental_tree_bind_factory), NULL); GtkExpander *hello = GTK_EXPANDER (gtk_expander_new ("hello !")); gtk_expander_set_expanded (GTK_EXPANDER (hello), TRUE); @@ -35,8 +47,51 @@ GtkBox *get_experimental_box_new(){ gtk_widget_set_margin_start(GTK_WIDGET (it_s_me), 20); g_signal_connect (it_s_me, "activate", G_CALLBACK (on_experimental_expander_toggled), it_s_me); gtk_box_append (experimental_box, GTK_WIDGET (it_s_me)); - - gtk_box_append (experimental_box, GTK_WIDGET(gtk_label_new ("\n\n"))); - return experimental_box; } + + + + + + + + + + + + + + +static void on_experimental_tree_bind_factory (GtkSignalListItemFactory *factory, + GObject* object, + gpointer user_data) +{ +// GObject *item; + const gchar *text; + GtkTreeListRow *row; + GtkListItem *list_item; + GtkWidget *expander; + + 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 + // TODO g_signal_handlers_disconnect_by_func(expander, G_CALLBACK(on_tree_expander_toggled), row); + + // Connect the signal handler + // TODO 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_experimental_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"); + } +} diff --git a/hot.h b/hot.h index bf329bb..cedd578 100644 --- a/hot.h +++ b/hot.h @@ -12,5 +12,7 @@ #include "display.h" #include "contain.h" - -GtkBox *get_experimental_box_new(); +void on_experimental_tree_setup_factory (GtkSignalListItemFactory *factory, + GObject* object, + gpointer user_data); +void create_experimental_tree (GtkBox *experimental_box); diff --git a/hot.o b/hot.o index 6329303..e4657a6 100644 Binary files a/hot.o and b/hot.o differ diff --git a/myprogram b/myprogram index da729da..b25064d 100755 Binary files a/myprogram and b/myprogram differ diff --git a/tree.c b/tree.c index c60975e..634a731 100644 --- a/tree.c +++ b/tree.c @@ -188,7 +188,7 @@ GListModel* ui_tree_create_model_func(GObject *item, gpointer root) } // Application activation callback -static void ui_create_tree (GtkWidget *target_widget) +void ui_create_tree (GtkWidget *target_widget) { GtkStringList *model; GtkTreeListModel *tree_model; @@ -260,11 +260,3 @@ static void ui_create_tree (GtkWidget *target_widget) gtk_widget_set_visible(GTK_WIDGET(scrolled_window), TRUE); gtk_widget_set_visible(GTK_WIDGET(list_view), TRUE); } - -GtkBox *get_rules_user_tree_new(){ - GtkBox *tree_sketch_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); - gtk_box_append (tree_sketch_box, GTK_WIDGET (get_experimental_box_new())); - ui_create_tree (GTK_WIDGET (tree_sketch_box)); - return tree_sketch_box; -} - diff --git a/tree.h b/tree.h index 38dc1b8..9fe09e2 100644 --- a/tree.h +++ b/tree.h @@ -7,4 +7,4 @@ /* */ /******************************************************************************/ -GtkBox *get_rules_user_tree_new(); +void ui_create_tree (GtkWidget *target_widget); diff --git a/tree.o b/tree.o index c5934c5..67e6b4b 100644 Binary files a/tree.o and b/tree.o differ