From eeed9d1890e8f462445af36974ff756409111da5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 26 Sep 2003 23:01:32 +0000 Subject: Demonstrate the use of the connect-proxy signal. 2003-09-27 Matthias Clasen * tests/testmerge.c: Demonstrate the use of the connect-proxy signal. * gtk/gtkaction.c (connect_proxy): Add connect-proxy and disconnect-proxy signals to do small customizations like displaying tooltips in the statusbar without custom actions. (#122894, Philip Langdale) * gtk/gtkuimanager.c (update_node): Don't leak tooltip. --- gtk/gtkaction.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'gtk/gtkaction.c') diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index 38d986a7fb..50bc3c4f0f 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -37,6 +37,7 @@ #include "gtkimagemenuitem.h" #include "gtkintl.h" #include "gtklabel.h" +#include "gtkmarshalers.h" #include "gtkmenuitem.h" #include "gtkstock.h" #include "gtktoolbutton.h" @@ -71,6 +72,8 @@ struct _GtkActionPrivate enum { + CONNECT_PROXY, + DISCONNECT_PROXY, ACTIVATE, LAST_SIGNAL }; @@ -248,6 +251,47 @@ gtk_action_class_init (GtkActionClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + /** + * GtkAction::connect-proxy: + * @action: the action + * @proxy: the proxy + * + * The connect_proxy signal is emitted after connecting a proxy to + * an action. Note that the proxy may have been connected to a different + * action before. + * + * This is intended for simple customizations for which a custom action + * class would be too clumsy, e.g. showing tooltips for menuitems in the + * statusbar. + * + * Since: 2.4 + */ + action_signals[CONNECT_PROXY] = + g_signal_new ("connect_proxy", + G_OBJECT_CLASS_TYPE (klass), + 0, 0, NULL, NULL, + _gtk_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + GTK_TYPE_WIDGET); + + /** + * GtkAction::disconnect-proxy: + * @action: the action + * @proxy: the proxy + * + * The disconnect_proxy signal is emitted after disconnecting a proxy + * from an action. + * + * Since: 2.4 + */ + action_signals[DISCONNECT_PROXY] = + g_signal_new ("disconnect_proxy", + G_OBJECT_CLASS_TYPE (klass), + 0, 0, NULL, NULL, + _gtk_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + GTK_TYPE_WIDGET); + g_type_class_add_private (gobject_class, sizeof (GtkActionPrivate)); } @@ -709,6 +753,8 @@ connect_proxy (GtkAction *action, G_CALLBACK (gtk_action_activate), action, G_CONNECT_SWAPPED); } + + g_signal_emit (action, action_signals[CONNECT_PROXY], 0, proxy); } static void @@ -749,6 +795,8 @@ disconnect_proxy (GtkAction *action, g_signal_handlers_disconnect_by_func (proxy, G_CALLBACK (gtk_action_create_menu_proxy), action); + + g_signal_emit (action, action_signals[DISCONNECT_PROXY], 0, proxy); } /** -- cgit v1.2.1