| 1 |
/* Copyright (C) 2013 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 |
#include <gtkmm/bin.h> |
| 18 |
#include <giomm/menumodel.h> |
| 19 |
|
| 20 |
_DEFS(gtkmm,gtk) |
| 21 |
_PINCLUDE(gtkmm/private/bin_p.h) |
| 22 |
|
| 23 |
namespace Gtk |
| 24 |
{ |
| 25 |
_WRAP_ENUM(PopoverConstraint, GtkPopoverConstraint, decl_prefix GTKMM_API) |
| 26 |
|
| 27 |
/** Context dependent bubbles. |
| 28 |
* |
| 29 |
* Gtk::Popover is a bubble-like context window, primarily meant to |
| 30 |
* provide context-dependent information or options. Popovers are |
| 31 |
* attached to a widget, passed at construction time on Gtk::Popover(), |
| 32 |
* or updated afterwards through Gtk::Popover::set_relative_to(), by |
| 33 |
* default they will point to the whole widget area, although this |
| 34 |
* behavior can be changed through Gtk::Popover::set_pointing_to(). |
| 35 |
* |
| 36 |
* The position of a popover relative to the widget it is attached to |
| 37 |
* can also be changed through Gtk::Popover::set_position(). |
| 38 |
* |
| 39 |
* By default, Gtk::Popover performs a GTK+ grab, in order to ensure |
| 40 |
* input events get redirected to it while it is shown, and also so |
| 41 |
* the popover is dismissed in the expected situations (clicks outside |
| 42 |
* the popover, or the Esc key being pressed). If no such modal behavior |
| 43 |
* is desired on a popover, Gtk::Popover::set_modal() may be called on it |
| 44 |
* to tweak its behavior. |
| 45 |
* |
| 46 |
* @ingroup Widgets |
| 47 |
* @newin{3,12} |
| 48 |
*/ |
| 49 |
class GTKMM_API Popover |
| 50 |
: public Bin |
| 51 |
{ |
| 52 |
_CLASS_GTKOBJECT(Popover, GtkPopover, GTK_POPOVER, Gtk::Bin, GtkBin, , , GTKMM_API) |
| 53 |
public: |
| 54 |
|
| 55 |
/** Creates a new popover to point to @a relative_to |
| 56 |
* |
| 57 |
* @param relative_to The Gtk::Widget the popover is related to |
| 58 |
*/ |
| 59 |
_WRAP_CTOR(Popover(const Widget& relative_to{?}), gtk_popover_new) |
| 60 |
|
| 61 |
//This is custom-implemented because the gtk_popover_new_from_model() does more |
| 62 |
//than just call g_object_new. MenuBar and Menu have both the same issue. |
| 63 |
//See https://bugzilla.gnome.org/show_bug.cgi?id=704671 |
| 64 |
/** Creates a Popover and populates it according to |
| 65 |
* @a model. The popover is pointed to the @a relative_to widget. |
| 66 |
* |
| 67 |
* The created buttons are connected to actions found in the |
| 68 |
* ApplicationWindow to which the popover belongs - typically |
| 69 |
* by means of being attached to a widget that is contained within |
| 70 |
* the ApplicationWindow widget hierarchy. |
| 71 |
* |
| 72 |
* Actions can also be added using Widget::insert_action_group() |
| 73 |
* on the menu's attached widget or on any of its parent widgets. |
| 74 |
* |
| 75 |
* @param relative_to: Widget the popover is related to |
| 76 |
* @param model: a Gio::MenuModel |
| 77 |
* |
| 78 |
* @newin{3,12} |
| 79 |
*/ |
| 80 |
explicit Popover(const Widget& relative_to, const Glib::RefPtr<Gio::MenuModel>& model); |
| 81 |
|
| 82 |
/** Creates a Popover and populates it according to |
| 83 |
* @a model. |
| 84 |
* |
| 85 |
* The created buttons are connected to actions found in the |
| 86 |
* ApplicationWindow to which the popover belongs - typically |
| 87 |
* by means of being attached to a widget that is contained within |
| 88 |
* the ApplicationWindow widget hierarchy. |
| 89 |
* |
| 90 |
* Actions can also be added using Widget::insert_action_group() |
| 91 |
* on the menu's attached widget or on any of its parent widgets. |
| 92 |
* |
| 93 |
* @param model: a Gio::MenuModel |
| 94 |
* |
| 95 |
* @newin{3,12} |
| 96 |
*/ |
| 97 |
explicit Popover(const Glib::RefPtr<Gio::MenuModel>& model); |
| 98 |
|
| 99 |
_IGNORE(gtk_popover_new_from_model) |
| 100 |
|
| 101 |
|
| 102 |
_WRAP_METHOD(void set_relative_to(const Widget& relative_to), gtk_popover_set_relative_to) |
| 103 |
// transfer none |
| 104 |
_WRAP_METHOD(Widget* get_relative_to(), gtk_popover_get_relative_to) |
| 105 |
_WRAP_METHOD(const Widget* get_relative_to() const, gtk_popover_get_relative_to, constversion) |
| 106 |
|
| 107 |
//This cannot take NULL to mean unset. |
| 108 |
#m4 _CONVERSION(`const GdkRectangle*',`const Gdk::Rectangle&',`Glib::wrap($3)') |
| 109 |
_WRAP_METHOD(void set_pointing_to(const Gdk::Rectangle& rect), gtk_popover_set_pointing_to) |
| 110 |
#m4 _CONVERSION(`GdkRectangle*',`Gdk::Rectangle&',`Glib::wrap($3)') |
| 111 |
_WRAP_METHOD(bool get_pointing_to(Gdk::Rectangle& rect) const, gtk_popover_get_pointing_to) |
| 112 |
|
| 113 |
_WRAP_METHOD(void set_position(PositionType position = POS_TOP), gtk_popover_set_position) |
| 114 |
_WRAP_METHOD(PositionType get_position() const, gtk_popover_get_position) |
| 115 |
|
| 116 |
_WRAP_METHOD(void set_modal(bool modal = true), gtk_popover_set_modal) |
| 117 |
_WRAP_METHOD(bool get_modal() const, gtk_popover_get_modal) |
| 118 |
|
| 119 |
_WRAP_METHOD(void bind_model(const Glib::RefPtr<Gio::MenuModel>& model, const Glib::ustring& action_namespace{?}), gtk_popover_bind_model) |
| 120 |
|
| 121 |
_WRAP_METHOD(void set_transitions_enabled(bool transitions_enabled = true), gtk_popover_set_transitions_enabled, deprecated "You can show or hide the popover without transitions using show() and hide(), or with transitions using popup() and popdown().") |
| 122 |
_WRAP_METHOD(bool get_transitions_enabled() const, gtk_popover_get_transitions_enabled, deprecated "See set_transitions_enabled().") |
| 123 |
|
| 124 |
_WRAP_METHOD(void set_default_widget(Widget& widget), gtk_popover_set_default_widget) |
| 125 |
|
| 126 |
_WRAP_METHOD(Widget* get_default_widget(), gtk_popover_get_default_widget) |
| 127 |
_WRAP_METHOD(const Widget* get_default_widget() const, gtk_popover_get_default_widget, constversion) |
| 128 |
|
| 129 |
_WRAP_METHOD(void set_constrain_to(PopoverConstraint constraint), gtk_popover_set_constrain_to) |
| 130 |
_WRAP_METHOD(PopoverConstraint get_constrain_to() const, gtk_popover_get_constrain_to) |
| 131 |
|
| 132 |
_WRAP_METHOD(void popup(), gtk_popover_popup) |
| 133 |
_WRAP_METHOD(void popdown(), gtk_popover_popdown) |
| 134 |
|
| 135 |
_WRAP_PROPERTY("relative-to", Widget*) |
| 136 |
_WRAP_PROPERTY("pointing-to", Gdk::Rectangle) |
| 137 |
_WRAP_PROPERTY("position", PositionType) |
| 138 |
_WRAP_PROPERTY("modal", bool) |
| 139 |
_WRAP_PROPERTY("transitions-enabled", bool, deprecated "See set_transitions_enabled()") |
| 140 |
_WRAP_PROPERTY("constrain-to", PopoverConstraint) |
| 141 |
|
| 142 |
_WRAP_SIGNAL(void closed(), "closed") |
| 143 |
}; |
| 144 |
|
| 145 |
} // namespace Gtk |