I have a program here that uses the GTK Status bar and I'd like to have multi-line output in it. When I try to output multiple lines into it, I get glyphs instead as seen below:
I'd expect it to work like in emacs:
After some searching, I discovered layoutSetSingleParagraphMode which seems to do exactly what I want. The default setting is False for most widgets and we're not setting it ourselves anywhere which makes me think that Statusbar defaults to single paragraph mode.
My problem is that I have no idea how to go from Statusbar
to PangoLayout
upon which I can use this function.
The closest I have come was finding widgetGetPangoContext which then let me get PangoLayout
with layoutEmpty but as the name suggest, this seems to just create a separate PangoLayout
which doesn't affect the statusbar when manipulated: pushing or popping of text behaves as it did before this.
Is there a function I'm missing? Admittedly, gtk2hs
swims in a sea of type-classes to emulate OO which doesn't contribute to the readability of the generated docs. It seems that it should be a simple task.
If we're never meant to get out a PangoLayout
from existing widget then how can I achieve what I want? There seems to be no option to choose the paragraph mode at Statusbar creation time.
See this for a GitHub issue for this project relating to this.
Please try this:
Use statusbarGetMessageArea
to get the Gtk.Box
where the status bar's text label is.
Then get the text label with containerGetChildren <status bar message area>
. This function returns a list of Gtk.Widget
with just one element, the label.
Cast the widget to a label with castToLabel
.
Now you can set multi line mode with labelSetSingleLineMode <label> False
.
Set the label's contents with labelSetText
or labelSetMarkup
.
I have tried it with success (gtk 0.12.5 from Hackage, using GTK2, haven't tried it with GTK3).