[gtkmm] Resurrect Widget::can_default() and can_focus()



commit bf601e53904ff543309ae597f32a928776b6d3e7
Author: Daniel Elstner <daniel kitta gmail com>
Date:   Sun Oct 4 03:24:05 2009 +0200

    Resurrect Widget::can_default() and can_focus()
    
    * gtk/src/widget.{ccg,hg} (Gtk::Widget::can_default): Wrap using
    _WRAP_METHOD(), thereby reintroducing the accidentally removed
    method implementation.
    (can_focus): Use _WRAP_METHOD() to bring back both the declaration
    and the implementation of this accidentally removed method.
    (get_allocation): Properly implement the accessor in terms of
    gtk_widget_get_allocation().

 ChangeLog          |   12 ++++++++++++
 gtk/src/widget.ccg |   33 +++++++++++++++++----------------
 gtk/src/widget.hg  |   14 ++++++++------
 3 files changed, 37 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 832366c..f224bd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-10-04  Daniel Elstner  <daniel kitta gmail com>
+
+	Resurrect Widget::can_default() and can_focus()
+
+	* gtk/src/widget.{ccg,hg} (Gtk::Widget::can_default): Wrap using
+	_WRAP_METHOD(), thereby reintroducing the accidentally removed
+	method implementation.
+	(can_focus): Use _WRAP_METHOD() to bring back both the declaration
+	and the implementation of this accidentally removed method.
+	(get_allocation): Properly implement the accessor in terms of
+	gtk_widget_get_allocation().
+
 2009-09-22  José Alburquerque  <jaalburqu svn gnome org>
 
 	gtkmm.h: Add infobar.h to list of includes.
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index b03b752..54ab381 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -325,7 +325,9 @@ _DEPRECATE_IFDEF_END
 
 Allocation Widget::get_allocation() const
 {
-  return (Allocation)(Glib::wrap(&(gobj()->allocation)));
+  Allocation allocation;
+  gtk_widget_get_allocation(const_cast<GtkWidget*>(gobj()), allocation.gobj());
+  return allocation;
 }
 
 bool Widget::parent_sensitive() const
@@ -445,7 +447,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
   //if(self)
    //g_warning("  gtypename: %s\n", G_OBJECT_TYPE_NAME(self));
   #endif
-  
+
   Widget *const obj = dynamic_cast<Widget*>(
       Glib::ObjectBase::_get_current_wrapper(self));
 
@@ -454,7 +456,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
   // have to test for cpp_destruction_in_progress_ at this point.
 
   if(obj && !obj->_cpp_destruction_is_in_progress()) //When it should really be destroyed, we zero gobj_.
-  { 
+  {
     GtkWidget *const pWidget = obj->gobj();
     g_return_if_fail(pWidget == GTK_WIDGET(self));
 
@@ -462,9 +464,9 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
     // the nasty self-destroying behaviour of GTK+.  This applies to
     // any widget inside a GtkContainer on gtk_container_destroy()
     // See also Window_Class::dispose_vfunc_callback().
-  
+
     if(obj->referenced_) //Not managed
-    { 
+    {
       // GTKMM_LIFECYCLE
       // Remove the widget from its parent container so that it
       // won't be destroyed later by gtk_container_destroy().
@@ -478,7 +480,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
         #ifdef GLIBMM_DEBUG_REFCOUNTING
         g_warning("Widget_Class::dispose_vfunc_callback(): removing gobject_: %p from parent: %p", (void*)self, (void*)pWidget->parent);
         #endif
-  
+
         gtk_container_remove(GTK_CONTAINER(pWidget->parent), pWidget);
 
         #ifdef GLIBMM_DEBUG_REFCOUNTING
@@ -488,7 +490,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
       // Special case for GtkMenu because gtk_menu_attach_to_widget does
       // not set widget->parent but gtk_menu_item_destroy() destroys the menu
       // like gtk_container_destroy()
-      // Gtk::Menu does not use a parent widget because it must 
+      // Gtk::Menu does not use a parent widget because it must
       // be contained in its Gtk::Window so that it can be displayed as a popup.
       else if (GTK_IS_MENU(pWidget) && GTK_IS_MENU_ITEM(gtk_menu_get_attach_widget(GTK_MENU(pWidget))))
       {
@@ -498,7 +500,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
       #ifdef GLIBMM_DEBUG_REFCOUNTING
       g_warning("Widget_Class::dispose_vfunc_callback(): before gtk_widget_hide().");
       #endif
-        
+
       // Now hide the widget.  The C++ object must _not_ be accessed anymore
       // after this call, because a signal_hide() handler might delete it.
       gtk_widget_hide(pWidget);
@@ -506,7 +508,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
       #ifdef GLIBMM_DEBUG_REFCOUNTING
       g_warning("Widget_Class::dispose_vfunc_callback(): after gtk_widget_hide().");
       #endif
-      
+
       // GTKMM_LIFECYCLE
       return; // Prevent calling of normal C dispose vfunc (see below)
     }
@@ -514,7 +516,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
     #ifdef GLIBMM_DEBUG_REFCOUNTING
     g_warning("Widget_Class::dispose_vfunc_callback(): unreferenced: before gtk_widget_hide().");
     #endif
-    
+
     // Always hide widgets on gtk_object_destroy(), regardless of whether
     // the widget is managed or not.  This is done for consistency so that
     // connecting to signal_hide() is guaranteed to work.
@@ -531,7 +533,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
   #ifdef GLIBMM_DEBUG_REFCOUNTING
   g_warning("Widget_Class::dispose_vfunc_callback(): before calling base->dispose.");
   #endif
-        
+
   if(base->dispose)
     (*base->dispose)(self);
 
@@ -552,12 +554,12 @@ Glib::ustring Widget::drag_dest_find_target(const Glib::RefPtr<Gdk::DragContext>
 }
 
 void Widget::unset_shape_combine_mask()
-{            
+{
   gtk_widget_shape_combine_mask(gobj(), 0, 0, 0); /* See GTK+ docs */
 }
 
 void Widget::unset_input_shape_combine_mask()
-{            
+{
   gtk_widget_input_shape_combine_mask(gobj(), 0, 0, 0); /* See GTK+ docs */
 }
 
@@ -575,9 +577,8 @@ Requisition Widget::size_request() const
 
 Glib::RefPtr<Gdk::Pixmap> Widget::get_snapshot() const
 {
-  return Glib::wrap((GdkPixmapObject*)(gtk_widget_get_snapshot(const_cast<GtkWidget*>(gobj()), NULL)));
+  return Glib::wrap(reinterpret_cast<GdkPixmapObject*>(
+      gtk_widget_get_snapshot(const_cast<GtkWidget*>(gobj()), 0)), false);
 }
 
-
 } // namespace Gtk
-
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 623231e..bbba782 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -191,12 +191,16 @@ public:
 
   _WRAP_METHOD(void set_can_focus(bool can_focus = true), gtk_widget_set_can_focus)
   _WRAP_METHOD(bool get_can_focus() const, gtk_widget_get_can_focus)
+  _WRAP_METHOD(bool can_focus() const, gtk_widget_get_can_focus,
+               deprecated "Replaced by get_can_focus().")
   _WRAP_METHOD(bool has_focus() const, gtk_widget_has_focus)
 
   _WRAP_METHOD(bool is_focus() const, gtk_widget_is_focus)
   _WRAP_METHOD(void grab_focus(), gtk_widget_grab_focus)
   _WRAP_METHOD(void set_can_default(bool can_default = true), gtk_widget_set_can_default)
   _WRAP_METHOD(bool get_can_default() const, gtk_widget_get_can_default)
+  _WRAP_METHOD(bool can_default() const, gtk_widget_get_can_default,
+               deprecated "Replaced by get_can_default().")
   _WRAP_METHOD(bool has_default() const, gtk_widget_has_default)
   _WRAP_METHOD(void grab_default(), gtk_widget_grab_default)
   _WRAP_METHOD(void set_receives_default(bool receives_default = true), gtk_widget_set_receives_default)
@@ -251,11 +255,13 @@ public:
   _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)
 
-  //TODO: Documentation.
+  /** Retrieves the widget's location.
+   * @return The widget's allocated area.
+   */
   Allocation get_allocation() const;
   _IGNORE(gtk_widget_get_allocation)
 
-  #m4  _CONVERSION(`const Allocation&',`const GtkAllocation*',`($3).gobj()')
+#m4 _CONVERSION(`const Allocation&',`const GtkAllocation*',`($3).gobj()')
   _WRAP_METHOD(void set_allocation(const Allocation& allocation), gtk_widget_set_allocation)
 
   _WRAP_METHOD(Container* get_parent(), gtk_widget_get_parent)
@@ -605,10 +611,6 @@ _DEPRECATE_IFDEF_START
    */
   bool sensitive() const;
 
-  /** @deprecated: Use get_can_default() instead.
-   */
-  bool can_default() const;
-
   /** @deprecated: Use get_app_paintable() instead.
    */
   bool app_paintable() const;



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