Fix deprecation warning about Gdk.Screen

[Gdk.Screen.width()](https://lazka.github.io/pgi-docs/#Gdk-3.0/classes/Screen.html#Gdk.Screen.width)
and [.height()](https://lazka.github.io/pgi-docs/#Gdk-3.0/classes/Screen.html#Gdk.Screen.height)
are deprecated since 3.22.

The equivalent solution is to get the first monitor of the default
display.
This commit is contained in:
Romain Failliot 2020-03-28 18:06:23 -04:00
parent 0b4ff56fcc
commit c1b88634e5
1 changed files with 5 additions and 2 deletions

View File

@ -7423,11 +7423,14 @@ class Diffuse(Gtk.Window):
# number of created viewers (used to label some tabs)
self.viewer_count = 0
# get monitor resolution
monitor_geometry = Gdk.Display.get_default().get_monitor(0).get_geometry()
# state information that should persist across sessions
self.bool_state = { 'window_maximized': False, 'search_matchcase': False, 'search_backwards': False }
self.int_state = { 'window_width': 1024, 'window_height': 768 }
self.int_state['window_x'] = max(0, (Gdk.Screen.width() - self.int_state['window_width']) / 2)
self.int_state['window_y'] = max(0, (Gdk.Screen.height() - self.int_state['window_height']) / 2)
self.int_state['window_x'] = max(0, (monitor_geometry.width - self.int_state['window_width']) / 2)
self.int_state['window_y'] = max(0, (monitor_geometry.height - self.int_state['window_height']) / 2)
self.connect('configure-event', self.configure_cb)
self.connect('window-state-event', self.window_state_cb)