Module: Studium::GUI::Gtk::ControlPanelModule

Includes:
Gtk::BaseModule
Included in:
ControlPanel
Defined in:
lib/studium/gui/shared_code/control_panel/control_panel_module.rb

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
WIDTH =
#

WIDTH

#
1620
HEIGHT =
#

HEIGHT

#
800
USE_THIS_FONT =
#

USE_THIS_FONT

#
:hack_20

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(i = ARGV) ⇒ Object

#

Studium::GUI::Gtk::ControlPanelModule.run

#


303
304
305
306
307
308
309
310
311
312
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 303

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::Studium::GUI::Gtk::ControlPanel.new(i)
  r = ::Gtk.run
  r << _
  r.automatic
  r.top_left_then_run
end

Instance Method Details

#browser?Boolean

#

browser?

#

Returns:

  • (Boolean)


128
129
130
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 128

def browser?
  @browser
end

#connect_skeletonObject

#

connect_skeleton (connect tag)

#


207
208
209
210
211
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 207

def connect_skeleton
  maximal(
    @scrolled_window_containing_the_control_panel
  )
end

#create_skeletonObject

#

create_skeleton

#


184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 184

def create_skeleton
  create_the_buttons
  @label_containing_the_last_exam_question = gtk_label(::Studium.return_last_exam_question)
  @vbox_containing_the_control_panel = gtk_vbox
  @vbox_containing_the_control_panel.minimal(@browser)
  @vbox_containing_the_control_panel.minimal(@button_to_reset_the_exam_file)
  @vbox_containing_the_control_panel.minimal(
    gtk_label(
      ::Studium.return_string_how_many_exam_questions_are_already_answered
    )
  )
end

#create_the_buttonsObject

#

create_the_buttons

#


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
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 99

def create_the_buttons
  # ======================================================================= #
  # The "reset the exam file" button comes next.
  # ======================================================================= #
  @button_to_reset_the_exam_file = gtk_button('Reset the exam file')
  @button_to_reset_the_exam_file.hint = 'Click on '\
    'this button in order to reset the daily exam-file stats.'
  @button_to_reset_the_exam_file.on_clicked {
    ::Studium::Log::StoreLastQuestionAskedIntoFile.reset_file
  }
  @button_to_reset_the_exam_file.set_name('button1')
  @button_to_reset_the_exam_file.css_class('bblack2')
  # ======================================================================= #
  # === @button_create_new_exam_topic_pdf_file
  #
  # This button can be used to create a .pdf file.
  # ======================================================================= #
  @button_create_new_exam_topic_pdf_file = gtk_button(
    return_current_string_for_the_button_create_new_exam_topic_pdf_file
  )
  @button_create_new_exam_topic_pdf_file.hint = 'Click '\
    'this button to create a new exam-topics .pdf file.'
  @button_create_new_exam_topic_pdf_file.set_name('button1')
  @button_create_new_exam_topic_pdf_file.css_class('bblack2')
end

#current_exam_topic?Boolean

#

current_exam_topic?

#

Returns:

  • (Boolean)


200
201
202
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 200

def current_exam_topic?
  @parent_widget.current_exam_topic?
end

#determine_the_parent_widgetObject

#

determine_the_parent_widget

#


170
171
172
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 170

def determine_the_parent_widget
  @parent_widget = first_commandline_argument?
end

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Object

#

initialize

#


57
58
59
60
61
62
63
64
65
66
67
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 57

def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  super(:vertical)
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

#instantiate_a_new_browser_widgetObject

#

instantiate_a_new_browser_widget

#


135
136
137
138
139
140
141
142
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 135

def instantiate_a_new_browser_widget
  # ======================================================================= #
  # === @browser
  #
  # This will use the "Gtk::Browser" class.
  # ======================================================================= #
  @browser = ::Gtk::Browser.new
end

#label_containing_the_last_exam_question?Boolean

#

label_containing_the_last_exam_question?

#

Returns:

  • (Boolean)


177
178
179
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 177

def label_containing_the_last_exam_question?
  @label_containing_the_last_exam_question
end

#main_exam_topic?Boolean

#

main_exam_topic?

#

Returns:

  • (Boolean)


158
159
160
161
162
163
164
165
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 158

def main_exam_topic?
  if @parent_widget
    @parent_widget.main_exam_topic?.to_s
  else
    e 'No @parent_widget was provided, thus returning "amg1".'
    return 'amg1'
  end
end

#resetObject

#

reset

#


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 72

def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @parent_widget
  #
  # This can set the parent-widget.
  # ======================================================================= #
  @parent_widget = nil
  append_project_css_file
  infer_the_size_automatically
end

#return_current_string_for_the_button_create_new_exam_topic_pdf_fileObject

#

return_current_string_for_the_button_create_new_exam_topic_pdf_file

This method will also contain an emoji; we have to remember that this will not work on every computer system though.

#


150
151
152
153
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 150

def return_current_string_for_the_button_create_new_exam_topic_pdf_file
  '🗎 Create a new .pdf file containing the main exam topic '\
  '('+main_exam_topic?+', from the first notebook-tab)'
end

#runObject

#

run

#


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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/studium/gui/shared_code/control_panel/control_panel_module.rb', line 216

def run
  determine_the_parent_widget
  instantiate_a_new_browser_widget
  create_skeleton
  label_to_use = gtk_bold_label('The last exam question was: ').set_font(USE_THIS_FONT)
  label_to_use.make_bold
  # ======================================================================= #
  # Add the last-exam-question widget next.
  # ======================================================================= #
  small_hbox = gtk_hbox(
    label_to_use,
    @label_containing_the_last_exam_question
  )
  small_scrolled_window = gtk_scrolled_window(small_hbox) { :always }
  # ======================================================================= #
  # This small window will simply hold the last-exam-question asked,
  # as mentioned above.
  # ======================================================================= #
  small_scrolled_window.min_content_width  = 120
  small_scrolled_window.min_content_height = 180
  small_scrolled_window.do_show_the_scrollbars
  frame_to_use = gtk_frame(small_scrolled_window) {{ title: ' Last exam question ' }}
  @vbox_containing_the_control_panel.minimal(frame_to_use, 2)
  # ======================================================================= #
  # === Debug
  #
  # Add the small debug-widget next, but only if we are on roebe.
  # ======================================================================= #
  if ::Gtk.are_we_on_roebe?
    require 'gtk_paradise/widgets/gtk3/debug_widget/debug_widget.rb'
    debug_widget = ::Gtk::DebugWidget.new
    debug_widget.use_this_font(:hack_15)
    @vbox_containing_the_control_panel.minimal(
      debug_widget, 6 # gtk_bold_label('This should show Gtk::DebugWidget but it is currently disabled.')
    )
  end
  # ======================================================================= #
  # Add the ECTS-per-university widget:
  # ======================================================================= #
  @vbox_containing_the_control_panel.minimal(
    ::Studium::GUI::Gtk::EctsPerUniversity.new, 6
  )
  entry_where_the_pdf_file_is_stored = gtk_entry
  array_the_pdf_is_stored_here = []
  @button_create_new_exam_topic_pdf_file.on_clicked {
    @button_create_new_exam_topic_pdf_file.set_text(
      return_current_string_for_the_button_create_new_exam_topic_pdf_file
    )
    Thread.new {
      array_the_pdf_is_stored_here << Studium.create_pdf_file_for_this_exam_topic(
        current_exam_topic?
      ) {{
        may_we_exit_if_prawn_is_not_installed: false
      }}
      array_the_pdf_is_stored_here.flatten!
      entry_where_the_pdf_file_is_stored.set_text(
        array_the_pdf_is_stored_here.last
      )
    }.join
  }
  small_vbox = gtk_vbox
  small_vbox.minimal(@button_create_new_exam_topic_pdf_file)
  small_vbox.minimal(entry_where_the_pdf_file_is_stored)
  small_vbox.set_size_request(800, 50)
  @vbox_containing_the_control_panel.minimal(small_vbox)
  @vbox_containing_the_control_panel.minimal(
    Studium::GUI::Gtk::ShowUpcomingExams.new
  )
  @vbox_containing_the_control_panel.minimal(
    ::Studium::GUI::Gtk::ExpandTimeRange.new
  )

  # ======================================================================= #
  # === @scrolled_window_containing_the_control_panel
  # ======================================================================= #
  @scrolled_window_containing_the_control_panel = gtk_scrolled_window(
    @vbox_containing_the_control_panel
  )
  @scrolled_window_containing_the_control_panel.set_size_request(800, 600)
  @scrolled_window_containing_the_control_panel.pad8px
  @scrolled_window_containing_the_control_panel.set_border_width(10)
  connect_skeleton
end