[gnomemm] custom canvas item



Hi,

(please keep me in the CC list, thanks)

I started to work on an audio application and use libgnomemm1.3.  The
gtkmm/gnomemm wrappers have become really slick, congrats!  It's a pleasure
to work with them.

Now, for handling large audio files, I am using my own canvas type.  The
existing ones don't really like millions and millions of lines.

Following a mail by Murray which I found in the archive, I am using:

class AudioFileItem : public AudioFile, public Gnome::Canvas::Item
{
public:
  AudioFileItem (Gnome::Canvas::Group &parentx,
                 const std::string file) throw
};

AudioFileItem::AudioFileItem (Gnome::Canvas::Group &parentx,
                              const std::string file)
  : AudioFile (file),
    Gnome::Canvas::Item (GNOME_CANVAS_ITEM (g_object_new (get_type (), 0)))
{
  item_construct (parentx);
}

First let me say that this works quite fine.  I overrode update_vfunc and
render_vfunc, and the canvas displays the item just fine.  It would be nice
to have a Gnome::Canvas::Item (Gnome::Canvas::Group &parentx) constructor
that does the above wrapping of the C object in an opaque way.

Now, I thought that to make my item behave like the other items, it would be
nice to use the property system.  However, adding the property proxies
doesn't appear to be enough, because the underlying gobject doesn't know
anything about the properties:

class AudioFileItem
{
  ...

public:
  Glib::PropertyProxy<Glib::ustring> property_fill_color ();
};

Glib::PropertyProxy<Glib::ustring> AudioFileItem::property_fill_color()
{
  return Glib::PropertyProxy<Glib::ustring> (this, "fill_color");
}

This results in a run-time warning:

(main:2738): GLib-GObject-WARNING **: gobject.c:1032: object class
tkmm__GnomeCanvasItem' has no property named ill_color'

It would be nice to have a somewhat automatic way to register a new object
class and register its properties.  However, I wouldn't mind a manual way to
do that, too.  I am quite a Glib/Gdk/Gtk/Gnome newbie, so if you have an
example or a suggestion how to do that, I would appreciate it.  If
everything fails, it's not too hard to write my own property functions, I
was just thinking about consistency and the ability to derive new types
which behave like the others.

I also found a bug, but I am not sure if I didn't something wrong.
If in the above class I would change the order and first list the canvas
item, then the audiofile, and the audiofile constructor throws an exception,
then the application crashes in the Item destructor:

(main:2772): GnomeCanvas-CRITICAL **: file gnome-canvas.c: line 3721
(gnome_canvas_request_redraw): assertion NOME_IS_CANVAS (canvas)' failed
   
#0  0x406a0add in gnome_canvas_item_construct () from /usr/lib/libgnomecanvas-2.so.0
#1  0x40af0429 in g_object_class_list_properties () from /usr/lib/libgobject-2.0.so.0
#2  0x4038eb43 in Gtk::Object::_destroy_c_instance() () from /usr/lib/libgtkmm-2.0.so.1
#3  0x4038ee0a in Gtk::Object::destroy_() () from /usr/lib/libgtkmm-2.0.so.1
#4  0x400b17d1 in Gnome::Canvas::Item::~Item() () from /usr/lib/libgnomecanvasmm-2.0.so.1

I don't have debugging symbols installed, but I can probably make a small
test case if useful.

Thanks,
Marcus


-- 
`Rhubarb is no Egyptian god.' GNU      http://www.gnu.org    marcus gnu org
Marcus Brinkmann              The Hurd http://www.gnu.org/software/hurd/
Marcus Brinkmann ruhr-uni-bochum de
http://www.marcus-brinkmann.de/



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