[nautilus-actions] Define NAIConditions interface



commit 08044fe0aa2489b9842d4ce11df0b90c4e002b6f
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Mar 4 00:35:25 2010 +0100

    Define NAIConditions interface
    
    To be implemented by actions, profiles and menus (for now, only profiles).

 ChangeLog                            |   19 +++
 src/api/Makefile.am                  |    1 +
 src/api/na-iconditions.h             |   71 ++++++++++++
 src/api/na-ifactory-object-data.h    |    5 +-
 src/core/Makefile.am                 |    2 +
 src/core/na-iconditions-factory.c    |  207 ++++++++++++++++++++++++++++++++++
 src/core/na-iconditions.c            |  127 +++++++++++++++++++++
 src/core/na-object-profile-factory.c |  166 +---------------------------
 src/core/na-object-profile.c         |   21 ++++-
 9 files changed, 452 insertions(+), 167 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6a8aefe..fcb80da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2009-03-03 Pierre Wieser <pwieser trychlos org>
 
+	Define the NAIConditions interface, to be implemented by actions,
+	profiles and menus (for now, only profiles).
+
+	* src/api/na-iconditions.h:
+	* src/core/na-iconditions.c:
+	* src/core/na-iconditions-factory.c: New files.
+
+	* src/api/Makefile.am:
+	* src/core/Makefile.am: Updated accordingly.
+
+	* src/api/na-ifactory-object-data.h:
+	Define the NA_FACTORY_CONDITIONS_GROUP data group.
+
+	* src/core/na-object-profile-factory.c:
+	Use new data_def_conditions.
+
+	* src/core/na-object-profile.c (register_type):
+	Implement the new NAIConditions interface.
+
 	Review the rationales, replacing serializable+obsoleted by
 	readable+writable flags in NADataDef structure.
 
diff --git a/src/api/Makefile.am b/src/api/Makefile.am
index 83a4ecf..c28c776 100644
--- a/src/api/Makefile.am
+++ b/src/api/Makefile.am
@@ -44,6 +44,7 @@ api_include_HEADERS = \
 	na-data-types.h										\
 	na-gconf-monitor.h									\
 	na-gconf-utils.h									\
+	na-iconditions.h									\
 	na-iduplicable.h									\
 	na-ifactory-object.h								\
 	na-ifactory-object-data.h							\
diff --git a/src/api/na-iconditions.h b/src/api/na-iconditions.h
new file mode 100644
index 0000000..17273a3
--- /dev/null
+++ b/src/api/na-iconditions.h
@@ -0,0 +1,71 @@
+/*
+ * 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, 2010 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 __NAUTILUS_ACTIONS_API_NA_ICONDITIONS_H__
+#define __NAUTILUS_ACTIONS_API_NA_ICONDITIONS_H__
+
+/**
+ * SECTION: na_iconditions
+ * @short_description: #NAIConditions interface definition.
+ * @include: nautilus-actions/na-iconditions.h
+ *
+ * This interface is implemented by all #NAObject-derived objects
+ * which must met some conditions in order to be displayed in the
+ * Nautilus context menu.
+ *
+ * Implementors, typically actions, profiles and menus, host the required
+ * data as #NADataBoxed in a dedicated NA_FACTORY_CONDITIONS_GROUP
+ * data group.
+ */
+
+#include "na-object.h"
+
+G_BEGIN_DECLS
+
+#define NA_ICONDITIONS_TYPE							( na_iobject_conditions_get_type())
+#define NA_ICONDITIONS( instance )					( G_TYPE_CHECK_INSTANCE_CAST( instance, NA_ICONDITIONS_TYPE, NAIConditions ))
+#define NA_IS_ICONDITIONS( instance )				( G_TYPE_CHECK_INSTANCE_TYPE( instance, NA_ICONDITIONS_TYPE ))
+#define NA_ICONDITIONS_GET_INTERFACE( instance )	( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_ICONDITIONS_TYPE, NAIConditionsInterface ))
+
+typedef struct NAIConditions                 NAIConditions;
+
+typedef struct NAIConditionsInterfacePrivate NAIConditionsInterfacePrivate;
+
+typedef struct {
+	GTypeInterface                 parent;
+	NAIConditionsInterfacePrivate *private;
+}
+	NAIConditionsInterface;
+
+GType na_iconditions_get_type( void );
+
+G_END_DECLS
+
+#endif /* __NAUTILUS_ACTIONS_API_NA_ICONDITIONS_H__ */
diff --git a/src/api/na-ifactory-object-data.h b/src/api/na-ifactory-object-data.h
index 3ec16f7..521a101 100644
--- a/src/api/na-ifactory-object-data.h
+++ b/src/api/na-ifactory-object-data.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
 #define NA_FACTORY_OBJECT_ID_GROUP			"na-factory-group-id"
 #define NAFO_DATA_ID						"na-factory-data-id"
 #define NAFO_DATA_PARENT					"na-factory-data-parent"
+#define NAFO_DATA_CONDITIONS				"na-factory-data-conditions"
 
 #define NA_FACTORY_OBJECT_ITEM_GROUP		"na-factory-group-item"
 #define NAFO_DATA_TYPE						"na-factory-data-type"
@@ -75,6 +76,8 @@ G_BEGIN_DECLS
 #define NAFO_DATA_DESCNAME					"na-factory-data-descname"
 #define NAFO_DATA_PATH						"na-factory-data-path"
 #define NAFO_DATA_PARAMETERS				"na-factory-data-parameters"
+
+#define NA_FACTORY_OBJECT_CONDITIONS_GROUP	"na-factory-group-conditions"
 #define NAFO_DATA_BASENAMES					"na-factory-data-basenames"
 #define NAFO_DATA_MATCHCASE					"na-factory-data-matchcase"
 #define NAFO_DATA_MIMETYPES					"na-factory-data-mimetypes"
@@ -84,8 +87,6 @@ G_BEGIN_DECLS
 #define NAFO_DATA_SCHEMES					"na-factory-data-schemes"
 #define NAFO_DATA_FOLDERS					"na-factory-data-folders"
 
-#define NA_FACTORY_OBJECT_CONDITIONS_GROUP	"na-factory-group-conditions"
-
 G_END_DECLS
 
 #endif /* __NAUTILUS_ACTIONS_API_NA_IFACTORY_OBJECT_DATA_H__ */
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index fd235c4..5d536d4 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -59,6 +59,8 @@ libna_core_la_SOURCES = \
 	na-gtk-utils.h										\
 	na-iabout.c											\
 	na-iabout.h											\
+	na-iconditions.c									\
+	na-iconditions-factory.c							\
 	na-iduplicable.c									\
 	na-iexporter.c										\
 	na-ifactory-object.c								\
diff --git a/src/core/na-iconditions-factory.c b/src/core/na-iconditions-factory.c
new file mode 100644
index 0000000..65e3b79
--- /dev/null
+++ b/src/core/na-iconditions-factory.c
@@ -0,0 +1,207 @@
+/*
+ * 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, 2010 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 <glib/gi18n.h>
+
+#include <api/na-ifactory-object-data.h>
+#include <api/na-data-def.h>
+#include <api/na-data-types.h>
+
+NADataDef data_def_conditions [] = {
+
+	{ NAFO_DATA_BASENAMES,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "List of pattern to match the selected file(s)/folder(s)" ),
+				N_( "A list of strings with joker '*' or '?' to be matched against the name(s) " \
+					"of the selected file(s)/folder(s). Each selected items must match at least " \
+					"one of the filename patterns for the action or the menu be candidate to " \
+					"display.\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to '*'." ),
+				NAFD_TYPE_STRING_LIST,
+				"*",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"basenames", },
+
+	{ NAFO_DATA_MATCHCASE,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Whether the specified basenames are case sensitive" ),
+				N_( "Must be set to 'true' if the filename patterns are case sensitive, to 'false' " \
+					"otherwise. E.g., if you need to match a filename in a case-sensitive manner, " \
+					"set this key to 'true'. If you also want, for example '*.jpg' to match 'photo.JPG', " \
+					"then set 'false'.\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to 'true'." ),
+				NAFD_TYPE_BOOLEAN,
+				"true",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"matchcase" },
+
+	{ NAFO_DATA_MIMETYPES,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "List of patterns to match the mimetypes of the selected file(s)/folder(s)" ),
+				N_( "A list of strings with joker '*' to be matched against the mimetypes of the " \
+					"selected file(s)/folder(s). Each selected items must match at least one of " \
+					"the mimetype patterns for the action to appear.\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to '*/*'." ),
+				NAFD_TYPE_STRING_LIST,
+				"*",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"mimetypes" },
+
+	{ NAFO_DATA_ISFILE,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Whether the profile applies to files" ),
+				N_( "Set to 'true' if the selection can have files, to 'false' otherwise.\n" \
+					"This setting is tied in with the 'isdir' setting. The valid combinations are: \n" \
+					"isfile=TRUE and isdir=FALSE: the selection may hold only files\n" \
+					"isfile=FALSE and isdir=TRUE: the selection may hold only folders\n" \
+					"isfile=TRUE and isdir=TRUE: the selection may hold both files and folders\n" \
+					"isfile=FALSE and isdir=FALSE: this is an invalid combination " \
+					"(your configuration will never appear).\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to 'true'." ),
+				NAFD_TYPE_BOOLEAN,
+				"true",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"isfile" },
+
+	{ NAFO_DATA_ISDIR,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Whether the profile applies to folders" ),
+				N_( "Set to 'true' if the selection can have folders, to 'false' otherwise.\n" \
+					"This setting is tied in with the 'isfile' setting. The valid combinations are: \n" \
+					"isfile=TRUE and isdir=FALSE: the selection may hold only files\n" \
+					"isfile=FALSE and isdir=TRUE: the selection may hold only folders\n" \
+					"isfile=TRUE and isdir=TRUE: the selection may hold both files and folders\n" \
+					"isfile=FALSE and isdir=FALSE: this is an invalid combination " \
+					"(your configuration will never appear).\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to 'false'." ),
+				NAFD_TYPE_BOOLEAN,
+				"false",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"isdir" },
+
+	{ NAFO_DATA_MULTIPLE,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Whether the selection may be multiple" ),
+				N_( "If you need more than one files or folders to be selected, set this " \
+					"key to 'true'. If you want just one file or folder, set it to 'false'.\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to 'false'." ),
+				NAFD_TYPE_BOOLEAN,
+				"false",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"accept-multiple-files" },
+
+	{ NAFO_DATA_SCHEMES,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "List of schemes" ),
+										/* too long string for iso c: 510 (max=509) */
+				N_( "Defines the list of valid schemes to be matched against the selected " \
+					"items. The scheme is the protocol used to access the files. The " \
+					"keyword to use is the one used in the URI by the file manager.\n" \
+					"Examples of valid URI include:\n" \
+					"- file:///tmp/foo.txt\n" \
+					"- sftp:///root test example net/tmp/foo.txt\n" \
+					"The most common schemes are:\n" \
+					"'file': local files\n" \
+					"'sftp': files accessed via SSH\n" \
+					"'ftp': files accessed via FTP\n" \
+					"'smb': files accessed via Samba (Windows share)\n" \
+					"'dav': files accessed via WebDAV.\n" \
+					"All schemes used by your favorite file manager may be used here.\n" \
+					"This obviously only applies when there is a selection.\n" \
+					"Defaults to 'file'." ),
+				NAFD_TYPE_STRING_LIST,
+				"file",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"schemes" },
+
+	{ NAFO_DATA_FOLDERS,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "List of folders" ),
+				N_( "Defines the list of valid paths to be matched against the current folder.\n " \
+					"All folders 'under' the specified path are considered valid.\n" \
+					"This is only used when there is no selection.\n" \
+					"Defaults to '/'." ),
+				NAFD_TYPE_STRING_LIST,
+				"/",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"folders" },
+
+	{ NULL },
+};
diff --git a/src/core/na-iconditions.c b/src/core/na-iconditions.c
new file mode 100644
index 0000000..75ba93a
--- /dev/null
+++ b/src/core/na-iconditions.c
@@ -0,0 +1,127 @@
+/*
+ * 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, 2010 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 <api/na-iconditions.h>
+
+/* private interface data
+ */
+struct NAIConditionsInterfacePrivate {
+	void *empty;						/* so that gcc -pedantic is happy */
+};
+
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized   = FALSE;
+
+static GType register_type( void );
+static void  interface_base_init( NAIConditionsInterface *klass );
+static void  interface_base_finalize( NAIConditionsInterface *klass );
+
+/**
+ * na_iconditions_get_type:
+ *
+ * Returns: the #GType type of this interface.
+ */
+GType
+na_iconditions_get_type( void )
+{
+	static GType type = 0;
+
+	if( !type ){
+		type = register_type();
+	}
+
+	return( type );
+}
+
+/*
+ * na_iconditions_register_type:
+ *
+ * Registers this interface.
+ */
+static GType
+register_type( void )
+{
+	static const gchar *thisfn = "na_iconditions_register_type";
+	GType type;
+
+	static const GTypeInfo info = {
+		sizeof( NAIConditionsInterface ),
+		( GBaseInitFunc ) interface_base_init,
+		( GBaseFinalizeFunc ) interface_base_finalize,
+		NULL,
+		NULL,
+		NULL,
+		0,
+		0,
+		NULL
+	};
+
+	g_debug( "%s", thisfn );
+
+	type = g_type_register_static( G_TYPE_INTERFACE, "NAIConditions", &info, 0 );
+
+	g_type_interface_add_prerequisite( type, G_TYPE_OBJECT );
+
+	return( type );
+}
+
+static void
+interface_base_init( NAIConditionsInterface *klass )
+{
+	static const gchar *thisfn = "na_iconditions_interface_base_init";
+
+	if( !st_initialized ){
+
+		g_debug( "%s: klass%p (%s)", thisfn, ( void * ) klass, G_OBJECT_CLASS_NAME( klass ));
+
+		klass->private = g_new0( NAIConditionsInterfacePrivate, 1 );
+
+		st_initialized = TRUE;
+	}
+}
+
+static void
+interface_base_finalize( NAIConditionsInterface *klass )
+{
+	static const gchar *thisfn = "na_iconditions_interface_base_finalize";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+		st_finalized = TRUE;
+
+		g_free( klass->private );
+	}
+}
diff --git a/src/core/na-object-profile-factory.c b/src/core/na-object-profile-factory.c
index 41c8bf7..5654a91 100644
--- a/src/core/na-object-profile-factory.c
+++ b/src/core/na-object-profile-factory.c
@@ -39,6 +39,7 @@
 #include <api/na-data-types.h>
 
 extern NADataDef data_def_id [];			/* defined in na-object-id-factory.c */
+extern NADataDef data_def_conditions [];	/* defined in na-iconditions-factory.c */
 
 static NADataDef data_def_profile [] = {
 
@@ -101,175 +102,12 @@ static NADataDef data_def_profile [] = {
 				FALSE,
 				"parameters" },
 
-	{ NAFO_DATA_BASENAMES,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "List of pattern to match the selected file(s)/folder(s)" ),
-				N_( "A list of strings with joker '*' or '?' to be matched against the name(s) " \
-					"of the selected file(s)/folder(s). Each selected items must match at least " \
-					"one of the filename patterns for the action or the menu be candidate to " \
-					"display.\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to '*'." ),
-				NAFD_TYPE_STRING_LIST,
-				"*",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"basenames", },
-
-	{ NAFO_DATA_MATCHCASE,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "Whether the specified basenames are case sensitive" ),
-				N_( "Must be set to 'true' if the filename patterns are case sensitive, to 'false' " \
-					"otherwise. E.g., if you need to match a filename in a case-sensitive manner, " \
-					"set this key to 'true'. If you also want, for example '*.jpg' to match 'photo.JPG', " \
-					"then set 'false'.\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to 'true'." ),
-				NAFD_TYPE_BOOLEAN,
-				"true",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"matchcase" },
-
-	{ NAFO_DATA_MIMETYPES,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "List of patterns to match the mimetypes of the selected file(s)/folder(s)" ),
-				N_( "A list of strings with joker '*' to be matched against the mimetypes of the " \
-					"selected file(s)/folder(s). Each selected items must match at least one of " \
-					"the mimetype patterns for the action to appear.\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to '*/*'." ),
-				NAFD_TYPE_STRING_LIST,
-				"*",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"mimetypes" },
-
-	{ NAFO_DATA_ISFILE,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "Whether the profile applies to files" ),
-				N_( "Set to 'true' if the selection can have files, to 'false' otherwise.\n" \
-					"This setting is tied in with the 'isdir' setting. The valid combinations are: \n" \
-					"isfile=TRUE and isdir=FALSE: the selection may hold only files\n" \
-					"isfile=FALSE and isdir=TRUE: the selection may hold only folders\n" \
-					"isfile=TRUE and isdir=TRUE: the selection may hold both files and folders\n" \
-					"isfile=FALSE and isdir=FALSE: this is an invalid combination " \
-					"(your configuration will never appear).\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to 'true'." ),
-				NAFD_TYPE_BOOLEAN,
-				"true",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"isfile" },
-
-	{ NAFO_DATA_ISDIR,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "Whether the profile applies to folders" ),
-				N_( "Set to 'true' if the selection can have folders, to 'false' otherwise.\n" \
-					"This setting is tied in with the 'isfile' setting. The valid combinations are: \n" \
-					"isfile=TRUE and isdir=FALSE: the selection may hold only files\n" \
-					"isfile=FALSE and isdir=TRUE: the selection may hold only folders\n" \
-					"isfile=TRUE and isdir=TRUE: the selection may hold both files and folders\n" \
-					"isfile=FALSE and isdir=FALSE: this is an invalid combination " \
-					"(your configuration will never appear).\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to 'false'." ),
-				NAFD_TYPE_BOOLEAN,
-				"false",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"isdir" },
-
-	{ NAFO_DATA_MULTIPLE,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "Whether the selection may be multiple" ),
-				N_( "If you need more than one files or folders to be selected, set this " \
-					"key to 'true'. If you want just one file or folder, set it to 'false'.\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to 'false'." ),
-				NAFD_TYPE_BOOLEAN,
-				"false",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"accept-multiple-files" },
-
-	{ NAFO_DATA_SCHEMES,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "List of schemes" ),
-										/* too long string for iso c: 510 (max=509) */
-				N_( "Defines the list of valid schemes to be matched against the selected " \
-					"items. The scheme is the protocol used to access the files. The " \
-					"keyword to use is the one used in the URI by the file manager.\n" \
-					"Examples of valid URI include:\n" \
-					"- file:///tmp/foo.txt\n" \
-					"- sftp:///root test example net/tmp/foo.txt\n" \
-					"The most common schemes are:\n" \
-					"'file': local files\n" \
-					"'sftp': files accessed via SSH\n" \
-					"'ftp': files accessed via FTP\n" \
-					"'smb': files accessed via Samba (Windows share)\n" \
-					"'dav': files accessed via WebDAV.\n" \
-					"All schemes used by your favorite file manager may be used here.\n" \
-					"This obviously only applies when there is a selection.\n" \
-					"Defaults to 'file'." ),
-				NAFD_TYPE_STRING_LIST,
-				"file",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"schemes" },
-
-	{ NAFO_DATA_FOLDERS,
-				TRUE,
-				TRUE,
-				TRUE,
-				N_( "List of folders" ),
-				N_( "Defines the list of valid paths to be matched against the current folder.\n " \
-					"All folders 'under' the specified path are considered valid.\n" \
-					"This is only used when there is no selection.\n" \
-					"Defaults to '/'." ),
-				NAFD_TYPE_STRING_LIST,
-				"/",
-				TRUE,
-				TRUE,
-				FALSE,
-				FALSE,
-				"folders" },
-
 	{ NULL },
 };
 
 NADataGroup profile_data_groups [] = {
 	{ NA_FACTORY_OBJECT_ID_GROUP,         data_def_id },
 	{ NA_FACTORY_OBJECT_PROFILE_GROUP,    data_def_profile },
-	{ NA_FACTORY_OBJECT_CONDITIONS_GROUP, NULL },
+	{ NA_FACTORY_OBJECT_CONDITIONS_GROUP, data_def_conditions },
 	{ NULL }
 };
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index 18a9c86..e5ff88a 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -38,6 +38,7 @@
 #include <libnautilus-extension/nautilus-file-info.h>
 
 #include <api/na-core-utils.h>
+#include <api/na-iconditions.h>
 #include <api/na-iio-provider.h>
 #include <api/na-ifactory-object.h>
 #include <api/na-object-api.h>
@@ -83,6 +84,8 @@ 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 );
 static guint        ifactory_object_write_done( NAIFactoryObject *instance, const NAIFactoryProvider *writer, void *writer_data, GSList **messages );
 
+static void         iconditions_iface_init( NAIConditionsInterface *iface );
+
 static gboolean     profile_is_valid( const NAObjectProfile *profile );
 static gboolean     is_valid_path_parameters( const NAObjectProfile *profile );
 static gboolean     is_valid_basenames( const NAObjectProfile *profile );
@@ -137,6 +140,12 @@ register_type( void )
 		( GInstanceInitFunc ) instance_init
 	};
 
+	static const GInterfaceInfo iconditions_iface_info = {
+		( GInterfaceInitFunc ) iconditions_iface_init,
+		NULL,
+		NULL
+	};
+
 	static const GInterfaceInfo ifactory_object_iface_info = {
 		( GInterfaceInitFunc ) ifactory_object_iface_init,
 		NULL,
@@ -147,6 +156,8 @@ register_type( void )
 
 	type = g_type_register_static( NA_OBJECT_ID_TYPE, "NAObjectProfile", &info, 0 );
 
+	g_type_add_interface_static( type, NA_ICONDITIONS_TYPE, &iconditions_iface_info );
+
 	g_type_add_interface_static( type, NA_IFACTORY_OBJECT_TYPE, &ifactory_object_iface_info );
 
 	return( type );
@@ -293,7 +304,7 @@ object_is_valid( const NAObject *object )
 static void
 ifactory_object_iface_init( NAIFactoryObjectInterface *iface )
 {
-	static const gchar *thisfn = "na_object_menu_ifactory_object_iface_init";
+	static const gchar *thisfn = "na_object_profile_ifactory_object_iface_init";
 
 	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
@@ -345,6 +356,14 @@ ifactory_object_write_done( NAIFactoryObject *instance, const NAIFactoryProvider
 	return( NA_IIO_PROVIDER_CODE_OK );
 }
 
+static void
+iconditions_iface_init( NAIConditionsInterface *iface )
+{
+	static const gchar *thisfn = "na_object_profile_iconditions_iface_init";
+
+	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+}
+
 static gboolean
 profile_is_valid( const NAObjectProfile *profile )
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]