Class: Watobo::Gui::WorkspaceDialog

Inherits:
FXDialogBox
  • Object
show all
Defined in:
lib/watobo/gui/workspace_dialog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, prefs) ⇒ WorkspaceDialog

Returns a new instance of WorkspaceDialog.



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
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/watobo/gui/workspace_dialog.rb', line 41

def initialize(parent, prefs)
   # Invoke base class initialize function first
   #  super(parent, "New Project", DECOR_TITLE|DECOR_BORDER)
   super(parent, "Define Workspace", DECOR_ALL)

   @workspace_dir = FXDataTarget.new('')

   if prefs[:workspace_dir] then
      if File.exists?(prefs[:workspace_dir]) then
         @workspace_dir.value = prefs[:workspace_dir]
      end
   end

   base_frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)

   workspace_path_form = FXHorizontalFrame.new(base_frame,
   :opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP)
   FXLabel.new(workspace_path_form, "Workspace Directory:" )
   @workspaceText = FXTextField.new(workspace_path_form, 60,
   :target => @workspace_dir, :selector => FXDataTarget::ID_VALUE,
   :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN)

   browse_button=FXButton.new(workspace_path_form, "Change")
   browse_button.connect(SEL_COMMAND, method(:open_select_workspace_dir_dialog) )


   #
   # BUTTONS FRAME
   #
   buttons_frame = FXHorizontalFrame.new(base_frame,
   :opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP)

   @finishButton = FXButton.new(buttons_frame, "Finish" ,  nil, nil, :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
   @finishButton.disable
   @finishButton.connect(SEL_COMMAND) do |sender, sel, item|
      #self.handle(self, FXSEL(SEL_COMMAND, ID_CANCEL), nil)
      self.handle(self, FXSEL(SEL_COMMAND, ID_ACCEPT), nil)
   end


   @cancelButton = FXButton.new(buttons_frame, "Cancel" ,
   :target => self, :selector => FXDialogBox::ID_CANCEL,
   :opts => BUTTON_NORMAL|LAYOUT_RIGHT)



end

Instance Attribute Details

#workspace_dirObject (readonly)

Returns the value of attribute workspace_dir.



27
28
29
# File 'lib/watobo/gui/workspace_dialog.rb', line 27

def workspace_dir
  @workspace_dir
end

Instance Method Details

#open_select_workspace_dir_dialog(sender, sel, ptr) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/watobo/gui/workspace_dialog.rb', line 29

def open_select_workspace_dir_dialog(sender, sel, ptr)
   workspace_dir = FXFileDialog.getOpenDirectory(self, "Select Workspace Directory", @workspace_dir.value)
   if workspace_dir != "" then
      if File.exists?(workspace_dir) then
         @workspace_dir.value = workspace_dir
         @workspace_dir.handle(self, FXSEL(SEL_UPDATE, 0), nil)
         updateProjectList(@workspace_dir.value)
      end
   end
end