Development/Tutorials/Plasma/PackageStructure

< Development‎ | Tutorials‎ | Plasma
Revision as of 08:43, 17 March 2011 by Hf.farhad (Talk | contribs)

Jump to: navigation, search

Contents

Abstract

PackageStructure defines what is in a Package. This information is used to create packages and provides a way to programatically refer to the contents. It's also used to provide an installation profile for you Packages.

The plasmapkg

This tool is used to get information about Packages and install, remove or upgrade them. Run plasmapkg --help to get a list of available options.

The Code

The Desktop File

Every PackageStructure needs a desktop file to tell plasma what package it's defining: plasma-packagestructure-test.desktop [Desktop Entry] Name=Test Comment=Test Package Structure Type=Service

X-KDE-ServiceTypes=Plasma/PackageStructure X-KDE-PluginInfo-Name=Plasma/Test X-KDE-Library=plasma_packagestructure_test

X-KDE-PluginInfo-Author=Farhad Hedayati Fard X-KDE-PluginInfo-Email=hf.farhad@gmail.com X-KDE-PluginInfo-Name=test X-KDE-PluginInfo-Version=0.1 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-License=GPLv3+ X-KDE-PluginInfo-EnabledByDefault=true X-Plasma-PackageFileFilter=*.test X-Plasma-PackageFileMimetypes=application/zip The most important fields are:

  • Name, Comment and Type fields, which are required for all desktop files.
  • X-KDE-ServiceTypes field which tells plasma that this is a PackageStructure
  • X-KDE-PluginInfo-Name field which should be identical to the name used in your code (discussed later).
  • X-KDE-Library field which tells plasma how to load/install the packages with this package structure.
  • X-KDE-PluginInfo-Name field which should be identical to the name of dataengine/plasmoid that uses this PackageStructure.

The Header File

testpackage.h

  1. ifndef TESTPACKAGE_H
  2. define TESTPACKAGE_H

// We need this header since we are inheriting it

  1. include <plasma/packagestructure.h>

/**

This PackageStructe provides an structure for packages used by the test 
DataEngine.
  • /

class TestPackage : public Plasma::PackageStructure { public:

 // Every PackageStructure needs an explicit constructor with these arguments 
 explicit TestPackage( QObject *parent = 0, const QVariantList& args = QVariantList() );

};

  1. endif // TESTPACKAGE_H


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal