rugui 1.6.0 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +48 -23
- data/Rakefile +3 -10
- data/bin/rugui +4 -1
- data/lib/rugui/base_view.rb +5 -5
- data/lib/rugui/configuration.rb +1 -29
- data/lib/rugui/entity_registration_support.rb +17 -2
- data/lib/rugui/framework_adapters/GTK.rb +15 -32
- data/lib/rugui/framework_adapters/Qt4.rb +22 -3
- data/lib/rugui/generators/rugui/rugui_generator.rb +3 -9
- data/lib/rugui/generators/rugui/templates/Gemfile.tt +20 -0
- data/lib/rugui/generators/rugui/templates/Rakefile +0 -4
- data/lib/rugui/generators/rugui/templates/app/main.rb +1 -1
- data/lib/rugui/generators/rugui/templates/config/boot.rb +5 -78
- data/lib/rugui/generators/rugui/templates/config/environment.rb.tt +7 -7
- data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/xml/main_view.xml +43 -0
- data/lib/rugui/generators/rugui/templates/spec/spec_helper.rb +0 -2
- data/lib/rugui/initializer.rb +3 -60
- data/lib/rugui/observable_property_support.rb +5 -1
- data/lib/rugui/property_changed_support.rb +1 -1
- data/lib/rugui/signal_support.rb +2 -2
- data/lib/rugui/tasks/rugui.rb +1 -1
- data/lib/rugui/tasks/runner_application.rake +1 -1
- data/lib/rugui/tasks/spec_application.rake +5 -44
- data/lib/rugui/tasks/spec_framework.rake +3 -25
- data/lib/rugui/version.rb +1 -7
- data/lib/rugui.rb +0 -3
- data/spec/framework/base_controller_spec.rb +7 -14
- data/spec/framework/base_model_spec.rb +1 -3
- data/spec/framework/base_view_helper_spec.rb +1 -3
- data/spec/framework/base_view_spec.rb +2 -5
- data/spec/framework/log_support_spec.rb +2 -2
- data/spec/framework/observable_property_proxy_spec.rb +13 -14
- data/spec/framework/observable_property_support_spec.rb +8 -10
- data/spec/framework/property_observer_spec.rb +20 -22
- data/spec/helpers/controllers.rb +3 -3
- data/spec/helpers/helper_manager.rb +9 -0
- data/spec/helpers/observables.rb +40 -52
- data/spec/helpers/views.rb +15 -15
- data/spec/resource_files/my_other_view.xml +53 -0
- data/spec/resource_files/my_view.xml +53 -0
- data/spec/spec_helper.rb +9 -3
- metadata +98 -84
- data/lib/rugui/gem_builder.rb +0 -21
- data/lib/rugui/gem_dependency.rb +0 -282
- data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/glade/main_view.glade +0 -33
- data/lib/rugui/generators/rugui/templates/spec/rcov.opts +0 -1
- data/lib/rugui/generators/rugui/templates/spec/spec.opts +0 -4
- data/lib/rugui/generators/rugui/templates/test/test_helper.rb +0 -12
- data/lib/rugui/plugin/loader.rb +0 -77
- data/lib/rugui/tasks/gems_application.rake +0 -71
- data/lib/rugui/tasks/test_application.rake +0 -77
- data/lib/rugui/vendor_gem_source_index.rb +0 -140
- data/spec/rcov.opts +0 -1
- data/spec/spec.opts +0 -5
data/README.rdoc
CHANGED
@@ -27,32 +27,45 @@ A basic support for building Rubygame applications was also added. It is still
|
|
27
27
|
missing some functionality like signal connections and widget creation but it is
|
28
28
|
usable. By using RuGUI you will gain a template directory structure as well some
|
29
29
|
of the features of RuGUI, like configuration, a shell script for running your
|
30
|
-
game, support for
|
30
|
+
game, support for Rspec, etc.
|
31
31
|
|
32
|
-
==
|
32
|
+
== Dependencies
|
33
33
|
|
34
|
-
|
34
|
+
RuGUI depends, of course, on the Ruby binding for the GUI framework that you'll
|
35
|
+
use. When generating an application you may choose which framework you'll want
|
36
|
+
to use. By default it will use GTK.
|
35
37
|
|
36
|
-
|
38
|
+
Here are the recommended way to install the bindings for each platform:
|
37
39
|
|
38
|
-
|
40
|
+
=== Mac OS X
|
39
41
|
|
40
|
-
|
42
|
+
We recommend that you use brew:
|
41
43
|
|
42
|
-
|
44
|
+
brew install gtk+ # for GTK
|
45
|
+
brew install qt # for Qt4
|
46
|
+
brew install sdl # for Rubygame
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
For Rubygame you may also want to install some other SDL related libraries:
|
49
|
+
|
50
|
+
brew install sdl_gfx sdl_image sdl_mixer sdl_net sdl_rtf sdl_sound sdl_ttf
|
51
|
+
|
52
|
+
=== Linux
|
53
|
+
|
54
|
+
TODO: Describe linux installation instructions for GTK, Qt4 and Rubygame
|
55
|
+
|
56
|
+
=== Windows
|
47
57
|
|
48
|
-
|
58
|
+
TODO: Describe windows installation instructions for GTK, Qt4 and Rubygame
|
49
59
|
|
50
|
-
|
60
|
+
== Installation
|
51
61
|
|
52
|
-
|
62
|
+
Install the gem:
|
63
|
+
|
64
|
+
gem install rugui
|
53
65
|
|
54
|
-
|
55
|
-
|
66
|
+
To check if the installation was successful type in a console:
|
67
|
+
|
68
|
+
rugui -v
|
56
69
|
|
57
70
|
== Generating an Application
|
58
71
|
|
@@ -61,22 +74,34 @@ application and type:
|
|
61
74
|
|
62
75
|
rugui <app_name>
|
63
76
|
|
64
|
-
For more options type:
|
77
|
+
For more options type (including changing GUI framework):
|
65
78
|
|
66
79
|
rugui -h
|
67
80
|
|
81
|
+
Next cd into your application and run:
|
82
|
+
|
83
|
+
bundle install
|
84
|
+
|
85
|
+
You'll surely want to use RVM[http://rvm.io].
|
86
|
+
|
87
|
+
After all gems are installed you can run your application by:
|
88
|
+
|
89
|
+
rake run
|
90
|
+
|
68
91
|
== Testing
|
69
92
|
|
70
|
-
|
71
|
-
|
72
|
-
|
93
|
+
RuGUI ships with support for RSpec, just add specs to spec/ dir and you're ready
|
94
|
+
to go!
|
95
|
+
|
96
|
+
== Contributing
|
73
97
|
|
74
|
-
|
98
|
+
In order to run RuGUI framework specs, you just need to fork the repository, clone
|
99
|
+
it to your machine, then after installing all dependencies, run:
|
75
100
|
|
76
|
-
|
77
|
-
|
101
|
+
bundle install
|
102
|
+
rake spec
|
78
103
|
|
79
|
-
|
104
|
+
If all specs pass, then you're good to go and contribute by sending a pull request!
|
80
105
|
|
81
106
|
== More info
|
82
107
|
|
data/Rakefile
CHANGED
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# and open the template in the editor.
|
4
|
-
|
5
|
-
|
6
|
-
require 'rake'
|
7
|
-
require 'rake/testtask'
|
8
|
-
require 'rake/rdoctask'
|
9
|
-
|
10
|
-
require 'lib/rugui/tasks/rugui_framework'
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require File.expand_path('../lib/rugui/tasks/rugui_framework', __FILE__)
|
11
3
|
|
4
|
+
task :default => :spec
|
data/bin/rugui
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'thor/group'
|
6
|
+
|
7
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
8
|
+
|
6
9
|
require 'rugui/generators'
|
7
10
|
|
8
11
|
if %w(-v --version).include? ARGV.first
|
9
12
|
require 'rugui/version'
|
10
|
-
puts "RuGUI #{RuGUI::VERSION
|
13
|
+
puts "RuGUI #{RuGUI::VERSION}"
|
11
14
|
exit(0)
|
12
15
|
end
|
13
16
|
|
data/lib/rugui/base_view.rb
CHANGED
@@ -37,11 +37,11 @@ module RuGUI
|
|
37
37
|
attr_reader :widgets
|
38
38
|
attr_reader :unnamed_widgets
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
class_attribute :configured_builder_file
|
41
|
+
class_attribute :configured_builder_file_usage
|
42
|
+
class_attribute :configured_builder_file_extension
|
43
|
+
class_attribute :configured_root
|
44
|
+
class_attribute :configured_display_root
|
45
45
|
|
46
46
|
def initialize
|
47
47
|
@controllers = {}
|
data/lib/rugui/configuration.rb
CHANGED
@@ -47,14 +47,6 @@ module RuGUI
|
|
47
47
|
# A hash of application specific configurations.
|
48
48
|
attr_accessor :application
|
49
49
|
|
50
|
-
# An array of gems that this RuGUI application depends on. RuGUI will automatically load
|
51
|
-
# these gems during installation, and allow you to install any missing gems with:
|
52
|
-
#
|
53
|
-
# rake gems:install
|
54
|
-
#
|
55
|
-
# You can add gems with the #gem method.
|
56
|
-
attr_accessor :gems
|
57
|
-
|
58
50
|
def initialize
|
59
51
|
set_root_path!
|
60
52
|
|
@@ -65,7 +57,6 @@ module RuGUI
|
|
65
57
|
self.styles_paths = default_styles_paths
|
66
58
|
self.queue_timeout = default_queue_timeout
|
67
59
|
self.automatically_register_conventionally_named_views = default_automatically_register_conventionally_named_views
|
68
|
-
self.gems = default_gems
|
69
60
|
self.logger = {}
|
70
61
|
self.application = {}
|
71
62
|
end
|
@@ -73,7 +64,7 @@ module RuGUI
|
|
73
64
|
# The path to the current environment's file (<tt>development.rb</tt>, etc.). By
|
74
65
|
# default the file is at <tt>config/environments/#{environment}.rb</tt>.
|
75
66
|
def environment_path
|
76
|
-
root_path.join('config', 'environments', "#{environment}.rb")
|
67
|
+
root_path.join('config', 'environments', "#{environment}.rb").to_s
|
77
68
|
end
|
78
69
|
|
79
70
|
def set_root_path!
|
@@ -83,21 +74,6 @@ module RuGUI
|
|
83
74
|
@root_path = Pathname.new(File.expand_path(::APPLICATION_ROOT))
|
84
75
|
end
|
85
76
|
|
86
|
-
# Adds a single Gem dependency to the RuGUI application. By default, it will require
|
87
|
-
# the library with the same name as the gem. Use :lib to specify a different name.
|
88
|
-
#
|
89
|
-
# # gem 'aws-s3', '>= 0.4.0'
|
90
|
-
# # require 'aws/s3'
|
91
|
-
# config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \
|
92
|
-
# :source => "http://code.whytheluckystiff.net"
|
93
|
-
#
|
94
|
-
# To require a library be installed, but not attempt to load it, pass :lib => false
|
95
|
-
#
|
96
|
-
# config.gem 'qrp', :version => '0.4.1', :lib => false
|
97
|
-
def gem(name, options = {})
|
98
|
-
@gems << RuGUI::GemDependency.new(name, options)
|
99
|
-
end
|
100
|
-
|
101
77
|
private
|
102
78
|
def default_environment
|
103
79
|
::RUGUI_ENV
|
@@ -136,9 +112,5 @@ module RuGUI
|
|
136
112
|
def default_automatically_register_conventionally_named_views
|
137
113
|
true
|
138
114
|
end
|
139
|
-
|
140
|
-
def default_gems
|
141
|
-
[]
|
142
|
-
end
|
143
115
|
end
|
144
116
|
end
|
@@ -7,6 +7,16 @@ module RuGUI
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
def clear_all_registries
|
11
|
+
self.entity_registrations.keys.each do |entity|
|
12
|
+
clear_registry(entity)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear_registry(entity)
|
17
|
+
self.entity_registrations[entity] = []
|
18
|
+
end
|
19
|
+
|
10
20
|
private
|
11
21
|
def register_entity(entity, name)
|
12
22
|
self.entity_registrations[entity] ||= []
|
@@ -15,8 +25,13 @@ module RuGUI
|
|
15
25
|
end
|
16
26
|
|
17
27
|
def self.included(base)
|
18
|
-
base.
|
28
|
+
base.class_attribute :entity_registrations
|
19
29
|
base.entity_registrations = {}
|
30
|
+
|
31
|
+
def base.inherited(base)
|
32
|
+
base.entity_registrations = {}
|
33
|
+
end
|
34
|
+
|
20
35
|
base.extend(ClassMethods)
|
21
36
|
end
|
22
37
|
|
@@ -91,4 +106,4 @@ module RuGUI
|
|
91
106
|
class_eval
|
92
107
|
end
|
93
108
|
end
|
94
|
-
end
|
109
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'gtk2'
|
2
|
-
require 'libglade2'
|
3
2
|
|
4
3
|
unless Object.respond_to?(:instance_exec) # Ruby 1.9 does already has Object#instance_exec
|
5
4
|
# See the discussion here: http://eigenclass.org/hiki.rb?instance_exec
|
@@ -104,6 +103,7 @@ module RuGUI
|
|
104
103
|
|
105
104
|
# Adds a widget to the given container widget.
|
106
105
|
def add_widget_to_container(widget, container_widget)
|
106
|
+
widget.parent.remove(widget) if widget.parent && widget.parent != container_widget
|
107
107
|
container_widget.add(widget)
|
108
108
|
end
|
109
109
|
|
@@ -128,9 +128,9 @@ module RuGUI
|
|
128
128
|
# it is used instead of the view itself.
|
129
129
|
def autoconnect_signals(other_target = nil)
|
130
130
|
if self.adapted_object.use_builder?
|
131
|
-
self.adapted_object.
|
132
|
-
target
|
133
|
-
|
131
|
+
self.adapted_object.builder_instance.connect_signals do |name|
|
132
|
+
target = other_target || self.adapted_object
|
133
|
+
target.method(name) if target.respond_to?(name)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
@@ -152,28 +152,26 @@ module RuGUI
|
|
152
152
|
|
153
153
|
# Builds widgets from the given filename, using the proper builder.
|
154
154
|
def build_widgets_from(filename)
|
155
|
-
self.adapted_object.
|
155
|
+
self.adapted_object.builder_instance ||= Gtk::Builder.new
|
156
|
+
self.adapted_object.builder_instance.add_from_file(filename)
|
156
157
|
|
157
|
-
self.adapted_object.
|
158
|
-
self.adapted_object.send(:create_attribute_for_widget,
|
158
|
+
self.adapted_object.builder_instance.objects.each do |widget|
|
159
|
+
self.adapted_object.send(:create_attribute_for_widget, widget.builder_name)
|
159
160
|
end
|
160
|
-
self.adapted_object.root_widget.show if self.adapted_object.display_root? and not self.adapted_object.root_widget.nil?
|
161
161
|
end
|
162
162
|
|
163
163
|
# Registers widgets as attributes of the view class.
|
164
164
|
def register_widgets
|
165
|
-
self.adapted_object.
|
166
|
-
|
167
|
-
|
168
|
-
self.adapted_object.widgets[widget_name] = self.adapted_object.glade[widget_name]
|
169
|
-
end
|
165
|
+
self.adapted_object.builder_instance.objects.each do |widget|
|
166
|
+
self.adapted_object.send("#{widget.builder_name}=", widget)
|
167
|
+
self.adapted_object.widgets[widget.builder_name] = widget
|
170
168
|
end
|
171
169
|
end
|
172
170
|
|
173
171
|
class << self
|
174
172
|
# Returns the builder file extension to be used for this view class.
|
175
173
|
def builder_file_extension
|
176
|
-
'
|
174
|
+
'xml'
|
177
175
|
end
|
178
176
|
end
|
179
177
|
end
|
@@ -183,9 +181,7 @@ end
|
|
183
181
|
|
184
182
|
module RuGUI
|
185
183
|
class BaseView < BaseObject
|
186
|
-
|
187
|
-
|
188
|
-
attr_accessor :glade
|
184
|
+
attr_accessor :builder_instance
|
189
185
|
|
190
186
|
# Adds a signal handler for all widgets of the given type.
|
191
187
|
def add_signal_handler_for_widget_type(widget_type, signal, &block)
|
@@ -218,22 +214,9 @@ module RuGUI
|
|
218
214
|
# definition doesn't need to point to an existing widget we can use this
|
219
215
|
# to simplify the widget styling here.
|
220
216
|
def change_widget_style(widget_or_name, widget_path_style)
|
221
|
-
|
222
|
-
widget = widget_or_name
|
223
|
-
else
|
224
|
-
widget = @glade[widget_or_name.to_s]
|
225
|
-
end
|
217
|
+
widget = widget_or_name.is_a?(Gtk::Widget) ? widget_or_name : self.builder_instance.get_object(widget_or_name)
|
226
218
|
style = Gtk::RC.get_style_by_paths(Gtk::Settings.default, widget_path_style.to_s, nil, nil)
|
227
219
|
widget.style = style
|
228
220
|
end
|
229
|
-
|
230
|
-
class << self
|
231
|
-
# Call this method at class level if the view should be built from a glade
|
232
|
-
# file.
|
233
|
-
def use_glade
|
234
|
-
self.logger.warn('DEPRECATED - Call use_builder class method instead in your view.')
|
235
|
-
use_builder
|
236
|
-
end
|
237
|
-
end
|
238
221
|
end
|
239
|
-
end
|
222
|
+
end
|
@@ -13,6 +13,21 @@ end
|
|
13
13
|
|
14
14
|
Qt.create_application
|
15
15
|
|
16
|
+
# This is a monkey patch needed because ActiveSupport::Depndencies define a load
|
17
|
+
# method that conflicts with Qt::UiLoader#load method. We save the old load method,
|
18
|
+
# require ActiveSupport::Depndencies, the revert the load method back again.
|
19
|
+
class Qt::UiLoader
|
20
|
+
alias old_qt_load load
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'active_support/dependencies'
|
24
|
+
|
25
|
+
class Qt::UiLoader
|
26
|
+
alias load old_qt_load
|
27
|
+
end
|
28
|
+
|
29
|
+
### End of Qt::UiLoader monkey patch
|
30
|
+
|
16
31
|
module RuGUI
|
17
32
|
module FrameworkAdapters
|
18
33
|
module Qt4
|
@@ -108,10 +123,14 @@ module RuGUI
|
|
108
123
|
|
109
124
|
private
|
110
125
|
def load_ui_file(filename)
|
111
|
-
file = Qt::File.new(filename)
|
112
|
-
|
126
|
+
file = Qt::File.new(filename) do
|
127
|
+
open(Qt::File::ReadOnly)
|
128
|
+
end
|
129
|
+
|
113
130
|
loader = Qt::UiLoader.new
|
114
|
-
loader.load
|
131
|
+
loader.load file
|
132
|
+
ensure
|
133
|
+
file.close if file.present?
|
115
134
|
end
|
116
135
|
|
117
136
|
def root_widget_from(ui_file_root_widget)
|
@@ -8,12 +8,9 @@ class Rugui < Thor::Group
|
|
8
8
|
class_option :framework_adapter, :type => :string, :aliases => '-a', :default => 'gtk',
|
9
9
|
:desc => "Choose which framework adapter to use, must be one of 'gtk', 'qt' or 'rubygame'"
|
10
10
|
|
11
|
-
class_option :test_framework, :type => :string, :aliases => '-t', :default => 'RSpec',
|
12
|
-
:desc => "Choose which test framework to use, defaults to 'RSpec', but can be set to 'test-unit' also"
|
13
|
-
|
14
11
|
class_option :version, :type => :boolean, :aliases => "-v", :group => :rugui,
|
15
12
|
:desc => "Show RuGUI version number and quit"
|
16
|
-
|
13
|
+
|
17
14
|
class_option :help, :type => :boolean, :aliases => "-h", :group => :rugui,
|
18
15
|
:desc => "Show this help message and quit"
|
19
16
|
|
@@ -31,6 +28,7 @@ class Rugui < Thor::Group
|
|
31
28
|
def create_root_files
|
32
29
|
copy_file 'README'
|
33
30
|
copy_file 'Rakefile'
|
31
|
+
template 'Gemfile.tt'
|
34
32
|
end
|
35
33
|
|
36
34
|
def create_directory_structure
|
@@ -81,7 +79,7 @@ class Rugui < Thor::Group
|
|
81
79
|
end
|
82
80
|
|
83
81
|
def create_test_files
|
84
|
-
directory
|
82
|
+
directory 'spec'
|
85
83
|
end
|
86
84
|
|
87
85
|
protected
|
@@ -100,8 +98,4 @@ class Rugui < Thor::Group
|
|
100
98
|
def framework_specific_file(path)
|
101
99
|
File.join('framework_specific', options[:framework_adapter], path)
|
102
100
|
end
|
103
|
-
|
104
|
-
def test_framework_dir
|
105
|
-
options[:test_framework] == 'RSpec' ? 'spec' : 'test'
|
106
|
-
end
|
107
101
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# RuGUI gem
|
4
|
+
gem 'rugui', '~> 2.0.0.beta'
|
5
|
+
|
6
|
+
# GTK ruby bindings
|
7
|
+
<%= '#' unless framework_adapter_name == 'GTK' %>gem 'gtk2'
|
8
|
+
|
9
|
+
# Qt ruby bindings
|
10
|
+
<%= '#' unless framework_adapter_name == 'Qt4' %>gem 'qtbindings'
|
11
|
+
|
12
|
+
# Rubygame
|
13
|
+
<%= '#' unless framework_adapter_name == 'Rubygame' %>gem 'rubygame'
|
14
|
+
|
15
|
+
# Uncomment this if you want to debug applications
|
16
|
+
# gem 'debugger'
|
17
|
+
|
18
|
+
group :test do
|
19
|
+
gem 'rspec', '>= 2.11.0'
|
20
|
+
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Do not modify it, unless you know what you are doing.
|
6
6
|
#
|
7
7
|
|
8
|
-
require File.
|
8
|
+
require File.expand_path('../../config/environment', __FILE__)
|
9
9
|
|
10
10
|
main_controller = MainController.new
|
11
11
|
main_controller.run
|
@@ -1,81 +1,8 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# This was mainly copied (but modified a little bit) from the rails framework
|
4
|
-
# initializers, but made less picky about gem loading.
|
1
|
+
require 'rubygems'
|
5
2
|
|
6
|
-
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
7
5
|
|
8
|
-
|
9
|
-
class << self
|
10
|
-
def boot!
|
11
|
-
unless booted?
|
12
|
-
preinitialize
|
13
|
-
pick_boot.run
|
14
|
-
end
|
15
|
-
end
|
6
|
+
APPLICATION_ROOT = File.expand_path('../..', __FILE__) unless defined?(APPLICATION_ROOT)
|
16
7
|
|
17
|
-
|
18
|
-
defined? RuGUI::Initializer
|
19
|
-
end
|
20
|
-
|
21
|
-
def pick_boot
|
22
|
-
(vendor_rugui? ? VendorBoot : GemBoot).new
|
23
|
-
end
|
24
|
-
|
25
|
-
def vendor_rugui?
|
26
|
-
File.exist?("#{APPLICATION_ROOT}/vendor/rugui")
|
27
|
-
end
|
28
|
-
|
29
|
-
def preinitialize
|
30
|
-
load(preinitializer_path) if File.exist?(preinitializer_path)
|
31
|
-
end
|
32
|
-
|
33
|
-
def preinitializer_path
|
34
|
-
"#{APPLICATION_ROOT}/config/preinitializer.rb"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Boot
|
39
|
-
def run
|
40
|
-
load_initializer
|
41
|
-
RuGUI::Initializer.run(:set_load_path)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class VendorBoot < Boot
|
46
|
-
def load_initializer
|
47
|
-
require "#{APPLICATION_ROOT}/vendor/rugui/lib/rugui/initializer"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class GemBoot < Boot
|
52
|
-
def load_initializer
|
53
|
-
self.class.load_rubygems
|
54
|
-
load_rugui
|
55
|
-
require 'rugui/initializer'
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_rugui
|
59
|
-
require 'rugui'
|
60
|
-
rescue Gem::LoadError
|
61
|
-
$stderr.puts %(Missing the RuGUI gem. Please `gem install rugui`.)
|
62
|
-
exit 1
|
63
|
-
end
|
64
|
-
|
65
|
-
class << self
|
66
|
-
def rubygems_version
|
67
|
-
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
|
68
|
-
end
|
69
|
-
|
70
|
-
def load_rubygems
|
71
|
-
require 'rubygems'
|
72
|
-
rescue LoadError
|
73
|
-
$stderr.puts %(RuGUI requires RubyGems. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
74
|
-
exit 1
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# All that for this:
|
81
|
-
RuGUI.boot!
|
8
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
@@ -1,8 +1,14 @@
|
|
1
1
|
# Uncomment below to force the RuGUI application into production mode
|
2
2
|
# ENV['RUGUI_ENV'] ||= 'production'
|
3
|
+
ENV['RUGUI_ENV'] ||= 'development'
|
3
4
|
|
4
5
|
# Bootstrap the RuGUI environment, and default configuration
|
5
|
-
require File.
|
6
|
+
require File.expand_path('../boot', __FILE__)
|
7
|
+
|
8
|
+
# require gems
|
9
|
+
Bundler.require(:default, ENV['RUGUI_ENV'])
|
10
|
+
|
11
|
+
require 'rugui/initializer'
|
6
12
|
|
7
13
|
RuGUI::Initializer.run do |config|
|
8
14
|
# Settings in config/environments/* take precedence over those specified here.
|
@@ -30,10 +36,4 @@ RuGUI::Initializer.run do |config|
|
|
30
36
|
# See with more details here:
|
31
37
|
# http://www.rubybrain.com/api/ruby-1.8.7/doc/index.html?a=M000253&name=strftime
|
32
38
|
#config.logger[:format] = "%Y-%m-%d %H:%M:%S"
|
33
|
-
|
34
|
-
# Specify gems that this application depends on.
|
35
|
-
# They can then be installed with "rake gems:install" on new installations.
|
36
|
-
# config.gem "bj"
|
37
|
-
# config.gem "hapricot", :version => '>0.8', :source => "http://code.whytheluckystiff.net"
|
38
|
-
# config.gem "aws-s3", :lib => "aws/s3"
|
39
39
|
end
|
data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/xml/main_view.xml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<interface>
|
3
|
+
<!-- interface-requires gtk+ 2.6 -->
|
4
|
+
<!-- interface-naming-policy toplevel-contextual -->
|
5
|
+
<object class="GtkWindow" id="main_window">
|
6
|
+
<property name="visible">True</property>
|
7
|
+
<property name="can_focus">False</property>
|
8
|
+
<property name="title" translatable="yes">Hello World!</property>
|
9
|
+
<child>
|
10
|
+
<object class="GtkVBox" id="main_container">
|
11
|
+
<property name="visible">True</property>
|
12
|
+
<property name="can_focus">False</property>
|
13
|
+
<child>
|
14
|
+
<object class="GtkLabel" id="message_label">
|
15
|
+
<property name="visible">True</property>
|
16
|
+
<property name="can_focus">False</property>
|
17
|
+
<property name="label" translatable="yes">Just a simple label</property>
|
18
|
+
</object>
|
19
|
+
<packing>
|
20
|
+
<property name="expand">True</property>
|
21
|
+
<property name="fill">True</property>
|
22
|
+
<property name="position">0</property>
|
23
|
+
</packing>
|
24
|
+
</child>
|
25
|
+
<child>
|
26
|
+
<object class="GtkButton" id="hello_button">
|
27
|
+
<property name="label" translatable="yes">click me</property>
|
28
|
+
<property name="use_action_appearance">False</property>
|
29
|
+
<property name="visible">True</property>
|
30
|
+
<property name="can_focus">True</property>
|
31
|
+
<property name="receives_default">True</property>
|
32
|
+
<signal name="clicked" handler="on_hello_button_clicked" swapped="no"/>
|
33
|
+
</object>
|
34
|
+
<packing>
|
35
|
+
<property name="expand">True</property>
|
36
|
+
<property name="fill">True</property>
|
37
|
+
<property name="position">1</property>
|
38
|
+
</packing>
|
39
|
+
</child>
|
40
|
+
</object>
|
41
|
+
</child>
|
42
|
+
</object>
|
43
|
+
</interface>
|