aboutsummaryrefslogtreecommitdiff
path: root/h-client
diff options
context:
space:
mode:
Diffstat (limited to 'h-client')
-rw-r--r--h-client/hclient.py238
-rw-r--r--h-client/hlibrary.py36
2 files changed, 180 insertions, 94 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py
index 8b3a463..f0198b2 100644
--- a/h-client/hclient.py
+++ b/h-client/hclient.py
@@ -24,30 +24,6 @@ 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 = ''
@@ -83,9 +59,15 @@ class hclient:
startiter, enditer = descriptionBuffer.get_bounds()
self.currentDevice.setDescription(descriptionBuffer.get_text(startiter, enditer))
+
+ #reset the modifications
+ def resetChanges(self,widget):
+ self.setEntries()
+
#set the device that has to be displaced in the right window
- def setEntries(self, selection):
+ #and fill the entries
+ def setCurrentDevice(self, selection):
model, path = selection.get_selected()
if path:
#get the code:
@@ -98,27 +80,34 @@ class hclient:
#get the device
device = self.client.devices[code][0]
- #set the model entry
- self.setModelEntry()
- #set the vendorid:productid entry
- self.setVendorIdProductIDCode()
- #set the commercialization year entry
- self.setCommYearEntry()
- #set the interface entry
- self.setInterfaceEntry()
- #set the distribution entry
- self.setDistributionEntry()
- #set the kernel entry
- self.setKernelEntry()
- #set the howItWorks entry
- self.setHowItWorksEntry()
- #set the driver entry
- self.setDriverEntry()
- #set the description entry
- self.setDescriptionEntry()
+
+ self.setEntries()
#make sensitive the apply button
self.applyButton.set_sensitive(True)
+ self.resetButton.set_sensitive(True)
+
+
+ #set the pyGTK device entries
+ def setEntries(self):
+ #set the model entry
+ self.setModelEntry()
+ #set the vendorid:productid entry
+ self.setVendorIdProductIDCode()
+ #set the commercialization year entry
+ self.setCommYearEntry()
+ #set the interface entry
+ self.setInterfaceEntry()
+ #set the distribution entry
+ self.setDistributionEntry()
+ #set the kernel entry
+ self.setKernelEntry()
+ #set the howItWorks entry
+ self.setHowItWorksEntry()
+ #set the driver entry
+ self.setDriverEntry()
+ #set the description entry
+ self.setDescriptionEntry()
#set the model name entry
@@ -133,8 +122,12 @@ class hclient:
#set the year of commercialization
def setCommYearEntry(self):
- if self.currentDevice.getYear() in self._years:
- index = self._years.index(self.currentDevice.getYear())
+ self.commYearCombo.get_model().clear()
+ for year in self.currentDevice.getYears():
+ self.commYearCombo.append_text(year)
+
+ if self.currentDevice.getYear() in self.currentDevice.getYears():
+ index = self.currentDevice.getYears().index(self.currentDevice.getYear())
else:
index = 0
@@ -189,7 +182,62 @@ class hclient:
textbuffer.set_text(self.currentDevice.getDescription())
self.descriptionText.set_buffer(textbuffer)
-
+
+ #set the node
+ def setNode(self,widget):
+ self.client.setNode(self.serverEntry.get_text())
+
+ #close the window for preferences
+ def closePref(self,widget):
+ self.prefWindow.destroy()
+
+
+ #start the window for preferences
+ def openPrefWindow(self,widget):
+ #window for preferences
+ self.prefWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.prefWindow.set_title("preferences")
+ self.prefWindow.set_size_request(300, -1)
+
+ vbox = gtk.VBox(False, 0)
+
+ self.prefWindow.add(vbox)
+
+ table = gtk.Table(1, 2, True)
+ table.set_border_width(10)
+
+ vbox.pack_start(table, False, True, 10)
+
+ ### server
+ serverLabel = gtk.Label("Server URL:")
+ #add the label
+ table.attach(serverLabel, 0, 1, 0, 1)
+
+ #model name input
+ self.serverEntry = gtk.Entry()
+ self.serverEntry.set_text(self.client.getNode())
+ #add the input to the table
+ table.attach(self.serverEntry, 1, 2, 0, 1)
+
+ hbox = gtk.HBox(False, 0)
+ hbox.set_border_width(10)
+ applyButton = gtk.Button(stock=gtk.STOCK_APPLY)
+ closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
+ applyButton.connect("clicked", self.setNode)
+ closeButton.connect("clicked", self.closePref)
+ hbox.pack_end(applyButton, False, True, 0)
+ hbox.pack_end(closeButton, False, True, 3)
+ vbox.pack_start(hbox, False, True, 10)
+ #applyButton.connect("clicked", self.applyChanges)
+
+ self.prefWindow.show_all()
+
+
+ def synchronize(self,widget):
+ self.client.sync()
+ self.setEntries()
+
+
#another callback
def delete_event(self, widget, event, data=None):
gtk.main_quit()
@@ -198,31 +246,27 @@ class hclient:
def __init__(self):
#start the client object
- self.client = Client('h-source')
+ self.client = Client()
self.client.createDevices()
- # Create a new window
+ # Create the main window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- # This is a new call, which just sets the title of our
- # 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)
+ self.window.set_size_request(550, -1)
- # Here we just set a handler for delete_event that immediately
- # exits GTK.
self.window.connect("delete_event", self.delete_event)
- # Sets the border width of the window.
- self.window.set_border_width(0)
+ #self.window.set_border_width(0)
vbox = gtk.VBox(False, 0)
-
- self.centerWindow = gtk.HBox(False, 0)
+ #add the bottom box
+ self.window.add(vbox)
+ self.centerWindow = gtk.HBox(False, 0)
## build the toolbar ##
toolbar = gtk.Toolbar()
@@ -231,19 +275,18 @@ class hclient:
pref = gtk.ToolButton(gtk.STOCK_PREFERENCES)
pref.set_tooltip_text('Preferences')
- #sync = gtk.ToolButton(None,'Synchronize')
- #sync.set_tooltip_text('Synchronize with the server: this will override your entries')
+ pref.connect("clicked", self.openPrefWindow)
+ sync = gtk.ToolButton(gtk.STOCK_REFRESH)
+ sync.set_tooltip_text('Synchronize with the server: this will override the entries or your devices')
+ sync.connect("clicked", self.synchronize)
info = gtk.ToolButton(gtk.STOCK_INFO)
info.set_tooltip_text('Information')
- toolbar.insert(pref, 0)
- #toolbar.insert(sync, 1)
- toolbar.insert(info, 1)
+ toolbar.insert(sync, 0)
+ toolbar.insert(pref, 1)
+ toolbar.insert(info, 2)
toolbar.show_all()
- #add the bottom box
- self.window.add(vbox)
-
vbox.pack_start(toolbar, True, True, 0)
@@ -256,46 +299,56 @@ class hclient:
#start the left vertical box
self.leftWindow = gtk.VBox(False, 0)
#self.leftWindow.set_border_width(5)
- self.lframe = gtk.Frame()
- self.lframe.set_border_width(5)
-
- self.centerWindow.pack_start(self.lframe, True, True, 0)
+ self.centerWindow.pack_start(self.leftWindow, True, True, 0)
- self.lframe.add(self.leftWindow)
+ #treeFrame.add(self.leftWindow)
#self.centerWindow.pack_start(self.rframe, True, True, 5)
#self.leftWindow.pack_start(gtk.Label("Your hardware:"), False, True, 5)
self.tree = gtk.TreeView()
+ self.tree.set_headers_visible(False)
- devices = gtk.TreeViewColumn()
- devices.set_title("Your PCI and USB devices")
+ #treeFrame = gtk.Frame()
+ #treeFrame.set_border_width(5)
+ ##treeFrame.add(self.tree)
+ #treeFrame.show_all()
+
+ devices = gtk.TreeViewColumn("Your PCI and USB devices")
cell = gtk.CellRendererText()
devices.pack_start(cell, False)
devices.add_attribute(cell, "text", 0)
+ devices.add_attribute(cell, "weight", 2)
- self.treestore = gtk.TreeStore(str,str)
+ self.treestore = gtk.TreeStore(str,str,int)
- it = self.treestore.append(None, ["PCI Devices",""])
+ pci = self.treestore.append(None, ["PCI Devices","",800])
for key,dev in self.client.devices.iteritems():
if key[0] == 'p':
- self.treestore.append(it, [dev[0].getType(),key])
+ self.treestore.append(pci, [dev[0].getType(),key,400])
selection = self.tree.get_selection()
- selection.connect('changed', self.setEntries)
+ selection.connect('changed', self.setCurrentDevice)
self.tree.append_column(devices)
self.tree.set_model(self.treestore)
-
- self.leftWindow.pack_start(self.tree, False, True, 0)
+
+ treesw = gtk.ScrolledWindow()
+ treesw.set_size_request(50,400)
+ treesw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+ treesw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ treesw.add(self.tree)
+
+ self.leftWindow.set_border_width(5)
+ self.leftWindow.pack_start(treesw, False, True, 0)
self.leftWindow.show_all()
-
- #self.lframe.add(self.leftWindow)
+ self.tree.expand_all()
+ #treeFrame.add(self.leftWindow)
## build the right window ##
@@ -337,11 +390,6 @@ class hclient:
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)
@@ -416,6 +464,7 @@ class hclient:
#description input
sw = gtk.ScrolledWindow()
+ sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.descriptionText = gtk.TextView()
@@ -431,22 +480,27 @@ class hclient:
self.rightTable.show_all()
#apply and submit buttons
- hboxBelowEntries = gtk.VBox(False, 0)
+ hboxBelowEntries = gtk.HBox(False, 0)
+ #apply button
self.applyButton = gtk.Button(stock=gtk.STOCK_APPLY)
self.applyButton.set_sensitive(False)
self.applyButton.connect("clicked", self.applyChanges)
+ #reset button
+ self.resetButton = gtk.Button(stock=gtk.STOCK_REVERT_TO_SAVED)
+ self.resetButton.set_sensitive(False)
+ self.resetButton.connect("clicked", self.resetChanges)
- hboxBelowEntries.pack_start(self.applyButton, False, True, 0)
+ hboxBelowEntries.pack_end(self.applyButton, False, True, 0)
+ hboxBelowEntries.pack_end(self.resetButton, False, True, 0)
hboxBelowEntries.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.rightTable, False, True, 5)
self.rightWindow.pack_start(self.descriptionLabel, False, True, 3)
self.rightWindow.pack_start(sw, False, True, 0)
self.rightWindow.pack_start(hboxBelowEntries, False, True, 10)
- self.rightWindow.show()
self.rightWindow.show_all()
self.centerWindow.pack_start(self.rightWindow, True, True, 5)
@@ -455,12 +509,10 @@ class hclient:
#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():
gtk.main()
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index a9e93dd..c08239f 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -59,6 +59,31 @@ class Device(object):
#'venenux_0_8_2' : 'VENENUX-EC 0.8.2'
#}
+ #allowed years of commercialization
+ _years = [
+ 'not-specified',
+ '2011',
+ '2010',
+ '2009',
+ '2008',
+ '2007',
+ '2006',
+ '2005',
+ '2004',
+ '2003',
+ '2002',
+ '2001',
+ '2000',
+ '1999',
+ '1998',
+ '1997',
+ '1996',
+ '1995',
+ '1994',
+ '1993',
+ '1992'
+ ]
+
#list of interfaces
_interfaces = []
@@ -150,6 +175,9 @@ class Device(object):
def getInterfaces(self):
return self._interfaces
+ def getYears(self):
+ return self._years
+
def getType(self):
return self._type
@@ -283,6 +311,9 @@ class Mycurl:
if self.domain[len(self.domain)-1] != '/':
self.domain += '/'
+ def getDomain(self):
+ return self.domain
+
def setPost(self,post):
self._post = post
@@ -326,9 +357,12 @@ class Client:
}
}
- def __init__(self,url = ''):
+ def __init__(self,url = 'http://www.h-node.com'):
self.request = Mycurl(url)
+ def getNode(self):
+ return self.request.getDomain()
+
def setNode(self,domain):
self.request.setDomain(domain)