File: scim_setup_module.cpp

package info (click to toggle)
scim 1.4.7-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 20,368 kB
  • ctags: 12,834
  • sloc: cpp: 51,239; sh: 22,370; ansic: 18,716; makefile: 1,258; xml: 641; yacc: 288
file content (158 lines) | stat: -rw-r--r-- 3,838 bytes parent folder | download | duplicates (11)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
 * Smart Common Input Method
 * 
 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
 *
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *
 * $Id: scim_setup_module.cpp,v 1.9 2005/01/10 08:30:45 suzhe Exp $
 *
 */

#define Uses_SCIM_CONFIG_BASE
#define Uses_SCIM_MODULE

#include "scim_private.h"
#include "scim.h"
#include "scim_setup_module.h"

SetupModule::SetupModule ()
    : m_create_ui (0),
      m_get_category (0),
      m_get_name (0),
      m_get_description (0),
      m_load_config (0),
      m_save_config (0)
{
}

SetupModule::SetupModule (const String &name)
    : m_create_ui (0),
      m_get_category (0),
      m_get_name (0),
      m_get_description (0),
      m_load_config (0),
      m_save_config (0)
{
    load (name);
}

bool
SetupModule::load (const String &name)
{
    if (!m_module.load (name, "SetupUI"))
        return false;

    m_create_ui       = (SetupModuleCreateUIFunc) m_module.symbol ("scim_setup_module_create_ui");
    m_get_category    = (SetupModuleGetCategoryFunc) m_module.symbol ("scim_setup_module_get_category");
    m_get_name        = (SetupModuleGetNameFunc) m_module.symbol ("scim_setup_module_get_name");
    m_get_description = (SetupModuleGetDescriptionFunc) m_module.symbol ("scim_setup_module_get_description");
    m_load_config     = (SetupModuleLoadConfigFunc) m_module.symbol ("scim_setup_module_load_config");
    m_save_config     = (SetupModuleSaveConfigFunc) m_module.symbol ("scim_setup_module_save_config");
    m_query_changed   = (SetupModuleQueryChangedFunc) m_module.symbol ("scim_setup_module_query_changed");


    if (!m_create_ui || !m_get_category || !m_get_name ||
        !m_load_config || !m_save_config) {
        m_module.unload ();
        m_create_ui = 0;
        m_get_category = 0;
        m_get_name = 0;
        m_get_description = 0;
        m_load_config = 0;
        m_save_config = 0;
        return false;
    }

    return true;
}

bool
SetupModule::valid () const
{
    return (m_module.valid () &&
            m_create_ui && m_get_category && m_get_name &&
            m_load_config && m_save_config);
}

GtkWidget *
SetupModule::create_ui () const
{
    if (valid ())
        return m_create_ui ();

    return 0;
}

String
SetupModule::get_category () const
{
    if (valid ())
        return m_get_category ();

    return String ();
}

String
SetupModule::get_name () const
{
    if (valid ())
        return m_get_name ();

    return String ();
}

String
SetupModule::get_description () const
{
    if (valid () && m_get_description)
        return m_get_description ();

    return String ();
}

void
SetupModule::load_config (const ConfigPointer &config) const
{
    if (valid ())
        m_load_config (config);
}

void
SetupModule::save_config (const ConfigPointer &config) const
{
    if (valid ())
        m_save_config (config);
}

bool
SetupModule::query_changed () const
{
    if (valid () && m_query_changed)
        return m_query_changed ();
    return false;
}

int scim_get_setup_module_list (std::vector <String>& mod_list)
{
    return scim_get_module_list (mod_list, "SetupUI");
}


/*
vi:ts=4:nowrap:ai:expandtab
*/