[gtk/better-tabs-demo: 1/2] Beef up the tabs demo




commit 5fe4f1b930c5cea45e103e82005a330ac59b36a0
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 29 09:25:32 2021 -0500

    Beef up the tabs demo
    
    Show various alignments, including numeric.

 demos/gtk-demo/tabs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/tabs.c b/demos/gtk-demo/tabs.c
index aaa33af822..c6818e7d91 100644
--- a/demos/gtk-demo/tabs.c
+++ b/demos/gtk-demo/tabs.c
@@ -1,6 +1,11 @@
 /* Text View/Tabs
  *
  * GtkTextView can position text at fixed positions, using tabs.
+ * Tabs can specify alignment, and also allow aligning numbers
+ * on the decimal point.
+ *
+ * The example here has three tabs, with left, numeric and right
+ * alignment.
  */
 
 #include <gtk/gtk.h>
@@ -35,13 +40,14 @@ do_tabs (GtkWidget *do_widget)
 
       tabs = pango_tab_array_new (3, TRUE);
       pango_tab_array_set_tab (tabs, 0, PANGO_TAB_LEFT, 0);
-      pango_tab_array_set_tab (tabs, 1, PANGO_TAB_LEFT, 100);
-      pango_tab_array_set_tab (tabs, 2, PANGO_TAB_LEFT, 200);
+      pango_tab_array_set_tab (tabs, 1, PANGO_TAB_DECIMAL, 120);
+      pango_tab_array_set_decimal_point (tabs, 1, '.');
+      pango_tab_array_set_tab (tabs, 2, PANGO_TAB_RIGHT, 240);
       gtk_text_view_set_tabs (GTK_TEXT_VIEW (view), tabs);
       pango_tab_array_free (tabs);
 
       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-      gtk_text_buffer_set_text (buffer, "one\ttwo\tthree\nfour\tfive\tsix\nseven\teight\tnine", -1);
+      gtk_text_buffer_set_text (buffer, "one\t2.0\tthree\nfour\t5.555\tsix\nseven\t88.88\tnine", -1);
 
       sw = gtk_scrolled_window_new ();
       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),


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