34 from dbus
import Interface
35 from dbus.connection
import Connection
36 from python_qt_binding.QtCore
import (QByteArray, qCritical, QDataStream,
37 qDebug, QIODevice, Qt, qWarning, Slot)
38 from python_qt_binding.QtGui
import QVBoxLayout, QX11EmbedWidget
47 Client part of the `PluginHandlerXEmbed`. 49 Client utilizes the `PluginHandlerDBusService` of the `PluginHandlerXEmbedContainer` through a 50 peer-to-peer DBus connection. 53 def __init__(self, parent, main_window, instance_id,
54 application_context, container_manager, argv, dbus_object_path):
55 super(PluginHandlerXEmbedClient, self).
__init__(
56 parent, main_window, instance_id, application_context, container_manager, argv)
57 self.setObjectName(
'PluginHandlerXEmbedClient')
66 conn = Connection(self._application_context.options.embed_plugin_address)
68 self.
_remote_container = Interface(proxy,
'org.ros.qt_gui.PluginHandlerContainer')
69 self._remote_container.connect_to_signal(
'shutdown_plugin', self.
_shutdown_plugin)
71 self._remote_container.connect_to_signal(
73 self._remote_container.connect_to_signal(
75 self._remote_container.connect_to_signal(
83 super(PluginHandlerXEmbedClient, self).
_load()
87 if exception
is not None:
88 self._remote_container.load_completed(
False,
False)
99 self._remote_container.shutdown_plugin_completed()
106 qDebug(
'PluginHandlerXEmbedClient._save_settings_from_remote()')
113 'PluginHandlerXEmbedClient._save_settings_from_remote() plugin "%s" ' 114 'raised an exception:\n%s' % (str(self.
_instance_id), traceback.format_exc()))
118 self._remote_container.save_settings_completed()
125 qDebug(
'PluginHandlerXEmbedClient._restore_settings_from_remote()')
132 'PluginHandlerXEmbedClient._restore_settings_from_remote() ' 133 'plugin "%s" raised an exception:\n%s' %
138 self._remote_container.restore_settings_completed()
144 qWarning(
'PluginHandlerXEmbedClient.add_widget() widget "%s" already added' %
147 embed_widget = QX11EmbedWidget()
148 layout = QVBoxLayout()
149 layout.setContentsMargins(0, 0, 0, 0)
150 layout.addWidget(widget)
151 embed_widget.setLayout(layout)
157 embed_container_window_id = self._remote_container.embed_widget(
158 os.getpid(), widget.objectName())
159 embed_widget.embedInto(embed_container_window_id)
166 signaler.window_icon_changed_signal.emit(widget)
167 signaler.window_title_changed_signal.emit(widget)
174 s = QDataStream(ba, QIODevice.WriteOnly)
175 s << widget.windowIcon()
176 icon_str = str(ba.toBase64())
177 self._remote_container.update_embedded_widget_icon(widget.objectName(), icon_str)
180 self._remote_container.update_embedded_widget_title(
181 widget.objectName(), widget.windowTitle())
190 self._remote_container.unembed_widget(widget.objectName())
192 widget.setParent(
None)
193 embed_widget.deleteLater()
200 qWarning(
'PluginHandlerXEmbedClient.add_toolbar() toolbar "%s" already added' %
201 toolbar.objectName())
203 embed_widget = QX11EmbedWidget()
204 layout = QVBoxLayout()
205 layout.setContentsMargins(0, 0, 0, 0)
206 layout.addWidget(toolbar)
207 embed_widget.setLayout(layout)
213 print(
'embed_widget.containerClosed')
214 embed_widget.containerClosed.connect(foo)
216 embed_container_window_id = self._remote_container.embed_toolbar(
217 os.getpid(), toolbar.objectName())
218 embed_widget.embedInto(embed_container_window_id)
225 for toolbar, (embed_widget, _)
in self._embed_widgets.items():
226 if embed_widget.containerWinId() == win_id:
227 toolbar.setOrientation(Qt.Horizontal
if is_horizontal
else Qt.Vertical)
235 self._remote_container.unembed_widget(toolbar.objectName())
237 toolbar.setParent(
None)
238 embed_widget.deleteLater()
242 self._remote_container.close_plugin()
def remove_toolbar(self, toolbar)
def add_widget(self, widget)
def _on_embed_widget_icon_changed(self, widget)
def emit_shutdown_plugin_completed(self)
def emit_save_settings_completed(self)
def _emit_load_completed(self, exception=None)
def _restore_settings_from_remote(self)
_plugin_has_configuration
def add_toolbar(self, toolbar)
def shutdown_plugin(self, callback)
def _trigger_configuration(self)
def _save_settings_from_remote(self)
def emit_restore_settings_completed(self)
def emit_restore_settings_completed(self)
def _toolbar_orientation_changed(self, win_id, is_horizontal)
def _emit_close_plugin(self)
_remote_instance_settings
def save_settings(self, plugin_settings, instance_settings, callback=None)
def _restore_settings(self, plugin_settings, instance_settings)
def __init__(self, parent, main_window, instance_id, application_context, container_manager, argv, dbus_object_path)
def emit_save_settings_completed(self)
def restore_settings(self, plugin_settings, instance_settings, callback=None)
def _shutdown_plugin(self)
def remove_widget(self, widget)
def _save_settings(self, plugin_settings, instance_settings)
def _on_embed_widget_title_changed(self, widget)