Class: TopinambourApplication
- Inherits:
-
Gtk::Application
- Object
- Gtk::Application
- TopinambourApplication
- Defined in:
- lib/application.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #check_css_file_path ⇒ Object
-
#initialize ⇒ TopinambourApplication
constructor
A new instance of TopinambourApplication.
- #reload_css_config ⇒ Object
Constructor Details
#initialize ⇒ TopinambourApplication
Returns a new instance of TopinambourApplication.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/application.rb', line 21 def initialize = {} @exit_status = 0 super("com.github.cedlemo.topinambour", [:non_unique, :handles_command_line]) signal_connect "startup" do |application| ENV["GSETTINGS_SCHEMA_DIR"] = DATA_PATH @settings = Gio::Settings.new("com.github.cedlemo.topinambour") initialize_css_provider load_css_config TopinambourActions.add_actions_to(application) (application) end signal_connect "activate" do |application| window = TopinambourWindow.new(application) window.present if [:execute] [:execute].each do |cmd| window.add_terminal(cmd) window.notebook.current.term.custom_title = cmd window.current_label.text = cmd end else window.add_terminal end end signal_connect "command-line" do |_application, command_line| begin parse_command_line(command_line.arguments) rescue SystemExit => error error.status rescue OptionParser::InvalidOption => error STDERR.puts error. 1 rescue => error STDERR.puts "#{error.class}: #{error.message}" STDERR.puts error.backtrace 1 else activate @exit_status end end end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
20 21 22 |
# File 'lib/application.rb', line 20 def settings @settings end |
Instance Method Details
#check_css_file_path ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/application.rb', line 103 def check_css_file_path css_file = if File.exist?(@settings["css-file"]) @settings["css-file"] else "#{CONFIG_DIR}/#{@settings["css-file"]}" end File.exist?(css_file) ? css_file : nil end |
#reload_css_config ⇒ Object
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 101 |
# File 'lib/application.rb', line 71 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. # 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. = e. + "\n\n" + bad_css error_popup.show_all end end end |