File: testmodule.c

package info (click to toggle)
keyman 18.0.245-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,316 kB
  • sloc: python: 52,784; cpp: 21,278; sh: 7,633; ansic: 4,823; xml: 3,617; perl: 959; makefile: 139; javascript: 138
file content (68 lines) | stat: -rw-r--r-- 1,699 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "ibusimcontext.h"
#include <linux/input-event-codes.h>
#include <glib-object.h>
#include <glib.h>
#include <ibus.h>
#include "testmodule.h"

static GType test_module_get_type(void);

#define TEST_TYPE_MODULE (test_module_get_type())

static gboolean
test_module_load(GTypeModule *module) {
  TestModule *test_module = TEST_MODULE(module);

  test_module->register_func(module);

  return TRUE;
}

static void
test_module_unload(GTypeModule *module) {
}

static void
test_module_class_init(TestModuleClass *class) {
  GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS(class);

  module_class->load   = test_module_load;
  module_class->unload = test_module_unload;
}

static GType
test_module_get_type(void) {
  static GType object_type = 0;

  if (!object_type) {
    static const GTypeInfo object_info = {
        sizeof(TestModuleClass),  (GBaseInitFunc)NULL,
        (GBaseFinalizeFunc)NULL,  (GClassInitFunc)test_module_class_init,
        (GClassFinalizeFunc)NULL, NULL,
        sizeof(TestModule),       0,
        (GInstanceInitFunc)NULL,  NULL,
    };
    object_type = g_type_register_static(G_TYPE_TYPE_MODULE, "TestModule", &object_info, 0);
  }
  return object_type;
}

GTypeModule *
test_module_new(TestModuleRegisterFunc register_func) {
  TestModule *test_module = g_object_new(TEST_TYPE_MODULE, NULL);
  GTypeModule *module     = G_TYPE_MODULE(test_module);

  test_module->register_func = register_func;

  /* Register the types initially */
  g_type_module_set_name(module, "FOO");
  g_type_module_use(module);
  //g_type_module_unuse(module);

  return G_TYPE_MODULE(module);
}

void
test_module_unuse(GTypeModule *test_module) {
  g_type_module_unuse(test_module);
}