[nautilus-actions] Define XML provider as a dynamic module
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define XML provider as a dynamic module
- Date: Fri, 19 Feb 2010 02:22:27 +0000 (UTC)
commit 182f8f7eed478e8ab6236166198b523912e9bdfd
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Feb 15 14:21:51 2010 +0100
Define XML provider as a dynamic module
ChangeLog | 7 +
src/Makefile.am | 21 ++--
src/io-xml/Makefile.am | 51 +++++++++
src/io-xml/naxml-module.c | 114 +++++++++++++++++++
src/io-xml/naxml-provider.c | 254 +++++++++++++++++++++++++++++++++++++++++++
src/io-xml/naxml-provider.h | 74 +++++++++++++
6 files changed, 511 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ad1637c..e7328d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2009-02-15 Pierre Wieser <pwieser trychlos org>
+ Define XML provider as a dynamic module.
+
+ * io-xml/Makefile.am:
+ * io-xml/naxml-module.c:
+ * io-xml/naxml-provider.c:
+ * io-xml/naxml-provider.h: New files.
+
Rename source tree from nautilus-actions/ to src/
Rename src/io-provider-desktop/ to src/io-desktop/
Rename src/io-provider-gconf/ to src/io-gconf/
diff --git a/src/Makefile.am b/src/Makefile.am
index feffae2..16b48ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,14 +27,15 @@
# ... and many others (see AUTHORS)
SUBDIRS = \
- api \
- private \
- runtime \
- io-desktop \
- io-gconf \
- nact \
- plugin-menu \
- plugin-tracker \
- test \
- utils \
+ api \
+ private \
+ runtime \
+ io-desktop \
+ io-gconf \
+ io-xml \
+ nact \
+ plugin-menu \
+ plugin-tracker \
+ test \
+ utils \
$(NULL)
diff --git a/src/io-xml/Makefile.am b/src/io-xml/Makefile.am
new file mode 100644
index 0000000..b159b8c
--- /dev/null
+++ b/src/io-xml/Makefile.am
@@ -0,0 +1,51 @@
+# Nautilus Actions
+# A Nautilus extension which offers configurable context menu actions.
+#
+# Copyright (C) 2005 The GNOME Foundation
+# Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+# Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+#
+# 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 Library; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307, USA.
+#
+# Authors:
+# Frederic Ruaudel <grumz grumz net>
+# Rodrigo Moya <rodrigo gnome-db org>
+# Pierre Wieser <pwieser trychlos org>
+# ... and many others (see AUTHORS)
+
+pkglib_LTLIBRARIES = libna-io-xml.la
+
+AM_CPPFLAGS += \
+ -I $(top_srcdir) \
+ $(NAUTILUS_ACTIONS_CFLAGS) \
+ -DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_IO_XML}\" \
+ $(NULL)
+
+libna_io_xml_la_SOURCES = \
+ naxml-module.c \
+ naxml-provider.c \
+ naxml-provider.h \
+ $(NULL)
+
+libna_io_xml_la_LIBADD = \
+ $(top_builddir)/src/core/libna-core.la \
+ $(NULL)
+
+libna_io_xml_la_LDFLAGS = \
+ -module \
+ -no-undefined \
+ -avoid-version \
+ $(NULL)
diff --git a/src/io-xml/naxml-module.c b/src/io-xml/naxml-module.c
new file mode 100644
index 0000000..4e4159b
--- /dev/null
+++ b/src/io-xml/naxml-module.c
@@ -0,0 +1,114 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <api/na-extension.h>
+
+#include "naxml-provider.h"
+
+/* the count of GType types provided by this extension
+ * each new GType type must
+ * - be registered in na_extension_startup()
+ * - be addressed in na_extension_list_types().
+ */
+#define NAXML_TYPES_COUNT 1
+
+/*
+ * na_extension_startup:
+ *
+ * mandatory starting with API v. 1.
+ */
+/* TODO: remove this when we will be ready to release the desktop provider */
+gboolean
+na_extension_startup( GTypeModule *module )
+{
+ static const gchar *thisfn = "naxml_module_na_extension_startup";
+
+ g_debug( "%s: module=%p", thisfn, ( void * ) module );
+
+ naxml_provider_register_type( module );
+
+ return( TRUE );
+}
+
+/*
+ * na_extension_get_version:
+ *
+ * optional, defaults to 1.
+ */
+guint
+na_extension_get_version( void )
+{
+ static const gchar *thisfn = "naxml_module_na_extension_get_version";
+ guint version;
+
+ version = 1;
+
+ g_debug( "%s: version=%d", thisfn, version );
+
+ return( version );
+}
+
+/*
+ * na_extension_list_types:
+ *
+ * mandatory starting with v. 1.
+ */
+guint
+na_extension_list_types( const GType **types )
+{
+ static const gchar *thisfn = "naxml_module_na_extension_list_types";
+ static GType types_list [1+NAXML_TYPES_COUNT];
+
+ g_debug( "%s: types=%p", thisfn, ( void * ) types );
+
+ types_list[0] = NAXML_PROVIDER_TYPE;
+
+ types_list[NAXML_TYPES_COUNT] = 0;
+ *types = types_list;
+
+ return( NAXML_TYPES_COUNT );
+}
+
+/*
+ * na_extension_shutdown:
+ *
+ * mandatory starting with v. 1.
+ */
+void
+na_extension_shutdown( void )
+{
+ static const gchar *thisfn = "naxml_module_na_extension_shutdown";
+
+ g_debug( "%s", thisfn );
+}
diff --git a/src/io-xml/naxml-provider.c b/src/io-xml/naxml-provider.c
new file mode 100644
index 0000000..fbcebf6
--- /dev/null
+++ b/src/io-xml/naxml-provider.c
@@ -0,0 +1,254 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n.h>
+
+#include <api/na-iio-factory.h>
+#include <api/na-iio-provider.h>
+
+#include "naxml-provider.h"
+
+/* private class data
+ */
+struct NaxmlProviderClassPrivate {
+ void *empty; /* so that gcc -pedantic is happy */
+};
+
+/* private instance data
+ */
+struct NaxmlProviderPrivate {
+ gboolean dispose_has_run;
+};
+
+static GType st_module_type = 0;
+static GObjectClass *st_parent_class = NULL;
+
+static void class_init( NaxmlProviderClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *object );
+static void instance_finalize( GObject *object );
+
+static void iio_provider_iface_init( NAIIOProviderInterface *iface );
+static gchar *iio_provider_get_id( const NAIIOProvider *provider );
+static gchar *iio_provider_get_name( const NAIIOProvider *provider );
+static guint iio_provider_get_version( const NAIIOProvider *provider );
+static gboolean iio_provider_is_willing_to_write( const NAIIOProvider *instance );
+static gboolean iio_provider_is_able_to_write( const NAIIOProvider *instance );
+static guint iio_provider_write_item( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
+
+static void iio_factory_iface_init( NAIIOFactoryInterface *iface );
+static guint iio_factory_get_version( const NAIIOFactory *provider );
+
+GType
+naxml_provider_get_type( void )
+{
+ return( st_module_type );
+}
+
+void
+naxml_provider_register_type( GTypeModule *module )
+{
+ static const gchar *thisfn = "naxml_provider_register_type";
+
+ static GTypeInfo info = {
+ sizeof( NaxmlProviderClass ),
+ NULL,
+ NULL,
+ ( GClassInitFunc ) class_init,
+ NULL,
+ NULL,
+ sizeof( NaxmlProvider ),
+ 0,
+ ( GInstanceInitFunc ) instance_init
+ };
+
+ static const GInterfaceInfo iio_provider_iface_info = {
+ ( GInterfaceInitFunc ) iio_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ static const GInterfaceInfo iio_factory_iface_info = {
+ ( GInterfaceInitFunc ) iio_factory_iface_init,
+ NULL,
+ NULL
+ };
+
+ g_debug( "%s", thisfn );
+
+ st_module_type = g_type_module_register_type( module, G_TYPE_OBJECT, "NaxmlProvider", &info, 0 );
+
+ g_type_module_add_interface( module, st_module_type, NA_IIO_PROVIDER_TYPE, &iio_provider_iface_info );
+
+ g_type_module_add_interface( module, st_module_type, NA_IIO_FACTORY_TYPE, &iio_factory_iface_info );
+}
+
+static void
+class_init( NaxmlProviderClass *klass )
+{
+ static const gchar *thisfn = "naxml_provider_class_init";
+ GObjectClass *object_class;
+
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ st_parent_class = g_type_class_peek_parent( klass );
+
+ object_class = G_OBJECT_CLASS( klass );
+ object_class->dispose = instance_dispose;
+ object_class->finalize = instance_finalize;
+
+ klass->private = g_new0( NaxmlProviderClassPrivate, 1 );
+}
+
+static void
+instance_init( GTypeInstance *instance, gpointer klass )
+{
+ static const gchar *thisfn = "naxml_provider_instance_init";
+ NaxmlProvider *self;
+
+ g_debug( "%s: instance=%p (%s), klass=%p",
+ thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
+ g_return_if_fail( NAGP_IS_GCONF_PROVIDER( instance ));
+ self = NAXML_PROVIDER( instance );
+
+ self->private = g_new0( NaxmlProviderPrivate, 1 );
+
+ self->private->dispose_has_run = FALSE;
+}
+
+static void
+instance_dispose( GObject *object )
+{
+ static const gchar *thisfn = "naxml_provider_instance_dispose";
+ NaxmlProvider *self;
+
+ g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+ g_return_if_fail( NAGP_IS_GCONF_PROVIDER( object ));
+ self = NAXML_PROVIDER( object );
+
+ if( !self->private->dispose_has_run ){
+
+ self->private->dispose_has_run = TRUE;
+
+ /* chain up to the parent class */
+ if( G_OBJECT_CLASS( st_parent_class )->dispose ){
+ G_OBJECT_CLASS( st_parent_class )->dispose( object );
+ }
+ }
+}
+
+static void
+instance_finalize( GObject *object )
+{
+ NaxmlProvider *self;
+
+ g_assert( NAGP_IS_GCONF_PROVIDER( object ));
+ self = NAXML_PROVIDER( object );
+
+ g_free( self->private );
+
+ /* chain call to parent class */
+ if( G_OBJECT_CLASS( st_parent_class )->finalize ){
+ G_OBJECT_CLASS( st_parent_class )->finalize( object );
+ }
+}
+
+static void
+iio_provider_iface_init( NAIIOProviderInterface *iface )
+{
+ static const gchar *thisfn = "naxml_provider_iio_provider_iface_init";
+
+ g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+
+ iface->get_id = iio_provider_get_id;
+ iface->get_name = iio_provider_get_name;
+ iface->get_version = iio_provider_get_version;
+ iface->read_items = NULL;
+ iface->is_willing_to_write = iio_provider_is_willing_to_write;
+ iface->is_able_to_write = iio_provider_is_able_to_write;
+ iface->write_item = iio_provider_write_item;
+ iface->delete_item = NULL;
+}
+
+static gchar *
+iio_provider_get_id( const NAIIOProvider *provider )
+{
+ return( g_strdup( "na-xml" ));
+}
+
+static gchar *
+iio_provider_get_name( const NAIIOProvider *provider )
+{
+ return( g_strdup( _( "Nautilus-Actions XML I/O Provider" )));
+}
+
+static guint
+iio_provider_get_version( const NAIIOProvider *provider )
+{
+ return( 1 );
+}
+
+static gboolean
+iio_provider_is_willing_to_write( const NAIIOProvider *instance )
+{
+ return( TRUE );
+}
+
+static gboolean
+iio_provider_is_able_to_write( const NAIIOProvider *instance )
+{
+ return( TRUE );
+}
+
+static guint
+iio_provider_write_item( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages )
+{
+ return( NA_IIO_PROVIDER_CODE_OK );
+}
+
+static void
+iio_factory_iface_init( NAIIOFactoryInterface *iface )
+{
+ static const gchar *thisfn = "naxml_provider_iio_factory_iface_init";
+
+ g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+
+ iface->get_version = iio_factory_get_version;
+}
+
+static guint
+iio_factory_get_version( const NAIIOFactory *provider )
+{
+ return( 1 );
+}
diff --git a/src/io-xml/naxml-provider.h b/src/io-xml/naxml-provider.h
new file mode 100644
index 0000000..0f2b490
--- /dev/null
+++ b/src/io-xml/naxml-provider.h
@@ -0,0 +1,74 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NAXML_PROVIDER_H__
+#define __NAXML_PROVIDER_H__
+
+/**
+ * SECTION: naxml_provider
+ * @short_description: #NaxmlProvider class definition.
+ * @include: naxml-provider.h
+ *
+ * This class manages I/O in XML formats.
+ */
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define NAXML_PROVIDER_TYPE ( naxml_provider_get_type())
+#define NAXML_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NAXML_PROVIDER_TYPE, NaxmlProvider ))
+#define NAXML_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NAXML_PROVIDER_TYPE, NaxmlProviderClass ))
+#define NAGP_IS_GCONF_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NAXML_PROVIDER_TYPE ))
+#define NAGP_IS_GCONF_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NAXML_PROVIDER_TYPE ))
+#define NAXML_PROVIDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NAXML_PROVIDER_TYPE, NaxmlProviderClass ))
+
+typedef struct NaxmlProviderPrivate NaxmlProviderPrivate;
+
+typedef struct {
+ GObject parent;
+ NaxmlProviderPrivate *private;
+}
+ NaxmlProvider;
+
+typedef struct NaxmlProviderClassPrivate NaxmlProviderClassPrivate;
+
+typedef struct {
+ GObjectClass parent;
+ NaxmlProviderClassPrivate *private;
+}
+ NaxmlProviderClass;
+
+GType naxml_provider_get_type ( void );
+void naxml_provider_register_type( GTypeModule *module );
+
+G_END_DECLS
+
+#endif /* __NAXML_PROVIDER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]