class GerminalCssEditor
Attributes
preview[RW]
tab_label[RW]
Public Class Methods
new(window)
click to toggle source
Calls superclass method
# File lib/css_editor.rb, line 19 def initialize(window) super() @window = window @provider = window.application.provider @default_css = @provider.to_s @modified_css = @default_css @tab_label = "Css Editor" gen_source_view sw = Gtk::ScrolledWindow.new(nil, nil) sw.vexpand = true sw.hexpand = true sw.add(@view) attach(sw, 0, 0, 3, 1) button = gen_reset_button attach(button, 0, 1, 1, 1) @style_button = gen_style_chooser_button attach(@style_button, 1, 1, 1, 1) button = gen_save_button attach(button, 2, 1, 1, 1) manage_buffer_changes manage_css_errors show_all end
Private Instance Methods
gen_source_view()
click to toggle source
# File lib/css_editor.rb, line 50 def gen_source_view @view = GtkSource::View.new @manager = GtkSource::LanguageManager.new @language = @manager.get_language("css") @sm = GtkSource::StyleSchemeManager.default @view.show_line_numbers = true @view.insert_spaces_instead_of_tabs = true @view.buffer.language = @language @view.buffer.highlight_syntax = true @view.buffer.highlight_matching_brackets = true @view.buffer.text = @default_css @view.show_right_margin = true @view.right_margin_position = 80 @view.smart_backspace = true end
manage_buffer_changes()
click to toggle source
# File lib/css_editor.rb, line 106 def manage_buffer_changes @view.buffer.signal_connect "changed" do |buffer| @modified_css = buffer.get_text(buffer.start_iter, buffer.end_iter, false) begin @provider.load_from_data(@modified_css) rescue @provider.load_from_data(@default_css) end reload_custom_css_properties Gtk::StyleContext.reset_widgets style_scheme = nil if @sm.scheme_ids.include?(@window.css_editor_style) style_scheme = @sm.get_scheme(@window.css_editor_style) else style_scheme = @sm.get_scheme("classic") end @view.buffer.style_scheme = style_scheme @style_button.style_scheme = style_scheme end end
manage_css_errors()
click to toggle source
# File lib/css_editor.rb, line 130 def manage_css_errors @provider.signal_connect "parsing-error" do |_css_provider, section, error| # @start_i = @view.buffer.get_iter_at(:line => section.start_line, # :index => section.start_position) # @end_i = @view.buffer.get_iter_at(:line => section.end_line, # :index => section.end_position) # if error == Gtk::CssProviderError::DEPRECATED # else # end end end
reload_custom_css_properties()
click to toggle source
# File lib/css_editor.rb, line 142 def reload_custom_css_properties reload_terminal_custom_css_properties reload_window_custom_css_properties end
reload_terminal_custom_css_properties()
click to toggle source
# File lib/css_editor.rb, line 147 def reload_terminal_custom_css_properties @window.notebook.each do |tab| next unless tab.class == GerminalTerminal colors = tab.get_css_colors unless colors tab.colors = colors tab.apply_colors end end
reload_window_custom_css_properties()
click to toggle source
# File lib/css_editor.rb, line 156 def reload_window_custom_css_properties @window.load_css_properties end