zenity-wrapper 2.30.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS ADDED
@@ -0,0 +1,9 @@
1
+ 2.30.0.1 2013-02-26
2
+
3
+ * Add general options width and heigth
4
+ * Add methods and constants to check the exit status
5
+
6
+
7
+ 2.30.0.0 2013-02-18
8
+
9
+ * List and message dialogs
@@ -0,0 +1,160 @@
1
+ zenity-wrapper
2
+ ================
3
+
4
+
5
+ Description
6
+ -----------
7
+ What did you expect with that name? Zenity-wrapper is a ruby wrapper over
8
+ the [zenity utilily][2].
9
+
10
+ I wrote it because I need it for a personal project. It is far from complete,
11
+ it could only open **list** and **message** dialog boxes.
12
+ Anyway I release it because it could be helpfull to somebody.
13
+
14
+ Install
15
+ -------------------------
16
+
17
+ gem install zenity-wrapper
18
+ apt-get zenity
19
+
20
+
21
+ Usage
22
+ --------------------------
23
+
24
+ You should check [zenity documentation][1] first.
25
+
26
+ ### Simple example
27
+
28
+ require 'zenity'
29
+
30
+ Zenity::Message.new(:error, "content text").proceed
31
+
32
+ ### General options
33
+
34
+ A big error message:
35
+
36
+ m = Zenity::Message.new(:error, "content text")
37
+ m.title = "Big error message"
38
+ m.width = 600
39
+ m.height = 400
40
+ m.proceed
41
+
42
+ ### Exit Status
43
+
44
+ Zenity defines the following module constants:
45
+
46
+ + OK
47
+ + CANCEL
48
+ + ERROR
49
+ + EXPIRED
50
+
51
+ And the following methods for each dialogs classes:
52
+
53
+ + `exit_status`
54
+ + `ok?`
55
+ + `cancel?`
56
+ + `error?`
57
+ + `expired?`
58
+
59
+ A dumb usage example:
60
+
61
+ m = Zenity::Message.new(:question, "your question")
62
+ answer = m.proceed
63
+ if m.exit_status == Zenity::OK
64
+ puts answer
65
+ elsif m.expired?
66
+ puts "too late..."
67
+ end
68
+
69
+ ### Returned Value
70
+
71
+ The `proceed` method returns a String.
72
+
73
+ ### Calendar
74
+
75
+ TODO
76
+
77
+ ### File Select
78
+
79
+ TODO
80
+
81
+ ### Notification
82
+
83
+ TODO
84
+
85
+ ### List
86
+
87
+ list = List.new(columns = ["Reference", "Title"],
88
+ data = ['1 "title 1"', '2 "title 2"'])
89
+ # You could modify the separator
90
+ list.separator = "---"
91
+ # You could modify the returned column(s)
92
+ list.print_column = "ALL"
93
+ puts list.proceed
94
+
95
+ ### Message
96
+
97
+ Message.new(:error, "This is an error message").proceed
98
+
99
+ Message.new(:info, "This is an info message").proceed
100
+
101
+ Message.new(:warning, "This is a warning message").proceed
102
+
103
+ answer = Message.new(:question, "This is a question message").proceed
104
+ puts answer
105
+
106
+ ### Progress Bar
107
+
108
+ TODO
109
+
110
+ ### Entry
111
+
112
+ TODO
113
+
114
+ ### Text Info
115
+
116
+ TODO
117
+
118
+
119
+ Dependencies
120
+ --------------------------
121
+
122
+ + ruby >= 1.9.3
123
+ + zenity >= 2.30
124
+
125
+ License
126
+ --------------------------
127
+
128
+ MIT
129
+
130
+ Copyright (c) 2013 Xavier Nayrac
131
+
132
+ Permission is hereby granted, free of charge, to any person obtaining
133
+ a copy of this software and associated documentation files (the
134
+ "Software"), to deal in the Software without restriction, including
135
+ without limitation the rights to use, copy, modify, merge, publish,
136
+ distribute, sublicense, and/or sell copies of the Software, and to
137
+ permit persons to whom the Software is furnished to do so, subject to
138
+ the following conditions:
139
+
140
+ The above copyright notice and this permission notice shall be included
141
+ in all copies or substantial portions of the Software.
142
+
143
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
144
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
145
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
146
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
147
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
148
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
149
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
150
+
151
+
152
+ Questions and/or Comments
153
+ --------------------------
154
+
155
+ Feel free to email [Xavier Nayrac](mailto:xavier.nayrac@gmail.com)
156
+ with any questions.
157
+
158
+
159
+ [1]: http://help.gnome.org/users/zenity/2.32/
160
+ [2]: http://en.wikipedia.org/wiki/Zenity
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'rake'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Test Zenity'
7
+ task :default => :spec
8
+
9
+ desc 'Test Zenity with rspec'
10
+ RSpec::Core::RakeTask.new(:spec) do |t|
11
+ t.rspec_opts = ['--color']
12
+ end
13
+
14
+ desc 'Check for code smells'
15
+ task :reek do
16
+ puts 'Checking for code smells...'
17
+ files = Dir.glob 'lib/**/*.rb'
18
+ args = files.join(' ')
19
+ sh "reek --quiet #{args} | ./reek.sed"
20
+ end
21
+
22
+ desc 'Build Zenity & install it'
23
+ task :install do
24
+ sh "rm zenity-wrapper-*gem"
25
+ sh "gem build zenity-wrapper.gemspec"
26
+ f = FileList['zenity*gem'].to_a
27
+ sh "gem install #{f.first}"
28
+ end
29
+
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+
2
+ doc utilisation sommaire dans readme
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.30.0.1
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__)
4
+ $ZENITY_PATH = File.expand_path(File.expand_path(File.dirname(__FILE__)) + '/..')
5
+
6
+ require 'zenity/base'
7
+ require 'zenity/list'
8
+ require 'zenity/message'
9
+
10
+ module Zenity
11
+ OK = 0
12
+ CANCEL = 1
13
+ ERROR = -1
14
+ EXPIRED = 5
15
+ end
@@ -0,0 +1,67 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Zenity
4
+
5
+ # Internal: Base class for all dialog boxes.
6
+ class Base
7
+ attr_writer :title, :width, :height
8
+ attr_reader :exit_status
9
+
10
+ def initialize
11
+ @exit_status = nil
12
+ end
13
+
14
+ def proceed
15
+ ret = %x[ #{get_command} ]
16
+ @exit_status = $?.exitstatus
17
+ ret.delete("\n")
18
+ end
19
+
20
+ def ok?
21
+ @exit_status == OK
22
+ end
23
+
24
+ def cancel?
25
+ @exit_status == CANCEL
26
+ end
27
+
28
+ def error?
29
+ @exit_status == ERROR
30
+ end
31
+
32
+ def expired?
33
+ @exit_status == EXPIRED
34
+ end
35
+
36
+ private
37
+
38
+ def general_options
39
+ title + width + height
40
+ end
41
+
42
+ def title
43
+ if defined? @title
44
+ " --title=\"#{@title}\" "
45
+ else
46
+ ""
47
+ end
48
+ end
49
+
50
+ def width
51
+ if defined? @width
52
+ " --width=\"#{@width}\" "
53
+ else
54
+ ""
55
+ end
56
+ end
57
+
58
+ def height
59
+ if defined? @height
60
+ " --height=\"#{@height}\" "
61
+ else
62
+ ""
63
+ end
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Zenity
4
+
5
+ # Public: List dialog box wrapper.
6
+ class List < Base
7
+ attr_writer :separator, :print_column
8
+
9
+ def initialize columns = ["Column Title"], data = ["Data"], options = []
10
+ @command = "zenity --list \\\n"
11
+ unless options.empty?
12
+ options.each do |opt|
13
+ if ['checklist', 'radiolist', 'editable'].include? opt
14
+ @command += "--#{opt} \\\n"
15
+ else
16
+ raise "Unknown option #{opt} for zenity list"
17
+ end
18
+ end
19
+ end
20
+ columns.map! { |col| "--column=\"#{col}\"" }
21
+ @command += columns.join(" ") + " \\\n"
22
+ @command += data.join(" \\\n")
23
+ end
24
+
25
+ def get_command
26
+ @command + option_separator + option_print_column + general_options
27
+ end
28
+
29
+ private
30
+
31
+ def option_separator
32
+ if defined? @separator
33
+ " --separator=#{@separator} "
34
+ else
35
+ ""
36
+ end
37
+ end
38
+
39
+ def option_print_column
40
+ if defined? @print_column
41
+ " --print-column=#{@print_column} "
42
+ else
43
+ ""
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Zenity
4
+
5
+ # Public: Boite de dialogue de message.
6
+ class Message < Base
7
+
8
+ # Public:
9
+ #
10
+ # type - A String, the type of the message, one of:
11
+ # 'error'
12
+ # 'warning'
13
+ # 'question'
14
+ # 'info'
15
+ # text - The text String to display in dialog box.
16
+ def initialize type, text
17
+ if [:error, :warning, :question, :info].include? type
18
+ @command = "zenity --#{type} --text=\"#{text}\""
19
+ else
20
+ raise "Unknown message type #{type} for zenity message"
21
+ end
22
+ end
23
+
24
+ # Internal: Get the shell command for the dialog box.
25
+ # Used mostly for testing purposes.
26
+ #
27
+ # Returns the shell command as a String
28
+ def get_command
29
+ @command + general_options
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zenity-wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.30.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Xavier Nayrac
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! 'What did you expect with that name? Zenity-wrapper is a ruby wrapper
15
+ over
16
+
17
+ the zenity utilily.
18
+
19
+
20
+ I wrote it because I need it for a personal project. It is far from complete,
21
+
22
+ it could only open **list** and **message** dialog boxes.
23
+
24
+ Anyway I release it because it could be helpfull to somebody.'
25
+ email: xavier.nayrac@gmail.com
26
+ executables: []
27
+ extensions: []
28
+ extra_rdoc_files: []
29
+ files:
30
+ - lib/zenity/list.rb
31
+ - lib/zenity/message.rb
32
+ - lib/zenity/base.rb
33
+ - lib/zenity.rb
34
+ - VERSION
35
+ - NEWS
36
+ - README.markdown
37
+ - Rakefile
38
+ - TODO
39
+ homepage: https://github.com/lkdjiin/zenity-wrapper
40
+ licenses:
41
+ - MIT
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: 1.9.3
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.25
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Zenity-wrapper is a ruby wrapper over the zenity utilily
64
+ test_files: []