def update_font_color_preview(self): source_style_scheme_manager = ServiceLocator.get_source_style_scheme_manager( ) name = self.settings.get_value('preferences', 'syntax_scheme') source_style_scheme_light = source_style_scheme_manager.get_scheme( name) name = self.settings.get_value('preferences', 'syntax_scheme_dark_mode') source_style_scheme_dark = source_style_scheme_manager.get_scheme(name) if self.view.style_switcher_stack.get_visible_child_name() == 'light': self.view.source_buffer.set_style_scheme(source_style_scheme_light) self.view.preview_wrapper.get_style_context().remove_class( 'light-bg') self.view.preview_wrapper.get_style_context().remove_class( 'dark-bg') if ServiceLocator.get_is_dark_mode(): self.view.preview_wrapper.get_style_context().add_class( 'light-bg') else: self.view.source_buffer.set_style_scheme(source_style_scheme_dark) self.view.preview_wrapper.get_style_context().remove_class( 'light-bg') self.view.preview_wrapper.get_style_context().remove_class( 'dark-bg') if not ServiceLocator.get_is_dark_mode(): self.view.preview_wrapper.get_style_context().add_class( 'dark-bg')
def init(self): self.update_switchers() self.view.style_switcher.set_active_id(self.settings.get_value('preferences', 'syntax_scheme')) self.view.style_switcher.connect('changed', self.on_style_switcher_changed, False) self.view.style_switcher_dark_mode.set_active_id(self.settings.get_value('preferences', 'syntax_scheme_dark_mode')) self.view.style_switcher_dark_mode.connect('changed', self.on_style_switcher_changed, True) self.view.style_switcher_label_light.connect('clicked', self.set_style_switcher_page, 'light') self.view.style_switcher_label_dark.connect('clicked', self.set_style_switcher_page, 'dark') source_language_manager = ServiceLocator.get_source_language_manager() source_language = source_language_manager.get_language('latex') self.view.source_buffer.set_language(source_language) self.update_font_color_preview() if ServiceLocator.get_is_dark_mode(): self.view.style_switcher_label_dark.clicked() self.view.add_scheme_button.connect('clicked', self.on_add_scheme_button_clicked) self.view.remove_scheme_button.connect('clicked', self.on_remove_scheme_button_clicked) self.view.font_chooser_button.set_font(self.settings.get_value('preferences', 'font_string')) self.view.font_chooser_button.connect('font-set', self.on_font_set) self.view.option_use_system_font.set_active(self.settings.get_value('preferences', 'use_system_font')) self.view.font_chooser_revealer.set_reveal_child(not self.view.option_use_system_font.get_active()) self.view.option_use_system_font.connect('toggled', self.on_use_system_font_toggled)
def on_new_document(self, workspace, document): document.set_dark_mode(ServiceLocator.get_is_dark_mode()) if document.is_latex_document(): self.main_window.latex_notebook.append_page(document.view) elif document.is_bibtex_document(): self.main_window.bibtex_notebook.append_page(document.view) else: self.main_window.others_notebook.append_page(document.view)
def update_syntax_scheme(self): name = self.settings.get_value('preferences', 'syntax_scheme') self.source_style_scheme_light = self.source_style_scheme_manager.get_scheme( name) name = self.settings.get_value('preferences', 'syntax_scheme_dark_mode') self.source_style_scheme_dark = self.source_style_scheme_manager.get_scheme( name) self.set_use_dark_scheme(ServiceLocator.get_is_dark_mode())
def on_add_scheme_button_clicked(self, button): dialog = AddSchemeDialog(self.main_window) pathname = dialog.run() if pathname != None: destination = os.path.join(ServiceLocator.get_config_folder(), 'syntax_schemes', os.path.basename(pathname)) shutil.copyfile(pathname, destination) ServiceLocator.get_source_style_scheme_manager().force_rescan() self.update_switchers() scheme_id = self.get_scheme_id_from_file(destination) if ServiceLocator.get_is_dark_mode(): self.view.style_switcher_dark_mode.set_active_id(scheme_id) else: self.view.style_switcher.set_active_id(scheme_id)
def __init__(self): self.view = ServiceLocator.get_main_window().sidebar # detect dark mode dm = 'True' if ServiceLocator.get_is_dark_mode() else 'False' # tabbed pages: name, icon name, tooltip, widget self.pages = list() self.pages.append([ 'greek_letters', 'own-symbols-greek-letters-symbolic', _('Greek Letters'), 'sidebar_view.SidebarPageSymbolsList("greek_letters", 25, ' + dm + ')' ]) self.pages.append([ 'arrows', 'own-symbols-arrows-symbolic', _('Arrows'), 'sidebar_view.SidebarPageSymbolsList("arrows", 48, ' + dm + ')' ]) self.pages.append([ 'relations', 'own-symbols-relations-symbolic', _('Relations'), 'sidebar_view.SidebarPageSymbolsList("relations", 39, ' + dm + ')' ]) self.pages.append([ 'operators', 'own-symbols-operators-symbolic', _('Operators'), 'sidebar_view.SidebarPageSymbolsList("operators", 47, ' + dm + ')' ]) self.pages.append([ 'misc_math', 'own-symbols-misc-math-symbolic', _('Misc. Math'), 'sidebar_view.SidebarPageSymbolsList("misc_math", 42, ' + dm + ')' ]) self.pages.append([ 'misc_text', 'own-symbols-misc-text-symbolic', _('Misc. Symbols'), 'sidebar_view.SidebarPageSymbolsList("misc_text", 38, ' + dm + ')' ]) self.page_views = list() self.init_page_stack() self.view.show_all()
def change_notification(self, change_code, notifying_object, parameter): if change_code == 'new_document': document = parameter document.set_dark_mode(ServiceLocator.get_is_dark_mode()) if document.is_latex_document(): self.main_window.latex_notebook.append_page(document.view) elif document.is_bibtex_document(): self.main_window.bibtex_notebook.append_page(document.view) else: self.main_window.others_notebook.append_page(document.view) if change_code == 'document_removed': document = parameter if document.is_latex_document(): self.main_window.latex_notebook.remove(document.view) elif document.is_bibtex_document(): self.main_window.bibtex_notebook.remove(document.view) else: self.main_window.others_notebook.remove(document.view) if self.workspace.active_document == None: self.activate_welcome_screen_mode() if change_code == 'new_active_document': document = parameter if document.is_latex_document(): notebook = self.main_window.latex_notebook notebook.set_current_page(notebook.page_num(document.view)) document.view.source_view.grab_focus() try: self.main_window.preview_paned_overlay.add_overlay( document.autocomplete.view) document.autocomplete.update() except AttributeError: pass self.update_latex_shortcuts_bar() self.activate_latex_documents_mode() elif document.is_bibtex_document(): notebook = self.main_window.bibtex_notebook notebook.set_current_page(notebook.page_num(document.view)) document.view.source_view.grab_focus() self.update_bibtex_shortcuts_bar() self.activate_bibtex_documents_mode() else: notebook = self.main_window.others_notebook notebook.set_current_page(notebook.page_num(document.view)) document.view.source_view.grab_focus() self.update_others_shortcuts_bar() self.activate_other_documents_mode() if change_code == 'new_inactive_document': document = parameter if document.is_latex_document(): try: self.main_window.preview_paned_overlay.remove( document.autocomplete.view) except AttributeError: pass self.main_window.latex_shortcuts_bar.top_icons.remove( document.view.wizard_button) if change_code == 'set_show_sidebar': self.animate_sidebar(parameter, True) if change_code == 'set_show_preview_or_help': if self.workspace.show_preview: self.main_window.preview_help_stack.set_visible_child_name( 'preview') self.focus_active_document() elif self.workspace.show_help: self.main_window.preview_help_stack.set_visible_child_name( 'help') if self.main_window.help_panel.stack.get_visible_child_name( ) == 'search': self.main_window.help_panel.search_entry.set_text('') self.main_window.help_panel.search_entry.grab_focus() else: self.focus_active_document() else: self.focus_active_document() self.animate_preview(self.workspace.show_preview, self.workspace.show_help, True) if change_code == 'show_build_log_state_change': self.build_log_animate(parameter, True) if change_code == 'set_dark_mode': ServiceLocator.get_settings().gtksettings.get_default( ).set_property('gtk-application-prefer-dark-theme', parameter)