NewMessageDialog now uses InputDialog
This commit is contained in:
		
							parent
							
								
									0eeba54e67
								
							
						
					
					
						commit
						4aa1f88420
					
				
					 2 changed files with 30 additions and 251 deletions
				
			
		| 
						 | 
				
			
			@ -639,58 +639,46 @@ _('You can not join a group chat unless you are connected.')).get_response()
 | 
			
		|||
 | 
			
		||||
class NewMessageDialog:
 | 
			
		||||
	def __init__(self, plugin, account):
 | 
			
		||||
		if gajim.connections[account].connected < 2:
 | 
			
		||||
			ErrorDialog(_('You are not connected to the server'),
 | 
			
		||||
				_('Without a connection, you can not send messages.')).get_response()
 | 
			
		||||
			return
 | 
			
		||||
		self.plugin = plugin
 | 
			
		||||
		self.account = account
 | 
			
		||||
		self.xml = gtk.glade.XML(GTKGUI_GLADE, 'new_message_dialog', APP)
 | 
			
		||||
		self.window = self.xml.get_widget('new_message_dialog')
 | 
			
		||||
		self.jid_entry = self.xml.get_widget('jid_entry')
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		our_jid = gajim.config.get_per('accounts', self.account, 'name') + '@' + \
 | 
			
		||||
			gajim.config.get_per('accounts', self.account, 'hostname')
 | 
			
		||||
		if len(gajim.connections) > 1:
 | 
			
		||||
			title = _('New Message as ') + our_jid
 | 
			
		||||
		else:
 | 
			
		||||
			title = _('New Message')
 | 
			
		||||
		self.window.set_title(title)
 | 
			
		||||
		
 | 
			
		||||
		self.xml.signal_autoconnect(self)
 | 
			
		||||
		self.window.show_all()
 | 
			
		||||
		prompt_text = _('Enter the user ID of the contact you would like\nto send a chat message to:')
 | 
			
		||||
 | 
			
		||||
	def on_cancel_button_clicked(self, widget):
 | 
			
		||||
		'''When Cancel button is clicked'''
 | 
			
		||||
		self.window.destroy()
 | 
			
		||||
		instance = InputDialog(title, prompt_text)
 | 
			
		||||
		response = instance.get_response()
 | 
			
		||||
		if response == gtk.RESPONSE_OK:  
 | 
			
		||||
			jid = instance.input_entry.get_text()
 | 
			
		||||
 | 
			
		||||
	def on_chat_button_clicked(self, widget):
 | 
			
		||||
		'''When Chat button is clicked'''
 | 
			
		||||
		jid = self.jid_entry.get_text()
 | 
			
		||||
		if jid.find('@') == -1: # if no @ was given
 | 
			
		||||
			ErrorDialog(_('Invalid user ID'),
 | 
			
		||||
_('User ID must be of the form "username@servername".')).get_response()
 | 
			
		||||
			return
 | 
			
		||||
		self.window.destroy()
 | 
			
		||||
		# use User class, new_chat expects it that way
 | 
			
		||||
		# is it in the roster?
 | 
			
		||||
		if self.plugin.roster.contacts[self.account].has_key(jid):
 | 
			
		||||
			user = self.plugin.roster.contacts[self.account][jid][0]
 | 
			
		||||
		else:
 | 
			
		||||
			keyID = ''
 | 
			
		||||
			attached_keys = gajim.config.get_per('accounts', self.account,
 | 
			
		||||
				'attached_gpg_keys').split()
 | 
			
		||||
			if jid in attached_keys:
 | 
			
		||||
				keyID = attached_keys[attached_keys.index(jid) + 1]
 | 
			
		||||
			user = User(jid, jid, ['not in the roster'], 'not in the roster',
 | 
			
		||||
				'not in the roster', 'none', None, '', 0, keyID)
 | 
			
		||||
			self.plugin.roster.contacts[self.account][jid] = [user]
 | 
			
		||||
			self.plugin.roster.add_user_to_roster(user.jid, self.account)			
 | 
			
		||||
			if jid.find('@') == -1: # if no @ was given
 | 
			
		||||
				ErrorDialog(_('Invalid user ID'),
 | 
			
		||||
		_('User ID must be of the form "username@servername".')).get_response()
 | 
			
		||||
				return
 | 
			
		||||
 | 
			
		||||
		if not self.plugin.windows[self.account]['chats'].has_key(jid):
 | 
			
		||||
			self.plugin.roster.new_chat(user, self.account)
 | 
			
		||||
		self.plugin.windows[self.account]['chats'][jid].set_active_tab(jid)
 | 
			
		||||
		self.plugin.windows[self.account]['chats'][jid].window.present()
 | 
			
		||||
			# use User class, new_chat expects it that way
 | 
			
		||||
			# is it in the roster?
 | 
			
		||||
			if self.plugin.roster.contacts[self.account].has_key(jid):
 | 
			
		||||
				user = self.plugin.roster.contacts[self.account][jid][0]
 | 
			
		||||
			else:
 | 
			
		||||
				keyID = ''
 | 
			
		||||
				attached_keys = gajim.config.get_per('accounts', self.account,
 | 
			
		||||
					'attached_gpg_keys').split()
 | 
			
		||||
				if jid in attached_keys:
 | 
			
		||||
					keyID = attached_keys[attached_keys.index(jid) + 1]
 | 
			
		||||
				user = User(jid, jid, ['not in the roster'], 'not in the roster',
 | 
			
		||||
					'not in the roster', 'none', None, '', 0, keyID)
 | 
			
		||||
				self.plugin.roster.contacts[self.account][jid] = [user]
 | 
			
		||||
				self.plugin.roster.add_user_to_roster(user.jid, self.account)			
 | 
			
		||||
 | 
			
		||||
			if not self.plugin.windows[self.account]['chats'].has_key(jid):
 | 
			
		||||
				self.plugin.roster.new_chat(user, self.account)
 | 
			
		||||
			self.plugin.windows[self.account]['chats'][jid].set_active_tab(jid)
 | 
			
		||||
			self.plugin.windows[self.account]['chats'][jid].window.present()
 | 
			
		||||
 | 
			
		||||
class ChangePasswordDialog:
 | 
			
		||||
	def __init__(self, plugin, account):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										211
									
								
								src/gtkgui.glade
									
										
									
									
									
								
							
							
						
						
									
										211
									
								
								src/gtkgui.glade
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -10777,216 +10777,6 @@ JID: whatever@jabber.org</property>
 | 
			
		|||
  </child>
 | 
			
		||||
</widget>
 | 
			
		||||
 | 
			
		||||
<widget class="GtkDialog" id="new_message_dialog">
 | 
			
		||||
  <property name="border_width">6</property>
 | 
			
		||||
  <property name="title" translatable="yes"></property>
 | 
			
		||||
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
 | 
			
		||||
  <property name="window_position">GTK_WIN_POS_NONE</property>
 | 
			
		||||
  <property name="modal">False</property>
 | 
			
		||||
  <property name="resizable">True</property>
 | 
			
		||||
  <property name="destroy_with_parent">False</property>
 | 
			
		||||
  <property name="decorated">True</property>
 | 
			
		||||
  <property name="skip_taskbar_hint">False</property>
 | 
			
		||||
  <property name="skip_pager_hint">False</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>
 | 
			
		||||
 | 
			
		||||
  <child internal-child="vbox">
 | 
			
		||||
    <widget class="GtkVBox" id="dialog-vbox8">
 | 
			
		||||
      <property name="visible">True</property>
 | 
			
		||||
      <property name="homogeneous">False</property>
 | 
			
		||||
      <property name="spacing">0</property>
 | 
			
		||||
 | 
			
		||||
      <child internal-child="action_area">
 | 
			
		||||
	<widget class="GtkHButtonBox" id="dialog-action_area7">
 | 
			
		||||
	  <property name="visible">True</property>
 | 
			
		||||
	  <property name="layout_style">GTK_BUTTONBOX_END</property>
 | 
			
		||||
 | 
			
		||||
	  <child>
 | 
			
		||||
	    <widget class="GtkButton" id="cancel_button">
 | 
			
		||||
	      <property name="visible">True</property>
 | 
			
		||||
	      <property name="can_default">True</property>
 | 
			
		||||
	      <property name="can_focus">True</property>
 | 
			
		||||
	      <property name="label">gtk-cancel</property>
 | 
			
		||||
	      <property name="use_stock">True</property>
 | 
			
		||||
	      <property name="relief">GTK_RELIEF_NORMAL</property>
 | 
			
		||||
	      <property name="focus_on_click">True</property>
 | 
			
		||||
	      <property name="response_id">-6</property>
 | 
			
		||||
	      <signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Sat, 05 Mar 2005 18:13:22 GMT"/>
 | 
			
		||||
	    </widget>
 | 
			
		||||
	  </child>
 | 
			
		||||
 | 
			
		||||
	  <child>
 | 
			
		||||
	    <widget class="GtkButton" id="chat_button">
 | 
			
		||||
	      <property name="visible">True</property>
 | 
			
		||||
	      <property name="can_default">True</property>
 | 
			
		||||
	      <property name="has_default">True</property>
 | 
			
		||||
	      <property name="can_focus">True</property>
 | 
			
		||||
	      <property name="relief">GTK_RELIEF_NORMAL</property>
 | 
			
		||||
	      <property name="focus_on_click">True</property>
 | 
			
		||||
	      <property name="response_id">0</property>
 | 
			
		||||
	      <signal name="clicked" handler="on_chat_button_clicked" last_modification_time="Wed, 02 Mar 2005 16:16:54 GMT"/>
 | 
			
		||||
 | 
			
		||||
	      <child>
 | 
			
		||||
		<widget class="GtkAlignment" id="alignment48">
 | 
			
		||||
		  <property name="visible">True</property>
 | 
			
		||||
		  <property name="xalign">0.5</property>
 | 
			
		||||
		  <property name="yalign">0.5</property>
 | 
			
		||||
		  <property name="xscale">0</property>
 | 
			
		||||
		  <property name="yscale">0</property>
 | 
			
		||||
		  <property name="top_padding">0</property>
 | 
			
		||||
		  <property name="bottom_padding">0</property>
 | 
			
		||||
		  <property name="left_padding">0</property>
 | 
			
		||||
		  <property name="right_padding">0</property>
 | 
			
		||||
 | 
			
		||||
		  <child>
 | 
			
		||||
		    <widget class="GtkHBox" id="hbox2931">
 | 
			
		||||
		      <property name="visible">True</property>
 | 
			
		||||
		      <property name="homogeneous">False</property>
 | 
			
		||||
		      <property name="spacing">2</property>
 | 
			
		||||
 | 
			
		||||
		      <child>
 | 
			
		||||
			<widget class="GtkImage" id="image436">
 | 
			
		||||
			  <property name="visible">True</property>
 | 
			
		||||
			  <property name="stock">gtk-ok</property>
 | 
			
		||||
			  <property name="icon_size">4</property>
 | 
			
		||||
			  <property name="xalign">0.5</property>
 | 
			
		||||
			  <property name="yalign">0.5</property>
 | 
			
		||||
			  <property name="xpad">0</property>
 | 
			
		||||
			  <property name="ypad">0</property>
 | 
			
		||||
			</widget>
 | 
			
		||||
			<packing>
 | 
			
		||||
			  <property name="padding">0</property>
 | 
			
		||||
			  <property name="expand">False</property>
 | 
			
		||||
			  <property name="fill">False</property>
 | 
			
		||||
			</packing>
 | 
			
		||||
		      </child>
 | 
			
		||||
 | 
			
		||||
		      <child>
 | 
			
		||||
			<widget class="GtkLabel" id="label211">
 | 
			
		||||
			  <property name="visible">True</property>
 | 
			
		||||
			  <property name="label" translatable="yes">_Chat</property>
 | 
			
		||||
			  <property name="use_underline">True</property>
 | 
			
		||||
			  <property name="use_markup">False</property>
 | 
			
		||||
			  <property name="justify">GTK_JUSTIFY_LEFT</property>
 | 
			
		||||
			  <property name="wrap">False</property>
 | 
			
		||||
			  <property name="selectable">False</property>
 | 
			
		||||
			  <property name="xalign">0.5</property>
 | 
			
		||||
			  <property name="yalign">0.5</property>
 | 
			
		||||
			  <property name="xpad">0</property>
 | 
			
		||||
			  <property name="ypad">0</property>
 | 
			
		||||
			</widget>
 | 
			
		||||
			<packing>
 | 
			
		||||
			  <property name="padding">0</property>
 | 
			
		||||
			  <property name="expand">False</property>
 | 
			
		||||
			  <property name="fill">False</property>
 | 
			
		||||
			</packing>
 | 
			
		||||
		      </child>
 | 
			
		||||
		    </widget>
 | 
			
		||||
		  </child>
 | 
			
		||||
		</widget>
 | 
			
		||||
	      </child>
 | 
			
		||||
	    </widget>
 | 
			
		||||
	  </child>
 | 
			
		||||
	</widget>
 | 
			
		||||
	<packing>
 | 
			
		||||
	  <property name="padding">0</property>
 | 
			
		||||
	  <property name="expand">False</property>
 | 
			
		||||
	  <property name="fill">True</property>
 | 
			
		||||
	  <property name="pack_type">GTK_PACK_END</property>
 | 
			
		||||
	</packing>
 | 
			
		||||
      </child>
 | 
			
		||||
 | 
			
		||||
      <child>
 | 
			
		||||
	<widget class="GtkVBox" id="vbox55">
 | 
			
		||||
	  <property name="border_width">5</property>
 | 
			
		||||
	  <property name="visible">True</property>
 | 
			
		||||
	  <property name="homogeneous">False</property>
 | 
			
		||||
	  <property name="spacing">5</property>
 | 
			
		||||
 | 
			
		||||
	  <child>
 | 
			
		||||
	    <widget class="GtkHBox" id="hbox2932">
 | 
			
		||||
	      <property name="visible">True</property>
 | 
			
		||||
	      <property name="homogeneous">False</property>
 | 
			
		||||
	      <property name="spacing">10</property>
 | 
			
		||||
 | 
			
		||||
	      <child>
 | 
			
		||||
		<widget class="GtkImage" id="image437">
 | 
			
		||||
		  <property name="visible">True</property>
 | 
			
		||||
		  <property name="stock">gtk-dialog-question</property>
 | 
			
		||||
		  <property name="icon_size">6</property>
 | 
			
		||||
		  <property name="xalign">0.5</property>
 | 
			
		||||
		  <property name="yalign">0.5</property>
 | 
			
		||||
		  <property name="xpad">0</property>
 | 
			
		||||
		  <property name="ypad">0</property>
 | 
			
		||||
		</widget>
 | 
			
		||||
		<packing>
 | 
			
		||||
		  <property name="padding">0</property>
 | 
			
		||||
		  <property name="expand">True</property>
 | 
			
		||||
		  <property name="fill">True</property>
 | 
			
		||||
		</packing>
 | 
			
		||||
	      </child>
 | 
			
		||||
 | 
			
		||||
	      <child>
 | 
			
		||||
		<widget class="GtkLabel" id="label212">
 | 
			
		||||
		  <property name="visible">True</property>
 | 
			
		||||
		  <property name="label" translatable="yes">Enter the user ID of the contact you would like to
 | 
			
		||||
send a chat message to:</property>
 | 
			
		||||
		  <property name="use_underline">False</property>
 | 
			
		||||
		  <property name="use_markup">False</property>
 | 
			
		||||
		  <property name="justify">GTK_JUSTIFY_LEFT</property>
 | 
			
		||||
		  <property name="wrap">False</property>
 | 
			
		||||
		  <property name="selectable">False</property>
 | 
			
		||||
		  <property name="xalign">0.5</property>
 | 
			
		||||
		  <property name="yalign">0.5</property>
 | 
			
		||||
		  <property name="xpad">0</property>
 | 
			
		||||
		  <property name="ypad">0</property>
 | 
			
		||||
		</widget>
 | 
			
		||||
		<packing>
 | 
			
		||||
		  <property name="padding">5</property>
 | 
			
		||||
		  <property name="expand">False</property>
 | 
			
		||||
		  <property name="fill">False</property>
 | 
			
		||||
		</packing>
 | 
			
		||||
	      </child>
 | 
			
		||||
	    </widget>
 | 
			
		||||
	    <packing>
 | 
			
		||||
	      <property name="padding">0</property>
 | 
			
		||||
	      <property name="expand">True</property>
 | 
			
		||||
	      <property name="fill">True</property>
 | 
			
		||||
	    </packing>
 | 
			
		||||
	  </child>
 | 
			
		||||
 | 
			
		||||
	  <child>
 | 
			
		||||
	    <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">True</property>
 | 
			
		||||
	    </widget>
 | 
			
		||||
	    <packing>
 | 
			
		||||
	      <property name="padding">0</property>
 | 
			
		||||
	      <property name="expand">False</property>
 | 
			
		||||
	      <property name="fill">False</property>
 | 
			
		||||
	    </packing>
 | 
			
		||||
	  </child>
 | 
			
		||||
	</widget>
 | 
			
		||||
	<packing>
 | 
			
		||||
	  <property name="padding">0</property>
 | 
			
		||||
	  <property name="expand">True</property>
 | 
			
		||||
	  <property name="fill">True</property>
 | 
			
		||||
	</packing>
 | 
			
		||||
      </child>
 | 
			
		||||
    </widget>
 | 
			
		||||
  </child>
 | 
			
		||||
</widget>
 | 
			
		||||
 | 
			
		||||
<widget class="GtkMenu" id="systray_context_menu">
 | 
			
		||||
 | 
			
		||||
  <child>
 | 
			
		||||
| 
						 | 
				
			
			@ -12139,6 +11929,7 @@ send a chat message to:</property>
 | 
			
		|||
</widget>
 | 
			
		||||
 | 
			
		||||
<widget class="GtkDialog" id="input_dialog">
 | 
			
		||||
  <property name="border_width">6</property>
 | 
			
		||||
  <property name="visible">True</property>
 | 
			
		||||
  <property name="title" translatable="yes"></property>
 | 
			
		||||
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue