class GerminalColorSelector
Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com This file is part of Germinal.
Germinal is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
Germinal is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Germinal. If not, see <www.gnu.org/licenses/>.
Attributes
colors[R]
Public Class Methods
new(window)
click to toggle source
Calls superclass method
# File lib/color_selector.rb, line 18 def initialize(window) @window = window super(:horizontal, 0) reset_button = Gtk::Button.new(:label => "Reset") reset_button.signal_connect "clicked" do initialize_default_colors children[1..-2].each_with_index do |child, i| child.rgba = @default_colors[i] end apply_new_colors end pack_start(reset_button, :expand => false, :fill => false, :padding => 0) initialize_default_colors add_color_selectors save_button = Gtk::Button.new(:label => "Save") save_button.signal_connect "clicked" do new_props = {} TERMINAL_COLOR_NAMES.each_with_index do |c, i| new_props["-GerminalTerminal-#{c}"] = @colors[i].to_s end toplevel.application.update_css(new_props) toplevel.notebook.each do |tab| if tab.class == GerminalTerminal tab.colors = @colors tab.apply_colors end end toplevel.exit_overlay_mode end pack_start(save_button, :expand => false, :fill => false, :padding => 0) show_all set_halign(:center) set_valign(:end) set_name("color_selector") end
Private Instance Methods
add_color_selectors()
click to toggle source
# File lib/color_selector.rb, line 65 def add_color_selectors TERMINAL_COLOR_NAMES.each_with_index do |name, i| color_sel = Gtk::ColorButton.new(@default_colors[i]) color_sel.set_title(name.to_s) color_sel.signal_connect "color-set" do @colors[i] = color_sel.rgba apply_new_colors end pack_start(color_sel, :expand => false, :fill => false, :padding => 0) end end
apply_new_colors()
click to toggle source
# File lib/color_selector.rb, line 77 def apply_new_colors @window.notebook.current.colors = @colors @window.notebook.current.apply_colors end
initialize_default_colors()
click to toggle source
# File lib/color_selector.rb, line 60 def initialize_default_colors @default_colors = @window.notebook.current.get_css_colors @colors = @default_colors.dup end