From b592f60c4519ca2f1e99e9a526c04531a2320f8a Mon Sep 17 00:00:00 2001
From: Nikos Kouremenos <kourem@gmail.com>
Date: Thu, 3 Mar 2005 22:14:50 +0000
Subject: [PATCH] new message class should be stable

---
 plugins/gtkgui/dialogs.py   | 29 ++++++++++++----------------
 plugins/gtkgui/gtkgui.glade | 38 +++++++++++++++++++++++++++----------
 plugins/gtkgui/gtkgui.py    |  6 +++---
 3 files changed, 43 insertions(+), 30 deletions(-)

diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py
index db8c96d0f3..4deaa4a3df 100644
--- a/plugins/gtkgui/dialogs.py
+++ b/plugins/gtkgui/dialogs.py
@@ -3,7 +3,7 @@
 ## Gajim Team:
 ## 	- Yann Le Boulanger <asterix@lagaule.org>
 ## 	- Vincent Hanquez <tab@snarc.org>
-##  - Nikos Kouremenos <nkour@jabber.org>
+##		- Nikos Kouremenos <nkour@jabber.org>
 ##
 ##	Copyright (C) 2003-2005 Gajim Team
 ##
@@ -584,7 +584,7 @@ class join_groupchat_window:
 		self.xml.signal_autoconnect(self)
 		self.plugin.windows['join_gc'] = self # now add us to open windows
 
-class new_message_window: #FIXME: NOT READY
+class New_message_window:
 	def on_delete_event(self, widget):
 		"""close window"""
 		del self.plugin.windows['new_msg']
@@ -595,22 +595,15 @@ class new_message_window: #FIXME: NOT READY
 
 	def on_chat_button_clicked(self, widget):
 		"""When Chat button is clicked"""
-		#FIXME: either make it simple entry, or find a way to handle windows the easy way
-		userid_comboboxentry = self.xml.get_widget('userid_comboboxentry')
-		userid_comboboxentry.child.set_activates_default(True)
-		userid = self.xml.get_widget('userid_comboboxentry').child.get_text()
-		#FIXME: if the user doesn't give jid, but name look in the roster
-		#DO IT WITH AUTOCOMPLETE
-		#SO USER ID SHOULD BECOME JID and sent to new_chat()
-		jid = userid
-		
-		#FIXME: if user is there, use that instance IF POSSIBLE [is it Yann?]
-		#if not self.plugin.roster.contacts[self.account].has_key(jid):
+		jid = self.jid_entry.get_text()
 		# use User class, new_chat expects it that way
-		user = gtkgui.User(jid, jid, ['not in the roster'], \
-			'not in the roster', 'not in the roster', 'none', None, '', 0, '')
-		self.plugin.roster.contacts[self.account][jid] = [user]
-		self.plugin.roster.add_user_to_roster(user.jid, self.account)
+		if not self.plugin.roster.contacts[self.account].has_key(jid):
+			user = gtkgui.User(jid, jid, ['not in the roster'], \
+				'not in the roster', 'not in the roster', 'none', None, '', 0, '')
+			self.plugin.roster.contacts[self.account][jid] = [user]
+			self.plugin.roster.add_user_to_roster(user.jid, self.account)
+		else:
+			[user] = self.plugin.roster.contacts[self.account][jid]
 		self.plugin.roster.new_chat(user, self.account)
 		widget.get_toplevel().destroy()
 
@@ -622,5 +615,7 @@ class new_message_window: #FIXME: NOT READY
 		self.account = account
 		self.xml = gtk.glade.XML(GTKGUI_GLADE, 'new_message_window', APP)
 		self.window = self.xml.get_widget('new_message_window')
+		self.jid_entry = self.xml.get_widget('jid_entry')
+		self.jid_entry.set_activates_default(True)
 		self.xml.signal_autoconnect(self)
 		self.plugin.windows['new_message'] = self # now add us to open windows
diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade
index 754a28f3c0..059f7197b7 100644
--- a/plugins/gtkgui/gtkgui.glade
+++ b/plugins/gtkgui/gtkgui.glade
@@ -314,6 +314,7 @@
 </widget>
 
 <widget class="GtkWindow" id="configure_accounts_window">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Accounts</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -518,6 +519,7 @@
 </widget>
 
 <widget class="GtkWindow" id="about_window">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">About</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -644,6 +646,7 @@ Nikos Kouremenos (nkour@jabber.org)</property>
 </widget>
 
 <widget class="GtkWindow" id="account_window">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Account Modification</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -1858,7 +1861,7 @@ on the server as a vCard</property>
 </widget>
 
 <widget class="GtkWindow" id="add_contact_window">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="width_request">400</property>
   <property name="height_request">334</property>
   <property name="visible">True</property>
@@ -2244,7 +2247,7 @@ on the server as a vCard</property>
 </widget>
 
 <widget class="GtkWindow" id="subscription_request_window">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Subscription request</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -2509,6 +2512,7 @@ on the server as a vCard</property>
 </widget>
 
 <widget class="GtkWindow" id="agent_browser_window">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Agents browser</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -2772,7 +2776,7 @@ on the server as a vCard</property>
 </widget>
 
 <widget class="GtkWindow" id="agent_registration_window">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Register to</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -3004,7 +3008,7 @@ on the server as a vCard</property>
 </widget>
 
 <widget class="GtkWindow" id="preferences_window">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Preferences</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -5180,7 +5184,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkWindow" id="vcard_information_window">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Information</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -6491,6 +6495,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkWindow" id="history_window">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Log</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -6807,7 +6812,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkWindow" id="Gc">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Groupchat</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -7055,7 +7060,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkWindow" id="join_groupchat_window">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Join Groupchat</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -7387,6 +7392,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkDialog" id="passphrase_dialog">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Passphrase</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -7528,6 +7534,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkDialog" id="choose_gpg_key_dialog">
+  <property name="border_width">4</property>
   <property name="visible">True</property>
   <property name="title" translatable="yes">Passphrase</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
@@ -7656,7 +7663,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkDialog" id="away_message_dialog">
-  <property name="border_width">5</property>
+  <property name="border_width">4</property>
   <property name="width_request">303</property>
   <property name="height_request">225</property>
   <property name="visible">True</property>
@@ -8171,6 +8178,7 @@ Custom</property>
 		    <widget class="GtkTextView" id="message_textview">
 		      <property name="visible">True</property>
 		      <property name="can_focus">True</property>
+		      <property name="has_focus">True</property>
 		      <property name="editable">True</property>
 		      <property name="overwrite">False</property>
 		      <property name="accepts_tab">True</property>
@@ -8230,6 +8238,7 @@ Custom</property>
 </widget>
 
 <widget class="GtkWindow" id="new_message_window">
+  <property name="border_width">4</property>
   <property name="width_request">461</property>
   <property name="height_request">163</property>
   <property name="visible">True</property>
@@ -8305,13 +8314,22 @@ send a chat message to</property>
       </child>
 
       <child>
-	<widget class="GtkComboBoxEntry" id="userid_comboboxentry">
+	<widget class="GtkEntry" id="jid_entry">
 	  <property name="visible">True</property>
+	  <property name="can_focus">True</property>
+	  <property name="has_focus">True</property>
+	  <property name="editable">True</property>
+	  <property name="visibility">True</property>
+	  <property name="max_length">0</property>
+	  <property name="text" translatable="yes"></property>
+	  <property name="has_frame">True</property>
+	  <property name="invisible_char">*</property>
+	  <property name="activates_default">False</property>
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
 	  <property name="expand">False</property>
-	  <property name="fill">True</property>
+	  <property name="fill">False</property>
 	</packing>
       </child>
 
diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py
index 36e0f13ab1..87df6b123a 100644
--- a/plugins/gtkgui/gtkgui.py
+++ b/plugins/gtkgui/gtkgui.py
@@ -3,7 +3,7 @@
 ## Gajim Team:
 ## 	- Yann Le Boulanger <asterix@lagaule.org>
 ## 	- Vincent Hanquez <tab@snarc.org>
-##  - Nikos Kouremenos <nkour@jabber.org>
+##		- Nikos Kouremenos <nkour@jabber.org>
 ##
 ##	Copyright (C) 2003-2005 Gajim Team
 ##
@@ -1815,9 +1815,9 @@ class roster_window:
 		join_groupchat_window(self.plugin, account)
 
 	def on_new_message_menuitem_activate(self, widget, account):
-		"""When New Message is activated:
+		"""When new message menuitem is activated:
 		call the new_message_window class"""
-		new_message_window(self.plugin, account)
+		New_message_window(self.plugin, account)
 			
 	def on_about_menuitem_activate(self, widget):
 		"""When about is selected :
-- 
GitLab