aboutsummaryrefslogtreecommitdiff
path: root/h-client
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-04-11 23:40:41 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-04-11 23:40:41 +0000
commit9fb4924d5aa544bc51b3f5811772485fe865ca81 (patch)
tree016807b1291a2f3e6a228b0f97b80e5d521ff7ba /h-client
parente4ef6b116b273362c521854cc517bb1c5b8b0cd7 (diff)
h-client:implemented big icons
Diffstat (limited to 'h-client')
-rw-r--r--h-client/credits.txt2
-rw-r--r--h-client/hclient.py119
-rw-r--r--h-client/hlibrary.py21
-rwxr-xr-xh-client/img/devices/big/unknown.pngbin0 -> 3913 bytes
4 files changed, 68 insertions, 74 deletions
diff --git a/h-client/credits.txt b/h-client/credits.txt
index e89d30b..b880447 100644
--- a/h-client/credits.txt
+++ b/h-client/credits.txt
@@ -15,3 +15,5 @@ icons taken from the Crystal Projects icons (http://www.everaldo.com/crystal/?ac
img/devices/small/videocard.png
+img/devices/big/videocard.png
+
diff --git a/h-client/hclient.py b/h-client/hclient.py
index 64c59e3..f97cbd3 100644
--- a/h-client/hclient.py
+++ b/h-client/hclient.py
@@ -90,6 +90,12 @@ class hclient:
self.resetButton.set_sensitive(True)
self.submitButton.set_sensitive(True)
+ self.tihbox.show()
+ self.bigIcon.set_from_file("img/devices/big/"+self.currentDevice.getIcon())
+ if self.client.devices[code][2] == 'insert':
+ self.deviceInfoLabel.set_markup("this device is not present in the server database,\n would you like to <b>insert</b> it?")
+ else:
+ self.deviceInfoLabel.set_markup("this device is already present in the server database,\n would you like to <b>update</b> it?")
#self.updateStatus()
else:
@@ -99,6 +105,7 @@ class hclient:
self.submitButton.set_sensitive(False)
self.currentDevice = None
self.currentDeviceCode = None
+
#self.updateStatus()
@@ -201,6 +208,7 @@ class hclient:
#set the node
def setNode(self,widget):
self.client.logout()
+ self.client.errors = []
self.client.setNode(self.serverEntry.get_text())
self.updateStatus()
@@ -214,11 +222,10 @@ class hclient:
self.updateStatus()
if self._submitFlag:
- if self.client.isLogged() != -2:
- if self.client.isLogged():
- self.applyChanges(None)
- self.client.submit(self.currentDeviceCode)
- self.printErrors()
+ if self.client.isLogged():
+ self.applyChanges(None)
+ self.client.submit(self.currentDeviceCode)
+ self.printErrors()
self._submitFlag = False
@@ -230,12 +237,11 @@ class hclient:
self.applyChanges(None)
self.licenseNoticeWindow.destroy()
- if self.client.isLogged() != -2:
- if self.client.isLogged():
- self.client.submit(self.currentDeviceCode)
- else:
- self._submitFlag = True
- self.openLoginWindow(None)
+ if self.client.isLogged():
+ self.client.submit(self.currentDeviceCode)
+ else:
+ self._submitFlag = True
+ self.openLoginWindow(None)
self.printErrors()
@@ -261,35 +267,16 @@ class hclient:
self.infoWindow.destroy()
def openInfoWindow(self,widget):
- self.infoWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.infoWindow.set_title("info")
- self.infoWindow.set_position(gtk.WIN_POS_CENTER)
- self.infoWindow.set_icon_from_file("img/icon.png")
- #self.infoWindow.set_size_request(300, -1)
-
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- self.infoWindow.add(vbox)
-
- label = gtk.Label("<b>h-node client</b>")
- label.set_use_markup(True)
- vbox.pack_start(label, False, True, 5)
+ about = gtk.AboutDialog()
+ about.set_program_name("h-node client")
+ #about.set_version("")
+ about.set_copyright("(c) Antonio Gallo")
+ about.set_comments("simple client for h-node.com, licensed under the GPLv3")
+ about.set_website("http://www.h-node.com")
+ #about.set_logo(gtk.gdk.pixbuf_new_from_file("battery.png"))
+ about.run()
+ about.destroy()
- label = gtk.Label("Copyright (C) 2011 Antonio Gallo")
- label.set_use_markup(True)
- vbox.pack_start(label, False, True, 5)
-
- label = gtk.Label("GPLv3")
- label.set_use_markup(True)
- vbox.pack_start(label, False, True, 5)
-
- closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
- closeButton.connect("clicked", self.closeInfoWindowWindow)
- vbox.pack_start(closeButton, False, True, 5)
-
- self.infoWindow.show_all()
-
-
#start the window containing the license notice
def openLicenseNoticeWindow(self,widget):
#window for preferences
@@ -333,7 +320,7 @@ class hclient:
hbox = gtk.HBox(False, 0)
hbox.set_border_width(10)
applyButton = gtk.Button(stock=gtk.STOCK_APPLY)
- closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
+ closeButton = gtk.Button(stock=gtk.STOCK_CANCEL)
applyButton.connect("clicked", self.submit)
closeButton.connect("clicked", self.closeLicenseNoticeWindow)
hbox.pack_end(applyButton, False, True, 0)
@@ -396,7 +383,7 @@ class hclient:
hbox = gtk.HBox(False, 0)
hbox.set_border_width(10)
applyButton = gtk.Button(stock=gtk.STOCK_APPLY)
- closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
+ closeButton = gtk.Button(stock=gtk.STOCK_CANCEL)
applyButton.connect("clicked", self.login)
closeButton.connect("clicked", self.closeLoginWindow)
hbox.pack_end(applyButton, False, True, 0)
@@ -484,33 +471,24 @@ class hclient:
self.logoutButton.show()
info = self.client.getUserInfo()
if info != False:
- if info != -2:
- self.statusLabel.set_markup("<i>hello</i> <b>"+info['username']+"</b>, <i>you are logged in</i>")
+ self.statusLabel.set_markup("<i>hello</i> <b>"+info['username']+"</b>, <i>you are logged in</i>")
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>")
- #def setTreeViewCell(self,column, cell_renderer, model, iter):
- ##img = model.get_value(iter, 3)
- ##imgFlag = model.get_value(iter, 5)
- #print model
- ##self.devices.clear_attributes(cell_renderer)
- ##if imgFlag == 'image':
- ###print True
- ##cell_renderer.set_property('pixbuf', img)
- #return
+ self.printErrors()
+ #delete event of the login window
def delete_event_login(self, widget, event, data=None):
self._submitFlag = False
return False
- #another callback
+
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
@@ -521,7 +499,7 @@ class hclient:
self._submitFlag = False
#start the client object
- self.client = Client('http://www.h-node.com')
+ self.client = Client('h-source')
self.client.createDevices()
# Create the main window
@@ -530,7 +508,7 @@ class hclient:
self.window.set_title("h-client")
self.window.set_icon_from_file("img/icon.png")
- self.window.set_size_request(550, -1)
+ self.window.set_size_request(600, -1)
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.connect("delete_event", self.delete_event)
@@ -663,11 +641,20 @@ class hclient:
self.statusLabel.set_use_markup(True)
rthbox.pack_end(self.statusLabel, False, True, 0)
+ #top image
+ self.tihbox = gtk.HBox(False, 0)
+ self.bigIcon = gtk.Image()
+ self.bigIcon.set_from_file("img/devices/big/unknown.png")
+ self.tihbox.pack_end(self.bigIcon, False, True, 0)
- self.rightTable = gtk.Table(8, 2, True)
+ self.deviceInfoLabel = gtk.Label("rrr")
+ self.deviceInfoLabel.set_use_markup(True)
+ self.tihbox.pack_start(self.deviceInfoLabel, False, True, 3)
#create the entries
+ self.rightTable = gtk.Table(8, 2, True)
+
### model
#model name label
self.modelNameLabel = gtk.Label("Model name:")
@@ -790,6 +777,8 @@ class hclient:
self.descriptionText = gtk.TextView()
self.descriptionText.set_wrap_mode(gtk.WRAP_CHAR)
+ self.descriptionText.set_left_margin(5)
+ self.descriptionText.set_right_margin(5)
sw.add(self.descriptionText)
sw.show()
@@ -826,7 +815,8 @@ class hclient:
#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.tihbox, True, True, 3)
+ self.rightWindow.pack_start(self.rightTable, False, True, 3)
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)
@@ -843,8 +833,6 @@ class hclient:
rvbox.pack_start(rthbox, True, True, 0)
rvbox.pack_start(rFrame, True, True, 0)
-
-
self.centerWindow.pack_start(rvbox, True, True, 0)
#self.rframe.add(self.rightWindow)
@@ -856,6 +844,15 @@ class hclient:
self.window.show()
self.synchronize(None)
self.updateStatus()
+
+ #select the first device
+ self.tree.get_selection().select_path(0)
+ ts, itera = self.tree.get_selection().get_selected()
+ if itera:
+ next = ts.iter_nth_child(itera, 0)
+ path = ts.get_path(next)
+ self.tree.get_selection().select_path(path)
+
#self.logoutButton.hide()
def main():
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index c3ade68..cc25edc 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -432,12 +432,10 @@ class Client:
result = self.request.perform('users/login/en')
self.request.setPost(None)
if result:
- result_login = self.isLogged()
- if result_login != -2:
- if result_login:
- return True
- else:
- self.errors.append("wrong username or password")
+ if self.isLogged():
+ return True
+ else:
+ self.errors.append("wrong username or password")
else:
self.errors.append("unable to connect to server")
@@ -474,7 +472,7 @@ class Client:
return {'status':status,'username':username,'token':token,'groups':groups}
except:
self.errors.append("the server is not up-to-date: unable to parse the xml database")
- return -2
+ return False
else:
self.errors.append("unable to connect to server")
return False
@@ -484,12 +482,9 @@ class Client:
info = self.getUserInfo()
if info != False:
- if info != -2:
- if info['status'] == 'logged':
- return True
- else:
- return -2
-
+ if info['status'] == 'logged':
+ return True
+
return False
#return the license info
diff --git a/h-client/img/devices/big/unknown.png b/h-client/img/devices/big/unknown.png
new file mode 100755
index 0000000..c2ab531
--- /dev/null
+++ b/h-client/img/devices/big/unknown.png
Binary files differ