Commit f6d0a9dd authored by Pierre Wieser's avatar Pierre Wieser

New NAIDuplicable and NactIMenubar interfaces for the new UI

parent ec3923bf
2009-07-25 Pierre Wieser <pwieser@trychlos.org>
* src/common/na-action-class.h:
* src/common/na-action-profile-class.h:
New files to properly handle forward declarations.
* src/common/na-ipivot-container.c:
* src/common/na-ipivot-container.h:
Renamed as na-ipivot-consumer.{c,h}.
* src/common/na-iduplicable.c:
* src/common/na-iduplicable.h:
New NAIDuplicable interface implemented by NAObject class.
* src/nact/nact-imenubar.c:
* src/nact/nact-imenubar.h:
New NactIMenubar interface implemented by NactMainWindow class.
2009-07-19 Pierre Wieser <pwieser@trychlos.org>
* src/nact/nact-action-conditions-editor.c:
......
......@@ -29,6 +29,6 @@
SUBDIRS = \
common \
nact \
$(OPTIONAL_SUBDIR) \
plugin \
$(OPTIONAL_SUBDIR) \
$(NULL)
......@@ -37,15 +37,19 @@ AM_CPPFLAGS += \
libnact_la_SOURCES = \
na-action.c \
na-action.h \
na-action-class.h \
na-action-profile.c \
na-action-profile.h \
na-action-profile-class.h \
na-gconf.c \
na-gconf.h \
na-gconf-keys.h \
na-iduplicable.c \
na-iduplicable.h \
na-iio-provider.c \
na-iio-provider.h \
na-ipivot-container.c \
na-ipivot-container.h \
na-ipivot-consumer.c \
na-ipivot-consumer.h \
na-object.c \
na-object.h \
na-pivot.c \
......
......@@ -28,43 +28,42 @@
* ... and many others (see AUTHORS)
*/
#ifndef __NA_IPIVOT_CONTAINER_H__
#define __NA_IPIVOT_CONTAINER_H__
#ifndef __NA_ACTION_CLASS_H__
#define __NA_ACTION_CLASS_H__
/*
* NAIPivotContainer interface definition.
*
* This interface should be implemented by all classes which embed a
* NAPivot object, in order to receive modification notification
* messages.
/**
* SECTION: na_action
*/
#include <glib-object.h>
#include "na-object.h"
G_BEGIN_DECLS
#define NA_IPIVOT_CONTAINER_TYPE ( na_ipivot_container_get_type())
#define NA_IPIVOT_CONTAINER( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_IPIVOT_CONTAINER_TYPE, NAIPivotContainer ))
#define NA_IS_IPIVOT_CONTAINER( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_IPIVOT_CONTAINER_TYPE ))
#define NA_IPIVOT_CONTAINER_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_IPIVOT_CONTAINER_TYPE, NAIPivotContainerInterface ))
#define NA_ACTION_TYPE ( na_action_get_type())
#define NA_ACTION( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_ACTION_TYPE, NAAction ))
#define NA_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_ACTION_TYPE, NAActionClass ))
#define NA_IS_ACTION( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_ACTION_TYPE ))
#define NA_IS_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_ACTION_TYPE ))
#define NA_ACTION_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_ACTION_TYPE, NAActionClass ))
typedef struct NAIPivotContainer NAIPivotContainer;
typedef struct NAIPivotContainerInterfacePrivate NAIPivotContainerInterfacePrivate;
typedef struct NAActionPrivate NAActionPrivate;
typedef struct {
GTypeInterface parent;
NAIPivotContainerInterfacePrivate *private;
/* api */
void ( *on_actions_changed )( NAIPivotContainer *instance, gpointer user_data );
NAObject parent;
NAActionPrivate *private;
}
NAIPivotContainerInterface;
NAAction;
GType na_ipivot_container_get_type( void );
typedef struct NAActionClassPrivate NAActionClassPrivate;
typedef struct {
NAObjectClass parent;
NAActionClassPrivate *private;
}
NAActionClass;
void na_ipivot_container_notify( NAIPivotContainer *instance );
GType na_action_get_type( void );
G_END_DECLS
#endif /* __NA_IPIVOT_CONTAINER_H__ */
#endif /* __NA_ACTION_CLASS_H__ */
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifndef __NA_ACTION_PROFILE_CLASS_H__
#define __NA_ACTION_PROFILE_CLASS_H__
/**
* SECTION: na_action_profile
*/
#include "na-object.h"
G_BEGIN_DECLS
#define NA_ACTION_PROFILE_TYPE ( na_action_profile_get_type())
#define NA_ACTION_PROFILE( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_ACTION_PROFILE_TYPE, NAActionProfile ))
#define NA_ACTION_PROFILE_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_ACTION_PROFILE_TYPE, NAActionProfileClass ))
#define NA_IS_ACTION_PROFILE( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_ACTION_PROFILE_TYPE ))
#define NA_IS_ACTION_PROFILE_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_ACTION_PROFILE_TYPE ))
#define NA_ACTION_PROFILE_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_ACTION_PROFILE_TYPE, NAActionProfileClass ))
typedef struct NAActionProfilePrivate NAActionProfilePrivate;
typedef struct {
NAObject parent;
NAActionProfilePrivate *private;
}
NAActionProfile;
typedef struct NAActionProfileClassPrivate NAActionProfileClassPrivate;
typedef struct {
NAObjectClass parent;
NAActionProfileClassPrivate *private;
}
NAActionProfileClass;
GType na_action_profile_get_type( void );
G_END_DECLS
#endif /* __NA_ACTION_PROFILE_CLASS_H__ */
This diff is collapsed.
......@@ -31,71 +31,32 @@
#ifndef __NA_ACTION_PROFILE_H__
#define __NA_ACTION_PROFILE_H__
/*
* NactActionProfile class definition.
/**
* SECTION: na_action_profile
* @short_description: #NAActionProfile class definition.
* @include: common/na-action-profile.h
*
* This is a companion class of NactAction. It embeds the profile
* This is a companion class of NAAction. It embeds the profile
* definition of an action.
*
* As NactAction itself, NactActionProfile class is derived from
* NAObject which takes care of i/o.
* As NAAction itself, NAActionProfile class is derived from
* NAObject class, which takes care of IDuplicable interface management.
*/
#include "na-object.h"
#include "na-action-class.h"
#include "na-action-profile-class.h"
G_BEGIN_DECLS
#define NA_ACTION_PROFILE_TYPE ( na_action_profile_get_type())
#define NA_ACTION_PROFILE( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_ACTION_PROFILE_TYPE, NAActionProfile ))
#define NA_ACTION_PROFILE_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_ACTION_PROFILE_TYPE, NAActionProfileClass ))
#define NA_IS_ACTION_PROFILE( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_ACTION_PROFILE_TYPE ))
#define NA_IS_ACTION_PROFILE_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_ACTION_PROFILE_TYPE ))
#define NA_ACTION_PROFILE_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_ACTION_PROFILE_TYPE, NAActionProfileClass ))
typedef struct NAActionProfilePrivate NAActionProfilePrivate;
typedef struct {
NAObject parent;
NAActionProfilePrivate *private;
}
NAActionProfile;
typedef struct NAActionProfileClassPrivate NAActionProfileClassPrivate;
typedef struct {
NAObjectClass parent;
NAActionProfileClassPrivate *private;
}
NAActionProfileClass;
/* instance properties
*/
#define PROP_PROFILE_ACTION_STR "profile-action"
#define PROP_PROFILE_NAME_STR "profile-name"
#define PROP_PROFILE_LABEL_STR "profile-desc-name"
#define PROP_PROFILE_PATH_STR "profile-path"
#define PROP_PROFILE_PARAMETERS_STR "profile-parameters"
#define PROP_PROFILE_BASENAMES_STR "profile-basenames"
#define PROP_PROFILE_MATCHCASE_STR "profile-matchcase"
#define PROP_PROFILE_ISDIR_STR "profile-isdir"
#define PROP_PROFILE_ISFILE_STR "profile-isfile"
#define PROP_PROFILE_ACCEPT_MULTIPLE_STR "profile-accept-multiple-files"
#define PROP_PROFILE_MIMETYPES_STR "profile-mimetypes"
#define PROP_PROFILE_SCHEMES_STR "profile-schemes"
/* internal identifier of profiles must begin with the following prefix
* this let us identify a profile key versus an action key
* corollarily, no action entry must begin with this same prefix
*/
#define ACTION_PROFILE_PREFIX "profile-"
GType na_action_profile_get_type( void );
#define ACTION_PROFILE_PREFIX "profile-"
NAActionProfile *na_action_profile_new( const NAObject *action, const gchar *name );
NAActionProfile *na_action_profile_duplicate( const NAAction *action, const NAActionProfile *profile );
void na_action_profile_free( NAActionProfile *profile );
NAActionProfile *na_action_profile_new( void );
NAObject *na_action_profile_get_action( const NAActionProfile *profile );
NAAction *na_action_profile_get_action( const NAActionProfile *profile );
gchar *na_action_profile_get_name( const NAActionProfile *profile );
gchar *na_action_profile_get_label( const NAActionProfile *profile );
gchar *na_action_profile_get_path( const NAActionProfile *profile );
......@@ -103,13 +64,13 @@ gchar *na_action_profile_get_parameters( const NAActionProfile *profil
GSList *na_action_profile_get_basenames( const NAActionProfile *profile );
gboolean na_action_profile_get_matchcase( const NAActionProfile *profile );
GSList *na_action_profile_get_mimetypes( const NAActionProfile *profile );
gboolean na_action_profile_get_is_dir( const NAActionProfile *profile );
gboolean na_action_profile_get_is_file( const NAActionProfile *profile );
gboolean na_action_profile_get_is_dir( const NAActionProfile *profile );
gboolean na_action_profile_get_multiple( const NAActionProfile *profile );
GSList *na_action_profile_get_schemes( const NAActionProfile *profile );
gboolean na_action_profile_are_equal( NAActionProfile *first, NAActionProfile *second );
void na_action_profile_set_action( NAActionProfile *profile, const NAAction *action );
void na_action_profile_set_name( NAActionProfile *profile, const gchar *name );
void na_action_profile_set_label( NAActionProfile *profile, const gchar *label );
void na_action_profile_set_path( NAActionProfile *profile, const gchar *path );
void na_action_profile_set_parameters( NAActionProfile *profile, const gchar *parameters );
......
This diff is collapsed.
......@@ -31,52 +31,22 @@
#ifndef __NA_ACTION_H__
#define __NA_ACTION_H__
/*
* NAAction class definition.
*
* This is the class which maintains an action.
/**
* SECTION: na_action
* @short_description: #NAAction class definition.
* @include: common/na-action.h
*
* NAAction class is derived from NAObject.
* This is the class which maintains data and properties of an Nautilus
* action.
*/
#include "na-object.h"
#include "na-pivot.h"
#include "na-action-class.h"
#include "na-action-profile-class.h"
#include "na-iio-provider.h"
G_BEGIN_DECLS
#define NA_ACTION_TYPE ( na_action_get_type())
#define NA_ACTION( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_ACTION_TYPE, NAAction ))
#define NA_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_ACTION_TYPE, NAActionClass ))
#define NA_IS_ACTION( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_ACTION_TYPE ))
#define NA_IS_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_ACTION_TYPE ))
#define NA_ACTION_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_ACTION_TYPE, NAActionClass ))
typedef struct NAActionPrivate NAActionPrivate;
typedef struct {
NAObject parent;
NAActionPrivate *private;
}
NAAction;
typedef struct NAActionClassPrivate NAActionClassPrivate;
typedef struct {
NAObjectClass parent;
NAActionClassPrivate *private;
}
NAActionClass;
/* instance properties
*/
#define PROP_ACTION_UUID_STR "action-uuid"
#define PROP_ACTION_VERSION_STR "action-version"
#define PROP_ACTION_LABEL_STR "action-label"
#define PROP_ACTION_TOOLTIP_STR "action-tooltip"
#define PROP_ACTION_ICON_STR "action-icon"
#define PROP_ACTION_READONLY_STR "action-read-only"
#define PROP_ACTION_PROVIDER_STR "action-provider"
/* TODO: move this declaration elsewhere */
/* export formats
* used to be only GConf schemas ('gconfschemafile' XML document)
*/
......@@ -84,38 +54,35 @@ enum {
EXPORT_FORMAT_GCONFSCHEMAFILE = 1
};
GType na_action_get_type( void );
NAAction *na_action_new( const gchar *uuid );
NAAction *na_action_new_with_profile( void );
NAAction *na_action_duplicate( const NAAction *action );
gchar *na_action_get_uuid( const NAAction *action );
gchar *na_action_get_version( const NAAction *action );
gchar *na_action_get_label( const NAAction *action );
gchar *na_action_get_tooltip( const NAAction *action );
gchar *na_action_get_icon( const NAAction *action );
gchar *na_action_get_verified_icon_name( const NAAction *action );
gboolean na_action_is_readonly( const NAAction *action );
gpointer na_action_get_provider( const NAAction *action );
void na_action_set_new_uuid( NAAction *action );
void na_action_set_uuid( NAAction *action, const gchar *uuid );
void na_action_set_version( NAAction *action, const gchar *version );
void na_action_set_label( NAAction *action, const gchar *label );
void na_action_set_tooltip( NAAction *action, const gchar *tooltip );
void na_action_set_icon( NAAction *action, const gchar *icon_name );
gboolean na_action_are_equal( const NAAction *first, const NAAction *second );
gchar *na_action_get_new_profile_name( const NAAction *action );
NAObject *na_action_get_profile( const NAAction *action, const gchar *name );
GSList *na_action_get_profiles( const NAAction *action );
void na_action_add_profile( NAAction *action, NAObject *profile );
void na_action_set_profiles( NAAction *action, GSList *list );
void na_action_free_profiles( GSList *list );
guint na_action_get_profiles_count( const NAAction *action );
NAAction *na_action_new( void );
NAAction *na_action_new_with_profile( void );
gchar *na_action_get_uuid( const NAAction *action );
gchar *na_action_get_label( const NAAction *action );
gchar *na_action_get_version( const NAAction *action );
gchar *na_action_get_tooltip( const NAAction *action );
gchar *na_action_get_icon( const NAAction *action );
gchar *na_action_get_verified_icon_name( const NAAction *action );
gboolean na_action_is_readonly( const NAAction *action );
NAIIOProvider *na_action_get_provider( const NAAction *action );
void na_action_set_new_uuid( NAAction *action );
void na_action_set_uuid( NAAction *action, const gchar *uuid );
void na_action_set_label( NAAction *action, const gchar *label );
void na_action_set_version( NAAction *action, const gchar *version );
void na_action_set_tooltip( NAAction *action, const gchar *tooltip );
void na_action_set_icon( NAAction *action, const gchar *icon_name );
void na_action_set_readonly( NAAction *action, gboolean readonly );
void na_action_set_provider( NAAction *action, const NAIIOProvider *provider );
gchar *na_action_get_new_profile_name( const NAAction *action );
NAActionProfile *na_action_get_profile( const NAAction *action, const gchar *name );
GSList *na_action_get_profiles( const NAAction *action );
void na_action_attach_profile( NAAction *action, NAActionProfile *profile );
void na_action_remove_profile( NAAction *action, NAActionProfile *profile );
void na_action_set_profiles( NAAction *action, GSList *list );
void na_action_free_profiles( GSList *list );
guint na_action_get_profiles_count( const NAAction *action );
G_END_DECLS
......
This diff is collapsed.
......@@ -31,10 +31,13 @@
#ifndef __NA_GCONF_H__
#define __NA_GCONF_H__
/*
* NAGConf class definition.
/**
* SECTION: na_gconf
* @short_description: #NAGConf class definition.
* @include: common/na-gconf.h
*
* Implements the NactIIOProvider (I/O storage subsystem) interface.
* This class manages the GConf I/O storage subsystem.
* It should only be used through the NAIIOProvider interface.
*/
#include <glib-object.h>
......
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "na-iduplicable.h"
/* private interface data
*/
struct NAIDuplicableInterfacePrivate {
};
/* data set against GObject
*/
#define PROP_IDUPLICABLE_ORIGIN "na-iduplicable-origin"
#define PROP_IDUPLICABLE_ISMODIFIED "na-iduplicable-is-modified"
#define PROP_IDUPLICABLE_ISVALID "na-iduplicable-is-valid"
static GType register_type( void );
static void interface_base_init( NAIDuplicableInterface *klass );
static void interface_base_finalize( NAIDuplicableInterface *klass );
static NAObject *v_duplicate( const NAObject *object );
static gboolean v_are_equal( const NAObject *a, const NAObject *b );
static gboolean v_is_valid( const NAObject *object );
static NAObject *get_origin( const NAObject *object );
static void set_origin( const NAObject *object, const NAObject *origin );
static gboolean get_modified( const NAObject *object );
static void set_modified( const NAObject *object, gboolean is_modified );
static gboolean get_valid( const NAObject *object );
static void set_valid( const NAObject *object, gboolean is_valid );
GType
na_iduplicable_get_type( void )
{
static GType iface_type = 0;
if( !iface_type ){
iface_type = register_type();
}
return( iface_type );
}
static GType
register_type( void )
{
static const gchar *thisfn = "na_iduplicable_register_type";
g_debug( "%s", thisfn );
static const GTypeInfo info = {
sizeof( NAIDuplicableInterface ),
( GBaseInitFunc ) interface_base_init,
( GBaseFinalizeFunc ) interface_base_finalize,
NULL,
NULL,
NULL,
0,
0,
NULL
};
GType type = g_type_register_static( G_TYPE_INTERFACE, "NAIDuplicable", &info, 0 );
g_type_interface_add_prerequisite( type, G_TYPE_OBJECT );
return( type );
}
static void
interface_base_init( NAIDuplicableInterface *klass )
{
static const gchar *thisfn = "na_iduplicable_interface_base_init";
static gboolean initialized = FALSE;
if( !initialized ){
g_debug( "%s: klass=%p", thisfn, klass );
klass->private = g_new0( NAIDuplicableInterfacePrivate, 1 );
initialized = TRUE;
}
}
static void
interface_base_finalize( NAIDuplicableInterface *klass )
{
static const gchar *thisfn = "na_iduplicable_interface_base_finalize";
static gboolean finalized = FALSE ;
if( !finalized ){
g_debug( "%s: klass=%p", thisfn, klass );
g_free( klass->private );
finalized = TRUE;
}
}
/**
* na_iduplicable_init:
* @object: the #NAObject object to be initialized.
*
* Initializes the properties of a IDuplicable object.
*
* This function should be called when creating the object, e.g. from
* instance_init().
*/
void
na_iduplicable_init( NAObject *object )
{
g_assert( NA_IS_OBJECT( object ));
g_assert( NA_IS_IDUPLICABLE( object ));
set_origin( object, NULL );
set_modified( object, FALSE );
set_valid( object, TRUE );
}
/**
* na_iduplicable_dump:
* @object: the #NAObject object to be duplicated.
*
* Dumps via g_debug the properties of the object.
*/
void
na_iduplicable_dump( const NAObject *object )
{
static const gchar *thisfn = "na_iduplicable_dump";
NAObject *origin = NULL;
gboolean modified = FALSE;
gboolean valid = TRUE;
if( object ){
g_assert( NA_IS_OBJECT( object ));
g_assert( NA_IS_IDUPLICABLE( object ));
origin = get_origin( object );
modified = get_modified( object );
valid = get_valid( object );
}
g_debug( "%s: origin=%p", thisfn, origin );
g_debug( "%s: modified=%s", thisfn, modified ? "True" : "False" );
g_debug( "%s: valid=%s", thisfn, valid ? "True" : "False" );
}
/**
* na_iduplicable_duplicate:
* @object: the #NAObject object to be duplicated.
*
* Exactly duplicates a #NAObject-derived object.
* Properties %PROP_IDUPLICABLE_ORIGIN, %PROP_IDUPLICABLE_ISMODIFIED
* and %PROP_IDUPLICABLE_ISVALID are initialized to their default
* values.
*
* As %PROP_IDUPLICABLE_ISVALID property is set to %TRUE without any
* further check, this suppose that only valid objects are duplicated.
*
* Returns: a new #NAObject.
*/
NAObject *
na_iduplicable_duplicate( const NAObject *object )
{
static const gchar *thisfn = "na_iduplicable_duplicate";
g_debug( "%s: object=%p", thisfn, object );
NAObject *dup = NULL;
if( object ){
g_assert( NA_IS_OBJECT( object ));
g_assert( NA_IS_IDUPLICABLE( object ));
dup = v_duplicate( object );
set_origin( dup, object );
set_modified( dup, FALSE );
set_valid( dup, TRUE );
}
return( dup );
}
/**
* na_iduplicable_check_edited_status:
* @object: the #NAObject object to be checked.
*
* Checks the edition status of the #NAObject object, and set up the
* corresponding %PROP_IDUPLICABLE_ISMODIFIED and
* %PROP_IDUPLICABLE_ISVALID properties.
*
* This function is supposed to be called each time the object may have
* been modified in order to set these properties. Helper functions
* na_iduplicable_is_modified() and na_iduplicable_is_valid() will
* then only return the current value of the properties.
*/
void
na_iduplicable_check_edited_status( const NAObject *object )
{
/*static const gchar *thisfn = "na_iduplicable_check_edited_status";
g_debug( "%s: object=%p", thisfn, object );*/
if( object ){
g_assert( NA_IS_OBJECT( object ));
g_assert( NA_IS_IDUPLICABLE( object ));
gboolean modified = TRUE;
NAObject *origin = get_origin( object );
if( origin ){
modified = !v_are_equal( object, origin );
}
set_modified( object, modified );
gboolean valid = v_is_valid( object );
set_valid( object, valid );
}
}
/**
* na_iduplicable_is_modified:
* @object: the #NAObject object whose status is to be returned.
*
* Returns the current value of the %PROP_IDUPLICABLE_ISMODIFIED
* property without rechecking the edition status itself.
*
* Returns: %TRUE is the provided object has been modified regarding of
* the original one.
*/
gboolean
na_iduplicable_is_modified( const NAObject *object )
{
/*static const gchar *thisfn = "na_iduplicable_is_modified";
g_debug( "%s: object=%p", thisfn, object );*/
gboolean is_modified = FALSE;
if( object ){
g_assert( NA_IS_OBJECT( object ));
g_assert( NA_IS_IDUPLICABLE( object ));
is_modified = get_modified( object );
}
return( is_modified );
}
/**
* na_iduplicable_is_valid:
* @object: the #NAObject object whose status is to be returned.
*
* Returns the current value of the %PROP_IDUPLICABLE_ISVALID property
* without rechecking the edition status itself.
*
* Returns: %TRUE is the provided object is valid.
*/
gboolean
na_iduplicable_is_valid( const NAObject *object )