summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind@gmail.com>2018-11-06 11:19:00 +0000
committerCalum Lind <calumlind@gmail.com>2018-11-06 11:19:00 +0000
commit83cac4978aaf567e4d4cda446b3bdac20acfb0cd (patch)
tree864fdb4346cb641a201b3654965e4ab2404257ee
parent2bb9a8e71c82e40b8374ab533662291039ee8f0c (diff)
downloaddeluge-83cac4978aaf567e4d4cda446b3bdac20acfb0cd.tar.gz
deluge-83cac4978aaf567e4d4cda446b3bdac20acfb0cd.tar.bz2
deluge-83cac4978aaf567e4d4cda446b3bdac20acfb0cd.zip
[GTK] Fix and cleanup storing window position
-rw-r--r--deluge/ui/gtk3/mainwindow.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py
index b380c5a82..42ffc59e9 100644
--- a/deluge/ui/gtk3/mainwindow.py
+++ b/deluge/ui/gtk3/mainwindow.py
@@ -158,11 +158,7 @@ class MainWindow(component.Component):
def hide(self):
component.get('TorrentView').save_state()
component.pause(self.child_components)
-
- # Store the x, y positions for when we restore the window
- self.config['window_x_pos'], self.config[
- 'window_y_pos'
- ] = self.window.get_position()
+ self.save_position()
self.window.hide()
def present(self):
@@ -193,7 +189,7 @@ class MainWindow(component.Component):
def visible(self):
"""Returns True if window is visible, False if not."""
- return self.window.get_property('visible')
+ return self.window.get_visible()
def get_builder(self):
"""Returns a reference to the main window GTK builder object."""
@@ -250,21 +246,20 @@ class MainWindow(component.Component):
if self.config['window_maximized']:
self.window.maximize()
- def on_window_configure_event(self, widget, event):
- if not self.config['window_maximized'] and self.visible:
+ def save_position(self):
+ self.config['window_maximized'] = self.window.props.is_maximized
+ if not self.config['window_maximized'] and self.visible():
self.config['window_x_pos'], self.config[
'window_y_pos'
] = self.window.get_position()
- self.config['window_width'] = event.width
- self.config['window_height'] = event.height
+ self.config['window_width'], self.config[
+ 'window_height'
+ ] = self.window.get_size()
+
+ def on_window_configure_event(self, widget, event):
+ self.save_position()
def on_window_state_event(self, widget, event):
- if event.changed_mask & WindowState.MAXIMIZED:
- if event.new_window_state & WindowState.MAXIMIZED:
- log.debug('pos: %s', self.window.get_position())
- self.config['window_maximized'] = True
- elif not event.new_window_state & WindowState.WITHDRAWN:
- self.config['window_maximized'] = False
if event.changed_mask & WindowState.ICONIFIED:
if event.new_window_state & WindowState.ICONIFIED:
log.debug('MainWindow is minimized..')