gtkmm  3.3.20
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions
Gtk::Application Class Reference

TODO. More...

Inheritance diagram for Gtk::Application:
Inheritance graph
[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.
std::vector< Window* > get_windows ()
 Gets a list of the Gtk::Windows associated with application.
std::vector< const Window* > get_windows () const
 Gets a list of the Gtk::Windows associated with application.
void add_window (Window& window)
 Adds a window to the Gtk::Application.
void remove_window (Window& window)
 Remove a window from application.
int run (int argc, char** argv)
 Starts the application.
int run (Window& window, int argc, char** argv)
 Starts the application.
int run (Window& window)
 Starts the application.
int run ()
 Starts the application.
Glib::RefPtr< Gio::MenuModelget_app_menu ()
 Returns the menu model that has been set with set_app_menu().
Glib::RefPtr< const
Gio::MenuModel
get_app_menu () const
 Returns the menu model that has been set with set_app_menu().
void set_app_menu (const Glib::RefPtr< Gio::MenuModel >& app_menu)
 Sets or unsets the application menu for application.
Glib::RefPtr< Gio::MenuModelget_menubar ()
 Returns the menu model that has been set with set_menubar().
Glib::RefPtr< const
Gio::MenuModel
get_menubar () const
 Returns the menu model that has been set with set_menubar().
void set_menubar (const Glib::RefPtr< Gio::MenuModel >& menubar)
 Sets or unsets the menubar for windows of application.
void add_accelerator (const Glib::ustring& accelerator, const Glib::ustring& action_name, GVariant* parameter)
 Installs an accelerator that will cause the named action to be activated when the key combination specificed by accelerator is pressed.
void remove_accelerator (const Glib::ustring& action_name, GVariant* parameter)
 Removes an accelerator that has been previously added with add_accelerator().
guint inhibit (Window& window, ApplicationInhibitFlags flags, const Glib::ustring& reason)
 Inform the session manager that certain types of actions should be inhibited.
void uninhibit (guint cookie)
 Removes an inhibitor that has been established with Glib::application_inhibit().
bool is_inhibited (ApplicationInhibitFlags flags) const
 Determines if any of the actions specified in flags are currently inhibited (possibly by another application).
Glib::PropertyProxy
< Glib::RefPtr< Gio::MenuModel > > 
property_app_menu ()
 The GMenuModel for the application menu.
Glib::PropertyProxy_ReadOnly
< Glib::RefPtr< Gio::MenuModel > > 
property_app_menu () const
 The GMenuModel for the application menu.
Glib::PropertyProxy
< Glib::RefPtr< Gio::MenuModel > > 
property_menubar ()
 The GMenuModel for the menubar.
Glib::PropertyProxy_ReadOnly
< Glib::RefPtr< Gio::MenuModel > > 
property_menubar () const
 The GMenuModel for the menubar.
Glib::PropertyProxy< bool > property_register_session ()
 Register with the session manager.
Glib::PropertyProxy_ReadOnly
< bool > 
property_register_session () const
 Register with the session manager.
Glib::SignalProxy1< void,
Window* > 
signal_window_added ()
Glib::SignalProxy1< void,
Window* > 
signal_window_removed ()

Static Public Member Functions

static Glib::RefPtr< Applicationcreate (const Glib::ustring& application_id, Gio::ApplicationFlags flags=Gio::APPLICATION_FLAGS_NONE)
static Glib::RefPtr< Applicationcreate (int& argc, char**& argv, const Glib::ustring& application_id, Gio::ApplicationFlags flags=Gio::APPLICATION_FLAGS_NONE)

Protected Member Functions

 Application (const Glib::ustring& application_id, Gio::ApplicationFlags flags=Gio::APPLICATION_FLAGS_NONE)
 Creates a new Application instance.
 Application (int& argc, char**& argv, const Glib::ustring& application_id, Gio::ApplicationFlags flags=Gio::APPLICATION_FLAGS_NONE)
 Creates a new Application instance.
virtual void on_window_added (Window* window)
 This is a default handler for the signal signal_window_added().
virtual void on_window_removed (Window* window)
 This is a default handler for the signal signal_window_removed().

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::Applicationwrap (GtkApplication* object, bool take_copy=false)
 A Glib::wrap() method for this object.

Detailed Description

TODO.

Since gtkmm 3.4:

Constructor & Destructor Documentation

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

Reimplemented from Gio::Application.

Gtk::Application::Application ( const Glib::ustring application_id,
Gio::ApplicationFlags  flags = Gio::APPLICATION_FLAGS_NONE 
) [explicit, protected]

Creates a new Application instance.

This constructor calls g_type_init() for you. You should call run() with your main() function's argc and argv parameters to initialize gtkmm too.

Parameters:
application_idA valid application id
flagsThe application flags
Since gtkmm 3.4:

Reimplemented from Gio::Application.

Gtk::Application::Application ( int &  argc,
char **&  argv,
const Glib::ustring application_id,
Gio::ApplicationFlags  flags = Gio::APPLICATION_FLAGS_NONE 
) [explicit, protected]

Creates a new Application instance.

This constructor initializes gtkmm for you, so you should call run() without specifying the the argc and argv parameters again.

Parameters:
argcThe parameter received by your main() function.
argvThe parameter received by your main() function.
application_idA valid application id
flagsThe application flags
Since gtkmm 3.4:

Member Function Documentation

void Gtk::Application::add_accelerator ( const Glib::ustring accelerator,
const Glib::ustring action_name,
GVariant *  parameter 
)

Installs an accelerator that will cause the named action to be activated when the key combination specificed by accelerator is pressed.

accelerator must be a string that can be parsed by gtk_accelerator_parse(), e.g. "<Primary>q" or "<Control><Alt>p".

action_name must be the name of an action as it would be used in the app menu, i.e. actions that have been added to the application are referred to with an "app." prefix, and window-specific actions with a "win." prefix.

GtkApplication also extracts accelerators out of 'accel' attributes in the MenuModels passed to set_app_menu() and set_menubar(), which is usually more convenient than calling this function for each accelerator.

Since gtkmm 3.4:
Parameters:
acceleratorAccelerator string.
action_nameThe name of the action to activate.
parameterParameter to pass when activating the action, or 0 if the action does not accept an activation parameter.

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 new Gtk::Window.

Since gtkmm 3.4:
Parameters:
windowA toplevel window to add to the application.

Reimplemented from Gio::Application.

static Glib::RefPtr<Application> Gtk::Application::create ( int &  argc,
char **&  argv,
const Glib::ustring application_id,
Gio::ApplicationFlags  flags = Gio::APPLICATION_FLAGS_NONE 
) [static]

Returns the menu model that has been set with set_app_menu().

Since gtkmm 3.4:
Returns:
The application menu of application.

Returns the menu model that has been set with set_app_menu().

Since gtkmm 3.4:
Returns:
The application menu of application.

Returns the menu model that has been set with set_menubar().

Since gtkmm 3.4:
Returns:
The menubar for windows of application.

Returns the menu model that has been set with set_menubar().

Since gtkmm 3.4:
Returns:
The menubar for windows of application.

Gets a list of the Gtk::Windows associated with application.

The list is sorted by most recently focused window, such that the first element is the currently focused window. (Useful for choosing a parent for a transient window.)

The list that is returned should not be modified in any way. It will only remain valid until the next focus change or window creation or deletion.

Since gtkmm 3.0:
Returns:
A List of Gtk::Window.

Gets a list of the Gtk::Windows associated with application.

The list is sorted by most recently focused window, such that the first element is the currently focused window. (Useful for choosing a parent for a transient window.)

The list that is returned should not be modified in any way. It will only remain valid until the next focus change or window creation or deletion.

Since gtkmm 3.0:
Returns:
A List of Gtk::Window.
GtkApplication* Gtk::Application::gobj ( ) [inline]

Provides access to the underlying C GObject.

Reimplemented from Gio::Application.

const GtkApplication* Gtk::Application::gobj ( ) const [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.

guint Gtk::Application::inhibit ( Window window,
ApplicationInhibitFlags  flags,
const Glib::ustring reason 
)

Inform the session manager that certain types of actions should be inhibited.

This is not guaranteed to work on all platforms and for all types of actions.

Applications should invoke this method when they begin an operation that should not be interrupted, such as creating a CD or DVD. The types of actions that may be blocked are specified by the flags parameter. When the application completes the operation it should call Glib::application_uninhibit() to remove the inhibitor. Note that an application can have multiple inhibitors, and all of the must be individually removed. Inhibitors are also cleared when the application exits.

Applications should not expect that they will always be able to block the action. In most cases, users will be given the option to force the action to take place.

Reasons should be short and to the point.

If window is given, the session manager may point the user to this window to find out more about why the action is inhibited.

Since gtkmm 3.4:
Parameters:
windowA Gtk::Window, or 0.
flagsWhat types of actions should be inhibited.
reasonA short, human-readable string that explains why these operations are inhibited.
Returns:
A non-zero cookie that is used to uniquely identify this request. It should be used as an argument to Glib::application_uninhibit() in order to remove the request. If the platform does not support inhibiting or the request failed for some reason, 0 is returned.

Determines if any of the actions specified in flags are currently inhibited (possibly by another application).

Since gtkmm 3.4:
Parameters:
flagsWhat types of actions should be queried.
Returns:
true if any of the actions specified in flags are inhibited.
virtual void Gtk::Application::on_window_added ( Window window) [protected, virtual]

This is a default handler for the signal signal_window_added().

virtual void Gtk::Application::on_window_removed ( Window window) [protected, virtual]

This is a default handler for the signal signal_window_removed().

The GMenuModel for the application menu.

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.

The GMenuModel for the application menu.

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.

The GMenuModel for the menubar.

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.

The GMenuModel for the menubar.

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.

Register with the session manager.

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.

Register with the session manager.

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::Application::remove_accelerator ( const Glib::ustring action_name,
GVariant *  parameter 
)

Removes an accelerator that has been previously added with add_accelerator().

Since gtkmm 3.4:
Parameters:
action_nameThe name of the action to activate.
parameterParameter to pass when activating the action, or 0 if the action does not accept an activation parameter.

Remove a window from application.

If window belongs to application then this call is equivalent to setting the Gtk::Window::property_application() property of window to 0.

The application may stop running as a result of a call to this function.

Since gtkmm 3.0:
Parameters:
windowA Gtk::Window.
int Gtk::Application::run ( int  argc,
char **  argv 
)

Starts the application.

The default implementation of this virtual function will simply run a main loop.

It is an error to call this function if application is a proxy for a remote application.

Since gtkmm 3.4:

Reimplemented from Gio::Application.

int Gtk::Application::run ( Window window,
int  argc,
char **  argv 
)

Starts the application.

The default implementation of this virtual function will simply run a main loop.

It is an error to call this function if application is a proxy for a remote application.

Parameters:
windowThe window to show. This method will return when the window is hidden.
Since gtkmm 3.4:
int Gtk::Application::run ( Window window)

Starts the application.

The default implementation of this virtual function will simply run a main loop.

It is an error to call this function if application is a proxy for a remote application.

Parameters:
windowThe window to show. This method will return when the window is hidden.
Since gtkmm 3.4:

Starts the application.

The default implementation of this virtual function will simply run a main loop.

It is an error to call this function if application is a proxy for a remote application.

Since gtkmm 3.4:

Sets or unsets the application menu for application.

The application menu is a single menu containing items that typically impact the application as a whole, rather than acting on a specific window or document. For example, you would expect to see "Preferences" or "Quit" in an application menu, but not "Save" or "Print".

If supported, the application menu will be rendered by the desktop environment.

Since gtkmm 3.4:
Parameters:
app_menuA MenuModel, or 0.

Sets or unsets the menubar for windows of application.

This is a menubar in the traditional sense.

Depending on the desktop environment, this may appear at the top of each window, or at the top of the screen. In some environments, if both the application menu and the menubar are set, the application menu will be presented as if it were the first item of the menubar. Other environments treat the two as completely separate -- for example, the application menu may be rendered by the desktop shell while the menubar (if set) remains in each individual window.

Since gtkmm 3.4:
Parameters:
menubarA MenuModel, or 0.
Slot Prototype:
void on_my_window_added(Window* window)

Emitted when a Gtk::Window is added to application through Gtk::Application::add_window().

Since gtkmm 3.2:
Parameters:
windowThe newly-added Gtk::Window.
Slot Prototype:
void on_my_window_removed(Window* window)

Emitted when a Gtk::Window is removed from application, either as a side-effect of being destroyed or explicitly through Gtk::Application::remove_window().

Since gtkmm 3.2:
Parameters:
windowThe Gtk::Window that is being removed.
void Gtk::Application::uninhibit ( guint  cookie)

Removes an inhibitor that has been established with Glib::application_inhibit().

Inhibitors are also cleared when the application exits.

Since gtkmm 3.4:
Parameters:
cookieA cookie that was returned by Glib::application_inhibit().

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:
objectThe C instance.
take_copyFalse 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: