Skip to content

Instantly share code, notes, and snippets.

@take-cheeze
Created December 3, 2010 15:37
Show Gist options
  • Save take-cheeze/727102 to your computer and use it in GitHub Desktop.
Save take-cheeze/727102 to your computer and use it in GitHub Desktop.
// g++ $(pkg-config gtk+-2.0 --libs --cflags) gtk_dialog.cxx
#include <cstdlib>
#include <string>
#include <gtk/gtk.h>
#include <glib.h>
void ShowMessageBox(GtkMessageType type, std::string const& title, std::string const& message)
{
GtkWidget* dialog = gtk_message_dialog_new(
(GtkWindow*)NULL, GTK_DIALOG_MODAL, type, GTK_BUTTONS_OK, message.c_str() );
gtk_window_set_title( (GtkWindow*)dialog, title.c_str() );
gtk_widget_show_all(dialog);
(void)gtk_dialog_run( GTK_DIALOG(dialog) );
gtk_widget_destroy(dialog);
}
int main(int argc, char* argv[])
{
gtk_init(&argc, &argv);
ShowMessageBox(GTK_MESSAGE_QUESTION, "Hello!", "Hello World!");
ShowMessageBox(GTK_MESSAGE_WARNING, "Hello!", "Hello World!");
ShowMessageBox(GTK_MESSAGE_ERROR, "Hello!", "Hello World!");
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment