Re: gnome_vfs_uri_list_parse unwrapped?
- From: John Spray <jcspray icculus org>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: gnome_vfs_uri_list_parse unwrapped?
- Date: Sun, 14 Jan 2007 21:10:49 +0000
On Sun, 2007-01-14 at 20:43 +0100, Murray Cumming wrote:
> A patch would be welcome for gnome-vfsmm, ideally with doxygen
> documentation saying when and how to use it, maybe with a real-world
> example.
Here's an almost-working patch. It works fine if I instead use
std::list as the container for the return value, but something's causing
a crash in the way I'm using Glib::ListHandle: I get a segfault when I
try to dereference a child of the returned listhandle with a
"g_object_get_qdata: assertion `G_IS_OBJECT (object)' failed" warning.
So hopefully you can easily spot what's wrong with the use of the
container.
John
diff -urp gnome-vfsmm-2.16.0/libgnomevfs/libgnomevfsmm/uri.cc gnome-vfsmm2.6-2.16.0-jcs/libgnomevfs/libgnomevfsmm/uri.cc
--- gnome-vfsmm-2.16.0/libgnomevfs/libgnomevfsmm/uri.cc 2006-05-18 21:12:50.000000000 +0100
+++ gnome-vfsmm2.6-2.16.0-jcs/libgnomevfs/libgnomevfsmm/uri.cc 2007-01-14 20:32:08.000000000 +0000
@@ -291,6 +291,26 @@ Glib::ustring Uri::extract_short_path_na
return Glib::convert_return_gchar_ptr_to_ustring(gnome_vfs_uri_extract_short_path_name(const_cast<GnomeVFSURI*>(gobj())));
}
+Glib::ListHandle< Glib::RefPtr< Uri > > Uri::list_parse(const Glib::ustring& uri_list)
+{
+ GList *list = gnome_vfs_uri_list_parse (uri_list.c_str());
+
+ std::list<Glib::RefPtr<Gnome::Vfs::Uri> > uris;
+
+ GList *p = list;
+ while (p != NULL) {
+ Glib::RefPtr<Gnome::Vfs::Uri> uri =
+ Glib::wrap ((GnomeVFSURI*)(p->data), true);
+ uris.push_back (uri);
+
+ p = g_list_next (p);
+ }
+
+ gnome_vfs_uri_list_free (list);
+
+ return uris;
+}
+
Glib::ustring Uri::make_full_from_relative(const Glib::ustring& base_uri, const Glib::ustring& relative_uri)
{
return Glib::convert_return_gchar_ptr_to_ustring(gnome_vfs_uri_make_full_from_relative(base_uri.c_str(), relative_uri.c_str()));
diff -urp gnome-vfsmm-2.16.0/libgnomevfs/libgnomevfsmm/uri.h gnome-vfsmm2.6-2.16.0-jcs/libgnomevfs/libgnomevfsmm/uri.h
--- gnome-vfsmm-2.16.0/libgnomevfs/libgnomevfsmm/uri.h 2006-01-07 22:38:24.000000000 +0000
+++ gnome-vfsmm2.6-2.16.0-jcs/libgnomevfs/libgnomevfsmm/uri.h 2007-01-14 20:35:36.000000000 +0000
@@ -309,13 +309,17 @@ public:
*/
Glib::ustring extract_short_path_name() const;
- //These are used for creating hashes for hash tables, apparently.
- //I don't see the point of wrapping them.
-
-/*
-GList* gnome_vfs_uri_list_parse(const Glib::ustring& uri_list), )
-*/
+ /** Returns a list of pointers to Uris by parsing a text list of string-representation URIs
+ *
+ * This function might be used in a signal handler for
+ * Gtk::Widget::signal_drag_data_received when receiving the mime type
+ * text/uri-list.
+ *
+ * @param uri_list A textual list of URIs
+ * @return A ListHandle of Glib::RefPtrs to Uris
+ */
+ static Glib::ListHandle< Glib::RefPtr< Uri > > list_parse(const Glib::ustring& uri_list);
/** Returns a full Uri given a full base URI, and a secondary URI which may
#include <gtkmm.h>
#include <libgnomevfsmm.h>
#include <libgnomeuimm.h>
#include <iostream>
int main (int argc, char **argv)
{
Gnome::Main gui ("foo", "bar",
Gnome::UI::module_info_get(), argc, argv);
Gnome::Vfs::init ();
Glib::ustring listtxt = "file:///home/jcspray/foo\nfile:///home/jcspray/bar\n";
typedef Glib::ListHandle<Glib::RefPtr<Gnome::Vfs::Uri> > urilist;
urilist list = Gnome::Vfs::Uri::list_parse (listtxt);
urilist::iterator it = list.begin ();
urilist::iterator const end = list.end ();
for (; it != end; ++it) {
std::cerr << "Uri looks like " << (*it)->to_string () << "\n";
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]