[glide] Begin implementing themeing



commit 0b45348f989bb8e6e3052435c1aac6dde53fce25
Author: Robert Carr <racarr Valentine localdomain>
Date:   Thu May 6 04:23:01 2010 -0400

    Begin implementing themeing

 libglide/glide-document.c |    1 +
 libglide/glide-theme.c    |   41 ++++++++++++++++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/libglide/glide-document.c b/libglide/glide-document.c
index ad8c126..cc8467e 100644
--- a/libglide/glide-document.c
+++ b/libglide/glide-document.c
@@ -523,6 +523,7 @@ glide_document_load_archive (GlideDocument *d,
       g_error_free (e);
       g_object_unref (G_OBJECT (p));
       g_free (json_file);
+      g_free (sec);
       
       return NULL;
     }
diff --git a/libglide/glide-theme.c b/libglide/glide-theme.c
index 43da76e..f5302cf 100644
--- a/libglide/glide-theme.c
+++ b/libglide/glide-theme.c
@@ -21,11 +21,10 @@
 #include "glide-theme.h"
 #include "glide-theme-priv.h"
 
-#include <girepository.h>
-#include <glib/gstdio.h>
-
 #include <gio/gio.h>
 
+#include "glide-gtk-util.h"
+#include "glide-json-util.h"
 #include "glide-debug.h"
 
 
@@ -45,12 +44,48 @@ enum {
 
 static guint theme_signals[LAST_SIGNAL] = { 0, };*/
 
+static JsonParser *
+glide_theme_parse_theme (GlideTheme *theme)
+{
+  JsonParser *p = json_parser_new ();
+  GError *e = NULL;
+
+  json_parser_load_from_file (p, theme->priv->path, &e);
+  if (e)
+    {
+      gchar *sec = g_strdup_printf ("Failed to load theme: %s", theme->priv->path);
+      g_warning ("Error loading theme: %s", e->message);
+      
+      glide_gtk_util_show_error_dialog ("Failed to load theme", sec);
+      
+      g_error_free (e);
+      g_object_unref (G_OBJECT (p));
+      g_free (sec);
+    }
+}
+
+static void
+glide_theme_load_file (GlideTheme *theme)
+{
+  JsonParser *p = glide_theme_parse_theme (theme);
+  JsonNode *root;
+  JsonObject *root_object;
+  
+  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"));
+  
+  g_object_unref (G_OBJECT (p));
+}
 
 static void
 glide_theme_set_path (GlideTheme *theme, gchar *path)
 {
   g_return_if_fail (theme->priv->path == NULL);
   theme->priv->path = path;
+  
+  glide_theme_load_file (theme);
 }
 
 static void



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