File: im_engine.cpp

package info (click to toggle)
scim-unikey 0.3.1+debian-3.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,396 kB
  • ctags: 1,262
  • sloc: sh: 10,650; cpp: 7,490; makefile: 169; sed: 16
file content (130 lines) | stat: -rw-r--r-- 3,649 bytes parent folder | download | duplicates (3)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
   Scim-Unikey Input Method

   Copyright (C) 2008-2009 Ubuntu-VN <http://www.ubuntu-vn.org>
   Author: Le Quoc Tuan <mr.lequoctuan@gmail.com>
   Home: http://scim-unikey.googlecode.com
   License: GNU LESSER GENERAL PUBLIC LICENSE v2.1
*/

#define Uses_SCIM_IMENGINE
#define Uses_SCIM_ICONV
#define Uses_SCIM_CONFIG_BASE
#define Uses_SCIM_CONFIG_PATH

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <libintl.h>
#define _(String) dgettext(PACKAGE_NAME,String)

#include <scim.h>
#include "scim_unikey_const.h"
#include "im_engine.h"

#include <string.h>
#include "unikey.h"

#define scim_module_init                            unikey_LTX_scim_module_init
#define scim_module_exit                            unikey_LTX_scim_module_exit
#define scim_imengine_module_init                   unikey_LTX_scim_imengine_module_init
#define scim_imengine_module_create_factory         unikey_LTX_scim_imengine_module_create_factory

ConfigPointer   __config;

using namespace scim;

extern "C"
{
    void scim_module_init(void)
    {
        UnikeySetup();
    }

    void scim_module_exit(void)
    {
        UnikeyCleanup();
    }

    unsigned int scim_imengine_module_init(ConfigPointer &config)
    {
        if (config.null())
            return 0;
        __config = config;

        return 2;
    }

    IMEngineFactoryPointer scim_imengine_module_create_factory(unsigned int index)
    {
        return new UnikeyFactory(index);
    }
}

UnikeyFactory::UnikeyFactory(int id)
{
    m_id = id;
    set_languages("vi_VN");
}
UnikeyFactory::~UnikeyFactory()
{
}
WideString UnikeyFactory::get_name() const
{
    return utf8_mbstowcs(m_id==0?"Unikey":"Unikey Classic");
}
String UnikeyFactory::get_uuid() const
{
    return String("16ef5139-de02-494f-8d98-ddfcd60bbae1-") + String(m_id==0?"PREEDIT":"CLASSIC");
}
WideString UnikeyFactory::get_authors() const
{
    return utf8_mbstowcs("Le Quoc Tuan <mr.lequoctuan@gmail.com>");
}
WideString UnikeyFactory::get_credits() const
{
    return utf8_mbstowcs(String("Scim-Unikey Input Method\n"
                                "Version: " PACKAGE_VERSION "\n"
                                "Copyright © 2008-2009 Ubuntu-VN\n"
                                "http://www.ubuntu-vn.org\n\n"
                                "Thanks to Pham Kim Long for ukengine")
        );
}
WideString UnikeyFactory::get_help() const
{
    return utf8_mbstowcs(_("This IME work best when environment variable are\n"
                           "- GTK_IM_MODULE=scim-bridge\n"
                           "- QT_IM_MODULE=xim\n\n"

                           "Some time, in some application, you \"must\"\n"
                           "use Preedit to input properly\n\n"

                           "In some application, scim can't enable,\n"
                           "this is not a bug of scim-unikey.\n"
                           "You can try this in terminal: app_name | scim\n\n"

                           "This IME come into being not intend to\n"
                           "replace scim-m17n, just a choose, I recommend\n"
                           "use this combine with scim-m17n\n\n"

                           "For other support goto:\n"
                           "  http://code.google.com/p/scim-unikey/wiki/Support"));
}
String UnikeyFactory::get_icon_file() const
{
    return String(SCIM_ICONDIR SCIM_UNIKEY_ICON_MAIN);
}

IMEngineInstancePointer UnikeyFactory::create_instance(const String & encoding, int id)
{
    if (m_id==0)
    {
        return new UnikeyInstancePreedit(this, encoding, id);
    }
    else
    {
        return new UnikeyInstanceClassic(this, encoding, id);
    }
}