[gtk/matthiasc/for-master] gkt-demo: Add a columview to the scroll demo




commit 4f2143e24c228093d170035a2cd9e80e5f149b8d
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 9 20:07:09 2020 -0500

    gkt-demo: Add a columview to the scroll demo
    
    This is an interesting case, since it has many labels,
    and we are struggling to provide good scrolling performance.

 demos/gtk-demo/iconscroll.c   | 25 ++++++++++++++++++++++++-
 demos/gtk-demo/listview_ucd.c |  5 +++--
 2 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/iconscroll.c b/demos/gtk-demo/iconscroll.c
index d7a6c1b5e3..9e2fe9dc8a 100644
--- a/demos/gtk-demo/iconscroll.c
+++ b/demos/gtk-demo/iconscroll.c
@@ -13,7 +13,7 @@ static GtkWidget *window = NULL;
 static GtkWidget *scrolledwindow;
 static int selected;
 
-#define N_WIDGET_TYPES 6
+#define N_WIDGET_TYPES 7
 
 
 static int hincrement = 5;
@@ -177,6 +177,24 @@ populate_grid (void)
   gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
 }
 
+extern GtkWidget *create_ucd_view (GtkWidget *label);
+
+static void
+populate_list2 (void)
+{
+  GtkWidget *list;
+
+  list = create_ucd_view (NULL);
+
+  hincrement = 0;
+  vincrement = 5;
+
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+                                  GTK_POLICY_AUTOMATIC,
+                                  GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
+}
+
 static void
 set_widget_type (int type)
 {
@@ -216,6 +234,11 @@ set_widget_type (int type)
       break;
 
     case 5:
+      gtk_window_set_title (GTK_WINDOW (window), "Scrolling a columned list");
+      populate_list2 ();
+      break;
+
+    case 6:
       gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
       populate_grid ();
       break;
diff --git a/demos/gtk-demo/listview_ucd.c b/demos/gtk-demo/listview_ucd.c
index 9fe85fcbd1..df120fcb08 100644
--- a/demos/gtk-demo/listview_ucd.c
+++ b/demos/gtk-demo/listview_ucd.c
@@ -259,7 +259,7 @@ selection_changed (GObject    *object,
   gtk_label_set_label (GTK_LABEL (label), buffer);
 }
 
-static GtkWidget *
+GtkWidget *
 create_ucd_view (GtkWidget *label)
 {
   GtkWidget *cv;
@@ -273,7 +273,8 @@ create_ucd_view (GtkWidget *label)
   selection = gtk_single_selection_new (ucd_model);
   gtk_single_selection_set_autoselect (selection, TRUE);
   gtk_single_selection_set_can_unselect (selection, FALSE);
-  g_signal_connect (selection, "notify::selected", G_CALLBACK (selection_changed), label);
+  if (label)
+    g_signal_connect (selection, "notify::selected", G_CALLBACK (selection_changed), label);
 
   cv = gtk_column_view_new (GTK_SELECTION_MODEL (selection));
   gtk_column_view_set_show_column_separators (GTK_COLUMN_VIEW (cv), TRUE);


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