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

Kjell Ahlstedt via gtkmm-list <[email protected]> Sun, 3 May 2020 15:24:01 +0200
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
I don't understand why panzoomarea.h (and I suppose also panzoomarea.cc) 
is broken. Don't you get any kind of warning or error message? Probably 
your gmmproc-command can be made much shorter:

/usr/lib/x86_64-linux-gnu/glibmm-2.4/proc/gmmproc -I 
/usr/lib/x86_64-linux-gnu/gtkmm-3.0/proc/m4 panzoomarea mm mm

But I don't expect that to make a difference.

You can add a --debug argument to the gmmproc command. Some temporary 
files are then saved. You will probably find them in the /tmp directory.

Kjell

On 2020-05-03 02:07, Josh Bialkowski wrote:
> 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
>
>

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list