aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshiaki Asai <toshi.alternative@gmail.com>2017-11-21 00:33:36 +0900
committerToshiaki Asai <toshi.alternative@gmail.com>2017-11-26 20:04:03 +0900
commitfefb0f3368cc880e8878316ecd074a046718c4f6 (patch)
treeba0237a09e294eee41f365778989679c18684aa8
parent3247d19a056ce6c53acabf66147f39332689926f (diff)
downloadmikutter-fefb0f3368cc880e8878316ecd074a046718c4f6.tar.gz
search spellを実装
-rw-r--r--core/plugin/search/.mikutter.yml1
-rw-r--r--core/plugin/search/search.rb6
-rw-r--r--core/plugin/spell/struct.rb2
3 files changed, 7 insertions, 2 deletions
diff --git a/core/plugin/search/.mikutter.yml b/core/plugin/search/.mikutter.yml
index 179ae011..876d3260 100644
--- a/core/plugin/search/.mikutter.yml
+++ b/core/plugin/search/.mikutter.yml
@@ -8,6 +8,7 @@ depends:
- uitranslator
- skin
- twitter
+ - spell
version: '1.0'
author: toshi_a
name: 検索
diff --git a/core/plugin/search/search.rb b/core/plugin/search/search.rb
index c05e4dca..bc6d9932 100644
--- a/core/plugin/search/search.rb
+++ b/core/plugin/search/search.rb
@@ -6,6 +6,10 @@ Plugin.create :search do
Plugin.call(:search_start, token.model.query)
end
+ defspell(:search, :twitter) do |twitter, options|
+ twitter.search(options)
+ end
+
querybox = ::Gtk::Entry.new()
querycont = ::Gtk::VBox.new(false, 0)
searchbtn = ::Gtk::Button.new(_('検索'))
@@ -37,7 +41,7 @@ Plugin.create :search do
searchbtn.signal_connect('clicked'){ |elm|
elm.sensitive = querybox.sensitive = false
timeline(:search).clear
- Service.primary.search(q: querybox.text, count: 100).next{ |res|
+ spell(:search, Service.primary, q: querybox.text, count: 100).next{ |res|
timeline(:search) << res if res.is_a? Array
elm.sensitive = querybox.sensitive = true
}.trap{ |e|
diff --git a/core/plugin/spell/struct.rb b/core/plugin/spell/struct.rb
index 039a8c01..39ddc1cf 100644
--- a/core/plugin/spell/struct.rb
+++ b/core/plugin/spell/struct.rb
@@ -4,7 +4,7 @@ module Plugin::Spell
Spell = Struct.new(:name, :constraint, :condition, :proc) do
def match(models, optional)
- Set.new(constraint.map{|a| Diva::Model(a) }) == Set.new(models.map{|a| a.class }) and condition?(models)
+ Set.new(constraint.map{|a| Diva::Model(a) }) == Set.new(models.map{|a| a.class }) and condition?(models, optional)
end
def call(models, optional)