Commit 07cddfe3 authored by Jekyll Wu's avatar Jekyll Wu

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
parent 39a857b0
...@@ -457,6 +457,8 @@ Session* Application::createSession(Profile::Ptr profile, ...@@ -457,6 +457,8 @@ Session* Application::createSession(Profile::Ptr profile,
&& profile->property<bool>(Profile::StartInCurrentSessionDir)) && profile->property<bool>(Profile::StartInCurrentSessionDir))
session->setInitialWorkingDirectory(directory); 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 // create view before starting the session process so that the session
// doesn't suffer a change in terminal size right after the session // doesn't suffer a change in terminal size right after the session
// starts. Some applications such as GNU Screen and Midnight Commander // starts. Some applications such as GNU Screen and Midnight Commander
......
...@@ -843,6 +843,11 @@ void Session::setEnvironment(const QStringList& environment) ...@@ -843,6 +843,11 @@ void Session::setEnvironment(const QStringList& environment)
_environment = environment; _environment = environment;
} }
void Session::addEnvironmentEntry(const QString& entry)
{
_environment << entry;
}
int Session::sessionId() const int Session::sessionId() const
{ {
return _sessionId; return _sessionId;
......
...@@ -378,6 +378,8 @@ public slots: ...@@ -378,6 +378,8 @@ public slots:
*/ */
Q_SCRIPTABLE void setEnvironment(const QStringList& environment); Q_SCRIPTABLE void setEnvironment(const QStringList& environment);
void addEnvironmentEntry(const QString& entry);
/** /**
* Closes the terminal session. It kills the terminal process by calling * Closes the terminal session. It kills the terminal process by calling
* closeInNormalWay() and, optionally, closeInForceWay(). * closeInNormalWay() and, optionally, closeInForceWay().
......
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
using namespace Konsole; using namespace Konsole;
int ViewManager::lastManagerId = 0;
ViewManager::ViewManager(QObject* parent , KActionCollection* collection) ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
: QObject(parent) : QObject(parent)
, _viewSplitter(0) , _viewSplitter(0)
...@@ -61,6 +63,7 @@ ViewManager::ViewManager(QObject* parent , KActionCollection* collection) ...@@ -61,6 +63,7 @@ ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
, _navigationPosition(ViewContainer::NavigationPositionTop) , _navigationPosition(ViewContainer::NavigationPositionTop)
, _showQuickButtons(false) , _showQuickButtons(false)
, _newTabBehavior(PutNewTabAtTheEnd) , _newTabBehavior(PutNewTabAtTheEnd)
, _managerId(0)
{ {
// create main view area // create main view area
_viewSplitter = new ViewSplitter(0); _viewSplitter = new ViewSplitter(0);
...@@ -96,12 +99,20 @@ ViewManager::ViewManager(QObject* parent , KActionCollection* collection) ...@@ -96,12 +99,20 @@ ViewManager::ViewManager(QObject* parent , KActionCollection* collection)
new KonsoleAdaptor(this); new KonsoleAdaptor(this);
QDBusConnection::sessionBus().registerObject(QLatin1String("/Konsole"), this); QDBusConnection::sessionBus().registerObject(QLatin1String("/Konsole"), this);
_managerId = ++lastManagerId;
QDBusConnection::sessionBus().registerObject(QLatin1String("/Windows/") + QString::number(_managerId), this);
} }
ViewManager::~ViewManager() ViewManager::~ViewManager()
{ {
delete _newViewMenu; delete _newViewMenu;
} }
int ViewManager::managerId() const
{
return _managerId;
}
QMenu* ViewManager::createNewViewMenu() QMenu* ViewManager::createNewViewMenu()
{ {
if (_newViewMenu) if (_newViewMenu)
......
...@@ -178,6 +178,8 @@ public: ...@@ -178,6 +178,8 @@ public:
void updateNavigationOptions(NavigationOptions options); void updateNavigationOptions(NavigationOptions options);
void applyNavigationOptions(ViewContainer* container); void applyNavigationOptions(ViewContainer* container);
int managerId() const;
signals: signals:
/** Emitted when the last view is removed from the view manager */ /** Emitted when the last view is removed from the view manager */
void empty(); void empty();
...@@ -389,6 +391,9 @@ private: ...@@ -389,6 +391,9 @@ private:
ViewContainer::NavigationPosition _navigationPosition; ViewContainer::NavigationPosition _navigationPosition;
bool _showQuickButtons; bool _showQuickButtons;
NewTabBehavior _newTabBehavior; NewTabBehavior _newTabBehavior;
int _managerId;
static int lastManagerId;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment