[gtkmm] Gtk::Widget: reparent() takes a Container&
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::Widget: reparent() takes a Container&
- Date: Sun, 13 Nov 2016 14:55:52 +0000 (UTC)
commit 24059c5adf1cc990b5c006eeb2dfd23d4d4ea98f
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sun Nov 13 15:46:17 2016 +0100
Gtk::Widget: reparent() takes a Container&
gtk/src/widget.ccg | 16 ++++++----------
gtk/src/widget.hg | 5 ++---
2 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index b96e44a..a1ff8cb 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -277,20 +277,16 @@ void Widget_Class::measure_vfunc_callback(GtkWidget* self, GtkOrientation orient
Widget::~Widget() noexcept
{}
-void Widget::reparent(Widget& new_parent)
+void Widget::reparent(Container& new_parent)
{
- //TODO: When 'Widget& new_parent' is changed to 'Container& new_parent',
- // remove the next two statements.
- auto new_container = dynamic_cast<Container*>(&new_parent);
- g_return_if_fail(new_container != nullptr); // if new_parent is not a Container
- auto old_container = get_parent();
- g_return_if_fail(old_container != nullptr); // if the widget is not in a Container
-
- if (old_container != new_container)
+ auto old_parent = get_parent();
+ g_return_if_fail(old_parent != nullptr); // if the widget is not in a Container
+
+ if (old_parent != &new_parent)
{
reference();
- old_container->remove(*this);
- new_container->add(*this);
+ old_parent->remove(*this);
+ new_parent.add(*this);
unreference();
}
}
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 3aa1f3c..748c1b8 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -162,14 +162,13 @@ public:
_WRAP_METHOD(bool send_focus_change(GdkEvent* gdk_event), gtk_widget_send_focus_change)
_WRAP_METHOD(bool activate(), gtk_widget_activate)
- //TODO: When we can break ABI/API, change to void reparent(Container& new_parent).
- // gtk_widget_reparent() is deprecated, but we want to keep Gtk::Widget::reparent().
+ // gtk_widget_reparent() has been removed, but we want to keep Gtk::Widget::reparent().
/** Moves a widget from one Gtk::Container to another, handling reference
* count issues to avoid destroying the widget.
*
* @param new_parent A Gtk::Container to move the widget into.
*/
- void reparent(Widget& new_parent);
+ void reparent(Container& new_parent);
bool intersect(const Gdk::Rectangle& area) const;
_WRAP_METHOD(bool intersect(const Gdk::Rectangle& area, Gdk::Rectangle& intersection) const,
gtk_widget_intersect)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]