mittens_ui 0.0.16 → 0.0.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce8a7d0aa1723a2134b6364e0e6fda2c2b9cd4e91b4e05c4f4ca6e948428c643
4
- data.tar.gz: 34d9f15cb0cae6dedbc33bd62a8e2a137c06323d196fb607295ddd47b66196a2
3
+ metadata.gz: c853332d958f3db1b9c3fcf0257a81b8658c753844560fc313af3a874852182d
4
+ data.tar.gz: 7ab8875182370c9f4ea193c8e37c1dcd36d10912e97308c51a9de78e83aff9f1
5
5
  SHA512:
6
- metadata.gz: 3528b40c3376faf23d93874d84247cfa6bcfa4b59f932a3e6000090619aa26c7dba5a2ff617f8530ca1cb62096f97ac533a4235da5ba91479e2dc9fa2601bb9d
7
- data.tar.gz: b1c75473975e722ca380dda49dba9566128bc8becae1e6937a7e02a543361b367f5eb57a7b9c6837e980c95e7fa837583ce85a20c55c076ff4c3b664789ab932
6
+ metadata.gz: 8a4ce1db12ab26e00675371d60c1a120db50ee1c06618919532fee35bec5f2302c5b65cd006aece45b07f40d13416f0df55f916a3e6edc424668643aa9ccd0af
7
+ data.tar.gz: e1a05208a5dc5954bf140dcb7398bb55d4fe9949db7e80b7fd370b65d8732368cacabd7e98be6c6cba642cd5d9a0df58f4d30ed9b90b0061e6ed0cc190105dfa
data/README.md CHANGED
@@ -1,22 +1,8 @@
1
1
  # MittensUi
2
2
 
3
- A lightweight Ruby GUI toolkit built on top of GTK, inspired by Ruby Shoes. MittensUi wraps the complexity of GTK so you can build desktop apps with plain Ruby objects and a simple, natural API — no DSLs, no magic, just Ruby.
3
+ A lightweight Ruby GUI toolkit built on top of GTK, inspired by Ruby Shoes. MittensUi wraps the complexity of GTK so you can build desktop apps in Ruby.
4
4
 
5
- We will always try to keep up with the latest GTK updates.
6
-
7
- ## Requirements
8
-
9
- MittensUi requires GTK native libraries to be installed on your system.
10
-
11
- **Ubuntu / Debian**
12
- ```bash
13
- sudo apt install build-essential libgtk-4-dev libcairo2-dev
14
- ```
15
-
16
- **macOS**
17
- ```bash
18
- brew install gtk+4 cairo pkg-config
19
- ```
5
+ We always try to keep up with the latest GTK updates.
20
6
 
21
7
  ## Installation
22
8
 
@@ -81,7 +67,7 @@ Two `:half` widgets placed back to back sit side by side automatically. A `:full
81
67
 
82
68
  ### Horizontal Rows
83
69
 
84
- Use `HBox` to place widgets side by side in a row. The block style is recommended — no `defer_render` needed:
70
+ Use `HBox` to place widgets side by side in a row:
85
71
  ```ruby
86
72
  MittensUi::HBox.new(spacing: 8) do
87
73
  MittensUi::Label.new("Name:")
@@ -161,7 +147,7 @@ Buttons support a loading state that disables the button and shows a spinner whi
161
147
  ```ruby
162
148
  btn.click do
163
149
  btn.loading do
164
- sleep 2 # runs in background thread
150
+ sleep 2 # runs on a background thread
165
151
  puts "done!"
166
152
  end
167
153
  end
@@ -221,7 +207,7 @@ lb.clear_search
221
207
  ### Slider
222
208
  ```ruby
223
209
  s = MittensUi::Slider.new(start_value: 0, stop_value: 100, initial_value: 50)
224
- s.slide { |widget| puts widget.value }
210
+ s.slide { |widget, value| puts "#{widget}: #{value}" }
225
211
  ```
226
212
 
227
213
  ### Switch
@@ -268,7 +254,7 @@ MittensUi::Notify.new("Saved!", type: :info) # banner notification
268
254
  ```ruby
269
255
  loader = MittensUi::Loader.new
270
256
  loader.start do
271
- sleep 3 # runs in background thread
257
+ sleep 3 # runs on a background thread
272
258
  end
273
259
  ```
274
260
 
@@ -304,7 +290,7 @@ MittensUi::WebLink.new("GitHub", "https://github.com")
304
290
 
305
291
  ### Separator
306
292
  ```ruby
307
- MittensUi::Separator.new # horizontal (default)
293
+ MittensUi::Separator.new
308
294
  MittensUi::Separator.new(:horizontal, top: 10, bottom: 10) # with margin
309
295
  ```
310
296
 
@@ -326,7 +312,7 @@ MittensUi::HBox.new(spacing: 8) do
326
312
  end
327
313
  end
328
314
 
329
- # array style — requires defer_render: true on each widget
315
+ # array style — requires `defer_render: true` attribute to be set on each widget
330
316
  MittensUi::HBox.new([
331
317
  MittensUi::Button.new(title: "OK", defer_render: true),
332
318
  MittensUi::Button.new(title: "Cancel", defer_render: true)
@@ -335,11 +321,12 @@ MittensUi::HBox.new([
335
321
 
336
322
  ## Development
337
323
 
338
- **Setup Ruby**
339
- # setup and install Ruby if you have not done so:
324
+ MittensUi requires GTK native libraries to be installed on your system.
325
+
326
+ ### Install Ruby if you have not done so:
340
327
  ```bash
341
328
  rbenv install 4.0.0
342
- rbenv global 4.0.0`
329
+ rbenv global 4.0.0
343
330
  ```
344
331
 
345
332
  **Linux**
@@ -351,9 +338,9 @@ bundle install
351
338
 
352
339
  **macOS**
353
340
  ```bash
354
- brew install gtk+3 cairo pkg-config rbenv
341
+ brew install gtk4 cairo pkg-config rbenv
355
342
 
356
- git clone https://github.com/tuttza/mittens_ui.git
343
+ git clone https://codeberg.com/tuttza/mittens_ui.git
357
344
  cd mittens_ui
358
345
  bundle install
359
346
  ```
@@ -363,15 +350,11 @@ Run the test suite:
363
350
  bundle exec rspec
364
351
  ```
365
352
 
366
- Generate docs:
353
+ Generate API docs:
367
354
  ```bash
368
355
  bundle exec yard doc
369
356
  ```
370
357
 
371
- ## Contributing
372
-
373
- Bug reports and pull requests are welcome on GitHub at https://github.com/tuttza/mittens_ui.
374
-
375
358
  ## License
376
359
 
377
360
  Available under the MIT License.
data/examples/mig.rb CHANGED
@@ -66,7 +66,7 @@ MittensUi::Application.Window(app_options) do
66
66
  MittensUi::Separator.new(:horizontal, top: 10, bottom: 10)
67
67
 
68
68
  s = MittensUi::Slider.new({ start_value: 1, stop_value: 100, initial_value: 30 })
69
- s.slide { |value| puts "slider value: #{value}" }
69
+ s.slide { |w, v| puts "slider: #{w} value: #{v}" }
70
70
 
71
71
  switch = MittensUi::Switch.new(left: 220)
72
72
  switch.on do
@@ -38,7 +38,7 @@ module MittensUi
38
38
  # @return [void]
39
39
  def toggle
40
40
  @checkbox.signal_connect('toggled') do
41
- yield
41
+ yield(self)
42
42
  end
43
43
  end
44
44
 
@@ -51,8 +51,8 @@ module MittensUi
51
51
  def initialize(widget, options = {})
52
52
  @core_widget = widget # This represents the GTK widget.
53
53
  @core_widget.focusable = true
54
- @width = options[:width] || :full
55
- @defer_render = options[:defer_render] || false
54
+ @width = options.fetch(:width, :full)
55
+ @defer_render = options.fetch(:defer_render, false)
56
56
  set_margin_from_opts_for(@core_widget, options)
57
57
  render unless @defer_render
58
58
  enable_hover_focus
@@ -59,7 +59,7 @@ module MittensUi
59
59
  # end
60
60
  def move
61
61
  @scale.signal_connect('value_changed') do |scale_widget|
62
- yield(scale_widget.value)
62
+ yield(scale_widget, scale_widget.value)
63
63
  end
64
64
  end
65
65
  alias slide move
@@ -1,3 +1,3 @@
1
1
  module MittensUi
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.18"
3
3
  end
data/lib/mittens_ui.rb CHANGED
@@ -227,10 +227,10 @@ module MittensUi
227
227
  # @yield [window] the GTK application window
228
228
  # @return [void]
229
229
  def init_gtk_application(options, &block)
230
- app_name = options[:name] || 'mittens_ui_app'
231
- height = options[:height] || 600
232
- width = options[:width] || 400
233
- title = options[:title] || 'Mittens App'
230
+ app_name = options.fetch(:name, 'mittens_ui_app')
231
+ height = options.fetch(:height, 600)
232
+ width = options.fetch(:width, 400)
233
+ title = options.fetch(:title, 'Mittens App')
234
234
  can_resize = options.fetch(:can_resize, true)
235
235
  theme = options.fetch(:theme, :system)
236
236
  app_assets_path = File.join(__dir__, 'mittens_ui', 'assets')
data/mittens_ui.gemspec CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |spec|
8
8
  spec.licenses = ['MIT']
9
9
  spec.summary = "A tiny GUI toolkit written on top of GTK"
10
10
  spec.description = "GUI Toolkit!"
11
- spec.homepage = "https://github.com/tuttza/mittens_ui"
11
+ spec.homepage = "https://codeberg.org/tuttza/mittens_ui"
12
12
  spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
13
13
 
14
14
  #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://codeberg.org/tuttza/mittens_ui"
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
18
  #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mittens_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Tuttle
@@ -147,11 +147,11 @@ files:
147
147
  - mittens_ui.gemspec
148
148
  - notes/dev_setup.txt
149
149
  - notes/gtk.txt
150
- homepage: https://github.com/tuttza/mittens_ui
150
+ homepage: https://codeberg.org/tuttza/mittens_ui
151
151
  licenses:
152
152
  - MIT
153
153
  metadata:
154
- homepage_uri: https://github.com/tuttza/mittens_ui
154
+ homepage_uri: https://codeberg.org/tuttza/mittens_ui
155
155
  source_code_uri: https://codeberg.org/tuttza/mittens_ui
156
156
  rdoc_options: []
157
157
  require_paths: