gtk3app 2.1.0 → 5.1.210203

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: 5776600dff1a4cff414d107d0730f52aa16d5648f7c23f158bec4d2f17ee78e0
4
- data.tar.gz: 90fa95e7e54faec826906680e2835aef28f2ce78ff7b9fd252a46163a7b7e868
3
+ metadata.gz: 490766226e419c95df9c289a498e2993cd7d30d60ebe067513ba19e6ceb3671c
4
+ data.tar.gz: e77336b94e3f9308e53f5c68edbab1e78d4ea36db963ca0887c9eef213794e94
5
5
  SHA512:
6
- metadata.gz: f558b83b77e6322ee8508faf0bde2a15b3e346804db506d20a29a87c8194954e27ec5d04b2a13d1ba4d0b30dbbbe609be6a89ce7080f1337f682243288ef6681
7
- data.tar.gz: 014e92636224ddbe4400db0ba500197bd36465c6bd512cc4f7645a48b092d1c22c472db45aa880c1c1252fbc85f3db9b77b09e4b70aa49860f6d11f85104a20c
6
+ metadata.gz: b1c28dd78c7b7f46ef9d5aecefce83ef36b8afe43c3044a81afbaea7af0a183772c33c3c1b3b70d16c3c5456fa59668385404a1966a01dc91f35c9b062979262
7
+ data.tar.gz: 3bc60d705a3029a7f3e29b7f829f27d3d0b5edd7ea62d6bc575a4ba72013c980caaac202e6b3dc0efb6047b23a567fa640f9ed849c4adffe5bc842f54be6d8d8
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # Gtk3App
2
+
3
+ * [VERSION 5.1.210203](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/)
data/lib/gtk3app.rb CHANGED
@@ -1,40 +1,21 @@
1
- module Gtk3App
2
- VERSION = '2.1.0'
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 = '5.1.210203'
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,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) 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
- # Note that you can reference the item.key,
92
- # see: Gtk3App::Widget::MenuItem < Such::MenuItem
93
- APP_MENU: a0,
94
- app_menu: {
95
- append_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
- append_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,89 +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
- 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
- @gui = 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
+ 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
80
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
81
126
  end
127
+ end
82
128
 
83
- def quit!
84
- release
85
- @gui.finalize if @gui.respond_to? :finalize
86
- 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
87
179
  end
88
180
  end
89
181
  end
182
+ 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.1.0
4
+ version: 5.1.210203
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2021-02-03 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.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,92 +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'
60
100
  - - ">="
61
101
  - !ruby/object:Gem::Version
62
- version: 3.2.7
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.7
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: '2.0'
80
120
  - - ">="
81
121
  - !ruby/object:Gem::Version
82
- version: 0.4.0
122
+ version: 2.0.210201
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: '2.0'
90
130
  - - ">="
91
131
  - !ruby/object:Gem::Version
92
- version: 0.4.0
132
+ version: 2.0.210201
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
144
  extra_rdoc_files: []
101
145
  files:
102
- - README.rdoc
103
- - data/VERSION
146
+ - README.md
104
147
  - data/logo.png
105
- - data/ruby.png
106
148
  - lib/gtk3app.rb
107
149
  - lib/gtk3app/config.rb
108
- - lib/gtk3app/dialog/dialogs.rb
109
- - lib/gtk3app/gtk3app.rb
110
150
  - lib/gtk3app/program.rb
111
- - lib/gtk3app/slot.rb
112
- - lib/gtk3app/widget/widgets.rb
151
+ - lib/gtk3app/widgets.rb
113
152
  homepage: https://github.com/carlosjhr64/gtk3app
114
153
  licenses:
115
154
  - MIT
116
155
  metadata: {}
117
- post_install_message:
156
+ post_install_message:
118
157
  rdoc_options: []
119
158
  require_paths:
120
159
  - lib
@@ -129,10 +168,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
168
  - !ruby/object:Gem::Version
130
169
  version: '0'
131
170
  requirements:
132
- - 'ruby: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]'
133
- rubyforge_project:
134
- rubygems_version: 2.7.6
135
- 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:
136
174
  specification_version: 4
137
- summary: Gtk3App provides a Gtk3 application stub.
175
+ summary: Gtk3App provides a [Ruby Gnome Gtk3](https://rubygems.org/gems/gtk3) application
176
+ stub.
138
177
  test_files: []
data/README.rdoc DELETED
@@ -1,77 +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
- === New for 2.1
38
-
39
- If in the above example MyApp.run return an object the responds to #finalize,
40
- the method will be called before the Gtk main quit.
41
- This allows for any cleanups the gui may need to do before exit.
42
-
43
- == INSTALL:
44
-
45
- $ sudo gem install gtk3app
46
-
47
- == LICENSE:
48
-
49
- (The MIT License)
50
-
51
- Copyright (c) 2017
52
-
53
- Permission is hereby granted, free of charge, to any person obtaining
54
- a copy of this software and associated documentation files (the
55
- 'Software'), to deal in the Software without restriction, including
56
- without limitation the rights to use, copy, modify, merge, publish,
57
- distribute, sublicense, and/or sell copies of the Software, and to
58
- permit persons to whom the Software is furnished to do so, subject to
59
- the following conditions:
60
-
61
- The above copyright notice and this permission notice shall be
62
- included in all copies or substantial portions of the Software.
63
-
64
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
65
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
66
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
67
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
68
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
70
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
71
-
72
- == CREDITS
73
-
74
- Stuff here I may have taken from:
75
-
76
- http://www.softicons.com/application-icons/ruby-programming-icons-by-ahmad-galal/ruby-gtk-icon
77
- http://zetcode.com/gui/rubygtk/
data/data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.1.0
data/data/ruby.png DELETED
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
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
@@ -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