aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-04-05 15:27:10 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-04-05 15:27:10 +0000
commitf178c9a514e1fc849ebeaa8e8a546296836d29d6 (patch)
tree54a0b5b19c0a62d2da478d57bfe1da92915927fe
parent023cb1161725ae164c4019f253d656ee685a425b (diff)
h-client:improved submit button
-rw-r--r--h-client/hclient.py74
-rw-r--r--h-client/hlibrary.py14
2 files changed, 82 insertions, 6 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py
index 0320388..af5dc65 100644
--- a/h-client/hclient.py
+++ b/h-client/hclient.py
@@ -26,6 +26,7 @@ class hclient:
#the device that has to be displaced in the right window
currentDevice = None
+ currentDeviceCode = None
#get the active text from a combo
#combo: the gtk combo instance
@@ -77,16 +78,19 @@ class hclient:
#set the current device
self.currentDevice = self.client.devices[code][0]
+ self.currentDeviceCode = code
#get the device
- device = self.client.devices[code][0]
+ #device = self.client.devices[code][0]
self.setEntries()
#make sensitive the apply button
self.applyButton.set_sensitive(True)
self.resetButton.set_sensitive(True)
- self.submitButton.set_sensitive(True)
+
+ if self.client.isLogged():
+ self.submitButton.set_sensitive(True)
else:
#make non sensitive the apply button
@@ -94,6 +98,7 @@ class hclient:
self.resetButton.set_sensitive(False)
self.submitButton.set_sensitive(False)
self.currentDevice = None
+ self.currentDeviceCode = None
#set the pyGTK device entries
@@ -219,13 +224,66 @@ class hclient:
def closeLoginWindow(self,widget):
self.loginWindow.destroy()
+ #start the window containing the license notice
+ def openLicenseNoticeWindow(self,widget):
+ #window for preferences
+ self.licenseNoticeWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.licenseNoticeWindow.set_title("license notice")
+ self.licenseNoticeWindow.set_position(gtk.WIN_POS_CENTER)
+ self.licenseNoticeWindow.set_icon_from_file("img/icon.png")
+ self.licenseNoticeWindow.set_size_request(300, -1)
+
+ vbox = gtk.VBox(False, 0)
+ vbox.set_border_width(10)
+ self.licenseNoticeWindow.add(vbox)
+
+ result = self.client.getLicenseNotice();
+ #print result
+ ##if result
+
+ #label = gtk.Label(result)
+ #label.set_use_markup(True)
+
+ #description input
+ sw = gtk.ScrolledWindow()
+ #sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+ sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
+
+ noticeText = gtk.TextView()
+ noticeText.set_wrap_mode(gtk.WRAP_CHAR)
+
+ textbuffer = gtk.TextBuffer(table=None)
+ textbuffer.set_text(result)
+ noticeText.set_buffer(textbuffer)
+
+ sw.add(noticeText)
+ #sw.show()
+ #sw.show_all()
+
+ vbox.pack_start(sw, False, True, 5)
+
+ 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.login)
+ #closeButton.connect("clicked", self.closeLoginWindow)
+ hbox.pack_end(applyButton, False, True, 0)
+ hbox.pack_end(closeButton, False, True, 3)
+ vbox.pack_start(hbox, False, True, 0)
+
+ self.licenseNoticeWindow.show_all()
+
+
#start the login window
def openLoginWindow(self,widget):
#window for preferences
self.loginWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.loginWindow.set_title("preferences")
+ self.loginWindow.set_title("login")
self.loginWindow.set_position(gtk.WIN_POS_CENTER)
+ self.loginWindow.set_icon_from_file("img/icon.png")
+ self.loginWindow.set_size_request(300, -1)
#self.prefWindow.set_size_request(300, -1)
@@ -284,7 +342,8 @@ class hclient:
self.prefWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.prefWindow.set_title("preferences")
self.prefWindow.set_position(gtk.WIN_POS_CENTER)
- #self.prefWindow.set_size_request(300, -1)
+ self.prefWindow.set_icon_from_file("img/icon.png")
+ self.prefWindow.set_size_request(300, -1)
vbox = gtk.VBox(False, 0)
@@ -356,13 +415,16 @@ class hclient:
info = self.client.getUserInfo()
if info != False:
self.statusLabel.set_markup("<i>hello</i> <b>"+info['username']+"</b>, <i>you are logged in</i>")
- #else:
+
+ if self.currentDeviceCode != None:
+ self.submitButton.set_sensitive(True)
self.printErrors()
else:
self.printErrors()
self.loginButton.show()
self.logoutButton.hide()
self.statusLabel.set_markup("<i>you are not logged in</i>")
+ self.submitButton.set_sensitive(False)
#another callback
@@ -656,7 +718,7 @@ class hclient:
#submit button
self.submitButton = gtk.Button("Submit")
self.submitButton.set_sensitive(False)
- #self.resetButton.connect("clicked", self.resetChanges)
+ self.submitButton.connect("clicked", self.openLicenseNoticeWindow)
hboxBelowEntries.pack_end(self.applyButton, False, True, 0)
hboxBelowEntries.pack_end(self.resetButton, False, True, 0)
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 9f030ba..974fced 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -471,6 +471,18 @@ class Client:
return True
return False
+
+ #return the license info
+ def getLicenseNotice(self):
+ result = self.request.perform("client/licenseinfo/en");
+ if result:
+ xmldoc = minidom.parseString(self.request.contents)
+ notice = xmldoc.getElementsByTagName("license_info")[0].childNodes[0].data.encode('utf-8')
+ return notice
+ else:
+ self.errors.append("unable to connect to server")
+ return -1
+
def createDevices(self):
if not os.system('lspci -vmmnn > tmp/temp'):
@@ -574,6 +586,8 @@ class Client:
if device.getElementsByTagName("description")[0].hasChildNodes():
description = device.getElementsByTagName("description")[0].childNodes[0].data.encode('utf-8')
dev[0].setDescription(description)
+ else:
+ dev[0].setDescription('')
if device.getElementsByTagName("kernel_libre")[0].hasChildNodes():
kernel_libre = device.getElementsByTagName("kernel_libre")[0].childNodes[0].data.encode('utf-8')