Project

General

Profile

Bug #853912

Gtk3 detachable widget handles are too large with recent Gtk

Added by Jacob Nevins 7 months ago. Updated 5 months ago.

Status:
In Progress
Priority:
Normal
Assignee:
Category:
gui-gtk-3
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Split out from bug #693382:

The vertical handles which allow you to detach UI components are far too wide, with recent Gtk3. An example is attached to that bug. In that screenshot they were 34px wide. On my Debian buster system (Gtk 3.24.5) they are 36px wide. In comparison, gui-gtk2 on the same system has them 8px wide, which is reasonable.

Bug #693382 indicates this changed some time between 3.10.8 and 3.22.16.

m-gtk3-huge-detach-handles.patch (4.63 KB) m-gtk3-huge-detach-handles.patch Jacob Nevins, 2019-12-26 05:50 PM
30-26-gtk3-huge-detach-handles.patch (3.22 KB) 30-26-gtk3-huge-detach-handles.patch Jacob Nevins, 2019-12-26 05:50 PM
Screenshot #853912.png (38.5 KB) Screenshot #853912.png Marko Lindqvist, 2019-12-26 07:34 PM
Screenshot #853912 Xenial, before.png (129 KB) Screenshot #853912 Xenial, before.png Marko Lindqvist, 2019-12-26 08:01 PM
Screenshot #853912 Xenial, after.png (103 KB) Screenshot #853912 Xenial, after.png Marko Lindqvist, 2019-12-26 08:01 PM
m-gtk3-huge-detach-handles-bis.patch (4.63 KB) m-gtk3-huge-detach-handles-bis.patch revised master patch addressing comment 15 Jacob Nevins, 2019-12-27 10:17 AM
m-30-26-gtk30-huge-detach-handles.patch (1.87 KB) m-30-26-gtk30-huge-detach-handles.patch Jacob Nevins, 2019-12-27 04:46 PM

Related issues

Related to Freeciv - Bug #854002: Gtk3.22/4 detachable widget handles are too largeClosed

Blocks Freeciv - Bug #693382: Gtk3/3.22 theme is not good with recent Gtk3New

History

#1 Updated by Jacob Nevins 7 months ago

  • Blocks Bug #693382: Gtk3/3.22 theme is not good with recent Gtk3 added

#2 Updated by Jacob Nevins 7 months ago

As far as I can tell, these handles are just GtkToggleButtons, without anything particularly special for theming engines to select on. (In Gtk2 and Gtk3.)

On my system, I can get them a bit smaller by hacking with the CSS: if I start
GTK_DEBUG=interactive inst/bin/freeciv-gtk3
and then enter this hack on the "CSS" tab of the debug window:
button.toggle { padding: 0px 0px 0px 0px; }
I can get them down from 36px to 18px wide. Reducing "margin" (space outside control) to 0px makes no difference. Reducing "border-width" to 0px only saves a couple of pixels. "Objects" tab doesn't show any interesting objects inside the GtkToggleButton.

#3 Updated by Jacob Nevins 7 months ago

I notice that data/themes/gui-gtk-3.0/Freeciv/gtk-3.0/gtk.css is setting these:

-GtkButton-default-border: 1;
-GtkButton-default-outside-border: 2;

But the Gtk3 docs say they

...been deprecated since version 3.14 and should not be used in newly-written code.
Use CSS margins and padding instead; the value of this style property is ignored.

And indeed with my Gtk3.24.5 I get these runtime warnings (among many others):

(freeciv-gtk3:12531): Gtk-WARNING **: 15:59:37.988: Theme parsing error: gtk.css:5:29: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version

(freeciv-gtk3:12531): Gtk-WARNING **: 15:59:37.988: Theme parsing error: gtk.css:6:37: The style property GtkButton:default-outside-border is deprecated and shouldn't be used anymore. It will be removed in a future version

I wonder if this has anything to do with the behaviour difference between old and new Gtk libraries -- perhaps we were somehow relying on these properties and they are no longer doing anything?

#4 Updated by Jacob Nevins 7 months ago

Modifying my CSS hackery to

button.toggle { padding: 0px 0px 0px 0px; min-width:6px; }

gets me controls that are 8px wide, including the border.

I think the way to productionise this is probably to put some special selectable property on the button created by detached_widget_fill(), and attach the above style to it in gtk.css.

I no longer have any direct ability to build and test against old Gtk3, so I guess the way to find out how it affects that will be to commit it and test the next msys1 build.

#5 Updated by Jacob Nevins 7 months ago

and attach the above style to it in gtk.css

That doesn't work for people who want to use a system theme. (Also, I can't figure out how to make it work.)

I suspect instead I should add it with some gtk_style_context_add_provider_for_screen() faff, like gui_update_font(). (Hopefully that will be overrideable with themes if anyone cares to.)

#6 Updated by Jacob Nevins 7 months ago

  • Category set to gui-gtk-3
  • Status changed from New to In Progress
  • Assignee set to Jacob Nevins

#7 Updated by Jacob Nevins 7 months ago

Any pre-commit testing of this with ancient Gtk3 would be appreciated. (Although at this stage I'm probably content with "not catastrophically worse than before" rather than "looks perfect".)

#8 Updated by Jacob Nevins 7 months ago

With this patch and GTK_DEBUG=interactive, entering this in the debugger CSS tab:

.detach_button {
  min-width: 10px;
}

did cause the detach handles to grow wider again, so I'm reasonably confident that a custom theme could override the embedded CSS if it tried hard enough.

#9 Updated by Marko Lindqvist 7 months ago

Jacob Nevins wrote:

Any pre-commit testing of this with ancient Gtk3 would be appreciated. (Although at this stage I'm probably content with "not catastrophically worse than before" rather than "looks perfect".)

At my Ubuntu Trusty virtual machine handles turned unusable. I don't know if they disappeared completely or are they hidden by the border of the window.

#10 Updated by Marko Lindqvist 7 months ago

Marko Lindqvist wrote:

At my Ubuntu Trusty virtual machine handles turned unusable.

Same with Xenial. From the "before" screenshot you can also see that original issue is not there with gtk+-3.18.9

#11 Updated by Jacob Nevins 7 months ago

  • Status changed from Resolved to In Progress

Oh, dear. Thanks for testing.

From the "before" screenshot you can also see that original issue is not there with gtk+-3.18.9

(handle width is 13-15 pixels or so)

#12 Updated by Jacob Nevins 7 months ago

There's a bunch of stuff in our Gtk3 gtk.css that I can't square with the docs (like .button selector syntax), so I don't know what it's meant to do; and with Gtk 3.24.5 I get a bunch of deprecation warnings about stuff in gtk.css. Perhaps that stuff is being ignored on my system, and not on older systems, and interacts with my new styling in some bad way.

#13 Updated by Jacob Nevins 7 months ago

...if this drags on, perhaps I'll need to split out the Gtk3.22 patch? That should be safe, right?

#14 Updated by Marko Lindqvist 7 months ago

Jacob Nevins wrote:

...if this drags on, perhaps I'll need to split out the Gtk3.22 patch? That should be safe, right?

At least it's promising that Ubuntu Bionic (gtk+-3.22.30) gtk3.22-client works with the patch, though it didn't have the original issue without. So broken "before" state is not a prerequisite for the patched version to work. It seems the patch can be used with both gtk+-3.22 and gtk+-3.24 that are the only versions that gtk3.22-client may use.

#15 Updated by Marko Lindqvist 7 months ago

This causes gtk3x-client compile error.

../../../../src/client/gui-gtk-4.0/gui_main.c: In function ‘detached_widget_fill’:
../../../../src/client/gui-gtk-4.0/gui_main.c:878:5: error: too many arguments to function ‘gtk_css_provider_load_from_data’
878 | gtk_css_provider_load_from_data(detach_button_provider, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#16 Updated by Jacob Nevins 7 months ago

Oops. (Cf feature #647927.) Thanks. Should be fixed in attached patch. (Not currently commit candidate due to Gtk3 issues.)

#17 Updated by Jacob Nevins 7 months ago

  • Related to Bug #854002: Gtk3.22/4 detachable widget handles are too large added

#18 Updated by Jacob Nevins 7 months ago

Revised patch covers just gui-gtk-3.0. It's not a commit candidate because it will still have the same problems with old libraries.

(Of course, investigating why it's bad with older library versions may yet yield a better solution for all Gtk versions.)

#19 Updated by Jacob Nevins 5 months ago

  • Target version changed from 2.6.2 to 2.6.3

I don't have a clear plan for resolving the remaining gtk3-client issue; it's probably going to involve messing around with VMs. I'm certainly not going to get to it for 2.6.2.

Also available in: Atom PDF