Ejemplo n.º 1
0
    def __init__(self, document):
        Observable.__init__(self)

        self.is_enabled = False

        self.blocks = list()
        self.marks_start = dict()
        self.folding_regions = dict()
        self.folding_regions_by_region_id = dict()
        self.maximum_region_id = 0
        self.initial_folded_regions_set = False
        self.initial_folding_done = False
        self.initial_folding_regions_checked_count = 0

        self.document = document
        self.gutter_object = code_folding_gutter_object.CodeFoldingGutterObject(
            self)
        document.gutter.add_widget(self.gutter_object)

        self.presenter = code_folding_presenter.CodeFoldingPresenter(self)
        self.controller = code_folding_controller.CodeFoldingController(self)

        self.document.content.connect('text_inserted', self.on_text_inserted)
        self.document.content.connect('text_deleted', self.on_text_deleted)
        self.document.content.connect('buffer_changed', self.on_buffer_changed)
Ejemplo n.º 2
0
    def __init__(self, workspace):
        Observable.__init__(self)

        self.workspace = workspace
        self.view = ServiceLocator.get_main_window().help_panel

        self.path = 'file://' + os.path.join(
            ServiceLocator.get_resources_path(), 'help')
        self.home_uri = self.path + '/latex2e_0.html'
        self.current_uri = self.home_uri

        with open(
                os.path.join(ServiceLocator.get_resources_path(), 'help',
                             'search_index.pickle'), 'rb') as filehandle:
            self.search_index = pickle.load(filehandle)

        self.search_results_blank = list()
        self.search_results = self.search_results_blank
        self.query = ''

        self.controller = help_panel_controller.HelpPanelController(
            self, self.view)
        self.presenter = help_panel_presenter.HelpPanelPresenter(
            self, self.view)

        self.add_change_code('search_query_changed')
Ejemplo n.º 3
0
    def __init__(self, preview, view):
        Observable.__init__(self)
        self.preview = preview
        self.view = view

        self.hidpi_factor = self.view.get_scale_factor()
        self.ppp = self.get_ppp()  # pixels per point
        self.vertical_margin_points = 0
        self.horizontal_margin_points = 0
        self.vertical_margin = None
        self.horizontal_margin = None
        self.page_width = None
        self.page_height = None
        self.page_gap_points = 5
        self.page_gap = None
        self.border_width = None
        self.canvas_width = None
        self.canvas_height = None
        self.scale_factor = None
        self.current_page = None
        self.visible_synctex_rectangles = dict()
        self.visible_synctex_rectangles_time = None
        self.has_layout = False

        self.preview.register_observer(self)

        if self.preview.pdf_filename != None:
            self.update_layout()
Ejemplo n.º 4
0
    def __init__(self, document):
        Observable.__init__(self)
        self.document = document

        self.pdf_filename = None
        self.invert_pdf = False

        self.poppler_document = None
        self.page_width = None
        self.page_height = None
        self.xoffset = 0
        self.yoffset = 0
        self.layout = None

        self.visible_synctex_rectangles = list()
        self.visible_synctex_rectangles_time = None

        self.view = preview_view.PreviewView()
        self.layouter = preview_layouter.PreviewLayouter(self, self.view)
        self.zoom_manager = preview_zoom_manager.PreviewZoomManager(self, self.view)
        self.controller = preview_controller.PreviewController(self, self.view)
        self.page_renderer = preview_page_renderer.PreviewPageRenderer(self)
        self.links_parser = preview_links_parser.PreviewLinksParser(self)
        self.presenter = preview_presenter.PreviewPresenter(self, self.page_renderer, self.view)
        self.paging_widget = paging_widget.PagingWidget(self)
        self.zoom_widget = zoom_widget.ZoomWidget(self)

        self.document.connect('filename_change', self.on_filename_change)
        self.document.connect('pdf_updated', self.on_pdf_updated)
Ejemplo n.º 5
0
    def __init__(self):
        Observable.__init__(self)

        self.settings = ServiceLocator.get_settings()

        self.displayname = ''
        self.filename = None
        self.save_date = None
        self.deleted_on_disk_dialog_shown_after_last_save = False
        self.last_activated = 0
        self.dark_mode = False
        self.is_root = False
        self.root_is_set = False

        self.source_buffer = source_buffer.SourceBuffer(self)

        self.view = document_view.DocumentView(self, self.source_buffer.view)
        self.gutter = gutter.Gutter(self, self.view)
        self.search = search.Search(self, self.view, self.view.search_bar)
        self.spellchecker = spellchecker.Spellchecker(self.view.source_view)
        self.document_switcher_item = document_switcher_item.DocumentSwitcherItem(
            self)
        self.context_menu = context_menu.ContextMenu(self, self.view)
        self.shortcutsbar = shortcutsbar_presenter.ShortcutsbarPresenter(
            self, self.view)

        self.presenter = document_presenter.DocumentPresenter(self, self.view)
        self.controller = document_controller.DocumentController(
            self, self.view)

        self.line_numbers = line_numbers.LineNumbers(self, self.view)
Ejemplo n.º 6
0
    def __init__(self, document):
        Observable.__init__(self)
        self.document = document
        self.settings = ServiceLocator.get_settings()

        self.items = list()

        self.view = build_widget_view.BuildWidgetView()
        self.view.stop_button.connect('clicked',
                                      self.on_stop_build_button_click)
        self.view.clean_button.connect('clicked', self.on_clean_button_click)

        self.view.build_button.show_all()
        self.view.stop_button.hide()

        self.build_button_state = ('idle', int(time.time() * 1000))
        self.set_clean_button_state()

        self.document.connect('filename_change', self.on_filename_change)
        self.document.build_system.connect('build_state_change',
                                           self.on_build_state_change)
        self.document.build_system.connect('build_state', self.on_build_state)
        self.settings.connect('settings_changed', self.on_settings_changed)

        self.view.build_timer.connect('notify::child-revealed',
                                      self.on_revealer_finished)
Ejemplo n.º 7
0
    def __init__(self, workspace):
        Observable.__init__(self)

        self.workspace = workspace
        self.workspace.register_observer(self)
        self.document = None
        self.can_sync = False
        self.update_document()
Ejemplo n.º 8
0
    def __init__(self, preview, view):
        Observable.__init__(self)
        self.preview = preview
        self.view = view

        self.zoom_level_fit_to_width = None
        self.zoom_level_fit_to_text_width = None
        self.zoom_level_fit_to_height = None
        self.zoom_level = None
        self.zoom_set = False
Ejemplo n.º 9
0
    def __init__(self, workspace):
        Observable.__init__(self)
        self.workspace = workspace

        self.presenter = document_switcher_presenter.DocumentSwitcherPresenter(
            self, self.workspace)
        self.controller = document_switcher_controller.DocumentSwitcherController(
            self, self.workspace)

        # can be normal or selection
        self.mode = 'normal'
Ejemplo n.º 10
0
    def __init__(self, main_window):
        Observable.__init__(self)

        self.main_window = main_window
        self.default_folder = None
        self.filename = None
        self.filters = list()
        self.title = _('Choose File')

        self.view = FilechooserButtonView()

        self.view.connect('clicked', self.on_button_clicked)
Ejemplo n.º 11
0
    def __init__(self, main_window, settings):
        Observable.__init__(self)

        self.main_window = main_window
        self.settings = settings
        self.settings.connect('settings_changed', self.on_settings_changed)

        self.text_view = Gtk.TextView()
        self.text_view.set_monospace(True)
        self.system_font = self.text_view.get_pango_context().get_font_description().to_string()
        self.font_string = None
        self.update_font_string()
Ejemplo n.º 12
0
    def __init__(self):
        Observable.__init__(self)

        self.settings = ServiceLocator.get_settings()

        self.displayname = ''
        self.filename = None
        self.save_date = None
        self.last_activated = 0

        self.parser = None
        self.source_buffer = source_buffer.SourceBuffer(self)
        self.source_buffer.connect('changed', self.on_buffer_changed)
Ejemplo n.º 13
0
    def __init__(self, workspace):
        Observable.__init__(self)
        self.workspace = workspace
        self.settings = ServiceLocator.get_settings()
        self.document = None

        self.items = list()
        self.hover_item = None

        self.view = ServiceLocator.get_main_window().build_log
        self.presenter = build_log_presenter.BuildLogPresenter(self, self.view)
        self.controller = build_log_controller.BuildLogController(
            self, self.view)
Ejemplo n.º 14
0
    def __init__(self, main_window, settings):
        Observable.__init__(self)

        self.main_window = main_window
        self.settings = settings
        self.settings.register_observer(self)

        textview = Gtk.TextView()
        textview.set_monospace(True)
        self.system_font = textview.get_pango_context().get_font_description(
        ).to_string()
        self.font_string = None
        self.update_font_string()
Ejemplo n.º 15
0
    def __init__(self, sidebar, workspace):
        Observable.__init__(self)

        self.workspace = workspace
        self.document = None

        self.integrated_includes = dict()

        self.signal_id = sidebar.view.connect('draw', self.on_first_draw)
        self.workspace.connect('new_document', self.on_new_document)
        self.workspace.connect('document_removed', self.on_document_removed)
        self.workspace.connect('new_active_document',
                               self.on_new_active_document)
        self.workspace.connect('root_state_change', self.on_root_state_change)
Ejemplo n.º 16
0
    def __init__(self, pathname):
        Observable.__init__(self)

        self.gtksettings = Gtk.Settings.get_default()

        self.pathname = pathname

        self.data = dict()
        self.defaults = dict()
        self.set_defaults()

        if not self.unpickle():
            self.data = self.defaults
            self.pickle()
Ejemplo n.º 17
0
    def __init__(self, document):
        Observable.__init__(self)
        self.document = document
        self.settings = ServiceLocator.get_settings()
        self.active_query = None

        # possible states: idle, ready_for_building
        # building_in_progress, building_to_stop
        self.build_state = 'idle'

        # possible values: build, forward_sync, build_and_forward_sync
        self.build_mode = 'build_and_forward_sync'

        self.document_has_been_built = False
        self.build_time = None
        self.last_build_start_time = None

        self.has_synctex_file = False
        self.backward_sync_data = None
        self.forward_sync_arguments = None
        self.can_sync = False
        self.update_can_sync()

        self.build_log_data = {
            'items': list(),
            'error_count': 0,
            'warning_count': 0,
            'badbox_count': 0
        }

        self.builders = dict()
        self.builders['build_latex'] = builder_build_latex.BuilderBuildLaTeX()
        self.builders[
            'build_bibtex'] = builder_build_bibtex.BuilderBuildBibTeX()
        self.builders['build_biber'] = builder_build_biber.BuilderBuildBiber()
        self.builders[
            'build_makeindex'] = builder_build_makeindex.BuilderBuildMakeindex(
            )
        self.builders[
            'build_glossaries'] = builder_build_glossaries.BuilderBuildGlossaries(
            )
        self.builders[
            'forward_sync'] = builder_forward_sync.BuilderForwardSync()
        self.builders[
            'backward_sync'] = builder_backward_sync.BuilderBackwardSync()

        self.document.preview.connect('pdf_changed', self.update_can_sync)

        GObject.timeout_add(50, self.results_loop)
Ejemplo n.º 18
0
    def __init__(self):
        Observable.__init__(self)

        self.settings = ServiceLocator.get_settings()

        self.displayname = ''
        self.filename = None
        self.save_date = None
        self.last_activated = 0

        self.source_buffer = None
        self.search_settings = None
        self.search_context = None
        self.parser = None
        self.init_buffer()
Ejemplo n.º 19
0
    def __init__(self):
        Observable.__init__(self)
        self.pathname = ServiceLocator.get_config_folder()

        self.open_documents = list()
        self.open_latex_documents = list()
        self.root_document = None
        self.recently_opened_documents = dict()
        self.untitled_documents_no = 0

        self.active_document = None

        self.can_sync = False
        self.sync_document = None
        self.update_sync_document()

        self.recently_opened_session_files = dict()
        self.session_file_opened = None

        self.settings = ServiceLocator.get_settings()
        self.inline_spellchecking = self.settings.get_value(
            'preferences', 'inline_spellchecking')
        self.spellchecking_language_code = self.settings.get_value(
            'preferences', 'spellchecking_language_code')
        self.dark_mode = self.settings.get_value('preferences',
                                                 'prefer_dark_mode')
        self.invert_pdf = self.settings.get_value('preferences', 'invert_pdf')

        self.sidebar = sidebar.Sidebar(self)
        self.welcome_screen = welcome_screen.WelcomeScreen()
        self.show_symbols = self.settings.get_value('window_state',
                                                    'show_symbols')
        self.show_document_structure = self.settings.get_value(
            'window_state', 'show_document_structure')
        self.sidebar_position = self.settings.get_value(
            'window_state', 'sidebar_paned_position')
        self.show_help = self.settings.get_value('window_state', 'show_help')
        self.show_preview = self.settings.get_value('window_state',
                                                    'show_preview')
        self.preview_position = self.settings.get_value(
            'window_state', 'preview_paned_position')
        self.build_log = build_log.BuildLog(self)
        self.show_build_log = self.settings.get_value('window_state',
                                                      'show_build_log')
        self.build_log_position = self.settings.get_value(
            'window_state', 'build_log_paned_position')
        self.shortcutsbar = shortcutsbar.Shortcutsbar(self)
        self.shortcuts = shortcuts.Shortcuts(self)
Ejemplo n.º 20
0
    def __init__(self, pathname):
        Observable.__init__(self)

        self.gtksettings = Gtk.Settings.get_default()
        
        self.pathname = pathname
    
        self.data = dict()
        self.defaults = dict()
        self.set_defaults()

        if not self.unpickle():
            self.data = self.defaults
            self.pickle()
            
        # load gsettings schema concerning application menu / window decorations
        self.button_layout = self.gtksettings.get_property('gtk-decoration-layout')
Ejemplo n.º 21
0
    def __init__(self, document):
        Observable.__init__(self)
        self.document = document

        self.pdf_filename = None
        self.pdf_date = None
        self.invert_pdf = False

        self.poppler_document_lock = thread.allocate_lock()
        self.poppler_document = None
        self.links_lock = thread.allocate_lock()
        self.links_parsed = True
        with self.links_lock:
            self.links = dict()
        self.links_parser_lock = thread.allocate_lock()
        self.number_of_pages = 0
        self.page_width = None
        self.page_height = None
        self.xoffset = 0
        self.yoffset = 0
        self.zoom_levels = [
            0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0, 4.0
        ]
        self.zoom_level_fit_to_width = None
        self.zoom_level_fit_to_text_width = None
        self.zoom_level_fit_to_height = None
        self.zoom_level = None
        self.visible_synctex_rectangles = list()
        self.visible_synctex_rectangles_time = None
        self.pdf_loaded = False

        self.is_visible = False
        self.first_show = True

        self.view = preview_view.PreviewView()
        self.layouter = preview_layouter.PreviewLayouter(self, self.view)
        self.controller = preview_controller.PreviewController(
            self, self.layouter, self.view)
        self.page_renderer = preview_page_renderer.PreviewPageRenderer(
            self, self.layouter)
        self.presenter = preview_presenter.PreviewPresenter(
            self, self.layouter, self.page_renderer, self.view)
        self.paging_widget = paging_widget.PagingWidget(self, self.layouter)
        self.zoom_widget = zoom_widget.ZoomWidget(self)

        self.document.register_observer(self)
Ejemplo n.º 22
0
    def __init__(self, workspace):
        Observable.__init__(self)
        self.workspace = workspace
        self.settings = ServiceLocator.get_settings()
        self.document = None

        self.items = list()
        self.symbols = {
            'Badbox': 'own-badbox-symbolic',
            'Error': 'dialog-error-symbolic',
            'Warning': 'dialog-warning-symbolic'
        }

        self.view = ServiceLocator.get_main_window().build_log
        self.presenter = build_log_presenter.BuildLogPresenter(self, self.view)
        self.controller = build_log_controller.BuildLogController(
            self, self.view)
Ejemplo n.º 23
0
    def __init__(self, language, document):
        Observable.__init__(self)
        self.document = document

        self.settings = ServiceLocator.get_settings()

        self.source_buffer = GtkSource.Buffer()
        self.source_view = GtkSource.View.new_with_buffer(self.source_buffer)
        self.source_language_manager = ServiceLocator.get_source_language_manager(
        )
        self.source_style_scheme_manager = ServiceLocator.get_source_style_scheme_manager(
        )
        if language == 'bibtex':
            self.source_language = self.source_language_manager.get_language(
                'bibtex')
        else:
            self.source_language = self.source_language_manager.get_language(
                'latex')
        self.source_buffer.set_language(self.source_language)
        self.update_syntax_scheme()

        self.scroll_to = None
        self.insert_position = 0

        self.synctex_tag_count = 0
        self.synctex_highlight_tags = dict()

        self.indentation_update = None
        self.indentation_tags = dict()

        self.placeholder_tag = self.source_buffer.create_tag('placeholder')
        self.placeholder_tag.set_property('background', '#fce94f')
        self.placeholder_tag.set_property('foreground', '#000')

        self.source_buffer.connect('mark-set', self.on_mark_set)
        self.source_buffer.connect('mark-deleted', self.on_mark_deleted)
        self.source_buffer.connect('insert-text', self.on_insert_text)
        self.source_buffer.connect('delete-range', self.on_delete_range)
        self.source_buffer.connect('changed', self.on_buffer_changed)
        self.source_buffer.connect('modified-changed',
                                   self.on_modified_changed)
        self.undo_manager = self.source_buffer.get_undo_manager()
        self.undo_manager.connect('can-undo-changed', self.on_can_undo_changed)
        self.undo_manager.connect('can-redo-changed', self.on_can_redo_changed)
        self.settings.connect('settings_changed', self.on_settings_changed)
Ejemplo n.º 24
0
    def __init__(self, document):
        Observable.__init__(self)

        self.is_enabled = False

        self.folding_regions = dict()
        self.folding_regions_by_region_id = dict()
        self.maximum_region_id = 0
        self.initial_folded_regions_set = False
        self.initial_folding_done = False
        self.initial_folding_regions_checked_count = 0

        self.document = document
        self.view = code_folding_view.CodeFoldingView()
        self.presenter = code_folding_presenter.CodeFoldingPresenter(
            self, self.view)
        self.controller = code_folding_controller.CodeFoldingController(self)

        self.on_buffer_changed(self.document.get_buffer())
Ejemplo n.º 25
0
    def __init__(self, document):
        Observable.__init__(self)
        self.document = document
        self.settings = ServiceLocator.get_settings()

        self.items = list()

        self.view = build_widget_view.BuildWidgetView()
        self.view.stop_button.connect('clicked',
                                      self.on_stop_build_button_click)
        self.view.clean_button.connect('clicked', self.on_clean_button_click)

        self.view.build_button.show_all()
        self.view.stop_button.hide()

        self.build_button_state = ('idle', int(time.time() * 1000))
        self.set_clean_button_state()

        self.document.register_observer(self)
        self.settings.register_observer(self)
Ejemplo n.º 26
0
    def __init__(self, workspace):
        Observable.__init__(self)

        self.workspace = workspace
        self.view = ServiceLocator.get_main_window().help_panel

        self.path = 'file://' + os.path.join(
            ServiceLocator.get_resources_path(), 'help')
        self.home_uri = self.path + '/latex2e_0.html'
        self.current_uri = self.home_uri

        with open(
                os.path.join(ServiceLocator.get_resources_path(), 'help',
                             'search_index.pickle'), 'rb') as filehandle:
            self.search_index = pickle.load(filehandle)

        self.search_results_blank = list()
        self.search_results = self.search_results_blank
        self.query = ''

        GLib.idle_add(self.activate, priority=GLib.PRIORITY_LOW)
Ejemplo n.º 27
0
    def __init__(self):
        Observable.__init__(self)
        self.pathname = ServiceLocator.get_config_folder()

        self.open_documents = list()
        self.open_latex_documents = list()
        self.master_document = None
        self.recently_opened_documents = dict()
        self.untitled_documents_no = 0

        self.active_document = None

        self.recently_opened_session_files = dict()
        self.session_file_opened = None

        self.settings = ServiceLocator.get_settings()
        self.inline_spellchecking = self.settings.get_value(
            'preferences', 'inline_spellchecking')
        self.spellchecking_language_code = self.settings.get_value(
            'preferences', 'spellchecking_language_code')
        self.dark_mode = self.settings.get_value('preferences',
                                                 'prefer_dark_mode')

        self.sidebar = sidebar.Sidebar()
        self.show_sidebar = self.settings.get_value('window_state',
                                                    'show_sidebar')
        self.sidebar_position = self.settings.get_value(
            'window_state', 'sidebar_paned_position')
        self.show_help = self.settings.get_value('window_state', 'show_help')
        self.show_preview = self.settings.get_value('window_state',
                                                    'show_preview')
        self.preview_position = self.settings.get_value(
            'window_state', 'preview_paned_position')
        self.build_log = build_log.BuildLog(self)
        self.show_build_log = self.settings.get_value('window_state',
                                                      'show_build_log')
        self.build_log_position = self.settings.get_value(
            'window_state', 'build_log_paned_position')
        self.shortcuts = shortcuts.Shortcuts(self)
Ejemplo n.º 28
0
    def __init__(self):
        Observable.__init__(self)

        self.font_manager = ServiceLocator.get_font_manager()

        self.displayname = ''
        self.filename = None
        self.save_date = None
        self.deleted_on_disk_dialog_shown_after_last_save = False
        self.last_activated = 0
        self.dark_mode = False
        self.is_root = False
        self.root_is_set = False

        self.symbols = dict()
        self.symbols['bibitems'] = set()
        self.symbols['labels'] = set()
        self.symbols['labels_with_offset'] = list()
        self.symbols['included_latex_files'] = set()
        self.symbols['bibliographies'] = set()
        self.symbols['packages'] = set()
        self.symbols['packages_detailed'] = dict()
        self.symbols['blocks'] = list()
Ejemplo n.º 29
0
    def __init__(self, preview):
        Observable.__init__(self)
        self.preview = preview
        self.maximum_rendered_pixels = 20000000

        self.visible_pages_lock = thread.allocate_lock()
        self.visible_pages = list()
        self.page_width = None
        self.pdf_date = None
        self.rendered_pages = dict()
        self.is_active_lock = thread.allocate_lock()
        self.is_active = False

        self.preview.connect('position_changed', self.on_layout_or_position_changed)
        self.preview.connect('layout_changed', self.on_layout_or_position_changed)

        self.page_render_count_lock = thread.allocate_lock()
        self.page_render_count = dict()
        self.render_queue = queue.Queue()
        self.render_queue_low_priority = queue.Queue()
        self.rendered_pages_queue = queue.Queue()
        thread.start_new_thread(self.render_page_loop, ())
        GObject.timeout_add(50, self.rendered_pages_loop)
Ejemplo n.º 30
0
    def __init__(self, preview, layouter):
        Observable.__init__(self)
        self.preview = preview
        self.layouter = layouter
        self.maximum_rendered_pixels = 20000000

        self.visible_pages_lock = thread.allocate_lock()
        self.visible_pages = list()
        self.page_width = None
        self.pdf_date = None
        self.rendered_pages = dict()
        self.is_active_lock = thread.allocate_lock()
        self.is_active = False

        self.preview.register_observer(self)
        self.layouter.register_observer(self)

        self.page_render_count_lock = thread.allocate_lock()
        self.page_render_count = dict()
        self.render_queue = queue.Queue()
        self.render_queue_low_priority = queue.Queue()
        self.rendered_pages_queue = queue.Queue()
        thread.start_new_thread(self.render_page_loop, ())
        GObject.timeout_add(50, self.rendered_pages_loop)