source: msgwin.c @ c748e8a

release-1.10release-1.8release-1.9
Last change on this file since c748e8a was d4927a7, checked in by Anders Kaseorg <andersk@mit.edu>, 14 years ago
Replace owl_strdup with g_strdup. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Reviewed-by: Karl Ramm <kcr@mit.edu>
  • 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, g_strdup(msg));
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.