[gtkmm/gtkmm-3maybe] Wrap GtkBorder as boxed type.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-3maybe] Wrap GtkBorder as boxed type.
- Date: Tue, 22 Dec 2009 17:00:59 +0000 (UTC)
commit 2ff92e410afd0334be7b7d10318f03a97988b2e0
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Tue Dec 22 17:53:36 2009 +0100
Wrap GtkBorder as boxed type.
* gtk/src/border.[hg|ccg]: Wrapped GtkBorder.
* gtk/src/filelist.am: Added border.hg and border.ccg.
* gtk/src/entry.hg: Removed a TODO and typedef and included
border.h.
* gtk/src/range.[hg|ccg]: Made get_range_border vfunc use
Gtk::Border& instead of GtkBorder* - this needed wrapping it
partially by hand by writing custom C callback.
* tools/m4/convert_gtk.m4: Added conversion macros for Gtk::Border.
* gtk/gtkmm.h: Added border.h include.
* MSVC_Net{2005,2008}/gtkmm/gtkmm.vcproj: Added border.h
and border.cc to build.
ChangeLog | 12 ++++++++++
MSVC_Net2005/gtkmm/gtkmm.vcproj | 8 ++++++
MSVC_Net2008/gtkmm/gtkmm.vcproj | 8 ++++++
gtk/gtkmm.h | 1 +
gtk/src/border.ccg | 20 +++++++++++++++++
gtk/src/border.hg | 45 ++++++++++++++++++++++++++++++++++++++
gtk/src/entry.hg | 4 +--
gtk/src/filelist.am | 1 +
gtk/src/range.ccg | 46 +++++++++++++++++++++++++++++++++++++++
gtk/src/range.hg | 19 +++++++++++++++-
tools/m4/convert_gtk.m4 | 6 +++-
11 files changed, 164 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0d0d011..921dfa4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-11 Krzesimir Nowak <qdlacz gmail com>
+
+ * gtk/src/border.[hg|ccg]: Wrapped GtkBorder.
+ * gtk/src/entry.hg: Removed a TODO and typedef and included border.h.
+ * gtk/src/range.[hg|ccg]: Made get_range_border vfunc use Gtk::Border&
+ instead of GtkBorder* - this needed wrapping it partially by hand by
+ writing custom C callback.
+ * tools/m4/convert_gtk.m4: Added conversion macros for Gtk::Border.
+ * gtk/gtkmm.h: Added border.h include.
+ * MSVC_Net{2005,2008}/gtkmm/gtkmm.vcproj: Added border.h and border.cc
+ to build.
+
2009-05-05 Murray Cumming <murrayc murrayc com>
* gdk/gdkmm/general.[h|cc]:
diff --git a/MSVC_Net2005/gtkmm/gtkmm.vcproj b/MSVC_Net2005/gtkmm/gtkmm.vcproj
index 9be0e24..91bf4fd 100755
--- a/MSVC_Net2005/gtkmm/gtkmm.vcproj
+++ b/MSVC_Net2005/gtkmm/gtkmm.vcproj
@@ -240,6 +240,10 @@
>
</File>
<File
+ RelativePath="..\..\gtk\gtkmm\border.cc"
+ >
+ </File>
+ <File
RelativePath="..\..\gtk\gtkmm\box.cc"
>
</File>
@@ -962,6 +966,10 @@
>
</File>
<File
+ RelativePath="..\..\gtk\gtkmm\border.h"
+ >
+ </File>
+ <File
RelativePath="..\..\gtk\gtkmm\box.h"
>
</File>
diff --git a/MSVC_Net2008/gtkmm/gtkmm.vcproj b/MSVC_Net2008/gtkmm/gtkmm.vcproj
index ca82a76..5ee3d9d 100644
--- a/MSVC_Net2008/gtkmm/gtkmm.vcproj
+++ b/MSVC_Net2008/gtkmm/gtkmm.vcproj
@@ -239,6 +239,10 @@
>
</File>
<File
+ RelativePath="..\..\gtk\gtkmm\border.cc"
+ >
+ </File>
+ <File
RelativePath="..\..\gtk\gtkmm\box.cc"
>
</File>
@@ -961,6 +965,10 @@
>
</File>
<File
+ RelativePath="..\..\gtk\gtkmm\border.h"
+ >
+ </File>
+ <File
RelativePath="..\..\gtk\gtkmm\box.h"
>
</File>
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 1e7c57f..ca1ce28 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -41,6 +41,7 @@ extern const int gtkmm_micro_version;
#include <gtkmm/assistant.h>
#include <gtkmm/base.h>
#include <gtkmm/bin.h>
+#include <gtkmm/border.h>
#include <gtkmm/box.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
diff --git a/gtk/src/border.ccg b/gtk/src/border.ccg
new file mode 100644
index 0000000..14c3865
--- /dev/null
+++ b/gtk/src/border.ccg
@@ -0,0 +1,20 @@
+/* border.cc
+ *
+ * Copyright 2009 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/border.hg b/gtk/src/border.hg
new file mode 100644
index 0000000..844a2ab
--- /dev/null
+++ b/gtk/src/border.hg
@@ -0,0 +1,45 @@
+/* border.h
+ *
+ * Copyright 2009 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_DEFS(gtkmm,gtk)
+
+namespace Gtk
+{
+
+class Border
+{
+ _CLASS_BOXEDTYPE(Border, GtkBorder, gtk_border_new, gtk_border_copy, gtk_border_free)
+public:
+
+ _MEMBER_GET(left, left, int, gint)
+ _MEMBER_SET(left, left, int, gint)
+
+ _MEMBER_GET(right, right, int, gint)
+ _MEMBER_SET(right, right, int, gint)
+
+ _MEMBER_GET(top, top, int, gint)
+ _MEMBER_SET(top, top, int, gint)
+
+ _MEMBER_GET(bottom, bottom, int, gint)
+ _MEMBER_SET(bottom, bottom, int, gint)
+};
+
+} /* namespace Gtk */
+
+
diff --git a/gtk/src/entry.hg b/gtk/src/entry.hg
index 36d3457..1781a86 100644
--- a/gtk/src/entry.hg
+++ b/gtk/src/entry.hg
@@ -26,6 +26,7 @@
#include <gtkmm/entrycompletion.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/image.h> //For ImageType.
+#include <gtkmm/border.h>
_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)
@@ -35,9 +36,6 @@ namespace Gtk
_WRAP_ENUM(EntryIconPosition, GtkEntryIconPosition)
-//TODO: This is used in Range too, so put it somewhere more appropriate:
-typedef GtkBorder Border;
-
/** A single line text entry field.
*
* The Gtk::Entry widget is a single line text entry widget. A fairly large
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 63c15f2..f083581 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -25,6 +25,7 @@ gtkmm_files_any_hg = \
aspectframe.hg \
assistant.hg \
bin.hg \
+ border.hg \
box.hg \
buildable.hg \
builder.hg \
diff --git a/gtk/src/range.ccg b/gtk/src/range.ccg
index 482eff3..3801fbe 100644
--- a/gtk/src/range.ccg
+++ b/gtk/src/range.ccg
@@ -29,6 +29,52 @@ void Range::unset_adjustment()
gtk_range_set_adjustment(gobj(), 0);
}
+#ifdef GLIBMM_VFUNCS_ENABLED
+void Range_Class::get_range_border_vfunc_callback(GtkRange* self, GtkBorder* border)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ // Call the virtual member method, which derived classes might override.
+ Gtk::Border cxx_border(border, true);
+ obj->get_range_border_vfunc(cxx_border);
+ *border = *(cxx_border.gobj());
+ return;
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->get_range_border)
+ (*base->get_range_border)(self, border);
+
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
} // namespace Gtk
diff --git a/gtk/src/range.hg b/gtk/src/range.hg
index 7c985fb..588901a 100644
--- a/gtk/src/range.hg
+++ b/gtk/src/range.hg
@@ -19,6 +19,7 @@
#include <gtkmm/widget.h>
#include <gtkmm/enums.h> //For SensitivityType.
+#include <gtkmm/border.h>
_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)
@@ -106,7 +107,23 @@ public:
_WRAP_PROPERTY("fill-level", double)
protected:
- _WRAP_VFUNC(void get_range_border(GtkBorder* border) const, get_range_border)
+ virtual void get_range_border_vfunc(Gtk::Border& border) const;
+#m4begin
+dnl /* get_range_border_vfunc is wrapped partially by hand (C callback is
+dnl * custom), because this vfunc is a getter with a "return value" as
+dnl * parameter. This complicates things a bit - we cannot use Glib::wrap in
+dnl * obj->get_range_border_vfunc(Glib::wrap(c_border));
+dnl * because compiler complains about passing `Gtk::Border', when expecting
+dnl * `Gtk::Border&'. Using `Gtk::Border(c_border)' also does not work, because
+dnl * it is making a copy of passed C border and, when went out of scope,
+dnl * destroys it without copying contents to a C border. See:
+dnl * https://bugzilla.gnome.org/show_bug.cgi?id=603926#c3
+dnl */
+dnl // _VFUNC_H is not used - prototype is written above.
+ _VFUNC_PH(get_range_border, void, `GtkRange* self, GtkBorder* border')
+ _VFUNC_CC(get_range_border_vfunc, get_range_border, void, void, `Gtk::Border& border', `border.gobj()', 1)
+dnl // _VFUNC_PCC is not used - custom C callback is implemented in range.ccg.
+#m4end
};
} // namespace Gtk
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 8514faf..67f2aec 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -511,8 +511,10 @@ _CONVERSION(`GtkEntry*',`const Entry*',__RP2P)
_CONVERSION(`Entry&',`GtkEntry*',__FR2P)
-_CONVERSION(`const Border&',`const GtkBorder*',`&($3)')
-_CONVERSION(`const GtkBorder*',`Border',`*($3)')
+_CONVERSION(`Gtk::Border&',`GtkBorder*',__FR2P)
+_CONVERSION(`GtkBorder*',`Gtk::Border&',`Glib::wrap($3)')
+_CONVERSION(`const Border&',`const GtkBorder*',__FR2P)
+_CONVERSION(`const GtkBorder*',`Border',`Glib::wrap(const_cast<GtkBorder*>($3))')
#RecentFilter
_CONVERSION(`GtkRecentFilterFlags',`RecentFilterFlags',`($2)$3')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]