summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Stachowiak <mstachow@src.gnome.org>2000-10-03 04:12:50 +0000
committerMaciej Stachowiak <mstachow@src.gnome.org>2000-10-03 04:12:50 +0000
commit10b8bae1c2bf9199ed396af201a8e59ee6a4c76d (patch)
treeabcb7d8102bdd1fa47a8478b93e199b864e2b707
parentf82a3ba61e08c658c8982e017c70ec649e2e74f0 (diff)
downloadnautilus-10b8bae1c2bf9199ed396af201a8e59ee6a4c76d.tar.gz
Fixed bug 3223.
* components/adapter/nautilus-adapter-file-load-strategy.c: (nautilus_adapter_file_load_strategy_new), (nautilus_adapter_file_load_strategy_load_location): * components/adapter/nautilus-adapter-file-load-strategy.h: * components/adapter/nautilus-adapter-load-strategy.c: (nautilus_adapter_load_strategy_initialize_class), (nautilus_adapter_load_strategy_get), (nautilus_adapter_load_strategy_stop_loading), (nautilus_adapter_load_strategy_report_load_underway), (nautilus_adapter_load_strategy_report_load_progress), (nautilus_adapter_load_strategy_report_load_complete), (nautilus_adapter_load_strategy_report_load_failed): * components/adapter/nautilus-adapter-load-strategy.h: * components/adapter/nautilus-adapter-progressive-load-strategy.c: (nautilus_adapter_progressive_load_strategy_destroy), (nautilus_adapter_progressive_load_strategy_new), (stop_loading), (nautilus_adapter_progressive_load_strategy_load_location), (nautilus_adapter_progressive_load_strategy_stop_loading): * components/adapter/nautilus-adapter-progressive-load-strategy.h: * components/adapter/nautilus-adapter-stream-load-strategy.c: (nautilus_adapter_stream_load_strategy_new), (nautilus_adapter_stream_load_strategy_load_location): * components/adapter/nautilus-adapter-stream-load-strategy.h: * components/adapter/nautilus-adapter.c: (nautilus_adapter_destroy), (nautilus_adapter_new), (nautilus_adapter_load_underway_callback), (nautilus_adapter_load_progress_callback), (nautilus_adapter_load_complete_callback), (nautilus_adapter_load_failed_callback): Changed the load strategies to no longer depend on the view; instead, they emit appropriate signals at different stages of progress, which the NautilusAdapter object hooks into (connecting with _connect_object_while_alive). Also, the progressive load strategy now checks for cancellation around various CORBA calls, so it should actually respect the stop button. * AUTHORS, THANKS, check-THANKS.pl: Updated Josh Barrow's email address.
-rw-r--r--AUTHORS2
-rw-r--r--ChangeLog43
-rw-r--r--THANKS1
-rwxr-xr-xcheck-THANKS.pl5
-rw-r--r--components/adapter/nautilus-adapter-file-load-strategy.c18
-rw-r--r--components/adapter/nautilus-adapter-file-load-strategy.h3
-rw-r--r--components/adapter/nautilus-adapter-load-strategy.c89
-rw-r--r--components/adapter/nautilus-adapter-load-strategy.h30
-rw-r--r--components/adapter/nautilus-adapter-progressive-load-strategy.c107
-rw-r--r--components/adapter/nautilus-adapter-progressive-load-strategy.h3
-rw-r--r--components/adapter/nautilus-adapter-stream-load-strategy.c17
-rw-r--r--components/adapter/nautilus-adapter-stream-load-strategy.h3
-rw-r--r--components/adapter/nautilus-adapter.c67
13 files changed, 310 insertions, 78 deletions
diff --git a/AUTHORS b/AUTHORS
index 3db6f1066..952e41f3c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,7 +10,7 @@ Gene Z. Ragan <gzr@eazel.com>
George Lebl <jirka@5z.com>
Ian McKellar <yakk@yakk.net.au>
John Sullivan <sullivan@eazel.com>
-Josh Barrow <linuxfan@ionet.net>
+Josh Barrow <josh@eazel.com>
J Shane Culpepper <pepper@eazel.com>
Maciej Stachowiak <mjs@eazel.com>
Mathieu Lacage <mathieu@eazel.com>
diff --git a/ChangeLog b/ChangeLog
index ef3c132b7..a9a5f305c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2000-10-02 Maciej Stachowiak <mjs@eazel.com>
+
+ Fixed bug 3223.
+
+ * components/adapter/nautilus-adapter-file-load-strategy.c:
+ (nautilus_adapter_file_load_strategy_new),
+ (nautilus_adapter_file_load_strategy_load_location):
+ * components/adapter/nautilus-adapter-file-load-strategy.h:
+ * components/adapter/nautilus-adapter-load-strategy.c:
+ (nautilus_adapter_load_strategy_initialize_class),
+ (nautilus_adapter_load_strategy_get),
+ (nautilus_adapter_load_strategy_stop_loading),
+ (nautilus_adapter_load_strategy_report_load_underway),
+ (nautilus_adapter_load_strategy_report_load_progress),
+ (nautilus_adapter_load_strategy_report_load_complete),
+ (nautilus_adapter_load_strategy_report_load_failed):
+ * components/adapter/nautilus-adapter-load-strategy.h:
+ * components/adapter/nautilus-adapter-progressive-load-strategy.c:
+ (nautilus_adapter_progressive_load_strategy_destroy),
+ (nautilus_adapter_progressive_load_strategy_new), (stop_loading),
+ (nautilus_adapter_progressive_load_strategy_load_location),
+ (nautilus_adapter_progressive_load_strategy_stop_loading):
+ * components/adapter/nautilus-adapter-progressive-load-strategy.h:
+ * components/adapter/nautilus-adapter-stream-load-strategy.c:
+ (nautilus_adapter_stream_load_strategy_new),
+ (nautilus_adapter_stream_load_strategy_load_location):
+ * components/adapter/nautilus-adapter-stream-load-strategy.h:
+ * components/adapter/nautilus-adapter.c:
+ (nautilus_adapter_destroy), (nautilus_adapter_new),
+ (nautilus_adapter_load_underway_callback),
+ (nautilus_adapter_load_progress_callback),
+ (nautilus_adapter_load_complete_callback),
+ (nautilus_adapter_load_failed_callback): Changed the load
+ strategies to no longer depend on the view; instead, they emit
+ appropriate signals at different stages of progress, which the
+ NautilusAdapter object hooks into (connecting with
+ _connect_object_while_alive). Also, the progressive load strategy
+ now checks for cancellation around various CORBA calls, so it
+ should actually respect the stop button.
+
+ * AUTHORS, THANKS, check-THANKS.pl: Updated Josh Barrow's email
+ address.
+
2000-10-02 Ramiro Estrugo <ramiro@eazel.com>
* test/test-nautilus-label.c: (delete_event), (main):
diff --git a/THANKS b/THANKS
index 32bcce45e..abb83e021 100644
--- a/THANKS
+++ b/THANKS
@@ -20,6 +20,7 @@ Morten Welinder <terra@diku.dk> - check-fixme suggestions
Richard Hult <rhult@hem.passagen.se> - bug reporting
Robert Brady <rwb197@zepler.org> - bugfixes
Shane Butlers <sbutle@deakin.edu.au> - IDE in hardware view patch for showing IDE
+Victor Lecha <victor@eazel.com> - testing, build fixes.
As well as the following people who contributed translations:
diff --git a/check-THANKS.pl b/check-THANKS.pl
index e9016924c..5e5b49a18 100755
--- a/check-THANKS.pl
+++ b/check-THANKS.pl
@@ -58,7 +58,8 @@ my %email_map = ('at@ue-spacy.com' => 'tagoh@gnome.gr.jp',
'kmaraas@online.no' => 'kmaraas@gnome.org',
'kmaraas@gnu.org' => 'kmaraas@gnome.org',
'raph@gimp.org' => 'raph@acm.org',
- 'baulig@suse.de' => 'martin@home-of-linux.org');
+ 'baulig@suse.de' => 'martin@home-of-linux.org'
+ 'linuxfan@ionet.net' => 'josh@eazel.com');
# Some ChangeLog lines that carry no credit (incorrect changes that
@@ -178,7 +179,7 @@ if (@uncredited) {
print "The following people are in the ChangeLog but not credited in THANKS or AUTHORS:\n\n";
foreach my $person (@uncredited) {
- print "xx ${person}\n";
+ print "${person}\n";
}
print "\n";
}
diff --git a/components/adapter/nautilus-adapter-file-load-strategy.c b/components/adapter/nautilus-adapter-file-load-strategy.c
index f93cc4cf7..9f3c717f6 100644
--- a/components/adapter/nautilus-adapter-file-load-strategy.c
+++ b/components/adapter/nautilus-adapter-file-load-strategy.c
@@ -40,7 +40,6 @@
struct NautilusAdapterFileLoadStrategyDetails {
Bonobo_PersistFile persist_file;
- NautilusView *nautilus_view;
};
@@ -102,8 +101,7 @@ nautilus_adapter_file_load_strategy_destroy (GtkObject *object)
NautilusAdapterLoadStrategy *
-nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file,
- NautilusView *view)
+nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file)
{
NautilusAdapterFileLoadStrategy *strategy;
@@ -112,7 +110,6 @@ nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file,
gtk_object_sink (GTK_OBJECT (strategy));
strategy->details->persist_file = persist_file;
- strategy->details->nautilus_view = view;
return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy);
}
@@ -129,27 +126,30 @@ nautilus_adapter_file_load_strategy_load_location (NautilusAdapterLoadStrategy *
strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (abstract_strategy);
+ gtk_object_ref (GTK_OBJECT (strategy));
+
CORBA_exception_init (&ev);
local_path = gnome_vfs_get_local_path_from_uri (uri);
if (local_path == NULL) {
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_failed (abstract_strategy);
CORBA_exception_free (&ev);
return;
}
- nautilus_view_report_load_underway (strategy->details->nautilus_view);
+ 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_view_report_load_complete (strategy->details->nautilus_view);
-
+ nautilus_adapter_load_strategy_report_load_complete (abstract_strategy);
} else {
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_failed (abstract_strategy);
}
+ gtk_object_unref (GTK_OBJECT (strategy));
+
CORBA_exception_free (&ev);
g_free (local_path);
diff --git a/components/adapter/nautilus-adapter-file-load-strategy.h b/components/adapter/nautilus-adapter-file-load-strategy.h
index 7f1660c78..8c7588da8 100644
--- a/components/adapter/nautilus-adapter-file-load-strategy.h
+++ b/components/adapter/nautilus-adapter-file-load-strategy.h
@@ -49,8 +49,7 @@ typedef struct {
/* GtkObject support */
GtkType nautilus_adapter_file_load_strategy_get_type (void);
-NautilusAdapterLoadStrategy *nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file,
- NautilusView *view);
+NautilusAdapterLoadStrategy *nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file);
#endif /* NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H */
diff --git a/components/adapter/nautilus-adapter-load-strategy.c b/components/adapter/nautilus-adapter-load-strategy.c
index dfdf49dc5..575d0547a 100644
--- a/components/adapter/nautilus-adapter-load-strategy.c
+++ b/components/adapter/nautilus-adapter-load-strategy.c
@@ -37,6 +37,20 @@
#include <gtk/gtkobject.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+
+
+
+enum {
+ REPORT_LOAD_UNDERWAY,
+ REPORT_LOAD_PROGRESS,
+ REPORT_LOAD_COMPLETE,
+ REPORT_LOAD_FAILED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
static void nautilus_adapter_load_strategy_initialize_class (NautilusAdapterLoadStrategyClass *klass);
@@ -59,6 +73,38 @@ nautilus_adapter_load_strategy_initialize_class (NautilusAdapterLoadStrategyClas
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_load_strategy, load_location);
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_load_strategy, stop_loading);
+
+
+ signals[REPORT_LOAD_UNDERWAY] =
+ gtk_signal_new ("report_load_underway",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusAdapterLoadStrategyClass, report_load_underway),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ signals[REPORT_LOAD_PROGRESS] =
+ gtk_signal_new ("report_load_progress",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusAdapterLoadStrategyClass, report_load_progress),
+ nautilus_gtk_marshal_NONE__DOUBLE,
+ GTK_TYPE_NONE, 1, GTK_TYPE_DOUBLE);
+ signals[REPORT_LOAD_COMPLETE] =
+ gtk_signal_new ("report_load_complete",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusAdapterLoadStrategyClass, report_load_complete),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ signals[REPORT_LOAD_FAILED] =
+ gtk_signal_new ("report_load_failed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (NautilusAdapterLoadStrategyClass, report_load_failed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
static void
@@ -81,8 +127,7 @@ nautilus_adapter_load_strategy_destroy (GtkObject *object)
NautilusAdapterLoadStrategy *
-nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
- NautilusView *view)
+nautilus_adapter_load_strategy_get (Bonobo_Unknown component)
{
Bonobo_PersistStream persist_stream;
Bonobo_PersistFile persist_file;
@@ -98,7 +143,7 @@ nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (progressive_data_sink, &ev)) {
CORBA_exception_free (&ev);
- return nautilus_adapter_progressive_load_strategy_new (progressive_data_sink, view);
+ return nautilus_adapter_progressive_load_strategy_new (progressive_data_sink);
}
@@ -108,7 +153,7 @@ nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (persist_stream, &ev)) {
CORBA_exception_free (&ev);
- return nautilus_adapter_stream_load_strategy_new (persist_stream, view);
+ return nautilus_adapter_stream_load_strategy_new (persist_stream);
}
@@ -119,10 +164,9 @@ nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (persist_file, &ev)) {
CORBA_exception_free (&ev);
- return nautilus_adapter_file_load_strategy_new (persist_file, view);
+ return nautilus_adapter_file_load_strategy_new (persist_file);
}
-
CORBA_exception_free (&ev);
return NULL;
@@ -148,3 +192,36 @@ nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strat
NAUTILUS_CALL_VIRTUAL (NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS, strategy,
stop_loading, (strategy));
}
+
+
+/* "protected" calls, should only be called by subclasses */
+
+void
+nautilus_adapter_load_strategy_report_load_underway (NautilusAdapterLoadStrategy *strategy)
+{
+ gtk_signal_emit (GTK_OBJECT (strategy),
+ signals[REPORT_LOAD_UNDERWAY]);
+}
+
+void
+nautilus_adapter_load_strategy_report_load_progress (NautilusAdapterLoadStrategy *strategy,
+ double fraction_done)
+{
+ gtk_signal_emit (GTK_OBJECT (strategy),
+ signals[REPORT_LOAD_PROGRESS],
+ fraction_done);
+}
+
+void
+nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy)
+{
+ gtk_signal_emit (GTK_OBJECT (strategy),
+ signals[REPORT_LOAD_COMPLETE]);
+}
+
+void
+nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy)
+{
+ gtk_signal_emit (GTK_OBJECT (strategy),
+ signals[REPORT_LOAD_FAILED]);
+}
diff --git a/components/adapter/nautilus-adapter-load-strategy.h b/components/adapter/nautilus-adapter-load-strategy.h
index 46af192ce..c3d941479 100644
--- a/components/adapter/nautilus-adapter-load-strategy.h
+++ b/components/adapter/nautilus-adapter-load-strategy.h
@@ -46,24 +46,38 @@ typedef struct {
typedef struct {
GtkObjectClass parent;
+ /* signals */
+ void (* report_load_underway) (NautilusAdapterLoadStrategy *strategy);
+ void (* report_load_progress) (NautilusAdapterLoadStrategy *strategy,
+ double fraction_done);
+ void (* report_load_complete) (NautilusAdapterLoadStrategy *strategy);
+ void (* report_load_failed) (NautilusAdapterLoadStrategy *strategy);
+
+ /* virtual methods */
void (*load_location) (NautilusAdapterLoadStrategy *strategy,
const char *uri);
void (*stop_loading) (NautilusAdapterLoadStrategy *strategy);
-
-
} NautilusAdapterLoadStrategyClass;
/* GtkObject support */
-GtkType nautilus_adapter_load_strategy_get_type (void);
+GtkType nautilus_adapter_load_strategy_get_type (void);
/* Instantiates the proper concrete subclass */
-NautilusAdapterLoadStrategy *nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
- NautilusView *view);
+NautilusAdapterLoadStrategy *nautilus_adapter_load_strategy_get (Bonobo_Unknown component);
+
+void nautilus_adapter_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy,
+ const char *uri);
+void nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy);
+
+
+/* "protected" calls, should only be called by subclasses */
-void nautilus_adapter_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy,
- const char *uri);
-void nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy);
+void nautilus_adapter_load_strategy_report_load_underway (NautilusAdapterLoadStrategy *strategy);
+void nautilus_adapter_load_strategy_report_load_progress (NautilusAdapterLoadStrategy *strategy,
+ double fraction_done);
+void nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy);
+void nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy);
#endif /* NAUTILUS_ADAPTER_LOAD_STRATEGY_H */
diff --git a/components/adapter/nautilus-adapter-progressive-load-strategy.c b/components/adapter/nautilus-adapter-progressive-load-strategy.c
index 12bad24c3..4a82a56fe 100644
--- a/components/adapter/nautilus-adapter-progressive-load-strategy.c
+++ b/components/adapter/nautilus-adapter-progressive-load-strategy.c
@@ -41,7 +41,7 @@
struct NautilusAdapterProgressiveLoadStrategyDetails {
Bonobo_ProgressiveDataSink progressive_data_sink;
- NautilusView *nautilus_view;
+ gboolean stop;
};
@@ -86,39 +86,72 @@ nautilus_adapter_progressive_load_strategy_destroy (GtkObject *object)
NautilusAdapterProgressiveLoadStrategy *strategy;
CORBA_Environment ev;
+ CORBA_exception_init (&ev);
+
strategy = NAUTILUS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY (object);
if (strategy->details->progressive_data_sink != CORBA_OBJECT_NIL) {
- CORBA_exception_init (&ev);
bonobo_object_release_unref (strategy->details->progressive_data_sink, &ev);
- CORBA_exception_free (&ev);
}
+ CORBA_exception_free (&ev);
+
g_free (strategy->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
-
-
-
NautilusAdapterLoadStrategy *
-nautilus_adapter_progressive_load_strategy_new (Bonobo_ProgressiveDataSink progressive_data_sink,
- NautilusView *view)
+nautilus_adapter_progressive_load_strategy_new (Bonobo_ProgressiveDataSink progressive_data_sink)
{
NautilusAdapterProgressiveLoadStrategy *strategy;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
strategy = NAUTILUS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY (gtk_object_new (NAUTILUS_TYPE_ADAPTER_PROGRESSIVE_LOAD_STRATEGY, NULL));
gtk_object_ref (GTK_OBJECT (strategy));
gtk_object_sink (GTK_OBJECT (strategy));
strategy->details->progressive_data_sink = progressive_data_sink;
- strategy->details->nautilus_view = view;
+
+ CORBA_exception_free (&ev);
return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy);
}
-#define LOAD_CHUNK 512
+
+static void
+stop_loading (NautilusAdapterProgressiveLoadStrategy *strategy,
+ GnomeVFSHandle *handle,
+ Bonobo_ProgressiveDataSink_iobuf *iobuf,
+ CORBA_Environment *ev)
+{
+ Bonobo_ProgressiveDataSink_end (strategy->details->progressive_data_sink, ev);
+ nautilus_adapter_load_strategy_report_load_failed (NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy));
+ gtk_object_unref (GTK_OBJECT (strategy));
+ gnome_vfs_close (handle);
+ CORBA_free (iobuf);
+ CORBA_exception_free (ev);
+}
+
+
+
+#define STOP_LOADING \
+ do { \
+ stop_loading (strategy, handle, iobuf, &ev); \
+ return; \
+ } while (0)
+
+#define CHECK_IF_STOPPED \
+ do { \
+ if (strategy->details->stop) { \
+ STOP_LOADING; \
+ } \
+ } while (0)
+
+
+#define LOAD_CHUNK 2048
static void
nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStrategy *abstract_strategy,
@@ -135,15 +168,18 @@ nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStr
strategy = NAUTILUS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY (abstract_strategy);
+ strategy->details->stop = FALSE;
+ gtk_object_ref (GTK_OBJECT (strategy));
+
CORBA_exception_init (&ev);
/* FIXME: this code is stupid and loads the component in a way
that blocks the nautilus adapter component, which is
pointless/stupid; it should be async. */
-
if (gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ) != GNOME_VFS_OK) {
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_failed (abstract_strategy);
+ gtk_object_unref (GTK_OBJECT (strategy));
CORBA_exception_free (&ev);
return;
}
@@ -153,10 +189,19 @@ nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStr
data = CORBA_sequence_CORBA_octet_allocbuf (LOAD_CHUNK);
iobuf->_buffer = data;
- nautilus_view_report_load_underway (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_underway (abstract_strategy);
+
+ if (strategy->details->stop) {
+ nautilus_adapter_load_strategy_report_load_failed (abstract_strategy);
+ gtk_object_unref (GTK_OBJECT (strategy));
+ CORBA_exception_free (&ev);
+ return;
+ }
Bonobo_ProgressiveDataSink_start (strategy->details->progressive_data_sink, &ev);
+ CHECK_IF_STOPPED;
+
gnome_vfs_file_info_init (&file_info);
result = gnome_vfs_get_file_info_from_handle (handle, &file_info, GNOME_VFS_FILE_INFO_DEFAULT);
gnome_vfs_file_info_clear (&file_info);
@@ -164,6 +209,7 @@ nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStr
if (result == GNOME_VFS_OK && file_info.valid_fields | GNOME_VFS_FILE_INFO_FIELDS_SIZE) {
Bonobo_ProgressiveDataSink_set_size (strategy->details->progressive_data_sink,
(long) file_info.size, &ev);
+ CHECK_IF_STOPPED;
}
do {
@@ -174,37 +220,36 @@ nautilus_adapter_progressive_load_strategy_load_location (NautilusAdapterLoadStr
Bonobo_ProgressiveDataSink_add_data (strategy->details->progressive_data_sink, iobuf, &ev);
+ CHECK_IF_STOPPED;
+
if (ev._major != CORBA_NO_EXCEPTION) {
- Bonobo_ProgressiveDataSink_end (strategy->details->progressive_data_sink, &ev);
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
- break;
+ STOP_LOADING;
}
} else if (result == GNOME_VFS_ERROR_EOF) {
- Bonobo_ProgressiveDataSink_end (strategy->details->progressive_data_sink, &ev);
if (ev._major == CORBA_NO_EXCEPTION) {
- nautilus_view_report_load_complete (strategy->details->nautilus_view);
+ Bonobo_ProgressiveDataSink_end (strategy->details->progressive_data_sink, &ev);
+ nautilus_adapter_load_strategy_report_load_complete (abstract_strategy);
+ gtk_object_unref (GTK_OBJECT (strategy));
+ gnome_vfs_close (handle);
+ CORBA_free (iobuf);
+ CORBA_exception_free (&ev);
+ return;
} else {
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ STOP_LOADING;
}
} else {
- Bonobo_ProgressiveDataSink_end (strategy->details->progressive_data_sink, &ev);
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ STOP_LOADING;
}
- } while (result == GNOME_VFS_OK);
-
-
- gnome_vfs_close (handle);
-
- CORBA_free (iobuf);
-
- CORBA_exception_free (&ev);
+ } while (TRUE);
}
static void
-nautilus_adapter_progressive_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy)
+nautilus_adapter_progressive_load_strategy_stop_loading (NautilusAdapterLoadStrategy *abstract_strategy)
{
+ NautilusAdapterProgressiveLoadStrategy *strategy;
- g_return_if_fail (NAUTILUS_IS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY (strategy));
+ strategy = NAUTILUS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY (abstract_strategy);
+ strategy->details->stop = TRUE;
}
diff --git a/components/adapter/nautilus-adapter-progressive-load-strategy.h b/components/adapter/nautilus-adapter-progressive-load-strategy.h
index b0a991b15..7c8aea0f8 100644
--- a/components/adapter/nautilus-adapter-progressive-load-strategy.h
+++ b/components/adapter/nautilus-adapter-progressive-load-strategy.h
@@ -49,8 +49,7 @@ typedef struct {
/* GtkObject support */
GtkType nautilus_adapter_progressive_load_strategy_get_type (void);
-NautilusAdapterLoadStrategy *nautilus_adapter_progressive_load_strategy_new (Bonobo_ProgressiveDataSink progressive_data_sink,
- NautilusView *view);
+NautilusAdapterLoadStrategy *nautilus_adapter_progressive_load_strategy_new (Bonobo_ProgressiveDataSink progressive_data_sink);
#endif /* NAUTILUS_ADAPTER_PROGRESSIVE_LOAD_STRATEGY_H */
diff --git a/components/adapter/nautilus-adapter-stream-load-strategy.c b/components/adapter/nautilus-adapter-stream-load-strategy.c
index c1f805784..19dcfb1f9 100644
--- a/components/adapter/nautilus-adapter-stream-load-strategy.c
+++ b/components/adapter/nautilus-adapter-stream-load-strategy.c
@@ -39,7 +39,6 @@
struct NautilusAdapterStreamLoadStrategyDetails {
Bonobo_PersistStream persist_stream;
- NautilusView *nautilus_view;
};
@@ -99,8 +98,7 @@ nautilus_adapter_stream_load_strategy_destroy (GtkObject *object)
NautilusAdapterLoadStrategy *
-nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream,
- NautilusView *view)
+nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream)
{
NautilusAdapterStreamLoadStrategy *strategy;
@@ -109,7 +107,6 @@ nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream,
gtk_object_sink (GTK_OBJECT (strategy));
strategy->details->persist_stream = persist_stream;
- strategy->details->nautilus_view = view;
return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy);
}
@@ -124,15 +121,16 @@ nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy
CORBA_Environment ev;
strategy = NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY (abstract_strategy);
+ gtk_object_ref (GTK_OBJECT (strategy));
CORBA_exception_init (&ev);
- nautilus_view_report_load_underway (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_underway (abstract_strategy);
stream = bonobo_stream_vfs_open (uri, Bonobo_Storage_READ);
if (stream == NULL) {
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_failed (abstract_strategy);
} else {
/* FIXME bugzilla.eazel.com 1248:
* Dan Winship points out that we should pass the
@@ -152,15 +150,16 @@ nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy
bonobo_object_unref (BONOBO_OBJECT (stream));
if (ev._major == CORBA_NO_EXCEPTION) {
- nautilus_view_report_load_complete (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_complete (abstract_strategy);
} else {
- nautilus_view_report_load_failed (strategy->details->nautilus_view);
+ nautilus_adapter_load_strategy_report_load_failed (abstract_strategy);
}
}
- CORBA_exception_free (&ev);
+ gtk_object_unref (GTK_OBJECT (strategy));
+ CORBA_exception_free (&ev);
}
static void
diff --git a/components/adapter/nautilus-adapter-stream-load-strategy.h b/components/adapter/nautilus-adapter-stream-load-strategy.h
index f393556c6..7f4bb68ad 100644
--- a/components/adapter/nautilus-adapter-stream-load-strategy.h
+++ b/components/adapter/nautilus-adapter-stream-load-strategy.h
@@ -49,8 +49,7 @@ typedef struct {
/* GtkObject support */
GtkType nautilus_adapter_stream_load_strategy_get_type (void);
-NautilusAdapterLoadStrategy *nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream,
- NautilusView *view);
+NautilusAdapterLoadStrategy *nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream);
#endif /* NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY_H */
diff --git a/components/adapter/nautilus-adapter.c b/components/adapter/nautilus-adapter.c
index 7b1bdd96b..a1d1a36d0 100644
--- a/components/adapter/nautilus-adapter.c
+++ b/components/adapter/nautilus-adapter.c
@@ -53,8 +53,6 @@ struct NautilusAdapterDetails {
static void nautilus_adapter_load_location_callback (NautilusView *view,
const char *uri,
NautilusAdapter *adapter);
-
-
static void nautilus_adapter_stop_loading_callback (NautilusView *view,
NautilusAdapter *adapter);
@@ -62,6 +60,12 @@ static void nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrateg
const char *uri,
NautilusAdapter *adapter);
+static void nautilus_adapter_load_underway_callback (NautilusAdapter *adapter);
+static void nautilus_adapter_load_progress_callback (NautilusAdapter *adapter,
+ double fraction_complete);
+static void nautilus_adapter_load_complete_callback (NautilusAdapter *adapter);
+static void nautilus_adapter_load_failed_callback (NautilusAdapter *adapter);
+
static void nautilus_adapter_initialize_class (NautilusAdapterClass *klass);
@@ -105,10 +109,10 @@ nautilus_adapter_destroy (GtkObject *object)
{
NautilusAdapter *server;
-
server = NAUTILUS_ADAPTER (object);
if (server->details->load_strategy != NULL) {
+ nautilus_adapter_load_strategy_stop_loading (server->details->load_strategy);
gtk_object_unref (GTK_OBJECT (server->details->load_strategy));
}
@@ -149,8 +153,6 @@ nautilus_adapter_new (Bonobo_Unknown component)
gtk_object_unref,
GTK_OBJECT (adapter));
-
-
/* Get the class to handle embedding this kind of component. */
adapter->details->embed_strategy = nautilus_adapter_embed_strategy_get
(component, bonobo_object_corba_objref (BONOBO_OBJECT (bonobo_control_get_ui_handler
@@ -169,7 +171,7 @@ nautilus_adapter_new (Bonobo_Unknown component)
/* Get the class to handle loading this kind of component. */
adapter->details->load_strategy = nautilus_adapter_load_strategy_get
- (component, adapter->details->nautilus_view);
+ (component);
if (adapter->details->load_strategy == NULL) {
gtk_object_unref (GTK_OBJECT (adapter));
@@ -177,6 +179,32 @@ nautilus_adapter_new (Bonobo_Unknown component)
return NULL;
}
+ /* hook up load strategy signals */
+ gtk_signal_connect_object_while_alive (GTK_OBJECT (adapter->details->load_strategy),
+ "report_load_underway",
+ nautilus_adapter_load_underway_callback,
+ GTK_OBJECT (adapter));
+
+ /* hook up load strategy signals */
+ gtk_signal_connect_object_while_alive (GTK_OBJECT (adapter->details->load_strategy),
+ "report_load_progress",
+ nautilus_adapter_load_progress_callback,
+ GTK_OBJECT (adapter));
+
+ /* hook up load strategy signals */
+ gtk_signal_connect_object_while_alive (GTK_OBJECT (adapter->details->load_strategy),
+ "report_load_complete",
+ nautilus_adapter_load_complete_callback,
+ GTK_OBJECT (adapter));
+
+ /* hook up load strategy signals */
+ gtk_signal_connect_object_while_alive (GTK_OBJECT (adapter->details->load_strategy),
+ "report_load_failed",
+ nautilus_adapter_load_failed_callback,
+ GTK_OBJECT (adapter));
+
+ /* complete the embedding */
+
gtk_container_add (GTK_CONTAINER (bin),
nautilus_adapter_embed_strategy_get_widget (adapter->details->embed_strategy));
@@ -233,3 +261,30 @@ nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrategy *strategy
}
+
+static void
+nautilus_adapter_load_underway_callback (NautilusAdapter *adapter)
+{
+ nautilus_view_report_load_underway (adapter->details->nautilus_view);
+}
+
+static void
+nautilus_adapter_load_progress_callback (NautilusAdapter *adapter,
+ double fraction_complete)
+{
+ nautilus_view_report_load_progress (adapter->details->nautilus_view,
+ fraction_complete);
+}
+
+static void
+nautilus_adapter_load_complete_callback (NautilusAdapter *adapter)
+{
+ nautilus_view_report_load_complete (adapter->details->nautilus_view);
+}
+
+static void
+nautilus_adapter_load_failed_callback (NautilusAdapter *adapter)
+{
+ nautilus_view_report_load_failed (adapter->details->nautilus_view);
+}
+