Problem Drawing SVG File to Cluttermm Stage



I'm evaluating the use of Cluttermm or Cairomm for the development of an aesthetically pleasing budgeting program, and while it wasn't too difficult for me to get Cairomm up an running, as well as drawing SVG images to gtkmm widgets, I have not been so fortunate with Cluttermm. I am developing this for GTK2, so gtkmm 2.4, Cluttermm 1.1.3, and clutter-gtkmm 0.10.

The problem is when I was trying to get SVG into Cluttermm. There was a project called Dax, which could be used to import SVG files, but it did not have a stable release available. However, there was the option in Cluttermm to produce a Clutter::Cairo::Texture, which is a special type of Clutter::Texture that one can create a Cairo::Context to perform Cairo drawing operations on. From here, I figured I could just use the same librsvgmm that I had used to get SVG files drawn in Cairomm. Here's the code:

Glib::RefPtr<Clutter::Actor> get_svg_from_file(char const *filename, guint width, guint height)
{
  std::string str(filename);
  Glib::RefPtr<Clutter::Actor> ret_actor;
  try
  {
    Glib::RefPtr<Rsvg::Handle> handle = Rsvg::Handle::create_from_file(str);
    Glib::RefPtr<Clutter::Cairo::Texture> cairo_texture = 
      Clutter::Cairo::Texture::create(width, height);
    Glib::RefPtr<Cairo::Context> draw_context = cairo_texture->create_context();
    handle->render(draw_context);
    ret_actor = cairo_texture;
  }
  catch (Rsvg::Error e)
  {
    // Return the failure actor.
    Glib::ustring error_str("Bad Filename!");
    ret_actor = Clutter::Text::create(ERROR_FONT, error_str, ERROR_COLOR);
  }
  return ret_actor;
}

The problem here is that Rsvg::Handle::render() doesn't take a Glib::RefPtr<Cairo::Context>, instead it takes a Cairo::RefPtr<Cairo::Context>! This seems like a trivial issue, as it would be sensible for Cluttermm to return a Cairo::RefPtr instead of a Glib::RefPtr in this particular instance, but it does not. Either this was intentional, for reasons I cannot fathom, or it's an oversight, which I suppose makes sense considering the disparate libraries I'm connecting. To make my point more pronounced, it's clear this causes an error, as it's my first build problem:

zeke@GoddamnPC:~/Projects/C/abe/abe/clutter_drawing$ g++ TryDrawSVG.cpp -o try `pkg-config --libs --cflags cluttermm-1.0 gtkmm-2.4 clutter-gtkmm-1.0 librsvgmm-2.0`
TryDrawSVG.cpp: In function ‘Glib::RefPtr<Clutter::Actor> get_svg_from_file(const char*, guint, guint)’:
TryDrawSVG.cpp:61: error: no matching function for call to ‘Rsvg::Handle::render(Glib::RefPtr<Cairo::Context>&)’
/usr/local/include/librsvgmm-2.0/librsvgmm/rsvg.h:328: note: candidates are: bool Rsvg::Handle::render(const Cairo::RefPtr<Cairo::Context>&) const

I was hoping someone on this mailing list has encountered these kinds of issues before, namely the interchanging of different libraries RefPtrs and how to go about changing it from a Glib::RefPtr to a Cairo::RefPtr. If this isn't an option, could someone give me another choice or method to import SVG files for drawing onto a Clutter::Stage?

Thank you for any assistance.


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