forked from Mirrors/apostrophe
fix recents menu (now we pass App to window and headerbar)
parent
cbd59b5f0b
commit
2e2dc33e7f
|
@ -66,7 +66,7 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
#__gtype_name__ = "UberwriterWindow"
|
||||
WORDCOUNT = re.compile(r"(?!\-\w)[\s#*\+\-]+", re.UNICODE)
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, app):
|
||||
"""Set up the main window"""
|
||||
|
||||
Gtk.ApplicationWindow.__init__(self,
|
||||
|
@ -84,9 +84,9 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
self.set_name('UberwriterWindow')
|
||||
|
||||
# Headerbars
|
||||
self.headerbar = headerbars.MainHeaderbar()
|
||||
self.headerbar = headerbars.MainHeaderbar(app)
|
||||
self.set_titlebar(self.headerbar.hb_container)
|
||||
self.fs_headerbar = headerbars.FsHeaderbar(self.builder)
|
||||
self.fs_headerbar = headerbars.FsHeaderbar(self.builder, app)
|
||||
|
||||
self.title_end = " – UberWriter"
|
||||
self.set_headerbar_title("New File" + self.title_end)
|
||||
|
@ -926,6 +926,9 @@ class UberwriterWindow(Gtk.ApplicationWindow):
|
|||
|
||||
def load_file(self, filename=None):
|
||||
"""Open File from command line or open / open recent etc."""
|
||||
if self.check_change() == Gtk.ResponseType.CANCEL:
|
||||
return
|
||||
|
||||
if filename:
|
||||
if filename.startswith('file://'):
|
||||
filename = filename[7:]
|
||||
|
|
|
@ -27,7 +27,7 @@ class MainHeaderbar: #pylint: disable=too-few-public-methods
|
|||
"""Sets up the main application headerbar
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, app):
|
||||
self.hb = Gtk.HeaderBar().new() #pylint: disable=C0103
|
||||
self.hb.props.show_close_button = True
|
||||
self.hb.get_style_context().add_class("titlebar")
|
||||
|
@ -44,8 +44,9 @@ class MainHeaderbar: #pylint: disable=too-few-public-methods
|
|||
self.hb_container.add(self.hb_revealer)
|
||||
self.hb_container.show()
|
||||
|
||||
btns = buttons()
|
||||
pack_buttons(self.hb, btns)
|
||||
self.btns = buttons(app)
|
||||
self.rec = self.btns.recent
|
||||
pack_buttons(self.hb, self.btns)
|
||||
|
||||
# btns.recent.set_popup(self.generate_recent_files_menu())
|
||||
|
||||
|
@ -56,7 +57,7 @@ class FsHeaderbar:
|
|||
"""Sets up and manages the fullscreen headerbar and his events
|
||||
"""
|
||||
|
||||
def __init__(self, builder):
|
||||
def __init__(self, builder, app):
|
||||
self.events = builder.get_object("FullscreenEventbox")
|
||||
self.revealer = builder.get_object(
|
||||
"FullscreenHbPlaceholder")
|
||||
|
@ -68,7 +69,7 @@ class FsHeaderbar:
|
|||
self.hb.show()
|
||||
self.events.hide()
|
||||
|
||||
self.btns = buttons()
|
||||
self.btns = buttons(app)
|
||||
|
||||
fs_btn_exit = Gtk.Button().new_from_icon_name("view-restore-symbolic",
|
||||
Gtk.IconSize.BUTTON)
|
||||
|
@ -99,7 +100,7 @@ class FsHeaderbar:
|
|||
else:
|
||||
self.revealer.set_reveal_child(False)
|
||||
|
||||
def buttons():
|
||||
def buttons(app):
|
||||
"""constructor for the headerbar buttons
|
||||
|
||||
Returns:
|
||||
|
|
|
@ -157,7 +157,7 @@ class Application(Gtk.Application):
|
|||
# Windows are associated with the application
|
||||
# when the last one is closed the application shuts down
|
||||
# self.window = Window(application=self, title="UberWriter")
|
||||
self.window = UberwriterWindow.UberwriterWindow()
|
||||
self.window = UberwriterWindow.UberwriterWindow(self)
|
||||
if self.args:
|
||||
self.window.load_file(self.args[0])
|
||||
if self.options.experimental_features:
|
||||
|
@ -241,9 +241,8 @@ class Application(Gtk.Application):
|
|||
def on_open(self, _action, _value):
|
||||
self.window.open_document()
|
||||
|
||||
def on_open_recent(self):
|
||||
print(self)
|
||||
#self.window.load_file(self.get_current_uri())
|
||||
def on_open_recent(self, file):
|
||||
self.window.load_file(file.get_current_uri())
|
||||
|
||||
def on_example(self, _action, _value):
|
||||
self.window.open_uberwriter_markdown()
|
||||
|
|
Loading…
Reference in New Issue