Module: Roebe::GUI::SimpleClockModule
- Includes:
- UniversalWidgets::BaseModule
- Included in:
- SimpleClock
- Defined in:
- lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb
Overview
Roebe::GUI::SimpleClockModule
Constant Summary
collapse
- TITLE =
'A simple clock'
- MAIN_FONT_SIZE =
32
- WIDTH =
320
- HEIGHT =
220
Class Method Summary
collapse
-
.run(i = ARGV) ⇒ Object
# === GtkParadise::GUI::Gtk::SimpleClockModule.run ========================================================================= #.
Instance Method Summary
collapse
Class Method Details
.run(i = ARGV) ⇒ Object
#
GtkParadise::GUI::Gtk::SimpleClockModule.run
#
200
201
202
203
204
205
206
207
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 200
def self.run(i = ARGV)
require 'gtk_paradise/run'
_ = ::Roebe::GUI::SimpleClock.new(i)
r = ::Gtk.run
r << _
r.set_size_request(_.width?,_.height?)
r.top_left_then_run
end
|
Instance Method Details
#border_size? ⇒ Boolean
111
112
113
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 111
def border_size?
2
end
|
#create_skeleton ⇒ Object
#
create_skeleton (skeleton tag)
#
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 186
def create_skeleton
create_the_entries
create_the_buttons
@label_showing_the_current_time = text(return_current_time)
@label_showing_the_current_time.set_font_size(MAIN_FONT_SIZE)
end
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 168
def create_the_buttons
@button_for_applying_the_modifier = bold_button(
'Modify the clock by n seconds'
)
@button_for_applying_the_modifier.hint = 'This will '\
'modify the display of the clock by <b>n seconds</b>. It '\
'is an ad-hoc way to correct the time.'
@button_for_applying_the_modifier.on_clicked {
do_modify_the_time
}
end
|
#create_the_entries ⇒ Object
#
create_the_entries (entries tag)
#
158
159
160
161
162
163
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 158
def create_the_entries
@entry_for_n_seconds = create_entry
end
|
#do_modify_the_time ⇒ Object
139
140
141
142
143
144
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 139
def do_modify_the_time
@apply_this_modifier = @entry_for_n_seconds.text.to_f
end
|
#modify_the_label_of_the_frame ⇒ Object
#
modify_the_label_of_the_frame
#
149
150
151
152
153
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 149
def modify_the_label_of_the_frame
label_widget.set_markup(
%Q(<span weight="bold" size="xx-large" foreground="darkslategrey">#{TITLE}</span>)
) if use_gtk3?
end
|
#padding? ⇒ Boolean
104
105
106
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 104
def padding?
2
end
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 52
def reset
super() if respond_to?(:super)
create_the_internal_hash_unless_it_already_exists
infer_the_namespace
@use_a_small_icon_showing_a_clock = true
@apply_this_modifier = nil
@use_top_label = true
@configuration = [true, __dir__, NAMESPACE]
title_width_height(TITLE, WIDTH, HEIGHT)
use_gtk_paradise_project_css_file
infer_the_size_automatically
end
|
#return_current_time(apply_this_modifier = @apply_this_modifier) ⇒ Object
#
return_current_time
An optional modifier, as an Integer, can be given, which modifies the time.
#
91
92
93
94
95
96
97
98
99
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 91
def return_current_time(
apply_this_modifier = @apply_this_modifier
)
_ = ::Time.now
if apply_this_modifier
_ = "#{_}#{apply_this_modifier}"
end
_.strftime('%H:%M:%S')
end
|
#update_current_time(i = return_current_time) ⇒ Object
118
119
120
121
122
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 118
def update_current_time(
i = return_current_time
)
@label_showing_the_current_time.set_text(i)
end
|
#update_label_continually ⇒ Object
#
update_label_continually
#
127
128
129
130
131
132
133
134
|
# File 'lib/roebe/gui/shared_code/simple_clock/simple_clock_module.rb', line 127
def update_label_continually
Thread.new {
loop {
sleep 1
update_current_time
}
}
end
|