comparison console/libgnt/gntmain.c @ 14245:f64ff0c57457

[gaim-migrate @ 16927] Press alt+l to refresh the screen, useful if you resize the terminal. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 21 Aug 2006 01:44:07 +0000
parents 1d793e808e5b
children e7de1f6d9f35
comparison
equal deleted inserted replaced
14244:935f8b258d1b 14245:f64ff0c57457
55 } GntKeyPressMode; 55 } GntKeyPressMode;
56 56
57 static GHashTable *nodes; 57 static GHashTable *nodes;
58 58
59 static void free_node(gpointer data); 59 static void free_node(gpointer data);
60 static void draw_taskbar(); 60 static void draw_taskbar(gboolean reposition);
61 static void bring_on_top(GntWidget *widget); 61 static void bring_on_top(GntWidget *widget);
62 62
63 static gboolean 63 static gboolean
64 update_screen(gpointer null) 64 update_screen(gpointer null)
65 { 65 {
86 focus_list = g_list_find(focus_list, w ? w : widget); 86 focus_list = g_list_find(focus_list, w ? w : widget);
87 87
88 gnt_widget_set_focus(widget, TRUE); 88 gnt_widget_set_focus(widget, TRUE);
89 if (w) 89 if (w)
90 gnt_widget_set_focus(w, FALSE); 90 gnt_widget_set_focus(w, FALSE);
91 draw_taskbar(); 91 draw_taskbar(FALSE);
92 } 92 }
93 93
94 void gnt_screen_remove_widget(GntWidget *widget) 94 void gnt_screen_remove_widget(GntWidget *widget)
95 { 95 {
96 int pos = g_list_index(g_list_first(focus_list), widget); 96 int pos = g_list_index(g_list_first(focus_list), widget);
110 110
111 if (focus_list) 111 if (focus_list)
112 { 112 {
113 bring_on_top(focus_list->data); 113 bring_on_top(focus_list->data);
114 } 114 }
115 draw_taskbar(); 115 draw_taskbar(FALSE);
116 } 116 }
117 117
118 static void 118 static void
119 bring_on_top(GntWidget *widget) 119 bring_on_top(GntWidget *widget)
120 { 120 {
134 { 134 {
135 GntNode *nd = g_hash_table_lookup(nodes, window_list.window); 135 GntNode *nd = g_hash_table_lookup(nodes, window_list.window);
136 top_panel(nd->panel); 136 top_panel(nd->panel);
137 } 137 }
138 update_screen(NULL); 138 update_screen(NULL);
139 draw_taskbar(); 139 draw_taskbar(FALSE);
140 } 140 }
141 141
142 static void 142 static void
143 update_window_in_list(GntWidget *wid) 143 update_window_in_list(GntWidget *wid)
144 { 144 {
154 154
155 gnt_tree_set_row_flags(GNT_TREE(window_list.tree), wid, flag); 155 gnt_tree_set_row_flags(GNT_TREE(window_list.tree), wid, flag);
156 } 156 }
157 157
158 static void 158 static void
159 draw_taskbar() 159 draw_taskbar(gboolean reposition)
160 { 160 {
161 static WINDOW *taskbar = NULL; 161 static WINDOW *taskbar = NULL;
162 GList *iter; 162 GList *iter;
163 int n, width = 0; 163 int n, width = 0;
164 int i; 164 int i;
165 165
166 if (taskbar == NULL) 166 if (taskbar == NULL)
167 { 167 {
168 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); 168 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0);
169 } 169 }
170 else if (reposition)
171 {
172 mvwin(taskbar, Y_MAX, 0);
173 }
170 174
171 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); 175 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
172 werase(taskbar); 176 werase(taskbar);
173 177
174 n = g_list_length(g_list_first(focus_list)); 178 n = g_list_length(g_list_first(focus_list));
341 345
342 all = g_list_insert(all, widget, pos); 346 all = g_list_insert(all, widget, pos);
343 all = g_list_delete_link(all, list); 347 all = g_list_delete_link(all, list);
344 if (focus_list == list) 348 if (focus_list == list)
345 focus_list = g_list_find(all, widget); 349 focus_list = g_list_find(all, widget);
346 draw_taskbar(); 350 draw_taskbar(FALSE);
347 } 351 }
348 352
349 static void 353 static void
350 dump_screen() 354 dump_screen()
351 { 355 {
450 } 454 }
451 fprintf(file, "</pre>"); 455 fprintf(file, "</pre>");
452 fclose(file); 456 fclose(file);
453 } 457 }
454 458
459 static void
460 refresh_node(GntWidget *widget, GntNode *node, gpointer null)
461 {
462 int x, y, w, h;
463 int nw, nh;
464
465 gnt_widget_get_position(widget, &x, &y);
466 gnt_widget_get_size(widget, &w, &h);
467
468 if (x + w >= X_MAX)
469 x = MAX(0, X_MAX - w);
470 if (y + h >= Y_MAX)
471 y = MAX(0, Y_MAX - h);
472 gnt_screen_move_widget(widget, x, y);
473
474 nw = MIN(w, X_MAX);
475 nh = MIN(h, Y_MAX);
476 if (nw != w || nh != h)
477 gnt_screen_resize_widget(widget, nw, nh);
478 }
479
455 static gboolean 480 static gboolean
456 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) 481 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null)
457 { 482 {
458 char buffer[256]; 483 char buffer[256];
459 gboolean ret = FALSE; 484 gboolean ret = FALSE;
545 { 570 {
546 shift_window(focus_list->data, 1); 571 shift_window(focus_list->data, 1);
547 } 572 }
548 else if (strcmp(buffer + 1, "l") == 0) 573 else if (strcmp(buffer + 1, "l") == 0)
549 { 574 {
550 touchwin(stdscr);
551 touchwin(newscr);
552 wrefresh(newscr);
553 update_screen(NULL); 575 update_screen(NULL);
554 draw_taskbar(); 576 werase(stdscr);
577 wrefresh(stdscr);
578
579 X_MAX = getmaxx(stdscr);
580 Y_MAX = getmaxy(stdscr) - 1;
581
582 g_hash_table_foreach(nodes, (GHFunc)refresh_node, NULL);
583
584 update_screen(NULL);
585 draw_taskbar(TRUE);
555 } 586 }
556 else if (strlen(buffer) == 2 && isdigit(*(buffer + 1))) 587 else if (strlen(buffer) == 2 && isdigit(*(buffer + 1)))
557 { 588 {
558 int n = *(buffer + 1) - '0'; 589 int n = *(buffer + 1) - '0';
559 590
880 911
881 if (focus_list && focus_list->data == widget) 912 if (focus_list && focus_list->data == widget)
882 return; 913 return;
883 914
884 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT); 915 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_URGENT);
885 draw_taskbar(); 916 draw_taskbar(FALSE);
886 } 917 }
887 918
888 void gnt_quit() 919 void gnt_quit()
889 { 920 {
890 gnt_uninit_colors(); 921 gnt_uninit_colors();