4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2003, the ROX-Filer team.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
22 /* bind.c - converts user gestures (clicks, etc) into actions */
33 Option o_new_button_1
, o_single_click
;
34 static Option o_single_pinboard
;
36 /****************************************************************
37 * EXTERNAL INTERFACE *
38 ****************************************************************/
42 option_add_int(&o_new_button_1
, "bind_new_button_1", FALSE
);
43 option_add_int(&o_single_click
, "bind_single_click", TRUE
);
44 option_add_int(&o_single_pinboard
, "bind_single_pinboard", TRUE
);
47 /* Call this when a button event occurs and you want to know what
50 BindAction
bind_lookup_bev(BindContext context
, GdkEventButton
*event
)
52 gint b
= event
->button
;
53 gint menu_button
= 3; /* o_menu_button_2.int_value ? 2 : 3; */
54 gboolean shift
= (event
->state
& GDK_SHIFT_MASK
) != 0;
55 gboolean ctrl
= (event
->state
& GDK_CONTROL_MASK
) != 0;
56 gboolean icon
= context
== BIND_PINBOARD_ICON
||
57 context
== BIND_PANEL_ICON
;
58 gboolean item
= icon
|| context
== BIND_DIRECTORY_ICON
;
59 gboolean background
= context
== BIND_PINBOARD
||
60 context
== BIND_PANEL
||
61 context
== BIND_DIRECTORY
;
62 gboolean press
= event
->type
== GDK_BUTTON_PRESS
;
63 gboolean release
= event
->type
== GDK_BUTTON_RELEASE
;
64 gboolean select
= event
->button
== 1; /* (old RISC OS names) */
65 gboolean adjust
= event
->button
!= 1;
67 gboolean dclick
= event
->type
== GDK_2BUTTON_PRESS
;
68 gboolean dclick_mode
=
69 (context
== BIND_DIRECTORY_ICON
&& !o_single_click
.int_value
) ||
70 (context
== BIND_PINBOARD_ICON
&& !o_single_pinboard
.int_value
);
75 if (context
== BIND_PINBOARD_ICON
|| context
== BIND_PINBOARD
)
76 menu_button
= 3; /* Must work with window manager */
79 return press
? ACT_POPUP_MENU
: ACT_IGNORE
;
81 if (item
&& dclick
&& dclick_mode
)
82 return shift
? ACT_EDIT_ITEM
: ACT_OPEN_ITEM
;
84 if (dclick
&& context
== BIND_DIRECTORY
)
89 if (release
&& item
&& (!dclick_mode
) && (!ctrl
) &&
90 (select
|| (adjust
&& context
== BIND_DIRECTORY_ICON
)))
91 return shift
? ACT_EDIT_ITEM
: ACT_OPEN_ITEM
;
97 gboolean clear
= (!ctrl
) && select
;
99 if (context
== BIND_PANEL
)
100 return ACT_CLEAR_SELECTION
;
102 return clear
? ACT_LASSO_CLEAR
: ACT_LASSO_MODIFY
;
105 if (ctrl
|| (adjust
&& dclick_mode
))
106 return ACT_PRIME_AND_TOGGLE
;
108 if (context
== BIND_PANEL_ICON
&& adjust
)
109 return ACT_MOVE_ICON
;
111 return dclick_mode
? ACT_PRIME_AND_SELECT
: ACT_PRIME_FOR_DND
;