1 This patch adds a button on the toolbar to change the sort function.
3 Updated for 1.3.3 CVS 2002-07-30 by Marcin Juszkiewicz <marcin@amiga.pl>
5 Index:rox-2002-05-26-sortbutton/ROX-Filer/src/toolbar.c
6 *** rox-2002-05-26/ROX-Filer/src/toolbar.c Mon May 27 09:46:34 2002
7 --- rox-2002-05-26-sortbutton/ROX-Filer/src/toolbar.c Mon May 27 10:51:47 2002
11 FilerWindow *filer_window);
12 static void toolbar_hidden_clicked(GtkWidget *widget,
13 FilerWindow *filer_window);
14 + static void toolbar_sort_clicked(GtkWidget *widget,
15 + FilerWindow *filer_window);
16 static GtkWidget *add_button(GtkWidget *bar, Tool *tool,
17 FilerWindow *filer_window);
18 static GtkWidget *create_toolbar(FilerWindow *filer_window);
22 toolbar_size_clicked, DROP_NONE, TRUE,
25 + {N_("Sort"), GTK_STOCK_SORT_ASCENDING, N_("Change sort criteria"),
26 + toolbar_sort_clicked, DROP_NONE, TRUE,
29 {N_("Details"), GTK_STOCK_JUSTIFY_LEFT, N_("Show extra details"),
30 toolbar_details_clicked, DROP_NONE, TRUE,
35 bev->type == GDK_BUTTON_RELEASE && bev->button == 1);
38 + /* This typedef makes things a lot easier... */
39 + typedef int (*sort_fn_t)(const void *a, const void *b);
41 + static void toolbar_sort_clicked(GtkWidget *widget, FilerWindow *filer_window)
43 + GdkEventButton *bev;
44 + int i, current, next;
47 + static sort_fn_t sort_fns[]={
48 + sort_by_name, sort_by_type, sort_by_date, sort_by_size
50 + #define NSORT (sizeof(sort_fns)/sizeof(sort_fn_t))
52 + bev = (GdkEventButton *) gtk_get_current_event();
53 + adjust=(bev->button == 2) && bev->type == GDK_BUTTON_RELEASE;
56 + for(i=0; i<NSORT; i++)
57 + if(filer_window->sort_fn==sort_fns[i]) {
64 + next=(current+NSORT-1)%NSORT;
66 + next=(current+1)%NSORT;
68 + display_set_sort_fn(filer_window, sort_fns[next]);
71 static void toolbar_details_clicked(GtkWidget *widget,
72 FilerWindow *filer_window)