Git init
[framework/uifw/isf.git] / ism / extras / gtk_panel / isf_setup_utility.cpp
1 /*
2  * ISF(Input Service Framework)
3  *
4  * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
5  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6  *
7  * Contact: Shuo Liu <shuo0805.liu@samsung.com>, Hengliang Luo <hl.luo@samsung.com>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License as published by the
11  * Free Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
15  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation, Inc., 51
21  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24
25 #define Uses_SCIM_PANEL_AGENT
26
27
28 #include "isf_setup_utility.h"
29
30 MapStringVectorSizeT         _groups;
31 std::vector < String >       _uuids;
32 std::vector < String >       _names;
33 std::vector < String >       _module_names;
34 std::vector < String >       _langs;
35 std::vector < String >       _icons;
36 std::vector < uint32 >       _options;
37 std::vector <TOOLBAR_MODE_T> _modes;
38 MapStringString              _keyboard_ise_help_map;
39 MapStringVectorString        _disabled_ise_map;
40 std::vector < String >       _disabled_langs;
41 MapStringVectorString        _disabled_ise_map_bak;
42 std::vector < String >       _disabled_langs_bak;
43 std::vector < String >       _isf_app_list;
44 gboolean                     _ise_list_changed      = false;
45 gboolean                     _setup_enable_changed  = false;
46 gboolean                     _lang_selected_changed = false;
47
48
49 void get_all_languages (std::vector<String> &all_langs)
50 {
51     String lang_name;
52
53     for (MapStringVectorSizeT::iterator it = _groups.begin (); it != _groups.end (); ++it) {
54         lang_name = scim_get_language_name_english (it->first);
55         all_langs.push_back (lang_name);
56     }
57 }
58
59 void get_selected_languages (std::vector<String> &selected_langs)
60 {
61     String lang_name;
62
63     for (MapStringVectorSizeT::iterator it = _groups.begin (); it != _groups.end (); ++it) {
64         lang_name = scim_get_language_name_english (it->first);
65
66         if (std::find (_disabled_langs.begin (), _disabled_langs.end (), lang_name) == _disabled_langs.end ())
67             selected_langs.push_back (lang_name);
68     }
69 }
70
71 void get_all_iselist_in_languages (std::vector<String> lang_list, std::vector<String> &all_iselist)
72 {
73     String lang_name;
74
75     for (MapStringVectorSizeT::iterator it = _groups.begin (); it != _groups.end (); ++it) {
76         lang_name = scim_get_language_name_english (it->first);
77
78         if (std::find (lang_list.begin (), lang_list.end (), lang_name) != lang_list.end ()) {
79             for (size_t i = 0; i < it->second.size (); i++) {
80                 if (std::find (all_iselist.begin (), all_iselist.end (), _names[it->second[i]]) == all_iselist.end ())
81                     all_iselist.push_back (_names[it->second[i]]);
82             }
83         }
84     }
85 }
86
87 void get_interested_iselist_in_languages (std::vector<String> lang_list, std::vector<String> &interested)
88 {
89     String lang_name;
90     String active_app = _isf_app_list [0];
91
92     for (MapStringVectorSizeT::iterator it = _groups.begin (); it != _groups.end (); ++it) {
93         lang_name = scim_get_language_name_english (it->first);
94         if (std::find(lang_list.begin(), lang_list.end(), lang_name) != lang_list.end ()) {
95             for (size_t i = 0; i < it->second.size (); i++) {
96                 if (std::find (_disabled_ise_map[active_app].begin (), _disabled_ise_map[active_app].end (), _uuids[it->second[i]])
97                         ==_disabled_ise_map[active_app].end ()) {
98                     // Protect from add the same ise more than once in case of multiple langs.-->f_show list
99                     if (std::find (interested.begin (), interested.end (), _names[it->second[i]]) == interested.end ())
100                         interested.push_back (_names[it->second[i]]);
101                 }
102             }
103         }
104     }
105 }
106
107
108 /*
109 vi:ts=4:nowrap:ai:expandtab
110 */