summaryrefslogtreecommitdiffstats
path: root/kicker/applets/run
diff options
context:
space:
mode:
Diffstat (limited to 'kicker/applets/run')
-rw-r--r--kicker/applets/run/Makefile.am19
-rw-r--r--kicker/applets/run/runapplet.cpp294
-rw-r--r--kicker/applets/run/runapplet.desktop130
-rw-r--r--kicker/applets/run/runapplet.h65
4 files changed, 508 insertions, 0 deletions
diff --git a/kicker/applets/run/Makefile.am b/kicker/applets/run/Makefile.am
new file mode 100644
index 000000000..ec4de4984
--- /dev/null
+++ b/kicker/applets/run/Makefile.am
@@ -0,0 +1,19 @@
+INCLUDES = $(all_includes)
+
+kde_module_LTLIBRARIES = run_panelapplet.la
+
+run_panelapplet_la_SOURCES = runapplet.cpp
+
+METASOURCES = runapplet.moc
+noinst_HEADERS = runapplet.h
+
+lnkdir = $(kde_datadir)/kicker/applets
+lnk_DATA = runapplet.desktop
+
+EXTRA_DIST = $(lnk_DATA)
+
+run_panelapplet_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+run_panelapplet_la_LIBADD = $(LIB_KSYCOCA) $(LIB_KDEUI)
+
+messages:
+ $(XGETTEXT) *.cpp *.h -o $(podir)/krunapplet.pot
diff --git a/kicker/applets/run/runapplet.cpp b/kicker/applets/run/runapplet.cpp
new file mode 100644
index 000000000..93bb5d7ad
--- /dev/null
+++ b/kicker/applets/run/runapplet.cpp
@@ -0,0 +1,294 @@
+/*****************************************************************
+
+Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#include <qlabel.h>
+#include <qfont.h>
+#include <qstringlist.h>
+#include <qpushbutton.h>
+#include <qhbox.h>
+
+#include <kapplication.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kcombobox.h>
+#include <kurifilter.h>
+#include <kdialog.h>
+#include <krun.h>
+#include <kmessagebox.h>
+
+#include "runapplet.h"
+#include "runapplet.moc"
+
+extern "C"
+{
+ KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile)
+ {
+ KGlobal::locale()->insertCatalogue("krunapplet");
+ return new RunApplet(configFile, KPanelApplet::Stretch, 0, parent, "krunapplet");
+ }
+}
+
+RunApplet::RunApplet(const QString& configFile, Type type, int actions,
+ QWidget *parent, const char *name)
+ : KPanelApplet(configFile, type, actions, parent, name)
+{
+ // setBackgroundMode(X11ParentRelative);
+ setBackgroundOrigin( AncestorOrigin );
+ // setup label
+ _label = new QLabel(i18n("Run command:"), this);
+ QFont f(_label->font());
+ f.setPixelSize(12);
+// _label->setBackgroundMode(X11ParentRelative);
+ _label->setBackgroundOrigin( AncestorOrigin );
+ _label->setFixedHeight(14);
+ _label->setFont(f);
+
+ // setup popup button
+ _btn = new QPushButton(this);
+ f = _btn->font();
+ f.setPixelSize(12);
+ _btn->setFont(f);
+ connect(_btn, SIGNAL(clicked()), SLOT(popup_combo()));
+
+ // setup history combo
+ _input = new KHistoryCombo(this);
+ _input->setFocus();
+ _input->clearEdit();
+ watchForFocus(_input->lineEdit());
+ connect(_input, SIGNAL(activated(const QString&)),
+ SLOT(run_command(const QString&)));
+
+ KConfig *c = config();
+ c->setGroup("General");
+
+ // restore history and completion list
+ QStringList list = c->readListEntry("Completion list");
+ _input->completionObject()->setItems(list);
+ list = c->readListEntry("History list");
+ _input->setHistoryItems(list);
+ int mode = c->readNumEntry( "CompletionMode", KGlobalSettings::completionMode() );
+ _input->setCompletionMode( (KGlobalSettings::Completion) mode );
+
+ _filterData = new KURIFilterData();
+
+ _hbox = new QHBox( 0, 0, WStyle_Customize | WType_Popup );
+ _hbox->setFixedSize(120, 22);
+}
+
+RunApplet::~RunApplet()
+{
+ KConfig *c = config();
+ c->setGroup("General");
+
+ // save history and completion list
+ QStringList list = _input->completionObject()->items();
+ c->writeEntry("Completion list", list);
+ list = _input->historyItems();
+ c->writeEntry("History list", list);
+ c->writeEntry( "CompletionMode", (int) _input->completionMode() );
+ c->sync();
+
+ delete _filterData;
+ KGlobal::locale()->removeCatalogue("krunapplet");
+}
+
+void RunApplet::resizeEvent(QResizeEvent*)
+{
+ if(orientation() == Horizontal)
+ {
+ _btn->hide();
+ _input->reparent(this, QPoint(0,0), true);
+ _label->setGeometry(0,0, width(), _label->height());
+
+ if(height() >= _input->sizeHint().height() + _label->height())
+ {
+ int inputVOffset = height() - _input->sizeHint().height() - 2;
+ int labelHeight = _label->sizeHint().height();
+ _label->setGeometry(0, inputVOffset - labelHeight,
+ width(), labelHeight);
+ _input->setGeometry(0, inputVOffset,
+ width(), _input->sizeHint().height());
+ _label->show();
+ }
+ else
+ {
+ _label->hide();
+
+ // make it as high as the combobox naturally wants to be
+ // but no taller than the panel is!
+ // don't forget to center it vertically either.
+ int newHeight = _input->sizeHint().height();
+ if (newHeight > height())
+ newHeight = height();
+ _input->setGeometry(0, (height() - newHeight) / 2,
+ width(), newHeight);
+ }
+ }
+ else
+ {
+ _btn->show();
+ _btn->setFixedSize(width(), 22);
+ _input->reparent( _hbox, QPoint(0, 0), false);
+ _label->hide();
+ }
+ setButtonText();
+}
+
+void RunApplet::positionChange(KPanelApplet::Position)
+{
+ setButtonText();
+}
+
+void RunApplet::setButtonText()
+{
+ QString t;
+
+ if (position() == pRight)
+ {
+ if (width() >= 42)
+ t = i18n("< Run");
+ else
+ t = "<";
+ }
+ else
+ {
+ if(width() >= 42)
+ t = i18n("Run >");
+ else
+ t = ">";
+ }
+
+ _btn->setText(t);
+}
+
+int RunApplet::widthForHeight(int ) const
+{
+ return _label->sizeHint().width();
+}
+
+int RunApplet::heightForWidth(int ) const
+{
+ return 22;
+}
+
+void RunApplet::popup_combo()
+{
+ QPoint p;
+ if (position() == pRight)
+ p = mapToGlobal(QPoint(-_input->width()-1, 0));
+ else
+ p = mapToGlobal(QPoint(width()+1, 0));
+ _hbox->move(p);
+ _hbox->show();
+ _input->setFocus();
+}
+
+void RunApplet::run_command(const QString& command)
+{
+ QString exec;
+ bool focusNeeded = false;
+
+ kapp->propagateSessionManager();
+
+ _filterData->setData( _input->currentText().stripWhiteSpace() );
+ QStringList filters;
+ filters << "kurisearchfilter" << "kshorturifilter";
+ KURIFilter::self()->filterURI( *(_filterData), filters );
+
+ _input->addToHistory(command);
+ _input->clearEdit();
+
+ QString cmd = (_filterData->uri().isLocalFile() ? _filterData->uri().path():_filterData->uri().url());
+
+ // Nothing interesting. Quit!
+ if ( cmd.isEmpty() ){
+ KMessageBox::sorry(0L, i18n("You have to enter a command to execute "
+ "or a URL to be opened first."));
+ focusNeeded = true;
+ goto hide;
+ }
+ else if (cmd == "logout")
+ {
+ bool shutdown = kapp->requestShutDown();
+ if( !shutdown )
+ {
+ // This i18n string is in kdesktop/desktop.cc as well. Maybe we should DCOP to kdesktop instead ?
+ KMessageBox::error( 0, i18n("Unable to log out properly.\nThe session manager cannot "
+ "be contacted. You can try to force a shutdown by pressing "
+ "Ctrl+Alt+Backspace. Note, however, that your current "
+ "session will not be saved with a forced shutdown." ) );
+ focusNeeded = true;
+ }
+ goto hide;
+ }
+ else
+ {
+ switch( _filterData->uriType() )
+ {
+ case KURIFilterData::LOCAL_FILE:
+ case KURIFilterData::LOCAL_DIR:
+ case KURIFilterData::NET_PROTOCOL:
+ case KURIFilterData::HELP:
+ {
+ (void) new KRun( _filterData->uri() );
+ goto hide;
+ }
+ case KURIFilterData::EXECUTABLE:
+ case KURIFilterData::SHELL:
+ {
+ exec = cmd;
+ if( _filterData->hasArgsAndOptions() )
+ cmd += _filterData->argsAndOptions();
+ break;
+ }
+ case KURIFilterData::UNKNOWN:
+ case KURIFilterData::ERROR:
+ default:
+ KMessageBox::sorry( 0, i18n("<qt>The program name or command <b>%1</b>\n"
+ "cannot be found. Please correct the command\n"
+ "or URL and try again</qt>").arg( cmd ) );
+ _input->removeFromHistory( _input->currentText() );
+ focusNeeded = true;
+ goto hide;
+ }
+ }
+ if (KRun::runCommand( cmd, exec, "" ))
+ goto hide;
+ else
+ {
+ KMessageBox::sorry( 0, i18n("<qt>Could not run <b>%1</b>.\nPlease correct"
+ " the command or URL and try again.</qt>").arg( cmd ) );
+ _input->removeFromHistory( _input->currentText() );
+ focusNeeded = true;
+ goto hide;
+ }
+
+ needsFocus(focusNeeded);
+ return;
+
+ hide:
+ if (orientation() == Vertical)
+ _hbox->hide();
+ needsFocus(focusNeeded);
+}
diff --git a/kicker/applets/run/runapplet.desktop b/kicker/applets/run/runapplet.desktop
new file mode 100644
index 000000000..66937ccae
--- /dev/null
+++ b/kicker/applets/run/runapplet.desktop
@@ -0,0 +1,130 @@
+[Desktop Entry]
+Type=Plugin
+Name=Run Command
+Name[af]=Hardloop Opdrag
+Name[ar]=تنفيذ الأمر
+Name[be]=Выканаць праграму
+Name[bg]=Изпълнение на команда
+Name[bn]=কমান্ড চালাও
+Name[br]=Seveniñ ur Goulev
+Name[bs]=Izvrši naredbu
+Name[ca]=Executa un comandament
+Name[cs]=Spustit příkaz
+Name[csb]=Zrëszënié pòlétu
+Name[cy]=Rhedeg Gorchymyn
+Name[da]=Kør kommando
+Name[de]=Befehl ausführen
+Name[el]=Εκτέλεση εντολής
+Name[eo]=Lanĉu komandon
+Name[es]=Ejecutar una orden
+Name[et]=Käsu käivitamine
+Name[eu]=Exekutatu komandoa
+Name[fa]=اجرای فرمان
+Name[fi]=Suorita komento
+Name[fr]=Lancer une commande
+Name[fy]=kommando útfiere
+Name[ga]=Rith Ordú
+Name[gl]=Executar Comando
+Name[he]=הפעלת פקודה
+Name[hi]=कमांड चलाएँ
+Name[hr]=Pokreni naredbu
+Name[hu]=Parancs végrehajtása
+Name[is]=Keyra skipun
+Name[it]=Esegui comando
+Name[ja]=コマンドを実行
+Name[ka]=ბრძანების შესრულება
+Name[kk]=Команданы орындау
+Name[km]=រត់​ពាក្យ​បញ្ជា
+Name[ko]=Penguin Command
+Name[lt]=Paleisti komandą
+Name[lv]=Darbināt komandu
+Name[mk]=Изврши команда
+Name[ms]=Arahan Laksana
+Name[nb]=Kjør kommando
+Name[nds]=Befehl utföhren
+Name[ne]=आदेश चलाउनुहोस्
+Name[nl]=Commando uitvoeren
+Name[nn]=Køyr kommando
+Name[pa]=ਕਮਾਂਡ ਚਲਾਓ
+Name[pl]=Uruchomienie polecenia
+Name[pt]=Executar um Comando
+Name[pt_BR]=Executar Comando
+Name[ro]=Execută comanda
+Name[ru]=Выполнить команду
+Name[rw]=Gutangiza Ibwiriza
+Name[se]=Vuoje gohččuma
+Name[sk]=Vykonať príkaz
+Name[sl]=Poženi ukaz
+Name[sr]=Покретање наредбе
+Name[sr@Latn]=Pokretanje naredbe
+Name[sv]=Kör kommando
+Name[ta]=இயக்க கட்டளை
+Name[tg]=Иҷрои фармон
+Name[th]=ใช้งานคำสั่ง
+Name[tr]=Komut Çalıştır
+Name[tt]=Boyırıq Eşlätü
+Name[uk]=Запуск команди
+Name[uz]=Buyruqni bajarish
+Name[uz@cyrillic]=Буйруқни бажариш
+Name[vi]=Gõ lệnh
+Name[wa]=Enonder ene comande
+Name[zh_CN]=运行命令
+Name[zh_TW]=執行命令
+Comment=Launch single commands without a terminal window
+Comment[af]=Lanseer enkel opdragte sonder 'n terminaal venster
+Comment[ar]=أطلق أوامر وحيدة بدون الحاجة إلى نافذة المطراف
+Comment[be]=Запускае асобныя каманды без тэрмінальнага акна
+Comment[bg]=Стартиране на команда без да има нужда от терминален прозорец
+Comment[bn]=টার্মিনাল উইণ্ডো ছাড়াই একটি কমান্ড চালান
+Comment[bs]=Izvršite pojedinačne naredbe bez prozora terminala
+Comment[ca]=Engega ordres sense una finestra de terminal
+Comment[cs]=Spouštění jednotlivých příkazů bez terminálového okna
+Comment[csb]=Zrëszanié pòjedińczëch pòlétów kònsolë bez òtmëkaniô òkna terminala
+Comment[da]=Start enkelte kommandoer uden et terminalvindue
+Comment[de]=Ausführen einzelner Kommandos ohne Terminalfenster
+Comment[el]=Εκτέλεση εντολών χωρίς ένα παράθυρο τερματικού
+Comment[eo]=Lanĉi unuopajn komandojn sen terminala fenestro
+Comment[es]=Lanzar órdenes individuales sin ventana de terminal
+Comment[et]=Üksikute käskude käivitamine terminali abita
+Comment[eu]=Abiarazi komandoak terminal leihorik gabe
+Comment[fa]=راه‌اندازی فرمانهای تک بدون پنجرۀ پایانه
+Comment[fi]=Käynnistä yksittäisiä komentoja ilman pääteikkunaa.
+Comment[fr]=Lancer des commandes simples sans fenêtre de terminal
+Comment[fy]=Fier losse kommando's út sûnder in terminalfinster
+Comment[ga]=Rith orduithe aonair gan fhuinneog theirminéil
+Comment[gl]=Executa comandos individuais sen usar unha terminal
+Comment[he]=הפעל פקודות פשוטות ללא חלון מסוף
+Comment[hr]=Pokretanje pojedinih naredbi bez terminalskog prozora
+Comment[hu]=Parancs kiadása parancsértelmező ablak nélkül
+Comment[is]=Keyrðu einstakar skipanir án skeljaglugga
+Comment[it]=Lancia singoli comandi senza una finestra di terminale
+Comment[ja]=ターミナルウィンドウを開かずに一つのコマンドを実行
+Comment[kk]=Болек командаларды терминал терезесінен тыс жегу
+Comment[km]=បើក​ពាក្យ​បញ្ជា​តែ​មួយ ដោយ​គ្មាន​បង្អួច​ស្ថានីយ
+Comment[lt]=Vykdykite pavienes komandas ne terminalo lange
+Comment[mk]=Стартување на единечни команди без терминалски прозорец
+Comment[nb]=Kjør en enkelt kommando uten et skall
+Comment[nds]=Enkel Befehlen ahn Terminalfinster starten
+Comment[ne]=टर्मिनल सञ्झ्याल बिना एकल आदेश सुरुआत गर्नुहोस्
+Comment[nl]=Voer losse commando's uit zonder een terminalvenster
+Comment[nn]=Køyr ein enkelt kommando utan eit skal.
+Comment[pl]=Uruchamianie pojedynczych poleceń konsoli bez otwierania okna terminala
+Comment[pt]=Lançar comandos simples sem uma janela de terminal
+Comment[pt_BR]=Abre comandos digitados sem a necessidade de uma janela de terminal
+Comment[ro]=Lansează comenzi fără o fereastră de terminal
+Comment[ru]=Выполнение отдельной команды без окна терминала
+Comment[se]=Vuoje oktonas gohččomiid terminálaláse haga
+Comment[sk]=Spustiť príkaz bez okna terminálu
+Comment[sl]=Poganjanje posameznih ukazov brez okna terminala
+Comment[sr]=Покрените једноструке наредбе без терминалског прозора
+Comment[sr@Latn]=Pokrenite jednostruke naredbe bez terminalskog prozora
+Comment[sv]=Starta enstaka kommandon utan ett terminalfönster
+Comment[th]=เรียกใช้งานคำสั่งเดี่ยวๆ โดยไม่ต้องเข้าหน้าต่างเทอร์มินัล
+Comment[uk]=Запуск окремих команд без вікна термінала
+Comment[vi]=Chạy một lệnh đơn mà không cần mở một thiết bị đầu cuối
+Comment[wa]=Lancî ene comande seule sins terminå
+Comment[zh_CN]=调用单条命令而无须使用终端窗口
+Comment[zh_TW]=不使用終端機視窗而送出單行指令
+Icon=exec
+X-KDE-Library=run_panelapplet
+X-KDE-UniqueApplet=true
diff --git a/kicker/applets/run/runapplet.h b/kicker/applets/run/runapplet.h
new file mode 100644
index 000000000..ded8fc398
--- /dev/null
+++ b/kicker/applets/run/runapplet.h
@@ -0,0 +1,65 @@
+/*****************************************************************
+
+Copyright (c) 2000 Matthias Elter
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef __runapplet_h__
+#define __runapplet_h__
+
+#include <qstring.h>
+#include <kpanelapplet.h>
+
+class QLabel;
+class QHBox;
+class QPushButton;
+class KHistoryCombo;
+class KURIFilterData;
+
+class RunApplet : public KPanelApplet
+{
+ Q_OBJECT
+
+public:
+ RunApplet(const QString& configFile, Type t = Stretch, int actions = 0,
+ QWidget *parent = 0, const char *name = 0);
+ virtual ~RunApplet();
+
+ int widthForHeight(int height) const;
+ int heightForWidth(int width) const;
+
+protected:
+ void resizeEvent(QResizeEvent*);
+ void positionChange(KPanelApplet::Position);
+
+protected slots:
+ void run_command(const QString&);
+ void popup_combo();
+ void setButtonText();
+
+private:
+ KHistoryCombo *_input;
+ KURIFilterData *_filterData;
+ QLabel *_label;
+ QPushButton *_btn;
+ QHBox *_hbox;
+};
+
+#endif