aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-ui-utils.c
diff options
context:
space:
mode:
authorShaun McCance <Shaun McCance>2009-10-06 03:22:32 +0800
committerShaun McCance <shaunm@gnome.org>2009-11-25 05:14:51 +0800
commitf167ec2d92a526d19f1faf8320d9ff975ae1e502 (patch)
tree3c2c3888e3a77efd8d23a9a0a909f7608cacd33e /libempathy-gtk/empathy-ui-utils.c
parentcfb4283d66005aa2f12b15ce0d5aefde965d815a (diff)
downloadgsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar
gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.gz
gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.bz2
gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.lz
gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.xz
gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.tar.zst
gsoc2013-empathy-f167ec2d92a526d19f1faf8320d9ff975ae1e502.zip
Utilitiy function to send files from a URI list, for dnd implementations
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 411a76640..9f4182ce1 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1473,6 +1473,36 @@ empathy_send_file (EmpathyContact *contact, GFile *file)
g_object_unref (factory);
}
+void
+empathy_send_file_from_uri_list (EmpathyContact *contact, const gchar *uri_list)
+{
+ const gchar *nl;
+ GFile *file;
+
+ /* Only handle a single file for now. It would be wicked cool to be
+ able to do multiple files, offering to zip them or whatever like
+ nautilus-sendto does. Note that text/uri-list is defined to have
+ each line terminated by \r\n, but we can be tolerant of applications
+ that only use \n or don't terminate single-line entries.
+ */
+ nl = strstr (uri_list, "\r\n");
+ if (!nl) {
+ nl = strchr (uri_list, '\n');
+ }
+ if (nl) {
+ gchar *uri = g_strndup (uri_list, nl - uri_list);
+ file = g_file_new_for_uri (uri);
+ g_free (uri);
+ }
+ else {
+ file = g_file_new_for_uri (uri_list);
+ }
+
+ empathy_send_file (contact, file);
+
+ g_object_unref (file);
+}
+
static void
file_manager_send_file_response_cb (GtkDialog *widget,
gint response_id,