# Gtk::Application Class Reference

TODO. More...

Inherits Gio::Application.

Collaboration diagram for Gtk::Application:
[legend]

List of all members.

## Public Member Functions

virtual | ~Application ()
GtkApplication* | gobj ()
| Provides access to the underlying C GObject.
const GtkApplication* | gobj () const
| Provides access to the underlying C GObject.
GtkApplication* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | set_action_group (const Glib::RefPtr< ActionGroup >& group)
| Set group as this application's global action group.
Window* | create_window ()
| Creates a new Gtk::Window for the application.
Window* | get_window ()
| A simple Gtk::Application has a "default window".
const Window* | get_window () const
| A simple Gtk::Application has a "default window".
Glib::SListHandle< Window* > | get_windows ()
| Retrieves the list of windows previously registered with create_window() or add_window().
Glib::SListHandle< const Window* > | get_windows () const
| Retrieves the list of windows previously registered with create_window() or add_window().
void | add_window (Window& window)
| Adds a window to the Gtk::Application.
void | run ()
| Runs the main loop; see Glib::application_run().
void | quit ()
| Request the application exit.

## Static Public Member Functions

static Glib::RefPtr< Application > | create (const Glib::ustring& appid, int& argc, char**& argv)
| Create a new Gtk::Application, or if one has already been initialized in this process, return the existing instance.
static Glib::RefPtr< Application > | create (const Glib::ustring& appid)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gtk::Application > | wrap (GtkApplication* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

TODO.

## Constructor & Destructor Documentation

virtual Gtk::Application::~Application | ( |  | ) | `[virtual]`

Reimplemented from Gio::Application.

## Member Function Documentation

void Gtk::Application::add_window | ( | Window& | window | ) |

Adds a window to the Gtk::Application.

If all the windows managed by Gtk::Application are closed, the Gtk::Application will call quit(), and quit the application.

If your application uses only a single toplevel window, you can use get_window(). If you are using a sub-class of Gtk::Application you should call create_window() to let the Gtk::Application instance create a Gtk::Window and add it to the list of toplevels of the application. You should call this function only to add Gtk::Windows that you created directly using Gtk::Window::new().

Since gtkmm 3.0:

Parameters:

  | window | A toplevel window to add to app.

static Glib::RefPtr<Application> Gtk::Application::create | ( | const Glib::ustring & | appid | ) | `[static]`

static Glib::RefPtr<Application> Gtk::Application::create | ( | const Glib::ustring & | appid,
|  | int & | argc,
|  | char **& | argv |
| ) |  |  | `[static]`

Create a new Gtk::Application, or if one has already been initialized in this process, return the existing instance.

This function will as a side effect initialize the display system; see gtk_init().

For the behavior if this application is running in another process, see Glib::application_new().

Since gtkmm 3.0:

Parameters:

  | appid | System-dependent application identifier.
  | argc | System argument count.
  | argv | System argument vector.

Returns:
  A newly-referenced Gtk::Application.

Window* Gtk::Application::create_window | ( |  | ) |

Creates a new Gtk::Window for the application.

This function calls the Gtk::Application::create_window() virtual function, which can be overridden by sub-classes, for instance to use Gtk::Builder to create the user interface. After creating a new Gtk::Window instance, it will be added to the list of toplevels associated to the application.

Since gtkmm 3.0:

Returns:
  The newly created application Gtk::Window.

const Window* Gtk::Application::get_window | ( |  | ) | const

A simple Gtk::Application has a "default window".

This window should act as the primary user interaction point with your application. The window returned by this function is of type Gtk::WINDOW_TYPE_TOPLEVEL and its properties such as "title" and "icon-name" will be initialized as appropriate for the platform.

If the user closes this window, and your application hasn't created any other windows, the default action will be to call quit().

If your application has more than one toplevel window (e.g. an single-document-interface application with multiple open documents), or if you are constructing your toplevel windows yourself (e.g. using Gtk::Builder), use create_window() or add_window() instead.

Since gtkmm 3.0:

Returns:
  The default Gtk::Window for this application.

Window* Gtk::Application::get_window | ( |  | ) |

A simple Gtk::Application has a "default window".

This window should act as the primary user interaction point with your application. The window returned by this function is of type Gtk::WINDOW_TYPE_TOPLEVEL and its properties such as "title" and "icon-name" will be initialized as appropriate for the platform.

If the user closes this window, and your application hasn't created any other windows, the default action will be to call quit().

If your application has more than one toplevel window (e.g. an single-document-interface application with multiple open documents), or if you are constructing your toplevel windows yourself (e.g. using Gtk::Builder), use create_window() or add_window() instead.

Since gtkmm 3.0:

Returns:
  The default Gtk::Window for this application.

Glib::SListHandle<const Window*> Gtk::Application::get_windows | ( |  | ) | const

Retrieves the list of windows previously registered with create_window() or add_window().

Since gtkmm 3.0:

Returns:
  A pointer to the list of Gtk::Windows registered by this application, or `0`. The returned SList is owned by the Gtk::Application and it should not be modified or freed directly.

Glib::SListHandle<Window*> Gtk::Application::get_windows | ( |  | ) |

Retrieves the list of windows previously registered with create_window() or add_window().

Since gtkmm 3.0:

Returns:
  A pointer to the list of Gtk::Windows registered by this application, or `0`. The returned SList is owned by the Gtk::Application and it should not be modified or freed directly.

const GtkApplication* Gtk::Application::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::Application.

GtkApplication* Gtk::Application::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::Application.

GtkApplication* Gtk::Application::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Reimplemented from Gio::Application.

void Gtk::Application::quit | ( |  | ) |

Request the application exit.

This function invokes Glib::application_quit_with_data(), which normally will in turn cause app to emit Gtk::Application::quit.

To control an application's quit behavior (for example, to ask for files to be saved), connect to the Gtk::Application::quit signal handler.

Since gtkmm 3.0:

void Gtk::Application::run | ( |  | ) |

Runs the main loop; see Glib::application_run().

The default implementation for Gtk::Application uses gtk_main().

Since gtkmm 3.0:

void Gtk::Application::set_action_group | ( | const Glib::RefPtr< ActionGroup >& | group | ) |

Set group as this application's global action group.

This will ensure the operating system interface uses these actions as follows:

<itemizedlist> <listitem>In GNOME 2 this exposes the actions for scripting.</listitem> <listitem>In GNOME 3, this function populates the application menu.</listitem> <listitem>In Windows prior to version 7, this function does nothing.</listitem> <listitem>In Windows 7, this function adds "Tasks" to the Jump List.</listitem> <listitem>In Mac OS X, this function extends the Dock menu.</listitem> </itemizedlist>

It is an error to call this function more than once.

Since gtkmm 3.0:

Parameters:

  | group | A Gtk::ActionGroup.

## Friends And Related Function Documentation

Glib::RefPtr< Gtk::Application > wrap | ( | GtkApplication * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gtkmm/application.h