diff options
Diffstat (limited to 'h-client')
-rw-r--r-- | h-client/hclient.py | 286 | ||||
-rw-r--r-- | h-client/hlibrary.py | 31 | ||||
-rw-r--r-- | h-client/img/icon.png | bin | 0 -> 518 bytes |
3 files changed, 282 insertions, 35 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py index 2ca8c03..522e500 100644 --- a/h-client/hclient.py +++ b/h-client/hclient.py @@ -24,14 +24,91 @@ from hlibrary import * class hclient: + _years = [ + 'not-specified', + '2011', + '2010', + '2009', + '2008', + '2007', + '2006', + '2005', + '2004', + '2003', + '2002', + '2001', + '2000', + '1999', + '1998', + '1997', + '1996', + '1995', + '1994', + '1993', + '1992' + ] + #the device that has to be displaced in the right window currentDevice = '' #set the device that has to be displaced in the right window - def setCurrentDevice(self, widget, data): - self.currentDevice = data - print self.currentDevice + def setCurrentDevice(self, selection): + model, path = selection.get_selected() + if path: + #get the code: + code = model.get_value(path, 1) + #set the current device + self.currentDevice = code + #get the device + if code in self.client.devices: + device = self.client.devices[code][0] + #set the model entry + self.setModelEntry(device) + #set the vendorid:productid entry + self.setVendorIdProductIDCode(device) + #set the commercialization year + self.setCommYearEntry(device) + #set the interface + self.setInterfaceEntry(device) + + + #set the model name entry + #device: a device object (a subclass of Device - see hlibrary.py) + def setModelEntry(self,device): + self.modelNameEntry.set_text(device.getModel()) + + + #set the vendorid:productid entry + #device: a device object (a subclass of Device - see hlibrary.py) + def setVendorIdProductIDCode(self,device): + self.vendorIdProductIdEntry.set_text(device.getVendorId() + ':' + device.getProductId()) + + + #set the year of commercialization + #device: a device object (a subclass of Device - see hlibrary.py) + def setCommYearEntry(self,device): + if device.getYear() in self._years: + index = self._years.index(device.getYear()) + else: + index = 0 + + self.commYearCombo.set_active(index) + + #set the interface + #device: a device object (a subclass of Device - see hlibrary.py) + def setInterfaceEntry(self,device): + self.interfaceCombo.get_model().clear() + for interface in device.getInterfaces(): + self.interfaceCombo.append_text(interface) + + if device.getInterface() in device.getInterfaces(): + index = device.getInterfaces().index(device.getInterface()) + else: + index = 0 + + self.interfaceCombo.set_active(index) + # another callback def delete_event(self, widget, event, data=None): gtk.main_quit() @@ -50,6 +127,7 @@ class hclient: # new window to "Hello Buttons!" self.window.set_title("h-client") + self.window.set_icon_from_file("img/icon.png") #self.window.set_size_request(200, 100) # Here we just set a handler for delete_event that immediately @@ -57,43 +135,205 @@ class hclient: self.window.connect("delete_event", self.delete_event) # Sets the border width of the window. - self.window.set_border_width(10) - - - self.bottomWindow = gtk.HBox(False, 0) + self.window.set_border_width(3) + self.centerWindow = gtk.HBox(False, 0) + #add the bottom box - self.window.add(self.bottomWindow) + self.window.add(self.centerWindow) ## build the left window ## #start the left vertical box self.leftWindow = gtk.VBox(False, 0) + self.leftWindow.set_border_width(5) + #self.lframe = gtk.Frame("Your devices") + + + self.centerWindow.pack_start(self.leftWindow, True, True, 0) + #self.centerWindow.pack_start(self.rframe, True, True, 5) - #start the right vertical box - self.rightWindow = gtk.VBox(False, 0) + #self.leftWindow.pack_start(gtk.Label("Your hardware:"), False, True, 5) + + self.tree = gtk.TreeView() - self.frame = gtk.Frame("Your devices") + languages = gtk.TreeViewColumn() + languages.set_title("Your PCI and USB devices") + cell = gtk.CellRendererText() + languages.pack_start(cell, True) + languages.add_attribute(cell, "text", 0) - self.bottomWindow.pack_start(self.frame, True, True, 0) - self.bottomWindow.pack_start(self.rightWindow, True, True, 0) + self.treestore = gtk.TreeStore(str,str) + it = self.treestore.append(None, ["PCI Devices",""]) for key,dev in self.client.devices.iteritems(): - - self.button = gtk.Button(dev[0].getType()) - self.button.connect("clicked", self.setCurrentDevice, key) - - self.leftWindow.pack_start(self.button, False, True, 0) - self.button.show() + if key[0] == 'p': + self.treestore.append(it, [dev[0].getType(),key]) - self.frame.add(self.leftWindow) + selection = self.tree.get_selection() + selection.connect('changed', self.setCurrentDevice) - self.bottomWindow.show() - self.frame.show() - self.leftWindow.show() + + self.tree.append_column(languages) + self.tree.set_model(self.treestore) + + self.leftWindow.pack_start(self.tree, False, True, 5) + + self.leftWindow.show_all() + + #self.lframe.add(self.leftWindow) + + self.rightTable = gtk.Table(8, 2, True) + + #create the entries + + ### model + #model name label + self.modelNameLabel = gtk.Label("Model name:") + #add the label + self.rightTable.attach(self.modelNameLabel, 0, 1, 0, 1) + + #model name input + self.modelNameEntry = gtk.Entry() + #add the input to the table + self.rightTable.attach(self.modelNameEntry, 1, 2, 0, 1) + + + ### vendorid:productid + #vendorid:productid label + self.vendorIdProductIdLabel = gtk.Label("VendorID:productID code:") + #add the label + self.rightTable.attach(self.vendorIdProductIdLabel, 0, 1, 1, 2) + + #vendorid:productid input + self.vendorIdProductIdEntry = gtk.Entry() + #set as not editable + self.vendorIdProductIdEntry.set_editable(False) + #add the input to the table + self.rightTable.attach(self.vendorIdProductIdEntry, 1, 2, 1, 2) + + + ###year of commercialization + #year of commercialization label + self.commYearLabel = gtk.Label("Year of commercialization:") + #add the label + self.rightTable.attach(self.commYearLabel, 0, 1, 2, 3) + + self.commYearCombo = gtk.combo_box_new_text() + + for item in self._years: + self.commYearCombo.append_text(item) + + self.commYearCombo.set_active(0) + + #add the combo to the table + self.rightTable.attach(self.commYearCombo, 1, 2, 2, 3) + + + ###interface + #interface label + self.interfaceLabel = gtk.Label("Interface:") + #add the label + self.rightTable.attach(self.interfaceLabel, 0, 1, 3, 4) + + self.interfaceCombo = gtk.combo_box_new_text() + + self.interfaceCombo.append_text('not-specified') + + self.interfaceCombo.set_active(0) + + #add the combo to the table + self.rightTable.attach(self.interfaceCombo, 1, 2, 3, 4) + + + ### distribution + #distribution label + self.distributionLabel = gtk.Label("Distribution:") + #add the label + self.rightTable.attach(self.distributionLabel, 0, 1, 4, 5) + + #distribution input + self.distributionEntry = gtk.Entry() + #add the input + self.rightTable.attach(self.distributionEntry, 1, 2, 4, 5) + + + ### kernel + #kernel label + self.kernelLabel = gtk.Label("Kernel libre version:") + #add the label + self.rightTable.attach(self.kernelLabel, 0, 1, 5, 6) + + #kernel input + self.kernelEntry = gtk.Entry() + #add the input + self.rightTable.attach(self.kernelEntry, 1, 2, 5, 6) + + + ###how it works + #how it works label + self.howItWorksLabel = gtk.Label("How does it work?") + #add the label + self.rightTable.attach(self.howItWorksLabel, 0, 1, 6, 7) + + self.howItWorksLabelCombo = gtk.combo_box_new_text() + + #add the combo to the table + self.rightTable.attach(self.howItWorksLabelCombo, 1, 2, 6, 7) + + + ### driver + #driver label + self.driverLabel = gtk.Label("Free driver used:") + #add the label + self.rightTable.attach(self.driverLabel, 0, 1, 7, 8) + + #driver input + self.driverEntry = gtk.Entry() + #add the input + self.rightTable.attach(self.driverEntry, 1, 2, 7, 8) + + + ### description + #description label + self.descriptionLabel = gtk.Label("Description:") + + #description input + sw = gtk.ScrolledWindow() + sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + + self.descriptionText = textview = gtk.TextView() + self.descriptionText.set_wrap_mode(gtk.WRAP_CHAR) + sw.add(self.descriptionText) + sw.show() + sw.show_all() + + ##add the input + #self.rightTable.attach(sw, 1, 2, 7, 8) + + self.rightTable.show_all() + + #start the left vertical box + self.rightWindow = gtk.VBox(False, 0) + + self.rightWindow.pack_start(self.rightTable, False, True, 10) + self.rightWindow.pack_start(self.descriptionLabel, False, True, 3) + self.rightWindow.pack_start(sw, False, True, 0) self.rightWindow.show() + self.rightWindow.show_all() + + self.centerWindow.pack_start(self.rightWindow, True, True, 5) + + #self.rframe.add(self.rightWindow) + #self.rframe.set_border_width(30) + + self.centerWindow.show() + #self.lframe.show() + #self.rframe.show() + self.rightTable.show() + self.leftWindow.show() self.window.show() def main(): diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py index 975f2f9..4be6a1b 100644 --- a/h-client/hlibrary.py +++ b/h-client/hlibrary.py @@ -1,20 +1,20 @@ # -*- coding: utf-8 -*- -# hlibrary, a python library to manage the database of an h-source node +# h-client, a python library to manage the database of an h-source node # Copyright (C) 2011 Antonio Gallo # # -# hlibrary is free software: you can redistribute it and/or modify +# h-client is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# hlibrary is distributed in the hope that it will be useful, +# h-client is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with hlibrary. If not, see <http://www.gnu.org/licenses/>. +# along with h-client. If not, see <http://www.gnu.org/licenses/>. import os import string @@ -55,22 +55,24 @@ class Device(object): #'venenux_0_8_2' : 'VENENUX-EC 0.8.2' #} + _interfaces = [] + _status = True errors = [] def __init__(self): self._post = {} - self._type = None - self._vendor = None - self._model = None - self._kernel = None + self._type = '' + self._vendor = '' + self._model = '' + self._kernel = '' self._distributions = [self.userDistribution()] self._interface = 'not-specified' self._year = 'not-specified' - self._vendorId = None - self._productId = None - self._howItWorks = None + self._vendorId = '' + self._productId = '' + self._howItWorks = '' self._driver = '' self._description = '' @@ -135,6 +137,9 @@ class Device(object): self._status = False self.errors.append('tmp folder not writable') + def getInterfaces(self): + return self._interfaces + def getType(self): return self._type @@ -219,6 +224,7 @@ class Videocard(Device): super(Videocard, self).__init__() self._type = 'videocard' self._howItWorks = 'does_not_work' + self._interfaces = ['not-specified','PCI','AGP','PCI-E','ISA','MCA','VLB'] def setPost(self): super(Videocard, self).setPost() @@ -230,6 +236,7 @@ class Wifi(Device): super(Wifi, self).__init__() self._type = 'wifi' self._howItWorks = 'no' + self._interfaces = ['not-specified','USB','PCI','PCI-E','mini-PCI','mini-PCI-E','ExpressCard','PC-Card'] def setPost(self): super(Wifi, self).setPost() @@ -241,6 +248,7 @@ class Soundcard(Device): super(Soundcard, self).__init__() self._type = 'soundcard' self._howItWorks = 'no' + self._interfaces = ['not-specified','PCI','ISA','USB','Firewire','Parallel','PCI-E','PCMCIA'] def setPost(self): super(Soundcard, self).setPost() @@ -422,7 +430,6 @@ class Client: dev.setProductId(pr.group(2).replace("\t","")) dev.setModel(pr.group(1).replace("\t","")) - dev.setInterface('not-specified') dev.setKernel(self.getKernel()) self.devices['p_' + dev.getVendorId() + ':' + dev.getProductId()] = [dev,cl.group(2),'insert','0'] diff --git a/h-client/img/icon.png b/h-client/img/icon.png Binary files differnew file mode 100644 index 0000000..7f61564 --- /dev/null +++ b/h-client/img/icon.png |