summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-03-05 15:29:45 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-03-05 15:29:45 +0000
commitceac4cca7ce4d7e2d26eb443927b73cf2378a281 (patch)
treebcca036711022e681dae8c77db39c026252c59b4 /libnautilus-private
parentb25b5655de073b21886629d37ca4d87867f4c986 (diff)
downloadnautilus-ceac4cca7ce4d7e2d26eb443927b73cf2378a281.tar.gz
Add async x-content type getter, change sync one to only read the cached
2008-03-05 Alexander Larsson <alexl@redhat.com> * libnautilus-private/nautilus-autorun.[ch]: Add async x-content type getter, change sync one to only read the cached value * src/file-manager/fm-directory-view.c: * src/nautilus-window-manage-views.c: Get x-content type async svn path=/trunk/; revision=13884
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/nautilus-autorun.c76
-rw-r--r--libnautilus-private/nautilus-autorun.h9
2 files changed, 75 insertions, 10 deletions
diff --git a/libnautilus-private/nautilus-autorun.c b/libnautilus-private/nautilus-autorun.c
index f2126def5..389ba4625 100644
--- a/libnautilus-private/nautilus-autorun.c
+++ b/libnautilus-private/nautilus-autorun.c
@@ -1269,20 +1269,80 @@ nautilus_autorun (GMount *mount, NautilusAutorunOpenWindow open_window_func, gpo
data);
}
+typedef struct {
+ NautilusAutorunGetContent callback;
+ gpointer user_data;
+} GetContentTypesData;
+
+static void
+get_types_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GetContentTypesData *data;
+ char **types;
+
+ data = user_data;
+ types = _g_mount_guess_content_type_finish (G_MOUNT (source_object), res, NULL);
+
+ if (data->callback) {
+ data->callback (types, data->user_data);
+ }
+ g_strfreev (types);
+ g_free (data);
+}
+
+void
+nautilus_autorun_get_x_content_types_for_mount_async (GMount *mount,
+ NautilusAutorunGetContent callback,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ char **cached;
+ GetContentTypesData *data;
+
+ if (mount == NULL) {
+ if (callback) {
+ callback (NULL, user_data);
+ }
+ return;
+ }
+
+ cached = g_object_get_data (G_OBJECT (mount), "content-type-cache");
+ if (cached != NULL) {
+ if (callback) {
+ callback (cached, user_data);
+ }
+ return;
+ }
+
+ data = g_new (GetContentTypesData, 1);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ _g_mount_guess_content_type_async (mount,
+ FALSE,
+ cancellable,
+ get_types_cb,
+ data);
+}
+
+
char **
-nautilus_autorun_get_x_content_types_for_mount (GMount *mount,
- gboolean force_rescan)
+nautilus_autorun_get_cached_x_content_types_for_mount (GMount *mount)
{
+ char **cached;
+
if (mount == NULL) {
return NULL;
}
- /* since we always guess the content type at mount type, we're guaranteed
- * to get the cached results
- *
- * TODO: Really? what if we didn't mount the mount ourself?
- */
- return _g_mount_guess_content_type (mount, force_rescan, NULL);
+ cached = g_object_get_data (G_OBJECT (mount), "content-type-cache");
+ if (cached != NULL) {
+ return g_strdupv (cached);
+ }
+
+ return NULL;
}
diff --git a/libnautilus-private/nautilus-autorun.h b/libnautilus-private/nautilus-autorun.h
index 0037a5bfd..72a99c9f8 100644
--- a/libnautilus-private/nautilus-autorun.h
+++ b/libnautilus-private/nautilus-autorun.h
@@ -66,6 +66,7 @@ typedef void (*NautilusAutorunComboBoxChanged) (gboolean selected_ask,
gpointer user_data);
typedef void (*NautilusAutorunOpenWindow) (GMount *mount, gpointer user_data);
+typedef void (*NautilusAutorunGetContent) (char **content, gpointer user_data);
void nautilus_autorun_prepare_combo_box (GtkWidget *combo_box,
const char *x_content_type,
@@ -79,8 +80,12 @@ void nautilus_autorun_get_preferences (const char *x_content_type, gboolean *pre
void nautilus_autorun (GMount *mount, NautilusAutorunOpenWindow open_window_func, gpointer user_data);
-char **nautilus_autorun_get_x_content_types_for_mount (GMount *mount,
- gboolean force_rescan);
+char **nautilus_autorun_get_cached_x_content_types_for_mount (GMount *mount);
+
+void nautilus_autorun_get_x_content_types_for_mount_async (GMount *mount,
+ NautilusAutorunGetContent callback,
+ GCancellable *cancellable,
+ gpointer user_data);
void nautilus_autorun_launch_for_mount (GMount *mount, GAppInfo *app_info);