Re: Cannot `dynamic_cast` custom wrapped widget from Gtk::Builder



Thanks Kjell, you have a good eye. I tried making the change to `_CLASS_GTKOBJECT` but I'm not sure what else needs to change. On my system `class_gtkobject.m4` is installed at `/usr/lib/x86_64-linux-gnu/gtkmm-3.0/proc/m4`, so I tried the following execution of gmmproc but the generated .h file is mostly empty:
~~~
M4PATH=/usr/lib/x86_64-linux-gnu/gtkmm-3.0/proc/m4:/usr/lib/x86_64-linux-gnu/glibmm-2.4/proc/m4 /usr/lib/x86_64-linux-gnu/glibmm-2.4/proc/gmmproc -I /usr/lib/x86_64-linux-gnu/glibmm-2.4/proc/m4 -I /usr/lib/x86_64-linux-gnu/gtkmm-3.0/proc/m4 panzoomarea mm mm
~~~

The generated `panzoomarea.h` looks broken:
~~~
// Generated by gmmproc 2.56.0 -- DO NOT MODIFY!
#ifndef _TANGENT_GTKUTIL_MM_PANZOOMAREA_H
#define _TANGENT_GTKUTIL_MM_PANZOOMAREA_H


#include <glibmm/ustring.h>
#include <sigc++/sigc++.h>

// clang-format off


// clang-format on

#include <glibmm.h>
#include <gtkmm/drawingarea.h>

namespace Gtk {


#endif /* _TANGENT_GTKUTIL_MM_PANZOOMAREA_H */

~~~

here is the full `panzoomarea.hg`:
~~~
// clang-format off
_DEFS(tangent/gtkutil/mm, tangent)
_PINCLUDE(gtkmm/private/drawingarea_p.h)
_PINCLUDE(tangent/gtkutil/mm/private/hack.h)
// clang-format on

#include <glibmm.h>
#include <gtkmm/drawingarea.h>

namespace Gtk {

class PanZoomArea : public Gtk::DrawingArea {
  _CLASS_GTKOBJECT(PanZoomArea, GtkPanZoomArea, GTK_PANZOOM_AREA,
                   Gtk::DrawingArea, GtkDrawingArea)

 public:
  _CTOR_DEFAULT

 public:
  // _WRAP_METHOD(void get_offset(double offset[2]), gtk_panzoom_area_set_offset);
  // _WRAP_METHOD(void get_offset(double offset[2]), gtk_panzoom_area_set_offset);

  _WRAP_METHOD(double get_scale(), gtk_panzoom_area_get_scale);
  _WRAP_METHOD(void set_scale(double scale), gtk_panzoom_area_set_scale);
  _WRAP_METHOD(double get_scale_rate(), gtk_panzoom_area_get_scale_rate);
  _WRAP_METHOD(void set_scale_rate(double rate),
               gtk_panzoom_area_set_scale_rate);

  // TODO(josh): can't wrap a signal whose default handler has a different
  // name than the name of the signal.
  _WRAP_SIGNAL(bool area_motion(GdkEventMotion* event), "area-motion");
  _WRAP_SIGNAL(bool area_button(GdkEventButton* event), "area-button");

// clang-format off
#m4 _CONVERSION(`CairoContext*',`const ::Cairo::RefPtr< ::Cairo::Context>&',`::Cairo::RefPtr< ::Cairo::Context>(new ::Cairo::Context($3, false /* has_reference */))')
#m4 _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Context>&',`CairoContext*',`($3)->cobj()')
  _WRAP_SIGNAL(bool area_draw(const ::Cairo::RefPtr< ::Cairo::Context>& cr),
               "area-draw");
  // clang-format on

  _WRAP_PROPERTY("offset-x-adjustment", Glib::RefPtr<Gtk::Adjustment>);
  _WRAP_PROPERTY("offset-y-adjustment", Glib::RefPtr<Gtk::Adjustment>);
  _WRAP_PROPERTY("scale-adjustment", Glib::RefPtr<Gtk::Adjustment>);
  _WRAP_PROPERTY("scale-rate-adjustment", Glib::RefPtr<Gtk::Adjustment>);
  _WRAP_PROPERTY("active", bool);
  _WRAP_PROPERTY("pan-button", int);
  _WRAP_PROPERTY("demo-draw-enabled", bool);
};

}  // namespace Gtk

~~~

Is there something else I need to make the `_CLASS_GTKOBJECT` macro work?

Thanks for the help,
Josh

On Sat, May 2, 2020 at 12:27 AM Kjell Ahlstedt <kjellahlstedt gmail com> wrote:
On 2020-05-01 23:28, Josh Bialkowski via gtkmm-list wrote:

~~~
class PanZoomArea : public Gtk::DrawingArea {
  _CLASS_GOBJECT(PanZoomArea, GtkPanZoomArea, GTK_PANZOOM_AREA,
                 Gtk::DrawingArea, GtkDrawingArea);

~~~

You must use _CLASS_GTKOBJECT() instead of _CLASS_GOBJECT() for a widget.
_CLASS_GTKOBJCT() is defined in gtkmm/tools/m4/class_gtkobject.m4. You won't find it in glibmm.

Don't know if this is the only error.

Kjell



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