WIP: How to make this popover popup ? (see heads.c 183 & calls.c 351

This commit is contained in:
Jean Sirmai 2024-07-14 06:57:32 +02:00
parent aaf8777299
commit 34f295d8cc
Signed by: jean
GPG Key ID: FB3115C340E057E3
4 changed files with 17 additions and 10 deletions

View File

@ -71,7 +71,8 @@ void on_SITUATIONS_box_RESET_VALUE (GtkAdjustment *adjustment, gpointer data);
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data);
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data);
void on_clicked_MENU (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);

View File

@ -348,8 +348,8 @@ void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data)
/******************************************************************************/
void on_clicked_MENU (GtkWidget *btt_reset, gpointer list_box)
{
void on_clicked_MENU_pop (GtkWidget *btt_reset, gpointer pop) {
gpointer list_box = gtk_popover_get_child (GTK_POPOVER (pop));
if (gtk_list_box_get_row_at_index (list_box, 3))
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\

View File

@ -178,20 +178,23 @@ static void window_header_bar (GtkWindow *window, char *title)
// GtkWidget *menu_item_D = GTK_WIDGET (gtk_button_new_with_label ("button_D")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_D);
// gtk_list_box_append (GTK_LIST_BOX (list_box), gtk_label_new ("any text"));
GtkWidget *pop = gtk_popover_new ();
gtk_popover_set_child (GTK_POPOVER (pop), list_box);
if (0) gtk_popover_popup (GTK_POPOVER (pop));
GtkButton *open_menu = GTK_BUTTON (gtk_button_new ()); // gtk_button_new or gtk_menu_button_new ?
gtk_button_set_icon_name (GTK_BUTTON (open_menu), "open-menu-symbolic");
// gtk_menu_button_set_label (open_menu, "open-menu-symbolic");
// gtk_menu_button_set_child (open_menu, list);
g_signal_connect (open_menu, "clicked", G_CALLBACK (on_clicked_MENU), list_box);
// g_signal_connect (open_menu, "clicked", G_CALLBACK (on_clicked_MENU_list_box), list_box);
g_signal_connect (open_menu, "clicked", G_CALLBACK (on_clicked_MENU_pop), pop);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu));
/*
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (get_menu_anchor()));
GtkWidget *menu_btt = gtk_menu_button_new ();
gtk_menu_button_set_child (GTK_MENU_BUTTON (menu_btt), NULL);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menu_btt), NULL); // GMenuModel* menu_model
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (menu_btt));
*/
}
void widget_head_MAIN_WINDOW_design (GtkWindow *main_window){

View File

@ -81,6 +81,9 @@ static GListModel* get_user_menu_model (GObject *item, gpointer root){
GtkWidget *get_menu_anchor()
{
// https://docs.gtk.org/gio/class.MenuModel.html
// https://www.geany.org/manual/gtk/gobject/index.html
if (0) labo_create_a_simple_gtk_string_list ();
struct MenuNode_t *menu_root = create_user_menu_node("menu");
struct MenuNode_t *item_a = create_user_menu_node("item_a");add_menu_item (menu_root, item_a);