Advertisement
Guest User

Untitled

a guest
Aug 6th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 38.13 KB | None | 0 0
  1. // Generated by gmmproc 2.54.0 -- DO NOT MODIFY!
  2. #ifndef _GTKMM_APPLICATION_H
  3. #define _GTKMM_APPLICATION_H
  4.  
  5. #include <gtkmmconfig.h>
  6.  
  7.  
  8. #include <glibmm/ustring.h>
  9. #include <sigc++/sigc++.h>
  10.  
  11. /* Copyright (C) 2003-2014 The gtkmm Development Team
  12.  *
  13.  * This library is free software; you can redistribute it and/or
  14.  * modify it under the terms of the GNU Lesser General Public
  15.  * License as published by the Free Software Foundation; either
  16.  * version 2.1 of the License, or (at your option) any later version.
  17.  *
  18.  * This library is distributed in the hope that it will be useful,
  19.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  21.  * Lesser General Public License for more details.
  22.  *
  23.  * You should have received a copy of the GNU Lesser General Public
  24.  * License along with this library; if not, write to the Free
  25.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  */
  27.  
  28.  
  29. #include <vector>
  30.  
  31. #include <gtkmm/actiongroup.h>
  32. #include <giomm/application.h>
  33. #include <giomm/menumodel.h>
  34. #include <giomm/menu.h>
  35. #include <vector>
  36. #include <glibmm/arrayhandle.h>
  37.  
  38.  
  39. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  40. using GtkApplication = struct _GtkApplication;
  41. using GtkApplicationClass = struct _GtkApplicationClass;
  42. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  43.  
  44.  
  45. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  46. namespace Gtk
  47. { class Application_Class; } // namespace Gtk
  48. #endif //DOXYGEN_SHOULD_SKIP_THIS
  49.  
  50. namespace Gtk
  51. {
  52.  
  53. /** @addtogroup gtkmmEnums gtkmm Enums and Flags */
  54.  
  55. /**
  56.  *  @var ApplicationInhibitFlags APPLICATION_INHIBIT_LOGOUT
  57.  * Inhibit ending the user session
  58.  * by logging out or by shutting down the computer.
  59.  *
  60.  *  @var ApplicationInhibitFlags APPLICATION_INHIBIT_SWITCH
  61.  * Inhibit user switching.
  62.  *
  63.  *  @var ApplicationInhibitFlags APPLICATION_INHIBIT_SUSPEND
  64.  * Inhibit suspending the
  65.  * session or computer.
  66.  *
  67.  *  @var ApplicationInhibitFlags APPLICATION_INHIBIT_IDLE
  68.  * Inhibit the session being
  69.  * marked as idle (and possibly locked).
  70.  *
  71.  *  @enum ApplicationInhibitFlags
  72.  *
  73.  * Types of user actions that may be blocked by Gtk::Application::inhibit().
  74.  *
  75.  * @newin{3,4}
  76.  *
  77.  * @ingroup gtkmmEnums
  78.  * @par Bitwise operators:
  79.  * <tt>%ApplicationInhibitFlags operator|(ApplicationInhibitFlags, ApplicationInhibitFlags)</tt><br>
  80.  * <tt>%ApplicationInhibitFlags operator&(ApplicationInhibitFlags, ApplicationInhibitFlags)</tt><br>
  81.  * <tt>%ApplicationInhibitFlags operator^(ApplicationInhibitFlags, ApplicationInhibitFlags)</tt><br>
  82.  * <tt>%ApplicationInhibitFlags operator~(ApplicationInhibitFlags)</tt><br>
  83.  * <tt>%ApplicationInhibitFlags& operator|=(ApplicationInhibitFlags&, ApplicationInhibitFlags)</tt><br>
  84.  * <tt>%ApplicationInhibitFlags& operator&=(ApplicationInhibitFlags&, ApplicationInhibitFlags)</tt><br>
  85.  * <tt>%ApplicationInhibitFlags& operator^=(ApplicationInhibitFlags&, ApplicationInhibitFlags)</tt><br>
  86.  */
  87. enum ApplicationInhibitFlags
  88. {
  89.   APPLICATION_INHIBIT_LOGOUT = (1 << 0),
  90.   APPLICATION_INHIBIT_SWITCH = (1 << 1),
  91.   APPLICATION_INHIBIT_SUSPEND = (1 << 2),
  92.   APPLICATION_INHIBIT_IDLE = (1 << 3)
  93. };
  94.  
  95. /** @ingroup gtkmmEnums */
  96. inline ApplicationInhibitFlags operator|(ApplicationInhibitFlags lhs, ApplicationInhibitFlags rhs)
  97.   { return static_cast<ApplicationInhibitFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
  98.  
  99. /** @ingroup gtkmmEnums */
  100. inline ApplicationInhibitFlags operator&(ApplicationInhibitFlags lhs, ApplicationInhibitFlags rhs)
  101.   { return static_cast<ApplicationInhibitFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
  102.  
  103. /** @ingroup gtkmmEnums */
  104. inline ApplicationInhibitFlags operator^(ApplicationInhibitFlags lhs, ApplicationInhibitFlags rhs)
  105.   { return static_cast<ApplicationInhibitFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
  106.  
  107. /** @ingroup gtkmmEnums */
  108. inline ApplicationInhibitFlags operator~(ApplicationInhibitFlags flags)
  109.   { return static_cast<ApplicationInhibitFlags>(~static_cast<unsigned>(flags)); }
  110.  
  111. /** @ingroup gtkmmEnums */
  112. inline ApplicationInhibitFlags& operator|=(ApplicationInhibitFlags& lhs, ApplicationInhibitFlags rhs)
  113.   { return (lhs = static_cast<ApplicationInhibitFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
  114.  
  115. /** @ingroup gtkmmEnums */
  116. inline ApplicationInhibitFlags& operator&=(ApplicationInhibitFlags& lhs, ApplicationInhibitFlags rhs)
  117.   { return (lhs = static_cast<ApplicationInhibitFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
  118.  
  119. /** @ingroup gtkmmEnums */
  120. inline ApplicationInhibitFlags& operator^=(ApplicationInhibitFlags& lhs, ApplicationInhibitFlags rhs)
  121.   { return (lhs = static_cast<ApplicationInhibitFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
  122.  
  123. } // namespace Gtk
  124.  
  125. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  126. namespace Glib
  127. {
  128.  
  129. template <>
  130. class Value<Gtk::ApplicationInhibitFlags> : public Glib::Value_Flags<Gtk::ApplicationInhibitFlags>
  131. {
  132. public:
  133.   static GType value_type() G_GNUC_CONST;
  134. };
  135.  
  136. } // namespace Glib
  137. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  138.  
  139. namespace Gtk
  140. {
  141.  
  142.  
  143. class Window;
  144.  
  145. //TODO: Add overview documentation discussing the techniques show in the examples in gtkmm-docmentation.
  146. //TODO: Add the screenshots from the C API?
  147.  
  148. /** The Gtk::Application class handles many important aspects
  149.  * of a GTK+ application in a convenient fashion, without enforcing
  150.  * a one-size-fits-all application model.
  151.  *
  152.  * Currently, Gtk::Application handles GTK+ and gtkmm initialization, application
  153.  * uniqueness, session management, provides some basic scriptability and
  154.  * desktop shell integration by exporting actions and menus, and manages a
  155.  * list of toplevel windows whose life-cycle is automatically tied to the
  156.  * life-cycle of your application.
  157.  *
  158.  * While Gtk::Application works fine with plain Gtk::Window%s, it is recommended
  159.  * to use it together with Gtk::ApplicationWindow.
  160.  *
  161.  * When GDK threads are enabled, Gtk::Application will acquire the GDK
  162.  * lock when invoking actions that arrive from other processes.  The GDK
  163.  * lock is not touched for local action invocations.  In order to have
  164.  * actions invoked in a predictable context it is therefore recommended
  165.  * that the GDK lock be held while invoking actions locally with
  166.  * Gio::ActionGroup::activate_action().  The same applies to actions
  167.  * associated with Gtk::ApplicationWindow and to the Gio::Application::activate() and
  168.  * Gio::Application::open() methods.
  169.  *
  170.  * To set an application menu for a Gtk::Application, use
  171.  * set_app_menu(). The Gio::MenuModel that this method
  172.  * expects is usually constructed using Gtk::Builder.
  173.  * To specify a menubar that will be shown by
  174.  * Gtk::ApplicationWindow%s, use set_menubar(). Use the base
  175.  * Gio::ActionMap interface to add actions, to respond to the user
  176.  * selecting these menu items.
  177.  *
  178.  * GTK+ displays these menus as expected, depending on the platform
  179.  * the application is running on.
  180.  *
  181.  * Gtk::Application optionally registers with a session manager
  182.  * of the users session (if you set the register-session
  183.  * property) and offers various functionality related to the session
  184.  * life-cycle.
  185.  *
  186.  * An application can block various ways to end the session with
  187.  * the inhibit() method. Typical use cases for
  188.  * this kind of inhibiting are long-running, uninterruptible operations,
  189.  * such as burning a CD or performing a disk backup. The session
  190.  * manager may not honor the inhibitor, but it can be expected to
  191.  * inform the user about the negative consequences of ending the
  192.  * session while inhibitors are present.
  193.  *
  194.  * @newin{3,4}
  195.  */
  196.  
  197. class Application
  198.   : public Gio::Application
  199. {
  200. protected:
  201.  
  202. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  203.  
  204. public:
  205.   using CppObjectType = Application;
  206.   using CppClassType = Application_Class;
  207.   using BaseObjectType = GtkApplication;
  208.   using BaseClassType = GtkApplicationClass;
  209.  
  210.   // noncopyable
  211.   Application(const Application&) = delete;
  212.   Application& operator=(const Application&) = delete;
  213.  
  214. private:  friend class Application_Class;
  215.   static CppClassType application_class_;
  216.  
  217. protected:
  218.   explicit Application(const Glib::ConstructParams& construct_params);
  219.   explicit Application(GtkApplication* castitem);
  220.  
  221. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  222.  
  223. public:
  224.  
  225.   Application(Application&& src) noexcept;
  226.   Application& operator=(Application&& src) noexcept;
  227.  
  228.   ~Application() noexcept override;
  229.  
  230.   /** Get the GType for this class, for use with the underlying GObject type system.
  231.    */
  232.   static GType get_type()      G_GNUC_CONST;
  233.  
  234. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  235.  
  236.  
  237.   static GType get_base_type() G_GNUC_CONST;
  238. #endif
  239.  
  240.   ///Provides access to the underlying C GObject.
  241.   GtkApplication*       gobj()       { return reinterpret_cast<GtkApplication*>(gobject_); }
  242.  
  243.   ///Provides access to the underlying C GObject.
  244.   const GtkApplication* gobj() const { return reinterpret_cast<GtkApplication*>(gobject_); }
  245.  
  246.   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
  247.   GtkApplication* gobj_copy();
  248.  
  249. private:
  250.  
  251.  
  252. protected:
  253.  
  254.   /** Creates a new Application instance.
  255.    *
  256.    * This initializes gtkmm (and the GObject type system) for you.
  257.    *
  258.    * If non-empty, the application ID must be valid.  See
  259.    * g_application_id_is_valid().
  260.    *
  261.    * If no application ID is given then some features (most notably application
  262.    * uniqueness) will be disabled. A null application ID is only allowed with
  263.    * gtkmm 3.6 or later.
  264.    *
  265.    * @param application_id A valid application ID.
  266.    * @param flags The application flags.
  267.    *
  268.    * @newin{3,4}
  269.    */
  270.   explicit Application(const Glib::ustring& application_id = Glib::ustring(), Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
  271.  
  272.  
  273.   //This constructor does not correspond to anything in the C API.
  274.   //We added it so we can choose to always initialize gtkmm as early as possible.
  275.   //See https://bugzilla.gnome.org/show_bug.cgi?id=639925
  276.   /** Creates a new Application instance.
  277.    *
  278.    * This initializes gtkmm (and the GObject type system) for you, parsing the
  279.    * standard GTK+ command line arguments.
  280.    *
  281.    * You could instead use the constructor that takes no command line arguments
  282.    * and later supply the command line arguments to run().
  283.    *
  284.    * Note that all GTK+ functionality that is available via command line arguments
  285.    * can instead be achieved by setting suitable environment variables
  286.    * such as G_DEBUG.
  287.    *
  288.    * If non-empty, the application ID must be valid.  See
  289.    * g_application_id_is_valid().
  290.    *
  291.    * If no application ID is given then some features (most notably application
  292.    * uniqueness) will be disabled. A null application ID is only allowed with
  293.    * gtkmm 3.6 or later.
  294.    *
  295.    * @param argc The parameter received by your main() function.
  296.    * @param argv The parameter received by your main() function.
  297.    * @param application_id A valid application ID.
  298.    * @param flags The application flags.
  299.    *
  300.    * @newin{3,4}
  301.    */
  302.   explicit Application(int& argc, char**& argv, const Glib::ustring& application_id = Glib::ustring(), Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
  303.  
  304. public:
  305.  
  306.   /** Creates a new Application instance.
  307.    *
  308.    * This initializes gtkmm (and the GObject type system) for you.
  309.    *
  310.    * If non-empty, the application ID must be valid.  See
  311.    * g_application_id_is_valid().
  312.    *
  313.    * If no application ID is given then some features (most notably application
  314.    * uniqueness) will be disabled. A null application ID is only allowed with
  315.    * gtkmm 3.6 or later.
  316.    *
  317.    * @param application_id A valid application ID.
  318.    * @param flags The application flags.
  319.    *
  320.    * @newin{3,4}
  321.    */
  322.   static Glib::RefPtr<Application> create(const Glib::ustring& application_id = Glib::ustring(), Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
  323.  
  324.   /** Creates a new Application instance.
  325.    *
  326.    * This initializes gtkmm (and the GObject type system) for you, parsing the
  327.    * standard GTK+ command line arguments.
  328.    *
  329.    * You could instead use the constructor that takes no command line arguments
  330.    * and later supply the command line arguments to run().
  331.    *
  332.    * Note that all GTK+ functionality that is available via command line arguments
  333.    * can instead be achieved by setting suitable environment variables
  334.    * such as G_DEBUG.
  335.    *
  336.    * If non-empty, the application ID must be valid.  See
  337.    * g_application_id_is_valid().
  338.    *
  339.    * If no application ID is given then some features (most notably application
  340.    * uniqueness) will be disabled. A null application ID is only allowed with
  341.    * gtkmm 3.6 or later.
  342.    *
  343.    * @param argc The parameter received by your main() function.
  344.    * @param argv The parameter received by your main() function.
  345.    * @param application_id A valid application ID.
  346.    *
  347.    * @param flags The application flags.
  348.    * @newin{3,4}
  349.    */
  350.   static Glib::RefPtr<Application> create(int& argc, char**& argv, const Glib::ustring& application_id = Glib::ustring(), Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
  351.  
  352.  
  353.   /** Gets a list of the Gtk::Windows associated with @a application.
  354.    *
  355.    * The list is sorted by most recently focused window, such that the first
  356.    * element is the currently focused window. (Useful for choosing a parent
  357.    * for a transient window.)
  358.    *
  359.    * The list that is returned should not be modified in any way. It will
  360.    * only remain valid until the next focus change or window creation or
  361.    * deletion.
  362.    *
  363.    * @newin{3,0}
  364.    *
  365.    * @return A List of Gtk::Window.
  366.    */
  367.   std::vector<Window*> get_windows();
  368.  
  369.  
  370.   /** Gets a list of the Gtk::Windows associated with @a application.
  371.    *
  372.    * The list is sorted by most recently focused window, such that the first
  373.    * element is the currently focused window. (Useful for choosing a parent
  374.    * for a transient window.)
  375.    *
  376.    * The list that is returned should not be modified in any way. It will
  377.    * only remain valid until the next focus change or window creation or
  378.    * deletion.
  379.    *
  380.    * @newin{3,0}
  381.    *
  382.    * @return A List of Gtk::Window.
  383.    */
  384.   std::vector<const Window*> get_windows() const;
  385.  
  386.   //Concerning the note on quit(), see https://bugzilla.gnome.org/show_bug.cgi?id=731126
  387.   /** Adds a window to the Gtk::Application.
  388.    *
  389.    * If all the windows managed by Gtk::Application are closed (hidden) or
  390.    * removed from the application then the call to run() will return.
  391.    *
  392.    * This call is equivalent to calling Gtk::Window::set_application().
  393.    *
  394.    * Normally, the connection between the application and the window
  395.    * will remain until the window is closed (hidden) or destroyed, but you can explicitly
  396.    * remove it with remove_window().
  397.    *
  398.    * @note If you call Gio::Application::quit() while a window is connected to
  399.    * the application, and then return from main() without removing the window
  400.    * from the application, the application's destructor will not be called.
  401.    *
  402.    * @newin{3,4}
  403.    *
  404.    * @param window A toplevel window to add to the application.
  405.    */
  406.   void add_window(Window& window);
  407.  
  408.  
  409.   /** Remove a window from @a application.
  410.    *
  411.    * If @a window belongs to @a application then this call is equivalent to
  412.    * setting the Gtk::Window::property_application() property of @a window to
  413.    * <tt>nullptr</tt>.
  414.    *
  415.    * The application may stop running as a result of a call to this
  416.    * function.
  417.    *
  418.    * @newin{3,0}
  419.    *
  420.    * @param window A Gtk::Window.
  421.    */
  422.   void remove_window(Window& window);
  423.  
  424.   /** Starts the application.
  425.    *
  426.    * The default implementation of this virtual function will simply run
  427.    * a main loop.
  428.    *
  429.    * It is an error to call this function if @a application is a proxy for
  430.    * a remote application.
  431.    *
  432.    * @param argc The argc from main() (or 0 if @a argv is <tt>0</tt>).
  433.    * @param argv The argv from main(), or <tt>0</tt>.
  434.    * @return The exit status.
  435.    *
  436.    * @newin{3,4}
  437.    */
  438.   int run(int argc, char** argv);
  439.  
  440.   /** Starts the application.
  441.    *
  442.    * The default implementation of this virtual function will simply run
  443.    * a main loop.
  444.    *
  445.    * It is an error to call this function if @a application is a proxy for
  446.    * a remote application.
  447.    *
  448.    * @note If you call Gio::Application::quit() while a window is connected to
  449.    * the application, and then return from main() without removing the window
  450.    * from the application, the application's destructor will not be called.
  451.    *
  452.    * @param window The window to show. This method will return when the window is hidden.
  453.    * @param argc The argc from main() (or 0 if @a argv is <tt>0</tt>).
  454.    * @param argv The argv from main(), or <tt>0</tt>.
  455.    * @return The exit status.
  456.    *
  457.    * @newin{3,4}
  458.    */
  459.   int run(Window& window, int argc, char** argv);
  460.  
  461.   //TODO: If argc and argv are necessary at all, document the need to call that constructor first.
  462.   //See https://bugzilla.gnome.org/show_bug.cgi?id=639925#c4
  463.   /** Starts the application.
  464.    *
  465.    * The default implementation of this virtual function will simply run
  466.    * a main loop.
  467.    *
  468.    * It is an error to call this function if @a application is a proxy for
  469.    * a remote application.
  470.    *
  471.    * @note If you call Gio::Application::quit() while a window is connected to
  472.    * the application, and then return from main() without removing the window
  473.    * from the application, the application's destructor will not be called.
  474.    *
  475.    * @param window The window to show. This method will return when the window is hidden.
  476.    * @return The exit status.
  477.    *
  478.    * @newin{3,4}
  479.    */
  480.   int run(Window& window);
  481.  
  482.   //TODO: If argc and argv are necessary at all, document the need to call that constructor first.
  483.   //See https://bugzilla.gnome.org/show_bug.cgi?id=639925#c4
  484.   /** Starts the application.
  485.    *
  486.    * The default implementation of this virtual function will simply run
  487.    * a main loop.
  488.    *
  489.    * It is an error to call this function if @a application is a proxy for
  490.    * a remote application.
  491.    *
  492.    * @return The exit status.
  493.    *
  494.    * @newin{3,4}
  495.    */
  496.   int run();
  497.  
  498.  
  499.   /** Returns the menu model that has been set with
  500.    * set_app_menu().
  501.    *
  502.    * @newin{3,4}
  503.    *
  504.    * @return The application menu of @a application
  505.    * or <tt>nullptr</tt> if no application menu has been set.
  506.    */
  507.   Glib::RefPtr<Gio::MenuModel> get_app_menu();
  508.  
  509.   /** Returns the menu model that has been set with
  510.    * set_app_menu().
  511.    *
  512.    * @newin{3,4}
  513.    *
  514.    * @return The application menu of @a application
  515.    * or <tt>nullptr</tt> if no application menu has been set.
  516.    */
  517.   Glib::RefPtr<const Gio::MenuModel> get_app_menu() const;
  518.  
  519.  
  520.   /** Sets or unsets the application menu for @a application.
  521.    *
  522.    * This can only be done in the primary instance of the application,
  523.    * after it has been registered.  Application::signal_startup() is a good place
  524.    * to call this.
  525.    *
  526.    * The application menu is a single menu containing items that typically
  527.    * impact the application as a whole, rather than acting on a specific
  528.    * window or document.  For example, you would expect to see
  529.    * “Preferences” or “Quit” in an application menu, but not “Save” or
  530.    * “Print”.
  531.    *
  532.    * If supported, the application menu will be rendered by the desktop
  533.    * environment.
  534.    *
  535.    * Use the base ActionMap interface to add actions, to respond to the user
  536.    * selecting these menu items.
  537.    *
  538.    * @newin{3,4}
  539.    *
  540.    * @param app_menu A MenuModel, or <tt>nullptr</tt>.
  541.    */
  542.   void set_app_menu(const Glib::RefPtr<Gio::MenuModel>& app_menu);
  543.  
  544.  
  545.   /** Returns the menu model that has been set with
  546.    * set_menubar().
  547.    *
  548.    * @newin{3,4}
  549.    *
  550.    * @return The menubar for windows of @a application.
  551.    */
  552.   Glib::RefPtr<Gio::MenuModel> get_menubar();
  553.  
  554.   /** Returns the menu model that has been set with
  555.    * set_menubar().
  556.    *
  557.    * @newin{3,4}
  558.    *
  559.    * @return The menubar for windows of @a application.
  560.    */
  561.   Glib::RefPtr<const Gio::MenuModel> get_menubar() const;
  562.  
  563.  
  564.   /** Sets or unsets the menubar for windows of @a application.
  565.    *
  566.    * This is a menubar in the traditional sense.
  567.    *
  568.    * This can only be done in the primary instance of the application,
  569.    * after it has been registered.  Application::signal_startup() is a good place
  570.    * to call this.
  571.    *
  572.    * Depending on the desktop environment, this may appear at the top of
  573.    * each window, or at the top of the screen.  In some environments, if
  574.    * both the application menu and the menubar are set, the application
  575.    * menu will be presented as if it were the first item of the menubar.
  576.    * Other environments treat the two as completely separate — for example,
  577.    * the application menu may be rendered by the desktop shell while the
  578.    * menubar (if set) remains in each individual window.
  579.    *
  580.    * Use the base ActionMap interface to add actions, to respond to the
  581.    * user selecting these menu items.
  582.    *
  583.    * @newin{3,4}
  584.    *
  585.    * @param menubar A MenuModel, or <tt>nullptr</tt>.
  586.    */
  587.   void set_menubar(const Glib::RefPtr<Gio::MenuModel>& menubar);
  588.  
  589.  
  590. #ifndef GTKMM_DISABLE_DEPRECATED
  591.  
  592.   /** Installs an accelerator that will cause the named action
  593.    * to be activated when the key combination specificed by @a accelerator
  594.    * is pressed.
  595.    *
  596.    *  @a accelerator must be a string that can be parsed by gtk_accelerator_parse(),
  597.    * e.g. "<Primary>q" or “<Control><Alt>p”.
  598.    *
  599.    *  @a action_name must be the name of an action as it would be used
  600.    * in the app menu, i.e. actions that have been added to the application
  601.    * are referred to with an “app.” prefix, and window-specific actions
  602.    * with a “win.” prefix.
  603.    *
  604.    * GtkApplication also extracts accelerators out of “accel” attributes
  605.    * in the MenuModels passed to set_app_menu() and
  606.    * set_menubar(), which is usually more convenient
  607.    * than calling this function for each accelerator.
  608.    *
  609.    * @newin{3,4}
  610.    *
  611.    * Deprecated: 3.14: Use set_accels_for_action() instead
  612.    *
  613.    * @deprecated Use set_accels_for_action() instead.
  614.    *
  615.    * @param accelerator Accelerator string.
  616.    * @param action_name The name of the action to activate.
  617.    * @param parameter Parameter to pass when activating the action,
  618.    * or <tt>nullptr</tt> if the action does not accept an activation parameter.
  619.    */
  620.   void add_accelerator(const Glib::ustring& accelerator, const Glib::ustring& action_name, GVariant* parameter);
  621. #endif // GTKMM_DISABLE_DEPRECATED
  622.  
  623.  
  624. #ifndef GTKMM_DISABLE_DEPRECATED
  625.  
  626.  
  627.   /// A add_accelerator() convenience overload.
  628.   void add_accelerator(const Glib::ustring& accelerator, const Glib::ustring& action_name);
  629. #endif // GTKMM_DISABLE_DEPRECATED
  630.  
  631.  
  632. #ifndef GTKMM_DISABLE_DEPRECATED
  633.  
  634.   /** Removes an accelerator that has been previously added
  635.    * with add_accelerator().
  636.    *
  637.    * @newin{3,4}
  638.    *
  639.    * Deprecated: 3.14: Use set_accels_for_action() instead
  640.    *
  641.    * @deprecated Use set_accels_for_action() or unset_accels_for_action() instead.
  642.    *
  643.    * @param action_name The name of the action to activate.
  644.    * @param parameter Parameter to pass when activating the action,
  645.    * or <tt>nullptr</tt> if the action does not accept an activation parameter.
  646.    */
  647.   void remove_accelerator(const Glib::ustring& action_name, GVariant* parameter);
  648. #endif // GTKMM_DISABLE_DEPRECATED
  649.  
  650.  
  651. #ifndef GTKMM_DISABLE_DEPRECATED
  652.  
  653.  
  654.   /// A remove_accelerator() convenience overload.
  655.   void remove_accelerator(const Glib::ustring& action_name);
  656. #endif // GTKMM_DISABLE_DEPRECATED
  657.  
  658.  
  659.   /** Inform the session manager that certain types of actions should be
  660.    * inhibited. This is not guaranteed to work on all platforms and for
  661.    * all types of actions.
  662.    *
  663.    * Applications should invoke this method when they begin an operation
  664.    * that should not be interrupted, such as creating a CD or DVD. The
  665.    * types of actions that may be blocked are specified by the @a flags
  666.    * parameter. When the application completes the operation it should
  667.    * call uninhibit() to remove the inhibitor. Note that
  668.    * an application can have multiple inhibitors, and all of them must
  669.    * be individually removed. Inhibitors are also cleared when the
  670.    * application exits.
  671.    *
  672.    * Applications should not expect that they will always be able to block
  673.    * the action. In most cases, users will be given the option to force
  674.    * the action to take place.
  675.    *
  676.    * Reasons should be short and to the point.
  677.    *
  678.    * If @a window is given, the session manager may point the user to
  679.    * this window to find out more about why the action is inhibited.
  680.    *
  681.    * @newin{3,4}
  682.    *
  683.    * @param window A Gtk::Window, or <tt>nullptr</tt>.
  684.    * @param flags What types of actions should be inhibited.
  685.    * @param reason A short, human-readable string that explains
  686.    * why these operations are inhibited.
  687.    * @return A non-zero cookie that is used to uniquely identify this
  688.    * request. It should be used as an argument to uninhibit()
  689.    * in order to remove the request. If the platform does not support
  690.    * inhibiting or the request failed for some reason, 0 is returned.
  691.    */
  692.   guint inhibit(Window& window, ApplicationInhibitFlags flags, const Glib::ustring& reason);
  693.  
  694.   /** Removes an inhibitor that has been established with inhibit().
  695.    * Inhibitors are also cleared when the application exits.
  696.    *
  697.    * @newin{3,4}
  698.    *
  699.    * @param cookie A cookie that was returned by inhibit().
  700.    */
  701.   void uninhibit(guint cookie);
  702.  
  703.   /** Determines if any of the actions specified in @a flags are
  704.    * currently inhibited (possibly by another application).
  705.    *
  706.    * @newin{3,4}
  707.    *
  708.    * @param flags What types of actions should be queried.
  709.    * @return <tt>true</tt> if any of the actions specified in @a flags are inhibited.
  710.    */
  711.   bool is_inhibited(ApplicationInhibitFlags flags) const;
  712.  
  713.  
  714.   /** Returns the Gtk::ApplicationWindow with the given ID.
  715.    *
  716.    * The ID of a Gtk::ApplicationWindow can be retrieved with
  717.    * Gtk::ApplicationWindow::get_id().
  718.    *
  719.    * @newin{3,6}
  720.    *
  721.    * @param id An identifier number.
  722.    * @return The window with ID @a id, or
  723.    * <tt>nullptr</tt> if there is no window with this ID.
  724.    */
  725.   Window* get_window_by_id(guint id);
  726.  
  727.   /** Returns the Gtk::ApplicationWindow with the given ID.
  728.    *
  729.    * The ID of a Gtk::ApplicationWindow can be retrieved with
  730.    * Gtk::ApplicationWindow::get_id().
  731.    *
  732.    * @newin{3,6}
  733.    *
  734.    * @param id An identifier number.
  735.    * @return The window with ID @a id, or
  736.    * <tt>nullptr</tt> if there is no window with this ID.
  737.    */
  738.   const Window* get_window_by_id(guint id) const;
  739.  
  740.  
  741.   /** Gets the “active” window for the application.
  742.    *
  743.    * The active window is the one that was most recently focused (within
  744.    * the application).  This window may not have the focus at the moment
  745.    * if another application has it — this is just the most
  746.    * recently-focused window within this application.
  747.    *
  748.    * @newin{3,6}
  749.    *
  750.    * @return The active window.
  751.    */
  752.   Window* get_active_window();
  753.  
  754.   /** Gets the “active” window for the application.
  755.    *
  756.    * The active window is the one that was most recently focused (within
  757.    * the application).  This window may not have the focus at the moment
  758.    * if another application has it — this is just the most
  759.    * recently-focused window within this application.
  760.    *
  761.    * @newin{3,6}
  762.    *
  763.    * @return The active window.
  764.    */
  765.   const Window* get_active_window() const;
  766.  
  767.  
  768.   /** Lists the detailed action names which have associated accelerators.
  769.    * See set_accels_for_action().
  770.    *
  771.    * @newin{3,12}
  772.    *
  773.    * @return A <tt>nullptr</tt>-terminated array of strings.
  774.    */
  775.   std::vector<Glib::ustring> list_action_descriptions() const;
  776.  
  777.  
  778.   /** Gets the accelerators that are currently associated with
  779.    * the given action.
  780.    *
  781.    * @newin{3,12}
  782.    *
  783.    * @param detailed_action_name A detailed action name, specifying an action
  784.    * and target to obtain accelerators for.
  785.    * @return Accelerators for @a detailed_action_name, as
  786.    * a <tt>nullptr</tt>-terminated array.
  787.    */
  788.   std::vector<Glib::ustring> get_accels_for_action(const Glib::ustring& detailed_action_name) const;
  789.  
  790.  
  791.   /** Returns the list of actions (possibly empty) that @a accel maps to.
  792.    * Each item in the list is a detailed action name in the usual form.
  793.    *
  794.    * This might be useful to discover if an accel already exists in
  795.    * order to prevent installation of a conflicting accelerator (from
  796.    * an accelerator editor or a plugin system, for example). Note that
  797.    * having more than one action per accelerator may not be a bad thing
  798.    * and might make sense in cases where the actions never appear in the
  799.    * same context.
  800.    *
  801.    * In case there are no actions for a given accelerator, an empty array
  802.    * is returned.  <tt>nullptr</tt> is never returned.
  803.    *
  804.    * It is a programmer error to pass an invalid accelerator string.
  805.    * If you are unsure, check it with gtk_accelerator_parse() first.
  806.    *
  807.    * @newin{3,14}
  808.    *
  809.    * @param accel An accelerator that can be parsed by gtk_accelerator_parse().
  810.    * @return A <tt>nullptr</tt>-terminated array of actions for @a accel.
  811.    */
  812.   std::vector<Glib::ustring> get_actions_for_accel(const Glib::ustring& accel) const;
  813.  
  814.  
  815.   /** Sets zero or more keyboard accelerators that will trigger the
  816.    * given action. The first item in @a accels will be the primary
  817.    * accelerator, which may be displayed in the UI.
  818.    *
  819.    * To remove all accelerators for an action, use an empty, zero-terminated
  820.    * array for @a accels.
  821.    *
  822.    * For the @a detailed_action_name, see Glib::action_parse_detailed_name() and
  823.    * Glib::action_print_detailed_name().
  824.    *
  825.    * @newin{3,12}
  826.    *
  827.    * @param detailed_action_name A detailed action name, specifying an action
  828.    * and target to associate accelerators with.
  829.    * @param accels A list of accelerators in the format
  830.    * understood by gtk_accelerator_parse().
  831.    */
  832.   void set_accels_for_action(const Glib::ustring& detailed_action_name, const std::vector<Glib::ustring>& accels);
  833.  
  834.   /** Sets a keyboard accelerator that will trigger the
  835.    * given action. It will be the primary
  836.    * accelerator, which may be displayed in the UI.
  837.    *
  838.    * See unset_accels_for_action().
  839.    *
  840.    * @param detailed_action_name A detailed action name, specifying an action
  841.    * and target to associate accelerators with.
  842.    * @param accel An accelerator in the format understood by gtk_accelerator_parse().
  843.    *
  844.    * @newin{3,12}
  845.    */
  846.   void set_accel_for_action(const Glib::ustring& detailed_action_name, const Glib::ustring& accel);
  847.  
  848.   /** Unsets a keyboard accelerator that will trigger the
  849.    * given action. See set_accels_for_action() and set_accel_for_action().
  850.    *
  851.    * @param detailed_action_name A detailed action name, specifying an action
  852.    * and target to associate accelerators with.
  853.    *
  854.    * @newin{3,12}
  855.    */
  856.   void unset_accels_for_action(const Glib::ustring& detailed_action_name);
  857.  
  858.  
  859.   /** Determines if the desktop environment in which the application is
  860.    * running would prefer an application menu be shown.
  861.    *
  862.    * If this function returns <tt>true</tt> then the application should call
  863.    * set_app_menu() with the contents of an application
  864.    * menu, which will be shown by the desktop environment.  If it returns
  865.    * <tt>false</tt> then you should consider using an alternate approach, such as
  866.    * a menubar.
  867.    *
  868.    * The value returned by this function is purely advisory and you are
  869.    * free to ignore it.  If you call set_app_menu() even
  870.    * if the desktop environment doesn't support app menus, then a fallback
  871.    * will be provided.
  872.    *
  873.    * Applications are similarly free not to set an app menu even if the
  874.    * desktop environment wants to show one.  In that case, a fallback will
  875.    * also be created by the desktop environment (GNOME, for example, uses
  876.    * a menu with only a "Quit" item in it).
  877.    *
  878.    * The value returned by this function never changes.  Once it returns a
  879.    * particular value, it is guaranteed to always return the same value.
  880.    *
  881.    * You may only call this function after the application has been
  882.    * registered and after the base startup handler has run.  You're most
  883.    * likely to want to use this from your own startup handler.  It may
  884.    * also make sense to consult this function while constructing UI (in
  885.    * activate, open or an action activation handler) in order to determine
  886.    * if you should show a gear menu or not.
  887.    *
  888.    * This function will return <tt>false</tt> on Mac OS and a default app menu
  889.    * will be created automatically with the "usual" contents of that menu
  890.    * typical to most Mac OS applications.  If you call
  891.    * set_app_menu() anyway, then this menu will be
  892.    * replaced with your own.
  893.    *
  894.    * @newin{3,14}
  895.    *
  896.    * @return <tt>true</tt> if you should set an app menu.
  897.    */
  898.   bool prefers_app_menu() const;
  899.  
  900.  
  901.   /** Gets a menu from automatically loaded resources.
  902.    * See [Automatic resources][automatic-resources]
  903.    * for more information.
  904.    *
  905.    * @newin{3,14}
  906.    *
  907.    * @param id The id of the menu to look up.
  908.    * @return Gets the menu with the
  909.    * given id from the automatically loaded resources.
  910.    */
  911.   Glib::RefPtr<Gio::Menu> get_menu_by_id(const Glib::ustring& id);
  912.  
  913.   /** Gets a menu from automatically loaded resources.
  914.    * See [Automatic resources][automatic-resources]
  915.    * for more information.
  916.    *
  917.    * @newin{3,14}
  918.    *
  919.    * @param id The id of the menu to look up.
  920.    * @return Gets the menu with the
  921.    * given id from the automatically loaded resources.
  922.    */
  923.   Glib::RefPtr<const Gio::Menu> get_menu_by_id(const Glib::ustring& id) const;
  924.  
  925.   /** The GMenuModel for the application menu.
  926.    *
  927.    * @return A PropertyProxy that allows you to get or set the value of the property,
  928.    * or receive notification when the value of the property changes.
  929.    */
  930.   Glib::PropertyProxy< Glib::RefPtr<Gio::MenuModel> > property_app_menu() ;
  931.  
  932. /** The GMenuModel for the application menu.
  933.    *
  934.    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
  935.    * or receive notification when the value of the property changes.
  936.    */
  937.   Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gio::MenuModel> > property_app_menu() const;
  938.  
  939.   /** The GMenuModel for the menubar.
  940.    *
  941.    * @return A PropertyProxy that allows you to get or set the value of the property,
  942.    * or receive notification when the value of the property changes.
  943.    */
  944.   Glib::PropertyProxy< Glib::RefPtr<Gio::MenuModel> > property_menubar() ;
  945.  
  946. /** The GMenuModel for the menubar.
  947.    *
  948.    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
  949.    * or receive notification when the value of the property changes.
  950.    */
  951.   Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Gio::MenuModel> > property_menubar() const;
  952.  
  953.   /** Set this property to <tt>true</tt> to register with the session manager.
  954.    *
  955.    * @newin{3,4}
  956.    *
  957.    * @return A PropertyProxy that allows you to get or set the value of the property,
  958.    * or receive notification when the value of the property changes.
  959.    */
  960.   Glib::PropertyProxy< bool > property_register_session() ;
  961.  
  962. /** Set this property to <tt>true</tt> to register with the session manager.
  963.    *
  964.    * @newin{3,4}
  965.    *
  966.    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
  967.    * or receive notification when the value of the property changes.
  968.    */
  969.   Glib::PropertyProxy_ReadOnly< bool > property_register_session() const;
  970.  
  971.   /** The window which most recently had focus.
  972.    *
  973.    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
  974.    * or receive notification when the value of the property changes.
  975.    */
  976.   Glib::PropertyProxy_ReadOnly< Window* > property_active_window() const;
  977.  
  978.  
  979.   /**
  980.    * @par Slot Prototype:
  981.    * <tt>void on_my_%window_added(Window* window)</tt>
  982.    *
  983.    * Flags: Run First
  984.    *
  985.    * Emitted when a Gtk::Window is added to @a application through
  986.    * Gtk::Application::add_window().
  987.    *
  988.    * @newin{3,2}
  989.    *
  990.    * @param window The newly-added Gtk::Window.
  991.    */
  992.  
  993.   Glib::SignalProxy< void,Window* > signal_window_added();
  994.  
  995.  
  996.   /**
  997.    * @par Slot Prototype:
  998.    * <tt>void on_my_%window_removed(Window* window)</tt>
  999.    *
  1000.    * Flags: Run First
  1001.    *
  1002.    * Emitted when a Gtk::Window is removed from @a application,
  1003.    * either as a side-effect of being destroyed or explicitly
  1004.    * through Gtk::Application::remove_window().
  1005.    *
  1006.    * @newin{3,2}
  1007.    *
  1008.    * @param window The Gtk::Window that is being removed.
  1009.    */
  1010.  
  1011.   Glib::SignalProxy< void,Window* > signal_window_removed();
  1012.  
  1013.  
  1014. private:
  1015.   /** This is just a way to call Glib::init() (which calls g_type_init()) before
  1016.    * calling application_class_.init(), so that
  1017.    * gtk_application_get_type() will always succeed.
  1018.    * See https://bugzilla.gnome.org/show_bug.cgi?id=639925
  1019.    */
  1020.   const Glib::Class& custom_class_init();
  1021.  
  1022.   void on_activate_add_and_show_main_window(Window* window);
  1023.   void on_window_hide(Window* window);
  1024.  
  1025.   //We need these to call g_application_run(),
  1026.   //even if we have already called gtk_init().
  1027.   int m_argc;
  1028.   char** m_argv;
  1029.  
  1030.  
  1031. public:
  1032.  
  1033. public:
  1034.   //C++ methods used to invoke GTK+ virtual functions:
  1035.  
  1036. protected:
  1037.   //GTK+ Virtual Functions (override these to change behaviour):
  1038.  
  1039.   //Default Signal Handlers::
  1040.   /// This is a default handler for the signal signal_window_added().
  1041.   virtual void on_window_added(Window* window);
  1042.   /// This is a default handler for the signal signal_window_removed().
  1043.   virtual void on_window_removed(Window* window);
  1044.  
  1045.  
  1046. };
  1047.  
  1048. } // namespace Gtk
  1049.  
  1050.  
  1051. namespace Glib
  1052. {
  1053.   /** A Glib::wrap() method for this object.
  1054.    *
  1055.    * @param object The C instance.
  1056.    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
  1057.    * @result A C++ instance that wraps this C instance.
  1058.    *
  1059.    * @relates Gtk::Application
  1060.    */
  1061.   Glib::RefPtr<Gtk::Application> wrap(GtkApplication* object, bool take_copy = false);
  1062. }
  1063.  
  1064.  
  1065. #endif /* _GTKMM_APPLICATION_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement