From 4839cf5d44255304354adb7b361f98e5c787ab3c Mon Sep 17 00:00:00 2001
From: gunnar_g <gunnar_g@localhost>
Date: Wed, 10 Dec 2008 13:41:27 +0000
Subject: [PATCH] The leading slash is removed.  Instead of "" the first
 element is now a correct directoryname

---
 src/treeview.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/treeview.c b/src/treeview.c
index 5a80c84f..bac54077 100644
--- a/src/treeview.c
+++ b/src/treeview.c
@@ -2649,13 +2649,21 @@ treeview_create_country_list(const GPtrArray *country_list)
     gboolean create_new_line;
     // This variable will be used to lookup 
     gchar* previous_element;
+    gchar* current_country;
     
     for(i=0;i<country_list->len;i++)
     {
         // We get countries as <Continent>/<...>/<country>
         // We then try to build a tree using "/ or \" as a separator
         // 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++)
         {
             create_new_line = FALSE;
@@ -2666,7 +2674,7 @@ treeview_create_country_list(const GPtrArray *country_list)
                 create_new_line=TRUE;
             } 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) 
                     {
                         create_new_line=TRUE;