diff --git a/include/widget.h b/include/widget.h index 7324a5e..0dbb6f8 100644 --- a/include/widget.h +++ b/include/widget.h @@ -87,7 +87,7 @@ int widget_get_object_transparency (int i); // top // called in : src/widget/rules/distrib.c void *widget_get_selected_rule(); -void *widget_get_rules_tree(); +void *widget_get_rules_tree_and_pilot_box(); void *widget_get_rules_page(); void *widget_get_rule_edit_controls(); void *widget_get_rule_explore_controls(); diff --git a/src/main.c b/src/main.c index 2c46181..480917a 100644 --- a/src/main.c +++ b/src/main.c @@ -157,3 +157,10 @@ int main (int argc, char **argv) // GTK itself does not support event sounds, << A GREAT WAY TO DEBUG ! TODO // you have to use a loadable module like the one that comes with libcanberra. + + +// Property GtkSettings:gtk-error-bell + +// property gtk-error-bell: gboolean [ read, write ] +// When TRUE, keyboard navigation and other input-related errors will cause a beep. + diff --git a/src/widget/labo.c b/src/widget/labo.c index d95bfe0..2bd3242 100644 --- a/src/widget/labo.c +++ b/src/widget/labo.c @@ -73,39 +73,48 @@ void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) { - struct TreeNode_t *a = widget_create_user_tree_node("We, the people");widget_add_child_node(tree_root, a); - struct TreeNode_t *b = widget_create_user_tree_node("in Order to"); widget_add_child_node(tree_root, b); - struct TreeNode_t *c = widget_create_user_tree_node("do establish"); widget_add_child_node(tree_root, c); - struct TreeNode_t *aa = widget_create_user_tree_node("aware of"); widget_add_child_node(a, aa); - struct TreeNode_t *aaa = widget_create_user_tree_node("our rights"); widget_add_child_node(aa, aaa); - struct TreeNode_t *aab = widget_create_user_tree_node("our duties"); widget_add_child_node(aa, aab); - struct TreeNode_t *aaa0 = widget_create_user_tree_node("speak"); widget_add_child_node(aaa, aaa0); - struct TreeNode_t *aaaa = widget_create_user_tree_node("read"); widget_add_child_node(aaa, aaaa); - struct TreeNode_t *aaab = widget_create_user_tree_node("write"); widget_add_child_node(aaa, aaab); - struct TreeNode_t *aaaf = widget_create_user_tree_node("imagine"); widget_add_child_node(aaa, aaaf); - struct TreeNode_t *aaae = widget_create_user_tree_node("share"); widget_add_child_node(aaa, aaae); - struct TreeNode_t *aaac = widget_create_user_tree_node("copy"); widget_add_child_node(aaa, aaac); - struct TreeNode_t *aaad = widget_create_user_tree_node("edit"); widget_add_child_node(aaa, aaad); - struct TreeNode_t *aaaba= widget_create_user_tree_node("code"); widget_add_child_node(aaab, aaaba); - struct TreeNode_t *aaabb= widget_create_user_tree_node("language"); widget_add_child_node(aaab, aaabb); - struct TreeNode_t *aaabc= widget_create_user_tree_node("any art"); widget_add_child_node(aaab, aaabc); - struct TreeNode_t *aaadb= widget_create_user_tree_node("publish"); widget_add_child_node(aaac, aaadb); - struct TreeNode_t *aaada= widget_create_user_tree_node("create"); widget_add_child_node(aaad, aaada); - struct TreeNode_t *aaba = widget_create_user_tree_node("learn"); widget_add_child_node(aab, aaba); - struct TreeNode_t *aabb = widget_create_user_tree_node("help"); widget_add_child_node(aab, aabb); - struct TreeNode_t *ba = widget_create_user_tree_node("promote"); widget_add_child_node(b, ba); - struct TreeNode_t *bb = widget_create_user_tree_node("individual"); widget_add_child_node(b, bb); - struct TreeNode_t *bc = widget_create_user_tree_node("and common"); widget_add_child_node(b, bc); - struct TreeNode_t *bd = widget_create_user_tree_node("well-being"); widget_add_child_node(b, bd); - struct TreeNode_t *bca = widget_create_user_tree_node("education"); widget_add_child_node(bc, bca); - struct TreeNode_t *bcb = widget_create_user_tree_node("mutual"); widget_add_child_node(bc, bcb); - struct TreeNode_t *bcc = widget_create_user_tree_node("support"); widget_add_child_node(bc, bcc); - struct TreeNode_t *bcd = widget_create_user_tree_node("health"); widget_add_child_node(bc, bcd); - struct TreeNode_t *bcda = widget_create_user_tree_node("mental"); widget_add_child_node(bcd, bcda); - struct TreeNode_t *bcdb = widget_create_user_tree_node("physical"); widget_add_child_node(bcd, bcdb); - struct TreeNode_t *ca = widget_create_user_tree_node("free"); widget_add_child_node(c, ca); - struct TreeNode_t *cb = widget_create_user_tree_node("code"); widget_add_child_node(c, cb); - struct TreeNode_t *cc = widget_create_user_tree_node("access"); widget_add_child_node(c, cc); + struct TreeNode_t *a = widget_create_user_tree_node("aware of"); widget_add_child_node(tree_root, a); + struct TreeNode_t *b = widget_create_user_tree_node("eager to"); widget_add_child_node(tree_root, b); + struct TreeNode_t *c = widget_create_user_tree_node("decide"); widget_add_child_node(tree_root, c); + struct TreeNode_t *aaa = widget_create_user_tree_node("our rights"); widget_add_child_node(a, aaa); + struct TreeNode_t *aab = widget_create_user_tree_node("our duties"); widget_add_child_node(a, aab); + + struct TreeNode_t *aaa0 = widget_create_user_tree_node("speak"); widget_add_child_node(aaa, aaa0); + struct TreeNode_t *aaa1 = widget_create_user_tree_node("question"); widget_add_child_node(aaa, aaa1); + struct TreeNode_t *aaaa = widget_create_user_tree_node("read"); widget_add_child_node(aaa, aaaa); + struct TreeNode_t *aaab = widget_create_user_tree_node("write"); widget_add_child_node(aaa, aaab); + struct TreeNode_t *aaac = widget_create_user_tree_node("compute"); widget_add_child_node(aaa, aaac); + struct TreeNode_t *aaad = widget_create_user_tree_node("code"); widget_add_child_node(aaa, aaad); + struct TreeNode_t *aaae = widget_create_user_tree_node("interact"); widget_add_child_node(aaa, aaae); + + struct TreeNode_t *aaaco = widget_create_user_tree_node("copy"); widget_add_child_node(aaaa, aaaco); + + struct TreeNode_t *aaadx = widget_create_user_tree_node("edit"); widget_add_child_node(aaae, aaadx); + struct TreeNode_t *aaadb = widget_create_user_tree_node("publish"); widget_add_child_node(aaae, aaadb); +// struct TreeNode_t *aaada = widget_create_user_tree_node("manifest"); widget_add_child_node(aaad, aaada); + + struct TreeNode_t *aaba = widget_create_user_tree_node("learn"); widget_add_child_node(aab, aaba); + + struct TreeNode_t *aabl = widget_create_user_tree_node("access"); widget_add_child_node(aaac, aabl); + struct TreeNode_t *aabm = widget_create_user_tree_node("free"); widget_add_child_node(aaac, aabm); + struct TreeNode_t *aabn = widget_create_user_tree_node("tools"); widget_add_child_node(aaac, aabn); + + struct TreeNode_t *aabb = widget_create_user_tree_node("share"); widget_add_child_node(aab, aabb); + struct TreeNode_t *aabc = widget_create_user_tree_node("help"); widget_add_child_node(aab, aabc); + + struct TreeNode_t *ba = widget_create_user_tree_node("promote"); widget_add_child_node(b, ba); + struct TreeNode_t *bb = widget_create_user_tree_node("individual"); widget_add_child_node(b, bb); + struct TreeNode_t *bc = widget_create_user_tree_node("and common"); widget_add_child_node(b, bc); + struct TreeNode_t *bd = widget_create_user_tree_node("well-being"); widget_add_child_node(b, bd); + struct TreeNode_t *bca = widget_create_user_tree_node("education"); widget_add_child_node(bc, bca); + struct TreeNode_t *bcb = widget_create_user_tree_node("mutual"); widget_add_child_node(bc, bcb); + struct TreeNode_t *bcc = widget_create_user_tree_node("support"); widget_add_child_node(bc, bcc); + struct TreeNode_t *bcd = widget_create_user_tree_node("health"); widget_add_child_node(bc, bcd); + struct TreeNode_t *bcda = widget_create_user_tree_node("mental"); widget_add_child_node(bcd, bcda); + struct TreeNode_t *bcdb = widget_create_user_tree_node("physical"); widget_add_child_node(bcd, bcdb); + struct TreeNode_t *ca = widget_create_user_tree_node("free"); widget_add_child_node(c, ca); + struct TreeNode_t *cb = widget_create_user_tree_node("code"); widget_add_child_node(c, cb); + struct TreeNode_t *cc = widget_create_user_tree_node("access"); widget_add_child_node(c, cc); } #define W_IMAGE_ABSURD 1920 / 32 // 1920 x 960 ad hoc (pour mon écran) @@ -209,6 +218,14 @@ GtkBox *get_an_impression_of_what_a_rules_comparator_could_be(){ gtk_box_append (comparator, GTK_WIDGET (compare_left)); gtk_box_append (comparator, GTK_WIDGET (compare_right)); +/* + GtkScrolledWindow *comparator = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new ()); + GtkBox *inside = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); + gtk_box_append (inside, GTK_WIDGET (compare_left)); + gtk_box_append (inside, GTK_WIDGET (compare_right)); + gtk_scrolled_window_set_child (comparator, GTK_WIDGET (inside)); +*/ + return comparator; } diff --git a/src/widget/rules/distrib.c b/src/widget/rules/distrib.c index b447d61..1649a40 100644 --- a/src/widget/rules/distrib.c +++ b/src/widget/rules/distrib.c @@ -63,7 +63,7 @@ static void *widget_rule_itself_vs_explore_edit_pane() void *widget_get_rules_page() { GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); - gtk_paned_set_start_child (H_tree_vs_selected, GTK_WIDGET (widget_get_rules_tree())); + gtk_paned_set_start_child (H_tree_vs_selected, GTK_WIDGET (widget_get_rules_tree_and_pilot_box())); gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (widget_rule_itself_vs_explore_edit_pane())); gtk_paned_set_position (H_tree_vs_selected, 340); // WARNING : c'est une position "absolue" gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE); diff --git a/src/widget/rules/user_tree.c b/src/widget/rules/user_tree.c index 9a8b659..5bf8b51 100644 --- a/src/widget/rules/user_tree.c +++ b/src/widget/rules/user_tree.c @@ -32,7 +32,8 @@ #include "../../../include/signal.h" -void *widget_get_rules_tree (){ +static void *widget_get_rules_tree () +{ GtkPaned *H_tree_vs_comparison = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); // GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre"); @@ -41,7 +42,7 @@ void *widget_get_rules_tree (){ gtk_paned_set_start_child (H_tree_vs_comparison, GTK_WIDGET (widget_get_user_rules_tree())); gtk_paned_set_end_child (H_tree_vs_comparison, GTK_WIDGET (get_an_impression_of_what_a_rules_comparator_could_be())); - gtk_paned_set_position (H_tree_vs_comparison, 300); + gtk_paned_set_position (H_tree_vs_comparison, 200); gtk_paned_set_wide_handle (H_tree_vs_comparison, TRUE); gtk_widget_set_size_request (GTK_WIDGET (H_tree_vs_comparison), W_IMAGE_LOCAL, H_IMAGE_LOCAL); gtk_paned_set_shrink_start_child (H_tree_vs_comparison, FALSE); @@ -50,3 +51,19 @@ void *widget_get_rules_tree (){ return GTK_WIDGET (H_tree_vs_comparison); } +static void *widget_get_rules_pilot_box () +{ + GtkBox *rules_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (rules_pilot_box, + GTK_WIDGET (gtk_label_new ("\n - - - - - - - (some widgets here) - - - - - - - \n"))); + return rules_pilot_box; +} + +void *widget_get_rules_tree_and_pilot_box () +{ + GtkBox *rules_tree_and_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_pilot_box ())); + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_tree ())); + return rules_tree_and_pilot_box; +} diff --git a/src/widget/topbar.c b/src/widget/topbar.c index af56019..0a5f3f5 100644 --- a/src/widget/topbar.c +++ b/src/widget/topbar.c @@ -185,17 +185,18 @@ static void connect(GApplication *app, gpointer *data) { puts("Connect menu item static void window_header_bar_right (GtkWidget *header_bar) { - gpointer no_local_data = NULL; + gpointer no_local_data = NULL; - GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ()); - gtk_button_set_icon_name (btt_go_home, "go-home-symbolic"); - g_signal_connect (btt_go_home, "clicked", G_CALLBACK (on_clicked_home), no_local_data); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_go_home)); + GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (btt_go_home, "go-home-symbolic"); +// gtk_widget_error_bell (GTK_WIDGET (btt_go_home)); << TODO si c'est possible ? + g_signal_connect (btt_go_home, "clicked", G_CALLBACK (on_clicked_home), no_local_data); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_go_home)); - GtkButton *search = GTK_BUTTON (gtk_button_new ()); - gtk_button_set_icon_name (search, "folder-saved-search-symbolic"); - g_signal_connect (search, "clicked", G_CALLBACK (on_clicked_search), no_local_data); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search)); + GtkButton *search = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (search, "folder-saved-search-symbolic"); + g_signal_connect (search, "clicked", G_CALLBACK (on_clicked_search), no_local_data); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search)); @@ -205,37 +206,37 @@ static void window_header_bar_right (GtkWidget *header_bar) -// https://discourse.gnome.org/t/when-do-we-really-have-to-use-gtk-popover-present-to-show-a-popover-at-a-given-widget/17566/5 -// https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4 + // https://discourse.gnome.org/t/when-do-we-really-have-to-use-gtk-popover-present-to-show-a-popover-at-a-given-widget/17566/5 + // https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4 - GtkWidget* list_box = gtk_list_box_new(); - GtkWidget *label_A = GTK_WIDGET (gtk_label_new("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A); - GtkWidget *label_B = GTK_WIDGET (gtk_label_new("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B); - GtkWidget *label_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C); + GtkWidget* list_box = gtk_list_box_new(); + GtkWidget *label_A = GTK_WIDGET (gtk_label_new("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A); + GtkWidget *label_B = GTK_WIDGET (gtk_label_new("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B); + GtkWidget *label_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C); - GtkWidget *pop = gtk_popover_new (); - gtk_popover_set_child (GTK_POPOVER (pop), list_box); - gtk_popover_present (GTK_POPOVER (pop)); - gtk_popover_set_autohide (GTK_POPOVER (pop), FALSE); - gtk_popover_set_cascade_popdown (GTK_POPOVER (pop), TRUE); + GtkWidget *pop = gtk_popover_new (); + gtk_popover_set_child (GTK_POPOVER (pop), list_box); + gtk_popover_present (GTK_POPOVER (pop)); + gtk_popover_set_autohide (GTK_POPOVER (pop), FALSE); + gtk_popover_set_cascade_popdown (GTK_POPOVER (pop), TRUE); - GtkMenuButton *open_menu = GTK_MENU_BUTTON (gtk_menu_button_new ()); - gtk_menu_button_set_icon_name (open_menu, "open-menu-symbolic"); - gtk_menu_button_set_always_show_arrow (open_menu, TRUE); - gtk_menu_button_set_popover (open_menu, GTK_WIDGET (pop)); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu)); + GtkMenuButton *open_menu = GTK_MENU_BUTTON (gtk_menu_button_new ()); + gtk_menu_button_set_icon_name (open_menu, "open-menu-symbolic"); + gtk_menu_button_set_always_show_arrow (open_menu, TRUE); + gtk_menu_button_set_popover (open_menu, GTK_WIDGET (pop)); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu)); GSimpleAction *act_connect = g_simple_action_new("connect", NULL); g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL); -// gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu); -// gtk_menu_item_activate (label_C); -// g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect)); -// GMenuItem *label_E = g_menu_item_new("connect", "app.connect"); -// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (label_E)); + // gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu); + // gtk_menu_item_activate (label_C); + // g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect)); + // GMenuItem *label_E = g_menu_item_new("connect", "app.connect"); + // gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (label_E)); @@ -246,20 +247,20 @@ static void window_header_bar_right (GtkWidget *header_bar) -/* - https://docs.gtk.org/gtk4/class.ListView.html - GtkStringList *model = gtk_string_list_new (NULL); // model = create_application_list (); + /* + https://docs.gtk.org/gtk4/class.ListView.html + GtkStringList *model = gtk_string_list_new (NULL); // model = create_application_list (); - GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new()); - g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL); - g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL); + GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new()); + g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL); + g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL); - GtkStringList *list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory); + GtkStringList *list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory); - g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL); + g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list); -*/ + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list); + */ @@ -269,13 +270,13 @@ static void window_header_bar_right (GtkWidget *header_bar) - // ce qui suit ira dans le callback - GtkListBoxRow *selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box)); - if (selected_row != NULL) + // ce qui suit ira dans le callback + GtkListBoxRow *selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box)); + if (selected_row != NULL) printf("selected_row = %s\n", - gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (selected_row)))); + gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (selected_row)))); -// g_signal_connect (label_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); + // g_signal_connect (label_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); } diff --git a/src/widget/tree.c b/src/widget/tree.c index 8035e94..0250a2c 100644 --- a/src/widget/tree.c +++ b/src/widget/tree.c @@ -85,7 +85,7 @@ static GListModel *get_user_tree_model (GObject *item, gpointer root) void *widget_get_user_rules_tree () { - struct TreeNode_t *tree_root = widget_create_user_tree_node("root"); + struct TreeNode_t *tree_root = widget_create_user_tree_node("We, the people,"); widget_let_us_create_a_complex_useless_and_expensive_tree (tree_root); GtkStringList *model = gtk_string_list_new(NULL);