Class: Sangoro::UserInterface
- Inherits:
-
Object
- Object
- Sangoro::UserInterface
- Defined in:
- lib/sangoro/user_interface.rb
Instance Attribute Summary collapse
-
#box_set ⇒ Object
readonly
Returns the value of attribute box_set.
-
#button_set ⇒ Object
readonly
Returns the value of attribute button_set.
-
#img_parameters ⇒ Object
readonly
Returns the value of attribute img_parameters.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
-
#initialize ⇒ UserInterface
constructor
A new instance of UserInterface.
-
#run ⇒ Object
main method - shows the window with all the buttons and abilities to select images and change meta data.
Constructor Details
#initialize ⇒ UserInterface
Returns a new instance of UserInterface.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sangoro/user_interface.rb', line 13 def initialize # initialize parameters for the image @img_parameters = BasicElements.define_img_parameters # define the window, the boxes and the buttons @window = BasicElements.define_window @box_set = BasicElements.define_boxes @button_set = BasicElements. @button_set, @img_parameters = Actions.toggle_sensitivity(@button_set, @img_parameters, false) end |
Instance Attribute Details
#box_set ⇒ Object (readonly)
Returns the value of attribute box_set.
11 12 13 |
# File 'lib/sangoro/user_interface.rb', line 11 def box_set @box_set end |
#button_set ⇒ Object (readonly)
Returns the value of attribute button_set.
11 12 13 |
# File 'lib/sangoro/user_interface.rb', line 11 def @button_set end |
#img_parameters ⇒ Object (readonly)
Returns the value of attribute img_parameters.
11 12 13 |
# File 'lib/sangoro/user_interface.rb', line 11 def img_parameters @img_parameters end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
11 12 13 |
# File 'lib/sangoro/user_interface.rb', line 11 def window @window end |
Instance Method Details
#run ⇒ Object
main method - shows the window with all the buttons and abilities to select images and change meta data
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 |
# File 'lib/sangoro/user_interface.rb', line 27 def run @window.add(@box_set[:main_box]) # prepare meta data for the chosen image - file name and original creation time img_name_label, img_name_text = Actions.("file name", @box_set[:img_name_box]) img_time_label, img_time_text = Actions.("creation date & time", @box_set[:img_time_box]) @box_set[:img_name_time_box].pack_start(@box_set[:img_name_box], :expand => true, :fill => true, :padding => 0) @box_set[:img_name_time_box].pack_start(@box_set[:img_time_box], :expand=> true, :fill => true, :padding => 0) # execute the action for the SELECT button selected_file = "" @button_set[:select_img_btn].signal_connect("clicked") { selected_file, img_name_text, img_time_text = Actions.run_select_action(window, @img_parameters, @button_set, img_name_text, img_time_text) } # define new time - process the input for the new hour, minutes and seconds @img_parameters[:new_hour_ent].signal_connect("key_release_event") { @img_parameters[:new_hour_val], @img_parameters[:hour_set] = Actions.process_time_unit(@img_parameters[:new_hour_ent]) } @img_parameters[:new_min_ent].signal_connect("key_release_event") { @img_parameters[:new_min_val], @img_parameters[:min_set] = Actions.process_time_unit(@img_parameters[:new_min_ent]) } @img_parameters[:new_sec_ent].signal_connect("key_release_event") { @img_parameters[:new_sec_val], @img_parameters[:sec_set] = Actions.process_time_unit(@img_parameters[:new_sec_ent]) } # execute the action when the the ACCEPT button is clicked @button_set[:apply_btn].signal_connect("clicked") { Actions.run_accept_action(@img_parameters, @button_set, img_time_text, selected_file) } # define the action for the QUIT button @button_set[:quit_btn].signal_connect("clicked") do |w| Gtk.main_quit false end # pack all the boxes Actions.pack_boxes(@box_set, @button_set, @img_parameters) # show everything @window.show_all # run the program Gtk.main end |