smartdict-gtk 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/smartdict/gui/controller.rb +21 -23
  3. metadata +6 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -34,7 +34,7 @@ module Smartdict::Gui
34
34
  @interchange_button = InterchangeButton.new(self)
35
35
  @word_list = WordList.new(self)
36
36
 
37
- @db_mutex = Mutex.new
37
+ @mutex = Mutex.new
38
38
 
39
39
  load_history
40
40
  end
@@ -50,25 +50,11 @@ module Smartdict::Gui
50
50
  end
51
51
 
52
52
  def translate
53
- safe_concurrent_run do
54
- word = @word_entry.text.strip.downcase
55
- from_lang = @translator.default_opts[:from_lang]
56
- to_lang = @translator.default_opts[:to_lang]
57
-
58
- if add_to_history?(word, from_lang, to_lang)
59
- translation = @translator.translate(word)
60
- add_to_history(translation)
61
- else
62
- translation = @translator.translate(word, :log => false)
53
+ Thread.new do
54
+ @mutex.synchronize do
55
+ _translate
63
56
  end
64
-
65
- @text_view.show_translation(translation)
66
- @word_list.scroll_up
67
57
  end
68
- rescue Smartdict::TranslationNotFound => error
69
- @text_view.buffer.text = error.message
70
- rescue Exception => error
71
- @text_view.show_error(error)
72
58
  end
73
59
 
74
60
  # @param [String] word
@@ -124,12 +110,24 @@ module Smartdict::Gui
124
110
  end
125
111
  end
126
112
 
127
- def safe_concurrent_run
128
- Thread.new do
129
- @db_mutex.synchronize do
130
- yield
131
- end
113
+ def _translate
114
+ word = @word_entry.text.strip.downcase
115
+ from_lang = @translator.default_opts[:from_lang]
116
+ to_lang = @translator.default_opts[:to_lang]
117
+
118
+ if add_to_history?(word, from_lang, to_lang)
119
+ translation = @translator.translate(word)
120
+ add_to_history(translation)
121
+ else
122
+ translation = @translator.translate(word, :log => false)
132
123
  end
124
+
125
+ @text_view.show_translation(translation)
126
+ @word_list.scroll_up
127
+ rescue Smartdict::TranslationNotFound => error
128
+ @text_view.buffer.text = error.message
129
+ rescue Exception => error
130
+ @text_view.show_error(error)
133
131
  end
134
132
 
135
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartdict-gtk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: smartdict-core
@@ -217,6 +217,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  - - ! '>='
218
218
  - !ruby/object:Gem::Version
219
219
  version: '0'
220
+ segments:
221
+ - 0
222
+ hash: 3712988387274917201
220
223
  required_rubygems_version: !ruby/object:Gem::Requirement
221
224
  none: false
222
225
  requirements:
@@ -225,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
228
  version: '0'
226
229
  requirements: []
227
230
  rubyforge_project:
228
- rubygems_version: 1.8.24
231
+ rubygems_version: 1.8.21
229
232
  signing_key:
230
233
  specification_version: 3
231
234
  summary: GTK GUI for Smartdict dictionary