[gtkmm/gtkmm-2-24] Widget::set_window(): Increase the ref count of the Gdk::Window.



commit 7e2a13b000564dc2adb9c07db647401d6e490105
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Jan 13 11:32:37 2011 +0100

    Widget::set_window(): Increase the ref count of the Gdk::Window.
    
      * gdk/src/widget.[hg|ccg]: set_window() increases the ref count of the
      Gdk::Window, since gtk_widget_set_window() does not.
    
      Bug #606903 (Hammered)

 ChangeLog          |    9 +++++++++
 gtk/src/widget.ccg |    7 +++++++
 gtk/src/widget.hg  |   18 +++++++++++++++++-
 3 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0682b62..d0783f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-01-11  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+  Widget::set_window(): Increase the ref count of the Gdk::Window.
+
+  * gdk/src/widget.[hg|ccg]: set_window() increases the ref count of the
+  Gdk::Window, since gtk_widget_set_window() does not.
+  
+  Bug #606903 (Hammered)
+
 2011-01-11  Murray Cumming  <murrayc murrayc-x61>
 
 	Screen: Fix a typo, so the monitors_changed() signal really uses the C signal.
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index 854eba2..be3c14d 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -339,6 +339,13 @@ void Widget::unset_flags(WidgetFlags flags)
 
 _DEPRECATE_IFDEF_END
 
+void Widget::set_window(const Glib::RefPtr<Gdk::Window>& window)
+{
+  gtk_widget_set_window(gobj(), Glib::unwrap(window));
+  if (window)
+    window->reference(); // gtk_widget_set_window does not add a ref.
+}
+
 Allocation Widget::get_allocation() const
 {
   Allocation allocation;
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 756f9e2..2e0afa2 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -261,7 +261,23 @@ public:
   _WRAP_METHOD(void set_child_visible(bool is_visible = true), gtk_widget_set_child_visible)
   _WRAP_METHOD(bool get_child_visible() const, gtk_widget_get_child_visible)
 
-  _WRAP_METHOD(void set_window(const Glib::RefPtr<Gdk::Window>& window), gtk_widget_set_window)
+  /** Sets a widget's window. This function should only be used in a
+   * widget's Gtk::Widget::on_realize() implementation. The %window passed is
+   * usually either a new window created with Gdk::Window::create(), or the
+   * window of its parent widget as returned by get_parent_window().
+   * 
+   * Widgets must indicate whether they will create their own Gdk::Window
+   * by calling set_has_window(). This is usually done in the
+   * widget's constructor.
+   *
+   * This function should only be called by custom widget implementations,
+   * and they should call it in their on_realize() function.
+   * 
+   * @newin{2,18}
+   * @param window A Gdk::Window.
+   */
+  void set_window(const Glib::RefPtr<Gdk::Window>& window);
+  _IGNORE(gtk_widget_set_window)
 
   _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_window(), gtk_widget_get_window, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_window() const, gtk_widget_get_window, refreturn, constversion)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]