def __init__(self): super(BusNameInfoBox, self).__init__() self.busname = None ui = UILoader(UILoader.UI_INTROSPECTVIEW) info_table = ui.get_root_widget() self.name_label = ui.get_widget('name_label1') self.unique_name_label = ui.get_widget('unique_name_label1') self.process_label = ui.get_widget('process_label1') self.introspection_box = ui.get_widget('introspect_box1') self.introspect_tree_view = gtk.TreeView() button_renderer = gtk.CellRendererPixbuf() text_renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("Introspection Data", None) column.pack_start(button_renderer, False) column.pack_start(text_renderer, True) column.add_attribute(button_renderer, 'icon-name', IntrospectData.ICON_NAME_COL) column.add_attribute(text_renderer, 'markup', IntrospectData.DISPLAY_COL) column.set_cell_data_func(text_renderer, self.text_cell_data_handler, self.introspect_tree_view) self.introspect_tree_view.connect('row-collapsed', self.row_collapsed_handler) self.introspect_tree_view.connect('row-expanded', self.row_expanded_handler) self.introspect_tree_view.connect('cursor-changed', self.cursor_changed_handler) self.introspect_tree_view.append_column(column) scroll = gtk.ScrolledWindow() scroll.add(self.introspect_tree_view) self.introspection_box.pack_start(scroll, True, True) scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.introspect_tree_view.show_all() self.add(info_table) self.introspect_tree_view.connect('row-activated', self.row_activated_handler)
def __init__(self, parent): ui = UILoader(UILoader.UI_ADDCONNECTIONDIALOG) self.dialog = ui.get_root_widget() self.combo_entry = ui.get_widget('address_comboentry1') self.dialog.add_button('gtk-cancel', -1) self.dialog.add_button('gtk-connect', 1)
def __init__(self, busname, method): signal_dict = {"execute_dbus_method_cb": self.execute_cb, "execute_dialog_close_cb": self.close_cb} ui = UILoader(UILoader.UI_EXECUTEDIALOG) self.dialog = ui.get_root_widget() self.command_label = ui.get_widget("commandlabel1") self.notebook = ui.get_widget("notebook1") self.parameter_textview = ui.get_widget("parametertextview1") self.source_textview = ui.get_widget("sourcetextview1") self.notebook.set_tab_label_text(self.source_textview.get_parent(), "Source") self.prettyprint_textview = ui.get_widget("prettyprinttextview1") self.notebook.set_tab_label_text(self.prettyprint_textview.get_parent(), "Pretty Print") ui.connect_signals(signal_dict) self.busname = busname self.method = method # FIXME: get the interface and object path text = "Execute " + str(self.method) self.command_label.set_text(text)
def __init__(self, watch): super(BusBox, self).__init__() # FilterBox signal_dict = { 'hide_private_toggled' : self.hide_private_toggled_cb, 'filter_entry_changed': self.filter_entry_changed_cb } self.bus_watch = watch ui = UILoader(UILoader.UI_FILTERBOX) filter_box = ui.get_root_widget() filter_entry = ui.get_widget('filter_entry1') self.pack_start(filter_box, False, False) self.completion = gtk.EntryCompletion() self.completion.set_model(watch) self.completion.set_inline_completion(True) # older gtk+ does not support this method call # but it is not fatal try: self.completion.set_inline_selection(True) except: pass filter_entry.set_completion(self.completion) # Content self.paned = gtk.HPaned() self.busname_box = BusNameBox(watch) self.busname_info_box = BusNameInfoBox() self.busname_box.connect('busname-selected', self.busname_selected_cb) self.busname_info_box.connect('selected', self.busname_info_selected_cb) self.paned.pack1(self.busname_box) self.paned.pack2(self.busname_info_box) self.paned.set_position(300) self.pack_start(self.paned, True, True) ui.connect_signals(signal_dict)
def __init__(self, busname, buspath, busiface=None, xslttype=0): signal_dict = { 'export_dbus_path_cb' : self.export_cb, 'export_dialog_close_cb': self.close_cb, 'chooserforxlst_file_set_cb': self.choose_file_Cb, 'chooserforresult_file_set_cb': self.choose_file_Cb, } ui = UILoader(UILoader.UI_EXPORTDIALOG) self.dialog = ui.get_root_widget() self._lblbusname = ui.get_widget('busname') self._lblobjectpath = ui.get_widget('objectpath') self._lblinterface = ui.get_widget('interface') self._chooserxsltlabel = ui.get_widget('labelforxslt') self._chooserxslt = ui.get_widget('chooserforxlst') self._information = ui.get_widget('exportinfo') ui.connect_signals(signal_dict) self.busname = busname self.buspath = buspath self.busiface = busiface self.xslttype = xslttype self._lblbusname.set_text(busname.get_bus_name()) self._lblobjectpath.set_text(buspath) self._lblinterface.set_text(busiface or '*') self.information = "" self.resultfile = None self.xsltfile = None try: if len(XLST_TYPES) > xslttype: self._chooserxsltlabel.set_text( XLST_TYPES[xslttype].get('title', 'Choose one xslt file')) if XLST_TYPES[xslttype].has_key('file'): self.xsltfile = XLST_TYPES[xslttype]['file'] self._chooserxslt.destroy() elif xslttype is XMLN: self._chooserxslt.destroy() except Exception as e: print e self._information.set_text('Fail to open xslt, choose other.')
class MonitorBox(Gtk.VBox): """Class to handle dbus monitor interface""" def __del__(self): try: self.stop() except: pass def __exit__(self): self.__del__() def __init__(self, busname, dbusmonitor, data_dir, *args, **kw): self.busname = busname self.dbusmonitor = dbusmonitor self.callback = None self.data_dir = data_dir self.ui = UILoader(data_dir, UILoader.UI_MONITORBOX) self.root_widget = self.ui.get_root_widget() self.__init_gtk() def __init_gtk(self): Gtk.VBox.__init__(self) self.connect('destroy', self.stop) self.add(self.ui.get_root_widget()) self.root_widget.show_all() self.show_all() #callback @thread_locking def register_message(self, bus, message, dbusmonitor, *args, **kws): textview = self.ui.get_widget('monitortextview') formated_msg = DbusMonitor.message_printer(message) text_buffer = textview.get_buffer() text_buffer.insert_at_cursor(formated_msg) def start(self, *args, **kws): def _filter_cb(bus, message, dbusmonitor, * args, **kws): return self.register_message(bus, message, dbusmonitor, *args, **kws) self.callback = _filter_cb self.dbusmonitor.start(_filter_cb) def stop(self, *args, **kws): if self.callback: self.dbusmonitor.stop() self.callback = None #constructor helpers @staticmethod def new_with_monitor(busname, sender=None, path=None, interface=None, mtype=None, member=None, *args, **kws): ''' Create one new MonitorBox with parameters: sender: busname of who are sending message path: object path of who are sending message interface: dbus interface mtype: type of member, one of: MonitorDialog.MSG_ERROR for error messages only MonitorDialog.MSG_SINGAL for signal messages only MonitorDialog.MSG_METHOD for method call messages only MonitorDialog.MSG_RETURN for method return messages only member: member to be watched (name of method or signal) more args are converted in filter see: http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules ''' return MonitorBox(busname, sender=sender, path=path, interface=interface, mtype=mtype, member=member, *args, **kws)
class MonitorBox(gtk.VBox): __gsignals__ = { 'started': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)), 'stoped': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)), } def __init__(self, busname, dbusmonitor, *args, **kw): signal_dict = { 'destroy_monitor_box_cb' : self.stop, } gtk.VBox.__init__(self) self.connect('destroy', self.stop) self.ui = UILoader(UILoader.UI_MONITORBOX) self.root_widget = self.ui.get_root_widget() self.busname = busname self.dbusmonitor = dbusmonitor self.ui.connect_signals(signal_dict) self.textviews = { DbusMonitor.MSG_ERROR: 'errostextview', DbusMonitor.MSG_METHOD: 'calltextview', DbusMonitor.MSG_RETURN: 'resulttextview', DbusMonitor.MSG_SIGNAL: 'signalstextview', } self.callback = None self.root_widget.show_all() self.add(self.ui.get_root_widget()) self.show_all() #callback def monitore(self, bus, message, dbusmonitor, *args, **kws): print 'rule: ', dbusmonitor.rule print DbusMonitor.message_printer(message) mtype = message.get_type() if mtype in self.textviews.keys(): self.ui.get_widget(self.textviews.get(mtype))\ .get_buffer().insert_at_cursor(DbusMonitor.message_printer(message)) def start(self, *args, **kws): def _filter_cb(bus, message, dbusmonitor, * args, **kws): return self.monitore(bus, message, dbusmonitor, *args, **kws) self.callback = _filter_cb self.dbusmonitor.start(_filter_cb) self.emit('started', self.dbusmonitor) def stop(self, *args, **kws): if self.callback: self.dbusmonitor.stop() self.callback = None self.emit('stoped', self.dbusmonitor) #constructor helpers @staticmethod def new_with_monitor(busname, sender=None, path=None, interface=None, mtype=None, member=None, *args, **kws): ''' Create one new MonitorBox with parameters: sender: busname of who are sending message path: object path of who are sending message interface: dbus interface mtype: type of member, one of: MonitorDialog.MSG_ERROR for error messages only MonitorDialog.MSG_SINGAL for signal messages only MonitorDialog.MSG_METHOD for method call messages only MonitorDialog.MSG_RETURN for method return messages only member: member to be watched (name of method or signal) more args are converted in filter see: http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules ''' return MonitorBox(busname, sender=sender, path=path, interface=interface, mtype=mtype, member=member, *args, **kws)