From 9e91c026b84166c044670e46ad519493d7f41463 Mon Sep 17 00:00:00 2001
From: Nikos Kouremenos <kourem@gmail.com>
Date: Wed, 16 Mar 2005 01:27:37 +0000
Subject: [PATCH] I tried to make gajim more HCI friendly. ERRORS use Error
 dialog and not warning dialog. Need core implementation too. Also other
 fixes. plz see a comment for you yann (sre)

---
 plugins/gtkgui/chat.py             |  8 ++++++--
 plugins/gtkgui/config.py           | 30 +++++++++++++--------------
 plugins/gtkgui/dialogs.py          | 33 +++++++++++++++---------------
 plugins/gtkgui/groupchat_window.py |  2 +-
 plugins/gtkgui/gtkgui.glade        | 10 ++++-----
 plugins/gtkgui/roster_window.py    |  4 ++--
 6 files changed, 46 insertions(+), 41 deletions(-)

diff --git a/plugins/gtkgui/chat.py b/plugins/gtkgui/chat.py
index 97c923c71f..310e8c840c 100644
--- a/plugins/gtkgui/chat.py
+++ b/plugins/gtkgui/chat.py
@@ -90,9 +90,13 @@ class Chat:
 		elif unread == 1:
 			start = "* "
 		chat = self.names[jid]
-		if len(self.xmls) > 1:
+		if len(self.xmls) > 1: # if more than one tabs in the same window
 			chat = 'Chat'
-		self.window.set_title(start + chat + ' (' + self.account + ')')
+		if len(self.plugin.accounts.keys()) >= 2: # if we have 2 or more accounts
+			title = start + chat + ' (account: ' + self.account + ')'
+		else:
+			title = start + chat
+		self.window.set_title(title)
 
 	def redraw_tab(self, jid):
 		"""redraw the label of the tab"""
diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py
index e9234e4088..9ecc025cd5 100644
--- a/plugins/gtkgui/config.py
+++ b/plugins/gtkgui/config.py
@@ -1067,26 +1067,26 @@ class Account_modification_window:
 		proxyhost = self.xml.get_widget('proxyhost_entry').get_text()
 		proxyport = self.xml.get_widget('proxyport_entry').get_text()
 		if (name == ''):
-			Warning_dialog(_('You must enter a name for this account'))
-			return 0
+			Error_dialog(_('You must enter a name for this account'))
+			return
 		if name.find(' ') != -1:
-			Warning_dialog(_('Spaces are not permited in account name'))
-			return 0
+			Error_dialog(_('Spaces are not permited in account name'))
+			return
 		if (jid == '') or (jid.count('@') != 1):
-			Warning_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org'))
-			return 0
+			Error_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org'))
+			return
 		if new_account_checkbutton.get_active() and password == '':
-			Warning_dialog(_('You must enter a password to register a new account'))
-			return 0
+			Error_dialog(_('You must enter a password to register a new account'))
+			return
 		if use_proxy:
 			if proxyport != '':
 				try:
 					proxyport = int(proxyport)
 				except ValueError:
-					Warning_dialog(_('Proxy Port must be a port number'))
-					return 0
+					Error_dialog(_('Proxy Port must be a port number'))
+					return
 			if proxyhost == '':
-				Warning_dialog(_('You must enter a proxy host to use proxy'))
+				Error_dialog(_('You must enter a proxy host to use proxy'))
 
 		(login, hostname) = jid.split('@')
 		key_name = self.xml.get_widget('gpg_name_label').get_text()
@@ -1145,7 +1145,7 @@ class Account_modification_window:
 			return
 		#if it's a new account
 		if name in self.plugin.accounts.keys():
-			Warning_dialog(_('An account already has this name'))
+			Error_dialog(_('An account already has this name'))
 			return
 		#if we neeed to register a new account
 		if new_account_checkbutton.get_active():
@@ -1234,11 +1234,11 @@ class Account_modification_window:
 
 	def on_edit_details_button_clicked(self, widget):
 		if not self.plugin.windows.has_key(self.account):
-			Warning_dialog(_('You must first create your account before editing your information'))
+			Error_dialog(_('You must first create your account before editing your information'))
 			return
 		jid = self.xml.get_widget('jid_entry').get_text()
 		if self.plugin.connected[self.account] < 2:
-			Warning_dialog(_('You must be connected to edit your information'))
+			Error_dialog(_('You must be connected to edit your information'))
 			return
 		if not self.plugin.windows[self.account]['infos'].has_key('vcard'):
 			self.plugin.windows[self.account]['infos'][jid] = \
@@ -1579,7 +1579,7 @@ class agent_browser_window:
 		
 	def __init__(self, plugin, account):
 		if plugin.connected[account] < 2:
-			Warning_dialog(_("You must be connected to view Agents"))
+			Error_dialog(_("You must be connected to view Agents"))
 			return
 		xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)
 		self.window = xml.get_widget('agent_browser_window')
diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py
index 997359b30b..8d582e21e1 100644
--- a/plugins/gtkgui/dialogs.py
+++ b/plugins/gtkgui/dialogs.py
@@ -151,7 +151,7 @@ class vcard_information_window:
 
 	def on_publish_button_clicked(self, widget):
 		if self.plugin.connected[self.account] < 2:
-			Warning_dialog(_("You must be connected to publish your informations"))
+			Error_dialog(_("You must be connected to publish your informations"))
 			return
 		vcard = self.make_vcard()
 		nick = ''
@@ -166,7 +166,7 @@ class vcard_information_window:
 		if self.plugin.connected[self.account] > 1:
 			self.plugin.send('ASK_VCARD', self.account, self.jid)
 		else:
-			Warning_dialog(_('You must be connected to get your informations'))
+			Error_dialog(_('You must be connected to get your informations'))
 
 	def change_to_vcard(self):
 		self.xml.get_widget('information_notebook').remove_page(0)
@@ -237,7 +237,7 @@ class Passphrase_dialog:
 		self.xml.signal_autoconnect(self)
 
 class choose_gpg_key_dialog:
-	"""Class for Away Message Window"""
+	"""Class for GPG key dialog"""
 	def run(self):
 		"""Wait for Ok button to be pressed and return the selected key"""
 		rep = self.window.run()
@@ -270,7 +270,7 @@ class choose_gpg_key_dialog:
 		self.keys_treeview.insert_column_with_attributes(-1, _('User name'), \
 			renderer, text=1)
 
-class Away_message_dialog:
+class Change_status_message_dialog:
 	"""Class for Away message dialog"""
 	def run(self):
 		"""Wait for OK button to be pressed and return away messsage"""
@@ -296,14 +296,15 @@ class Away_message_dialog:
 		name = model[active][0]
 		self.message_buffer.set_text(self.values[name])
 	
-	def on_away_message_dialog_key_press_event(self, widget, event):
-		if event.keyval == gtk.keysyms.Return:
+	def on_change_status_message_dialog_key_press_event(self, widget, event):
+		if event.keyval == gtk.keysyms.Return: # catch CTRL+ENTER
 			if (event.state & gtk.gdk.CONTROL_MASK):
 				self.window.response(gtk.RESPONSE_OK)
 	
-	def __init__(self, plugin, autoconnect = 0):
-		self.xml = gtk.glade.XML(GTKGUI_GLADE, 'away_message_dialog', APP)
-		self.window = self.xml.get_widget('away_message_dialog')
+	def __init__(self, plugin, status, autoconnect = 0):
+		self.xml = gtk.glade.XML(GTKGUI_GLADE, 'change_status_message_dialog', APP)
+		self.window = self.xml.get_widget('change_status_message_dialog')
+		self.window.set_title(status.capitalize() + ' Status Message')
 		self.plugin = plugin
 		self.autoconnect = autoconnect
 		message_textview = self.xml.get_widget('message_textview')
@@ -336,7 +337,7 @@ class add_contact_window:
 		if not jid:
 			return
 		if jid.find('@') < 0:
-			Warning_dialog(_("The contact's name must be something like login@hostname"))
+			Error_dialog(_("The contact's name must be something like login@hostname"))
 			return
 		message_buffer = self.xml.get_widget('message_textview').get_buffer()
 		start_iter = message_buffer.get_start_iter()
@@ -393,7 +394,7 @@ class add_contact_window:
 		
 	def __init__(self, plugin, account, jid=None):
 		if plugin.connected[account] < 2:
-			Warning_dialog(_('You must be connected to add a contact'))
+			Error_dialog(_('You must be connected to add a contact'))
 			return
 		self.plugin = plugin
 		self.account = account
@@ -569,7 +570,7 @@ class join_groupchat_window:
 
 	def __init__(self, plugin, account, server='', room = ''):
 		if plugin.connected[account] < 2:
-			Warning_dialog(_('You must be connected to join a group chat'))
+			Error_dialog(_('You must be connected to join a group chat'))
 			return
 		self.plugin = plugin
 		self.account = account
@@ -613,7 +614,7 @@ class New_message_dialog:
 
 	def __init__(self, plugin, account):
 		if plugin.connected[account] < 2:
-			Warning_dialog(_('You must be connected to send a message to a contact'))
+			Error_dialog(_('You must be connected to send a message to a contact'))
 			return
 		self.plugin = plugin
 		self.account = account
@@ -632,11 +633,11 @@ class Change_password_dialog:
 			if rep == gtk.RESPONSE_OK:
 				password1 = self.password1_entry.get_text()
 				if not password1:
-					Warning_dialog(_('Your password cannot be empty'))
+					Error_dialog(_('Your password cannot be empty'))
 					continue
 				password2 = self.password2_entry.get_text()
 				if password1 != password2:
-					Warning_dialog(_('Your passwords are not the same'))
+					Error_dialog(_('Confirmation password is not the same'))
 					continue
 				message = password1
 			else:
@@ -647,7 +648,7 @@ class Change_password_dialog:
 
 	def __init__(self, plugin, account):
 		if plugin.connected[account] < 2:
-			Warning_dialog(_('You must be connected to change your password'))
+			Error_dialog(_('You must be connected to change your password'))
 			return
 		self.plugin = plugin
 		self.account = account
diff --git a/plugins/gtkgui/groupchat_window.py b/plugins/gtkgui/groupchat_window.py
index fed8f2dc4a..142ad42985 100644
--- a/plugins/gtkgui/groupchat_window.py
+++ b/plugins/gtkgui/groupchat_window.py
@@ -23,7 +23,7 @@ import gtk.glade
 import pango
 import gobject
 import time
-import sre #usefull later
+import sre #usefull later #(nk) really? :)
 
 from dialogs import *
 from chat import *
diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade
index 8c325f6da4..534dba7776 100644
--- a/plugins/gtkgui/gtkgui.glade
+++ b/plugins/gtkgui/gtkgui.glade
@@ -7819,12 +7819,12 @@ Custom</property>
   </child>
 </widget>
 
-<widget class="GtkDialog" id="away_message_dialog">
+<widget class="GtkDialog" id="change_status_message_dialog">
   <property name="border_width">4</property>
   <property name="width_request">303</property>
   <property name="height_request">225</property>
   <property name="visible">True</property>
-  <property name="title" translatable="yes">Message</property>
+  <property name="title" translatable="yes">Status Message for</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="window_position">GTK_WIN_POS_NONE</property>
   <property name="modal">False</property>
@@ -7836,7 +7836,7 @@ Custom</property>
   <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
   <property name="has_separator">True</property>
-  <signal name="key_press_event" handler="on_away_message_dialog_key_press_event" last_modification_time="Wed, 02 Mar 2005 12:35:32 GMT"/>
+  <signal name="key_press_event" handler="on_change_status_message_dialog_key_press_event" last_modification_time="Wed, 16 Mar 2005 00:53:06 GMT"/>
 
   <child internal-child="vbox">
     <widget class="GtkVBox" id="dialog-vbox5">
@@ -7881,7 +7881,7 @@ Custom</property>
 	  <child>
 	    <widget class="GtkLabel" id="label164">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Enter your message :</property>
+	      <property name="label" translatable="yes">Enter your message:</property>
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -7938,7 +7938,7 @@ Custom</property>
 	  <child>
 	    <widget class="GtkLabel" id="label165">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Or choose your message :</property>
+	      <property name="label" translatable="yes">Or choose your message:</property>
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
diff --git a/plugins/gtkgui/roster_window.py b/plugins/gtkgui/roster_window.py
index a9ea1ebd0e..0773393238 100644
--- a/plugins/gtkgui/roster_window.py
+++ b/plugins/gtkgui/roster_window.py
@@ -730,8 +730,8 @@ class roster_window:
 			or (status == 'offline' and not \
 			self.plugin.config['ask_offline_status']):
 			return status
-		w = Away_message_dialog(self.plugin, autoconnect)
-		message = w.run()
+		dlg = Change_status_message_dialog(self.plugin, status, autoconnect)
+		message = dlg.run()
 		return message
 
 	def change_status(self, widget, account, status):
-- 
GitLab