gnome-control-center r8692 - in trunk/capplets: appearance common



Author: jensg
Date: Tue May  6 17:41:57 2008
New Revision: 8692
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8692&view=rev

Log:
2008-05-06  Jens Granseuer  <jensgr gmx net>

	* Makefile.am:
	* gnome-theme-info.c: (gnome_theme_info_error_quark),
	(gnome_theme_meta_info_free), (gnome_theme_meta_info_validate):
	* gnome-theme-info.h: move metatheme validation code here from the
	appearance capplet and add proper error codes

2008-05-06  Jens Granseuer  <jensgr gmx net>

	* Makefile.am:
	* appearance-themes.c: (theme_message_area_update): move metatheme
	validation code to common/gnome-theme-info.c


Modified:
   trunk/capplets/appearance/ChangeLog
   trunk/capplets/appearance/Makefile.am
   trunk/capplets/appearance/appearance-themes.c
   trunk/capplets/common/ChangeLog
   trunk/capplets/common/Makefile.am
   trunk/capplets/common/gnome-theme-info.c
   trunk/capplets/common/gnome-theme-info.h

Modified: trunk/capplets/appearance/Makefile.am
==============================================================================
--- trunk/capplets/appearance/Makefile.am	(original)
+++ trunk/capplets/appearance/Makefile.am	Tue May  6 17:41:57 2008
@@ -57,7 +57,6 @@
 	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
 	-DGNOMECC_GLADE_DIR="\"$(gladedir)\"" \
 	-DGNOMECC_PIXMAP_DIR="\"$(pixmapdir)\"" \
-	-DGTK_ENGINE_DIR="\"$(GTK_ENGINE_DIR)\"" \
 	-DWALLPAPER_DATADIR="\"$(wallpaperdir)\""
 
 CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)

Modified: trunk/capplets/appearance/appearance-themes.c
==============================================================================
--- trunk/capplets/appearance/appearance-themes.c	(original)
+++ trunk/capplets/appearance/appearance-themes.c	Tue May  6 17:41:57 2008
@@ -352,67 +352,6 @@
   return TRUE;
 }
 
-static gchar *
-theme_validate (const GnomeThemeMetaInfo *info)
-{
-  GnomeThemeInfo *theme;
-  gchar *gtkrc;
-
-  theme = gnome_theme_info_find (info->gtk_theme_name);
-  if (!theme || !theme->has_gtk) {
-    return g_strdup_printf (
-        _("This theme will not look as intended because the required GTK+ theme '%s' is not installed."),
-          info->gtk_theme_name);
-  }
-
-  theme = gnome_theme_info_find (info->metacity_theme_name);
-  if (!theme || !theme->has_metacity) {
-    return g_strdup_printf (
-        _("This theme will not look as intended because the required window manager theme '%s' is not installed."),
-          info->metacity_theme_name);
-  }
-
-  if (!gnome_theme_icon_info_find (info->icon_theme_name)) {
-    return g_strdup_printf (
-        _("This theme will not look as intended because the required icon theme '%s' is not installed."),
-        info->gtk_theme_name);
-  }
-
-  /* check for gtk theme engines */
-  gtkrc = gtkrc_find_named (info->gtk_theme_name);
-  if (gtkrc) {
-    GSList *engines = NULL, *l;
-    gchar *msg = NULL;
-    gboolean found;
-
-    gtkrc_get_details (gtkrc, &engines, NULL);
-    g_free (gtkrc);
-
-    for (l = engines; l; l = l->next) {
-      gchar *lib = g_strconcat ("lib", l->data, ".so", NULL);
-      gchar *full = g_build_filename (GTK_ENGINE_DIR, lib, NULL);
-
-      g_free (lib);
-      found = g_file_test (full, G_FILE_TEST_EXISTS);
-      g_free (full);
-
-      if (!found) {
-        msg = g_strdup_printf (
-            _("This theme will not look as intended because the required GTK+ theme engine '%s' is not installed."),
-            (gchar *) l->data);
-        break;
-      }
-    }
-
-    g_slist_foreach (engines, (GFunc) g_free, NULL);
-    g_slist_free (engines);
-
-    return msg;
-  }
-
-  return NULL;
-}
-
 static void
 theme_set_custom_from_theme (const GnomeThemeMetaInfo *info, AppearanceData *data)
 {
@@ -639,16 +578,15 @@
   gboolean show_revert_font = FALSE;
   gboolean show_error;
   const gchar *message;
-  gchar *error_message;
   gchar *font;
+  GError *error = NULL;
 
   theme = theme_get_selected (GTK_ICON_VIEW (glade_xml_get_widget (data->xml, "theme_list")), data);
 
   if (!theme)
     return;
 
-  error_message = theme_validate (theme);
-  show_error = (error_message != NULL);
+  show_error = !gnome_theme_meta_info_validate (theme, &error);
 
   if (!show_error) {
     if (theme->background_image != NULL) {
@@ -747,7 +685,7 @@
   }
 
   if (show_error)
-    message = error_message;
+    message = error->message;
   else if (show_apply_background && show_apply_font && show_revert_font)
     message = _("The current theme suggests a background and a font. Also, the last applied font suggestion can be reverted.");
   else if (show_apply_background && show_revert_font)
@@ -796,7 +734,7 @@
   }
 
   gtk_label_set_text (GTK_LABEL (data->theme_message_label), message);
-  g_free (error_message);
+  g_clear_error (&error);
 }
 
 static void

Modified: trunk/capplets/common/Makefile.am
==============================================================================
--- trunk/capplets/common/Makefile.am	(original)
+++ trunk/capplets/common/Makefile.am	Tue May  6 17:41:57 2008
@@ -3,13 +3,13 @@
 INCLUDES = \
 	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""				\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""			\
+	-DGTK_ENGINE_DIR="\"$(GTK_ENGINE_DIR)\"" 			\
 	-DG_LOG_DOMAIN=\"capplet-common\"				\
 	-DINSTALL_PREFIX=\"$(prefix)\"					\
 	-I$(top_srcdir)							\
 	-I$(top_srcdir)/libbackground					\
 	-I$(top_srcdir)/libwindow-settings				\
 	$(DBUS_CFLAGS)							\
-	$(VFS_CAPPLET_CFLAGS)						\
 	$(GNOME_DESKTOP_CFLAGS)						\
 	$(METACITY_CFLAGS)						\
 	$(GSD_DBUS_CFLAGS)

Modified: trunk/capplets/common/gnome-theme-info.c
==============================================================================
--- trunk/capplets/common/gnome-theme-info.c	(original)
+++ trunk/capplets/common/gnome-theme-info.c	Tue May  6 17:41:57 2008
@@ -251,6 +251,12 @@
   }
 }
 
+GQuark
+gnome_theme_info_error_quark (void)
+{
+  return g_quark_from_static_string ("gnome-theme-info-error-quark");
+}
+
 GnomeThemeMetaInfo *
 gnome_theme_read_meta_theme (GFile *meta_theme_uri)
 {
@@ -1554,6 +1560,71 @@
   g_free (meta_theme_info);
 }
 
+gboolean
+gnome_theme_meta_info_validate (GnomeThemeMetaInfo *info, GError **error)
+{
+  GnomeThemeInfo *theme;
+  gchar *gtkrc;
+
+  g_assert (error == NULL || *error == NULL);
+
+  theme = gnome_theme_info_find (info->gtk_theme_name);
+  if (!theme || !theme->has_gtk) {
+    g_set_error (error, GNOME_THEME_ERROR, GNOME_THEME_ERROR_GTK_THEME_NOT_AVAILABLE,
+                 _("This theme will not look as intended because the required GTK+ theme '%s' is not installed."),
+                 info->gtk_theme_name);
+    return FALSE;
+  }
+
+  theme = gnome_theme_info_find (info->metacity_theme_name);
+  if (!theme || !theme->has_metacity) {
+    g_set_error (error, GNOME_THEME_ERROR, GNOME_THEME_ERROR_WM_THEME_NOT_AVAILABLE,
+                 _("This theme will not look as intended because the required window manager theme '%s' is not installed."),
+                 info->metacity_theme_name);
+    return FALSE;
+  }
+
+  if (!gnome_theme_icon_info_find (info->icon_theme_name)) {
+    g_set_error (error, GNOME_THEME_ERROR, GNOME_THEME_ERROR_ICON_THEME_NOT_AVAILABLE,
+                 _("This theme will not look as intended because the required icon theme '%s' is not installed."),
+                 info->icon_theme_name);
+    return FALSE;
+  }
+
+  /* check for gtk theme engines */
+  gtkrc = gtkrc_find_named (info->gtk_theme_name);
+  if (gtkrc) {
+    GSList *engines = NULL, *l;
+    gboolean found;
+
+    gtkrc_get_details (gtkrc, &engines, NULL);
+    g_free (gtkrc);
+
+    for (l = engines; l; l = l->next) {
+      gchar *lib = g_strconcat ("lib", l->data, ".so", NULL);
+      gchar *full = g_build_filename (GTK_ENGINE_DIR, lib, NULL);
+
+      g_free (lib);
+      found = g_file_test (full, G_FILE_TEST_EXISTS);
+      g_free (full);
+
+      if (!found) {
+        g_set_error (error, GNOME_THEME_ERROR, GNOME_THEME_ERROR_GTK_THEME_NOT_AVAILABLE,
+                     _("This theme will not look as intended because the required GTK+ theme engine '%s' is not installed."),
+                     (gchar *) l->data);
+        break;
+      }
+    }
+
+    g_slist_foreach (engines, (GFunc) g_free, NULL);
+    g_slist_free (engines);
+
+    return found;
+  }
+
+  return TRUE;
+}
+
 GnomeThemeMetaInfo *
 gnome_theme_meta_info_find (const char *meta_theme_name)
 {

Modified: trunk/capplets/common/gnome-theme-info.h
==============================================================================
--- trunk/capplets/common/gnome-theme-info.h	(original)
+++ trunk/capplets/common/gnome-theme-info.h	Tue May  6 17:41:57 2008
@@ -128,13 +128,23 @@
 				       GnomeThemeChangeType  change_type,
 				       gpointer              user_data);
 
+#define GNOME_THEME_ERROR gnome_theme_info_error_quark ()
+
+enum {
+  GNOME_THEME_ERROR_GTK_THEME_NOT_AVAILABLE = 1,
+  GNOME_THEME_ERROR_WM_THEME_NOT_AVAILABLE,
+  GNOME_THEME_ERROR_ICON_THEME_NOT_AVAILABLE,
+  GNOME_THEME_ERROR_GTK_ENGINE_NOT_AVAILABLE,
+  GNOME_THEME_ERROR_UNKNOWN
+};
+
 
 /* GTK/Metacity/keybinding Themes */
 GnomeThemeInfo     *gnome_theme_info_new                   (void);
 void                gnome_theme_info_free                  (GnomeThemeInfo     *theme_info);
 GnomeThemeInfo     *gnome_theme_info_find                  (const gchar        *theme_name);
 GList              *gnome_theme_info_find_by_type          (guint               elements);
-
+GQuark              gnome_theme_info_error_quark           (void);
 
 /* Icon Themes */
 GnomeThemeIconInfo *gnome_theme_icon_info_new              (void);
@@ -159,6 +169,8 @@
 GList              *gnome_theme_meta_info_find_all         (void);
 gint                gnome_theme_meta_info_compare          (GnomeThemeMetaInfo *a,
 							    GnomeThemeMetaInfo *b);
+gboolean            gnome_theme_meta_info_validate         (const GnomeThemeMetaInfo *info,
+                                                            GError            **error);
 GnomeThemeMetaInfo *gnome_theme_read_meta_theme            (GFile              *meta_theme_uri);
 
 /* Other */



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