Do not allow to add anything but directories to sort bar in
authorLaurent Monin <geeqie@norz.org>
Thu, 24 Apr 2008 20:18:59 +0000 (20:18 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 24 Apr 2008 20:18:59 +0000 (20:18 +0000)
folder mode through drag'n'drop.
Introduce a new field only_directories to _BookMarkData struct.

src/bar_sort.c
src/ui_bookmark.c
src/ui_bookmark.h

index 35f801a..9ea31f3 100644 (file)
@@ -135,6 +135,7 @@ static void bar_sort_mode_sync(SortData *sd, SortModeType mode)
 
        bookmark_list_set_no_defaults(sd->bookmarks, !folder_mode);
        bookmark_list_set_editable(sd->bookmarks, folder_mode);
+       bookmark_list_set_only_directories(sd->bookmarks, folder_mode);
 
        if (folder_mode)
                {
index 432b97d..80de82c 100644 (file)
@@ -376,6 +376,7 @@ struct _BookMarkData
 
        gint no_defaults;
        gint editable;
+       gint only_directories;
 
        BookButtonData *active_button;
 };
@@ -1010,11 +1011,12 @@ static void bookmark_dnd_get_data(GtkWidget *widget,
                gchar *path = work->data;
                gchar *buf;
 
+               work = work->next;
+
+               if (bm->only_directories && !isdir(path)) continue;
                buf = bookmark_string(filename_from_path(path), path, NULL);
                history_list_add_to_key(bm->key, buf, 0);
                g_free(buf);
-
-               work = work->next;
                }
 
        string_list_free(list);
@@ -1048,6 +1050,7 @@ GtkWidget *bookmark_list_new(const gchar *key,
 
        bm->no_defaults = FALSE;
        bm->editable = TRUE;
+       bm->only_directories = FALSE;
 
        scrolled = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
@@ -1114,6 +1117,16 @@ void bookmark_list_set_editable(GtkWidget *list, gint editable)
        bm->editable = editable;
 }
 
+void bookmark_list_set_only_directories(GtkWidget *list, gint only_directories)
+{
+       BookMarkData *bm;
+
+       bm = g_object_get_data(G_OBJECT(list), BOOKMARK_DATA_KEY);
+       if (!bm) return;
+
+       bm->only_directories = only_directories;
+}
+
 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path)
 {
        BookMarkData *bm;
index de77962..075c068 100644 (file)
@@ -41,6 +41,7 @@ GtkWidget *bookmark_list_new(const gchar *key,
 void bookmark_list_set_key(GtkWidget *list, const gchar *key);
 void bookmark_list_set_no_defaults(GtkWidget *list, gint no_defaults);
 void bookmark_list_set_editable(GtkWidget *list, gint editable);
+void bookmark_list_set_only_directories(GtkWidget *list, gint only_directories);
 void bookmark_list_add(GtkWidget *list, const gchar *name, const gchar *path);
 
 /* allows apps to set up the defaults */