[glide] Themes inside archives
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Themes inside archives
- Date: Thu, 6 May 2010 09:18:37 +0000 (UTC)
commit 2f486b3eb41428379560e5396218a232a18554f7
Author: Robert Carr <racarr Valentine localdomain>
Date: Thu May 6 05:19:19 2010 -0400
Themes inside archives
configure.ac | 1 -
data/themes/default/Makefile.am | 10 +++++-
data/themes/default/default.glide-theme.in | 2 -
data/themes/default/theme.json | 2 +
libglide/glide-theme-priv.h | 2 +
libglide/glide-theme.c | 41 +++++++++++++++++++++++++--
6 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 40e7cd3..da6cff2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,7 +93,6 @@ data/icons/hicolor/scalable/apps/Makefile
data/ui/Makefile
data/themes/Makefile
data/themes/default/Makefile
-data/themes/default/default.glide-theme
libglide/Makefile
po/Makefile.in
src/Makefile
diff --git a/data/themes/default/Makefile.am b/data/themes/default/Makefile.am
index ebabf87..9d50619 100644
--- a/data/themes/default/Makefile.am
+++ b/data/themes/default/Makefile.am
@@ -1,5 +1,11 @@
themedir=$(datadir)/glide/themes/default
-theme_DATA = default.glide-theme background.png
+theme_DATA = default.glide-theme
+
+theme_FILES = theme.json background.png
+
+default.glide-theme: theme.json background.png
+ tar -cjspf default.glide-theme $(theme_FILES)
EXTRA_DIST = \
- $(theme_DATA)
\ No newline at end of file
+ $(theme_DATA) \
+ $(theme_FILES)
\ No newline at end of file
diff --git a/data/themes/default/theme.json b/data/themes/default/theme.json
new file mode 100644
index 0000000..18c585e
--- /dev/null
+++ b/data/themes/default/theme.json
@@ -0,0 +1,2 @@
+{"name":"Default Glide Theme",
+"default_background":"background.png"}
\ No newline at end of file
diff --git a/libglide/glide-theme-priv.h b/libglide/glide-theme-priv.h
index bb21a01..fbaad38 100644
--- a/libglide/glide-theme-priv.h
+++ b/libglide/glide-theme-priv.h
@@ -28,6 +28,8 @@ struct _GlideThemePrivate
{
gchar *path;
gchar *name;
+
+ gchar *working_path;
gchar *default_background;
};
diff --git a/libglide/glide-theme.c b/libglide/glide-theme.c
index a881e8b..b4de9e4 100644
--- a/libglide/glide-theme.c
+++ b/libglide/glide-theme.c
@@ -50,8 +50,9 @@ glide_theme_parse_theme (GlideTheme *theme)
{
JsonParser *p = json_parser_new ();
GError *e = NULL;
+ gchar *json_file = g_strconcat (theme->priv->working_path, "/", "theme.json", NULL);
- json_parser_load_from_file (p, theme->priv->path, &e);
+ json_parser_load_from_file (p, json_file, &e);
if (e)
{
gchar *sec = g_strdup_printf ("Failed to load theme: %s", theme->priv->path);
@@ -62,23 +63,41 @@ glide_theme_parse_theme (GlideTheme *theme)
g_error_free (e);
g_object_unref (G_OBJECT (p));
g_free (sec);
+ g_free (json_file);
+
+ return NULL;
}
+ g_free (json_file);
return p;
}
static void
+glide_theme_extract_archive (GlideTheme *theme)
+{
+ gchar *command = g_strdup_printf ("tar -xjf %s -C %s",
+ theme->priv->path,
+ theme->priv->working_path);
+ system(command);
+ g_free(command);
+}
+
+static void
glide_theme_load_file (GlideTheme *theme)
{
- JsonParser *p = glide_theme_parse_theme (theme);
+ JsonParser *p;
JsonNode *root;
JsonObject *root_object;
+ glide_theme_extract_archive (theme);
+
+ p = glide_theme_parse_theme (theme);
+
root = json_parser_get_root (p);
root_object = json_node_get_object (root);
theme->priv->name = g_strdup (glide_json_object_get_string (root_object, "name"));
- theme->priv->default_background = g_strdup (glide_json_object_get_string (root_object, "default_background"));
+ theme->priv->default_background = g_strconcat (theme->priv->working_path, "/", glide_json_object_get_string (root_object, "default_background"), NULL);
g_object_unref (G_OBJECT (p));
}
@@ -100,6 +119,7 @@ glide_theme_finalize (GObject *object)
g_free (theme->priv->name);
g_free (theme->priv->path);
g_free (theme->priv->default_background);
+ g_free (theme->priv->working_path);
G_OBJECT_CLASS (glide_theme_parent_class)->finalize (object);
}
@@ -183,9 +203,24 @@ glide_theme_class_init (GlideThemeClass *klass)
}
static void
+glide_theme_make_working_dir (GlideTheme *d)
+{
+ gchar *wdir;
+ wdir = g_strdup_printf("%s/glide-theme-%ld", g_get_tmp_dir(), time(NULL));
+ g_mkdir(wdir, 0700);
+
+ if (d->priv->working_path)
+ g_free (d->priv->working_path);
+
+ d->priv->working_path = wdir;
+}
+
+static void
glide_theme_init (GlideTheme *d)
{
d->priv = GLIDE_THEME_GET_PRIVATE (d);
+
+ glide_theme_make_working_dir (d);
}
GlideTheme *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]