source: msgwin.c @ 9bd51b8

release-1.10release-1.7release-1.8release-1.9
Last change on this file since 9bd51b8 was d70f45f, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Port the msgwin to owl_window I feel kind of silly making a new file for this, but meh.
  • 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}
13
14static void owl_msgwin_redraw(owl_window *w, WINDOW *curswin, void *msgwin_)
15{
16  owl_msgwin *msgwin = msgwin_;
17
18  werase(curswin);
19  if (msgwin->msg)
20    waddstr(curswin, msgwin->msg); 
21}
22
23void owl_msgwin_set_text(owl_msgwin *msgwin, const char *msg)
24{
25  owl_msgwin_set_text_nocopy(msgwin, msg ? g_strdup(msg) : NULL);
26}
27
28void owl_msgwin_set_text_nocopy(owl_msgwin *msgwin, char *msg)
29{
30  g_free(msgwin->msg);
31  msgwin->msg = msg;
32  owl_window_dirty(msgwin->window);
33}
34
35void owl_msgwin_cleanup(owl_msgwin *msgwin)
36{
37  g_free(msgwin->msg);
38  msgwin->msg = NULL;
39  if (msgwin->window) {
40    g_signal_handler_disconnect(msgwin->window, msgwin->redraw_id);
41    g_object_unref(msgwin->window);
42    msgwin->window = NULL;
43    msgwin->redraw_id = 0;
44  }
45}
Note: See TracBrowser for help on using the repository browser.