rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / gtk / src / messagedialog.ccg
1 // -*- c++ -*-
2 /* $Id: messagedialog.ccg,v 1.7 2005/02/15 10:52:44 murrayc Exp $ */
3
4 /* 
5  *
6  * Copyright 2002 The gtkmm Development Team
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include <gtk/gtkmessagedialog.h>
24 #include <gtk/gtklabel.h>
25
26
27 namespace Gtk
28 {
29
30 MessageDialog::MessageDialog(const Glib::ustring& message, bool use_markup,
31                              MessageType type, ButtonsType buttons,
32                              bool modal)
33 :
34   _CONSTRUCT("message_type", (GtkMessageType)type, "buttons", (GtkButtonsType)buttons)
35 {
36   set_modal(modal);
37   set_message(message, use_markup);
38 }
39
40 MessageDialog::MessageDialog(Gtk::Window& parent, const Glib::ustring& message, bool use_markup,
41                              MessageType type, ButtonsType buttons,
42                              bool modal)
43 :
44   _CONSTRUCT("message_type", (GtkMessageType)type, "buttons", (GtkButtonsType)buttons)
45 {
46   set_modal(modal);
47   set_transient_for(parent);
48   set_message(message, use_markup);
49 }
50
51 void MessageDialog::set_message(const Glib::ustring& message, bool use_markup)
52 {
53   // TODO: GTK+ bug: The label widget is really a <private> struct field.
54   // There should really be a message property.
55
56   if(use_markup)
57     gtk_message_dialog_set_markup(gobj(), message.c_str()); 
58   else
59     gtk_label_set_text(GTK_LABEL(gobj()->label), message.c_str());
60 }
61
62 void MessageDialog::set_secondary_text(const Glib::ustring& text, bool use_markup)
63 {
64   if(use_markup)
65     gtk_message_dialog_format_secondary_markup(gobj(), text.c_str());
66   else
67     gtk_message_dialog_format_secondary_text(gobj(), text.c_str());
68 }
69
70 } // namespace Gtk
71