source: editcontext.c @ 7803326

release-1.10release-1.9
Last change on this file since 7803326 was f271129, checked in by Jason Gross <jgross@mit.edu>, 13 years ago
Fix up headers The additions to owl.h and some of the removals were done by Alejandro Sedeño <asedeno@mit.edu> in commit 77a0258b3919468fc9d7f7602588ac427ab36e6c. Notes: * I think owl.c lost the need for sys/time.h when we punted select() in favor of glib's main loop. * We don't actually need to include things like stdarg.h, stdio.h, glib/gstdio.h, glib-object.h. I think they get indirectly included via owl.h and/or glib.h. They're left in (or added in to) the files that use functions/types from them. * I'm not entirely sure what sys/socket.h is doing in message.c. It is there from the initial commit. I suspect it might have had something to do with the call to getnameinfo. message.c compiles without it, but http://pubs.opengroup.org/onlinepubs/009695399/functions/getnameinfo.html suggests that we're supposed to include it? *shrugs* I'm leaving it in, for now. (Rather, I'll leave one copy of the #include in.)
  • Property mode set to 100644
File size: 890 bytes
Line 
1#include "owl.h"
2#include <assert.h>
3
4bool owl_is_editcontext(const owl_context *ctx)
5{
6  return owl_context_matches(ctx, OWL_CTX_TYPWIN);
7}
8
9CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
10{
11  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
12                                     owl_editwin_get_window(e));
13  ctx->deactivate_cb = deactivate_cb;
14  ctx->delete_cb = owl_editcontext_delete_cb;
15  ctx->cbdata = cbdata;
16  /* TODO: the flags are really screwy. */
17  assert(owl_is_editcontext(ctx));
18  return ctx;
19}
20
21owl_editwin *owl_editcontext_get_editwin(const owl_context *ctx)
22{
23  if (!owl_is_editcontext(ctx)) return NULL;
24  return ctx->data;
25}
26
27void owl_editcontext_delete_cb(owl_context *ctx)
28{
29  if (owl_is_editcontext(ctx) && ctx->data) {
30    owl_editwin_unref(ctx->data);
31    ctx->data = NULL;
32  }
33}
Note: See TracBrowser for help on using the repository browser.