Fix crash on drag and drop from Xfe
[geeqie.git] / src / ui_bookmark.c
index a2a63aa..18f7311 100644 (file)
@@ -485,7 +485,7 @@ static void bookmark_drag_set_data(GtkWidget *button,
 
        gchar **uris = uris_from_filelist(list);
        gboolean ret = gtk_selection_data_set_uris(selection_data, uris);
-       if (!ret) 
+       if (!ret)
                {
                char *str = g_strjoinv("\r\n", uris);
                ret = gtk_selection_data_set_text(selection_data, str, -1);
@@ -502,7 +502,7 @@ static void bookmark_drag_begin(GtkWidget *button, GdkDragContext *context, gpoi
        GdkModifierType mask;
        gint x, y;
        GtkAllocation allocation;
-       
+
        gtk_widget_get_allocation(button, &allocation);
 
 #if GTK_CHECK_VERSION(3,0,0)
@@ -550,6 +550,10 @@ static void bookmark_populate(BookMarkData *bm)
                        history_list_add_to_key(bm->key, buf, 0);
                        g_free(buf);
 
+                       buf = bookmark_string(".", g_strdup(history_list_find_last_path_by_key("path_list")), NULL);
+                       history_list_add_to_key(bm->key, buf, 0);
+                       g_free(buf);
+
                        path = g_build_filename(homedir(), "Desktop", NULL);
                        if (isname(path))
                                {
@@ -570,7 +574,14 @@ static void bookmark_populate(BookMarkData *bm)
                        path = work->data;
                        work = work->next;
 
-                       buf = bookmark_string(name, path, NULL);
+                       if (strcmp(name, ".") == 0)
+                               {
+                               buf = bookmark_string(name, g_strdup(history_list_find_last_path_by_key("path_list")), NULL);
+                               }
+                       else
+                               {
+                               buf = bookmark_string(name, path, NULL);
+                               }
                        history_list_add_to_key(bm->key, buf, 0);
                        g_free(buf);
                        }
@@ -585,6 +596,16 @@ static void bookmark_populate(BookMarkData *bm)
                b = bookmark_from_string(work->data);
                if (b)
                        {
+                       if (strcmp(b->name, ".") == 0)
+                               {
+                               gchar *buf;
+
+                               b->path = g_strdup(history_list_find_last_path_by_key("path_list"));
+                               buf = bookmark_string(".", b->path, b->icon);
+                               history_list_item_change("bookmarks", b->key, buf);
+                               b->key = g_strdup(buf);
+                               g_free(buf);
+                               }
                        GtkWidget *box;
 
                        b->button = gtk_button_new();
@@ -686,13 +707,19 @@ static void bookmark_dnd_get_data(GtkWidget *widget,
 {
        BookMarkData *bm = data;
        GList *list = NULL;
+       GList *errors = NULL;
        GList *work;
        gchar **uris;
 
        if (!bm->editable) return;
 
        uris = gtk_selection_data_get_uris(selection_data);
-       list = uri_filelist_from_uris(uris);
+       list = uri_filelist_from_uris(uris, &errors);
+       if(errors)
+               {
+               warning_dialog_dnd_uri_error(errors);
+               string_list_free(errors);
+               }
        g_strfreev(uris);
 
        work = list;