[goffice] Fixed theme related issues.



commit 8d01c19e816658afec5b44e648a9f7b0bb53f2ea
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Nov 8 15:37:38 2012 +0100

    Fixed theme related issues.

 ChangeLog                          |   10 ++++++++++
 goffice/graph/gog-axis-color-map.c |    5 ++++-
 goffice/graph/gog-graph.c          |    2 +-
 goffice/graph/gog-theme.c          |   26 ++++++++++++++++++++------
 4 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0b1efc5..d60edca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-11-08  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/graph/gog-axis-color-map.c (color_map_load_from_uri): cosmetic
+	changes.
+	* goffice/graph/gog-graph.c (gog_graph_populate_editor): use Id instead
+	of name to list themes.
+	* goffice/graph/gog-theme.c (gog_theme_sax_save),
+	(gog_theme_registry_lookup), (theme_load_from_uri): make embedded theme
+	saving really work.
+
 2012-11-07  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/graph/gog-graph-prefs.ui: add a button to save an embedded
diff --git a/goffice/graph/gog-axis-color-map.c b/goffice/graph/gog-axis-color-map.c
index 6d15e0a..0dcb79f 100644
--- a/goffice/graph/gog-axis-color-map.c
+++ b/goffice/graph/gog-axis-color-map.c
@@ -880,8 +880,11 @@ color_map_load_from_uri (char const *uri)
 	if (!gsf_xml_in_doc_parse (xml, input, &state))
 		g_warning ("[GogAxisColorMap]: Could not parse %s", uri);
 	if (state.map != NULL) {
-		if (state.map && !go_file_access (uri, W_OK))
+		if (!go_file_access (uri, W_OK)) {
 			state.map->uri = g_strdup (uri);
+			state.map->type = GO_RESOURCE_RW;
+		} else
+			state.map->type = GO_RESOURCE_RO;
 		color_map_loaded (&state, uri, TRUE);
 		if (state.map)
 			gog_axis_color_map_registry_add (state.map);
diff --git a/goffice/graph/gog-graph.c b/goffice/graph/gog-graph.c
index 50516fb..f65cf24 100644
--- a/goffice/graph/gog-graph.c
+++ b/goffice/graph/gog-graph.c
@@ -327,7 +327,7 @@ gog_graph_populate_editor (GogObject *gobj,
 		char const *graph_theme_name;
 		int count, index = 0;
 
-		graph_theme_name = gog_theme_get_name (graph->theme);
+		graph_theme_name = gog_theme_get_id (graph->theme);
 		combo = go_gtk_builder_get_widget (gui, "theme_combo");
 		model = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo)));
 
diff --git a/goffice/graph/gog-theme.c b/goffice/graph/gog-theme.c
index f204ab5..b77cb53 100644
--- a/goffice/graph/gog-theme.c
+++ b/goffice/graph/gog-theme.c
@@ -423,7 +423,8 @@ gog_theme_sax_save (GOPersist const *gp, GsfXMLOut *output)
 	g_hash_table_foreach (theme->descs, (GHFunc) save_desc_cb, output);
 	g_hash_table_foreach (theme->elem_hash_by_class, (GHFunc) save_elem_cb, output);
 	g_hash_table_foreach (theme->elem_hash_by_role, (GHFunc) save_elem_cb, output);
-	g_ptr_array_foreach (theme->palette, (GFunc) save_series_style_cb, output);
+	if (theme->palette)
+		g_ptr_array_foreach (theme->palette, (GFunc) save_series_style_cb, output);
 	if (theme->cm && gog_axis_color_map_get_resource_type (theme->cm) == GO_RESOURCE_CHILD) {
 		gsf_xml_out_start_element (output, "GogAxisColorMap");
 		gsf_xml_out_add_cstr_unchecked (output, "type", (theme->cm == theme->dcm)? "both": "gradient");
@@ -1154,7 +1155,7 @@ gog_theme_registry_lookup (char const *name)
 			}
 		}
 		/* create an empty theme */
-		theme = g_object_new (GOG_TYPE_THEME, "resource-type", GO_RESOURCE_RW, NULL);
+		theme = g_object_new (GOG_TYPE_THEME, "resource-type", GO_RESOURCE_EXTERNAL, NULL);
 		theme->id = g_strdup (name);
 		gog_theme_registry_add (theme, FALSE);
 	}
@@ -1552,10 +1553,23 @@ theme_load_from_uri (char const *uri)
 	if (!gsf_xml_in_doc_parse (xml, input, &state))
 		g_warning ("[GogTheme]: Could not parse %s", uri);
 	if (state.theme != NULL) {
-		state.theme->uri = g_strdup (uri);
-		if (state.theme->id == NULL) {
-			state.theme->id = go_uuid ();
-			gog_theme_save (state.theme);
+		if (!go_file_access (uri, W_OK)) {
+			state.theme->uri = g_strdup (uri);
+			if (state.theme->id == NULL) {
+				state.theme->id = go_uuid ();
+				gog_theme_save (state.theme);
+			}
+			state.theme->type = GO_RESOURCE_RW;
+		} else {
+			if (state.theme->id == NULL) {
+				/* just duplicate the name, anyway, this should never occur */
+				char *name = g_hash_table_lookup (state.theme->names, "C");
+				if (name)
+					state.theme->id = g_strdup (name);
+				else
+					g_warning ("[GogTheme]: Theme with no Id in %s", uri);
+			}
+			state.theme->type = GO_RESOURCE_RO;
 		}
 		theme_loaded (&state);
 		gog_theme_registry_add (state.theme, FALSE);



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