Class: Watobo::Gui::SaveChatDialog

Inherits:
FXDialogBox
  • Object
show all
Includes:
Responder
Defined in:
lib/watobo/gui/save_chat_dialog.rb

Defined Under Namespace

Classes: Sender

Instance Method Summary collapse

Constructor Details

#initialize(owner, chat, prefs = {}) ⇒ SaveChatDialog

Returns a new instance of SaveChatDialog.

Raises:

  • (ArgumentError)

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/watobo/gui/save_chat_dialog.rb', line 70

def initialize(owner, chat, prefs={})
  raise ArgumentError, "Need Chat Object" unless chat.respond_to? :request
  super(owner, "Save Response", :opts => DECOR_ALL)
  @chat = chat
  @sender = Sender.new
  @response = chat.response

  FXMAPFUNC(SEL_COMMAND, ID_ACCEPT, :onAccept)

  @path = Watobo.workspace_path

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

  frame = FXHorizontalFrame.new(main_frame, :opts => LAYOUT_FILL_X)
  FXLabel.new(frame,"Response:")
  @reload_btn = FXButton.new(frame, "Reload", nil, self, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_SIDE_RIGHT)

  @response_viewer = Watobo::Gui::ResponseViewer.new(main_frame, LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @response_viewer.setText(@response)
  @reload_btn.connect(SEL_COMMAND){
    s,a = @sender.send_request(@chat.request)
    @response = a
    @response.extend Watobo::Mixin::Parser::Web10
    @response.extend Watobo::Mixin::Shaper::Web10
    @response_viewer.setText(@response)
  }

  frame = FXHorizontalFrame.new(main_frame, :opts => LAYOUT_FILL_X)
  FXLabel.new(frame, "Save To:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  @filename_txt = FXTextField.new(frame,  25, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
  @select_btn = FXButton.new(frame, "Select")
  @select_btn.connect(SEL_COMMAND){ select_target_file }
  if @chat.respond_to? :response
  @select_btn.enable
  @filename_txt.enable
  else
  @select_btn.disable
  @filename_txt.disable
  end

  buttons = FXHorizontalFrame.new(main_frame, :opts => LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,
  :padLeft => 40, :padRight => 40, :padTop => 20, :padBottom => 20)

  accept = FXButton.new(buttons, "&Save", nil, self, ID_ACCEPT,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  accept.enable
  # Cancel
  FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
end

Instance Method Details

#filenameObject


66
67
68
# File 'lib/watobo/gui/save_chat_dialog.rb', line 66

def filename
  @filename_txt.text
end