def __init__(self, data_dir, connection, connection_is_bus, bus_name, method_obj, parent_window): signal_dict = { 'execute_dbus_method_cb': self.execute_cb, 'execute_dialog_close_cb': self.close_cb } self.connection = connection self.connection_is_bus = connection_is_bus self.bus_name = bus_name self.method_obj = method_obj ui = UILoader(data_dir, UILoader.UI_EXECUTEDIALOG) self.dialog = ui.get_root_widget() self.dialog.set_transient_for(parent_window) self.label_method_name = ui.get_widget('label_method_name') self.label_bus_name = ui.get_widget('label_bus_name') self.label_object_path = ui.get_widget('label_object_path') self.label_interface = ui.get_widget('label_interface') self.notebook = ui.get_widget('notebook1') self.parameter_textview = ui.get_widget('parametertextview1') self.source_textview = ui.get_widget('sourcetextview1') self.prettyprint_textview = ui.get_widget('prettyprinttextview1') self.method_execution_count_spinbutton = ui.get_widget( 'method_exec_count_spinbutton') self.label_avg = ui.get_widget('label_avg') self.label_min = ui.get_widget('label_min') self.label_max = ui.get_widget('label_max') ui.connect_signals(signal_dict) self.label_method_name.set_markup("%s" % (self.method_obj.markup_str)) self.label_bus_name.set_text(self.bus_name) self.label_object_path.set_markup("%s" % (self.method_obj.object_path)) self.label_interface.set_markup("%s" % (self.method_obj.iface_info.name))
def __init__(self, data_dir, connection, connection_is_bus, bus_name, method_obj): signal_dict = { 'execute_dbus_method_cb': self.execute_cb, 'execute_dialog_close_cb': self.close_cb } self.connection = connection self.connection_is_bus = connection_is_bus self.bus_name = bus_name self.method_obj = method_obj ui = UILoader(data_dir, UILoader.UI_EXECUTEDIALOG) self.dialog = ui.get_root_widget() self.label_method_name = ui.get_widget('label_method_name') self.label_object_path = ui.get_widget('label_object_path') self.label_interface = ui.get_widget('label_interface') self.notebook = ui.get_widget('notebook1') self.parameter_textview = ui.get_widget('parametertextview1') self.source_textview = ui.get_widget('sourcetextview1') self.prettyprint_textview = ui.get_widget('prettyprinttextview1') self.method_execution_count_spinbutton = ui.get_widget('method_exec_count_spinbutton') self.label_avg = ui.get_widget('label_avg') self.label_min = ui.get_widget('label_min') self.label_max = ui.get_widget('label_max') ui.connect_signals(signal_dict) self.label_method_name.set_markup("%s" % (self.method_obj.markup_str)) self.label_object_path.set_markup("%s" % (self.method_obj.object_path)) self.label_interface.set_markup("%s" % (self.method_obj.iface_info.name))
def __init__(self, data_dir, address, name, unique_name, connection_is_bus=True): self.data_dir = data_dir signal_dict = { 'treeview_row_activated_cb': self.__treeview_row_activated_cb, 'treeview_row_expanded_cb': self.__treeview_row_expanded_cb, 'button_reload_clicked_cb': self.__button_reload_clicked_cb, } self.address = address # can be Gio.BusType.SYSTEM or Gio.BusType.SYSTEM or other address self.name = name # the well-known name or None self.unique_name = unique_name # the unique name or None self.connection_is_bus = connection_is_bus # is it a bus or a p2p connection? # setup UI ui = UILoader(self.data_dir, UILoader.UI_INTROSPECTION) self.introspect_box = ui.get_root_widget() # this is the main box with the treeview self.__spinner = ui.get_widget('spinner') # progress during the introspection self.__scrolledwindow = \ ui.get_widget('scrolledwindow') # the scrolledwindow contains the treeview self.__treemodel = ui.get_widget('treestore') self.__treemodel.set_sort_func(0, self.__sort_model) self.__treemodel.set_sort_column_id(0, Gtk.SortType.ASCENDING) self.__treeview = ui.get_widget('treeview') self.__label_name = ui.get_widget('label_name') self.__label_unique_name = ui.get_widget('label_unique_name') self.__label_address = ui.get_widget('label_address') self.__messagedialog = ui.get_widget('messagedialog') self.__messagedialog.connect("close", self.__messagedialog_close_cb) # connect signals ui.connect_signals(signal_dict) if self.connection_is_bus: # we expect a bus connection if self.address == Gio.BusType.SYSTEM or self.address == Gio.BusType.SESSION: self.connection = Gio.bus_get_sync(self.address, None) self.__label_address.set_text( Gio.dbus_address_get_for_bus_sync(self.address, None)) elif Gio.dbus_is_address(self.address): self.connection = Gio.DBusConnection.new_for_address_sync( self.address, Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT | Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION, None, None) self.__label_address.set_text(self.address) else: self.connection = None raise Exception("Invalid bus address '%s'" % (self.address)) else: # we have a peer-to-peer connection if Gio.dbus_is_supported_address(self.address): self.connection = Gio.DBusConnection.new_for_address_sync( self.address, Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT, None, None) self.__label_address.set_text(self.address) else: self.connection = None raise Exception("Invalid p2p address '%s'" % (self.address)) # start processing data self.introspect_start()
def __init__(self, data_dir, bus_address): self.__data_dir = data_dir self.__bus_address = bus_address # setup UI ui = UILoader(self.__data_dir, UILoader.UI_BUS) self.__box_bus = ui.get_root_widget() self.__scrolledwindow_listbox = ui.get_widget("scrolledwindow_listbox") self.__bus_name_filter = ui.get_widget('entry_filter') # create a listbox for all the busnames self.__listbox = Gtk.ListBox(hexpand=True, vexpand=True, expand=True) self.__listbox.set_sort_func(self.__listbox_sort_by_name, None) self.__listbox.set_filter_func(self.__listbox_filter_by_name, None) self.__scrolledwindow_listbox.add(self.__listbox) self.__scrolledwindow_listbox.show_all() # setup the bus connection if self.__bus_address == Gio.BusType.SYSTEM or self.__bus_address == Gio.BusType.SESSION: # TODO: do this async self.connection = Gio.bus_get_sync(self.__bus_address, None) elif Gio.dbus_is_supported_address(self.__bus_address): # TODO: do this async self.connection = Gio.DBusConnection.new_for_address_sync( self.__bus_address, Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT | Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION, None, None) else: raise ValueError("Invalid bus address '{0}'".format(self.__bus_address)) # setup signals self.connection.signal_subscribe(None, "org.freedesktop.DBus", "NameOwnerChanged", None, None, 0, self.__name_owner_changed_cb, None) # refilter if someone wants to filter the busbox list self.__bus_name_filter.connect("changed", self.__bus_name_filter_changed_cb) # change bus detail tree if a different bus is selected self.__listbox.connect("row-selected", self.__listbox_row_selected_cb) # TODO: do this async self.bus_proxy = Gio.DBusProxy.new_sync(self.connection, Gio.DBusProxyFlags.NONE, None, 'org.freedesktop.DBus', '/org/freedesktop/DBus', 'org.freedesktop.DBus', None) # get a list with activatable names self.bus_proxy.ListActivatableNames('()', result_handler=self.__list_act_names_handler, error_handler=self.__list_act_names_error_handler) # list all names self.bus_proxy.ListNames('()', result_handler=self.__list_names_handler, error_handler=self.__list_names_error_handler)
def __init__(self, data_dir, address): self.data_dir = data_dir self.address = address #setup UI ui = UILoader(self.data_dir, UILoader.UI_BUSWATCH) self.paned_buswatch = ui.get_root_widget() self.liststore_model = ui.get_widget('liststore_buswatch') self.treemodelfilter_buswatch = ui.get_widget('treemodelfilter_buswatch') self.treemodelfilter_buswatch.set_visible_func(self.__treemodelfilter_buswatch_cb) self.treemodelsort_buswatch = ui.get_widget("treemodelsort_buswatch") self.treemodelsort_buswatch.set_sort_func(2, self.__sort_on_name) self.treemodelsort_buswatch.set_sort_column_id(2, Gtk.SortType.ASCENDING) self.treeview = ui.get_widget('treeview_buswatch') self.entry_filter = ui.get_widget('entry_filter') self.grid_bus_name_selected_info = ui.get_widget('grid_bus_name_info') self.label_bus_name_selected_name = ui.get_widget('label_bus_name_selected_name') self.label_bus_name_selected_pid = ui.get_widget('label_bus_name_selected_pid') self.label_bus_name_selected_cmdline = ui.get_widget('label_bus_name_selected_cmdline') self.addr_info = None # hold the currently selected AddressInfo object self.treeview.connect('cursor-changed', self.__tree_view_cursor_changed_cb) self.entry_filter.connect("changed", self.__entry_filter_changed_cb) #setup the conection if self.address == Gio.BusType.SYSTEM or self.address == Gio.BusType.SESSION: self.connection = Gio.bus_get_sync(self.address, None) elif Gio.dbus_is_supported_address(self.address): self.connection = Gio.DBusConnection.new_for_address_sync( self.address, Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT | Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION, None, None) #setup signals self.connection.signal_subscribe(None, "org.freedesktop.DBus", "NameOwnerChanged", None, None, 0, self.__name_owner_changed_cb, None) self.bus_proxy = Gio.DBusProxy.new_sync(self.connection, Gio.DBusProxyFlags.NONE, None, 'org.freedesktop.DBus', '/org/freedesktop/DBus', 'org.freedesktop.DBus', None) #list all names self.bus_proxy.ListNames('()', result_handler=self.__list_names_handler, error_handler=self.__list_names_error_handler)
def __init__(self, data_dir, connection, connection_is_bus, bus_name, signal_obj): # by Zex signal_dict = { 'emit_dbus_signal_cb': self.emit_signal_cb, 'execute_dialog_close_cb': self.close_cb } self.connection = connection self.connection_is_bus = connection_is_bus self.bus_name = bus_name self.signal_obj = signal_obj self.emit_iface = signal_obj.iface_info.name self.emit_signame = str(signal_obj) self.emit_path = signal_obj.object_path self.emit_signature = signal_obj.args # ----------------subscribe backend------------------ self.subscribe_id = connection.signal_subscribe( None,#bus_name, # sender signal_obj.iface_info.name, # interface str(signal_obj), # signal name signal_obj.object_path, # object path None, 0, self.subscribe_cb, signal_obj.args) # --------------------------------------------------- ui = UILoader(data_dir, UILoader.UI_BUSWATCHBYZEX) self.dialog = ui.get_root_widget() self.label_sender_name = ui.get_widget('label_sender_name') self.label_object_path = ui.get_widget('label_object_path') self.label_interface_name = ui.get_widget('label_interface_name') self.label_signal_name = ui.get_widget('label_signal_name') """ self.label_interface = ui.get_widget('label_interface') self.notebook = ui.get_widget('notebook1') self.parameter_textview = ui.get_widget('parametertextview1') """ self.parameter_textview = ui.get_widget('parametertextview1') self.source_textview = ui.get_widget('sourcetextview1') self.prettyprint_textview = ui.get_widget('prettyprinttextview1') """ self.method_execution_count_spinbutton = ui.get_widget('method_exec_count_spinbutton') self.label_avg = ui.get_widget('label_avg') self.label_min = ui.get_widget('label_min') self.label_max = ui.get_widget('label_max') """ ui.connect_signals(signal_dict) """
def __init__(self, data_dir, parent, address_bus_history=[]): ui = UILoader(data_dir, UILoader.UI_ADDCONNECTIONDIALOG) self.dialog = ui.get_root_widget() self.dialog.set_transient_for(parent) # get the hbox and add address combo box with model hbox1 = ui.get_widget('hbox1') self.address_combo_box_store = Gtk.ListStore(str) self.address_combo_box = Gtk.ComboBox.new_with_model_and_entry( self.address_combo_box_store) self.address_combo_box.set_entry_text_column(0) self.label_status = ui.get_widget('label_status') hbox1.pack_start(self.address_combo_box, True, True, 0) hbox1.show_all() # add history to model for el in address_bus_history: self.address_combo_box_store.append([el]) self.dialog.add_button('gtk-cancel', Gtk.ResponseType.CANCEL) self.dialog.add_button('gtk-connect', Gtk.ResponseType.OK)