dclext-gtk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ ext/Makefile
2
+ ext/mkmf.log
3
+ ext/*.o
4
+ ext/*.so
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in narray_miss.gemspec
4
+ gemspec
@@ -0,0 +1,34 @@
1
+ RubyDCLExt-Gtk is copyrighted free software by Seiya Nishizawa and GFD
2
+ Dennou Club (http://www.gfd-dennou.org/).
3
+
4
+ Copyright 2001 (C) Seiya Nishizawa and GFD Dennou Club
5
+ (http://www.gfd-dennou.org/) All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are
9
+ met:
10
+
11
+ 1. Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+
14
+ 2. Redistributions in binary form must reproduce the above copyright
15
+ notice, this list of conditions and the following disclaimer in
16
+ the documentation and/or other materials provided with the
17
+ distribution.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY GFD DENNOU CLUB AND CONTRIBUTORS ``AS IS''
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GFD DENNOU CLUB OR
23
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ The views and conclusions contained in the software and documentation
32
+ are those of the authors and should not be interpreted as representing
33
+ official policies, either expressed or implied, of Seiya Nishizawa
34
+ and GFD Dennou Club.
@@ -0,0 +1,41 @@
1
+ = What's RubyDCLExt-Gtk
2
+
3
+ RubyDCLExt-Gtk is an extension for RubyDCL
4
+ to support extra operation related with Gtk.
5
+
6
+
7
+ = RubyDCLExt-Gtk home-page
8
+
9
+ The URL of the RubyDCLExt-Gtk home-page is:
10
+ http://ruby.gfd-dennou.org/products/ruby-dclext-gtk/
11
+
12
+
13
+ = Requires
14
+
15
+ * Ruby (http://www.ruby-lang.org/)
16
+ * RubyDCL (http://ruby.gfd-dennou.org/products/ruby-dcl/)
17
+ * Ruby-Gtk2 (http://ruby-gnome2.sourceforge.jp/)
18
+
19
+
20
+ = Install
21
+
22
+ # gem install dclext-gtk
23
+
24
+
25
+ = Copying
26
+
27
+ See the file LICENSE.txt.
28
+
29
+
30
+ = Usage
31
+
32
+ To use this library, put the following in your script.
33
+ require 'numru/dclext/gtk'
34
+
35
+
36
+ = The Author
37
+
38
+ Feel free to send comments and bug reports to the author.
39
+ The author's e-mail addess is
40
+
41
+ seiya@gfd-dennou.org
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "numru/dclext/gtk/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "dclext-gtk"
7
+ s.version = NumRu::DCLExt::Gtk::VERSION
8
+ s.authors = ["Seiya Nishizawa"]
9
+ s.email = ["seiya@gfd-dennou.org"]
10
+ s.homepage = "http://ruby.gfd-dennou.org/products/ruby-dclext-gtk/"
11
+ s.summary = %q{Gtk extension for RubyDCL}
12
+ s.description = %q{RubyDCLExt-Gtk is an extension for RubyDCL to support extra operation related with Gtk.}
13
+
14
+ s.rubyforge_project = "dclext-gtk"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.extensions << "ext/extconf.rb"
21
+
22
+ # specify any dependencies here; for example:
23
+ #s.add_development_dependency "rspec"
24
+ #s.add_runtime_dependency "numru/dcl"
25
+ s.add_runtime_dependency "gtk2"
26
+ end
@@ -0,0 +1,89 @@
1
+ #include <gtk/gtk.h>
2
+ #include <gdk/gdk.h>
3
+ #include "ruby.h"
4
+
5
+ #define RVAL2GOBJ(obj) (rbgobj_instance_from_ruby_object(obj))
6
+ #define GOBJ2RVAL(gobj) (rbgobj_ruby_object_from_instance(gobj))
7
+
8
+ extern gpointer rbgobj_instance_from_ruby_object(VALUE obj);
9
+ extern VALUE rbgobj_ruby_object_from_instance(gpointer instance);
10
+
11
+
12
+ static VALUE
13
+ dcl_zgsdrw(self, drawable)
14
+ VALUE self, drawable;
15
+ {
16
+ extern void zgsdrw_(GtkWidget*);
17
+
18
+ zgsdrw_( GTK_WIDGET(RVAL2GOBJ(drawable)) );
19
+
20
+ return Qnil;
21
+ }
22
+
23
+ static VALUE
24
+ dcl_zgspmp(self, pixmap)
25
+ VALUE self, pixmap;
26
+ {
27
+ extern void zgspmp_(GdkPixmap*);
28
+
29
+ GdkPixmap *c_pixmap = RVAL2GOBJ(pixmap);
30
+ g_object_ref(G_OBJECT(c_pixmap));
31
+ zgspmp_( (c_pixmap) );
32
+
33
+ return Qnil;
34
+ }
35
+
36
+ static VALUE
37
+ dcl_zgqdrw(self)
38
+ VALUE self;
39
+ {
40
+ extern GtkWidget *zgqdrw_(void);
41
+
42
+ return GOBJ2RVAL(zgqdrw_());
43
+
44
+ }
45
+
46
+ static VALUE
47
+ dcl_zgqpmp(self)
48
+ VALUE self;
49
+ {
50
+ extern GdkPixmap *zgqpmp_(void);
51
+
52
+ return GOBJ2RVAL(zgqpmp_());
53
+
54
+ }
55
+
56
+ static VALUE
57
+ r_gtk_version(self)
58
+ VALUE self;
59
+ {
60
+ return rb_ary_new3(3,
61
+ INT2NUM(gtk_major_version),
62
+ INT2NUM(gtk_minor_version),
63
+ INT2NUM(gtk_micro_version));
64
+ }
65
+
66
+
67
+ void
68
+ Init_gtk()
69
+ {
70
+
71
+ VALUE mNumRu, mDCLExt;
72
+
73
+ rb_require("gtk2");
74
+ rb_require("numru/dcl");
75
+
76
+ mNumRu = rb_define_module("NumRu");
77
+ mDCLExt = rb_define_module_under(mNumRu, "DCLExt");
78
+
79
+
80
+ rb_define_module_function(mDCLExt, "gtk_version", r_gtk_version, 0);
81
+
82
+ rb_define_module_function(mDCLExt, "zgsdrw", dcl_zgsdrw, 1);
83
+ rb_define_module_function(mDCLExt, "zgspmp", dcl_zgspmp, 1);
84
+
85
+ rb_define_module_function(mDCLExt, "zgqdrw", dcl_zgqdrw, 0);
86
+ rb_define_module_function(mDCLExt, "zgqpmp", dcl_zgqpmp, 0);
87
+
88
+ }
89
+
@@ -0,0 +1,19 @@
1
+ require "mkmf"
2
+
3
+ if(xsystem("which cdclconfig"))
4
+ gtkversion = `cdclconfig --gtkversion`.chop
5
+ unless $?.exitstatus == 0
6
+ raise "cdcl was not compiled with gtk"
7
+ end
8
+ else
9
+ raise "cannot find cdclconfig"
10
+ end
11
+
12
+ $CPPFLAGS = `cdclconfig --cflags`.chop + " " + $CPPFLAGS
13
+ unless have_header("gtk/gtk.h")
14
+ raise "cannot find gtk/gtk.h"
15
+ end
16
+
17
+ $LDFLAGS = `cdclconfig --ldflags`.chop + " " + $LDFLAGS
18
+
19
+ create_makefile("numru/dclext/gtk")
@@ -0,0 +1,2 @@
1
+ require "numru/dcl"
2
+ require "numru/dclext/gtk.so"
@@ -0,0 +1,7 @@
1
+ module NumRu
2
+ module DCLExt
3
+ module Gtk
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ require "test/unit"
2
+ require "fileutils"
3
+ require "numru/dclext/gtk"
4
+ include NumRu
5
+
6
+
7
+ class TestGet < Test::Unit::TestCase
8
+ DUMP_FNAME = ".dclext_test"
9
+
10
+ def setup
11
+ @padding = 2
12
+
13
+ @width = 15
14
+ @height = 10
15
+
16
+ DCL.swlset("lwnd", false)
17
+ DCL.swcset("fname", DUMP_FNAME)
18
+ DCL.swiset("iwidth", @width)
19
+ DCL.swiset("iheight", @height)
20
+ DCL.gropn(4)
21
+ end
22
+ def teardown
23
+ DCL.grcls
24
+ Dir[DUMP_FNAME+"*.png"].each do |fname|
25
+ FileUtils.rm(fname)
26
+ end
27
+ end
28
+
29
+ def test_get_gobj
30
+ drawing_area = DCLExt.zgqdrw
31
+ allocation = drawing_area.allocation
32
+ assert_equal @width+@padding*2, allocation.width
33
+ assert_equal @height+@padding*2, allocation.height
34
+
35
+ pixmap = DCLExt.zgqpmp
36
+ size = pixmap.size
37
+ assert_equal @width+@padding*2, size[0]
38
+ assert_equal @height+@padding*2, size[1]
39
+ end
40
+
41
+ end
42
+
@@ -0,0 +1,38 @@
1
+ require "test/unit"
2
+ require "fileutils"
3
+ require "numru/dclext/gtk"
4
+ include NumRu
5
+
6
+
7
+ class TestSet < Test::Unit::TestCase
8
+ DUMP_FNAME = ".dclext_test"
9
+
10
+ def setup
11
+ @padding = 2
12
+
13
+ @width = 15
14
+ @height = 10
15
+
16
+ @drawing_area = Gtk::DrawingArea.new
17
+ @drawing_area.set_size_request(@width+@padding*2, @height+@padding*2)
18
+ @drawing_area.show
19
+ window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
20
+ window.add(@drawing_area)
21
+ @drawing_area.realize
22
+ @pixmap = Gdk::Pixmap.new(window.window, @width, @height, -1)
23
+
24
+ DCL.zgsdrw(@drawing_area)
25
+ DCL.zgspmp(@pixmap)
26
+ DCL.gropn(4)
27
+ end
28
+ def teardown
29
+ DCL.grcls
30
+ end
31
+
32
+ def test_set_gobj
33
+ assert_equal @drawing_area, DCLExt.zgqdrw
34
+ assert_equal @pixmap, DCLExt.zgqpmp
35
+ end
36
+
37
+ end
38
+
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dclext-gtk
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Seiya Nishizawa
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-31 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: gtk2
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: RubyDCLExt-Gtk is an extension for RubyDCL to support extra operation related with Gtk.
35
+ email:
36
+ - seiya@gfd-dennou.org
37
+ executables: []
38
+
39
+ extensions:
40
+ - ext/extconf.rb
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE.txt
47
+ - README.rdoc
48
+ - Rakefile
49
+ - dclext-gtk.gemspec
50
+ - ext/dclext_gtk.c
51
+ - ext/extconf.rb
52
+ - lib/numru/dclext/gtk.rb
53
+ - lib/numru/dclext/gtk/version.rb
54
+ - test/test_get.rb
55
+ - test/test_set.rb
56
+ homepage: http://ruby.gfd-dennou.org/products/ruby-dclext-gtk/
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project: dclext-gtk
85
+ rubygems_version: 1.8.11
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Gtk extension for RubyDCL
89
+ test_files:
90
+ - test/test_get.rb
91
+ - test/test_set.rb