Commit 34be635a authored by Pierre Wieser's avatar Pierre Wieser

Various fixes

Review all the copy machinery, introducing a 'recursive' flag for actions.
Fix the update of the NAPivot tree when removing an item.
Fix the writing of the data to I/O Gconf provider.
parent 6c6f7da2
2009-02-28 Pierre Wieser <pwieser@trychlos.org>
* src/api/na-ifactory-object.h:
* src/core/na-object-item-factory.c:
* src/nact/nact-iactions-list-bis.c:
* src/nact/nact-iactions-list.h:
Fix minor typo.
* src/api/na-object-api.h:
New na_object_copy macro (evaluates as na_object_object_copy).
* src/api/na-object-item.h (na_object_item_copy): Removed function.
* src/api/na-object.h:
* src/core/na-object.c:.
(copy): Add 'recursive' flag.
(iduplicable_copy): Use na_object_copy() macro.
(na_object_object_copy): New function.
* src/core/na-factory-object.c (na_factory_object_copy):
No more delete all NADataBoxed, but update those who already exist.
(write_data_iter): Fix return code.
* src/core/na-iduplicable.c (na_iduplicable_duplicate):
Review the rationale, and ensure that the function is recursive.
* src/core/na-object-action.c
* src/core/na-object-item.c:
* src/core/na-object-menu.c:
* src/core/na-object-profile.c:
(instance_constructed): Removed function.
(ifactory_object_copy): Removed function.
(object_copy): New function, implementation of NAObject::copy.
* src/core/na-pivot.c (instance_dispose): Add debug message.
* src/core/na-updater.c (na_updater_remove_item):
Only update tree if object has no parent.
* src/io-gconf/nagp-gconf-provider.c
(ifactory_provider_iface_init): Address nagp_writer_write_start().
* src/io-gconf/nagp-reader.c (nagp_reader_read_data): Comment debug message.
* src/io-gconf/nagp-writer.c:
* src/io-gconf/nagp-writer.h (nagp_writer_write_start): New function.
Write the type of the NAObjectItem.
* src/nact/nact-iaction-tab.c (on_tab_updatable_selection_changed):
* src/nact/nact-icommand-tab.c (on_tab_updatable_selection_changed):
* src/nact/nact-iconditions-tab.c (on_tab_updatable_selection_changed):
As objects have defaults, no more test for null string.
* src/nact/nact-main-menubar.c
(nact_main_menubar_save_items): Dump after check status.
(save_item): Use new na_object_copy() macro.
* src/nact/nact-window.c (nact_window_save_item):
Remove superfluous dumps.
2009-02-27 Pierre Wieser <pwieser@trychlos.org>
* src/core/na-iduplicable.c (na_iduplicable_check_status):
......
......@@ -165,3 +165,5 @@
- segfaults on reload
- check adding/removing profile on desktop/gconf/xml import/export
- shouldn't be able to copy an action into an action !
......@@ -89,10 +89,9 @@ typedef struct {
* @instance: the target #NAIFactoryObject instance.
* @source: the source #NAIFactoryObject instance.
*
* This function is triggered when copying one instance to another,
* after all copyable elementary dats have been copied themselves.
* The target @instance may take advantage of this call to do some
* particular copy tasks.
* This function is triggered after having copied @source to
* @instance target. This later may take advantage of this call
* to do some particular copy tasks.
*/
void ( *copy ) ( NAIFactoryObject *instance, const NAIFactoryObject *source );
......
......@@ -66,6 +66,7 @@ G_BEGIN_DECLS
/* NAObject
*/
#define na_object_copy( tgt, src, rec ) na_object_object_copy( NA_OBJECT( tgt ), NA_OBJECT( src ), ( rec ))
#define na_object_dump( obj ) na_object_object_dump( NA_OBJECT( obj ))
#define na_object_dump_norec( obj ) na_object_object_dump_norec( NA_OBJECT( obj ))
#define na_object_dump_tree( tree ) na_object_object_dump_tree( tree )
......
......@@ -77,7 +77,6 @@ enum {
GType na_object_item_get_type( void );
void na_object_item_copy ( NAObjectItem *item, const NAObjectItem *source );
gboolean na_object_item_are_equal( const NAObjectItem *a, const NAObjectItem *b );
NAObjectId *na_object_item_get_item ( const NAObjectItem *item, const gchar *id );
......
......@@ -81,6 +81,7 @@ typedef struct {
* copy:
* @target: the #NAObject-derived object which will receive data.
* @source: the #NAObject-derived object which will provide data.
* @recursive: whether children should be recursively copied.
*
* Copies data and properties from @source to @target.
*
......@@ -90,7 +91,7 @@ typedef struct {
* base class up to the most-derived one. Each class has so only to
* take care of dumping its own data.
*/
void ( *copy ) ( NAObject *target, const NAObject *source );
void ( *copy ) ( NAObject *target, const NAObject *source, gboolean recursive );
/**
* are_equal:
......@@ -143,6 +144,8 @@ void na_object_object_reset_origin ( NAObject *object, const NAObject *or
NAObject *na_object_object_ref ( NAObject *object );
void na_object_object_unref( NAObject *object );
void na_object_object_copy ( NAObject *target, const NAObject *source, gboolean recursive );
void na_object_object_dump ( const NAObject *object );
void na_object_object_dump_norec( const NAObject *object );
void na_object_object_dump_tree ( GList *tree );
......
......@@ -265,6 +265,8 @@ na_factory_object_set_defaults( NAIFactoryObject *object )
if( ifactory_object_initialized && !ifactory_object_finalized ){
g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
groups = v_get_groups( object );
if( !groups ){
g_warning( "%s: no NADataGroup found for %s", thisfn, G_OBJECT_TYPE_NAME( object ));
......@@ -349,9 +351,16 @@ na_factory_object_move_boxed( NAIFactoryObject *target, const NAIFactoryObject *
void
na_factory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source )
{
static const gchar *thisfn = "na_factory_object_copy";
GList *src_list, *isrc;
free_data_boxed_list( target );
g_return_if_fail( NA_IS_IFACTORY_OBJECT( target ));
g_return_if_fail( NA_IS_IFACTORY_OBJECT( source ));
g_debug( "%s: target=%p (%s), source=%p (%s)",
thisfn,
( void * ) target, G_OBJECT_TYPE_NAME( target ),
( void * ) source, G_OBJECT_TYPE_NAME( source ));
src_list = g_object_get_data( G_OBJECT( source ), NA_IFACTORY_OBJECT_PROP_DATA );
......@@ -359,11 +368,14 @@ na_factory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source
NADataBoxed *src_boxed = NA_DATA_BOXED( isrc->data );
NADataDef *def = na_data_boxed_get_data_def( src_boxed );
if( def->copyable ){
NADataBoxed *tgt_boxed = na_data_boxed_new( def );
if( def->copyable ){
NADataBoxed *tgt_boxed = data_boxed_from_name( target, def->name );
if( !tgt_boxed ){
tgt_boxed = na_data_boxed_new( def );
attach_boxed_to_object( target, tgt_boxed );
}
na_data_boxed_set_from_boxed( tgt_boxed, src_boxed );
attach_boxed_to_object( target, tgt_boxed );
}
}
......@@ -681,7 +693,7 @@ write_data_iter( const NAIFactoryObject *object, NADataBoxed *boxed, NafoWriteIt
}
/* iter while code is ok */
return( iter->code == NA_IIO_PROVIDER_CODE_OK );
return( iter->code != NA_IIO_PROVIDER_CODE_OK );
}
/**
......
......@@ -234,13 +234,17 @@ na_iduplicable_dump( const NAIDuplicable *object )
* na_iduplicable_duplicate:
* @object: the #NAIDuplicable object to be duplicated.
*
* Exactly duplicates a #NAIDuplicable-implemented object.
* Properties %NA_IDUPLICABLE_PROP_ORIGIN, %PROP_IDUPLICABLE_ISMODIFIED
* and %PROP_IDUPLICABLE_ISVALID are initialized to their default
* values.
* Exactly duplicates a #NAIDuplicable-implemented object, including
* modification and validity status which are copied from @object to
* the duplicated one.
*
* As %PROP_IDUPLICABLE_ISVALID property is set to %TRUE without any
* further check, this suppose that only valid objects are duplicated.
* Though this function is not recursive by itself, it is widely supposed
* everywhere in the program that recursivity is provided but #NAObject
* implementation.
*
* +------------------------------------------------------------------------------+
* | na_object_duplicate (aka na_iduplicable_duplicate) is definitively recursive |
* +------------------------------------------------------------------------------+
*
* Returns: a new #NAIDuplicable.
*/
......
......@@ -71,18 +71,17 @@ static NAObjectItemClass *st_parent_class = NULL;
static GType register_type( void );
static void class_init( NAObjectActionClass *klass );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_constructed( GObject *object );
static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
static void object_copy( NAObject *target, const NAObject *source, gboolean recursive );
static gboolean object_is_valid( const NAObject *object );
static void ifactory_object_iface_init( NAIFactoryObjectInterface *iface );
static guint ifactory_object_get_version( const NAIFactoryObject *instance );
static NADataGroup *ifactory_object_get_groups( const NAIFactoryObject *instance );
static void ifactory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source );
static gboolean ifactory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *b );
static gboolean ifactory_object_is_valid( const NAIFactoryObject *object );
static void ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages );
......@@ -138,10 +137,6 @@ register_type( void )
g_type_add_interface_static( type, NA_IFACTORY_OBJECT_TYPE, &ifactory_object_iface_info );
#if 0
na_factory_object_register_type( type, action_id_groups );
#endif
return( type );
}
......@@ -157,7 +152,6 @@ class_init( NAObjectActionClass *klass )
st_parent_class = g_type_class_peek_parent( klass );
object_class = G_OBJECT_CLASS( klass );
object_class->constructed = instance_constructed;
object_class->set_property = instance_set_property;
object_class->get_property = instance_get_property;
object_class->dispose = instance_dispose;
......@@ -165,7 +159,7 @@ class_init( NAObjectActionClass *klass )
naobject_class = NA_OBJECT_CLASS( klass );
naobject_class->dump = NULL;
naobject_class->copy = NULL;
naobject_class->copy = object_copy;
naobject_class->are_equal = NULL;
naobject_class->is_valid = object_is_valid;
......@@ -190,27 +184,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NAObjectActionPrivate, 1 );
}
static void
instance_constructed( GObject *object )
{
static const gchar *thisfn = "na_object_action_instance_constructed";
NAObjectAction *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
self = NA_OBJECT_ACTION( object );
if( !self->private->dispose_has_run ){
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( object ));
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
G_OBJECT_CLASS( st_parent_class )->constructed( object );
}
}
}
static void
instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
{
......@@ -278,6 +251,19 @@ instance_finalize( GObject *object )
}
}
static void
object_copy( NAObject *target, const NAObject *source, gboolean recursive )
{
g_return_if_fail( NA_IS_OBJECT_ACTION( target ));
g_return_if_fail( NA_IS_OBJECT_ACTION( source ));
if( !NA_OBJECT_ACTION( target )->private->dispose_has_run &&
!NA_OBJECT_ACTION( source )->private->dispose_has_run ){
na_factory_object_copy( NA_IFACTORY_OBJECT( target ), NA_IFACTORY_OBJECT( source ));
}
}
static gboolean
object_is_valid( const NAObject *object )
{
......@@ -295,7 +281,7 @@ ifactory_object_iface_init( NAIFactoryObjectInterface *iface )
iface->get_version = ifactory_object_get_version;
iface->get_groups = ifactory_object_get_groups;
iface->copy = ifactory_object_copy;
iface->copy = NULL;
iface->are_equal = ifactory_object_are_equal;
iface->is_valid = ifactory_object_is_valid;
iface->read_start = NULL;
......@@ -316,12 +302,6 @@ ifactory_object_get_groups( const NAIFactoryObject *instance )
return( action_data_groups );
}
static void
ifactory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source )
{
na_object_item_copy( NA_OBJECT_ITEM( target ), NA_OBJECT_ITEM( source ));
}
static gboolean
ifactory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *b )
{
......@@ -365,6 +345,8 @@ ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider
} else {
g_object_unref( parms.profile );
}
na_factory_object_set_defaults( instance );
}
static guint
......@@ -511,7 +493,6 @@ na_object_action_new_with_profile( void )
NAObjectProfile *profile;
action = na_object_action_new();
profile = na_object_profile_new();
na_object_action_attach_profile( action, profile );
......@@ -536,6 +517,7 @@ na_object_action_new_with_defaults( void )
na_object_set_new_id( action, NULL );
na_object_set_label( action, NEW_NAUTILUS_ACTION );
na_object_set_toolbar_label( action, NEW_NAUTILUS_ACTION );
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( action ));
profile = na_object_profile_new_with_defaults();
na_object_action_attach_profile( action, profile );
......
......@@ -100,9 +100,9 @@ NADataDef data_def_item [] = {
NAFD_TYPE_POINTER,
NULL,
FALSE, /* not copyable */
FALSE, /* comparable */
FALSE,
FALSE,
FALSE, /* not comparable */
FALSE, /* not mandatory */
FALSE, /* not localized */
NULL,
FALSE },
......
......@@ -67,8 +67,11 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
static void object_copy( NAObject*target, const NAObject *source, gboolean recursive );
static gchar *object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent );
static void copy_children( NAObjectItem *target, const NAObjectItem *source );
static void rebuild_children_slist( NAObjectItem *item );
GType
......@@ -126,7 +129,7 @@ class_init( NAObjectItemClass *klass )
naobject_class = NA_OBJECT_CLASS( klass );
naobject_class->dump = NULL;
naobject_class->copy = NULL;
naobject_class->copy = object_copy;
naobject_class->are_equal = NULL;
naobject_class->is_valid = NULL;
......@@ -197,6 +200,21 @@ instance_finalize( GObject *object )
}
}
static void
object_copy( NAObject *target, const NAObject *source, gboolean recursive )
{
g_return_if_fail( NA_IS_OBJECT_ITEM( target ));
g_return_if_fail( NA_IS_OBJECT_ITEM( source ));
if( !NA_OBJECT_ITEM( target )->private->dispose_has_run &&
!NA_OBJECT_ITEM( source )->private->dispose_has_run ){
if( recursive ){
copy_children( NA_OBJECT_ITEM( target ), NA_OBJECT_ITEM( source ));
}
}
}
/*
* new_parent is not relevant when allocating a new UUID for an action
* or a menu ; it may safely be left as NULL though there is no gain to
......@@ -230,47 +248,6 @@ object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent )
return( new_uuid );
}
/**
* na_object_item_copy:
* @item: the target #NAObjectItem instance.
* @source: the source #NAObjectItem instance.
* @recursive: whether the children should be recursively copied.
*
* Copies data from @source to @item.
*
* This function participates to the #na_iduplicable_duplicate() stack,
* and is triggered after all copyable elementary data (in #NAIFactoryObject
* sense) have already been copied themselves.
*/
void
na_object_item_copy( NAObjectItem *item, const NAObjectItem *source )
{
static const gchar *thisfn = "na_object_item_copy";
GList *tgt_children, *src_children, *ic;
NAObject *dup;
tgt_children = na_object_get_items( item );
g_debug( "%s: tgt_children=%p (count=%d)", thisfn, ( void * ) tgt_children, g_list_length( tgt_children ));
if( tgt_children ){
g_warning( "%s: target %s has already %d children",
thisfn, G_OBJECT_TYPE_NAME( item ), g_list_length( tgt_children ));
na_object_unref_items( tgt_children );
tgt_children = NULL;
}
src_children = na_object_get_items( source );
for( ic = src_children ; ic ; ic = ic->next ){
dup = ( NAObject * ) na_object_duplicate( ic->data );
na_object_set_parent( dup, item );
tgt_children = g_list_prepend( tgt_children, dup );
}
tgt_children = g_list_reverse( tgt_children );
na_object_set_items( item, tgt_children );
}
/**
* na_object_item_are_equal:
* @a: the first (original) #NAObjectItem instance.
......@@ -316,6 +293,14 @@ na_object_item_are_equal( const NAObjectItem *a, const NAObjectItem *b )
if( !equal ){
g_debug( "%s: %p (%s) not equal as g_list_length not equal",
thisfn, ( void * ) b, G_OBJECT_TYPE_NAME( b ));
g_debug( "a=%p children_count=%u", ( void * ) a, g_list_length( a_children ));
for( it = a_children ; it ; it = it->next ){
g_debug( "a_child=%p", ( void * ) it->data );
}
g_debug( "b=%p children_count=%u", ( void * ) b, g_list_length( b_children ));
for( it = b_children ; it ; it = it->next ){
g_debug( "b_child=%p", ( void * ) it->data );
}
}
}
......@@ -576,7 +561,12 @@ na_object_item_remove_item( NAObjectItem *item, const NAObjectId *object )
if( !item->private->dispose_has_run ){
children = na_object_get_items( item );
if( children ){
g_debug( "na_object_item_remove_item: removing %p (%s) from %p (%s)",
( void * ) object, G_OBJECT_TYPE_NAME( object ),
( void * ) item, G_OBJECT_TYPE_NAME( item ));
children = g_list_remove( children, ( gconstpointer ) object );
na_object_set_items( item, children );
}
......@@ -697,6 +687,33 @@ na_object_item_factory_write_start( NAObjectItem *item )
rebuild_children_slist( item );
}
static void
copy_children( NAObjectItem *target, const NAObjectItem *source )
{
static const gchar *thisfn = "na_object_item_copy_children";
GList *tgt_children, *src_children, *ic;
NAObject *dup;
tgt_children = na_object_get_items( target );
g_debug( "%s: tgt_children=%p (count=%d)", thisfn, ( void * ) tgt_children, g_list_length( tgt_children ));
if( tgt_children ){
na_object_unref_items( tgt_children );
tgt_children = NULL;
}
src_children = na_object_get_items( source );
for( ic = src_children ; ic ; ic = ic->next ){
dup = ( NAObject * ) na_object_duplicate( ic->data );
na_object_set_parent( dup, target );
tgt_children = g_list_prepend( tgt_children, dup );
}
tgt_children = g_list_reverse( tgt_children );
na_object_set_items( target, tgt_children );
}
static void
rebuild_children_slist( NAObjectItem *item )
{
......@@ -718,7 +735,6 @@ rebuild_children_slist( NAObjectItem *item )
na_object_set_items_slist( item, slist );
na_core_utils_slist_dump( slist );
na_core_utils_slist_free( slist );
}
}
......@@ -64,18 +64,17 @@ static NAObjectItemClass *st_parent_class = NULL;
static GType register_type( void );
static void class_init( NAObjectMenuClass *klass );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_constructed( GObject *object );
static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
static void object_copy( NAObject *target, const NAObject *source, gboolean recursive );
static gboolean object_is_valid( const NAObject *object );
static void ifactory_object_iface_init( NAIFactoryObjectInterface *iface );
static guint ifactory_object_get_version( const NAIFactoryObject *instance );
static NADataGroup *ifactory_object_get_groups( const NAIFactoryObject *instance );
static void ifactory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source );
static gboolean ifactory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *b );
static gboolean ifactory_object_is_valid( const NAIFactoryObject *object );
static void ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages );
......@@ -143,7 +142,6 @@ class_init( NAObjectMenuClass *klass )
st_parent_class = g_type_class_peek_parent( klass );
object_class = G_OBJECT_CLASS( klass );
object_class->constructed = instance_constructed;
object_class->set_property = instance_set_property;
object_class->get_property = instance_get_property;
object_class->dispose = instance_dispose;
......@@ -151,7 +149,7 @@ class_init( NAObjectMenuClass *klass )
naobject_class = NA_OBJECT_CLASS( klass );
naobject_class->dump = NULL;
naobject_class->copy = NULL;
naobject_class->copy = object_copy;
naobject_class->are_equal = NULL;
naobject_class->is_valid = object_is_valid;
......@@ -176,27 +174,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NAObjectMenuPrivate, 1 );
}
static void
instance_constructed( GObject *object )
{
static const gchar *thisfn = "na_object_menu_instance_constructed";
NAObjectMenu *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
g_return_if_fail( NA_IS_OBJECT_MENU( object ));
self = NA_OBJECT_MENU( object );
if( !self->private->dispose_has_run ){
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( object ));
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
G_OBJECT_CLASS( st_parent_class )->constructed( object );
}
}
}
static void
instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
{
......@@ -264,6 +241,19 @@ instance_finalize( GObject *object )
}
}
static void
object_copy( NAObject *target, const NAObject *source, gboolean recursive )
{
g_return_if_fail( NA_IS_OBJECT_MENU( target ));
g_return_if_fail( NA_IS_OBJECT_MENU( source ));
if( !NA_OBJECT_MENU( target )->private->dispose_has_run &&
!NA_OBJECT_MENU( source )->private->dispose_has_run ){
na_factory_object_copy( NA_IFACTORY_OBJECT( target ), NA_IFACTORY_OBJECT( source ));
}
}
static gboolean
object_is_valid( const NAObject *object )
{
......@@ -281,7 +271,7 @@ ifactory_object_iface_init( NAIFactoryObjectInterface *iface )
iface->get_version = ifactory_object_get_version;
iface->get_groups = ifactory_object_get_groups;
iface->copy = ifactory_object_copy;
iface->copy = NULL;
iface->are_equal = ifactory_object_are_equal;
iface->is_valid = ifactory_object_is_valid;
iface->read_start = NULL;
......@@ -302,12 +292,6 @@ ifactory_object_get_groups( const NAIFactoryObject *instance )
return( menu_data_groups );
}
static void
ifactory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source )
{
na_object_item_copy( NA_OBJECT_ITEM( target ), NA_OBJECT_ITEM( source ));
}
static gboolean
ifactory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *b )
{
......@@ -325,7 +309,7 @@ ifactory_object_is_valid( const NAIFactoryObject *object )
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
na_factory_object_set_defaults( instance );
}
static guint
......@@ -422,9 +406,9 @@ NAObjectMenu *
na_object_menu_new_with_defaults( void )
{
NAObjectMenu *menu = na_object_menu_new();
na_object_set_new_id( menu, NULL );
na_object_set_label( menu, NEW_NAUTILUS_MENU );
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( menu ));
return( menu );
}
......@@ -68,12 +68,12 @@ static NAObjectIdClass *st_parent_class = NULL;
static GType register_type( void );
static void class_init( NAObjectProfileClass *klass );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_constructed( GObject *object );
static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
static void object_copy( NAObject *target, const NAObject *source, gboolean recursive );
static gboolean object_is_valid( const NAObject *object );
static void ifactory_object_iface_init( NAIFactoryObjectInterface *iface );
......@@ -165,7 +165,6 @@ class_init( NAObjectProfileClass *klass )
st_parent_class = g_type_class_peek_parent( klass );
object_class = G_OBJECT_CLASS( klass );
object_class->constructed = instance_constructed;
object_class->set_property = instance_set_property;
object_class->get_property = instance_get_property;
object_class->dispose = instance_dispose;
......@@ -173,7 +172,7 @@ class_init( NAObjectProfileClass *klass )
naobject_class = NA_OBJECT_CLASS( klass );
naobject_class->dump = NULL;
naobject_class->copy = NULL;
naobject_class->copy = object_copy;
naobject_class->are_equal = NULL;
naobject_class->is_valid = object_is_valid;
......@@ -203,27 +202,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->dispose_has_run = FALSE;
}
static void
instance_constructed( GObject *object )
{
static const gchar *thisfn = "na_object_profile_instance_constructed";
NAObjectProfile *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
self = NA_OBJECT_PROFILE( object );
if( !self->private->dispose_has_run ){
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( object ));
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
G_OBJECT_CLASS( st_parent_class )->constructed( object );
}
}
}
static void
instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
{
......@@ -291,6 +269,19 @@ instance_finalize( GObject *object )
}
}
static void
object_copy( NAObject *target, const NAObject *source, gboolean recursive )
{
g_return_if_fail( NA_IS_OBJECT_PROFILE( target ));
g_return_if_fail( NA_IS_OBJECT_PROFILE( source ));
if( !NA_OBJECT_PROFILE( target )->private->dispose_has_run &&
!NA_OBJECT_PROFILE( source )->private->dispose_has_run ){
na_factory_object_copy( NA_IFACTORY_OBJECT( target ), NA_IFACTORY_OBJECT( source ));
}
}
static gboolean
object_is_valid( const NAObject *object )
{
......@@ -345,7 +336,7 @@ ifactory_object_is_valid( const NAIFactoryObject *object )
static void
ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider *reader, void *reader_data, GSList **messages )
{
na_factory_object_set_defaults( instance );
}
static guint
......@@ -552,9 +543,10 @@ NAObjectProfile *
na_object_profile_new_with_defaults( void )
{
NAObjectProfile *profile = na_object_profile_new();
na_object_set_id( profile, "profile-zero" );
/* i18n: label for the default profile */
na_object_set_label( profile, _( "Default profile" ));
na_factory_object_set_defaults( NA_IFACTORY_OBJECT( profile ));
return( profile );
}
......
......@@ -48,7 +48,7 @@ struct NAObjectPrivate {