gtk3app 3.0.0 → 5.2.210918

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25f1d4d3cc539cbaa2e1c8961dc053d5d713bee8a32d95fafe9e4f2914fa9cc6
4
- data.tar.gz: 83a1c8e493598daffca2618d0a7ecc10112a8afddab7a709a7f98270c5324105
3
+ metadata.gz: 65620e18ada07b4401b19604ba75868311716e6e5c7182815d4b1d92c6b1ef1f
4
+ data.tar.gz: 768bd649c2b3d6114535abb51efc2821aff736127e2336fd2ea05879af448c7c
5
5
  SHA512:
6
- metadata.gz: 676586049ff04b8595e856bffc723a12e009a0165f352918da887af9ee772866d6a7d4db53c4dccce30c703dfcf9fd09446c09c44fdf9a81522e19ea14403b32
7
- data.tar.gz: 46ed7d0cd569a66b71f7f8636f5aade898d6da90c3508c27fdcc2a8b00c79737b78adff762fcb975df66bdc912e6d1ce4df73d7db8ed8f5fdb6b4f88d81f0b8e
6
+ metadata.gz: 7ffc04e758e68e432323f5b91736e093c2dd0c5e4c4e690f68517ac1e539f72178deaf9646b4db666ca28747ec2e05f689281b470f75d145a54dc5255220a5bb
7
+ data.tar.gz: eb56fa8cfca7d8c54c947c95db04056db0a1a2e07c08b9bb9f32e3b4900cd56cb6de1fb777bdc5763719b5cefc03392bf04fb3cf11dbffc6868ced99fdda97ab
data/README.md CHANGED
@@ -1,29 +1,37 @@
1
- # gt3applib
1
+ # Gtk3App
2
+
3
+ * [VERSION 5.2.210918](https://github.com/carlosjhr64/gtk3app/releases)
4
+ * [github](https://www.github.com/carlosjhr64/gtk3app)
5
+ * [rubygems](https://rubygems.org/gems/gtk3app)
6
+
7
+ ![stub](examples/stub.png)
2
8
 
3
9
  ## DESCRIPTION:
4
10
 
5
11
  Gtk3App provides a
6
12
  [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3)
7
13
  application stub.
8
- It automatically provides for user configuration, application menu, and minime window.
14
+
15
+ The stub provides you with two Expander containers.
16
+ One for a horizontal toolbar.
17
+ The other for your main stage area.
18
+
19
+ ## INSTALL:
20
+
21
+ ```console
22
+ $ sudo gem install gtk3app
23
+ ```
9
24
 
10
25
  ## SYNOPSIS:
11
26
 
12
- Given a module file such as `~./my_app.rb` providing `MyApp`, the module is expected to at least provide MyApp.run(program):
13
-
14
- module MyApp
15
- def self.run(program)
16
- window = program.window
17
- # develop as you would on a Gtk3::Window object...
18
- # ...probably a good idea to show all your work.
19
- window.show_all
20
- self
21
- end
22
- def self.finalyze
23
- # do any cleanups needed at quit time...
24
- end
25
- end
26
- Gtk3App.main(MyApp)
27
+ ```ruby
28
+ require 'gtk3app'
29
+ # Expander = Such::Expander < Gtk::Expander
30
+ # Gtk3App.run do |Expander container, Expander toolbar, HelpParser options|
31
+ Gtk3App.run do |stage, toolbar, options|
32
+ # add stuff to stage and toolbar
33
+ end
34
+ ```
27
35
 
28
36
  That's enough to get you going.
29
37
  The three examples in the [./examples](https://github.com/carlosjhr64/gtk3app/tree/master/examples)
@@ -31,21 +39,24 @@ directory fully explains the rest of what Gtk3App can do for you.
31
39
 
32
40
  ## FEATURES:
33
41
 
34
- * [Such](https://github.com/carlosjhr64/Such) wrappers.
35
- * [Rafini](https://github.com/carlosjhr64/rafini) refinements.
36
- * [UserSpace](https://github.com/carlosjhr64/user_space) XDG support.
37
- * MiniMe, an alternative to the deprecated Gtk::StatusIcon.
38
- * Popup Application Menu from window button 3 press event (standard left click on application).
42
+ * xdg directory maintainance via [UserSpace](https://www.github.com/carlosjhr64/user_space)
43
+ * cofiguration via [RBON](https://www.github.com/carlosjhr64/rbon)
44
+ * command line options via [HelpParser](https://www.github.com/carlosjhr64/Ruby-HelpParser)
45
+ * [Such](https://github.com/carlosjhr64/Such) Gtk::Widget wrappers.
46
+ * default application menu
47
+ * minime window
39
48
 
40
- ## INSTALL:
49
+ ## EXEMPLAR:
50
+
51
+ * [gtk2passwordapp](https://github.com/carlosjhr64/gtk2passwordapp)
41
52
 
42
- $ sudo gem install gtk3app
53
+ ![demo](examples/demo.png)
43
54
 
44
55
  ## LICENSE:
45
56
 
46
57
  * The MIT License
47
58
 
48
- Copyright (c) 2017
59
+ Copyright (c) 2021 CarlosJHR64
49
60
 
50
61
  Permission is hereby granted, free of charge, to any person obtaining
51
62
  a copy of this software and associated documentation files (the
@@ -1,12 +1,15 @@
1
1
  module Gtk3App
2
- using Rafini::String
3
-
4
- # The gem's root directory
5
- APPDIR = File.dirname File.dirname __dir__
6
-
7
- a0 = Rafini::Empty::ARRAY
8
- h0 = Rafini::Empty::HASH
9
- s0 = Rafini::Empty::STRING
2
+ using Rafini::String # provides String#semantic
3
+ extend Rafini::Empty # provides s0, a0, and h0.
4
+
5
+ HELP = <<~HELP
6
+ Usage:
7
+ #{File.basename $0} [:options+]
8
+ Options:
9
+ --minime \tReal minime
10
+ --notoggle \tMinime wont toggle decorated and keep above
11
+ --notdecorated\tDont decorate window
12
+ HELP
10
13
 
11
14
  # CONFIG follows the following conventions:
12
15
  # * Strings and numbers are mixed case.
@@ -14,98 +17,93 @@ module Gtk3App
14
17
  # * Hashes are all lower case.
15
18
  # * Lower case bang! keys have special meaning in Such.
16
19
  # * Note that method keys may have mixed case as the method itself.
17
- CONFIG = {
20
+ @@CONFIG = {
21
+ # Application SHOULD modify LOGO to use it's own logo image.
22
+ Logo: "#{UserSpace::XDG['data']}/gtk3app/logo.png",
23
+ # Scale logo to this size.
24
+ LogoSize: 25,
18
25
 
19
26
  # The command to open with default application
20
- Open: 'gnome-open',
21
-
22
- Slots: 13, # The number of minime slots
23
- SlotsDBM: "#{XDG['CACHE']}/gtk3app/slots.sdbm", # slot management database
24
- SLOTS_OFFSET: [0,0], # The offset from the bottom right corner
25
- SlotsScale: 25, # The size of the slots
26
- SlotsOrientation: :horizontal,
27
-
28
- thing: { # The application MAY overwrite some these
29
-
30
- # Main window configuration
31
- WINDOW: a0, # Window.new's parameters
32
- window: h0, # window settings
33
- window!: [:WINDOW,:window],
34
-
35
- # Minime's configuration
36
- # Application SHOULD NOT modify these.
37
- MINI: a0,
38
- mini: {
39
- set_decorated: false,
40
- minime: a0,
41
- },
42
- mini!: [:MINI,:mini],
43
-
44
- # Fullscreen app-menu item
45
- # Application MAY modify :FS for language
46
- FS: [label: 'Full Screen'],
47
- fs: h0,
48
- fs!: [:FS, :fs, 'activate'],
49
-
50
- # About app-menu item
51
- # Application MAY modify :ABOUT for language
52
- # Application SHOULD modify :about_dialog
53
- ABOUT: [label: 'About'],
54
- about: h0,
55
- about!: [:ABOUT, :about, 'activate'],
56
- about_dialog: {
57
- set_program_name: 'Gtk3App',
58
- set_version: VERSION.semantic(0..1),
59
- set_copyright: '(c) 2018 CarlosJHR64',
60
- set_comments: 'A Gtk3 Application Stub',
61
- set_website: 'https://github.com/carlosjhr64/gtk3app',
62
- set_website_label: 'See it at GitHub!',
63
- },
64
- # Application SHOULD modify LOGO to use it's own logo image.
65
- Logo: "#{XDG['DATA']}/gtk3app/logo.png",
66
- # Application SHOULD modify :HelpFile to their own help page.
67
- HelpFile: 'https://github.com/carlosjhr64/gtk3app',
68
- # By convention, I'm using mix case for simple String configurations in here thing.
69
-
70
- # Help app-menu item
71
- # Application MAY modify :HELP for language
72
- HELP: [label: 'Help'],
73
- help: h0,
74
- help!: [:HELP, :help, 'activate'],
75
-
76
- # Minime's app-menu item.
77
- # Application MAY modify :MINIME for language.
78
- MINIME: [label: 'Mini-me'],
79
- minime: h0,
80
- minime!: [:MINIME, :minime, 'activate'],
81
-
82
- # Quit app-menu item.
83
- # Application MAY modify :QUIT for language.
84
- QUIT: [label: 'Quit'],
85
- quit: h0,
86
- quit!: [:QUIT, :quit, 'activate'],
87
-
88
- # The app menu configuration.
89
- # The application MAY ONLY modify app_menu.add_menu_item
90
- # by removing un-wanted app menu items.
91
- # Note that you can reference the item.key,
92
- # see: Gtk3App::Widget::MenuItem < Such::MenuItem
93
- APP_MENU: a0,
94
- app_menu: {
95
- add_menu_item: [:fs!, :about!, :help!, :minime!, :quit!],
96
- },
97
- app_menu!: [:APP_MENU, :app_menu, s0],
98
-
99
- # Minime's app-menu configuration.
100
- # The application SHOULD NOT modify
101
- # (the application will have the opportunity later to modify
102
- # minime's app-menu directly).
103
- MINI_MENU: a0,
104
- mini_menu: {
105
- add_menu_item: [:quit!],
106
- },
107
- mini_menu!: [:MINI_MENU, :mini_menu, s0],
108
-
27
+ Open: 'xdg-open',
28
+
29
+ # Main window configuration
30
+ MAIN: a0, # Window.new's parameters
31
+ main: h0, # window settings
32
+ main!: [:MAIN,:main],
33
+
34
+ # Expander stage configuration
35
+ STAGE: a0,
36
+ stage: {set_expanded:true},
37
+ stage!: [:STAGE, :stage],
38
+
39
+ # Expander toolbar configuration
40
+ TOOLBAR: a0,
41
+ toolbar: {set_expanded:true},
42
+ toolbar!: [:TOOLBAR, :toolbar],
43
+
44
+ # Fullscreen app-menu item
45
+ # Application MAY modify :FS for language
46
+ FS: [label: 'Full Screen'],
47
+ fs: h0,
48
+ fs!: [:FS, :fs, 'activate'],
49
+
50
+ # About app-menu item
51
+ # Application MAY modify :ABOUT for language
52
+ # Application SHOULD modify :about_dialog
53
+ ABOUT: [label: 'About'],
54
+ about: h0,
55
+ about!: [:ABOUT, :about, 'activate'],
56
+ about_dialog: {
57
+ set_program_name: 'Gtk3App',
58
+ set_version: VERSION.semantic(0..1),
59
+ set_copyright: '(c) 2021 CarlosJHR64',
60
+ set_comments: 'A Gtk3 Application Stub',
61
+ set_website: 'https://github.com/carlosjhr64/gtk3app',
62
+ set_website_label: 'See it at GitHub!',
63
+ },
64
+ # Application SHOULD modify :HelpFile to their own help page.
65
+ HelpFile: 'https://github.com/carlosjhr64/gtk3app',
66
+
67
+ # Help app-menu item
68
+ # Application MAY modify :HELP for language
69
+ HELP: [label: 'Help'],
70
+ help: h0,
71
+ help!: [:HELP, :help, 'activate'],
72
+
73
+ # Minime's app-menu item.
74
+ # Application MAY modify :MINIME for language.
75
+ MINIME: [label: 'Minime'],
76
+ minime: h0,
77
+ minime!: [:MINIME, :minime, 'activate'],
78
+
79
+ # Quit app-menu item.
80
+ # Application MAY modify :QUIT for language.
81
+ QUIT: [label: 'Quit'],
82
+ quit: h0,
83
+ quit!: [:QUIT, :quit, 'activate'],
84
+
85
+ # Quit confirmation dialog.
86
+ QUIT_URSURE: a0,
87
+ quit_ursure: {add_label: 'Quit?'},
88
+ quit_ursure!: [:QUIT_URSURE, :quit_ursure],
89
+
90
+ # Quit Exception(raised by finalizer) message
91
+ QUIT_EXCEPTION: a0,
92
+ quit_exception: {set_message_type: :info},
93
+ quit_exception!: [:QUIT_EXCEPTION, :quit_exception],
94
+
95
+ # The app menu configuration.
96
+ # The application MAY ONLY modify app_menu.add_menu_item
97
+ # by removing un-wanted app menu items.
98
+ # Note that you can reference the item.key,
99
+ # see: Gtk3App::Widget::MenuItem < Such::MenuItem
100
+ APP_MENU: a0,
101
+ app_menu: {
102
+ add_menu_item: [ :minime!, :fs!, :help!, :about!, :quit! ],
109
103
  },
104
+ # s0 tells AppMenu not to connect to any signal, otherwise it assumes "clicked".
105
+ app_menu!: [:APP_MENU, :app_menu, s0],
110
106
  }
107
+ CONFIG = lambda{|k| @@CONFIG[k]}
108
+ def CONFIG.to_h = @@CONFIG
111
109
  end
@@ -1,90 +1,182 @@
1
1
  module Gtk3App
2
- class Program
3
- using Rafini::Array
2
+ class << self
3
+ # Gtk2App.run(version:String?, help:String?, klass:(Class | Module)?), appdir:String?, appname:String?, config:Hash?)
4
+ def run(**kw)
5
+ kw[:appdir] ||= UserSpace.appdir
6
+ ensure_keywords(kw)
7
+ @options = HelpParser[kw[:version], kw[:help]]
8
+ install(kw)
4
9
 
5
- attr_reader :window, :app_menu, :mini, :mini_menu, :fs, :slot
6
- def initialize(app)
7
- @gui = nil # Initialized
8
- Widget::MainWindow.set_icon Such::Thing::PARAMETERS[:Logo]
10
+ Such::Thing.configure @@CONFIG
11
+ @main = Such::Window.new :main!, 'delete-event' do quit! end
12
+ @main.set_decorated false if @options.notdecorated
9
13
 
10
- @window = Widget::MainWindow.new(:window!, 'delete-event'){quit!}
14
+ vbox = Such::Box.new @main, [:vertical]
15
+ hbox = Such::Box.new vbox, [:horizontal]
11
16
 
12
- @app_menu = Widget::AppMenu.new(@window, :app_menu!) do |w,*_,s|
13
- self.method(w.key).call if s=='activate'
17
+ size = @@CONFIG[:LogoSize]
18
+ @pixbuf = GdkPixbuf::Pixbuf.new(file: @@CONFIG[:Logo]).scale(size,size)
19
+ logo = Gtk3App::EventImage.new hbox, [pixbuf:@pixbuf]
20
+ Gtk3App::AppMenu.new(logo, :app_menu!) do |widget,*e,signal|
21
+ case signal
22
+ when 'activate'
23
+ send widget.key
24
+ when 'button_press_event'
25
+ @logo_press_event.call(e[0].button) if @logo_press_event
14
26
  end
27
+ end
15
28
 
16
- @mini = @mini_menu = nil
17
- if @app_menu.children.which{|item| item.key==:minime!}
18
- @mini = Widget::MainWindow.new(:mini, 'delete-event'){quit!}
19
- @mini_menu = Widget::AppMenu.new(@mini, :mini_menu!) do |w,*_,s|
20
- self.method(w.key).call if s=='activate'
21
- minime! if s=='button_press_event'
22
- end
23
- end
29
+ @stage = Such::Expander.new vbox, :stage!
30
+ @toolbar = Such::Expander.new hbox, :toolbar!
24
31
 
25
- @fs = false
26
- @slot = nil
27
- @gui = app.run(self)
28
- end
32
+ kw[:klass]&.new(@stage, @toolbar, @options) or yield(@stage, @toolbar, @options)
29
33
 
30
- def fs!
31
- @fs ? @window.unfullscreen : @window.fullscreen
32
- @fs = !@fs
33
- end
34
+ @minime = @fs = false
35
+ @main.show_all
36
+ Gtk.main
37
+ end
34
38
 
35
- def about!
36
- about = Such::AboutDialog.new :about_dialog
37
- about.transient_for = @window
38
- about.set_logo Widget::MainWindow.icon
39
- about.run
40
- about.destroy
39
+ def raise_argument_error(kw)
40
+ $stderr.puts 'Expected Signature:'
41
+ $stderr.puts ' Gtk3App.run(version:String?, help:String?, :klass:Class?, appdir:String?, :appname:String? config:Hash?)'
42
+ raise ArgumentError, kw.inspect
43
+ end
44
+
45
+ def ensure_keywords(kw)
46
+ keys = [:version, :help, :klass, :appdir, :appname, :config]
47
+ raise_argument_error(kw) if kw.keys.any?{not keys.include?_1}
48
+ klass = kw[:klass]
49
+
50
+ unless kw[:version]
51
+ if klass and defined? klass::VERSION
52
+ kw[:version] = klass::VERSION
53
+ else
54
+ kw[:version] = (defined? ::VERSION)? ::VERSION : VERSION
55
+ end
41
56
  end
42
57
 
43
- def help!
44
- system "#{CONFIG[:Open]} '#{Such::Thing::PARAMETERS[:HelpFile]}'"
58
+ unless kw[:help]
59
+ if klass and defined? klass::HELP
60
+ kw[:help] = klass::HELP
61
+ else
62
+ kw[:help] = (defined? ::HELP)? ::HELP : HELP
63
+ end
45
64
  end
46
65
 
47
- def release
48
- if @slot
49
- Slot.release(@slot)
50
- @slot = nil
66
+ kw[:appname] ||= klass&.name&.downcase || File.basename($0)
67
+
68
+ unless kw[:config]
69
+ if klass and defined? klass::CONFIG
70
+ kw[:config] = klass::CONFIG
51
71
  end
52
72
  end
73
+ end
53
74
 
54
- def minime!
55
- if @window.visible?
56
- @slot = Slot.get
57
- if @slot
58
- s = CONFIG[:SlotsScale]
59
- x, y = CONFIG[:SLOTS_OFFSET]
60
- w, h = Gdk::Screen.width, Gdk::Screen.height
61
- case CONFIG[:SlotsOrientation]
62
- when :horizontal
63
- @mini.move(w-@slot*s+x, h-s+y)
64
- when :vertical
65
- @mini.move(w-s+x, h-@slot*s+y)
66
- else
67
- if @slot%2==0
68
- @mini.move(w-((@slot+2)/2)*s+x, h-s+y)
69
- else
70
- @mini.move(w-s+x, h-((@slot+1)/2)*s+y)
71
- end
72
- end
73
- @mini.keep_above=true
74
- @window.hide
75
- @mini.show
76
- end
77
- else
78
- release
79
- @mini.hide
80
- @window.show
75
+ def transient(window)
76
+ window.transient_for = @main
77
+ end
78
+
79
+ def logo_press_event(&block)
80
+ @logo_press_event = block
81
+ end
82
+
83
+ def fs!
84
+ @fs ? @main.unfullscreen : @main.fullscreen
85
+ @fs = !@fs
86
+ end
87
+
88
+ def about!
89
+ about = Such::AboutDialog.new :about_dialog
90
+ transient about
91
+ about.set_logo @pixbuf
92
+ about.run
93
+ about.destroy
94
+ end
95
+
96
+ def help!
97
+ system(@@CONFIG[:Open], @@CONFIG[:HelpFile])
98
+ end
99
+
100
+ def minime!
101
+ if @minime
102
+ @minime = false
103
+ unless @options.notoggle
104
+ @main.set_decorated true unless @options.notdecorated
105
+ @main.set_keep_above false
106
+ end
107
+ @stage.set_expanded true
108
+ @toolbar.set_expanded true
109
+ if @options.minime?
110
+ @stage.show
111
+ @toolbar.show
112
+ end
113
+ else
114
+ @minime = true
115
+ unless @options.notoggle
116
+ @main.set_decorated false unless @options.notdecorated
117
+ @main.set_keep_above true
81
118
  end
119
+ @stage.set_expanded false
120
+ @toolbar.set_expanded false
121
+ if @options.minime?
122
+ @stage.hide
123
+ @toolbar.hide
124
+ end
125
+ @main.resize 1,1
82
126
  end
127
+ end
83
128
 
84
- def quit!
85
- release
86
- @gui.finalize if @gui.respond_to? :finalize
87
- Gtk.main_quit
129
+ using Rafini::Exception
130
+ def quit!
131
+ ursure = Gtk3App::YesNoDialog.new :quit_ursure!
132
+ transient ursure
133
+ return true unless ursure.ok?
134
+ @finalize.call if @finalize
135
+ Gtk.main_quit
136
+ return false
137
+ rescue # finalize raised exception
138
+ $!.puts
139
+ dialog = Such::MessageDialog.new
140
+ transient dialog
141
+ dialog.set_text $!.message
142
+ dialog.run
143
+ dialog.destroy
144
+ return true
145
+ end
146
+
147
+ def finalize(&block)
148
+ @finalize = block
149
+ end
150
+
151
+
152
+ using Rafini::String
153
+ def install(kw)
154
+ stub = UserSpace.new parser:RBON,
155
+ appname:'gtk3app',
156
+ config:"config-#{VERSION.semantic(0..1)}"
157
+ stub.configures @@CONFIG
158
+
159
+ # :klass and :config flags user wants xdg maintainance.
160
+ # :appname, :appdir, and :version are sanity checks.
161
+ if [:klass,:config,:appname,:appdir,:version].all?{kw[_1]}
162
+ app = UserSpace.new parser:RBON,
163
+ # Will be a subdirectory in gtk3app:
164
+ appname:"gtk3app/#{kw[:appname]}",
165
+ appdir:kw[:appdir],
166
+ config:"config-#{kw[:version].semantic(0..1)}"
167
+ app.configures kw[:config]
168
+ end
169
+ # Pad-up klass::CONFIG and switch to it:
170
+ if cfg = kw[:config]
171
+ @@CONFIG.each do |k,v|
172
+ if cfg.key? k
173
+ $stderr.puts "Overriding Gtk3App::CONFIG[#{k}]" if $VERBOSE
174
+ else
175
+ cfg[k]=v
176
+ end
177
+ end
178
+ @@CONFIG = cfg
88
179
  end
89
180
  end
90
181
  end
182
+ end
@@ -1,6 +1,4 @@
1
1
  module Gtk3App
2
- module Widget
3
-
4
2
  class MenuItem < Such::MenuItem
5
3
  attr_accessor :key
6
4
  end
@@ -19,7 +17,8 @@ module Widget
19
17
  window.add_events(Gdk::EventMask::BUTTON_PRESS_MASK)
20
18
  window.signal_connect('button_press_event') do |w,e|
21
19
  if e.button == 3
22
- self.popup(nil, nil, 3, e.time)
20
+ #self.popup(nil, nil, 3, e.time)
21
+ self.popup_at_pointer #(nil, nil, 3, e.time)
23
22
  else
24
23
  block.call(w,e,'button_press_event')
25
24
  end
@@ -32,25 +31,29 @@ module Widget
32
31
  end
33
32
  end
34
33
 
35
- class MainWindow < Such::Window
36
- def self.set_icon(file)
37
- @@icon = GdkPixbuf::Pixbuf.new(file: file)
34
+ class EventImage < Such::EventBox
35
+ def initialize(container, ...)
36
+ super container
37
+ Such::Image.new(self, ...)
38
38
  end
39
+ end
39
40
 
40
- def self.icon
41
- @@icon
41
+ class YesNoDialog < Such::Dialog
42
+ def initialize(...)
43
+ super(...)
44
+ add_button '_No', Gtk::ResponseType::CANCEL
45
+ add_button '_Yes', Gtk::ResponseType::OK
42
46
  end
43
47
 
44
- def initialize(*par, &block)
45
- super(*par, &block)
46
- self.set_icon MainWindow.icon
48
+ def add_label(text)
49
+ Such::Label.new(child).text = text
47
50
  end
48
51
 
49
- def minime(x=CONFIG[:SlotsScale])
50
- self.set_default_size(x,x)
51
- self.add Gtk::Image.new(pixbuf: MainWindow.icon.scale(x,x)).show
52
+ def ok?
53
+ show_all
54
+ response = run
55
+ destroy
56
+ response == Gtk::ResponseType::OK
52
57
  end
53
58
  end
54
-
55
- end
56
59
  end
data/lib/gtk3app.rb CHANGED
@@ -1,29 +1,21 @@
1
- module Gtk3App
2
- VERSION = '3.0.0'
3
- end
4
-
5
- # Standard Libraries
6
- require 'yaml'
7
- require 'sdbm'
8
-
9
1
  # Supporting Gems
2
+ require 'help_parser'
10
3
  require 'user_space'
11
4
  require 'rafini'
5
+ require 'rbon'
12
6
 
13
7
  # Workhorse Gems
14
8
  require 'gtk3'
15
9
  require 'such'
16
- Such::Things.gtk_widget
10
+ Such::Things.in Gtk::Widget
17
11
 
18
- ### Gtk3App ###
19
- # Configuration
20
- require_relative 'gtk3app/config.rb'
21
- # Custom Widgets
22
- require_relative 'gtk3app/widget/widgets.rb'
23
- # Program Flow
24
- require_relative 'gtk3app/slot.rb'
25
- require_relative 'gtk3app/program.rb'
26
- require_relative 'gtk3app/gtk3app.rb'
12
+ # This Gem
13
+ module Gtk3App
14
+ VERSION = '5.2.210918'
27
15
 
16
+ require 'gtk3app/config'
17
+ require 'gtk3app/widgets'
18
+ require 'gtk3app/program'
19
+ end
28
20
  # Requires:
29
21
  #`ruby`
metadata CHANGED
@@ -1,17 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk3app
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 5.2.210918
5
5
  platform: ruby
6
6
  authors:
7
- - carlosjhr64
8
- autorequire:
7
+ - CarlosJHR64
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-24 00:00:00.000000000 Z
11
+ date: 2021-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: help_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '8.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 8.0.210917
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '8.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 8.0.210917
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: user_space
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '5.1'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.1.210201
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '5.1'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.1.210201
53
+ - !ruby/object:Gem::Dependency
54
+ name: rafini
15
55
  requirement: !ruby/object:Gem::Requirement
16
56
  requirements:
17
57
  - - "~>"
@@ -19,7 +59,7 @@ dependencies:
19
59
  version: '3.0'
20
60
  - - ">="
21
61
  - !ruby/object:Gem::Version
22
- version: 3.0.0
62
+ version: 3.0.210112
23
63
  type: :runtime
24
64
  prerelease: false
25
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,85 +69,91 @@ dependencies:
29
69
  version: '3.0'
30
70
  - - ">="
31
71
  - !ruby/object:Gem::Version
32
- version: 3.0.0
72
+ version: 3.0.210112
33
73
  - !ruby/object:Gem::Dependency
34
- name: rafini
74
+ name: rbon
35
75
  requirement: !ruby/object:Gem::Requirement
36
76
  requirements:
37
77
  - - "~>"
38
78
  - !ruby/object:Gem::Version
39
- version: '1.2'
79
+ version: '0.2'
40
80
  - - ">="
41
81
  - !ruby/object:Gem::Version
42
- version: 1.2.1
82
+ version: 0.2.210125
43
83
  type: :runtime
44
84
  prerelease: false
45
85
  version_requirements: !ruby/object:Gem::Requirement
46
86
  requirements:
47
87
  - - "~>"
48
88
  - !ruby/object:Gem::Version
49
- version: '1.2'
89
+ version: '0.2'
50
90
  - - ">="
51
91
  - !ruby/object:Gem::Version
52
- version: 1.2.1
92
+ version: 0.2.210125
53
93
  - !ruby/object:Gem::Dependency
54
94
  name: gtk3
55
95
  requirement: !ruby/object:Gem::Requirement
56
96
  requirements:
57
97
  - - "~>"
58
98
  - !ruby/object:Gem::Version
59
- version: '3.2'
99
+ version: '3.4'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 3.4.9
60
103
  type: :runtime
61
104
  prerelease: false
62
105
  version_requirements: !ruby/object:Gem::Requirement
63
106
  requirements:
64
107
  - - "~>"
65
108
  - !ruby/object:Gem::Version
66
- version: '3.2'
109
+ version: '3.4'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 3.4.9
67
113
  - !ruby/object:Gem::Dependency
68
114
  name: such
69
115
  requirement: !ruby/object:Gem::Requirement
70
116
  requirements:
71
117
  - - "~>"
72
118
  - !ruby/object:Gem::Version
73
- version: '0.4'
119
+ version: '2.0'
74
120
  - - ">="
75
121
  - !ruby/object:Gem::Version
76
- version: 0.4.0
122
+ version: 2.0.210201
77
123
  type: :runtime
78
124
  prerelease: false
79
125
  version_requirements: !ruby/object:Gem::Requirement
80
126
  requirements:
81
127
  - - "~>"
82
128
  - !ruby/object:Gem::Version
83
- version: '0.4'
129
+ version: '2.0'
84
130
  - - ">="
85
131
  - !ruby/object:Gem::Version
86
- version: 0.4.0
132
+ version: 2.0.210201
87
133
  description: |
88
- Gtk3App provides a Gtk3 application stub.
134
+ Gtk3App provides a
135
+ [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3)
136
+ application stub.
89
137
 
90
- It automatically provides for user configuration, and minime windows.
138
+ The stub provides you with two Expander containers.
139
+ One for a horizontal toolbar.
140
+ The other for your main stage area.
91
141
  email: carlosjhr64@gmail.com
92
142
  executables: []
93
143
  extensions: []
94
144
  extra_rdoc_files: []
95
145
  files:
96
146
  - README.md
97
- - data/VERSION
98
147
  - data/logo.png
99
- - data/ruby.png
100
148
  - lib/gtk3app.rb
101
149
  - lib/gtk3app/config.rb
102
- - lib/gtk3app/gtk3app.rb
103
150
  - lib/gtk3app/program.rb
104
- - lib/gtk3app/slot.rb
105
- - lib/gtk3app/widget/widgets.rb
151
+ - lib/gtk3app/widgets.rb
106
152
  homepage: https://github.com/carlosjhr64/gtk3app
107
153
  licenses:
108
154
  - MIT
109
155
  metadata: {}
110
- post_install_message:
156
+ post_install_message:
111
157
  rdoc_options: []
112
158
  require_paths:
113
159
  - lib
@@ -122,10 +168,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
168
  - !ruby/object:Gem::Version
123
169
  version: '0'
124
170
  requirements:
125
- - 'ruby: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]'
126
- rubyforge_project:
127
- rubygems_version: 2.7.6
128
- signing_key:
171
+ - 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
172
+ rubygems_version: 3.2.22
173
+ signing_key:
129
174
  specification_version: 4
130
- summary: Gtk3App provides a Gtk3 application stub.
175
+ summary: Gtk3App provides a [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3) application
176
+ stub.
131
177
  test_files: []
data/data/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.0.0
data/data/ruby.png DELETED
Binary file
@@ -1,49 +0,0 @@
1
- module Gtk3App
2
- using Rafini::String
3
- using Rafini::Hash
4
- using Rafini::Exception
5
-
6
- def self.config(mod)
7
- # Let's get NameErrors out of the way first
8
- appdir = mod::APPDIR
9
- config = mod::CONFIG
10
- version = mod::VERSION
11
- # Create the directory name for UserSpace.
12
- appname = mod.name.downcase
13
- appname.prepend('gtk3app/') unless mod==Gtk3App
14
- # UserSpace does its thing...
15
- user_space = UserSpace.new(
16
- YAML,
17
- ext: 'yml',
18
- config: "config-#{version.semantic(0..1)}",
19
- appname: appname,
20
- appdir: appdir
21
- )
22
- user_space.install unless user_space.version == version
23
- user_space.configures(config)
24
- rescue NameError
25
- $!.puts 'Application is not using APPDIR, VERSION, or CONFIG.'
26
- end
27
-
28
- def self.init(mod)
29
- Gtk3App.config mod
30
- if thing = mod::CONFIG[:thing]
31
- Such::Thing.configure thing
32
- end
33
- rescue NameError
34
- $!.puts 'Application is not using CONFIG.'
35
- end
36
-
37
- def self.main(app)
38
- @program = nil # initialized
39
- Gtk3App.init Gtk3App
40
- Gtk3App.init app
41
- @program = Program.new app
42
- Gtk.main
43
- rescue StandardError
44
- $!.puts
45
- exit 1
46
- ensure
47
- @program.release if @program
48
- end
49
- end
data/lib/gtk3app/slot.rb DELETED
@@ -1,42 +0,0 @@
1
- module Gtk3App
2
- module Slot
3
- using Rafini::Array
4
-
5
- def self.dbm
6
- SDBM.open(CONFIG[:SlotsDBM]){|db|yield(db)}
7
- end
8
-
9
- def self.numbers
10
- 1.upto(CONFIG[:Slots]){|n|yield(n.to_s)}
11
- end
12
-
13
- def self.get
14
- Slot.dbm do |db|
15
- Slot.numbers do |slot|
16
- unless db[slot]
17
- db[slot]=$$.to_s
18
- return slot.to_i
19
- end
20
- end
21
- end
22
- return nil
23
- end
24
-
25
- def self.release(slot)
26
- Slot.dbm{|db|db.delete(slot.to_s)}
27
- end
28
-
29
- def self.gc
30
- Thread.new do
31
- Slot.dbm do |db|
32
- Slot.numbers do |slot|
33
- if pid = db[slot]
34
- db.delete(slot) unless File.directory?("/proc/#{pid}")
35
- end
36
- end
37
- end
38
- end
39
- end
40
- Slot.gc
41
- end
42
- end