Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 388551

Summary: dev-qt/qtgui should export GTK2_RC_FILES when USE="gtkstyle" is enabled
Product: Gentoo Linux Reporter: Brad Laue <brad>
Component: Current packagesAssignee: Qt Bug Alias <qt>
Status: RESOLVED FIXED    
Severity: normal CC: gnome
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=491226
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: qtgui-gtk2rc.patch

Description Brad Laue 2011-10-26 14:10:40 UTC
QT 4.7 relies on libgnomeui 2.x in order to conform to the current GTK theme. If USE="gtkstyle' is used and libgnomeui is not present on the system (possible with fresh installs using GNOME3 or other), QT  will not match the current GTK theme.

This is not a build dependency - installing libgnomeui after the fact corrects the problem.

Reproducible: Always
Comment 1 Rafał Mużyło 2011-10-26 16:18:48 UTC
qt4 checks *only* for 'gtk+-2.0 ">=" 2.10 atk gobject-2.0' and only uses libs from gobject-2.0.

But the problem lies actually in src/gui/styles/qgtkstyle_p.cpp (and a couple other):
- it dlopens (more or less) libgtk-x11-2.0.so.0
- then it checks GTK2_RC_FILES env var, if it's unset - falls back to /desktop/gnome/interface/gtk_theme gconf key (which it dlopens to) (it checks few other gconf keys too, but this is the only, that really matters)
- finally, to make things really ugly, it dlopens libgnomeui-2 and libgnomevfs-2 to determine filesystem icons (though it seems this step can safely fail without affecting the rest of the theme)

Given the state of libgnomeui and gnome-vfs, I think the solution would be to find more recent api equivalents - actually, only gnome_icon_lookup_sync seems to matter, as gnome_vfs_init seems to be called only for the sake of the former.
Comment 2 Davide Pesavento gentoo-dev 2012-01-18 13:17:04 UTC
Additionally, since version 4.8.0, Qt reads font hinting settings from GConf if it's available.
Comment 3 Rafał Mużyło 2012-01-19 07:26:21 UTC
(In reply to comment #2)
> Additionally, since version 4.8.0, Qt reads font hinting settings from GConf if
> it's available.

...right in time for GConf going out of style (even if certain gsettings specifics are quite a bother)...
:sigh:

As my first comment says, this is an upstream problem of using obsolete tools.
While a few Gnome programs still use GConf, those libs are simply dead.
Comment 4 Ben de Groot (RETIRED) gentoo-dev 2012-07-13 11:13:28 UTC
+  13 Jul 2012; Ben de Groot <yngwin@gentoo.org> qt-gui-4.7.4-r1.ebuild,
+  qt-gui-4.8.1-r1.ebuild, qt-gui-4.8.2.ebuild:
+  Add elog message to inform users about how to use gtkstyle, bug #388551

	if use gtkstyle ; then                                              
		# see bug 388551
		elog "For Qt's GTK style to work, you need to either export"
		elog "the following variable into your environment:"
		elog '  GTK2_RC_FILES="$HOME/.gtkrc-2.0"'
		elog "or alternatively install gnome-base/libgnomeui"
	fi
Comment 5 Pacho Ramos gentoo-dev 2012-07-19 19:39:47 UTC
(In reply to comment #4)
> +  13 Jul 2012; Ben de Groot <yngwin@gentoo.org> qt-gui-4.7.4-r1.ebuild,
> +  qt-gui-4.8.1-r1.ebuild, qt-gui-4.8.2.ebuild:
> +  Add elog message to inform users about how to use gtkstyle, bug #388551
> 
> 	if use gtkstyle ; then                                              
> 		# see bug 388551
> 		elog "For Qt's GTK style to work, you need to either export"
> 		elog "the following variable into your environment:"
> 		elog '  GTK2_RC_FILES="$HOME/.gtkrc-2.0"'
> 		elog "or alternatively install gnome-base/libgnomeui"
> 	fi

Is there any reason for not exporting this variable always? (using env.d file I mean)
Comment 6 Ben de Groot (RETIRED) gentoo-dev 2012-09-14 14:26:41 UTC
(In reply to comment #5)
> Is there any reason for not exporting this variable always? (using env.d
> file I mean)

Applied in Qt 4.8.3
Comment 7 Pacho Ramos gentoo-dev 2012-09-14 18:52:26 UTC
Thanks a lot :)
Comment 8 Ben de Groot (RETIRED) gentoo-dev 2012-09-16 04:32:02 UTC
Change reverted because it doesn't work, leading to bug #435054.
Comment 9 Pacho Ramos gentoo-dev 2012-09-16 07:59:45 UTC
(In reply to comment #8)
> Change reverted because it doesn't work, leading to bug #435054.

Per https://bugs.gentoo.org/show_bug.cgi?id=435054#c3 looks like the solution would be to add a simple script exporting that variable into /etc/profile.d, similar to java-config-2.sh, that exports needed variables ;)
Comment 10 Ben de Groot (RETIRED) gentoo-dev 2012-09-16 08:04:59 UTC
patches welcome
Comment 11 Pacho Ramos gentoo-dev 2012-09-16 08:17:10 UTC
(In reply to comment #10)
> patches welcome

Isn't adding a qt-qui.sh script with this:
export GTK2_RC_FILES=${HOME}/.gtkrc-2.0

enough?
Comment 12 Paul Thompson 2012-12-07 09:12:35 UTC
(In reply to comment #4)
> +  13 Jul 2012; Ben de Groot <yngwin@gentoo.org> qt-gui-4.7.4-r1.ebuild,
> +  qt-gui-4.8.1-r1.ebuild, qt-gui-4.8.2.ebuild:
> +  Add elog message to inform users about how to use gtkstyle, bug #388551
> 
> 	if use gtkstyle ; then                                              
> 		# see bug 388551
> 		elog "For Qt's GTK style to work, you need to either export"
> 		elog "the following variable into your environment:"
> 		elog '  GTK2_RC_FILES="$HOME/.gtkrc-2.0"'
> 		elog "or alternatively install gnome-base/libgnomeui"
> 	fi

As mentioned in some other threads out there, and my personal experience,
exporting the variable is not enough in some situations where people do
not have enough gnome infrastructure installed. Installing gnome-base/gconf
and telling it the theme seems to work: (coming from a fvwm user)

gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme MY_THEME
Comment 13 Michael Palimaka (kensington) gentoo-dev 2013-03-11 08:55:27 UTC
Created attachment 341644 [details, diff]
qtgui-gtk2rc.patch

Please review this patch installing 'export GTK2_RC_FILES=${HOME}/.gtkrc-2.0' to /etc/profile.d/qtgui.sh
Comment 14 Pacho Ramos gentoo-dev 2013-06-10 19:36:55 UTC
(In reply to Michael Palimaka (kensington) from comment #13)
> Created attachment 341644 [details, diff] [details, diff]
> qtgui-gtk2rc.patch
> 
> Please review this patch installing 'export
> GTK2_RC_FILES=${HOME}/.gtkrc-2.0' to /etc/profile.d/qtgui.sh

Just tested and it works fine :D

Thanks!
Comment 15 Michael Palimaka (kensington) gentoo-dev 2013-06-11 11:59:08 UTC
Thanks, patch is applied in git and will hit the tree with 4.8.5
Comment 16 Davide Pesavento gentoo-dev 2013-06-11 16:32:30 UTC
(In reply to Michael Palimaka (kensington) from comment #15)
> Thanks, patch is applied in git and will hit the tree with 4.8.5

No more "if use gtkstyle; ... fi" ?
Comment 17 Michael Palimaka (kensington) gentoo-dev 2013-06-11 16:34:14 UTC
(In reply to Davide Pesavento from comment #16)
> No more "if use gtkstyle; ... fi" ?

Do you mean we should only install that file if that USE flag is set?
Comment 18 Davide Pesavento gentoo-dev 2013-06-11 16:49:53 UTC
(In reply to Michael Palimaka (kensington) from comment #17)
> (In reply to Davide Pesavento from comment #16)
> > No more "if use gtkstyle; ... fi" ?
> 
> Do you mean we should only install that file if that USE flag is set?

That's what I mean yes. I guess it's useless if gtkstyle is not built.
Comment 19 Michael Palimaka (kensington) gentoo-dev 2013-06-12 07:46:56 UTC
Good point, fixed in git.
Comment 20 Davide Pesavento gentoo-dev 2013-07-09 11:15:35 UTC
Now in tree with qtgui-4.8.5. Thanks everybody!