signal 'clicked' is invalid for instance of type 'GtkMenuButton', 'GtkListBox' or 'GtkLabel' (heads.c 198)

This commit is contained in:
Jean Sirmai 2024-07-14 15:08:45 +02:00
parent f47014b4e6
commit b3ea5c4676
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 22 additions and 6 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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){