[nautilus-actions] Add 'write_if_default' property to data definition
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Add 'write_if_default' property to data definition
- Date: Thu, 10 Jun 2010 22:35:00 +0000 (UTC)
commit 6f749f23e426e3f69d804064a7e9b251595d8f46
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu May 20 19:16:44 2010 +0200
Add 'write_if_default' property to data definition
This let us write the new 'iversion' data, even if it is the default.
ChangeLog | 14 ++++++++++++++
src/api/na-data-def.h | 3 +++
src/core/na-icontext-factory.c | 17 +++++++++++++++++
src/core/na-object-action-factory.c | 16 ++++++++++++++++
src/core/na-object-id-factory.c | 2 ++
src/core/na-object-item-factory.c | 13 +++++++++++++
src/core/na-object-profile-factory.c | 7 +++++++
src/io-desktop/nadp-writer.c | 2 +-
src/io-gconf/nagp-writer.c | 4 ++--
src/io-xml/naxml-writer.c | 31 +++++++++++++------------------
10 files changed, 88 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c0075b5..030c003 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,20 @@
2010-05-20 Pierre Wieser <pwieser trychlos org>
+ * src/api/na-data-def.h: Add write_if_default.
+
+ * src/core/na-icontext-factory.c:
+ * src/core/na-object-action-factory.c:
+ * src/core/na-object-id-factory.c:
+ * src/core/na-object-item-factory.c:
+ * src/core/na-object-profile-factory.c: Update all data structures.
+
+ * src/io-desktop/nadp-writer.c
+ (nadp_writer_ifactory_provider_write_data):
+ * src/io-gconf/nagp-writer.c (nagp_writer_write_data):
+ * src/io-xml/naxml-writer.c (naxml_writer_write_data):
+ Updated accordingly.
+
* src/io-desktop/nadp-reader.c
(nadp_reader_ifactory_provider_read_start): Removed function.
diff --git a/src/api/na-data-def.h b/src/api/na-data-def.h
index cfa7a4b..237a466 100644
--- a/src/api/na-data-def.h
+++ b/src/api/na-data-def.h
@@ -79,6 +79,9 @@ typedef struct {
* this default is also displayed in command-line help
* of nautilus-actions-new utility */
+ gboolean write_if_default; /* write this value even if it is the default value ?
+ * default to FALSE */
+
gboolean copyable; /* whether this data should be automatically copied when
* we are duplicating an object to another
* in all cases, the implementation is always triggered
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index 6fa272d..a4d94bc 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -53,6 +53,7 @@ NADataDef data_def_conditions [] = {
"Defaults to '*'." ),
NAFD_TYPE_STRING_LIST,
"[*]",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -81,6 +82,7 @@ NADataDef data_def_conditions [] = {
"Defaults to 'true'." ),
NAFD_TYPE_BOOLEAN,
"true",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -106,6 +108,7 @@ NADataDef data_def_conditions [] = {
"Defaults to '*/*'." ),
NAFD_TYPE_STRING_LIST,
"[*/*]",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -136,6 +139,7 @@ NADataDef data_def_conditions [] = {
"selection mimetypes",
NAFD_TYPE_BOOLEAN,
"true",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -165,6 +169,7 @@ NADataDef data_def_conditions [] = {
"Defaults to 'true'." ),
NAFD_TYPE_BOOLEAN,
"true",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -194,6 +199,7 @@ NADataDef data_def_conditions [] = {
"Defaults to 'false'." ),
NAFD_TYPE_BOOLEAN,
"false",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -225,6 +231,7 @@ NADataDef data_def_conditions [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"accept-multiple-files",
NULL,
0,
@@ -258,6 +265,7 @@ NADataDef data_def_conditions [] = {
"Defaults to 'file'." ),
NAFD_TYPE_STRING_LIST,
"[file]",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -282,6 +290,7 @@ NADataDef data_def_conditions [] = {
"Defaults to '/'." ),
NAFD_TYPE_STRING_LIST,
"[/]",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -307,6 +316,7 @@ NADataDef data_def_conditions [] = {
"Defaults to \">0\"." ),
NAFD_TYPE_STRING,
">0",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -328,6 +338,7 @@ NADataDef data_def_conditions [] = {
N_( "Defaults to all." ),
NAFD_TYPE_STRING_LIST,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -349,6 +360,7 @@ NADataDef data_def_conditions [] = {
N_( "Defaults to none." ),
NAFD_TYPE_STRING_LIST,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -373,6 +385,7 @@ NADataDef data_def_conditions [] = {
"Defaults to successful." ),
NAFD_TYPE_STRING,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -397,6 +410,7 @@ NADataDef data_def_conditions [] = {
"Defaults to successful." ),
NAFD_TYPE_STRING,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -421,6 +435,7 @@ NADataDef data_def_conditions [] = {
"Defaults to successful." ),
NAFD_TYPE_STRING,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -445,6 +460,7 @@ NADataDef data_def_conditions [] = {
"Defaults to successful." ),
NAFD_TYPE_STRING,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -474,6 +490,7 @@ NADataDef data_def_conditions [] = {
"Defaults to \"*;\"." ),
NAFD_TYPE_STRING_LIST,
"*",
+ FALSE,
TRUE,
TRUE,
FALSE,
diff --git a/src/core/na-object-action-factory.c b/src/core/na-object-action-factory.c
index 6579f29..b0d3aaf 100644
--- a/src/core/na-object-action-factory.c
+++ b/src/core/na-object-action-factory.c
@@ -57,6 +57,7 @@ static NADataDef data_def_action [] = {
"The version of the configuration format that will be used to manage backward compatibility.",
NAFD_TYPE_STRING,
NULL,
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -82,6 +83,7 @@ static NADataDef data_def_action [] = {
"Defaults to TRUE." ),
NAFD_TYPE_BOOLEAN,
"true",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -107,6 +109,7 @@ static NADataDef data_def_action [] = {
"Defaults to FALSE" ),
NAFD_TYPE_BOOLEAN,
"false",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -131,6 +134,7 @@ static NADataDef data_def_action [] = {
"Defaults to FALSE." ),
NAFD_TYPE_BOOLEAN,
"false",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -154,6 +158,7 @@ static NADataDef data_def_action [] = {
"Defaults to label of the context menu when not set or empty."),
NAFD_TYPE_LOCALE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -180,6 +185,7 @@ static NADataDef data_def_action [] = {
"Does the toolbar label is the same than the main one ?",
NAFD_TYPE_BOOLEAN,
"true",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -204,6 +210,7 @@ static NADataDef data_def_action [] = {
"reset to zero when saving the action.",
NAFD_TYPE_UINT,
"0",
+ FALSE,
TRUE,
FALSE,
FALSE,
@@ -238,6 +245,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"path",
NULL,
0,
@@ -259,6 +267,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"parameters",
NULL,
0,
@@ -280,6 +289,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"basenames",
NULL,
0,
@@ -301,6 +311,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"matchcase",
NULL,
0,
@@ -322,6 +333,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"mimetypes",
NULL,
0,
@@ -343,6 +355,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"isfile",
NULL,
0,
@@ -364,6 +377,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"isdir",
NULL,
0,
@@ -385,6 +399,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"accept-multiple-files",
NULL,
0,
@@ -406,6 +421,7 @@ NADataDef data_def_action_v1 [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"schemes",
NULL,
0,
diff --git a/src/core/na-object-id-factory.c b/src/core/na-object-id-factory.c
index 7ef7470..239fd6f 100644
--- a/src/core/na-object-id-factory.c
+++ b/src/core/na-object-id-factory.c
@@ -51,6 +51,7 @@ NADataDef data_def_id [] = {
"it is also the basename of the .desktop file (thus UTF-8, case sensitive).",
NAFD_TYPE_STRING,
NULL,
+ FALSE,
TRUE,
TRUE,
TRUE,
@@ -78,6 +79,7 @@ NADataDef data_def_id [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
NULL,
NULL,
0,
diff --git a/src/core/na-object-item-factory.c b/src/core/na-object-item-factory.c
index 180df74..78b6eb0 100644
--- a/src/core/na-object-item-factory.c
+++ b/src/core/na-object-item-factory.c
@@ -66,6 +66,7 @@ NADataDef data_def_item [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"type",
NULL,
0,
@@ -89,6 +90,7 @@ NADataDef data_def_item [] = {
"It is also used as a default for the toolbar label of an action." ),
NAFD_TYPE_LOCALE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -112,6 +114,7 @@ NADataDef data_def_item [] = {
"with his/her mouse." ),
NAFD_TYPE_LOCALE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -136,6 +139,7 @@ NADataDef data_def_item [] = {
"May be the localized name of a themed icon, or a full path to any appropriate image." ),
NAFD_TYPE_LOCALE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -158,6 +162,7 @@ NADataDef data_def_item [] = {
"May be used, e.g. when displaying available items on a web site." ),
NAFD_TYPE_LOCALE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -184,6 +189,7 @@ NADataDef data_def_item [] = {
"Defaults to empty." ),
NAFD_TYPE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -207,6 +213,7 @@ NADataDef data_def_item [] = {
"List of subitems objects",
NAFD_TYPE_POINTER,
NULL,
+ FALSE,
FALSE, /* not copyable */
FALSE, /* not comparable */
FALSE, /* not mandatory */
@@ -238,6 +245,7 @@ NADataDef data_def_item [] = {
FALSE,
FALSE,
FALSE,
+ FALSE,
"items",
NULL, /* Profiles or ItemsList */
0,
@@ -257,6 +265,7 @@ NADataDef data_def_item [] = {
"Defaults to TRUE." ),
NAFD_TYPE_BOOLEAN,
"true",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -286,6 +295,7 @@ NADataDef data_def_item [] = {
"TRUE if an eccor occurs on a later write operation.",
NAFD_TYPE_BOOLEAN,
"false",
+ FALSE,
TRUE,
FALSE,
FALSE,
@@ -309,6 +319,7 @@ NADataDef data_def_item [] = {
"A pointer to the NAIOProvider object.",
NAFD_TYPE_POINTER,
NULL,
+ FALSE,
TRUE,
FALSE,
FALSE,
@@ -333,6 +344,7 @@ NADataDef data_def_item [] = {
"A pointer to some NAIOProvider specific data.",
NAFD_TYPE_POINTER,
NULL,
+ FALSE,
TRUE,
FALSE,
FALSE,
@@ -360,6 +372,7 @@ NADataDef data_def_item [] = {
"3",
TRUE,
TRUE,
+ TRUE,
FALSE,
FALSE,
"iversion",
diff --git a/src/core/na-object-profile-factory.c b/src/core/na-object-profile-factory.c
index d7e0075..2e9de1e 100644
--- a/src/core/na-object-profile-factory.c
+++ b/src/core/na-object-profile-factory.c
@@ -52,6 +52,7 @@ static NADataDef data_def_profile [] = {
"If not set, it defaults to an auto-generated name." ),
NAFD_TYPE_LOCALE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -78,6 +79,7 @@ static NADataDef data_def_profile [] = {
"in the file manager context menu or in the toolbar." ),
NAFD_TYPE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
TRUE,
@@ -138,6 +140,7 @@ static NADataDef data_def_profile [] = {
" %%: a percent sign." ),
NAFD_TYPE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -169,6 +172,7 @@ static NADataDef data_def_profile [] = {
"Defaults to \"Normal\"." ),
NAFD_TYPE_UINT,
"1",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -191,6 +195,7 @@ static NADataDef data_def_profile [] = {
"Defaults to FALSE." ),
NAFD_TYPE_BOOLEAN,
"false",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -213,6 +218,7 @@ static NADataDef data_def_profile [] = {
"Defaults to empty." ),
NAFD_TYPE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
@@ -239,6 +245,7 @@ static NADataDef data_def_profile [] = {
"Defaults to empty: the command will be executed as the current user." ),
NAFD_TYPE_STRING,
"",
+ FALSE,
TRUE,
TRUE,
FALSE,
diff --git a/src/io-desktop/nadp-writer.c b/src/io-desktop/nadp-writer.c
index 994d827..a33d46f 100644
--- a/src/io-desktop/nadp-writer.c
+++ b/src/io-desktop/nadp-writer.c
@@ -366,7 +366,7 @@ nadp_writer_ifactory_provider_write_data(
group_name = g_strdup( NADP_GROUP_DESKTOP );
}
- if( na_data_boxed_is_set( boxed )){
+ if( na_data_boxed_is_set( boxed ) || def->write_if_default ){
switch( def->type ){
diff --git a/src/io-gconf/nagp-writer.c b/src/io-gconf/nagp-writer.c
index c5b0f40..6fc9137 100644
--- a/src/io-gconf/nagp-writer.c
+++ b/src/io-gconf/nagp-writer.c
@@ -262,9 +262,9 @@ nagp_writer_write_data( const NAIFactoryProvider *provider, void *writer_data,
msg = NULL;
code = NA_IIO_PROVIDER_CODE_OK;
+ def = na_data_boxed_get_data_def( boxed );
- if( na_data_boxed_is_set( boxed )){
- def = na_data_boxed_get_data_def( boxed );
+ if( na_data_boxed_is_set( boxed ) || def->write_if_default ){
if( NA_IS_OBJECT_PROFILE( object )){
NAObjectItem *parent = NA_OBJECT_ITEM( na_object_get_parent( object ));
diff --git a/src/io-xml/naxml-writer.c b/src/io-xml/naxml-writer.c
index db6f010..2d6ac17 100644
--- a/src/io-xml/naxml-writer.c
+++ b/src/io-xml/naxml-writer.c
@@ -87,7 +87,7 @@ struct ExportFormatFn {
gchar *list_node;
void ( *write_list_attribs_fn )( NAXMLWriter *, const NAObjectItem * );
gchar *element_node;
- void ( *write_data_fn )( NAXMLWriter *, const NAObjectId *, const NADataBoxed * );
+ void ( *write_data_fn )( NAXMLWriter *, const NAObjectId *, const NADataBoxed *, const NADataDef * );
void ( *write_type_fn )( NAXMLWriter *, const NAObjectItem *, const NADataDef *, const gchar * );
};
@@ -99,14 +99,14 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
-static void write_data_schema_v1( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed );
+static void write_data_schema_v1( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed, const NADataDef *def );
static void write_data_schema_v1_element( NAXMLWriter *writer, const NADataDef *def );
static void write_type_schema_v1( NAXMLWriter *writer, const NAObjectItem *object, const NADataDef *def, const gchar *value );
-static void write_data_schema_v2( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed );
+static void write_data_schema_v2( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed, const NADataDef *def );
static void write_data_schema_v2_element( NAXMLWriter *writer, const NADataDef *def, const gchar *object_id, const gchar *value_str );
static void write_type_schema_v2( NAXMLWriter *writer, const NAObjectItem *object, const NADataDef *def, const gchar *value );
static void write_list_attribs_dump( NAXMLWriter *writer, const NAObjectItem *object );
-static void write_data_dump( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed );
+static void write_data_dump( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed, const NADataDef *def );
static void write_data_dump_element( NAXMLWriter *writer, const NADataDef *def, const NADataBoxed *boxed, const gchar *entry, const gchar *value_str );
static void write_type_dump( NAXMLWriter *writer, const NAObjectItem *object, const NADataDef *def, const gchar *value );
@@ -410,20 +410,23 @@ guint
naxml_writer_write_data( const NAIFactoryProvider *provider, void *writer_data, const NAIFactoryObject *object, const NADataBoxed *boxed, GSList **messages )
{
NAXMLWriter *writer;
+ NADataDef *def;
/*NADataDef *def = na_data_boxed_get_data_def( boxed );
g_debug( "naxml_writer_write_data: def=%s", def->name );*/
+ def = na_data_boxed_get_data_def( boxed );
+
/* do no export empty values
*/
- if( na_data_boxed_is_set( boxed )){
+ if( na_data_boxed_is_set( boxed ) || def->write_if_default ){
writer = NAXML_WRITER( writer_data );
writer->private->schema_node = NULL;
writer->private->locale_node = NULL;
- ( *writer->private->fn_str->write_data_fn )( writer, NA_OBJECT_ID( object ), boxed );
+ ( *writer->private->fn_str->write_data_fn )( writer, NA_OBJECT_ID( object ), boxed, def );
}
return( NA_IIO_PROVIDER_CODE_OK );
@@ -436,13 +439,9 @@ naxml_writer_write_done( const NAIFactoryProvider *provider, void *writer_data,
}
static void
-write_data_schema_v1( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed )
+write_data_schema_v1( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed, const NADataDef *def )
{
- NADataDef *def;
-
- write_data_schema_v2( writer, object, boxed );
-
- def = na_data_boxed_get_data_def( boxed );
+ write_data_schema_v2( writer, object, boxed, def );
write_data_schema_v1_element( writer, def );
}
@@ -478,13 +477,11 @@ write_type_schema_v1( NAXMLWriter *writer, const NAObjectItem *object, const NAD
* <applyto>/apps/nautilus-actions/configurations/item_id/profile_id/entry</applyto>
*/
static void
-write_data_schema_v2( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed )
+write_data_schema_v2( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed, const NADataDef *def )
{
gchar *object_id;
- NADataDef *def;
gchar *value_str;
- def = na_data_boxed_get_data_def( boxed );
value_str = na_data_boxed_get_as_string( boxed );
/* boolean value must be lowercase
@@ -582,13 +579,11 @@ write_list_attribs_dump( NAXMLWriter *writer, const NAObjectItem *object )
}
static void
-write_data_dump( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed )
+write_data_dump( NAXMLWriter *writer, const NAObjectId *object, const NADataBoxed *boxed, const NADataDef *def )
{
gchar *entry;
- NADataDef *def;
gchar *value_str;
- def = na_data_boxed_get_data_def( boxed );
value_str = na_data_boxed_get_as_string( boxed );
/* boolean value must be lowercase
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]