class TopinambourColorSelector
Attributes
colors[R]
Public Class Methods
new(window)
click to toggle source
Calls superclass method
# File lib/color_selector.rb, line 22 def initialize(window) @window = window super() reset_button = generate_reset_button attach(reset_button, 0, 0, 1, 1) initialize_default_colors add_color_selectors save_button = generate_save_button attach(save_button, 0, 1, 1, 1) import_button = generate_import_button attach(import_button, 10, 0, 1, 1) export_button = generate_export_button attach(export_button, 10, 1, 1, 1) show_all set_halign(:center) set_valign(:end) set_name("topinambour-color-selector") end
Private Instance Methods
add_color_selector(name, i, position=nil)
click to toggle source
# File lib/color_selector.rb, line 171 def add_color_selector(name, i, position=nil) color_sel = Gtk::ColorButton.new(@default_colors[i]) color_sel.title = name.to_s color_sel.name = "topinambour-button-#{name}" color_sel.tooltip_text = name.to_s color_sel.signal_connect "color-set" do @colors[i] = color_sel.rgba apply_new_colors end attach(color_sel, position[0], position[1], 1, 1) end
add_color_selectors()
click to toggle source
# File lib/color_selector.rb, line 183 def add_color_selectors add_color_selector("foreground", 0, [1, 0]) add_color_selector("background", 1, [1, 1]) TERMINAL_COLOR_NAMES.each_with_index do |name, i| add_color_selector(name, i + 2, [2 + i, 0]) end TERMINAL_COLOR_NAMES.each_with_index do |name, i| add_color_selector("bright#{name}", i + 10, [2 + i, 1]) end end
apply_new_colors()
click to toggle source
# File lib/color_selector.rb, line 195 def apply_new_colors @window.terminal.colors = @colors end
apply_new_properties()
click to toggle source
# File lib/color_selector.rb, line 155 def apply_new_properties colors_strings = @colors.map { |c| c.to_s } @window.application.settings["colorscheme"] = colors_strings @window.terminal.load_colors @window.terminal.load_settings end
double_to_hex(d)
click to toggle source
# File lib/color_selector.rb, line 94 def double_to_hex(d) (d * 255).to_i.to_s(16) end
initialize_default_colors()
click to toggle source
# File lib/color_selector.rb, line 126 def initialize_default_colors colors_strings = @window.application.settings["colorscheme"] @default_colors = colors_strings.map {|c| Gdk::RGBA.parse(c) } @colors = @default_colors.dup end
rgba_to_hex_string(rgba)
click to toggle source
# File lib/color_selector.rb, line 98 def rgba_to_hex_string(rgba) "##{double_to_hex(rgba.red)}#{double_to_hex(rgba.green)}#{double_to_hex(rgba.blue)}" end