KGtk (Use KDE Dialogs in Gtk Apps)

Various KDE 1.-4. Improvements

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

11
Score 76.7%
Description:

This is a quick-and-dirty LD_PRELOAD hack that allows *some* Gtk applications to use KDE's file dialogs when run under KDE.

The Gtk file chooser functions have been overridden to communicate with this KDE module/application.

After compiling and installing this, you can run Gtk applications in 2 ways:

A. call /usr/local/bin/kgtk-wrapper gimp

B. i. Create a symbolic link from the wrapper script to your application, e.g.
ln -s /usr/local/bin/kgtk-wrapper /usr/local/bin/gimp
ii. Make sure /usr/local/bin is before /usr/bin (or wherever gimp is installed) in your $PATH
iii. Now simply run 'gimp' - this should find the wrapper script first.

If this works OK, then edit the .desktop file (e.g. /usr/share/applications/gimp.desktop) to have "Exec=/usr/local/bin/[appname]" instead of "Exec=[appname]", e.g. for gimp.desktop this would be:

Exec=/usr/local/bin/gimp-remote-2.2 %U

or:

Exec=/usr/local/bin/kgtk-wrapper gimp-remote-2.2 %U


So far I have tested this with the following applications:

1. Kino. Works perfectly - in fact Kino was my main reason for doing this.
2. Firefox. Works with Firefox 1.5, but *not* Firefox 1.0.x
3. GIMP. Again, seems to work just fine. However, there is no progress bar on file loading - as GIMP uses a progress bar embedded in the file chooser.
4. Inkscape. Works OK - at least 0.43
5. Streamtuner - the folder browser button works.
6. AbiWord - does *not* work. Don't even try...
7. Glade2. Seems to work OK, however I have had it crash when loading Kino's .glade file, but not always. So I'm not sure if this is Glade's fault, or mine.
8. Eclipse. Will work only if dlsym can be overriden

As the only Gtk apps I use are Kino, GIMP, and a little of Firefox, this library works great for me. Your millage may vary, and please note that this is only a quick hack to get things working now for me. I'm not sure how stable it will be under heavy usage, so don't be surprised if it breaks. However, if it does break - the only thing that should happen is that the Gtk apps will fall back to using the standard Gtk dialogs.


p.s. Before anyone asks, as they always do:
Widget style: QtCurve, works for KDE and Gtk (also does KDE->Gtk icon mapping). This is set on the "Clear" variation.
Window decoration: Crystal with Knifty buttons
Font: Verdana. However, I have recompiled FreeType with the TrueType byte encoder enabled - this give great looking non anti-aliased fonts (otherwise they look *horrible*)
Last changelog:

8 years ago

0.11.0
------
1. Gtk3 support.
2. Better, and safer, lookup of file filters.
3. Correctly determine size of string needed for pidfile!
4. Add thunderbird, and LibreOffice apps, to list of gtk2 apps.
5. Cleanup usless stuff; remove kdialogd3, qt3, qt4, kgtk2-wrapper, kqt3-wrapper, kqt4-wrapper.
6. Merge kgtkXX-wrapper scripts into kgtk-wrapper
7. Install kdialogd4 into KDE4 libexec dir.
8. Fix crash where client is terminated whilst file dialog is open.
9. Configurable debug. Pass cmake -DKGTK_DEBUG=true
When starting app, set KGTK_DEBUG env var, e.g.

KGTK_DEBUG=0x10 kgtk-wrapper lowriter

0x01 Connection debug
0x02 General debug
0x04 Filter get and set debug
0x08 Filter creation debug
0x10 Custom widget debug
0x20 dlsym debug
Values may be combined

10. If LibreOffice is detected (app is libreoffice, lowriter, etc.) then also set the OOO_FORCE_DESKTOP env var to gnome, so that we get nicer
themeing.
11. When passing filters to KFileDialog, replace / with \/
12. Make filter combo non-editable.
13. When returning selected filter to Gtk app, also return the filter name and not just the file pattern. This way if two filters have the same file pattern the corrent one can be selected.
14. Support for checkbox custom widgets.
15. Save location history per app.

insulae

13 years ago

great app, i try in Kubuntu Dapper with KDE 3.5.4 and work perfectly.

i use AVIDEMUX and SYNAPTIC and Work fine to!!

i created a deb package you can find here:
ftp://ftp.insulae.com.ar/tmp/kgtk/kgtk_0.8-1_i386.deb

to run kgtk you must do:
/usr/local/kde/bin/kgtk-wrapper kino

but i created a script in /usr/local/bin/kgtk with:

----------
#!/bin/sh
cd /usr/local/kde/bin/
./kgtk-wrapper $1
----------

now i run only
$: kgtk kino

Regards
insulae

Report

paulatz

13 years ago

I have tryed it with avidemux2 but it doesn't work correctly. What version are you using?

Report

C

CraigD

13 years ago

You could have done:

ln -s /usr/local/kde/bin/kgtk-wrapper /usr/local/bin/kino

Then as long as /usr/local/bin is before the location of the real kino, the kgtk-wrapper version will be called first - ie. just by calling kino

Anyway, glad its working!

Report

deadbabylon

13 years ago

I'm running openbox on FC5 with many kde-apps. Just compile kgtk-0.8 with kdeprefix. In a KDE-Session it works fine with firefox (from mozilla.org) and gimp. But outside KDE it will show the normal gtk-dialogs.
Is this the expected behaviour or is there a solution?

Report

C

CraigD

13 years ago

Yes. KGtk checks for the presence of the KDE_FULL_SESSION environment variable.

The idea being that if you modified an apps .desktop file, then when run from KDE the KDE dialogs would be used, but when run under GNOME the Gtk ones would be used instead. To force the KDE dialogs to be used, sumply set KDE_FULL_SESSION before starting the app.

Report

deadbabylon

13 years ago

mhh. seems not to work. I still have the gtk-dialogs:

$ KDE_FULL_SESSION=true
$ export $KDE_FULL_SESSION
$ kgtk-wrapper firefox

Report

C

CraigD

13 years ago

Well I've just installed IceWM under KUbuntu - and the following works for me:

export KDE_FULL_SESSION=true
kgtk-wrapper gimp

Are you *sure* you're using 0.8? As previous version will *only* work under KDE. Can you try reconfiguring with the --enable-debug-messages parameter?

Report

deadbabylon

13 years ago

Ups, my fault. I had an $ to much. Now it works. Thanks!

Report

CyberFoxx

13 years ago

I'm not sure exactly why this is happening, but for some reason, after cleaning out my /tmp directory (By booting to command line, using lsof to make sure nothing is using /tmp, and rm -rf everything in it.) KGtk has stopped working.

The only clue I can get is this:
kded: ERROR: KDialogD - KDialogD - bind(): 2
kded: ERROR: KDialogD - KDialogD could not create socket

And the apps, like firefox, startup with:
KGTK::gtk_init
true
Could not access socket, /tmp/ksocket-cyberfoxx/kdialogd-1

Thing is, there is no /tmp/ksocket-cyberfoxx. But, if I manually create /tmp/ksocket-cyberfoxx, restart kdialogd via "dcop kded kded unloadModule kdialogd && dcop kded kded loadModule kdialogd" and then start firefox, KGtk works.

I'm using Gentoo and KDE 3.5.4, and I'm not using the ebuild version, I've compiled KGtk from the tarball here. Maybe an earlier version of KDE created /tmp/ksocket-cyberfoxx for me, but now it doesn't seem to need it. Either that, or Gentoo patches KDE to not create it, not sure.

Then again, if that's the case, I haven't seen any bug reports in Gentoo bugzilla about it...

Report

C

CraigD

13 years ago

Please try 0.8 (*after* removing 0.7, and *restarting* KDE). This should create the socket folder if it does not exist.

Report

ezust

13 years ago

I think I am running into a similar problem - it was working great (0.8) for weeks until my upgrade a week ago (debian sid) and now whenever I try to open a KDE file dialog, it just pauses for 20 seconds and then shows me an ugly GTK file dialog :-(

What's mysterious is that when I run it from the console, I can't see any output or error message.

I tried doing a make clean, reconfigure and reinstall but that made no difference.

I tried removing /usr/share/kgtk* and did a reinstall, still no dice.
What is the proper way to uninstall?

Report

queltosh

13 years ago

When i try to launch an application I get this.

$ kgtk-wrapper.sh kino
KGTK::gtk_init
false

I have restarted kded after installing (logout and restart the X system)

What's happend?

I use Debian Sid with kernel 2.6.16-2-686 precompiled and KDE 3.5.4

Report

C

CraigD

13 years ago

With 0.7 - which is what you are using - the "false" is a return value from the DCOP command:

dcop kded kded loadModule kdialogd

Gtk apps called via KGtk will try the call above to load the KDE module required for displaying the file dailogs. "false" implies that either dcop could not talk to KDED, or that KDED could not load the KDialogD part of KGtk.

Is this running under KDE? As 0.7 will only work under KDE. Is KDialogD listed in the "Service Manager" KControl module?

Report

queltosh

13 years ago

Yes i am using KDE. But kdialogd is not listed in "Service Manager". If I "locate" kdialogd files i found:

/usr/local/kde/lib/kde3/kded_kdialogd.la
/usr/local/kde/lib/kde3/kded_kdialogd.so
/usr/local/kde/share/services/kded/kdialogd.desktop

I have reinstall (make clean; ./configure; make;make install) but still not work.

what's happening?

thanks

Report

C

CraigD

13 years ago

You need to install KGtk 0.7 into the *same* prefix as kde. Try

./configure --prefix=`kde-config --prefix`

Report

queltosh

13 years ago

Great!!! it was!!!

When i reinstall i had the same problem of CyberFoxx. But when i restarted KDE all works fine ;-)

Thank you very very much by the help and of course for this great software (i was looking for it years...)

And now....spreading xD

Report

CyberFoxx

13 years ago

Just thought I should mention I'm getting some weird behaviour with KGtk and Firefox (Now Firefox 1.5.0.6, but has been with the last couple Firefox versions too.)

Anyway, when I bring up the save dialog via the right-click context-menu to save an image, if the mouse passes over the image, the right-click context-menu will pop-up again. And, the context-menu won't go away till the save dialog is closed, either by saving or hitting cancel.

This only seems to happen if I try to save an image in a webpage. If I'm viewing the image on it's own, this bug doesn't seem to happen.

This is a great little "hack" and it's sure made using Firefox with KDE alot easier for me. ^_^

Report

C

CraigD

13 years ago

How, odd. I cant reproduce this under Firefox 1.5.0.5 under KUbuntu... Might be because I'm using a newer KGtk version (not released), but not sure if it'd make any difference...

Report

6thpink

13 years ago

I submited an updated ebuild to bugzilla, in hope that the gentoo team will update the one in portage (it's 5.1 right now).

The bug is this, here you can find the ebuild:
http://bugs.gentoo.org/show_bug.cgi?id=142574

I also suggested the addition of the ~amd64 keyword (amd64 unstable), since it works nicely in my amd64 box.

I have only found one little annoyance, nothing too severe though. In gxine, you can use this wrapper and it works great, the only problem is that the gtk dialog is also displayed. Under it (if i move the window to any other location) there is the qt open/save dialog. The gtk one is unresponsive, you can't click on it or interact with it in any way. Only the qt one is "alive". When the qt dialog is over, the gtk one goes away as well.

As I said, nothing too important. I dont use gxine so often either.

Nice work. :)

Report

crissi

13 years ago

I would be very cool if print dialogs could be replaced with kprinter

Anyway: Thanks for the good work!!!

Report

C

CraigD

13 years ago

...yup, I had already thought about that. But it will have to wait for Gtk 2.10 - as that is when gtk gets the print dialog support.

I can't override app specific print dialogs - only those that come from a library (eg. Gtk).

Report

mablanco

13 years ago

As I did with version 0.6, these are my compatibility tests for 0.7:

* Firefox 1.5.0.4: works
* QComicBook 0.2.7: works
* Inkscape 0.44: works
* Scribus 1.2.5: works
* Gimp 2.2.11: works
* Planner 0.14: works, but asks twice for open file

That's all by now. Best regards.

Report

bmarsh

13 years ago

Worked for Firefox. Does not work for Audacity. Just reporting this since Audacity wasn't listed.

Report

C

CraigD

13 years ago

...audacity is a gtk 1.x app, no? In which case its no suprise, as only Gtk 2.x is supported...

Report

csanchisb

13 years ago

I have tried and tried and cannot get the suse rpm, but the php script (download.php).

Report

8 years ago

0.11.0
------
1. Gtk3 support.
2. Better, and safer, lookup of file filters.
3. Correctly determine size of string needed for pidfile!
4. Add thunderbird, and LibreOffice apps, to list of gtk2 apps.
5. Cleanup usless stuff; remove kdialogd3, qt3, qt4, kgtk2-wrapper, kqt3-wrapper, kqt4-wrapper.
6. Merge kgtkXX-wrapper scripts into kgtk-wrapper
7. Install kdialogd4 into KDE4 libexec dir.
8. Fix crash where client is terminated whilst file dialog is open.
9. Configurable debug. Pass cmake -DKGTK_DEBUG=true
When starting app, set KGTK_DEBUG env var, e.g.

KGTK_DEBUG=0x10 kgtk-wrapper lowriter

0x01 Connection debug
0x02 General debug
0x04 Filter get and set debug
0x08 Filter creation debug
0x10 Custom widget debug
0x20 dlsym debug
Values may be combined

10. If LibreOffice is detected (app is libreoffice, lowriter, etc.) then also set the OOO_FORCE_DESKTOP env var to gnome, so that we get nicer
themeing.
11. When passing filters to KFileDialog, replace / with \/
12. Make filter combo non-editable.
13. When returning selected filter to Gtk app, also return the filter name and not just the file pattern. This way if two filters have the same file pattern the corrent one can be selected.
14. Support for checkbox custom widgets.
15. Save location history per app.

12345678910
8
product-maker arcanis Jun 15 2014 9 excellent
product-maker YAFU Sep 26 2012 9 excellent
product-maker frag Sep 20 2012 9 excellent
product-maker dreamsoul Nov 04 2011 9 excellent
product-maker deabru Nov 04 2011 9 excellent
product-maker tcat Jun 20 2011 9 excellent
product-maker unikum111 Apr 25 2011 9 excellent
product-maker ZaWertun Nov 11 2010 9 excellent
product-maker Base: 4 x 5.0 Ratings
deabru
Nov 04 2011
tcat
Jun 20 2011
unikum111
Nov 12 2010
tigerfoot
Mar 07 2010
Raboch
Feb 24 2010
DaiVied
Dec 30 2009
Camberwell
Dec 01 2009
usrkl
Oct 07 2009
-luk-
Feb 23 2009
val-gaav
Feb 23 2009
alecs1
Feb 15 2009
File (click to download) Version Description PackagetypeArchitecture Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
0.11.0
updated Nov 03 2011
added Mar 06 2006
downloads 24h
0
mediaviews 24h 0
pageviews 24h 13