source: msgwin.c @ 0be3efd

release-1.10release-1.7release-1.8release-1.9
Last change on this file since 0be3efd was 521e600, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Dirty windows when we init them
  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include "owl.h"
2
3static void owl_msgwin_redraw(owl_window *w, WINDOW *curswin, void *msgwin_);
4
5/* Maintains a small status window of text */
6
7void owl_msgwin_init(owl_msgwin *msgwin, owl_window *window)
8{
9  msgwin->msg = NULL;
10  msgwin->window = g_object_ref(window);
11  msgwin->redraw_id = g_signal_connect(window, "redraw", G_CALLBACK(owl_msgwin_redraw), msgwin);
12  owl_window_dirty(window);
13}
14
15static void owl_msgwin_redraw(owl_window *w, WINDOW *curswin, void *msgwin_)
16{
17  owl_msgwin *msgwin = msgwin_;
18
19  werase(curswin);
20  if (msgwin->msg)
21    waddstr(curswin, msgwin->msg); 
22}
23
24void owl_msgwin_set_text(owl_msgwin *msgwin, const char *msg)
25{
26  owl_msgwin_set_text_nocopy(msgwin, msg ? g_strdup(msg) : NULL);
27}
28
29void owl_msgwin_set_text_nocopy(owl_msgwin *msgwin, char *msg)
30{
31  g_free(msgwin->msg);
32  msgwin->msg = msg;
33  owl_window_dirty(msgwin->window);
34}
35
36void owl_msgwin_cleanup(owl_msgwin *msgwin)
37{
38  g_free(msgwin->msg);
39  msgwin->msg = NULL;
40  if (msgwin->window) {
41    g_signal_handler_disconnect(msgwin->window, msgwin->redraw_id);
42    g_object_unref(msgwin->window);
43    msgwin->window = NULL;
44    msgwin->redraw_id = 0;
45  }
46}
Note: See TracBrowser for help on using the repository browser.