pidgin: 4d5c3b5e: Allow rebinding button activations (e.g....

sadrul at pidgin.im sadrul at pidgin.im
Sun Jun 29 04:20:43 EDT 2008


-----------------------------------------------------------------
Revision: 4d5c3b5ef59ce60e98576ffc7edf6ebb0960fff1
Ancestor: c7c314a24b71eb00e86c11e07dc64420857b2148
Author: sadrul at pidgin.im
Date: 2008-06-29T01:51:59
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4d5c3b5ef59ce60e98576ffc7edf6ebb0960fff1

Modified files:
        finch/libgnt/gntbutton.c

ChangeLog: 

Allow rebinding button activations (e.g. to space).

-------------- next part --------------
============================================================
--- finch/libgnt/gntbutton.c	a947c6212594ebc4d7cfdf4d957d43e37b455abc
+++ finch/libgnt/gntbutton.c	be57de01c3fa867db8891d3ad40ef32fd1ed635a
@@ -77,18 +77,6 @@ static gboolean
 }
 
 static gboolean
-gnt_button_key_pressed(GntWidget *widget, const char *key)
-{
-	if (strcmp(key, GNT_KEY_ENTER) == 0 ||
-			strcmp(key, SAFE(cursor_down)) == 0)
-	{
-		gnt_widget_activate(widget);
-		return TRUE;
-	}
-	return FALSE;
-}
-
-static gboolean
 gnt_button_clicked(GntWidget *widget, GntMouseEvent event, int x, int y)
 {
 	if (event == GNT_LEFT_MOUSE_DOWN) {
@@ -106,23 +94,33 @@ gnt_button_destroy(GntWidget *widget)
 	g_free(button->priv);
 }
 
+static gboolean
+button_activate(GntBindable *bind, GList *null)
+{
+	gnt_widget_activate(GNT_WIDGET(bind));
+	return TRUE;
+}
+
 static void
 gnt_button_class_init(GntWidgetClass *klass)
 {
 	char *style;
+	GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass);
 
 	parent_class = GNT_WIDGET_CLASS(klass);
 	parent_class->draw = gnt_button_draw;
 	parent_class->map = gnt_button_map;
 	parent_class->size_request = gnt_button_size_request;
-	parent_class->key_pressed = gnt_button_key_pressed;
 	parent_class->clicked = gnt_button_clicked;
 	parent_class->destroy = gnt_button_destroy;
 
 	style = gnt_style_get_from_name(NULL, "small-button");
 	small_button = gnt_style_parse_bool(style);
 	g_free(style);
-	GNTDEBUG;
+
+	gnt_bindable_class_register_action(bindable, "activate", button_activate,
+				GNT_KEY_ENTER, NULL);
+	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
 }
 
 static void


More information about the Commits mailing list