Changeset 053f751
- Timestamp:
- Jun 1, 2010, 12:25:28 AM (15 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- e00355d
- Parents:
- 4751077a
- git-author:
- David Benjamin <davidben@mit.edu> (06/01/10 00:24:15)
- git-committer:
- David Benjamin <davidben@mit.edu> (06/01/10 00:25:28)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
r4e33cb2 r053f751 502 502 setlocale(LC_ALL, ""); 503 503 504 g_type_init (); 505 504 506 memset(&opts, 0, sizeof opts); 505 507 opts.load_initial_subs = 1; -
popwin.c
r3da1f4f r053f751 66 66 { 67 67 owl_window_unlink(pw->border); 68 owl_window_delete(pw->border); 68 g_object_unref(pw->border); 69 g_object_unref(pw->content); 69 70 pw->border = 0; 70 71 pw->content = 0; -
window.c
r3da1f4f r053f751 4 4 5 5 struct _owl_window { /*noproto*/ 6 GObject object; 6 7 /* hierarchy information */ 7 8 owl_window *parent; … … 32 33 }; 33 34 35 static void owl_window_dispose(GObject *gobject); 36 static void owl_window_finalize(GObject *gobject); 37 34 38 static owl_window *_owl_window_new(owl_window *parent, int nlines, int ncols, int begin_y, int begin_x); 35 39 … … 41 45 static void _owl_window_realize(owl_window *w); 42 46 static void _owl_window_unrealize(owl_window *w); 47 48 G_DEFINE_TYPE (OwlWindow, owl_window, G_TYPE_OBJECT) 49 50 static void owl_window_class_init (OwlWindowClass *klass) 51 { 52 GObjectClass *object_class = G_OBJECT_CLASS (klass); 53 54 object_class->dispose = owl_window_dispose; 55 object_class->finalize = owl_window_finalize; 56 } 57 58 static void owl_window_dispose (GObject *object) 59 { 60 owl_window *w = OWL_WINDOW (object); 61 62 /* Unmap the window */ 63 owl_window_hide (w); 64 65 /* Unlink and unref all children */ 66 while (w->child) { 67 owl_window *child = w->child; 68 owl_window_unlink (child); 69 } 70 71 /* Clear all cbs */ 72 owl_window_set_redraw_cb (w, 0, 0, 0); 73 owl_window_set_size_cb (w, 0, 0, 0); 74 owl_window_set_destroy_cb (w, 0, 0, 0); 75 76 /* Remove from hierarchy */ 77 owl_window_unlink (w); 78 79 G_OBJECT_CLASS (owl_window_parent_class)->dispose (object); 80 } 81 82 static void owl_window_finalize (GObject *object) 83 { 84 owl_window *w = OWL_WINDOW(object); 85 86 if (w->pan) { 87 del_panel(w->pan); 88 w->pan = NULL; 89 } 90 91 G_OBJECT_CLASS (owl_window_parent_class)->finalize (object); 92 } 93 94 static void owl_window_init (owl_window *w) 95 { 96 } 43 97 44 98 /** singletons **/ … … 90 144 owl_window *w; 91 145 92 w = owl_malloc(sizeof(owl_window));93 memset(w, 0, sizeof(*w));146 w = g_object_new (OWL_TYPE_WINDOW, NULL); 147 if (w == NULL) g_error("Failed to create owl_window instance"); 94 148 95 149 w->nlines = nlines; … … 105 159 106 160 return w; 107 }108 109 void owl_window_delete(owl_window *w)110 {111 /* destroy all children */112 owl_window_children_foreach_onearg(w, owl_window_delete);113 114 /* notify everyone of your imminent demise */115 if (w->destroy_cb)116 w->destroy_cb(w, w->destroy_cbdata);117 118 /* clear all cbs */119 owl_window_set_redraw_cb(w, 0, 0, 0);120 owl_window_set_size_cb(w, 0, 0, 0);121 owl_window_set_destroy_cb(w, 0, 0, 0);122 123 /* destroy curses structures */124 owl_window_unmap(w);125 if (w->pan) {126 del_panel(w->pan);127 }128 129 /* remove from hierarchy */130 _owl_window_unlink(w);131 owl_free(w);132 161 } 133 162 … … 193 222 w->parent->child = w->next; 194 223 w->parent = NULL; 224 g_object_unref (w); 195 225 } 196 226 } … … 206 236 w->next = parent->child; 207 237 parent->child = w; 238 g_object_ref (w); 208 239 } 209 240 } … … 222 253 void owl_window_children_foreach_onearg(owl_window *parent, void (*func)(owl_window*)) 223 254 { 224 owl_window *w; 225 for (w = parent->child; 226 w != NULL; 227 w = w->next) { 228 func(w); 229 } 255 owl_window_children_foreach(parent, (GFunc)func, NULL); 230 256 } 231 257 -
window.h
r3da1f4f r053f751 3 3 4 4 #include <glib.h> 5 #include <glib-object.h> 5 6 6 typedef struct _owl_window owl_window; 7 G_BEGIN_DECLS 8 9 #define OWL_TYPE_WINDOW (owl_window_get_type ()) 10 #define OWL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OWL_TYPE_WINDOW, OwlWindow)) 11 #define OWL_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OWL_TYPE_WINDOW)) 12 #define OWL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OWL_TYPE_WINDOW, OwlWindowClass)) 13 #define OWL_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OWL_TYPE_WINDOW)) 14 #define OWL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OWL_TYPE_WINDOW, OwlWindowClass)) 15 16 typedef struct _owl_window OwlWindow; 17 typedef struct _OwlWindowClass OwlWindowClass; 18 typedef OwlWindow owl_window; /* meh */ 19 20 struct _OwlWindowClass 21 { 22 GObjectClass parent_class; 23 }; 24 25 GType owl_window_get_type(void); 7 26 8 27 owl_window *owl_window_get_screen(void); 9 28 10 29 owl_window *owl_window_new(owl_window *parent); 11 void owl_window_delete(owl_window *w);12 30 void owl_window_unlink(owl_window *w); 13 31 … … 43 61 void owl_window_erase_cb(owl_window *w, WINDOW *win, void *user_data); 44 62 63 G_END_DECLS 64 45 65 #endif /* __BARNOWL_WINDOW_H__ */
Note: See TracChangeset
for help on using the changeset viewer.