[glide] Load default theme on startup



commit 4873d62b99d049a3a548c2be5a80ca64d0e9b85f
Author: Robert Carr <racarr Valentine localdomain>
Date:   Thu May 6 04:37:02 2010 -0400

    Load default theme on startup

 configure.ac                    |    1 +
 data/Makefile.am                |    2 +-
 data/themes/Makefile.am         |    5 +++++
 data/themes/default.glide-theme |    1 +
 libglide/glide-dirs.c           |   10 ++++++++++
 libglide/glide-dirs.h           |    3 +++
 libglide/glide-document-priv.h  |    2 ++
 libglide/glide-document.c       |   33 ++++++++++++++++++++++++++++++++-
 libglide/glide-document.h       |    4 ++++
 libglide/glide-theme.c          |    2 ++
 libglide/glide.c                |   22 ++++++++++++++++++++++
 libglide/glide.h                |    4 ++++
 12 files changed, 87 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2d2a2ac..7622fbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,7 @@ data/icons/hicolor/Makefile
 data/icons/hicolor/scalable/Makefile
 data/icons/hicolor/scalable/apps/Makefile
 data/ui/Makefile
+data/themes/Makefile
 libglide/Makefile
 po/Makefile.in
 src/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 2d52563..beeea76 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = ui icons
+SUBDIRS = ui icons themes
 
 desktopdir = $(datadir)/applications
 desktop_in_files = glide.desktop.in.in
diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am
new file mode 100644
index 0000000..856267d
--- /dev/null
+++ b/data/themes/Makefile.am
@@ -0,0 +1,5 @@
+themedir=$(datadir)/glide/themes
+theme_DATA = default.glide-theme
+
+EXTRA_DIST = \
+	$(theme_DATA)
\ No newline at end of file
diff --git a/data/themes/default.glide-theme b/data/themes/default.glide-theme
new file mode 100644
index 0000000..1796c20
--- /dev/null
+++ b/data/themes/default.glide-theme
@@ -0,0 +1 @@
+{"name":"Default Glide Theme"}
\ No newline at end of file
diff --git a/libglide/glide-dirs.c b/libglide/glide-dirs.c
index c5a0521..90b827d 100644
--- a/libglide/glide-dirs.c
+++ b/libglide/glide-dirs.c
@@ -45,3 +45,13 @@ glide_dirs_get_glide_ui_dir ()
   g_free (datadir);
   return uidir;
 }
+
+gchar *
+glide_dirs_get_glide_theme_dir ()
+{
+  gchar *datadir = glide_dirs_get_glide_data_dir();
+  gchar *themedir = g_build_filename(datadir, "themes", NULL);
+  
+  g_free (datadir);
+  return themedir;
+}
diff --git a/libglide/glide-dirs.h b/libglide/glide-dirs.h
index d083fc8..9bc017e 100644
--- a/libglide/glide-dirs.h
+++ b/libglide/glide-dirs.h
@@ -31,4 +31,7 @@ glide_dirs_get_glide_image_dir (void);
 gchar *
 glide_dirs_get_glide_ui_dir (void);
 
+gchar *
+glide_dirs_get_glide_theme_dir (void);
+
 #endif
diff --git a/libglide/glide-document-priv.h b/libglide/glide-document-priv.h
index 1b8588b..80951ba 100644
--- a/libglide/glide-document-priv.h
+++ b/libglide/glide-document-priv.h
@@ -34,6 +34,8 @@ struct _GlideDocumentPrivate
   
   gint width, height;
   gboolean dirty;
+
+  GlideTheme *theme;
 };
 
 G_END_DECLS
diff --git a/libglide/glide-document.c b/libglide/glide-document.c
index cc8467e..e382c25 100644
--- a/libglide/glide-document.c
+++ b/libglide/glide-document.c
@@ -42,7 +42,8 @@ enum {
   PROP_PATH,
   PROP_WIDTH,
   PROP_HEIGHT,
-  PROP_DIRTY
+  PROP_DIRTY,
+  PROP_THEME
 };
 
 #define DEFAULT_PRESENTATION_WIDTH 800
@@ -98,6 +99,9 @@ glide_document_get_property (GObject *object,
     case PROP_DIRTY:
       g_value_set_boolean (value, document->priv->dirty);
       break;
+    case PROP_THEME:
+      g_value_set_object (value, document->priv->theme);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -134,6 +138,9 @@ glide_document_set_property (GObject *object,
     case PROP_DIRTY:
       glide_document_set_dirty (document, g_value_get_boolean (value));
       break;
+    case PROP_THEME:
+      glide_document_set_theme (document, (GlideTheme *)g_value_get_object (value));
+      break;
     default: 
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -191,6 +198,17 @@ glide_document_class_init (GlideDocumentClass *klass)
 							 FALSE,
 							 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (object_class,
+				   PROP_THEME,
+				   g_param_spec_object ("theme",
+							"Theme",
+							"The documents theme",
+							GLIDE_TYPE_THEME,
+							G_PARAM_READWRITE |
+							G_PARAM_STATIC_STRINGS));
+
+
+
   document_signals[SLIDE_ADDED] = 
     g_signal_new ("slide-added",
 		  G_TYPE_FROM_CLASS (object_class),
@@ -569,3 +587,16 @@ glide_document_get_resource_path (GlideDocument *d,
   return g_strdup_printf("%s/resources/%s",d->priv->working_path,
 			 resource_name);
 }
+
+GlideTheme *
+glide_document_get_theme (GlideDocument *d)
+{
+  return d->priv->theme;
+}
+
+void
+glide_document_set_theme (GlideDocument *d, GlideTheme *theme)
+{
+  d->priv->theme = theme;
+  g_object_notify (G_OBJECT (d), "theme");
+}
diff --git a/libglide/glide-document.h b/libglide/glide-document.h
index 1eaa71b..9110737 100644
--- a/libglide/glide-document.h
+++ b/libglide/glide-document.h
@@ -26,6 +26,7 @@
 #include <json-glib/json-glib.h>
 
 #include "glide-types.h"
+#include "glide-theme.h"
 
 G_BEGIN_DECLS
 
@@ -104,6 +105,9 @@ JsonParser *glide_document_load_archive (GlideDocument *d,
 gchar *glide_document_add_resource (GlideDocument *d, const gchar *filename);
 gchar *glide_document_get_resource_path (GlideDocument *d, const gchar *resource_name);
 
+void glide_document_set_theme (GlideDocument *d, GlideTheme *theme);
+GlideTheme *glide_document_get_theme (GlideDocument *d);
+
 G_END_DECLS
 
 #endif  /* __GLIDE_DOCUMENT_H__  */
diff --git a/libglide/glide-theme.c b/libglide/glide-theme.c
index f5302cf..1d10ef6 100644
--- a/libglide/glide-theme.c
+++ b/libglide/glide-theme.c
@@ -62,6 +62,8 @@ glide_theme_parse_theme (GlideTheme *theme)
       g_object_unref (G_OBJECT (p));
       g_free (sec);
     }
+  
+  return p;
 }
 
 static void
diff --git a/libglide/glide.c b/libglide/glide.c
index 7a14658..536c81f 100644
--- a/libglide/glide.c
+++ b/libglide/glide.c
@@ -19,8 +19,10 @@
 #include "glide.h"
 #include "glide-animation-manager.h"
 #include "glide-debug.h"
+#include "glide-dirs.h"
 
 guint glide_debug_flags = 0;
+GlideTheme *default_theme = NULL;
 
 #ifdef GLIDE_ENABLE_DEBUG
 static const GDebugKey glide_debug_keys[] = {
@@ -104,11 +106,31 @@ glide_parse_args (int *argc, char ***argv)
   return ret;
 }
 
+static void
+glide_load_default_theme ()
+{
+  gchar *theme_dir = glide_dirs_get_glide_theme_dir ();
+  gchar *theme_path = g_strconcat (theme_dir, "/default.glide-theme", NULL);
+  
+  default_theme = glide_theme_new (theme_path);
+  
+  g_free (theme_dir);
+  g_free (theme_path);
+}
+
 gboolean
 glide_init (int *argc, char ***argv)
 {
   gboolean res = glide_parse_args (argc, argv);
 
   glide_animation_manager_register_animations ();
+  glide_load_default_theme ();
+
   return res;
 }
+
+GlideTheme *
+glide_get_default_theme ()
+{
+  return default_theme;
+}
diff --git a/libglide/glide.h b/libglide/glide.h
index c0c0699..7f7ed0a 100644
--- a/libglide/glide.h
+++ b/libglide/glide.h
@@ -19,10 +19,14 @@
 #ifndef __GLIDE_H__
 #define __GLIDE_H__
 #include <glib.h>
+#include "glide-theme.h"
 
 G_BEGIN_DECLS
 GOptionGroup *glide_get_option_group (void);
 gboolean glide_init (int *argc, char ***argv);
+
+GlideTheme *glide_get_default_theme ();
+
 G_END_DECLS
 
 #endif



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