The leading slash is removed. Instead of "" the first element is now a correct directoryname

This commit is contained in:
gunnar_g 2008-12-10 13:41:27 +00:00
parent a6f1e29973
commit 40d31060d8
1 changed files with 10 additions and 2 deletions

View File

@ -2649,13 +2649,21 @@ treeview_create_country_list(const GPtrArray *country_list)
gboolean create_new_line; gboolean create_new_line;
// This variable will be used to lookup // This variable will be used to lookup
gchar* previous_element; gchar* previous_element;
gchar* current_country;
for(i=0;i<country_list->len;i++) for(i=0;i<country_list->len;i++)
{ {
// We get countries as <Continent>/<...>/<country> // We get countries as <Continent>/<...>/<country>
// We then try to build a tree using "/ or \" as a separator // We then try to build a tree using "/ or \" as a separator
// The list is already sorted, so we don't need to verify // The list is already sorted, so we don't need to verify
dir_split_up = g_strsplit_set ((gchar*)g_ptr_array_index(country_list, i), "\\/", -1); current_country = g_strdup((gchar*)g_ptr_array_index(country_list, i));
if (g_str_has_prefix(current_country,"/")||g_str_has_prefix(current_country,"\\"))
{
// Strip leading "\\"
sprintf(buf, "%.*s", strlen(current_country) - 1, &current_country[1]);
current_country = g_strdup(buf);
}
dir_split_up = g_strsplit_set (current_country, "\\/", -1);
for (j=0; j<g_strv_length(dir_split_up); j++) for (j=0; j<g_strv_length(dir_split_up); j++)
{ {
create_new_line = FALSE; create_new_line = FALSE;
@ -2666,7 +2674,7 @@ treeview_create_country_list(const GPtrArray *country_list)
create_new_line=TRUE; create_new_line=TRUE;
} else } else
{ {
gtk_tree_model_get (ls,(GtkTreeIter*)g_ptr_array_index(iterators,j), 1, &previous_element, -1); gtk_tree_model_get ((GtkTreeModel*)ls,(GtkTreeIter*)g_ptr_array_index(iterators,j), 1, &previous_element, -1);
if (strcmp(previous_element,dir_split_up[j])!=0) if (strcmp(previous_element,dir_split_up[j])!=0)
{ {
create_new_line=TRUE; create_new_line=TRUE;