def __init__(self,parent): self.discoverer=None self.gladefile=GLADEFILE self.wTree=gtk.glade.XML(self.gladefile,"bluetoothDevices") self.devicesDialog=self.wTree.get_widget("bluetoothDevices") self.devicesDialog.set_title("Bluetooth device neighbourhood") self.devicesModelView=self.wTree.get_widget("devicesTreeView") # Create the listStore model to use with the devicesListView self.devicesModel=gtk.ListStore(str,str,str) # (DevAddr,DevName,Type) self.populateWithCurrentDevices() # Create a filter, from the model and set the TreeView to use it #self.deviceFilter=self.devicesModel.filter_new() #self.deviceFilter.set_visible_column(1) self.devicesModelView.set_model(self.devicesModel) self.devicesModelView.set_enable_search(True) self.devicesModelView.set_search_column(1) treeselection=self.devicesModelView.get_selection() treeselection.connect('changed',self.on_device_selection_changed) col1=contactDetails.createTreeViewColumn("Device",1) self.devicesModelView.append_column(col1) col2=contactDetails.createTreeViewColumn("Type",2) self.devicesModelView.append_column(col2) self.devicesDialog.connect("close",self.on_close,self) self.devicesDialog.connect("delete-event",self.on_close,self) # autoconnect => signal handlers are named class methods. eg. "on_mainWindow_destroy" self.wTree.signal_autoconnect(self) # Now show everything! self.show()
def __init__(self): log.debug("ContactsApp::__init__") self.currentContact = None self.about_dialog = None self.hostHasGtkBuilder = False version=gtk.gtk_version if int(version[0]) >= 2 and int(version[1]) >= 12: self.hostHasGtkBuilder = True log.debug("Does host support GtkBuilder?: %s" % self.hostHasGtkBuilder) self.gladefile=GLADEFILE self.wTree=gtk.glade.XML(self.gladefile,"mainWindow") self.window = self.wTree.get_widget("mainWindow") self.window.maximize() self.notebook=self.wTree.get_widget("mainNotebook") self.statusbar = self.wTree.get_widget("statusbar") self.contactModelView=self.wTree.get_widget("contactsTreeView") # Color changing of background needs to be done on the uppermost widget - in our case the viewport self.contactDetailViewport=self.wTree.get_widget("summaryViewport") color = gtk.gdk.color_parse("white") self.contactDetailViewport.modify_bg(gtk.STATE_NORMAL,color) self.contactDetailVbox=self.wTree.get_widget("summaryVbox") self.contactDetailName=self.wTree.get_widget("summaryName") self.contactDetailPhoto=self.wTree.get_widget("summaryPhoto") self.contactDetailTable=self.wTree.get_widget("summaryTable") # Create the listStore model to use with the contactListView self.contactModel=gtk.ListStore(str,str) # (ContactId,FullName) self.populateWithAddressBookContacts() # Create a filter, from the model and set the TreeView to use it self.contactFilter=self.contactModel.filter_new() self.contactFilter.set_visible_column(1) #view=gtk.TreeView(filter) self.contactModelView.set_model(self.contactModel) self.contactModelView.set_enable_search(True) self.contactModelView.set_search_column(1) #self.contactModelView.set_filter(self.contactFilter) treeselection=self.contactModelView.get_selection() treeselection.connect('changed',self.on_contactsTreeView_selection_changed) col=contactDetails.createTreeViewColumn("Name",1) self.contactModelView.append_column(col) self.toolbar = self.wTree.get_widget("toolbar") # autoconnect => signal handlers are named class methods. eg. "on_mainWindow_destroy" self.wTree.signal_autoconnect(self) self.window.set_icon_name(gtk.STOCK_ORIENTATION_PORTRAIT) # set the window icon to the GTK "portrait" icon self.statusbar_cid = self.statusbar.get_context_id(APPNAME) # setup and initialize our statusbar # We're going to fire up the last contact Id on startup self.contactModelView.set_cursor(121,col) # Now show everything! self.window.show()