comparison 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
comparison
equal deleted inserted replaced
1166:26b9fca795f8 1167:e812b1a7adda
61 GtkWidget *entry; 61 GtkWidget *entry;
62 gchar *dir_path; 62 gchar *dir_path;
63 GList *file_list; 63 GList *file_list;
64 void (*enter_func)(const gchar *, gpointer); 64 void (*enter_func)(const gchar *, gpointer);
65 void (*tab_func)(const gchar *, gpointer); 65 void (*tab_func)(const gchar *, gpointer);
66 void (*tab_append_func)(const gchar *, gpointer, gint);
67
66 gpointer enter_data; 68 gpointer enter_data;
67 gpointer tab_data; 69 gpointer tab_data;
68 70 gpointer tab_append_data;
71
69 GtkWidget *combo; 72 GtkWidget *combo;
70 gint has_history; 73 gint has_history;
71 gchar *history_key; 74 gchar *history_key;
72 gint history_levels; 75 gint history_levels;
73 76
731 void tab_completion_append_to_history(GtkWidget *entry, const gchar *path) 734 void tab_completion_append_to_history(GtkWidget *entry, const gchar *path)
732 { 735 {
733 TabCompData *td; 736 TabCompData *td;
734 GtkTreeModel *store; 737 GtkTreeModel *store;
735 GList *work; 738 GList *work;
739 gint n = 0;
736 740
737 td = g_object_get_data(G_OBJECT(entry), "tab_completion_data"); 741 td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
738 742
739 if (!path) return; 743 if (!path) return;
740 744
750 work = history_list_get_by_key(td->history_key); 754 work = history_list_get_by_key(td->history_key);
751 while (work) 755 while (work)
752 { 756 {
753 gtk_combo_box_append_text(GTK_COMBO_BOX(td->combo), (gchar *)work->data); 757 gtk_combo_box_append_text(GTK_COMBO_BOX(td->combo), (gchar *)work->data);
754 work = work->next; 758 work = work->next;
755 } 759 n++;
760 }
761
762 if (td->tab_append_func) {
763 td->tab_append_func(path, td->tab_append_data, n);
764 }
756 } 765 }
757 766
758 GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text, 767 GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text,
759 void (*enter_func)(const gchar *, gpointer), gpointer data) 768 void (*enter_func)(const gchar *, gpointer), gpointer data)
760 { 769 {
817 826
818 td->tab_func = tab_func; 827 td->tab_func = tab_func;
819 td->tab_data = data; 828 td->tab_data = data;
820 } 829 }
821 830
831 /* Add a callback function called when a new entry is appended to the list */
832 void tab_completion_add_append_func(GtkWidget *entry, void (*tab_append_func)(const gchar *, gpointer, gint), gpointer data)
833 {
834 TabCompData *td = g_object_get_data(G_OBJECT(entry), "tab_completion_data");
835
836 if (!td) return;
837
838 td->tab_append_func = tab_append_func;
839 td->tab_append_data = data;
840 }
841
822 gchar *remove_trailing_slash(const gchar *path) 842 gchar *remove_trailing_slash(const gchar *path)
823 { 843 {
824 gint l; 844 gint l;
825 845
826 if (!path) return NULL; 846 if (!path) return NULL;