Skip to content

Commit e3eeb7e

Browse files
committed
Make init_window_content compatible with the way async calls work in GTK
though the async call itself is commented. Related to #377
1 parent 90ce77e commit e3eeb7e

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ def open_window_with_content(self, gfile, get_cb):
111111
clipboard content."""
112112
win = DrWindow(application=self)
113113
win.present()
114-
win.init_window_content(gfile, get_cb) # this optimization has no effect
115-
# because of GLib unknown magic, but should be kept anyway because the
116-
# window is presented to the user regardless of loading errors, making
117-
# any issue in `init_window_content` very explicit, and more likely to
118-
# be reported.
114+
115+
content_params = {'gfile': gfile, 'get_cb': get_cb}
116+
# Parameters are: time in milliseconds, method, data # XXX todo?
117+
# GLib.timeout_add(10, win.init_window_content_async, content_params)
118+
win.init_window_content_async(content_params)
119119
return win
120120

121121
def on_activate(self, *args):

src/window.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,22 @@ def __init__(self, **kwargs):
113113
# self.resize(720, 288)
114114
self._set_ui_bars()
115115

116-
def init_window_content(self, gfile, get_cb):
116+
def init_window_content_async(self, content_params):
117117
"""Initialize the window's content, such as the minimap, the color
118118
popovers, the tools, their options, and a new image. Depending on the
119119
parameters, the new image can be imported from the clipboard, loaded
120-
from a GioFile, or (else) it can be a blank image."""
120+
from a GioFile, or (else) it can be a blank image.
121+
122+
This method is called asynchronously, which isn't *correct* (not very
123+
thread-safe or anything) but it allows the window to be shown quicker.
124+
If it fails, a window is here anyway because this is independant from
125+
the object constructor."""
126+
121127
self.prompt_action(_("Error starting the application, please report this bug."))
122128

129+
gfile = content_params['gfile']
130+
get_cb = content_params['get_cb']
131+
123132
self.tools = {}
124133
self.minimap = DrMinimap(self, None)
125134
self.options_manager = DrOptionsManager(self)
@@ -148,6 +157,9 @@ def init_window_content(self, gfile, get_cb):
148157
self.set_picture_title()
149158
self._try_show_release_notes()
150159

160+
# has to return False to be removed from the mainloop immediatly
161+
return False
162+
151163
def _try_show_release_notes(self):
152164
last_version = self.gsettings.get_string('last-version')
153165
current_version = self.app.get_current_version()

0 commit comments

Comments
 (0)