本文整理汇总了Python中gi.repository.GtkSource.StyleSchemeManager方法的典型用法代码示例。如果您正苦于以下问题:Python GtkSource.StyleSchemeManager方法的具体用法?Python GtkSource.StyleSchemeManager怎么用?Python GtkSource.StyleSchemeManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GtkSource
的用法示例。
在下文中一共展示了GtkSource.StyleSchemeManager方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_buffer
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def new_buffer(self):
style_scheme_manager = GtkSource.StyleSchemeManager()
b = GtkSource.Buffer()
b.set_language(self.language_manager.get_language(self.language))
b.set_highlight_syntax(True)
user_editor_style = global_gui_config.get_config_value(self.editor_style, "classic")
if user_editor_style.startswith("rafcon"):
user_editor_style = "rafcon"
dark_theme = global_gui_config.get_config_value('THEME_DARK_VARIANT', True)
if dark_theme:
user_editor_style = "rafcon-dark"
scheme = style_scheme_manager.get_scheme(user_editor_style)
if scheme:
self.style_scheme = scheme
else:
logger.debug("The editor style '{}' is not supported. Using the default 'classic'".format(
user_editor_style))
self.style_scheme = style_scheme_manager.get_scheme('classic')
b.set_style_scheme(self.style_scheme)
return b
示例2: __init__
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def __init__(self, parentWindow):
self.parentWindow = parentWindow
builder = get_ui("scriptpage.xml")
self.ui = builder.get_object("scriptpage")
builder.connect_signals(self)
self.buffer = GtkSource.Buffer()
self.buffer.connect("changed", self.on_modified)
self.editor = GtkSource.View.new_with_buffer(self.buffer)
scrolledWindow = builder.get_object("scrolledWindow")
scrolledWindow.add(self.editor)
# Editor font
settings = Gio.Settings.new("org.gnome.desktop.interface")
fontDesc = Pango.font_description_from_string(settings.get_string("monospace-font-name"))
self.editor.modify_font(fontDesc)
self.promptCheckbox = builder.get_object("promptCheckbox")
self.showInTrayCheckbox = builder.get_object("showInTrayCheckbox")
self.linkButton = builder.get_object("linkButton")
label = self.linkButton.get_child()
label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
vbox = builder.get_object("settingsVbox")
self.settingsWidget = SettingsWidget(parentWindow)
vbox.pack_start(self.settingsWidget.ui, False, False, 0)
# Configure script editor
self.__m = GtkSource.LanguageManager()
self.__sm = GtkSource.StyleSchemeManager()
self.buffer.set_language(self.__m.get_language("python"))
self.buffer.set_style_scheme(self.__sm.get_scheme("classic"))
self.editor.set_auto_indent(True)
self.editor.set_smart_home_end(True)
self.editor.set_insert_spaces_instead_of_tabs(True)
self.editor.set_tab_width(4)
self.ui.show_all()
示例3: _setup_color_schemes
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def _setup_color_schemes(self):
chooser = GtkSource.StyleSchemeChooserWidget()
sw = self.builder.get_object('sw_color_schemes')
sw.add(chooser)
sm = GtkSource.StyleSchemeManager()
chooser.set_style_scheme(
sm.get_scheme(self.config.ui_style_scheme))
chooser.connect(
'notify::style-scheme',
lambda *a: self._sp('ui-style-scheme',
chooser.get_style_scheme().get_id()))
self._chooser_color_scheme = chooser
示例4: _setup_style_scheme
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def _setup_style_scheme(self):
sm = GtkSource.StyleSchemeManager()
def set_theme(*args):
self.buffer.set_style_scheme(
sm.get_scheme(self._config.ui_style_scheme))
set_theme()
self._config.connect('notify::ui-style-scheme', set_theme)
示例5: __init__
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def __init__(self):
GtkSource.View.__init__(self)
self.set_hexpand(True)
self.set_vexpand(True)
# create buffer
self.buf = self.get_buffer()
# setup style and lang managers
self.lm = GtkSource.LanguageManager()
self.sm = GtkSource.StyleSchemeManager()
self.lm.set_search_path([LANGDIR])
self.sm.set_search_path([STYLEDIR])
self.buf.set_style_scheme(self.sm.get_scheme('gcode'))
self.buf.set_language(self.lm.get_language('gcode'))
self.buf.set_max_undo_levels(20)
self.set_show_line_numbers(True)
self.set_show_line_marks(False)
self.set_highlight_current_line(False)
self.connect('key-press-event', self.on_key_press)
# Set line highlight styles
self.add_mark_category('error', '#ff7373')
self.add_mark_category('motion', '#c5c5c5')
self.add_mark_category('selected', '#96fef6')
self.mark = None
self.current_file = None
self.error_line = None
self.show()
示例6: __init__
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def __init__(self, *args, **kwargs):
self.label = Gtk.Label(label='Edit')
"""The :py:class:`Gtk.Label` representing this tabs name."""
super(MailSenderEditTab, self).__init__(*args, **kwargs)
self.textview = self.gobjects['view_html_file']
"""The :py:class:`Gtk.TextView` object of the editor."""
self.textbuffer = GtkSource.Buffer()
"""The :py:class:`Gtk.TextBuffer` used by the :py:attr:textview` attribute."""
self.textview.set_buffer(self.textbuffer)
self.language_manager = GtkSource.LanguageManager()
self.textbuffer.set_language(self.language_manager.get_language('html'))
self.textbuffer.set_highlight_syntax(True)
self.textview.modify_font(Pango.FontDescription(self.config['text_font']))
self.textview.set_property('highlight-current-line', self.config.get('text_source.highlight_line', True))
self.textview.set_property('indent-width', self.config.get('text_source.tab_width', 4))
self.textview.set_property('insert-spaces-instead-of-tabs', not self.config.get('text_source.hardtabs', False))
self.textview.set_property('tab-width', self.config.get('text_source.tab_width', 4))
wrap_mode = self.config.get('text_source.wrap_mode', 'NONE')
if wrap_mode.startswith('GTK_WRAP_'):
wrap_mode = wrap_mode[9:]
if wrap_mode.upper() in ('CHAR', 'NONE', 'WORD', 'WORD_CHAR'):
self.textview.set_property('wrap-mode', getattr(Gtk.WrapMode, wrap_mode.upper()))
else:
self.logger.warning("invalid GtkWrapMode: {0!r}".format(wrap_mode))
self.toolbutton_save_html_file = self.gobjects['toolbutton_save_html_file']
self.textview.connect('populate-popup', self.signal_textview_populate_popup)
self.textview.connect('key-press-event', self.signal_textview_key_pressed)
scheme_manager = GtkSource.StyleSchemeManager()
style_scheme_name = self.config['text_source.theme']
style_scheme = scheme_manager.get_scheme(style_scheme_name)
if style_scheme:
self.textbuffer.set_style_scheme(style_scheme)
else:
self.logger.error("invalid GTK source theme: '{0}'".format(style_scheme_name))
self.file_monitor = None
source_completion = self.textview.get_completion()
source_completion.set_property('accelerators', 0)
source_completion.set_property('auto-complete-delay', 250)
source_completion.set_property('show-icons', False)
source_completion.add_provider(completion_providers.HTMLCompletionProvider())
source_completion.add_provider(completion_providers.JinjaEmailCompletionProvider())
示例7: __init__
# 需要导入模块: from gi.repository import GtkSource [as 别名]
# 或者: from gi.repository.GtkSource import StyleSchemeManager [as 别名]
def __init__(self, application, file_path, directory):
"""
This class is used to set up the Gtk.SourceView instance to edit the file
:param application: The main client application instance.
:type application: :py:class:`Gtk.Application`
:param str file_path: the path of the file to edit
:param directory: the local or remote directory instance
"""
self.application = application
# get editor tab objects
self.file_location = directory.location
self.file_path = file_path
self.file_contents = None
self.directory = directory
config = self.application.config
self.sourceview_editor = sftp_utilities.get_object('SFTPClient.notebook.page_editor.sourceview')
self.save_button = sftp_utilities.get_object('SFTPClient.notebook.page_editor.toolbutton_save_html_file')
self.template_button = sftp_utilities.get_object('SFTPClient.notebook.page_editor.toolbutton_template_wiki')
self.template_button.connect('clicked', self.signal_template_help)
self.statusbar = sftp_utilities.get_object('SFTPClient.notebook.page_editor.statusbar')
# set up sourceview for editing
self.sourceview_buffer = GtkSource.Buffer()
self.sourceview_buffer.connect('changed', self.signal_buff_changed)
self.sourceview_editor.set_buffer(self.sourceview_buffer)
self.sourceview_editor.modify_font(Pango.FontDescription(config['text_font']))
language_manager = GtkSource.LanguageManager()
self.sourceview_buffer.set_language(language_manager.get_language('html'))
self.sourceview_buffer.set_highlight_syntax(True)
self.sourceview_editor.set_property('highlight-current-line', config.get('text_source.highlight_line', True))
self.sourceview_editor.set_property('indent-width', config.get('text_source.tab_width', 4))
self.sourceview_editor.set_property('insert-spaces-instead-of-tabs', not config.get('text_source.hardtabs', False))
self.sourceview_editor.set_property('tab-width', config.get('text_source.tab_width', 4))
scheme_manager = GtkSource.StyleSchemeManager()
style_scheme_name = config.get('text_source.theme', 'cobalt')
style_scheme = scheme_manager.get_scheme(style_scheme_name)
if style_scheme:
self.sourceview_buffer.set_style_scheme(style_scheme)
else:
logger.error("invalid GTK source theme: '{0}'".format(style_scheme_name))
self.view_completion = self.sourceview_editor.get_completion()
self.view_completion.set_property('accelerators', 0)
self.view_completion.set_property('auto-complete-delay', 250)
self.view_completion.set_property('show-icons', False)
if not self.view_completion.get_providers():
self.view_completion.add_provider(completion_providers.HTMLCompletionProvider())
self.view_completion.add_provider(completion_providers.JinjaPageCompletionProvider())
logger.info('successfully loaded HTML and Jinja completion providers')