From b3ea5c4676a2696fd231e26045061d8852730be0 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 14 Jul 2024 15:08:45 +0200 Subject: [PATCH] signal 'clicked' is invalid for instance of type 'GtkMenuButton', 'GtkListBox' or 'GtkLabel' (heads.c 198) --- include/calls.h | 5 +++-- src/calls.c | 6 ++++-- src/widget.c/heads.c | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/calls.h b/include/calls.h index e2c6cd4..ee6c0c2 100644 --- a/include/calls.h +++ b/include/calls.h @@ -72,8 +72,9 @@ void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data); void on_clicked_HOME (GtkWidget *btt_reset, gpointer data); //void on_clicked_MENU_list_box (GtkWidget *btt_reset, gpointer data); -void on_clicked_MENU_pop (GtkWidget *btt_reset, gpointer data); - +//void on_clicked_MENU_pop (GtkWidget *btt_reset, gpointer data); +void on_clicked_search (GtkWidget *btt_menu, gpointer list_box); +void on_clicked_menu_experiment (GtkWidget *btt_menu, gpointer list_box); diff --git a/src/calls.c b/src/calls.c index 915ac61..f275034 100644 --- a/src/calls.c +++ b/src/calls.c @@ -348,7 +348,7 @@ void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data) /******************************************************************************/ -void on_clicked_MENU_pop (GtkWidget *btt_menu, gpointer list_box) { +void on_clicked_menu_experiment (GtkWidget *btt_menu, gpointer list_box) { printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box); // gpointer list_box = gtk_popover_get_child (GTK_POPOVER (pop)); if (gtk_list_box_get_row_at_index (list_box, 3)) @@ -361,9 +361,11 @@ void on_clicked_MENU_pop (GtkWidget *btt_menu, gpointer list_box) { // learning_how_to_create_a_menu (menu_button); // https://docs.gtk.org/gtk4/class.ListBox.html +} +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 - // gtk_window_present (GTK_WINDOW (widget_head_get_TEXT_WINDOW())); + gtk_window_present (GTK_WINDOW (widget_head_get_TEXT_WINDOW())); } void on_clicked_HOME (GtkWidget *btt_reset, gpointer data) diff --git a/src/widget.c/heads.c b/src/widget.c/heads.c index 44ea778..f3e1006 100644 --- a/src/widget.c/heads.c +++ b/src/widget.c/heads.c @@ -168,14 +168,22 @@ static void window_header_bar (GtkWindow *window, char *title) gtk_button_set_icon_name (search, "preferences-desktop-appearance-symbolic"); gtk_button_set_icon_name (search, "applications-utilities-symbolic"); 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)); + + + + GtkWidget* list_box = gtk_list_box_new(); // GtkWidget *menu_item_A = GTK_WIDGET (gtk_menu_item_new ("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_A); // GtkWidget *menu_item_B = GTK_WIDGET (gtk_menu_item_new_with_label("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_B); GtkWidget *menu_item_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_C); + GtkWidget *menu_item_D = GTK_WIDGET (gtk_label_new("D")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_D); +// gtk_menu_item_activate (menu_item_C); +// 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 GtkWidget *pop = gtk_popover_new (); gtk_popover_set_child (GTK_POPOVER (pop), list_box); gtk_popover_present (GTK_POPOVER (pop)); @@ -187,14 +195,19 @@ static void window_header_bar (GtkWindow *window, char *title) gtk_menu_button_set_popover (open_menu, GTK_WIDGET (pop)); gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu)); +// g_signal_connect (menu_item_D, "clicked", G_CALLBACK (on_clicked_menu_experiment), list_box); +// signal 'clicked' is invalid for instance '0xbcb2900' of type 'GtkMenuButton' +// signal 'clicked' is invalid for instance '0x2812f80' of type 'GtkListBox' +// signal 'clicked' is invalid for instance '0x2a15120' of type 'GtkLabel' + + // 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 (menu_item_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); +// g_signal_connect (menu_item_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); -// 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 } void widget_head_MAIN_WINDOW_design (GtkWindow *main_window){