summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-02-08 17:49:35 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-02-08 17:50:43 (GMT)
commit07cddfe302233c3555258f077429e55ce622e262 (patch)
tree14804c89f8e02fed51812ff21703b12de13da96b
parent39a857b03731b3f1fcfa85c42bb8324a3eeeabec (diff)
Create dbus object for each Konsole window respectively
Its naming scheme is "/Windows/N", similar to "/Sessions/N" for sessions. That is not the final decision and might change before next major release. The old "/Konsole" dbus object is still available at this moment, but it might disappear or be used for something different in the future, so it is better to use "/Windows/N" from now on. For convenience, $KONSOLE_DBUS_WINDOW can be used to refer to the dbus object corresponding to the Konsole window containing current session. Note, that environment variable does not work well with detaching and draging. Maybe it should not be added at all. CCBUG:276912 CCBUG:281513 CCBUG:292309 REVIEW:103790
-rw-r--r--src/Application.cpp2
-rw-r--r--src/Session.cpp5
-rw-r--r--src/Session.h2
-rw-r--r--src/ViewManager.cpp11
-rw-r--r--src/ViewManager.h5
5 files changed, 25 insertions, 0 deletions
diff --git a/src/Application.cpp b/src/Application.cpp
index 060b1c9..237496b 100644
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -457,6 +457,8 @@ Session* Application::createSession(Profile::Ptr profile,
&& profile->property<bool>(Profile::StartInCurrentSessionDir))
session->setInitialWorkingDirectory(directory);
+ session->addEnvironmentEntry( QString("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(viewManager->managerId()) );
+
// create view before starting the session process so that the session
// doesn't suffer a change in terminal size right after the session
// starts. Some applications such as GNU Screen and Midnight Commander
diff --git a/src/Session.cpp b/src/Session.cpp
index c8f33d4..01b62bf 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -843,6 +843,11 @@ void Session::setEnvironment(const QStringList& environment)
_environment = environment;
}
+void Session::addEnvironmentEntry(const QString& entry)
+{
+ _environment << entry;
+}
+
int Session::sessionId() const
{
return _sessionId;
diff --git a/src/Session.h b/src/Session.h
index 4f869c5..d4b16ad 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -378,6 +378,8 @@ public slots:
*/
Q_SCRIPTABLE void setEnvironment(const QStringList& environment);
+ void addEnvironmentEntry(const QString& entry);
+
/**
* Closes the terminal session. It kills the terminal process by calling
* closeInNormalWay() and, optionally, closeInForceWay().
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index 987ae33..f39cda4 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -50,6 +50,8 @@
using namespace Konsole;
+int ViewManager::lastManagerId = 0;
+
ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
: QObject(parent)
, _viewSplitter(0)
@@ -61,6 +63,7 @@ ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
, _navigationPosition(ViewContainer::NavigationPositionTop)
, _showQuickButtons(false)
, _newTabBehavior(PutNewTabAtTheEnd)
+ , _managerId(0)
{
// create main view area
_viewSplitter = new ViewSplitter(0);
@@ -96,12 +99,20 @@ ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
new KonsoleAdaptor(this);
QDBusConnection::sessionBus().registerObject(QLatin1String("/Konsole"), this);
+ _managerId = ++lastManagerId;
+ QDBusConnection::sessionBus().registerObject(QLatin1String("/Windows/") + QString::number(_managerId), this);
}
ViewManager::~ViewManager()
{
delete _newViewMenu;
}
+
+int ViewManager::managerId() const
+{
+ return _managerId;
+}
+
QMenu* ViewManager::createNewViewMenu()
{
if (_newViewMenu)
diff --git a/src/ViewManager.h b/src/ViewManager.h
index 5e0d437..3c84d88 100644
--- a/src/ViewManager.h
+++ b/src/ViewManager.h
@@ -178,6 +178,8 @@ public:
void updateNavigationOptions(NavigationOptions options);
void applyNavigationOptions(ViewContainer* container);
+ int managerId() const;
+
signals:
/** Emitted when the last view is removed from the view manager */
void empty();
@@ -389,6 +391,9 @@ private:
ViewContainer::NavigationPosition _navigationPosition;
bool _showQuickButtons;
NewTabBehavior _newTabBehavior;
+
+ int _managerId;
+ static int lastManagerId;
};
}