2024-06-30 17:18:18 +02:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* *
|
2024-07-08 07:52:27 +02:00
|
|
|
* Gem-graph client *
|
2024-06-30 17:18:18 +02:00
|
|
|
* *
|
2024-07-08 07:52:27 +02:00
|
|
|
* Callbacks header *
|
2024-06-30 17:18:18 +02:00
|
|
|
* *
|
2024-07-08 07:52:27 +02:00
|
|
|
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
|
|
|
|
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
|
|
|
|
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
|
2024-06-30 17:18:18 +02:00
|
|
|
* *
|
|
|
|
* This file is part of Gem-graph. *
|
|
|
|
* *
|
2024-07-08 07:52:27 +02:00
|
|
|
* 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. *
|
2024-06-30 17:18:18 +02:00
|
|
|
* *
|
2024-07-08 07:52:27 +02:00
|
|
|
* 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. *
|
2024-06-30 17:18:18 +02:00
|
|
|
* *
|
2024-07-08 07:52:27 +02:00
|
|
|
* 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/>. *
|
2024-06-30 17:18:18 +02:00
|
|
|
* *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
2024-07-08 07:52:27 +02:00
|
|
|
|
2024-07-18 22:06:24 +02:00
|
|
|
#include "../include/fsm.h"
|
|
|
|
#include "../include/signal.h"
|
|
|
|
#include "../include/widget.h"
|
|
|
|
#include "../include/graphics.h"
|
2024-04-22 18:40:30 +02:00
|
|
|
|
2024-06-30 11:53:03 +02:00
|
|
|
|
2024-07-06 08:27:05 +02:00
|
|
|
static void on_auto_notification (const char *message)
|
|
|
|
{
|
|
|
|
/* Ignored (2024-06-06) because I don't know how to get "main_window" easily
|
|
|
|
|
|
|
|
if (window->toast_revealer == NULL) {
|
|
|
|
g_printerr("Can't find app->toast_overlay !\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->toast_text == NULL) {
|
|
|
|
g_printerr("Can't find app->toast_overlay !\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_label_set_label(window->toast_text, message);
|
|
|
|
gtk_revealer_set_reveal_child(window->toast_revealer, true);
|
|
|
|
*/
|
|
|
|
g_printerr("%s\n", message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-08 07:52:27 +02:00
|
|
|
void on_windows_activation (GtkApplication *app,
|
2024-07-13 07:48:46 +02:00
|
|
|
gpointer no_user_data)
|
2024-04-22 18:40:30 +02:00
|
|
|
{
|
2024-07-20 16:38:31 +02:00
|
|
|
widget_create_main_window (app);
|
|
|
|
widget_topbar_design_main_window (GTK_WINDOW (widget_topbar_get_main_window ()));
|
2024-04-22 18:40:30 +02:00
|
|
|
|
2024-07-20 16:38:31 +02:00
|
|
|
widget_create_dialog_window (app);
|
|
|
|
widget_topbar_design_dialog_window (GTK_WINDOW (widget_topbar_get_main_window ()),
|
|
|
|
GTK_WINDOW (widget_topbar_get_dialog_window()));
|
2024-04-22 18:40:30 +02:00
|
|
|
|
2024-07-20 16:38:31 +02:00
|
|
|
widget_create_text_window (app);
|
|
|
|
widget_topbar_design_text_window (GTK_WINDOW (widget_topbar_get_main_window ()),
|
|
|
|
GTK_WINDOW (widget_topbar_get_text_window()));
|
2024-07-04 22:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-22 18:40:30 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
/* T R E E */
|
|
|
|
/******************************************************************************/
|
2024-06-30 11:53:03 +02:00
|
|
|
|
2024-07-08 09:13:11 +02:00
|
|
|
static void on_user_tree_expander_toggled (GtkExpander *expander,
|
2024-06-30 11:53:03 +02:00
|
|
|
gpointer user_data)
|
2024-04-22 18:40:30 +02:00
|
|
|
{
|
|
|
|
GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data);
|
2024-06-30 11:53:03 +02:00
|
|
|
gboolean is_expanded = gtk_tree_list_row_get_expanded (row);
|
|
|
|
gtk_tree_list_row_set_expanded (row,
|
2024-07-08 07:52:27 +02:00
|
|
|
! is_expanded);
|
2024-04-22 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
2024-06-30 11:53:03 +02:00
|
|
|
|
|
|
|
void on_bind_user_tree_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object,
|
|
|
|
gpointer user_data)
|
2024-04-22 18:40:30 +02:00
|
|
|
{
|
2024-06-30 11:53:03 +02:00
|
|
|
GtkListItem *list_item = GTK_LIST_ITEM (object);
|
|
|
|
assert (list_item);
|
|
|
|
|
|
|
|
GtkTreeListRow *row = gtk_list_item_get_item (list_item);
|
2024-07-08 07:52:27 +02:00
|
|
|
assert (row); // if (row != NULL) {...} do something ? TODO Check !
|
2024-06-30 11:53:03 +02:00
|
|
|
|
|
|
|
const gchar *text = gtk_string_object_get_string (
|
|
|
|
GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row)));
|
2024-04-22 18:40:30 +02:00
|
|
|
GtkWidget *expander = gtk_list_item_get_child (list_item);
|
|
|
|
gtk_expander_set_label (GTK_EXPANDER (expander), text);
|
2024-06-30 11:53:03 +02:00
|
|
|
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);
|
|
|
|
gtk_widget_set_margin_start (expander,
|
|
|
|
gtk_tree_list_row_get_depth(row) * 20);
|
2024-04-22 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
2024-07-01 07:26:16 +02:00
|
|
|
void on_setup_user_tree_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object, gpointer user_data){
|
|
|
|
GtkWidget* expander = gtk_expander_new (NULL);
|
|
|
|
gtk_list_item_set_child (GTK_LIST_ITEM (object), expander);
|
|
|
|
if (0) printf("[on_setup_user_tree_factory] here is an expander\n");
|
|
|
|
}
|
|
|
|
|
2024-06-30 11:53:03 +02:00
|
|
|
|
2024-04-22 18:40:30 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
/* G L A R E A */
|
|
|
|
/******************************************************************************/
|
2024-06-30 11:53:03 +02:00
|
|
|
|
|
|
|
gboolean on_glarea_render(GtkGLArea *area,
|
|
|
|
GdkGLContext *context)
|
2024-04-22 18:40:30 +02:00
|
|
|
{
|
|
|
|
// Check if the widget is a glarea
|
|
|
|
if(gtk_gl_area_get_error(area) != NULL) {
|
|
|
|
on_auto_notification("An OpenGL error occured !");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-07-18 23:51:04 +02:00
|
|
|
if (graphics_render_stack(gtk_widget_get_parent(GTK_WIDGET(area))) == false) {
|
2024-04-22 18:40:30 +02:00
|
|
|
on_auto_notification("Failed to render corresponding graphic stack !");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* We need to set up our state when we realize the GtkGLArea widget */
|
|
|
|
void on_glarea_realize(GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GError *internal_error = NULL;
|
|
|
|
|
|
|
|
// Make the GL context current to be able to call the GL API
|
|
|
|
gtk_gl_area_make_current(GTK_GL_AREA(widget));
|
|
|
|
|
|
|
|
// Check if the widget is a glarea
|
|
|
|
if(gtk_gl_area_get_error(GTK_GL_AREA(widget)) != NULL) {
|
|
|
|
on_auto_notification("An OpenGL error occured !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Link graphical stack to widget
|
2024-07-18 23:51:04 +02:00
|
|
|
if (graphics_init_graphics_stack(gtk_widget_get_parent(widget),
|
2024-04-22 18:40:30 +02:00
|
|
|
internal_error) == false) {
|
|
|
|
on_auto_notification(
|
|
|
|
"Failed to link the graphic stack to widgets !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_gl_area_set_auto_render(GTK_GL_AREA(widget), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We should tear down the state when unrealizing */
|
|
|
|
void on_glarea_unrealize(GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GError *internal_error = NULL;
|
|
|
|
|
|
|
|
// Make the GL context current to be able to call the GL API
|
|
|
|
gtk_gl_area_make_current(GTK_GL_AREA(widget));
|
|
|
|
|
|
|
|
// Check if the widget is a glarea
|
|
|
|
if(gtk_gl_area_get_error(GTK_GL_AREA(widget)) != NULL) {
|
|
|
|
on_auto_notification("An OpenGL error occured !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy graphic stack
|
2024-07-18 23:51:04 +02:00
|
|
|
if (graphics_shutdown_graphics_stack(gtk_widget_get_parent(widget),
|
2024-04-22 18:40:30 +02:00
|
|
|
internal_error) == false) {
|
|
|
|
on_auto_notification(
|
|
|
|
"Failed to shutdown the graphic stack !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
|
|
|
|
{
|
|
|
|
|
|
|
|
GtkWidget *slider = gtk_widget_get_parent(GTK_WIDGET(data));
|
|
|
|
GtkWidget *container_widget = gtk_widget_get_parent(GTK_WIDGET(slider));
|
|
|
|
|
|
|
|
const gchar *label_text = gtk_label_get_label(GTK_LABEL(data));
|
|
|
|
|
|
|
|
// THANKS ASCIIIII/Unicode/Whateverrr !
|
|
|
|
int axis = label_text[0] - 'X';
|
|
|
|
|
|
|
|
g_assert(axis >= 0 && axis < N_AXIS);
|
|
|
|
|
|
|
|
/* Update the rotation angle */
|
2024-07-18 23:51:04 +02:00
|
|
|
graphics_update_axis_stack(container_widget,
|
2024-04-22 18:40:30 +02:00
|
|
|
axis,
|
|
|
|
gtk_adjustment_get_value(adjustment));
|
|
|
|
|
|
|
|
/* Update the contents of the GL drawing area */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2024-07-08 07:52:27 +02:00
|
|
|
/* D I A L O G W I D G E T S */
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (data),
|
|
|
|
TRUE);
|
|
|
|
printf ("callback.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gtk_window_close (GTK_WINDOW (data));
|
|
|
|
printf ("callback.c - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gtk_window_close (GTK_WINDOW (data));
|
|
|
|
printf ("callback.c - WRITE_CURRENT_MODEL\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* S T A T E W I D G E T */
|
2024-04-22 18:40:30 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
|
2024-07-06 08:27:05 +02:00
|
|
|
static void switch_STATE_RULES_DATA()
|
|
|
|
{
|
2024-07-19 00:17:19 +02:00
|
|
|
switch (fsm_get_STATE_RULES_DATA()) {
|
2024-06-30 11:53:03 +02:00
|
|
|
|
|
|
|
case (STATE) :
|
2024-07-20 16:38:31 +02:00
|
|
|
gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()),
|
2024-07-20 15:24:32 +02:00
|
|
|
GTK_WIDGET (widget_rec_state_page()));
|
2024-06-30 11:53:03 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case (RULES) :
|
2024-07-20 16:38:31 +02:00
|
|
|
gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()),
|
2024-07-20 15:24:32 +02:00
|
|
|
GTK_WIDGET (widget_rec_rules_page()));
|
2024-06-30 11:53:03 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case (DATA) :
|
2024-07-20 16:38:31 +02:00
|
|
|
gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()),
|
2024-07-20 15:24:32 +02:00
|
|
|
GTK_WIDGET (widget_rec_stock_page()));
|
2024-06-30 11:53:03 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default :
|
|
|
|
printf("default in callback.on_toggle_STATE_RULES_DATA()\n");
|
2024-06-29 23:31:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-06 08:27:05 +02:00
|
|
|
void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data)
|
|
|
|
{
|
2024-07-19 00:17:19 +02:00
|
|
|
if (fsm_get_EXEC_EDIT ()) {
|
2024-06-30 11:53:03 +02:00
|
|
|
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (toggled_button),
|
|
|
|
"power-profile-balanced-rtl-symbolic");
|
2024-07-19 00:17:19 +02:00
|
|
|
fsm_set_EXEC_EDIT (EXEC);
|
2024-06-30 11:53:03 +02:00
|
|
|
|
2024-04-22 18:40:30 +02:00
|
|
|
} else {
|
2024-06-30 11:53:03 +02:00
|
|
|
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (toggled_button),
|
|
|
|
"text-editor-symbolic");
|
|
|
|
|
|
|
|
// https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30
|
2024-07-20 16:38:31 +02:00
|
|
|
// gtk_window_present (GTK_WINDOW (widget_topbar_get_dialog_window())); // works once only !
|
2024-06-30 11:53:03 +02:00
|
|
|
|
2024-07-19 00:17:19 +02:00
|
|
|
fsm_set_EXEC_EDIT (EDIT);
|
2024-04-22 18:40:30 +02:00
|
|
|
}
|
2024-06-29 23:31:17 +02:00
|
|
|
|
|
|
|
switch_STATE_RULES_DATA();
|
2024-04-22 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
2024-07-06 08:27:05 +02:00
|
|
|
void on_toggle_STATE_RULES_DATA (GtkWidget *toggled_button, gpointer user_data)
|
|
|
|
{
|
2024-06-30 11:53:03 +02:00
|
|
|
const char *toggled_button_name
|
|
|
|
= gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button));
|
2024-04-22 18:40:30 +02:00
|
|
|
int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button));
|
|
|
|
|
2024-06-30 11:53:03 +02:00
|
|
|
if (! strcmp (toggled_button_name, "state")) {
|
2024-07-19 00:17:19 +02:00
|
|
|
fsm_set_STATE_RULES_DATA (STATE);
|
2024-06-30 11:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! strcmp (toggled_button_name, "rules")) {
|
2024-07-19 00:17:19 +02:00
|
|
|
fsm_set_STATE_RULES_DATA (RULES);
|
2024-06-30 11:53:03 +02:00
|
|
|
}
|
2024-04-22 18:40:30 +02:00
|
|
|
|
2024-06-30 11:53:03 +02:00
|
|
|
if (! strcmp (toggled_button_name, "data analysis")) {
|
2024-07-19 00:17:19 +02:00
|
|
|
fsm_set_STATE_RULES_DATA (DATA);
|
2024-06-30 11:53:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_active) {
|
|
|
|
switch_STATE_RULES_DATA();
|
|
|
|
}
|
2024-04-22 18:40:30 +02:00
|
|
|
}
|
|
|
|
|
2024-07-06 23:09:47 +02:00
|
|
|
|
2024-07-04 08:04:58 +02:00
|
|
|
|
2024-07-20 15:24:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-05 22:19:18 +02:00
|
|
|
|
|
|
|
|
2024-07-19 23:02:27 +02:00
|
|
|
void on_OBJECTS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
|
2024-07-06 08:27:05 +02:00
|
|
|
{
|
2024-07-19 23:02:27 +02:00
|
|
|
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
|
|
|
|
double db = gtk_adjustment_get_value (adj_obj);
|
|
|
|
puts("on_OBJECTS_box_DO_RESET");
|
|
|
|
fsm_set_OBJECTS_box_RESET_VALUE (db);
|
2024-07-06 08:27:05 +02:00
|
|
|
}
|
2024-07-05 22:19:18 +02:00
|
|
|
|
2024-07-20 15:24:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-06 08:27:05 +02:00
|
|
|
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data)
|
|
|
|
{
|
2024-07-19 23:02:27 +02:00
|
|
|
puts("on_SITUATIONS_box_DO_RESET");
|
2024-07-19 00:17:19 +02:00
|
|
|
fsm_set_SITUATIONS_box_RESET_VALUE (1);
|
2024-07-06 08:27:05 +02:00
|
|
|
}
|
2024-07-05 22:19:18 +02:00
|
|
|
|
2024-07-06 23:09:47 +02:00
|
|
|
|
2024-07-08 07:52:27 +02:00
|
|
|
/******************************************************************************/
|
2024-07-10 23:31:30 +02:00
|
|
|
/* M A I N W I N D O W H E A D E R W I D G E T S */
|
2024-07-08 07:52:27 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
2024-07-15 07:11:30 +02:00
|
|
|
void on_clicked_search (GtkWidget *btt_menu, gpointer list_box) {
|
|
|
|
// next line presents the text_window and works only once.\nIt should present a menu.\n"); // TODO
|
2024-07-20 16:38:31 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (widget_topbar_get_text_window()));
|
2024-07-15 07:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data)
|
|
|
|
{
|
|
|
|
printf ("callback.on_clicked_HOME() button presents the dialog_window\
|
|
|
|
( :- ) but it works only once.\n"); // TODO
|
2024-07-20 16:38:31 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (widget_topbar_get_dialog_window()));
|
2024-07-15 07:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* M E N U */
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2024-07-14 15:08:45 +02:00
|
|
|
void on_clicked_menu_experiment (GtkWidget *btt_menu, gpointer list_box) {
|
2024-07-14 12:39:07 +02:00
|
|
|
printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
|
2024-07-15 10:26:14 +02:00
|
|
|
|
2024-07-14 12:39:07 +02:00
|
|
|
// gpointer list_box = gtk_popover_get_child (GTK_POPOVER (pop));
|
2024-07-15 10:26:14 +02:00
|
|
|
|
|
|
|
/*
|
2024-07-13 20:20:51 +02:00
|
|
|
if (gtk_list_box_get_row_at_index (list_box, 3))
|
2024-07-14 06:57:32 +02:00
|
|
|
printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
|
|
|
|
else printf ("callback.on_clicked_MENU() button > in list_box are the three buttons : %s, %s, %s\n\
|
2024-07-13 20:20:51 +02:00
|
|
|
and now : how to display these three buttons (and make use of them) ? 2024-07-13 (20h)\n",\
|
|
|
|
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 0)))),
|
|
|
|
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 1)))),
|
|
|
|
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 2)))));
|
2024-07-13 19:31:25 +02:00
|
|
|
|
|
|
|
// learning_how_to_create_a_menu (menu_button);
|
2024-07-13 11:14:14 +02:00
|
|
|
// https://docs.gtk.org/gtk4/class.ListBox.html
|
2024-07-15 10:26:14 +02:00
|
|
|
*/
|
2024-07-14 15:08:45 +02:00
|
|
|
}
|
2024-07-13 19:31:25 +02:00
|
|
|
|
2024-07-08 07:52:27 +02:00
|
|
|
|
2024-07-15 07:11:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-06 23:09:47 +02:00
|
|
|
|
|
|
|
|
2024-07-13 19:31:25 +02:00
|
|
|
/******************************************************************************/
|
2024-07-15 07:11:30 +02:00
|
|
|
/* M E N U (from TREE) */
|
2024-07-13 19:31:25 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
static void on_user_menu_expander_toggled (GtkExpander *expander,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
const gchar *text = gtk_string_object_get_string (
|
|
|
|
GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row)));
|
|
|
|
if (1) printf("[on_user_menu_expander_toggled] > %s\n", text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_bind_user_menu_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkListItem *list_item = GTK_LIST_ITEM (object);
|
|
|
|
assert (list_item);
|
|
|
|
|
|
|
|
GtkTreeListRow *row = gtk_list_item_get_item (list_item);
|
|
|
|
assert (row); // if (row != NULL) {...} do something ? TODO Check !
|
|
|
|
|
|
|
|
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);
|
|
|
|
gtk_expander_set_label (GTK_EXPANDER (expander), text);
|
|
|
|
g_signal_handlers_disconnect_by_func (expander,
|
|
|
|
G_CALLBACK (on_user_menu_expander_toggled),
|
|
|
|
row);
|
|
|
|
g_signal_connect (expander,
|
|
|
|
"activate",
|
|
|
|
G_CALLBACK (on_user_menu_expander_toggled),
|
|
|
|
row);
|
|
|
|
gtk_widget_set_margin_start (expander,
|
|
|
|
gtk_tree_list_row_get_depth(row) * 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_setup_user_menu_factory (GtkSignalListItemFactory *factory,
|
|
|
|
GObject* object, gpointer user_data){
|
|
|
|
GtkWidget* expander = gtk_expander_new (NULL);
|
|
|
|
gtk_list_item_set_child (GTK_LIST_ITEM (object), expander);
|
|
|
|
if (0) printf("[on_setup_user_menu_factory] here is an expander\n");
|
|
|
|
}
|
|
|
|
|
2024-07-19 23:02:27 +02:00
|
|
|
|