source: editcontext.c @ d191f45

release-1.10release-1.8release-1.9
Last change on this file since d191f45 was 6829afc, checked in by David Benjamin <davidben@mit.edu>, 13 years ago
Define CALLER_OWN macro Replace our exising uses of G_GNUC_WARN_UNUSED_RESULT with it. The old macro is just way too long. This also more clearly specifies the intent.
  • Property mode set to 100644
File size: 891 bytes
Line 
1#include "owl.h"
2
3#include <assert.h>
4
5bool owl_is_editcontext(const owl_context *ctx)
6{
7  return owl_context_matches(ctx, OWL_CTX_TYPWIN);
8}
9
10CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
11{
12  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
13                                     owl_editwin_get_window(e));
14  ctx->deactivate_cb = deactivate_cb;
15  ctx->delete_cb = owl_editcontext_delete_cb;
16  ctx->cbdata = cbdata;
17  /* TODO: the flags are really screwy. */
18  assert(owl_is_editcontext(ctx));
19  return ctx;
20}
21
22owl_editwin *owl_editcontext_get_editwin(const owl_context *ctx)
23{
24  if (!owl_is_editcontext(ctx)) return NULL;
25  return ctx->data;
26}
27
28void owl_editcontext_delete_cb(owl_context *ctx)
29{
30  if (owl_is_editcontext(ctx) && ctx->data) {
31    owl_editwin_unref(ctx->data);
32    ctx->data = NULL;
33  }
34}
Note: See TracBrowser for help on using the repository browser.