diff --git a/src/main.py b/src/main.py index 4c95f4a8..d358f09a 100644 --- a/src/main.py +++ b/src/main.py @@ -111,11 +111,11 @@ def open_window_with_content(self, gfile, get_cb): clipboard content.""" win = DrWindow(application=self) win.present() - win.init_window_content(gfile, get_cb) # this optimization has no effect - # because of GLib unknown magic, but should be kept anyway because the - # window is presented to the user regardless of loading errors, making - # any issue in `init_window_content` very explicit, and more likely to - # be reported. + + content_params = {'gfile': gfile, 'get_cb': get_cb} + # Parameters are: time in milliseconds, method, data # XXX todo? + # GLib.timeout_add(10, win.init_window_content_async, content_params) + win.init_window_content_async(content_params) return win def on_activate(self, *args): diff --git a/src/window.py b/src/window.py index 57315f78..d554d885 100644 --- a/src/window.py +++ b/src/window.py @@ -113,13 +113,22 @@ def __init__(self, **kwargs): # self.resize(720, 288) self._set_ui_bars() - def init_window_content(self, gfile, get_cb): + def init_window_content_async(self, content_params): """Initialize the window's content, such as the minimap, the color popovers, the tools, their options, and a new image. Depending on the parameters, the new image can be imported from the clipboard, loaded - from a GioFile, or (else) it can be a blank image.""" + from a GioFile, or (else) it can be a blank image. + + This method is called asynchronously, which isn't *correct* (not very + thread-safe or anything) but it allows the window to be shown quicker. + If it fails, a window is here anyway because this is independant from + the object constructor.""" + self.prompt_action(_("Error starting the application, please report this bug.")) + gfile = content_params['gfile'] + get_cb = content_params['get_cb'] + self.tools = {} self.minimap = DrMinimap(self, None) self.options_manager = DrOptionsManager(self) @@ -148,6 +157,9 @@ def init_window_content(self, gfile, get_cb): self.set_picture_title() self._try_show_release_notes() + # has to return False to be removed from the mainloop immediatly + return False + def _try_show_release_notes(self): last_version = self.gsettings.get_string('last-version') current_version = self.app.get_current_version()