Exemple #1
0
    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)
Exemple #2
0
    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.')
    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)
Exemple #4
0
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)