Reid Thompson wrote:
Would someone be willing to post a glade-3 gtkbuilder based copy of the Toolbar, Scrollable Text View and File Chooser example found at http://live.gnome.org/Vala/GTKSample ?
Hi, see attachment, compile with: $ valac text-file-viewer.vala --pkg gtk+-2.0 --pkg gmodule-2.0 Best regards, Frederik
Attachment:
text-file-viewer.ui
Description: application/designer
using Gtk; public class TextFileViewer { private Builder builder; public TextFileViewer () throws Error { this.builder = new Builder (); builder.add_from_file ("text-file-viewer.ui"); builder.connect_signals (this); } [CCode (instance_pos = -1)] protected void on_open_clicked (ToolButton sender) { var file_chooser = this.builder.get_object ("filechooserdialog1") as FileChooserDialog; if (file_chooser.run () == ResponseType.ACCEPT) { open_file (file_chooser.get_filename ()); } file_chooser.destroy (); } private void open_file (string filename) { var text_view = this.builder.get_object ("textview1") as TextView; try { string text; FileUtils.get_contents (filename, out text); text_view.buffer.text = text; } catch (Error e) { stderr.printf ("Error: %s\n", e.message); } } } int main (string[] args) { Gtk.init (ref args); try { var app = new TextFileViewer (); Gtk.main (); } catch (Error e) { stderr.printf ("Error: %s\n", e.message); return 1; } return 0; }