summaryrefslogtreecommitdiffstats
path: root/kxkb/rules.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kxkb/rules.cpp')
-rw-r--r--kxkb/rules.cpp97
1 files changed, 15 insertions, 82 deletions
diff --git a/kxkb/rules.cpp b/kxkb/rules.cpp
index 20f817602..ab89b4f17 100644
--- a/kxkb/rules.cpp
+++ b/kxkb/rules.cpp
@@ -35,8 +35,6 @@ XkbRules::XkbRules(bool layoutsOnly):
}
loadRules(rulesFile, layoutsOnly);
- loadOldLayouts(rulesFile);
- loadGroups(::locate("config", "kxkb_groups"));
}
@@ -58,84 +56,6 @@ void XkbRules::loadRules(TQString file, bool layoutsOnly)
// fixLayouts();
}
-// void XkbRules::fixLayouts() {
-// // THIS IS TEMPORARY!!!
-// // This should be fixed in XFree86 (and actually is fixed in XFree 4.2)
-// // some handcoded ones, because the X11 rule file doesn't get them correctly, or in case
-// // the rule file wasn't found
-// static struct {
-// const char * locale;
-// const char * layout;
-// } fixedLayouts[] = {
-// { "ben", "Bengali" },
-// { "ar", "Arabic" },
-// { "ir", "Farsi" },
-// { 0, 0 }
-// };
-//
-// for(int i=0; fixedLayouts[i].layout != 0; i++ ) {
-// if( m_layouts.find(fixedLayouts[i].locale) == 0 )
-// m_layouts.insert(fixedLayouts[i].locale, fixedLayouts[i].layout);
-// }
-// }
-
-bool XkbRules::isSingleGroup(const TQString& layout)
-{
- return X11Helper::areSingleGroupsSupported()
- && !m_oldLayouts.contains(layout)
- && !m_nonLatinLayouts.contains(layout);
-}
-
-
-// check $oldlayouts and $nonlatin groups for XFree 4.3 and later
-void XkbRules::loadOldLayouts(TQString rulesFile)
-{
- OldLayouts* oldLayoutsStruct = X11Helper::loadOldLayouts( rulesFile );
- m_oldLayouts = oldLayoutsStruct->oldLayouts;
- m_nonLatinLayouts = oldLayoutsStruct->nonLatinLayouts;
-}
-
-// for multi-group layouts in XFree 4.2 and older
-// or if layout is present in $oldlayout or $nonlatin groups
-void XkbRules::loadGroups(TQString file)
-{
- TQFile f(file);
- if (f.open(IO_ReadOnly))
- {
- TQTextStream ts(&f);
- TQString locale;
- unsigned int grp;
-
- while (!ts.eof()) {
- ts >> locale >> grp;
- locale.simplifyWhiteSpace();
-
- if (locale[0] == '#' || locale.left(2) == "//" || locale.isEmpty())
- continue;
-
- m_initialGroups.insert(locale, grp);
- }
-
- f.close();
- }
-}
-
-unsigned int
-XkbRules::getDefaultGroup(const TQString& layout, const TQString& includeGroup)
-{
-// check for new one-group layouts in XFree 4.3 and older
- if( isSingleGroup(layout) ) {
- if( includeGroup.isEmpty() == false )
- return 1;
- else
- return 0;
- }
-
- TQMap<TQString, unsigned int>::iterator it = m_initialGroups.find(layout);
- return it == m_initialGroups.end() ? 0 : it.data();
-}
-
-
TQStringList
XkbRules::getAvailableVariants(const TQString& layout)
{
@@ -146,11 +66,24 @@ XkbRules::getAvailableVariants(const TQString& layout)
if( result1 )
return *result1;
- bool oldLayouts = m_oldLayouts.contains(layout);
- TQStringList* result = X11Helper::getVariants(layout, X11_DIR, oldLayouts);
+ TQStringList* result = X11Helper::getVariants(layout, X11_DIR);
m_varLists.insert(layout, result);
return *result;
}
+TQString XkbRules::getLayoutName(LayoutUnit layout) const {
+ TQString fullName = i18n(m_layouts[layout.layout]);
+ if (!layout.variant.isEmpty()) {
+ fullName += " (" + layout.variant + ")";
+ }
+ return fullName;
+}
+
+TQString XkbRules::trOpt(TQString opt) {
+ // xkeyboard-config's translation is generated directly from the xml and has some querks
+ // like sustitution for the '<' and '>'. We will have to workaroung those manually:
+ TQString translated = i18n(opt.replace("<", "&lt;").replace(">", "&gt;").utf8());
+ return translated.replace("&lt;", "<").replace("&gt;", ">");
+}