summaryrefslogtreecommitdiffstats
path: root/kicker/menuext/konsole
diff options
context:
space:
mode:
Diffstat (limited to 'kicker/menuext/konsole')
-rw-r--r--kicker/menuext/konsole/Makefile.am15
-rw-r--r--kicker/menuext/konsole/konsole_mnu.cpp318
-rw-r--r--kicker/menuext/konsole/konsole_mnu.h64
-rw-r--r--kicker/menuext/konsole/konsolebookmarkhandler.cpp117
-rw-r--r--kicker/menuext/konsole/konsolebookmarkhandler.h60
-rw-r--r--kicker/menuext/konsole/konsolebookmarkmenu.cpp187
-rw-r--r--kicker/menuext/konsole/konsolebookmarkmenu.h58
-rw-r--r--kicker/menuext/konsole/konsolemenu.desktop137
8 files changed, 956 insertions, 0 deletions
diff --git a/kicker/menuext/konsole/Makefile.am b/kicker/menuext/konsole/Makefile.am
new file mode 100644
index 000000000..907e79769
--- /dev/null
+++ b/kicker/menuext/konsole/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(all_includes)
+
+kde_module_LTLIBRARIES = kickermenu_konsole.la
+
+kickermenu_konsole_la_SOURCES = konsole_mnu.cpp konsolebookmarkhandler.cpp konsolebookmarkmenu.cpp
+kickermenu_konsole_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kickermenu_konsole_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO)
+
+kickermenu_konsole_la_METASOURCES = AUTO
+
+desktopmenu_DATA = konsolemenu.desktop
+desktopmenudir = $(kde_datadir)/kicker/menuext
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/libkickermenu_konsole.pot
diff --git a/kicker/menuext/konsole/konsole_mnu.cpp b/kicker/menuext/konsole/konsole_mnu.cpp
new file mode 100644
index 000000000..87df6f268
--- /dev/null
+++ b/kicker/menuext/konsole/konsole_mnu.cpp
@@ -0,0 +1,318 @@
+/*****************************************************************
+
+Copyright (c) 1996-2001 the kicker authors. See file AUTHORS.
+
+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 <stdlib.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <qdir.h>
+#include <qfileinfo.h>
+
+#include <kapplication.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kio/global.h>
+#include <klocale.h>
+#include <krun.h>
+#include <kshell.h>
+#include <ksimpleconfig.h>
+#include <kstandarddirs.h>
+
+#include "konsole_mnu.h"
+
+K_EXPORT_KICKER_MENUEXT(konsole, KonsoleMenu)
+
+KonsoleMenu::KonsoleMenu(QWidget *parent, const char *name, const QStringList& /* args */)
+ : KPanelMenu("", parent, name),
+ m_profileMenu(0),
+ m_bookmarksSession(0),
+ m_bookmarkHandlerSession(0)
+{
+}
+
+KonsoleMenu::~KonsoleMenu()
+{
+ KGlobal::locale()->removeCatalogue("libkickermenu_konsole");
+}
+
+static void insertItemSorted(KPopupMenu *menu,
+ const QIconSet &iconSet,
+ const QString &txt, int id)
+{
+ const int defaultId = 1; // The id of the 'new' item.
+ int index = menu->indexOf(defaultId);
+ int count = menu->count();
+ if (index >= 0)
+ {
+ index++; // Skip separator
+ while(true)
+ {
+ index++;
+ if (index >= count)
+ {
+ index = -1; // Insert at end
+ break;
+ }
+ if (menu->text(menu->idAt(index)) > txt)
+ break; // Insert before this item
+ }
+ }
+ menu->insertItem(iconSet, txt, id, index);
+}
+
+
+void KonsoleMenu::initialize()
+{
+ if (initialized())
+ {
+ clear();
+ }
+ else
+ {
+ kapp->iconLoader()->addAppDir("konsole");
+ }
+
+ setInitialized(true);
+
+ QStringList list = KGlobal::dirs()->findAllResources("data",
+ "konsole/*.desktop",
+ false, true);
+
+ QString defaultShell = locate("data", "konsole/shell.desktop");
+ list.prepend(defaultShell);
+
+ int id = 1;
+
+ sessionList.clear();
+ for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
+ {
+ if ((*it == defaultShell) && (id != 1))
+ {
+ continue;
+ }
+
+ KSimpleConfig conf(*it, true /* read only */);
+ conf.setDesktopGroup();
+ QString text = conf.readEntry("Name");
+
+ // try to locate the binary
+ QString exec= conf.readPathEntry("Exec");
+ if (exec.startsWith("su -c \'"))
+ {
+ exec = exec.mid(7,exec.length()-8);
+ }
+
+ exec = KRun::binaryName(exec, false);
+ exec = KShell::tildeExpand(exec);
+ QString pexec = KGlobal::dirs()->findExe(exec);
+ if (text.isEmpty() ||
+ conf.readEntry("Type") != "KonsoleApplication" ||
+ (!exec.isEmpty() && pexec.isEmpty()))
+ {
+ continue;
+ }
+ insertItemSorted(this, SmallIconSet(conf.readEntry("Icon", "konsole")),
+ text, id++);
+ QFileInfo fi(*it);
+ sessionList.append(fi.baseName(true));
+
+ if (id == 2)
+ {
+ insertSeparator();
+ }
+ }
+
+ m_bookmarkHandlerSession = new KonsoleBookmarkHandler(this, false);
+ m_bookmarksSession = m_bookmarkHandlerSession->menu();
+ insertSeparator();
+ insertItem(SmallIconSet("keditbookmarks"),
+ i18n("New Session at Bookmark"), m_bookmarksSession);
+ connect(m_bookmarkHandlerSession,
+ SIGNAL(openURL(const QString&, const QString&)),
+ SLOT(newSession(const QString&, const QString&)));
+
+
+ screenList.clear();
+ QCString screenDir = getenv("SCREENDIR");
+
+ if (screenDir.isEmpty())
+ {
+ screenDir = QFile::encodeName(QDir::homeDirPath()) + "/.screen/";
+ }
+
+ QStringList sessions;
+ // Can't use QDir as it doesn't support FIFOs :(
+ DIR *dir = opendir(screenDir);
+ if (dir)
+ {
+ struct dirent *entry;
+ while ((entry = readdir(dir)))
+ {
+ QCString path = screenDir + "/" + entry->d_name;
+ struct stat st;
+ if (stat(path, &st) != 0)
+ {
+ continue;
+ }
+
+ int fd;
+ if (S_ISFIFO(st.st_mode) && !(st.st_mode & 0111) && // xbit == attached
+ (fd = open(path, O_WRONLY | O_NONBLOCK)) != -1)
+ {
+ ::close(fd);
+ screenList.append(QFile::decodeName(entry->d_name));
+ insertItem(SmallIconSet("konsole"),
+ i18n("Screen is a program controlling screens!",
+ "Screen at %1").arg(entry->d_name), id);
+ id++;
+ }
+ }
+ closedir(dir);
+ }
+
+ // reset id as we are now going to populate the profiles submenu
+ id = 0;
+
+ delete m_profileMenu;
+ m_profileMenu = new KPopupMenu(this);
+ QStringList profiles = KGlobal::dirs()->findAllResources("data",
+ "konsole/profiles/*",
+ false, true );
+ m_profiles.resize(profiles.count());
+ QStringList::ConstIterator pEnd = profiles.end();
+ for (QStringList::ConstIterator pIt = profiles.begin(); pIt != pEnd; ++pIt)
+ {
+ QFileInfo info(*pIt);
+ QString profileName = KIO::decodeFileName(info.baseName());
+ QString niceName = profileName;
+ KSimpleConfig cfg(*pIt, true);
+ if (cfg.hasGroup("Profile"))
+ {
+ cfg.setGroup("Profile");
+ if (cfg.hasKey("Name"))
+ {
+ niceName = cfg.readEntry("Name");
+ }
+ }
+
+ m_profiles[id] = profileName;
+ ++id;
+ m_profileMenu->insertItem(niceName, id);
+ }
+
+ int profileID = insertItem(i18n("New Session Using Profile"),
+ m_profileMenu);
+ if (id == 1)
+ {
+ // we don't have any profiles, disable the menu
+ setItemEnabled(profileID, false);
+ }
+ connect(m_profileMenu, SIGNAL(activated(int)), SLOT(launchProfile(int)));
+
+ insertSeparator();
+ insertItem(SmallIconSet("reload"),
+ i18n("Reload Sessions"), this, SLOT(reinitialize()));
+}
+
+void KonsoleMenu::slotExec(int id)
+{
+ if (id < 1)
+ {
+ return;
+ }
+
+ --id;
+ kapp->propagateSessionManager();
+ QStringList args;
+ if (static_cast<unsigned int>(id) < sessionList.count())
+ {
+ args << "--type";
+ args << sessionList[id];
+ }
+ else
+ {
+ args << "-e";
+ args << "screen";
+ args << "-r";
+ args << screenList[id - sessionList.count()];
+ }
+ KApplication::kdeinitExec("konsole", args);
+ return;
+}
+
+void KonsoleMenu::launchProfile(int id)
+{
+ if (id < 1 || id > m_profiles.count())
+ {
+ return;
+ }
+
+ --id;
+ // this is a session, not a bookmark, so execute that instead
+ QStringList args;
+ args << "--profile" << m_profiles[id];
+ kapp->kdeinitExec("konsole", args);
+}
+
+KURL KonsoleMenu::baseURL() const
+{
+ KURL url;
+ /*url.setPath(se->getCwd()+"/");*/
+ return url;
+}
+
+void KonsoleMenu::newSession(const QString& sURL, const QString& title)
+{
+ QStringList args;
+
+ KURL url = KURL(sURL);
+ if ((url.protocol() == "file") && (url.hasPath()))
+ {
+ args << "-T" << title;
+ args << "--workdir" << url.path();
+ KApplication::kdeinitExec("konsole", args);
+ return;
+ }
+ else if ((!url.protocol().isEmpty()) && (url.hasHost()))
+ {
+ QString protocol = url.protocol();
+ QString host = url.host();
+ args << "-T" << title;
+ args << "-e" << protocol.latin1(); /* argv[0] == command to run. */
+ if (url.hasUser()) {
+ args << "-l" << url.user().latin1();
+ }
+ args << host.latin1();
+ KApplication::kdeinitExec("konsole", args);
+ return;
+ }
+ /*
+ * We can't create a session without a protocol.
+ * We should ideally popup a warning, about an invalid bookmark.
+ */
+}
+
+
+#include "konsole_mnu.moc"
diff --git a/kicker/menuext/konsole/konsole_mnu.h b/kicker/menuext/konsole/konsole_mnu.h
new file mode 100644
index 000000000..988764124
--- /dev/null
+++ b/kicker/menuext/konsole/konsole_mnu.h
@@ -0,0 +1,64 @@
+/*****************************************************************
+
+Copyright (c) 1996-2001 the kicker authors. See file AUTHORS.
+
+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 _konsole_mnu_h_
+#define _konsole_mnu_h_
+
+#include <qvaluevector.h>
+
+#include <kpanelmenu.h>
+#include <klibloader.h>
+
+#include "konsolebookmarkmenu.h"
+#include "konsolebookmarkhandler.h"
+
+
+class KonsoleMenu : public KPanelMenu/*, public KPReloadObject*/
+{
+ Q_OBJECT
+
+public:
+ KonsoleMenu(QWidget *parent, const char *name, const QStringList& /* args */);
+ ~KonsoleMenu();
+ KURL baseURL() const;
+
+
+protected slots:
+ void slotExec(int id);
+ void launchProfile(int id);
+ void initialize();
+ void newSession(const QString& sURL, const QString& title);
+
+
+private:
+ QStringList sessionList;
+ QStringList screenList;
+ QValueVector<QString> m_profiles;
+ KPopupMenu* m_profileMenu;
+ KPopupMenu* m_bookmarksSession;
+
+ KonsoleBookmarkHandler *m_bookmarkHandlerSession;
+};
+
+#endif
+
diff --git a/kicker/menuext/konsole/konsolebookmarkhandler.cpp b/kicker/menuext/konsole/konsolebookmarkhandler.cpp
new file mode 100644
index 000000000..c9f8e2806
--- /dev/null
+++ b/kicker/menuext/konsole/konsolebookmarkhandler.cpp
@@ -0,0 +1,117 @@
+// Born as kdelibs/kio/kfile/kfilebookmarkhandler.cpp
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <qtextstream.h>
+
+#include <kbookmarkimporter.h>
+#include <kmimetype.h>
+#include <kpopupmenu.h>
+#include <ksavefile.h>
+#include <kstandarddirs.h>
+
+#include "konsole_mnu.h"
+#include "konsolebookmarkmenu.h"
+#include "konsolebookmarkhandler.h"
+
+KonsoleBookmarkHandler::KonsoleBookmarkHandler( KonsoleMenu *konsole, bool )
+ : QObject( konsole, "KonsoleBookmarkHandler" ),
+ KBookmarkOwner(),
+ m_konsole( konsole ),
+ m_importStream( 0L )
+{
+ m_menu = new KPopupMenu( konsole, "bookmark menu" );
+
+ QString file = locate( "data", "konsole/bookmarks.xml" );
+ if ( file.isEmpty() )
+ file = locateLocal( "data", "konsole/bookmarks.xml" );
+
+ // import old bookmarks
+ if ( !KStandardDirs::exists( file ) ) {
+ QString oldFile = locate( "data", "kfile/bookmarks.html" );
+ if ( !oldFile.isEmpty() )
+ importOldBookmarks( oldFile, file );
+ }
+
+ KBookmarkManager *manager = KBookmarkManager::managerForFile( file, false);
+ manager->setUpdate( true );
+ manager->setShowNSBookmarks( false );
+
+ connect( manager, SIGNAL( changed(const QString &, const QString &) ),
+ SLOT( slotBookmarksChanged(const QString &, const QString &) ) );
+ m_bookmarkMenu = new KonsoleBookmarkMenu( manager, this, m_menu,
+ NULL, false, /*Not toplevel*/
+ false /*No 'Add Bookmark'*/ );
+}
+
+QString KonsoleBookmarkHandler::currentURL() const
+{
+ return m_konsole->baseURL().url();
+}
+
+void KonsoleBookmarkHandler::importOldBookmarks( const QString& path,
+ const QString& destinationPath )
+{
+ KSaveFile file( destinationPath );
+ if ( file.status() != 0 )
+ return;
+
+ m_importStream = file.textStream();
+ *m_importStream << "<!DOCTYPE xbel>\n<xbel>\n";
+
+ KNSBookmarkImporter importer( path );
+ connect( &importer,
+ SIGNAL( newBookmark( const QString&, const QCString&, const QString& )),
+ SLOT( slotNewBookmark( const QString&, const QCString&, const QString& )));
+ connect( &importer,
+ SIGNAL( newFolder( const QString&, bool, const QString& )),
+ SLOT( slotNewFolder( const QString&, bool, const QString& )));
+ connect( &importer, SIGNAL( newSeparator() ), SLOT( newSeparator() ));
+ connect( &importer, SIGNAL( endMenu() ), SLOT( endMenu() ));
+
+ importer.parseNSBookmarks( false );
+
+ *m_importStream << "</xbel>";
+
+ file.close();
+ m_importStream = 0L;
+}
+
+void KonsoleBookmarkHandler::slotNewBookmark( const QString& /*text*/,
+ const QCString& url,
+ const QString& additionalInfo )
+{
+ *m_importStream << "<bookmark icon=\"" << KMimeType::iconForURL( KURL( url ) );
+ *m_importStream << "\" href=\"" << QString::fromUtf8(url) << "\">\n";
+ *m_importStream << "<title>" << (additionalInfo.isEmpty() ? QString::fromUtf8(url) : additionalInfo) << "</title>\n</bookmark>\n";
+}
+
+void KonsoleBookmarkHandler::slotNewFolder( const QString& text, bool /*open*/,
+ const QString& /*additionalInfo*/ )
+{
+ *m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
+ *m_importStream << text << "\">\n";
+}
+
+void KonsoleBookmarkHandler::slotBookmarksChanged( const QString &,
+ const QString & )
+{
+ // This is called when someone changes bookmarks in konsole....
+ m_bookmarkMenu->slotBookmarksChanged("");
+}
+
+void KonsoleBookmarkHandler::newSeparator()
+{
+ *m_importStream << "<separator/>\n";
+}
+
+void KonsoleBookmarkHandler::endFolder()
+{
+ *m_importStream << "</folder>\n";
+}
+
+void KonsoleBookmarkHandler::virtual_hook( int id, void* data )
+{ KBookmarkOwner::virtual_hook( id, data ); }
+
+#include "konsolebookmarkhandler.moc"
diff --git a/kicker/menuext/konsole/konsolebookmarkhandler.h b/kicker/menuext/konsole/konsolebookmarkhandler.h
new file mode 100644
index 000000000..b22f0d03d
--- /dev/null
+++ b/kicker/menuext/konsole/konsolebookmarkhandler.h
@@ -0,0 +1,60 @@
+// Born as kdelibs/kio/kfile/kfilebookmarkhandler.h
+
+#ifndef KONSOLEBOOKMARKHANDLER_H
+#define KONSOLEBOOKMARKHANDLER_H
+
+#include <kbookmarkmanager.h>
+#include "konsolebookmarkmenu.h"
+
+
+class QTextStream;
+class KPopupMenu;
+class KonsoleBookmarkMenu;
+class KonsoleMenu;
+
+class KonsoleBookmarkHandler : public QObject, public KBookmarkOwner
+{
+ Q_OBJECT
+
+public:
+ KonsoleBookmarkHandler( KonsoleMenu *konsole, bool toplevel );
+
+ QPopupMenu * popupMenu();
+
+ // KBookmarkOwner interface:
+ virtual void openBookmarkURL( const QString& url, const QString& title )
+ { emit openURL( url, title ); }
+ virtual QString currentURL() const;
+
+ KPopupMenu *menu() const { return m_menu; }
+
+signals:
+ void openURL( const QString& url, const QString& title );
+
+private slots:
+ // for importing
+ void slotNewBookmark( const QString& text, const QCString& url,
+ const QString& additionalInfo );
+ void slotNewFolder( const QString& text, bool open,
+ const QString& additionalInfo );
+ void slotBookmarksChanged( const QString &, const QString & caller );
+ void newSeparator();
+ void endFolder();
+
+private:
+ void importOldBookmarks( const QString& path, const QString& destinationPath );
+
+ KonsoleMenu *m_konsole;
+ KPopupMenu *m_menu;
+ KonsoleBookmarkMenu *m_bookmarkMenu;
+ QTextStream *m_importStream;
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KonsoleBookmarkHandlerPrivate;
+ KonsoleBookmarkHandlerPrivate *d;
+};
+
+
+#endif // KONSOLEBOOKMARKHANDLER_H
diff --git a/kicker/menuext/konsole/konsolebookmarkmenu.cpp b/kicker/menuext/konsole/konsolebookmarkmenu.cpp
new file mode 100644
index 000000000..b10d26c40
--- /dev/null
+++ b/kicker/menuext/konsole/konsolebookmarkmenu.cpp
@@ -0,0 +1,187 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <qtextstream.h>
+
+#include <kbookmarkimporter.h>
+#include <kmimetype.h>
+#include <kpopupmenu.h>
+#include <ksavefile.h>
+#include <kstandarddirs.h>
+//#include <kbookmarkmenu.h>
+
+#include "konsole_mnu.h"
+#include "konsolebookmarkmenu.h"
+#include "konsolebookmarkhandler.h"
+
+#include <qfile.h>
+
+#include <kaction.h>
+#include <klocale.h>
+
+
+KonsoleBookmarkMenu::KonsoleBookmarkMenu( KBookmarkManager* mgr,
+ KonsoleBookmarkHandler * _owner, KPopupMenu * _parentMenu,
+ KActionCollection *collec, bool _isRoot, bool _add,
+ const QString & parentAddress )
+: KBookmarkMenu( mgr, _owner, _parentMenu, collec, _isRoot, _add,
+ parentAddress),
+ m_kOwner(_owner)
+{
+ /*
+ * First, we disconnect KBookmarkMenu::slotAboutToShow()
+ * Then, we connect KonsoleBookmarkMenu::slotAboutToShow().
+ * They are named differently because the SLOT() macro thinks we want
+ * KonsoleBookmarkMenu::KBookmarkMenu::slotAboutToShow()
+ * Could this be solved if slotAboutToShow() is virtual in KBookmarMenu?
+ */
+ disconnect( _parentMenu, SIGNAL( aboutToShow() ), this,
+ SLOT( slotAboutToShow() ) );
+ connect( _parentMenu, SIGNAL( aboutToShow() ),
+ SLOT( slotAboutToShow2() ) );
+}
+
+/*
+ * Duplicate this exactly because KBookmarkMenu::slotBookmarkSelected can't
+ * be overrided. I would have preferred to NOT have to do this.
+ *
+ * Why did I do this?
+ * - when KBookmarkMenu::fillbBookmarkMenu() creates sub-KBookmarkMenus.
+ * - when ... adds KActions, it uses KBookmarkMenu::slotBookmarkSelected()
+ * instead of KonsoleBookmarkMenu::slotBookmarkSelected().
+ */
+void KonsoleBookmarkMenu::slotAboutToShow2()
+{
+ // Did the bookmarks change since the last time we showed them ?
+ if ( m_bDirty )
+ {
+ m_bDirty = false;
+ refill();
+ }
+}
+
+void KonsoleBookmarkMenu::refill()
+{
+ //kdDebug(1203) << "KBookmarkMenu::refill()" << endl;
+ m_lstSubMenus.clear();
+ QPtrListIterator<KAction> it( m_actions );
+ for (; it.current(); ++it )
+ it.current()->unplug( m_parentMenu );
+ m_parentMenu->clear();
+ m_actions.clear();
+ fillBookmarkMenu();
+ m_parentMenu->adjustSize();
+}
+
+void KonsoleBookmarkMenu::fillBookmarkMenu()
+{
+ if ( m_bIsRoot )
+ {
+ if ( m_bAddBookmark )
+ addAddBookmark();
+
+ addEditBookmarks();
+
+ if ( m_bAddBookmark )
+ addNewFolder();
+
+ if ( m_pManager->showNSBookmarks()
+ && QFile::exists( KNSBookmarkImporter::netscapeBookmarksFile() ) )
+ {
+ m_parentMenu->insertSeparator();
+
+ KActionMenu * actionMenu = new KActionMenu( i18n("Netscape Bookmarks"),
+ "netscape",
+ m_actionCollection, 0L );
+ actionMenu->plug( m_parentMenu );
+ m_actions.append( actionMenu );
+ KonsoleBookmarkMenu *subMenu = new KonsoleBookmarkMenu( m_pManager,
+ m_kOwner, actionMenu->popupMenu(),
+ m_actionCollection, false,
+ m_bAddBookmark, QString::null );
+ m_lstSubMenus.append(subMenu);
+ connect( actionMenu->popupMenu(), SIGNAL(aboutToShow()), subMenu,
+ SLOT(slotNSLoad()));
+ }
+ }
+
+ KBookmarkGroup parentBookmark = m_pManager->findByAddress( m_parentAddress ).toGroup();
+ Q_ASSERT(!parentBookmark.isNull());
+ bool separatorInserted = false;
+ for ( KBookmark bm = parentBookmark.first(); !bm.isNull();
+ bm = parentBookmark.next(bm) )
+ {
+ QString text = bm.text();
+ text.replace( '&', "&&" );
+ if ( !separatorInserted && m_bIsRoot) { // inserted before the first konq bookmark, to avoid the separator if no konq bookmark
+ m_parentMenu->insertSeparator();
+ separatorInserted = true;
+ }
+ if ( !bm.isGroup() )
+ {
+ if ( bm.isSeparator() )
+ {
+ m_parentMenu->insertSeparator();
+ }
+ else
+ {
+ // kdDebug(1203) << "Creating URL bookmark menu item for " << bm.text() << endl;
+ // create a normal URL item, with ID as a name
+ KAction * action = new KAction( text, bm.icon(), 0,
+ this, SLOT( slotBookmarkSelected() ),
+ m_actionCollection, bm.url().url().utf8() );
+
+ action->setStatusText( bm.url().prettyURL() );
+
+ action->plug( m_parentMenu );
+ m_actions.append( action );
+ }
+ }
+ else
+ {
+ // kdDebug(1203) << "Creating bookmark submenu named " << bm.text() << endl;
+ KActionMenu * actionMenu = new KActionMenu( text, bm.icon(),
+ m_actionCollection, 0L );
+ actionMenu->plug( m_parentMenu );
+ m_actions.append( actionMenu );
+ KonsoleBookmarkMenu *subMenu = new KonsoleBookmarkMenu( m_pManager,
+ m_kOwner, actionMenu->popupMenu(),
+ m_actionCollection, false,
+ m_bAddBookmark, bm.address() );
+ m_lstSubMenus.append( subMenu );
+ }
+ }
+
+ if ( !m_bIsRoot && m_bAddBookmark )
+ {
+ m_parentMenu->insertSeparator();
+ addAddBookmark();
+ addNewFolder();
+ }
+}
+
+void KonsoleBookmarkMenu::slotBookmarkSelected()
+{
+ KAction * a;
+ QString b;
+
+ if ( !m_pOwner ) return; // this view doesn't handle bookmarks...
+ a = (KAction*)sender();
+ b = a->text();
+ m_kOwner->openBookmarkURL( QString::fromUtf8(sender()->name()), /* URL */
+ ( (KAction *)sender() )->text() /* Title */ );
+}
+
+void KonsoleBookmarkMenu::slotNSBookmarkSelected()
+{
+ KAction *a;
+ QString b;
+
+ QString link(sender()->name()+8);
+ a = (KAction*)sender();
+ b = a->text();
+ m_kOwner->openBookmarkURL( link, /*URL */
+ ( (KAction *)sender() )->text() /* Title */ );
+}
+
+#include "konsolebookmarkmenu.moc"
diff --git a/kicker/menuext/konsole/konsolebookmarkmenu.h b/kicker/menuext/konsole/konsolebookmarkmenu.h
new file mode 100644
index 000000000..65e87f0f5
--- /dev/null
+++ b/kicker/menuext/konsole/konsolebookmarkmenu.h
@@ -0,0 +1,58 @@
+#ifndef KONSOLEBOOKMARKMENU_H
+#define KONSOLEBOOKMARKMENU_H
+
+#include <qptrlist.h>
+#include <qptrstack.h>
+#include <qobject.h>
+#include <sys/types.h>
+#include <kbookmark.h>
+#include <kbookmarkmenu.h>
+
+#include "konsolebookmarkhandler.h"
+
+
+class QString;
+class KBookmark;
+class KAction;
+class KActionMenu;
+class KActionCollection;
+class KBookmarkOwner;
+class KBookmarkMenu;
+class KPopupMenu;
+class KonsoleBookmarkMenu;
+
+class KonsoleBookmarkMenu : public KBookmarkMenu
+{
+ Q_OBJECT
+
+public:
+ KonsoleBookmarkMenu( KBookmarkManager* mgr,
+ KonsoleBookmarkHandler * _owner, KPopupMenu * _parentMenu,
+ KActionCollection *collec, bool _isRoot,
+ bool _add = true, const QString & parentAddress = "");
+
+ void fillBookmarkMenu();
+
+public slots:
+
+signals:
+
+private slots:
+
+private:
+ KonsoleBookmarkHandler * m_kOwner;
+
+protected slots:
+ void slotAboutToShow2();
+ void slotBookmarkSelected();
+ void slotNSBookmarkSelected();
+
+protected:
+ void refill();
+
+private:
+ class KonsoleBookmarkMenuPrivate;
+ KonsoleBookmarkMenuPrivate *d;
+};
+
+#endif // KONSOLEBOOKMARKMENU_H
diff --git a/kicker/menuext/konsole/konsolemenu.desktop b/kicker/menuext/konsole/konsolemenu.desktop
new file mode 100644
index 000000000..5766d7f03
--- /dev/null
+++ b/kicker/menuext/konsole/konsolemenu.desktop
@@ -0,0 +1,137 @@
+[Desktop Entry]
+Name=Terminal Sessions
+Name[af]=Terminaal Sessies
+Name[ar]=جلسات مطراف سطر الأوامر
+Name[az]=Terminal İclasları
+Name[be]=Тэрмінальныя сесіі
+Name[bg]=Терминални сесии
+Name[bn]=টার্মিনাল সেশন
+Name[br]=Dalc'hoù an termenell
+Name[bs]=Sesije terminala
+Name[ca]=Sessions de terminal
+Name[cs]=Terminálové relace
+Name[csb]=Sesëje terminala
+Name[cy]=Sesiynnau Terfynell
+Name[da]=Terminalsessioner
+Name[de]=Terminalsitzungen
+Name[el]=Συνεδρίες τερματικού
+Name[eo]=Terminalaj seancoj
+Name[es]=Sesiones de terminal
+Name[et]=Terminali seansid
+Name[eu]=Terminal saioak
+Name[fa]=نشستهای پایانه
+Name[fi]=Komentoikkunaistunnot
+Name[fr]=Sessions de terminal
+Name[fy]=Terminal-sesjes
+Name[ga]=Seisiúin Teirminéil
+Name[gl]=Sesións de Terminal
+Name[he]=משימות מסוף
+Name[hi]=टर्मिनल सत्र
+Name[hr]=Terminalske sesije
+Name[hu]=Terminálablakok
+Name[is]=Skjáhermisforrit
+Name[it]=Sessioni terminale
+Name[ja]=ターミナルセッション
+Name[ka]=სერმინალის სეანსები
+Name[kk]=Терминал сеанстары
+Name[km]=សម័យ​ស្ថានីយ
+Name[ko]=터미널 프로그램
+Name[lo]=ໂປຣແກຣມເທີມິເນລ
+Name[lt]=Terminalo sesijos
+Name[lv]=Termināla sesijas
+Name[mk]=Терминалски сесии
+Name[mn]=Терминал-Суултууд
+Name[ms]=Sesi Terminal
+Name[mt]=Sessjonijiet tat-terminal
+Name[nb]=Terminaløkter
+Name[nds]=Terminal-Törns
+Name[ne]=टर्मिनल सत्र
+Name[nl]=Terminal-sessies
+Name[nn]=Terminaløkter
+Name[nso]=Ditiragalo tsa Terminal
+Name[pa]=ਟਰਮੀਨਲ ਸ਼ੈਸ਼ਨ
+Name[pl]=Sesje terminala
+Name[pt]=Sessões de Terminal
+Name[pt_BR]=Sessões de Terminal
+Name[ro]=Sesiuni de terminal
+Name[ru]=Терминальные сеансы
+Name[rw]=Imikoro Ihera
+Name[se]=Terminálbargovuorut
+Name[sk]=Sedenia terminálu
+Name[sl]=Terminalske seje
+Name[sr]=Сесије терминала
+Name[sr@Latn]=Sesije terminala
+Name[sv]=Terminalsessioner
+Name[ta]=கடைசி அமர்வுகள்
+Name[te]=టెర్మినల్ సెషన్లు
+Name[tg]=Ҷаласаҳои терминал
+Name[th]=เซสชันของเทอร์มินัล
+Name[tr]=Uçbirim Oturumları
+Name[tt]=Terminal Sessiläre
+Name[uk]=Сеанси терміналів
+Name[uz]=Terminal seanslari
+Name[uz@cyrillic]=Терминал сеанслари
+Name[ven]=Zwitenwa zwa theminala
+Name[vi]=Phiên chạy đầu cuối
+Name[wa]=Sessions do terminå
+Name[xh]=Intlanganiso Yesiphelo sendlela
+Name[zh_CN]=终端会话
+Name[zh_TW]=終端機工作階段
+Name[zu]=Iziqendu Zangaphandle
+Comment=Menu for starting a terminal emulator with a session or bookmark
+Comment[af]='n Kieslys wat 'n terminaal emuleerder met 'n sessie of boekmerk kan begin
+Comment[ar]=قائمة لبدء تشغيل مضاهِ مطراف مع جلسة أو علامة موقع
+Comment[be]=Меню для запуску эмулятара тэрміналу з сесіяй ці закладкай
+Comment[bg]=Меню за стартиране на сесия в терминален прозорец
+Comment[bs]=Meni za pokretanje simulatora terminala sa sesijom ili zabilješkom
+Comment[ca]=Menú per engegar un emulador de terminal amb una sessió o punt
+Comment[cs]=Nabídka pro spuštění teminálu s relací nebo záložkou
+Comment[csb]=Menu zrëszëniô òkna terminala ze spamiãtóną sesëją abò załóżka
+Comment[da]=Menu til at starte en terminalemulator med en session eller bogmærke
+Comment[de]=Menü zum Starten des Terminal-Emulators mit einer Sitzung oder Lesezeichen
+Comment[el]=Μενού για την εκκίνηση ενός εξομοιωτή τερματικού με μια συνεδρία ή σελιδοδείκτη
+Comment[eo]=Menuo por lanĉi terminalsimulilon jam ŝarĝita kun seaco aŭ legosigno
+Comment[es]=Menú para iniciar un emulador de terminal con una sesión o marcador
+Comment[et]=Menüü seansi või järjehoidja käivitamiseks terminali emulaatoris
+Comment[eu]=Terminal emuladorea saio edo laster-markaz abiarazteko menua
+Comment[fa]=گزینگانی برای آغاز مقلد پایانه، توسط یک نشست یا چوب ‌الف
+Comment[fi]=Valikko pääteikkunan käynnistämiseen istunnon tai kirjanmerkin kanssa
+Comment[fr]=Menu permettant de démarrer un émulateur de terminal à partir d'une session ou un signet
+Comment[fy]=Menu foar it begjinnen fan in terminalemulaasje mei in sesje of blêdwizer
+Comment[gl]=Menu para lanzar un emulador de terminal
+Comment[he]=תפריט להפעלת מסוף עם הפעלה או סימנייה
+Comment[hr]=Izbornik za pokretanje terminalske emulacije putem sesije ili oznake
+Comment[hu]=Menü parancsértelmező indításához (könyvjelzővel is)
+Comment[is]=Valmynd til að ræsa skjáhermi með setu eða bókamerki
+Comment[it]=Menu per l'emulatore di terminale con una data sessione o segnalibro
+Comment[ja]=指定したセッションやブックマーク先でターミナルエミュレータを起動します
+Comment[kk]=Терминал сеансын не бетбелгіні ашу мәзірі
+Comment[km]=ម៉ឺនុយ​សម្រាប់​ចាប់ផ្ដើម​កម្មវិធី​ត្រាប់តាម​កម្មវិធី​ស្ថានីយ​ជា​មួយ​នឹង​សម័យ ឬ​ចំណាំ
+Comment[lt]=Meniu terminalo emuliatoriaus paleidimui su tam tikra sesija ar - nuo žymeklio
+Comment[mk]=Мени за стартување на терминалски емулатор со сесија или обележувач
+Comment[nb]=Meny for å starte en terminalemulator med en økt eller et bokmerke
+Comment[nds]=Menü för dat Starten vun en Terminal-Emulator mit Leestekens oder Törns
+Comment[ne]=सत्र वा पुस्तकचिनोसँग टर्मिनल इमुलेटर सुरुआत गर्नका लागि मेनु
+Comment[nl]=Menu voor het starten van een terminalemulatie met een sessie of bladwijzer
+Comment[nn]=Meny for å starta ein terminalemulator med ei økt eller eit bokmerke
+Comment[pl]=Menu uruchomienia okna terminala z zapamiętaną sesją lub zakładką
+Comment[pt]=Um menu para iniciar um emulador de terminal com uma sessão ou favorito
+Comment[pt_BR]=Menu para início de um emulador de terminal, com uma sessão ou favorito
+Comment[ro]=Meniu pentru pornirea unui emulator de terminal cu o sesiune sau semn de carte
+Comment[ru]=Быстрый доступ к сеансам и закладкам терминала
+Comment[sk]=Menu pre spustenie emulátora terminálu so sedením alebo záložkou
+Comment[sl]=Meni za zaganjanje terminalskega emulatorja s sejo ali zaznamkom
+Comment[sr]=Мени за покретање емулатора терминала са сесијом или маркером
+Comment[sr@Latn]=Meni za pokretanje emulatora terminala sa sesijom ili markerom
+Comment[sv]=Meny för att starta en terminalemulator med en session eller bokmärke
+Comment[th]=เมนูสำหรับเริ่มโปรแกรมจำลองเทอร์มินัล พร้อมกับวาระ หรือที่คั่นหน้า
+Comment[tr]=Bir uçbirim düzenleyiciyi oturum ya da yer imi ile açmanızı sağlar
+Comment[uk]=Меню для запуску терміналу емулятора через сеанс або закладку
+Comment[vi]=Thực đơn chạy một trình đầu cuối với một phiên chạy hay một địa chỉ lưu trong sổ
+Comment[wa]=Dressêye po-z enonder on terminå avou ene session ou ene rimåke
+Comment[zh_CN]=以会话或书签启动终端模拟器的菜单
+Comment[zh_TW]=用來啟動作業階段和書籤的終端機模擬程式的選單
+Icon=konsole
+
+X-KDE-Library=kickermenu_konsole
+X-KDE-AuthorizeAction=shell_access