From 3387fccd7e84e960e9e2eff96d37343c8051dad4 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Fri, 12 Aug 2011 11:59:48 -0700 Subject: [PATCH] Factored gfile-open out of gfile-query-info. --- src/gtk/gio.scm | 55 +++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/src/gtk/gio.scm b/src/gtk/gio.scm index 60274d508..902e165c0 100644 --- a/src/gtk/gio.scm +++ b/src/gtk/gio.scm @@ -727,44 +727,23 @@ USA. (define (gfile-query-info gfile attributes follow-symlinks?) (guarantee-string attributes 'gfile-query-info) - (let* ((ginfo (make-gfile-info)) - (gio-info (gio-cleanup-info ginfo)) - (queue (gio-queue ginfo)) - (gerror* (gio-cleanup-info-gerror-pointer gio-info)) - (callback-id - (without-interrupts ;don't leak callback IDs - (lambda () - (let* ((alien (gobject-alien ginfo)) - (id (make-query-finish-callback alien queue gerror*))) - (set-gio-cleanup-info-pending-op! gio-info 'QUERY) - (set-gio-cleanup-info-callback-id! gio-info id) - id))))) - (let retry () - (C-call "g_file_query_info_async" - (gobject-alien gfile) - attributes - (if follow-symlinks? - (C-enum "G_FILE_QUERY_INFO_NONE") - (C-enum "G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS")) - (gio-priority ginfo) - (gobject-alien (gio-cleanup-info-gcancellable gio-info)) - (C-callback "async_ready") - callback-id) - (let ((value (thread-queue/dequeue! queue))) - (cond ((eq? value #t) - (set-gio-cleanup-info-pending-op! gio-info 'CLOSED) - (without-interrupts - (lambda () - (cleanup-gio gio-info))) - ginfo) - ((equal? value "The specified location is not mounted") - (gfile-mount gfile) - (retry)) - ((string? value) - (set-gio-cleanup-info-pending-op! gio-info 'ERROR) - (error (string-append (gfile-uri gfile) ":") value)) - (else - (error "Unexpected value from:" queue ginfo))))))) + (gfile-open gfile 'QUERY + make-gfile-info + (named-lambda (query-callout + gfile* priority gcancellable* callback id) + (C-call "g_file_query_info_async" + gfile* + attributes + (if follow-symlinks? + (C-enum "G_FILE_QUERY_INFO_NONE") + (C-enum "G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS")) + priority gcancellable* callback id)) + make-query-finish-callback + (named-lambda (cleanup-gfile-info gfile-info queue gerror*) + (declare (ignore queue gerror*)) + (let ((gio-info (gio-cleanup-info gfile-info))) + (set-gio-cleanup-info-pending-op! gio-info 'CLOSED) + (cleanup-gio gio-info))))) (define (make-query-finish-callback alien queue gerror*) (C-callback -- 2.25.1