Closed IgnorantGuru closed 11 years ago
I'm pretty sure that it works perfectly here; I have none of those issues. It might be a theme issue or maybe a change from Gtk3.4 to Gtk3.6.
with darkmint theme with no theme
Seems to be broken in both in different ways. The expansion of the drop-down lists is similar to #23. At any rate it's unusable like this.
I'm still using gtk 3.4, which otherwise works without problems with DarkMint theme. No other problems with drop-down lists except in this example.
Oddly, if I manually shrink the unthemed window, then the drop-down lists expand vertically, and the labels go multi-line: screenshot
Yup, I don't have those problems. You should be able to change the packing to GTK_SHRINK like was done with the wallpaper options and the problem should go away.
Relevant code (master branch). This isn't a glade file, and the --compact option to --hbox packs it without vertical expansion (code). Suggestion?
I'd try gtk_label_set_single_line_mode for the labels, then they shouldn't wrap. If those aren't tall, the comboboxes shouldn't be either.
Well labels in custom-dialog are supposed to handle multiple lines, so that doesn't work. But they shouldn't go to multiple lines with just one line of text. I'll see how it is when I go to gtk 3.6.
It seems they broke something. In gtk2 it doesn't happen. In gtk3 the labels shrink too small causing multiple lines, yet the automatic width of the window isn't enough to prevent it. If I expand the window it goes away. Even if I remove the third item label and droplist, it still chooses too small a window size. Looks like a gtk bug.
I think this is like the situation with the labels in the tabs. The changes to how the minimum size of a label is handled is the reason for this. They changed the handling to be consistent with the other widgets rather than a special case, which leaves some things incompatible. I'll take a look at it when I have the chance.
Without setting the label's width, it doesn't make sense to have them wrap automatically. This causes gtk3 to give them the minimum width of 1 character and allows the window to be shrunk to that size and wraps the text accordingly. The call to gtk_label_set_line_wrap on line 2597 is the cause of this behavior. It can still handle multiple lines without that call if line breaks are put in the command.
I'd say just remove that line.
Unfortunately that solution doesn't behave well in other situations. For example:
spacefm -g --label TEXT
TEXT may contain a large one-line paragraph, which should be wrapped. Otherwise the window just becomes wide beyond the width of the screen.
SpaceFM Dialog is designed to choose reasonable defaults for general use, since we don't really know what will be in the label. It's a little different than using gtk to build a static dialog. Also, the contents of label may change radically while the dialog is running.
It seems that gtk3's shrinking the label is very dysfunctional. gtk has always handled labels poorly, and now they seem to have made it worse with a hacked fix for one issue rather than taking the time to make it better. Still not sure what to do about this. Maybe a custom allocation handler, but that can get tricky with themes and font sizes changing things as well.
Even if you pack the label with expand TRUE it still shrinks the labels ridiculously, so this does seem like a gtk3 bug.
And if you use expand TRUE with wrap on a very long line, it wraps the text but the window becomes abnormally tall with lots of empty space. expand TRUE seems to work okay in gtk2, although I think there was a reason why I made that false. gtk3 labels just seem really messed up.
At any rate it needs to be tested with a short text, a very long text requiring wrapping, and a multi-line text containing \n, with both short and long lines that need to be wrapped.
As I said, you can't expect the label to know a good place to wrap automatically, unless you're wrapping at the end of the window. The issue is that the size of the window depends on the size of the label. That's somewhat of a recursive dependency. http://www.16software.com/blog/dynamic-label-wrapping-in-gtk - That is a good place to see how things are in gtk2, which is more rigid, where you have a hard time having a label auto-wrap with respect to a window, which was fixed in gtk3.
I'd say that by default the text shouldn't wrap, and an option can be passed to have the label autowrap. Those are two different use-cases with a different set of needs. I don't think there can be one way that will properly satisfy both, not even in gtk2. Resizing the window in gtk2 with wrapped text should seem poor as compared to with gtk3, while it may look fine at its default size.
Note to self: does this wrap issue only occur when label is in an hbox - if so then maybe wrap can be optional or turned off only then.
In https://github.com/IgnorantGuru/spacefm/commit/3963ea79ef250c535762aa9da70a35149977e1ff I added a hack for gtk3 when a label is packed into an hbox. It turns wrap off in that case. I also added manual --wrap and --nowrap options for --label so if necessary this can be controlled. Also, --compact and --expand can now be included with any element to force how its packed.
However, there is still an issue with this. For example:
spacefm -g --label "xxx...xxx"
Where "xxx...xxx" represents a long string, maybe 200 characters or so. The window is shown with a huge vertical height beyond the screen size. It seems to allocate enough space so that you can horizontally minimize the window.
Adding a button gets this under control somewhat, since the minimum width of the window is seen as a window width minimum, which in turn limits the height:
spacefm -g --label "xxx...xxx" --button ok
But even so, the label is taking way more space than it should making the window abnormally tall.
Any idea how to get that under control in a reasonable way? The design of spacefm Dialog tries to make things as automatic as possible, and the gtk2 and gtk3 versions should be similar (since the plugin author won't know which gtk the user is using in general). And while the wrap hack makes gtk3 behave a little better, it too will create differences between gtk2 and gtk3 in some cases.
With most gtk2 widgets, if you pack them into a window they are given reasonable size so the window looks okay without any fussing with it, but with gtk3 labels this requires hacks.
So what hack can we use to prevent that vertically huge problem in gtk3?
The only thing I can think of is to use gtk_label_set_width_chars, which makes you lose the ability to reduce the window width, but you can't do that in gtk2 anyway.
Okay used that in https://github.com/IgnorantGuru/spacefm/commit/3cee75f96b12b75e2a341075d1f112b4125b9717 - thanks
Please see the difference when running the following command under gtk2 vs gtk3. In my theme at least, under gtk3 the --compact options seems to have no effect on the drop-down lists, and the labels are vertical with wrap at 1 char.