class Gtk::CRUD

CRUDなリストビューを簡単に実現するためのクラス

Attributes

creatable[RW]
deletable[RW]
dialog_title[RW]
updatable[RW]

Public Class Methods

new() click to toggle source
Calls superclass method
# File core/mui/gtk_crud.rb, line 13
def initialize
  super()
  initialize_model
  @creatable = @updatable = @deletable = true
  set_columns
  # self.set_enable_search(true).set_search_column(1).set_search_equal_func{ |model, column, key, iter|
  #   not iter[column].include?(key) }
  handle_release_event
  handle_row_activated
end

Public Instance Methods

buttons(box_klass) click to toggle source
# File core/mui/gtk_crud.rb, line 24
def buttons(box_klass)
  box_klass.new(false, 4).closeup(create_button).closeup(update_button).closeup(delete_button) end
create_button() click to toggle source
# File core/mui/gtk_crud.rb, line 27
def create_button
  if not defined? @create_button
    @create_button = Gtk::Button.new(Gtk::Stock::ADD)
    @create_button.ssc(:clicked) {
      record_create(nil, nil) } end
  @create_button end
delete_button() click to toggle source
# File core/mui/gtk_crud.rb, line 41
def delete_button
  if not defined? @delete_button
    @delete_button = Gtk::Button.new(Gtk::Stock::DELETE)
    @delete_button.ssc(:clicked) {
      record_delete(nil, nil) } end
  @delete_button end
update_button() click to toggle source
# File core/mui/gtk_crud.rb, line 34
def update_button
  if not defined? @update_button
    @update_button = Gtk::Button.new(Gtk::Stock::EDIT)
    @update_button.ssc(:clicked) {
      record_update(nil, nil) } end
  @update_button end

Protected Instance Methods

handle_release_event() click to toggle source
# File core/mui/gtk_crud.rb, line 57
def handle_release_event
  self.signal_connect('button_release_event'){ |widget, event|
    if (event.button == 3)
      menu_pop(self, event)
      true end }
end
handle_row_activated() click to toggle source
# File core/mui/gtk_crud.rb, line 50
def handle_row_activated
  self.signal_connect("row-activated"){|view, path, column|
    if @updatable and iter = view.model.get_iter(path)
      if record = popup_input_window((0...model.n_columns).map{|i| iter[i] })
        force_record_update(iter, record) end end }
end
on_created(iter) click to toggle source
# File core/mui/gtk_crud.rb, line 64
def on_created(iter)
end
on_deleted(iter) click to toggle source
# File core/mui/gtk_crud.rb, line 70
def on_deleted(iter)
end
on_updated(iter) click to toggle source
# File core/mui/gtk_crud.rb, line 67
def on_updated(iter)
end