Changeset 9eb38bb for viewwin.c


Ignore:
Timestamp:
Sep 18, 2010, 5:07:39 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
d574d61
Parents:
8ee712e0
git-author:
David Benjamin <davidben@mit.edu> (08/01/10 14:09:34)
git-committer:
David Benjamin <davidben@mit.edu> (09/18/10 17:07:39)
Message:
Likewise, don't reuse a global owl_viewwin

This means we don't have to support plugging and unplugging that thing
over and over. We also can almost entirely drop the global owl_viewwin.
Most of the code gets it from the context anyway.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • viewwin.c

    r61c1f19 r9eb38bb  
    77static void owl_viewwin_set_window(owl_viewwin *v, owl_window *w);
    88
    9 /* initialize the viewwin e.  'win' is an already initialzed curses
    10  * window that will be used by viewwin
     9/* Create a viewwin.  'win' is an already initialized owl_window that
     10 * will be used by the viewwin
    1111 */
    12 void owl_viewwin_init_text(owl_viewwin *v, owl_window *win, const char *text)
     12owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1313{
     14  owl_viewwin *v = owl_malloc(sizeof(owl_viewwin));
     15  memset(v, 0, sizeof(*v));
    1416  owl_fmtext_init_null(&(v->fmtext));
    1517  if (text) {
     
    2527
    2628  owl_viewwin_set_window(v, win);
     29  return v;
    2730}
    2831
     
    4245}
    4346
    44 /* initialize the viewwin e.  'win' is an already initialzed curses
    45  * window that will be used by viewwin
     47/* Create a viewwin.  'win' is an already initialized owl_window that
     48 * will be used by the viewwin
    4649 */
    47 void owl_viewwin_init_fmtext(owl_viewwin *v, owl_window *win, const owl_fmtext *fmtext)
     50owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    4851{
    4952  char *text;
     53  owl_viewwin *v = owl_malloc(sizeof(owl_viewwin));
     54  memset(v, 0, sizeof(*v));
    5055
    5156  owl_fmtext_copy(&(v->fmtext), fmtext);
     
    6065
    6166  owl_viewwin_set_window(v, win);
     67  return v;
    6268}
    6369
    6470static void owl_viewwin_set_window(owl_viewwin *v, owl_window *w)
    6571{
    66   if (v->window) {
    67     g_signal_handler_disconnect(v->window, v->sig_redraw_id);
    68     g_object_unref(v->window);
    69   }
    7072  v->window = w;
    7173  if (w) {
     
    181183}
    182184
    183 void owl_viewwin_cleanup(owl_viewwin *v)
     185void owl_viewwin_delete(owl_viewwin *v)
    184186{
    185   owl_viewwin_set_window(v, NULL);
    186187  if (v->onclose_hook) {
    187188    v->onclose_hook(v, v->onclose_hook_data);
     
    189190    v->onclose_hook_data = NULL;
    190191  }
     192  if (v->window) {
     193    g_signal_handler_disconnect(v->window, v->sig_redraw_id);
     194    g_object_unref(v->window);
     195    v->window = NULL;
     196  }
    191197  owl_fmtext_cleanup(&(v->fmtext));
     198  owl_free(v);
    192199}
Note: See TracChangeset for help on using the changeset viewer.