Skip to content

Commit

Permalink
Consistently wait for end of initialization to care about document
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Mar 23, 2017
1 parent 026b6ac commit fbf4f2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 6 additions & 2 deletions pympress/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk
from gi.repository import Gtk, Gdk, GLib

import pympress.util
gettext.install('pympress', pympress.util.get_resource_path('share', 'locale'))
Expand Down Expand Up @@ -100,7 +100,11 @@ def main(argv = sys.argv[1:]):
name = None

# Create windows
ui = pympress.ui.UI(name, ett)
ui = pympress.ui.UI(ett)
if name:
GLib.idle_add(ui.swap_document, name)
else:
GLib.idle_add(ui.pick_file)
ui.run()


Expand Down
11 changes: 2 additions & 9 deletions pympress/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class UI:
redraw_timeout = 0

#: Current :class:`~pympress.document.Document` instance.
doc = None
doc = pympress.document.EmptyDocument()

#: Whether to use notes mode or not
notes_mode = False
Expand Down Expand Up @@ -243,10 +243,9 @@ class UI:
# The :class:`UI` singleton, since there is only one (as a class variable). Used by classmethods only.
_instance = None

def __init__(self, docpath = None, ett = 0):
def __init__(self, ett = 0):
"""
Args:
docpath (string): the path to the document to open
ett (int): the estimated (intended) talk time
"""
UI._instance = self
Expand All @@ -261,9 +260,6 @@ def __init__(self, docpath = None, ett = 0):
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)

# Document
self.doc = pympress.document.Document.create(docpath)

# Use notes mode by default if the document has notes
self.notes_mode = self.doc.has_notes()
self.show_annotations = not self.notes_mode
Expand Down Expand Up @@ -415,9 +411,6 @@ def initial_resize(self):

GLib.idle_add(self.resize_annotation_list)

# delayed check for a file, prompt which to open
GLib.idle_add(lambda: self.doc.pages_number() > 0 or self.pick_file())


def load_time_colors(self):
# Load color from CSS
Expand Down

0 comments on commit fbf4f2c

Please sign in to comment.