doesn't allow to send socket files
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 7 Nov 2011 14:44:59 +0000 (15:44 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 10 Nov 2011 14:20:17 +0000 (15:20 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=663563

libempathy-gtk/empathy-ui-utils.c

index 5d9551d12dc20f82cdc2c587e90984a52a3e2e20..a387160d312b503211366b5de1914bca670c2457 100644 (file)
@@ -1825,6 +1825,27 @@ file_manager_send_file_response_cb (GtkDialog      *widget,
        gtk_widget_destroy (GTK_WIDGET (widget));
 }
 
+static gboolean
+filter_cb (const GtkFileFilterInfo *filter_info,
+               gpointer data)
+{
+       /* filter out socket files */
+       return tp_strdiff (filter_info->mime_type, "inode/socket");
+}
+
+static GtkFileFilter *
+create_file_filter (void)
+{
+       GtkFileFilter *filter;
+
+       filter = gtk_file_filter_new ();
+
+       gtk_file_filter_add_custom (filter, GTK_FILE_FILTER_MIME_TYPE, filter_cb,
+               NULL, NULL);
+
+       return filter;
+}
+
 void
 empathy_send_file_with_file_chooser (EmpathyContact *contact)
 {
@@ -1859,6 +1880,9 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact)
        gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget),
                g_get_home_dir ());
 
+       gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget),
+               create_file_filter ());
+
        g_signal_connect (widget, "response",
                          G_CALLBACK (file_manager_send_file_response_cb),
                          g_object_ref (contact));