[gtkmm] Glib::ListHandle and a new Gnome::Vfs class...



Hey all,
    I'm running into a brick wall and I wasn't sure which list to send this to, so I sent
it to both (since it has to do with both gtkmm/glibmm and gnomemm).  I have this
gnome-vfs function (gnome_vfs_mime_get_short_list_applications), that returns a GList* of
GnomeVFSMimeApplication*'s (the doc for this function is at
http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-gnome-vfs-mime-database.html#gnome-vfs-mime-get-short-list-applications)

Anyway, I have GnomeVFSMimeApplication wrapped.  Here's the class (maybe I'm doing
something wrong):

class MimeApplication
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef MimeApplication CppObjectType;
  typedef GnomeVFSMimeApplication BaseObjectType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  MimeApplication();

  // Use make_a_copy=true when getting it directly from a struct.
  explicit MimeApplication(GnomeVFSMimeApplication* castitem, bool make_a_copy = false);

  MimeApplication(const MimeApplication& src);
  MimeApplication& operator=(const MimeApplication& src);

  ~MimeApplication();

  GnomeVFSMimeApplication*       gobj()       { return gobject_; }
  const GnomeVFSMimeApplication* gobj() const { return gobject_; }

structs.
  GnomeVFSMimeApplication* gobj_copy() const;

protected:
  GnomeVFSMimeApplication* gobject_;

public:
  static MimeApplication create_from_id(const Glib::ustring& id);

  Glib::ustring get_id() const;
  Glib::ustring get_name() const;
  Glib::ustring get_command() const;
  MimeApplicationArgumentType get_argument_type() const;
  Glib::ListHandle<Glib::ustring> get_supported_uri_schemes() const;
  
  bool can_open_multiple_files();
  bool requires_terminal();
};

here are the important methods:

MimeApplication::MimeApplication()
:
  gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to
methods.
{}

MimeApplication::MimeApplication(const MimeApplication& src)
:
  gobject_ ((src.gobject_) ? gnome_vfs_mime_application_copy(src.gobject_) : 0)
{}

MimeApplication::MimeApplication(GnomeVFSMimeApplication* castitem, bool make_a_copy /* =
false */)
{
  if(!make_a_copy)
  {
    // It was given to us by a function which has already made a copy for us to keep.
    gobject_ = castitem;
  }
  else
  {
    // We are probably getting it via direct access to a struct,
    // so we can not just take it - we have to take a copy of it.
    if(castitem)
      gobject_ = gnome_vfs_mime_application_copy(castitem);
    else
      gobject_ = 0;
  }
}

MimeApplication& MimeApplication::operator=(const MimeApplication& src)
{
  GnomeVFSMimeApplication *const new_gobject = (src.gobject_) ?
gnome_vfs_mime_application_copy(src.gobject_) : 0;

  if(gobject_)
    gnome_vfs_mime_application_free(gobject_);

  gobject_ = new_gobject;

  return *this;
}

MimeApplication::~MimeApplication()
{
  if(gobject_)
    gnome_vfs_mime_application_free(gobject_);
}

GnomeVFSMimeApplication* MimeApplication::gobj_copy() const
{
  return gnome_vfs_mime_application_copy(gobject_);
}

This class is in the Gnome and Vfs namespaces (just so you know).  Also, this is
generated from an hg file (the class is _CLASS_OPAQUE_COPYABLE).  Anyway, when I go to
wrap the function (a function that will be in the Mime namespace), this is how I do it:

Glib::ListHandle<Gnome::Vfs::MimeApplication> get_short_list_applications(const
Glib::ustring& mime_type)
{
  GList* pList = gnome_vfs_mime_get_short_list_applications(mime_type.c_str());
  return Glib::ListHandle<Gnome::Vfs::MimeApplication>(pList, Glib::OWNERSHIP_NONE);
}

This way worked in application-registry.[h|cc], but it doesn't seem to work here.  I get
this compile error:

/opt/gnome2/include/gtkmm-2.0/glibmm/listhandle.h: In destructor `void
   Glib::ListHandle<T, Tr>::ListHandle() [with T = Gnome::Vfs::MimeApplication,
   Tr = Glib::Container_Helpers::TypeTraits<Gnome::Vfs::MimeApplication>]':
mime-handlers.cc:47:   instantiated from here
/opt/gnome2/include/gtkmm-2.0/glibmm/listhandle.h:299: invalid conversion from
   `void*' to `GnomeVFSMimeApplication*'
/opt/gnome2/include/gtkmm-2.0/glibmm/listhandle.h:299:   initializing argument
   1 of `Gnome::Vfs::MimeApplication::MimeApplication(GnomeVFSMimeApplication*,
   bool)'
make[1]: *** [mime-handlers.lo] Error 1

I'm not sure why listhandle.h thinks the GList* is a list of void*'s, so it really
confuses me, but maybe I'm doing something completely wrong.  Just so you know, I'm
compiling with g++-3.2 (so it's not that dumb 3.3 error).  I know this is a long email,
but I wanted to be sure that yall knew exactly what was up so you could help me.  Thanks
in advance!!

-Bryan

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com



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