logo top
Main Page   Widgets   Namespaces   Book  

Gtk::Dialog Class Reference
[Dialogs]

Inheritance diagram for Gtk::Dialog:

Inheritance graph
[legend]
List of all members.

Detailed Description

Create popup windows.

Dialog boxes are a convenient way to prompt the user for a small amount of input, eg. to display a message, ask a question, or anything else that does not require extensive effort on the user's part.

gtkmm treats a dialog as a window split vertically. The top section is a Gtk::VBox, and is where widgets such as a Gtk::Label or a Gtk::Entry should be packed. The bottom area is known as the action_area. This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a Gtk::HSeparator.

The dialog can be 'modal' (that is, one which freezes the rest of the application from user input) - this can be specified in the Gtk::Dialog constructor.

When adding buttons using add_button(), clicking the button will emit signal_response() with a "response id" you specified. You are encouraged to use the Gtk::ResponseType enum. If a dialog receives a delete event, the "response" signal will be emitted with a response id of Gtk::RESPONSE_NONE.

If you want to block waiting for a dialog to return before returning control flow to your code, you can call run(). This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked.


Public Member Functions

virtual ~Dialog ()
GtkDialog* gobj ()
 Provides access to the underlying C GtkObject.

const GtkDialog* gobj () const
 Provides access to the underlying C GtkObject.

 Dialog ()
 Dialog (const Glib::ustring& title, bool modal=false, bool use_separator=false)
 Dialog (const Glib::ustring& title, Gtk::Window& parent, bool modal=false, bool use_separator=false)
void add_action_widget (Widget& child, int response_id)
 Adds an activatable widget to the action area of a Gtk::Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated.

Buttonadd_button (const Glib::ustring& button_text, int response_id)
 Adds a button with the given text (or a stock button, if button_text is a stock ID) and sets things up so that clicking the button will emit the "response" signal with the given response_id .

Buttonadd_button (const Gtk::StockID& stock_id, int response_id)
 Adds a button with the given text (or a stock button, if button_text is a stock ID) and sets things up so that clicking the button will emit the "response" signal with the given response_id .

void set_response_sensitive (int response_id, bool setting=true)
 Calls gtk_widget_set_sensitive (widget, setting ) for each widget in the dialog's action area with the given response_id .

void set_default_response (int response_id)
 Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog.

void set_has_separator (bool setting=true)
 Sets whether the dialog has a separator above the buttons.

bool get_has_separator () const
 Accessor for whether the dialog has a separator.

void response (int response_id)
 Emits the "response" signal with the given response ID.

int run ()
 Blocks in a recursive main loop until the dialog emits the response signal.

VBoxget_vbox ()
const VBoxget_vbox () const
HButtonBoxget_action_area ()
const HButtonBoxget_action_area () const
Glib::PropertyProxy<bool> property_has_separator ()
 You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Glib::SignalProxy1< void,
int > 
signal_response ()
Glib::SignalProxy0<void> signal_close ()

Protected Member Functions

virtual void on_response (int response_id)
virtual void on_close ()
void construct_ (bool modal, bool use_separator)

Related Functions

(Note that these are not member functions.)

Gtk::Dialogwrap (GtkDialog* object, bool take_copy=false)


Constructor & Destructor Documentation

virtual Gtk::Dialog::~Dialog (  )  [virtual]
 

Gtk::Dialog::Dialog (  ) 
 

Gtk::Dialog::Dialog ( const Glib::ustring title,
bool  modal = false,
bool  use_separator = false
[explicit]
 

Gtk::Dialog::Dialog ( const Glib::ustring title,
Gtk::Window parent,
bool  modal = false,
bool  use_separator = false
 


Member Function Documentation

void Gtk::Dialog::add_action_widget ( Widget child,
int  response_id
 

Adds an activatable widget to the action area of a Gtk::Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated.

The widget is appended to the end of the dialog's action area. If you want to add a non-activatable widget, simply pack it into the action_area field of the Gtk::Dialog struct.

Parameters:
child An activatable widget.
response_id Response ID for child .

Button* Gtk::Dialog::add_button ( const Gtk::StockID stock_id,
int  response_id
 

Adds a button with the given text (or a stock button, if button_text is a stock ID) and sets things up so that clicking the button will emit the "response" signal with the given response_id .

The button is appended to the end of the dialog's action area. The button widget is returned, but usually you don't need it.

Parameters:
button_text Text of button, or stock ID.
response_id Response ID for the button.
Returns:
The button widget that was added.

Button* Gtk::Dialog::add_button ( const Glib::ustring button_text,
int  response_id
 

Adds a button with the given text (or a stock button, if button_text is a stock ID) and sets things up so that clicking the button will emit the "response" signal with the given response_id .

The button is appended to the end of the dialog's action area. The button widget is returned, but usually you don't need it.

Parameters:
button_text Text of button, or stock ID.
response_id Response ID for the button.
Returns:
The button widget that was added.

void Gtk::Dialog::construct_ ( bool  modal,
bool  use_separator
[protected]
 

const HButtonBox* Gtk::Dialog::get_action_area (  )  const
 

Reimplemented in Gtk::FileSelection.

HButtonBox* Gtk::Dialog::get_action_area (  ) 
 

Reimplemented in Gtk::FileSelection.

bool Gtk::Dialog::get_has_separator (  )  const
 

Accessor for whether the dialog has a separator.

Returns:
true if the dialog has a separator.

const VBox* Gtk::Dialog::get_vbox (  )  const
 

VBox* Gtk::Dialog::get_vbox (  ) 
 

const GtkDialog* Gtk::Dialog::gobj (  )  const [inline]
 

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Window.

Reimplemented in Gtk::ColorSelectionDialog, Gtk::FileSelection, Gtk::FontSelectionDialog, Gtk::InputDialog, and Gtk::MessageDialog.

GtkDialog* Gtk::Dialog::gobj (  )  [inline]
 

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Window.

Reimplemented in Gtk::ColorSelectionDialog, Gtk::FileSelection, Gtk::FontSelectionDialog, Gtk::InputDialog, and Gtk::MessageDialog.

virtual void Gtk::Dialog::on_close (  )  [protected, virtual]
 

virtual void Gtk::Dialog::on_response ( int  response_id  )  [protected, virtual]
 

Glib::PropertyProxy<bool> Gtk::Dialog::property_has_separator (  ) 
 

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

void Gtk::Dialog::response ( int  response_id  ) 
 

Emits the "response" signal with the given response ID.

Used to indicate that the user has responded to the dialog in some way; typically either you or run() will be monitoring the "response" signal and take appropriate action.

Parameters:
response_id Response ID.

int Gtk::Dialog::run (  ) 
 

Blocks in a recursive main loop until the dialog emits the response signal.

It returns the response ID from the "response" signal emission. Before entering the recursive main loop, run() calls Gtk::Widget::show() on the dialog for you. Note that you still need to show any children of the dialog yourself.

If the dialog receives "delete_event", Gtk::Dialog::run() will return Gtk::RESPONSE_DELETE_EVENT. Also, during Gtk::Dialog::run() the dialog will be modal. You can force Gtk::Dialog::run() to return at any time by calling Gtk::Dialog::response() to emit the "response" signal.

After Gtk::Dialog::run() returns, you are responsible for hiding or destroying the dialog if you wish to do so.

Typical usage of this function might be:

 <tt>int</tt> result = dialog.run();
 switch (result)
 {
 case GTK_RESPONSE_ACCEPT:
 do_application_specific_something (&lt;!-- --&gt;);
 break;
 default:
 do_nothing_since_dialog_was_cancelled (&lt;!-- --&gt;);
 break;
 }
Returns:
Response ID.

void Gtk::Dialog::set_default_response ( int  response_id  ) 
 

Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog.

Pressing "Enter" normally activates the default widget.

Parameters:
response_id A response ID.

void Gtk::Dialog::set_has_separator ( bool  setting = true  ) 
 

Sets whether the dialog has a separator above the buttons.

true by default.

Parameters:
setting true to have a separator.

void Gtk::Dialog::set_response_sensitive ( int  response_id,
bool  setting = true
 

Calls gtk_widget_set_sensitive (widget, setting ) for each widget in the dialog's action area with the given response_id .

A convenient way to sensitize/desensitize dialog buttons.

Parameters:
response_id A response ID.
setting true for sensitive.

Glib::SignalProxy0<void> Gtk::Dialog::signal_close (  ) 
 

Prototype:
void close()

Glib::SignalProxy1<void,int> Gtk::Dialog::signal_response (  ) 
 

Prototype:
void response(int response_id)


Friends And Related Function Documentation

Gtk::Dialog* wrap ( GtkDialog*  object,
bool  take_copy = false
[related]
 


The documentation for this class was generated from the following file:
Generated for gtkmm2.2 by Doxygen 1.3.4 © 1997-2001