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