Class: JLDrill::Gtk::ItemTableWindow
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- JLDrill::Gtk::ItemTableWindow
- Includes:
- Context::Gtk::Widget
- Defined in:
- lib/jldrill/views/gtk/widgets/ItemTableWindow.rb
Instance Attribute Summary
Attributes included from Context::Gtk::Widget
Instance Method Summary collapse
- #addItem(item) ⇒ Object
- #close ⇒ Object
- #connectSignals ⇒ Object
- #deleteCurrentItem ⇒ Object
- #editCurrentItem ⇒ Object
- #explicitDestroy ⇒ Object
-
#initialize(view) ⇒ ItemTableWindow
constructor
A new instance of ItemTableWindow.
- #markCut ⇒ Object
- #markPaste ⇒ Object
- #moveCurrentItemDown ⇒ Object
- #moveCurrentItemUp ⇒ Object
- #preview ⇒ Object
- #removeItem(item) ⇒ Object
- #searching? ⇒ Boolean
-
#select(item) ⇒ Object
Select the item in the table if it exists.
- #showBusy(bool) ⇒ Object
- #updateItem(item) ⇒ Object
- #updateTable(items) ⇒ Object
Methods included from Context::Gtk::Widget
#addToThisWidget, #afterWidgetIsAdded, #afterWidgetIsRemoved, #expandWidgetHeight, #expandWidgetHeight?, #expandWidgetWidth, #expandWidgetWidth?, #gtkAddWidget, #gtkRemoveWidget, #isAMainWindow, #isInTests?, #removeFromThisWidget, #setupWidget, #widgetWasAddedTo, #widgetWasRemovedFrom
Constructor Details
#initialize(view) ⇒ ItemTableWindow
Returns a new instance of ItemTableWindow.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 10 def initialize(view) @view = view @context = @view.context @closed = false super("All Vocabulary") self.set_default_size(450, 300) @vbox = Gtk::VBox.new self.add(@vbox) @frame = Gtk::HBox.new @vbox.pack_start(@frame, true, true, 5) @sideButtons = Gtk::VBox.new @frame.pack_end(@sideButtons, true, true, 5) @previewButton = Gtk::Button.new("Preview (P)") @sideButtons.pack_start(@previewButton, false, false, 5) @editButton = Gtk::Button.new("Edit (E)") @sideButtons.pack_start(@editButton, false, false, 5) @deleteButton = Gtk::Button.new("Delete (D)") @sideButtons.pack_start(@deleteButton, false, false, 5) @upButton = Gtk::Button.new("Move Up (Shift-Up)") @sideButtons.pack_start(@upButton, false, false, 5) @downButton = Gtk::Button.new("Move Down (Shift-Down)") @sideButtons.pack_start(@downButton, false, false, 5) @vocabTable = nil @buttons = Gtk::HBox.new @exitButton = Gtk::Button.new("Exit") @buttons.pack_end(@exitButton, true, true, 5) @vbox.pack_end(@buttons, false, false) connectSignals end |
Instance Method Details
#addItem(item) ⇒ Object
149 150 151 152 153 154 155 156 157 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 149 def addItem(item) if !item.nil? if @vocabTable.nil? updateTable([item]) else @vocabTable.addItem(item) end end end |
#close ⇒ Object
130 131 132 133 134 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 130 def close if !@closed @view.close end end |
#connectSignals ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 40 def connectSignals @accel = Gtk::AccelGroup.new @accel.connect(Gdk::Keyval::GDK_Escape, 0, Gtk::ACCEL_VISIBLE) do self.close end @accel.connect(Gdk::Keyval::GDK_E, 0, Gtk::ACCEL_VISIBLE) do if !searching? self.editCurrentItem end end @accel.connect(Gdk::Keyval::GDK_D, 0, Gtk::ACCEL_VISIBLE) do self.deleteCurrentItem end @accel.connect(Gdk::Keyval::GDK_P, 0, Gtk::ACCEL_VISIBLE) do if !searching? self.preview end end @accel.connect(Gdk::Keyval::GDK_Up, Gdk::Window::SHIFT_MASK, Gtk::ACCEL_VISIBLE) do if !searching? self.moveCurrentItemUp end end @accel.connect(Gdk::Keyval::GDK_Down, Gdk::Window::SHIFT_MASK, Gtk::ACCEL_VISIBLE) do if !searching? self.moveCurrentItemDown end end @accel.connect(Gdk::Keyval::GDK_X, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE) do if !searching? self.markCut end end @accel.connect(Gdk::Keyval::GDK_V, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE) do if !searching? self.markPaste end end add_accel_group(@accel) signal_connect('delete_event') do # Request that the destroy signal be sent false end signal_connect('destroy') do self.close end @exitButton.signal_connect('clicked') do self.close end @previewButton.signal_connect('clicked') do self.preview end @editButton.signal_connect('clicked') do self.editCurrentItem end @deleteButton.signal_connect('clicked') do self.deleteCurrentItem end @upButton.signal_connect('clicked') do self.moveCurrentItemUp end @downButton.signal_connect('clicked') do self.moveCurrentItemDown end end |
#deleteCurrentItem ⇒ Object
179 180 181 182 183 184 185 186 187 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 179 def deleteCurrentItem if !@vocabTable.nil? item = @vocabTable.getSelectedItem if !item.nil? @vocabTable.stopSearching @context.delete(item) end end end |
#editCurrentItem ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 169 def editCurrentItem if !@vocabTable.nil? item = @vocabTable.getSelectedItem if !item.nil? @vocabTable.stopSearching @context.edit(item) end end end |
#explicitDestroy ⇒ Object
211 212 213 214 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 211 def explicitDestroy @closed = true self.destroy end |
#markCut ⇒ Object
224 225 226 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 224 def markCut @vocabTable.markCut end |
#markPaste ⇒ Object
228 229 230 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 228 def markPaste @vocabTable.pasteBefore end |
#moveCurrentItemDown ⇒ Object
220 221 222 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 220 def moveCurrentItemDown @vocabTable.moveDown end |
#moveCurrentItemUp ⇒ Object
216 217 218 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 216 def moveCurrentItemUp @vocabTable.moveUp end |
#preview ⇒ Object
204 205 206 207 208 209 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 204 def preview item = @vocabTable.getSelectedItem if !item.nil? @context.preview(item) end end |
#removeItem(item) ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 159 def removeItem(item) if !item.nil? if @vocabTable.nil? updateTable([item]) else @vocabTable.removeItem(item) end end end |
#searching? ⇒ Boolean
126 127 128 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 126 def searching? return !@vocabTable.nil? && @vocabTable.searching? end |
#select(item) ⇒ Object
Select the item in the table if it exists
137 138 139 140 141 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 137 def select(item) if !item.nil? && !@vocabTable.nil? @vocabTable.selectItem(item) end end |
#showBusy(bool) ⇒ Object
232 233 234 235 236 237 238 239 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 232 def showBusy(bool) if bool self.window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::WATCH)) else self.window.set_cursor(nil) end Gdk::flush() end |
#updateItem(item) ⇒ Object
143 144 145 146 147 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 143 def updateItem(item) if !item.nil? && !@vocabTable.nil? @vocabTable.updateItem(item) end end |
#updateTable(items) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/jldrill/views/gtk/widgets/ItemTableWindow.rb', line 189 def updateTable(items) if !@vocabTable.nil? @frame.remove(@vocabTable) end if !items.empty? @vocabTable = ItemTable.new(items) do |item| @vocabTable.stopSearching @context.edit(item) end @frame.pack_start(@vocabTable, true, true) @vocabTable.focusTable end @vbox.show_all end |