[nautilus-actions] Refactoring: Rename src/api/na-iio-provider.c to src/core/na-iio-provider.c
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Refactoring: Rename src/api/na-iio-provider.c to src/core/na-iio-provider.c
- Date: Fri, 19 Feb 2010 02:23:32 +0000 (UTC)
commit 3abeccd9ed2ab9ebfa42a7ca5d5ccee742b9e287
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Feb 15 17:19:49 2010 +0100
Refactoring: Rename src/api/na-iio-provider.c to src/core/na-iio-provider.c
ChangeLog | 2 +
src/api/Makefile.am | 2 +-
src/api/na-iio-provider.h | 110 ++++++++++++++++++-----------------
src/core/Makefile.am | 4 +-
src/{api => core}/na-iio-provider.c | 75 ++++++++++++++++++-----
5 files changed, 119 insertions(+), 74 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index deb0619..bd4bbf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2009-02-15 Pierre Wieser <pwieser trychlos org>
+ Rename src/api/na-iio-provider.c to src/core/na-iio-provider.c
+
* src/api/na-dbus.h: Update defined name.
* m4/na-log-domains.m4: Update log domains with new subdirs.
diff --git a/src/api/Makefile.am b/src/api/Makefile.am
index ca7aa27..533c4f5 100644
--- a/src/api/Makefile.am
+++ b/src/api/Makefile.am
@@ -32,10 +32,10 @@ api_include_HEADERS = \
na-extension.h \
\
na-dbus.h \
+ na-iio-provider.h \
\
na-core-utils.h \
na-gconf-monitor.h \
na-gconf-keys.h \
- na-iio-provider.h \
na-object-api.h \
$(NULL)
diff --git a/src/api/na-iio-provider.h b/src/api/na-iio-provider.h
index e89a436..143e1fe 100644
--- a/src/api/na-iio-provider.h
+++ b/src/api/na-iio-provider.h
@@ -28,27 +28,32 @@
* ... and many others (see AUTHORS)
*/
-#ifndef __NAUTILUS_ACTIONS_NA_IIO_PROVIDER_H__
-#define __NAUTILUS_ACTIONS_NA_IIO_PROVIDER_H__
+#ifndef __NAUTILUS_ACTIONS_API_NA_IIO_PROVIDER_H__
+#define __NAUTILUS_ACTIONS_API_NA_IIO_PROVIDER_H__
/**
* SECTION: na_iio_provider
* @short_description: #NAIIOProvider interface definition.
- * @include: nautilus-actions/api/na-iio-provider.h
+ * @include: nautilus-actions/na-iio-provider.h
*
- * This is the API all I/O Providers should implement in order to
- * provide I/O storage resources to Nautilus-Actions.
+ * The #NAIIOProvider interface provides two types of services:
+ * - load all items at startup
+ * - create, update or delete items via the management user interface.
+ *
+ * These services may be fully implemented by the I/O provider itself.
+ * Or, the I/O provider may also prefer to take advantage of the data
+ * factory management (see #NAIDataFactory and #NAIIOFactory interfaces).
*
* Nautilus-Actions v 2.30 - API version: 1
*/
-#include <nautilus-actions/private/na-object-item-class.h>
+#include "na-object-item.h"
G_BEGIN_DECLS
#define NA_IIO_PROVIDER_TYPE ( na_iio_provider_get_type())
-#define NA_IIO_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_IIO_PROVIDER_TYPE, NAIIOProvider ))
-#define NA_IS_IIO_PROVIDER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_IIO_PROVIDER_TYPE ))
+#define NA_IIO_PROVIDER( instance ) ( G_TYPE_CHECK_INSTANCE_CAST( instance, NA_IIO_PROVIDER_TYPE, NAIIOProvider ))
+#define NA_IS_IIO_PROVIDER( instance ) ( G_TYPE_CHECK_INSTANCE_TYPE( instance, NA_IIO_PROVIDER_TYPE ))
#define NA_IIO_PROVIDER_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_IIO_PROVIDER_TYPE, NAIIOProviderInterface ))
typedef struct NAIIOProvider NAIIOProvider;
@@ -59,21 +64,27 @@ typedef struct {
GTypeInterface parent;
NAIIOProviderInterfacePrivate *private;
- /*
- * This is the API the I/O providers have to implement.
+ /**
+ * get_version:
+ * @instance: the #NAIIOProvider provider.
+ *
+ * Returns: the version of this interface supported by the I/O provider.
+ *
+ * Defaults to 1.
*/
+ guint ( *get_version ) ( const NAIIOProvider *instance );
/**
* get_id:
* @instance: the #NAIIOProvider provider.
*
- * Returns: the id of the IO provider as a newly allocated string
+ * Returns: the id of the I/O provider, as a newly allocated string
* which should be g_free() by the caller.
*
- * To avoid any collision, the IO provider id is allocated by the
- * Nautilus-Actions maintainer team. If you wish develop a new IO
+ * To avoid any collision, the I/O provider id is allocated by the
+ * Nautilus-Actions maintainer team. If you wish develop a new I/O
* provider, and so need a new provider id, please contact the
- * maintainers (see nautilus-actions.doap).
+ * maintainers (see #nautilus-actions.doap).
*
* The I/O provider must implement this function.
*/
@@ -83,7 +94,7 @@ typedef struct {
* get_name:
* @instance: the #NAIIOProvider provider.
*
- * Returns: the name to be displayed for this I/O provider as a
+ * Returns: the name to be displayed for this I/O provider, as a
* newly allocated string which should be g_free() by the caller.
*
* Defaults to an empty string.
@@ -91,26 +102,15 @@ typedef struct {
gchar * ( *get_name ) ( const NAIIOProvider *instance );
/**
- * get_version:
- * @instance: the #NAIIOProvider provider.
- *
- * Returns: the version of this API supported by the IO provider.
- *
- * Defaults to 1.
- */
- guint ( *get_version ) ( const NAIIOProvider *instance );
-
- /**
* read_items:
* @instance: the #NAIIOProvider provider.
- * @messages: a pointer to a #GSList which has been initialized to
- * NULL before calling this function ; the provider may append error
- * messages to this list, but shouldn't reinitialize it.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
*
* Reads the whole items list from the specified I/O provider.
*
- * Returns: a unordered flat #GList of #NAObjectItem-derived objects
- * (menus or actions) ; the actions embed their own profiles.
+ * Returns: a unordered flat #GList of #NAIDataFactory-derived objects
+ * (menus or actions); the actions embed their own profiles.
*/
GList * ( *read_items ) ( const NAIIOProvider *instance, GSList **messages );
@@ -122,12 +122,13 @@ typedef struct {
* %FALSE else.
*
* The 'willing_to_write' property is intrinsic to the I/O provider.
- * It shouldn't do any supposition against the actual runtime
- * environment.
- * It just says that the developer/maintainer has released the needed
- * code in order to update/create/delete #NAObjectItem-derived objects.
+ * It is not supposed to make any assumption on the environment it is
+ * currently running on.
+ * This property just says that the developer/maintainer has released
+ * the needed code in order to update/create/delete #NAIDataFactory-
+ * derived objects.
*
- * Note that even if this property is %TRUE, there is yet several
+ * Note that even if this property is %TRUE, there is yet many
* reasons for not being able to update/delete existing items or
* create new ones (see e.g. #is_able_to_write() below).
*/
@@ -146,7 +147,8 @@ typedef struct {
* down to its storage subsystems.
*
* The 'able_to_write' property is independant of the
- * 'willing_to_write' above.
+ * 'willing_to_write' above, though it is only checked if the
+ * I/O provider is actually willing to write.
*
* This condition is only relevant when trying to define new items,
* to see if a willing_to provider is actually able to do write
@@ -154,57 +156,57 @@ typedef struct {
* existings items as they have already checked their own runtime
* writability status when readen from the storage subsystems.
*
- * Note that even if this property is %TRUE, there is yet several
+ * Note that even if this property is %TRUE, there is yet many
* reasons for not being able to update/delete existing items or
- * create new ones (see e.g. #is_willing_to_write() above).
+ * create new ones (see e.g. 'locked' preference key).
*/
gboolean ( *is_able_to_write ) ( const NAIIOProvider *instance );
/**
* write_item:
* @instance: the #NAIIOProvider provider.
- * @item: a #NAObjectItem-derived menu or action.
- * @messages: a pointer to a #GSList which has been initialized to
- * NULL before calling this function ; the provider may append error
- * messages to this list, but shouldn't reinitialize it.
+ * @item: a #NAObjectItem-derived item, menu or action.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
*
* Writes a new @item.
*
- * Returns: %NA_IIO_PROVIDER_WRITE_OK if the write operation
+ * Returns: %NA_IIO_PROVIDER_CODE_OK if the write operation
* was successfull, or another code depending of the detected error.
*
* Note: there is no update_item function ; it is the responsability
* of the provider to delete the previous version of an item before
- * writing the new version.
+ * actually writing the new one.
*/
guint ( *write_item ) ( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
/**
* delete_item:
* @instance: the #NAIIOProvider provider.
- * @item: a #NAObjectItem-derived menu or action.
- * @messages: a pointer to a #GSList which has been initialized to
- * NULL before calling this function ; the provider may append error
- * messages to this list, but shouldn't reinitialize it.
+ * @item: a #NAObjectItem-derived item, menu or action.
+ * @messages: a pointer to a #GSList list of strings; the provider
+ * may append messages to this list, but shouldn't reinitialize it.
*
* Deletes an existing @item from the I/O subsystem.
*
- * Returns: %NA_IIO_PROVIDER_WRITE_OK if the delete operation was
+ * Returns: %NA_IIO_PROVIDER_CODE_OK if the delete operation was
* successfull, or another code depending of the detected error.
*/
guint ( *delete_item ) ( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
}
NAIIOProviderInterface;
-GType na_iio_provider_get_type ( void );
+GType na_iio_provider_get_type( void );
/* This function is to be called by the I/O provider when it detects
* that the specified object has been modified in its underlying storage
- * subsystem.
+ * subsystem. It eventually ends up by sending a messages to the consumers.
*/
-void na_iio_provider_config_changed ( const NAIIOProvider *instance, const gchar *id );
+void na_iio_provider_item_changed ( const NAIIOProvider *instance, const gchar *id );
+
+#define IIO_PROVIDER_SIGNAL_ITEM_CHANGED "na-iio-provider-notify-pivot"
-/* the reasons for which an item may not be writable
+/* The reasons for which an item may not be writable
* adding a new status here should imply also adding a new tooltip
* in nact_main_statusbar_set_locked().
*/
@@ -234,4 +236,4 @@ enum {
G_END_DECLS
-#endif /* __NAUTILUS_ACTIONS_NA_IIO_PROVIDER_H__ */
+#endif /* __NAUTILUS_ACTIONS_API_NA_IIO_PROVIDER_H__ */
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 7a40b64..10b1b69 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -32,19 +32,19 @@ AM_CPPFLAGS += \
-I $(top_srcdir) \
-DPKGLIBDIR=\""$(pkglibdir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
- -DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_RUNTIME}\" \
+ -DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_CORE}\" \
$(NAUTILUS_ACTIONS_CFLAGS) \
$(NULL)
libna_core_la_SOURCES = \
na-core-utils.c \
na-gconf-monitor.c \
+ na-iio-provider.c \
\
na-gconf-utils.c \
na-gconf-utils.h \
na-iabout.c \
na-iabout.h \
- na-io-provider.c \
na-io-provider.h \
na-ipivot-consumer.c \
na-ipivot-consumer.h \
diff --git a/src/api/na-iio-provider.c b/src/core/na-iio-provider.c
similarity index 69%
rename from src/api/na-iio-provider.c
rename to src/core/na-iio-provider.c
index e398c6f..4dfc502 100644
--- a/src/api/na-iio-provider.c
+++ b/src/core/na-iio-provider.c
@@ -32,7 +32,7 @@
#include <config.h>
#endif
-#include "na-iio-provider.h"
+#include <api/na-iio-provider.h>
/* private interface data
*/
@@ -40,8 +40,16 @@ struct NAIIOProviderInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
-static gboolean st_initialized = FALSE;
-static gboolean st_finalized = FALSE;
+/* signals
+ */
+enum {
+ ITEM_CHANGED,
+ LAST_SIGNAL
+};
+
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+static gint st_signals[ LAST_SIGNAL ] = { 0 };
static GType register_type( void );
static void interface_base_init( NAIIOProviderInterface *klass );
@@ -51,20 +59,27 @@ static gboolean do_is_willing_to_write( const NAIIOProvider *instance );
static gboolean do_is_able_to_write( const NAIIOProvider *instance );
/**
- * Registers the GType of this interface.
+ * na_iio_provider_get_type:
+ *
+ * Returns: the #GType type of this interface.
*/
GType
na_iio_provider_get_type( void )
{
- static GType object_type = 0;
+ static GType type = 0;
- if( !object_type ){
- object_type = register_type();
+ if( !type ){
+ type = register_type();
}
- return( object_type );
+ return( type );
}
+/*
+ * na_iio_provider_register_type:
+ *
+ * Registers this interface.
+ */
static GType
register_type( void )
{
@@ -97,8 +112,17 @@ interface_base_init( NAIIOProviderInterface *klass )
{
static const gchar *thisfn = "na_iio_provider_interface_base_init";
+#if 0
+ g_debug( "%s: st_initialized=%s, st_finalized=%s, klass%p (%s)",
+ thisfn,
+ st_initialized ? "True":"False",
+ st_finalized ? "True":"False",
+ ( void * ) klass, G_OBJECT_CLASS_NAME( klass ));
+#endif
+
if( !st_initialized ){
- g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ g_debug( "%s: klass%p (%s)", thisfn, ( void * ) klass, G_OBJECT_CLASS_NAME( klass ));
klass->private = g_new0( NAIIOProviderInterfacePrivate, 1 );
@@ -110,6 +134,23 @@ interface_base_init( NAIIOProviderInterface *klass )
klass->write_item = NULL;
klass->delete_item = NULL;
+ /* register the signal (without any default handler)
+ * this signal should be sent by the #NAIIOProvider instance when
+ * an item has changed in the underlying storage subsystem
+ * #NAPivot is connected to this signal
+ */
+ st_signals[ ITEM_CHANGED ] = g_signal_new(
+ IIO_PROVIDER_SIGNAL_ITEM_CHANGED,
+ NA_IIO_PROVIDER_TYPE,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER );
+
st_initialized = TRUE;
}
}
@@ -119,12 +160,12 @@ interface_base_finalize( NAIIOProviderInterface *klass )
{
static const gchar *thisfn = "na_iio_provider_interface_base_finalize";
- if( !st_finalized ){
-
- st_finalized = TRUE;
+ if( st_initialized && !st_finalized ){
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+ st_finalized = TRUE;
+
g_free( klass->private );
}
}
@@ -142,8 +183,8 @@ do_is_able_to_write( const NAIIOProvider *instance )
}
/**
- * na_iio_provider_config_changed:
- * @instance: the calling NAIIOProvider.
+ * na_iio_provider_item_changed:
+ * @instance: the calling #NAIIOProvider.
* @id: the id of the modified #NAObjectItem-derived object.
*
* Advertises Nautilus-Actions that this #NAIIOProvider @instance has
@@ -153,11 +194,11 @@ do_is_able_to_write( const NAIIOProvider *instance )
* derived modified objects, but (if possible) only once for each one.
*/
void
-na_iio_provider_config_changed( const NAIIOProvider *instance, const gchar *id )
+na_iio_provider_item_changed( const NAIIOProvider *instance, const gchar *id )
{
- static const gchar *thisfn = "na_iio_provider_config_changed";
+ static const gchar *thisfn = "na_iio_provider_item_changed";
g_debug( "%s: instance=%p, id=%s", thisfn, ( void * ) instance, id );
- g_signal_emit_by_name(( gpointer ) instance, "notify-consumer-of-action-change", id );
+ g_signal_emit_by_name(( gpointer ) instance, IIO_PROVIDER_SIGNAL_ITEM_CHANGED, id );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]