diff console/libgnt/gntwidget.c @ 14834:52022b0a9405

[gaim-migrate @ 17601] Add another action "context-menu" for all widgets. This will allow to popup the context-menu for adding buddies. etc. in the buddylist with some custom binding for keyboards that don't have the menu-key (like the one at my work). committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 28 Oct 2006 15:22:30 +0000
parents 945936eaa74e
children bfcdd361357e
line wrap: on
line diff
--- a/console/libgnt/gntwidget.c	Sat Oct 28 14:24:10 2006 +0000
+++ b/console/libgnt/gntwidget.c	Sat Oct 28 15:22:30 2006 +0000
@@ -21,6 +21,7 @@
 	SIG_SIZE_CHANGED,
 	SIG_POSITION,
 	SIG_CLICKED,
+	SIG_CONTEXT_MENU,
 	SIGS
 };
 
@@ -83,6 +84,14 @@
 }
 
 static gboolean
+context_menu(GntWidget *widget, GList *null)
+{
+	gboolean ret = FALSE;
+	g_signal_emit(widget, signals[SIG_CONTEXT_MENU], 0, &ret);
+	return ret;
+}
+
+static gboolean
 gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint,
 				  GValue                *return_accu,
 				  const GValue          *handler_return,
@@ -234,11 +243,24 @@
 					 gnt_closure_marshal_BOOLEAN__INT_INT_INT,
 					 G_TYPE_BOOLEAN, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
 
+	signals[SIG_CONTEXT_MENU] = 
+		g_signal_new("context-menu",
+					 G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST,
+					 0,
+					 gnt_boolean_handled_accumulator, NULL,
+					 gnt_closure_marshal_BOOLEAN__VOID,
+					 G_TYPE_BOOLEAN, 0);
+
 	klass->actions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
 				(GDestroyNotify)gnt_widget_action_free);
 	klass->bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
 				(GDestroyNotify)gnt_widget_action_param_free);
 
+	/* This is relevant for all widgets */
+	gnt_widget_class_register_action(klass, "context-menu", context_menu,
+				"\033" GNT_KEY_POPUP, NULL);
+
 	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), klass);
 
 	GNTDEBUG;