aboutsummaryrefslogtreecommitdiff
path: root/h-client
diff options
context:
space:
mode:
Diffstat (limited to 'h-client')
-rw-r--r--h-client/hclient.py24
-rw-r--r--h-client/hlibrary.py16
2 files changed, 29 insertions, 11 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py
index d645833..0320388 100644
--- a/h-client/hclient.py
+++ b/h-client/hclient.py
@@ -195,9 +195,8 @@ class hclient:
#set the node
def setNode(self,widget):
self.client.logout()
- self.updateStatus()
- self.printErrors()
self.client.setNode(self.serverEntry.get_text())
+ self.updateStatus()
#close the preferences window
def closePref(self,widget):
@@ -207,14 +206,14 @@ class hclient:
def login(self,widget):
self.client.login(self.usernameEntry.get_text(),self.passwordEntry.get_text())
self.updateStatus()
- self.printErrors()
+ #self.printErrors()
self.loginWindow.destroy()
#logout to the server
def logout(self,widget):
self.client.logout()
self.updateStatus()
- self.printErrors()
+ #self.printErrors()
#close the login window
def closeLoginWindow(self,widget):
@@ -226,6 +225,8 @@ class hclient:
#window for preferences
self.loginWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.loginWindow.set_title("preferences")
+ self.loginWindow.set_position(gtk.WIN_POS_CENTER)
+
#self.prefWindow.set_size_request(300, -1)
vbox = gtk.VBox(False, 0)
@@ -244,6 +245,7 @@ class hclient:
### username
usernameLabel = gtk.Label("username:")
+ usernameLabel.set_alignment(0.95,0.5)
#add the label
table.attach(usernameLabel, 0, 1, 0, 1)
@@ -253,6 +255,7 @@ class hclient:
### password
passwordLabel = gtk.Label("password:")
+ passwordLabel.set_alignment(0.95,0.5)
#add the label
table.attach(passwordLabel, 0, 1, 1, 2)
@@ -280,6 +283,7 @@ class hclient:
#window for preferences
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)
vbox = gtk.VBox(False, 0)
@@ -328,7 +332,8 @@ class hclient:
self.errorBarHBox.destroy()
if len(self.client.errors) > 0:
-
+
+ self.client.errors = list(set(self.client.errors))
#self.errorBar.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self.errorBarHBox = gtk.HBox(False, 0)
@@ -351,9 +356,10 @@ 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:
- self.printErrors()
+ #else:
+ self.printErrors()
else:
+ self.printErrors()
self.loginButton.show()
self.logoutButton.hide()
self.statusLabel.set_markup("<i>you are not logged in</i>")
@@ -377,7 +383,8 @@ class hclient:
self.window.set_icon_from_file("img/icon.png")
self.window.set_size_request(550, -1)
-
+ self.window.set_position(gtk.WIN_POS_CENTER)
+
self.window.connect("delete_event", self.delete_event)
#self.window.set_border_width(0)
@@ -617,6 +624,7 @@ class hclient:
### description
#description label
self.descriptionLabel = gtk.Label("Description:")
+ self.descriptionLabel.set_alignment(0,0.5)
#description input
sw = gtk.ScrolledWindow()
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 79679b7..ae27316 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -421,8 +421,18 @@ class Client:
#log in
def login(self, username, password):
self.request.setPost({'username' : username, 'password' : password})
- self.request.perform('users/login/en')
+ result = self.request.perform('users/login/en')
self.request.setPost(None)
+ if result:
+ if self.isLogged():
+ return True
+ else:
+ self.errors.append("wrong username or password")
+ else:
+ self.errors.append("unable to connect to server")
+ return -1
+
+ return False
#log out
def logout(self):
@@ -450,13 +460,13 @@ class Client:
else:
self._status = False
self.errors.append("unable to connect to server")
- return False
+ return -1
#return True if the user is logged, else return False
def isLogged(self):
info = self.getUserInfo()
- if info != False:
+ if info != -1:
if info['status'] == 'logged':
return True