1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Add an option to suppress horizontal scroll bars in list boxes.

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]
This commit is contained in:
Simon Tatham 2014-09-09 11:46:14 +00:00
parent 80a9a7918a
commit f3860ec95e
3 changed files with 16 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;

View 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);