2 * Copyright (c) 2008 Jiri Benc <jbenc@upir.cz>
3 * Copyright (c) 2009 Roman Moravcik <roman.moravcik@gmail.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <hildon/hildon-caption.h>
24 #include <hildon/hildon.h>
26 #include <gconf/gconf.h>
27 #include <gconf/gconf-client.h>
32 #define GETTEXT_PACKAGE "ukeyboard"
33 #include <glib/gi18n-lib.h>
35 #define L_CONF_DIR "/apps/osso/inputmethod/hildon-im-languages"
37 gboolean
get_l_bool(GConfClient
*client
, char *lang
, char *key
)
39 char *tmp
= g_strjoin("/", L_CONF_DIR
, lang
, key
, NULL
);
42 res
= gconf_client_get_bool(client
, tmp
, NULL
);
47 void set_l_bool(GConfClient
*client
, char *lang
, char *key
, gboolean val
)
49 char *tmp
= g_strjoin("/", L_CONF_DIR
, lang
, key
, NULL
);
51 g_debug("%s %d\n", tmp
, val
);
53 gconf_client_set_bool(client
, tmp
, val
, NULL
);
57 gchar
*get_l_str(GConfClient
*client
, char *lang
, char *key
)
59 char *tmp
= g_strjoin("/", L_CONF_DIR
, lang
, key
, NULL
);
63 val
= gconf_client_get_without_default(client
, tmp
, NULL
);
67 if (val
->type
!= GCONF_VALUE_STRING
) {
68 gconf_value_free(val
);
71 res
= g_strdup(gconf_value_get_string(val
));
72 gconf_value_free(val
);
76 void set_l_str(GConfClient
*client
, char *lang
, char *key
, gchar
*val
)
78 char *tmp
= g_strjoin("/", L_CONF_DIR
, lang
, key
, NULL
);
80 gconf_client_set_string(client
, tmp
, val
, NULL
);
84 GList
*get_dicts(GList
*langs
)
86 GList
*item
, *dicts
= NULL
;
87 struct lang
*lang
, *dict
;
90 for (item
= langs
, i
= 0; item
; item
= g_list_next(item
)) {
93 /* WORKAROUND: czech, german and russian dictionary must be listed,
94 because they are officially supported */
96 if ((strcmp(lang
->fname
, "cz-qwertz")) &&
97 (strcmp(lang
->fname
, "de-qwertz")) &&
98 (strcmp(lang
->fname
, "es-qwerty")) &&
99 (strcmp(lang
->fname
, "ru-windows")))
103 dict
= g_malloc(sizeof(struct lang
));
104 dict
->fname
= g_strdup(lang
->fname
);
105 dict
->desc
= g_strdup(lang
->desc
);
106 dict
->code
= g_strdup(lang
->code
);
107 dicts
= g_list_append(dicts
, dict
);
112 void fill_dict(HildonTouchSelector
*combo
, GList
*langs
, gchar
*deflang
)
118 for (item
= langs
, i
= 0; item
; item
= g_list_next(item
)) {
121 hildon_touch_selector_append_text(combo
, lang
->desc
);
123 if (deflang
&& !strcmp(lang
->code
, deflang
))
124 hildon_touch_selector_set_active(combo
, 0, i
);
128 hildon_touch_selector_append_text(combo
, _TI("tein_fi_word_completion_language_empty"));
130 if (!deflang
|| !*deflang
)
131 hildon_touch_selector_set_active(combo
, 0, i
);
133 /* check if something is really selected, if not select last item */
134 if (hildon_touch_selector_get_active(combo
, 0) < 0)
135 hildon_touch_selector_set_active(combo
, 0, i
);