Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anwar_N
ibus-braille
Commits
6826982f
Commit
6826982f
authored
Feb 11, 2016
by
Anwar_N
Browse files
Liblouis integration step 1
parent
076da093
Changes
3
Hide whitespace changes
Inline
Side-by-side
engine/engine.py
View file @
6826982f
...
...
@@ -28,6 +28,9 @@ import configparser
from
gi.repository
import
GLib
from
gi.repository
import
IBus
from
gi.repository
import
Pango
#Liblouis
import
louis
keysyms
=
IBus
...
...
@@ -92,6 +95,7 @@ class EngineSharadaBraille(IBus.Engine):
self
.
list_switch_key
=
int
(
Config
.
get
(
'cfg'
,
"list_switch_key"
))
self
.
language_iter
=
int
(
Config
.
get
(
'cfg'
,
"default-language"
))
self
.
conventional_braille
=
int
(
Config
.
get
(
'cfg'
,
"conventional-braille"
))
self
.
liblouis_mode
=
int
(
Config
.
get
(
'cfg'
,
"liblouis-mode"
))
except
:
self
.
checked_languages
=
[
"english-en"
,
"hindi-hi"
]
self
.
simple_mode
=
0
...
...
@@ -100,11 +104,13 @@ class EngineSharadaBraille(IBus.Engine):
self
.
list_switch_key
=
56
self
.
language_iter
=
0
self
.
conventional_braille
=
False
;
self
.
liblouis_mode
=
False
;
self
.
conventional_braille_dot_4
=
False
;
self
.
conventional_braille_dot_4_pass
=
False
;
self
.
conventional_braille_dot_3
=
False
;
#Braille Iter's
self
.
braille_letter_map_pos
=
0
;
...
...
@@ -153,7 +159,7 @@ class EngineSharadaBraille(IBus.Engine):
self
.
old_braille_letter_map_pos
=
self
.
braille_letter_map_pos
#Move map position to contraction if any
if
ordered_pressed_keys
in
self
.
contractions_dict
.
keys
():
if
(
ordered_pressed_keys
in
self
.
contractions_dict
.
keys
()
and
self
.
liblouis_mode
==
False
)
:
self
.
braille_letter_map_pos
=
self
.
contractions_dict
[
ordered_pressed_keys
];
#Toggle Punctuation
...
...
@@ -227,23 +233,31 @@ class EngineSharadaBraille(IBus.Engine):
self
.
capital_switch
=
1
;
elif
(
self
.
conventional_braille
==
True
and
ordered_pressed_keys
==
"4"
):
ordered_pressed_keys
==
"4"
and
self
.
liblouis_mode
==
False
):
self
.
conventional_braille_dot_4
=
True
;
else
:
if
(
len
(
ordered_pressed_keys
)
>
0
):
value
=
self
.
map
[
ordered_pressed_keys
][
self
.
braille_letter_map_pos
]
if
(
self
.
capital_switch
==
1
or
self
.
capital
==
1
):
value
=
value
.
upper
()
self
.
capital_switch
=
0
;
self
.
__commit_string
(
value
);
self
.
conventional_braille_dot_4_pass
=
False
;
self
.
conventional_braille_dot_3
=
False
;
if
(
self
.
conventional_braille
==
1
and
self
.
conventional_braille_dot_4
):
self
.
conventional_braille_dot_4
=
False
;
self
.
__commit_string
(
self
.
map
[
"4"
][
self
.
braille_letter_map_pos
]);
self
.
conventional_braille_dot_4_pass
=
True
;
self
.
braille_letter_map_pos
=
1
;
if
(
self
.
liblouis_mode
):
sum
=
0
for
i
in
ordered_pressed_keys
:
sum
=
sum
+
pow
(
2
,
int
(
i
)
-
1
);
pressed_dots
=
0x2800
+
sum
#self.louis_current_typing_word = self.louis_current_typing_word + chr(pressed_dots)
self
.
__commit_string
(
chr
(
pressed_dots
))
else
:
value
=
self
.
map
[
ordered_pressed_keys
][
self
.
braille_letter_map_pos
]
if
(
self
.
capital_switch
==
1
or
self
.
capital
==
1
):
value
=
value
.
upper
()
self
.
capital_switch
=
0
;
self
.
__commit_string
(
value
);
self
.
conventional_braille_dot_4_pass
=
False
;
self
.
conventional_braille_dot_3
=
False
;
if
(
self
.
conventional_braille
==
1
and
self
.
conventional_braille_dot_4
):
self
.
conventional_braille_dot_4
=
False
;
self
.
__commit_string
(
self
.
map
[
"4"
][
self
.
braille_letter_map_pos
]);
self
.
conventional_braille_dot_4_pass
=
True
;
self
.
braille_letter_map_pos
=
1
;
return
False
...
...
@@ -255,20 +269,31 @@ class EngineSharadaBraille(IBus.Engine):
self
.
pressed_keys
+=
self
.
keycode_map
[
keycode
];
return
True
else
:
if
keyval
==
keysyms
.
space
:
if
(
keyval
==
keysyms
.
space
)
:
self
.
braille_letter_map_pos
=
0
;
if
(
self
.
conventional_braille
==
True
):
if
(
self
.
conventional_braille_dot_3
):
self
.
__commit_string
(
self
.
map
[
"3"
][
self
.
old_braille_letter_map_pos
]);
self
.
conventional_braille_dot_3
=
False
;
if
(
self
.
conventional_braille_dot_4
):
self
.
conventional_braille_dot_4
=
False
;
self
.
__commit_string
(
self
.
map
[
"4"
][
self
.
braille_letter_map_pos
]);
elif
(
self
.
conventional_braille_dot_4_pass
==
True
):
self
.
conventional_braille_dot_4_pass
=
False
self
.
__commit_string
(
self
.
map
[
"8"
][
self
.
braille_letter_map_pos
]);
return
True
if
(
self
.
liblouis_mode
):
surrounding_text
=
self
.
get_surrounding_text
()
text
=
surrounding_text
[
0
].
get_text
()
cursor_pos
=
surrounding_text
[
1
]
string_up_to_cursor
=
text
[:
cursor_pos
];
count
=
len
(
string_up_to_cursor
.
split
()[
-
1
])
last_word
=
string_up_to_cursor
.
split
()[
-
1
]
if
(
string_up_to_cursor
[
-
1
]
!=
" "
):
word
=
louis
.
backTranslate
([
'unicode.dis'
,
'ml-in-g1.utb'
],
last_word
,
None
,
0
)
self
.
delete_surrounding_text
(
-
(
count
),
count
);
self
.
__commit_string
(
word
[
0
])
else
:
if
(
self
.
conventional_braille
==
True
):
if
(
self
.
conventional_braille_dot_3
):
self
.
__commit_string
(
self
.
map
[
"3"
][
self
.
old_braille_letter_map_pos
]);
self
.
conventional_braille_dot_3
=
False
;
if
(
self
.
conventional_braille_dot_4
):
self
.
conventional_braille_dot_4
=
False
;
self
.
__commit_string
(
self
.
map
[
"4"
][
self
.
braille_letter_map_pos
]);
elif
(
self
.
conventional_braille_dot_4_pass
==
True
):
self
.
conventional_braille_dot_4_pass
=
False
self
.
__commit_string
(
self
.
map
[
"8"
][
self
.
braille_letter_map_pos
]);
return
True
else
:
if
(
keycode
==
self
.
key_to_switch_between_languages
):
if
(
len
(
self
.
checked_languages
)
-
1
==
self
.
language_iter
):
...
...
preferences/main.py
View file @
6826982f
...
...
@@ -55,6 +55,7 @@ class ibus_sharada_braille_preferences():
# The following are for a try only
self
.
config
.
get
(
'cfg'
,
"conventional-braille"
)
self
.
config
.
get
(
'cfg'
,
"simple-mode"
)
self
.
config
.
get
(
'cfg'
,
"liblouis-mode"
)
except
:
# To avoid duplication of cfg section
...
...
@@ -67,6 +68,7 @@ class ibus_sharada_braille_preferences():
self
.
reset_keys_and_shorcuts
(
None
,
None
)
self
.
config
.
set
(
'cfg'
,
"simple-mode"
,
str
(
0
))
self
.
config
.
set
(
'cfg'
,
"conventional-braille"
,
str
(
0
))
self
.
config
.
set
(
'cfg'
,
"liblouis-mode"
,
str
(
0
))
self
.
config
.
set
(
'cfg'
,
"default-language"
,
str
(
0
))
default_language
=
0
;
self
.
key_dict
=
self
.
default_key_dict
.
copy
()
...
...
@@ -108,6 +110,10 @@ class ibus_sharada_braille_preferences():
#Set Simple conventional-braille checkbox
checkbutton_conventional_braille
=
self
.
guibuilder
.
get_object
(
"checkbutton_conventional_braille"
)
checkbutton_conventional_braille
.
set_active
(
int
(
self
.
config
.
get
(
'cfg'
,
"conventional-braille"
)))
#Set liblouis-mode checkbox
checkbutton_liblouis_mode
=
self
.
guibuilder
.
get_object
(
"checkbutton_liblouis_mode"
)
checkbutton_liblouis_mode
.
set_active
(
int
(
self
.
config
.
get
(
'cfg'
,
"liblouis-mode"
)))
self
.
guibuilder
.
connect_signals
(
self
)
self
.
window
.
show
()
...
...
@@ -120,6 +126,9 @@ class ibus_sharada_braille_preferences():
def
conventional_braille_toggled
(
self
,
widget
,
data
=
None
):
self
.
config
.
set
(
'cfg'
,
"conventional-braille"
,
str
(
int
(
widget
.
get_active
())))
def
liblouis_mode_toggled
(
self
,
widget
,
data
=
None
):
self
.
config
.
set
(
'cfg'
,
"liblouis-mode"
,
str
(
int
(
widget
.
get_active
())))
def
reset_keys_and_shorcuts
(
self
,
widget
,
data
=
None
):
...
...
preferences/ui.glade
View file @
6826982f
...
...
@@ -52,6 +52,22 @@
<property
name=
"position"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkCheckButton"
id=
"checkbutton_liblouis_mode"
>
<property
name=
"label"
translatable=
"yes"
>
Liblouis-mode
</property>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"xalign"
>
0
</property>
<property
name=
"draw_indicator"
>
True
</property>
<signal
name=
"toggled"
handler=
"liblouis_mode_toggled"
swapped=
"no"
/>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
2
</property>
</packing>
</child>
<child>
<object
class=
"GtkBox"
id=
"box4"
>
<property
name=
"visible"
>
True
</property>
...
...
@@ -86,7 +102,7 @@
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
2
</property>
<property
name=
"position"
>
3
</property>
</packing>
</child>
</object>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment