def __init__(self, app): Gtk.Window.__init__(self, application=app) self.app = app self.set_size_request(-1, 550) self.add_events(Gdk.EventMask.KEY_PRESS_MASK) # window state variables self.current_width = 0 self.current_height = 0 self.ismaximized = False # headerbar self.headerbar = headerbar_view.HeaderBar() self.set_titlebar(self.headerbar) # latex notebook self.latex_notebook = Gtk.Notebook() self.latex_notebook.set_show_tabs(False) self.latex_notebook.set_show_border(False) self.latex_notebook.set_scrollable(True) self.latex_notebook.set_size_request(550, -1) self.latex_shortcuts_bar = latex_shortcutsbar_view.LaTeXShortcutsBar() self.latex_notebook_wrapper = Gtk.VBox() self.latex_notebook_wrapper.pack_start(self.latex_shortcuts_bar, False, False, 0) self.latex_notebook_wrapper.pack_start(self.latex_notebook, True, True, 0) # bibtex notebook self.bibtex_notebook = Gtk.Notebook() self.bibtex_notebook.set_show_tabs(False) self.bibtex_notebook.set_show_border(False) self.bibtex_notebook.set_scrollable(True) self.bibtex_notebook.set_size_request(550, -1) self.bibtex_shortcuts_bar = bibtex_shortcutsbar_view.BibTeXShortcutsBar( ) self.bibtex_notebook_wrapper = Gtk.VBox() self.bibtex_notebook_wrapper.pack_start(self.bibtex_shortcuts_bar, False, False, 0) self.bibtex_notebook_wrapper.pack_start(self.bibtex_notebook, True, True, 0) # others notebook self.others_notebook = Gtk.Notebook() self.others_notebook.set_show_tabs(False) self.others_notebook.set_show_border(False) self.others_notebook.set_scrollable(True) self.others_notebook.set_size_request(550, -1) self.others_shortcuts_bar = others_shortcutsbar_view.OthersShortcutsBar( ) self.others_notebook_wrapper = Gtk.VBox() self.others_notebook_wrapper.pack_start(self.others_shortcuts_bar, False, False, 0) self.others_notebook_wrapper.pack_start(self.others_notebook, True, True, 0) # build log self.build_log = build_log_view.BuildLogView() self.build_log_paned = Gtk.VPaned() self.build_log_paned.pack1(self.latex_notebook_wrapper, True, False) self.build_log_paned.pack2(self.build_log, False, True) self.build_log_visible = None # preview self.preview_panel = preview_panel_view.PreviewPanelView() self.preview_visible = None # help self.help_panel = help_panel_view.HelpPanelView() self.help_visible = None # sidebar self.sidebar = sidebar_view.Sidebar() self.sidebar_visible = None # paneds self.preview_paned_overlay = Gtk.Overlay() self.overlay_widget = None self.preview_help_stack = Gtk.Stack() self.preview_help_stack.add_named(self.preview_panel, 'preview') self.preview_help_stack.add_named(self.help_panel, 'help') self.preview_paned = Gtk.HPaned() self.preview_paned.pack1(self.build_log_paned, True, False) self.preview_paned.pack2(self.preview_help_stack, False, True) self.preview_paned_overlay.add(self.preview_paned) self.sidebar_paned = Gtk.HPaned() self.sidebar_paned.pack1(self.sidebar, False, True) self.sidebar_paned.pack2(self.preview_paned_overlay, True, False) self.sidebar_paned.get_style_context().add_class('sidebar_paned') # welcome screen self.welcome_screen = welcome_screen_view.WelcomeScreenView() # mode stack self.mode_stack = Gtk.Stack() self.mode_stack.add_named(self.welcome_screen, 'welcome_screen') self.mode_stack.add_named(self.sidebar_paned, 'latex_documents') self.mode_stack.add_named(self.bibtex_notebook_wrapper, 'bibtex_documents') self.mode_stack.add_named(self.others_notebook_wrapper, 'other_documents') self.add(self.mode_stack) self.css_provider = Gtk.CssProvider() resources_path = ServiceLocator.get_resources_path() self.css_provider.load_from_path( os.path.join(resources_path, 'style_gtk.css')) self.style_context = Gtk.StyleContext() self.style_context.add_provider_for_screen( self.get_screen(), self.css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.css_provider_font_size = Gtk.CssProvider() self.style_context.add_provider_for_screen( self.get_screen(), self.css_provider_font_size, Gtk.STYLE_PROVIDER_PRIORITY_USER)
def __init__(self, app, settings): Gtk.Window.__init__(self, application=app) self.app = app self.set_size_request(-1, 550) self.add_events(Gdk.EventMask.KEY_PRESS_MASK) resources_path = ServiceLocator.get_resources_path() app_icons_path = ServiceLocator.get_app_icons_path() Gtk.IconTheme.append_search_path(Gtk.IconTheme.get_default(), os.path.join(resources_path, 'icons')) Gtk.IconTheme.append_search_path( Gtk.IconTheme.get_default(), os.path.join(resources_path, 'symbols', 'arrows')) Gtk.IconTheme.append_search_path( Gtk.IconTheme.get_default(), os.path.join(resources_path, 'symbols', 'greek_letters')) Gtk.IconTheme.append_search_path( Gtk.IconTheme.get_default(), os.path.join(resources_path, 'symbols', 'misc_math')) Gtk.IconTheme.append_search_path( Gtk.IconTheme.get_default(), os.path.join(resources_path, 'symbols', 'misc_text')) Gtk.IconTheme.append_search_path( Gtk.IconTheme.get_default(), os.path.join(resources_path, 'symbols', 'operators')) Gtk.IconTheme.append_search_path( Gtk.IconTheme.get_default(), os.path.join(resources_path, 'symbols', 'relations')) Gtk.IconTheme.append_search_path(Gtk.IconTheme.get_default(), app_icons_path) # window state variables self.current_width = 0 self.current_height = 0 self.ismaximized = False # headerbar self.headerbar = headerbar_view.HeaderBar() self.set_titlebar(self.headerbar) # notebook self.notebook_wrapper = Gtk.VBox() self.notebook = DocumentViewWrapper() self.shortcuts_bar = shortcutsbar_view.ShortcutsBar() self.notebook_wrapper.pack_start(self.shortcuts_bar, False, False, 0) self.notebook_wrapper.pack_start(self.notebook, True, True, 0) # bibtex notebook self.bibtex_notebook = Gtk.Notebook() self.bibtex_notebook.set_show_tabs(False) self.bibtex_notebook.set_show_border(False) self.bibtex_notebook.set_scrollable(True) self.bibtex_shortcuts_bar = bibtex_shortcutsbar_view.BibTeXShortcutsBar( ) self.bibtex_notebook_wrapper = Gtk.VBox() self.bibtex_notebook_wrapper.pack_start(self.bibtex_shortcuts_bar, False, False, 0) self.bibtex_notebook_wrapper.pack_start(self.bibtex_notebook, True, True, 0) # build log self.build_log = build_log_view.BuildLogView() self.build_log_paned = Gtk.VPaned() self.build_log_paned.pack1(self.notebook_wrapper, True, False) self.build_log_paned.pack2(self.build_log, False, True) self.build_log_visible = None # preview self.preview_panel = preview_panel_view.PreviewPanelView() self.preview_visible = None # sidebar self.sidebar = sidebar_view.Sidebar() self.sidebar_visible = None # paneds self.preview_paned_overlay = Gtk.Overlay() self.overlay_widget = None self.preview_paned = Gtk.HPaned() self.preview_paned.pack1(self.build_log_paned, True, False) self.preview_paned.pack2(self.preview_panel, False, True) self.preview_paned_overlay.add(self.preview_paned) self.sidebar_paned = Gtk.HPaned() self.sidebar_paned.pack1(self.sidebar, False, True) self.sidebar_paned.pack2(self.preview_paned_overlay, True, False) self.sidebar_paned.get_style_context().add_class('sidebar_paned') # blank slate self.blank_slate = BlankSlate() # mode stack self.mode_stack = Gtk.Stack() self.mode_stack.add_named(self.blank_slate, 'blank_slate') self.mode_stack.add_named(self.sidebar_paned, 'latex_documents') self.mode_stack.add_named(self.bibtex_notebook_wrapper, 'bibtex_documents') self.add(self.mode_stack) self.css_provider = Gtk.CssProvider() self.css_provider.load_from_path( os.path.join(resources_path, 'style_gtk.css')) self.style_context = Gtk.StyleContext() self.style_context.add_provider_for_screen( self.get_screen(), self.css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) # actions self.new_latex_document_action = Gio.SimpleAction.new( 'new-latex-document', None) self.add_action(self.new_latex_document_action) self.new_bibtex_document_action = Gio.SimpleAction.new( 'new-bibtex-document', None) self.add_action(self.new_bibtex_document_action) self.save_as_action = Gio.SimpleAction.new('save-as', None) self.add_action(self.save_as_action) self.save_all_action = Gio.SimpleAction.new('save-all', None) self.add_action(self.save_all_action) self.save_session_action = Gio.SimpleAction.new('save-session', None) self.add_action(self.save_session_action) self.restore_session_action = Gio.SimpleAction.new( 'restore-session', GLib.VariantType('as')) self.add_action(self.restore_session_action) self.find_action = Gio.SimpleAction.new('find', None) self.add_action(self.find_action) self.find_next_action = Gio.SimpleAction.new('find-next', None) self.add_action(self.find_next_action) self.find_prev_action = Gio.SimpleAction.new('find-prev', None) self.add_action(self.find_prev_action) self.find_replace_action = Gio.SimpleAction.new('find-replace', None) self.add_action(self.find_replace_action) self.close_all_action = Gio.SimpleAction.new('close-all-documents', None) self.add_action(self.close_all_action) self.close_document_action = Gio.SimpleAction.new( 'close-active-document', None) self.add_action(self.close_document_action) self.insert_before_after_action = Gio.SimpleAction.new( 'insert-before-after', GLib.VariantType('as')) self.add_action(self.insert_before_after_action) self.insert_symbol_action = Gio.SimpleAction.new( 'insert-symbol', GLib.VariantType('as')) self.add_action(self.insert_symbol_action) self.insert_before_document_end_action = Gio.SimpleAction.new( 'insert-before-document-end', GLib.VariantType('as')) self.add_action(self.insert_before_document_end_action) self.document_wizard_action = Gio.SimpleAction.new( 'show-document-wizard', None) self.add_action(self.document_wizard_action) self.create_new_bibtex_entry_action = Gio.SimpleAction.new( 'create-new-bibtex-entry', None) self.add_action(self.create_new_bibtex_entry_action) self.show_previous_bibtex_entries_action = Gio.SimpleAction.new( 'show-previous-bibtex-entries', None) self.add_action(self.show_previous_bibtex_entries_action) self.search_online_for_bibtex_entries_action = Gio.SimpleAction.new( 'search-online-for-bibtex-entries', None) self.add_action(self.search_online_for_bibtex_entries_action) self.include_bibtex_file_action = Gio.SimpleAction.new( 'include-bibtex-file', None) self.add_action(self.include_bibtex_file_action) self.include_latex_file_action = Gio.SimpleAction.new( 'include-latex-file', None) self.add_action(self.include_latex_file_action) self.add_remove_packages_dialog_action = Gio.SimpleAction.new( 'add-remove-packages-dialog', None) self.add_action(self.add_remove_packages_dialog_action) self.add_packages_action = Gio.SimpleAction.new( 'add-packages', GLib.VariantType('as')) self.add_action(self.add_packages_action) self.shortcuts_window_action = Gio.SimpleAction.new( 'show-shortcuts-window', None) self.add_action(self.shortcuts_window_action) self.show_preferences_action = Gio.SimpleAction.new( 'show-preferences-dialog', None) self.add_action(self.show_preferences_action) self.show_about_action = Gio.SimpleAction.new('show-about-dialog', None) self.add_action(self.show_about_action) self.quit_action = Gio.SimpleAction.new('quit', None) self.add_action(self.quit_action) self.close_build_log_action = Gio.SimpleAction.new( 'close-build-log', None) self.add_action(self.close_build_log_action) sc_default = GLib.Variant.new_boolean( settings.get_value('preferences', 'inline_spellchecking')) self.toggle_spellchecking_action = Gio.SimpleAction.new_stateful( 'toggle-spellchecking', None, sc_default) self.add_action(self.toggle_spellchecking_action) self.set_spellchecking_language_action = Gio.SimpleAction.new( 'set-spellchecking-language', None) self.add_action(self.set_spellchecking_language_action) self.spellchecking_action = Gio.SimpleAction.new('spellchecking', None) self.add_action(self.spellchecking_action) dm_default = GLib.Variant.new_boolean( settings.get_value('preferences', 'prefer_dark_mode')) self.toggle_dark_mode_action = Gio.SimpleAction.new_stateful( 'toggle-dark-mode', None, dm_default) self.add_action(self.toggle_dark_mode_action) settings.gtksettings.get_default().set_property( 'gtk-application-prefer-dark-theme', dm_default)