lustr-xul 0.1.0

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.
@@ -0,0 +1,4 @@
1
+ +++ 0.1.0 2007-05-23
2
+
3
+ + 1 major enhancement:
4
+ + Initial release
@@ -0,0 +1,16 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/lustr-xul.rb
6
+ lib/lustr-xul/version.rb
7
+ lib/lustr-xul/_common.rb
8
+ lib/lustr-xul/button.rb
9
+ lib/lustr-xul/box.rb
10
+ lib/lustr-xul/label.rb
11
+ lib/lustr-xul/field.rb
12
+ lib/lustr-xul/app.rb
13
+ lib/lustr-xul/dividedbox.rb
14
+ scripts/txt2html
15
+ setup.rb
16
+
@@ -0,0 +1,6 @@
1
+ Lustr is a Ruby DSL for GUI development. Lustr4Wx allows Lustr UIs to be
2
+ displayed via XUL.
3
+
4
+ More details on Lustr can be found at {Lustr's home page}[http://www.codecorps.org/moinmoin/index.cgi/Lustr]
5
+ or on the {RubyForge}[http://rubyforge.org/projects/lustr] site.
6
+
@@ -0,0 +1,93 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ include FileUtils
12
+ require File.join(File.dirname(__FILE__), 'lib', 'lustr-xul', 'version')
13
+
14
+ AUTHOR = 'FIXME full name' # can also be an array of Authors
15
+ EMAIL = "FIXME email"
16
+ DESCRIPTION = "description of gem"
17
+ GEM_NAME = 'lustr-xul' # what ppl will type to install your gem
18
+ RUBYFORGE_PROJECT = 'lustr' # The unix name for your project
19
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
21
+
22
+ NAME = "lustr-xul"
23
+ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
24
+ VERS = Lustr4XUL::VERSION::STRING + (REV ? ".#{REV}" : "")
25
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
26
+ RDOC_OPTS = ['--quiet', '--title', 'lustr-xul documentation',
27
+ "--opname", "index.html",
28
+ "--line-numbers",
29
+ "--main", "README",
30
+ "--inline-source"]
31
+
32
+ class Hoe
33
+ def extra_deps
34
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
35
+ end
36
+ end
37
+
38
+ # Generate all the Rake tasks
39
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
40
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
41
+ p.author = AUTHOR
42
+ p.description = DESCRIPTION
43
+ p.email = EMAIL
44
+ p.summary = DESCRIPTION
45
+ p.url = HOMEPATH
46
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
47
+ p.test_globs = ["test/**/test_*.rb"]
48
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
49
+
50
+ # == Optional
51
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
52
+ p.extra_deps = [['lustr-core', '>=0.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
53
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
54
+ end
55
+
56
+
57
+ desc 'Generate website files'
58
+ task :website_generate do
59
+ Dir['website/**/*.txt'].each do |txt|
60
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
61
+ end
62
+ end
63
+
64
+ desc 'Upload website files to rubyforge'
65
+ task :website_upload do
66
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
67
+ host = "#{config["username"]}@rubyforge.org"
68
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
69
+ # remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
+ local_dir = 'website'
71
+ sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
72
+ end
73
+
74
+ desc 'Generate and upload website files'
75
+ task :website => [:website_generate, :website_upload]
76
+
77
+ desc 'Release the website and new gem version'
78
+ task :deploy => [:check_version, :website, :release]
79
+
80
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
81
+ task :local_deploy => [:website_generate, :install_gem]
82
+
83
+ task :check_version do
84
+ unless ENV['VERSION']
85
+ puts 'Must pass a VERSION=x.y.z release version'
86
+ exit
87
+ end
88
+ unless ENV['VERSION'] == VERS
89
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
90
+ exit
91
+ end
92
+ end
93
+
@@ -0,0 +1,17 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ path=File::join(File::dirname(__FILE__), 'lustr-xul')
17
+ Dir[path+'/*.rb'].sort.each {|f| require f}
@@ -0,0 +1,136 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ require 'lustr'
17
+ require 'rubygems'
18
+ require 'builder'
19
+
20
+ module Lustr4XUL
21
+ class GenerationContext < Builder::XmlMarkup
22
+ attr_reader :name
23
+
24
+ def initialize(name)
25
+ super()
26
+ @name=name
27
+ @namespaces={'xmlns:xul'=>"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"}
28
+ @script_needed=true
29
+ end
30
+
31
+ def to_s
32
+ self.target!
33
+ end
34
+
35
+ def build_gadget_ref(gadget)
36
+ self.xul :box, :class=>gadget.builder.name.to_sym, :id=>gadget.name
37
+ end
38
+
39
+ def net_attrs(raw={})
40
+ result=raw.reject {|key, value| !value || (value.kind_of?(String) && value.size==0)}
41
+
42
+ if @namespaces
43
+ result.merge!(@namespaces)
44
+ end
45
+
46
+ @namespaces=nil
47
+
48
+ return result
49
+ end
50
+
51
+ def descend(widget)
52
+ if @script_needed
53
+ self.xul :script, 'src'=>'_'+@name+'.js'
54
+ @script_needed=false
55
+ end
56
+
57
+ first=true if block_given?
58
+
59
+ widget.children.each do |child|
60
+ child.generate(self)
61
+
62
+ if first
63
+ first=false
64
+ yield
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ class XULGenerationContext < GenerationContext
71
+ def initialize(name)
72
+ super
73
+ @script_needed=true
74
+
75
+ self.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
76
+ self.instruct! 'xml-stylesheet', :href=>"chrome://global/skin/", :type=>"text/css"
77
+ self.instruct! 'xml-stylesheet', :href=>"gadgets.css", :type=>"text/css"
78
+ end
79
+ end
80
+
81
+ class XBLGenerationContext < GenerationContext
82
+ def initialize(name)
83
+ super
84
+ @script_needed=true
85
+ end
86
+
87
+ def to_s
88
+ wrapper=Builder::XmlMarkup.new
89
+
90
+ wrapper.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
91
+ wrapper.bindings 'xmlns'=>'http://www.mozilla.org/xbl' do
92
+ wrapper.binding 'id'=>name do
93
+ wrapper.content do
94
+ wrapper.children
95
+ wrapper << self.target!
96
+ end
97
+ end
98
+ end
99
+
100
+ return(wrapper.target!)
101
+ end
102
+ end
103
+
104
+ class Generator < Lustr::Generator
105
+ def create_context(name)
106
+ XULGenerationContext.new name
107
+ end
108
+
109
+ def create_gadget_context(name)
110
+ XBLGenerationContext.new name
111
+ end
112
+
113
+ def generate_extra_files(dir)
114
+ path=File::join(dir, 'gadgets.css')
115
+
116
+ File.open(path, "w") do |aFile|
117
+ parse_context.gadget_builders.keys.each do |gadget|
118
+ if gadget
119
+ aFile.puts <<EOS
120
+ box.#{gadget} { -moz-binding: url('gadgets/#{gadget}.xml##{gadget}'); }
121
+ EOS
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+
129
+ module Lustr
130
+ class XmlBasedWidget
131
+ def action(bus_message)
132
+ return "#{bus_message}(event)" if bus_message
133
+ end
134
+ end
135
+ end
136
+
@@ -0,0 +1,37 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ require 'lustr'
17
+
18
+ module Lustr4XUL
19
+ class AppWidget < Lustr::XmlBasedWidget
20
+ def generate(xml)
21
+ attrs=xml.net_attrs 'onload'=>action(option(:on_init))
22
+
23
+ xml.xul :window, attrs do
24
+ scripts=option(:scripts) || []
25
+
26
+ scripts.each do |script|
27
+ xml.xul :script, 'src'=>script
28
+ end
29
+
30
+ xml.descend(self)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ Lustr.declare(Lustr::SimpleBuilder.new(:app, Lustr4XUL::AppWidget))
37
+
@@ -0,0 +1,35 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ require 'lustr'
17
+
18
+ module Lustr4XUL
19
+ class BoxWidget < Lustr::XmlBasedWidget
20
+ def generate(xml)
21
+ if option(:direction)==:horizontal
22
+ xml.xul :hbox, xml.net_attrs('id'=>option(:name), 'flex'=>option(:flex)) do
23
+ xml.descend(self)
24
+ end
25
+ else
26
+ xml.xul :vbox, xml.net_attrs('id'=>option(:name)) do
27
+ xml.descend(self)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ Lustr.declare(Lustr::SimpleBuilder.new(:box, Lustr4XUL::BoxWidget))
35
+
@@ -0,0 +1,31 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ require 'lustr'
17
+
18
+ module Lustr4XUL
19
+ class ButtonWidget < Lustr::XmlBasedWidget
20
+ def generate(xml)
21
+ xml.xul :button, xml.net_attrs('id'=>option(:name),
22
+ 'label'=>option(:text),
23
+ 'oncommand'=>action(option(:on_click))) do
24
+ xml.descend(self)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Lustr.declare(Lustr::SimpleBuilder.new(:button, Lustr4XUL::ButtonWidget))
31
+
@@ -0,0 +1,43 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ require 'lustr'
17
+
18
+ module Lustr4XUL
19
+ class DividedBoxWidget < Lustr::XmlBasedWidget
20
+ def generate(xml)
21
+ if option(:direction)==:horizontal
22
+ xml.xul :hbox, xml.net_attrs('id'=>option(:name), 'flex'=>option(:flex)) do
23
+ xml.descend(self) {
24
+ xml.xul :splitter do
25
+ xml.xul :grippy
26
+ end
27
+ }
28
+ end
29
+ else
30
+ xml.xul :vbox, xml.net_attrs('id'=>option(:name)) do
31
+ xml.descend(self) {
32
+ xml.xul :splitter do
33
+ xml.xul :grippy
34
+ end
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ Lustr.declare(Lustr::SimpleBuilder.new(:divided_box, Lustr4XUL::DividedBoxWidget))
43
+
@@ -0,0 +1,31 @@
1
+ =begin
2
+ This file is part of Lustr (http://rubyforge.org/projects/lustr).
3
+
4
+ Copyright (c) 2007 Mark L. Murphy.
5
+
6
+ Lustr is free software; you can redistribute it and/or modify it under the
7
+ terms of the GNU General Public License as published by the Free Software
8
+ Foundation; either version 2 of the License.
9
+
10
+ Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ details. This file is included in the Ruby gem as License.txt.
14
+ =end
15
+
16
+ require 'lustr'
17
+
18
+ module Lustr4XUL
19
+ class FieldWidget < Lustr::XmlBasedWidget
20
+ def generate(xml)
21
+ xml.xul :textbox, xml.net_attrs('id'=>option(:name),
22
+ 'type'=>(option(:password) ? 'password' : nil),
23
+ 'oninput'=>action(option(:on_change))) do
24
+ xml.descend(self)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Lustr.declare(Lustr::SimpleBuilder.new(:field, Lustr4XUL::FieldWidget))
31
+