]> git.pld-linux.org Git - packages/rox.git/blob - rox-sortbutton.patch
- Ok - it works now (moved rox.xml to %%(_datadir}/mime/packages)
[packages/rox.git] / rox-sortbutton.patch
1 This patch adds a button on the toolbar to change the sort function.
2
3 Updated for 1.3.3 CVS 2002-07-30 by Marcin Juszkiewicz <marcin@amiga.pl>
4
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
8 ***************
9 *** 81,86 ****
10 --- 81,88 ----
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);
19 ***************
20 *** 124,129 ****
21 --- 126,135 ----
22          toolbar_size_clicked, DROP_NONE, TRUE,
23          NULL},
24         
25 +       {N_("Sort"), GTK_STOCK_SORT_ASCENDING, N_("Change sort criteria"),
26 +        toolbar_sort_clicked, DROP_NONE, TRUE,
27 +        NULL},
28 +       
29         {N_("Details"), GTK_STOCK_JUSTIFY_LEFT, N_("Show extra details"),
30          toolbar_details_clicked, DROP_NONE, TRUE,
31          NULL},
32 ***************
33 *** 317,322 ****
34 --- 323,361 ----
35                 bev->type == GDK_BUTTON_RELEASE && bev->button == 1);
36   }
37   
38 + /* This typedef makes things a lot easier... */
39 + typedef int (*sort_fn_t)(const void *a, const void *b);
40
41 + static void toolbar_sort_clicked(GtkWidget *widget, FilerWindow *filer_window)
42 + {
43 +       GdkEventButton  *bev;
44 +       int i, current, next;
45 +       gboolean adjust;
46
47 +       static sort_fn_t sort_fns[]={
48 +         sort_by_name, sort_by_type, sort_by_date, sort_by_size
49 +       };
50 + #define NSORT (sizeof(sort_fns)/sizeof(sort_fn_t))
51
52 +       bev = (GdkEventButton *) gtk_get_current_event();
53 +       adjust=(bev->button == 2) && bev->type == GDK_BUTTON_RELEASE;
54
55 +       current=-1;
56 +       for(i=0; i<NSORT; i++)
57 +         if(filer_window->sort_fn==sort_fns[i]) {
58 +           current=i;
59 +           break;
60 +         }
61 +       if(current==-1)
62 +         next=0;
63 +       else if(adjust)
64 +         next=(current+NSORT-1)%NSORT;
65 +       else
66 +         next=(current+1)%NSORT;
67 +         
68 +       display_set_sort_fn(filer_window, sort_fns[next]);
69 + }
70
71   static void toolbar_details_clicked(GtkWidget *widget,
72                                     FilerWindow *filer_window)
73   {
This page took 0.0693240000000001 seconds and 3 git commands to generate.