4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2001, 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 gboolean o_new_window_on_1
= FALSE
;
34 static gboolean o_menu_button
= 3;
35 static gboolean o_single_click
= TRUE
;
37 /* Static prototypes */
38 static void update_options(void);
40 /****************************************************************
41 * EXTERNAL INTERFACE *
42 ****************************************************************/
46 option_add_int("bind_new_button_1", o_new_window_on_1
, NULL
);
47 option_add_int("bind_menu_button_2", FALSE
, NULL
);
48 option_add_int("bind_single_click", o_single_click
, NULL
);
50 option_add_notify(update_options
);
53 /* Call this when a button event occurs and you want to know what
56 BindAction
bind_lookup_bev(BindContext context
, GdkEventButton
*event
)
58 gint b
= event
->button
;
59 gboolean shift
= (event
->state
& GDK_SHIFT_MASK
) != 0;
60 gboolean ctrl
= (event
->state
& GDK_CONTROL_MASK
) != 0;
61 gboolean icon
= context
== BIND_PINBOARD_ICON
||
62 context
== BIND_PANEL_ICON
;
63 gboolean item
= icon
|| context
== BIND_DIRECTORY_ICON
;
64 gboolean background
= context
== BIND_PINBOARD
||
65 context
== BIND_PANEL
||
66 context
== BIND_DIRECTORY
;
67 gboolean press
= event
->type
== GDK_BUTTON_PRESS
;
68 gboolean release
= event
->type
== GDK_BUTTON_RELEASE
;
69 gboolean select
= event
->button
== 1; /* (old RISC OS names) */
70 gboolean adjust
= event
->button
!= 1;
72 gboolean dclick
= event
->type
== GDK_2BUTTON_PRESS
;
73 gboolean dclick_mode
=
74 (context
== BIND_DIRECTORY_ICON
&& !o_single_click
);
79 if (b
== o_menu_button
)
80 return press
? ACT_POPUP_MENU
: ACT_IGNORE
;
82 if (item
&& dclick
&& dclick_mode
)
83 return shift
? ACT_EDIT_ITEM
: ACT_OPEN_ITEM
;
85 if (dclick
&& context
== BIND_DIRECTORY
)
90 if (release
&& item
&& (!dclick_mode
) && (!ctrl
) &&
91 (select
|| (adjust
&& context
== BIND_DIRECTORY_ICON
)))
92 return shift
? ACT_EDIT_ITEM
: ACT_OPEN_ITEM
;
98 gboolean clear
= (!ctrl
) && select
;
100 if (context
== BIND_DIRECTORY
)
101 return clear
? ACT_LASSO_CLEAR
: ACT_LASSO_MODIFY
;
103 if (context
== BIND_PANEL
)
104 return clear
? ACT_SLIDE_CLEAR_PANEL
: ACT_SLIDE_PANEL
;
106 return clear
? ACT_CLEAR_SELECTION
: ACT_IGNORE
;
109 if (ctrl
|| (adjust
&& dclick_mode
))
110 return ACT_PRIME_AND_TOGGLE
;
113 return ACT_MOVE_ICON
;
115 return dclick_mode
? ACT_PRIME_AND_SELECT
: ACT_PRIME_FOR_DND
;
118 /****************************************************************
119 * INTERNAL FUNCTIONS *
120 ****************************************************************/
122 static void update_options(void)
124 o_new_window_on_1
= option_get_int("bind_new_button_1");
125 o_menu_button
= option_get_int("bind_menu_button_2") ? 2 : 3;
126 o_single_click
= option_get_int("bind_single_click");