From 2c7c345a7c4717c5079d7f10757c1d70317b0661 Mon Sep 17 00:00:00 2001
From: js <js-gajim@webkeks.org>
Date: Sun, 23 Nov 2008 19:17:58 +0000
Subject: [PATCH] [kaylan] Remember size and position of history window. Closes
 #2824.

---
 src/common/config.py  |  4 ++++
 src/history_window.py | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/common/config.py b/src/common/config.py
index b5cc1d6205..1b6fd7cb07 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -156,6 +156,10 @@ class Config:
 		'roster_y-position': [ opt_int, 0 ],
 		'roster_width': [ opt_int, 200 ],
 		'roster_height': [ opt_int, 400 ],
+		'history_window_width': [ opt_int, 650 ],
+		'history_window_height': [ opt_int, 450 ],
+		'history_window_x-position': [ opt_int, 0 ],
+		'history_window_y-position': [ opt_int, 0 ],
 		'latest_disco_addresses': [ opt_str, '' ],
 		'recently_groupchat': [ opt_str, '' ],
 		'time_stamp': [ opt_str, '[%X] ', _('This option let you customize timestamp that is printed in conversation. For exemple "[%H:%M] " will show "[hour:minute] ". See python doc on strftime for full documentation: http://docs.python.org/lib/module-time.html') ],
diff --git a/src/history_window.py b/src/history_window.py
index 36e790191a..ba345ad228 100644
--- a/src/history_window.py
+++ b/src/history_window.py
@@ -119,6 +119,13 @@ class HistoryWindow:
 		if jid:
 			self.jid_entry.set_text(jid)	
 
+		gtkgui_helpers.resize_window(self.window,
+			gajim.config.get('history_window_width'),
+			gajim.config.get('history_window_height'))
+		gtkgui_helpers.move_window(self.window,
+			gajim.config.get('history_window_x-position'),
+			gajim.config.get('history_window_y-position'))
+				
 		xml.signal_autoconnect(self)
 		self.window.show_all()
 
@@ -217,9 +224,11 @@ class HistoryWindow:
 
 	def on_history_window_key_press_event(self, widget, event):
 		if event.keyval == gtk.keysyms.Escape:
+			self.save_state()
 			self.window.destroy()
 
 	def on_close_button_clicked(self, widget):
+		self.save_state()
 		self.window.destroy()
 
 	def on_jid_entry_activate(self, widget):
@@ -588,4 +597,15 @@ class HistoryWindow:
 			self._load_history(jid, account)
 		self.results_window.set_property('visible', False)
 
+	def save_state(self):
+		x,y = self.window.window.get_root_origin()
+		width, height = self.window.get_size()
+
+		gajim.config.set('history_window_x-position', x)
+		gajim.config.set('history_window_y-position', y)
+		gajim.config.set('history_window_width', width);
+		gajim.config.set('history_window_height', height);
+
+		gajim.interface.save_config()
+
 # vim: se ts=3:
-- 
GitLab