| 1 |
/* Copyright (C) 2012 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
#include <gtkmm/window.h> |
| 20 |
#include <giomm/actiongroup.h> |
| 21 |
#include <giomm/actionmap.h> |
| 22 |
|
| 23 |
_DEFS(gtkmm,gtk) |
| 24 |
_PINCLUDE(gtkmm/private/window_p.h) |
| 25 |
|
| 26 |
namespace Gtk |
| 27 |
{ |
| 28 |
class GTKMM_API ShortcutsWindow; |
| 29 |
|
| 30 |
/** A Gtk::Window subclass with Gtk::Application support. |
| 31 |
* |
| 32 |
* ApplicationWindow is a Gtk::Window subclass that offers some |
| 33 |
* extra functionality for better integration with Gtk::Application |
| 34 |
* features. Notably, it can handle both the application menu as well |
| 35 |
* as the menubar. See set_app_menu() and |
| 36 |
* set_menubar(). |
| 37 |
* |
| 38 |
* This class derives from Gio::ActionGroup and Gio::ActionMap, |
| 39 |
* to let you add window-specific actions that will be exported by the |
| 40 |
* associated Gtk::Application, together with its application-wide |
| 41 |
* actions. Window-specific actions are prefixed with the "win." |
| 42 |
* prefix and application-wide actions are prefixed with the "app." |
| 43 |
* prefix. Actions must be addressed with the prefixed name when |
| 44 |
* referring to them from a Gio::MenuModel. |
| 45 |
* |
| 46 |
* Note that widgets that are placed inside a Gtk::ApplicationWindow |
| 47 |
* can also activate these actions, if they implement the |
| 48 |
* Gtk::Actionable interface. |
| 49 |
* |
| 50 |
* As with Gtk::Application, the GDK lock will be acquired when |
| 51 |
* processing actions arriving from other processes and should therefore |
| 52 |
* be held when activating actions locally (if GDK threads are enabled). |
| 53 |
* |
| 54 |
* The settings Gtk::Settings::property_gtk_shell_shows_app_menu() and |
| 55 |
* Gtk::Settings::property_gtk_shell_shows_menubar() tell GTK+ whether the |
| 56 |
* desktop environment is showing the application menu and menubar |
| 57 |
* models outside the application as part of the desktop shell. |
| 58 |
* For instance, on OS X, both menus will be displayed remotely; |
| 59 |
* on Windows neither will be. gnome-shell (starting with version 3.4) |
| 60 |
* will display the application menu, but not the menubar. |
| 61 |
* |
| 62 |
* If the desktop environment does not display the menubar, then |
| 63 |
* Gtk::ApplicationWindow will automatically show a Gtk::MenuBar for it. |
| 64 |
* This behaviour can be overridden with the Gtk::ApplicationWindow::property_show_menubar() |
| 65 |
* property. If the desktop environment does not display the application |
| 66 |
* menu, then it will automatically be included in the menubar. |
| 67 |
*/ |
| 68 |
class GTKMM_API ApplicationWindow |
| 69 |
: public Gtk::Window, |
| 70 |
public Gio::ActionGroup, |
| 71 |
public Gio::ActionMap |
| 72 |
{ |
| 73 |
//TODO: At the next ABI-break, remove _NO_WRAP_FUNCTION, and the hand-coded gobj_copy() and wrap(). |
| 74 |
// https://bugzilla.gnome.org/show_bug.cgi?id=767951 |
| 75 |
_CLASS_GTKOBJECT(ApplicationWindow, GtkApplicationWindow, GTK_APPLICATION_WINDOW, Gtk::Window, GtkWindow, , , GTKMM_API) |
| 76 |
_IMPLEMENTS_INTERFACE(Gio::ActionGroup) |
| 77 |
_IMPLEMENTS_INTERFACE(Gio::ActionMap) |
| 78 |
_UNMANAGEABLE |
| 79 |
_NO_WRAP_FUNCTION |
| 80 |
public: |
| 81 |
_CTOR_DEFAULT |
| 82 |
explicit ApplicationWindow(const Glib::RefPtr<Application>& application); |
| 83 |
dnl // Don't ignore gtk_application_window_new(). h2def.py erroneously classifies |
| 84 |
dnl // it as a GtkApplication method, because its first parameter is a GtkApplication*. |
| 85 |
dnl //_IGNORE(gtk_application_window_new) |
| 86 |
|
| 87 |
_DEPRECATE_IFDEF_START |
| 88 |
/** Provides access to the underlying C instance. |
| 89 |
* The caller is responsible for unrefing it. Use when directly setting fields in structs. |
| 90 |
* @deprecated This method should never have been created. |
| 91 |
*/ |
| 92 |
GtkApplicationWindow* gobj_copy(); |
| 93 |
_DEPRECATE_IFDEF_END |
| 94 |
|
| 95 |
_WRAP_METHOD(void set_show_menubar(bool show_menubar = true), gtk_application_window_set_show_menubar) |
| 96 |
_WRAP_METHOD(bool get_show_menubar() const, gtk_application_window_get_show_menubar) |
| 97 |
|
| 98 |
_WRAP_METHOD(guint get_id() const, gtk_application_window_get_id) |
| 99 |
|
| 100 |
_WRAP_METHOD(void set_help_overlay(ShortcutsWindow& help_overlay), gtk_application_window_set_help_overlay) |
| 101 |
/** Undoes the effect of a previous call to set_help_overlay(). |
| 102 |
* @newin{3,20} |
| 103 |
*/ |
| 104 |
void unset_help_overlay(); |
| 105 |
_WRAP_METHOD(ShortcutsWindow* get_help_overlay(), gtk_application_window_get_help_overlay) |
| 106 |
_WRAP_METHOD(const ShortcutsWindow* get_help_overlay() const, gtk_application_window_get_help_overlay, constversion) |
| 107 |
|
| 108 |
_WRAP_PROPERTY("show-menubar", bool) |
| 109 |
}; |
| 110 |
|
| 111 |
} // namespace Gtk |
| 112 |
|
| 113 |
_DEPRECATE_IFDEF_START |
| 114 |
namespace Glib |
| 115 |
{ |
| 116 |
/** A Glib::wrap() method for this object. |
| 117 |
* |
| 118 |
* @note |
| 119 |
* This wrap() function is broken. It will be fixed at the next ABI-break. |
| 120 |
* It should return a Gtk::ApplicationWindow*. A workaround: |
| 121 |
* @code |
| 122 |
* GtkApplicationWindow* gtkappwin = some_func(); |
| 123 |
* Gtk::ApplicationWindow* appwinmm = |
| 124 |
* dynamic_cast<Gtk::ApplicationWindow*>(Glib::wrap((GtkWindow*)gtkappwin, take_copy)); |
| 125 |
* @endcode |
| 126 |
* |
| 127 |
* @deprecated Use the workaround instead. |
| 128 |
* |
| 129 |
* @param object The C instance. |
| 130 |
* @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 131 |
* @result A C++ instance that wraps this C instance. |
| 132 |
* |
| 133 |
* @relates Gtk::ApplicationWindow |
| 134 |
*/ |
| 135 |
GTKMM_API |
| 136 |
Glib::RefPtr<Gtk::ApplicationWindow> wrap(GtkApplicationWindow* object, bool take_copy = false); |
| 137 |
} |
| 138 |
_DEPRECATE_IFDEF_END |