~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to uim/uim-custom.h

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2006-11-23 15:10:53 UTC
  • mfrom: (3.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061123151053-q42sk1lvks41xpfx
Tags: 1:1.2.1-9
uim-gtk2.0.postinst: Don't call update-gtk-immodules on purge.
(closes: Bug#398530)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
  Copyright (c) 2003-2006 uim Project http://uim.freedesktop.org/
 
4
 
 
5
  All rights reserved.
 
6
 
 
7
  Redistribution and use in source and binary forms, with or without
 
8
  modification, are permitted provided that the following conditions
 
9
  are met:
 
10
 
 
11
  1. Redistributions of source code must retain the above copyright
 
12
     notice, this list of conditions and the following disclaimer.
 
13
  2. Redistributions in binary form must reproduce the above copyright
 
14
     notice, this list of conditions and the following disclaimer in the
 
15
     documentation and/or other materials provided with the distribution.
 
16
  3. Neither the name of authors nor the names of its contributors
 
17
     may be used to endorse or promote products derived from this software
 
18
     without specific prior written permission.
 
19
 
 
20
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
 
21
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
22
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
23
  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
 
24
  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
25
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
26
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
27
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
28
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
29
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
30
  SUCH DAMAGE.
 
31
 
 
32
*/
 
33
 
 
34
 
 
35
#ifndef _uim_custom_h_included_
 
36
#define _uim_custom_h_included_
 
37
 
 
38
#include "uim.h"
 
39
 
 
40
#ifdef __cplusplus
 
41
extern "C" {
 
42
#endif
 
43
 
 
44
enum UCustomType {
 
45
  UCustom_Bool,
 
46
  UCustom_Int,
 
47
  UCustom_Str,
 
48
  UCustom_Pathname,
 
49
  UCustom_Choice,
 
50
  UCustom_OrderedList,
 
51
  UCustom_Key
 
52
};
 
53
 
 
54
enum UCustomPathnameType {
 
55
  UCustomPathnameType_RegularFile,
 
56
  UCustomPathnameType_Directory
 
57
};
 
58
 
 
59
enum UCustomKeyType {
 
60
  UCustomKey_Regular,   /* "<Control>j" */
 
61
  UCustomKey_Reference  /* "generic-cancel-key" */
 
62
};
 
63
 
 
64
enum UCustomKeyEditorType {
 
65
  UCustomKeyEditor_Basic,    /* only "<Control>j" style should be available */
 
66
  UCustomKeyEditor_Advanced  /* "generic-cancel-key" style should be specifiable */
 
67
};
 
68
 
 
69
union uim_custom_value {
 
70
  int as_bool;
 
71
  int as_int;
 
72
  char *as_str;
 
73
  struct uim_custom_pathname *as_pathname;
 
74
  struct uim_custom_choice *as_choice;
 
75
  struct uim_custom_choice **as_olist;
 
76
  struct uim_custom_key **as_key;
 
77
};
 
78
 
 
79
struct uim_custom_pathname {
 
80
  char *str;
 
81
  int type;   /* UCustomPathnameType */
 
82
};
 
83
 
 
84
struct uim_custom_choice {
 
85
  char *symbol;
 
86
  char *label;
 
87
  char *desc;
 
88
};
 
89
 
 
90
struct uim_custom_key {
 
91
  int type;         /* UCustomKeyType */
 
92
  int editor_type;  /* UCustomKeyEditorType */
 
93
  char *literal;
 
94
  char *label;
 
95
  char *desc;
 
96
};
 
97
 
 
98
union uim_custom_range {
 
99
  struct {
 
100
    int min, max;
 
101
  } as_int;
 
102
 
 
103
  struct {
 
104
    char *regex;
 
105
  } as_str;
 
106
 
 
107
  struct {
 
108
    struct uim_custom_choice **valid_items;
 
109
  } as_choice;
 
110
 
 
111
  struct {
 
112
    struct uim_custom_choice **valid_items;  /* contains all possible items */
 
113
  } as_olist;
 
114
};
 
115
 
 
116
struct uim_custom {
 
117
  int type;  /* UCustomType */
 
118
  int is_active;
 
119
  char *symbol;
 
120
  char *label;
 
121
  char *desc;
 
122
  union uim_custom_value *value;
 
123
  union uim_custom_value *default_value;
 
124
  union uim_custom_range *range;
 
125
};
 
126
 
 
127
struct uim_custom_group {
 
128
  char *symbol;
 
129
  char *label;
 
130
  char *desc;
 
131
};
 
132
 
 
133
 
 
134
uim_bool uim_custom_enable(void);
 
135
 
 
136
/* load & save */
 
137
uim_bool uim_custom_load(void);
 
138
uim_bool uim_custom_save(void);
 
139
uim_bool uim_custom_broadcast(void);
 
140
uim_bool uim_custom_broadcast_reload_request(void);
 
141
 
 
142
/* custom variable */
 
143
struct uim_custom *uim_custom_get(const char *custom_sym);
 
144
uim_bool uim_custom_set(const struct uim_custom *custom);
 
145
void uim_custom_free(struct uim_custom *custom);
 
146
 
 
147
/* callback function */
 
148
uim_bool uim_custom_cb_add(const char *custom_sym, void *ptr,
 
149
                           void (*update_cb)(void *ptr, const char *custom_sym));
 
150
uim_bool uim_custom_cb_remove(const char *custom_sym);
 
151
uim_bool uim_custom_group_cb_add(const char *group_sym, void *ptr,
 
152
                                 void (*update_cb)(void *ptr, const char *group_sym));
 
153
uim_bool uim_custom_group_cb_remove(const char *group_sym);
 
154
uim_bool uim_custom_global_cb_add(void *ptr,
 
155
                                  void (*group_list_update_cb)(void *ptr));
 
156
uim_bool uim_custom_global_cb_remove(void);
 
157
 
 
158
/* literalization */
 
159
char *uim_custom_value_as_literal(const char *custom_sym);
 
160
char *uim_custom_definition_as_literal(const char *custom_sym);
 
161
 
 
162
/* custom group */
 
163
struct uim_custom_group *uim_custom_group_get(const char *group_sym);
 
164
void uim_custom_group_free(struct uim_custom_group *custom_group);
 
165
 
 
166
/* custom symbol list */
 
167
char **uim_custom_collect_by_group(const char *group_sym);
 
168
/* char **uim_custom_collect_by_groups(const char *const *group_syms); */
 
169
 
 
170
/* group symbol list */
 
171
char **uim_custom_groups(void);
 
172
char **uim_custom_primary_groups(void);
 
173
char **uim_custom_group_subgroups(const char *group_sym);
 
174
 
 
175
void uim_custom_symbol_list_free(char **symbol_list);
 
176
 
 
177
/* custom choice (for ordered list) */
 
178
struct uim_custom_choice *uim_custom_choice_new(char *symbol,
 
179
                                                char *label,
 
180
                                                char *desc);
 
181
void uim_custom_choice_list_free(struct uim_custom_choice **list);
 
182
 
 
183
/* custom key */
 
184
struct uim_custom_key *uim_custom_key_new(int type,
 
185
                                          int editor_type,
 
186
                                          char *literal,
 
187
                                          char *label,
 
188
                                          char *desc);
 
189
void uim_custom_key_list_free(struct uim_custom_key **list);
 
190
 
 
191
#ifdef __cplusplus
 
192
}
 
193
#endif
 
194
#endif  /* _uim_custom_h_included_ */