[gtk/matthiasc/for-master: 2/4] gtk-demo: Ellipsize columns in the characters demo
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/4] gtk-demo: Ellipsize columns in the characters demo
- Date: Fri, 9 Oct 2020 03:13:42 +0000 (UTC)
commit bc9d037fd0151f60cc4041c42b407d0741c01f7a
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 8 15:55:22 2020 -0400
gtk-demo: Ellipsize columns in the characters demo
some of the columns have uneven widths, causing them
to bounce around as you scroll. Ellipsize them and
give them a fixed with.
demos/gtk-demo/listview_ucd.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/listview_ucd.c b/demos/gtk-demo/listview_ucd.c
index 4331d646fb..d6711a1aec 100644
--- a/demos/gtk-demo/listview_ucd.c
+++ b/demos/gtk-demo/listview_ucd.c
@@ -116,6 +116,18 @@ setup_label (GtkSignalListItemFactory *factory,
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
}
+static void
+setup_ellipsizing_label (GtkSignalListItemFactory *factory,
+ GObject *listitem)
+{
+ GtkWidget *label;
+ label = gtk_label_new ("");
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_width_chars (GTK_LABEL (label), 20);
+ gtk_list_item_set_child (GTK_LIST_ITEM (listitem), label);
+}
+
static void
bind_codepoint (GtkSignalListItemFactory *factory,
GObject *listitem)
@@ -279,21 +291,21 @@ create_ucd_view (GtkWidget *label)
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
- g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
+ g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_name), NULL);
column = gtk_column_view_column_new ("Name", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
- g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
+ g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_type), NULL);
column = gtk_column_view_column_new ("Type", factory);
gtk_column_view_column_set_resizable (column, TRUE);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
factory = gtk_signal_list_item_factory_new ();
- g_signal_connect (factory, "setup", G_CALLBACK (setup_label), NULL);
+ g_signal_connect (factory, "setup", G_CALLBACK (setup_ellipsizing_label), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_break_type), NULL);
column = gtk_column_view_column_new ("Break Type", factory);
gtk_column_view_column_set_resizable (column, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]