From 1da7a5424b7ea012dde0b8fc8951db7bf9da7981 Mon Sep 17 00:00:00 2001 From: Harri Vattulainen Date: Tue, 9 Dec 2008 13:11:58 +0200 Subject: [PATCH] Modified layout_get_themes to check in what theme bg belongs. --- irreco/src/core/irreco_config.c | 72 ++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/irreco/src/core/irreco_config.c b/irreco/src/core/irreco_config.c index 7c70e30f..930e015e 100644 --- a/irreco/src/core/irreco_config.c +++ b/irreco/src/core/irreco_config.c @@ -284,7 +284,6 @@ void irreco_config_read_button_from_keyfile(IrrecoData * irreco_data, if (irreco_theme_manager_get_button_style( irreco_data->theme_manager, style_name, &style)) { - IRRECO_LINE IRRECO_PRINTF("Style: \"%s\"\n", style->name->str); } else { IRRECO_ERROR("Button uses unknown style \"%s\"\n", @@ -741,6 +740,7 @@ gboolean irreco_layout_get_themes(IrrecoData *data, IrrecoStringTable **list) { IrrecoStringTable *themelist = NULL; + gchar *bgpath = NULL; IRRECO_ENTER @@ -758,43 +758,63 @@ gboolean irreco_layout_get_themes(IrrecoData *data, key, IrrecoButtonLayout *, layout) - /* TODO get theme used by bg */ - IRRECO_DEBUG("Layout %s, bg img: %s\n", - layout->name->str, - layout->background_image->str); /* Skip layouts with wrong name */ - if(g_str_equal(layoutname, layout->name->str)) - IRRECO_PTR_ARRAY_FORWARDS(layout->button_array, - IrrecoButton *, - irreco_button) - gboolean match = FALSE; - IRRECO_STRING_TABLE_FOREACH_KEY(*list, themename) - if(g_str_equal( + if(g_str_equal(layoutname, layout->name->str)) { + if(layout->background_type == 2) { + bgpath = g_strdup(layout->background_image->str); + } + IRRECO_PTR_ARRAY_FORWARDS(layout->button_array, + IrrecoButton *, + irreco_button) + gboolean match = FALSE; + IRRECO_STRING_TABLE_FOREACH_KEY(*list, themename) + if(g_str_equal( irreco_button->style->theme_name->str, themename)) { match = TRUE; + } + IRRECO_STRING_TABLE_FOREACH_END + if(!match) { + irreco_string_table_add(*list, + irreco_button->style->theme_name->str, + NULL); } - IRRECO_STRING_TABLE_FOREACH_END - if(!match) { - irreco_string_table_add(*list, - irreco_button->style->theme_name->str, NULL); - } - IRRECO_PTR_ARRAY_BACKWARDS_END + IRRECO_PTR_ARRAY_BACKWARDS_END + } IRRECO_STRING_TABLE_FOREACH_END /* Loop through themes and get versions of wanted themes */ - IRRECO_STRING_TABLE_FOREACH_KEY(*list, themename) - IRRECO_STRING_TABLE_FOREACH(themelist, key, IrrecoTheme*, theme) - if(g_str_equal(themename, theme->name->str)) { - /*IRRECO_DEBUG("%s, %s, %s\n", - themename, - theme->name->str, - theme->version->str);*/ - irreco_string_table_change_data(*list, themename, theme->version->str); + IRRECO_STRING_TABLE_FOREACH(themelist, key, IrrecoTheme*, theme) + IRRECO_STRING_TABLE_FOREACH(theme->backgrounds, + bgkey, + IrrecoThemeBg*, + bgtheme) + if(bgpath != NULL) + if(g_str_equal(bgtheme->image_path->str, bgpath)) { + gboolean match = FALSE; + /* Matching theme found for bg */ + IRRECO_STRING_TABLE_FOREACH_KEY(*list, themename) + if(g_str_equal(theme->name->str, + themename)) { + match = TRUE; + } + IRRECO_STRING_TABLE_FOREACH_END + if(!match) { + irreco_string_table_add(*list, + theme->name->str, + NULL); + } } IRRECO_STRING_TABLE_FOREACH_END + IRRECO_STRING_TABLE_FOREACH_KEY(*list, themename) + if(g_str_equal(themename, theme->name->str)) { + irreco_string_table_change_data(*list, themename, theme->version->str); + } + IRRECO_STRING_TABLE_FOREACH_END IRRECO_STRING_TABLE_FOREACH_END + g_free(bgpath); + IRRECO_RETURN_BOOL(TRUE); } -- 2.11.4.GIT