diff options
author | Michael Meeks <michael@ximian.com> | 2002-05-31 16:18:12 +0000 |
---|---|---|
committer | Michael Meeks <michael@src.gnome.org> | 2002-05-31 16:18:12 +0000 |
commit | be0eed841ea8be591b85c56fa7788c1ac7648d3a (patch) | |
tree | 05b8097890c6457860507026185956e9cd556285 | |
parent | 892e12fc058de0bb83875d5be079dc63993af2c0 (diff) | |
download | nautilus-be0eed841ea8be591b85c56fa7788c1ac7648d3a.tar.gz |
upd. (get_file_load_method): impl.
2002-05-31 Michael Meeks <michael@ximian.com>
* components/adapter/nautilus-adapter-file-load-strategy.c
(nautilus_adapter_file_load_strategy_load_location): upd.
(get_file_load_method): impl.
* components/adapter/nautilus-adapter-stream-load-strategy.c
(nautilus_adapter_stream_load_strategy_load_location): upd.
(unref_stream_cb, get_stream_load_method): impl.
* components/adapter/nautilus-adapter-load-strategy.c
(nautilus_adapter_load_strategy_load_async): impl.
(nautilus_adapter_load_strategy_report_async_status): impl.
(nautilus_adapter_load_strategy_report_load_failed),
(nautilus_adapter_load_strategy_report_load_complete): prune.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | components/adapter/nautilus-adapter-file-load-strategy.c | 45 | ||||
-rw-r--r-- | components/adapter/nautilus-adapter-load-strategy.c | 79 | ||||
-rw-r--r-- | components/adapter/nautilus-adapter-load-strategy.h | 6 | ||||
-rw-r--r-- | components/adapter/nautilus-adapter-stream-load-strategy.c | 53 |
5 files changed, 163 insertions, 36 deletions
@@ -1,5 +1,21 @@ 2002-05-31 Michael Meeks <michael@ximian.com> + * components/adapter/nautilus-adapter-file-load-strategy.c + (nautilus_adapter_file_load_strategy_load_location): upd. + (get_file_load_method): impl. + + * components/adapter/nautilus-adapter-stream-load-strategy.c + (nautilus_adapter_stream_load_strategy_load_location): upd. + (unref_stream_cb, get_stream_load_method): impl. + + * components/adapter/nautilus-adapter-load-strategy.c + (nautilus_adapter_load_strategy_load_async): impl. + (nautilus_adapter_load_strategy_report_async_status): impl. + (nautilus_adapter_load_strategy_report_load_failed), + (nautilus_adapter_load_strategy_report_load_complete): prune. + +2002-05-31 Michael Meeks <michael@ximian.com> + * src/file-manager/fm-directory-view.c (display_pending_idle_callback): only NIL the idle_id if we are going to return FALSE and disconnect diff --git a/components/adapter/nautilus-adapter-file-load-strategy.c b/components/adapter/nautilus-adapter-file-load-strategy.c index 31c36b756..caf43672c 100644 --- a/components/adapter/nautilus-adapter-file-load-strategy.c +++ b/components/adapter/nautilus-adapter-file-load-strategy.c @@ -30,6 +30,7 @@ #include <config.h> +#include <string.h> #include "nautilus-adapter-file-load-strategy.h" #include <gtk/gtkobject.h> @@ -114,44 +115,59 @@ nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file) return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy); } +static ORBit_IMethod * +get_file_load_method (void) +{ + guint i; + ORBit_IInterface *iface; + static ORBit_IMethod *method = NULL; + + iface = &Bonobo_PersistFile__iinterface; + if (!method) { + for (i = 0; i < iface->methods._length; i++) { + if (!strcmp ("load", iface->methods._buffer [i].name)) { + method = &iface->methods._buffer [i]; + } + } + } + g_assert (method); + + return method; +} static void nautilus_adapter_file_load_strategy_load_location (NautilusAdapterLoadStrategy *abstract_strategy, const char *uri) { - CORBA_Environment ev; - NautilusAdapterFileLoadStrategy *strategy; char *local_path; + gpointer args[1]; + NautilusAdapterFileLoadStrategy *strategy; strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (abstract_strategy); g_object_ref (strategy); - CORBA_exception_init (&ev); - local_path = gnome_vfs_get_local_path_from_uri (uri); if (local_path == NULL) { nautilus_adapter_load_strategy_report_load_failed (abstract_strategy); - CORBA_exception_free (&ev); return; } nautilus_adapter_load_strategy_report_load_underway (abstract_strategy); - Bonobo_PersistFile_load (strategy->details->persist_file, local_path, &ev); - - if (ev._major == CORBA_NO_EXCEPTION) { - nautilus_adapter_load_strategy_report_load_complete (abstract_strategy); - } else { - nautilus_adapter_load_strategy_report_load_failed (abstract_strategy); - } + args [0] = &local_path; + + nautilus_adapter_load_strategy_load_async ( + abstract_strategy, + strategy->details->persist_file, + get_file_load_method (), + args, + NULL, NULL); g_object_unref (strategy); - CORBA_exception_free (&ev); - g_free (local_path); } @@ -162,3 +178,4 @@ nautilus_adapter_file_load_strategy_stop_loading (NautilusAdapterLoadStrategy * g_return_if_fail (NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY (abstract_strategy)); } + diff --git a/components/adapter/nautilus-adapter-load-strategy.c b/components/adapter/nautilus-adapter-load-strategy.c index e7da4963b..4c1a31961 100644 --- a/components/adapter/nautilus-adapter-load-strategy.c +++ b/components/adapter/nautilus-adapter-load-strategy.c @@ -37,8 +37,7 @@ #include <gtk/gtkobject.h> #include <eel/eel-gtk-macros.h> #include <eel/eel-gtk-extensions.h> - - +#include <bonobo/bonobo-exception.h> enum { REPORT_LOAD_UNDERWAY, @@ -201,15 +200,79 @@ nautilus_adapter_load_strategy_report_load_progress (NautilusAdapterLoadStrateg } void -nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy) +nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy) { - g_signal_emit (strategy, - signals[REPORT_LOAD_COMPLETE], 0); + g_signal_emit (strategy, signals[REPORT_LOAD_COMPLETE], 0); } void -nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy) +nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy) { - g_signal_emit (strategy, - signals[REPORT_LOAD_FAILED], 0); + g_signal_emit (strategy, signals[REPORT_LOAD_FAILED], 0); +} + +typedef struct { + gpointer user_data; + GDestroyNotify done_cb; + NautilusAdapterLoadStrategy *strategy; +} AsyncClosure; + +static void +nautilus_adapter_load_strategy_report_async_status (CORBA_Object object, + ORBit_IMethod *m_data, + ORBitAsyncQueueEntry *aqe, + gpointer user_data, + CORBA_Environment *ev) +{ + AsyncClosure *c; + + c = user_data; + g_return_if_fail (NAUTILUS_IS_ADAPTER_LOAD_STRATEGY (c->strategy)); + + if (BONOBO_EX (ev)) { + nautilus_adapter_load_strategy_report_load_failed (c->strategy); + } else { + nautilus_adapter_load_strategy_report_load_complete (c->strategy); + } + + g_object_unref (c->strategy); + + if (c->done_cb) { + c->done_cb (c->user_data); + } + + g_free (c); +} + +void +nautilus_adapter_load_strategy_load_async (NautilusAdapterLoadStrategy *strategy, + CORBA_Object object, + ORBit_IMethod *m_data, + gpointer *args, + GDestroyNotify done_cb, + gpointer user_data) +{ + AsyncClosure *c; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + c = g_new (AsyncClosure, 1); + c->done_cb = done_cb; + c->strategy = strategy; + c->user_data = user_data; + + g_object_ref (G_OBJECT (strategy)); + + ORBit_small_invoke_async + (object, m_data, + nautilus_adapter_load_strategy_report_async_status, + c, args, NULL, &ev); + + if (BONOBO_EX (&ev)) { + nautilus_adapter_load_strategy_report_async_status ( + object, m_data, NULL, c, &ev); + } + + CORBA_exception_free (&ev); } diff --git a/components/adapter/nautilus-adapter-load-strategy.h b/components/adapter/nautilus-adapter-load-strategy.h index c3d941479..2bf9e6d84 100644 --- a/components/adapter/nautilus-adapter-load-strategy.h +++ b/components/adapter/nautilus-adapter-load-strategy.h @@ -79,6 +79,12 @@ void nautilus_adapter_load_strategy_report_load_progress void nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy); void nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy); +void nautilus_adapter_load_strategy_load_async (NautilusAdapterLoadStrategy *strategy, + CORBA_Object object, + ORBit_IMethod *m_data, + gpointer *args, + GDestroyNotify done_cb, + gpointer user_data); #endif /* NAUTILUS_ADAPTER_LOAD_STRATEGY_H */ diff --git a/components/adapter/nautilus-adapter-stream-load-strategy.c b/components/adapter/nautilus-adapter-stream-load-strategy.c index 13361f568..1fb619634 100644 --- a/components/adapter/nautilus-adapter-stream-load-strategy.c +++ b/components/adapter/nautilus-adapter-stream-load-strategy.c @@ -30,6 +30,7 @@ #include <config.h> +#include <string.h> #include "nautilus-adapter-stream-load-strategy.h" #include <bonobo/bonobo-stream.h> @@ -114,6 +115,31 @@ nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream) return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy); } +static ORBit_IMethod * +get_stream_load_method (void) +{ + guint i; + ORBit_IInterface *iface; + static ORBit_IMethod *method = NULL; + + iface = &Bonobo_PersistStream__iinterface; + if (!method) { + for (i = 0; i < iface->methods._length; i++) { + if (!strcmp ("load", iface->methods._buffer [i].name)) { + method = &iface->methods._buffer [i]; + } + } + } + g_assert (method); + + return method; +} + +static void +unref_stream_cb (gpointer user_data) +{ + bonobo_object_release_unref (user_data, NULL); +} static void nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy *abstract_strategy, @@ -124,6 +150,8 @@ nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy CORBA_Environment ev; char *moniker_str; char *escaped_uri; + char *mime_type; + gpointer args[2]; strategy = NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY (abstract_strategy); g_object_ref (strategy); @@ -153,22 +181,19 @@ nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy * it should be easy to keep it around and pass it in here. */ - Bonobo_PersistStream_load - (strategy->details->persist_stream, - stream, - "", /* MIME type of stream */ - &ev); - - bonobo_object_release_unref (stream, &ev); - - if (ev._major == CORBA_NO_EXCEPTION) { - nautilus_adapter_load_strategy_report_load_complete (abstract_strategy); - } else { - nautilus_adapter_load_strategy_report_load_failed (abstract_strategy); - } + mime_type = ""; + args [0] = &stream; + args [1] = &mime_type; + + nautilus_adapter_load_strategy_load_async ( + abstract_strategy, + strategy->details->persist_stream, + get_stream_load_method (), + args, + unref_stream_cb, + stream); } - g_object_unref (strategy); CORBA_exception_free (&ev); |