Method: TopinambourApplication#reload_css_config

Defined in:
lib/application.rb

#reload_css_configObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/application.rb', line 70

def reload_css_config
  error_popup = nil
  bad_css = nil
  css_file = check_css_file_path
  if css_file
    @provider.signal_connect "parsing-error" do |css_provider, section, error|
      buf = Gtk::TextBuffer.new
      buf.text = @css_content
      start_i = buf.get_iter_at(:line => section.start_line,
                                :index => section.start_position)
      end_i =  buf.get_iter_at(:line => section.start_line + 10,
                               :index => section.end_position)
      bad_css = ""
      buf.get_text(start_i, end_i, true).lines.each_with_index do |line, i|
        bad_css += "#{section.start_line  + 1 + i}  #{line}"
      end
    end

    begin
      load_custom_css(css_file)
    rescue => e
      self.windows.first.exit_overlay_mode
      # TODO : deal with the preferences window which is a transient one
      # that keeps the focus even when the popup shows up.
      error_popup = TopinambourCssErrorPopup.new(self.windows.first)
      error_popup.transient_for = self.windows.first
      error_popup.message = e.message + "\n\n" + bad_css
      error_popup.show_all
    end
  end
end