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.

KuramuHasukaru

10 years ago

Having Kde dialogs instead of the ugly Gtk dialogs would be great, but sadly, I can't compile it :(

I'm using the latest Kde 4.3.2 and Qt 4.5.3, and below is the output I get. For whatever odd reason, it seems to be unable to find Qt 4 and Kde 4:

$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DKGTK_KDE4=true -DKGTK_QT4=true -DKGTK_GTK2=false -DLIB_SUFFIX=64
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for getpeereid
-- Looking for getpeereid - not found
** INFORMATION: Compiling Qt4/KDE4, Qt3/KDE3 disabled
-- Found Automoc4: /usr/bin/automoc4
-- Found Perl: /usr/bin/perl
-- KDE4 not found, because Qt4 was not found
** ERROR : Could not locate Qt4/KDE4 headers, KDialogD for KDE4 will not be built.
** ERROR : Could not locate Qt4 headers, Qt4 LD_PRELOAD library will not be built.
** INFORMATION: Using installation prefix: /usr
-- Configuring done
-- Generating done

Report

crissi

10 years ago

Hello,

I have problems with 0.10.0 and 0.10.1. Kdialogd crashes.

But after a whiole searching I found a workaround:

0.9.4 works without crash.
http://www.filewatcher.com/m/KGtk-0.9.4.tar.bz2.42300.0.0.html

If I have time, i'll look into the code of 0.10.1 later.

Report

warnec

10 years ago

Hi. Abgx360gui is a tool to verify Xbox 360 game backups to see if they are safe to play online. It works well when I start it with "kgtk-wrapper abgx360gui" and I have the file selection dialog from kde4, but after I open it, and then close it, I can not close abgx360gui normallly using the cross in the window tab, but must use Ctlr+C in the Konsole window. When I open it using kgtk and DON't open file dialog, just open the main window, it closes fine.

Notes displayed in Konsole after opening file chooser:


(abgx360gui:8515): Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed

(abgx360gui:8515): Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed

then, when I close the file chooser using "X" in the tab bar:

(abgx360gui:8515): Gdk-CRITICAL **: gdk_x11_atom_to_xatom_for_display: assertion `atom != GDK_NONE' failed

(abgx360gui:8515): Gdk-CRITICAL **: gdk_window_set_modal_hint: assertion `GDK_IS_WINDOW (window)' failed


And only KeyboardInterrupt works to close it.


Report

Dropknee

10 years ago

I install the .deb file from the PPA repo and follow the mirzad step and work great.

Im in Ubuntu with KDE 4.3 installed from the Kubuntu repo.

Report

qqqqqqqqq9

10 years ago

Hi,
if i use kgtk as the user who started the kde-session everything works fine. if i use a different user the fileopen dialog crashes.

Report

9

YAFU

10 years ago

Hello. I have Kubuntu 9.04 64bit and KDE 4.3 with Compiz. Kgtk from launchpad repository.
When I open a KDE file dialog in GTK app, the dialog is not opened to the front and GTK app loses focus, while others opened apps are brought to the front.
In Compiz Settings, "general options" > "Focus & Raice Behaviour" turning off "focus-prevention-level" the situation improves, but only sometimes.
Do you know a setting on Compiz or other way to solve this problem?
Thanks!

Report

Pafrape

10 years ago

Despite all my efforts to install kgtk on Kubuntu 9.04, it does not work.
More specifically, is that kdialogd4 plant each time. This is what KDialog Daemon says:

Application: KDialog Daemon (kdialogd4), signal: Segmentation fault
[KCrash Handler]
#6 0xb6692dec in ?? () from /lib/tls/i686/cmov/libc.so.6
#7 0xb6694b8d in ?? () from /lib/tls/i686/cmov/libc.so.6
#8 0xb66969c5 in malloc () from /lib/tls/i686/cmov/libc.so.6
#9 0xb6875f47 in operator new () from /usr/lib/libstdc++.so.6
#10 0xb687608d in operator new[] () from /usr/lib/libstdc++.so.6
#11 0xb681a8e3 in std::basic_filebuf::_M_allocate_internal_buffer () from /usr/lib/libstdc++.so.6
#12 0xb681c0a2 in std::basic_filebuf::open () from /usr/lib/libstdc++.so.6
#13 0x0804ebeb in _start ()


However, sometimes, but it's very rare that kgtk works, and there is happiness.

That is unfortunate, because I'm computer trainer in my company and I wish I could convince my colleagues to switch to linux, specifically on kde4. Unfortunately, once they see the dialog box instead of gtk kde4, they tell me that linux is not yet mature, because the dialog boxes are not the same as logiciles used.
It is a pity, because it's really the only thing which put off a lot, and I understand.

Thank you in advance for your help so that I can really make the promotion of linux (especially KDE) with a single dialog box regardless of the applications.

Report

mirzaD

10 years ago

there is an excellent repository for kgtk and kubuntu

https://launchpad.net/~kgtk/+archive/ppa

after installing those packages everything seems to work...

try it and let me know

Report

Pafrape

10 years ago

After compiling kgtk, it did not work.
So I decided to install kgtk via launchpad, but the result is always the same: kgtk does not work with kde4, at least for me. I think there is a communication problem with kdialog as kdialogd4 spits since its inception.
I tried reinstalling linux completely, but without effect.
I think it would be sufficient to some changes in kgtk so that it works properly, but unfortunately nobody has been able to bring me a solution.

Report

mirzaD

10 years ago

Kkgtk works with kde4 for me. Here are 'detailed' instructions for kubuntu jaunty:
-Add folowing repository to the /etc/apt/sources.list :
deb http://ppa.launchpad.net/kgtk/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/kgtk/ppa/ubuntu jaunty main

-Install following packages:
- kgtk
- kgtk-base
- kgtk-config-firefox
- kgtk-gtk
- kgtk-qt3
- kgtk-qt4
here is a screenshot:
http://img256.imageshack.us/img256/6875/plasmadesktopoz4804.jpg

- There are more scripts available for different programs but i installed only these.

- To start Firefox with kgtk write:
kgtk2-wrapper firefox

- If this works, open menu editor (right click on kicker(start) icon and choose Menu Editor)
replace firefox command with this:
kgtk2-wrapper firefox %u

and do the same in default application section of system settings.

With this firefox will always start with kgtk wrapper.
-------------------------------
I want to help you because it is a shame not to use this with kde. I was so happy when I figured this out, because i had a bug with gtk file picker and it kept crashing gtk applications.

If you have any more questions please ask them. Also read the README file in source archive, it explains a lot.

Report

Pafrape

10 years ago

That is exactly what I did, on multiple PC and the result is always the same.
For against, I made an installation with kubuntu alternate and not conventional.
With that version as you do your installation?

Report

lumpy211

10 years ago

I noticed there were a few other comments about this, but no prescribed solution. I'm running KDEmod 3 (Arch Linux) and kgtk 0.10.0 from my distro's repository. I've got Swiftweasel (essentially optimized Firefox) running and KGTK works great, with the exception that whenever a file dialog is opened the window loses focus. This is the only thing that's really keeping me from wanting to use Firefox in a KDE environment, and it happens with GIMP too. Any ideas how to fix? Does 0.10.1 fix this?

Also, I'm using 0.10.0 because it works with KDE 3 dialogs. Will upgrading to 0.10.1 remove this ability?

Thanks.

Report

lumpy211

10 years ago

After playing around for a bit, I've found out that it depends on whether or not Compiz Fusion is running. Without it, the dialogs open fine. With it, however, the app in question loses its focus. I tried fooling around with QWidget::raise() and QWidget::setActiveWindow() to no avail. Disabling the focus-stealing capabilities of Compiz also has no effect. Still looking for a solution, I'll post back if I find one.

Report

Camberwell

10 years ago

Hello there,

I'm experiencing this apps losing focus with compiz

however I seem to have found a quick fix

in compiz settings goto...

General Options->Focus and Raise Behaviour

then in the "Focus Prevention Windows" box put...

(any) & !(class=Kdialogd4)

this fixes it for me, well in firefox and thunderbird anyway.

Report

lumpy211

10 years ago

So reading the readme (I should have done that first! :) ) I was able to compile 0.10.1 with KDE3 support. This still doesn't fix it, so I'd still like to hear any suggestions if there are any.

Report

dotancohen

10 years ago

I see that this app was last updatedin March 2009, but the readme still references Firefox <=1.5 only, so I have my doubts as to the accuracy of the rest of the information. What apps are known to work, and more importantly, what apps are still known to be problematic? Does Abiword work yet?

Furthermore, I have been STFW for a 32-bit KDE-4 Ubuntu deb file of this, but cannot find one. Does anyone know where to find such a beast?

Thanks!

Report

Muzer

10 years ago

By the way, someone might be interested in this:

To apply it to all GTK apps (but don't apply it twice if one already has it applied), run this as root (sudo bash):

for f in `find /usr/share/applications`; do if [ "`grep Categories.*GTK $f`" != "" ] && [ "`grep kgtk-wrapper $f`" = "" ]; then sed -i s/Exec\=/Exec\=kgtk-wrapper\ / $f; fi; done

You may wish to add this to /etc/rc.local (to make it run on boot) and run it manually after installing an application or performing an upgrade. It should be perfectly safe (as long as I haven't made a typo typing it out...)

Report

Muzer

10 years ago

By the way, someone might be interested in this:

To apply it to all GTK apps (but don't apply it twice if one already has it applied), run this as root (sudo bash):

for f in `find /usr/share/applications`; do if [ "`grep Categories.*GTK $f`" != "" ] && [ "`grep kgtk-wrapper $f`" = "" ]; then sed -i s/Exec\=/Exec\=kgtk-wrapper\ / $f; fi; done

You may wish to add this to /etc/rc.local (to make it run on boot) and run it manually after installing an application or performing an upgrade. It should be perfectly safe (as long as I haven't made a typo typing it out...)

Report

Muzer

10 years ago

Unfortunately, when opera is run under the wrapper, opening files and directories you download seems to break (I added Default File Handler=kde-open ,1
Default Directory Handler=kde-open ,1

to ~/.opera/filehandler.ini to make it use KDE file associations)

Any chance this could be fixed?

Thanks,

Muzer.


PS: Why is the build so complicated? Why is it not possible to build the gtk2, qt3 and qt4 libs at the same time, as building the KDE4 kdialogd? That's what most people would use.

Report

Muzer

10 years ago

OK, I managed to make a REALLY UGLY workaround. It's really ugly, but it works perfectly. Here is how I did it:

As root, use your favourite text editor to create the file /usr/bin/opera-opend :

kdesudo kate /usr/bin/opera-opend

Copy and paste this into it:

#!/bin/bash

# Hack to get real file associations and KDE file dialogues at the same time.
rm /tmp/opera-open
while [ 1 ]; do
if [ -f /tmp/opera-open ]; then
kde-open "`cat /tmp/opera-open`" &
sleep 1
rm /tmp/opera-open
fi
done



Save the file and exit.

Now, do the same with opera-open (but with different text, obviously):

kdesudo kate /usr/bin/opera-open

With this text:

#!/bin/bash

# Client for opera-opend
echo "`date` Started!" >> /var/log/opera
while [ -f /tmp/opera-open ]; do
echo "`date` File in use..." >> /var/log/opera
sleep 3
done
echo -n "$*" > /tmp/opera-open
echo "`date` Success! File contents is `cat /tmp/opera-open`"



(note that I did a bit of debug logging here. You might want to remove the lines starting with echo, otherwise the log will gradually increase in size until it is massive)

Save the file and exit.

Make both files executable:

sudo chmod +x /usr/bin/opera-open*

Add opera-opend to your autostart:
(for KDE4, other DMs will vary):

ln -sv /usr/bin/opera-opend ~/.kde/Autostart/

(important note: This MUST be run as a normal user, NOT root. Therefore, do NOT put it in /etc/rc.local or another file that gets run as root rather than a normal user)

Start the daemon for the current session only (future sessions it will automatically start, which is what we did above):

opera-opend 2>/dev/null &

Create and edit the filehandler.ini file:

kate ~/.opera/filehandler.ini

Add this contents and save and exit:

Opera Preferences version 2.1
; Do not edit this file while Opera is running
; This file is stored in UTF-8 encoding

[Settings]
Default File Handler=opera-open ,1
Default Directory Handler=opera-open ,1


Close Opera.

Modify Opera's .desktop file so that it starts with kgtk-wrapper:

kdesudo kate /usr/share/applications/opera.desktop

Edit this line:

Exec=opera %u


To read:

Exec=kgtk-wrapper opera %u


Save and exit. Start Opera. Make sure everything works: Try the open and save dialogues to make sure they are KDE4. Go to your transfers and try opening on of the files (you might have to do right click --> open with --> opera-open if it doesn't work), and one of the directories (right click --> Open Folder)

Success! (Hopefully).

Report

adolf102

10 years ago

In case it will help someone here is how i can run it with Thunderbrid:

/opt/thunderbird2$ ./run-mozilla.sh /usr/bin/kgtk-wrapper ./thunderbird-bin

Report

adolf102

11 years ago

Great idea and works well too!

Thanks!

Report

Pafrape

11 years ago

Hello,

I'm trying desperately to compile kgtk to install, but I can not.
I tried to do what is in the "readme", but without result.
Could you tell me the exact lines and actions that you have done to compile and install kgtk.

I'm on Linux only recently.
What distribution and what version you?
I'm on Kubuntu jaunty.
Thank you for your help because I feel like you kgtk fantastic if it can be installed.

Report

radn

11 years ago

On 64bit architecture (Fedora 11 Pre1) kgtk doesn't work at all. It writes this error to the console:

ERROR: ld.so: object '/usr/lib/kgtk/libkgtk2.so' from LD_PRELOAD cannot be preloaded: ignored.

So I figured out a patch here:
http://www.stud.fit.vutbr.cz/~xnovac06/fedora/kgtk-0.10.1-cmake.patch

Report

SpectrumDT

11 years ago

Dear CraigD.

KGtk is a great program. I have one bug report: I am running Fedora Core 10. When installing KGtk from the repositories (sudo yum install kgtk), it only gets built for Qt4, so if I want it to work for Qt3 applications (such as Opera), I have to build it for Qt3 manually from source.

If you believe fixing this is not your responsibility, please advise me on where I should go to report it instead.

Thanks in advance.

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
1
mediaviews 24h 0
pageviews 24h 21