[gnome-control-center] sound: Fallback if loading an inexistant custom theme



commit cdbff7ba6a7761ca8ef376e87a0b9b0442e33e9b
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 22 19:31:06 2011 +0000

    sound: Fallback if loading an inexistant custom theme
    
    If the sound theme is set to be a custom sound theme, but it
    does not exist, then we should fallback gracefully on the
    default sound theme, and avoid warnings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645541

 panels/sound/gvc-sound-theme-chooser.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/panels/sound/gvc-sound-theme-chooser.c b/panels/sound/gvc-sound-theme-chooser.c
index b9ab8fa..7cb73dc 100644
--- a/panels/sound/gvc-sound-theme-chooser.c
+++ b/panels/sound/gvc-sound-theme-chooser.c
@@ -68,6 +68,7 @@ G_DEFINE_TYPE (GvcSoundThemeChooser, gvc_sound_theme_chooser, GTK_TYPE_VBOX)
 #define DEFAULT_ALERT_ID        "__default"
 #define CUSTOM_THEME_NAME       "__custom"
 #define NO_SOUNDS_THEME_NAME    "__no_sounds"
+#define DEFAULT_THEME           "freedesktop"
 
 enum {
         THEME_DISPLAY_COL,
@@ -317,7 +318,7 @@ save_theme_name (GvcSoundThemeChooser *chooser,
 {
         /* If the name is empty, use "freedesktop" */
         if (theme_name == NULL || *theme_name == '\0') {
-                theme_name = "freedesktop";
+                theme_name = DEFAULT_THEME;
         }
 
         /* special case for no sounds */
@@ -413,7 +414,10 @@ update_alert (GvcSoundThemeChooser *chooser,
                 /* remove custom just in case */
                 remove_custom = TRUE;
         } else if (! is_custom && ! is_default) {
-                create_custom_theme (chooser->priv->current_parent);
+                if (chooser->priv->current_parent)
+                        create_custom_theme (chooser->priv->current_parent);
+                else
+                        create_custom_theme (DEFAULT_THEME);
                 save_alert_sounds (chooser, alert_id);
                 add_custom = TRUE;
         } else if (is_custom && is_default) {
@@ -669,8 +673,13 @@ update_theme (GvcSoundThemeChooser *chooser)
 
         if (g_strcmp0 (last_theme, chooser->priv->current_theme) != 0) {
                 g_free (chooser->priv->current_parent);
-                load_theme_name (chooser->priv->current_theme,
-                                 &chooser->priv->current_parent);
+                if (load_theme_name (chooser->priv->current_theme,
+                                     &chooser->priv->current_parent) == FALSE) {
+                        g_free (chooser->priv->current_theme);
+                        chooser->priv->current_theme = g_strdup (DEFAULT_THEME);
+                        load_theme_name (DEFAULT_THEME,
+                                         &chooser->priv->current_parent);
+                }
         }
         g_free (last_theme);
 



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