Mercurial > emacs
comparison src/gtkutil.c @ 90737:95d0cdf160ea
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 586-614)
- Update from CVS
- Update from erc--emacs--22
- Merge from gnus--rel--5.10
- Merge from erc--main--0
- Make byte compiler correctly write circular constants
* gnus--rel--5.10 (patch 186-196)
- Update from CVS
- Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-162
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 26 Jan 2007 06:16:11 +0000 |
parents | bc10a33dd40b 3d45362f1d38 |
children | f83d17e1ace6 |
comparison
equal
deleted
inserted
replaced
90736:ef1369583937 | 90737:95d0cdf160ea |
---|---|
1 /* Functions for creating and updating GTK widgets. | 1 /* Functions for creating and updating GTK widgets. |
2 Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. | 2 Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
1716 xfree (data); | 1716 xfree (data); |
1717 } | 1717 } |
1718 } | 1718 } |
1719 | 1719 |
1720 /* Callback called when the pointer enters/leaves a menu item. | 1720 /* Callback called when the pointer enters/leaves a menu item. |
1721 W is the menu item. | 1721 W is the parent of the menu item. |
1722 EVENT is either an enter event or leave event. | 1722 EVENT is either an enter event or leave event. |
1723 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. | 1723 CLIENT_DATA is not used. |
1724 | 1724 |
1725 Returns FALSE to tell GTK to keep processing this event. */ | 1725 Returns FALSE to tell GTK to keep processing this event. */ |
1726 | 1726 |
1727 static gboolean | 1727 static gboolean |
1728 menuitem_highlight_callback (w, event, client_data) | 1728 menuitem_highlight_callback (w, event, client_data) |
1729 GtkWidget *w; | 1729 GtkWidget *w; |
1730 GdkEventCrossing *event; | 1730 GdkEventCrossing *event; |
1731 gpointer client_data; | 1731 gpointer client_data; |
1732 { | 1732 { |
1733 if (client_data) | 1733 GdkEvent ev; |
1734 { | 1734 GtkWidget *subwidget; |
1735 xg_menu_item_cb_data *data = (xg_menu_item_cb_data*) client_data; | 1735 xg_menu_item_cb_data *data; |
1736 gpointer call_data = event->type == GDK_LEAVE_NOTIFY ? 0 : client_data; | 1736 |
1737 | 1737 ev.crossing = *event; |
1738 subwidget = gtk_get_event_widget (&ev); | |
1739 data = (xg_menu_item_cb_data *) g_object_get_data (G_OBJECT (subwidget), | |
1740 XG_ITEM_DATA); | |
1741 if (data) | |
1742 { | |
1738 if (! NILP (data->help) && data->cl_data->highlight_cb) | 1743 if (! NILP (data->help) && data->cl_data->highlight_cb) |
1739 { | 1744 { |
1745 gpointer call_data = event->type == GDK_LEAVE_NOTIFY ? 0 : data; | |
1740 GtkCallback func = (GtkCallback) data->cl_data->highlight_cb; | 1746 GtkCallback func = (GtkCallback) data->cl_data->highlight_cb; |
1741 (*func) (w, call_data); | 1747 (*func) (subwidget, call_data); |
1742 } | 1748 } |
1743 } | 1749 } |
1744 | 1750 |
1745 return FALSE; | 1751 return FALSE; |
1746 } | 1752 } |
2002 | 2008 |
2003 cb_data = xmalloc (sizeof (xg_menu_item_cb_data)); | 2009 cb_data = xmalloc (sizeof (xg_menu_item_cb_data)); |
2004 | 2010 |
2005 xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs); | 2011 xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs); |
2006 | 2012 |
2007 cb_data->unhighlight_id = cb_data->highlight_id = cb_data->select_id = 0; | 2013 cb_data->select_id = 0; |
2008 cb_data->help = item->help; | 2014 cb_data->help = item->help; |
2009 cb_data->cl_data = cl_data; | 2015 cb_data->cl_data = cl_data; |
2010 cb_data->call_data = item->call_data; | 2016 cb_data->call_data = item->call_data; |
2011 | 2017 |
2012 g_signal_connect (G_OBJECT (w), | 2018 g_signal_connect (G_OBJECT (w), |
2021 if (item->call_data && ! item->contents) | 2027 if (item->call_data && ! item->contents) |
2022 { | 2028 { |
2023 if (select_cb) | 2029 if (select_cb) |
2024 cb_data->select_id | 2030 cb_data->select_id |
2025 = g_signal_connect (G_OBJECT (w), "activate", select_cb, cb_data); | 2031 = g_signal_connect (G_OBJECT (w), "activate", select_cb, cb_data); |
2026 } | |
2027 | |
2028 if (! NILP (item->help) && highlight_cb) | |
2029 { | |
2030 /* We use enter/leave notify instead of select/deselect because | |
2031 select/deselect doesn't go well with detached menus. */ | |
2032 cb_data->highlight_id | |
2033 = g_signal_connect (G_OBJECT (w), | |
2034 "enter-notify-event", | |
2035 G_CALLBACK (menuitem_highlight_callback), | |
2036 cb_data); | |
2037 cb_data->unhighlight_id | |
2038 = g_signal_connect (G_OBJECT (w), | |
2039 "leave-notify-event", | |
2040 G_CALLBACK (menuitem_highlight_callback), | |
2041 cb_data); | |
2042 } | 2032 } |
2043 | 2033 |
2044 return w; | 2034 return w; |
2045 } | 2035 } |
2046 | 2036 |
2121 { | 2111 { |
2122 if (! menu_bar_p) | 2112 if (! menu_bar_p) |
2123 { | 2113 { |
2124 wmenu = gtk_menu_new (); | 2114 wmenu = gtk_menu_new (); |
2125 xg_set_screen (wmenu, f); | 2115 xg_set_screen (wmenu, f); |
2116 /* Connect this to the menu instead of items so we get enter/leave for | |
2117 disabled items also. TODO: Still does not get enter/leave for | |
2118 disabled items in detached menus. */ | |
2119 g_signal_connect (G_OBJECT (wmenu), | |
2120 "enter-notify-event", | |
2121 G_CALLBACK (menuitem_highlight_callback), | |
2122 NULL); | |
2123 g_signal_connect (G_OBJECT (wmenu), | |
2124 "leave-notify-event", | |
2125 G_CALLBACK (menuitem_highlight_callback), | |
2126 NULL); | |
2126 } | 2127 } |
2127 else wmenu = gtk_menu_bar_new (); | 2128 else wmenu = gtk_menu_bar_new (); |
2128 | 2129 |
2129 /* Fix up grabs after keyboard traversal ends. */ | 2130 /* Fix up grabs after keyboard traversal ends. */ |
2130 g_signal_connect (G_OBJECT (wmenu), | 2131 g_signal_connect (G_OBJECT (wmenu), |
2616 } | 2617 } |
2617 else if (cb_data->select_id) | 2618 else if (cb_data->select_id) |
2618 { | 2619 { |
2619 g_signal_handler_disconnect (w, cb_data->select_id); | 2620 g_signal_handler_disconnect (w, cb_data->select_id); |
2620 cb_data->select_id = 0; | 2621 cb_data->select_id = 0; |
2621 } | |
2622 | |
2623 if (NILP (cb_data->help)) | |
2624 { | |
2625 /* Shall not have help. Remove if any existed previously. */ | |
2626 if (cb_data->highlight_id) | |
2627 { | |
2628 g_signal_handler_disconnect (G_OBJECT (w), | |
2629 cb_data->highlight_id); | |
2630 cb_data->highlight_id = 0; | |
2631 } | |
2632 if (cb_data->unhighlight_id) | |
2633 { | |
2634 g_signal_handler_disconnect (G_OBJECT (w), | |
2635 cb_data->unhighlight_id); | |
2636 cb_data->unhighlight_id = 0; | |
2637 } | |
2638 } | |
2639 else if (! cb_data->highlight_id && highlight_cb) | |
2640 { | |
2641 /* Have help now, but didn't previously. Add callback. */ | |
2642 cb_data->highlight_id | |
2643 = g_signal_connect (G_OBJECT (w), | |
2644 "enter-notify-event", | |
2645 G_CALLBACK (menuitem_highlight_callback), | |
2646 cb_data); | |
2647 cb_data->unhighlight_id | |
2648 = g_signal_connect (G_OBJECT (w), | |
2649 "leave-notify-event", | |
2650 G_CALLBACK (menuitem_highlight_callback), | |
2651 cb_data); | |
2652 } | 2622 } |
2653 } | 2623 } |
2654 } | 2624 } |
2655 | 2625 |
2656 /* Update the toggle menu item W so it corresponds to VAL. */ | 2626 /* Update the toggle menu item W so it corresponds to VAL. */ |