Module: Gtk3App
- Defined in:
- lib/gtk3app.rb,
lib/gtk3app/slot.rb,
lib/gtk3app/config.rb,
lib/gtk3app/gtk3app.rb,
lib/gtk3app/program.rb,
lib/gtk3app/dialog/dialogs.rb,
lib/gtk3app/widget/widgets.rb
Defined Under Namespace
Modules: Dialog, Slot, Widget Classes: Program
Constant Summary collapse
- VERSION =
'2.0.0'- APPDIR =
The gem’s root directory
File.dirname File.dirname __dir__
- CONFIG =
CONFIG follows the following conventions:
-
Strings and numbers are mixed case.
-
Arrays are all upper case (may except for arrays of length 1, see Such).
-
Hashes are all lower case.
-
Lower case bang! keys have special meaning in Such.
-
Note that method keys may have mixed case as the method itself.
-
{ # The command to open with default application Open: 'gnome-open', Slots: 13, # The number of minime slots SlotsDBM: "#{XDG['CACHE']}/gtk3app/slots.sdbm", # slot management database SLOTS_OFFSET: [0,0], # The offset from the bottom right corner SlotsScale: 25, # The size of the slots SlotsOrientation: :horizontal, thing: { # The application MAY overwrite some these # Main window configuration WINDOW: a0, # Window.new's parameters window: h0, # window settings window!: [:WINDOW,:window], # Minime's configuration # Application SHOULD NOT modify these. MINI: a0, mini: { set_decorated: false, minime: a0, }, mini!: [:MINI,:mini], # Fullscreen app-menu item # Application MAY modify :FS for language FS: [label: 'Full Screen'], fs: h0, fs!: [:FS, :fs, 'activate'], # About app-menu item # Application MAY modify :ABOUT for language # Application SHOULD modify :about_dialog ABOUT: [label: 'About'], about: h0, about!: [:ABOUT, :about, 'activate'], about_dialog: { set_program_name: 'Gtk3App', set_version: VERSION.semantic(0..1), set_copyright: '(c) 2017 CarlosJHR64', set_comments: 'A Gtk3 Application Stub', set_website: 'https://github.com/carlosjhr64/gtk3app', set_website_label: 'See it at GitHub!', }, # Application SHOULD modify LOGO to use it's own logo image. Logo: "#{XDG['DATA']}/gtk3app/logo.png", # Application SHOULD modify :HelpFile to their own help page. HelpFile: 'https://github.com/carlosjhr64/gtk3app', # By convention, I'm using mix case for simple String configurations in here thing. # Help app-menu item # Application MAY modify :HELP for language HELP: [label: 'Help'], help: h0, help!: [:HELP, :help, 'activate'], # Minime's app-menu item. # Application MAY modify :MINIME for language. MINIME: [label: 'Mini-me'], minime: h0, minime!: [:MINIME, :minime, 'activate'], # Quit app-menu item. # Application MAY modify :QUIT for language. QUIT: [label: 'Quit'], quit: h0, quit!: [:QUIT, :quit, 'activate'], # The app menu configuration. # The application MAY ONLY modify app_menu.append_menu_item # by removing un-wanted app menu items. APP_MENU: a0, app_menu: { append_menu_item: [:fs!, :about!, :help!, :minime!, :quit!], }, : [:APP_MENU, :app_menu, s0], # Minime's app-menu configuration. # The application SHOULD NOT modify # (the application will have the opportunity later to modify # minime's app-menu directly). MINI_MENU: a0, mini_menu: { append_menu_item: [:quit!], }, : [:MINI_MENU, :mini_menu, s0], }, }
Class Method Summary collapse
Class Method Details
.config(mod) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gtk3app/gtk3app.rb', line 9 def self.config(mod) # Let's get NameErrors out of the way first appdir = mod::APPDIR config = mod::CONFIG version = mod::VERSION # Create the directory name for UserSpace. appname = mod.name.downcase appname.prepend('gtk3app/') unless mod==Gtk3App # UserSpace does its thing... UserSpace::OPTIONS[:config] = "config-#{version.semantic(0..1)}" user_space = UserSpace.new(appname: appname, appdir: appdir) user_space.install unless user_space.version == version user_space.configures(config) rescue NameError $!.puts 'Application is not using APPDIR, VERSION, or CONFIG.' end |
.init(mod) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/gtk3app/gtk3app.rb', line 26 def self.init(mod) Gtk3App.config mod if thing = mod::CONFIG[:thing] Such::Thing.configure thing end rescue NameError $!.puts 'Application is not using CONFIG.' end |
.main(app) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gtk3app/gtk3app.rb', line 35 def self.main(app) Gtk3App.init Gtk3App Gtk3App.init app @program = Program.new app Gtk.main rescue StandardError $!.puts exit 1 ensure @program.release if @program end |