[nautilus-actions] Fix XML import of localized vs. unlocalized profile description name
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Fix XML import of localized vs. unlocalized profile description name
- Date: Mon, 9 Aug 2010 21:16:46 +0000 (UTC)
commit 43366212b0f763233b96e10fc9a54def175e8516
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Aug 9 23:15:00 2010 +0200
Fix XML import of localized vs. unlocalized profile description name
Profile description used to be unlocalized up to and included 1.11.0.
ChangeLog | 11 +++++++++
src/api/na-ifactory-object-data.h | 3 +-
src/api/na-object-api.h | 1 +
src/core/na-object-profile-factory.c | 24 ++++++++++++++++++++
src/io-xml/naxml-reader.c | 39 ++++++++++++++++++++++++++++++++++
5 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2924bf3..43faa3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2010-08-09 Pierre Wieser <pwieser trychlos org>
+ Fix XML import of localized vs. unlocalized profile label.
+
+ * src/api/na-ifactory-object-data.h:
+ * src/core/na-object-profile-factory.c:
+ Define new NAFO_DATA_DESCNAME_NOLOC unlocalized profile label.
+
+ * src/api/na-object-api.h (na_object_get_label_noloc): New macro.
+
+ * src/io-xml/naxml-reader.c (naxml_reader_read_done):
+ Deals with localized vs. unlocalized profile description name.
+
Fix XML import of localized vs. unlocalized icons.
* src/api/na-ifactory-object-data.h:
diff --git a/src/api/na-ifactory-object-data.h b/src/api/na-ifactory-object-data.h
index 5364b3b..45c4735 100644
--- a/src/api/na-ifactory-object-data.h
+++ b/src/api/na-ifactory-object-data.h
@@ -43,13 +43,13 @@ G_BEGIN_DECLS
#define NA_FACTORY_OBJECT_ID_GROUP "na-factory-group-id"
#define NAFO_DATA_ID "na-factory-data-id"
+#define NAFO_DATA_LABEL "na-factory-data-label"
#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_IVERSION "na-factory-data-iversion"
#define NAFO_DATA_TYPE "na-factory-data-type"
-#define NAFO_DATA_LABEL "na-factory-data-label"
#define NAFO_DATA_TOOLTIP "na-factory-data-tooltip"
#define NAFO_DATA_ICON "na-factory-data-icon"
#define NAFO_DATA_ICON_NOLOC "na-factory-data-unlocalized-icon"
@@ -77,6 +77,7 @@ G_BEGIN_DECLS
#define NA_FACTORY_OBJECT_PROFILE_GROUP "na-factory-group-profile"
#define NAFO_DATA_DESCNAME "na-factory-data-descname"
+#define NAFO_DATA_DESCNAME_NOLOC "na-factory-data-unlocalized-descname"
#define NAFO_DATA_PATH "na-factory-data-path"
#define NAFO_DATA_PARAMETERS "na-factory-data-parameters"
#define NAFO_DATA_WORKING_DIR "na-factory-data-working-dir"
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index e5a3d16..718a3b6 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -80,6 +80,7 @@ G_BEGIN_DECLS
*/
#define na_object_get_id( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ID ))
#define na_object_get_label( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), ( NA_IS_OBJECT_PROFILE( obj ) ? NAFO_DATA_DESCNAME : NAFO_DATA_LABEL )))
+#define na_object_get_label_noloc( obj ) (( gchar * )( NA_IS_OBJECT_PROFILE( obj ) ? na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_DESCNAME_NOLOC ) : NULL ))
#define na_object_get_parent( obj ) (( NAObjectItem * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PARENT ))
#define na_object_set_id( obj, id ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ID, ( const void * )( id ))
diff --git a/src/core/na-object-profile-factory.c b/src/core/na-object-profile-factory.c
index a03998f..c228eb1 100644
--- a/src/core/na-object-profile-factory.c
+++ b/src/core/na-object-profile-factory.c
@@ -66,6 +66,30 @@ static NADataDef data_def_profile [] = {
NULL,
NULL },
+ /* label of the profile was unlocalized up to and included 1.11.0
+ */
+ { NAFO_DATA_DESCNAME_NOLOC,
+ TRUE,
+ FALSE,
+ FALSE,
+ "Unlocalized name of the profile",
+ "Unlocalized name of the profile",
+ NAFD_TYPE_STRING,
+ "",
+ FALSE,
+ FALSE,
+ FALSE,
+ FALSE,
+ FALSE,
+ "desc-name",
+ NULL,
+ 0,
+ NULL,
+ 0,
+ 0,
+ NULL,
+ NULL },
+
/* Path and Parameters are two separate data both in GConf, in GConf-derived
* export files and in NACT. Only in desktop files, they are merged as only
* one 'Exec' data which is splitted at read time.
diff --git a/src/io-xml/naxml-reader.c b/src/io-xml/naxml-reader.c
index 8fa8150..de4dba0 100644
--- a/src/io-xml/naxml-reader.c
+++ b/src/io-xml/naxml-reader.c
@@ -163,6 +163,8 @@ static void read_done_item_set_localized_icon( NAXMLReader *reader, NAO
static void read_done_action( NAXMLReader *reader, NAObjectAction *action );
static gchar *read_done_action_get_next_profile_id( NAXMLReader *reader );
static void read_done_action_load_profile( NAXMLReader *reader, const gchar *profile_id );
+static void read_done_profile( NAXMLReader *reader, NAObjectProfile *profile );
+static void read_done_profile_set_localized_label( NAXMLReader *reader, NAObjectProfile *profile );
static guint reader_parse_xmldoc( NAXMLReader *reader );
static guint iter_on_root_children( NAXMLReader *reader, xmlNode *root );
@@ -758,6 +760,10 @@ naxml_reader_read_done( const NAIFactoryProvider *provider, void *reader_data, c
read_done_action( NAXML_READER( reader_data ), NA_OBJECT_ACTION( object ));
}
+ if( NA_IS_OBJECT_PROFILE( object )){
+ read_done_profile( NAXML_READER( reader_data ), NA_OBJECT_PROFILE( object ));
+ }
+
g_debug( "%s: quitting for %s at %p", thisfn, G_OBJECT_TYPE_NAME( object ), ( void * ) object );
}
@@ -887,6 +893,39 @@ read_done_action_load_profile( NAXMLReader *reader, const gchar *profile_id )
&reader->private->parms->messages );
}
+static void
+read_done_profile( NAXMLReader *reader, NAObjectProfile *profile )
+{
+ read_done_profile_set_localized_label( reader, profile );
+}
+
+/*
+ * just having readen this NAObjectProfile
+ * so deals with unlocalized/localized desc-name
+ */
+static void
+read_done_profile_set_localized_label( NAXMLReader *reader, NAObjectProfile *profile )
+{
+ gchar *descname, *unloc_descname;
+
+ /* deals with localized/unlocalized descname name
+ * it used to be unlocalized up to 2.29.4 included
+ */
+ descname = na_object_get_label( profile );
+
+ if( !descname || !strlen( descname )){
+ unloc_descname = na_object_get_label_noloc( profile );
+
+ if( unloc_descname && strlen( unloc_descname )){
+ na_object_set_label( profile, unloc_descname );
+ }
+
+ g_free( unloc_descname );
+ }
+
+ g_free( descname );
+}
+
/*
* 'key' and 'applyto' keys: check the id
* 'applyto' key: check for type
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]