D
David Torres
I have a question about using ruby and ruby-gtk2. I have a simple gui
and am using SourceView as my text buffer and have added a menu to open
and save files. My question is how in the world to I open a file and
display it within my buffer?
so far my open method is:
callback_open = Proc.new {
p "Open is called."
dialog = FileChooserDialog.new("Open File",nil,
FileChooser::ACTION_OPEN,nil,
[Stock::CANCEL,Dialog::RESPONSE_CANCEL],
[Stock::OPEN,Dialog::RESPONSE_ACCEPT])
if dialog.run == Dialog::RESPONSE_ACCEPT
@filename = #{dialog.filename}
file = File.open(@filename)
}
after the file variable line I have tried different things to actually
add the text to the buffer but none seem to work. I checked the API but
I'm not sure if their is a TextBuffer method that I can use to read in
the file line by line.
Any help would be appreciated.
David Torres
and am using SourceView as my text buffer and have added a menu to open
and save files. My question is how in the world to I open a file and
display it within my buffer?
so far my open method is:
callback_open = Proc.new {
p "Open is called."
dialog = FileChooserDialog.new("Open File",nil,
FileChooser::ACTION_OPEN,nil,
[Stock::CANCEL,Dialog::RESPONSE_CANCEL],
[Stock::OPEN,Dialog::RESPONSE_ACCEPT])
if dialog.run == Dialog::RESPONSE_ACCEPT
@filename = #{dialog.filename}
file = File.open(@filename)
}
after the file variable line I have tried different things to actually
add the text to the buffer but none seem to work. I checked the API but
I'm not sure if their is a TextBuffer method that I can use to read in
the file line by line.
Any help would be appreciated.
David Torres