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
This commit is contained in:
Bastien Nocera 2011-03-22 19:31:06 +00:00
parent d7e4369d40
commit cdbff7ba6a

View file

@ -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) {
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,9 +673,14 @@ 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,
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);
gtk_widget_set_sensitive (chooser->priv->selection_box, events_enabled);