Class: JLDrill::Gtk::VocabularyWindow
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- JLDrill::Gtk::VocabularyWindow
show all
- Includes:
- Context::Gtk::Widget
- Defined in:
- lib/jldrill/views/gtk/widgets/VocabularyWindow.rb
Instance Attribute Summary collapse
#gtkWidgetMainWindow
Instance Method Summary
collapse
#addToThisWidget, #afterWidgetIsAdded, #afterWidgetIsRemoved, #expandWidgetHeight, #expandWidgetHeight?, #expandWidgetWidth, #expandWidgetWidth?, #gtkAddWidget, #gtkRemoveWidget, #isAMainWindow, #isInTests?, #removeFromThisWidget, #setupWidget, #widgetWasAddedTo, #widgetWasRemovedFrom
Constructor Details
Returns a new instance of VocabularyWindow.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 15
def initialize(view, label)
@view = view
@closed = false
super(label)
set_default_size(400, 500)
@vbox = Gtk::VBox.new
self.add(@vbox)
@vocabView = GtkVocabView.new(@view.vocabulary)
@vbox.add(@vocabView)
@searchTable = nil
@buttons = Gtk::HBox.new
@searchButton = Gtk::Button.new("Search")
@previewButton = Gtk::Button.new("Preview")
@addButton = Gtk::Button.new(label)
@buttons.pack_start(@searchButton, true, true, 5)
@buttons.pack_start(@previewButton, true, true, 5)
@buttons.pack_end(@addButton, true, true, 5)
@vbox.pack_end(@buttons, false, false)
connectSignals
end
|
Instance Attribute Details
Returns the value of attribute addButton.
13
14
15
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 13
def addButton
@addButton
end
|
Instance Method Details
#close ⇒ Object
82
83
84
85
86
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 82
def close
if !@closed
@view.close
end
end
|
#connectSignals ⇒ Object
36
37
38
39
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
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 36
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_D, Gdk::Window::CONTROL_MASK,
Gtk::ACCEL_VISIBLE) do
@view.loadDictionary
end
@accel.connect(Gdk::Keyval::GDK_S, Gdk::Window::CONTROL_MASK,
Gtk::ACCEL_VISIBLE) do
updateSearchTable
end
add_accel_group(@accel)
signal_connect('delete_event') do
false
end
signal_connect('destroy') do
self.close
end
@addButton.signal_connect('clicked') do
@view.action
end
@previewButton.signal_connect('clicked') do
preview
end
@searchButton.signal_connect('clicked') do
updateSearchTable
end
@vocabView.setAcceptReading do
updateSearchTable
end
@vocabView.setAcceptKanji do
updateSearchTable
end
end
|
#createSearchTable ⇒ Object
106
107
108
109
110
111
112
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 106
def createSearchTable
if @view.dictionaryLoaded?
@searchTable = SearchTable.new(self, self.kanji, self.reading)
@vbox.add(@searchTable)
@vbox.show_all
end
end
|
#definitions ⇒ Object
165
166
167
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 165
def definitions
@vocabView.definitions
end
|
#definitions=(string) ⇒ Object
169
170
171
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 169
def definitions=(string)
@vocabView.definitions=(string)
end
|
#explicitDestroy ⇒ Object
136
137
138
139
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 136
def explicitDestroy
@closed = true
self.destroy
end
|
#getVocab ⇒ Object
181
182
183
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 181
def getVocab
@vocabView.getVocab
end
|
#hint ⇒ Object
149
150
151
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 149
def hint
@vocabView.hint
end
|
#hint=(string) ⇒ Object
153
154
155
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 153
def hint=(string)
@vocabView.hint=(string)
end
|
#kanji ⇒ Object
141
142
143
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 141
def kanji
@vocabView.kanji
end
|
#kanji=(string) ⇒ Object
145
146
147
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 145
def kanji=(string)
@vocabView.kanji=(string)
end
|
#markers ⇒ Object
173
174
175
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 173
def markers
@vocabView.markers
end
|
#markers=(string) ⇒ Object
177
178
179
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 177
def markers=(string)
@vocabView.markers=(string)
end
|
#preview ⇒ Object
132
133
134
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 132
def preview
@view.preview(JLDrill::Item.create(getVocab.to_s))
end
|
#reading ⇒ Object
157
158
159
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 157
def reading
@vocabView.reading
end
|
#reading=(string) ⇒ Object
161
162
163
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 161
def reading=(string)
@vocabView.reading=(string)
end
|
#removeSearchTable ⇒ Object
88
89
90
91
92
93
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 88
def removeSearchTable
if !@searchTable.nil?
@vbox.remove(@searchTable)
@searchTable = nil
end
end
|
#search(kanji, reading) ⇒ Object
Callback from the Search table
96
97
98
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 96
def search(kanji, reading)
@view.search(self.kanji, self.reading)
end
|
#searchActivated(item) ⇒ Object
Callback from the Search table
101
102
103
104
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 101
def searchActivated(item)
@vocabView.setDictionaryVocab(item.toVocab)
@addButton.grab_focus
end
|
#selectClosestMatch ⇒ Object
114
115
116
117
118
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 114
def selectClosestMatch
if !@searchTable.nil?
@searchTable.selectClosestMatch(getVocab)
end
end
|
#setFocus ⇒ Object
189
190
191
192
193
194
195
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 189
def setFocus
if !@searchTable.nil? && @searchTable.hasSelection?
@searchTable.focusTable
else
@vocabView.focusReading
end
end
|
#showBusy(bool) ⇒ Object
197
198
199
200
201
202
203
204
205
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 197
def showBusy(bool)
@vocabView.showBusy(bool)
if bool
self.window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::WATCH))
else
self.window.set_cursor(nil)
end
Gdk::flush()
end
|
#update(vocab) ⇒ Object
185
186
187
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 185
def update(vocab)
@vocabView.setVocab(vocab)
end
|
#updateSearchTable ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/jldrill/views/gtk/widgets/VocabularyWindow.rb', line 120
def updateSearchTable
if @searchTable.nil? ||
(self.reading != @searchTable.reading) ||
(self.kanji != @searchTable.kanji)
removeSearchTable
createSearchTable
end
selectClosestMatch
end
|