ModalInfoDialog.h
Go to the documentation of this file.00001 #ifndef MODALINFODIALOG_H_
00002 #define MODALINFODIALOG_H_
00003
00004 #include <gtk/gtkwindow.h>
00005 #include <gtk/gtklabel.h>
00006 #include <gtk/gtkvbox.h>
00007
00008 #include <string>
00009
00010 namespace gtkutil
00011 {
00012
00018 class ModalInfoDialog
00019 {
00020
00021 GtkWidget* _widget;
00022
00023
00024 GtkWidget* _label;
00025
00026 private:
00027
00028
00029
00030 static gboolean _onDelete (GtkWidget* widget, gpointer data)
00031 {
00032 return TRUE;
00033 }
00034
00035 public:
00036
00040 ModalInfoDialog (GtkWindow* parent, const std::string& title) :
00041 _widget(gtk_window_new(GTK_WINDOW_TOPLEVEL)), _label(gtk_label_new(""))
00042 {
00043
00044 gtk_window_set_transient_for(GTK_WINDOW(_widget), parent);
00045 gtk_window_set_modal(GTK_WINDOW(_widget), TRUE);
00046 gtk_window_set_title(GTK_WINDOW(_widget), title.c_str());
00047 gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT);
00048 gtk_window_set_default_size(GTK_WINDOW(_widget), 360, 80);
00049
00050 g_signal_connect(G_OBJECT(_widget), "delete-event", G_CALLBACK(_onDelete), NULL);
00051
00052
00053 GtkWidget* vbx = gtk_vbox_new(FALSE, 0);
00054 gtk_box_pack_start(GTK_BOX(vbx), _label, TRUE, FALSE, 0);
00055 gtk_container_add(GTK_CONTAINER(_widget), vbx);
00056 gtk_container_set_border_width(GTK_CONTAINER(_widget), 6);
00057
00058
00059 gtk_widget_show_all(_widget);
00060 }
00061
00064 ~ModalInfoDialog ()
00065 {
00066 gtk_widget_destroy(_widget);
00067 }
00068
00071 void setText (const std::string& text)
00072 {
00073 gtk_label_set_markup(GTK_LABEL(_label), text.c_str());
00074 }
00075 };
00076
00077 }
00078
00079 #endif