r4269: Bugfix: New detail crashes cleanice theme. Try another value... (reported
[rox-filer/translations.git] / ROX-Filer / src / bind.c
blobd9350a0f781a39bf33d12641047b7b6fdba0959d
1 /*
2 * $Id$
4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2005, 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)
10 * any later version.
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
15 * more details.
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 */
24 #include "config.h"
26 #include <stdlib.h>
28 #include "global.h"
30 #include "options.h"
31 #include "bind.h"
33 Option o_new_button_1, o_single_click;
34 static Option o_single_pinboard;
35 static Option o_dclick_resizes;
37 /****************************************************************
38 * EXTERNAL INTERFACE *
39 ****************************************************************/
41 void bind_init(void)
43 option_add_int(&o_new_button_1, "bind_new_button_1", FALSE);
44 option_add_int(&o_single_click, "bind_single_click", TRUE);
45 option_add_int(&o_single_pinboard, "bind_single_pinboard", TRUE);
46 option_add_int(&o_dclick_resizes, "bind_dclick_resizes", TRUE);
49 /* Call this when a button event occurs and you want to know what
50 * to do.
52 BindAction bind_lookup_bev(BindContext context, GdkEventButton *event)
54 gint b = event->button;
55 gint menu_button = 3; /* o_menu_button_2.int_value ? 2 : 3; */
56 gboolean shift = (event->state & GDK_SHIFT_MASK) != 0;
57 gboolean ctrl = (event->state & GDK_CONTROL_MASK) != 0;
58 gboolean icon = context == BIND_PINBOARD_ICON ||
59 context == BIND_PANEL_ICON;
60 gboolean item = icon || context == BIND_DIRECTORY_ICON;
61 gboolean background = context == BIND_PINBOARD ||
62 context == BIND_PANEL ||
63 context == BIND_DIRECTORY;
64 gboolean press = event->type == GDK_BUTTON_PRESS;
65 gboolean release = event->type == GDK_BUTTON_RELEASE;
66 gboolean select = event->button == 1; /* (old RISC OS names) */
67 gboolean adjust = event->button != 1;
69 gboolean dclick = event->type == GDK_2BUTTON_PRESS;
70 gboolean dclick_mode =
71 (context == BIND_DIRECTORY_ICON && !o_single_click.int_value) ||
72 (context == BIND_PINBOARD_ICON && !o_single_pinboard.int_value);
74 if (b > 3)
75 return ACT_IGNORE;
77 if (context == BIND_PINBOARD_ICON || context == BIND_PINBOARD)
78 menu_button = 3; /* Must work with window manager */
80 if (b == menu_button)
81 return press ? ACT_POPUP_MENU : ACT_IGNORE;
83 if (item && dclick && dclick_mode)
84 return shift ? ACT_EDIT_ITEM : ACT_OPEN_ITEM;
86 if (dclick && context == BIND_DIRECTORY && o_dclick_resizes.int_value)
87 return ACT_RESIZE;
89 if (!press)
91 if (release && item && (!dclick_mode) && (!ctrl) &&
92 (select || (adjust && context == BIND_DIRECTORY_ICON)))
93 return shift ? ACT_EDIT_ITEM : ACT_OPEN_ITEM;
94 return ACT_IGNORE;
97 if (background)
99 gboolean clear = (!ctrl) && select;
101 if (context == BIND_PANEL)
102 return ACT_CLEAR_SELECTION;
104 return clear ? ACT_LASSO_CLEAR : ACT_LASSO_MODIFY;
107 if (ctrl || (adjust && dclick_mode))
108 return ACT_PRIME_AND_TOGGLE;
110 if (context == BIND_PANEL_ICON && adjust)
111 return ACT_MOVE_ICON;
113 return dclick_mode ? ACT_PRIME_AND_SELECT : ACT_PRIME_FOR_DND;