==== Patch <gajim-message-mode> level 4
Source: c68c8ed0-6fce-42b2-a3b7-6be8b34235d4:/local:7664 [local]
Target: c4d4e39b-2f5f-9a77-1c94-36969bb79148:/trunk:8975 [mirrored]
        (svn://svn.gajim.org/gajim/trunk)
Log:
 r7653@damasonium:  ddanier | 2007-11-14 21:10:55 +0100
 
 r7654@damasonium:  ddanier | 2007-11-15 00:32:14 +0100
  * Implemented very simple message-mode like psi:
    - Configuration option for default-type of new messages when clicking on an roster item
    - SingleMessageWindow:
      - Added "Next" and "Quote" button
      - "Next"-button to read next message waiting
      - "Next"-button show how many messages are waiting (by subscribing to gajim.events)
      - "Reply"-button does not quote, "Quote"-button does
      - Focus on Text by default
      - "RE: " only added to subject if subject is not empty
      - "Reply"/"Quote" does not close received message window, the parent is closed when reply window is closed and only if there are no more messages waiting
 r7655@damasonium:  ddanier | 2007-11-15 00:33:26 +0100
  * TODO for message-mode
 r7658@damasonium:  ddanier | 2007-11-15 18:24:49 +0100
  * SingleMessageWindow:
    - Action-menu
    - Username is displayed
    - GPG-Support, but untested
  * typo in src/chat_control.py
 r7662@damasonium:  ddanier | 2007-11-15 20:33:24 +0100
  * Bugfix: new chat messages are accessible
  * SingleMessageWindow:
    - RosterIcons are displayed
    - GPG-Button works at least for outgoing messages :)
    - Activated encryption is saved to config, like in normal chat window
  * "send_outgoing_messages" renamed to "default_message_type" (see http://trac.gajim.org/ticket/1041#comment:9)

=== src/config.py
==================================================================
--- src/config.py	(revision 8975)
+++ src/config.py	(patch gajim-message-mode level 4)
@@ -71,6 +71,8 @@
 		self.notebook = self.xml.get_widget('preferences_notebook')
 		self.treat_incoming_messages_combobox =\
 			self.xml.get_widget('treat_incoming_messages_combobox')
+		self.default_message_type_combobox =\
+			self.xml.get_widget('default_message_type_combobox')
 		self.one_window_type_combobox =\
 			self.xml.get_widget('one_window_type_combobox')
 		self.iconset_combobox = self.xml.get_widget('iconset_combobox')
@@ -140,6 +142,14 @@
 		else:
 			self.treat_incoming_messages_combobox.set_active(0)
 
+		# Set default for send outgoing messages
+		choices = common.config.opt_default_message_type
+		type = gajim.config.get('default_message_type')
+		if type in choices:
+			self.default_message_type_combobox.set_active(choices.index(type))
+		else:
+			self.default_message_type_combobox.set_active(0)
+
 		# Set default for single window type
 		choices = common.config.opt_one_window_types
 		type = gajim.config.get('one_message_window')
@@ -574,6 +584,11 @@
 		config_type = common.config.opt_treat_incoming_messages[active]
 		gajim.config.set('treat_incoming_messages', config_type)
 
+	def on_default_message_type_combobox_changed(self, widget):
+		active = widget.get_active()
+		config_type = common.config.opt_default_message_type[active]
+		gajim.config.set('default_message_type', config_type)
+
 	def on_one_window_type_combo_changed(self, widget):
 		active = widget.get_active()
 		config_type = common.config.opt_one_window_types[active]
=== src/roster_window.py
==================================================================
--- src/roster_window.py	(revision 8975)
+++ src/roster_window.py	(patch gajim-message-mode level 4)
@@ -1969,14 +1969,16 @@
 			self.draw_account(account)
 
 	def on_send_single_message_menuitem_activate(self, widget, account,
-	contact = None):
+	contact=None, resource=None):
 		if contact is None:
 			dialogs.SingleMessageWindow(account, action = 'send')
 		elif type(contact) == type([]):
 			dialogs.SingleMessageWindow(account, contact, 'send')
 		else:
 			jid = contact.jid
-			if contact.jid == gajim.get_jid_from_account(account):
+			if resource:
+				jid += '/' + resource
+			elif contact.jid == gajim.get_jid_from_account(account):
 				jid += '/' + contact.resource
 			dialogs.SingleMessageWindow(account, jid, 'send')
 
@@ -4350,6 +4352,7 @@
 					else:
 						child_iter = model.iter_next(child_iter)
 			session = None
+			chat_messages_waiting = False
 			if first_ev:
 				if first_ev.type_ in ('chat', 'normal'):
 					session = first_ev.parameters[8]
@@ -4358,12 +4361,18 @@
 					fjid += '/' + resource
 				if self.open_event(account, fjid, first_ev):
 					return
+				elif first_ev.type_ == 'chat':
+					chat_messages_waiting = True
 			c = gajim.contacts.get_contact(account, jid, resource)
 			if not c or isinstance(c, list):
 				c = gajim.contacts.get_contact_with_highest_priority(account, jid)
 			if jid == gajim.get_jid_from_account(account):
 				resource = c.resource
-			self.on_open_chat_window(widget, c, account, resource = resource, session = session)
+			default_message_type = gajim.config.get('default_message_type')
+			if default_message_type == 'normal' and not chat_messages_waiting:
+				self.on_send_single_message_menuitem_activate(widget, account, c, resource = resource)
+			else:
+				self.on_open_chat_window(widget, c, account, resource = resource, session = session)
 
 	def on_roster_treeview_row_activated(self, widget, path, col = 0):
 		'''When an iter is double clicked: open the first event window'''
=== src/dialogs.py
==================================================================
--- src/dialogs.py	(revision 8975)
+++ src/dialogs.py	(patch gajim-message-mode level 4)
@@ -1832,7 +1832,7 @@
 	# Keep a reference on windows so garbage collector don't restroy them
 	instances = []
 	def __init__(self, account, to='', action='', from_whom='', subject='',
-	message='', resource='', session=None, form_node=None):
+	message='', resource='', session=None, form_node=None, encrypted=False):
 		self.instances.append(self)
 		self.account = account
 		self.action = action
@@ -1844,13 +1844,20 @@
 		self.resource = resource
 		self.session = session
 
+		self.encrypted = encrypted
+		self.next_count = 0
+
 		self.xml = gtkgui_helpers.get_glade('single_message_window.glade')
 		self.window = self.xml.get_widget('single_message_window')
 		self.count_chars_label = self.xml.get_widget('count_chars_label')
 		self.from_label = self.xml.get_widget('from_label')
 		self.from_entry = self.xml.get_widget('from_entry')
+		self.from_status_image = self.xml.get_widget('from_status_image')
+		self.from_name = self.xml.get_widget('from_name')
 		self.to_label = self.xml.get_widget('to_label')
 		self.to_entry = self.xml.get_widget('to_entry')
+		self.to_status_image = self.xml.get_widget('to_status_image')
+		self.to_name = self.xml.get_widget('to_name')
 		self.subject_entry = self.xml.get_widget('subject_entry')
 		self.message_scrolledwindow = self.xml.get_widget(
 			'message_scrolledwindow')
@@ -1876,8 +1883,13 @@
 				parent_box.child_get_property(self.xml.get_widget('conversation_scrolledwindow'), 'position'))
 			self.action = 'form'
 
+		self.gpg_togglebutton = self.xml.get_widget('gpg_togglebutton')
+		self.gpg_togglebutton_separator = self.xml.get_widget('gpg_togglebutton_separator')
 		self.send_button = self.xml.get_widget('send_button')
+		self.quote_button = self.xml.get_widget('quote_button')
 		self.reply_button = self.xml.get_widget('reply_button')
+		self.next_button = self.xml.get_widget('next_button')
+		self.next_count_label = self.xml.get_widget('next_count_label')
 		self.send_and_close_button = self.xml.get_widget('send_and_close_button')
 		self.cancel_button = self.xml.get_widget('cancel_button')
 		self.close_button = self.xml.get_widget('close_button')
@@ -1902,6 +1914,11 @@
 
 		self.prepare_widgets_for(self.action)
 
+		gajim.events.event_added_subscribe(self.on_event_added)
+		gajim.events.event_removed_subscribe(self.on_event_removed)
+		if self.action == 'receive':
+			self.update_next_count()
+
 		# set_text(None) raises TypeError exception
 		if self.subject is None:
 			self.subject = ''
@@ -1924,9 +1941,11 @@
 
 		if gajim.config.get('saveposition'):
 			# get window position and size from config
-			gtkgui_helpers.move_window(self.window,
-				gajim.config.get('single-msg-x-position'),
-				gajim.config.get('single-msg-y-position'))
+			# Makes absolutely no sense when dealing with multiple windows
+			# (for example when hitting "reply" the orig window stays)
+			#gtkgui_helpers.move_window(self.window,
+			#	gajim.config.get('single-msg-x-position'),
+			#	gajim.config.get('single-msg-y-position'))
 			gtkgui_helpers.resize_window(self.window,
 				gajim.config.get('single-msg-width'),
 				gajim.config.get('single-msg-height'))
@@ -1968,11 +1987,25 @@
 			self.send_and_close_button.show()
 			self.to_label.show()
 			self.to_entry.show()
+			self.to_status_image.show()
+			self.to_name.show()
 			self.reply_button.hide()
+			self.quote_button.hide()
+			self.next_button.hide()
 			self.from_label.hide()
 			self.from_entry.hide()
+			self.from_status_image.hide()
+			self.from_name.hide()
 			self.conversation_scrolledwindow.hide()
 			self.message_scrolledwindow.show()
+			self.gpg_togglebutton.show()
+			if type(self.to) == type([]):
+				self.gpg_togglebutton.set_property('sensitive', False)
+				self.gpg_togglebutton.set_active(False)
+			else:
+				self.gpg_togglebutton.set_property('sensitive', True)
+				self.gpg_togglebutton.set_active(self.encrypted)
+			self.gpg_togglebutton_separator.show()
 
 			if self.message: # we come from a reply?
 				self.message_textview.grab_focus()
@@ -1983,19 +2016,34 @@
 			else: # we write a new message (not from reply)
 				self.close_button.hide()
 				if self.to: # do we already have jid?
-					self.subject_entry.grab_focus()
+					# Most of the time users skip the subject
+					#self.subject_entry.grab_focus()
+					self.message_textview.grab_focus()
+				else:
+					self.to_entry.grab_focus()
+			self.update_to_information()
 
 		elif action == 'receive': # prepare UI for Receiving
 			title = _('Received %s') % title
 			self.reply_button.show()
+			self.quote_button.show()
+			self.next_button.show()
 			self.from_label.show()
 			self.from_entry.show()
+			self.from_status_image.show()
+			self.from_name.show()
 			self.send_button.hide()
 			self.send_and_close_button.hide()
 			self.to_label.hide()
 			self.to_entry.hide()
+			self.to_status_image.hide()
+			self.to_name.hide()
 			self.conversation_scrolledwindow.show()
 			self.message_scrolledwindow.hide()
+			self.gpg_togglebutton.show()
+			self.gpg_togglebutton.set_property('sensitive', False)
+			self.gpg_togglebutton.set_active(self.encrypted)
+			self.gpg_togglebutton_separator.show()
 
 			if self.message:
 				self.conversation_textview.print_real_text(self.message)
@@ -2008,20 +2056,302 @@
 			self.reply_button.grab_focus()
 			self.cancel_button.hide()
 			self.close_button.show()
+			self.update_from_information()
+			
 		elif action == 'form': # prepare UI for Receiving
 			title = _('Form %s') % title 
 			self.send_button.show() 
 			self.send_and_close_button.show() 
 			self.to_label.show() 
 			self.to_entry.show() 
+			self.to_status_image.show()
+			self.to_name.show()
 			self.reply_button.hide() 
 			self.from_label.hide() 
 			self.from_entry.hide() 
+			self.from_status_image.hide()
+			self.from_name.hide()
 			self.conversation_scrolledwindow.hide() 
 			self.message_scrolledwindow.hide() 
+			self.gpg_togglebutton.hide()
+			self.gpg_togglebutton_separator.hide()
+			self.update_to_information()
 
 		self.window.set_title(title)
 
+	def on_to_entry_changed(self, widget):
+		self.update_to_information()
+
+	def update_to_information(self):
+		jid, resource, contact = self.get_jid_resource_and_contact()
+		if contact:
+			self.to_status_image.show()
+			roster = gajim.interface.roster
+			show = contact.show
+			img = roster.get_appropriate_state_images(jid, icon_name=show)
+			status_image = img[show]
+			if status_image.get_storage_type() == gtk.IMAGE_ANIMATION:
+				self.to_status_image.set_from_animation(status_image.get_animation())
+			else:
+				pix = status_image.get_pixbuf()
+				if pix is not None:
+					self.to_status_image.set_from_pixbuf(pix)
+			self.to_name.show()
+			self.to_name.set_text(contact.get_shown_name())
+		else:
+			self.to_status_image.hide()
+			self.to_name.hide()
+
+	def update_from_information(self):
+		jid = self.from_whom
+		contact = None
+		if '@' in jid:
+			if '/' in jid:
+				jid, resource = jid.split('/', 1)
+			else:
+				resource = self.resource
+			contact = gajim.contacts.get_contact(self.account, jid, resource)
+		if contact:
+			self.from_status_image.show()
+			roster = gajim.interface.roster
+			show = contact.show
+			img = roster.get_appropriate_state_images(jid, icon_name=show)
+			status_image = img[show]
+			if status_image.get_storage_type() == gtk.IMAGE_ANIMATION:
+				self.from_status_image.set_from_animation(status_image.get_animation())
+			else:
+				pix = status_image.get_pixbuf()
+				if pix is not None:
+					self.from_status_image.set_from_pixbuf(pix)
+			self.from_name.show()
+			self.from_name.set_text(contact.get_shown_name())
+		else:
+			self.from_status_image.hide()
+			self.from_name.hide()
+
+	def on_actions_button_clicked(self, widget):
+		'''popup action menu'''
+		menu = self.prepare_context_menu()
+		menu.show_all()
+		gtkgui_helpers.popup_emoticons_under_button(menu, widget, self.window.window)
+
+	def get_jid_and_resource(self):
+		if self.action == 'receive':
+			jid = self.from_whom
+		elif self.action == 'send':
+			jid = self.to_entry.get_text()
+		else:
+			jid = self.to
+		if '/' in jid:
+			jid, resource = jid.split('/', 1)
+		else:
+			resource = self.resource
+		return jid, resource
+
+	def get_contact(self):
+		jid, resource = self.get_jid_and_resource()
+		if '@' in jid:
+			return gajim.contacts.get_contact(self.account, jid, self.resource)
+		else:
+			return None
+
+	def get_jid_resource_and_contact(self):
+		jid, resource = self.get_jid_and_resource()
+		if '@' in jid:
+			return jid, resource, gajim.contacts.get_contact(self.account, jid, self.resource)
+		else:
+			return jid, resource, None
+
+	def prepare_context_menu(self):
+		'''sets compact view menuitem active state
+		sets active and sensitivity state for toggle_gpg_menuitem
+		sets sensitivity for history_menuitem (False for transports)
+		and file_transfer_menuitem
+		and hide()/show() for add_to_roster_menuitem
+		'''
+		xml = gtkgui_helpers.get_glade('chat_control_popup_menu.glade')
+		menu = xml.get_widget('chat_control_popup_menu')
+
+		history_menuitem = xml.get_widget('history_menuitem')
+		toggle_gpg_menuitem = xml.get_widget('toggle_gpg_menuitem')
+		toggle_e2e_menuitem = xml.get_widget('toggle_e2e_menuitem')
+		add_to_roster_menuitem = xml.get_widget('add_to_roster_menuitem')
+		send_file_menuitem = xml.get_widget('send_file_menuitem')
+		information_menuitem = xml.get_widget('information_menuitem')
+		convert_to_gc_menuitem = xml.get_widget('convert_to_groupchat')
+		muc_icon = gajim.interface.roster.load_icon('muc_active')
+		if muc_icon:
+			convert_to_gc_menuitem.set_image(muc_icon) 
+
+		jid, resource, contact = self.get_jid_resource_and_contact()
+
+		# check if gpg capabitlies or else make gpg toggle insensitive
+		gpg_btn = self.gpg_togglebutton
+		isactive = gpg_btn.get_active()
+		is_sensitive = gpg_btn.get_property('sensitive')
+		toggle_gpg_menuitem.set_active(isactive)
+		toggle_gpg_menuitem.set_property('sensitive', is_sensitive)
+
+		# TODO: support this, if possible
+		toggle_e2e_menuitem.set_sensitive(False)
+
+		# If we don't have resource, we can't do file transfer
+		# in transports, contact holds our info we need to disable it too
+		if jid and resource:
+			send_file_menuitem.set_sensitive(True)
+		elif contact and contact.resource and contact.jid.find('@') != -1:
+			send_file_menuitem.set_sensitive(True)
+		else:
+			send_file_menuitem.set_sensitive(False)
+
+		# check if it's possible to convert to groupchat
+		if gajim.get_transport_name_from_jid(jid) or \
+		gajim.connections[self.account].is_zeroconf:
+			convert_to_gc_menuitem.set_sensitive(False)
+
+		# add_to_roster_menuitem
+		if contact and _('Not in Roster') in contact.groups:
+			add_to_roster_menuitem.show()
+			add_to_roster_menuitem.set_no_show_all(False)
+		else:
+			add_to_roster_menuitem.hide()
+			add_to_roster_menuitem.set_no_show_all(True)
+
+		# connect signals
+		history_menuitem.connect('activate', 
+			self.on_history_menuitem_activate)
+		send_file_menuitem.connect('activate', 
+			self.on_send_file_menuitem_activate)
+		add_to_roster_menuitem.connect('activate', 
+			self.on_add_to_roster_menuitem_activate)
+		toggle_gpg_menuitem.connect('activate', 
+			self.on_toggle_gpg_menuitem_activate)
+		#toggle_e2e_menuitem.connect('activate', 
+		#	self.on_toggle_e2e_menuitem_activate)
+		information_menuitem.connect('activate', 
+			self.on_contact_information_menuitem_activate)
+		convert_to_gc_menuitem.connect('activate',
+			self.on_convert_to_gc_menuitem_activate)
+		menu.connect('selection-done', self.destroy_menu)
+		return menu
+
+	def destroy_menu(self, menu):
+		# destroy menu
+		menu.destroy()
+
+	def on_history_menuitem_activate(self, widget):
+		'''When history menuitem is pressed: call history window'''
+		import history_window
+		jid, resource = self.get_jid_and_resource()
+
+		if gajim.interface.instances.has_key('logs'):
+			gajim.interface.instances['logs'].window.present()
+			gajim.interface.instances['logs'].open_history(jid, self.account)
+		else:
+			gajim.interface.instances['logs'] = \
+				history_window.HistoryWindow(jid, self.account)
+
+	def on_send_file_menuitem_activate(self, widget):
+		contact = self.get_contact()
+		if contact:
+			gajim.interface.instances['file_transfers'].show_file_send_request( 
+				self.account, contact)
+
+	def on_add_to_roster_menuitem_activate(self, widget):
+		jid, resource = self.get_jid_and_resource()
+		AddNewContactWindow(self.account, jid)
+
+	def on_toggle_gpg_menuitem_activate(self, widget):
+		if self.gpg_togglebutton.get_active():
+			self.gpg_togglebutton.set_active(False)
+		else:
+			self.gpg_togglebutton.set_active(True)
+		self.gpg_togglebutton.toggled()
+
+	def on_gpg_togglebutton_toggled(self, widget):
+		self.encrypted = self.gpg_togglebutton.get_active()
+		contact = self.get_contact()
+		if contact: # only save if we have a valid contact
+			gajim.config.set_per('contacts', contact.jid, 'gpg_enabled',
+				self.encrypted)
+
+	def on_contact_information_menuitem_activate(self, widget):
+		contact = self.get_contact()
+		if contact:
+			gajim.interface.roster.on_info(widget, contact, self.account)
+
+	def on_convert_to_gc_menuitem_activate(self, widget):
+		'''user want to invite some friends to chat'''
+		jid, resource = self.get_jid_and_resource()
+		TransformChatToMUC(self.account, [jid])
+
+	def on_single_message_window_destroy(self, widget):
+		gajim.events.event_added_unsubscribe(self.on_event_added)
+		gajim.events.event_removed_unsubscribe(self.on_event_removed)
+
+	def update_next_count(self):
+		# gajim.get_jid_without_resource(self.from_jid)?
+		self.next_count = len(gajim.events.get_events(self.account, \
+			self.from_whom, types=('normal',)))
+		self.next_count_label.set_label("(%d)" % self.next_count)
+		if self.next_count == 0:
+			self.next_button.set_property('sensitive', False)
+		else:
+			self.next_button.set_property('sensitive', True)
+
+	def on_event_added(self, event):
+		if event.type_ == 'normal':
+			self.update_next_count()
+
+	def on_event_removed(self, event_list):
+		for event in event_list:
+			if event.type_ == 'normal':
+				self.update_next_count()
+				return
+
+	def on_next_button_clicked(self, widget):
+		if self.next_count == 0:
+			return
+		next_event = gajim.events.get_first_event(self.account, self.from_whom, 'normal')
+		#if not next_event:
+		#	next_event = gajim.events.get_first_event(self.account, self.from_whom, 'chat')
+		if not next_event:
+			return
+		# parameters:
+		# message, subject, kind, time, encrypted, resource,
+		# msg_id
+		self.action = 'receive'
+		self.subject = next_event.parameters[1]
+		self.message = next_event.parameters[0]
+		self.resource = next_event.parameters[5]
+		self.session = next_event.parameters[8]
+		form_node = next_event.parameters[9]
+		
+		parent_box = self.xml.get_widget('conversation_scrolledwindow').get_parent()
+		if form_node:
+			dataform = dataforms.ExtendForm(node = form_node)
+			self.form_widget = dataforms_widget.DataFormWidget(dataform)
+			self.form_widget.show_all()
+			parent_box.add(self.form_widget)
+			parent_box.child_set_property(self.form_widget, 'position',
+				parent_box.child_get_property(self.xml.get_widget('conversation_scrolledwindow'), 'position'))
+			self.action = 'form'
+		elif self.form_widget:
+			self.form_widget.hide()
+			parent_box.remove(self.form_widget)
+			self.form_widget = None
+
+		self.conversation_textview.clear()
+		self.prepare_widgets_for(self.action)
+
+		# set_text(None) raises TypeError exception
+		if self.subject is None:
+			self.subject = ''
+		self.subject_entry.set_text(self.subject)
+
+		gajim.interface.remove_first_event(self.account, self.from_whom, next_event.type_)
+		self.update_next_count()
+
 	def on_cancel_button_clicked(self, widget):
 		self.save_pos()
 		self.window.destroy()
@@ -2066,9 +2396,12 @@
 				form_node = self.form_widget.data_form
 			else:
 				form_node = None
-			# FIXME: allow GPG message some day
+			keyID = None
+			if self.encrypted:
+				contact = self.get_contact()
+				keyID = contact.keyID
 			gajim.connections[self.account].send_message(to_whom_jid, message,
-				keyID=None, type='normal', subject=subject, session=session,
+				keyID=keyID, type='normal', subject=subject, session=session,
 				form_node=form_node)
 
 		self.subject_entry.set_text('') # we sent ok, clear the subject
@@ -2076,18 +2409,34 @@
 
 	def on_send_button_clicked(self, widget):
 		self.send_single_message()
+	
+	def on_child_window_destroy(self, widget):
+		# TODO: Only close window if child send a message
+		if self.next_count == 0:
+			self.save_pos()
+			self.window.destroy()
 
-	def on_reply_button_clicked(self, widget):
+	def on_reply_button_clicked(self, widget, quote=False):
 		# we create a new blank window to send and we preset RE: and to jid
-		self.subject = _('RE: %s') % self.subject
-		self.message = _('%s wrote:\n') % self.from_whom + self.message
-		# add > at the begining of each line
-		self.message = self.message.replace('\n', '\n> ') + '\n\n'
-		self.window.destroy()
-		SingleMessageWindow(self.account, to = self.from_whom,
-			action = 'send',	from_whom = self.from_whom, subject = self.subject,
-			message = self.message, session = self.session)
+		if self.subject:
+			subject = _('RE: %s') % self.subject
+		else:
+			subject = ''
+		if quote:
+			message = _('%s wrote:\n') % self.from_whom + self.message
+			# add > at the begining of each line
+			message = message.replace('\n', '\n> ') + '\n\n'
+		else:
+			message = ''
+		smw = SingleMessageWindow(self.account, to = self.from_whom,
+			action = 'send',	from_whom = self.from_whom, subject = subject,
+			message = message, session = self.session)
+		smw.window.connect('destroy',
+			self.on_child_window_destroy)
 
+	def on_quote_button_clicked(self, widget):
+		self.on_reply_button_clicked(widget, quote=True)
+
 	def on_send_and_close_button_clicked(self, widget):
 		self.send_single_message()
 		self.save_pos()
=== src/common/config.py
==================================================================
--- src/common/config.py	(revision 8975)
+++ src/common/config.py	(patch gajim-message-mode level 4)
@@ -47,6 +47,7 @@
 opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
 opt_one_window_types = ['never', 'always', 'peracct', 'pertype']
 opt_treat_incoming_messages = ['', 'chat', 'normal']
+opt_default_message_type = ['chat', 'normal']
 
 class Config:
 
@@ -245,6 +246,7 @@
 		'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use Gnome Keyring (if available) to store account passwords.')],
 		'show_contacts_number': [opt_bool, True, _('If True, Gajim will show number of online and total contacts in account and group rows.')],
 		'treat_incoming_messages': [ opt_str, '', _('Can be empty, \'chat\' or \'normal\'. If not empty, treat all incoming messages as if they were of this type')],
+		'default_message_type': [ opt_str, 'chat', _('Can be \'chat\' or \'normal\'. Default type of outgoing messages.')],
 		'scroll_roster_to_last_message': [opt_bool, True, _('If True, Gajim will scroll and select the contact who sent you the last message, if chat window is not already opened.')],
 		'use_latex': [opt_bool, False, _('If True, Gajim will convert string between $$ and $$ to an image using dvips and convert before insterting it in chat window.')],
 		'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
=== src/chat_control.py
==================================================================
--- src/chat_control.py	(revision 8975)
+++ src/chat_control.py	(patch gajim-message-mode level 4)
@@ -1623,7 +1623,7 @@
 	def prepare_context_menu(self):
 		'''sets compact view menuitem active state
 		sets active and sensitivity state for toggle_gpg_menuitem
-		sets sensitivity for history_menuitem (False for tranasports)
+		sets sensitivity for history_menuitem (False for transports)
 		and file_transfer_menuitem
 		and hide()/show() for add_to_roster_menuitem
 		'''
=== data/glade/single_message_window.glade
==================================================================
--- data/glade/single_message_window.glade	(revision 8975)
+++ data/glade/single_message_window.glade	(patch gajim-message-mode level 4)
@@ -7,6 +7,7 @@
     <property name="default_width">550</property>
     <property name="default_height">280</property>
     <signal name="key_press_event" handler="on_single_message_window_key_press_event"/>
+    <signal name="destroy" handler="on_single_message_window_destroy"/>
     <signal name="delete_event" handler="on_single_message_window_delete_event"/>
     <signal name="destroy" handler="on_single_message_window_destroy"/>
     <child>
@@ -17,10 +18,66 @@
           <widget class="GtkTable" id="headers_table">
             <property name="visible">True</property>
             <property name="n_rows">3</property>
-            <property name="n_columns">3</property>
+            <property name="n_columns">5</property>
             <property name="column_spacing">12</property>
             <property name="row_spacing">6</property>
             <child>
+              <widget class="GtkLabel" id="from_name">
+                <property name="visible">True</property>
+                <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="no_show_all">True</property>
+                <property name="label" translatable="yes">from_name</property>
+              </widget>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="right_attach">5</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkImage" id="from_status_image">
+                <property name="visible">True</property>
+                <property name="events"></property>
+                <property name="no_show_all">True</property>
+                <property name="stock">gtk-missing-image</property>
+              </widget>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkImage" id="to_status_image">
+                <property name="visible">True</property>
+                <property name="events"></property>
+                <property name="no_show_all">True</property>
+                <property name="stock">gtk-missing-image</property>
+              </widget>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="to_name">
+                <property name="visible">True</property>
+                <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="no_show_all">True</property>
+                <property name="label" translatable="yes">to_name</property>
+              </widget>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="right_attach">5</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
               <widget class="GtkLabel" id="to_label">
                 <property name="visible">True</property>
                 <property name="no_show_all">True</property>
@@ -51,11 +108,11 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="no_show_all">True</property>
-                <property name="invisible_char">*</property>
+                <signal name="changed" handler="on_to_entry_changed"/>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="right_attach">3</property>
+                <property name="right_attach">2</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
                 <property name="y_options"></property>
@@ -67,8 +124,7 @@
                 <property name="label" translatable="yes">0</property>
               </widget>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
+                <property name="left_attach">4</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_FILL</property>
@@ -79,11 +135,10 @@
               <widget class="GtkEntry" id="subject_entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="invisible_char">*</property>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="right_attach">4</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
                 <property name="y_options"></property>
@@ -94,11 +149,10 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="no_show_all">True</property>
-                <property name="invisible_char">*</property>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="right_attach">3</property>
+                <property name="right_attach">2</property>
                 <property name="y_options"></property>
               </packing>
             </child>
@@ -156,182 +210,404 @@
           </packing>
         </child>
         <child>
-          <widget class="GtkHButtonBox" id="hbuttonbox26">
+          <widget class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
-            <property name="spacing">12</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="spacing">1</property>
             <child>
-              <widget class="GtkButton" id="close_button">
+              <widget class="GtkToggleButton" id="gpg_togglebutton">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
                 <property name="no_show_all">True</property>
-                <property name="label">gtk-close</property>
-                <property name="use_stock">True</property>
+                <property name="relief">GTK_RELIEF_NONE</property>
+                <property name="focus_on_click">False</property>
                 <property name="response_id">0</property>
-                <signal name="clicked" handler="on_close_button_clicked"/>
+                <signal name="toggled" handler="on_gpg_togglebutton_toggled"/>
+                <child>
+                  <widget class="GtkImage" id="image2">
+                    <property name="visible">True</property>
+                    <property name="stock">gtk-dialog-authentication</property>
+                  </widget>
+                </child>
               </widget>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="cancel_button">
+              <widget class="GtkVSeparator" id="gpg_togglebutton_separator">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="no_show_all">True</property>
-                <property name="label">gtk-cancel</property>
-                <property name="use_stock">True</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="on_cancel_button_clicked"/>
               </widget>
               <packing>
+                <property name="expand">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="send_button">
+              <widget class="GtkHButtonBox" id="hbuttonbox26">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="no_show_all">True</property>
-                <property name="tooltip" translatable="yes">Send message</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="on_send_button_clicked"/>
+                <property name="spacing">5</property>
+                <property name="layout_style">GTK_BUTTONBOX_END</property>
                 <child>
-                  <widget class="GtkAlignment" id="alignment98">
+                  <widget class="GtkButton" id="close_button">
                     <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="label">gtk-close</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_close_button_clicked"/>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="cancel_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="label">gtk-cancel</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_cancel_button_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="actions_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_actions_button_clicked"/>
                     <child>
-                      <widget class="GtkHBox" id="hbox3003">
+                      <widget class="GtkAlignment" id="alignment2">
                         <property name="visible">True</property>
-                        <property name="spacing">2</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <widget class="GtkImage" id="image1326">
+                          <widget class="GtkHBox" id="hbox2">
                             <property name="visible">True</property>
-                            <property name="stock">gtk-jump-to</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <widget class="GtkImage" id="image2">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-execute</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label2">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes" comments="Make sure the character after &quot;_&quot; is not M/m (conflicts with Alt+M that is supposed to show the Emoticon Selector)">_Actions</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkArrow" id="arrow2">
+                                <property name="visible">True</property>
+                                <property name="arrow_type">GTK_ARROW_DOWN</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
                         </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="send_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="tooltip" translatable="yes">Send message</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_send_button_clicked"/>
+                    <child>
+                      <widget class="GtkAlignment" id="alignment98">
+                        <property name="visible">True</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <widget class="GtkLabel" id="label370">
+                          <widget class="GtkHBox" id="hbox3003">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">Sen_d</property>
-                            <property name="use_underline">True</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <widget class="GtkImage" id="image1326">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-jump-to</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label370">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Sen_d</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                       </widget>
                     </child>
                   </widget>
+                  <packing>
+                    <property name="position">3</property>
+                  </packing>
                 </child>
-              </widget>
-              <packing>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkButton" id="reply_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="no_show_all">True</property>
-                <property name="tooltip" translatable="yes">Reply to this message</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="on_reply_button_clicked"/>
                 <child>
-                  <widget class="GtkAlignment" id="alignment82">
+                  <widget class="GtkButton" id="send_and_close_button">
                     <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="tooltip" translatable="yes">Send message and close window</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_send_and_close_button_clicked"/>
                     <child>
-                      <widget class="GtkHBox" id="hbox2982">
+                      <widget class="GtkAlignment" id="alignment83">
                         <property name="visible">True</property>
-                        <property name="spacing">2</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <widget class="GtkImage" id="image862">
+                          <widget class="GtkHBox" id="hbox2983">
                             <property name="visible">True</property>
-                            <property name="stock">gtk-ok</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <widget class="GtkImage" id="image878">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-ok</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label347">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">_Send &amp; Close</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
                         </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="quote_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="tooltip" translatable="yes">Reply to this message</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_quote_button_clicked"/>
+                    <child>
+                      <widget class="GtkAlignment" id="alignment3">
+                        <property name="visible">True</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <widget class="GtkLabel" id="label346">
+                          <widget class="GtkHBox" id="hbox3">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">_Reply</property>
-                            <property name="use_underline">True</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <widget class="GtkImage" id="image3">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-ok</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label3">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">_Quote</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                       </widget>
                     </child>
                   </widget>
+                  <packing>
+                    <property name="position">5</property>
+                  </packing>
                 </child>
-              </widget>
-              <packing>
-                <property name="position">3</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkButton" id="send_and_close_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="no_show_all">True</property>
-                <property name="tooltip" translatable="yes">Send message and close window</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="on_send_and_close_button_clicked"/>
                 <child>
-                  <widget class="GtkAlignment" id="alignment83">
+                  <widget class="GtkButton" id="reply_button">
                     <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="tooltip" translatable="yes">Reply to this message</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_reply_button_clicked"/>
                     <child>
-                      <widget class="GtkHBox" id="hbox2983">
+                      <widget class="GtkAlignment" id="alignment82">
                         <property name="visible">True</property>
-                        <property name="spacing">2</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <widget class="GtkImage" id="image878">
+                          <widget class="GtkHBox" id="hbox2982">
                             <property name="visible">True</property>
-                            <property name="stock">gtk-ok</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <widget class="GtkImage" id="image862">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-ok</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label346">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">_Reply</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                          </packing>
                         </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="position">6</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="next_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="no_show_all">True</property>
+                    <property name="tooltip" translatable="yes">View next message</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_next_button_clicked"/>
+                    <child>
+                      <widget class="GtkAlignment" id="alignment5">
+                        <property name="visible">True</property>
+                        <property name="xscale">0</property>
+                        <property name="yscale">0</property>
                         <child>
-                          <widget class="GtkLabel" id="label347">
+                          <widget class="GtkHBox" id="hbox5">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">_Send &amp; Close</property>
-                            <property name="use_underline">True</property>
+                            <property name="spacing">2</property>
+                            <child>
+                              <widget class="GtkImage" id="image5">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-media-next</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkHBox" id="hbox1">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="spacing">4</property>
+                                <child>
+                                  <widget class="GtkLabel" id="label5">
+                                    <property name="visible">True</property>
+                                    <property name="label" translatable="yes">_Next</property>
+                                    <property name="use_underline">True</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="next_count_label">
+                                    <property name="visible">True</property>
+                                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="label" translatable="yes">(0)</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                       </widget>
                     </child>
                   </widget>
+                  <packing>
+                    <property name="position">7</property>
+                  </packing>
                 </child>
               </widget>
               <packing>
-                <property name="position">4</property>
+                <property name="expand">False</property>
+                <property name="padding">6</property>
+                <property name="pack_type">GTK_PACK_END</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </widget>
=== data/glade/preferences_window.glade
==================================================================
--- data/glade/preferences_window.glade	(revision 8975)
+++ data/glade/preferences_window.glade	(patch gajim-message-mode level 4)
@@ -26,7 +26,6 @@
                   <widget class="GtkFrame" id="frame1">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment1">
@@ -111,7 +110,6 @@
                   <widget class="GtkFrame" id="frame2">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment2">
@@ -122,7 +120,7 @@
                           <widget class="GtkTable" id="table1">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="n_rows">6</property>
+                            <property name="n_rows">7</property>
                             <property name="n_columns">2</property>
                             <property name="column_spacing">6</property>
                             <property name="row_spacing">6</property>
@@ -155,6 +153,35 @@
                               </packing>
                             </child>
                             <child>
+                              <widget class="GtkComboBox" id="treat_incoming_messages_combobox">
+                                <property name="visible">True</property>
+                                <property name="items" translatable="yes">Determined by sender
+Chat message
+Single message</property>
+                                <signal name="changed" handler="on_treat_incoming_messages_combobox_changed"/>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label387">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">1</property>
+                                <property name="label" translatable="yes">Treat all incoming messages as:</property>
+                              </widget>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
                               <widget class="GtkCheckButton" id="speller_checkbutton">
                                 <property name="can_focus">True</property>
                                 <property name="label" translatable="yes">_Highlight misspelled words</property>
@@ -165,8 +192,8 @@
                               </widget>
                               <packing>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">5</property>
-                                <property name="bottom_attach">6</property>
+                                <property name="top_attach">6</property>
+                                <property name="bottom_attach">7</property>
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
@@ -183,8 +210,8 @@
                               </widget>
                               <packing>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">4</property>
-                                <property name="bottom_attach">5</property>
+                                <property name="top_attach">5</property>
+                                <property name="bottom_attach">6</property>
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
@@ -200,6 +227,21 @@
                               </widget>
                               <packing>
                                 <property name="right_attach">2</property>
+                                <property name="top_attach">4</property>
+                                <property name="bottom_attach">5</property>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label379">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">1</property>
+                                <property name="label" translatable="yes">Use only one message _window:</property>
+                                <property name="use_underline">True</property>
+                                <property name="mnemonic_widget">one_window_type_combobox</property>
+                              </widget>
+                              <packing>
                                 <property name="top_attach">3</property>
                                 <property name="bottom_attach">4</property>
                                 <property name="x_options">GTK_FILL</property>
@@ -217,35 +259,17 @@
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkComboBox" id="treat_incoming_messages_combobox">
+                              <widget class="GtkLabel" id="label14">
                                 <property name="visible">True</property>
-                                <property name="items" translatable="yes">Determined by sender
-Chat message
-Single message</property>
-                                <signal name="changed" handler="on_treat_incoming_messages_combobox_changed"/>
-                              </widget>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkLabel" id="label379">
-                                <property name="visible">True</property>
                                 <property name="xalign">0</property>
                                 <property name="xpad">1</property>
-                                <property name="label" translatable="yes">Use only one message _window:</property>
-                                <property name="use_underline">True</property>
-                                <property name="mnemonic_widget">one_window_type_combobox</property>
+                                <property name="label" translatable="yes">Send outgoing messages as:</property>
                               </widget>
                               <packing>
                                 <property name="top_attach">2</property>
@@ -254,15 +278,17 @@
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="label387">
+                              <widget class="GtkComboBox" id="default_message_type_combobox">
                                 <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="xpad">1</property>
-                                <property name="label" translatable="yes">Treat all incoming messages as:</property>
+                                <property name="items" translatable="yes">Chat message
+Single message</property>
+                                <signal name="changed" handler="on_default_message_type_combobox_changed"/>
                               </widget>
                               <packing>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
                               </packing>
                             </child>
@@ -291,7 +317,6 @@
                   <widget class="GtkFrame" id="frame3">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment3">
@@ -438,9 +463,6 @@
                   </packing>
                 </child>
               </widget>
-              <packing>
-                <property name="tab_expand">False</property>
-              </packing>
             </child>
             <child>
               <widget class="GtkLabel" id="label74">
@@ -449,7 +471,6 @@
               </widget>
               <packing>
                 <property name="type">tab</property>
-                <property name="tab_expand">False</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
@@ -462,7 +483,6 @@
                   <widget class="GtkFrame" id="frame4">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment4">
@@ -584,7 +604,6 @@
                 <child>
                   <widget class="GtkFrame" id="frame24">
                     <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment53">
@@ -880,7 +899,6 @@
               </widget>
               <packing>
                 <property name="position">1</property>
-                <property name="tab_expand">False</property>
               </packing>
             </child>
             <child>
@@ -891,7 +909,6 @@
               <packing>
                 <property name="type">tab</property>
                 <property name="position">1</property>
-                <property name="tab_expand">False</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
@@ -903,7 +920,6 @@
                 <child>
                   <widget class="GtkFrame" id="frame29">
                     <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment58">
@@ -1076,7 +1092,6 @@
                   <widget class="GtkFrame" id="frame5">
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment5">
@@ -1229,7 +1244,6 @@
               </widget>
               <packing>
                 <property name="position">2</property>
-                <property name="tab_expand">False</property>
               </packing>
             </child>
             <child>
@@ -1240,7 +1254,6 @@
               <packing>
                 <property name="type">tab</property>
                 <property name="position">2</property>
-                <property name="tab_expand">False</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
@@ -1522,7 +1535,6 @@
                 <child>
                   <widget class="GtkFrame" id="frame22">
                     <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment49">
@@ -1638,7 +1650,6 @@
               </widget>
               <packing>
                 <property name="position">3</property>
-                <property name="tab_expand">False</property>
               </packing>
             </child>
             <child>
@@ -1649,7 +1660,6 @@
               <packing>
                 <property name="type">tab</property>
                 <property name="position">3</property>
-                <property name="tab_expand">False</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
@@ -1661,7 +1671,6 @@
                 <child>
                   <widget class="GtkFrame" id="applications_frame">
                     <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment89">
@@ -1685,7 +1694,6 @@
                             </child>
                             <child>
                               <widget class="GtkFrame" id="custom_apps_frame">
-                                <property name="label_xalign">0</property>
                                 <property name="shadow_type">GTK_SHADOW_NONE</property>
                                 <child>
                                   <widget class="GtkAlignment" id="alignment43">
@@ -1825,7 +1833,6 @@
                   <widget class="GtkFrame" id="frame_gmail">
                     <property name="visible">True</property>
                     <property name="no_show_all">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment_gmail">
@@ -1892,7 +1899,6 @@
                 <child>
                   <widget class="GtkFrame" id="frame27">
                     <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment56">
@@ -1974,7 +1980,6 @@
                 <child>
                   <widget class="GtkFrame" id="frame31">
                     <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
                     <property name="shadow_type">GTK_SHADOW_NONE</property>
                     <child>
                       <widget class="GtkAlignment" id="alignment64">
@@ -2048,7 +2053,6 @@
               </widget>
               <packing>
                 <property name="position">4</property>
-                <property name="tab_expand">False</property>
               </packing>
             </child>
             <child>
@@ -2059,7 +2063,6 @@
               <packing>
                 <property name="type">tab</property>
                 <property name="position">4</property>
-                <property name="tab_expand">False</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
=== TODO.message-mode
==================================================================
--- TODO.message-mode	(revision 8975)
+++ TODO.message-mode	(patch gajim-message-mode level 4)
@@ -0,0 +1,2 @@
+ * Cleanup!
+
