Mercurial > pidgin
diff console/libgnt/gntbox.c @ 14343:0387a167f342
[gaim-migrate @ 17044]
A WM can now act on keystrokes. As an example, the sample WM will toggle
the buddylist on pressing Alt+b.
Mouse clicking and scrolling is now supported in most/all widgets.
To use a WM, you need to add "wm=/path/to/wm.so" under [general] in ~/.gntrc.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Aug 2006 12:54:39 +0000 |
parents | 1a500db56415 |
children | f4af666fafe3 |
line wrap: on
line diff
--- a/console/libgnt/gntbox.c Sat Aug 26 07:11:55 2006 +0000 +++ b/console/libgnt/gntbox.c Sat Aug 26 12:54:39 2006 +0000 @@ -454,6 +454,30 @@ reposition_children(widget); } +static gboolean +gnt_box_clicked(GntWidget *widget, GntMouseEvent event, int cx, int cy) +{ + GList *iter; + for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) { + int x, y, w, h; + GntWidget *wid = iter->data; + + gnt_widget_get_position(wid, &x, &y); + gnt_widget_get_size(wid, &w, &h); + + if (cx >= x && cx < x + w && cy >= y && cy < y + h) { + if (event <= GNT_MIDDLE_MOUSE_DOWN && + GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_CAN_TAKE_FOCUS)) { + while (widget->parent) + widget = widget->parent; + gnt_box_give_focus_to_child(GNT_BOX(widget), wid); + } + return gnt_widget_clicked(wid, event, cx, cy); + } + } + return FALSE; +} + static void gnt_box_class_init(GntBoxClass *klass) { @@ -465,6 +489,7 @@ parent_class->size_request = gnt_box_size_request; parent_class->set_position = gnt_box_set_position; parent_class->key_pressed = gnt_box_key_pressed; + parent_class->clicked = gnt_box_clicked; parent_class->lost_focus = gnt_box_lost_focus; parent_class->gained_focus = gnt_box_gained_focus; parent_class->confirm_size = gnt_box_confirm_size; @@ -603,6 +628,7 @@ if (box->vertical) { + x = pos; if (box->alignment == GNT_ALIGN_RIGHT) x += widget->priv.width - width; else if (box->alignment == GNT_ALIGN_MID) @@ -612,6 +638,7 @@ } else { + y = pos; if (box->alignment == GNT_ALIGN_BOTTOM) y += widget->priv.height - height; else if (box->alignment == GNT_ALIGN_MID) @@ -622,6 +649,7 @@ copywin(w->window, widget->window, 0, 0, y, x, y + height - 1, x + width - 1, FALSE); + gnt_widget_set_position(w, x + widget->priv.x, y + widget->priv.y); } }