[goffice] Graph themes: fix filename-to-uri for themes.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Graph themes: fix filename-to-uri for themes.
- Date: Wed, 24 Nov 2010 15:36:27 +0000 (UTC)
commit 9ae6b0df9d79dbaf9a25d86bb890e0697e93a5e8
Author: Morten Welinder <terra gnome org>
Date: Wed Nov 24 10:35:45 2010 -0500
Graph themes: fix filename-to-uri for themes.
ChangeLog | 8 ++++++++
NEWS | 1 +
goffice/graph/gog-theme.c | 28 ++++++++++++++++------------
3 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e29d489..864b9fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-11-24 Morten Welinder <terra gnome org>
+
+ * goffice/graph/gog-theme.c (themes_load_from_dir): Fix URI
+ handling.
+ (_gog_themes_init): Use g_get_home_dir.
+ (gog_theme_finalize): Remove the theme from the global list.
+ (_gog_themes_shutdown): Free the list of themes.
+
2010-11-10 Jean Brefort <jean brefort normalesup org>
* plugins/plot_distrib/gog-histogram.c
diff --git a/NEWS b/NEWS
index a3e5325..2e31908 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Jean:
Morten:
* Fix GOImage-vs-cairo lifecycle issue.
+ * Fix loading of weird themes.
--------------------------------------------------------------------------
goffice 0.8.11:
diff --git a/goffice/graph/gog-theme.c b/goffice/graph/gog-theme.c
index c9f161f..94627b0 100644
--- a/goffice/graph/gog-theme.c
+++ b/goffice/graph/gog-theme.c
@@ -224,7 +224,8 @@ static void
gog_theme_finalize (GObject *obj)
{
GogTheme *theme = GOG_THEME (obj);
- unsigned i;
+
+ themes = g_slist_remove (themes, theme);
g_free (theme->name); theme->name = NULL;
g_free (theme->local_name); theme->local_name = NULL;
@@ -236,6 +237,7 @@ gog_theme_finalize (GObject *obj)
if (theme->class_aliases)
g_hash_table_destroy (theme->class_aliases);
if (theme->palette) {
+ unsigned i;
for (i = 0; i < theme->palette->len; i++)
g_object_unref (g_ptr_array_index (theme->palette, i));
g_ptr_array_free (theme->palette, TRUE);
@@ -1088,17 +1090,18 @@ themes_load_from_dir (char const *path)
{
GDir *dir = g_dir_open (path, 0, NULL);
char const *d_name;
- char *uri, *mime_type;
if (dir == NULL)
return;
while ((d_name = g_dir_read_name (dir)) != NULL) {
- uri = g_strconcat ("file://", path, "/", d_name, NULL);
- mime_type = go_get_mime_type (uri);
+ char *fullname = g_build_filename (path, d_name, NULL);
+ char *uri = go_filename_to_uri (fullname);
+ char *mime_type = go_get_mime_type (uri);
if (!strcmp (mime_type, "application/x-theme"))
theme_load_from_uri (uri);
g_free (mime_type);
g_free (uri);
+ g_free (fullname);
}
g_dir_close (dir);
}
@@ -1107,7 +1110,6 @@ void
_gog_themes_init (void)
{
char *path;
- char const *home;
build_predefined_themes ();
@@ -1115,8 +1117,8 @@ _gog_themes_init (void)
path = g_build_filename (go_sys_data_dir (), "themes", NULL);
themes_load_from_dir (path);
g_free (path);
- home = getenv ("HOME");
- path = g_strconcat (home, "/.goffice/themes", NULL);
+
+ path = g_build_filename (g_get_home_dir (), ".goffice", "themes", NULL);
themes_load_from_dir (path);
g_free (path);
}
@@ -1124,10 +1126,12 @@ _gog_themes_init (void)
void
_gog_themes_shutdown (void)
{
- GSList *ptr;
-
- if (default_theme != NULL)
+ if (default_theme != NULL) {
g_object_unref (default_theme);
- for (ptr = themes; ptr != NULL ; ptr = ptr->next)
- g_object_unref (ptr->data);
+ default_theme = NULL;
+ }
+
+ go_slist_free_custom (g_slist_copy (themes), g_object_unref);
+ g_slist_free (themes);
+ themes = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]