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.

iea

12 years ago

Hi,
I just wanted to confirm what MetaMorfoziS and BoknesMonster said regarding firefox crashing. I'm running debian iceweasel 2.0.0.3-1 (which is just a renamed version of firefox - in the case you didn't know) and it (iceweasel alias firefox) also crashes for me if I try to overwrite e.g. a gif file:

foo@bar:~$ /usr/bin/kgtk-wrapper iceweasel
/usr/bin/kgtk-wrapper: line 17: 21807 Segmentation fault LD_PRELOAD=/usr/share/apps/kgtk/libkgtk.so:$LD_PRELOAD "$@"


thanks for the good work,


Tom

Report

bugmenot

12 years ago

Hi,

First thank you for this!

But there is small problem: why the dialogs don't get my language (pt_BR)? There is a way to make them use the default locale?

Report

BoknesMonster

12 years ago

Hi,
This package is now included in Fedora (should be available on all mirrors in a day or so)

So if you are a Fedora user, simply type :

yum install kgtk

to install it.
Thank you very much for this great utility!

Report

MetaMorfoziS

13 years ago

I'm just wanna report some bugs, and if you want, please fix thats.

This bugs with firefox (I'm not tried with other apps)
- If a file that i want to save is exists, it crashes (10/8 times;))
- Sometimes it isn't saves the file, it's just simple not shows up in the download manager etc...

Report

C

CraigD

12 years ago

How odd! What crashes, firefox, or kdialogd? (kdialogd is the KDE daemon that shows the file dialogs).

If the file exists, you should get a message box asking if you want to overwrite it.

Also, what version of firefox?

Report

BoknesMonster

12 years ago

I can confirm this.
After a bit of testing, I've come up with some more detailed information, though:

- firefox crashes, not kdialogd (kdialogd is also still functional after the crash, e.g. other programs can still use it)

- the crash almost ALWAYS happen when trying to overwrite an existing file, HOWEVER:

- the crash seems to be limited to binary files only (e.g. .gif, .jpeg, .tar) - for instance, saving a web page (overwriting an existing .html file) works fine. To test:
1. Go to www.google.com, save the google logo as logo.gif and save the page as google.html
2. Now save the page again, overwriting the google.html - this will work
3. Now save the logo again, overwriting the logo.gif file - this will crash firefox

- this was tested on firefox 1.5.0.9 using kdialogd 0.8

Report

C

CraigD

12 years ago

Nope. Sorry, I still can't reproduce this. Using Firefox 1.5.0.9 on KUbuntu dapper - I can repeatedly save the google logo, and everything's fine.

What locale are you using? Perhaps its an encoding issue?

Report

BoknesMonster

12 years ago

Hi,
Sorry, it's been awhile :-)
I doubt it's encoding (I use en/us mostly).
Here's a gdb dump of the "firefox-bin" process when recreating the problem:

(gdb) continue
Continuing.
[New Thread -1231856752 (LWP 15114)]
[Thread -1231856752 (LWP 15114) exited]
[New Thread -1329382512 (LWP 15125)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208383792 (LWP 14505)]
0x02479326 in gtk_file_chooser_button_new () from /usr/lib/libgtk-x11-2.0.so.0

(gdb) bt
#0 0x02479326 in gtk_file_chooser_button_new () from /usr/lib/libgtk-x11-2.0.so.0
#1 0x02613e19 in gtk_file_system_unix_new () from /usr/lib/libgtk-x11-2.0.so.0
#2 0x02613f38 in gtk_file_system_unix_new () from /usr/lib/libgtk-x11-2.0.so.0
#3 0x008b26e1 in g_source_is_destroyed () from /lib/libglib-2.0.so.0
#4 0x008b4442 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#5 0x008b741f in g_main_context_check () from /lib/libglib-2.0.so.0
#6 0x008b77c9 in g_main_loop_run () from /lib/libglib-2.0.so.0
#7 0x024d74b4 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#8 0x00753f0f in ?? () from /usr/lib/firefox-1.5.0.9/components/libwidget_gtk2.so
#9 0x009a0e96 in ?? () from /usr/lib/firefox-1.5.0.9/components/libtoolkitcomps.so
#10 0x0804f67e in __cxa_pure_virtual ()
#11 0x0804ab90 in __cxa_pure_virtual ()
#12 0x00367f2c in __libc_start_main () from /lib/libc.so.6
#13 0x0804aae1 in __cxa_pure_virtual ()

Some extra info:
----------------
GTK version: 2.10.8
Qt version: 3.3.7
glib version: 2.12.9
firefox: 1.5.0.9
kdelibs: 3.5.6

Running on Fedora Core 6.
And again, thanks for this great application!

Report

MetaMorfoziS

13 years ago

I can't say anything other about this, it's cool.

Report

warriorness

13 years ago

Works fine (gentoo, I just emerged kgtk and did the symlink thing), but sometimes freezes/hangs for a while before opening up. There should be an image preview section in it, like with native KDE apps.

Also, what's with the tiny window that pops up behind the file open dialog?

Report

C

CraigD

13 years ago

The file dialog *is* a standard KDE file dialog - so it should have the image preview. Perhaps you just need to enable it in the file dialog itself?

As for the small window - I create a small Gtk widget so that the Gtk apps wait for this to close. Its very hacky, but works for me. This small window should not be visible though - its moved off the screen, etc. What window manager do you use?

Report

warriorness

12 years ago

I'm using Beryl, actually. Come to think of it, I've never noticed the small window when using Kwin. Any chance of getting a fix for Beryl users?

Report

Karoogoo

13 years ago

Hi
I test kgtk on Gentoo with: media-gfx/inkscape-0.43
works like a charm out of box
simply
cd /usr/local/bin/
ln -s /usr/bin/kgtk-wrapper inkscape

media-gfx/gimp-2.2.12
need modify on /usr/share/applications/gimp-2.2.desktop
change
Exec=gimp-remote-2.2 %U
to
Exec=/usr/bin/kgtk-wrapper gimp-remote-2.2 %U

www-client/mozilla-firefox-2.x do not need kgtk for change filedialog.
http://konquefox.free.fr/index.html (not testet)

Problem with kgtk: The Dialog is allways english :-(
but ist OK, thanks al lot!

Report

Karoogoo

13 years ago

Ok, I test the Firefox setting "ui.allow_platform_file_picker false" now and it was not so good like kgtk!
Better use kgtk IMHO.

Report

Schalken

13 years ago

Is there a chance the SUSE 10.1 RPM will work in OpenSUSE 10.2?

Report

zzzzzz

13 years ago

I would like to try kgtk, but I can't compile it.
My system:
GTK2 2.10.6
KDE 3.4.2
Qt 3.3.3
GCC 3.3.4
linux kernel 2.6.17.4

The configure process is OK.
The make process stops with these errors:

In file included from connect.h:22,
from kgtk.c:62:
../kdialogd/common.h:31: warning: no previous prototype for `getSockName'
In file included from connect.h:22,
from kgtk.c:62:
../kdialogd/common.h:54:18: missing terminating ' character
../kdialogd/common.h:137: warning: no previous prototype for `getLockName'
kgtk.c: In function `kdialogdMain':
kgtk.c:182: warning: initialization from incompatible pointer type
kgtk.c: In function `sendMessage':
kgtk.c:242: warning: passing arg 1 of `gdk_x11_drawable_get_xid' from incompatible pointer type
kgtk.c: In function `isApp':
kgtk.c:421: warning: comparison between signed and unsigned
kgtk.c: In function `kgtkInit':
kgtk.c:450: warning: assignment discards qualifiers from pointer target type
kgtk.c: In function `gtk_init_check':
kgtk.c:616: warning: assignment makes integer from pointer without a cast
kgtk.c: In function `modifyFilter':
kgtk.c:720: warning: implicit declaration of function `tolower'
kgtk.c: In function `getFilters':
kgtk.c:875: warning: declaration of `close' shadows a global declaration
/usr/include/unistd.h:306: warning: shadowed declaration is here
kgtk.c:760: warning: unused parameter `act'
kgtk.c: In function `setFilter':
kgtk.c:899: warning: unused parameter `act'
kgtk.c: In function `removeProtocol':
kgtk.c:1013: warning: initialization discards qualifiers from pointer target type
kgtk.c:1016: warning: assignment discards qualifiers from pointer target type
kgtk.c: In function `gtk_dialog_run':
kgtk.c:1178: warning: passing arg 1 of `kgtk_file_chooser_get_do_overwrite_confirmation' from incompatible pointer type
kgtk.c:1189: warning: passing arg 1 of `kgtk_file_chooser_set_do_overwrite_confirmation' from incompatible pointer type
kgtk.c:1329: warning: return makes integer from pointer without a cast
kgtk.c: In function `gtk_file_chooser_select_filename':
kgtk.c:1382: warning: suggest parentheses around && within ||
kgtk.c: In function `handleGtkFileChooserButtfooed':
kgtk.c:1639: warning: passing arg 1 of `gtk_dialog_run' from incompatible pointer type
kgtk.c:1637: warning: unused parameter `button'
kgtk.c: In function `handleGtkFileChooserComboChanged':
kgtk.c:1658: warning: passing arg 1 of `gtk_dialog_run' from incompatible pointer type
kgtk.c: At top level:
kgtk.c:1772: warning: no previous prototype for `kgtk_g_module_check_init'
kgtk.c: In function `kgtk_g_module_check_init':
kgtk.c:1771: warning: unused parameter `module'
kgtk.c: At top level:
kgtk.c:1777: warning: `struct PR_LoadLibrary' declared inside parameter list
kgtk.c:1777: warning: its scope is only this definition or declaration, which is probably not what you want
kgtk.c:1778: warning: no previous prototype for `PR_FindFunctionSymbol'
make[2]: *** [kgtk.lo] Error 1
make[2]: Leaving directory `/home/stefano/download/kgtk-0.8/gtk'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/stefano/download/kgtk-0.8'
make: *** [all] Error 2

Any hint appreciated. Thanks.

Report

zzzzzz

13 years ago

Solved. I removed the ' character from common.h. Then I added #include to common.h, because compilation gave me a new error on missing "time" declaration.

Report

zzzzzz

13 years ago

#include time.h

Report

angrkeyboarder

13 years ago

"firefox-gnome-support" package (in Debian, Ubuntu and possibly others)?

I've not tried your program yet, because I wonder if it would conflict with the above mentioned package.

I use both KDE and GNOME and ideally would like FireFox to integrate with both.

Report

StefanT

13 years ago

Thanks for the nice program. Especially in GIMP the file dialog bugged me several times.

Find a Kubuntu Edgy (6.10) package for AMD64 here:

http://members.inode.at/499177/software/kubuntu/kgtk_0.8-1_amd64.deb

Report

gassauer

13 years ago

version 0.8
ERROR: ld.so: object '/daten/kdesvn/kde35/share/apps/kgtk/libkgtk.so' from LD_PRELOAD cannot be preloaded: ignored.

just a guess - does/should it work on 64bit systems?

Report

StefanT

13 years ago

Works here fine on Kubuntu 64bit.
Maybe either kgtk or the program you tried to start are 32bit ?

Report

rmn

13 years ago

hi,

there're several problems during compilation.

kde 3.3.2, qt 3.3.4, g++ 3.3.5

-- issue #1 --
kdialogd/common.h, line 54
I've had to remove ' character in you comment line to force compilation.

-- issue #2 --
kdialogd/kdialogd.cpp, line 428
KWin::setMainWindow() method is present since version 3.4. It's better to find a workaround for older versions of kde. I've just comment out this line (I don't know better solution).

-- issue #3 --
kdialogd/kdialogd.cpp, line 549
KMessageBox::Notify|KMessageBox::PlainCaption
I've removed `|KMessageBox::PlainCaption'. It seems that it works only in kde 3.4.

-- issue #4 --
there was a linking problem with libXext library after 'Making all in qt' (a location of this library in my system: /usr/X11R6/lib/libXext.so). I've edit LD_FLAGS in kgtk-0.8/qt/Makefile to define path to the library.

Report

C

CraigD

13 years ago

1 - how odd! That's got to be a compiler bug, anyway will fix for 0.9
2 - ok, will fix in 0.9. for now, just remove the #define USE_KWIN
3 - ok, again will fix
4 - not sure about how to fix this...

Thanks for reporting this - I'll try to do a 0.9 release soonish...

Report

8an

13 years ago

I can't get it to work with Audacity 1.3b. The dialog appears, but when I select some file or close it, Audacity freezes (UI redraws, but I can't click anywhere).

$ kgtk-wrapper.sh audacity
KGTK::gtk_init_check
true
KGTK::APP audacity
KGTK::gtk_file_chooser_dialog_new
KGTK::lookupHash 86BC830
KGTK::lookupHash 86BC830
KGTK::gtk_file_chooser_set_current_folder /home/8an/Documents 0
KGTK::gtk_widget_show GtkFileChooserDialog 1
KGTK::gtk_dialog_run
KGTK::lookupHash 86BC830
KGTK::sendMessage
KGTK::RETURN RESP:-6
KGTK::gtk_widget_hide GtkFileChooserDialog 1

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 3