Mercurial > pidgin
comparison console/libgnt/gntmain.c @ 14362:665b814f8fd7
[gaim-migrate @ 17068]
Fix the wm to give focus to the buddylist after you toggle it on with alt+b.
Draw a line on the right of the buddylist. this should also show how to add
other window-decorations.
Draw a [X] at the corner of the windows, clicking which closes the windows.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 28 Aug 2006 05:39:42 +0000 |
parents | 0387a167f342 |
children | 3bfea4c4ce33 |
comparison
equal
deleted
inserted
replaced
14361:0c3957362c69 | 14362:665b814f8fd7 |
---|---|
75 | 75 |
76 static GntWM wm = | 76 static GntWM wm = |
77 { | 77 { |
78 NULL, /* new_window */ | 78 NULL, /* new_window */ |
79 NULL, /* close_window */ | 79 NULL, /* close_window */ |
80 NULL, /* window_resized */ | |
80 NULL, /* key_pressed */ | 81 NULL, /* key_pressed */ |
81 NULL, /* mouse clicked */ | 82 NULL, /* mouse clicked */ |
82 bring_on_top, /* give_focus */ | 83 bring_on_top, /* give_focus */ |
83 NULL, /* uninit */ | 84 NULL, /* uninit */ |
84 list_all_windows, /* window_list */ | 85 list_all_windows, /* window_list */ |
514 /** | 515 /** |
515 * Mouse support: | 516 * Mouse support: |
516 * - bring a window on top if you click on its taskbar | 517 * - bring a window on top if you click on its taskbar |
517 * - click on the top-bar of the active window and drag+drop to move a window | 518 * - click on the top-bar of the active window and drag+drop to move a window |
518 * - click on a window to bring it to focus | 519 * - click on a window to bring it to focus |
520 * - allow scrolling in tree/textview on wheel-scroll event | |
521 * - click to activate button or select a row in tree | |
519 * wishlist: | 522 * wishlist: |
520 * - have a little [X] on the windows, and clicking it will close that window. | 523 * - have a little [X] on the windows, and clicking it will close that window. |
521 * - allow scrolling in tree/textview on wheel-scroll event | |
522 * - click to activate button or select a row in tree | |
523 * - all these can be fulfilled by adding a "clicked" event for GntWidget | |
524 * which will send the (x,y) to the widget. (look at "key_pressed" for hints) | |
525 */ | 524 */ |
526 static gboolean | 525 static gboolean |
527 detect_mouse_action(const char *buffer) | 526 detect_mouse_action(const char *buffer) |
528 { | 527 { |
529 int x, y; | 528 int x, y; |
534 MOUSE_MIDDLE | 533 MOUSE_MIDDLE |
535 } button = MOUSE_NONE; | 534 } button = MOUSE_NONE; |
536 static GntWidget *remember = NULL; | 535 static GntWidget *remember = NULL; |
537 static int offset = 0; | 536 static int offset = 0; |
538 GntMouseEvent event; | 537 GntMouseEvent event; |
538 GntWidget *widget = NULL; | |
539 GList *iter; | |
539 | 540 |
540 if (!ordered || buffer[0] != 27) | 541 if (!ordered || buffer[0] != 27) |
541 return FALSE; | 542 return FALSE; |
542 | 543 |
543 buffer++; | 544 buffer++; |
549 if (x < 0) x += 256; | 550 if (x < 0) x += 256; |
550 if (y < 0) y += 256; | 551 if (y < 0) y += 256; |
551 x -= 33; | 552 x -= 33; |
552 y -= 33; | 553 y -= 33; |
553 | 554 |
555 for (iter = ordered; iter; iter = iter->next) { | |
556 GntWidget *wid = iter->data; | |
557 if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) { | |
558 if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) { | |
559 widget = wid; | |
560 break; | |
561 } | |
562 } | |
563 } | |
554 if (strncmp(buffer, "[M ", 3) == 0) { | 564 if (strncmp(buffer, "[M ", 3) == 0) { |
555 /* left button down */ | 565 /* left button down */ |
556 /* Bring the window you clicked on to front */ | 566 /* Bring the window you clicked on to front */ |
557 /* If you click on the topbar, then you can drag to move the window */ | 567 /* If you click on the topbar, then you can drag to move the window */ |
558 GList *iter; | |
559 for (iter = ordered; iter; iter = iter->next) { | |
560 GntWidget *wid = iter->data; | |
561 if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) { | |
562 if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) { | |
563 if (iter != ordered) { | |
564 GntWidget *w = ordered->data; | |
565 ordered = g_list_bring_to_front(ordered, iter->data); | |
566 wm.give_focus(ordered->data); | |
567 gnt_widget_set_focus(w, FALSE); | |
568 } | |
569 if (y == wid->priv.y) { | |
570 offset = x - wid->priv.x; | |
571 remember = wid; | |
572 button = MOUSE_LEFT; | |
573 } | |
574 break; | |
575 } | |
576 } | |
577 } | |
578 event = GNT_LEFT_MOUSE_DOWN; | 568 event = GNT_LEFT_MOUSE_DOWN; |
579 } else if (strncmp(buffer, "[M\"", 3) == 0) { | 569 } else if (strncmp(buffer, "[M\"", 3) == 0) { |
580 /* right button down */ | 570 /* right button down */ |
581 event = GNT_RIGHT_MOUSE_DOWN; | 571 event = GNT_RIGHT_MOUSE_DOWN; |
582 } else if (strncmp(buffer, "[M!", 3) == 0) { | 572 } else if (strncmp(buffer, "[M!", 3) == 0) { |
588 } else if (strncmp(buffer, "[Ma", 3) == 0) { | 578 } else if (strncmp(buffer, "[Ma", 3) == 0) { |
589 /* wheel down */ | 579 /* wheel down */ |
590 event = GNT_MOUSE_SCROLL_DOWN; | 580 event = GNT_MOUSE_SCROLL_DOWN; |
591 } else if (strncmp(buffer, "[M#", 3) == 0) { | 581 } else if (strncmp(buffer, "[M#", 3) == 0) { |
592 /* button up */ | 582 /* button up */ |
583 event = GNT_MOUSE_UP; | |
584 } else | |
585 return FALSE; | |
586 | |
587 if (wm.mouse_clicked && wm.mouse_clicked(event, x, y, widget)) | |
588 return TRUE; | |
589 | |
590 if (event == GNT_LEFT_MOUSE_DOWN && widget) { | |
591 if (widget != ordered->data) { | |
592 GntWidget *w = ordered->data; | |
593 ordered = g_list_bring_to_front(ordered, widget); | |
594 wm.give_focus(ordered->data); | |
595 gnt_widget_set_focus(w, FALSE); | |
596 } | |
597 if (y == widget->priv.y) { | |
598 offset = x - widget->priv.x; | |
599 remember = widget; | |
600 button = MOUSE_LEFT; | |
601 } | |
602 } else if (event == GNT_MOUSE_UP) { | |
593 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) { | 603 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) { |
604 /* Clicked on the taskbar */ | |
594 int n = g_list_length(focus_list); | 605 int n = g_list_length(focus_list); |
595 if (n) { | 606 if (n) { |
596 int width = getmaxx(stdscr) / n; | 607 int width = getmaxx(stdscr) / n; |
597 switch_window_n(x / width); | 608 switch_window_n(x / width); |
598 } | 609 } |
604 refresh_node(remember, NULL, NULL); | 615 refresh_node(remember, NULL, NULL); |
605 } | 616 } |
606 button = MOUSE_NONE; | 617 button = MOUSE_NONE; |
607 remember = NULL; | 618 remember = NULL; |
608 offset = 0; | 619 offset = 0; |
609 event = GNT_MOUSE_UP; | 620 } |
610 } else | |
611 return FALSE; | |
612 | 621 |
613 gnt_widget_clicked(ordered->data, event, x, y); | 622 gnt_widget_clicked(ordered->data, event, x, y); |
614 return FALSE; /* XXX: this should be TRUE */ | 623 return FALSE; /* XXX: this should be TRUE */ |
615 } | 624 } |
616 | 625 |
1139 return; | 1148 return; |
1140 | 1149 |
1141 hide_panel(node->panel); | 1150 hide_panel(node->panel); |
1142 gnt_widget_set_size(widget, width, height); | 1151 gnt_widget_set_size(widget, width, height); |
1143 gnt_widget_draw(widget); | 1152 gnt_widget_draw(widget); |
1144 replace_panel(node->panel, widget->window); | 1153 if (wm.window_resized) |
1154 node->panel = wm.window_resized(node->panel, widget); | |
1155 else | |
1156 replace_panel(node->panel, widget->window); | |
1145 show_panel(node->panel); | 1157 show_panel(node->panel); |
1146 update_screen(NULL); | 1158 update_screen(NULL); |
1147 } | 1159 } |
1148 } | 1160 } |
1149 | 1161 |