[gtkmm] Use Glib::wrap() instead of ->gobj().



commit 20881bf8b67742239c9082696a5108db7a6f5d4d
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Feb 1 10:43:24 2010 +0100

    Use Glib::wrap() instead of ->gobj().
    
    * gdk/src/*.ccg:
    * gtk/src/*.ccg: Use Glib::wrap() instead of ->gobj() in some places,
    so we are generally more forgiving of null RefPtrs<>, particular in case we
    have forgotten to wrap may-be-null parameters as extra method overrides.

 ChangeLog                 |    9 +++++++++
 gdk/src/color.ccg         |    2 +-
 gdk/src/colormap.ccg      |    2 +-
 gdk/src/cursor.ccg        |    8 ++++----
 gdk/src/event.ccg         |    2 +-
 gdk/src/gc.ccg            |    2 +-
 gdk/src/pixmap.ccg        |    2 +-
 gdk/src/window.ccg        |    2 +-
 gtk/src/actiongroup.ccg   |    2 +-
 gtk/src/cellview.ccg      |    2 +-
 gtk/src/iconfactory.ccg   |    2 +-
 gtk/src/iconinfo.ccg      |    2 +-
 gtk/src/iconset.ccg       |    2 +-
 gtk/src/menushell.ccg     |    2 +-
 gtk/src/printoperation.hg |    2 +-
 gtk/src/rc.ccg            |    8 ++++----
 gtk/src/recentinfo.ccg    |    2 +-
 gtk/src/tooltip.ccg       |    2 +-
 gtk/src/treeiter.ccg      |   12 ++++++------
 19 files changed, 38 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 33ffc8a..23c7d9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-01-31  Murray Cumming  <murrayc murrayc com>
+
+  Use Glib::wrap() instead of ->gobj().
+  
+	* gdk/src/*.ccg:
+	* gtk/src/*.ccg: Use Glib::wrap() instead of ->gobj() in some places, 
+	so we are generally more forgiving of null RefPtrs<>, particular in case we 
+	have forgotten to wrap may-be-null parameters as extra method overrides.
+
 2010-01-28  Murray Cumming  <murrayc murrayc com>
 
 	Action: Undeprecate some methods.
diff --git a/gdk/src/color.ccg b/gdk/src/color.ccg
index 0a766d0..1632291 100644
--- a/gdk/src/color.ccg
+++ b/gdk/src/color.ccg
@@ -184,7 +184,7 @@ void Color::set_blue(gushort value)
 
 void Color::rgb_find_color(const Glib::RefPtr<Gdk::Colormap>& map)
 {
-  gdk_rgb_find_color(map->gobj(), gobj());
+  gdk_rgb_find_color(Glib::unwrap(map), gobj());
 }
 
 guint Color::get_pixel() const
diff --git a/gdk/src/colormap.ccg b/gdk/src/colormap.ccg
index d2b3aea..2427068 100644
--- a/gdk/src/colormap.ccg
+++ b/gdk/src/colormap.ccg
@@ -26,7 +26,7 @@ namespace Gdk
 {
 
 Colormap::Colormap(const Glib::RefPtr<Visual>& visual, bool allocate)
-: Glib::Object( G_OBJECT( gdk_colormap_new(visual->gobj(), (gboolean)allocate) ) )
+: Glib::Object( G_OBJECT( gdk_colormap_new(Glib::unwrap(visual), (gboolean)allocate) ) )
   {}
 
 _DEPRECATE_IFDEF_START
diff --git a/gdk/src/cursor.ccg b/gdk/src/cursor.ccg
index 0faebb6..e3150da 100644
--- a/gdk/src/cursor.ccg
+++ b/gdk/src/cursor.ccg
@@ -34,7 +34,7 @@ Cursor::Cursor(const Glib::RefPtr<Pixmap>& source, const Glib::RefPtr<Pixmap>& m
 				       const Color& fg, const Color& bg,
 				       int x, int y)
 {
-  gobject_ = gdk_cursor_new_from_pixmap(source->gobj(), mask->gobj(), 
+  gobject_ = gdk_cursor_new_from_pixmap(Glib::unwrap(source), mask->gobj(), 
                                         const_cast<GdkColor*>(fg.gobj()),
 				        const_cast<GdkColor*>(bg.gobj()),
                                         x, y);
@@ -42,17 +42,17 @@ Cursor::Cursor(const Glib::RefPtr<Pixmap>& source, const Glib::RefPtr<Pixmap>& m
 
 Cursor::Cursor(const Glib::RefPtr<Display>& display, CursorType cursor_type)
 {
-  gobject_ = gdk_cursor_new_for_display(display->gobj(), (GdkCursorType)cursor_type);
+  gobject_ = gdk_cursor_new_for_display(Glib::unwrap(display), (GdkCursorType)cursor_type);
 }
 
 Cursor::Cursor(const Glib::RefPtr<Display>& display, const Glib::RefPtr<Pixbuf>& pixbuf, int x, int y)
 {
-  gobject_ = gdk_cursor_new_from_pixbuf(display->gobj(), pixbuf->gobj(), x, y);
+  gobject_ = gdk_cursor_new_from_pixbuf(Glib::unwrap(display), pixbuf->gobj(), x, y);
 }
 
 Cursor::Cursor(const Glib::RefPtr<Display>& display, const Glib::ustring& name)
 {
-  gobject_ = gdk_cursor_new_from_name(display->gobj(), name.c_str());
+  gobject_ = gdk_cursor_new_from_name(Glib::unwrap(display), name.c_str());
 }      
 
 } //namespace Gdk
diff --git a/gdk/src/event.ccg b/gdk/src/event.ccg
index 0e3bf90..e04bf36 100644
--- a/gdk/src/event.ccg
+++ b/gdk/src/event.ccg
@@ -27,7 +27,7 @@ namespace Gdk
 
 bool Event::send_client_message(const Glib::RefPtr<Display>& display, NativeWindow winid)
 {
-  return gdk_event_send_client_message_for_display(display->gobj(), gobj(), winid);
+  return gdk_event_send_client_message_for_display(Glib::unwrap(display), gobj(), winid);
 }
 
 } //namespace Gdk
diff --git a/gdk/src/gc.ccg b/gdk/src/gc.ccg
index 478ccba..7c4a5ae 100644
--- a/gdk/src/gc.ccg
+++ b/gdk/src/gc.ccg
@@ -31,7 +31,7 @@ namespace Gdk
 {
 
 GC::GC(const Glib::RefPtr<Drawable>& drawable)
-: Object( G_OBJECT( gdk_gc_new(drawable->gobj()) ) )
+: Object( G_OBJECT( gdk_gc_new(Glib::unwrap(drawable)) ) )
 {
   //We need a construct function if we really want to use our own GClass. Bug #86867
 }
diff --git a/gdk/src/pixmap.ccg b/gdk/src/pixmap.ccg
index bfa7bb8..13d3c97 100644
--- a/gdk/src/pixmap.ccg
+++ b/gdk/src/pixmap.ccg
@@ -65,7 +65,7 @@ Pixmap::Pixmap(const Glib::RefPtr<Drawable>& drawable, const char* data, int wid
 
 Pixmap::Pixmap(const Glib::RefPtr<Display>& display, NativeWindow anid)
 :
-  Drawable( (GdkDrawable*) gdk_pixmap_foreign_new_for_display(display->gobj(), anid) )
+  Drawable( (GdkDrawable*) gdk_pixmap_foreign_new_for_display(Glib::unwrap(display), anid) )
 {
   //gdk_pixmap_new() is implemented differently for x11, win32, etc,
   //so we can't really derived a new GType for GdkPixmap.
diff --git a/gdk/src/window.ccg b/gdk/src/window.ccg
index c048e9a..0170653 100644
--- a/gdk/src/window.ccg
+++ b/gdk/src/window.ccg
@@ -29,7 +29,7 @@ namespace Gdk
 
 Window::Window(const Glib::RefPtr<Window>& parent, GdkWindowAttr* attributes, int attributes_mask)
 :
-  Drawable((GdkDrawable*) gdk_window_new(parent->gobj(), attributes, attributes_mask))
+  Drawable((GdkDrawable*) gdk_window_new(Glib::unwrap(parent), attributes, attributes_mask))
 {
   //GdkWindow is X11/win32-specific, so we probably can't derived our own GType.
 }
diff --git a/gtk/src/actiongroup.ccg b/gtk/src/actiongroup.ccg
index fe2cdcb..23af142 100644
--- a/gtk/src/actiongroup.ccg
+++ b/gtk/src/actiongroup.ccg
@@ -50,7 +50,7 @@ void ActionGroup::add(const Glib::RefPtr<Action>& action, const AccelKey& accel_
       //Copied from the gtk_action_group_add_action_with_accel() implementation:
 
       gchar* action_name = 0;
-      g_object_get(G_OBJECT(action->gobj()), "name", &action_name, static_cast<char*>(0));
+      g_object_get(G_OBJECT(Glib::unwrap(action)), "name", &action_name, static_cast<char*>(0));
       if(action_name)
       {
         accel_path =  "<Actions>/" + get_name() + '/' + action_name;
diff --git a/gtk/src/cellview.ccg b/gtk/src/cellview.ccg
index dd5aba4..0bc6091 100644
--- a/gtk/src/cellview.ccg
+++ b/gtk/src/cellview.ccg
@@ -62,7 +62,7 @@ CellView::CellView(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
   #ifdef GLIBMM_PROPERTIES_ENABLED
   cell->property_pixbuf() = pixbuf;
   #else
-  cell->set_property("pixbuf", (void*)(pixbuf->gobj()));
+  cell->set_property("pixbuf", (void*)Glib::unwrap(pixbuf));
   #endif
 
   pack_start(*cell);
diff --git a/gtk/src/iconfactory.ccg b/gtk/src/iconfactory.ccg
index 1df0ce8..8406cfb 100644
--- a/gtk/src/iconfactory.ccg
+++ b/gtk/src/iconfactory.ccg
@@ -35,7 +35,7 @@ bool IconSize::lookup(IconSize size, int& width, int& height)
 // static
 bool IconSize::lookup(IconSize size, int& width, int& height, const Glib::RefPtr<Gtk::Settings>& settings)
 {
-  return gtk_icon_size_lookup_for_settings(settings->gobj(), (GtkIconSize) int(size), &width, &height);
+  return gtk_icon_size_lookup_for_settings(Glib::unwrap(settings), (GtkIconSize) int(size), &width, &height);
 }
 
 
diff --git a/gtk/src/iconinfo.ccg b/gtk/src/iconinfo.ccg
index 762967b..e89352c 100644
--- a/gtk/src/iconinfo.ccg
+++ b/gtk/src/iconinfo.ccg
@@ -22,7 +22,7 @@ namespace Gtk
 {
 
 IconInfo::IconInfo(const Glib::RefPtr<IconTheme>& icon_theme, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
-: gobject_( gtk_icon_info_new_for_pixbuf(icon_theme->gobj(), pixbuf->gobj()) )
+: gobject_( gtk_icon_info_new_for_pixbuf(Glib::unwrap(icon_theme), pixbuf->gobj()) )
 {
 }
 
diff --git a/gtk/src/iconset.ccg b/gtk/src/iconset.ccg
index 52db3e1..ad5ee06 100644
--- a/gtk/src/iconset.ccg
+++ b/gtk/src/iconset.ccg
@@ -29,7 +29,7 @@ namespace Gtk
 
 IconSet::IconSet(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
 {
-  gobject_ = gtk_icon_set_new_from_pixbuf(pixbuf->gobj());
+  gobject_ = gtk_icon_set_new_from_pixbuf(Glib::unwrap(pixbuf));
 }
 
 Glib::ArrayHandle<IconSize> IconSet::get_sizes() const
diff --git a/gtk/src/menushell.ccg b/gtk/src/menushell.ccg
index 1f993f9..00760bc 100644
--- a/gtk/src/menushell.ccg
+++ b/gtk/src/menushell.ccg
@@ -160,7 +160,7 @@ void MenuList::remove(Widget& widget)
     if(pAccelLabel) //If the child is an AccelLabel.
     {
       //The unset_accel_widget() method is not implemented in gtkmm until 2.4:
-      gtk_accel_label_set_accel_widget(pAccelLabel->gobj(), 0);
+      gtk_accel_label_set_accel_widget(Glib::unwrap(pAccelLabel), 0);
     }
   }
 
diff --git a/gtk/src/printoperation.hg b/gtk/src/printoperation.hg
index c1d9189..00606ba 100644
--- a/gtk/src/printoperation.hg
+++ b/gtk/src/printoperation.hg
@@ -140,7 +140,7 @@ public:
   _WRAP_SIGNAL(void custom_widget_apply(Widget* widget), "custom_widget_apply")
 
   #m4 _CONVERSION(`GtkPrintOperationPreview*', `const Glib::RefPtr<PrintOperationPreview>&', `Glib::wrap($3, true)')
-  #m4 _CONVERSION(`const Glib::RefPtr<PrintOperationPreview>&', `GtkPrintOperationPreview*', `($3)->gobj()')
+  #m4 _CONVERSION(`const Glib::RefPtr<PrintOperationPreview>&', `GtkPrintOperationPreview*', `(Glib::unwrap($3))')
 
   #m4 _CONVERSION(`Window*',`GtkWindow*',`Glib::unwrap($3)')
 
diff --git a/gtk/src/rc.ccg b/gtk/src/rc.ccg
index afe2cfb..3fa1215 100644
--- a/gtk/src/rc.ccg
+++ b/gtk/src/rc.ccg
@@ -132,26 +132,26 @@ bool RC::reparse_all()
 
 bool RC::reparse_all(const Glib::RefPtr<Settings>& settings, bool force_load)
 {
-  return gtk_rc_reparse_all_for_settings(settings->gobj(), force_load);
+  return gtk_rc_reparse_all_for_settings(Glib::unwrap(settings), force_load);
 }
 
 void RC::reset_styles(const Glib::RefPtr<Settings>& settings)
 {
-  gtk_rc_reset_styles(settings->gobj());        
+  gtk_rc_reset_styles(Glib::unwrap(settings));        
 }
 
 Glib::ustring
 RC::find_pixmap_in_path(const Glib::RefPtr<Settings>& context, GScanner *scanner, const Glib::ustring& pixmap_file)
 {
   return Glib::convert_return_gchar_ptr_to_ustring(
-      gtk_rc_find_pixmap_in_path(context->gobj(), scanner, const_cast<char*>(pixmap_file.c_str())));
+      gtk_rc_find_pixmap_in_path(Glib::unwrap(context), scanner, const_cast<char*>(pixmap_file.c_str())));
 }
 
 Glib::ustring
 RC::find_pixmap_in_path(const Glib::RefPtr<Settings>& context, const Glib::ustring& pixmap_file)
 {
   return Glib::convert_return_gchar_ptr_to_ustring(
-      gtk_rc_find_pixmap_in_path(context->gobj(), 0 /* see C docs */, const_cast<char*>(pixmap_file.c_str())));
+      gtk_rc_find_pixmap_in_path(Glib::unwrap(context), 0 /* see C docs */, const_cast<char*>(pixmap_file.c_str())));
 }
 
 Glib::ustring
diff --git a/gtk/src/recentinfo.ccg b/gtk/src/recentinfo.ccg
index a536c6f..cae9dc3 100644
--- a/gtk/src/recentinfo.ccg
+++ b/gtk/src/recentinfo.ccg
@@ -74,7 +74,7 @@ GType Value<RefPtr<Gtk::RecentInfo> >::value_type()
 
 void Value<RefPtr<Gtk::RecentInfo> >::set(const CppType& data)
 {
-  set_boxed(data->gobj());
+  set_boxed(Glib::unwrap(data));
 }
 
 Value<RefPtr<Gtk::RecentInfo> >::CppType Value<RefPtr<Gtk::RecentInfo> >::get() const
diff --git a/gtk/src/tooltip.ccg b/gtk/src/tooltip.ccg
index 2b28fd1..c532b67 100644
--- a/gtk/src/tooltip.ccg
+++ b/gtk/src/tooltip.ccg
@@ -24,7 +24,7 @@ namespace Gtk
 
 void Tooltip::trigger_tooltip_query(const Glib::RefPtr<Gdk::Display>& display)
 {
-  gtk_tooltip_trigger_tooltip_query(display->gobj());
+  gtk_tooltip_trigger_tooltip_query(Glib::unwrap(display));
 }
 
 } // namespace Gtk
diff --git a/gtk/src/treeiter.ccg b/gtk/src/treeiter.ccg
index c90bc0e..7f4685b 100644
--- a/gtk/src/treeiter.ccg
+++ b/gtk/src/treeiter.ccg
@@ -74,7 +74,7 @@ TreeIter& TreeIter::operator++()
   if(!gtk_tree_model_iter_next(model_->gobj(), &gobject_))
   {
     is_end_ = true;
-    gtk_tree_model_iter_parent(model_->gobj(), &gobject_, &previous);
+    gtk_tree_model_iter_parent(Glib::unwrap(model_), &gobject_, &previous);
   }
 
   return *this;
@@ -89,7 +89,7 @@ const TreeIter TreeIter::operator++(int)
   if(!gtk_tree_model_iter_next(model_->gobj(), &gobject_))
   {
     is_end_ = true;
-    gtk_tree_model_iter_parent(model_->gobj(), &gobject_, &previous.gobject_);
+    gtk_tree_model_iter_parent(Glib::unwrap(model_), &gobject_, &previous.gobject_);
   }
 
   return previous;
@@ -99,15 +99,15 @@ TreeIter& TreeIter::operator--()
 {
   if(!is_end_)
   {
-    gtkmm_gtk_tree_model_iter_previous(model_->gobj(), &gobject_);
+    gtkmm_gtk_tree_model_iter_previous(Glib::unwrap(model_), &gobject_);
   }
   else // --end yields last
   {
     GtkTreeIter next = gobject_;
     GtkTreeIter *const parent = (next.stamp != 0) ? &next : 0;
 
-    const int index = gtk_tree_model_iter_n_children(model_->gobj(), parent) - 1;
-    is_end_ = !gtk_tree_model_iter_nth_child(model_->gobj(), &gobject_, parent, index);
+    const int index = gtk_tree_model_iter_n_children(Glib::unwrap(model_), parent) - 1;
+    is_end_ = !gtk_tree_model_iter_nth_child(Glib::unwrap(model_), &gobject_, parent, index);
 
     g_assert(!is_end_);
   }
@@ -121,7 +121,7 @@ const TreeIter TreeIter::operator--(int)
 
   if(!is_end_)
   {
-    gtkmm_gtk_tree_model_iter_previous(model_->gobj(), &gobject_);
+    gtkmm_gtk_tree_model_iter_previous(Glib::unwrap(model_), &gobject_);
   }
   else // --end yields last
   {



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