[gtkmm] Gdk::Cursor: Avoid warnings and failures about reusing existing C instances.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk::Cursor: Avoid warnings and failures about reusing existing C instances.
- Date: Fri, 7 Jan 2011 23:30:38 +0000 (UTC)
commit 55447ff16a7df06b169504b2194aeac8145e4049
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Jan 7 00:57:01 2011 +0100
Gdk::Cursor: Avoid warnings and failures about reusing existing C instances.
* gdk/src/cursor.[hg|ccg]: Remove the constructors, because the
gdk_cursor_new_*() functions really return existing instances instead of
always returning new instances.
* demos/gtk-demo/example_change_display.cc: Use Gdk::Cursor via RefPtr.
ChangeLog | 11 ++++++++++-
demos/gtk-demo/example_change_display.cc | 2 +-
gdk/src/cursor.ccg | 27 ---------------------------
gdk/src/cursor.hg | 21 +++++++++------------
4 files changed, 20 insertions(+), 41 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f702d9a..c523842 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-01-07 Murray Cumming <murrayc murrayc com>
+
+ Gdk::Cursor: Avoid warnings and failures about reusing existing C instances.
+
+ * gdk/src/cursor.[hg|ccg]: Remove the constructors, because the
+ gdk_cursor_new_*() functions really return existing instances instead of
+ always returning new instances.
+ * demos/gtk-demo/example_change_display.cc: Use Gdk::Cursor via RefPtr.
+
2011-01-06 Krzesimir Nowak <qdlacz gmail com>
Wrapped gdk_device_get_history().
@@ -5,7 +14,7 @@
* gdk/src/device.[hg|ccg]: Wrapped gdk_device_get_history().
* gdk/src/timecoord.[hg|ccg]: New files.
* gdk/src/filelist.am: Added new files to build.
-
+
2011-01-06 Murray Cumming <murrayc murrayc com>
Range: Remove get/set_update_policy(), to fix the build.
diff --git a/demos/gtk-demo/example_change_display.cc b/demos/gtk-demo/example_change_display.cc
index 82a99d8..3b3eb87 100644
--- a/demos/gtk-demo/example_change_display.cc
+++ b/demos/gtk-demo/example_change_display.cc
@@ -384,7 +384,7 @@ Gtk::Window* Example_ChangeDisplay::query_for_toplevel(const Glib::RefPtr<Gdk::S
m_pPopup->show();
- Gdk::Cursor cursor(refDisplay, Gdk::CROSSHAIR);
+ Glib::RefPtr<Gdk::Cursor> cursor = Gdk::Cursor::create(refDisplay, Gdk::CROSSHAIR);
Gtk::Window* toplevel = 0;
diff --git a/gdk/src/cursor.ccg b/gdk/src/cursor.ccg
index c7754d0..7bf70c8 100644
--- a/gdk/src/cursor.ccg
+++ b/gdk/src/cursor.ccg
@@ -25,31 +25,4 @@
namespace Gdk
{
-
-//We don't use the _CONSTRUCT macro because the gdk_cursor_new()* functions
-//don't just call g_object_new()
-Cursor::Cursor(CursorType cursor_type)
-:
- Object((GObject*) gdk_cursor_new((GdkCursorType)cursor_type))
-{
-}
-
-Cursor::Cursor(const Glib::RefPtr<Display>& display, CursorType cursor_type)
-:
- Object((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)
-:
- Object((GObject*) gdk_cursor_new_from_pixbuf(Glib::unwrap(display), pixbuf->gobj(), x, y))
-{
-}
-
-Cursor::Cursor(const Glib::RefPtr<Display>& display, const Glib::ustring& name)
-:
- Object((GObject*) gdk_cursor_new_from_name(Glib::unwrap(display), name.c_str()))
-{
-}
-
} //namespace Gdk
diff --git a/gdk/src/cursor.hg b/gdk/src/cursor.hg
index 2786ca3..23f4e1f 100644
--- a/gdk/src/cursor.hg
+++ b/gdk/src/cursor.hg
@@ -41,23 +41,20 @@ class Cursor : public Glib::Object
_IGNORE(gdk_cursor_ref, gdk_cursor_unref) //deprecated
protected:
- explicit Cursor(CursorType cursor_type);
- _IGNORE(gdk_cursor_new)
-
- explicit Cursor(const Glib::RefPtr<Display>& display, CursorType cursor_type);
- _IGNORE(gdk_cursor_new_for_display)
-
- Cursor(const Glib::RefPtr<Display>& display, const Glib::RefPtr<Pixbuf>& pixbuf, int x, int y);
- _IGNORE(gdk_cursor_new_from_pixbuf)
explicit Cursor(const Glib::RefPtr<Display>& display, const Glib::ustring& name);
_IGNORE(gdk_cursor_new_from_name)
public:
- _WRAP_CREATE(CursorType cursor_type)
- _WRAP_CREATE(const Glib::RefPtr<Display>& display, CursorType cursor_type)
- _WRAP_CREATE(const Glib::RefPtr<Display>& display, const Glib::RefPtr<Pixbuf>& pixbuf, int x, int y)
- _WRAP_CREATE(const Glib::RefPtr<Display>& display, const Glib::ustring& name)
+ //We use _WRAP_METHOD() instead of _WRAP_CREATE() and constructors,
+ //because the gdk_cursor_new_*() functions actually return existing instances sometimes,
+ //but constructors assume that they own the instance.
+ //And we would have to have to use the gdk_cursor_new_*() functions in the constructors anyway,
+ //because they do more than just call g_object_new().
+ _WRAP_METHOD(static Glib::RefPtr<Cursor> create(CursorType cursor_type), gdk_cursor_new)
+ _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, CursorType cursor_type), gdk_cursor_new_for_display)
+ _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, const Glib::RefPtr<Pixbuf>& pixbuf, int x, int y), gdk_cursor_new_from_pixbuf)
+ _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, const Glib::ustring& name), gdk_cursor_new_from_name)
_WRAP_METHOD(Glib::RefPtr<Display> get_display(), gdk_cursor_get_display, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Display> get_display() const, gdk_cursor_get_display, refreturn, constversion)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]