Module: Studium::GUI::Gtk::ShowUpcomingExamsModule

Includes:
Gtk::BaseModule
Included in:
ShowUpcomingExams
Defined in:
lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb

Overview

Studium::GUI::Gtk::ShowUpcomingExamsModule

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
TITLE =
#

TITLE

#
'Studium::GUI::Gtk::ShowUpcomingExamsModule'
WIDTH =
#

WIDTH

#
1400
HEIGHT =
#

HEIGHT

#
500
USE_THIS_FONT_FOR_THE_TREE_VIEW =
#

USE_THIS_FONT_FOR_THE_TREE_VIEW

#
:noto_mono_18

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject

#

GtkParadise::GUI::Gtk::ShowUpcomingExamsModule.run

#


195
196
197
198
199
200
201
202
203
204
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 195

def self.run
  require 'gtk_paradise/run'
  _ = ::Studium::GUI::Gtk::ShowUpcomingExams.new
  r = ::Gtk.run
  r << _
  r.automatic_title
  r.automatic_size
  r.enable_quick_exit
  r.top_left_then_run
end

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


97
98
99
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 97

def border_size?
  2
end

#connect_skeletonObject

#

connect_skeleton

#


172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 172

def connect_skeleton
  Thread.abort_on_exception = true
  populate_liststore
  header_upcoming_exams = h1('Upcoming exams') # '•'
  header_upcoming_exams.align_to_the_left
  header_upcoming_exams.make_bold
  hbox = gtk_hbox
  hbox.minimal(image_starred, 10)
  hbox.maximal(header_upcoming_exams, 0)
  minimal(hbox)
  maximal(@scrolled_window, 2)
end

#create_liststoreObject

#

create_liststore

#


131
132
133
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 131

def create_liststore
  @list_store = gtk_liststore(*([String] * 3))
end

#create_scrolled_windowObject

#

create_scrolled_window

#


114
115
116
117
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 114

def create_scrolled_window
  @scrolled_window = gtk_scrolled_window(@tree_view) { :automatic_scrolling }
  @scrolled_window.set_size_request(400, 200)
end

#create_skeletonObject

#

create_skeleton

#


104
105
106
107
108
109
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 104

def create_skeleton
  @renderer = gtk_cell_renderer_text
  create_liststore
  create_treeview
  create_scrolled_window
end

#create_treeview(i = @list_store) ⇒ Object

#

create_treeview

#


122
123
124
125
126
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 122

def create_treeview(i = @list_store)
  @tree_view = gtk_treeview(i)
  @tree_view.do_use_clickable_headers
  @tree_view.set_font(USE_THIS_FONT_FOR_THE_TREE_VIEW)
end

#initialize(optional_file = nil, run_already = true) ⇒ Object

#

initialize

#


51
52
53
54
55
56
57
58
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 51

def initialize(
    optional_file = nil,
    run_already   = true
  )
  super(:vertical)
  reset
  run if run_already
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


90
91
92
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 90

def padding?
  2
end

#populate_liststoreObject

#

populate_liststore

#


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 138

def populate_liststore
  # ======================================================================= #
  # First, set up the three headers via a convenience method.
  # ======================================================================= #
  @tree_view.use_these_headers(
    '#', 'Name of the course', 'Exam Date'
  )
  # ======================================================================= #
  # If we want to align a column to the middle we could use the following
  # line of code:
  #   @tree_view.get_column(1).align_to_the_middle
  # ======================================================================= #
  index = 0
  @dataset.each {|the_name_of_the_course, inner_hash| index += 1
    name_of_the_course = the_name_of_the_course
    exam_date =  inner_hash['exams']
    if exam_date.is_a? Array
      exam_date = exam_date.first
    end
    iter = @list_store.append
    iter[0] = index.to_s 
    iter[1] = name_of_the_course
    if exam_date
      iter[2] = exam_date.squeeze(' ')
    else
      e '(Upcoming exams in a gtk-tree-view) '\
        'Problem with '+the_name_of_the_course.to_s
    end
  }
end

#resetObject

#

reset

#


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 63

def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  @title  = TITLE
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  set_use_this_font(:dejavu_condensed_25)
  @dataset = ::Studium.return_all_registered_upcoming_exams
  append_project_css_file
  increase_font_size
end

#runObject

#

run

#


188
189
190
# File 'lib/studium/gui/shared_code/show_upcoming_exams/show_upcoming_exams_module.rb', line 188

def run
  create_skeleton_then_connect_skeleton
end