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()
def _trigger_configuration(self)
def remove_widget(self, widget)
def load_completed(self, loaded, has_configuration)
def embed_widget(self, pid, widget_object_name)
def update_embedded_widget_title(self, widget_object_name, title)
def remove_toolbar(self, toolbar)
def unembed_toolbar(self, toolbar_object_name)
def emit_save_settings_completed(self)
def _emit_close_plugin(self)
def _add_toolbar(self, toolbar)
def embed_toolbar(self, pid, toolbar_object_name)
def update_embedded_widget_icon(self, widget_object_name, icon_str)
_plugin_has_configuration
def _print_process_error(self)
def save_settings(self, plugin_settings, instance_settings, callback=None)
def _print_process(self, data, method)
def unembed_widget(self, widget_object_name)
def shutdown_plugin(self, callback)
def _emit_load_completed(self, exception=None)
_dbus_instance_settings_service
def _on_toolbar_orientation_changed(self, toolbar_object_name)
def restore_settings(self, plugin_settings, instance_settings, callback=None)
def _emit_unload_completed(self)
def _update_title_bars(self)
def emit_shutdown_plugin_completed(self)
def _add_dbus_connection(self, conn)
def emit_restore_settings_completed(self)
def _create_dock_widget(self)
def _add_dock_widget(self, dock_widget, widget)
_dbus_plugin_settings_service
def __init__(self, parent, main_window, instance_id, application_context, container_manager, argv, dbus_object_path)
def _shutdown_plugin(self)
def _restore_settings(self, plugin_settings, instance_settings)
def _print_process_output(self)
def _save_settings(self, plugin_settings, instance_settings)