summaryrefslogtreecommitdiffstats
path: root/katapult/plugins/catalogs/programcatalog
diff options
context:
space:
mode:
Diffstat (limited to 'katapult/plugins/catalogs/programcatalog')
-rw-r--r--katapult/plugins/catalogs/programcatalog/Makefile.am15
-rw-r--r--katapult/plugins/catalogs/programcatalog/actionrunprogram.cpp65
-rw-r--r--katapult/plugins/catalogs/programcatalog/actionrunprogram.h44
-rw-r--r--katapult/plugins/catalogs/programcatalog/katapult_programcatalog.desktop43
-rw-r--r--katapult/plugins/catalogs/programcatalog/program.cpp55
-rw-r--r--katapult/plugins/catalogs/programcatalog/program.h48
-rw-r--r--katapult/plugins/catalogs/programcatalog/programcatalog.cpp153
-rw-r--r--katapult/plugins/catalogs/programcatalog/programcatalog.h62
-rw-r--r--katapult/plugins/catalogs/programcatalog/settings.ui101
9 files changed, 586 insertions, 0 deletions
diff --git a/katapult/plugins/catalogs/programcatalog/Makefile.am b/katapult/plugins/catalogs/programcatalog/Makefile.am
new file mode 100644
index 0000000..1e0fdf6
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/Makefile.am
@@ -0,0 +1,15 @@
+# set the include path for X, qt and KDE
+INCLUDES = -I$(top_srcdir)/katapult/common $(all_includes)
+
+# header files
+noinst_HEADERS = programcatalog.h program.h actionrunprogram.h
+
+# our plugin
+kde_module_LTLIBRARIES = katapult_programcatalog.la
+katapult_programcatalog_la_SOURCES = settings.ui programcatalog.cpp program.cpp actionrunprogram.cpp
+katapult_programcatalog_la_LDFLAGS = -module $(KDE_RPATH) $(KDE_PLUGIN) $(all_libraries)
+katapult_programcatalog_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(top_builddir)/katapult/common/libkatapult.la
+kde_services_DATA = katapult_programcatalog.desktop
+
+# use automoc
+METASOURCES = AUTO
diff --git a/katapult/plugins/catalogs/programcatalog/actionrunprogram.cpp b/katapult/plugins/catalogs/programcatalog/actionrunprogram.cpp
new file mode 100644
index 0000000..97ca084
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/actionrunprogram.cpp
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <krun.h>
+#include <kurl.h>
+#include <klocale.h>
+
+#include "program.h"
+#include "katapultitem.h"
+#include "actionrunprogram.h"
+
+ActionRunProgram::ActionRunProgram()
+ : KatapultAction()
+{
+}
+
+
+ActionRunProgram::~ActionRunProgram()
+{
+}
+
+QString ActionRunProgram::text() const
+{
+ return i18n("Run Program");
+}
+
+QPixmap ActionRunProgram::icon(int size) const
+{
+ return KGlobal::iconLoader()->loadIcon("exec", KIcon::NoGroup, size);
+}
+
+void ActionRunProgram::execute(const KatapultItem *item) const
+{
+ if(strcmp(item->className(), "Program") == 0) {
+ const Program *program = (const Program *) item;
+ KService *service = program->service();
+ if(service != 0)
+ KRun::run(*service, KURL::List());
+ //TODO: report error running program
+ }
+}
+
+bool ActionRunProgram::accepts(const KatapultItem *item) const
+{
+ return strcmp(item->className(), "Program") == 0;
+}
diff --git a/katapult/plugins/catalogs/programcatalog/actionrunprogram.h b/katapult/plugins/catalogs/programcatalog/actionrunprogram.h
new file mode 100644
index 0000000..1ee2e30
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/actionrunprogram.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef ACTIONRUNPROGRAM_H
+#define ACTIONRUNPROGRAM_H
+
+#include "katapultaction.h"
+
+class KatapultItem;
+
+/**
+@author Joe Ferris
+*/
+class ActionRunProgram : public KatapultAction
+{
+
+public:
+ ActionRunProgram();
+ ~ActionRunProgram();
+
+ virtual void execute(const KatapultItem *) const;
+ virtual bool accepts(const KatapultItem *) const;
+ virtual QString text() const;
+ virtual QPixmap icon(int) const;
+
+};
+
+#endif
diff --git a/katapult/plugins/catalogs/programcatalog/katapult_programcatalog.desktop b/katapult/plugins/catalogs/programcatalog/katapult_programcatalog.desktop
new file mode 100644
index 0000000..cf45514
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/katapult_programcatalog.desktop
@@ -0,0 +1,43 @@
+[Desktop Entry]
+Name=Program Catalog
+Name[ar]=مستعرض البرامج ( Program Catalog )
+Name[bg]=Каталог с програми
+Name[br]=Katalog program
+Name[da]=Katalogisér program
+Name[de]=Programm-Katalog
+Name[el]=Κατάλογος προγραμμάτων
+Name[es]=Catalogador de programas
+Name[et]=Programmikataloog
+Name[fr]=Catalogue des programmes
+Name[gl]=Catálogo de Programas
+Name[it]=Catalogo programmi
+Name[ja]=プログラムカタログ
+Name[nb]=Programkatalog
+Name[nl]=Programmacatalogus
+Name[pt]=Catálogo do Programa
+Name[pt_BR]=Catálogo de Programa
+Name[sv]=Katalogisera program
+Name[tr]=Program Kataloğu
+Name[uk]=Каталог програм
+Comment=Catalogs your KDE programs for easy launching through Katapult
+Comment[ar]=يستعرض برامجك كي دي أي ( KDE ) كي تستطيع اقلاعها بسهولة مستخدما Katapult
+Comment[bg]=Каталогизира с Katapult програмите в KDE за лесно стартиране
+Comment[da]=Katalogiserer dine KDE-programmer for nem start via Katapult
+Comment[de]=Katalogisiert Ihre KDE-Programme, um sie bequem mit Katapult zu starten
+Comment[el]=Δημιουργεί κατάλογο των προγραμμάτων σας του KDE για την εύκολη εκτέλεσή τους μέσω του Katapult
+Comment[es]=Cataloga sus programas de KDE para iniciarlos con facilidad a través de Katapult
+Comment[et]=Kataloogib sinu KDE programmid hõlpsaks käivitamiseks Katapultiga
+Comment[fr]=Cataloguer vos programmes KDE pour un lancement facile via Katapult
+Comment[gl]=Cataloga os seus programas de KDE para seren iniciados mediante Katapult
+Comment[it]=Cataloga in tuoi programmi KDE per avviarli facilmente attraverso Katapult
+Comment[ja]=Katapult から簡単に起動できるように KDE のプログラムをカタログ化
+Comment[nb]=Katalogiserer KDE-programmene for lettvint oppstart med Katapult
+Comment[nl]=Catalogiseert uw KDE-programma's voor eenvoudige opstart via Katapult
+Comment[pt]=Cataloga os seus programas do KDE para lançá-los facilmente através do Katapult
+Comment[pt_BR]=Cataloga os seus programas do KDE para lançá-los facilmente através do Katapult
+Comment[sv]=Katalogiserar dina KDE-program för enkel start via Katapult
+Comment[uk]=Робить каталог з програм KDE для легкого запуску через Катапульту
+ServiceTypes=Katapult/Catalog
+Type=Service
+X-KDE-Library=katapult_programcatalog
+X-Katapult-ID=Program Catalog
diff --git a/katapult/plugins/catalogs/programcatalog/program.cpp b/katapult/plugins/catalogs/programcatalog/program.cpp
new file mode 100644
index 0000000..dad529d
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/program.cpp
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kservice.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+
+#include "program.h"
+
+Program::Program(KService::Ptr s, bool useExecName)
+ : KatapultItem()
+{
+ if(useExecName)
+ _name = s->exec();
+ else
+ _name = s->name();
+ _icon = s->icon();
+ if(_icon == "")
+ _icon = s->name().lower();
+ _service = s;
+}
+
+QPixmap Program::icon(int size) const
+{
+ return KGlobal::iconLoader()->loadIcon(_icon, KIcon::NoGroup, size);
+}
+
+QString Program::text() const
+{
+ return _name;
+}
+
+KService * Program::service() const
+{
+ return _service;
+}
+
+#include "program.moc"
diff --git a/katapult/plugins/catalogs/programcatalog/program.h b/katapult/plugins/catalogs/programcatalog/program.h
new file mode 100644
index 0000000..f316042
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/program.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef PROGRAM_H
+#define PROGRAM_H
+
+#include <kservice.h>
+
+#include <katapultitem.h>
+
+/**
+@author Joe Ferris
+*/
+class Program : public KatapultItem
+{
+ Q_OBJECT
+public:
+
+ Program(KService::Ptr, bool);
+
+ virtual QPixmap icon(int) const;
+ virtual QString text() const;
+
+ KService * service() const;
+
+protected:
+ KService::Ptr _service;
+ QString _icon, _name;
+
+};
+
+#endif
diff --git a/katapult/plugins/catalogs/programcatalog/programcatalog.cpp b/katapult/plugins/catalogs/programcatalog/programcatalog.cpp
new file mode 100644
index 0000000..1c83394
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/programcatalog.cpp
@@ -0,0 +1,153 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kservicegroup.h>
+#include <ksycocaentry.h>
+#include <ksycocatype.h>
+#include <kapplication.h>
+#include <knuminput.h>
+#include <kcombobox.h>
+
+#include <qcheckbox.h>
+
+#include "settings.h"
+#include "programcatalog.h"
+#include "program.h"
+#include "actionregistry.h"
+#include "actionrunprogram.h"
+
+K_EXPORT_COMPONENT_FACTORY( katapult_programcatalog,
+ KGenericFactory<ProgramCatalog>( "katapult_programcatalog" ) )
+
+ProgramCatalog::ProgramCatalog(QObject *, const char *, const QStringList&)
+ : CachedCatalog()
+{
+ _minQueryLen = 1;
+ _ignoreIconless = TRUE;
+ _ignoreTerminal = TRUE;
+ _useExecName = FALSE;
+ ActionRegistry::self()->registerAction(new ActionRunProgram());
+}
+
+ProgramCatalog::~ProgramCatalog()
+{
+}
+
+void ProgramCatalog::initialize()
+{
+ cacheProgramList(QString::null);
+}
+
+void ProgramCatalog::cacheProgramList(QString relPath)
+{
+ KServiceGroup::Ptr group = KServiceGroup::group(relPath);
+ if(!group || !group->isValid())
+ return;
+
+ KServiceGroup::List list = group->entries();
+ if(list.isEmpty())
+ return;
+
+ KServiceGroup::List::ConstIterator it = list.begin();
+ for(; it != list.end(); ++it)
+ {
+ KSycocaEntry *e = *it;
+
+ if(e != 0) {
+ if(e->isType(KST_KServiceGroup))
+ {
+ KServiceGroup::Ptr g(static_cast<KServiceGroup *>(e));
+ if(!g->noDisplay())
+ cacheProgramList(g->relPath());
+ } else if(e->isType(KST_KService))
+ {
+ KService::Ptr s(static_cast<KService *>(e));
+ if(s->type() == "Application" &&
+ (!_ignoreIconless || !s->icon().isEmpty()) &&
+ (!_ignoreTerminal || !s->terminal()) && !s->noDisplay()
+ ) {
+ addItem(new Program(s, _useExecName));
+ }
+ }
+ }
+ }
+}
+
+unsigned int ProgramCatalog::minQueryLen() const
+{
+ return _minQueryLen;
+}
+
+void ProgramCatalog::readSettings(KConfigBase *config)
+{
+ _minQueryLen = config->readUnsignedNumEntry("MinQueryLen", 1);
+ _ignoreIconless = config->readBoolEntry("IgnoreIconless", TRUE);
+ _useExecName = config->readBoolEntry("UseExecName", FALSE);
+ _ignoreTerminal = config->readBoolEntry("IgnoreTerminal", TRUE);
+}
+
+void ProgramCatalog::writeSettings(KConfigBase *config)
+{
+ config->writeEntry("MinQueryLen", _minQueryLen);
+ config->writeEntry("IgnoreIconless", _ignoreIconless);
+ config->writeEntry("UseExecName", _useExecName);
+ config->writeEntry("IgnoreTerminal", _ignoreTerminal);
+}
+
+QWidget * ProgramCatalog::configure()
+{
+ ProgramCatalogSettings *settings = new ProgramCatalogSettings();
+
+ settings->minQueryLen->setValue(_minQueryLen);
+ connect(settings->minQueryLen, SIGNAL(valueChanged(int)), this, SLOT(minQueryLenChanged(int)));
+
+ settings->ignoreIconless->setChecked(_ignoreIconless);
+ connect(settings->ignoreIconless, SIGNAL(toggled(bool)), this, SLOT(toggleIgnoreIconless(bool)));
+
+ settings->useExecName->setChecked(_useExecName);
+ connect(settings->useExecName, SIGNAL(toggled(bool)), this, SLOT(toggleUseExecName(bool)));
+
+ settings->ignoreTerminal->setChecked(_ignoreTerminal);
+ connect(settings->ignoreTerminal, SIGNAL(toggled(bool)), this, SLOT(toggleIgnoreTerminal(bool)));
+
+ return settings;
+}
+
+void ProgramCatalog::minQueryLenChanged(int _minQueryLen)
+{
+ this->_minQueryLen = _minQueryLen;
+}
+
+void ProgramCatalog::toggleIgnoreIconless(bool _ignoreIconless)
+{
+ this->_ignoreIconless = _ignoreIconless;
+}
+
+void ProgramCatalog::toggleUseExecName(bool _useExecName)
+{
+ this->_useExecName = _useExecName;
+}
+
+void ProgramCatalog::toggleIgnoreTerminal(bool _ignoreTerminal)
+{
+ this->_ignoreTerminal = _ignoreTerminal;
+}
+
+#include "programcatalog.moc"
diff --git a/katapult/plugins/catalogs/programcatalog/programcatalog.h b/katapult/plugins/catalogs/programcatalog/programcatalog.h
new file mode 100644
index 0000000..ed00536
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/programcatalog.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef PROGRAMCATALOG_H
+#define PROGRAMCATALOG_H
+
+#include <kgenericfactory.h>
+
+#include <qptrlist.h>
+#include <qstring.h>
+
+#include "cachedcatalog.h"
+
+class QWidget;
+
+/**
+@author Joe Ferris
+*/
+class ProgramCatalog : public CachedCatalog
+{
+ Q_OBJECT
+public:
+ ProgramCatalog(QObject *, const char *, const QStringList&);
+ virtual ~ProgramCatalog();
+
+ virtual void initialize();
+ virtual void readSettings(KConfigBase *);
+ virtual void writeSettings(KConfigBase *);
+ virtual unsigned int minQueryLen() const;
+ virtual QWidget * configure();
+
+public slots:
+ void minQueryLenChanged(int);
+ void toggleIgnoreIconless(bool);
+ void toggleUseExecName(bool);
+ void toggleIgnoreTerminal(bool);
+
+private:
+ void cacheProgramList(QString);
+ int _minQueryLen;
+ bool _ignoreIconless;
+ bool _useExecName;
+ bool _ignoreTerminal;
+};
+
+#endif
diff --git a/katapult/plugins/catalogs/programcatalog/settings.ui b/katapult/plugins/catalogs/programcatalog/settings.ui
new file mode 100644
index 0000000..9e963f6
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/settings.ui
@@ -0,0 +1,101 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>ProgramCatalogSettings</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ProgramCatalogSettings</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>308</width>
+ <height>519</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Number of characters before searching:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>minQueryLen</cstring>
+ </property>
+ <property name="maxValue">
+ <number>10</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Katapult will not search for programs until you have typed at least this many characters in the Katapult launcher.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>ignoreIconless</cstring>
+ </property>
+ <property name="text">
+ <string>Ignore applications without icons</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>ignoreTerminal</cstring>
+ </property>
+ <property name="text">
+ <string>Ignore terminal applications</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>useExecName</cstring>
+ </property>
+ <property name="text">
+ <string>Catalog applications by executable name</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>370</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>