aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2006-02-14 10:01:58 +0000
committerJan Djärv2006-02-14 10:01:58 +0000
commit2334f9e76929128e5237b435746fcd6bb5df9e80 (patch)
treeaa8116defd1c6aca64bd58af3967d8594cdd18f5 /src
parentd39f8cb63439e175c8bbb53f921ab92d41dc0357 (diff)
downloademacs-2334f9e76929128e5237b435746fcd6bb5df9e80.tar.gz
emacs-2334f9e76929128e5237b435746fcd6bb5df9e80.zip
* gtkutil.c (xg_tool_bar_button_cb): New function.
(xg_tool_bar_callback): Call x_x_to_emacs_modifiers to store modifiers in event. (update_frame_tool_bar): Connect button-release-event to xg_tool_bar_button_cb.
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 3efc96cfe5d..a59fa18821c 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3242,11 +3242,28 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
3242 the GtkImage with a new image. */ 3242 the GtkImage with a new image. */
3243#define XG_TOOL_BAR_IMAGE_DATA "emacs-tool-bar-image" 3243#define XG_TOOL_BAR_IMAGE_DATA "emacs-tool-bar-image"
3244 3244
3245/* The key for storing the latest modifiers so the activate callback can
3246 get them. */
3247#define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier"
3248
3249
3245/* Callback function invoked when a tool bar item is pressed. 3250/* Callback function invoked when a tool bar item is pressed.
3246 W is the button widget in the tool bar that got pressed, 3251 W is the button widget in the tool bar that got pressed,
3247 CLIENT_DATA is an integer that is the index of the button in the 3252 CLIENT_DATA is an integer that is the index of the button in the
3248 tool bar. 0 is the first button. */ 3253 tool bar. 0 is the first button. */
3249 3254
3255static gboolean
3256xg_tool_bar_button_cb (widget, event, user_data)
3257 GtkWidget *widget;
3258 GdkEventButton *event;
3259 gpointer user_data;
3260{
3261 g_object_set_data (G_OBJECT (user_data), XG_TOOL_BAR_LAST_MODIFIER,
3262 (gpointer) event->state);
3263 return FALSE;
3264}
3265
3266
3250static void 3267static void
3251xg_tool_bar_callback (w, client_data) 3268xg_tool_bar_callback (w, client_data)
3252 GtkWidget *w; 3269 GtkWidget *w;
@@ -3254,6 +3271,8 @@ xg_tool_bar_callback (w, client_data)
3254{ 3271{
3255 /* The EMACS_INT cast avoids a warning. */ 3272 /* The EMACS_INT cast avoids a warning. */
3256 int idx = (int) (EMACS_INT) client_data; 3273 int idx = (int) (EMACS_INT) client_data;
3274 int mod = (int) g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER);
3275
3257 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); 3276 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
3258 Lisp_Object key, frame; 3277 Lisp_Object key, frame;
3259 struct input_event event; 3278 struct input_event event;
@@ -3274,7 +3293,10 @@ xg_tool_bar_callback (w, client_data)
3274 event.kind = TOOL_BAR_EVENT; 3293 event.kind = TOOL_BAR_EVENT;
3275 event.frame_or_window = frame; 3294 event.frame_or_window = frame;
3276 event.arg = key; 3295 event.arg = key;
3277 event.modifiers = 0; /* These are not available. */ 3296 /* Convert between the modifier bits GDK uses and the modifier bits
3297 Emacs uses. This assumes GDK an X masks are the same, which they are when
3298 this is written. */
3299 event.modifiers = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), mod);
3278 kbd_buffer_store_event (&event); 3300 kbd_buffer_store_event (&event);
3279} 3301}
3280 3302
@@ -3629,6 +3651,13 @@ update_frame_tool_bar (f)
3629 while (! GTK_IS_BUTTON (w)) 3651 while (! GTK_IS_BUTTON (w))
3630 w = gtk_widget_get_parent (w); 3652 w = gtk_widget_get_parent (w);
3631 3653
3654 /* Callback to save modifyer mask (Shift/Control, etc). GTK makes
3655 no distinction based on modifiers in the activate callback,
3656 so we have to do it ourselves. */
3657 g_signal_connect (w, "button-release-event",
3658 GTK_SIGNAL_FUNC (xg_tool_bar_button_cb),
3659 ti);
3660
3632 g_object_set_data (G_OBJECT (w), XG_FRAME_DATA, (gpointer)f); 3661 g_object_set_data (G_OBJECT (w), XG_FRAME_DATA, (gpointer)f);
3633 3662
3634 /* Use enter/leave notify to show help. We use the events 3663 /* Use enter/leave notify to show help. We use the events