diff -cr rox-1.3.9/ROX-Filer/src/toolbar.c rox-1.3.9-sortbutton/ROX-Filer/src/toolbar.c *** rox-1.3.9/ROX-Filer/src/toolbar.c Tue Apr 15 21:09:26 2003 --- rox-1.3.9-sortbutton/ROX-Filer/src/toolbar.c Wed May 21 17:49:32 2003 *************** *** 42,47 **** --- 42,48 ---- #include "diritem.h" #include "view_iface.h" #include "bookmarks.h" + #include "gui_support.h" typedef struct _Tool Tool; *************** *** 84,89 **** --- 85,92 ---- FilerWindow *filer_window); static void toolbar_hidden_clicked(GtkWidget *widget, FilerWindow *filer_window); + static void toolbar_sort_clicked(GtkWidget *widget, + FilerWindow *filer_window); static GtkWidget *add_button(GtkWidget *bar, Tool *tool, FilerWindow *filer_window); static GtkWidget *create_toolbar(FilerWindow *filer_window); *************** *** 138,143 **** --- 141,150 ---- toolbar_details_clicked, DROP_NONE, TRUE, FALSE}, + {N_("Sort"), GTK_STOCK_SORT_ASCENDING, N_("Change sort criteria"), + toolbar_sort_clicked, DROP_NONE, TRUE, + FALSE}, + {N_("Hidden"), ROX_STOCK_SHOW_HIDDEN, N_("Show/hide hidden files"), toolbar_hidden_clicked, DROP_NONE, TRUE, FALSE}, *************** *** 378,383 **** --- 385,446 ---- return; display_change_size(filer_window, bev->button == 1); + } + + static void toolbar_sort_clicked(GtkWidget *widget, + FilerWindow *filer_window) + { + GdkEventButton *bev; + int i, current, next; + gboolean adjust; + GtkSortType dir; + gchar *tip; + + static const SortType sorts[]={ + SORT_NAME, SORT_TYPE, SORT_DATE, SORT_SIZE, + SORT_OWNER, SORT_GROUP, + }; + static const int nsorts=sizeof(sorts)/sizeof(sorts[0]); + static const char *sort_names[]={ + N_("Sort by name"), N_("Sort by type"), N_("Sort by date"), + N_("Sort by size"), N_("Sort by owner"), N_("Sort by group"), + }; + + bev = (GdkEventButton *) gtk_get_current_event(); + adjust=(bev->button == 2) && bev->type == GDK_BUTTON_RELEASE; + + current=-1; + dir=filer_window->sort_order; + for(i=0; isort_type==sorts[i]) { + current=i; + break; + } + if(current==-1) { + next=0; + dir=GTK_SORT_ASCENDING; + } else if(adjust) { + next=current-1; + if(next<0) { + next=nsorts-1; + dir=(dir==GTK_SORT_ASCENDING)? + GTK_SORT_DESCENDING: GTK_SORT_ASCENDING; + } + } else { + next=current+1; + if(next>=nsorts) { + next=0; + dir=(dir==GTK_SORT_ASCENDING)? + GTK_SORT_DESCENDING: GTK_SORT_ASCENDING; + } + } + + display_set_sort_type(filer_window, sorts[next], dir); + tip=g_strconcat(_(sort_names[next]), ", ", + dir==GTK_SORT_ASCENDING? _("ascending"): _("descending"), + NULL); + tooltip_show(tip); + g_free(tip); } static void toolbar_details_clicked(GtkWidget *widget,