mittens_ui 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +71 -0
- data/README.md +67 -0
- data/Rakefile +14 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/app.rb +31 -0
- data/lib/mittens_ui/dsl_parser.rb +17 -0
- data/lib/mittens_ui/layouts/box.rb +36 -0
- data/lib/mittens_ui/layouts/grid.rb +28 -0
- data/lib/mittens_ui/layouts/stack.rb +21 -0
- data/lib/mittens_ui/version.rb +3 -0
- data/lib/mittens_ui/widgets/alert.rb +32 -0
- data/lib/mittens_ui/widgets/button.rb +29 -0
- data/lib/mittens_ui/widgets/label.rb +24 -0
- data/lib/mittens_ui/widgets/textbox.rb +26 -0
- data/lib/mittens_ui.rb +87 -0
- data/mittens_ui.gemspec +30 -0
- metadata +79 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d32efa4db9206db28408060f91ed79079017480cc8842b9e63f0631e19681312
|
|
4
|
+
data.tar.gz: 24b8fcd5e02eea0ee33f4c33a1c990819170a7d3759ba9bc0bbb19252ea866e0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e91dd5b43aa3e93400142759029e823e7f6f905c38b10aa1551d619d3b94dd0185b2650e25f1c0b4e6fc5f5114b9c512df362c8456f67d8581b6026be36283e0
|
|
7
|
+
data.tar.gz: 9dde2bd8508f239ca99f9a1fd0bee0baec875f401aaa7b3283cc0da735aaf46b0e7d853767e096395b743b5edd9d60e62a799c5b6621f554c7aca499ecfb56f2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
mittens_ui (0.1.0)
|
|
5
|
+
gtk3
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
atk (3.4.3)
|
|
11
|
+
glib2 (= 3.4.3)
|
|
12
|
+
cairo (1.16.6)
|
|
13
|
+
native-package-installer (>= 1.0.3)
|
|
14
|
+
pkg-config (>= 1.2.2)
|
|
15
|
+
cairo-gobject (3.4.3)
|
|
16
|
+
cairo (>= 1.16.2)
|
|
17
|
+
glib2 (= 3.4.3)
|
|
18
|
+
diff-lcs (1.4.4)
|
|
19
|
+
gdk3 (3.4.3)
|
|
20
|
+
cairo-gobject (= 3.4.3)
|
|
21
|
+
gdk_pixbuf2 (= 3.4.3)
|
|
22
|
+
pango (= 3.4.3)
|
|
23
|
+
gdk_pixbuf2 (3.4.3)
|
|
24
|
+
gio2 (= 3.4.3)
|
|
25
|
+
gio2 (3.4.3)
|
|
26
|
+
gobject-introspection (= 3.4.3)
|
|
27
|
+
glib2 (3.4.3)
|
|
28
|
+
native-package-installer (>= 1.0.3)
|
|
29
|
+
pkg-config (>= 1.3.5)
|
|
30
|
+
gobject-introspection (3.4.3)
|
|
31
|
+
glib2 (= 3.4.3)
|
|
32
|
+
gtk3 (3.4.3)
|
|
33
|
+
atk (= 3.4.3)
|
|
34
|
+
gdk3 (= 3.4.3)
|
|
35
|
+
gdk_pixbuf2 (= 3.4.3)
|
|
36
|
+
gio2 (= 3.4.3)
|
|
37
|
+
pango (= 3.4.3)
|
|
38
|
+
native-package-installer (1.0.9)
|
|
39
|
+
pango (3.4.3)
|
|
40
|
+
cairo-gobject (= 3.4.3)
|
|
41
|
+
gobject-introspection (= 3.4.3)
|
|
42
|
+
pkg-config (1.4.2)
|
|
43
|
+
rake (12.3.3)
|
|
44
|
+
rake-compiler (1.1.1)
|
|
45
|
+
rake
|
|
46
|
+
rspec (3.9.0)
|
|
47
|
+
rspec-core (~> 3.9.0)
|
|
48
|
+
rspec-expectations (~> 3.9.0)
|
|
49
|
+
rspec-mocks (~> 3.9.0)
|
|
50
|
+
rspec-core (3.9.2)
|
|
51
|
+
rspec-support (~> 3.9.3)
|
|
52
|
+
rspec-expectations (3.9.2)
|
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
|
+
rspec-support (~> 3.9.0)
|
|
55
|
+
rspec-mocks (3.9.1)
|
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
57
|
+
rspec-support (~> 3.9.0)
|
|
58
|
+
rspec-support (3.9.3)
|
|
59
|
+
|
|
60
|
+
PLATFORMS
|
|
61
|
+
ruby
|
|
62
|
+
|
|
63
|
+
DEPENDENCIES
|
|
64
|
+
gtk3
|
|
65
|
+
mittens_ui!
|
|
66
|
+
rake (~> 12.0)
|
|
67
|
+
rake-compiler
|
|
68
|
+
rspec (~> 3.0)
|
|
69
|
+
|
|
70
|
+
BUNDLED WITH
|
|
71
|
+
1.17.3
|
data/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# MittensUi
|
|
2
|
+
|
|
3
|
+
This is a small GUI toolkit inspired by Ruby Shoes and built on top of the GTK Ruby libraries. This isn't meant to be a wrapper
|
|
4
|
+
around GTK (but kind of is right now in its early stage). The goal of this project is make creating GUIs in Ruby dead simple
|
|
5
|
+
without the UI framework/library getting your way.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'mittens_ui'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle install
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install mittens_ui
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
require "mittens_ui"
|
|
27
|
+
|
|
28
|
+
app_options = {
|
|
29
|
+
title: "Mittens App Window Test!",
|
|
30
|
+
height: 400,
|
|
31
|
+
width: 350,
|
|
32
|
+
can_resize: true
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
MittensUi::Application.Window(app_options) do |window|
|
|
36
|
+
MittensUi::Box(window) do |box|
|
|
37
|
+
label_opts = {
|
|
38
|
+
layout: { box: box }
|
|
39
|
+
}
|
|
40
|
+
MittensUi::Label("Enter Name:", label_opts)
|
|
41
|
+
|
|
42
|
+
textbox_options = {
|
|
43
|
+
can_edit: true,
|
|
44
|
+
layout: { box: box }
|
|
45
|
+
}
|
|
46
|
+
text_box = MittensUi::Textbox(textbox_options)
|
|
47
|
+
|
|
48
|
+
btn1_options ={
|
|
49
|
+
title: "Click Here",
|
|
50
|
+
layout: { box: box }
|
|
51
|
+
}
|
|
52
|
+
MittensUi::Button(btn1_options) do
|
|
53
|
+
MittensUi::Alert(window, "Hello #{text_box.text}!")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
62
|
+
|
|
63
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tuttza/mittens_ui.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
|
+
|
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
5
|
+
|
|
6
|
+
require "rake/extensiontask"
|
|
7
|
+
|
|
8
|
+
task :build => :compile
|
|
9
|
+
|
|
10
|
+
Rake::ExtensionTask.new("mittens_ui") do |ext|
|
|
11
|
+
ext.lib_dir = "lib/mittens_ui"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
task :default => [:clobber, :compile, :spec]
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "mittens_ui"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/examples/app.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require '../lib/mittens_ui'
|
|
2
|
+
|
|
3
|
+
app_options = {
|
|
4
|
+
title: "Say Hello!",
|
|
5
|
+
height: 400,
|
|
6
|
+
width: 350,
|
|
7
|
+
can_resize: true
|
|
8
|
+
}.freeze
|
|
9
|
+
|
|
10
|
+
MittensUi::Application.Window(app_options) do |window|
|
|
11
|
+
MittensUi::Box(window) do |box|
|
|
12
|
+
label_opts = {
|
|
13
|
+
layout: { box: box }
|
|
14
|
+
}
|
|
15
|
+
MittensUi::Label("Enter Name:", label_opts)
|
|
16
|
+
|
|
17
|
+
textbox_options = {
|
|
18
|
+
can_edit: true,
|
|
19
|
+
layout: { box: box }
|
|
20
|
+
}
|
|
21
|
+
text_box = MittensUi::Textbox(textbox_options)
|
|
22
|
+
|
|
23
|
+
btn1_options ={
|
|
24
|
+
title: "Click Here",
|
|
25
|
+
layout: { box: box }
|
|
26
|
+
}
|
|
27
|
+
MittensUi::Button(btn1_options) do
|
|
28
|
+
MittensUi::Alert(window, "Hello #{text_box.text}!")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Layouts
|
|
3
|
+
class Box
|
|
4
|
+
class << self
|
|
5
|
+
def init(window, block = Proc.new)
|
|
6
|
+
box = Gtk::Box.new(:vertical, 6)
|
|
7
|
+
block.call(box)
|
|
8
|
+
window.add(box)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def attach(widget, options)
|
|
12
|
+
box_ref = options[:box]
|
|
13
|
+
|
|
14
|
+
expand = options.dig(:expand).nil? ? true : options.dig(:expand)
|
|
15
|
+
fill = options.dig(:fill).nil? ? true : options.dig(:fill)
|
|
16
|
+
padding = options.dig(:padding).nil? ? 0 : options.dig(:padding)
|
|
17
|
+
|
|
18
|
+
filterd_options = {
|
|
19
|
+
expaned: expand,
|
|
20
|
+
fill: fill,
|
|
21
|
+
padding: padding
|
|
22
|
+
}.freeze
|
|
23
|
+
|
|
24
|
+
case options.dig(:position)
|
|
25
|
+
when :start
|
|
26
|
+
box_ref.pack_start(widget, filterd_options)
|
|
27
|
+
when :end
|
|
28
|
+
box_ref.pack_end(widget, filterd_options)
|
|
29
|
+
when nil
|
|
30
|
+
box_ref.pack_start(widget, filterd_options)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Layouts
|
|
3
|
+
class Grid
|
|
4
|
+
class << self
|
|
5
|
+
def init(window, block = Proc.new)
|
|
6
|
+
grid = Gtk::Grid.new
|
|
7
|
+
block.call grid
|
|
8
|
+
window.add_child(grid)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def attach(widget, options)
|
|
12
|
+
grid = options[:grid]
|
|
13
|
+
grid_height = options[:height]
|
|
14
|
+
grid_width = options[:width]
|
|
15
|
+
grid_top = options[:top]
|
|
16
|
+
grid_left = options[:left]
|
|
17
|
+
|
|
18
|
+
if !grid.nil?
|
|
19
|
+
grid.attach(widget, grid_left, grid_top, grid_width, grid_height)
|
|
20
|
+
else
|
|
21
|
+
raise "You much pass a MittensUI:Grid or pass the Main app Window via the options hash."
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Layouts
|
|
3
|
+
class Stack
|
|
4
|
+
class << self
|
|
5
|
+
def init(window, block = Proc.new)
|
|
6
|
+
stack = Gtk::Stack.new
|
|
7
|
+
block.call(stack)
|
|
8
|
+
window.add_child(stack)
|
|
9
|
+
stack
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def attach(widget, options)
|
|
13
|
+
stack = options[:stack]
|
|
14
|
+
if stack
|
|
15
|
+
stack.add(widget)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Widgets
|
|
3
|
+
class Alert
|
|
4
|
+
class << self
|
|
5
|
+
def init(window, message, options)
|
|
6
|
+
dialog_options = {
|
|
7
|
+
title: "Alert",
|
|
8
|
+
parent: window,
|
|
9
|
+
flags: [:modal, :destroy_with_parent],
|
|
10
|
+
:buttons => [["_OK", :none]]
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
alert_dialog = Gtk::Dialog.new(dialog_options)
|
|
14
|
+
alert_dialog.set_transient_for(window)
|
|
15
|
+
alert_dialog.set_default_width(420)
|
|
16
|
+
alert_dialog.set_default_height(200)
|
|
17
|
+
|
|
18
|
+
message_label = Gtk::Label.new(message)
|
|
19
|
+
dialog_box = alert_dialog.content_area
|
|
20
|
+
dialog_box.add(message_label)
|
|
21
|
+
|
|
22
|
+
alert_dialog.show_all
|
|
23
|
+
|
|
24
|
+
response = alert_dialog.run
|
|
25
|
+
|
|
26
|
+
response == :none ? alert_dialog.destroy : alert_dialog.destroy
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Widgets
|
|
3
|
+
class Button
|
|
4
|
+
class << self
|
|
5
|
+
def init(options, block = Proc.new)
|
|
6
|
+
button_title = options[:title] || "MittensUi Button"
|
|
7
|
+
layout = options[:layout]
|
|
8
|
+
window = options[:window]
|
|
9
|
+
|
|
10
|
+
button = Gtk::Button.new(label: button_title)
|
|
11
|
+
|
|
12
|
+
if layout[:grid]
|
|
13
|
+
MittensUi::Layouts::Grid.attach(button, layout)
|
|
14
|
+
elsif layout[:stack]
|
|
15
|
+
MittensUi::Layouts::Stack.attach(button, layout)
|
|
16
|
+
elsif layout[:box]
|
|
17
|
+
MittensUi::Layouts::Box.attach(button, layout)
|
|
18
|
+
elsif window
|
|
19
|
+
window.add_child(button)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
button.signal_connect "clicked" do |widget|
|
|
23
|
+
block.call
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Widgets
|
|
3
|
+
class Label
|
|
4
|
+
class << self
|
|
5
|
+
def init(text, options)
|
|
6
|
+
layout = options[:layout]
|
|
7
|
+
window = options[:window]
|
|
8
|
+
|
|
9
|
+
label = Gtk::Label.new(text)
|
|
10
|
+
|
|
11
|
+
if layout[:grid]
|
|
12
|
+
MittensUi::Layouts::Grid.attach(label, layout)
|
|
13
|
+
elsif layout[:stack]
|
|
14
|
+
MittensUi::Layouts::Stack.attach(label, layout)
|
|
15
|
+
elsif layout[:box]
|
|
16
|
+
MittensUi::Layouts::Box.attach(label, layout)
|
|
17
|
+
elsif window
|
|
18
|
+
window.add_child(label)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module MittensUi
|
|
2
|
+
module Widgets
|
|
3
|
+
class Textbox
|
|
4
|
+
class << self
|
|
5
|
+
def init(options, block = Proc.new)
|
|
6
|
+
textbox = Gtk::Entry.new
|
|
7
|
+
layout = options[:layout]
|
|
8
|
+
can_edit = options[:can_edit].nil? ? true : options[:can_edit]
|
|
9
|
+
max_length = options[:max_length].nil? ? 200 : options[:max_length]
|
|
10
|
+
textbox.set_editable(can_edit)
|
|
11
|
+
textbox.set_max_length(max_length)
|
|
12
|
+
|
|
13
|
+
if layout[:grid]
|
|
14
|
+
MittensUi::Layouts::Grid.attach(textbox, layout)
|
|
15
|
+
elsif layout[:stack]
|
|
16
|
+
MittensUi::Layouts::Stack.attach(textbox, layout)
|
|
17
|
+
elsif layout[:box]
|
|
18
|
+
MittensUi::Layouts::Box.attach(textbox, layout)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
textbox
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/lib/mittens_ui.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require "mittens_ui/version"
|
|
2
|
+
|
|
3
|
+
require "mittens_ui/layouts/grid"
|
|
4
|
+
require "mittens_ui/layouts/stack"
|
|
5
|
+
require "mittens_ui/layouts/box"
|
|
6
|
+
|
|
7
|
+
require "mittens_ui/widgets/alert"
|
|
8
|
+
require "mittens_ui/widgets/label"
|
|
9
|
+
require "mittens_ui/widgets/button"
|
|
10
|
+
require "mittens_ui/widgets/textbox"
|
|
11
|
+
|
|
12
|
+
require "gtk3"
|
|
13
|
+
|
|
14
|
+
module MittensUi
|
|
15
|
+
class Error < StandardError; end
|
|
16
|
+
|
|
17
|
+
def self.Alert(window, message, options={})
|
|
18
|
+
MittensUi::Widgets::Alert.init(window, message, options)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.Label(text, options)
|
|
22
|
+
MittensUi::Widgets::Label.init(text, options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.Textbox(options, &block)
|
|
26
|
+
textbox = nil
|
|
27
|
+
|
|
28
|
+
unless block_given?
|
|
29
|
+
textbox = MittensUi::Widgets::Textbox.init(options, nil)
|
|
30
|
+
else
|
|
31
|
+
textbox = MittensUi::Widgets::Textbox.init(options, block = Proc.new)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
if block_given?
|
|
35
|
+
block.call textbox
|
|
36
|
+
else
|
|
37
|
+
return textbox
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.Box(window, &block)
|
|
42
|
+
raise Error.new("A MittensUi::Box must be passed a block.") unless block_given?
|
|
43
|
+
MittensUi::Layouts::Box.init(window, block = Proc.new)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.Grid(window, &block)
|
|
47
|
+
raise "A Grid must be passed a block." unless block_given?
|
|
48
|
+
MittensUi::Layouts::Grid.init(window, block = Proc.new)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.Stack(window, &block)
|
|
52
|
+
raise "A Stack must be passed a block." unless block_given?
|
|
53
|
+
MittensUi::Layouts::Stack.init(window, block = Proc.new)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.Button(options, &block)
|
|
57
|
+
raise "Button must be passed a block." unless block_given?
|
|
58
|
+
MittensUi::Widgets::Button.init(options, block = Proc.new)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class Application
|
|
62
|
+
class << self
|
|
63
|
+
def Window(options = {}, &block)
|
|
64
|
+
init_gtk_toplevel_window(options, &block)
|
|
65
|
+
block.call(@@GTK_WINDOW)
|
|
66
|
+
@@GTK_WINDOW.show_all
|
|
67
|
+
Gtk.main
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def init_gtk_toplevel_window(options)
|
|
71
|
+
@@GTK_WINDOW = Gtk::Window.new(:toplevel)
|
|
72
|
+
|
|
73
|
+
height = options[:height].nil? ? 600 : options[:height]
|
|
74
|
+
width = options[:width].nil? ? 400 : options[:width]
|
|
75
|
+
title = options[:title].nil? ? "Mittens App" : options[:title]
|
|
76
|
+
can_resize = options[:can_resize].nil? ? true : options[:can_resize]
|
|
77
|
+
|
|
78
|
+
@@GTK_WINDOW.set_size_request(width, height)
|
|
79
|
+
@@GTK_WINDOW.set_title(title)
|
|
80
|
+
@@GTK_WINDOW.set_resizable(can_resize)
|
|
81
|
+
|
|
82
|
+
@@GTK_WINDOW.signal_connect("delete-event") { |_widget| Gtk.main_quit }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
data/mittens_ui.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require_relative 'lib/mittens_ui/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "mittens_ui"
|
|
5
|
+
spec.version = MittensUi::VERSION
|
|
6
|
+
spec.authors = ["Zach Tuttle"]
|
|
7
|
+
spec.email = ["zachtuttle@tutanota.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "A tiny GUI tool kit written on top of GTK3"
|
|
10
|
+
spec.description = "GUI Toolkit!"
|
|
11
|
+
spec.homepage = "https://github.com/tuttza/mittens_ui"
|
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
13
|
+
|
|
14
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
15
|
+
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/tuttza/mittens_ui"
|
|
18
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
# spec.bindir = "exe"
|
|
26
|
+
#spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
#spec.extensions = ["ext/mittens_ui/extconf.rb"]
|
|
29
|
+
spec.add_runtime_dependency("gtk3")
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mittens_ui
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Zach Tuttle
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: gtk3
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: GUI Toolkit!
|
|
28
|
+
email:
|
|
29
|
+
- zachtuttle@tutanota.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- ".gitignore"
|
|
35
|
+
- ".rspec"
|
|
36
|
+
- ".travis.yml"
|
|
37
|
+
- Gemfile
|
|
38
|
+
- Gemfile.lock
|
|
39
|
+
- README.md
|
|
40
|
+
- Rakefile
|
|
41
|
+
- bin/console
|
|
42
|
+
- bin/setup
|
|
43
|
+
- examples/app.rb
|
|
44
|
+
- lib/mittens_ui.rb
|
|
45
|
+
- lib/mittens_ui/dsl_parser.rb
|
|
46
|
+
- lib/mittens_ui/layouts/box.rb
|
|
47
|
+
- lib/mittens_ui/layouts/grid.rb
|
|
48
|
+
- lib/mittens_ui/layouts/stack.rb
|
|
49
|
+
- lib/mittens_ui/version.rb
|
|
50
|
+
- lib/mittens_ui/widgets/alert.rb
|
|
51
|
+
- lib/mittens_ui/widgets/button.rb
|
|
52
|
+
- lib/mittens_ui/widgets/label.rb
|
|
53
|
+
- lib/mittens_ui/widgets/textbox.rb
|
|
54
|
+
- mittens_ui.gemspec
|
|
55
|
+
homepage: https://github.com/tuttza/mittens_ui
|
|
56
|
+
licenses: []
|
|
57
|
+
metadata:
|
|
58
|
+
homepage_uri: https://github.com/tuttza/mittens_ui
|
|
59
|
+
source_code_uri: https://github.com/tuttza/mittens_ui
|
|
60
|
+
post_install_message:
|
|
61
|
+
rdoc_options: []
|
|
62
|
+
require_paths:
|
|
63
|
+
- lib
|
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 2.3.0
|
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
requirements: []
|
|
75
|
+
rubygems_version: 3.0.3
|
|
76
|
+
signing_key:
|
|
77
|
+
specification_version: 4
|
|
78
|
+
summary: A tiny GUI tool kit written on top of GTK3
|
|
79
|
+
test_files: []
|