[gtk/popover-attach: 2/2] gtk-demo: Fix the popover demo



commit 0ead40efa38c05431b88b9b38491adcd09132e61
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Feb 23 20:27:35 2020 -0500

    gtk-demo: Fix the popover demo
    
    Use GtkPopoverHolder here to fix things up.

 demos/gtk-demo/popover.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/demos/gtk-demo/popover.c b/demos/gtk-demo/popover.c
index 2d5c44cf59..a2834cde52 100644
--- a/demos/gtk-demo/popover.c
+++ b/demos/gtk-demo/popover.c
@@ -100,6 +100,7 @@ day_selected_cb (GtkCalendar *calendar,
   GdkEvent *event;
   gdouble x, y;
   GtkWidget *widget;
+  GtkPopoverHolder *holder = GTK_POPOVER_HOLDER (user_data);
 
   event = gtk_get_current_event ();
 
@@ -114,7 +115,7 @@ day_selected_cb (GtkCalendar *calendar,
                                     &rect.x, &rect.y);
   rect.width = rect.height = 1;
 
-  popover = create_popover (GTK_WIDGET (calendar),
+  popover = create_popover (GTK_WIDGET (holder),
                             gtk_entry_new (),
                             GTK_POS_BOTTOM);
   gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
@@ -129,6 +130,8 @@ do_popover (GtkWidget *do_widget)
 {
   static GtkWidget *window = NULL;
   GtkWidget *popover, *box, *widget;
+  GtkWidget *entry;
+  GtkWidget *calendar;
 
   if (!window)
     {
@@ -150,11 +153,13 @@ do_popover (GtkWidget *do_widget)
                         G_CALLBACK (toggle_changed_cb), popover);
       gtk_container_add (GTK_CONTAINER (box), widget);
 
-      widget = gtk_entry_new ();
+      entry = gtk_entry_new ();
+      widget = gtk_popover_holder_new ();
+      gtk_popover_holder_set_child (GTK_POPOVER_HOLDER (widget), entry);
       popover = create_complex_popover (widget, GTK_POS_TOP);
-      gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
+      gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
                                          GTK_ENTRY_ICON_PRIMARY, "edit-find");
-      gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
+      gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
                                          GTK_ENTRY_ICON_SECONDARY, "edit-clear");
 
       g_signal_connect (widget, "icon-press",
@@ -163,9 +168,11 @@ do_popover (GtkWidget *do_widget)
                         G_CALLBACK (entry_size_allocate_cb), popover);
       gtk_container_add (GTK_CONTAINER (box), widget);
 
-      widget = gtk_calendar_new ();
-      g_signal_connect (widget, "day-selected",
-                        G_CALLBACK (day_selected_cb), NULL);
+      calendar = gtk_calendar_new ();
+      widget = gtk_popover_holder_new ();
+      gtk_popover_holder_set_child (GTK_POPOVER_HOLDER (widget), calendar);
+      g_signal_connect (calendar, "day-selected",
+                        G_CALLBACK (day_selected_cb), widget);
       gtk_container_add (GTK_CONTAINER (box), widget);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]