gtk3app 2.0.2 → 4.0.210128

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
- SHA1:
3
- metadata.gz: 7506605f52e9d924790adc878a4ccf356c67cb48
4
- data.tar.gz: 1b27d3dc59ad38f8ba19842a7e6d2fdeac316db3
2
+ SHA256:
3
+ metadata.gz: 82fe60ac20bffaf0840a5df94109d2d842b1f409e6349b80a1f7f8e4061c1b91
4
+ data.tar.gz: c7e9504cf4c894c049ecc08da84667746a5c17b372082e113b0ea34b4a00e261
5
5
  SHA512:
6
- metadata.gz: 334468b726331a4c895e8464a2b3c84e961c716aaed4b3817006412e12ebeeb93d0f0bbfb06edad684d5bc58301d514ed52aef2b5fdccdc496952d17e5b1e39c
7
- data.tar.gz: ec08fb66a0d2d9aa7282e047fb60d01cea5bf528f8bd75fca982b01de9b3b49569c79f3bae3780aa9388c71ac459d8b8620427c4cb456ee03806d917d6729216
6
+ metadata.gz: b54f387d4b6b6ca22fe60893bc4055a731261408bf72485f674b62c1a4bd94ea534b9d69bb609cb22494bb903003dd55b48b9d000a9bc6f5189eee79cc7508a1
7
+ data.tar.gz: 271c4fc554b1e00d5601c789751d97127b1ee932dfd67b1c3db72ae193d6f5555394596157153b690fdfa6b416c7913b154f54b26491624369e84731991b428c
@@ -0,0 +1,80 @@
1
+ # Gtk3App
2
+
3
+ * [VERSION 4.0.210128](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)
8
+
9
+ ## DESCRIPTION:
10
+
11
+ Gtk3App provides a
12
+ [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3)
13
+ application stub.
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
+ ```shell
22
+ $ sudo gem install gtk3app
23
+ ```
24
+
25
+ ## SYNOPSIS:
26
+
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
+ ```
35
+
36
+ That's enough to get you going.
37
+ The three examples in the [./examples](https://github.com/carlosjhr64/gtk3app/tree/master/examples)
38
+ directory fully explains the rest of what Gtk3App can do for you.
39
+
40
+ ## FEATURES:
41
+
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
48
+
49
+
50
+ ## LICENSE:
51
+
52
+ * The MIT License
53
+
54
+ Copyright (c) 2021 CarlosJHR64
55
+
56
+ Permission is hereby granted, free of charge, to any person obtaining
57
+ a copy of this software and associated documentation files (the
58
+ 'Software'), to deal in the Software without restriction, including
59
+ without limitation the rights to use, copy, modify, merge, publish,
60
+ distribute, sublicense, and/or sell copies of the Software, and to
61
+ permit persons to whom the Software is furnished to do so, subject to
62
+ the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be
65
+ included in all copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
68
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
69
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
70
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
71
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
72
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
73
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
74
+
75
+ ## CREDITS
76
+
77
+ Stuff here I may have taken from:
78
+
79
+ * [softicons](http://www.softicons.com/application-icons/ruby-programming-icons-by-ahmad-galal/ruby-gtk-icon)
80
+ * [zetcode](http://zetcode.com/gui/rubygtk/)
@@ -1,40 +1,21 @@
1
- module Gtk3App
2
- VERSION = '2.0.2'
3
- end
4
-
5
- # Standard Libraries
6
-
7
- require 'yaml'
8
- require 'sdbm'
9
-
10
1
  # Supporting Gems
11
-
2
+ require 'help_parser'
12
3
  require 'user_space'
13
4
  require 'rafini'
5
+ require 'rbon'
14
6
 
15
7
  # Workhorse Gems
16
-
17
8
  require 'gtk3'
18
-
19
9
  require 'such'
20
- Such::Things.gtk_widget
10
+ Such::Things.in Gtk::Widget
21
11
 
22
- ### Gtk3App ###
23
-
24
- # Configuration
25
-
26
- require 'gtk3app/config.rb'
27
-
28
- # Custom Widgets & Dialogs
29
-
30
- require 'gtk3app/widget/widgets.rb'
31
- require 'gtk3app/dialog/dialogs.rb'
32
-
33
- # Program Flow
34
-
35
- require 'gtk3app/slot.rb'
36
- require 'gtk3app/program.rb'
37
- require 'gtk3app/gtk3app.rb'
12
+ # This Gem
13
+ module Gtk3App
14
+ VERSION = '4.0.210128'
38
15
 
16
+ require 'gtk3app/config'
17
+ require 'gtk3app/widgets'
18
+ require 'gtk3app/program'
19
+ end
39
20
  # Requires:
40
21
  #`ruby`
@@ -1,12 +1,14 @@
1
1
  module Gtk3App
2
- using Rafini::String
2
+ using Rafini::String # provides String#semantic
3
+ extend Rafini::Empty # provides s0, a0, and h0.
3
4
 
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
5
+ HELP = <<~HELP
6
+ Usage:
7
+ #{File.basename $0} [:options+]
8
+ Options:
9
+ --notoggle Minime wont toggle decorated and keep above
10
+ --notdecorated Dont decorate window
11
+ HELP
10
12
 
11
13
  # CONFIG follows the following conventions:
12
14
  # * Strings and numbers are mixed case.
@@ -15,95 +17,90 @@ module Gtk3App
15
17
  # * Lower case bang! keys have special meaning in Such.
16
18
  # * Note that method keys may have mixed case as the method itself.
17
19
  CONFIG = {
20
+ # Application SHOULD modify LOGO to use it's own logo image.
21
+ Logo: "#{UserSpace::XDG['data']}/gtk3app/logo.png",
22
+ # Scale logo to this size.
23
+ LogoSize: 25,
18
24
 
19
25
  # 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) 2017 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.append_menu_item
90
- # by removing un-wanted app menu items.
91
- APP_MENU: a0,
92
- app_menu: {
93
- append_menu_item: [:fs!, :about!, :help!, :minime!, :quit!],
94
- },
95
- app_menu!: [:APP_MENU, :app_menu, s0],
96
-
97
- # Minime's app-menu configuration.
98
- # The application SHOULD NOT modify
99
- # (the application will have the opportunity later to modify
100
- # minime's app-menu directly).
101
- MINI_MENU: a0,
102
- mini_menu: {
103
- append_menu_item: [:quit!],
104
- },
105
- mini_menu!: [:MINI_MENU, :mini_menu, s0],
106
-
26
+ Open: 'xdg-open',
27
+
28
+ # Main window configuration
29
+ MAIN: a0, # Window.new's parameters
30
+ main: h0, # window settings
31
+ main!: [:MAIN,:main],
32
+
33
+ # Expander stage configuration
34
+ STAGE: a0,
35
+ stage: {set_expanded:true},
36
+ stage!: [:STAGE, :stage],
37
+
38
+ # Expander toolbar configuration
39
+ TOOLBAR: a0,
40
+ toolbar: {set_expanded:true},
41
+ toolbar!: [:TOOLBAR, :toolbar],
42
+
43
+ # Fullscreen app-menu item
44
+ # Application MAY modify :FS for language
45
+ FS: [label: 'Full Screen'],
46
+ fs: h0,
47
+ fs!: [:FS, :fs, 'activate'],
48
+
49
+ # About app-menu item
50
+ # Application MAY modify :ABOUT for language
51
+ # Application SHOULD modify :about_dialog
52
+ ABOUT: [label: 'About'],
53
+ about: h0,
54
+ about!: [:ABOUT, :about, 'activate'],
55
+ about_dialog: {
56
+ set_program_name: 'Gtk3App',
57
+ set_version: VERSION.semantic(0..1),
58
+ set_copyright: '(c) 2021 CarlosJHR64',
59
+ set_comments: 'A Gtk3 Application Stub',
60
+ set_website: 'https://github.com/carlosjhr64/gtk3app',
61
+ set_website_label: 'See it at GitHub!',
62
+ },
63
+ # Application SHOULD modify :HelpFile to their own help page.
64
+ HelpFile: 'https://github.com/carlosjhr64/gtk3app',
65
+
66
+ # Help app-menu item
67
+ # Application MAY modify :HELP for language
68
+ HELP: [label: 'Help'],
69
+ help: h0,
70
+ help!: [:HELP, :help, 'activate'],
71
+
72
+ # Minime's app-menu item.
73
+ # Application MAY modify :MINIME for language.
74
+ MINIME: [label: 'Minime'],
75
+ minime: h0,
76
+ minime!: [:MINIME, :minime, 'activate'],
77
+
78
+ # Quit app-menu item.
79
+ # Application MAY modify :QUIT for language.
80
+ QUIT: [label: 'Quit'],
81
+ quit: h0,
82
+ quit!: [:QUIT, :quit, 'activate'],
83
+
84
+ # Quit confirmation dialog.
85
+ QUIT_URSURE: a0,
86
+ quit_ursure: {add_label: 'Quit?'},
87
+ quit_ursure!: [:QUIT_URSURE, :quit_ursure],
88
+
89
+ # Quit Exception(raised by finalizer) message
90
+ QUIT_EXCEPTION: a0,
91
+ quit_exception: {set_message_type: :info},
92
+ quit_exception!: [:QUIT_EXCEPTION, :quit_exception],
93
+
94
+ # The app menu configuration.
95
+ # The application MAY ONLY modify app_menu.add_menu_item
96
+ # by removing un-wanted app menu items.
97
+ # Note that you can reference the item.key,
98
+ # see: Gtk3App::Widget::MenuItem < Such::MenuItem
99
+ APP_MENU: a0,
100
+ app_menu: {
101
+ add_menu_item: [ :minime!, :fs!, :help!, :about!, :quit! ],
107
102
  },
103
+ # s0 tells AppMenu not to connect to any signal, otherwise it assumes "clicked".
104
+ app_menu!: [:APP_MENU, :app_menu, s0],
108
105
  }
109
106
  end
@@ -1,88 +1,164 @@
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
- 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
8
13
 
9
- @window = Widget::MainWindow.new(:window!, 'delete-event'){quit!}
14
+ vbox = Such::Box.new @main, [:vertical]
15
+ hbox = Such::Box.new vbox, [:horizontal]
10
16
 
11
- @app_menu = Widget::AppMenu.new(@window, :app_menu!) do |w,*_,s|
12
- 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
13
26
  end
27
+ end
14
28
 
15
- @mini = @mini_menu = nil
16
- if @app_menu.children.which{|item| item.key==:minime!}
17
- @mini = Widget::MainWindow.new(:mini, 'delete-event'){quit!}
18
- @mini_menu = Widget::AppMenu.new(@mini, :mini_menu!) do |w,*_,s|
19
- self.method(w.key).call if s=='activate'
20
- minime! if s=='button_press_event'
21
- end
22
- end
29
+ @stage = Such::Expander.new vbox, :stage!
30
+ @toolbar = Such::Expander.new hbox, :toolbar!
23
31
 
24
- @fs = false
25
- @slot = nil
26
- app.run(self)
27
- end
32
+ kw[:klass]&.new(@stage, @toolbar, @options) or yield(@stage, @toolbar, @options)
28
33
 
29
- def fs!
30
- @fs ? @window.unfullscreen : @window.fullscreen
31
- @fs = !@fs
32
- end
34
+ @minime = @fs = false
35
+ @main.show_all
36
+ Gtk.main
37
+ end
33
38
 
34
- def about!
35
- about = Such::AboutDialog.new :about_dialog
36
- about.transient_for = @window
37
- about.set_logo Widget::MainWindow.icon
38
- about.run
39
- 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
40
56
  end
41
57
 
42
- def help!
43
- 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
44
64
  end
45
65
 
46
- def release
47
- if @slot
48
- Slot.release(@slot)
49
- @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
50
71
  end
51
72
  end
73
+ end
52
74
 
53
- def minime!
54
- if @window.visible?
55
- @slot = Slot.get
56
- if @slot
57
- s = CONFIG[:SlotsScale]
58
- x, y = CONFIG[:SLOTS_OFFSET]
59
- w, h = Gdk::Screen.width, Gdk::Screen.height
60
- case CONFIG[:SlotsOrientation]
61
- when :horizontal
62
- @mini.move(w-@slot*s+x, h-s+y)
63
- when :vertical
64
- @mini.move(w-s+x, h-@slot*s+y)
65
- else
66
- if @slot%2==0
67
- @mini.move(w-((@slot+2)/2)*s+x, h-s+y)
68
- else
69
- @mini.move(w-s+x, h-((@slot+1)/2)*s+y)
70
- end
71
- end
72
- @mini.keep_above=true
73
- @window.hide
74
- @mini.show
75
- end
76
- else
77
- release
78
- @mini.hide
79
- @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
+ else
110
+ @minime = true
111
+ unless @options.notoggle
112
+ @main.set_decorated false unless @options.notdecorated
113
+ @main.set_keep_above true
80
114
  end
115
+ @stage.set_expanded false
116
+ @toolbar.set_expanded false
117
+ @main.resize 1,1
81
118
  end
119
+ end
120
+
121
+ using Rafini::Exception
122
+ def quit!
123
+ ursure = Gtk3App::YesNoDialog.new :quit_ursure!
124
+ transient ursure
125
+ return true unless ursure.ok?
126
+ @finalize.call if @finalize
127
+ Gtk.main_quit
128
+ return false
129
+ rescue # finalize raised exception
130
+ $!.puts
131
+ dialog = Such::MessageDialog.new
132
+ transient dialog
133
+ dialog.set_text $!.message
134
+ dialog.run
135
+ dialog.destroy
136
+ return true
137
+ end
138
+
139
+ def finalize(&block)
140
+ @finalize = block
141
+ end
142
+
82
143
 
83
- def quit!
84
- release
85
- Gtk.main_quit
144
+ using Rafini::String
145
+ def install(kw)
146
+ stub = UserSpace.new parser:RBON,
147
+ appname:'gtk3app',
148
+ config:"config-#{VERSION.semantic(0..1)}"
149
+ stub.configures CONFIG
150
+
151
+ # :klass and :config flags user wants xdg maintainance.
152
+ # :appname, :appdir, and :version are sanity checks.
153
+ if [:klass,:config,:appname,:appdir,:version].all?{kw[_1]}
154
+ app = UserSpace.new parser:RBON,
155
+ # Will be a subdirectory in gtk3app:
156
+ appname:"gtk3app/#{kw[:appname]}",
157
+ appdir:kw[:appdir],
158
+ config:"config-#{kw[:version].semantic(0..1)}"
159
+ app.configures kw[:config]
86
160
  end
161
+ CONFIG.merge! kw[:config] if kw[:config]
87
162
  end
88
163
  end
164
+ end
@@ -0,0 +1,59 @@
1
+ module Gtk3App
2
+ class MenuItem < Such::MenuItem
3
+ attr_accessor :key
4
+ end
5
+
6
+ class Menu < Such::Menu
7
+ def add_menu_item(key, &block)
8
+ item = MenuItem.new(self, key, &block)
9
+ item.key = key
10
+ item.show
11
+ end
12
+ end
13
+
14
+ class AppMenu < Menu
15
+ def initialize(window, *par, &block)
16
+ @block = block
17
+ window.add_events(Gdk::EventMask::BUTTON_PRESS_MASK)
18
+ window.signal_connect('button_press_event') do |w,e|
19
+ if e.button == 3
20
+ #self.popup(nil, nil, 3, e.time)
21
+ self.popup_at_pointer #(nil, nil, 3, e.time)
22
+ else
23
+ block.call(w,e,'button_press_event')
24
+ end
25
+ end
26
+ super(*par)
27
+ end
28
+
29
+ def add_menu_item(key, &block)
30
+ super(key, &(block || @block))
31
+ end
32
+ end
33
+
34
+ class EventImage < Such::EventBox
35
+ def initialize(container, ...)
36
+ super container
37
+ Such::Image.new(self, ...)
38
+ end
39
+ end
40
+
41
+ class YesNoDialog < Such::Dialog
42
+ def initialize(...)
43
+ super(...)
44
+ add_button '_No', Gtk::ResponseType::CANCEL
45
+ add_button '_Yes', Gtk::ResponseType::OK
46
+ end
47
+
48
+ def add_label(text)
49
+ Such::Label.new(child).text = text
50
+ end
51
+
52
+ def ok?
53
+ show_all
54
+ response = run
55
+ destroy
56
+ response == Gtk::ResponseType::OK
57
+ end
58
+ end
59
+ end
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: 2.0.2
4
+ version: 4.0.210128
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2021-01-28 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: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.200907
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.200907
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.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.0.210123
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '5.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.0.210123
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,96 +69,92 @@ 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'
60
100
  - - ">="
61
101
  - !ruby/object:Gem::Version
62
- version: 3.2.0
102
+ version: 3.4.3
63
103
  type: :runtime
64
104
  prerelease: false
65
105
  version_requirements: !ruby/object:Gem::Requirement
66
106
  requirements:
67
107
  - - "~>"
68
108
  - !ruby/object:Gem::Version
69
- version: '3.2'
109
+ version: '3.4'
70
110
  - - ">="
71
111
  - !ruby/object:Gem::Version
72
- version: 3.2.0
112
+ version: 3.4.3
73
113
  - !ruby/object:Gem::Dependency
74
114
  name: such
75
115
  requirement: !ruby/object:Gem::Requirement
76
116
  requirements:
77
117
  - - "~>"
78
118
  - !ruby/object:Gem::Version
79
- version: '0.4'
119
+ version: '1.0'
80
120
  - - ">="
81
121
  - !ruby/object:Gem::Version
82
- version: 0.4.0
122
+ version: 1.0.210117
83
123
  type: :runtime
84
124
  prerelease: false
85
125
  version_requirements: !ruby/object:Gem::Requirement
86
126
  requirements:
87
127
  - - "~>"
88
128
  - !ruby/object:Gem::Version
89
- version: '0.4'
129
+ version: '1.0'
90
130
  - - ">="
91
131
  - !ruby/object:Gem::Version
92
- version: 0.4.0
132
+ version: 1.0.210117
93
133
  description: |
94
- Gtk3App provides a Gtk3 application stub.
134
+ Gtk3App provides a
135
+ [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3)
136
+ application stub.
95
137
 
96
- 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.
97
141
  email: carlosjhr64@gmail.com
98
142
  executables: []
99
143
  extensions: []
100
- extra_rdoc_files:
101
- - README.rdoc
144
+ extra_rdoc_files: []
102
145
  files:
103
- - README.rdoc
104
- - data/VERSION
146
+ - README.md
105
147
  - data/logo.png
106
- - data/ruby.png
107
148
  - lib/gtk3app.rb
108
149
  - lib/gtk3app/config.rb
109
- - lib/gtk3app/dialog/dialogs.rb
110
- - lib/gtk3app/gtk3app.rb
111
150
  - lib/gtk3app/program.rb
112
- - lib/gtk3app/slot.rb
113
- - lib/gtk3app/widget/widgets.rb
151
+ - lib/gtk3app/widgets.rb
114
152
  homepage: https://github.com/carlosjhr64/gtk3app
115
153
  licenses:
116
154
  - MIT
117
155
  metadata: {}
118
- post_install_message:
119
- rdoc_options:
120
- - "--main"
121
- - README.rdoc
156
+ post_install_message:
157
+ rdoc_options: []
122
158
  require_paths:
123
159
  - lib
124
160
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -132,10 +168,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
168
  - !ruby/object:Gem::Version
133
169
  version: '0'
134
170
  requirements:
135
- - 'ruby: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]'
136
- rubyforge_project:
137
- rubygems_version: 2.6.13
138
- signing_key:
171
+ - 'ruby: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]'
172
+ rubygems_version: 3.2.3
173
+ signing_key:
139
174
  specification_version: 4
140
- summary: Gtk3App provides a Gtk3 application stub.
175
+ summary: Gtk3App provides a [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3) application
176
+ stub.
141
177
  test_files: []
@@ -1,71 +0,0 @@
1
- = gt3applib
2
-
3
- {<img src="https://badge.fury.io/rb/gtk3app.svg" alt="Gem Version" />}[http://badge.fury.io/rb/gtk3app]
4
-
5
- == DESCRIPTION:
6
-
7
- Gtk3App provides a Gtk3 application stub.
8
-
9
- It automatically provides for user configuration, and minime windows.
10
-
11
- == SYNOPSIS:
12
-
13
- Given a module file such as ./my_app.rb, the module is expected to at least provide MyApp.run(program):
14
-
15
- module MyApp
16
- def self.run(program)
17
- window = program.window
18
- # develop as you would on a Gtk3::Window object...
19
- # ...probably a good idea to show all your work.
20
- window.show_all
21
- end
22
- end
23
- Gtk3App.main(MyApp)
24
-
25
- That's enough to get you going.
26
- The three examples in the ./examples[https://github.com/carlosjhr64/gtk3app/tree/master/examples]
27
- directory fully explains the rest of what Gtk3App can do for you.
28
-
29
- == FEATURES:
30
-
31
- * Such[https://github.com/carlosjhr64/Such] wrappers.
32
- * Rafini[https://github.com/carlosjhr64/rafini] refinements.
33
- * UserSpace[https://github.com/carlosjhr64/user_space] XDG support.
34
- * MiniMe, an alternative to the deprecated Gtk::StatusIcon.
35
- * Popup Application Menu from window button 3 press event (standard left click on application).
36
-
37
- == INSTALL:
38
-
39
- $ sudo gem install gtk3app
40
-
41
- == LICENSE:
42
-
43
- (The MIT License)
44
-
45
- Copyright (c) 2017
46
-
47
- Permission is hereby granted, free of charge, to any person obtaining
48
- a copy of this software and associated documentation files (the
49
- 'Software'), to deal in the Software without restriction, including
50
- without limitation the rights to use, copy, modify, merge, publish,
51
- distribute, sublicense, and/or sell copies of the Software, and to
52
- permit persons to whom the Software is furnished to do so, subject to
53
- the following conditions:
54
-
55
- The above copyright notice and this permission notice shall be
56
- included in all copies or substantial portions of the Software.
57
-
58
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
59
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
60
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
61
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
62
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
63
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
64
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65
-
66
- == CREDITS
67
-
68
- Stuff here I may have taken from:
69
-
70
- http://www.softicons.com/application-icons/ruby-programming-icons-by-ahmad-galal/ruby-gtk-icon
71
- http://zetcode.com/gui/rubygtk/
@@ -1 +0,0 @@
1
- 2.0.2
Binary file
@@ -1,59 +0,0 @@
1
- module Gtk3App
2
- module Dialog
3
-
4
- module Runs
5
- def initialize(*par,&block)
6
- @block = block
7
- super(*par)
8
- end
9
-
10
- def runs
11
- set_window_position(:center) if parent and not parent.visible?
12
- show_all
13
- response = run
14
- if block_given?
15
- response = yield(response)
16
- elsif @block
17
- response = @block.call(child, response)
18
- else
19
- response = (response==Gtk::ResponseType::OK)
20
- end
21
- destroy
22
- return response
23
- end
24
-
25
- # The following is just to save a bit of typing.
26
-
27
- def label(*par)
28
- Such::Label.new child, *par
29
- end
30
-
31
- def combo(*par)
32
- Such::ComboBoxText.new child, *par
33
- end
34
-
35
- def entry(*par)
36
- Such::Entry.new child, *par
37
- end
38
- end
39
-
40
- class CancelOk < Such::Dialog
41
- include Runs
42
- def initialize(*par)
43
- super
44
- add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
45
- add_button(Gtk::Stock::OK, Gtk::ResponseType::OK)
46
- end
47
- end
48
-
49
- class NoYes < Such::Dialog
50
- include Runs
51
- def initialize(*par)
52
- super
53
- add_button('_No', Gtk::ResponseType::CANCEL)
54
- add_button('_Yes', Gtk::ResponseType::OK)
55
- end
56
- end
57
-
58
- end
59
- end
@@ -1,48 +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
- Gtk3App.init Gtk3App
39
- Gtk3App.init app
40
- @program = Program.new app
41
- Gtk.main
42
- rescue StandardError
43
- $!.puts
44
- exit 1
45
- ensure
46
- @program.release if @program
47
- end
48
- end
@@ -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
@@ -1,56 +0,0 @@
1
- module Gtk3App
2
- module Widget
3
-
4
- class MenuItem < Such::MenuItem
5
- attr_accessor :key
6
- end
7
-
8
- class Menu < Such::Menu
9
- def append_menu_item(key, &block)
10
- item = MenuItem.new(self, key, &block)
11
- item.key = key
12
- item.show
13
- end
14
- end
15
-
16
- class AppMenu < Menu
17
- def initialize(window, *par, &block)
18
- @block = block
19
- window.add_events(Gdk::EventMask::BUTTON_PRESS_MASK)
20
- window.signal_connect('button_press_event') do |w,e|
21
- if e.button == 3
22
- self.popup(nil, nil, 3, e.time)
23
- else
24
- block.call(w,e,'button_press_event')
25
- end
26
- end
27
- super(*par)
28
- end
29
-
30
- def append_menu_item(key, &block)
31
- super(key, &(block || @block))
32
- end
33
- end
34
-
35
- class MainWindow < Such::Window
36
- def self.set_icon(file)
37
- @@icon = GdkPixbuf::Pixbuf.new(file: file)
38
- end
39
-
40
- def self.icon
41
- @@icon
42
- end
43
-
44
- def initialize(*par, &block)
45
- super(*par, &block)
46
- self.set_icon MainWindow.icon
47
- end
48
-
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
- end
53
- end
54
-
55
- end
56
- end