1 /*
2  * Nautilus-Actions
3  * A Nautilus extension which offers configurable context menu actions.
4  *
5  * Copyright (C) 2005 The GNOME Foundation
6  * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7  * Copyright (C) 2009-2014 Pierre Wieser and others (see AUTHORS)
8  *
9  * Nautilus-Actions is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * Nautilus-Actions is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Nautilus-Actions; see the file COPYING. If not, see
21  * <http://www.gnu.org/licenses/>.
22  *
23  * Authors:
24  *   Frederic Ruaudel <grumz@grumz.net>
25  *   Rodrigo Moya <rodrigo@gnome-db.org>
26  *   Pierre Wieser <pwieser@trychlos.org>
27  *   ... and many others (see AUTHORS)
28  */
29 
30 #ifndef __NAUTILUS_ACTIONS_API_NA_OBJECT_ID_H__
31 #define __NAUTILUS_ACTIONS_API_NA_OBJECT_ID_H__
32 
33 /**
34  * SECTION: object-id
35  * @title: NAObjectId
36  * @short_description: The Identified Object Base Class Definition
37  * @include: nautilus-actions/na-object-id.h
38  *
39  * This is a pure virtual class, i.e. not an instantiatable one.
40  * It serves as the base class for #NAObject -derived object which have
41  * a unique Id, i.e. for #NAObjectItem and #NAObjectProfile.
42  */
43 
44 #include "na-object.h"
45 
46 G_BEGIN_DECLS
47 
48 #define NA_TYPE_OBJECT_ID                ( na_object_id_get_type())
49 #define NA_OBJECT_ID( object )           ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_TYPE_OBJECT_ID, NAObjectId ))
50 #define NA_OBJECT_ID_CLASS( klass )      ( G_TYPE_CHECK_CLASS_CAST( klass, NA_TYPE_OBJECT_ID, NAObjectIdClass ))
51 #define NA_IS_OBJECT_ID( object )        ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_TYPE_OBJECT_ID ))
52 #define NA_IS_OBJECT_ID_CLASS( klass )   ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_TYPE_OBJECT_ID ))
53 #define NA_OBJECT_ID_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_TYPE_OBJECT_ID, NAObjectIdClass ))
54 
55 typedef struct _NAObjectIdPrivate        NAObjectIdPrivate;
56 
57 typedef struct {
58 	/*< private >*/
59 	NAObject           parent;
60 	NAObjectIdPrivate *private;
61 }
62 	NAObjectId;
63 
64 typedef struct _NAObjectIdClassPrivate   NAObjectIdClassPrivate;
65 
66 /**
67  * NAObjectIdClass:
68  * @new_id: Allocate a new id to an existing NAObjectId.
69  *
70  * The #NAObjectIdClass defines some methods available to derived classes.
71  */
72 typedef struct {
73 	/*< private >*/
74 	NAObjectClass           parent;
75 	NAObjectIdClassPrivate *private;
76 
77 	/*< public >*/
78 	/**
79 	 * new_id:
80 	 * @object: a NAObjectId object.
81 	 * @new_parent: possibly the new NAObjectId parent, or NULL.
82 	 * If not NULL, this should actually be a NAObjectItem.
83 	 *
84 	 * If @object is a NAObjectProfile, then @new_parent must be a
85 	 * not null NAObjectAction. This function ensures that the new
86 	 * profile name does not already exist in the given @new_parent.
87 	 *
88 	 * This is a pure virtual function which should be implemented by
89 	 * the actual class. Actually, we asks for the most-derived class
90 	 * which implements this function.
91 	 *
92 	 * Returns: a new id suitable for this @object.
93 	 *
94 	 * Since: 2.30
95 	 */
96 	gchar * ( *new_id )( const NAObjectId *object, const NAObjectId *new_parent );
97 }
98 	NAObjectIdClass;
99 
100 GType  na_object_id_get_type( void );
101 
102 gint   na_object_id_sort_alpha_asc   ( const NAObjectId *a, const NAObjectId *b );
103 gint   na_object_id_sort_alpha_desc  ( const NAObjectId *a, const NAObjectId *b );
104 
105 void   na_object_id_prepare_for_paste( NAObjectId *object, gboolean relabel, gboolean renumber, NAObjectId *parent );
106 void   na_object_id_set_copy_of_label( NAObjectId *object );
107 void   na_object_id_set_new_id       ( NAObjectId *object, const NAObjectId *new_parent );
108 
109 G_END_DECLS
110 
111 #endif /* __NAUTILUS_ACTIONS_API_NA_OBJECT_ID_H__ */
112