[indent=4] /* Build with valac --pkg gtk+-2.0 yourprogname.gs */ uses Gtk class MessageDialog : Window init title = "Simple Message Dialog Test" window_position = WindowPosition.CENTER default_height = 200 default_width = 350 destroy += Gtk.main_quit var vbox = new VBox (true, 5) var button1 = new Button.with_label("Question") button1.clicked += question_clicked var button2 = new Button.with_label("Information") button2.clicked += information_clicked var button3 = new Button.with_label("Warning") button3.clicked += warning_clicked var button4 = new Button.with_label("Error") button4.clicked += error_clicked var button5 = new Button.with_label("Exit this program now !") button5.clicked += Gtk.main_quit vbox.add (button1) vbox.add (button2) vbox.add (button3) vbox.add (button4) vbox.add (button5) add (vbox) def private question_clicked () var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, ("This is question message dialog with Yes and No buttons !!")) var response = messagedialog.run() if response is ResponseType.YES print("You have clicked on Yes") messagedialog.destroy() else if response is ResponseType.NO print("You have clicked on No") messagedialog.destroy() def private information_clicked () var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, ("This is information message dialog with Ok button !!")) messagedialog.run() messagedialog.destroy() def private warning_clicked () var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, ("This is warning message dialog with Ok and Cancel buttons !!")) messagedialog.run() messagedialog.destroy() def private error_clicked () var messagedialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, ("This is error message dialog with Close button !!")) messagedialog.run() messagedialog.destroy() init Gtk.init (ref args) var test = new MessageDialog () test.show_all () Gtk.main ()