[nautilus-actions] Review usage of g_assert and dispose_has_run
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Review usage of g_assert and dispose_has_run
- Date: Sat, 26 Sep 2009 22:49:31 +0000 (UTC)
commit 2a7516c48f95f5b7075e77c8baa7441aac09af84
Author: pierre <pierre vfedora10 virtuals pwi>
Date: Wed Sep 23 18:17:39 2009 +0200
Review usage of g_assert and dispose_has_run
ChangeLog | 30 ++
src/common/na-gconf-monitor.c | 19 +-
src/common/na-gconf-monitor.h | 2 +-
src/common/na-gconf-provider.c | 116 +++++---
src/common/na-gconf-utils.c | 165 ++++++++++-
src/common/na-iio-provider.c | 103 ++++---
src/common/na-ipivot-consumer.c | 47 ++-
src/common/na-iprefs.c | 67 +++--
src/common/na-object-action-class.h | 26 ++
src/common/na-object-action.c | 232 ++++++++-------
src/common/na-object-action.h | 22 +--
src/common/na-object-class.h | 5 +-
src/common/na-object-fn.h | 2 +-
src/common/na-object-id-class.h | 4 +
src/common/na-object-id-fn.h | 9 +-
src/common/na-object-id.c | 167 ++++++-----
src/common/na-object-item-class.h | 24 ++
src/common/na-object-item-fn.h | 21 +-
src/common/na-object-item.c | 480 +++++++++++++++++--------------
src/common/na-object-menu.c | 88 ++++--
src/common/na-object-menu.h | 2 +-
src/common/na-object-profile-class.h | 8 +
src/common/na-object-profile.c | 531 ++++++++++++++++++----------------
src/common/na-object-profile.h | 8 +-
src/common/na-object.c | 196 ++++++++-----
src/common/na-pivot.c | 114 +++++---
src/common/na-utils.c | 129 +++++++--
src/common/na-xml-writer.c | 72 +++--
src/common/na-xml-writer.h | 3 -
29 files changed, 1660 insertions(+), 1032 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d313392..3c89faf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,36 @@
* data/nautilus-actions.schemas.in: Migrate misnamed keys.
+ * src/common/na-gconf-monitor.c:
+ * src/common/na-gconf-monitor.h:
+ * src/common/na-gconf-provider.c:
+ * src/common/na-gconf-utils.c:
+ * src/common/na-iio-provider.c:
+ * src/common/na-ipivot-consumer.c:
+ * src/common/na-iprefs.c:
+ * src/common/na-object-action-class.h:
+ * src/common/na-object-action.c:
+ * src/common/na-object-action.h:
+ * src/common/na-object-class.h:
+ * src/common/na-object-fn.h:
+ * src/common/na-object-id-class.h:
+ * src/common/na-object-id-fn.h:
+ * src/common/na-object-id.c:
+ * src/common/na-object-item-class.h:
+ * src/common/na-object-item-fn.h:
+ * src/common/na-object-item.c:
+ * src/common/na-object-menu.c:
+ * src/common/na-object-menu.h:
+ * src/common/na-object-profile-class.h:
+ * src/common/na-object-profile.c:
+ * src/common/na-object-profile.h:
+ * src/common/na-object.c:
+ * src/common/na-pivot.c:
+ * src/common/na-utils.c:
+ * src/common/na-xml-writer.c:
+ * src/common/na-xml-writer.h:
+ Review code, usage of g_assert, test dispose_has_run.
+
* src/nact/base-iprefs.c:
* src/nact/base-iprefs.h (base_iprefs_migrate_key): New function.
diff --git a/src/common/na-gconf-monitor.c b/src/common/na-gconf-monitor.c
index 57a8458..9043b91 100644
--- a/src/common/na-gconf-monitor.c
+++ b/src/common/na-gconf-monitor.c
@@ -142,11 +142,11 @@ instance_dispose( GObject *object )
if( !self->private->dispose_has_run ){
- self->private->dispose_has_run = TRUE;
-
- /* release the installed monitor */
+ /* release the installed monitor before setting dispose_has_run */
release_monitor( self );
+ 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 );
@@ -249,12 +249,15 @@ install_monitor( NAGConfMonitor *monitor )
* Release allocated monitors.
*/
void
-na_gconf_monitor_release_monitors( GSList *monitors )
+na_gconf_monitor_release_monitors( GList *monitors )
{
- g_slist_foreach( monitors, ( GFunc ) g_object_unref, NULL );
- g_slist_free( monitors );
+ g_list_foreach( monitors, ( GFunc ) g_object_unref, NULL );
+ g_list_free( monitors );
}
+/*
+ * this is called by instance_dispose, before setting dispose_has_run
+ */
static void
release_monitor( NAGConfMonitor *monitor )
{
@@ -262,8 +265,8 @@ release_monitor( NAGConfMonitor *monitor )
GError *error = NULL;
g_debug( "%s: monitor=%p", thisfn, ( void * ) monitor );
-
g_return_if_fail( NA_IS_GCONF_MONITOR( monitor ));
+ g_return_if_fail( !monitor->private->dispose_has_run );
if( monitor->private->monitor_id ){
gconf_client_notify_remove( monitor->private->gconf, monitor->private->monitor_id );
@@ -272,7 +275,7 @@ release_monitor( NAGConfMonitor *monitor )
gconf_client_remove_dir( monitor->private->gconf, monitor->private->path, &error );
if( error ){
- g_warning( "%s[gconf_client_remove_dir] path=%s, error=%s", thisfn, monitor->private->path, error->message );
+ g_warning( "%s: path=%s, error=%s", thisfn, monitor->private->path, error->message );
g_error_free( error );
}
}
diff --git a/src/common/na-gconf-monitor.h b/src/common/na-gconf-monitor.h
index a0c6f5c..096cd36 100644
--- a/src/common/na-gconf-monitor.h
+++ b/src/common/na-gconf-monitor.h
@@ -70,7 +70,7 @@ GType na_gconf_monitor_get_type( void );
NAGConfMonitor *na_gconf_monitor_new( GConfClient *client, const gchar *path, gint preload, GConfClientNotifyFunc handler, gpointer user_data );
-void na_gconf_monitor_release_monitors( GSList *monitors );
+void na_gconf_monitor_release_monitors( GList *monitors );
G_END_DECLS
diff --git a/src/common/na-gconf-provider.c b/src/common/na-gconf-provider.c
index 894343f..0608908 100644
--- a/src/common/na-gconf-provider.c
+++ b/src/common/na-gconf-provider.c
@@ -57,7 +57,7 @@ struct NAGConfProviderPrivate {
gboolean dispose_has_run;
GConfClient *gconf;
NAPivot *pivot;
- GSList *monitors;
+ GList *monitors;
};
static GObjectClass *st_parent_class = NULL;
@@ -272,7 +272,7 @@ na_gconf_provider_new( NAPivot *handler )
static void
install_monitors( NAGConfProvider *provider )
{
- GSList *list = NULL;
+ GList *list = NULL;
g_return_if_fail( NA_IS_GCONF_PROVIDER( provider ));
g_return_if_fail( NA_IS_IIO_PROVIDER( provider ));
@@ -281,7 +281,8 @@ install_monitors( NAGConfProvider *provider )
/* monitor the configurations/ directory which contains all menus,
* actions and profiles definitions
*/
- list = g_slist_prepend( list,
+ list = g_list_prepend( list,
+
na_gconf_monitor_new(
provider->private->gconf,
NA_GCONF_CONFIG_PATH,
@@ -294,23 +295,30 @@ install_monitors( NAGConfProvider *provider )
/*
* this callback is triggered each time a value is changed under our
- * configurations/ directory
+ * configurations/ directory ; as each object has several entries which
+ * describe it, this callback is triggered several times for each object
+ * update
+ *
+ * up to and including 1.10.1, the user interface took care of writing
+ * a special key in GConf at the end of each update operations ;
+ * as GConf monitored only this special key, it triggered this callback
+ * once for each global update operation
*
- * if the modification is made from nautilus-actions-config ui, then
- * the callback is triggered several times (one time for each rewritten
- * property) as action/profile are edited as blocs of data ; in this
- * case, the ui takes care (as of of 1.10) of also writing at last a
- * particular key of the form xxx:yyyyyyyy-yyyy-yyyy-..., where :
+ * this special key was of the form xxx:yyyyyyyy-yyyy-yyyy-..., where :
* xxx was a sequential number (inside of the ui session)
* yyyyyyyy-yyyy-yyyy-... was the uuid of the involved action
*
- * this was so a sort of hack which simplifies a lot the notification
- * system (take the new action, replace it in the current global list)
- * but didn't work if the modification was made from outside of the ui
+ * this was a sort of hack which simplified a lot the notification
+ * system, but didn't take into account any modification which might
+ * come from outside of the ui
*
* if the modification is made elsewhere (an action is imported as a
* xml file in gconf, or gconf is directly edited), we'd have to rely
- * only on the standard mmonitor (GConf watch) mechanism
+ * only on the standard monitor (GConf watch) mechanism
+ *
+ * this is what we do below, thus triggering NAPivot for each and every
+ * modification in the GConf underlying system ; this is the prerogative
+ * of NAPivot to decide what to do with them
*/
static void
config_path_changed_cb( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAGConfProvider *provider )
@@ -318,15 +326,16 @@ config_path_changed_cb( GConfClient *client, guint cnxn_id, GConfEntry *entry, N
/*static const gchar *thisfn = "na_gconf_provider_config_path_changed_cb";*/
NAPivotNotify *npn;
- g_return_if_fail( NA_IS_GCONF_PROVIDER( provider ));
- g_return_if_fail( NA_IS_IIO_PROVIDER( provider ));
- g_return_if_fail( !provider->private->dispose_has_run );
-
/*g_debug( "%s: client=%p, cnxnid=%u, entry=%p, provider=%p",
thisfn, ( void * ) client, cnxn_id, ( void * ) entry, ( void * ) provider );*/
- npn = entry_to_notify( entry );
- g_signal_emit_by_name( provider->private->pivot, NA_IIO_PROVIDER_SIGNAL_ACTION_CHANGED, npn );
+ g_return_if_fail( NA_IS_GCONF_PROVIDER( provider ));
+ g_return_if_fail( NA_IS_IIO_PROVIDER( provider ));
+
+ if( !provider->private->dispose_has_run ){
+ npn = entry_to_notify( entry );
+ g_signal_emit_by_name( provider->private->pivot, NA_IIO_PROVIDER_SIGNAL_ACTION_CHANGED, npn );
+ }
}
/*
@@ -438,21 +447,21 @@ iio_provider_read_items_list( const NAIIOProvider *provider )
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NULL );
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), NULL );
self = NA_GCONF_PROVIDER( provider );
- g_return_val_if_fail( !self->private->dispose_has_run, NULL );
- listpath = na_gconf_utils_get_subdirs( self->private->gconf, NA_GCONF_CONFIG_PATH );
+ if( !self->private->dispose_has_run ){
- for( ip = listpath ; ip ; ip = ip->next ){
+ listpath = na_gconf_utils_get_subdirs( self->private->gconf, NA_GCONF_CONFIG_PATH );
- const gchar *path = ( const gchar * ) ip->data;
+ for( ip = listpath ; ip ; ip = ip->next ){
- item = read_item( self, path );
+ const gchar *path = ( const gchar * ) ip->data;
+ item = read_item( self, path );
+ items_list = g_list_prepend( items_list, item );
+ }
- items_list = g_list_prepend( items_list, item );
+ na_gconf_utils_free_subdirs( listpath );
}
- na_gconf_utils_free_subdirs( listpath );
-
return( items_list );
}
@@ -730,24 +739,38 @@ read_object_item_properties( NAGConfProvider *provider, GSList *entries, NAObjec
static gboolean
iio_provider_is_willing_to_write( const NAIIOProvider *provider )
{
+ NAGConfProvider *self;
+ gboolean willing_to = FALSE;
+
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), FALSE );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), FALSE );
- g_return_val_if_fail( !NA_GCONF_PROVIDER( provider )->private->dispose_has_run, FALSE );
+ self = NA_GCONF_PROVIDER( provider );
/* TODO: na_gconf_provider_iio_provider_is_willing_to_write */
- return( TRUE );
+ if( !self->private->dispose_has_run ){
+ willing_to = TRUE;
+ }
+
+ return( willing_to );
}
static gboolean
iio_provider_is_writable( const NAIIOProvider *provider, const NAObject *item )
{
+ NAGConfProvider *self;
+ gboolean willing_to = FALSE;
+
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), FALSE );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), FALSE );
- g_return_val_if_fail( !NA_GCONF_PROVIDER( provider )->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), FALSE );
+ self = NA_GCONF_PROVIDER( provider );
/* TODO: na_gconf_provider_iio_provider_is_writable */
- return( TRUE );
+ if( !self->private->dispose_has_run ){
+ willing_to = TRUE;
+ }
+
+ return( willing_to );
}
static guint
@@ -756,16 +779,22 @@ iio_provider_write_item( const NAIIOProvider *provider, NAObject *item, gchar **
static const gchar *thisfn = "na_gconf_provider_iio_provider_write_item";
NAGConfProvider *self;
- g_debug( "%s: provider=%p, item=%p, message=%p",
- thisfn, ( void * ) provider, ( void * ) item, ( void * ) message );
-
+ g_debug( "%s: provider=%p, item=%p (%s), message=%p",
+ thisfn, ( void * ) provider,
+ ( void * ) item, G_OBJECT_TYPE_NAME( item ), ( void * ) message );
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- g_return_val_if_fail( !NA_GCONF_PROVIDER( provider )->private->dispose_has_run, NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
self = NA_GCONF_PROVIDER( provider );
- message = NULL;
+
+ if( message ){
+ *message = NULL;
+ }
+
+ if( self->private->dispose_has_run ){
+ return( NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE );
+ }
if( NA_IS_OBJECT_ACTION( item )){
if( !write_item_action( self, NA_OBJECT_ACTION( item ), message )){
@@ -880,17 +909,24 @@ iio_provider_delete_item( const NAIIOProvider *provider, const NAObject *item, g
gchar *uuid, *path;
GError *error = NULL;
- g_debug( "%s: provider=%p, item=%p, message=%p",
- thisfn, ( void * ) provider, ( void * ) item, ( void * ) message );
+ g_debug( "%s: provider=%p, item=%p (%s), message=%p",
+ thisfn, ( void * ) provider,
+ ( void * ) item, G_OBJECT_TYPE_NAME( item ), ( void * ) message );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- g_return_val_if_fail( !NA_GCONF_PROVIDER( provider )->private->dispose_has_run, NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
self = NA_GCONF_PROVIDER( provider );
- message = NULL;
+ if( self->private->dispose_has_run ){
+ return( NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE );
+ }
+
+ if( message ){
+ *message = NULL;
+ }
+
ret = NA_IIO_PROVIDER_WRITE_OK;
uuid = na_object_get_id( NA_OBJECT( item ));
diff --git a/src/common/na-gconf-utils.c b/src/common/na-gconf-utils.c
index e3ac361..ede05f0 100644
--- a/src/common/na-gconf-utils.c
+++ b/src/common/na-gconf-utils.c
@@ -39,9 +39,17 @@
static gboolean sync_gconf( GConfClient *gconf, gchar **message );
-/*
- * load the keys which are the subdirs of the given path
- * returns a list of keys as full path
+/**
+ * na_gconf_utils_get_subdirs:
+ * @gconf: a #GConfClient instance.
+ * @path: a full path to be readen.
+ *
+ * Loads the subdirs of the given path.
+ *
+ * Returns: a GSList of full path subdirectories.
+ *
+ * The returned list should be na_gconf_utils_free_subdirs() by the
+ * caller.
*/
GSList *
na_gconf_utils_get_subdirs( GConfClient *gconf, const gchar *path )
@@ -61,12 +69,26 @@ na_gconf_utils_get_subdirs( GConfClient *gconf, const gchar *path )
return( list_subdirs );
}
+/**
+ * na_gconf_utils_free_subdirs:
+ * @subdirs: a list of subdirs as returned by na_gconf_utils_get_subdirs().
+ *
+ * Release the list of subdirs.
+ */
void
na_gconf_utils_free_subdirs( GSList *subdirs )
{
na_utils_free_string_list( subdirs );
}
+/**
+ * na_gconf_utils_have_subdir:
+ * @gconf: a #GConfClient instance.
+ * @path: a full path to be readen.
+ *
+ * Returns: %TRUE if the specified path has at least one subdirectory,
+ * %FALSE else.
+ */
gboolean
na_gconf_utils_have_subdir( GConfClient *gconf, const gchar *path )
{
@@ -80,12 +102,18 @@ na_gconf_utils_have_subdir( GConfClient *gconf, const gchar *path )
return( have_subdir );
}
-/*
- * load all the key=value pairs of this key specified as a full path,
- * returning them as a list of GConfEntry.
+/**
+ * na_gconf_utils_get_entries:
+ * @gconf: a #GConfClient instance.
+ * @path: a full path to be readen.
+ *
+ * Loads all the key=value pairs of the specified key.
+ *
+ * Returns: a list of #GConfEntry.
*
- * The list is not recursive, it contains only the immediate children of
- * path. To free the returned list, call na_gconf_utils_free_entries().
+ * The returned list is not recursive : it contains only the immediate
+ * children of @path. To free the returned list, call
+ * na_gconf_utils_free_entries().
*/
GSList *
na_gconf_utils_get_entries( GConfClient *gconf, const gchar *path )
@@ -105,6 +133,12 @@ na_gconf_utils_get_entries( GConfClient *gconf, const gchar *path )
return( list_entries );
}
+/**
+ * na_gconf_utils_free_entries:
+ * @list: a list of #GConfEntry as returned by na_gconf_utils_get_entries().
+ *
+ * Releases the provided list.
+ */
void
na_gconf_utils_free_entries( GSList *list )
{
@@ -112,6 +146,15 @@ na_gconf_utils_free_entries( GSList *list )
g_slist_free( list );
}
+/**
+ * na_gconf_utils_have_entry:
+ * @gconf: a #GConfClient instance.
+ * @path: the full path of a key.
+ * @entry: the entry to be tested.
+ *
+ * Returns: %TRUE if the given @entry exists for the given @path,
+ * %FALSE else.
+ */
gboolean
na_gconf_utils_have_entry( GConfClient *gconf, const gchar *path, const gchar *entry )
{
@@ -144,6 +187,17 @@ na_gconf_utils_have_entry( GConfClient *gconf, const gchar *path, const gchar *e
return( have_entry );
}
+/**
+ * na_gconf_utils_get_bool_from_entries:
+ * @entries: a list of #GConfEntry as returned by na_gconf_utils_get_entries().
+ * @entry: the searched entry.
+ * @value: a pointer to a gboolean to be set to the found value.
+ *
+ * Returns: %TRUE if the entry was found, %FALSE else.
+ *
+ * If the entry was not found, or was not of boolean type, @value is set
+ * to %FALSE.
+ */
gboolean
na_gconf_utils_get_bool_from_entries( GSList *entries, const gchar *entry, gboolean *value )
{
@@ -178,6 +232,19 @@ na_gconf_utils_get_bool_from_entries( GSList *entries, const gchar *entry, gbool
return( found );
}
+/**
+ * na_gconf_utils_get_string_from_entries:
+ * @entries: a list of #GConfEntry as returned by na_gconf_utils_get_entries().
+ * @entry: the searched entry.
+ * @value: a pointer to a gchar * to be set to the found value.
+ *
+ * Returns: %TRUE if the entry was found, %FALSE else.
+ *
+ * If the entry was not found, or was not of string type, @value is set
+ * to %NULL.
+ *
+ * If @value is returned not NULL, it should be g_free() by the caller.
+ */
gboolean
na_gconf_utils_get_string_from_entries( GSList *entries, const gchar *entry, gchar **value )
{
@@ -212,6 +279,20 @@ na_gconf_utils_get_string_from_entries( GSList *entries, const gchar *entry, gch
return( found );
}
+/**
+ * na_gconf_utils_get_string_list_from_entries:
+ * @entries: a list of #GConfEntry as returned by na_gconf_utils_get_entries().
+ * @entry: the searched entry.
+ * @value: a pointer to a GSList * to be set to the found value.
+ *
+ * Returns: %TRUE if the entry was found, %FALSE else.
+ *
+ * If the entry was not found, or was not of string list type, @value
+ * is set to %NULL.
+ *
+ * If @value is returned not NULL, it should be na_utils_free_string_list()
+ * by the caller.
+ */
gboolean
na_gconf_utils_get_string_list_from_entries( GSList *entries, const gchar *entry, GSList **value )
{
@@ -250,12 +331,31 @@ na_gconf_utils_get_string_list_from_entries( GSList *entries, const gchar *entry
return( found );
}
+/**
+ * na_gconf_utils_path_to_key:
+ * @path: the full path of a key.
+ *
+ * Returns: the key itself, i.e. the last part of the @path.
+ *
+ * The returned string should be g_free() by the caller.
+ */
gchar *
na_gconf_utils_path_to_key( const gchar *path )
{
return( na_utils_path_extract_last_dir( path ));
}
+/**
+ * na_gconf_utils_read_bool:
+ * @gconf: a #GConfClient instance.
+ * @path: the full path to the key.
+ * @use_schema: whether to use a default value from schema, or not.
+ * @default_value: default value to be used if @use_schema is %FALSE.
+ *
+ * Returns: the boolean value read at the specified @path, taking into
+ * account a default value from schema (if @use_schema if %TRUE), or
+ * the specified @default_value.
+ */
gboolean
na_gconf_utils_read_bool( GConfClient *gconf, const gchar *path, gboolean use_schema, gboolean default_value )
{
@@ -292,7 +392,12 @@ na_gconf_utils_read_bool( GConfClient *gconf, const gchar *path, gboolean use_sc
}
/**
- * Returns: a list of strings.
+ * na_gconf_utils_read_string_list:
+ * @gconf: a #GConfClient instance.
+ * @path: the full path to the key to be read.
+ *
+ * Returns: a list of strings,
+ * or %NULL if the entry was not found or was not of string list type.
*
* The returned list must be released with na_utils_free_string_list().
*/
@@ -316,6 +421,20 @@ na_gconf_utils_read_string_list( GConfClient *gconf, const gchar *path )
return( list_strings );
}
+/**
+ * na_gconf_utils_write_bool:
+ * @gconf: a #GConfClient instance.
+ * @path: the full path to the key.
+ * @value: the value to be written.
+ * @message: a pointer to a gchar * which will be allocated if needed.
+ *
+ * Writes a boolean at the given @path.
+ *
+ * Returns: %TRUE if the writing has been successfull, %FALSE else.
+ *
+ * If returned not NULL, the @message contains an error message.
+ * It should be g_free() by the caller.
+ */
gboolean
na_gconf_utils_write_bool( GConfClient *gconf, const gchar *path, gboolean value, gchar **message )
{
@@ -337,6 +456,20 @@ na_gconf_utils_write_bool( GConfClient *gconf, const gchar *path, gboolean value
return( ret );
}
+/**
+ * na_gconf_utils_write_string:
+ * @gconf: a #GConfClient instance.
+ * @path: the full path to the key.
+ * @value: the value to be written.
+ * @message: a pointer to a gchar * which will be allocated if needed.
+ *
+ * Writes a string at the given @path.
+ *
+ * Returns: %TRUE if the writing has been successfull, %FALSE else.
+ *
+ * If returned not NULL, the @message contains an error message.
+ * It should be g_free() by the caller.
+ */
gboolean
na_gconf_utils_write_string( GConfClient *gconf, const gchar *path, const gchar *value, gchar **message )
{
@@ -358,6 +491,20 @@ na_gconf_utils_write_string( GConfClient *gconf, const gchar *path, const gchar
return( ret );
}
+/**
+ * na_gconf_utils_write_string_list:
+ * @gconf: a #GConfClient instance.
+ * @path: the full path to the key.
+ * @value: the list of values to be written.
+ * @message: a pointer to a gchar * which will be allocated if needed.
+ *
+ * Writes a list of strings at the given @path.
+ *
+ * Returns: %TRUE if the writing has been successfull, %FALSE else.
+ *
+ * If returned not NULL, the @message contains an error message.
+ * It should be g_free() by the caller.
+ */
gboolean
na_gconf_utils_write_string_list( GConfClient *gconf, const gchar *path, GSList *value, gchar **message )
{
diff --git a/src/common/na-iio-provider.c b/src/common/na-iio-provider.c
index c78df49..fb476dc 100644
--- a/src/common/na-iio-provider.c
+++ b/src/common/na-iio-provider.c
@@ -161,25 +161,28 @@ na_iio_provider_get_items_tree( const NAPivot *pivot )
GSList *level_zero;
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
-
- g_return_val_if_fail( st_initialized && !st_finalized, NULL );
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
g_return_val_if_fail( NA_IS_IPREFS( pivot ), NULL );
- providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- merged = get_merged_items_list( pivot, providers );
- na_pivot_free_providers( providers );
+ hierarchy = NULL;
- level_zero = na_iprefs_get_level_zero_items( NA_IPREFS( pivot ));
- hierarchy = build_hierarchy( merged, level_zero, TRUE );
- na_utils_free_string_list( level_zero );
- na_object_free_items( merged );
+ if( st_initialized && !st_finalized ){
- if( na_iprefs_is_alphabetical_order( NA_IPREFS( pivot ))){
- hierarchy = sort_tree( pivot, hierarchy );
- }
+ providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
+ merged = get_merged_items_list( pivot, providers );
+ na_pivot_free_providers( providers );
- na_object_dump_tree( hierarchy );
+ level_zero = na_iprefs_get_level_zero_items( NA_IPREFS( pivot ));
+ hierarchy = build_hierarchy( merged, level_zero, TRUE );
+ na_utils_free_string_list( level_zero );
+ na_object_free_items( merged );
+
+ if( na_iprefs_is_alphabetical_order( NA_IPREFS( pivot ))){
+ hierarchy = sort_tree( pivot, hierarchy );
+ }
+
+ na_object_dump_tree( hierarchy );
+ }
return( hierarchy );
}
@@ -219,6 +222,7 @@ build_hierarchy( GList *tree, GSList *level_zero, gboolean list_if_empty )
}
}
}
+
/* if level-zero list is empty, we consider that all actions go to it
*/
else if( list_if_empty ){
@@ -306,39 +310,43 @@ na_iio_provider_write_item( const NAPivot *pivot, NAObject *item, gchar **messag
( void * ) item, G_OBJECT_TYPE_NAME( item ),
( void * ) message );
- g_return_val_if_fail( st_initialized && !st_finalized, NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail(( NA_IS_PIVOT( pivot ) || !pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- ret = NA_IIO_PROVIDER_NOT_WRITABLE;
- bad_instance = NULL;
+ ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
- /* try to write to the original provider of the item
- */
- instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
- if( instance ){
- ret = try_write_item( instance, item, message );
- if( ret == NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE || ret == NA_IIO_PROVIDER_NOT_WRITABLE ){
- bad_instance = instance;
- instance = NULL;
- }
- }
+ if( st_initialized && !st_finalized ){
- /* else, search for a provider which is willing to write the item
- */
- if( !instance && pivot ){
- providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- for( ip = providers ; ip ; ip = ip->next ){
+ ret = NA_IIO_PROVIDER_NOT_WRITABLE;
+ bad_instance = NULL;
- instance = NA_IIO_PROVIDER( ip->data );
- if( !bad_instance || bad_instance != instance ){
- ret = try_write_item( instance, item, message );
- if( ret == NA_IIO_PROVIDER_WRITE_OK ){
- break;
+ /* try to write to the original provider of the item
+ */
+ instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
+ if( instance ){
+ ret = try_write_item( instance, item, message );
+ if( ret == NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE || ret == NA_IIO_PROVIDER_NOT_WRITABLE ){
+ bad_instance = instance;
+ instance = NULL;
+ }
+ }
+
+ /* else, search for a provider which is willing to write the item
+ */
+ if( !instance && pivot ){
+ providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
+ for( ip = providers ; ip ; ip = ip->next ){
+
+ instance = NA_IIO_PROVIDER( ip->data );
+ if( !bad_instance || bad_instance != instance ){
+ ret = try_write_item( instance, item, message );
+ if( ret == NA_IIO_PROVIDER_WRITE_OK ){
+ break;
+ }
}
}
+ na_pivot_free_providers( providers );
}
- na_pivot_free_providers( providers );
}
return( ret );
@@ -401,22 +409,23 @@ na_iio_provider_delete_item( const NAPivot *pivot, const NAObject *item, gchar *
( void * ) item, G_OBJECT_TYPE_NAME( item ),
( void * ) message );
- g_return_val_if_fail( st_initialized && !st_finalized, NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- ret = NA_IIO_PROVIDER_NOT_WRITABLE;
- instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
+ ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
+
+ if( st_initialized && !st_finalized ){
- if( instance ){
- g_assert( NA_IS_IIO_PROVIDER( instance ));
+ ret = NA_IIO_PROVIDER_NOT_WRITABLE;
+ instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
- if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item ){
- ret = NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item( instance, item, message );
+ if( instance ){
+ g_return_val_if_fail( NA_IS_IIO_PROVIDER( instance ), NA_IIO_PROVIDER_PROGRAM_ERROR );
+
+ if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item ){
+ ret = NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item( instance, item, message );
+ }
}
- /*} else {
- *message = g_strdup( _( "Unable to delete the action: no I/O provider." ));
- ret = NA_IIO_PROVIDER_NO_PROVIDER;*/
}
return( ret );
diff --git a/src/common/na-ipivot-consumer.c b/src/common/na-ipivot-consumer.c
index 3e585d2..10b1118 100644
--- a/src/common/na-ipivot-consumer.c
+++ b/src/common/na-ipivot-consumer.c
@@ -104,6 +104,8 @@ interface_base_init( NAIPivotConsumerInterface *klass )
klass->private = g_new0( NAIPivotConsumerInterfacePrivate, 1 );
klass->on_actions_changed = NULL /*do_actions_changed*/;
+ klass->on_display_about_changed = NULL;
+ klass->on_display_order_changed = NULL;
st_initialized = TRUE;
}
@@ -136,19 +138,23 @@ interface_base_finalize( NAIPivotConsumerInterface *klass )
void
na_ipivot_consumer_delay_notify( NAIPivotConsumer *instance )
{
+ static const gchar *thisfn = "na_ipivot_consumer_delay_notify";
GTimeVal *last_delay;
- g_return_if_fail( st_initialized && !st_finalized );
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
- last_delay = ( GTimeVal * ) g_object_get_data( G_OBJECT( instance ), "na-ipivot-consumer-delay-notify" );
+ if( st_initialized && !st_finalized ){
- if( !last_delay ){
- last_delay = g_new0( GTimeVal, 1 );
- g_object_set_data( G_OBJECT( instance ), "na-ipivot-consumer-delay-notify", last_delay );
- }
+ last_delay = ( GTimeVal * ) g_object_get_data( G_OBJECT( instance ), "na-ipivot-consumer-delay-notify" );
- g_get_current_time( last_delay );
+ if( !last_delay ){
+ last_delay = g_new0( GTimeVal, 1 );
+ g_object_set_data( G_OBJECT( instance ), "na-ipivot-consumer-delay-notify", last_delay );
+ }
+
+ g_get_current_time( last_delay );
+ }
}
/**
@@ -165,12 +171,15 @@ void na_ipivot_consumer_notify( NAIPivotConsumer *instance )
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- g_return_if_fail( st_initialized && !st_finalized );
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
- if( is_notify_allowed( instance )){
- if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_actions_changed ){
- NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_actions_changed( instance, NULL );
+ if( st_initialized && !st_finalized ){
+
+ if( is_notify_allowed( instance )){
+
+ if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_actions_changed ){
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_actions_changed( instance, NULL );
+ }
}
}
}
@@ -185,11 +194,13 @@ void na_ipivot_consumer_notify( NAIPivotConsumer *instance )
void
na_ipivot_consumer_notify_display_order_change( NAIPivotConsumer *instance )
{
- g_return_if_fail( st_initialized && !st_finalized );
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
- if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed ){
- NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed( instance, NULL );
+ if( st_initialized && !st_finalized ){
+
+ if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed ){
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed( instance, NULL );
+ }
}
}
@@ -204,11 +215,13 @@ na_ipivot_consumer_notify_display_order_change( NAIPivotConsumer *instance )
void
na_ipivot_consumer_notify_display_about_change( NAIPivotConsumer *instance )
{
- g_return_if_fail( st_initialized && !st_finalized );
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
- if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed ){
- NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed( instance, NULL );
+ if( st_initialized && !st_finalized ){
+
+ if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed ){
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed( instance, NULL );
+ }
}
}
diff --git a/src/common/na-iprefs.c b/src/common/na-iprefs.c
index ed4eb93..80f11d1 100644
--- a/src/common/na-iprefs.c
+++ b/src/common/na-iprefs.c
@@ -128,30 +128,41 @@ interface_base_finalize( NAIPrefsInterface *klass )
/**
* na_iprefs_get_level_zero_items:
* @instance: this #NAIPrefs interface instance.
+ *
+ * Returns: the ordered list of UUID's of items which are to be
+ * displayed at level zero of the hierarchy.
+ *
+ * The returned list should be na_utils_free_string_list() by the caller.
*/
GSList *
na_iprefs_get_level_zero_items( NAIPrefs *instance )
{
- g_return_val_if_fail( st_initialized && !st_finalized, NULL );
+ GSList *level_zero = NULL;
+
g_return_val_if_fail( NA_IS_IPREFS( instance ), NULL );
- return( read_string_list( instance, PREFS_LEVEL_ZERO_ITEMS ));
+ if( st_initialized && !st_finalized ){
+ level_zero = read_string_list( instance, PREFS_LEVEL_ZERO_ITEMS );
+ }
+
+ return( level_zero );
}
/**
* na_iprefs_set_level_zero_items:
* @instance: this #NAIPrefs interface instance.
- * @order: a #GSList of item ids.
+ * @order: the ordered #GSList of item UUIDs.
*
- * Writes the order and the content of the level-zero items.
+ * Writes the order and the content of the level-zero UUID's.
*/
void
na_iprefs_set_level_zero_items( NAIPrefs *instance, GSList *order )
{
- g_return_if_fail( st_initialized && !st_finalized );
g_return_if_fail( NA_IS_IPREFS( instance ));
- write_string_list( instance, PREFS_LEVEL_ZERO_ITEMS, order );
+ if( st_initialized && !st_finalized ){
+ write_string_list( instance, PREFS_LEVEL_ZERO_ITEMS, order );
+ }
}
/**
@@ -170,23 +181,33 @@ na_iprefs_set_level_zero_items( NAIPrefs *instance, GSList *order )
gboolean
na_iprefs_is_alphabetical_order( NAIPrefs *instance )
{
- g_return_val_if_fail( st_initialized && !st_finalized, FALSE );
+ gboolean alpha_order = FALSE;
+
g_return_val_if_fail( NA_IS_IPREFS( instance ), FALSE );
- return( read_bool( instance, PREFS_DISPLAY_ALPHABETICAL_ORDER, TRUE ));
+ if( st_initialized && !st_finalized ){
+ alpha_order = read_bool( instance, PREFS_DISPLAY_ALPHABETICAL_ORDER, TRUE );
+ }
+
+ return( alpha_order );
}
/**
* na_iprefs_set_alphabetical_order:
* @instance: this #NAIPrefs interface instance.
+ * @enabled: the new value to be written.
+ *
+ * Writes the current status of 'alphabetical order' to the GConf
+ * preference system.
*/
void
na_iprefs_set_alphabetical_order( NAIPrefs *instance, gboolean enabled )
{
- g_return_if_fail( st_initialized && !st_finalized );
g_return_if_fail( NA_IS_IPREFS( instance ));
- write_bool( instance, PREFS_DISPLAY_ALPHABETICAL_ORDER, enabled );
+ if( st_initialized && !st_finalized ){
+ write_bool( instance, PREFS_DISPLAY_ALPHABETICAL_ORDER, enabled );
+ }
}
/**
@@ -205,32 +226,32 @@ na_iprefs_set_alphabetical_order( NAIPrefs *instance, gboolean enabled )
gboolean
na_iprefs_should_add_about_item( NAIPrefs *instance )
{
- g_return_val_if_fail( st_initialized && !st_finalized, FALSE );
+ gboolean about = FALSE;
+
g_return_val_if_fail( NA_IS_IPREFS( instance ), FALSE );
- return( read_bool( instance, PREFS_ADD_ABOUT_ITEM, TRUE ));
+ if( st_initialized && !st_finalized ){
+ about = read_bool( instance, PREFS_ADD_ABOUT_ITEM, TRUE );
+ }
+
+ return( about );
}
/**
- * na_iprefs_should_add_about_item:
+ * na_iprefs_set_add_about_item:
* @instance: this #NAIPrefs interface instance.
+ * @enabled: the new value to be written.
*
- * Returns: #TRUE if an "About Nautilus Actions" item may be added to
- * the first level of Nautilus context submenus (if any), #FALSE else.
- *
- * Note: this function returns a suitable default value if the key is
- * not found in GConf preferences.
- *
- * Note: please take care of keeping the default value synchronized with
- * those defined in schemas.
+ * Writes the new value to the GConf preference system.
*/
void
na_iprefs_set_add_about_item( NAIPrefs *instance, gboolean enabled )
{
- g_return_if_fail( st_initialized && !st_finalized );
g_return_if_fail( NA_IS_IPREFS( instance ));
- write_bool( instance, PREFS_ADD_ABOUT_ITEM, enabled );
+ if( st_initialized && !st_finalized ){
+ write_bool( instance, PREFS_ADD_ABOUT_ITEM, enabled );
+ }
}
static gboolean
diff --git a/src/common/na-object-action-class.h b/src/common/na-object-action-class.h
index d0db613..2373c5e 100644
--- a/src/common/na-object-action-class.h
+++ b/src/common/na-object-action-class.h
@@ -31,6 +31,32 @@
#ifndef __NA_OBJECT_ACTION_CLASS_H__
#define __NA_OBJECT_ACTION_CLASS_H__
+/**
+ * SECTION: na_object_action
+ * @short_description: #NAObjectAction class definition.
+ * @include: common/na-object-action-class.h
+ *
+ * This is the class which maintains data and properties of an Nautilus
+ * action.
+ *
+ * Note about the UUID :
+ *
+ * The uuid is only required when writing the action to GConf in order
+ * to ensure unicity of subdirectories.
+ *
+ * UUID is transfered through import/export operations.
+ *
+ * Note that a user may import an action, translate it and then
+ * reexport it : we so may have two different actions with the same
+ * uuid. The user has so to modify the UUID before import.
+ *
+ * Note about edition status :
+ *
+ * As a particular rule of #NAObjectItem derived class, an action is
+ * considered modified as soon as any of its profiles has been modified
+ * itself (because they are saved as a whole).
+ */
+
#include "na-object-item-class.h"
G_BEGIN_DECLS
diff --git a/src/common/na-object-action.c b/src/common/na-object-action.c
index e52c2c1..8360d31 100644
--- a/src/common/na-object-action.c
+++ b/src/common/na-object-action.c
@@ -194,21 +194,23 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
NAObjectAction *self;
g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
- g_return_if_fail( !NA_OBJECT_ACTION( object )->private->dispose_has_run );
self = NA_OBJECT_ACTION( object );
- switch( property_id ){
- case NAACTION_PROP_VERSION_ID:
- g_value_set_string( value, self->private->version );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAACTION_PROP_VERSION_ID:
+ g_value_set_string( value, self->private->version );
+ break;
- case NAACTION_PROP_READONLY_ID:
- g_value_set_boolean( value, self->private->read_only );
- break;
+ case NAACTION_PROP_READONLY_ID:
+ g_value_set_boolean( value, self->private->read_only );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -218,22 +220,24 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
NAObjectAction *self;
g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
- g_return_if_fail( !NA_OBJECT_ACTION( object )->private->dispose_has_run );
self = NA_OBJECT_ACTION( object );
- switch( property_id ){
- case NAACTION_PROP_VERSION_ID:
- g_free( self->private->version );
- self->private->version = g_value_dup_string( value );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAACTION_PROP_VERSION_ID:
+ g_free( self->private->version );
+ self->private->version = g_value_dup_string( value );
+ break;
- case NAACTION_PROP_READONLY_ID:
- self->private->read_only = g_value_get_boolean( value );
- break;
+ case NAACTION_PROP_READONLY_ID:
+ self->private->read_only = g_value_get_boolean( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -247,7 +251,6 @@ instance_dispose( GObject *object )
g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
self = NA_OBJECT_ACTION( object );
- g_return_if_fail( !self->private->dispose_has_run );
if( !self->private->dispose_has_run ){
@@ -269,7 +272,7 @@ instance_finalize( GObject *object )
/*g_debug( "%s: object=%p", thisfn, ( void * ) object );*/
g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
- self = ( NAObjectAction * ) object;
+ self = NA_OBJECT_ACTION( object );
g_free( self->private->version );
@@ -311,7 +314,7 @@ na_object_action_new( void )
*
* Allocates a new #NAObjectAction object along with a default profile.
*
- * Return: the newly allocated #NAObjectAction action.
+ * Returns: the newly allocated #NAObjectAction action.
*/
NAObjectAction *
na_object_action_new_with_profile( void )
@@ -345,12 +348,13 @@ na_object_action_new_with_profile( void )
gchar *
na_object_action_get_version( const NAObjectAction *action )
{
- gchar *version;
+ gchar *version = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), NULL );
- g_return_val_if_fail( !action->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( action ), NAACTION_PROP_VERSION, &version, NULL );
+ if( !action->private->dispose_has_run ){
+ g_object_get( G_OBJECT( action ), NAACTION_PROP_VERSION, &version, NULL );
+ }
return( version );
}
@@ -363,17 +367,18 @@ na_object_action_get_version( const NAObjectAction *action )
* Or, in other words, may this action be edited and then saved to the
* original I/O storage subsystem ?
*
- * Returns: %TRUE if the action is editable, %FALSE else.
+ * Returns: %TRUE if the action is read-only, %FALSE else.
*/
gboolean
na_object_action_is_readonly( const NAObjectAction *action )
{
- gboolean readonly;
+ gboolean readonly = FALSE;
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), FALSE );
- g_return_val_if_fail( !action->private->dispose_has_run, FALSE );
- g_object_get( G_OBJECT( action ), NAACTION_PROP_READONLY, &readonly, NULL );
+ if( !action->private->dispose_has_run ){
+ g_object_get( G_OBJECT( action ), NAACTION_PROP_READONLY, &readonly, NULL );
+ }
return( readonly );
}
@@ -400,9 +405,10 @@ void
na_object_action_set_version( NAObjectAction *action, const gchar *version )
{
g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
- g_return_if_fail( !action->private->dispose_has_run );
- g_object_set( G_OBJECT( action ), NAACTION_PROP_VERSION, version, NULL );
+ if( !action->private->dispose_has_run ){
+ g_object_set( G_OBJECT( action ), NAACTION_PROP_VERSION, version, NULL );
+ }
}
/**
@@ -416,9 +422,10 @@ void
na_object_action_set_readonly( NAObjectAction *action, gboolean readonly )
{
g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
- g_return_if_fail( !action->private->dispose_has_run );
- g_object_set( G_OBJECT( action ), NAACTION_PROP_READONLY, readonly, NULL );
+ if( !action->private->dispose_has_run ){
+ g_object_set( G_OBJECT( action ), NAACTION_PROP_READONLY, readonly, NULL );
+ }
}
/**
@@ -443,19 +450,21 @@ na_object_action_get_new_profile_name( const NAObjectAction *action )
gchar *candidate = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), NULL );
- g_return_val_if_fail( !action->private->dispose_has_run, NULL );
- for( i=1 ; !ok ; ++i ){
- g_free( candidate );
- candidate = g_strdup_printf( "%s%d", OBJECT_PROFILE_PREFIX, i );
- if( !na_object_get_item( action, candidate )){
- ok = TRUE;
+ if( !action->private->dispose_has_run ){
+
+ for( i=1 ; !ok ; ++i ){
+ g_free( candidate );
+ candidate = g_strdup_printf( "%s%d", OBJECT_PROFILE_PREFIX, i );
+ if( !na_object_get_item( action, candidate )){
+ ok = TRUE;
+ }
}
- }
- if( !ok ){
- g_free( candidate );
- candidate = NULL;
+ if( !ok ){
+ g_free( candidate );
+ candidate = NULL;
+ }
}
return( candidate );
@@ -472,11 +481,13 @@ void
na_object_action_attach_profile( NAObjectAction *action, NAObjectProfile *profile )
{
g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
- g_return_if_fail( !action->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- na_object_append_item( action, profile );
- na_object_profile_set_action( profile, action );
+ if( !action->private->dispose_has_run ){
+
+ na_object_append_item( action, profile );
+ na_object_profile_set_action( profile, action );
+ }
}
static void
@@ -487,21 +498,26 @@ object_dump( const NAObject *action )
g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
self = NA_OBJECT_ACTION( action );
- g_return_if_fail( !self->private->dispose_has_run );
- g_debug( "%s: version='%s'", thisfn, self->private->version );
- g_debug( "%s: read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
+ if( !self->private->dispose_has_run ){
+
+ g_debug( "%s: version='%s'", thisfn, self->private->version );
+ g_debug( "%s: read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
+ }
}
static gchar *
object_get_clipboard_id( const NAObject *action )
{
gchar *uuid;
- gchar *clipboard_id;
+ gchar *clipboard_id = NULL;
+
+ if( !NA_OBJECT_ACTION( action )->private->dispose_has_run ){
- uuid = na_object_get_id( action );
- clipboard_id = g_strdup_printf( "A:%s", uuid );
- g_free( uuid );
+ uuid = na_object_get_id( action );
+ clipboard_id = g_strdup_printf( "A:%s", uuid );
+ g_free( uuid );
+ }
return( clipboard_id );
}
@@ -520,32 +536,32 @@ object_copy( NAObject *target, const NAObject *source )
GList *profiles, *ip;
g_return_if_fail( NA_IS_OBJECT_ACTION( target ));
- g_return_if_fail( !NA_OBJECT_ACTION( target )->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_ACTION( source ));
- g_return_if_fail( !NA_OBJECT_ACTION( source )->private->dispose_has_run );
- g_object_get( G_OBJECT( source ),
- NAACTION_PROP_VERSION, &version,
- NAACTION_PROP_READONLY, &readonly,
- NULL );
+ if( !NA_OBJECT_ACTION( target )->private->dispose_has_run &&
+ !NA_OBJECT_ACTION( source )->private->dispose_has_run ){
- g_object_set( G_OBJECT( target ),
- NAACTION_PROP_VERSION, version,
- NAACTION_PROP_READONLY, readonly,
- NULL );
+ g_object_get( G_OBJECT( source ),
+ NAACTION_PROP_VERSION, &version,
+ NAACTION_PROP_READONLY, &readonly,
+ NULL );
- g_free( version );
+ g_object_set( G_OBJECT( target ),
+ NAACTION_PROP_VERSION, version,
+ NAACTION_PROP_READONLY, readonly,
+ NULL );
- /* profiles have been copied (duplicated) as subitems by parent class
- * we have to attach new profiles to target action
- */
- profiles = na_object_get_items( target );
- for( ip = profiles ; ip ; ip = ip->next ){
- na_object_profile_set_action( NA_OBJECT_PROFILE( ip->data ), NA_OBJECT_ACTION( target ));
- }
- na_object_free_items( profiles );
+ g_free( version );
- /*g_debug( "na_object_action_object_copy: end" );*/
+ /* profiles have been copied (duplicated) as subitems by parent class
+ * we have to attach new profiles to target action
+ */
+ profiles = na_object_get_items( target );
+ for( ip = profiles ; ip ; ip = ip->next ){
+ na_object_profile_set_action( NA_OBJECT_PROFILE( ip->data ), NA_OBJECT_ACTION( target ));
+ }
+ na_object_free_items( profiles );
+ }
}
/*
@@ -565,41 +581,43 @@ object_are_equal( const NAObject *a, const NAObject *b )
NAObjectProfile *profile;
g_return_val_if_fail( NA_IS_OBJECT_ACTION( a ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ACTION( a )->private->dispose_has_run, FALSE );
first = NA_OBJECT_ACTION( a );
g_return_val_if_fail( NA_IS_OBJECT_ACTION( b ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ACTION( b )->private->dispose_has_run, FALSE );
second = NA_OBJECT_ACTION( b );
- if( equal ){
- equal = ( strcmp( first->private->version, second->private->version ) == 0 );
- }
+ if( !NA_OBJECT_ACTION( a )->private->dispose_has_run &&
+ !NA_OBJECT_ACTION( b )->private->dispose_has_run ){
+
+ if( equal ){
+ equal = ( strcmp( first->private->version, second->private->version ) == 0 );
+ }
- if( equal ){
- profiles = na_object_get_items( a );
- for( ip = profiles ; ip && equal ; ip = ip->next ){
- id = na_object_get_id( ip->data );
- profile = NA_OBJECT_PROFILE( na_object_get_item( b, id ));
- equal = !na_object_is_modified( profile );
+ if( equal ){
+ profiles = na_object_get_items( a );
+ for( ip = profiles ; ip && equal ; ip = ip->next ){
+ id = na_object_get_id( ip->data );
+ profile = NA_OBJECT_PROFILE( na_object_get_item( b, id ));
+ equal = !na_object_is_modified( profile );
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
- if( !equal ){
- g_debug( "na_object_action_are_equal: profile=%p, equal=False", ( void * ) profile );
- }
+ if( !equal ){
+ g_debug( "na_object_action_are_equal: profile=%p, equal=False", ( void * ) profile );
+ }
#endif
- g_free( id );
+ g_free( id );
+ }
+ na_object_free_items( profiles );
}
- na_object_free_items( profiles );
- }
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
- g_debug( "na_object_action_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
- ( void * ) a, G_OBJECT_TYPE_NAME( a ),
- ( void * ) b, G_OBJECT_TYPE_NAME( b ),
- equal ? "True":"False" );
+ g_debug( "na_object_action_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
+ ( void * ) a, G_OBJECT_TYPE_NAME( a ),
+ ( void * ) b, G_OBJECT_TYPE_NAME( b ),
+ equal ? "True":"False" );
#endif
+ }
return( equal );
}
@@ -618,16 +636,18 @@ object_is_valid( const NAObject *action )
gboolean is_valid = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ACTION( action )->private->dispose_has_run, FALSE );
- if( is_valid ){
- label = na_object_get_label( NA_OBJECT_ACTION( action ));
- is_valid = ( label && g_utf8_strlen( label, -1 ) > 0 );
- g_free( label );
- }
+ if( !NA_OBJECT_ACTION( action )->private->dispose_has_run ){
- if( is_valid ){
- is_valid = ( na_object_get_items_count( action ) >= 1 );
+ if( is_valid ){
+ label = na_object_get_label( NA_OBJECT_ACTION( action ));
+ is_valid = ( label && g_utf8_strlen( label, -1 ) > 0 );
+ g_free( label );
+ }
+
+ if( is_valid ){
+ is_valid = ( na_object_get_items_count( action ) >= 1 );
+ }
}
return( is_valid );
diff --git a/src/common/na-object-action.h b/src/common/na-object-action.h
index c6c6dc7..c80b66e 100644
--- a/src/common/na-object-action.h
+++ b/src/common/na-object-action.h
@@ -33,28 +33,8 @@
/**
* SECTION: na_object_action
- * @short_description: #NAObjectAction class definition.
+ * @short_description: #NAObjectAction public function declaration.
* @include: common/na-object-action.h
- *
- * This is the class which maintains data and properties of an Nautilus
- * action.
- *
- * Note about the UUID :
- *
- * The uuid is only required when writing the action to GConf in order
- * to ensure unicity of subdirectories.
- *
- * UUID is transfered through import/export operations.
- *
- * Note that a user may import an action, translate it and then
- * reexport it : we so may have two different actions with the same
- * uuid. The user has so to modify the UUID before import.
- *
- * Note about edition status :
- *
- * As a particular rule of #NAObjectItem derived class, an action is
- * considered modified as soon as any of its profiles has been modified
- * itself (because they are saved as a whole).
*/
#include <glib/gi18n.h>
diff --git a/src/common/na-object-class.h b/src/common/na-object-class.h
index e0abe1f..5d0b018 100644
--- a/src/common/na-object-class.h
+++ b/src/common/na-object-class.h
@@ -38,8 +38,9 @@
*
* This is the base class for managed objects.
*
- * It implements the NAIDuplicable interface in order to have easily
- * duplicable derived objects.
+ * It implements the #NAIDuplicable interface in order to have easily
+ * duplicable derived objects. All the public API of the interface is
+ * converted to #NAObject virtual functions.
*
* The #NAObject class is a pure virtual class.
*/
diff --git a/src/common/na-object-fn.h b/src/common/na-object-fn.h
index 0ec7159..94c6fdf 100644
--- a/src/common/na-object-fn.h
+++ b/src/common/na-object-fn.h
@@ -33,7 +33,7 @@
/**
* SECTION: na_object
- * @short_description: #NAObject public functions definition.
+ * @short_description: #NAObject public functions declarations.
* @include: common/na-object-fn.h
*
* Define here the public functions of the #NAObject class.
diff --git a/src/common/na-object-id-class.h b/src/common/na-object-id-class.h
index fbb54bb..239f7f9 100644
--- a/src/common/na-object-id-class.h
+++ b/src/common/na-object-id-class.h
@@ -36,6 +36,10 @@
* @short_description: #NAObjectId class definition.
* @include: common/na-object-id-class.h
*
+ * A #NAObjectId object is characterized by :
+ * - an internal identifiant (ASCII, case insensitive)
+ * - a libelle (UTF8, localizable).
+ *
* The #NAObjectId class is a pure virtual class.
*/
diff --git a/src/common/na-object-id-fn.h b/src/common/na-object-id-fn.h
index 932d4e5..3019b9b 100644
--- a/src/common/na-object-id-fn.h
+++ b/src/common/na-object-id-fn.h
@@ -33,14 +33,13 @@
/**
* SECTION: na_object_id
- * @short_description: #NAObjectId class definition.
+ * @short_description: #NAObjectId public function declarations.
* @include: common/na-object-id-fn.h
*
- * A #NAObjectId object is characterized by :
- * - an internal identifiant (ASCII, case insensitive)
- * - a libelle (UTF8, localizable).
+ * Define here the public functions of the #NAObjectId class.
*
- * The #NAObjectId class is a pure virtual class.
+ * Note that most users of the class should rather use macros defined
+ * in na-object-api.h
*/
#include "na-object-id-class.h"
diff --git a/src/common/na-object-id.c b/src/common/na-object-id.c
index f7a896b..d697294 100644
--- a/src/common/na-object-id.c
+++ b/src/common/na-object-id.c
@@ -188,21 +188,23 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
NAObjectId *self;
g_return_if_fail( NA_IS_OBJECT_ID( object ));
- g_return_if_fail( !NA_OBJECT_ID( object )->private->dispose_has_run );
self = NA_OBJECT_ID( object );
- switch( property_id ){
- case NAOBJECT_ID_PROP_ID_ID:
- g_value_set_string( value, self->private->id );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAOBJECT_ID_PROP_ID_ID:
+ g_value_set_string( value, self->private->id );
+ break;
- case NAOBJECT_ID_PROP_LABEL_ID:
- g_value_set_string( value, self->private->label );
- break;
+ case NAOBJECT_ID_PROP_LABEL_ID:
+ g_value_set_string( value, self->private->label );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -212,23 +214,25 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
NAObjectId *self;
g_return_if_fail( NA_IS_OBJECT_ID( object ));
- g_return_if_fail( !NA_OBJECT_ID( object )->private->dispose_has_run );
self = NA_OBJECT_ID( object );
- switch( property_id ){
- case NAOBJECT_ID_PROP_ID_ID:
- g_free( self->private->id );
- self->private->id = g_value_dup_string( value );
- break;
+ if( !self->private->dispose_has_run ){
- case NAOBJECT_ID_PROP_LABEL_ID:
- g_free( self->private->label );
- self->private->label = g_value_dup_string( value );
- break;
+ switch( property_id ){
+ case NAOBJECT_ID_PROP_ID_ID:
+ g_free( self->private->id );
+ self->private->id = g_value_dup_string( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ case NAOBJECT_ID_PROP_LABEL_ID:
+ g_free( self->private->label );
+ self->private->label = g_value_dup_string( value );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -285,12 +289,13 @@ instance_finalize( GObject *object )
gchar *
na_object_id_get_id( const NAObjectId *object )
{
- gchar *id;
+ gchar *id = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ID( object ), NULL );
- g_return_val_if_fail( !object->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( object ), NAOBJECT_ID_PROP_ID, &id, NULL );
+ if( !object->private->dispose_has_run ){
+ g_object_get( G_OBJECT( object ), NAOBJECT_ID_PROP_ID, &id, NULL );
+ }
return( id );
}
@@ -307,12 +312,13 @@ na_object_id_get_id( const NAObjectId *object )
gchar *
na_object_id_get_label( const NAObjectId *object )
{
- gchar *label;
+ gchar *label = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ID( object ), NULL );
- g_return_val_if_fail( !object->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( object ), NAOBJECT_ID_PROP_LABEL, &label, NULL );
+ if( !object->private->dispose_has_run ){
+ g_object_get( G_OBJECT( object ), NAOBJECT_ID_PROP_LABEL, &label, NULL );
+ }
return( label );
}
@@ -330,9 +336,10 @@ void
na_object_id_set_id( NAObjectId *object, const gchar *id )
{
g_return_if_fail( NA_IS_OBJECT_ID( object ));
- g_return_if_fail( !object->private->dispose_has_run );
- g_object_set( G_OBJECT( object ), NAOBJECT_ID_PROP_ID, id, NULL );
+ if( !object->private->dispose_has_run ){
+ g_object_set( G_OBJECT( object ), NAOBJECT_ID_PROP_ID, id, NULL );
+ }
}
/**
@@ -348,13 +355,16 @@ na_object_id_set_new_id( NAObjectId *object )
gchar *id;
g_return_if_fail( NA_IS_OBJECT_ID( object ));
- g_return_if_fail( !object->private->dispose_has_run );
- id = v_new_id( object );
+ if( !object->private->dispose_has_run ){
- g_object_set( G_OBJECT( object ), NAOBJECT_ID_PROP_ID, id, NULL );
+ id = v_new_id( object );
- g_free( id );
+ if( id ){
+ g_object_set( G_OBJECT( object ), NAOBJECT_ID_PROP_ID, id, NULL );
+ g_free( id );
+ }
+ }
}
/**
@@ -368,9 +378,10 @@ void
na_object_id_set_label( NAObjectId *object, const gchar *label )
{
g_return_if_fail( NA_IS_OBJECT_ID( object ));
- g_return_if_fail( !object->private->dispose_has_run );
- g_object_set( G_OBJECT( object ), NAOBJECT_ID_PROP_LABEL, label, NULL );
+ if( !object->private->dispose_has_run ){
+ g_object_set( G_OBJECT( object ), NAOBJECT_ID_PROP_LABEL, label, NULL );
+ }
}
static void
@@ -379,10 +390,12 @@ object_dump( const NAObject *object )
static const char *thisfn = "na_object_id_object_dump";
g_return_if_fail( NA_IS_OBJECT_ID( object ));
- g_return_if_fail( !NA_OBJECT_ID( object )->private->dispose_has_run );
- g_debug( "%s: id=%s", thisfn, NA_OBJECT_ID( object )->private->id );
- g_debug( "%s: label=%s", thisfn, NA_OBJECT_ID( object )->private->label );
+ if( !NA_OBJECT_ID( object )->private->dispose_has_run ){
+
+ g_debug( "%s: id=%s", thisfn, NA_OBJECT_ID( object )->private->id );
+ g_debug( "%s: label=%s", thisfn, NA_OBJECT_ID( object )->private->label );
+ }
}
static void
@@ -391,22 +404,24 @@ object_copy( NAObject *target, const NAObject *source )
gchar *id, *label;
g_return_if_fail( NA_IS_OBJECT_ID( target ));
- g_return_if_fail( !NA_OBJECT_ID( target )->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_ID( source ));
- g_return_if_fail( !NA_OBJECT_ID( source )->private->dispose_has_run );
- g_object_get( G_OBJECT( source ),
- NAOBJECT_ID_PROP_ID, &id,
- NAOBJECT_ID_PROP_LABEL, &label,
- NULL );
+ if( !NA_OBJECT_ID( target )->private->dispose_has_run &&
+ !NA_OBJECT_ID( source )->private->dispose_has_run ){
+
+ g_object_get( G_OBJECT( source ),
+ NAOBJECT_ID_PROP_ID, &id,
+ NAOBJECT_ID_PROP_LABEL, &label,
+ NULL );
- g_object_set( G_OBJECT( target ),
- NAOBJECT_ID_PROP_ID, id,
- NAOBJECT_ID_PROP_LABEL, label,
- NULL );
+ g_object_set( G_OBJECT( target ),
+ NAOBJECT_ID_PROP_ID, id,
+ NAOBJECT_ID_PROP_LABEL, label,
+ NULL );
- g_free( id );
- g_free( label );
+ g_free( id );
+ g_free( label );
+ }
}
static gboolean
@@ -415,30 +430,32 @@ object_are_equal( const NAObject *a, const NAObject *b )
gboolean equal = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_ID( a ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ID( a )->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT_ID( b ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ID( b )->private->dispose_has_run, FALSE );
- if( equal ){
- if( g_ascii_strcasecmp( NA_OBJECT_ID( a )->private->id, NA_OBJECT_ID( b )->private->id )){
- /*g_debug( "a->id=%s, b->id=%s", NA_OBJECT_ID( a )->private->id, NA_OBJECT_ID( b )->private->id );*/
- equal = FALSE;
- }
- }
+ if( !NA_OBJECT_ID( a )->private->dispose_has_run &&
+ !NA_OBJECT_ID( b )->private->dispose_has_run ){
- if( equal ){
- if( g_utf8_collate( NA_OBJECT_ID( a )->private->label, NA_OBJECT_ID( b )->private->label )){
- /*g_debug( "a->label=%s, b->label=%s", NA_OBJECT_ID( a )->private->label, NA_OBJECT_ID( b )->private->label );*/
- equal = FALSE;
- }
- }
+ if( equal ){
+ if( g_ascii_strcasecmp( NA_OBJECT_ID( a )->private->id, NA_OBJECT_ID( b )->private->id )){
+ /*g_debug( "a->id=%s, b->id=%s", NA_OBJECT_ID( a )->private->id, NA_OBJECT_ID( b )->private->id );*/
+ equal = FALSE;
+ }
+ }
+
+ if( equal ){
+ if( g_utf8_collate( NA_OBJECT_ID( a )->private->label, NA_OBJECT_ID( b )->private->label )){
+ /*g_debug( "a->label=%s, b->label=%s", NA_OBJECT_ID( a )->private->label, NA_OBJECT_ID( b )->private->label );*/
+ equal = FALSE;
+ }
+ }
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
- g_debug( "na_object_id_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
- ( void * ) a, G_OBJECT_TYPE_NAME( a ),
- ( void * ) b, G_OBJECT_TYPE_NAME( b ),
- equal ? "True":"False" );
+ g_debug( "na_object_id_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
+ ( void * ) a, G_OBJECT_TYPE_NAME( a ),
+ ( void * ) b, G_OBJECT_TYPE_NAME( b ),
+ equal ? "True":"False" );
#endif
+ }
return( equal );
}
@@ -453,10 +470,12 @@ object_is_valid( const NAObject *object )
gboolean valid = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_ID( object ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ID( object )->private->dispose_has_run, FALSE );
- if( valid ){
- valid = ( NA_OBJECT_ID( object )->private->id && strlen( NA_OBJECT_ID( object )->private->id ));
+ if( !NA_OBJECT_ID( object )->private->dispose_has_run ){
+
+ if( valid ){
+ valid = ( NA_OBJECT_ID( object )->private->id && strlen( NA_OBJECT_ID( object )->private->id ));
+ }
}
return( valid );
diff --git a/src/common/na-object-item-class.h b/src/common/na-object-item-class.h
index 9998362..a724f51 100644
--- a/src/common/na-object-item-class.h
+++ b/src/common/na-object-item-class.h
@@ -31,6 +31,30 @@
#ifndef __NA_OBJECT_ITEM_CLASS_H__
#define __NA_OBJECT_ITEM_CLASS_H__
+/**
+ * SECTION: na_object_item
+ * @short_description: #NAObjectItem class definition.
+ * @include: common/na-object-item-class.h
+ *
+ * Derived from #NAObjectId class, this class implements objects which
+ * have :
+ * - a tooltip,
+ * - an icon,
+ * - a list of childs.
+ *
+ * Note that checking edition status of a #NAObjectItem is almost, but
+ * not really a recursive process :
+ *
+ * - it may appear as recursive because all childs of the checked
+ * #NAObjectItem, and childs of childs, etc., are also checked so that
+ * they are able to setup their individual own edition status ;
+ *
+ * - nonetheless, but a particular rule which may be implemented in a
+ * derived class, the edition status of the checked #NAObjectItem
+ * itself is computed individually, without regards of the respective
+ * edition status of its childs.
+ */
+
#include "na-object-id-class.h"
G_BEGIN_DECLS
diff --git a/src/common/na-object-item-fn.h b/src/common/na-object-item-fn.h
index dc1d4cd..349128a 100644
--- a/src/common/na-object-item-fn.h
+++ b/src/common/na-object-item-fn.h
@@ -33,24 +33,13 @@
/**
* SECTION: na_object_item
- * @short_description: #NAObjectItem class definition.
- * @include: common/na-object-item.h
+ * @short_description: #NAObjectItem public function declarations.
+ * @include: common/na-object-fn.h
*
- * Derived from #NAObjectId class, this class implements objects which
- * have :
- * - a tooltip,
- * - an icon,
- * - a list of childs.
+ * Define here the public functions of the #NAObjectItem class.
*
- * Note that checking edition status of a #NAObjectItem is almost, but
- * not really a recursive process :
- * - it may appear as recursive because all childs of the checked
- * #NAObjectItem, and childs of childs, etc., are also checked so that
- * they are able to setup their individual own edition status ;
- * - nonetheless, but a particular rule which may be implemented in a
- * derived class, the edition status of the checked #NAObjectItem
- * itself is computed individually, without regards of the edition
- * status of its childs.
+ * Note that most users of the class should rather use macros defined
+ * in na-object-api.h
*/
#include <gtk/gtk.h>
diff --git a/src/common/na-object-item.c b/src/common/na-object-item.c
index 1057309..9053233 100644
--- a/src/common/na-object-item.c
+++ b/src/common/na-object-item.c
@@ -228,29 +228,31 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
NAObjectItem *self;
g_return_if_fail( NA_IS_OBJECT_ITEM( object ));
- g_return_if_fail( !NA_OBJECT_ITEM( object )->private->dispose_has_run );
self = NA_OBJECT_ITEM( object );
- switch( property_id ){
- case NAOBJECT_ITEM_PROP_TOOLTIP_ID:
- g_value_set_string( value, self->private->tooltip );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAOBJECT_ITEM_PROP_TOOLTIP_ID:
+ g_value_set_string( value, self->private->tooltip );
+ break;
- case NAOBJECT_ITEM_PROP_ICON_ID:
- g_value_set_string( value, self->private->icon );
- break;
+ case NAOBJECT_ITEM_PROP_ICON_ID:
+ g_value_set_string( value, self->private->icon );
+ break;
- case NAOBJECT_ITEM_PROP_ENABLED_ID:
- g_value_set_boolean( value, self->private->enabled );
- break;
+ case NAOBJECT_ITEM_PROP_ENABLED_ID:
+ g_value_set_boolean( value, self->private->enabled );
+ break;
- case NAOBJECT_ITEM_PROP_PROVIDER_ID:
- g_value_set_pointer( value, self->private->provider );
- break;
+ case NAOBJECT_ITEM_PROP_PROVIDER_ID:
+ g_value_set_pointer( value, self->private->provider );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -260,31 +262,33 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
NAObjectItem *self;
g_return_if_fail( NA_IS_OBJECT_ITEM( object ));
- g_return_if_fail( !NA_OBJECT_ITEM( object )->private->dispose_has_run );
self = NA_OBJECT_ITEM( object );
- switch( property_id ){
- case NAOBJECT_ITEM_PROP_TOOLTIP_ID:
- g_free( self->private->tooltip );
- self->private->tooltip = g_value_dup_string( value );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAOBJECT_ITEM_PROP_TOOLTIP_ID:
+ g_free( self->private->tooltip );
+ self->private->tooltip = g_value_dup_string( value );
+ break;
- case NAOBJECT_ITEM_PROP_ICON_ID:
- g_free( self->private->icon );
- self->private->icon = g_value_dup_string( value );
- break;
+ case NAOBJECT_ITEM_PROP_ICON_ID:
+ g_free( self->private->icon );
+ self->private->icon = g_value_dup_string( value );
+ break;
- case NAOBJECT_ITEM_PROP_ENABLED_ID:
- self->private->enabled = g_value_get_boolean( value );
- break;
+ case NAOBJECT_ITEM_PROP_ENABLED_ID:
+ self->private->enabled = g_value_get_boolean( value );
+ break;
- case NAOBJECT_ITEM_PROP_PROVIDER_ID:
- self->private->provider = g_value_get_pointer( value );
- break;
+ case NAOBJECT_ITEM_PROP_PROVIDER_ID:
+ self->private->provider = g_value_get_pointer( value );
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -345,12 +349,13 @@ instance_finalize( GObject *object )
gchar *
na_object_item_get_tooltip( const NAObjectItem *item )
{
- gchar *tooltip;
+ gchar *tooltip = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !item->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TOOLTIP, &tooltip, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TOOLTIP, &tooltip, NULL );
+ }
return( tooltip );
}
@@ -368,12 +373,13 @@ na_object_item_get_tooltip( const NAObjectItem *item )
gchar *
na_object_item_get_icon( const NAObjectItem *item )
{
- gchar *icon;
+ gchar *icon = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !item->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ICON, &icon, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ICON, &icon, NULL );
+ }
return( icon );
}
@@ -422,33 +428,36 @@ GdkPixbuf *na_object_item_get_pixbuf( const NAObjectItem *item, GtkWidget *widge
GError* error = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !item->private->dispose_has_run, NULL );
- iconname = na_object_item_get_icon( item );
+ if( !item->private->dispose_has_run ){
- /* TODO: use the same algorythm than Nautilus to find and
- * display an icon + move the code to NAAction class +
- * remove na_action_get_verified_icon_name
- */
- if( iconname ){
- if( gtk_stock_lookup( iconname, &stock_item )){
- icon = gtk_widget_render_icon( widget, iconname, GTK_ICON_SIZE_MENU, NULL );
-
- } else if( g_file_test( iconname, G_FILE_TEST_EXISTS )
- && g_file_test( iconname, G_FILE_TEST_IS_REGULAR )){
-
- gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
- icon = gdk_pixbuf_new_from_file_at_size( iconname, width, height, &error );
- if( error ){
- g_warning( "%s: iconname=%s, error=%s", thisfn, iconname, error->message );
- g_error_free( error );
- error = NULL;
- icon = NULL;
+ iconname = na_object_item_get_icon( item );
+
+ /* TODO: use the same algorythm than Nautilus to find and
+ * display an icon + move the code to NAAction class +
+ * remove na_action_get_verified_icon_name
+ */
+ if( iconname ){
+ if( gtk_stock_lookup( iconname, &stock_item )){
+ icon = gtk_widget_render_icon( widget, iconname, GTK_ICON_SIZE_MENU, NULL );
+
+ } else if( g_file_test( iconname, G_FILE_TEST_EXISTS )
+ && g_file_test( iconname, G_FILE_TEST_IS_REGULAR )){
+
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
+ icon = gdk_pixbuf_new_from_file_at_size( iconname, width, height, &error );
+ if( error ){
+ g_warning( "%s: iconname=%s, error=%s", thisfn, iconname, error->message );
+ g_error_free( error );
+ error = NULL;
+ icon = NULL;
+ }
}
}
+
+ g_free( iconname );
}
- g_free( iconname );
return( icon );
}
@@ -468,12 +477,13 @@ GdkPixbuf *na_object_item_get_pixbuf( const NAObjectItem *item, GtkWidget *widge
NAIIOProvider *
na_object_item_get_provider( const NAObjectItem *item )
{
- NAIIOProvider *provider;
+ NAIIOProvider *provider = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !item->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_PROVIDER, &provider, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_PROVIDER, &provider, NULL );
+ }
return( provider );
}
@@ -497,15 +507,17 @@ na_object_item_get_item( const NAObjectItem *item, const gchar *id )
gchar *isubid;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !item->private->dispose_has_run, NULL );
- for( it = item->private->items ; it && !found ; it = it->next ){
- isub = NA_OBJECT( it->data );
- isubid = na_object_get_id( isub );
- if( !strcmp( id, isubid )){
- found = isub;
+ if( !item->private->dispose_has_run ){
+
+ for( it = item->private->items ; it && !found ; it = it->next ){
+ isub = NA_OBJECT( it->data );
+ isubid = na_object_get_id( isub );
+ if( !strcmp( id, isubid )){
+ found = isub;
+ }
+ g_free( isubid );
}
- g_free( isubid );
}
return( found );
@@ -525,17 +537,21 @@ na_object_item_get_item( const NAObjectItem *item, const gchar *id )
GList *
na_object_item_get_items( const NAObjectItem *item )
{
- GList *items, *it;
+ GList *items = NULL;
+ GList *it;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !item->private->dispose_has_run, NULL );
- items = NULL;
- for( it = item->private->items ; it ; it = it->next ){
- items = g_list_prepend( items, g_object_ref( it->data ));
+ if( !item->private->dispose_has_run ){
+
+ for( it = item->private->items ; it ; it = it->next ){
+ items = g_list_prepend( items, g_object_ref( it->data ));
+ }
+
+ items = g_list_reverse( items );
}
- return( g_list_reverse( items ));
+ return( items );
}
/**
@@ -547,10 +563,15 @@ na_object_item_get_items( const NAObjectItem *item )
guint
na_object_item_get_items_count( const NAObjectItem *item )
{
+ guint count = 0;
+
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), 0 );
- g_return_val_if_fail( !item->private->dispose_has_run, 0 );
- return( item->private->items ? g_list_length( item->private->items ) : 0 );
+ if( !item->private->dispose_has_run ){
+ count = item->private->items ? g_list_length( item->private->items ) : 0;
+ }
+
+ return( count );
}
/**
@@ -587,12 +608,13 @@ na_object_item_free_items( GList *items )
gboolean
na_object_item_is_enabled( const NAObjectItem *item )
{
- gboolean enabled;
+ gboolean enabled = FALSE;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), FALSE );
- g_return_val_if_fail( !item->private->dispose_has_run, FALSE );
- g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ENABLED, &enabled, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ENABLED, &enabled, NULL );
+ }
return( enabled );
}
@@ -613,9 +635,10 @@ void
na_object_item_set_tooltip( NAObjectItem *item, const gchar *tooltip )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TOOLTIP, tooltip, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TOOLTIP, tooltip, NULL );
+ }
}
/**
@@ -632,9 +655,10 @@ void
na_object_item_set_icon( NAObjectItem *item, const gchar *icon )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ICON, icon, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ICON, icon, NULL );
+ }
}
/**
@@ -648,9 +672,10 @@ void
na_object_item_set_enabled( NAObjectItem *item, gboolean enabled )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ENABLED, enabled, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_ENABLED, enabled, NULL );
+ }
}
/**
@@ -664,9 +689,10 @@ void
na_object_item_set_provider( NAObjectItem *item, const NAIIOProvider *provider )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_PROVIDER, provider, NULL );
+ if( !item->private->dispose_has_run ){
+ g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_PROVIDER, provider, NULL );
+ }
}
/**
@@ -687,15 +713,18 @@ na_object_item_set_items( NAObjectItem *item, GList *items )
GList *it;
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
- na_object_item_free_items( item->private->items );
- item->private->items = NULL;
+ if( !item->private->dispose_has_run ){
- for( it = items ; it ; it = it->next ){
- item->private->items = g_list_prepend( item->private->items, g_object_ref( it->data ));
+ na_object_item_free_items( item->private->items );
+ item->private->items = NULL;
+
+ for( it = items ; it ; it = it->next ){
+ item->private->items = g_list_prepend( item->private->items, g_object_ref( it->data ));
+ }
+
+ item->private->items = g_list_reverse( item->private->items );
}
- item->private->items = g_list_reverse( item->private->items );
}
/**
@@ -711,11 +740,13 @@ void
na_object_item_append_item( NAObjectItem *item, const NAObject *object )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT( object ));
- if( !g_list_find( item->private->items, ( gpointer ) object )){
- item->private->items = g_list_append( item->private->items, ( gpointer ) object );
+ if( !item->private->dispose_has_run ){
+
+ if( !g_list_find( item->private->items, ( gpointer ) object )){
+ item->private->items = g_list_append( item->private->items, ( gpointer ) object );
+ }
}
}
@@ -735,16 +766,18 @@ na_object_item_insert_item( NAObjectItem *item, const NAObject *object, const NA
GList *before_list;
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT( object ));
g_return_if_fail( NA_IS_OBJECT( before ));
- if( !g_list_find( item->private->items, ( gpointer ) object )){
- before_list = g_list_find( item->private->items, ( gconstpointer ) before );
- if( before_list ){
- item->private->items = g_list_insert_before( item->private->items, before_list, ( gpointer ) object );
- } else {
- item->private->items = g_list_prepend( item->private->items, ( gpointer ) object );
+ if( !item->private->dispose_has_run ){
+
+ if( !g_list_find( item->private->items, ( gpointer ) object )){
+ before_list = g_list_find( item->private->items, ( gconstpointer ) before );
+ if( before_list ){
+ item->private->items = g_list_insert_before( item->private->items, before_list, ( gpointer ) object );
+ } else {
+ item->private->items = g_list_prepend( item->private->items, ( gpointer ) object );
+ }
}
}
}
@@ -762,11 +795,13 @@ void
na_object_item_remove_item( NAObjectItem *item, const NAObject *object )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !item->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT( object ));
- if( g_list_find( item->private->items, ( gconstpointer ) object )){
- item->private->items = g_list_remove( item->private->items, ( gconstpointer ) object );
+ if( !item->private->dispose_has_run ){
+
+ if( g_list_find( item->private->items, ( gconstpointer ) object )){
+ item->private->items = g_list_remove( item->private->items, ( gconstpointer ) object );
+ }
}
}
@@ -774,29 +809,27 @@ static void
object_dump( const NAObject *item )
{
static const gchar *thisfn = "na_object_item_object_dump";
- /*GList *it;*/
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- g_return_if_fail( !NA_OBJECT_ITEM( item )->private->dispose_has_run );
-
- g_debug( "%s: tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
- g_debug( "%s: icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
- g_debug( "%s: enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
- g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
-
- /* dump subitems */
- g_debug( "%s: %d subitem(s) at %p",
- thisfn,
- NA_OBJECT_ITEM( item )->private->items ? g_list_length( NA_OBJECT_ITEM( item )->private->items ) : 0,
- ( void * ) NA_OBJECT_ITEM( item )->private->items );
-
- /* do not recurse here, as this is actually dealt with by
- * na_object_dump() api ;
- * else, we would have the action being dumped after its childs
- */
- /*for( it = NA_OBJECT_ITEM( item )->private->items ; it ; it = it->next ){
- na_object_dump( it->data );
- }*/
+
+ if( !NA_OBJECT_ITEM( item )->private->dispose_has_run ){
+
+ g_debug( "%s: tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
+ g_debug( "%s: icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
+ g_debug( "%s: enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
+ g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
+
+ /* dump subitems */
+ g_debug( "%s: %d subitem(s) at %p",
+ thisfn,
+ NA_OBJECT_ITEM( item )->private->items ? g_list_length( NA_OBJECT_ITEM( item )->private->items ) : 0,
+ ( void * ) NA_OBJECT_ITEM( item )->private->items );
+
+ /* do not recurse here, as this is actually dealt with by
+ * na_object_dump() api ;
+ * else, we would have the action being dumped after its childs
+ */
+ }
}
static void
@@ -814,36 +847,36 @@ object_copy( NAObject *target, const NAObject *source )
GList *subitems, *it;
g_return_if_fail( NA_IS_OBJECT_ITEM( target ));
- g_return_if_fail( !NA_OBJECT_ITEM( target )->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_ITEM( source ));
- g_return_if_fail( !NA_OBJECT_ITEM( source )->private->dispose_has_run );
-
- g_object_get( G_OBJECT( source ),
- NAOBJECT_ITEM_PROP_TOOLTIP, &tooltip,
- NAOBJECT_ITEM_PROP_ICON, &icon,
- NAOBJECT_ITEM_PROP_ENABLED, &enabled,
- NAOBJECT_ITEM_PROP_PROVIDER, &provider,
- NULL );
-
- g_object_set( G_OBJECT( target ),
- NAOBJECT_ITEM_PROP_TOOLTIP, tooltip,
- NAOBJECT_ITEM_PROP_ICON, icon,
- NAOBJECT_ITEM_PROP_ENABLED, enabled,
- NAOBJECT_ITEM_PROP_PROVIDER, provider,
- NULL );
-
- g_free( tooltip );
- g_free( icon );
-
- subitems = NULL;
- for( it = NA_OBJECT_ITEM( source )->private->items ; it ; it = it->next ){
- subitems = g_list_prepend( subitems, na_object_duplicate( it->data ));
- }
- subitems = g_list_reverse( subitems );
- na_object_set_items( target, subitems );
- na_object_free_items( subitems );
- /*g_debug( "na_object_item_object_copy: end" );*/
+ if( !NA_OBJECT_ITEM( target )->private->dispose_has_run &&
+ !NA_OBJECT_ITEM( source )->private->dispose_has_run ){
+
+ g_object_get( G_OBJECT( source ),
+ NAOBJECT_ITEM_PROP_TOOLTIP, &tooltip,
+ NAOBJECT_ITEM_PROP_ICON, &icon,
+ NAOBJECT_ITEM_PROP_ENABLED, &enabled,
+ NAOBJECT_ITEM_PROP_PROVIDER, &provider,
+ NULL );
+
+ g_object_set( G_OBJECT( target ),
+ NAOBJECT_ITEM_PROP_TOOLTIP, tooltip,
+ NAOBJECT_ITEM_PROP_ICON, icon,
+ NAOBJECT_ITEM_PROP_ENABLED, enabled,
+ NAOBJECT_ITEM_PROP_PROVIDER, provider,
+ NULL );
+
+ g_free( tooltip );
+ g_free( icon );
+
+ subitems = NULL;
+ for( it = NA_OBJECT_ITEM( source )->private->items ; it ; it = it->next ){
+ subitems = g_list_prepend( subitems, na_object_duplicate( it->data ));
+ }
+ subitems = g_list_reverse( subitems );
+ na_object_set_items( target, subitems );
+ na_object_free_items( subitems );
+ }
}
/*
@@ -879,69 +912,71 @@ object_are_equal( const NAObject *a, const NAObject *b )
GList *second_list;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( a ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ITEM( a )->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( b ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ITEM( b )->private->dispose_has_run, FALSE );
- if( equal ){
- equal =
- ( g_utf8_collate( NA_OBJECT_ITEM( a )->private->tooltip, NA_OBJECT_ITEM( b )->private->tooltip ) == 0 ) &&
- ( g_utf8_collate( NA_OBJECT_ITEM( a )->private->icon, NA_OBJECT_ITEM( b )->private->icon ) == 0 );
- }
+ if( !NA_OBJECT_ITEM( a )->private->dispose_has_run &&
+ !NA_OBJECT_ITEM( b )->private->dispose_has_run ){
- if( equal ){
- equal = ( NA_OBJECT_ITEM( a )->private->enabled && NA_OBJECT_ITEM( b )->private->enabled ) ||
- ( !NA_OBJECT_ITEM( a )->private->enabled && !NA_OBJECT_ITEM( b )->private->enabled );
- }
+ if( equal ){
+ equal =
+ ( g_utf8_collate( NA_OBJECT_ITEM( a )->private->tooltip, NA_OBJECT_ITEM( b )->private->tooltip ) == 0 ) &&
+ ( g_utf8_collate( NA_OBJECT_ITEM( a )->private->icon, NA_OBJECT_ITEM( b )->private->icon ) == 0 );
+ }
- if( equal ){
- equal = ( g_list_length( NA_OBJECT_ITEM( a )->private->items ) == g_list_length( NA_OBJECT_ITEM( b )->private->items ));
- }
+ if( equal ){
+ equal = ( NA_OBJECT_ITEM( a )->private->enabled && NA_OBJECT_ITEM( b )->private->enabled ) ||
+ ( !NA_OBJECT_ITEM( a )->private->enabled && !NA_OBJECT_ITEM( b )->private->enabled );
+ }
+
+ if( equal ){
+ equal = ( g_list_length( NA_OBJECT_ITEM( a )->private->items ) == g_list_length( NA_OBJECT_ITEM( b )->private->items ));
+ }
- if( equal ){
- for( it = NA_OBJECT_ITEM( a )->private->items ; it && equal ; it = it->next ){
- first_id = na_object_get_id( it->data );
- second_obj = na_object_get_item( b, first_id );
- if( second_obj ){
- first_pos = g_list_position( NA_OBJECT_ITEM( a )->private->items, it );
- second_list = g_list_find( NA_OBJECT_ITEM( b )->private->items, second_obj );
- second_pos = g_list_position( NA_OBJECT_ITEM( b )->private->items, second_list );
+ if( equal ){
+ for( it = NA_OBJECT_ITEM( a )->private->items ; it && equal ; it = it->next ){
+ first_id = na_object_get_id( it->data );
+ second_obj = na_object_get_item( b, first_id );
+ if( second_obj ){
+ first_pos = g_list_position( NA_OBJECT_ITEM( a )->private->items, it );
+ second_list = g_list_find( NA_OBJECT_ITEM( b )->private->items, second_obj );
+ second_pos = g_list_position( NA_OBJECT_ITEM( b )->private->items, second_list );
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
- g_debug( "na_object_item_object_are_equal: first_pos=%u, second_pos=%u", first_pos, second_pos );
+ g_debug( "na_object_item_object_are_equal: first_pos=%u, second_pos=%u", first_pos, second_pos );
#endif
- if( first_pos != second_pos ){
- equal = FALSE;
- }
- } else {
+ if( first_pos != second_pos ){
+ equal = FALSE;
+ }
+ } else {
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
g_debug( "na_object_item_object_are_equal: id=%s not found in b", first_id );
#endif
- equal = FALSE;
+ equal = FALSE;
+ }
+ g_free( first_id );
}
- g_free( first_id );
}
- }
- if( equal ){
- for( it = NA_OBJECT_ITEM( b )->private->items ; it && equal ; it = it->next ){
- second_id = na_object_get_id( it->data );
- first_obj = na_object_get_item( a, second_id );
- if( !first_obj ){
+ if( equal ){
+ for( it = NA_OBJECT_ITEM( b )->private->items ; it && equal ; it = it->next ){
+ second_id = na_object_get_id( it->data );
+ first_obj = na_object_get_item( a, second_id );
+ if( !first_obj ){
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
g_debug( "na_object_item_object_are_equal: id=%s not found in a", second_id );
#endif
- equal = FALSE;
+ equal = FALSE;
+ }
+ g_free( second_id );
}
- g_free( second_id );
}
- }
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
- g_debug( "na_object_item_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
- ( void * ) a, G_OBJECT_TYPE_NAME( a ),
- ( void * ) b, G_OBJECT_TYPE_NAME( b ),
- equal ? "True":"False" );
+ g_debug( "na_object_item_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
+ ( void * ) a, G_OBJECT_TYPE_NAME( a ),
+ ( void * ) b, G_OBJECT_TYPE_NAME( b ),
+ equal ? "True":"False" );
#endif
+ }
return( equal );
}
@@ -953,16 +988,13 @@ static gboolean
object_is_valid( const NAObject *object )
{
gboolean valid = TRUE;
- /*GList *it;*/
g_return_val_if_fail( NA_IS_OBJECT_ITEM( object ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_ITEM( object )->private->dispose_has_run, FALSE );
- /*if( valid ){
- for( it = NA_OBJECT_ITEM( object )->private->items ; it && valid ; it = it->next ){
- valid = na_object_is_valid( it->data );
- }
- }*/
+ if( !NA_OBJECT_ITEM( object )->private->dispose_has_run ){
+
+ /* nothing to check here */
+ }
return( valid );
}
@@ -970,7 +1002,15 @@ object_is_valid( const NAObject *object )
static GList *
object_get_childs( const NAObject *object )
{
- return( NA_OBJECT_ITEM( object )->private->items );
+ GList *childs = NULL;
+
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( object ), NULL );
+
+ if( !NA_OBJECT_ITEM( object )->private->dispose_has_run ){
+ childs = NA_OBJECT_ITEM( object )->private->items;
+ }
+
+ return( childs );
}
static gchar *
@@ -979,20 +1019,22 @@ object_id_new_id( const NAObjectId *item )
GList *it;
uuid_t uuid;
gchar uuid_str[64];
- gchar *new_uuid;
+ gchar *new_uuid = NULL;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
- g_return_val_if_fail( !NA_OBJECT_ITEM( item )->private->dispose_has_run, NULL );
- for( it = NA_OBJECT_ITEM( item )->private->items ; it ; it = it->next ){
- if( NA_IS_OBJECT_ITEM( it->data )){
- na_object_set_new_id( it->data );
+ if( !NA_OBJECT_ITEM( item )->private->dispose_has_run ){
+
+ for( it = NA_OBJECT_ITEM( item )->private->items ; it ; it = it->next ){
+ if( NA_IS_OBJECT_ITEM( it->data )){
+ na_object_set_new_id( it->data );
+ }
}
- }
- uuid_generate( uuid );
- uuid_unparse_lower( uuid, uuid_str );
- new_uuid = g_strdup( uuid_str );
+ uuid_generate( uuid );
+ uuid_unparse_lower( uuid, uuid_str );
+ new_uuid = g_strdup( uuid_str );
+ }
return( new_uuid );
}
diff --git a/src/common/na-object-menu.c b/src/common/na-object-menu.c
index 9999929..c9f6947 100644
--- a/src/common/na-object-menu.c
+++ b/src/common/na-object-menu.c
@@ -174,7 +174,7 @@ instance_finalize( GObject *object )
/*g_debug( "%s: object=%p", thisfn, ( void * ) object );*/
g_return_if_fail( NA_IS_OBJECT_MENU( object ));
- self = ( NAObjectMenu * ) object;
+ self = NA_OBJECT_MENU( object );
/* release string list of subitems */
na_utils_free_string_list( self->private->items_ids );
@@ -214,16 +214,22 @@ na_object_menu_new( void )
* na_object_menu_get_items_list:
* @menu: this #NAObjectMenu object.
*
- * Returns: the current state of intern items_ids string list.
+ * Returns: the items_ids string list, as readen from the IIOProvider.
*
* The returned list should be na_utils_free_string_list() by the caller.
*/
GSList *
na_object_menu_get_items_list( const NAObjectMenu *menu )
{
+ GSList *list = NULL;
+
g_return_val_if_fail( NA_IS_OBJECT_MENU( menu ), NULL );
- return( na_utils_duplicate_string_list( menu->private->items_ids ));
+ if( !menu->private->dispose_has_run ){
+ list = na_utils_duplicate_string_list( menu->private->items_ids );
+ }
+
+ return( list );
}
/**
@@ -246,19 +252,23 @@ na_object_menu_rebuild_items_list( const NAObjectMenu *menu )
gchar *uuid;
g_return_val_if_fail( NA_IS_OBJECT_MENU( menu ), NULL );
- g_return_val_if_fail( !menu->private->dispose_has_run, NULL );
- items = na_object_get_items( menu );
+ if( !menu->private->dispose_has_run ){
- for( it = items ; it ; it = it->next ){
- NAObjectItem *item = NA_OBJECT_ITEM( it->data );
- uuid = na_object_get_id( item );
- list = g_slist_prepend( list, uuid );
- }
+ items = na_object_get_items( menu );
- na_object_free_items( items );
+ for( it = items ; it ; it = it->next ){
+ NAObjectItem *item = NA_OBJECT_ITEM( it->data );
+ uuid = na_object_get_id( item );
+ list = g_slist_prepend( list, uuid );
+ }
+
+ na_object_free_items( items );
+
+ list = g_slist_reverse( list );
+ }
- return( g_slist_reverse( list ));
+ return( list );
}
/**
@@ -275,10 +285,12 @@ void
na_object_menu_set_items_list( NAObjectMenu *menu, GSList *items )
{
g_return_if_fail( NA_IS_OBJECT_MENU( menu ));
- g_return_if_fail( !menu->private->dispose_has_run );
- na_utils_free_string_list( menu->private->items_ids );
- menu->private->items_ids = na_utils_duplicate_string_list( items );
+ if( !menu->private->dispose_has_run ){
+
+ na_utils_free_string_list( menu->private->items_ids );
+ menu->private->items_ids = na_utils_duplicate_string_list( items );
+ }
}
static void
@@ -288,23 +300,27 @@ object_dump( const NAObject *menu )
/*NAObjectMenu *self;*/
g_return_if_fail( NA_IS_OBJECT_MENU( menu ));
- g_return_if_fail( !NA_OBJECT_MENU( menu )->private->dispose_has_run );
- g_debug( "%s: (nothing to dump)", thisfn );
+ if( !NA_OBJECT_MENU( menu )->private->dispose_has_run ){
+
+ g_debug( "%s: (nothing to dump)", thisfn );
+ }
}
static gchar *
object_get_clipboard_id( const NAObject *menu )
{
gchar *uuid;
- gchar *clipboard_id;
+ gchar *clipboard_id = NULL;
g_return_val_if_fail( NA_IS_OBJECT_MENU( menu ), NULL );
- g_return_val_if_fail( !NA_OBJECT_MENU( menu )->private->dispose_has_run, NULL );
- uuid = na_object_get_id( menu );
- clipboard_id = g_strdup_printf( "M:%s", uuid );
- g_free( uuid );
+ if( !NA_OBJECT_MENU( menu )->private->dispose_has_run ){
+
+ uuid = na_object_get_id( menu );
+ clipboard_id = g_strdup_printf( "M:%s", uuid );
+ g_free( uuid );
+ }
return( clipboard_id );
}
@@ -319,9 +335,13 @@ static void
object_copy( NAObject *target, const NAObject *source )
{
g_return_if_fail( NA_IS_OBJECT_MENU( target ));
- g_return_if_fail( !NA_OBJECT_MENU( target )->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_MENU( source ));
- g_return_if_fail( !NA_OBJECT_MENU( source )->private->dispose_has_run );
+
+ if( !NA_OBJECT_MENU( target )->private->dispose_has_run &&
+ !NA_OBJECT_MENU( source )->private->dispose_has_run ){
+
+ /* nothing to do */
+ }
}
static gboolean
@@ -330,9 +350,13 @@ object_are_equal( const NAObject *a, const NAObject *b )
gboolean equal = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_MENU( a ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_MENU( a )->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT_MENU( b ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_MENU( b )->private->dispose_has_run, FALSE );
+
+ if( !NA_OBJECT_MENU( a )->private->dispose_has_run &&
+ !NA_OBJECT_MENU( b )->private->dispose_has_run ){
+
+ /* nothing to compare */
+ }
return( equal );
}
@@ -348,12 +372,14 @@ object_is_valid( const NAObject *menu )
gboolean is_valid = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_MENU( menu ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_MENU( menu )->private->dispose_has_run, FALSE );
- if( is_valid ){
- label = na_object_get_label( menu );
- is_valid = ( label && g_utf8_strlen( label, -1 ) > 0 );
- g_free( label );
+ if( !NA_OBJECT_MENU( menu )->private->dispose_has_run ){
+
+ if( is_valid ){
+ label = na_object_get_label( menu );
+ is_valid = ( label && g_utf8_strlen( label, -1 ) > 0 );
+ g_free( label );
+ }
}
return( is_valid );
diff --git a/src/common/na-object-menu.h b/src/common/na-object-menu.h
index 18497a8..656f8d7 100644
--- a/src/common/na-object-menu.h
+++ b/src/common/na-object-menu.h
@@ -36,7 +36,7 @@
* @short_description: #NAObjectMenu class definition.
* @include: common/na-object-menu.h
*
- * This is a menu.
+ * This is a menu. It embeds other menus and/or actions.
*/
#include "na-object-item-class.h"
diff --git a/src/common/na-object-profile-class.h b/src/common/na-object-profile-class.h
index 47b2371..dd421c8 100644
--- a/src/common/na-object-profile-class.h
+++ b/src/common/na-object-profile-class.h
@@ -33,6 +33,14 @@
/**
* SECTION: na_object_profile
+ * @short_description: #NAObjectProfile class definition.
+ * @include: common/na-object-profile-class.h
+ *
+ * This is a companion class of NAObjectAction. It embeds the profile
+ * definition of an action.
+ *
+ * As NAObjectAction itself, NAObjectProfile class is derived from
+ * NAObject class, which takes care of IDuplicable interface management.
*/
#include "na-object-id-class.h"
diff --git a/src/common/na-object-profile.c b/src/common/na-object-profile.c
index d7aacce..2006fb3 100644
--- a/src/common/na-object-profile.c
+++ b/src/common/na-object-profile.c
@@ -287,56 +287,58 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
GSList *list;
g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
- g_return_if_fail( !NA_OBJECT_PROFILE( object )->private->dispose_has_run );
self = NA_OBJECT_PROFILE( object );
- switch( property_id ){
- case NAPROFILE_PROP_ACTION_ID:
- g_value_set_pointer( value, self->private->action );
- break;
-
- case NAPROFILE_PROP_PATH_ID:
- g_value_set_string( value, self->private->path );
- break;
-
- case NAPROFILE_PROP_PARAMETERS_ID:
- g_value_set_string( value, self->private->parameters );
- break;
-
- case NAPROFILE_PROP_BASENAMES_ID:
- list = na_utils_duplicate_string_list( self->private->basenames );
- g_value_set_pointer( value, list );
- break;
-
- case NAPROFILE_PROP_MATCHCASE_ID:
- g_value_set_boolean( value, self->private->match_case );
- break;
-
- case NAPROFILE_PROP_MIMETYPES_ID:
- list = na_utils_duplicate_string_list( self->private->mimetypes );
- g_value_set_pointer( value, list );
- break;
-
- case NAPROFILE_PROP_ISFILE_ID:
- g_value_set_boolean( value, self->private->is_file );
- break;
-
- case NAPROFILE_PROP_ISDIR_ID:
- g_value_set_boolean( value, self->private->is_dir );
- break;
-
- case NAPROFILE_PROP_ACCEPT_MULTIPLE_ID:
- g_value_set_boolean( value, self->private->accept_multiple );
- break;
-
- case NAPROFILE_PROP_SCHEMES_ID:
- list = na_utils_duplicate_string_list( self->private->schemes );
- g_value_set_pointer( value, list );
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAPROFILE_PROP_ACTION_ID:
+ g_value_set_pointer( value, self->private->action );
+ break;
+
+ case NAPROFILE_PROP_PATH_ID:
+ g_value_set_string( value, self->private->path );
+ break;
+
+ case NAPROFILE_PROP_PARAMETERS_ID:
+ g_value_set_string( value, self->private->parameters );
+ break;
+
+ case NAPROFILE_PROP_BASENAMES_ID:
+ list = na_utils_duplicate_string_list( self->private->basenames );
+ g_value_set_pointer( value, list );
+ break;
+
+ case NAPROFILE_PROP_MATCHCASE_ID:
+ g_value_set_boolean( value, self->private->match_case );
+ break;
+
+ case NAPROFILE_PROP_MIMETYPES_ID:
+ list = na_utils_duplicate_string_list( self->private->mimetypes );
+ g_value_set_pointer( value, list );
+ break;
+
+ case NAPROFILE_PROP_ISFILE_ID:
+ g_value_set_boolean( value, self->private->is_file );
+ break;
+
+ case NAPROFILE_PROP_ISDIR_ID:
+ g_value_set_boolean( value, self->private->is_dir );
+ break;
+
+ case NAPROFILE_PROP_ACCEPT_MULTIPLE_ID:
+ g_value_set_boolean( value, self->private->accept_multiple );
+ break;
+
+ case NAPROFILE_PROP_SCHEMES_ID:
+ list = na_utils_duplicate_string_list( self->private->schemes );
+ g_value_set_pointer( value, list );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -346,58 +348,60 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
NAObjectProfile *self;
g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
- g_return_if_fail( !NA_OBJECT_PROFILE( object )->private->dispose_has_run );
self = NA_OBJECT_PROFILE( object );
- switch( property_id ){
- case NAPROFILE_PROP_ACTION_ID:
- self->private->action = g_value_get_pointer( value );
- break;
-
- case NAPROFILE_PROP_PATH_ID:
- g_free( self->private->path );
- self->private->path = g_value_dup_string( value );
- break;
-
- case NAPROFILE_PROP_PARAMETERS_ID:
- g_free( self->private->parameters );
- self->private->parameters = g_value_dup_string( value );
- break;
-
- case NAPROFILE_PROP_BASENAMES_ID:
- na_utils_free_string_list( self->private->basenames );
- self->private->basenames = na_utils_duplicate_string_list( g_value_get_pointer( value ));
- break;
-
- case NAPROFILE_PROP_MATCHCASE_ID:
- self->private->match_case = g_value_get_boolean( value );
- break;
-
- case NAPROFILE_PROP_MIMETYPES_ID:
- na_utils_free_string_list( self->private->mimetypes );
- self->private->mimetypes = na_utils_duplicate_string_list( g_value_get_pointer( value ));
- break;
-
- case NAPROFILE_PROP_ISFILE_ID:
- self->private->is_file = g_value_get_boolean( value );
- break;
-
- case NAPROFILE_PROP_ISDIR_ID:
- self->private->is_dir = g_value_get_boolean( value );
- break;
-
- case NAPROFILE_PROP_ACCEPT_MULTIPLE_ID:
- self->private->accept_multiple = g_value_get_boolean( value );
- break;
-
- case NAPROFILE_PROP_SCHEMES_ID:
- na_utils_free_string_list( self->private->schemes );
- self->private->schemes = na_utils_duplicate_string_list( g_value_get_pointer( value ));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ if( !self->private->dispose_has_run ){
+
+ switch( property_id ){
+ case NAPROFILE_PROP_ACTION_ID:
+ self->private->action = g_value_get_pointer( value );
+ break;
+
+ case NAPROFILE_PROP_PATH_ID:
+ g_free( self->private->path );
+ self->private->path = g_value_dup_string( value );
+ break;
+
+ case NAPROFILE_PROP_PARAMETERS_ID:
+ g_free( self->private->parameters );
+ self->private->parameters = g_value_dup_string( value );
+ break;
+
+ case NAPROFILE_PROP_BASENAMES_ID:
+ na_utils_free_string_list( self->private->basenames );
+ self->private->basenames = na_utils_duplicate_string_list( g_value_get_pointer( value ));
+ break;
+
+ case NAPROFILE_PROP_MATCHCASE_ID:
+ self->private->match_case = g_value_get_boolean( value );
+ break;
+
+ case NAPROFILE_PROP_MIMETYPES_ID:
+ na_utils_free_string_list( self->private->mimetypes );
+ self->private->mimetypes = na_utils_duplicate_string_list( g_value_get_pointer( value ));
+ break;
+
+ case NAPROFILE_PROP_ISFILE_ID:
+ self->private->is_file = g_value_get_boolean( value );
+ break;
+
+ case NAPROFILE_PROP_ISDIR_ID:
+ self->private->is_dir = g_value_get_boolean( value );
+ break;
+
+ case NAPROFILE_PROP_ACCEPT_MULTIPLE_ID:
+ self->private->accept_multiple = g_value_get_boolean( value );
+ break;
+
+ case NAPROFILE_PROP_SCHEMES_ID:
+ na_utils_free_string_list( self->private->schemes );
+ self->private->schemes = na_utils_duplicate_string_list( g_value_get_pointer( value ));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -430,7 +434,7 @@ instance_finalize( GObject *object )
/*g_debug( "%s: object=%p", thisfn, (void * ) object );*/
g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
- self = ( NAObjectProfile * ) object;
+ self = NA_OBJECT_PROFILE( object );
g_free( self->private->path );
g_free( self->private->parameters );
@@ -481,12 +485,13 @@ na_object_profile_new( void )
NAObjectAction *
na_object_profile_get_action( const NAObjectProfile *profile )
{
- NAObjectAction *action;
+ NAObjectAction *action = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ACTION, &action, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ACTION, &action, NULL );
+ }
return( action );
}
@@ -503,12 +508,13 @@ na_object_profile_get_action( const NAObjectProfile *profile )
gchar *
na_object_profile_get_path( const NAObjectProfile *profile )
{
- gchar *path;
+ gchar *path = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_PATH, &path, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_PATH, &path, NULL );
+ }
return( path );
}
@@ -525,12 +531,13 @@ na_object_profile_get_path( const NAObjectProfile *profile )
gchar *
na_object_profile_get_parameters( const NAObjectProfile *profile )
{
- gchar *parameters;
+ gchar *parameters = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_PARAMETERS, ¶meters, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_PARAMETERS, ¶meters, NULL );
+ }
return( parameters );
}
@@ -550,12 +557,13 @@ na_object_profile_get_parameters( const NAObjectProfile *profile )
GSList *
na_object_profile_get_basenames( const NAObjectProfile *profile )
{
- GSList *basenames;
+ GSList *basenames = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_BASENAMES, &basenames, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_BASENAMES, &basenames, NULL );
+ }
return( basenames );
}
@@ -575,12 +583,13 @@ na_object_profile_get_basenames( const NAObjectProfile *profile )
gboolean
na_object_profile_get_matchcase( const NAObjectProfile *profile )
{
- gboolean matchcase;
+ gboolean matchcase = FALSE;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
- g_return_val_if_fail( !profile->private->dispose_has_run, FALSE );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_MATCHCASE, &matchcase, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_MATCHCASE, &matchcase, NULL );
+ }
return( matchcase );
}
@@ -600,12 +609,13 @@ na_object_profile_get_matchcase( const NAObjectProfile *profile )
GSList *
na_object_profile_get_mimetypes( const NAObjectProfile *profile )
{
- GSList *mimetypes;
+ GSList *mimetypes = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_MIMETYPES, &mimetypes, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_MIMETYPES, &mimetypes, NULL );
+ }
return( mimetypes );
}
@@ -624,12 +634,13 @@ na_object_profile_get_mimetypes( const NAObjectProfile *profile )
gboolean
na_object_profile_get_is_file( const NAObjectProfile *profile )
{
- gboolean isfile;
+ gboolean isfile = FALSE;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
- g_return_val_if_fail( !profile->private->dispose_has_run, FALSE );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, &isfile, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, &isfile, NULL );
+ }
return( isfile );
}
@@ -648,12 +659,13 @@ na_object_profile_get_is_file( const NAObjectProfile *profile )
gboolean
na_object_profile_get_is_dir( const NAObjectProfile *profile )
{
- gboolean isdir;
+ gboolean isdir = FALSE;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
- g_return_val_if_fail( !profile->private->dispose_has_run, FALSE );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ISDIR, &isdir, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ISDIR, &isdir, NULL );
+ }
return( isdir );
}
@@ -673,12 +685,13 @@ na_object_profile_get_is_dir( const NAObjectProfile *profile )
gboolean
na_object_profile_get_multiple( const NAObjectProfile *profile )
{
- gboolean multiple;
+ gboolean multiple = FALSE;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
- g_return_val_if_fail( !profile->private->dispose_has_run, FALSE );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple, NULL );
+ }
return( multiple );
}
@@ -698,12 +711,13 @@ na_object_profile_get_multiple( const NAObjectProfile *profile )
GSList *
na_object_profile_get_schemes( const NAObjectProfile *profile )
{
- GSList *schemes;
+ GSList *schemes = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_SCHEMES, &schemes, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_SCHEMES, &schemes, NULL );
+ }
return( schemes );
}
@@ -721,10 +735,11 @@ void
na_object_profile_set_action( NAObjectProfile *profile, const NAObjectAction *action )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ACTION, action, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ACTION, action, NULL );
+ }
}
/**
@@ -741,9 +756,10 @@ void
na_object_profile_set_path( NAObjectProfile *profile, const gchar *path )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_PATH, path, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_PATH, path, NULL );
+ }
}
/**
@@ -760,9 +776,10 @@ void
na_object_profile_set_parameters( NAObjectProfile *profile, const gchar *parameters )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_PARAMETERS, parameters, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_PARAMETERS, parameters, NULL );
+ }
}
/**
@@ -783,9 +800,10 @@ void
na_object_profile_set_basenames( NAObjectProfile *profile, GSList *basenames )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_BASENAMES, basenames, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_BASENAMES, basenames, NULL );
+ }
}
/**
@@ -803,9 +821,10 @@ void
na_object_profile_set_matchcase( NAObjectProfile *profile, gboolean matchcase )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_MATCHCASE, matchcase, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_MATCHCASE, matchcase, NULL );
+ }
}
/**
@@ -826,9 +845,10 @@ void
na_object_profile_set_mimetypes( NAObjectProfile *profile, GSList *mimetypes )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_MIMETYPES, mimetypes, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_MIMETYPES, mimetypes, NULL );
+ }
}
/**
@@ -842,9 +862,10 @@ void
na_object_profile_set_isfile( NAObjectProfile *profile, gboolean isfile )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, isfile, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, isfile, NULL );
+ }
}
/**
@@ -858,9 +879,10 @@ void
na_object_profile_set_isdir( NAObjectProfile *profile, gboolean isdir )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISDIR, isdir, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISDIR, isdir, NULL );
+ }
}
/**
@@ -880,9 +902,10 @@ void
na_object_profile_set_isfiledir( NAObjectProfile *profile, gboolean isfile, gboolean isdir )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, isfile, NAPROFILE_PROP_ISDIR, isdir, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ISFILE, isfile, NAPROFILE_PROP_ISDIR, isdir, NULL );
+ }
}
/**
@@ -899,9 +922,10 @@ void
na_object_profile_set_multiple( NAObjectProfile *profile, gboolean multiple )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple, NULL );
+ }
}
/**
@@ -919,16 +943,18 @@ na_object_profile_set_scheme( NAObjectProfile *profile, const gchar *scheme, gbo
gboolean exist;
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- exist = na_utils_find_in_list( profile->private->schemes, scheme );
- /*g_debug( "%s: scheme=%s exist=%s", thisfn, scheme, exist ? "True":"False" );*/
+ if( !profile->private->dispose_has_run ){
- if( selected && !exist ){
- profile->private->schemes = g_slist_prepend( profile->private->schemes, g_strdup( scheme ));
- }
- if( !selected && exist ){
- profile->private->schemes = na_utils_remove_ascii_from_string_list( profile->private->schemes, scheme );
+ exist = na_utils_find_in_list( profile->private->schemes, scheme );
+ /*g_debug( "%s: scheme=%s exist=%s", thisfn, scheme, exist ? "True":"False" );*/
+
+ if( selected && !exist ){
+ profile->private->schemes = g_slist_prepend( profile->private->schemes, g_strdup( scheme ));
+ }
+ if( !selected && exist ){
+ profile->private->schemes = na_utils_remove_ascii_from_string_list( profile->private->schemes, scheme );
+ }
}
}
@@ -950,9 +976,10 @@ void
na_object_profile_set_schemes( NAObjectProfile *profile, GSList *schemes )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( !profile->private->dispose_has_run );
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_SCHEMES, schemes, NULL );
+ if( !profile->private->dispose_has_run ){
+ g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_SCHEMES, schemes, NULL );
+ }
}
/**
@@ -993,7 +1020,10 @@ na_object_profile_is_candidate( const NAObjectProfile *profile, GList* files )
gchar *tmp_pattern, *tmp_filename, *tmp_filename2, *tmp_mimetype, *tmp_mimetype2;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
- g_return_val_if_fail( !profile->private->dispose_has_run, FALSE );
+
+ if( profile->private->dispose_has_run ){
+ return( FALSE );
+ }
if (profile->private->basenames && profile->private->basenames->next != NULL &&
g_ascii_strcasecmp ((gchar*)(profile->private->basenames->data), "*") == 0)
@@ -1238,7 +1268,10 @@ na_object_profile_parse_parameters( const NAObjectProfile *profile, GList* files
NAGnomeVFSURI *vfs;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !profile->private->dispose_has_run, NULL );
+
+ if( profile->private->dispose_has_run ){
+ return( NULL );
+ }
string = g_string_new( "" );
basename_list = g_string_new( "" );
@@ -1422,19 +1455,21 @@ object_dump( const NAObject *object )
NAObjectProfile *self;
g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
- g_return_if_fail( !NA_OBJECT_PROFILE( object )->private->dispose_has_run );
self = NA_OBJECT_PROFILE( object );
- g_debug( "%s: action=%p", thisfn, ( void * ) self->private->action );
- g_debug( "%s: path='%s'", thisfn, self->private->path );
- g_debug( "%s: parameters='%s'", thisfn, self->private->parameters );
- g_debug( "%s: accept_multiple='%s'", thisfn, self->private->accept_multiple ? "True" : "False" );
- g_debug( "%s: is_dir='%s'", thisfn, self->private->is_dir ? "True" : "False" );
- g_debug( "%s: is_file='%s'", thisfn, self->private->is_file ? "True" : "False" );
- g_debug( "%s: match_case='%s'", thisfn, self->private->match_case ? "True" : "False" );
- object_dump_list( thisfn, "basenames", self->private->basenames );
- object_dump_list( thisfn, "mimetypes", self->private->mimetypes );
- object_dump_list( thisfn, " schemes", self->private->schemes );
+ if( !self->private->dispose_has_run ){
+
+ g_debug( "%s: action=%p", thisfn, ( void * ) self->private->action );
+ g_debug( "%s: path='%s'", thisfn, self->private->path );
+ g_debug( "%s: parameters='%s'", thisfn, self->private->parameters );
+ g_debug( "%s: accept_multiple='%s'", thisfn, self->private->accept_multiple ? "True" : "False" );
+ g_debug( "%s: is_dir='%s'", thisfn, self->private->is_dir ? "True" : "False" );
+ g_debug( "%s: is_file='%s'", thisfn, self->private->is_file ? "True" : "False" );
+ g_debug( "%s: match_case='%s'", thisfn, self->private->match_case ? "True" : "False" );
+ object_dump_list( thisfn, "basenames", self->private->basenames );
+ object_dump_list( thisfn, "mimetypes", self->private->mimetypes );
+ object_dump_list( thisfn, " schemes", self->private->schemes );
+ }
}
static void
@@ -1450,16 +1485,18 @@ object_get_clipboard_id( const NAObject *profile )
{
gchar *uuid;
gchar *name;
- gchar *clipboard_id;
+ gchar *clipboard_id = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
- g_return_val_if_fail( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run, NULL );
- uuid = na_object_get_id( NA_OBJECT_PROFILE( profile )->private->action );
- name = na_object_get_id( profile );
- clipboard_id = g_strdup_printf( "P:%s/%s", uuid, name );
- g_free( uuid );
- g_free( name );
+ if( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run ){
+
+ uuid = na_object_get_id( NA_OBJECT_PROFILE( profile )->private->action );
+ name = na_object_get_id( profile );
+ clipboard_id = g_strdup_printf( "P:%s/%s", uuid, name );
+ g_free( uuid );
+ g_free( name );
+ }
return( clipboard_id );
}
@@ -1478,39 +1515,41 @@ object_copy( NAObject *target, const NAObject *source )
GSList *basenames, *mimetypes, *schemes;
g_return_if_fail( NA_IS_OBJECT_PROFILE( target ));
- g_return_if_fail( !NA_OBJECT_PROFILE( target )->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_PROFILE( source ));
- g_return_if_fail( !NA_OBJECT_PROFILE( source )->private->dispose_has_run );
-
- g_object_get( G_OBJECT( source ),
- NAPROFILE_PROP_PATH, &path,
- NAPROFILE_PROP_PARAMETERS, ¶meters,
- NAPROFILE_PROP_BASENAMES, &basenames,
- NAPROFILE_PROP_MATCHCASE, &matchcase,
- NAPROFILE_PROP_MIMETYPES, &mimetypes,
- NAPROFILE_PROP_ISFILE, &isfile,
- NAPROFILE_PROP_ISDIR, &isdir,
- NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple,
- NAPROFILE_PROP_SCHEMES, &schemes,
- NULL );
-
- g_object_set( G_OBJECT( target ),
- NAPROFILE_PROP_PATH, path,
- NAPROFILE_PROP_PARAMETERS, parameters,
- NAPROFILE_PROP_BASENAMES, basenames,
- NAPROFILE_PROP_MATCHCASE, matchcase,
- NAPROFILE_PROP_MIMETYPES, mimetypes,
- NAPROFILE_PROP_ISFILE, isfile,
- NAPROFILE_PROP_ISDIR, isdir,
- NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple,
- NAPROFILE_PROP_SCHEMES, schemes,
- NULL );
-
- g_free( path );
- g_free( parameters );
- na_utils_free_string_list( basenames );
- na_utils_free_string_list( mimetypes );
- na_utils_free_string_list( schemes );
+
+ if( !NA_OBJECT_PROFILE( target )->private->dispose_has_run &&
+ !NA_OBJECT_PROFILE( source )->private->dispose_has_run ){
+
+ g_object_get( G_OBJECT( source ),
+ NAPROFILE_PROP_PATH, &path,
+ NAPROFILE_PROP_PARAMETERS, ¶meters,
+ NAPROFILE_PROP_BASENAMES, &basenames,
+ NAPROFILE_PROP_MATCHCASE, &matchcase,
+ NAPROFILE_PROP_MIMETYPES, &mimetypes,
+ NAPROFILE_PROP_ISFILE, &isfile,
+ NAPROFILE_PROP_ISDIR, &isdir,
+ NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple,
+ NAPROFILE_PROP_SCHEMES, &schemes,
+ NULL );
+
+ g_object_set( G_OBJECT( target ),
+ NAPROFILE_PROP_PATH, path,
+ NAPROFILE_PROP_PARAMETERS, parameters,
+ NAPROFILE_PROP_BASENAMES, basenames,
+ NAPROFILE_PROP_MATCHCASE, matchcase,
+ NAPROFILE_PROP_MIMETYPES, mimetypes,
+ NAPROFILE_PROP_ISFILE, isfile,
+ NAPROFILE_PROP_ISDIR, isdir,
+ NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple,
+ NAPROFILE_PROP_SCHEMES, schemes,
+ NULL );
+
+ g_free( path );
+ g_free( parameters );
+ na_utils_free_string_list( basenames );
+ na_utils_free_string_list( mimetypes );
+ na_utils_free_string_list( schemes );
+ }
}
gboolean
@@ -1521,43 +1560,45 @@ object_are_equal( const NAObject *a, const NAObject *b )
gboolean equal = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( a ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_PROFILE( a )->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( b ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_PROFILE( b )->private->dispose_has_run, FALSE );
- if( equal ){
- equal =
- ( g_utf8_collate( first->private->path, second->private->path ) == 0 ) &&
- ( g_utf8_collate( first->private->parameters, second->private->parameters ) == 0 );
- }
+ if( !NA_OBJECT_PROFILE( a )->private->dispose_has_run &&
+ !NA_OBJECT_PROFILE( b )->private->dispose_has_run ){
- if( equal ){
- equal = (( first->private->accept_multiple && second->private->accept_multiple ) ||
- ( !first->private->accept_multiple && !second->private->accept_multiple ));
- }
+ if( equal ){
+ equal =
+ ( g_utf8_collate( first->private->path, second->private->path ) == 0 ) &&
+ ( g_utf8_collate( first->private->parameters, second->private->parameters ) == 0 );
+ }
- if( equal ){
- equal = (( first->private->is_dir && second->private->is_dir ) ||
- ( !first->private->is_dir && !second->private->is_dir ));
- }
+ if( equal ){
+ equal = (( first->private->accept_multiple && second->private->accept_multiple ) ||
+ ( !first->private->accept_multiple && !second->private->accept_multiple ));
+ }
- if( equal ){
- equal = (( first->private->is_file && second->private->is_file ) ||
- ( !first->private->is_file && !second->private->is_file ));
- }
+ if( equal ){
+ equal = (( first->private->is_dir && second->private->is_dir ) ||
+ ( !first->private->is_dir && !second->private->is_dir ));
+ }
- if( equal ){
- equal = na_utils_string_lists_are_equal( first->private->basenames, second->private->basenames ) &&
- na_utils_string_lists_are_equal( first->private->mimetypes, second->private->mimetypes ) &&
- na_utils_string_lists_are_equal( first->private->schemes, second->private->schemes );
- }
+ if( equal ){
+ equal = (( first->private->is_file && second->private->is_file ) ||
+ ( !first->private->is_file && !second->private->is_file ));
+ }
+
+ if( equal ){
+ equal = na_utils_string_lists_are_equal( first->private->basenames, second->private->basenames ) &&
+ na_utils_string_lists_are_equal( first->private->mimetypes, second->private->mimetypes ) &&
+ na_utils_string_lists_are_equal( first->private->schemes, second->private->schemes );
+ }
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
- g_debug( "na_object_profile_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
- ( void * ) a, G_OBJECT_TYPE_NAME( a ),
- ( void * ) b, G_OBJECT_TYPE_NAME( b ),
- equal ? "True":"False" );
+ g_debug( "na_object_profile_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
+ ( void * ) a, G_OBJECT_TYPE_NAME( a ),
+ ( void * ) b, G_OBJECT_TYPE_NAME( b ),
+ equal ? "True":"False" );
#endif
+ }
return( equal );
}
@@ -1573,12 +1614,14 @@ object_is_valid( const NAObject *profile )
gboolean is_valid = TRUE;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), FALSE );
- g_return_val_if_fail( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run, FALSE );
- if( is_valid ){
- label = na_object_get_label( profile );
- is_valid = ( label && g_utf8_strlen( label, -1 ) > 0 );
- g_free( label );
+ if( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run ){
+
+ if( is_valid ){
+ label = na_object_get_label( profile );
+ is_valid = ( label && g_utf8_strlen( label, -1 ) > 0 );
+ g_free( label );
+ }
}
return( is_valid );
diff --git a/src/common/na-object-profile.h b/src/common/na-object-profile.h
index 58a6c4d..bcf8356 100644
--- a/src/common/na-object-profile.h
+++ b/src/common/na-object-profile.h
@@ -33,14 +33,8 @@
/**
* SECTION: na_object_profile
- * @short_description: #NAObjectProfile class definition.
+ * @short_description: #NAObjectProfile public function declarations.
* @include: common/na-object-profile.h
- *
- * This is a companion class of NAObjectAction. It embeds the profile
- * definition of an action.
- *
- * As NAObjectAction itself, NAObjectProfile class is derived from
- * NAObject class, which takes care of IDuplicable interface management.
*/
#include "na-object-action-class.h"
diff --git a/src/common/na-object.c b/src/common/na-object.c
index a82ef3b..e3abf73 100644
--- a/src/common/na-object.c
+++ b/src/common/na-object.c
@@ -265,14 +265,16 @@ na_object_iduplicable_check_edition_status( const NAObject *object )
( void * ) object, G_OBJECT_TYPE_NAME( object ));
#endif
g_return_if_fail( NA_IS_OBJECT( object ));
- g_return_if_fail( !object->private->dispose_has_run );
- childs = v_get_childs( object );
- for( ic = childs ; ic ; ic = ic->next ){
- na_object_iduplicable_check_edition_status( NA_OBJECT( ic->data ));
- }
+ if( !object->private->dispose_has_run ){
+
+ childs = v_get_childs( object );
+ for( ic = childs ; ic ; ic = ic->next ){
+ na_object_iduplicable_check_edition_status( NA_OBJECT( ic->data ));
+ }
- na_iduplicable_check_edition_status( NA_IDUPLICABLE( object ));
+ na_iduplicable_check_edition_status( NA_IDUPLICABLE( object ));
+ }
}
/**
@@ -307,19 +309,22 @@ na_object_iduplicable_check_edition_status( const NAObject *object )
NAObject *
na_object_iduplicable_duplicate( const NAObject *object )
{
- NAIDuplicable *duplicate;
+ NAIDuplicable *duplicate = NULL;
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
g_return_val_if_fail( NA_IS_IDUPLICABLE( object ), NULL );
- g_return_val_if_fail( !object->private->dispose_has_run, NULL );
- duplicate = na_iduplicable_duplicate( NA_IDUPLICABLE( object ));
+ if( !object->private->dispose_has_run ){
+
+ duplicate = na_iduplicable_duplicate( NA_IDUPLICABLE( object ));
- /*g_debug( "na_object_iduplicable_duplicate: object=%p (%s), duplicate=%p (%s)",
- ( void * ) object, G_OBJECT_TYPE_NAME( object ),
- ( void * ) duplicate, duplicate ? G_OBJECT_TYPE_NAME( duplicate ) : "" );*/
+ /*g_debug( "na_object_iduplicable_duplicate: object=%p (%s), duplicate=%p (%s)",
+ ( void * ) object, G_OBJECT_TYPE_NAME( object ),
+ ( void * ) duplicate, duplicate ? G_OBJECT_TYPE_NAME( duplicate ) : "" );*/
+ }
- return( NA_OBJECT( duplicate ));
+ /* do not use NA_OBJECT macro as we may return a (valid) NULL value */
+ return(( NAObject * ) duplicate );
}
/**
@@ -338,12 +343,16 @@ na_object_iduplicable_duplicate( const NAObject *object )
gboolean
na_object_iduplicable_are_equal( const NAObject *a, const NAObject *b )
{
+ gboolean are_equal = FALSE;
+
g_return_val_if_fail( NA_IS_OBJECT( a ), FALSE );
- g_return_val_if_fail( !a->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT( b ), FALSE );
- g_return_val_if_fail( !b->private->dispose_has_run, FALSE );
- return( are_equal_hierarchy( a, b ));
+ if( !a->private->dispose_has_run && !b->private->dispose_has_run ){
+ are_equal = are_equal_hierarchy( a, b );
+ }
+
+ return( are_equal );
}
/**
@@ -364,10 +373,15 @@ na_object_iduplicable_are_equal( const NAObject *a, const NAObject *b )
gboolean
na_object_iduplicable_is_modified( const NAObject *object )
{
+ gboolean is_modified = FALSE;
+
g_return_val_if_fail( NA_IS_OBJECT( object ), FALSE );
- g_return_val_if_fail( !object->private->dispose_has_run, FALSE );
- return( na_iduplicable_is_modified( NA_IDUPLICABLE( object )));
+ if( !object->private->dispose_has_run ){
+ is_modified = na_iduplicable_is_modified( NA_IDUPLICABLE( object ));
+ }
+
+ return( is_modified );
}
/**
@@ -381,10 +395,15 @@ na_object_iduplicable_is_modified( const NAObject *object )
gboolean
na_object_iduplicable_is_valid( const NAObject *object )
{
+ gboolean is_valid = FALSE;
+
g_return_val_if_fail( NA_IS_OBJECT( object ), FALSE );
- g_return_val_if_fail( !object->private->dispose_has_run, FALSE );
- return( na_iduplicable_is_valid( NA_IDUPLICABLE( object )));
+ if( !object->private->dispose_has_run ){
+ is_valid = na_iduplicable_is_valid( NA_IDUPLICABLE( object ));
+ }
+
+ return( is_valid );
}
/**
@@ -394,17 +413,20 @@ na_object_iduplicable_is_valid( const NAObject *object )
* Returns the original object which was at the origin of @object.
*
* Returns: a #NAObject, or NULL.
- *
- * Do not use here NA_OBJECT macro as it may return a (valid) NULL value
*/
NAObject *
na_object_iduplicable_get_origin( const NAObject *object )
{
+ NAObject *origin = NULL;
+
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
- g_return_val_if_fail( !object->private->dispose_has_run, NULL );
- /*return( NA_OBJECT( na_iduplicable_get_origin( NA_IDUPLICABLE( object ))));*/
- return(( NAObject * ) na_iduplicable_get_origin( NA_IDUPLICABLE( object )));
+ if( !object->private->dispose_has_run ){
+ /* do not use NA_OBJECT macro as we may return a (valid) NULL value */
+ origin = ( NAObject * ) na_iduplicable_get_origin( NA_IDUPLICABLE( object ));
+ }
+
+ return( origin );
}
/**
@@ -423,15 +445,17 @@ na_object_iduplicable_set_origin( NAObject *object, const NAObject *origin )
GList *childs, *ic;
g_return_if_fail( NA_IS_OBJECT( object ));
- g_return_if_fail( !object->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT( origin ) || !origin );
- g_return_if_fail( !origin || !origin->private->dispose_has_run );
- na_iduplicable_set_origin( NA_IDUPLICABLE( object ), NA_IDUPLICABLE( origin ));
+ if( !object->private->dispose_has_run &&
+ ( !origin || !origin->private->dispose_has_run )){
- childs = v_get_childs( object );
- for( ic = childs ; ic ; ic = ic->next ){
- na_object_iduplicable_set_origin( NA_OBJECT( ic->data ), origin );
+ na_iduplicable_set_origin( NA_IDUPLICABLE( object ), NA_IDUPLICABLE( origin ));
+
+ childs = v_get_childs( object );
+ for( ic = childs ; ic ; ic = ic->next ){
+ na_object_iduplicable_set_origin( NA_OBJECT( ic->data ), origin );
+ }
}
}
@@ -451,13 +475,15 @@ na_object_object_dump( const NAObject *object )
GList *childs, *ic;
g_return_if_fail( NA_IS_OBJECT( object ));
- g_return_if_fail( !object->private->dispose_has_run );
- na_object_object_dump_norec( object );
+ if( !object->private->dispose_has_run ){
+
+ na_object_object_dump_norec( object );
- childs = v_get_childs( object );
- for( ic = childs ; ic ; ic = ic->next ){
- na_object_object_dump( NA_OBJECT( ic->data ));
+ childs = v_get_childs( object );
+ for( ic = childs ; ic ; ic = ic->next ){
+ na_object_object_dump( NA_OBJECT( ic->data ));
+ }
}
}
@@ -473,9 +499,10 @@ void
na_object_object_dump_norec( const NAObject *object )
{
g_return_if_fail( NA_IS_OBJECT( object ));
- g_return_if_fail( !object->private->dispose_has_run );
- dump_hierarchy( object );
+ if( !object->private->dispose_has_run ){
+ dump_hierarchy( object );
+ }
}
/**
@@ -502,10 +529,15 @@ na_object_object_dump_tree( GList *tree )
gchar *
na_object_object_get_clipboard_id( const NAObject *object )
{
+ gchar *id = NULL;
+
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
- g_return_val_if_fail( !object->private->dispose_has_run, NULL );
- return( most_derived_clipboard_id( object ));
+ if( !object->private->dispose_has_run ){
+ id = most_derived_clipboard_id( object );
+ }
+
+ return( id );
}
/**
@@ -549,22 +581,23 @@ na_object_object_reset_origin( NAObject *object, const NAObject *origin )
NAObject *orig_object;
g_return_if_fail( NA_IS_OBJECT( origin ));
- g_return_if_fail( !origin->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT( object ));
- g_return_if_fail( !object->private->dispose_has_run );
-
- origin_childs = v_get_childs( origin );
- object_childs = v_get_childs( object );
- for( iorig = origin_childs, iobj = object_childs ; iorig && iobj ; iorig = iorig->next, iobj = iobj->next ){
- orig_object = na_object_get_origin( iorig->data );
- g_return_if_fail( orig_object == iobj->data );
- na_object_reset_origin( iobj->data, iorig->data );
- }
- orig_object = na_object_get_origin( origin );
- g_return_if_fail( orig_object == object );
- na_iduplicable_set_origin( NA_IDUPLICABLE( object ), NA_IDUPLICABLE( origin ));
- na_iduplicable_set_origin( NA_IDUPLICABLE( origin ), NULL );
+ if( !object->private->dispose_has_run && !origin->private->dispose_has_run ){
+
+ origin_childs = v_get_childs( origin );
+ object_childs = v_get_childs( object );
+ for( iorig = origin_childs, iobj = object_childs ; iorig && iobj ; iorig = iorig->next, iobj = iobj->next ){
+ orig_object = na_object_get_origin( iorig->data );
+ g_return_if_fail( orig_object == iobj->data );
+ na_object_reset_origin( iobj->data, iorig->data );
+ }
+
+ orig_object = na_object_get_origin( origin );
+ g_return_if_fail( orig_object == object );
+ na_iduplicable_set_origin( NA_IDUPLICABLE( object ), NA_IDUPLICABLE( origin ));
+ na_iduplicable_set_origin( NA_IDUPLICABLE( origin ), NULL );
+ }
}
/**
@@ -576,17 +609,22 @@ na_object_object_reset_origin( NAObject *object, const NAObject *origin )
GList *
na_object_get_hierarchy( const NAObject *object )
{
- GList *hierarchy;
+ GList *hierarchy = NULL;
GObjectClass *class;
- hierarchy = NULL;
- class = G_OBJECT_GET_CLASS( object );
+ g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
+
+ if( !object->private->dispose_has_run ){
+
+ class = G_OBJECT_GET_CLASS( object );
+
+ while( G_OBJECT_CLASS_TYPE( class ) != NA_OBJECT_TYPE ){
+ hierarchy = g_list_prepend( hierarchy, class );
+ class = g_type_class_peek_parent( class );
+ }
- while( G_OBJECT_CLASS_TYPE( class ) != NA_OBJECT_TYPE ){
hierarchy = g_list_prepend( hierarchy, class );
- class = g_type_class_peek_parent( class );
}
- hierarchy = g_list_prepend( hierarchy, class );
return( hierarchy );
}
@@ -603,38 +641,58 @@ na_object_free_hierarchy( GList *hierarchy )
static NAIDuplicable *
iduplicable_new( const NAIDuplicable *object )
{
+ NAIDuplicable *new_object = NULL;
+
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
- g_return_val_if_fail( !NA_OBJECT( object )->private->dispose_has_run, NULL );
- return( NA_IDUPLICABLE( most_derived_new( NA_OBJECT( object ))));
+ if( !NA_OBJECT( object )->private->dispose_has_run ){
+ /* do not use NA_IDUPLICABLE macro as we may return a (valid) NULL value */
+ new_object = ( NAIDuplicable * ) most_derived_new( NA_OBJECT( object ));
+ }
+
+ return( new_object );
}
static void
iduplicable_copy( NAIDuplicable *target, const NAIDuplicable *source )
{
g_return_if_fail( NA_IS_OBJECT( target ));
- g_return_if_fail( !NA_OBJECT( target )->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT( source ));
- g_return_if_fail( !NA_OBJECT( source )->private->dispose_has_run );
- copy_hierarchy( NA_OBJECT( target ), NA_OBJECT( source ));
+ if( !NA_OBJECT( source )->private->dispose_has_run &&
+ !NA_OBJECT( target )->private->dispose_has_run ){
+
+ copy_hierarchy( NA_OBJECT( target ), NA_OBJECT( source ));
+ }
}
static gboolean
iduplicable_are_equal( const NAIDuplicable *a, const NAIDuplicable *b )
{
+ gboolean are_equal = FALSE;
+
g_return_val_if_fail( NA_IS_OBJECT( a ), FALSE );
- g_return_val_if_fail( !NA_OBJECT( a )->private->dispose_has_run, FALSE );
g_return_val_if_fail( NA_IS_OBJECT( b ), FALSE );
- g_return_val_if_fail( !NA_OBJECT( b )->private->dispose_has_run, FALSE );
- return( are_equal_hierarchy( NA_OBJECT( a ), NA_OBJECT( b )));
+ if( !NA_OBJECT( a )->private->dispose_has_run &&
+ !NA_OBJECT( b )->private->dispose_has_run ){
+
+ are_equal = are_equal_hierarchy( NA_OBJECT( a ), NA_OBJECT( b ));
+ }
+
+ return( are_equal );
}
static gboolean
iduplicable_is_valid( const NAIDuplicable *object )
{
- return( is_valid_hierarchy( NA_OBJECT( object )));
+ gboolean is_valid = FALSE;
+
+ if( !NA_OBJECT( object )->private->dispose_has_run ){
+ is_valid = is_valid_hierarchy( NA_OBJECT( object ));
+ }
+
+ return( is_valid );
}
static GList *
diff --git a/src/common/na-pivot.c b/src/common/na-pivot.c
index fb77891..b7e1dff 100644
--- a/src/common/na-pivot.c
+++ b/src/common/na-pivot.c
@@ -346,12 +346,15 @@ na_pivot_dump( const NAPivot *pivot )
GList *it;
int i;
- g_debug( "%s: consumers=%p (%d elts)", thisfn, ( void * ) pivot->private->consumers, g_slist_length( pivot->private->consumers ));
- g_debug( "%s: providers=%p (%d elts)", thisfn, ( void * ) pivot->private->providers, g_slist_length( pivot->private->providers ));
- g_debug( "%s: tree=%p (%d elts)", thisfn, ( void * ) pivot->private->tree, g_list_length( pivot->private->tree ));
+ if( !pivot->private->dispose_has_run ){
- for( it = pivot->private->tree, i = 0 ; it ; it = it->next ){
- g_debug( "%s: [%d]: %p", thisfn, i++, it->data );
+ g_debug( "%s: consumers=%p (%d elts)", thisfn, ( void * ) pivot->private->consumers, g_slist_length( pivot->private->consumers ));
+ g_debug( "%s: providers=%p (%d elts)", thisfn, ( void * ) pivot->private->providers, g_slist_length( pivot->private->providers ));
+ g_debug( "%s: tree=%p (%d elts)", thisfn, ( void * ) pivot->private->tree, g_list_length( pivot->private->tree ));
+
+ for( it = pivot->private->tree, i = 0 ; it ; it = it->next ){
+ g_debug( "%s: [%d]: %p", thisfn, i++, it->data );
+ }
}
}
@@ -377,11 +380,13 @@ na_pivot_get_providers( const NAPivot *pivot, GType type )
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
- g_return_val_if_fail( !pivot->private->dispose_has_run, NULL );
- for( ip = pivot->private->providers ; ip ; ip = ip->next ){
- if( G_TYPE_CHECK_INSTANCE_TYPE( G_OBJECT( ip->data ), type )){
- list = g_slist_prepend( list, g_object_ref( ip->data ));
+ if( !pivot->private->dispose_has_run ){
+
+ for( ip = pivot->private->providers ; ip ; ip = ip->next ){
+ if( G_TYPE_CHECK_INSTANCE_TYPE( G_OBJECT( ip->data ), type )){
+ list = g_slist_prepend( list, g_object_ref( ip->data ));
+ }
}
}
@@ -413,10 +418,15 @@ na_pivot_free_providers( GSList *providers )
GList *
na_pivot_get_items( const NAPivot *pivot )
{
+ GList *tree = NULL;
+
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
- g_return_val_if_fail( !pivot->private->dispose_has_run, NULL );
- return( pivot->private->tree );
+ if( !pivot->private->dispose_has_run ){
+ tree = pivot->private->tree;
+ }
+
+ return( tree );
}
/**
@@ -429,11 +439,13 @@ void
na_pivot_reload_items( NAPivot *pivot )
{
g_return_if_fail( NA_IS_PIVOT( pivot ));
- g_return_if_fail( !pivot->private->dispose_has_run );
- na_object_free_items( pivot->private->tree );
+ if( !pivot->private->dispose_has_run ){
- pivot->private->tree = na_iio_provider_get_items_tree( pivot );
+ na_object_free_items( pivot->private->tree );
+
+ pivot->private->tree = na_iio_provider_get_items_tree( pivot );
+ }
}
/**
@@ -450,10 +462,11 @@ void
na_pivot_add_item( NAPivot *pivot, const NAObject *item )
{
g_return_if_fail( NA_IS_PIVOT( pivot ));
- g_return_if_fail( !pivot->private->dispose_has_run );
g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
- pivot->private->tree = g_list_append( pivot->private->tree, ( gpointer ) item );
+ if( !pivot->private->dispose_has_run ){
+ pivot->private->tree = g_list_append( pivot->private->tree, ( gpointer ) item );
+ }
}
/**
@@ -471,17 +484,22 @@ NAObject *
na_pivot_get_item( const NAPivot *pivot, const gchar *uuid )
{
uuid_t uuid_bin;
+ NAObject *object = NULL;
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
- g_return_val_if_fail( !pivot->private->dispose_has_run, NULL );
- if( !uuid || !strlen( uuid )){
- return( NULL );
- }
+ if( !pivot->private->dispose_has_run ){
- uuid_parse( uuid, uuid_bin );
+ if( !uuid || !strlen( uuid )){
+ return( NULL );
+ }
+
+ uuid_parse( uuid, uuid_bin );
+
+ object = get_item_from_tree( pivot, pivot->private->tree, uuid_bin );
+ }
- return( get_item_from_tree( pivot, pivot->private->tree, uuid_bin ));
+ return( object );
}
/**
@@ -504,12 +522,14 @@ na_pivot_remove_item( NAPivot *pivot, NAObject *item )
( void * ) item, G_OBJECT_TYPE_NAME( item ));
g_return_if_fail( NA_IS_PIVOT( pivot ));
- g_return_if_fail( !pivot->private->dispose_has_run );
- pivot->private->tree = g_list_remove( pivot->private->tree, ( gconstpointer ) item );
+ if( !pivot->private->dispose_has_run ){
+
+ pivot->private->tree = g_list_remove( pivot->private->tree, ( gconstpointer ) item );
- if( NA_IS_OBJECT( item )){
- g_object_unref( item );
+ if( NA_IS_OBJECT( item )){
+ g_object_unref( item );
+ }
}
}
@@ -527,12 +547,17 @@ na_pivot_remove_item( NAPivot *pivot, NAObject *item )
guint
na_pivot_delete_item( const NAPivot *pivot, const NAObject *item, gchar **message )
{
+ guint ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
+
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- g_return_val_if_fail( !pivot->private->dispose_has_run, NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( message, NA_IIO_PROVIDER_PROGRAM_ERROR );
- return( na_iio_provider_delete_item( pivot, item, message ));
+ if( !pivot->private->dispose_has_run ){
+ ret = na_iio_provider_delete_item( pivot, item, message );
+ }
+
+ return( ret );
}
/**
@@ -549,12 +574,17 @@ na_pivot_delete_item( const NAPivot *pivot, const NAObject *item, gchar **messag
guint
na_pivot_write_item( const NAPivot *pivot, NAObject *item, gchar **message )
{
+ guint ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
+
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- g_return_val_if_fail( !pivot->private->dispose_has_run, NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( message, NA_IIO_PROVIDER_PROGRAM_ERROR );
- return( na_iio_provider_write_item( pivot, item, message ));
+ if( !pivot->private->dispose_has_run ){
+ ret = na_iio_provider_write_item( pivot, item, message );
+ }
+
+ return( ret );
}
/**
@@ -573,10 +603,11 @@ na_pivot_register_consumer( NAPivot *pivot, const NAIPivotConsumer *consumer )
g_debug( "%s: pivot=%p, consumer=%p", thisfn, ( void * ) pivot, ( void * ) consumer );
g_return_if_fail( NA_IS_PIVOT( pivot ));
- g_return_if_fail( !pivot->private->dispose_has_run );
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( consumer ));
- pivot->private->consumers = g_slist_prepend( pivot->private->consumers, ( gpointer ) consumer );
+ if( !pivot->private->dispose_has_run ){
+ pivot->private->consumers = g_slist_prepend( pivot->private->consumers, ( gpointer ) consumer );
+ }
}
/**
@@ -588,10 +619,15 @@ na_pivot_register_consumer( NAPivot *pivot, const NAIPivotConsumer *consumer )
gboolean
na_pivot_get_automatic_reload( const NAPivot *pivot )
{
+ gboolean auto_reload = FALSE;
+
g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
- g_return_val_if_fail( !pivot->private->dispose_has_run, FALSE );
- return( pivot->private->automatic_reload );
+ if( !pivot->private->dispose_has_run ){
+ auto_reload = pivot->private->automatic_reload;
+ }
+
+ return( auto_reload );
}
/**
@@ -612,9 +648,10 @@ void
na_pivot_set_automatic_reload( NAPivot *pivot, gboolean reload )
{
g_return_if_fail( NA_IS_PIVOT( pivot ));
- g_return_if_fail( !pivot->private->dispose_has_run );
- pivot->private->automatic_reload = reload;
+ if( !pivot->private->dispose_has_run ){
+ pivot->private->automatic_reload = reload;
+ }
}
static NAObject *
@@ -760,7 +797,10 @@ time_val_diff( const GTimeVal *recent, const GTimeVal *old )
}
/**
- * Free a NAPivotValue structure and its content.
+ * na_pivot_free_notify:
+ * @npn: a #NAPivotNotify structure.
+ *
+ * Frees a #NAPivotNotify structure and its content.
*/
void
na_pivot_free_notify( NAPivotNotify *npn )
diff --git a/src/common/na-utils.c b/src/common/na-utils.c
index 6480fd6..a9b055c 100644
--- a/src/common/na-utils.c
+++ b/src/common/na-utils.c
@@ -39,13 +39,13 @@
#include "na-utils.h"
/**
- * Search for a string in a string list.
- *
+ * na_utils_find_in_list:
* @list: the GSList of strings to be searched.
- *
* @str: the searched string.
*
- * Returns TRUE if the string has been found in list.
+ * Search for a string in a string list.
+ *
+ * Returns: %TRUE if the string has been found in list.
*/
gboolean
na_utils_find_in_list( GSList *list, const gchar *str )
@@ -63,13 +63,13 @@ na_utils_find_in_list( GSList *list, const gchar *str )
}
/**
- * Compare two string lists.
- *
+ * na_utils_string_lists_are_equal:
* @first: a GSList of strings.
- *
* @second: another GSList of strings to be compared with @first.
*
- * Returns TRUE if the two lists have same content.
+ * Compare two string lists, without regards to the order.
+ *
+ * Returns: %TRUE if the two lists have same content.
*/
gboolean
na_utils_string_lists_are_equal( GSList *first, GSList *second )
@@ -94,9 +94,12 @@ na_utils_string_lists_are_equal( GSList *first, GSList *second )
}
/**
- * Duplicates a GSList of strings.
- *
+ * na_utils_duplicate_string_list:
* @list: the GSList to be duplicated.
+ *
+ * Returns: a #GSList of strings.
+ *
+ * The returned list should be na_utils_free_string_list() by the caller.
*/
GSList *
na_utils_duplicate_string_list( GSList *list )
@@ -111,9 +114,10 @@ na_utils_duplicate_string_list( GSList *list )
}
/**
- * Frees a GSList of strings.
- *
+ * na_utils_free_string_list:
* @list: the GSList to be freed.
+ *
+ * Frees a GSList of strings.
*/
void
na_utils_free_string_list( GSList *list )
@@ -126,11 +130,13 @@ na_utils_free_string_list( GSList *list )
}
/**
- * Removes a string from a GSList of strings.
- *
+ * na_utils_remove_ascii_from_string_list:
* @list: the GSList to be updated.
- *
* @text: string to remove.
+ *
+ * Removes a string from a GSList of strings.
+ *
+ * Returns the new list after update.
*/
GSList *
na_utils_remove_ascii_from_string_list( GSList *list, const gchar *text )
@@ -147,8 +153,14 @@ na_utils_remove_ascii_from_string_list( GSList *list, const gchar *text )
}
/**
+ * na_utils_string_list_to_text:
+ * @strlist: a list of strings.
+ *
* Concatenates a string list to a semi-colon-separated text
* suitable for an entry in the user interface
+ *
+ * Returns: a newly allocated string, which should be g_free() by the
+ * caller.
*/
gchar *
na_utils_string_list_to_text( GSList *strlist )
@@ -172,8 +184,13 @@ na_utils_string_list_to_text( GSList *strlist )
}
/**
- * Extracts a list of strings from a semi-colon-separated text
+ * na_utils_text_to_string_list:
+ * @text: a semi-colon-separated string.
+ *
+ * Returns: a list of strings from a semi-colon-separated text
* (entry text in the user interface).
+ *
+ * The returned list should be na_utils_free_string_list() by the caller.
*/
GSList *
na_utils_text_to_string_list( const gchar *text )
@@ -204,6 +221,12 @@ na_utils_text_to_string_list( const gchar *text )
return( strlist );
}
+/**
+ * na_utils_dump_string_list:
+ * @list: a list of strings.
+ *
+ * Dumps the content of a list of strings.
+ */
void
na_utils_dump_string_list( GSList *list )
{
@@ -219,8 +242,13 @@ na_utils_dump_string_list( GSList *list )
}
/**
+ * na_utils_gslist_to_schema:
+ * @list: a list of strings.
+ *
* Converts a list of strings to a comma-separated list of strings,
* enclosed by brackets (dump format, GConf export format).
+ *
+ * Returns: a newly allocated string which should be g_free() by the caller.
*/
gchar *
na_utils_gslist_to_schema( GSList *list )
@@ -248,8 +276,14 @@ na_utils_gslist_to_schema( GSList *list )
}
/**
+ * na_utils_schema_to_gslist:
+ * @value: a string of the form [xxx,yyy,...] as read from GConf.
+ *
* Converts a string representing a list of strings in a GConf format
* to a list of strings.
+ *
+ * Returns: a newly allocated list of strings, which should be
+ * na_utils_free_string_list() by the caller.
*/
GSList *
na_utils_schema_to_gslist( const gchar *value )
@@ -295,7 +329,12 @@ na_utils_schema_to_gslist( const gchar *value )
}
/**
+ * na_utils_boolean_to_schema:
+ * @b: a boolean to be written.
+ *
* Converts a boolean to the suitable string for a GConf schema
+ *
+ * Returns: a newly allocated string which should be g_free() by the caller.
*/
gchar *
na_utils_boolean_to_schema( gboolean b )
@@ -305,8 +344,17 @@ na_utils_boolean_to_schema( gboolean b )
}
/**
- * Converts a string to a boolean
- * Not case sensitive, accepts abbreviations
+ * na_utils_schema_to_boolean:
+ * @value: a string which should contains a boolean value.
+ * @default_value: the default value to be used.
+ *
+ * Converts a string to a boolean.
+ *
+ * The conversion is not case sensitive, and accepts abbreviations.
+ * The default value is used if we cannot parse the provided string.
+ *
+ * Returns: the boolean.
+ *
*/
gboolean
na_utils_schema_to_boolean( const gchar *value, gboolean default_value )
@@ -324,8 +372,12 @@ na_utils_schema_to_boolean( const gchar *value, gboolean default_value )
}
/**
- * extract the last part of a full path
- * returns a newly allocated string which must be g_free() by the caller
+ * na_utils_path_extract_last_dir:
+ * @path: a full path.
+ *
+ * Extracts the last part of a full path.
+ *
+ * Returns: a newly allocated string which should be g_free() by the caller.
*/
gchar *
na_utils_path_extract_last_dir( const gchar *path )
@@ -338,7 +390,14 @@ na_utils_path_extract_last_dir( const gchar *path )
}
/**
- * Concatenates a gchar **list of strings to a GString.
+ * na_utils_gstring_joinv:
+ * @start: a prefix to be written at the beginning of the output string.
+ * @separator: a string to be used as separator.
+ * @list: the list of strings to be concatenated.
+ *
+ * Concatenates a gchar **list of strings to a new string.
+ *
+ * Returns: a newly allocated string which should be g_free() by the caller.
*/
gchar *
na_utils_gstring_joinv( const gchar *start, const gchar *separator, gchar **list )
@@ -366,6 +425,14 @@ na_utils_gstring_joinv( const gchar *start, const gchar *separator, gchar **list
return( g_string_free( tmp_string, FALSE ));
}
+/**
+ * na_utils_remove_last_level_from_path:
+ * @path: a full path.
+ *
+ * Removes last level from path (mostly a 'dirname').
+ *
+ * Returns: a newly allocated string which should be g_free() by the caller.
+ */
gchar *
na_utils_remove_last_level_from_path( const gchar *path )
{
@@ -395,6 +462,18 @@ na_utils_remove_last_level_from_path( const gchar *path )
return( new_path );
}
+/**
+ * na_utils_is_writable_dir:
+ * @uri: an uri which points to a directory.
+ *
+ * Returns: %TRUE if the directory is writable, %FALSE else.
+ *
+ * Please note that this type of test is subject to race conditions,
+ * as the directory may become unwritable after a successfull test,
+ * but before the caller has been able to actually write into it.
+ *
+ * There is no "super-test". Just try...
+ */
gboolean
na_utils_is_writable_dir( const gchar *uri )
{
@@ -437,6 +516,14 @@ na_utils_is_writable_dir( const gchar *uri )
return( writable );
}
+/**
+ * na_utils_exist_file:
+ * @uri: an uri which points to a file.
+ *
+ * Returns: %TRUE if the specified file exists, %FALSE else.
+ *
+ * Race condition: cf. na_utils_is_writable_dir() comment.
+ */
gboolean
na_utils_exist_file( const gchar *uri )
{
diff --git a/src/common/na-xml-writer.c b/src/common/na-xml-writer.c
index dd82f25..c94c7cd 100644
--- a/src/common/na-xml-writer.c
+++ b/src/common/na-xml-writer.c
@@ -59,10 +59,10 @@ struct NAXMLWriterPrivate {
/* instance properties
*/
enum {
- PROP_GCONF_WRITER_UUID = 1
+ XML_WRITER_PROP_UUID_ID = 1
};
-#define PROP_GCONF_WRITER_UUID_STR "gconf-writer-uuid"
+#define XLM_WRITER_PROP_UUID "na-xml-writer-uuid"
static GObjectClass *st_parent_class = NULL;
@@ -165,11 +165,11 @@ class_init( NAXMLWriterClass *klass )
object_class->set_property = instance_set_property;
spec = g_param_spec_string(
- PROP_GCONF_WRITER_UUID_STR,
- PROP_GCONF_WRITER_UUID_STR,
- "UUID of the action", "",
+ XLM_WRITER_PROP_UUID,
+ XLM_WRITER_PROP_UUID,
+ "UUID of the action for which we invoke this XMLWriter", "",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, PROP_GCONF_WRITER_UUID, spec );
+ g_object_class_install_property( object_class, XML_WRITER_PROP_UUID_ID, spec );
klass->private = g_new0( NAXMLWriterClassPrivate, 1 );
}
@@ -181,7 +181,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
NAXMLWriter *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
- g_assert( NA_IS_XML_WRITER( instance ));
+ g_return_if_fail( NA_IS_XML_WRITER( instance ));
self = NA_XML_WRITER( instance );
self->private = g_new0( NAXMLWriterPrivate, 1 );
@@ -194,17 +194,20 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
{
NAXMLWriter *self;
- g_assert( NA_IS_XML_WRITER( object ));
+ g_return_if_fail( NA_IS_XML_WRITER( object ));
self = NA_XML_WRITER( object );
- switch( property_id ){
- case PROP_GCONF_WRITER_UUID:
- g_value_set_string( value, self->private->uuid );
- break;
+ if( !self->private->dispose_has_run ){
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ switch( property_id ){
+ case XML_WRITER_PROP_UUID_ID:
+ g_value_set_string( value, self->private->uuid );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
@@ -213,27 +216,32 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
{
NAXMLWriter *self;
- g_assert( NA_IS_XML_WRITER( object ));
+ g_return_if_fail( NA_IS_XML_WRITER( object ));
self = NA_XML_WRITER( object );
- switch( property_id ){
- case PROP_GCONF_WRITER_UUID:
- g_free( self->private->uuid );
- self->private->uuid = g_value_dup_string( value );
- break;
+ if( !self->private->dispose_has_run ){
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
- break;
+ switch( property_id ){
+ case XML_WRITER_PROP_UUID_ID:
+ g_free( self->private->uuid );
+ self->private->uuid = g_value_dup_string( value );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
}
}
static void
instance_dispose( GObject *object )
{
+ static const gchar *thisfn = "na_xml_writer_instance_dispose";
NAXMLWriter *self;
- g_assert( NA_IS_XML_WRITER( object ));
+ g_debug( "%s: object=%p", thisfn, ( void * ) object );
+ g_return_if_fail( NA_IS_XML_WRITER( object ));
self = NA_XML_WRITER( object );
if( !self->private->dispose_has_run ){
@@ -241,7 +249,9 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
/* chain up to the parent class */
- G_OBJECT_CLASS( st_parent_class )->dispose( object );
+ if( G_OBJECT_CLASS( st_parent_class )->dispose ){
+ G_OBJECT_CLASS( st_parent_class )->dispose( object );
+ }
}
}
@@ -250,7 +260,7 @@ instance_finalize( GObject *object )
{
NAXMLWriter *self;
- g_assert( NA_IS_XML_WRITER( object ));
+ g_return_if_fail( NA_IS_XML_WRITER( object ));
self = NA_XML_WRITER( object );
g_free( self->private->uuid );
@@ -258,7 +268,7 @@ instance_finalize( GObject *object )
g_free( self->private );
/* chain call to parent class */
- if( st_parent_class->finalize ){
+ if( G_OBJECT_CLASS( st_parent_class )->finalize ){
G_OBJECT_CLASS( st_parent_class )->finalize( object );
}
}
@@ -266,7 +276,7 @@ instance_finalize( GObject *object )
static NAXMLWriter *
xml_writer_new( const gchar *uuid )
{
- return( g_object_new( NA_XML_WRITER_TYPE, PROP_GCONF_WRITER_UUID_STR, uuid, NULL ));
+ return( g_object_new( NA_XML_WRITER_TYPE, XLM_WRITER_PROP_UUID, uuid, NULL ));
}
/**
@@ -286,10 +296,12 @@ xml_writer_new( const gchar *uuid )
gchar *
na_xml_writer_export( const NAObjectAction *action, const gchar *folder, gint format, gchar **msg )
{
+ static const gchar *thisfn = "na_xml_writer_export";
gchar *filename = NULL;
gchar *xml_buffer;
- g_assert( action || format == FORMAT_GCONFSCHEMA );
+ g_debug( "%s: action=%p, format=%u", thisfn, ( void * ) action, format );
+ g_return_val_if_fail( action || format == FORMAT_GCONFSCHEMA, NULL );
switch( format ){
case FORMAT_GCONFSCHEMAFILE_V1:
diff --git a/src/common/na-xml-writer.h b/src/common/na-xml-writer.h
index fa2c006..0e6aa63 100644
--- a/src/common/na-xml-writer.h
+++ b/src/common/na-xml-writer.h
@@ -72,11 +72,8 @@ typedef struct {
GType na_xml_writer_get_type( void );
gchar *na_xml_writer_export( const NAObjectAction *action, const gchar *folder, gint format, gchar **msg );
-
gchar *na_xml_writer_get_output_fname( const NAObjectAction *action, const gchar *folder, gint format );
-
gchar *na_xml_writer_get_xml_buffer( const NAObjectAction *action, gint format );
-
void na_xml_writer_output_xml( const gchar *xml, const gchar *filename );
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]