qtjruby-core 0.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +55 -0
- data/Rakefile +78 -0
- data/TODO +3 -0
- data/bin/qtjruby +17 -0
- data/lib/qtjruby-core.jar +0 -0
- data/lib/qtjruby-core.rb +6 -0
- data/lib/qtjruby-core/qt.rb +61 -0
- data/lib/qtjruby-core/qt/ext/application.rb +15 -0
- data/lib/qtjruby-core/qt/ext/object.rb +16 -0
- data/lib/qtjruby-core/version.rb +5 -0
- metadata +76 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2009 Nicolas Mérouze
|
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.textile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
h1. Qt::JRuby
|
2
|
+
|
3
|
+
Build crossplatform applications with Qt and Ruby.
|
4
|
+
|
5
|
+
h1. Create a new application
|
6
|
+
|
7
|
+
*NB*: Java must be installed on your system.
|
8
|
+
|
9
|
+
<pre><code>gem install thor
|
10
|
+
thor install http://qtjruby.org/qtjruby.thor
|
11
|
+
thor qtjruby:app:create myapp
|
12
|
+
cd myapp
|
13
|
+
java -jar lib/jruby-complete-$VERSION.jar main.rb</code></pre>
|
14
|
+
|
15
|
+
h1. Installation from sources
|
16
|
+
|
17
|
+
Download Qt Jambi for your platform. Put qtjambi-$VERSION.jar and qtjambi-$PLATFORM-$VERSION.jar into $JRUBY_HOME/lib folder. Then :
|
18
|
+
|
19
|
+
<pre><code>jruby -S gem install extlib
|
20
|
+
git clone git://github.com/nmerouze/qtjruby-core.git
|
21
|
+
cd /path/to/qtjruby-core
|
22
|
+
jruby -S rake install</code></pre>
|
23
|
+
|
24
|
+
h2. Run
|
25
|
+
|
26
|
+
<pre><code>jruby -S qtjruby example4.rb</code></pre>
|
27
|
+
|
28
|
+
Add <code>-J-XstartOnFirstThread</code> option if you're under Mac OS X.
|
29
|
+
|
30
|
+
h2. Example
|
31
|
+
|
32
|
+
<pre><code>Qt::Application.initialize(ARGV)
|
33
|
+
hello = Qt::PushButton.new 'Hello World!'
|
34
|
+
hello.show
|
35
|
+
Qt::Application.exec</code></pre>
|
36
|
+
|
37
|
+
h1. Where does it work ?
|
38
|
+
|
39
|
+
Tested under:
|
40
|
+
|
41
|
+
* Mac OS X Tiger & Leopard
|
42
|
+
* Ubuntu 8.10 with Java 6 & OpenJDK
|
43
|
+
* Windows XP SP3
|
44
|
+
|
45
|
+
h1. Links
|
46
|
+
|
47
|
+
* Qt::JRuby : http://qtjruby.org & http://qtjruby.googlecode.com
|
48
|
+
* Qt::JRuby sources : http://github.com/nmerouze/qtjruby-core
|
49
|
+
* Qt Jambi Documentation : http://doc.trolltech.com
|
50
|
+
|
51
|
+
h1. License and support
|
52
|
+
|
53
|
+
(C) 2008-2009 Nicolas Mérouze, under an MIT licence. http://www.opensource.org/licenses/mit-license.php
|
54
|
+
|
55
|
+
Please leave any bugs or feedback at nicolas.merouze [at] gmail [dot] com
|
data/Rakefile
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
windows = (ENV_JAVA['os.name'] =~ /Windows/) rescue nil
|
5
|
+
SUDO = windows ? "" : "sudo"
|
6
|
+
|
7
|
+
NAME = 'qtjruby-core'
|
8
|
+
|
9
|
+
require "lib/qtjruby-core/version"
|
10
|
+
|
11
|
+
task :default => [:build, :install]
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = NAME
|
15
|
+
s.version = Qt::JRuby::VERSION
|
16
|
+
s.platform = "java"
|
17
|
+
s.author = "Nicolas Merouze"
|
18
|
+
s.email = "nicolas.merouze@gmail.com"
|
19
|
+
s.summary = "Qt meets Java meets Ruby."
|
20
|
+
s.bindir = "bin"
|
21
|
+
s.executables = %w( qtjruby )
|
22
|
+
s.description = s.summary
|
23
|
+
s.require_path = "lib"
|
24
|
+
s.files = %w( LICENSE README.textile Rakefile TODO ) + Dir["{bin,lib}/**/*"]
|
25
|
+
|
26
|
+
# rdoc
|
27
|
+
s.has_rdoc = true
|
28
|
+
s.extra_rdoc_files = ["LICENSE", "README.textile"]
|
29
|
+
|
30
|
+
# Dependencies
|
31
|
+
s.add_dependency "extlib", "~>0.9.9"
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::GemPackageTask.new(spec) do |package|
|
35
|
+
package.gem_spec = spec
|
36
|
+
end
|
37
|
+
|
38
|
+
task :build do
|
39
|
+
sh %{ant -lib #{ENV_JAVA['jruby.home']}/lib}
|
40
|
+
end
|
41
|
+
|
42
|
+
task :install => :package do
|
43
|
+
sh %{#{SUDO} #{ENV_JAVA['jruby.home']}/bin/jruby -S gem install --local pkg/#{NAME}-#{Qt::JRuby::VERSION}-java.gem --no-update-sources}
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :github do
|
47
|
+
desc "Update Github Gemspec"
|
48
|
+
task :update_gemspec do
|
49
|
+
skip_fields = %w(new_platform original_platform)
|
50
|
+
integer_fields = %w(specification_version)
|
51
|
+
|
52
|
+
result = "Gem::Specification.new do |s|\n"
|
53
|
+
spec.instance_variables.each do |ivar|
|
54
|
+
value = spec.instance_variable_get(ivar)
|
55
|
+
name = ivar.split("@").last
|
56
|
+
next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
|
57
|
+
if name == "dependencies"
|
58
|
+
value.each do |d|
|
59
|
+
dep, *ver = d.to_s.split(" ")
|
60
|
+
result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
|
61
|
+
end
|
62
|
+
else
|
63
|
+
case value
|
64
|
+
when Array
|
65
|
+
value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
|
66
|
+
when String
|
67
|
+
value = value.to_i if integer_fields.include?(name)
|
68
|
+
value = value.inspect
|
69
|
+
else
|
70
|
+
value = value.to_s.inspect
|
71
|
+
end
|
72
|
+
result << " s.#{name} = #{value}\n"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
result << "end"
|
76
|
+
File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
|
77
|
+
end
|
78
|
+
end
|
data/TODO
ADDED
data/bin/qtjruby
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
if File.exist?(lib_dir = Dir.pwd + '/lib')
|
3
|
+
Dir.glob(lib_dir + '/qtjambi-*.jar') { |jar| require jar }
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
|
8
|
+
if File.exist?(gem_dir = File.join(Dir.pwd, 'gems'))
|
9
|
+
Gem.clear_paths
|
10
|
+
Gem.path.unshift(gem_dir)
|
11
|
+
end
|
12
|
+
|
13
|
+
gem 'extlib', '~> 0.9.9'
|
14
|
+
require 'extlib'
|
15
|
+
|
16
|
+
require File.dirname(__FILE__) + '/../lib/qtjruby-core'
|
17
|
+
require ARGV.shift
|
Binary file
|
data/lib/qtjruby-core.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
dir = Pathname(__FILE__).dirname.expand_path / 'qt'
|
2
|
+
|
3
|
+
require dir / 'ext' / 'application'
|
4
|
+
require dir / 'ext' / 'object'
|
5
|
+
|
6
|
+
module Qt
|
7
|
+
include com.trolltech.qt.core.Qt
|
8
|
+
include_package 'org.qtjruby'
|
9
|
+
|
10
|
+
class JambiClass
|
11
|
+
include_package 'com.trolltech.qt.core'
|
12
|
+
include_package 'com.trolltech.qt.gui'
|
13
|
+
include_package 'com.trolltech.qt.webkit'
|
14
|
+
include_package 'com.trolltech.qt.phonon'
|
15
|
+
include_package 'com.trolltech.qt'
|
16
|
+
include_package 'com.trolltech.qt.svg'
|
17
|
+
include_package 'com.trolltech.qt.opengl'
|
18
|
+
|
19
|
+
def self.for_name(name)
|
20
|
+
const_get("Q#{name}"); rescue NameError; const_get(name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
# Create a Qt::JRuby class from a Qt Jambi class.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# name<String>:: The name of the class to create.
|
29
|
+
#
|
30
|
+
# ==== Returns
|
31
|
+
# Class:: The newly created Qt::JRuby class.
|
32
|
+
def const_missing(name)
|
33
|
+
klass = Class.new(Qt::JambiClass.for_name(name))
|
34
|
+
|
35
|
+
klass.class_eval do
|
36
|
+
include Qt::Ext.const_get(name) if Qt::Ext.const_defined?(name)
|
37
|
+
|
38
|
+
self.superclass.java_class.fields.each do |field|
|
39
|
+
self.class_eval %{
|
40
|
+
alias :old_#{field.name} :#{field.name}
|
41
|
+
|
42
|
+
def #{field.name}(*args, &block)
|
43
|
+
Qt::Object.connect(self.old_#{field.name}, self.method('slot'), &block)
|
44
|
+
end
|
45
|
+
|
46
|
+
alias :#{field.name.snake_case} :#{field.name}
|
47
|
+
} if field.type.to_s =~ /QSignalEmitter/
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def slot(*args, &block)
|
53
|
+
block.call(*args) if block_given?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
const_set(name, klass)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Qt
|
2
|
+
module Ext
|
3
|
+
module Object
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
def self.connect(signal, slot, &block)
|
8
|
+
klass = Java::JavaClass.for_name("org.qtjruby.Signals").ruby_class
|
9
|
+
klass.connect(signal, slot, block_given? ? block : nil)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
extensions: []
|
3
|
+
|
4
|
+
homepage:
|
5
|
+
executables:
|
6
|
+
- qtjruby
|
7
|
+
version: !ruby/object:Gem::Version
|
8
|
+
version: 0.3.0
|
9
|
+
post_install_message:
|
10
|
+
date: 2009-01-05 23:00:00 +00:00
|
11
|
+
files:
|
12
|
+
- LICENSE
|
13
|
+
- README.textile
|
14
|
+
- Rakefile
|
15
|
+
- TODO
|
16
|
+
- bin/qtjruby
|
17
|
+
- lib/qtjruby-core
|
18
|
+
- lib/qtjruby-core.jar
|
19
|
+
- lib/qtjruby-core.rb
|
20
|
+
- lib/qtjruby-core/qt
|
21
|
+
- lib/qtjruby-core/qt.rb
|
22
|
+
- lib/qtjruby-core/version.rb
|
23
|
+
- lib/qtjruby-core/qt/ext
|
24
|
+
- lib/qtjruby-core/qt/ext/application.rb
|
25
|
+
- lib/qtjruby-core/qt/ext/object.rb
|
26
|
+
rubygems_version: 1.3.1
|
27
|
+
rdoc_options: []
|
28
|
+
|
29
|
+
signing_key:
|
30
|
+
cert_chain: []
|
31
|
+
|
32
|
+
name: qtjruby-core
|
33
|
+
has_rdoc: true
|
34
|
+
platform: java
|
35
|
+
summary: Qt meets Java meets Ruby.
|
36
|
+
default_executable:
|
37
|
+
bindir: bin
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
version:
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
version:
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
specification_version: 2
|
53
|
+
test_files: []
|
54
|
+
|
55
|
+
dependencies:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
type: :runtime
|
58
|
+
name: extlib
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
version:
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.9.9
|
66
|
+
description: Qt meets Java meets Ruby.
|
67
|
+
email: nicolas.merouze@gmail.com
|
68
|
+
authors:
|
69
|
+
- Nicolas Merouze
|
70
|
+
extra_rdoc_files:
|
71
|
+
- LICENSE
|
72
|
+
- README.textile
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
autorequire:
|