nautilus r13884 - in trunk: . libnautilus-private src src/file-manager
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r13884 - in trunk: . libnautilus-private src src/file-manager
- Date: Wed, 5 Mar 2008 15:29:45 +0000 (GMT)
Author: alexl
Date: Wed Mar 5 15:29:45 2008
New Revision: 13884
URL: http://svn.gnome.org/viewvc/nautilus?rev=13884&view=rev
Log:
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
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-autorun.c
trunk/libnautilus-private/nautilus-autorun.h
trunk/src/file-manager/fm-directory-view.c
trunk/src/nautilus-window-manage-views.c
Modified: trunk/libnautilus-private/nautilus-autorun.c
==============================================================================
--- trunk/libnautilus-private/nautilus-autorun.c (original)
+++ trunk/libnautilus-private/nautilus-autorun.c Wed Mar 5 15:29:45 2008
@@ -1269,20 +1269,80 @@
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;
}
Modified: trunk/libnautilus-private/nautilus-autorun.h
==============================================================================
--- trunk/libnautilus-private/nautilus-autorun.h (original)
+++ trunk/libnautilus-private/nautilus-autorun.h Wed Mar 5 15:29:45 2008
@@ -66,6 +66,7 @@
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 (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);
Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c (original)
+++ trunk/src/file-manager/fm-directory-view.c Wed Mar 5 15:29:45 2008
@@ -4180,7 +4180,21 @@
}
static void
-add_x_content_apps (NautilusFile *file, GList **applications)
+get_x_content_async_callback (char **content,
+ gpointer user_data)
+{
+ FMDirectoryView *view;
+
+ view = FM_DIRECTORY_VIEW (user_data);
+
+ if (view->details->window != NULL) {
+ schedule_update_menus (view);
+ }
+ g_object_unref (view);
+}
+
+static void
+add_x_content_apps (FMDirectoryView *view, NautilusFile *file, GList **applications)
{
GMount *mount;
char **x_content_types;
@@ -4194,8 +4208,7 @@
return;
}
- x_content_types = nautilus_autorun_get_x_content_types_for_mount (mount, FALSE);
-
+ x_content_types = nautilus_autorun_get_cached_x_content_types_for_mount (mount);
if (x_content_types != NULL) {
for (n = 0; x_content_types[n] != NULL; n++) {
char *x_content_type = x_content_types[n];
@@ -4205,6 +4218,12 @@
*applications = g_list_concat (*applications, app_info_for_x_content_type);
}
g_strfreev (x_content_types);
+ } else {
+ nautilus_autorun_get_x_content_types_for_mount_async (mount,
+ get_x_content_async_callback,
+ NULL,
+ g_object_ref (view));
+
}
g_object_unref (mount);
@@ -4261,7 +4280,7 @@
}
if (g_list_length (selection) == 1) {
- add_x_content_apps (NAUTILUS_FILE (selection->data), &applications);
+ add_x_content_apps (view, NAUTILUS_FILE (selection->data), &applications);
}
Modified: trunk/src/nautilus-window-manage-views.c
==============================================================================
--- trunk/src/nautilus-window-manage-views.c (original)
+++ trunk/src/nautilus-window-manage-views.c Wed Mar 5 15:29:45 2008
@@ -1297,7 +1297,7 @@
}
static void
-nautilus_window_show_x_content_bar (NautilusWindow *window, GMount *mount, char **x_content_types)
+nautilus_window_show_x_content_bar (NautilusWindow *window, GMount *mount, const char **x_content_types)
{
unsigned int n;
@@ -1339,9 +1339,34 @@
typedef struct {
NautilusWindow *window;
GCancellable *cancellable;
+ GMount *mount;
} FindMountData;
static void
+found_content_type_cb (const char **x_content_types, FindMountData *data)
+{
+ NautilusWindow *window;
+
+ if (g_cancellable_is_cancelled (data->cancellable)) {
+ goto out;
+ }
+
+ window = data->window;
+
+ if (x_content_types != NULL && x_content_types[0] != NULL) {
+ nautilus_window_show_x_content_bar (window, data->mount, x_content_types);
+ update_extra_location_widgets_visibility (window);
+ }
+
+ window->details->find_mount_cancellable = NULL;
+
+ out:
+ g_object_unref (data->mount);
+ g_object_unref (data->cancellable);
+ g_free (data);
+}
+
+static void
found_mount_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -1349,7 +1374,6 @@
FindMountData *data = user_data;
GMount *mount;
NautilusWindow *window;
- char **x_content_types;
if (g_cancellable_is_cancelled (data->cancellable)) {
goto out;
@@ -1361,14 +1385,12 @@
res,
NULL);
if (mount != NULL) {
- x_content_types = nautilus_autorun_get_x_content_types_for_mount (mount, FALSE);
- if (x_content_types != NULL && x_content_types[0] != NULL) {
- nautilus_window_show_x_content_bar (window, mount, x_content_types);
- update_extra_location_widgets_visibility (window);
- }
- g_strfreev (x_content_types);
-
- g_object_unref (mount);
+ data->mount = mount;
+ nautilus_autorun_get_x_content_types_for_mount_async (mount,
+ (NautilusAutorunGetContent)found_content_type_cb,
+ data->cancellable,
+ data);
+ return;
}
window->details->find_mount_cancellable = NULL;
@@ -1455,6 +1477,7 @@
data = g_new (FindMountData, 1);
data->window = window;
data->cancellable = g_cancellable_new ();
+ data->mount = NULL;
window->details->find_mount_cancellable = data->cancellable;
g_file_find_enclosing_mount_async (window->details->location,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]