gluby-tk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/gluby-tk +33 -0
- data/lib/core_ext/string.rb +5 -0
- data/lib/gluby-tk.rb +7 -0
- data/lib/gluby-tk/generator.rb +132 -0
- data/lib/gluby-tk/version.rb +3 -0
- data/templates/boot.rb.template +19 -0
- data/templates/includes.rb.template +10 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ad90cf42c1588d6db4fb155446f3a1b886e4e3f
|
4
|
+
data.tar.gz: cc7d20313f3eb5d67ba937ab9e2609cf8427fd9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 660e04649c0488660ff22af4f726f5ee9345e31eeb24d0cc2c759c6fa6e6e3617d236b1c686e8b159557e063ae5a9cc58f7277c97d57a395fd9404d34bf5828e
|
7
|
+
data.tar.gz: b954a8701a12e455cda5fd7b431ec3bca205d50b67c05a164c739c6cf93302842c989f3ee9854cc6bae7f8e7e0f62e9645abe1b217d2c822312efe1fbc783118
|
data/bin/gluby-tk
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require "gluby-tk"
|
5
|
+
|
6
|
+
# options = {}
|
7
|
+
|
8
|
+
# OptionParser.new do |parser|
|
9
|
+
# parser.on("--new APP_NAME") do |name|
|
10
|
+
# puts "HERE"
|
11
|
+
# options[:app_name] = name
|
12
|
+
# end
|
13
|
+
# end.parse!
|
14
|
+
|
15
|
+
# if options.keys.include?(:app_name)
|
16
|
+
# puts "time to create #{options[:app_name]}"
|
17
|
+
# else
|
18
|
+
# GlubyTK.hi
|
19
|
+
# end
|
20
|
+
|
21
|
+
puts "No commands specified - exiting now..." and exit(0) if ARGV.empty?
|
22
|
+
|
23
|
+
if ARGV[0] == "new"
|
24
|
+
if ARGV[1].nil? || ARGV[1].strip.empty?
|
25
|
+
puts "No app name specified - exiting now..."
|
26
|
+
exit(1)
|
27
|
+
else
|
28
|
+
puts "Creating #{ARGV[1]}..."
|
29
|
+
GlubyTK::Generator.create(ARGV[1])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
exit(0)
|
data/lib/gluby-tk.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
module GlubyTK
|
2
|
+
class Generator
|
3
|
+
def self.create app_name
|
4
|
+
puts "#{app_name} already exists!" and exit(1) if File.exist?(app_name)
|
5
|
+
root = "#{Dir.pwd}/#{app_name}"
|
6
|
+
directories = [
|
7
|
+
"assets",
|
8
|
+
"assets/images",
|
9
|
+
"interface",
|
10
|
+
"src",
|
11
|
+
"src/model",
|
12
|
+
"src/view",
|
13
|
+
"src/controller"
|
14
|
+
]
|
15
|
+
|
16
|
+
templates = [
|
17
|
+
"src/application.rb",
|
18
|
+
]
|
19
|
+
|
20
|
+
# Create root directory
|
21
|
+
Dir.mkdir "#{Dir.pwd}/#{app_name}"
|
22
|
+
|
23
|
+
# Create sub-directories
|
24
|
+
directories.each do |dir|
|
25
|
+
Dir.mkdir "#{root}/#{dir}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create includes file
|
29
|
+
File.open("#{root}/src/includes.rb", "w+") { |file|
|
30
|
+
file.write(get_template_contents("includes.rb.template"))
|
31
|
+
}
|
32
|
+
|
33
|
+
# Create base module
|
34
|
+
module_name = "#{app_name.downcase}"
|
35
|
+
main_file = "#{root}/#{module_name}.rb"
|
36
|
+
File.open(main_file, "w+") { |file|
|
37
|
+
# file.write("module #{module_name.humanize}\n\nend\n")
|
38
|
+
file.write(get_template_contents("boot.rb.template"))
|
39
|
+
}
|
40
|
+
|
41
|
+
app_id = module_name.humanize.downcase
|
42
|
+
# Create Application
|
43
|
+
File.open("#{root}/src/application.rb", "w+") { |file|
|
44
|
+
|
45
|
+
file.write("class Application < Gtk::Application
|
46
|
+
def initialize
|
47
|
+
super('app.#{app_id}', :handles_open)
|
48
|
+
# TODO: Go to login screen if user is not ready logged in
|
49
|
+
signal_connect 'activate' do |application|
|
50
|
+
@window = ApplicationWindow.new(:application => application)
|
51
|
+
@window.present
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
")
|
56
|
+
}
|
57
|
+
|
58
|
+
# Create ApplicationWindow
|
59
|
+
File.open("#{root}/src/view/application_window.rb", "w+") { |file|
|
60
|
+
file.write("class ApplicationWindow < Gtk::ApplicationWindow
|
61
|
+
type_register
|
62
|
+
class << self
|
63
|
+
def init
|
64
|
+
set_template(:resource => '/app/#{app_id}/ApplicationWindow.glade')
|
65
|
+
# Specify the any UI elements you need to reference in code using the glade ID
|
66
|
+
[\"main_box\", \"welcome_label\"].each{|child_id| bind_template_child(child_id)}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def initialize(application: application)
|
71
|
+
super(application: application)
|
72
|
+
end
|
73
|
+
end")
|
74
|
+
}
|
75
|
+
|
76
|
+
File.open("#{root}/interface/interface.gresource.xml", "w+") { |file|
|
77
|
+
file.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
78
|
+
<gresources>
|
79
|
+
<gresource prefix=\"/app/#{app_id}\">
|
80
|
+
<file preprocess=\"xml-stripblanks\">ApplicationWindow.glade</file>
|
81
|
+
</gresource>
|
82
|
+
</gresources>
|
83
|
+
")
|
84
|
+
}
|
85
|
+
|
86
|
+
File.open("#{root}/interface/ApplicationWindow.glade", "w+") { |file|
|
87
|
+
file.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
88
|
+
<!-- Generated with glade 3.20.0 -->
|
89
|
+
<interface>
|
90
|
+
<requires lib=\"gtk+\" version=\"3.20\"/>
|
91
|
+
<template class=\"ApplicationWindow\" parent=\"GtkApplicationWindow\">
|
92
|
+
<property name=\"can_focus\">False</property>
|
93
|
+
<property name=\"window_position\">center</property>
|
94
|
+
<property name=\"icon_name\">computer</property>
|
95
|
+
<property name=\"gravity\">center</property>
|
96
|
+
<property name=\"show_menubar\">False</property>
|
97
|
+
<child>
|
98
|
+
<object class=\"GtkBox\" id=\"main_box\">
|
99
|
+
<property name=\"width_request\">300</property>
|
100
|
+
<property name=\"height_request\">300</property>
|
101
|
+
<property name=\"visible\">True</property>
|
102
|
+
<property name=\"can_focus\">False</property>
|
103
|
+
<property name=\"orientation\">vertical</property>
|
104
|
+
<child>
|
105
|
+
<object class=\"GtkLabel\" id=\"welcome_label\">
|
106
|
+
<property name=\"visible\">True</property>
|
107
|
+
<property name=\"can_focus\">False</property>
|
108
|
+
<property name=\"label\" translatable=\"yes\">Welcome to #{module_name.humanize}!\n\nBuilt with RGTK</property>
|
109
|
+
</object>
|
110
|
+
<packing>
|
111
|
+
<property name=\"expand\">False</property>
|
112
|
+
<property name=\"fill\">True</property>
|
113
|
+
<property name=\"position\">0</property>
|
114
|
+
</packing>
|
115
|
+
</child>
|
116
|
+
</object>
|
117
|
+
</child>
|
118
|
+
</template>
|
119
|
+
</interface>
|
120
|
+
")
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.get_template_contents(template_name)
|
125
|
+
File.read("#{template_dir}#{template_name}")
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.template_dir
|
129
|
+
"#{File.dirname(File.dirname(File.dirname(__FILE__)))}/templates/"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$: << 'src'
|
2
|
+
require 'includes'
|
3
|
+
|
4
|
+
data_path = "#{File.expand_path(File.dirname(__FILE__))}/interface"
|
5
|
+
|
6
|
+
gresource_bin = "#{data_path}/interface.gresource"
|
7
|
+
gresource_xml = "#{data_path}/interface.gresource.xml"
|
8
|
+
|
9
|
+
system("glib-compile-resources", "--target", gresource_bin, "--sourcedir", File.dirname(gresource_xml), gresource_xml)
|
10
|
+
|
11
|
+
at_exit do
|
12
|
+
FileUtils.rm_f(gresource_bin)
|
13
|
+
end
|
14
|
+
|
15
|
+
resource = Gio::Resource.load(gresource_bin)
|
16
|
+
Gio::Resources.register(resource)
|
17
|
+
|
18
|
+
# Start application
|
19
|
+
Application.new.run
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gluby-tk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- i2097i
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gtk3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.1
|
55
|
+
description: A tool for creating GTK applications using Ruby and Glade
|
56
|
+
email:
|
57
|
+
- i2097i@hotmail.com
|
58
|
+
executables:
|
59
|
+
- gluby-tk
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- bin/gluby-tk
|
64
|
+
- lib/core_ext/string.rb
|
65
|
+
- lib/gluby-tk.rb
|
66
|
+
- lib/gluby-tk/generator.rb
|
67
|
+
- lib/gluby-tk/version.rb
|
68
|
+
- templates/boot.rb.template
|
69
|
+
- templates/includes.rb.template
|
70
|
+
homepage: https://github.com/i2097i/gluby-tk
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.5.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Ruby+GTK+Glade
|
94
|
+
test_files: []
|