Mercurial > pidgin
comparison console/libgnt/gntwm.c @ 15652:995af0f20c27
Allow reordering windows from the window list. I find it much easier and faster.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 17 Feb 2007 23:44:17 +0000 |
parents | 7d682fc9098f |
children | 73219517f583 |
comparison
equal
deleted
inserted
replaced
15651:2dd78f245ba4 | 15652:995af0f20c27 |
---|---|
39 static void gnt_wm_new_window_real(GntWM *wm, GntWidget *widget); | 39 static void gnt_wm_new_window_real(GntWM *wm, GntWidget *widget); |
40 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); | 40 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); |
41 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); | 41 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); |
42 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); | 42 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); |
43 static void update_window_in_list(GntWM *wm, GntWidget *wid); | 43 static void update_window_in_list(GntWM *wm, GntWidget *wid); |
44 static void shift_window(GntWM *wm, GntWidget *widget, int dir); | |
44 | 45 |
45 static gboolean write_already(gpointer data); | 46 static gboolean write_already(gpointer data); |
46 static int write_timeout; | 47 static int write_timeout; |
47 | 48 |
48 static GList * | 49 static GList * |
371 | 372 |
372 gnt_widget_destroy(wm->_list.window); | 373 gnt_widget_destroy(wm->_list.window); |
373 gnt_wm_raise_window(wm, widget); | 374 gnt_wm_raise_window(wm, widget); |
374 } | 375 } |
375 | 376 |
377 static void | |
378 populate_window_list(GntWM *wm) | |
379 { | |
380 GList *iter; | |
381 GntTree *tree = GNT_TREE(wm->windows->tree); | |
382 for (iter = wm->list; iter; iter = iter->next) { | |
383 GntBox *box = GNT_BOX(iter->data); | |
384 | |
385 gnt_tree_add_row_last(tree, box, | |
386 gnt_tree_create_row(tree, box->title), NULL); | |
387 update_window_in_list(wm, GNT_WIDGET(box)); | |
388 } | |
389 } | |
390 | |
391 static gboolean | |
392 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) | |
393 { | |
394 if (text[1] == 0 && wm->ordered) { | |
395 GntWidget *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); | |
396 switch (text[0]) { | |
397 case '-': | |
398 case '<': | |
399 shift_window(wm, sel, -1); | |
400 break; | |
401 case '+': | |
402 case '>': | |
403 shift_window(wm, sel, 1); | |
404 break; | |
405 default: | |
406 return FALSE; | |
407 } | |
408 gnt_tree_remove_all(GNT_TREE(widget)); | |
409 populate_window_list(wm); | |
410 gnt_tree_set_selected(GNT_TREE(widget), sel); | |
411 return TRUE; | |
412 } | |
413 return FALSE; | |
414 } | |
415 | |
376 static gboolean | 416 static gboolean |
377 window_list(GntBindable *bindable, GList *null) | 417 window_list(GntBindable *bindable, GList *null) |
378 { | 418 { |
379 GntWM *wm = GNT_WM(bindable); | 419 GntWM *wm = GNT_WM(bindable); |
380 GntWidget *tree, *win; | 420 GntWidget *tree, *win; |
381 GList *iter; | |
382 | 421 |
383 if (wm->_list.window || wm->menu) | 422 if (wm->_list.window || wm->menu) |
384 return TRUE; | 423 return TRUE; |
385 | 424 |
386 if (!wm->ordered) | 425 if (!wm->ordered) |
391 | 430 |
392 win = wm->windows->window; | 431 win = wm->windows->window; |
393 tree = wm->windows->tree; | 432 tree = wm->windows->tree; |
394 | 433 |
395 gnt_box_set_title(GNT_BOX(win), "Window List"); | 434 gnt_box_set_title(GNT_BOX(win), "Window List"); |
396 | 435 |
397 for (iter = wm->list; iter; iter = iter->next) { | 436 populate_window_list(wm); |
398 GntBox *box = GNT_BOX(iter->data); | |
399 | |
400 gnt_tree_add_row_last(GNT_TREE(tree), box, | |
401 gnt_tree_create_row(GNT_TREE(tree), box->title), NULL); | |
402 update_window_in_list(wm, GNT_WIDGET(box)); | |
403 } | |
404 | 437 |
405 gnt_tree_set_selected(GNT_TREE(tree), wm->ordered->data); | 438 gnt_tree_set_selected(GNT_TREE(tree), wm->ordered->data); |
406 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); | 439 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); |
440 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); | |
407 | 441 |
408 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); | 442 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); |
409 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); | 443 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); |
410 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); | 444 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); |
411 | 445 |