From 10d85ba54884cd8c2c5a16e8b329103a7858acf1 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Mon, 30 May 2011 18:18:23 +0000 Subject: h-client:users can now change the device category - part 1 --- h-client/hclient.py | 49 +++++++++++++++++++++++++++++++++++++++---------- h-client/hlibrary.py | 8 ++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) (limited to 'h-client') diff --git a/h-client/hclient.py b/h-client/hclient.py index 57a5cbd..cc4e150 100644 --- a/h-client/hclient.py +++ b/h-client/hclient.py @@ -131,6 +131,8 @@ class hclient: #set the pyGTK device entries def setEntries(self): if self.currentDevice != None: + #set the type entry + self.setTypeEntry() #set the model entry self.setModelEntry() #set the other names entry @@ -155,6 +157,15 @@ class hclient: self.setDescriptionEntry() + #set the subtype entry (in the case pf printers) + def setTypeEntry(self): + if self.currentDevice.getType() in self.client.getTypes(): + index = self.client.getTypes().index(self.currentDevice.getType()) + else: + index = 0 + + self.typeCombo.set_active(index) + #set the model name entry def setModelEntry(self): self.modelNameEntry.set_text(self.currentDevice.getModel()) @@ -831,35 +842,53 @@ class hclient: label_base = gtk.Label("Base") label_adv = gtk.Label("Advanced") - self.rightTable = gtk.Table(4, 2, False) + self.rightTable = gtk.Table(5, 2, False) self.rightTableAdvances = gtk.Table(6, 2, False) self.rightTable.set_border_width(5) self.rightTableAdvances.set_border_width(5) + + self.rightTable.set_row_spacings(3) + self.rightTableAdvances.set_row_spacings(3) notebook.append_page(self.rightTable, label_base) notebook.append_page(self.rightTableAdvances, label_adv) + + ###type entry + #year of commercialization label + self.typeLabel = gtk.Label("Select the device category (if not correct):") + self.typeLabel.set_alignment(0.75,0.5) + #add the label + self.rightTable.attach(self.typeLabel, 0, 1, 0, 1) + + self.typeCombo = gtk.combo_box_new_text() + + for dtype in self.client.getTypes(): + self.typeCombo.append_text(dtype) + + #add the combo to the table + self.rightTable.attach(self.typeCombo, 1, 2, 0, 1) ### model #model name label self.modelNameLabel = gtk.Label("Model name:") self.modelNameLabel.set_alignment(0.94,0.5) #add the label - self.rightTable.attach(self.modelNameLabel, 0, 1, 0, 1) + self.rightTable.attach(self.modelNameLabel, 0, 1, 1, 2) #model name input self.modelNameEntry = gtk.Entry() #add the input to the table - self.rightTable.attach(self.modelNameEntry, 1, 2, 0, 1) + self.rightTable.attach(self.modelNameEntry, 1, 2, 1, 2) ### other names #other names label self.otherNamesLabel = gtk.Label("Possible other names of the device:\n( write one name per row )") self.otherNamesLabel.set_use_markup(True) - self.otherNamesLabel.set_alignment(0.76,0.5) + self.otherNamesLabel.set_alignment(0.83,0.5) self.otherNamesLabel.set_justify(gtk.JUSTIFY_RIGHT) - self.rightTable.attach(self.otherNamesLabel, 0, 1, 1, 2) + self.rightTable.attach(self.otherNamesLabel, 0, 1, 2, 3) #other names text area s = gtk.ScrolledWindow() @@ -876,7 +905,7 @@ class hclient: s.add(self.otherNamesText) s.show() s.show_all() - self.rightTable.attach(s, 1, 2, 1, 2) + self.rightTable.attach(s, 1, 2, 2, 3) ### vendorid:productid @@ -942,7 +971,7 @@ class hclient: self.distributionLabel = gtk.Label("Distribution used: ") self.distributionLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.distributionLabel, 0, 1, 2, 3) + self.rightTable.attach(self.distributionLabel, 0, 1, 3, 4) #distribution input self.distributionEntry = gtk.Entry() @@ -950,7 +979,7 @@ class hclient: #add the input - self.rightTable.attach(self.distributionEntry, 1, 2, 2, 3) + self.rightTable.attach(self.distributionEntry, 1, 2, 3, 4) ### kernel @@ -971,12 +1000,12 @@ class hclient: self.howItWorksLabel = gtk.Label("Does it work?") self.howItWorksLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.howItWorksLabel, 0, 1, 3, 4) + self.rightTable.attach(self.howItWorksLabel, 0, 1, 4, 5) self.howItWorksCombo = gtk.combo_box_new_text() #add the combo to the table - self.rightTable.attach(self.howItWorksCombo, 1, 2, 3, 4) + self.rightTable.attach(self.howItWorksCombo, 1, 2, 4, 5) ### driver diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py index e8b577b..85faca6 100644 --- a/h-client/hlibrary.py +++ b/h-client/hlibrary.py @@ -569,6 +569,14 @@ class Client: ) + #get the list of types + def getTypes(self): + types = [] + for Class,struct in self._types.iteritems(): + if struct['type'] not in types: + types.append(struct['type']) + return types + #check if a distro code is allowed or not def distroIsAllowed(self,distroCode): allowedDistroCodes = self.allowedDistros.keys() -- cgit v1.2.3