Class: GerminalColorSelector

Inherits:
Gtk::Box
  • Object
show all
Defined in:
lib/color_selector.rb

Overview

Copyright 2015-2016 Cédric LE MOIGNE, [email protected] 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/>.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ GerminalColorSelector

Returns a new instance of GerminalColorSelector.



18
19
20
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
# 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
    get_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)
  
  get_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

Instance Attribute Details

#colorsObject (readonly)

Returns the value of attribute colors.



17
18
19
# File 'lib/color_selector.rb', line 17

def colors
  @colors
end