Class: Roebe::GUI::LibUI::TodoViewer

Inherits:
Object
  • Object
show all
Includes:
LibuiParadise::Extensions
Defined in:
lib/roebe/gui/libui/todo_viewer/todo_viewer.rb

Overview

Roebe::GUI::LibUI::TodoViewer

Constant Summary collapse

TITLE =
#

TITLE

#
'Todo-Viewer'
WIDTH =
#

WIDTH

#
600
HEIGHT =
#

HEIGHT

#
480
TODO_DIRECTORY =
#

TODO_DIRECTORY

#
'/home/x/data/personal/todo/'

Instance Method Summary collapse

Constructor Details

#initialize(run_already = true) ⇒ TodoViewer

#

initialize

#


43
44
45
46
47
48
# File 'lib/roebe/gui/libui/todo_viewer/todo_viewer.rb', line 43

def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Instance Method Details

#do_read_in_data_from_this_todo_file(this_todo_file = :pc) ⇒ Object

#

do_read_in_data_from_this_todo_file

#


98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/roebe/gui/libui/todo_viewer/todo_viewer.rb', line 98

def do_read_in_data_from_this_todo_file(
    this_todo_file = :pc
  )
  if this_todo_file.is_a? String
    unless File.exist? this_todo_file
      this_todo_file = "#{TODO_DIRECTORY}#{this_todo_file}.md"
    end
  end
  if File.exist? this_todo_file
    @work_on_this_file = this_todo_file
    _ = File.read(@work_on_this_file)
    @text_buffer.set_text(_.to_s)
  end
end

#resetObject

#

reset (reset tag)

#


53
54
55
# File 'lib/roebe/gui/libui/todo_viewer/todo_viewer.rb', line 53

def reset
  title_width_height(TITLE, WIDTH, HEIGHT)
end

#runObject

#

run

#


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/roebe/gui/libui/todo_viewer/todo_viewer.rb', line 60

def run
  if File.directory? TODO_DIRECTORY
    cd(TODO_DIRECTORY)
  end
  window = ui_padded_main_window(title?, width?, height?, 0)
  outer_vbox = padded_vbox
  # ======================================================================= #
  # === button_open_file
  # ======================================================================= #
  button_open_file = button('Open file')
  button_open_file.on_clicked {
    begin
      filename = ui_open_file(window).to_s
      # e "The filename was: #{filename}" # <- For debugging.
      do_read_in_data_from_this_todo_file(filename)
    rescue ArgumentError => error # Rescue from "NULL pointer given"
      # pp error
    end
  }
  # ======================================================================= #
  # First add the two buttons on top:
  # ======================================================================= #
  hbox_on_top = padded_hbox
  button_quit = quit_button
  hbox_on_top.maximal(button_open_file)
  hbox_on_top.maximal(button_quit)
  outer_vbox.minimal(hbox_on_top)
  outer_vbox.add_hsep
  @text_buffer = ui_text_view
  outer_vbox.minimal(hspacer, 0)
  outer_vbox << @text_buffer
  window.add(outer_vbox)
  window.intelligent_exit
end