diff src/ui_tabcomp.c @ 1167:e812b1a7adda

Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
author zas_
date Sat, 22 Nov 2008 16:24:23 +0000
parents 1646720364cf
children 0bea79d87065
line wrap: on
line diff
--- a/src/ui_tabcomp.c	Thu Nov 20 17:28:34 2008 +0000
+++ b/src/ui_tabcomp.c	Sat Nov 22 16:24:23 2008 +0000
@@ -63,9 +63,12 @@
 	GList *file_list;
 	void (*enter_func)(const gchar *, gpointer);
 	void (*tab_func)(const gchar *, gpointer);
+	void (*tab_append_func)(const gchar *, gpointer, gint);
+
 	gpointer enter_data;
 	gpointer tab_data;
-
+	gpointer tab_append_data;
+	
 	GtkWidget *combo;
 	gint has_history;
 	gchar *history_key;
@@ -733,6 +736,7 @@
 	TabCompData *td;
 	GtkTreeModel *store;
 	GList *work;
+	gint n = 0;
 
 	td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
 
@@ -752,7 +756,12 @@
 		{
 		gtk_combo_box_append_text(GTK_COMBO_BOX(td->combo), (gchar *)work->data);
 		work = work->next;
+		n++;
 		}
+
+	if (td->tab_append_func) {
+		td->tab_append_func(path, td->tab_append_data, n);
+	}
 }
 
 GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text,
@@ -819,6 +828,17 @@
 	td->tab_data = data;
 }
 
+/* Add a callback function called when a new entry is appended to the list */
+void tab_completion_add_append_func(GtkWidget *entry, void (*tab_append_func)(const gchar *, gpointer, gint), gpointer data)
+{
+	TabCompData *td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
+
+	if (!td) return;
+
+	td->tab_append_func = tab_append_func;
+	td->tab_append_data = data;
+}
+
 gchar *remove_trailing_slash(const gchar *path)
 {
 	gint l;