Between where you create the fileselection widget and display it, add the function add_sort_button_fileselection. // I use glade which provides the function create_dataset_fileselection1() // and returns a GtkWidget * // dataset_fileselection1 = create_dataset_fileselection1 (); add_sort_button_fileselection(dataset_fileselection1); gtk_widget_show (dataset_fileselection1); which is declared: void add_sort_button_fileselection(GtkWidget *fileselection); in add_sort_button_fileselection, create a button, add it to the action_area of the fileselection widget and add a callback to do the sorting, passing the GtkClist for the file list. Add user data for the history_pulldown to the button too. We will need this info for when we change directories. void add_sort_button_fileselection(GtkWidget *fileselection) { GtkWidget *aa = GTK_FILE_SELECTION(fileselection)->action_area; GtkWidget *button = gtk_button_new_with_label(" Sort by Date "); GtkWidget *file_list = GTK_FILE_SELECTION(fileselection)->file_list; GtkOptionMenu *history_pulldown = GTK_OPTION_MENU(GTK_FILE_SELECTION(fileselection)->history_pulldown); gtk_object_set_user_data(GTK_OBJECT(button), (char *) history_pulldown); gtk_container_add(GTK_CONTAINER(aa),button); gtk_signal_connect (GTK_OBJECT(button), "clicked", (GtkSignalFunc) fileselection_sort_button_clicked, file_list); gtk_widget_show(button); } where fileselection_sort_button_clicked is: // You will have to rewrite this a bit if you want to use c: // void fileselection_sort_button_clicked( GtkWidget *sort_button, GtkCList *file_list) { std::vector v; char *text; static struct stat buf; time_t mtime; // Extract the user data from the button: GtkOptionMenu *history_pulldown = GTK_OPTION_MENU(gtk_object_get_user_data(GTK_OBJECT(sort_button))); // The menu item is a container than contains a label. // How do we get to the label given the container? // Strangely enough we use the history_pulldown. GList *dlist = gtk_container_children(GTK_CONTAINER(history_pulldown)); GList *free_list = dlist; std::string pre_directory(""); while (dlist) { // GtkWidget *list_item; // list_item = (GtkWidget *) (dlist->data); gchar *t = GTK_LABEL(dlist->data)->label; if (t != NULL) { pre_directory = t; } else { std::cout << "null label t " << std::endl; } dlist = dlist->next; } g_list_free(free_list); // Now we stat each of the files, adding the pre_directory // to the string to be stated. We make a vector, combining // the mtime info and the filename. // int status; std::string file_name; for(int i=0; irows; i++) { gtk_clist_get_text(file_list,i,0,&text); file_name = pre_directory; if (file_name != "") { file_name += "/"; file_name += text; } else { // Oh dear. This directory only. Else failure // this shouldn't happen hopefully. file_name = text; } status = stat(file_name.c_str(),&buf); if (status == 0) { mtime = buf.st_mtime; v.push_back(str_mtime(text,mtime)); } else { // We get this message for broken links: std::cout << "error stating " << file_name << std::endl; } } std::sort(v.begin(), v.end(), compare_mtimes); // Clear the list and re-add the entries in our prefered order gtk_clist_clear(file_list); for(int i=0; i b.mtime; } with: class str_mtime { public: str_mtime(std::string file_in, time_t mtime_in) { mtime = mtime_in; file = file_in; } time_t mtime; std::string file; }; which can be done just as easily with c: struct str_mtime { time_t mtime; std::string file; }; Easy when you know how! But I couldn't find information on the web and it took me 2 or 3 days to work out. I provide it here so that you don't have to. Enjoy.