changeset 521:57007e49d767

Do not allow to add anything but directories to sort bar in folder mode through drag'n'drop. Introduce a new field only_directories to _BookMarkData struct.
author zas_
date Thu, 24 Apr 2008 20:18:59 +0000
parents b5e79bcb46df
children fd4208f8b5f3
files src/bar_sort.c src/ui_bookmark.c src/ui_bookmark.h
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_sort.c	Thu Apr 24 16:35:02 2008 +0000
+++ b/src/bar_sort.c	Thu Apr 24 20:18:59 2008 +0000
@@ -135,6 +135,7 @@
 
 	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)
 		{
--- a/src/ui_bookmark.c	Thu Apr 24 16:35:02 2008 +0000
+++ b/src/ui_bookmark.c	Thu Apr 24 20:18:59 2008 +0000
@@ -376,6 +376,7 @@
 
 	gint no_defaults;
 	gint editable;
+	gint only_directories;
 
 	BookButtonData *active_button;
 };
@@ -1010,11 +1011,12 @@
 		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 @@
 
 	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 @@
 	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;
--- a/src/ui_bookmark.h	Thu Apr 24 16:35:02 2008 +0000
+++ b/src/ui_bookmark.h	Thu Apr 24 20:18:59 2008 +0000
@@ -41,6 +41,7 @@
 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 */