33 from dbus.server
import Server
34 from python_qt_binding
import QT_BINDING
35 from python_qt_binding.QtCore
import (QByteArray, QDataStream, qDebug, QIODevice,
36 QProcess, QSignalMapper, Qt, qWarning)
37 from python_qt_binding.QtGui
import QIcon, QToolBar, QX11EmbedContainer
47 Server part of the `PluginHandlerXEmbed`.
49 Starts the plugin in a subprocess and provides the `PluginHandlerDBusService` through a
50 peer-to-peer DBus connection.
55 def __init__(self, parent, main_window, instance_id,
56 application_context, container_manager, argv, dbus_object_path):
57 super(PluginHandlerXEmbedContainer, self).
__init__(
58 parent, main_window, instance_id, application_context, container_manager, argv)
59 self.setObjectName(
'PluginHandlerXEmbedContainer')
77 if not Main.main_filename:
79 'PluginHandlerXEmbedContainer._load() '
80 'filename of initially started script is unknown')
91 self.
_process.setProcessChannelMode(QProcess.SeparateChannels)
96 cmd = sys.executable +
' -u'
97 cmd +=
' %s' % Main.main_filename
98 cmd +=
' --qt-binding=%s' % QT_BINDING
99 cmd +=
' --embed-plugin=%s --embed-plugin-serial=%s --embed-plugin-address=%s' % (
103 cmd +=
' --args %s' %
' '.join(self.
argv())
106 started = self.
_process.waitForStarted(3000)
112 'PluginHandlerXEmbedContainer._load() could not start '
113 'subprocess in reasonable time')
122 qDebug(
'PluginHandlerXEmbedContainer._load() started subprocess (#%s) for plugin "%s"' %
142 lines = str(data).split(
'\n')
146 method(
' %d %s' % (self.
_pid, line))
150 exception =
None if loaded
else True
156 qDebug(
'PluginHandlerXEmbedContainer._shutdown_plugin()')
167 if self.
_process.state() != QProcess.NotRunning:
174 qDebug(
'PluginHandlerXEmbedContainer._unload()')
178 qDebug(
'PluginHandlerXEmbedContainer._save_settings()')
189 qDebug(
'PluginHandlerXEmbedContainer._restore_settings()')
204 embed_container = QX11EmbedContainer(dock_widget)
209 return embed_container.winId()
214 ba = QByteArray.fromBase64(icon_str)
215 s = QDataStream(ba, QIODevice.ReadOnly)
218 embed_container.setWindowIcon(icon)
222 embed_container.setWindowTitle(title)
231 toolbar.setObjectName(toolbar_object_name)
232 embed_container = QX11EmbedContainer(toolbar)
233 toolbar.addWidget(embed_container)
241 return embed_container.winId()
247 embed_container.winId(), toolbar.orientation() == Qt.Horizontal)
254 embed_container.close()