ruby_do_plugin_filesearch 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +62 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/glade/win_options.glade +246 -0
- data/gui/win_options.rb +105 -0
- data/include/database.rb +13 -0
- data/include/gui.rb +6 -0
- data/include/models.rb +3 -0
- data/lib/ruby_do_plugin_filesearch.rb +89 -0
- data/models/plugin_filesearch_folder.rb +3 -0
- data/ruby_do_plugin_filesearch.gemspec +72 -0
- data/spec/ruby_do_plugin_filesearch_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +142 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "ruby_do", ">= 0.0.0"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.8.0"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "bundler", ">= 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.8.4"
|
15
|
+
gem "rcov", ">= 0"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
atk (1.1.3)
|
5
|
+
glib2 (>= 1.1.3)
|
6
|
+
cairo (1.12.2)
|
7
|
+
pkg-config
|
8
|
+
diff-lcs (1.1.3)
|
9
|
+
gdk_pixbuf2 (1.1.3)
|
10
|
+
glib2 (>= 1.1.3)
|
11
|
+
gettext (2.2.1)
|
12
|
+
locale
|
13
|
+
git (1.2.5)
|
14
|
+
glib2 (1.1.3)
|
15
|
+
pkg-config
|
16
|
+
gtk2 (1.1.3)
|
17
|
+
atk (>= 1.1.3)
|
18
|
+
gdk_pixbuf2 (>= 1.1.3)
|
19
|
+
pango (>= 1.1.3)
|
20
|
+
jeweler (1.8.4)
|
21
|
+
bundler (~> 1.0)
|
22
|
+
git (>= 1.2.5)
|
23
|
+
rake
|
24
|
+
rdoc
|
25
|
+
json (1.7.3)
|
26
|
+
knjrbfw (0.0.55)
|
27
|
+
tsafe
|
28
|
+
wref
|
29
|
+
locale (2.0.5)
|
30
|
+
pango (1.1.3)
|
31
|
+
cairo (>= 1.10.0)
|
32
|
+
glib2 (>= 1.1.3)
|
33
|
+
pkg-config (1.1.3)
|
34
|
+
rake (0.9.2.2)
|
35
|
+
rcov (0.9.11)
|
36
|
+
rdoc (3.12)
|
37
|
+
json (~> 1.4)
|
38
|
+
rspec (2.8.0)
|
39
|
+
rspec-core (~> 2.8.0)
|
40
|
+
rspec-expectations (~> 2.8.0)
|
41
|
+
rspec-mocks (~> 2.8.0)
|
42
|
+
rspec-core (2.8.0)
|
43
|
+
rspec-expectations (2.8.0)
|
44
|
+
diff-lcs (~> 1.1.2)
|
45
|
+
rspec-mocks (2.8.0)
|
46
|
+
ruby_do (0.0.0)
|
47
|
+
gettext
|
48
|
+
gtk2
|
49
|
+
knjrbfw
|
50
|
+
tsafe (0.0.1)
|
51
|
+
wref (0.0.4)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
bundler (>= 1.0.0)
|
58
|
+
jeweler (~> 1.8.4)
|
59
|
+
rcov
|
60
|
+
rdoc (~> 3.12)
|
61
|
+
rspec (~> 2.8.0)
|
62
|
+
ruby_do (>= 0.0.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Kasper Johansen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= ruby_do_plugin_filesearch
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to ruby_do_plugin_filesearch
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ruby_do_plugin_filesearch"
|
18
|
+
gem.homepage = "http://github.com/kaspernj/ruby_do_plugin_filesearch"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A plugin for Ruby-Do that allows searching for and executing files.}
|
21
|
+
gem.description = %Q{A plugin for Ruby-Do that allows searching for and executing files.}
|
22
|
+
gem.email = "k@spernj.org"
|
23
|
+
gem.authors = ["Kasper Johansen"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "ruby_do_plugin_filesearch #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,246 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<interface>
|
3
|
+
<requires lib="gtk+" version="2.24"/>
|
4
|
+
<!-- interface-naming-policy project-wide -->
|
5
|
+
<object class="GtkWindow" id="window">
|
6
|
+
<property name="can_focus">False</property>
|
7
|
+
<child>
|
8
|
+
<object class="GtkVBox" id="boxArguments">
|
9
|
+
<property name="visible">True</property>
|
10
|
+
<property name="can_focus">False</property>
|
11
|
+
<signal name="destroy" handler="on_boxArguments_destroy" swapped="no"/>
|
12
|
+
<child>
|
13
|
+
<object class="GtkHPaned" id="hpaned1">
|
14
|
+
<property name="visible">True</property>
|
15
|
+
<property name="can_focus">True</property>
|
16
|
+
<property name="position">140</property>
|
17
|
+
<child>
|
18
|
+
<object class="GtkFrame" id="frame1">
|
19
|
+
<property name="visible">True</property>
|
20
|
+
<property name="can_focus">False</property>
|
21
|
+
<property name="label_xalign">0</property>
|
22
|
+
<property name="shadow_type">none</property>
|
23
|
+
<child>
|
24
|
+
<object class="GtkAlignment" id="alignment1">
|
25
|
+
<property name="visible">True</property>
|
26
|
+
<property name="can_focus">False</property>
|
27
|
+
<property name="left_padding">12</property>
|
28
|
+
<child>
|
29
|
+
<object class="GtkViewport" id="viewport1">
|
30
|
+
<property name="visible">True</property>
|
31
|
+
<property name="can_focus">False</property>
|
32
|
+
<child>
|
33
|
+
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
34
|
+
<property name="visible">True</property>
|
35
|
+
<property name="can_focus">True</property>
|
36
|
+
<property name="hscrollbar_policy">automatic</property>
|
37
|
+
<property name="vscrollbar_policy">automatic</property>
|
38
|
+
<child>
|
39
|
+
<object class="GtkTreeView" id="tvFolders">
|
40
|
+
<property name="visible">True</property>
|
41
|
+
<property name="can_focus">True</property>
|
42
|
+
</object>
|
43
|
+
</child>
|
44
|
+
</object>
|
45
|
+
</child>
|
46
|
+
</object>
|
47
|
+
</child>
|
48
|
+
</object>
|
49
|
+
</child>
|
50
|
+
<child type="label">
|
51
|
+
<object class="GtkLabel" id="label1">
|
52
|
+
<property name="visible">True</property>
|
53
|
+
<property name="can_focus">False</property>
|
54
|
+
<property name="label" translatable="yes"><b>Folders</b></property>
|
55
|
+
<property name="use_markup">True</property>
|
56
|
+
</object>
|
57
|
+
</child>
|
58
|
+
</object>
|
59
|
+
<packing>
|
60
|
+
<property name="resize">False</property>
|
61
|
+
<property name="shrink">True</property>
|
62
|
+
</packing>
|
63
|
+
</child>
|
64
|
+
<child>
|
65
|
+
<object class="GtkVBox" id="vbox1">
|
66
|
+
<property name="visible">True</property>
|
67
|
+
<property name="can_focus">False</property>
|
68
|
+
<child>
|
69
|
+
<object class="GtkFrame" id="frame2">
|
70
|
+
<property name="visible">True</property>
|
71
|
+
<property name="can_focus">False</property>
|
72
|
+
<property name="label_xalign">0</property>
|
73
|
+
<property name="shadow_type">none</property>
|
74
|
+
<child>
|
75
|
+
<object class="GtkAlignment" id="alignment2">
|
76
|
+
<property name="visible">True</property>
|
77
|
+
<property name="can_focus">False</property>
|
78
|
+
<property name="left_padding">12</property>
|
79
|
+
<child>
|
80
|
+
<object class="GtkVBox" id="vbox2">
|
81
|
+
<property name="visible">True</property>
|
82
|
+
<property name="can_focus">False</property>
|
83
|
+
<property name="spacing">4</property>
|
84
|
+
<child>
|
85
|
+
<object class="GtkTable" id="table1">
|
86
|
+
<property name="visible">True</property>
|
87
|
+
<property name="can_focus">False</property>
|
88
|
+
<property name="n_rows">2</property>
|
89
|
+
<property name="n_columns">2</property>
|
90
|
+
<property name="column_spacing">4</property>
|
91
|
+
<property name="row_spacing">4</property>
|
92
|
+
<child>
|
93
|
+
<object class="GtkLabel" id="label4">
|
94
|
+
<property name="visible">True</property>
|
95
|
+
<property name="can_focus">False</property>
|
96
|
+
<property name="xalign">0</property>
|
97
|
+
<property name="label" translatable="yes">Path</property>
|
98
|
+
</object>
|
99
|
+
<packing>
|
100
|
+
<property name="x_options">GTK_FILL</property>
|
101
|
+
<property name="y_options">GTK_FILL</property>
|
102
|
+
</packing>
|
103
|
+
</child>
|
104
|
+
<child>
|
105
|
+
<object class="GtkFileChooserButton" id="fcbFolder">
|
106
|
+
<property name="visible">True</property>
|
107
|
+
<property name="can_focus">False</property>
|
108
|
+
<property name="action">select-folder</property>
|
109
|
+
<property name="title" translatable="yes">Select a folder</property>
|
110
|
+
</object>
|
111
|
+
<packing>
|
112
|
+
<property name="left_attach">1</property>
|
113
|
+
<property name="right_attach">2</property>
|
114
|
+
</packing>
|
115
|
+
</child>
|
116
|
+
<child>
|
117
|
+
<object class="GtkLabel" id="label5">
|
118
|
+
<property name="visible">True</property>
|
119
|
+
<property name="can_focus">False</property>
|
120
|
+
<property name="xalign">0</property>
|
121
|
+
<property name="label" translatable="yes">Search depth</property>
|
122
|
+
</object>
|
123
|
+
<packing>
|
124
|
+
<property name="top_attach">1</property>
|
125
|
+
<property name="bottom_attach">2</property>
|
126
|
+
<property name="x_options">GTK_FILL</property>
|
127
|
+
<property name="y_options">GTK_FILL</property>
|
128
|
+
</packing>
|
129
|
+
</child>
|
130
|
+
<child>
|
131
|
+
<object class="GtkEntry" id="txtMaxDepth">
|
132
|
+
<property name="visible">True</property>
|
133
|
+
<property name="can_focus">True</property>
|
134
|
+
<property name="invisible_char">•</property>
|
135
|
+
<property name="primary_icon_activatable">False</property>
|
136
|
+
<property name="secondary_icon_activatable">False</property>
|
137
|
+
<property name="primary_icon_sensitive">True</property>
|
138
|
+
<property name="secondary_icon_sensitive">True</property>
|
139
|
+
</object>
|
140
|
+
<packing>
|
141
|
+
<property name="left_attach">1</property>
|
142
|
+
<property name="right_attach">2</property>
|
143
|
+
<property name="top_attach">1</property>
|
144
|
+
<property name="bottom_attach">2</property>
|
145
|
+
<property name="y_options">GTK_FILL</property>
|
146
|
+
</packing>
|
147
|
+
</child>
|
148
|
+
</object>
|
149
|
+
<packing>
|
150
|
+
<property name="expand">True</property>
|
151
|
+
<property name="fill">True</property>
|
152
|
+
<property name="position">0</property>
|
153
|
+
</packing>
|
154
|
+
</child>
|
155
|
+
<child>
|
156
|
+
<object class="GtkHButtonBox" id="hbuttonbox1">
|
157
|
+
<property name="visible">True</property>
|
158
|
+
<property name="can_focus">False</property>
|
159
|
+
<property name="spacing">4</property>
|
160
|
+
<property name="layout_style">end</property>
|
161
|
+
<child>
|
162
|
+
<object class="GtkButton" id="btnSave">
|
163
|
+
<property name="label">gtk-save</property>
|
164
|
+
<property name="visible">True</property>
|
165
|
+
<property name="can_focus">True</property>
|
166
|
+
<property name="receives_default">True</property>
|
167
|
+
<property name="use_action_appearance">False</property>
|
168
|
+
<property name="use_stock">True</property>
|
169
|
+
<signal name="clicked" handler="on_btnSave_clicked" swapped="no"/>
|
170
|
+
</object>
|
171
|
+
<packing>
|
172
|
+
<property name="expand">False</property>
|
173
|
+
<property name="fill">False</property>
|
174
|
+
<property name="position">0</property>
|
175
|
+
</packing>
|
176
|
+
</child>
|
177
|
+
<child>
|
178
|
+
<object class="GtkButton" id="btnDelete">
|
179
|
+
<property name="label">gtk-delete</property>
|
180
|
+
<property name="visible">True</property>
|
181
|
+
<property name="can_focus">True</property>
|
182
|
+
<property name="receives_default">True</property>
|
183
|
+
<property name="use_action_appearance">False</property>
|
184
|
+
<property name="use_stock">True</property>
|
185
|
+
<signal name="clicked" handler="on_btnDelete_clicked" swapped="no"/>
|
186
|
+
</object>
|
187
|
+
<packing>
|
188
|
+
<property name="expand">False</property>
|
189
|
+
<property name="fill">False</property>
|
190
|
+
<property name="position">1</property>
|
191
|
+
</packing>
|
192
|
+
</child>
|
193
|
+
</object>
|
194
|
+
<packing>
|
195
|
+
<property name="expand">True</property>
|
196
|
+
<property name="fill">True</property>
|
197
|
+
<property name="position">1</property>
|
198
|
+
</packing>
|
199
|
+
</child>
|
200
|
+
</object>
|
201
|
+
</child>
|
202
|
+
</object>
|
203
|
+
</child>
|
204
|
+
<child type="label">
|
205
|
+
<object class="GtkLabel" id="label2">
|
206
|
+
<property name="visible">True</property>
|
207
|
+
<property name="can_focus">False</property>
|
208
|
+
<property name="label" translatable="yes"><b>Folder options</b></property>
|
209
|
+
<property name="use_markup">True</property>
|
210
|
+
</object>
|
211
|
+
</child>
|
212
|
+
</object>
|
213
|
+
<packing>
|
214
|
+
<property name="expand">False</property>
|
215
|
+
<property name="fill">True</property>
|
216
|
+
<property name="position">0</property>
|
217
|
+
</packing>
|
218
|
+
</child>
|
219
|
+
<child>
|
220
|
+
<object class="GtkLabel" id="label3">
|
221
|
+
<property name="visible">True</property>
|
222
|
+
<property name="can_focus">False</property>
|
223
|
+
</object>
|
224
|
+
<packing>
|
225
|
+
<property name="expand">True</property>
|
226
|
+
<property name="fill">True</property>
|
227
|
+
<property name="position">1</property>
|
228
|
+
</packing>
|
229
|
+
</child>
|
230
|
+
</object>
|
231
|
+
<packing>
|
232
|
+
<property name="resize">True</property>
|
233
|
+
<property name="shrink">True</property>
|
234
|
+
</packing>
|
235
|
+
</child>
|
236
|
+
</object>
|
237
|
+
<packing>
|
238
|
+
<property name="expand">True</property>
|
239
|
+
<property name="fill">True</property>
|
240
|
+
<property name="position">0</property>
|
241
|
+
</packing>
|
242
|
+
</child>
|
243
|
+
</object>
|
244
|
+
</child>
|
245
|
+
</object>
|
246
|
+
</interface>
|
data/gui/win_options.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
class Ruby_do_plugin_filesearch::Gui::Win_options
|
2
|
+
attr_reader :box
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@args = args
|
6
|
+
|
7
|
+
@gui = Gtk::Builder.new.add("#{File.dirname(__FILE__)}/../glade/win_options.glade")
|
8
|
+
@gui.connect_signals{|h| method(h)}
|
9
|
+
Knj::Gtk2.translate(@gui)
|
10
|
+
|
11
|
+
|
12
|
+
#Initialize treeview.
|
13
|
+
Knj::Gtk2::Tv.init(@gui["tvFolders"], [
|
14
|
+
_("ID"),
|
15
|
+
_("Folder")
|
16
|
+
])
|
17
|
+
@gui["tvFolders"].columns[0].visible = false
|
18
|
+
@gui["tvFolders"].selection.signal_connect("changed", &self.method(:on_tvFolders_changed))
|
19
|
+
self.reload_folders
|
20
|
+
self.selected_folder = nil
|
21
|
+
|
22
|
+
|
23
|
+
#Make treeview reload when adding, update or delete happens.
|
24
|
+
@reload_id = @args[:filesearch].ob.connect("object" => :Plugin_filesearch_folder, "signals" => ["add", "update", "delete"], &self.method(:reload_folders))
|
25
|
+
|
26
|
+
|
27
|
+
@box = @gui["boxArguments"]
|
28
|
+
@gui["window"].remove(@box)
|
29
|
+
end
|
30
|
+
|
31
|
+
def reload_folders
|
32
|
+
@gui["tvFolders"].model.clear
|
33
|
+
|
34
|
+
Knj::Gtk2::Tv.append(@gui["tvFolders"], ["", _("Add new")])
|
35
|
+
@args[:filesearch].ob.list(:Plugin_filesearch_folder, "orderby" => "path") do |folder|
|
36
|
+
Knj::Gtk2::Tv.append(@gui["tvFolders"], [
|
37
|
+
folder.id,
|
38
|
+
folder[:path]
|
39
|
+
])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def selected_folder
|
44
|
+
sel = Knj::Gtk2::Tv.sel(@gui["tvFolders"])
|
45
|
+
return nil if !sel or sel[0].to_i <= 0
|
46
|
+
return @args[:filesearch].ob.get(:Plugin_filesearch_folder, sel[0])
|
47
|
+
end
|
48
|
+
|
49
|
+
def selected_folder=(folder)
|
50
|
+
if !folder
|
51
|
+
@gui["tvFolders"].selection.select_iter(@gui["tvFolders"].model.iter_first)
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
@gui["tvFolders"].model.each do |model, path, iter|
|
56
|
+
id_val = model.get_value(iter, 0).to_i
|
57
|
+
|
58
|
+
if id_val == folder.id.to_i
|
59
|
+
@gui["tvFolders"].selection.select_iter(iter)
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def on_btnSave_clicked
|
66
|
+
if !Knj::Php.is_numeric(@gui["txtMaxDepth"].text)
|
67
|
+
Knj::Gtk2.msgbox(_("Please enter a numeric value in the search-depth."))
|
68
|
+
return nil
|
69
|
+
end
|
70
|
+
|
71
|
+
save_hash = {
|
72
|
+
:path => @gui["fcbFolder"].current_folder,
|
73
|
+
:search_depth => @gui["txtMaxDepth"].text
|
74
|
+
}
|
75
|
+
|
76
|
+
if folder = selected_folder
|
77
|
+
folder.update(save_hash)
|
78
|
+
else
|
79
|
+
folder = @args[:filesearch].ob.add(:Plugin_filesearch_folder, save_hash)
|
80
|
+
end
|
81
|
+
|
82
|
+
self.selected_folder = folder
|
83
|
+
end
|
84
|
+
|
85
|
+
def on_btnDelete_clicked
|
86
|
+
@args[:filesearch].ob.delete(selected_folder)
|
87
|
+
self.selected_folder = nil
|
88
|
+
end
|
89
|
+
|
90
|
+
def on_tvFolders_changed(*args)
|
91
|
+
if folder = selected_folder
|
92
|
+
@gui["btnDelete"].visible = true
|
93
|
+
@gui["fcbFolder"].current_folder = folder[:path]
|
94
|
+
@gui["txtMaxDepth"].text = folder[:search_depth]
|
95
|
+
else
|
96
|
+
@gui["btnDelete"].visible = false
|
97
|
+
@gui["fcbFolder"].current_folder = Knj::Os.homedir
|
98
|
+
@gui["txtMaxDepth"].text = ""
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def on_boxArguments_destroy
|
103
|
+
@args[:filesearch].ob.unconnect("object" => :Plugin_filesearch_folder, "conn_id" => @reload_id)
|
104
|
+
end
|
105
|
+
end
|
data/include/database.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Ruby_do_plugin_filesearch::Database
|
2
|
+
SCHEMA = {
|
3
|
+
"tables" => {
|
4
|
+
"Plugin_filesearch_folder" => {
|
5
|
+
"columns" => [
|
6
|
+
{"name" => "id", "type" => "int", "autoincr" => true, "primarykey" => true},
|
7
|
+
{"name" => "path", "type" => "text"},
|
8
|
+
{"name" => "search_depth", "type" => "text"}
|
9
|
+
]
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
data/include/gui.rb
ADDED
data/include/models.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
class Ruby_do_plugin_filesearch < Ruby_do::Plugin::Base
|
2
|
+
def self.const_missing(name)
|
3
|
+
require "#{File.dirname(__FILE__)}/../include/#{name.to_s.downcase}.rb"
|
4
|
+
return const_get(name)
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :ob
|
8
|
+
|
9
|
+
def initialize(*args, &block)
|
10
|
+
super(*args, &block)
|
11
|
+
|
12
|
+
|
13
|
+
#Update database to contain tables for the plugin.
|
14
|
+
Knj::Db::Revision.new.init_db("db" => rdo_plugin_args[:rdo].db, "schema" => Ruby_do_plugin_filesearch::Database::SCHEMA)
|
15
|
+
|
16
|
+
|
17
|
+
#Initialize models-framework.
|
18
|
+
@ob = Knj::Objects.new(
|
19
|
+
:datarow => true,
|
20
|
+
:class_path => "#{File.dirname(__FILE__)}/../models",
|
21
|
+
:class_pre => "",
|
22
|
+
:db => rdo_plugin_args[:rdo].db,
|
23
|
+
:module => Ruby_do_plugin_filesearch::Models
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def on_options
|
28
|
+
win_options = Ruby_do_plugin_filesearch::Gui::Win_options.new(:rdo => self.rdo_plugin_args[:rdo], :filesearch => self)
|
29
|
+
|
30
|
+
return {
|
31
|
+
:widget => win_options.box
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_search(args)
|
36
|
+
return Enumerator.new do |yielder|
|
37
|
+
words = args[:text].split(/\s+/).map{|ele| ele.downcase}
|
38
|
+
|
39
|
+
if !words.empty?
|
40
|
+
@ob.list(:Plugin_filesearch_folder) do |folder|
|
41
|
+
files = self.scan_dir(folder[:path], :words => words, :depth => 0, :max_depth => folder[:search_depth].to_i) do |file|
|
42
|
+
title = sprintf(_("Open '%s'."), file[:name])
|
43
|
+
|
44
|
+
yielder << Ruby_do::Plugin::Result.new(
|
45
|
+
:plugin => self,
|
46
|
+
:title => title,
|
47
|
+
:title_html => "<b>#{Knj::Web.html(title)}</b>",
|
48
|
+
:descr => sprintf(_("Open the filepath: '%s'."), file[:path]),
|
49
|
+
:path => file[:path]
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute_result(res)
|
58
|
+
Knj::Os.subproc("xdg-open \"#{res.args[:path]}\"")
|
59
|
+
return :close_win_main
|
60
|
+
end
|
61
|
+
|
62
|
+
def scan_dir(path, args, &block)
|
63
|
+
depth = args[:depth] + 1
|
64
|
+
|
65
|
+
Dir.foreach(path) do |file|
|
66
|
+
next if file[0, 1] == "."
|
67
|
+
fp = "#{path}/#{file}"
|
68
|
+
filel = file.downcase
|
69
|
+
|
70
|
+
if File.directory?(fp)
|
71
|
+
begin
|
72
|
+
self.scan_dir(fp, args.merge(:depth => depth), &block) if depth < args[:max_depth]
|
73
|
+
rescue => e
|
74
|
+
$stderr.puts "Error while searching folder: '#{e.message}' for '#{fp}'."
|
75
|
+
end
|
76
|
+
else
|
77
|
+
all_found = true
|
78
|
+
args[:words].each do |word|
|
79
|
+
if file.index(word) == nil
|
80
|
+
all_found = false
|
81
|
+
break
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
block.call(:name => file, :path => fp) if all_found
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ruby_do_plugin_filesearch}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kasper Johansen"]
|
12
|
+
s.date = %q{2012-07-09}
|
13
|
+
s.description = %q{A plugin for Ruby-Do that allows searching for and executing files.}
|
14
|
+
s.email = %q{k@spernj.org}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"glade/win_options.glade",
|
29
|
+
"gui/win_options.rb",
|
30
|
+
"include/database.rb",
|
31
|
+
"include/gui.rb",
|
32
|
+
"include/models.rb",
|
33
|
+
"lib/ruby_do_plugin_filesearch.rb",
|
34
|
+
"models/plugin_filesearch_folder.rb",
|
35
|
+
"ruby_do_plugin_filesearch.gemspec",
|
36
|
+
"spec/ruby_do_plugin_filesearch_spec.rb",
|
37
|
+
"spec/spec_helper.rb"
|
38
|
+
]
|
39
|
+
s.homepage = %q{http://github.com/kaspernj/ruby_do_plugin_filesearch}
|
40
|
+
s.licenses = ["MIT"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = %q{1.6.2}
|
43
|
+
s.summary = %q{A plugin for Ruby-Do that allows searching for and executing files.}
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<ruby_do>, [">= 0.0.0"])
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
54
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<ruby_do>, [">= 0.0.0"])
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
59
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<ruby_do>, [">= 0.0.0"])
|
65
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
66
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
67
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
69
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'ruby_do_plugin_filesearch'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_do_plugin_filesearch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kasper Johansen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-07-09 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: ruby_do
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.8.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rdoc
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "3.12"
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.0.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: jeweler
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.8.4
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rcov
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
description: A plugin for Ruby-Do that allows searching for and executing files.
|
83
|
+
email: k@spernj.org
|
84
|
+
executables: []
|
85
|
+
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- .document
|
93
|
+
- .rspec
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
- Rakefile
|
99
|
+
- VERSION
|
100
|
+
- glade/win_options.glade
|
101
|
+
- gui/win_options.rb
|
102
|
+
- include/database.rb
|
103
|
+
- include/gui.rb
|
104
|
+
- include/models.rb
|
105
|
+
- lib/ruby_do_plugin_filesearch.rb
|
106
|
+
- models/plugin_filesearch_folder.rb
|
107
|
+
- ruby_do_plugin_filesearch.gemspec
|
108
|
+
- spec/ruby_do_plugin_filesearch_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: http://github.com/kaspernj/ruby_do_plugin_filesearch
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: -403522318111538229
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
version: "0"
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: "0"
|
134
|
+
requirements: []
|
135
|
+
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 1.6.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: A plugin for Ruby-Do that allows searching for and executing files.
|
141
|
+
test_files: []
|
142
|
+
|