glader 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +7 -0
- data/README.txt +82 -0
- data/Rakefile +13 -0
- data/bin/glader +28 -0
- data/lib/glader.rb +76 -0
- data/test/test_glader.rb +0 -0
- metadata +71 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
= Glader
|
2
|
+
|
3
|
+
* http://www.lesismore.co.za
|
4
|
+
* http://www.freewebs.com/lesliev
|
5
|
+
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
Glader is a tiny helper script that works with ruby-glade-create-template to create
|
10
|
+
a Ruby program that will show a Glade form. ruby-glade-create-template only creates
|
11
|
+
a class and doesn't actually show the window, and if you change that class subsequent
|
12
|
+
runs of the script will overwrite your changes.
|
13
|
+
|
14
|
+
Glader makes a main file that uses the class and extends it, so you can change your
|
15
|
+
glade file and regenerate it as often as you like, keeping code changes in the
|
16
|
+
main file.
|
17
|
+
|
18
|
+
ruby-glade-create-template is part of libglade2-ruby1.8 on my Ubuntu system.
|
19
|
+
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
glader form.glade
|
24
|
+
|
25
|
+
creates:
|
26
|
+
|
27
|
+
form_glade.rb output of ruby-glade-create-template that will be regenerated
|
28
|
+
each time you change form.glade and rerun glader
|
29
|
+
|
30
|
+
form.rb main program that will only be created once by glader, to create
|
31
|
+
and show a form using form_glade.rb. This is the file that
|
32
|
+
you should edit to create your form's signal handlers, glader
|
33
|
+
will not overwrite it.
|
34
|
+
|
35
|
+
|
36
|
+
== REQUIREMENTS:
|
37
|
+
|
38
|
+
*Ubuntu packages*
|
39
|
+
|
40
|
+
libglade2-ruby1.8, libgtk2-ruby1.8, glade-3
|
41
|
+
|
42
|
+
*Websites*
|
43
|
+
|
44
|
+
http://ruby-gnome2.sourceforge.jp/
|
45
|
+
|
46
|
+
http://glade.gnome.org/
|
47
|
+
http://gladewin32.sourceforge.net/ (Windows)
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
== INSTALL:
|
52
|
+
|
53
|
+
sudo gem install glader
|
54
|
+
|
55
|
+
|
56
|
+
== LICENSE:
|
57
|
+
|
58
|
+
(The MIT License)
|
59
|
+
|
60
|
+
Copyright (c) 2008
|
61
|
+
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
63
|
+
a copy of this software and associated documentation files (the
|
64
|
+
'Software'), to deal in the Software without restriction, including
|
65
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
66
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
67
|
+
permit persons to whom the Software is furnished to do so, subject to
|
68
|
+
the following conditions:
|
69
|
+
|
70
|
+
The above copyright notice and this permission notice shall be
|
71
|
+
included in all copies or substantial portions of the Software.
|
72
|
+
|
73
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
74
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
75
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
76
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
77
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
78
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
79
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
80
|
+
|
81
|
+
|
82
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/glader.rb'
|
6
|
+
|
7
|
+
Hoe.new('glader', Glader::VERSION) do |p|
|
8
|
+
p.developer('lesliev', 'leslieviljoen@gmail.com')
|
9
|
+
p.summary = 'A utility script for quickly converting a .glade file to a Ruby program'
|
10
|
+
p.author = 'Leslie Viljoen'
|
11
|
+
end
|
12
|
+
|
13
|
+
# vim: syntax=Ruby
|
data/bin/glader
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'glader'
|
3
|
+
|
4
|
+
if ARGV.length != 1
|
5
|
+
puts
|
6
|
+
puts " This script creates a class and a main program that shows a window using"
|
7
|
+
puts " that class from a .glade file. It can be used to quickly generate a functional Ruby"
|
8
|
+
puts " program from a .glade file"
|
9
|
+
puts
|
10
|
+
puts " Glader will regenerate and overwrite the file_glade.rb from file.glade each run, but will"
|
11
|
+
puts " not overwrite the file.rb file which is where you should put your signal handlers."
|
12
|
+
puts
|
13
|
+
puts " Usage: #{__FILE__} <file.glade>"
|
14
|
+
puts
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
glader = Glader.new(ARGV[0])
|
19
|
+
print "Making class file (#{glader.make_class})...\n"
|
20
|
+
|
21
|
+
begin
|
22
|
+
print "Making main file (#{glader.make_main})...\n"
|
23
|
+
rescue => e
|
24
|
+
puts e.message
|
25
|
+
end
|
26
|
+
puts
|
27
|
+
|
28
|
+
|
data/lib/glader.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
|
3
|
+
# This class is a quick way of creating a runnable Ruby program from
|
4
|
+
# a single Glade form.
|
5
|
+
#
|
6
|
+
class Glader
|
7
|
+
VERSION = '1.0.0'
|
8
|
+
|
9
|
+
def initialize(glade_filename)
|
10
|
+
raise ArgumentError.new("File missing: #{glade_filename}") if !File.exist?(glade_filename)
|
11
|
+
raise ArgumentError.new("Not a .glade file: #{glade_filename}") if glade_filename !~ /.*\.glade/
|
12
|
+
|
13
|
+
@glade_filename = glade_filename
|
14
|
+
@base_filename = File.basename(@glade_filename, ".glade")
|
15
|
+
@class_filename = @base_filename + "_glade.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Runs the ruby-glade-create-template script to create a file with a
|
19
|
+
# class that corresponds to the form. This can be called repeatedly
|
20
|
+
# to keep creating the class every time the .glade file changes.
|
21
|
+
#
|
22
|
+
def make_class
|
23
|
+
`/usr/bin/ruby-glade-create-template #{@glade_filename} > #{@class_filename}`
|
24
|
+
@class_filename
|
25
|
+
end
|
26
|
+
|
27
|
+
# Creates a main program that uses the glade class created with
|
28
|
+
# _make_class_ and opens the window with the form. It will do nothing
|
29
|
+
# if the main program file already exists, since the user is likely
|
30
|
+
# to add code to this file.
|
31
|
+
#
|
32
|
+
def make_main
|
33
|
+
main_filename = @base_filename + '.rb'
|
34
|
+
|
35
|
+
if(File.exist?(main_filename))
|
36
|
+
raise ArgumentError.new("#{main_filename} already exists, skipping")
|
37
|
+
else
|
38
|
+
File.open(main_filename, "w") {|f| f.write generate_main}
|
39
|
+
end
|
40
|
+
main_filename
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def generate_main()
|
45
|
+
class_name = File.read(@class_filename).scan(/class (.*)/).to_s
|
46
|
+
window_id = File.read(@glade_filename).scan(/class="\w+" id="(\w*)">$/).flatten[0]
|
47
|
+
|
48
|
+
main =<<END
|
49
|
+
|
50
|
+
require '#{@base_filename}_glade'
|
51
|
+
|
52
|
+
class #{class_name}
|
53
|
+
def form
|
54
|
+
@glade["#{window_id}"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def show
|
58
|
+
form.show
|
59
|
+
end
|
60
|
+
|
61
|
+
#if this signal exists, exit nicely
|
62
|
+
#
|
63
|
+
def on_#{window_id}_destroy(widget)
|
64
|
+
Gtk.main_quit
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
form = #{class_name}.new("#{@glade_filename}", nil, "Application")
|
69
|
+
form.show
|
70
|
+
|
71
|
+
Gtk.main
|
72
|
+
|
73
|
+
END
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
data/test/test_glader.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leslie Viljoen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-09 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.3
|
23
|
+
version:
|
24
|
+
description: Glader is a tiny helper script that works with ruby-glade-create-template to create a Ruby program that will show a Glade form. ruby-glade-create-template only creates a class and doesn't actually show the window, and if you change that class subsequent runs of the script will overwrite your changes. Glader makes a main file that uses the class and extends it, so you can change your glade file and regenerate it as often as you like, keeping code changes in the main file. ruby-glade-create-template is part of libglade2-ruby1.8 on my Ubuntu system.
|
25
|
+
email:
|
26
|
+
- leslieviljoen@gmail.com
|
27
|
+
executables:
|
28
|
+
- glader
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.txt
|
35
|
+
files:
|
36
|
+
- History.txt
|
37
|
+
- Manifest.txt
|
38
|
+
- README.txt
|
39
|
+
- Rakefile
|
40
|
+
- bin/glader
|
41
|
+
- lib/glader.rb
|
42
|
+
- test/test_glader.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://www.lesismore.co.za
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --main
|
48
|
+
- README.txt
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: glader
|
66
|
+
rubygems_version: 1.1.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: A utility script for quickly converting a .glade file to a Ruby program
|
70
|
+
test_files:
|
71
|
+
- test/test_glader.rb
|