April 20, 2010 6

Universal Apps

In Pardus Corporate we use KDE 3.5.10 and some of our new tools from Pardus 2009 which runs KDE 4.3.5 (for now). Tools in 2009 are designed to work with the current desktop environment which is KDE 4.3.5. So, we have a problem in Pardus Corporate side; we need kdelibs4 on KDE 3.5.10. It is possible to use kdelibs4 but in some ways it is not a great idea.

We think that we can create a solution for making universal apps which run on KDE 4.x with kdelibs4 and for others (kde3.5, xfce etc.) which use Qt libs.

Most of the code in our applications just depends on Qt 4.x, but some important parts for the desktop integration depends on KDE.

Basics of desktop integration

  1. Icons
  2. Colors
  3. Fonts
  4. Language Selection
  5. Translations
  6. Notifications

I started with KIconLoader port for Qt, which I have found the C++ version on this blog entry and ported it to Python from scratch. For colors, fonts or language selection it is enough to read the user’s kdeglobals files. Notifications are handled by PyNotify on Qt-Only mode… When things started to grow up I decided to merge them under the name of Pardus Desktop Services (Pds).

Example Usage of Pds

>> import pds
>> desktop = pds.Pds()
>> desktop.session.Name
>> desktop.session.Version
>> desktop.config_file
>> desktop.settings('Icons/Theme', 'default')

Other Classes

PDS also provides the following classes;

QIconLoader – for icon loading from current desktop settings (Kde 4, Kde 3.5, Xfce ..)

QUniqueApplication – for creating a unique application like KUniqueApplication. It also provides sending commands to running instances through QLocalServer.

I18n – Pds uses Gettext for translations and supports the kdelibs’ i18n-like parameters such as (%1, %2).

Notification – Uses PyNotify if it’s installed otherwise it uses QSystemTrayIcon balloon message.

worth a thousand words..

The following example shows two running Package-Manager instances; first one is running as a KUniqueApplication on Kde 4.4 provided by kdelibs4 and the second one is running as a QUniqueApplication which is provided by Pardus Desktop Services on Kde 3.5. Same application, same features, one code..

You can checkout source code of Pds from here and you may have a look at the package-manager fork for an example usage of Pds.

Tags: ,

  • tanguy

    “QUniqueApplication – for creating a unique application”

    Don’t re-invent the whell, check Qt4 Solutions: http://qt.nokia.com/products/appdev/add-on-products/catalog/4
    See QtSingleApplication http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtsingleapplication/

  • http://www.ratonred.com Gökmen Göksel

    First of all I already know the Qt solution for it, but if you look at source of Pds QUniqueApplication; its just 78 lines of code and its in Python not C++. So, the solution from Qt is not proper for us. Means we needed to find another solution not re-inventing the wheel.


  • guy

    Nice to see some Pardus related posts, hasnt been much news lately.

  • http://www.tigen.org/kevin.kofler/ Kevin Kofler

    It won’t matter for your Pardus-specific tools, but in case anyone wants to use this for cross-distro software, be warned that some hardcoded settings are not correct for all distros, e.g. KDE 4 settings are not always in ~/.kde4: the upstream default, as well as the setup on Fedora, Kubuntu (Intrepid or newer, the Hardy KDE 4 remix was special), Debian and several other distros is to share ~/.kde between KDE 3 and 4 apps (but some other distros such as openSUSE also use ~/.kde4).

  • http://www.ratonred.com Gökmen Göksel

    I just take care of Pardus settings for KDE 3.x and 4.x and I will add some information to README file about that. If someone helps from other distros we can make it work with others as well. In PDS code there is a file named environments.py which stores all desktop specific informations that you talk about.

  • Pingback: Pardus 2011 Beta with new Package Manager « rat on red()