mireru 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdbbb02cb56552275b740544a7156e7b155bd126
4
- data.tar.gz: efb1f67b291ec5733cf9499f6ca71cb4969251cd
3
+ metadata.gz: 406e348f2d11f8f56ac07255316499132fb2a788
4
+ data.tar.gz: 8796ee447bbbaee723af14d06ce2480937b43acd
5
5
  SHA512:
6
- metadata.gz: d73f9d68826bb2dc43fa3a9719e1b1d053bfe119a33c194660c26dfbdb7223ebfd5a3b6a292239a6f30e4841066ec552313be858edc719d72e10dba6e09a970d
7
- data.tar.gz: 55021cc099d4abef5652d11fef73e72cd170dd71c1b29291c90bfa7e1b0c9f0df4f406b3c174e9aa8f69089edb5e79734a0a216bed20523a2d479046622c02fa
6
+ metadata.gz: 0e5a7fdd5d5c57e92fcd235a618298e14354818e0665261e8feeae23341308efa66ca2dab88207733c334ecfcfdeba132f03fcb53b9b20583ef20cdd2eb240bf
7
+ data.tar.gz: 2cc0bd8b9a70d063880e6dd220434b97f9735acf30c4ffa1f34ce9ea6191dc14cdd67748269168d83d0fdf9439ea90b6ab1ff8fbf9a8690b868147197d3deac9
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ env:
3
3
  - DISPLAY=":99.0"
4
4
  language: ruby
5
5
  rvm:
6
+ - 1.9.3
6
7
  - 2.0.0
7
8
  - 2.1
8
9
  - rbx-2
data/NEWS.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.9.1: 2014-07-29
4
+
5
+ Introduce ChupaText!
6
+
7
+ ### Changes
8
+
9
+ * Improvements
10
+ * Add license header
11
+ * Introduce ChupaText
12
+ * Cache icons
13
+ * Add a key binding to run selected file (Windows and OS X)
14
+ * Show icons associated with MIME type
15
+
16
+ * Fixes
17
+ * Suppress an error from an empty file
18
+ * text: Support a multibyte encoding such as Shift_JIS
19
+
3
20
  ## 0.9.0: 2014-07-13
4
21
 
5
22
  Now we have TreeView, and many problems are resolved.
data/README.md CHANGED
@@ -4,12 +4,17 @@ Mireru is a keyboard friendly file viewer by Ruby/GTK3.
4
4
 
5
5
  It can handle a variety of file types (Picture, Text, PDF, Video and etc.).
6
6
 
7
- ## Requirements
7
+ ## Dependencies
8
8
 
9
9
  * Ruby/GTK3, Ruby/GtkSourceView3, Ruby/ClutterGTK, Ruby/ClutterGStreamer,
10
10
  Ruby/Poppler and Ruby/RSVG2 in
11
11
  [Ruby-GNOME2](http://ruby-gnome2.sourceforge.jp/)
12
12
  * [hexdump](https://github.com/postmodern/hexdump)
13
+ * [ChupaText](https://github.com/ranguba/chupa-text)
14
+ * [chupa-text-decomposer-html](https://github.com/ranguba/chupa-text-decomposer-html)
15
+ * [chupa-text-decomposer-pdf](https://github.com/ranguba/chupa-text-decomposer-pdf)
16
+ * [chupa-text-decomposer-libreoffice](https://github.com/ranguba/chupa-text-decomposer-libreoffice)
17
+ * [LibreOffice](https://www.libreoffice.org/)
13
18
 
14
19
  ## Installation
15
20
 
@@ -25,70 +30,79 @@ If no argument, then open the current directory.
25
30
 
26
31
  ### Options
27
32
 
28
- -h, --help<br />
29
- show this help message
33
+ * `-h`, `--help`
34
+ * show this help message
30
35
 
31
- -f, --font NAME<br />
32
- set a font such as "Monospace 16"
36
+ * `-f`, `--font NAME`
37
+ * set a font such as "Monospace 16"
33
38
 
34
39
  ### Key bindings
35
40
 
36
41
  #### Common
37
42
 
38
- n: next<br />
39
- p: prev<br />
40
- e: expand/collpse<br />
41
- r: reload<br />
42
- q: quit<br />
43
+ * `n`: next
44
+ * `p`: prev
45
+ * `e`: expand/collapse
46
+ * `r`: reload
47
+ * `q`: quit
48
+
49
+ ---
50
+
51
+ * `E`: extract text using ChupaText
43
52
 
44
53
  #### Control key mask
45
54
 
46
- Ctrl+n: 10 tiles next<br />
47
- Ctrl+p: 10 tiles prev<br />
48
- Ctrl+e: expand all/collpse even if cursor on file<br />
49
- Ctrl+h: move position of partition to left<br />
50
- Ctrl+l: move position of partition to right<br />
55
+ * Ctrl+`n`: 10 tiles next
56
+ * Ctrl+`p`: 10 tiles prev
57
+ * Ctrl+`e`: expand all/collapse even if cursor on file
58
+ * Ctrl+`h`: move position of partition to left
59
+ * Ctrl+`l`: move position of partition to right
60
+ * Ctrl+Enter: run selected file (only supports Windows and OS X)
51
61
 
52
62
  #### Scroll
53
63
 
54
- h: left<br />
55
- j: down<br />
56
- k: up<br />
57
- l: right<br />
64
+ * `h`: left
65
+ * `j`: down
66
+ * `k`: up
67
+ * `l`: right
68
+
69
+ ---
70
+
71
+ * `H`: 100 times left
72
+ * `J`: 100 times down
73
+ * `K`: 100 times up
74
+ * `L`: 100 times right
58
75
 
59
- Shift+h: 100 times left<br />
60
- Shift+j: 100 times down<br />
61
- Shift+k: 100 times up<br />
62
- Shift+l: 100 times right<br />
76
+ ---
63
77
 
64
- Shift+g: down to bottom<br />
78
+ * `G`: down to bottom
65
79
 
66
80
  #### Scale
67
81
 
68
- +: larger<br />
69
- -: smaller<br />
82
+ * `+`: larger
83
+ * `-`: smaller
70
84
 
71
85
  #### Image
72
86
 
73
- f: fit window size<br />
74
- o: scale to the original size<br />
87
+ * `f`: fit window size
88
+ * `o`: scale to the original size
75
89
 
76
90
  #### Text
77
91
 
78
- f: change font (at random)<br />
92
+ * `f`: change font (at random)
79
93
 
80
94
  #### Video
81
95
 
82
- space: play/pause<br />
96
+ * space: play/pause
83
97
 
84
98
  #### PDF
85
99
 
86
- j: next page<br />
87
- k: prev page<br />
100
+ * `j`: next page
101
+ * `k`: prev page
88
102
 
89
103
  ## License
90
104
 
91
- Copyright (c) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
105
+ Copyright (c) 2013-2014 Masafumi Yokoyama `<myokoym@gmail.com>`
92
106
 
93
107
  GPLv2 or later.
94
108
 
@@ -101,7 +115,3 @@ See 'license/gpl-2.0.txt' or 'http://www.gnu.org/licenses/gpl-2.0' for details.
101
115
  3. Commit your changes (`git commit -am 'Add some feature'`)
102
116
  4. Push to the branch (`git push origin my-new-feature`)
103
117
  5. Create new Pull Request
104
-
105
-
106
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/myokoym/mireru/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
107
-
data/Rakefile CHANGED
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  require "bundler/gem_tasks"
2
18
 
3
19
  desc "Run test"
data/bin/mireru CHANGED
@@ -1,4 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along
16
+ # with this program; if not, write to the Free Software Foundation, Inc.,
17
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2
18
 
3
19
  require "mireru/command/mireru"
4
20
 
data/lib/mireru.rb CHANGED
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  require "mireru/version"
2
18
  require "mireru/logger"
3
19
  require "mireru/widget"
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  require "mireru/logger"
2
18
  require "mireru/window"
3
19
  require "mireru/version"
@@ -72,16 +88,19 @@ Options:
72
88
  Key bindings:
73
89
  n: next
74
90
  p: prev
75
- e: expand/collpse
91
+ e: expand/collapse
76
92
  r: reload
77
93
  q: quit
78
94
 
95
+ E: extract text using ChupaText
96
+
79
97
  Control key mask:
80
98
  Ctrl+n: 10 tiles next
81
99
  Ctrl+p: 10 tiles prev
82
- Ctrl+e: expand all / collpse even if cursor on file
100
+ Ctrl+e: expand all / collapse even if cursor on file
83
101
  Ctrl+h: move position of partition to left
84
102
  Ctrl+l: move position of partition to right
103
+ Ctrl+Enter: run selected file (only supports Windows and OS X)
85
104
 
86
105
  scroll:
87
106
  h: left
@@ -89,12 +108,12 @@ Key bindings:
89
108
  k: up
90
109
  l: right
91
110
 
92
- Shift+h: 100 times left
93
- Shift+j: 100 times down
94
- Shift+k: 100 times up
95
- Shift+l: 100 times right
111
+ H: 100 times left
112
+ J: 100 times down
113
+ K: 100 times up
114
+ L: 100 times right
96
115
 
97
- Shift+g: down to bottom
116
+ G: down to bottom
98
117
 
99
118
  scale:
100
119
  +: larger
data/lib/mireru/logger.rb CHANGED
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  module Mireru
2
18
  class Logger
3
19
  def initialize
@@ -1,4 +1,21 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  require "gtk3"
18
+ require "gio2"
2
19
 
3
20
  module Mireru
4
21
  class Navigator < Gtk::ScrolledWindow
@@ -9,6 +26,7 @@ module Mireru
9
26
  @window = window
10
27
  @files = files
11
28
  @dir_iters = {}
29
+ @icons = {}
12
30
  set_policy(:automatic, :automatic)
13
31
  set_size_request(200, -1)
14
32
  @model = Gtk::TreeStore.new(String, String, Gdk::Pixbuf)
@@ -145,22 +163,44 @@ module Mireru
145
163
  file_icon = select_icon(file)
146
164
  iter.set_value(ICON_COLUMN, file_icon)
147
165
  end
148
- # TODO: too slow...
149
- #icon_width, icon_height = Gtk::IconSize.lookup(:menu)
150
- #begin
151
- # pixbuf = Gdk::Pixbuf.new(file_path, icon_width, icon_height)
152
- #rescue Gdk::PixbufError
153
- # pixbuf = file_icon
154
- #end
155
- #iter.set_value(ICON_COLUMN, pixbuf)
156
166
  end
157
167
 
158
168
  def select_icon(file)
159
- if Widget.video?(file) or Widget.music?(file)
160
- self.render_icon_pixbuf(Gtk::Stock::CDROM, :menu)
169
+ content_type = guess_content_type(file)
170
+ return @icons[content_type] if @icons[content_type]
171
+ icon_path = lookup_icon_path(content_type)
172
+
173
+ if icon_path
174
+ @icons[content_type] = Gdk::Pixbuf.new(icon_path)
161
175
  else
162
- self.render_icon_pixbuf(Gtk::Stock::FILE, :menu)
176
+ if Widget.video?(file) or Widget.music?(file)
177
+ @icons[content_type] = self.render_icon_pixbuf(Gtk::Stock::CDROM, :menu)
178
+ else
179
+ @icons[content_type] = self.render_icon_pixbuf(Gtk::Stock::FILE, :menu)
180
+ end
163
181
  end
182
+ @icons[content_type]
183
+ end
184
+
185
+ def lookup_icon_path(mime_type)
186
+ content_type = Gio::ContentType.new(mime_type)
187
+ icon = content_type.icon
188
+
189
+ icon_theme = Gtk::IconTheme.new
190
+ icon_info = icon_theme.lookup_icon(icon,
191
+ 16,
192
+ Gtk::IconTheme::LookupFlags::GENERIC_FALLBACK)
193
+
194
+ if icon_info
195
+ icon_info.filename
196
+ else
197
+ nil
198
+ end
199
+ end
200
+
201
+ def guess_content_type(file)
202
+ content_type, _uncertain = Gio::ContentType.guess(file)
203
+ content_type
164
204
  end
165
205
  end
166
206
  end
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  module Mireru
2
- VERSION = "0.9.0"
18
+ VERSION = "0.9.1"
3
19
  end
data/lib/mireru/widget.rb CHANGED
@@ -1,26 +1,45 @@
1
+ # Copyright (C) 2013-2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  require "mireru/widget/image"
2
18
  require "mireru/widget/video"
3
19
  require "mireru/widget/pdf"
4
20
  require "mireru/widget/svg"
21
+ require "mireru/widget/extracted_text"
5
22
  require "mireru/widget/text"
6
23
  require "mireru/widget/binary"
7
24
 
8
25
  module Mireru
9
26
  module Widget
10
27
  module_function
11
- def create(file, width, height)
12
- if image?(file)
13
- widget = Mireru::Widget::Image.new(file, width, height)
28
+ def create(file, width, height, chupa=false)
29
+ if chupa
30
+ widget = Widget::ExtractedText.new(file)
31
+ elsif image?(file)
32
+ widget = Widget::Image.new(file, width, height)
14
33
  elsif video?(file) or music?(file)
15
- widget = Mireru::Widget::Video.new(file)
34
+ widget = Widget::Video.new(file)
16
35
  elsif pdf?(file)
17
- widget = Mireru::Widget::PDF.new(file)
36
+ widget = Widget::PDF.new(file)
18
37
  elsif svg?(file)
19
- widget = Mireru::Widget::SVG.new(file)
38
+ widget = Widget::SVG.new(file)
20
39
  elsif text?(file)
21
- widget = Mireru::Widget::Text.new(file)
40
+ widget = Widget::Text.new(file)
22
41
  else
23
- widget = Mireru::Widget::Binary.new(file)
42
+ widget = Widget::Binary.new(file)
24
43
  end
25
44
  widget
26
45
  end
@@ -45,13 +64,31 @@ module Mireru
45
64
  /\.svg\z/i =~ file
46
65
  end
47
66
 
67
+ def document?(file)
68
+ /\.(odt|ods|odp|doc|xls|ppt|docx|xlsx|pptx)\z/i =~ file
69
+ end
70
+
48
71
  def text?(file)
49
72
  return false if binary?(file)
50
- File.read(file).valid_encoding?
73
+ true
51
74
  end
52
75
 
53
76
  def binary?(file)
54
- /\.(la|lo|o|so|a|dll|exe|msi|tar|gz|zip|7z|lzh|rar|iso)\z/i =~ file
77
+ if /\.(la|lo|o|so|a|dll|exe|msi|tar|gz|zip|7z|lzh|rar|iso)\z/i =~ file
78
+ true
79
+ else
80
+ bytes = File.read(file, 512)
81
+ return false if bytes.nil?
82
+ return false if utf16?(bytes)
83
+ bytes.count("\x00-\x07\x0b\x0e-\x1a\x1c-\x1f") > (bytes.size / 10)
84
+ end
85
+ end
86
+
87
+ def utf16?(bytes)
88
+ # TODO: simplify
89
+ (bytes.start_with?("\xff\xfe".force_encoding("ASCII-8BIT")) or
90
+ bytes.start_with?("\xfe\xff".force_encoding("ASCII-8BIT"))) and
91
+ bytes.count("\x01-\x07\x0b\x0e-\x1a\x1c-\x1f") < (bytes.size / 20)
55
92
  end
56
93
  end
57
94
  end