Browse Source

Position and size saving works

master
Julio Biason 16 years ago
parent
commit
7200fb09ca
  1. 42
      mitterlib/ui/ui_pygtk.py

42
mitterlib/ui/ui_pygtk.py

@ -276,17 +276,6 @@ class Interface(object):
return
def quit(self, widget, user_data=None):
"""Callback when the window is destroyed (e.g. when the user closes
the application."""
# this is really annoying: if the threads are locked doing some IO
# requests, the application will not quit. Displaying this message is
# the only option we have right now.
_log.debug('quit callback invoked. exiting now...')
gtk.main_quit()
def notify_reset(self, widget, event, user_data=None):
if getattr(event, 'in_', False):
self._main_window.set_urgency_hint(False)
@ -997,14 +986,22 @@ class Interface(object):
return
def _create_main_window(self):
main_window = gtk.Window()
"""Returns the object with the main window and the attached
widgets."""
main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
initial_width = int(self._options[self.NAMESPACE]['width'])
initial_height = int(self._options[self.NAMESPACE]['height'])
_log.debug('Initial size: %d x %d', initial_width, initial_height)
initial_x = int(self._options[self.NAMESPACE]['position_x'])
initial_y = int(self._options[self.NAMESPACE]['position_y'])
_log.debug('Initial position: %d x %d', initial_x, initial_y)
main_window.set_title('Mitter')
main_window.set_size_request(10, 10) # very small minimal size
main_window.resize(self._options[self.NAMESPACE]['width'],
self._options[self.NAMESPACE]['height'])
main_window.move(self._options[self.NAMESPACE]['position_x'],
self._options[self.NAMESPACE]['position_y'])
main_window.resize(initial_width, initial_height)
main_window.move(initial_x, initial_y)
if self._app_icon:
main_window.set_icon_from_file(self._app_icon)
@ -1090,7 +1087,7 @@ class Interface(object):
quit_action = gtk.Action('Quit', '_Quit',
'Exit Mitter', gtk.STOCK_QUIT)
quit_action.connect('activate', self.quit)
quit_action.connect('activate', self.quit_app)
settings_action = gtk.Action('Settings', '_Settings',
'Settings', gtk.STOCK_PREFERENCES)
@ -1295,6 +1292,17 @@ class Interface(object):
def quit_app(self, widget=None, user_data=None):
"""Callback when the window is destroyed or the user selects
"Quit"."""
(x, y) = self._main_window.get_position()
_log.debug('Current position: %d x %d', x, y)
self._options[self.NAMESPACE]['position_x'] = x
self._options[self.NAMESPACE]['position_y'] = y
(width, height) = self._main_window.get_size()
_log.debug('Current window size: %d x %d', width, height)
self._options[self.NAMESPACE]['width'] = width
self._options[self.NAMESPACE]['height'] = height
gtk.main_quit()
return

Loading…
Cancel
Save