GtkTextView auto calibration in GtkScrolledWindow

I am working on gschem , a free software tool for editing electronic circuitry. We recently encountered a problem using a GtkScrolledWindow containing a GtkTextView .

Context

Recent versions of Ubuntu use overlay scroll bars, which means that GtkScrolledWindows no longer sets a minimum height that provides enough space for the old scroll bar (they actually have a minimum height of 0). Likewise, a GtkTextView with no text to display queries with a height of 0. This means that one of the scrollable GtkTextViews in gschem is displayed as one pixel in height, and this is clearly unsuitable.

Screenshots showing broken

In the dialog box to the right of the screenshot shown above, pay attention to the invisible widget between the "Value:" label and the "Add" button.

This is reported independently of multiple users - see also error report .

Question

Obviously, we could fix this by doing:

g_object_set (textview, "height-request", 100, NULL); 

However, this is rather inelegant and will break for users who set very large font sizes in pixels (for example, users with vision problems or using high-resolution screens).

Ideally, therefore, we want to set the minimum size of the GtkTextView relative to the default font size, for example. say "show at least three lines of text."

Can anyone suggest a reasonable / elegant approach for this?

+7
source share
4 answers

Just disable the ubuntu bandwidth scroll in your application by doing:

 putenv("LIBOVERLAY_SCROLLBAR=0"); 

Not perfect, but not bad until you find a more permanent solution. Alternatively, just wait while Ubuntu disables scrollbar overlays ...

+2
source

I would add code to dig up the current / standard style information, use this to figure out the height of the baseline of the font, and then calculate the distribution of the approximate size based on this, around the three lines, as you mentioned.

0
source

Should it be textual? If you can use the eventbox instead, you can make it a cairo surface, visualize the text with pango, and then use pango_layout_get_size () to get the height of the text.

0
source

Similarly, a GtkTextView with no text to display requests with a height of 0.

Perhaps you can create a GtkTextView with some text inside. Like a few spaces, and set an empty value after creation.

0
source

All Articles