gtkmm  3.93.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Gtk::Main Class Reference

Main application class. More...

#include <gtkmm/main.h>

Inheritance diagram for Gtk::Main:
Inheritance graph
[legend]

Public Member Functions

 Main (bool set_locale=true)
 Initialization without command-line arguments. More...
 
virtual ~Main ()
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src)
 
 ~trackable ()
 
void add_destroy_notify_callback (void *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src)
 
void remove_destroy_notify_callback (void *data) const
 

Static Public Member Functions

static Gtk::Maininstance ()
 Access to the one global instance of Gtk::Main. More...
 
static void run ()
 Start the event loop. More...
 
static void run (Window& window)
 Returns from the main loop when the window is closed. More...
 
static void quit ()
 Makes the innermost invocation of the main loop return when it regains control. More...
 
static guint level ()
 
static bool iteration (bool blocking=true)
 Runs a single iteration of the main loop. More...
 
static bool events_pending ()
 Checks if any events are pending. More...
 
static void init_gtkmm_internals ()
 Initialize the table of wrap_new functions. More...
 

Protected Member Functions

void init (bool set_locale)
 
virtual void run_impl ()
 
virtual void quit_impl ()
 
virtual guint level_impl ()
 
virtual bool iteration_impl (bool blocking)
 
virtual bool events_pending_impl ()
 
virtual void on_window_hide ()
 

Additional Inherited Members

- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 

Detailed Description

Main application class.

Every application must have one of these objects. It may not be global and must be the first gtkmm object created. It is a singleton so declaring more than one will simply access the first created.

You would normally use this class in your main() function to initialize gtkmm and optionally to give argc and argv to the GTK+ initialization. After calling Gtk::Main::run(), you may use Gtk::Main::quit() to exit from the application, or just pass your main window to run(), to make run() return when that window closes.

A minimal gtkmm application would be something like this:

int main(int argc, char* argv[])
{
Gtk::Main kit();
... create some widgets and windows...
kit.run(window);
}
Deprecated:
Use Gtk::Application instead.

Constructor & Destructor Documentation

◆ Main()

Gtk::Main::Main ( bool  set_locale = true)
explicit

Initialization without command-line arguments.

Parameters
set_localePassing false prevents GTK+ from automatically calling setlocale(LC_ALL, ""). You would want to pass false if you wanted to set the locale for your program to something other than the user's locale, or if you wanted to set different values for different locale categories.
Deprecated:
Use Gtk::Application instead.

◆ ~Main()

virtual Gtk::Main::~Main ( )
virtual

Member Function Documentation

◆ events_pending()

static bool Gtk::Main::events_pending ( )
static

Checks if any events are pending.

This can be used to update the GUI and invoke timeouts etc. while doing some time intensive computation.

Example: Updating the GUI during a long computation.

// computation going on
// computation continued
Returns
true if any events are pending, false otherwise.

◆ events_pending_impl()

virtual bool Gtk::Main::events_pending_impl ( )
protectedvirtual

◆ init()

void Gtk::Main::init ( bool  set_locale)
protected

◆ init_gtkmm_internals()

static void Gtk::Main::init_gtkmm_internals ( )
static

Initialize the table of wrap_new functions.

This doesn't need an instance of Gtk::Main. This would usually only be used by the init() methods of libraries that depend on gtkmm.

◆ instance()

static Gtk::Main* Gtk::Main::instance ( )
static

Access to the one global instance of Gtk::Main.

Deprecated:
Use Gtk::Application instead.

◆ iteration()

static bool Gtk::Main::iteration ( bool  blocking = true)
static

Runs a single iteration of the main loop.

If no events are waiting to be processed GTK+ will block until the next event is noticed. If you don't want to block then pass false for blocking or check if any events are pending with pending() first.

Parameters
blockingWhether the caller must wait until the next event is noticed, or return immediately if there are no events.
Returns
true if quit() has been called for the innermost main loop.

◆ iteration_impl()

virtual bool Gtk::Main::iteration_impl ( bool  blocking)
protectedvirtual

◆ level()

static guint Gtk::Main::level ( )
static

◆ level_impl()

virtual guint Gtk::Main::level_impl ( )
protectedvirtual

◆ on_window_hide()

virtual void Gtk::Main::on_window_hide ( )
protectedvirtual

◆ quit()

static void Gtk::Main::quit ( )
static

Makes the innermost invocation of the main loop return when it regains control.

Deprecated:
Use Gtk::Application instead.

◆ quit_impl()

virtual void Gtk::Main::quit_impl ( )
protectedvirtual

◆ run() [1/2]

static void Gtk::Main::run ( )
static

Start the event loop.

This begins the event loop which handles events. No events propagate until this has been called. It may be called recursively to popup dialogs

Deprecated:
Use Gtk::Application instead.

◆ run() [2/2]

static void Gtk::Main::run ( Window window)
static

Returns from the main loop when the window is closed.

When using this override, you should not use Gtk::Main::quit() to close the application, but just call hide() on your Window class.

Parameters
windowThe window to show. This method will return when the window is hidden.
Deprecated:
Use Gtk::Application instead.

◆ run_impl()

virtual void Gtk::Main::run_impl ( )
protectedvirtual