]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Add an option to suppress horizontal scroll bars in list boxes.
authorSimon Tatham <anakin@pobox.com>
Tue, 9 Sep 2014 11:46:14 +0000 (11:46 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 9 Sep 2014 11:46:14 +0000 (11:46 +0000)
I'm about to add a list box which expects to contain some very long
but uninformative strings, and which is also quite vertically squashed
so there's not much room for a horizontal scroll bar to appear in it.
So here's an option in the list box specification structure which
causes the constructed GTKTreeView to use the 'ellipsize' option for
all its cell renderers, i.e. too-long strings are truncated with an
ellipsis.

Windows needs no change, because its list boxes already work this way.

[originally from svn r10219]

dialog.c
dialog.h
unix/gtkdlg.c

index 84869195fad5394ac8c7869c61f3712473c8ad52..cbe95124decc7b238d707500d183dc42c806025a 100644 (file)
--- a/dialog.c
+++ b/dialog.c
@@ -364,6 +364,7 @@ union control *ctrl_listbox(struct controlset *s,char *label,char shortcut,
     c->listbox.percentwidth = 100;
     c->listbox.ncols = 0;
     c->listbox.percentages = NULL;
+    c->listbox.hscroll = TRUE;
     return c;
 }
 
index 9ea8599ea0513af334fccf44698195fb870fea31..6f454f566c2e12a1055ac3f497bd082d1c0ac42b 100644 (file)
--- a/dialog.h
+++ b/dialog.h
@@ -345,6 +345,12 @@ union control {
         */
        int ncols;                     /* number of columns */
        int *percentages;              /* % width of each column */
+        /*
+         * Flag which can be set to FALSE to suppress the horizontal
+         * scroll bar if a list box entry goes off the right-hand
+         * side.
+         */
+        int hscroll;
     } listbox;
     struct {
        STANDARD_PREFIX;
index 86fa310e0a5201c9be6ec5cdb3a22abb6bdb8a37..3776df8c1998c50f20bf84b2c1cc35d37eefd1e4 100644 (file)
@@ -2276,15 +2276,22 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
                    cols = cols ? cols : 1;
                    for (i = 0; i < cols; i++) {
                        GtkTreeViewColumn *column;
+                        GtkCellRenderer *cellrend;
                        /*
                         * It appears that GTK 2 doesn't leave us any
                         * particularly sensible way to honour the
                         * "percentages" specification in the ctrl
                         * structure.
                         */
+                        cellrend = gtk_cell_renderer_text_new();
+                        if (!ctrl->listbox.hscroll) {
+                            gtk_object_set(GTK_OBJECT(cellrend),
+                                           "ellipsize", PANGO_ELLIPSIZE_END,
+                                           "ellipsize-set", TRUE,
+                                           NULL);
+                        }
                        column = gtk_tree_view_column_new_with_attributes
-                           ("heading", gtk_cell_renderer_text_new(),
-                            "text", i+1, (char *)NULL);
+                           ("heading", cellrend, "text", i+1, (char *)NULL);
                        gtk_tree_view_column_set_sizing
                            (column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
                        gtk_tree_view_append_column(GTK_TREE_VIEW(w), column);