[gtk/matthiasc/for-master] gtk-demo: Add a slider to the menu example




commit c920236c543050c3b6160db77d9a87fb9c8a7b2b
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 5 19:31:54 2021 -0400

    gtk-demo: Add a slider to the menu example
    
    This is a fun way to show that we can scale fast.

 demos/gtk-demo/menu.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/demos/gtk-demo/menu.c b/demos/gtk-demo/menu.c
index cdcfd0ed20..d7db025910 100644
--- a/demos/gtk-demo/menu.c
+++ b/demos/gtk-demo/menu.c
@@ -21,8 +21,10 @@ do_menu (GtkWidget *do_widget)
 
   if (!window)
     {
+      GtkWidget *box;
       GtkWidget *sw;
       GtkWidget *widget;
+      GtkWidget *scale;
 
       window = gtk_window_new ();
       gtk_window_set_title (GTK_WINDOW (window), "Menu");
@@ -31,11 +33,23 @@ do_menu (GtkWidget *do_widget)
                               gtk_widget_get_display (do_widget));
       g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
 
+      box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+      gtk_window_set_child (GTK_WINDOW (window), box);
+
       sw = gtk_scrolled_window_new ();
-      gtk_window_set_child (GTK_WINDOW (window), sw);
+      gtk_widget_set_vexpand (sw, TRUE);
+      gtk_box_append (GTK_BOX (box), sw);
 
       widget = demo3_widget_new ("/transparent/portland-rose.jpg");
       gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), widget);
+
+      scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.01, 10.0, 0.1);
+      gtk_range_set_value (GTK_RANGE (scale), 1.0);
+      gtk_box_append (GTK_BOX (box), scale);
+
+      g_object_bind_property (gtk_range_get_adjustment (GTK_RANGE (scale)), "value",
+                              widget, "scale",
+                              G_BINDING_BIDIRECTIONAL);
     }
 
   if (!gtk_widget_get_visible (window))


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