Class: TECSCDE::Palette

Inherits:
Object show all
Defined in:
lib/tecscde/palette.rb

Instance Method Summary collapse

Constructor Details

#initialize(control) ⇒ Palette

control::TECSCDE::Control



59
60
61
62
63
# File 'lib/tecscde/palette.rb', line 59

def initialize(control)
  @control = control
  setup
  @window.show_all
end

Instance Method Details

#set_view(view) ⇒ Object



168
169
170
171
172
# File 'lib/tecscde/palette.rb', line 168

def set_view(view)
  @window.set_transient_for(view.get_window)
  @window.window.set_group(view.get_window.window)
  @window.window.raise
end

#setupObject



65
66
67
68
69
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/tecscde/palette.rb', line 65

def setup
  @builder = Gtk::Builder.new
  @builder.add_from_file(File.join(__dir__, "palette.glade"))

  #----- window -----#
  @window = @builder["window_palette"]
  @window.realize
  # @window.type = ( Gtk::Window::TOPLEVEL )
  @window.window.set_functions(Gdk::Window::FUNC_RESIZE | Gdk::Window::FUNC_MOVE)

  setup_menubar

  #----- pointer BUTTON -----#
  @button_pointer = @builder["togglebutton_pointer"]
  @button_pointer.signal_connect("clicked") do
    @control.on_pointer
    # @button_pointer.active = true
    @button_new_cell.active = false
    false
  end

  #----- new cell BUTTON -----#
  @button_new_cell = @builder["togglebutton_new_cell"]
  @button_new_cell.signal_connect("clicked") do
    @control.on_new_cell
    # @button_new_cell.active = true
    @button_pointer.active = false
    false
  end

  #----- undo BUTTON -----#
  @button_undo = @builder["button_undo"]
  @button_undo.signal_connect("clicked") { @control.on_undo }

  #----- redo BUTTON -----#
  @button_redo = @builder["button_redo"]
  @button_redo.signal_connect("clicked") { @control.on_redo }
  # currently redo doesn't work well
  @button_redo.set_sensitive(false)

  #----- celltype TREEVIEW -----#
  @tree_view_celltype = @builder["treeview_celltype"]
  @celltype_tree_view = CelltypeTreeView.new(@tree_view_celltype)

  #-----  -----#
  @frame_cell = @builder["frame_cell"]

  #----- cell name ENTRY -----#
  @entry_cell_name = @builder["entry_cell_name"]
  @entry_cell_name.signal_connect("activate") do |entry|
    @control.on_cell_name_entry_active(entry)
    false
  end
  @entry_cell_name.signal_connect("focus-out-event") do |entry, _event|
    @control.on_cell_name_entry_focus_out(entry)
    false
  end

  @entry_cell_region = @builder["entry_cell_region"]
  @entry_cell_region.signal_connect("activate") do |entry|
    @control.on_cell_region_entry_active(entry)
    false
  end
  @entry_cell_region.signal_connect("focus-out-event") do |entry, _event|
    @control.on_cell_region_entry_focus_out(entry)
    false
  end

  @treeview_cell_attribute = @builder["treeview_cell_attribute"]
  @attr_tree_view = AttrTreeView.new(@treeview_cell_attribute)

  @control.set_attr_operation_widgets(@window, @celltype_tree_view, @attr_tree_view, @entry_cell_name, @entry_cell_region, @frame_cell)
end

#setup_menubarObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/tecscde/palette.rb', line 139

def setup_menubar
  @builder["menuitem-save"].signal_connect("activate") do
    @control.on_save
  end

  @builder["menuitem-export"].signal_connect("activate") do
    @control.on_export
  end

  @builder["menuitem-preferences"].signal_connect("activate") do
    preferences = TECSCDE::Preferences.new(@control)
    preferences.run
  end

  @builder["menuitem-quit"].signal_connect("activate") do
    @control.on_quit
  end

  @builder["menuitem-undo"].signal_connect("activate") do
    @control.on_undo
  end

  @builder["menuitem-redo"].signal_connect("activate") do
    @control.on_redo
  end
  # currently redo doesn't work well
  @builder["menuitem-redo"].sensitive = false
end