Commit 3b9d7401 authored by Maciej Stachowiak's avatar Maciej Stachowiak
Browse files

More work towards fixing bug 1994; in the process I think I might

	also end up fixing 2576, 2577, 2578 and 2579 (might also end up
	fixing 2580 later).

	* components/adapter/Makefile.am:

	* components/adapter/nautilus-adapter-load-strategy.h,
	components/adapter/nautilus-adapter-load-strategy.c: Abstract
	class that gives the interface for loading up a component that
	presents some particular interface.

	* components/adapter/nautilus-adapter-file-load-strategy.h,
	components/adapter/nautilus-adapter-file-load-strategy.c:
	Concrete subclass for loading a component that has the
	Bonobo::PersistFile interface.

	* components/adapter/nautilus-adapter-progressive-load-strategy.h,
	components/adapter/nautilus-adapter-progressive-load-strategy.c:
	Concrete subclass for loading a component that has the
	Bonobo::ProgressiveDataSink interface.

	* components/adapter/nautilus-adapter-stream-load-strategy.c,
	components/adapter/nautilus-adapter-stream-load-strategy.h:
	Concrete subclass for loading a component that has the
	Bonobo::PersistStream interface.

	* components/adapter/nautilus-adapter.h,
	components/adapter/nautilus-adapter.c:
	(nautilus_adapter_destroy, nautilus_adapter_new,
	nautilus_adapter_load_location_callback,
	nautilus_adapter_stop_loading_callback): Use load strategies.

	* libnautilus-extensions/bonobo-stream-vfs.c (vfs_read): Minor
	formatting correction.
parent 2cc972f5
2000-09-20 Maciej Stachowiak <mjs@eazel.com>
More work towards fixing bug 1994; in the process I think I might
also end up fixing 2576, 2577, 2578 and 2579 (might also end up
fixing 2580 later).
* components/adapter/Makefile.am:
* components/adapter/nautilus-adapter-load-strategy.h,
components/adapter/nautilus-adapter-load-strategy.c: Abstract
class that gives the interface for loading up a component that
presents some particular interface.
* components/adapter/nautilus-adapter-file-load-strategy.h,
components/adapter/nautilus-adapter-file-load-strategy.c:
Concrete subclass for loading a component that has the
Bonobo::PersistFile interface.
* components/adapter/nautilus-adapter-progressive-load-strategy.h,
components/adapter/nautilus-adapter-progressive-load-strategy.c:
Concrete subclass for loading a component that has the
Bonobo::ProgressiveDataSink interface.
* components/adapter/nautilus-adapter-stream-load-strategy.c,
components/adapter/nautilus-adapter-stream-load-strategy.h:
Concrete subclass for loading a component that has the
Bonobo::PersistStream interface.
* components/adapter/nautilus-adapter.h,
components/adapter/nautilus-adapter.c:
(nautilus_adapter_destroy, nautilus_adapter_new,
nautilus_adapter_load_location_callback,
nautilus_adapter_stop_loading_callback): Use load strategies.
* libnautilus-extensions/bonobo-stream-vfs.c (vfs_read): Minor
formatting correction.
2000-09-20 Andy Hertzfeld <andy@eazel.com>
* components/music/nautilus-music-view.c: (play_current_file):
......
CPPFLAGS = \
-DPREFIX=\"$(prefix)\" \
-DG_LOG_DOMAIN=\"Nautilus-Adapter\" \
-DICON_DIR=\"$(datadir)/pixmaps/nautilus\"
INCLUDES=-I$(top_srcdir) -I$(top_builddir) -I. \
$(GNOMEUI_CFLAGS) \
$(BONOBOX_CFLAGS) \
$(OAF_CFLAGS) \
$(XML_CFLAGS) \
-D_REENTRANT
NULL =
CPPFLAGS = \
-DPREFIX=\"$(prefix)\" \
-DG_LOG_DOMAIN=\"Nautilus-Adapter\" \
-DICON_DIR=\"$(datadir)/pixmaps/nautilus\" \
$(NULL)
INCLUDES = \
-I$(top_srcdir) -I$(top_builddir) -I. \
$(GNOMEUI_CFLAGS) \
$(BONOBOX_CFLAGS) \
$(OAF_CFLAGS) \
$(XML_CFLAGS) \
-D_REENTRANT \
$(NULL)
oafdir = $(datadir)/oaf
oaf_DATA = \
nautilus-adapter.oafinfo
nautilus-adapter.oafinfo \
$(NULL)
bin_PROGRAMS = \
nautilus-adapter
nautilus_adapter_SOURCES = \
main.c \
nautilus-adapter-factory-server.h \
nautilus-adapter-factory-server.c \
nautilus-adapter.h \
nautilus-adapter.c
nautilus_adapter_LDADD = \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/libnautilus-adapter/libnautilus-adapter.la \
$(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
$(GNOMEUI_LIBS) \
$(OAF_LIBS) \
$(BONOBO_PRINT_LIBS) \
$(VFS_LIBS) \
$(XML_LIBS) \
$(BONOBOX_LIBS) \
$(GNOMECANVASPIXBUF_LIBS) \
$(GHTTP_LIBS) \
$(GCONF_LIBS) \
$(LIBPNG)
nautilus-adapter \
$(NULL)
nautilus_adapter_SOURCES = \
main.c \
nautilus-adapter-factory-server.h \
nautilus-adapter-factory-server.c \
nautilus-adapter.h \
nautilus-adapter.c \
nautilus-adapter-load-strategy.h \
nautilus-adapter-load-strategy.c \
nautilus-adapter-load-strategy.h \
nautilus-adapter-stream-load-strategy.c \
nautilus-adapter-stream-load-strategy.h \
nautilus-adapter-file-load-strategy.c \
nautilus-adapter-file-load-strategy.h \
nautilus-adapter-progressive-load-strategy.h \
nautilus-adapter-progressive-load-strategy.c \
$(NULL)
nautilus_adapter_LDADD = \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/libnautilus-adapter/libnautilus-adapter.la \
$(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
$(GNOMEUI_LIBS) \
$(OAF_LIBS) \
$(BONOBO_PRINT_LIBS) \
$(VFS_LIBS) \
$(XML_LIBS) \
$(BONOBOX_LIBS) \
$(GNOMECANVASPIXBUF_LIBS) \
$(GHTTP_LIBS) \
$(GCONF_LIBS) \
$(LIBPNG) \
$(NULL)
EXTRA_DIST = $(oaf_DATA)
......@@ -67,7 +67,7 @@ vfs_read (BonoboStream *stream, CORBA_long count,
res = gnome_vfs_read(sfs->fd, data, count, &nread);
if (res == GNOME_VFS_OK){
if (res == GNOME_VFS_OK) {
(*buffer)->_buffer = data;
(*buffer)->_length = nread;
} else {
......@@ -77,6 +77,7 @@ vfs_read (BonoboStream *stream, CORBA_long count,
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_Bonobo_Stream_IOError, NULL);
}
sfs->got_eof = (res == GNOME_VFS_ERROR_EOF);
}
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Nautilus
*
* Copyright (C) 2000 Eazel, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* Nautilus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Maciej Stachowiak <mjs@eazel.com>
*/
/* nautilus-adapter-file-load-strategy.c -
*/
#include <config.h>
#include "nautilus-adapter-file-load-strategy.h"
#include <gtk/gtkobject.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus/nautilus-view.h>
struct NautilusAdapterFileLoadStrategyDetails {
Bonobo_PersistFile persist_file;
NautilusView *nautilus_view;
};
static void nautilus_adapter_file_load_strategy_initialize_class (NautilusAdapterFileLoadStrategyClass *klass);
static void nautilus_adapter_file_load_strategy_initialize (NautilusAdapterFileLoadStrategy *strategy);
static void nautilus_adapter_file_load_strategy_destroy (GtkObject *object);
static void nautilus_adapter_file_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy,
const char *uri);
static void nautilus_adapter_file_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusAdapterFileLoadStrategy, nautilus_adapter_file_load_strategy, NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY)
static void
nautilus_adapter_file_load_strategy_initialize_class (NautilusAdapterFileLoadStrategyClass *klass)
{
GtkObjectClass *object_class;
NautilusAdapterLoadStrategyClass *adapter_load_strategy_class;
object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = nautilus_adapter_file_load_strategy_destroy;
adapter_load_strategy_class = NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS (klass);
adapter_load_strategy_class->load_location = nautilus_adapter_file_load_strategy_load_location;
adapter_load_strategy_class->stop_loading = nautilus_adapter_file_load_strategy_stop_loading;
}
static void
nautilus_adapter_file_load_strategy_initialize (NautilusAdapterFileLoadStrategy *strategy)
{
strategy->details = g_new0 (NautilusAdapterFileLoadStrategyDetails, 1);
}
static void
nautilus_adapter_file_load_strategy_destroy (GtkObject *object)
{
NautilusAdapterFileLoadStrategy *strategy;
CORBA_Environment ev;
if (strategy->details->persist_file != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
bonobo_object_release_unref (strategy->details->persist_file, &ev);
CORBA_exception_free (&ev);
}
g_free (strategy->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
NautilusAdapterLoadStrategy *
nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file,
NautilusView *view)
{
NautilusAdapterFileLoadStrategy *strategy;
strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (gtk_type_new (NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY));
strategy->details->persist_file = persist_file;
strategy->details->nautilus_view = view;
return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy);
}
static void
nautilus_adapter_file_load_strategy_load_location (NautilusAdapterLoadStrategy *abstract_strategy,
const char *uri)
{
CORBA_Environment ev;
NautilusAdapterFileLoadStrategy *strategy;
char *local_path;
strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (abstract_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);
CORBA_exception_free (&ev);
return;
}
nautilus_view_report_load_underway (strategy->details->nautilus_view);
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);
} else {
nautilus_view_report_load_failed (strategy->details->nautilus_view);
}
CORBA_exception_free (&ev);
g_free (local_path);
}
static void
nautilus_adapter_file_load_strategy_stop_loading (NautilusAdapterLoadStrategy *abstract_strategy)
{
g_return_if_fail (NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY (abstract_strategy));
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Maciej Stachowiak <mjs@eazel.com>
*/
/* nautilus-adapter-file-load-strategy.h
*/
#ifndef NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H
#define NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H
#include "nautilus-adapter-load-strategy.h"
#define NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY (nautilus_adapter_file_load_strategy_get_type ())
#define NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY, NautilusAdapterFileLoadStrategy))
#define NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY, NautilusAdapterFileLoadStrategyClass))
#define NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY))
#define NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY))
typedef struct NautilusAdapterFileLoadStrategyDetails NautilusAdapterFileLoadStrategyDetails;
typedef struct {
NautilusAdapterLoadStrategy parent;
NautilusAdapterFileLoadStrategyDetails *details;
} NautilusAdapterFileLoadStrategy;
typedef struct {
NautilusAdapterLoadStrategyClass parent;
} NautilusAdapterFileLoadStrategyClass;
/* GtkObject support */
GtkType nautilus_adapter_file_load_strategy_get_type (void);
NautilusAdapterLoadStrategy *nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file,
NautilusView *view);
#endif /* NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Nautilus
*
* Copyright (C) 2000 Eazel, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* Nautilus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Maciej Stachowiak <mjs@eazel.com>
*/
/* nautilus-adapter-load-strategy.h
*/
#include <config.h>
#include "nautilus-adapter-load-strategy.h"
#include "nautilus-adapter-stream-load-strategy.h"
#include "nautilus-adapter-file-load-strategy.h"
#include "nautilus-adapter-progressive-load-strategy.h"
#include <gtk/gtkobject.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
static void nautilus_adapter_load_strategy_initialize_class (NautilusAdapterLoadStrategyClass *klass);
static void nautilus_adapter_load_strategy_initialize (NautilusAdapterLoadStrategy *strategy);
static void nautilus_adapter_load_strategy_destroy (GtkObject *object);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusAdapterLoadStrategy, nautilus_adapter_load_strategy, GTK_TYPE_OBJECT)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_load_strategy, load_location)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_load_strategy, stop_loading)
static void
nautilus_adapter_load_strategy_initialize_class (NautilusAdapterLoadStrategyClass *klass)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *) klass;
object_class->destroy = nautilus_adapter_load_strategy_destroy;
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_load_strategy, load_location);
NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_load_strategy, stop_loading);
}
static void
nautilus_adapter_load_strategy_initialize (NautilusAdapterLoadStrategy *strategy)
{
}
static void
nautilus_adapter_load_strategy_destroy (GtkObject *object)
{
NautilusAdapterLoadStrategy *strategy;
strategy = NAUTILUS_ADAPTER_LOAD_STRATEGY (object);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
NautilusAdapterLoadStrategy *
nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
NautilusView *view)
{
Bonobo_PersistStream persist_stream;
Bonobo_PersistFile persist_file;
Bonobo_ProgressiveDataSink progressive_data_sink;
CORBA_Environment ev;
CORBA_exception_init (&ev);
progressive_data_sink = Bonobo_Unknown_query_interface (component,
"IDL:Bonobo/ProgressiveDataSink:1.0", &ev);
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);
}
persist_stream = Bonobo_Unknown_query_interface (component,
"IDL:Bonobo/PersistStream:1.0", &ev);
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);
}
persist_file = Bonobo_Unknown_query_interface (component,
"IDL:Bonobo/PersistFile:1.0", &ev);
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);
}
CORBA_exception_free (&ev);
return NULL;
}
void
nautilus_adapter_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy,
const char *uri)
{
g_return_if_fail (NAUTILUS_IS_ADAPTER_LOAD_STRATEGY (strategy));
NAUTILUS_CALL_VIRTUAL (NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS, strategy,
load_location, (strategy, uri));
}
void
nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy)
{
g_return_if_fail (NAUTILUS_IS_ADAPTER_LOAD_STRATEGY (strategy));
NAUTILUS_CALL_VIRTUAL (NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS, strategy,
stop_loading, (strategy));
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Maciej Stachowiak <mjs@eazel.com>
*/
/* nautilus-adapter-load-strategy.h
*/
#ifndef NAUTILUS_ADAPTER_LOAD_STRATEGY_H
#define NAUTILUS_ADAPTER_LOAD_STRATEGY_H
#include <gtk/gtkobject.h>
#include <bonobo/Bonobo.h>
#include <libnautilus/nautilus-view.h>
#define NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY (nautilus_adapter_load_strategy_get_type ())
#define NAUTILUS_ADAPTER_LOAD_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY, NautilusAdapterLoadStrategy))
#define NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY, NautilusAdapterLoadStrategyClass))
#define NAUTILUS_IS_ADAPTER_LOAD_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY))
#define NAUTILUS_IS_ADAPTER_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY))
typedef struct NautilusAdapterLoadStrategyDetails NautilusAdapterLoadStrategyDetails;
typedef struct {
GtkObject parent;
} NautilusAdapterLoadStrategy;
typedef struct {
GtkObjectClass parent;
void (*load_location) (NautilusAdapterLoadStrategy *strategy,
const char *uri);
void (*stop_loading) (NautilusAdapterLoadStrategy *strategy);
} NautilusAdapterLoadStrategyClass;
/* GtkObject support */
GtkType nautilus_adapter_load_strategy_get_type (void);
/* Instantiates the proper concrete subclass */
NautilusAdapterLoadStrategy *nautilus_adapter_load_strategy_get (Bonobo_Unknown component,
NautilusView *view);
void nautilus_adapter_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy,
const char *uri);
void nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy);
#endif /* NAUTILUS_ADAPTER_LOAD_STRATEGY_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Nautilus
*
* Copyright (C) 2000 Eazel, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as