mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 09:42:25 +00:00
Add conditioned-out diagnostics in columns_compute_width.
These are a slightly cleaned-up version of the diagnostics I was using to debug the layout problems in the GTK3 config box the other day. In particular, if the box comes out far too wide - as I've just found out that it also does when I compile the current state of the code against OS X GTK3 - these diagnostics should provide enough information to figure out which control is the limiting factor. To enable: make CPPFLAGS="-DCOLUMNS_WIDTH_DIAGNOSTICS"
This commit is contained in:
parent
54dcfb033c
commit
76612e772d
@ -588,6 +588,10 @@ static gint columns_compute_width(Columns *cols, widget_dim_fn_t get_width)
|
|||||||
const gint *percentages;
|
const gint *percentages;
|
||||||
static const gint onecol[] = { 100 };
|
static const gint onecol[] = { 100 };
|
||||||
|
|
||||||
|
#ifdef COLUMNS_WIDTH_DIAGNOSTICS
|
||||||
|
printf("compute_width(%p): start\n", cols);
|
||||||
|
#endif
|
||||||
|
|
||||||
retwidth = 0;
|
retwidth = 0;
|
||||||
|
|
||||||
ncols = 1;
|
ncols = 1;
|
||||||
@ -611,6 +615,23 @@ static gint columns_compute_width(Columns *cols, widget_dim_fn_t get_width)
|
|||||||
childwidth = get_width(child);
|
childwidth = get_width(child);
|
||||||
colspan = child->colspan ? child->colspan : ncols-child->colstart;
|
colspan = child->colspan ? child->colspan : ncols-child->colstart;
|
||||||
|
|
||||||
|
#ifdef COLUMNS_WIDTH_DIAGNOSTICS
|
||||||
|
printf("compute_width(%p): ", cols);
|
||||||
|
if (GTK_IS_LABEL(child->widget))
|
||||||
|
printf("label %p '%s' wrap=%s: ", child->widget,
|
||||||
|
gtk_label_get_text(GTK_LABEL(child->widget)),
|
||||||
|
(gtk_label_get_line_wrap(GTK_LABEL(child->widget))
|
||||||
|
? "TRUE" : "FALSE"));
|
||||||
|
else
|
||||||
|
printf("widget %p: ", child->widget);
|
||||||
|
{
|
||||||
|
gint min, nat;
|
||||||
|
gtk_widget_get_preferred_width(child->widget, &min, &nat);
|
||||||
|
printf("minwidth=%d natwidth=%d ", min, nat);
|
||||||
|
}
|
||||||
|
printf("thiswidth=%d span=%d\n", childwidth, colspan);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To compute width: we know that childwidth + cols->spacing
|
* To compute width: we know that childwidth + cols->spacing
|
||||||
* needs to equal a certain percentage of the full width of
|
* needs to equal a certain percentage of the full width of
|
||||||
@ -635,6 +656,10 @@ static gint columns_compute_width(Columns *cols, widget_dim_fn_t get_width)
|
|||||||
* before dividing by percent.
|
* before dividing by percent.
|
||||||
*/
|
*/
|
||||||
fullwid = (thiswid * 100 + percent - 1) / percent;
|
fullwid = (thiswid * 100 + percent - 1) / percent;
|
||||||
|
#ifdef COLUMNS_WIDTH_DIAGNOSTICS
|
||||||
|
printf("compute_width(%p): after %p, thiswid=%d fullwid=%d\n",
|
||||||
|
cols, child->widget, thiswid, fullwid);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The above calculation assumes every widget gets
|
* The above calculation assumes every widget gets
|
||||||
@ -649,6 +674,10 @@ static gint columns_compute_width(Columns *cols, widget_dim_fn_t get_width)
|
|||||||
|
|
||||||
retwidth += 2*gtk_container_get_border_width(GTK_CONTAINER(cols));
|
retwidth += 2*gtk_container_get_border_width(GTK_CONTAINER(cols));
|
||||||
|
|
||||||
|
#ifdef COLUMNS_WIDTH_DIAGNOSTICS
|
||||||
|
printf("compute_width(%p): done, returning %d\n", cols, retwidth);
|
||||||
|
#endif
|
||||||
|
|
||||||
return retwidth;
|
return retwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user