diff options
Diffstat (limited to 'kicker/menuext/kate')
-rw-r--r-- | kicker/menuext/kate/Makefile.am | 15 | ||||
-rw-r--r-- | kicker/menuext/kate/katesessionmenu.cpp | 150 | ||||
-rw-r--r-- | kicker/menuext/kate/katesessionmenu.desktop | 98 | ||||
-rw-r--r-- | kicker/menuext/kate/katesessionmenu.h | 45 |
4 files changed, 308 insertions, 0 deletions
diff --git a/kicker/menuext/kate/Makefile.am b/kicker/menuext/kate/Makefile.am new file mode 100644 index 000000000..bc629e0f9 --- /dev/null +++ b/kicker/menuext/kate/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = kickermenu_kate.la + +kickermenu_kate_la_SOURCES = katesessionmenu.cpp +kickermenu_kate_la_LDFLAGS = $(all_libraries) -module -avoid-version +kickermenu_kate_la_LIBADD = $(LIB_KDEUI) + +kickermenu_kate_la_METASOURCES = AUTO + +desktopmenu_DATA = katesessionmenu.desktop +desktopmenudir = $(kde_datadir)/kicker/menuext + +messages: + $(XGETTEXT) *.cpp -o $(podir)/kickermenu_kate.pot
\ No newline at end of file diff --git a/kicker/menuext/kate/katesessionmenu.cpp b/kicker/menuext/kate/katesessionmenu.cpp new file mode 100644 index 000000000..63cee8106 --- /dev/null +++ b/kicker/menuext/kate/katesessionmenu.cpp @@ -0,0 +1,150 @@ +/* + 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. + + --- + Copyright (C) 2005, Anders Lund <[email protected]> + */ + +#include "katesessionmenu.h" +#include "katesessionmenu.moc" + +#include <kapplication.h> +#include <kconfig.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kinputdialog.h> +#include <klibloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <ksimpleconfig.h> +#include <kstandarddirs.h> + +#include <qvalidator.h> + +class Validator : public QValidator { + public: + Validator( QObject *parent ) : QValidator( parent, 0 ) {} + ~Validator() {} + virtual QValidator::State validate( QString &, int & ) const { return QValidator::Acceptable; } +}; + +K_EXPORT_KICKER_MENUEXT(kate, KateSessionMenu) + +KateSessionMenu::KateSessionMenu( QWidget *parent, const char *name, const QStringList& ) + : KPanelMenu( parent, name ), + m_parent( parent ) +{ +} + +KateSessionMenu::~KateSessionMenu() +{ +} + +// update the session list and rebuild the menu +void KateSessionMenu::initialize() +{ + if ( initialized() ) + { + return; + } + + m_sessions.clear(); + + int id = 0; + + // no session - exec 'kate' + insertItem( SmallIconSet("kate"), i18n("Start Kate (no arguments)"), id++ ); + + // new session - prompt for a name and exec 'kate --start NAME' + insertItem( SmallIconSet("new"), i18n("New Kate Session"), id++ ); + + // new anonymous session, 'kate --start ""' + insertItem( SmallIconSet("new"), i18n("New Anonymous Session"), id++ ); + + insertSeparator(); + + QStringList list = KGlobal::dirs()->findAllResources( "data", "kate/sessions/*.katesession", false, true); + for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) + { + KSimpleConfig config( *it, true ); + config.setGroup( "General" ); + m_sessions.append( config.readEntry( "Name" ) ); + } + + m_sessions.sort(); + + for ( QStringList::ConstIterator it1 = m_sessions.begin(); it1 != m_sessions.end(); ++it1 ) + { + insertItem( *it1, id++ ); + } + + // means for updating, to let the user manually update if he/she added new sessions. + insertSeparator(); + insertItem( SmallIconSet("reload"), i18n("Reload Session List"), this, SLOT(reinitialize()) ); +} + +void KateSessionMenu::slotExec( int id ) +{ + if ( id < 0 ) + return; + + QStringList args; + if ( id > 0 ) + args << "--start"; + + // If a new session is requested we try to ask for a name. + if ( id == 1 ) + { + bool ok (false); + QString name = KInputDialog::getText( i18n("Session Name"), + i18n("Please enter a name for the new session"), + QString::null, + &ok, 0, 0, new Validator( m_parent ) ); + if ( ! ok ) + return; + + if ( name.isEmpty() && KMessageBox::questionYesNo( 0, + i18n("An unnamed session will not be saved automatically. " + "Do you want to create such a session?"), + i18n("Create anonymous session?"), + KStdGuiItem::yes(), KStdGuiItem::cancel(), + "kate_session_button_create_anonymous" ) == KMessageBox::No ) + return; + + if ( m_sessions.contains( name ) && + KMessageBox::warningYesNo( 0, + i18n("You allready have a session named %1. Do you want to open that session?").arg( name ), + i18n("Session exists") ) == KMessageBox::No ) + return; + else + // mark the menu as dirty so that it gets rebuild at next display + // to show the new session + setInitialized( false ); + + args << name; + } + + else if ( id == 2 ) + args << ""; + + else if ( id > 2 ) + args << m_sessions[ id-3 ]; + + kapp->kdeinitExec("kate", args); +} + + +// kate: space-indent: on; indent-width 2; replace-tabs on; diff --git a/kicker/menuext/kate/katesessionmenu.desktop b/kicker/menuext/kate/katesessionmenu.desktop new file mode 100644 index 000000000..24eea8be4 --- /dev/null +++ b/kicker/menuext/kate/katesessionmenu.desktop @@ -0,0 +1,98 @@ +[Desktop Entry] +Name=Kate Session Menu +Name[bg]=Меню сесии на Kate +Name[bn]=কেট সেশন মেনু +Name[ca]=Menú de la sessió Kate +Name[cs]=Nabídka relace Kate +Name[csb]=Menu sesëji Kate +Name[da]=Kate Sessionsmenu +Name[de]=Kate Sitzungsmenü +Name[el]=Μενού συνεδρίας του Kate +Name[eo]=Kate Seanco Menuo +Name[es]=Menú de la sesión de Kate +Name[et]=Kate seansimenüü +Name[fa]=گزینگان نشست Kate +Name[fi]=Katen istuntojenhallinta +Name[fr]=Menu de sessions de Kate +Name[fy]=Kate Sesjemenu +Name[gl]=Menú de Sesións de Kate +Name[he]=תפריט ההפעלה של Kate +Name[hr]=Kate izbornik sesija +Name[hu]=Kate munkafolyamat-menü +Name[is]=Kate setuvalmynd +Name[it]=Menu delle sessioni di Kate +Name[ja]=Kate セッションメニュー +Name[kk]=Kate сеанс мәзірі +Name[km]=ម៉ឺនុយសម័យរបស់ Kate +Name[lt]=Kate sesijų meniu +Name[nb]=Meny for Kate-økter +Name[nds]=Kate-Törnmenü +Name[ne]=केट सत्र मेनु +Name[nl]=Kate sessiemenu +Name[pa]=ਕੇਟ ਸ਼ੈਸ਼ਨ ਮੇਨੂ +Name[pl]=Menu sesji Kate +Name[pt]=Menu de Sessões do Kate +Name[pt_BR]=Menu de Sessões do Kate +Name[ro]=Meniu sesiune Kate +Name[ru]=Сеанс Kate +Name[sk]=Kate menu sedenia +Name[sl]=Meni s sejami za Kate +Name[sr]=Kate-ин мени сесија +Name[sr@Latn]=Kate-in meni sesija +Name[sv]=Kate sessionsmeny +Name[te]=కేట్ సెషన్ పట్టీ +Name[th]=เมนูเซสชั่นของ Kate +Name[tr]=Kate Oturum Menüsü +Name[uk]=Меню сеансів Kate +Name[uz]=Kate seans menyusi +Name[uz@cyrillic]=Kate сеанс менюси +Name[wa]=Dressêye di sessions Kate +Name[zh_CN]=Kate 会话菜单 +Name[zh_TW]=Kate 工作階段選單 +Comment=Allows you to open Kate with a specified session, or create a new one +Comment[bg]=Позволя отварянето на определена сесия на Kate или създаването на нова +Comment[ca]=Us permet obrir Kate amb una sessió específica o bé crear-ne una de nova +Comment[cs]=Umožňuje otevřít Kate s určitou relací nebo si vytvořit novou +Comment[csb]=Pòzwôlô òtemknąc apartną sesëjã Kate abò ùsôdzëc nową +Comment[da]=Tillader dig at åbne Kate med en bestemt session, eller at oprette en ny +Comment[de]=Lässt Sie Kate mit einer vorhandenen oder neuen Sitzung starten +Comment[el]=Σας επιτρέπει να ανοίξετε το Kate μα μια καθορισμένη συνεδρία, ή να δημιουργήσετε μία νέα +Comment[eo]=Ebligas vin malfermi Kate-n kun aparta seanco, aŭ krei novan +Comment[es]=Le permite abrir Kate con una sesión específica, o crear una nueva +Comment[et]=Võimaldab avada Kate määratud seansiga või luua uue seansi +Comment[fa]=به شما اجازه میدهد Kate را توسط نشست مشخصشده باز کنید، یا مورد جدیدی را ایجاد نمایید +Comment[fi]=Voit avata Katesta määritellyn istunnon, tai luoda uuden +Comment[fr]=Vous permet d'ouvrir Kate avec une session spécifiée, ou d'en créer une nouvelle +Comment[fy]=Stiet jo ta om Kate mei in oantsjutte sesje te iepenjen, of in nije oan te meitsjen +Comment[gl]=Permítelle abrir Kate cunha sesión especificada, ou crear unha nova. +Comment[hr]=Dopušta otvaranje Kate uz određenu sesiju ili izradu nove sesije +Comment[hu]=Lehetővé teszi a Kate megnyitását egy megadott munkafolyamattal vagy egy újonnan létrehozottal +Comment[is]=Gerir þér kleyft að opna Kate með ákveðinni setu, eða búa til nýja +Comment[it]=Ti permette di aprire Kate con una particolare sessione, o di crearne una nuova +Comment[ja]=新規または既存のセッションで Kate を起動します +Comment[kk]=Kate-тің керек сеансын ашады, немесе жаңасын бастайды +Comment[km]= អនុញ្ញាតឲ្យអ្នកបើក Kate ជាមួយនឹងសម័យដែលបានបញ្ជាក់ ឬបង្កើតថ្មីមួយ +Comment[lt]=Leidžia atverti Kate su nurodyta sesija arba sukurti naują +Comment[nb]=Brukes til å åpne Kate med en bestemt økt, eller opprette en ny +Comment[nds]=Lett Di Kate mit en angeven oder niegen Törn opmaken +Comment[ne]=निर्दिष्ट गरिएको सत्रसँग केट खोल्न,वा एउटा नयाँ सिर्जना गर्न अनुमति दिन्छ +Comment[nl]=Stelt u in staat om Kate te openen met een opgegeven sessie, of u kunt een nieuwe sessie aanmaken +Comment[pl]=Pozwala otworzyć określoną sesję Kate albo utworzyć nową +Comment[pt]=Permite-lhe abrir o Kate com uma determinada sessão ou criar uma nova +Comment[pt_BR]=Permite que você abra o Kate com uma sessão específica, ou criar uma nova +Comment[ro]=Vă permite să deschideți Kate cu o sesiune specificată, sau să creați una nouă +Comment[ru]=Позволяет открыть заданный сеанс Kate +Comment[sk]=Umožní otvoriť Kate so špecifickým sedením alebo vytvoriť nové sedenie +Comment[sl]=Omogoča vam, da Kate odprete z izbrano sejo, ali pa ustvarite novo sejo +Comment[sr]=Омогућава вам да отворите Kate са задатом сесијом, или да направите нову +Comment[sr@Latn]=Omogućava vam da otvorite Kate sa zadatom sesijom, ili da napravite novu +Comment[sv]=Gör det möjligt att öppna Kate med en angiven session, eller skapa en ny +Comment[te]=కెట్ ను ఇవ్వబడిన సెషన్ తొ తెరువబడును, లేక కొత్తది సృష్టించబడును +Comment[th]=ให้คุณเปิด Kate ด้วยเซสชั่นที่ระบุ หรือสร้างเซสชั่นใหม่ +Comment[tr]=Kate'i belirli bir oturumla açmanızı sağlar +Comment[uk]=Надає можливість відкривати Kate з певним сеансом або створювати новий +Comment[wa]=Vos permete di drovi Kate avou ene sipecifieye session oudonbén nd ahiver ene novele +Comment[zh_CN]=允许您用指定会话打开 Kate,或创建新会话 +Comment[zh_TW]=讓您可以用指定的工作階段來開啟 Kate,或是建立新的工作階段 +Icon=kate +X-KDE-Library=kickermenu_kate diff --git a/kicker/menuext/kate/katesessionmenu.h b/kicker/menuext/kate/katesessionmenu.h new file mode 100644 index 000000000..ea78bf6ba --- /dev/null +++ b/kicker/menuext/kate/katesessionmenu.h @@ -0,0 +1,45 @@ +/* + 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. + + --- + Copyright (C) 2005, Anders Lund <[email protected]> + */ + +#ifndef _KateSessionMenu_h_ +#define _KateSessionMenu_h_ + +#include <kpanelmenu.h> + +class KateSessionMenu : public KPanelMenu { + Q_OBJECT + public: + KateSessionMenu( QWidget *parent=0, const char *name=0, const QStringList& /*args*/=QStringList() ); + ~KateSessionMenu(); + + public slots: + virtual void initialize(); + + protected slots: + virtual void slotExec( int id ); + + private: + QStringList m_sessions; + QWidget *m_parent; +}; + +#endif // _KateSessionMenu_h_ + +// kate: space-indent on; indent-width 2; replace-tabs on; |