WIP: préparation chantier menu dans widget/rules/selected/wip_menu.c *widget_get_btt_conditions_list()

This commit is contained in:
Jean Sirmai 2024-09-08 22:34:50 +02:00
parent 17d2306bd7
commit 147cefce6d
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 112 additions and 62 deletions

View File

@ -197,6 +197,7 @@ void *widget_get_rule_analyse(); // analyse.c
void *widget_get_selected_rule_texts(); void *widget_get_selected_rule_texts();
void *widget_get_selected_rule_images(); void *widget_get_selected_rule_images();
void *widget_get_btt_conditions_list();
/******************************************************************************/ /******************************************************************************/

View File

@ -31,7 +31,7 @@
#include "../../../../include/widget.h" #include "../../../../include/widget.h"
#include "../../../../include/signal.h" #include "../../../../include/signal.h"
/*
static void *get_btt_conditions_list() static void *get_btt_conditions_list()
{ {
GtkWidget* list_box = gtk_list_box_new(); GtkWidget* list_box = gtk_list_box_new();
@ -56,6 +56,7 @@ static void *get_btt_conditions_list()
return conditions; return conditions;
} }
*/
static void *get_btt_assign_list() static void *get_btt_assign_list()
{ {
@ -108,7 +109,7 @@ static void *get_btt_rule_identity()
void *widget_get_selected_rule_texts() void *widget_get_selected_rule_texts()
{ {
GtkWidget *label_ad_hoc = GTK_WIDGET (gtk_label_new (\ GtkWidget *label_ad_hoc = GTK_WIDGET (gtk_label_new (\
" ")); " ")); // ad hoc (provisoire)
GtkBox *conditions_actions_names_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); GtkBox *conditions_actions_names_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
GtkLayoutManager *conditions_actions_identity_layout = gtk_box_layout_new (GTK_ORIENTATION_HORIZONTAL); GtkLayoutManager *conditions_actions_identity_layout = gtk_box_layout_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_layout_manager (GTK_WIDGET (conditions_actions_names_box), gtk_widget_set_layout_manager (GTK_WIDGET (conditions_actions_names_box),
@ -116,7 +117,7 @@ void *widget_get_selected_rule_texts()
gtk_box_layout_set_spacing (GTK_BOX_LAYOUT (conditions_actions_identity_layout), 180); gtk_box_layout_set_spacing (GTK_BOX_LAYOUT (conditions_actions_identity_layout), 180);
// allocate (GTK_LAYOUT_MANAGER (conditions_actions_identity_layout), get_btt_conditions_list (), 100, 20,100); TODO // allocate (GTK_LAYOUT_MANAGER (conditions_actions_identity_layout), get_btt_conditions_list (), 100, 20,100); TODO
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (label_ad_hoc)); gtk_box_append (conditions_actions_names_box, GTK_WIDGET (label_ad_hoc));
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_conditions_list ())); gtk_box_append (conditions_actions_names_box, GTK_WIDGET (widget_get_btt_conditions_list ()));
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_assign_list())); gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_assign_list()));
gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_rule_identity())); gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_rule_identity()));

View File

@ -0,0 +1,105 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Rules *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../../include/fsm.h"
#include "../../../../include/widget.h"
#include "../../../../include/signal.h"
void *widget_get_btt_conditions_list()
{
GtkWidget* list_box = gtk_list_box_new();
GtkWidget *label_A = GTK_WIDGET (gtk_label_new("if (value (0,0,1,3) == 2)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A);
GtkWidget *label_B = GTK_WIDGET (gtk_label_new("if (value (0,1,1,0) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B);
GtkWidget *label_C = GTK_WIDGET (gtk_label_new("if (value (0,1,1,2) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C);
GtkWidget *label_D = GTK_WIDGET (gtk_label_new("if (value (1,0,1,2) == 1)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_D);
GtkWidget *label_E = GTK_WIDGET (gtk_label_new("if (value (1,1,1,0) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_E);
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 *conditions = GTK_MENU_BUTTON (gtk_menu_button_new ());
gtk_menu_button_set_label (GTK_MENU_BUTTON (conditions), "conditions");
gtk_menu_button_set_always_show_arrow (conditions, TRUE);
gtk_menu_button_set_popover (conditions, GTK_WIDGET (pop));
// gtk_widget_set_halign (GTK_WIDGET (conditions), GTK_ALIGN_START);
return conditions;
}
/*
GSimpleActionGroup *ga = g_simple_action_group_new ();
GtkShortcutAction *aa = gtk_named_action_new ("aa");
gtk_widget_insert_action_group (btt_A, "aa", G_ACTION_GROUP (ga)); // GActionGroup* group
// GtkShortcutAction *act_aa = gtk_callback_action_new (callback_aa, NULL, NULL);
GSimpleAction *act_connect = g_simple_action_new("connect", NULL);
g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL);
GSimpleAction *act_a = g_simple_action_new ("do_a", NULL);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_a));
g_signal_connect (act_a, "activate", G_CALLBACK (action_a), app);
// GMenuItem *menu_item_do_a = g_menu_item_new ("do_a", "app.do_a");
// gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu);
// gtk_menu_item_activate (btt_C);
// g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect));
// GMenuItem *label_E = g_menu_item_new("connect", "app.do_a");
// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (menu_item_do_a));
/
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);
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);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
/
// 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))));
// g_signal_connect (btt_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data);
*/

View File

@ -92,8 +92,9 @@ void window_design_topbar_left (GtkWidget *header_bar)
/* the last one is the winner (and the winner takes it all !...) */ /* the last one is the winner (and the winner takes it all !...) */
/* THE LAST ONE IS THE WINNER (AND THE WINNER TAKES IT ALL !...) */ /* THE LAST ONE IS THE WINNER (AND THE WINNER TAKES IT ALL !...) */
/******************************************************************************/ /******************************************************************************/
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_synth()), TRUE); gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_rules()), TRUE);
if (YOU_WANT_TO_START_ON_ANOTHER_PAGE) { // select one if (YOU_WANT_TO_START_ON_ANOTHER_PAGE) { // select one
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_synth()), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_rules()), TRUE); gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_rules()), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_state()), TRUE); gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_state()), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_data()), TRUE); gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_data()), TRUE);

View File

@ -85,14 +85,6 @@ static void display_widgets_at_the_right_side (GtkWidget *header_bar)
// https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4 // https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4
static void callback_aa () {puts("callback_aa() > menu item A clicked.\n");} static void callback_aa () {puts("callback_aa() > menu item A clicked.\n");}
static void action_a (GSimpleAction *action, GVariant *parameter, gpointer app) {puts("menu item A clicked.\n");} static void action_a (GSimpleAction *action, GVariant *parameter, gpointer app) {puts("menu item A clicked.\n");}
static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); } static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); }
@ -107,39 +99,6 @@ void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app)
// GtkShortcutAction *act_aa = gtk_callback_action_new (callback_aa, NULL, NULL); // GtkShortcutAction *act_aa = gtk_callback_action_new (callback_aa, NULL, NULL);
GSimpleAction *act_connect = g_simple_action_new("connect", NULL); GSimpleAction *act_connect = g_simple_action_new("connect", NULL);
g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL); g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL);
@ -156,14 +115,6 @@ void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app)
// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (menu_item_do_a)); // gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (menu_item_do_a));
/* /*
https://docs.gtk.org/gtk4/class.ListView.html https://docs.gtk.org/gtk4/class.ListView.html
GtkStringList *model = gtk_string_list_new (NULL); // model = create_application_list (); GtkStringList *model = gtk_string_list_new (NULL); // model = create_application_list ();
@ -179,14 +130,6 @@ void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
*/ */
// ce qui suit ira dans le callback // ce qui suit ira dans le callback
GtkListBoxRow *selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box)); GtkListBoxRow *selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box));
if (selected_row != NULL) if (selected_row != NULL)
@ -194,7 +137,6 @@ void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app)
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 (btt_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); // g_signal_connect (btt_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data);
} }