diff options
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/Makefile.am | 30 | ||||
-rw-r--r-- | libnautilus-private/nautilus-metafile-factory.c | 129 | ||||
-rw-r--r-- | libnautilus-private/nautilus-metafile-factory.h | 49 | ||||
-rw-r--r-- | libnautilus-private/nautilus-metafile-server.idl | 90 | ||||
-rw-r--r-- | libnautilus-private/nautilus-metafile.c | 260 | ||||
-rw-r--r-- | libnautilus-private/nautilus-metafile.h | 49 |
6 files changed, 607 insertions, 0 deletions
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 342ff77de..1361bea3b 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -47,7 +47,14 @@ libnautilus_extensions_la_LDFLAGS = \ $(XML_LIBS) \ $(NULL) +nautilus_metafile_server_idl_sources = \ + nautilus-metafile-server-stubs.c \ + nautilus-metafile-server-skels.c \ + nautilus-metafile-server.h \ + nautilus-metafile-server-common.c + libnautilus_extensions_la_SOURCES = \ + $(nautilus_metafile_server_idl_sources) \ bug-5712-pr3-workaround--gdk-pixbuf-drawable.c \ bug-5712-pr3-workaround--gdk-pixbuf-private.h \ bug-5712-pr3-workaround--gdkimage.c \ @@ -112,6 +119,8 @@ libnautilus_extensions_la_SOURCES = \ nautilus-list-column-title.c \ nautilus-list.c \ nautilus-merged-directory.c \ + nautilus-metafile.c \ + nautilus-metafile-factory.c \ nautilus-mime-actions.c \ nautilus-password-dialog.c \ nautilus-preferences-box.c \ @@ -223,6 +232,8 @@ noinst_HEADERS = \ nautilus-list.h \ nautilus-merged-directory.h \ nautilus-metadata.h \ + nautilus-metafile.h \ + nautilus-metafile-factory.h \ nautilus-mime-actions.h \ nautilus-password-dialog.h \ nautilus-preferences-box.h \ @@ -266,3 +277,22 @@ noinst_HEADERS = \ $(NULL) $(lib_LTLIBRARIES): $(dependency_static_libs) + +$(nautilus_metafile_server_idl_sources): nautilus_metafile_server_idl_stamp + +nautilus_metafile_server_idl_stamp: nautilus-metafile-server.idl $(ORBIT_IDL) + $(ORBIT_IDL) $(IDL_CFLAGS) $(srcdir)/nautilus-metafile-server.idl + touch nautilus_metafile_server_idl_stamp + +EXTRA_DIST = \ + nautilus-metafile-server.idl \ + $(NULL) + +BUILT_SOURCES = \ + $(nautilus_metafile_server_idl_sources) \ + $(NULL) + +CLEANFILES = \ + $(nautilus_metafile_server_idl_sources) \ + nautilus_metafile_server_idl_stamp \ + $(NULL) diff --git a/libnautilus-private/nautilus-metafile-factory.c b/libnautilus-private/nautilus-metafile-factory.c new file mode 100644 index 000000000..72a5be469 --- /dev/null +++ b/libnautilus-private/nautilus-metafile-factory.c @@ -0,0 +1,129 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* nautilus-metafile.c - server side of Nautilus::MetafileFactory + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "nautilus-metafile-factory.h" +#include "nautilus-metafile-server.h" +#include "nautilus-metafile.h" + +#include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus/nautilus-bonobo-workarounds.h> + +struct NautilusMetafileFactoryDetails { +}; + +static void nautilus_metafile_factory_initialize (NautilusMetafileFactory *factory); +static void nautilus_metafile_factory_initialize_class (NautilusMetafileFactoryClass *klass); + +static void destroy (GtkObject *factory); + +static Nautilus_Metafile corba_open (PortableServer_Servant servant, + const Nautilus_URI directory, + CORBA_Environment *ev); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusMetafileFactory, nautilus_metafile_factory, BONOBO_OBJECT_TYPE) + +static void +nautilus_metafile_factory_initialize_class (NautilusMetafileFactoryClass *klass) +{ + GTK_OBJECT_CLASS (klass)->destroy = destroy; +} + +static POA_Nautilus_MetafileFactory__epv * +nautilus_metafile_factory_get_epv (void) +{ + static POA_Nautilus_MetafileFactory__epv epv; + + epv.open = corba_open; + + return &epv; +} + +static POA_Nautilus_MetafileFactory__vepv * +nautilus_metafile_factory_get_vepv (void) +{ + static POA_Nautilus_MetafileFactory__vepv vepv; + + vepv.Bonobo_Unknown_epv = nautilus_bonobo_object_get_epv (); + vepv.Nautilus_MetafileFactory_epv = nautilus_metafile_factory_get_epv (); + + return &vepv; +} + +static POA_Nautilus_MetafileFactory * +nautilus_metafile_factory_create_servant (void) +{ + POA_Nautilus_MetafileFactory *servant; + CORBA_Environment ev; + + servant = (POA_Nautilus_MetafileFactory *) g_new0 (BonoboObjectServant, 1); + servant->vepv = nautilus_metafile_factory_get_vepv (); + CORBA_exception_init (&ev); + POA_Nautilus_MetafileFactory__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION){ + g_error ("can't initialize Nautilus metafile factory"); + } + CORBA_exception_free (&ev); + + return servant; +} + +static void +nautilus_metafile_factory_initialize (NautilusMetafileFactory *factory) +{ + Nautilus_MetafileFactory corba_factory; + + factory->details = g_new0 (NautilusMetafileFactoryDetails, 1); + + corba_factory = bonobo_object_activate_servant + (BONOBO_OBJECT (factory), nautilus_metafile_factory_create_servant ()); + bonobo_object_construct (BONOBO_OBJECT (factory), corba_factory); +} + +static void +destroy (GtkObject *object) +{ + NautilusMetafileFactory *factory; + + factory = NAUTILUS_METAFILE_FACTORY (object); + g_free (factory->details); + + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); +} + +NautilusMetafileFactory * +nautilus_meta_file_factory_new (void) +{ + NautilusMetafileFactory *metafile_factory; + metafile_factory = NAUTILUS_METAFILE_FACTORY (gtk_object_new (NAUTILUS_TYPE_METAFILE_FACTORY, NULL)); + return metafile_factory; +} + +static Nautilus_Metafile +corba_open (PortableServer_Servant servant, + const Nautilus_URI directory, + CORBA_Environment *ev) +{ + BonoboObject *object; + object = BONOBO_OBJECT (nautilus_metafile_new (directory)); + return CORBA_Object_duplicate (bonobo_object_corba_objref (object), ev); +}
\ No newline at end of file diff --git a/libnautilus-private/nautilus-metafile-factory.h b/libnautilus-private/nautilus-metafile-factory.h new file mode 100644 index 000000000..5e1c3bdf7 --- /dev/null +++ b/libnautilus-private/nautilus-metafile-factory.h @@ -0,0 +1,49 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* nautilus-metafile.h - server side of Nautilus::MetafileFactory + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NAUTILUS_METAFILE_FACTORY_H +#define NAUTILUS_METAFILE_FACTORY_H + +#include <bonobo/bonobo-object.h> + +#define NAUTILUS_TYPE_METAFILE_FACTORY (nautilus_metafile_factory_get_type ()) +#define NAUTILUS_METAFILE_FACTORY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_METAFILE_FACTORY, NautilusMetafileFactory)) +#define NAUTILUS_METAFILE_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_METAFILE_FACTORY, NautilusMetafileFactoryClass)) +#define NAUTILUS_IS_METAFILE_FACTORY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_METAFILE_FACTORY)) +#define NAUTILUS_IS_METAFILE_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_METAFILE_FACTORY)) + +typedef struct NautilusMetafileFactoryDetails NautilusMetafileFactoryDetails; + +typedef struct { + BonoboObject parent_slot; + NautilusMetafileFactoryDetails *details; +} NautilusMetafileFactory; + +typedef struct { + BonoboObjectClass parent_slot; +} NautilusMetafileFactoryClass; + +GtkType nautilus_metafile_factory_get_type (void); + +NautilusMetafileFactory *nautilus_meta_file_factory_new (void); + +#endif /* NAUTILUS_METAFILE_FACTORY_H */ diff --git a/libnautilus-private/nautilus-metafile-server.idl b/libnautilus-private/nautilus-metafile-server.idl new file mode 100644 index 000000000..a77235357 --- /dev/null +++ b/libnautilus-private/nautilus-metafile-server.idl @@ -0,0 +1,90 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* nautilus-metafile-server.idl - Interface for components to access Nautilus metadata + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NAUTILUS_METAFILE_SERVER_IDL_INCLUDED +#define NAUTILUS_METAFILE_SERVER_IDL_INCLUDED + +#include <Bonobo.idl> +#include <libnautilus/nautilus-view-component.idl> + +module Nautilus { + + /* NautilusFiles creates (and registers) MetafileMonitors in order + * to get notified of metafile changes. + */ + interface MetafileMonitor : ::Bonobo::Unknown { + void metafile_changed (); + }; + + typedef sequence<string> MetadataList; + + /* A Metafile provides access to the metadata for the files + * in a directory. + * + * Note: file names within the directory are specified, by + * strings whose special characters have been URI encoded. + */ + interface Metafile : ::Bonobo::Unknown { + + /* getters for a file's metadata + */ + string get (in string file_name, + in string key, + in string default_value); + MetadataList get_list (in string file_name, + in string list_key, + in string list_subkey); + + /* setters for a file's metadata + */ + boolean set (in string file_name, + in string key, + in string default_value, + in string metadata); + boolean set_list (in string file_name, + in string list_key, + in string list_subkey, + in MetadataList list); + + /* calls to keep metadata in sync with file operations + */ + void copy (in Metafile source_metafile, + in string source_file_name, + in string destination_file_name); + void remove (in string file_name); + void rename (in string old_file_name, + in string new_file_name); + + /* calls for registering a MetafileMonitor with a Metafile + */ + void register_monitor (in MetafileMonitor monitor); + void unregister_monitor (in MetafileMonitor monitor); + }; + + /* Components use the MetafileFactory to get a Metafile for a directory. + */ + interface MetafileFactory : ::Bonobo::Unknown { + Metafile open (in URI directory); + }; +}; + +#endif /* NAUTILUS_METAFILE_SERVER_IDL_INCLUDED */ diff --git a/libnautilus-private/nautilus-metafile.c b/libnautilus-private/nautilus-metafile.c new file mode 100644 index 000000000..30540881b --- /dev/null +++ b/libnautilus-private/nautilus-metafile.c @@ -0,0 +1,260 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* nautilus-metafile.c - server side of Nautilus::Metafile + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "nautilus-metafile.h" +#include "nautilus-metafile-server.h" + +#include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-directory.h> +#include <libnautilus/nautilus-bonobo-workarounds.h> + +struct NautilusMetafileDetails { + NautilusDirectory *directory; +}; + +static void nautilus_metafile_initialize (NautilusMetafile *metafile); +static void nautilus_metafile_initialize_class (NautilusMetafileClass *klass); + +static void destroy (GtkObject *metafile); + +static CORBA_char *corba_get (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *key, + const CORBA_char *default_value, + CORBA_Environment *ev); +static Nautilus_MetadataList *corba_get_list (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *list_key, + const CORBA_char *list_subkey, + CORBA_Environment *ev); + +static CORBA_boolean corba_set (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *key, + const CORBA_char *default_value, + const CORBA_char *metadata, + CORBA_Environment *ev); +static CORBA_boolean corba_set_list (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *list_key, + const CORBA_char *list_subkey, + const Nautilus_MetadataList *list, + CORBA_Environment *ev); + +static void corba_copy (PortableServer_Servant servant, + const Nautilus_Metafile source_metafile, + const CORBA_char *source_file_name, + const CORBA_char *destination_file_name, + CORBA_Environment *ev); +static void corba_remove (PortableServer_Servant servant, + const CORBA_char *file_name, + CORBA_Environment *ev); +static void corba_rename (PortableServer_Servant servant, + const CORBA_char *old_file_name, + const CORBA_char *new_file_name, + CORBA_Environment *ev); + +static void corba_register_monitor (PortableServer_Servant servant, + const Nautilus_MetafileMonitor monitor, + CORBA_Environment *ev); +static void corba_unregister_monitor (PortableServer_Servant servant, + const Nautilus_MetafileMonitor monitor, + CORBA_Environment *ev); + + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusMetafile, nautilus_metafile, BONOBO_OBJECT_TYPE) + +static void +nautilus_metafile_initialize_class (NautilusMetafileClass *klass) +{ + GTK_OBJECT_CLASS (klass)->destroy = destroy; +} + +static POA_Nautilus_Metafile__epv * +nautilus_metafile_get_epv (void) +{ + static POA_Nautilus_Metafile__epv epv; + + epv.get = corba_get; + epv.get_list = corba_get_list; + epv.set = corba_set; + epv.set_list = corba_set_list; + epv.copy = corba_copy; + epv.remove = corba_remove; + epv.rename = corba_rename; + epv.register_monitor = corba_register_monitor; + epv.unregister_monitor = corba_unregister_monitor; + + return &epv; +} + +static POA_Nautilus_Metafile__vepv * +nautilus_metafile_get_vepv (void) +{ + static POA_Nautilus_Metafile__vepv vepv; + + vepv.Bonobo_Unknown_epv = nautilus_bonobo_object_get_epv (); + vepv.Nautilus_Metafile_epv = nautilus_metafile_get_epv (); + + return &vepv; +} + +static POA_Nautilus_Metafile * +nautilus_metafile_create_servant (void) +{ + POA_Nautilus_Metafile *servant; + CORBA_Environment ev; + + servant = (POA_Nautilus_Metafile *) g_new0 (BonoboObjectServant, 1); + servant->vepv = nautilus_metafile_get_vepv (); + CORBA_exception_init (&ev); + POA_Nautilus_Metafile__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION){ + g_error ("can't initialize Nautilus metafile"); + } + CORBA_exception_free (&ev); + + return servant; +} + +static void +nautilus_metafile_initialize (NautilusMetafile *metafile) +{ + Nautilus_Metafile corba_metafile; + + metafile->details = g_new0 (NautilusMetafileDetails, 1); + + corba_metafile = bonobo_object_activate_servant + (BONOBO_OBJECT (metafile), nautilus_metafile_create_servant ()); + bonobo_object_construct (BONOBO_OBJECT (metafile), corba_metafile); +} + +static void +destroy (GtkObject *object) +{ + NautilusMetafile *metafile; + + metafile = NAUTILUS_METAFILE (object); + nautilus_directory_unref (metafile->details->directory); + g_free (metafile->details); + + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); +} + +NautilusMetafile * +nautilus_metafile_new (const char *directory_uri) +{ + NautilusMetafile *metafile; + metafile = NAUTILUS_METAFILE (gtk_object_new (NAUTILUS_TYPE_METAFILE, NULL)); + metafile->details->directory = nautilus_directory_get (directory_uri); + return metafile; +} + +static CORBA_char * +corba_get (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *key, + const CORBA_char *default_value, + CORBA_Environment *ev) +{ + /* mse-evil */ + return CORBA_OBJECT_NIL; +} + +static Nautilus_MetadataList * +corba_get_list (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *list_key, + const CORBA_char *list_subkey, + CORBA_Environment *ev) +{ + /* mse-evil */ + return CORBA_OBJECT_NIL; +} + +static CORBA_boolean +corba_set (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *key, + const CORBA_char *default_value, + const CORBA_char *metadata, + CORBA_Environment *ev) +{ + /* mse-evil */ + return CORBA_FALSE; +} + +static CORBA_boolean +corba_set_list (PortableServer_Servant servant, + const CORBA_char *file_name, + const CORBA_char *list_key, + const CORBA_char *list_subkey, + const Nautilus_MetadataList *list, + CORBA_Environment *ev) +{ + /* mse-evil */ + return CORBA_FALSE; +} + +static void +corba_copy (PortableServer_Servant servant, + const Nautilus_Metafile source_metafile, + const CORBA_char *source_file_name, + const CORBA_char *destination_file_name, + CORBA_Environment *ev) +{ + /* mse-evil */ +} + +static void +corba_remove (PortableServer_Servant servant, + const CORBA_char *file_name, + CORBA_Environment *ev) +{ + /* mse-evil */ +} + +static void +corba_rename (PortableServer_Servant servant, + const CORBA_char *old_file_name, + const CORBA_char *new_file_name, + CORBA_Environment *ev) +{ + /* mse-evil */ +} + +static void +corba_register_monitor (PortableServer_Servant servant, + const Nautilus_MetafileMonitor monitor, + CORBA_Environment *ev) +{ + /* mse-evil */ +} + +static void +corba_unregister_monitor (PortableServer_Servant servant, + const Nautilus_MetafileMonitor monitor, + CORBA_Environment *ev) +{ + /* mse-evil */ +} diff --git a/libnautilus-private/nautilus-metafile.h b/libnautilus-private/nautilus-metafile.h new file mode 100644 index 000000000..39050bbdf --- /dev/null +++ b/libnautilus-private/nautilus-metafile.h @@ -0,0 +1,49 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* nautilus-metafile.h - server side of Nautilus::Metafile + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NAUTILUS_METAFILE_H +#define NAUTILUS_METAFILE_H + +#include <bonobo/bonobo-object.h> + +#define NAUTILUS_TYPE_METAFILE (nautilus_metafile_get_type ()) +#define NAUTILUS_METAFILE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_METAFILE, NautilusMetafile)) +#define NAUTILUS_METAFILE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_METAFILE, NautilusMetafileClass)) +#define NAUTILUS_IS_METAFILE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_METAFILE)) +#define NAUTILUS_IS_METAFILE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_METAFILE)) + +typedef struct NautilusMetafileDetails NautilusMetafileDetails; + +typedef struct { + BonoboObject parent_slot; + NautilusMetafileDetails *details; +} NautilusMetafile; + +typedef struct { + BonoboObjectClass parent_slot; +} NautilusMetafileClass; + +GtkType nautilus_metafile_get_type (void); + +NautilusMetafile *nautilus_metafile_new (const char *directory_uri); + +#endif /* NAUTILUS_METAFILE_H */ |