Class: EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation
- Inherits:
-
Base
- Object
- Base
- EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation
show all
- Includes:
- UniversalWidgets::BaseModule
- Defined in:
- lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb
Overview
Constant Summary
collapse
- WIDTH =
'60% or minimum 1280px'
- HEIGHT =
'30% or minimum 880px'
Constants inherited
from Base
Base::TRY_TO_USE_HTML_COLOURS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#be_silent, #be_silent?, #be_verbose?, #blue, #cd, #col1, #commandline_arguments?, #crimson, #cyan, #darkgreen, #darkolivegreen, #dimgray, #disable_colours, #e, #enable_colours, #esystem, #first_argument?, #gold, #is_on_roebe?, #is_rbt_available?, #lightblue, #lightgreen, #lightseagreen, #limegreen, #load_dataset_from_this_file, #log_dir?, #mediumaquamarine, #mediumpurple, #olive, #olivedrab, #opne, #orange, #register_sigint, #return_very_silent_system_output_from, #rev, #royalblue, #sanitize_this_version_string, #seagreen, #set_be_silent, #set_be_verbose, #set_commandline_arguments, #set_use_colours, #sfancy, #sfile, #simp, #slateblue, #steelblue, #teal, #tomato, #tracked_programs?, #true_rev, #use_colours?, #write_what_into
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ EnvironmentInformation
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 42
def initialize(
commandline_arguments = nil,
run_already = true
)
super(:vertical) if use_gtk3?
determine_the_GUI_to_be_used(commandline_arguments) reset
set_commandline_arguments(
commandline_arguments
)
on_delete_event_quit_the_application
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
385
386
387
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 385
def self.[](i = ARGV)
new(i)
end
|
.height ⇒ Object
289
290
291
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 289
def self.height
HEIGHT
end
|
.run(i = ARGV) ⇒ Object
368
369
370
371
372
373
374
375
376
377
378
379
380
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 368
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.new(i)
r = ::Gtk.run
_.set_parent_widget(r) r << _
r.automatic_size_then_automatic_title
r.enable_quick_exit
r.set_background :white
r.top_left_then_run
end
|
.width ⇒ Object
282
283
284
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 282
def self.width
WIDTH
end
|
Instance Method Details
#add_status_icon ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 176
def add_status_icon
if use_gtk3?
_ = create_status_icon(:dialog_info)
=
quit = (:quit)
quit.on_activate { ::Gtk.main_quit }
.append(quit)
.show_all
_.signal_connect(:popup_menu) { |icon, button, time|
.(nil, nil, button, time)
}
return _
end
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 302
def connect_the_skeleton
abort_on_exception
outer_vbox = create_vbox
do_update_the_main_content_of_the_widget
@tree_view.append('Name', @renderer, text: 0)
@tree_view.append('Version', @renderer, text: 1)
@tree_view.
@tree_view.is_sortable
@tree_view.on_key_press_event { |w, event|
case Gdk::Keyval.to_name(event.keyval)
when 'Return','KP_Enter'
e currently_selected
end
}
vbox = create_vbox
vbox.add(@toolbar)
@scrolled_window = create_scrolled_window(@tree_view)
@scrolled_window.set_size_request(600, 600)
vbox.maximal(@scrolled_window, 2)
outer_vbox.maximal(vbox)
outer_vbox.minimal(add_status_icon) if use_gtk3?
window = create_window_or_runner
window << outer_vbox
properly_prepare_this_window(window,
{
title: title?,
font: font?,
width: width?,
height: height?,
padding: padding?,
border_size: border_size?
}
)
window.show_all
window.top_left
do_all_startup_related_actions
run_main
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
352
353
354
355
356
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 352
def create_the_skeleton
create_the_toolbar
create_the_tree_view
@renderer = create_cell_renderer_text
end
|
#
This will create the toolbar on top of the widget.
#
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 89
def create_the_toolbar
@toolbar = create_toolbar
button_refresh = create_button(:refresh)
button_refresh.no_relief
button_refresh.on_clicked {
do_update_the_main_content_of_the_widget
}
button_refresh.hint = '<b>Click</b> on this button in order to '\
'refresh the information shown below.'
@toolbar << button_refresh
pin_emoji = emoji(:pin)
event_box_for_the_pin_emoji = event_box(pin_emoji)
event_box_for_the_pin_emoji.on_clicked {
do_assign_the_current_selection_to_the_xorg_buffer
}
pin_emoji.hint = '<b>Click</b> on this button to assign the '\
'current selection to the xorg-buffer.'
@toolbar << event_box_for_the_pin_emoji
@button_assign_to_the_xorg_buffer = button_xorg_buffer(label: 'Xorg')
@button_assign_to_the_xorg_buffer.no_relief
@button_assign_to_the_xorg_buffer.on_clicked {
do_assign_the_current_selection_to_the_xorg_buffer
}
@toolbar << @button_assign_to_the_xorg_buffer
end
|
#create_the_tree_view ⇒ Object
#
create_the_tree_view
The TreeView widget is the main widget which allows the user to display environment-related information about installed programs.
#
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 201
def create_the_tree_view
@tree_view = ::Gtk::TreeView.new(@list_store) @tree_view.do_select_multiple @tree_view.
@tree_view.enable_model_drag_source(
:button1_mask,
[ ['GTK_TREE_MODEL_ROW', 0, 0] ],
Gdk::DragAction::COPY|Gdk::DragAction::MOVE
)
@tree_view.enable_model_drag_dest([
['GTK_TREE_MODEL_ROW', 0, 0] ],
Gdk::DragAction::COPY|Gdk::DragAction::MOVE
)
@tree_view.signal_connect(:row_activated) {
}
@tree_view.on_button_press_event { |widget, event|
if mouse_button_double_click?(event)
elsif left_mouse_button_clicked?(event)
elsif right_mouse_button_clicked?(event)
end
}
@tree_view.selection.set_mode(::Gtk::SelectionMode::MULTIPLE)
@tree_view.selection.signal_connect(:changed) {|entry|
entry.each {|model, path, inner_array|
if @display_information_on_the_commandline
if inner_array[0]
name_of_the_program = inner_array[0].strip
else
name_of_the_program = '(unknown'
end
version_of_the_program = inner_array[1]
result = Colours.steelblue(
name_of_the_program.ljust(25)
).dup
if ::EnvironmentInformation.is_this_a_registered_program?(name_of_the_program)
result << 'Version: '
end
result << Colours.lightgreen(version_of_the_program.to_s)
e result
end
}
}
@tree_view.
end
|
#currently_selected ⇒ Object
Also known as:
return_the_current_selection_of_the_treeview_widget
#
currently_selected
Will show both key and version.
#
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 131
def currently_selected
_ = ''.dup
if @tree_view and @tree_view.selection
@tree_view.selection.selected_each {|list_store, tree_path, tree_iter|
if tree_iter[0]
name_of_the_program = tree_iter[0].strip
else
name_of_the_program = 'unknown'
end
version_of_the_program = tree_iter[1]
_ << "#{name_of_the_program} #{version_of_the_program}"
}
end
return _
end
|
296
297
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 296
def do_all_startup_related_actions
end
|
#do_assign_the_current_selection_to_the_xorg_buffer(i = return_the_current_selection_of_the_treeview_widget) ⇒ Object
#
do_assign_the_current_selection_to_the_xorg_buffer
#
150
151
152
153
154
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 150
def do_assign_the_current_selection_to_the_xorg_buffer(
i = return_the_current_selection_of_the_treeview_widget
)
@button_assign_to_the_xorg_buffer.attach(i)
end
|
#do_update_the_main_content_of_the_widget ⇒ Object
#
do_update_the_main_content_of_the_widget
#
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 159
def do_update_the_main_content_of_the_widget
assign_the_environment_information_dataset_to_the_data_variable
@list_store.clear
@data.each {|line|
name, version = *line iter = @list_store.append
if version.nil? or version.to_s.empty?
version = '[Not installed.]'
end
iter.set_value(0, name)
iter.set_value(1, version)
}
end
|
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
#
261
262
263
264
265
266
267
268
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 261
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
more_CSS_then_apply_it '
'
end
|
#reset ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 59
def reset
super() if respond_to?(:super)
reset_the_shared_module reset_the_base_module
reset_the_internal_variables
infer_the_namespace
@configuration = [true, __dir__, namespace?]
title_width_height_font(TITLE, WIDTH, HEIGHT, "Mono #{FONT_SIZE}")
if use_gtk3?
handle_CSS_rules
end
infer_the_size_automatically
reset_the_variables
@list_store = ::Gtk::ListStore.new(String, String)
end
|
#reset_the_shared_module ⇒ Object
#
reset_the_shared_module
This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.
#
276
277
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 276
def reset_the_shared_module
end
|
#run ⇒ Object
361
362
363
|
# File 'lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb', line 361
def run
run_super
end
|