Skip to content

Commit d637cd6

Browse files
committed
feat: Better completions
Getting rid of Gtk.EntryCompletion
1 parent 34b1529 commit d637cd6

9 files changed

Lines changed: 433 additions & 123 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Wordbook
2323

2424
## Requirements
2525

26-
* GTK 4.6+ [Arch: `gtk4`]
26+
* GTK 4.16+ [Arch: `gtk4`]
2727
* libadwaita 1.7.0+ [Arch: `libadwaita`]
2828
* Python 3.12+ [Arch: `python`]
2929
* Python modules:

data/resources/style.css

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@
66

77
/* Favorite items styling */
88
.favorite-item {
9-
background-color: alpha(@accent_color, 0.1);
9+
background-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
1010
}
1111

1212
.favorite-item:hover {
13-
background-color: alpha(@accent_color, 0.15);
13+
background-color: color-mix(in srgb, var(--accent-color) 15%, transparent);
1414
}
1515

1616
/* History list row styling for favorites */
1717
listbox row.favorite-item {
18-
background-color: alpha(@accent_color, 0.08);
18+
background-color: color-mix(in srgb, var(--accent-color) 8%, transparent);
1919
}
2020

2121
listbox row.favorite-item:hover {
22-
background-color: alpha(@accent_color, 0.12);
22+
background-color: color-mix(in srgb, var(--accent-color) 12%, transparent);
2323
}
2424

2525
listbox row.favorite-item:selected {
26-
background-color: alpha(@accent_color, 0.2);
26+
background-color: color-mix(in srgb, var(--accent-color) 20%, transparent);
2727
}
2828

2929
.example-text {
3030
font-style: italic;
31-
color: @accent_color;
31+
color: var(--accent-color);
3232
}
3333

3434
.pos-header {
@@ -52,10 +52,49 @@ listbox row.favorite-item:selected {
5252
padding-right: 6px;
5353
padding-top: 1px;
5454
padding-bottom: 1px;
55-
color: @accent_fg_color;
56-
background-color: @accent_bg_color;
55+
color: var(--accent-fg-color);
56+
background-color: var(--accent-bg-color);
5757
}
5858

5959
.lemma-button:hover {
60-
background-color: alpha(@accent_bg_color, 0.7);
60+
background-color: color-mix(in srgb, var(--accent-bg-color) 70%, transparent);
61+
}
62+
63+
entry.completion-entry {
64+
transition:
65+
border-bottom-left-radius 120ms cubic-bezier(0.2, 0, 0, 1),
66+
border-bottom-right-radius 120ms cubic-bezier(0.2, 0, 0, 1);
67+
}
68+
69+
entry.completion-entry.completion-active {
70+
border-bottom-left-radius: 0;
71+
border-bottom-right-radius: 0;
72+
}
73+
74+
popover.completion-popover.background > contents {
75+
padding: 0;
76+
border-top-width: 0;
77+
border-top-left-radius: 0;
78+
border-top-right-radius: 0;
79+
}
80+
81+
popover.completion-popover scrolledwindow,
82+
popover.completion-popover viewport,
83+
popover.completion-popover list {
84+
background: transparent;
85+
}
86+
87+
popover.completion-popover list row {
88+
min-height: 0;
89+
padding: 0;
90+
border-radius: 0;
91+
}
92+
93+
popover.completion-popover list row:hover {
94+
background-color: color-mix(in srgb, currentColor 6%, transparent);
95+
}
96+
97+
popover.completion-popover list row:selected {
98+
background-color: color-mix(in srgb, currentColor 10%, transparent);
99+
color: inherit;
61100
}

data/resources/ui/window.blp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,18 @@ template $WordbookWindow: Adw.ApplicationWindow {
221221
Adw.ViewStackPage {
222222
name: "content_page";
223223

224-
child: Box {
225-
orientation: vertical;
226-
227-
228-
ListBox definitions_listbox {
229-
margin-start: 12;
230-
margin-end: 12;
231-
margin-bottom: 12;
232-
margin-top: 8;
233-
selection-mode: none;
234-
show-separators: false;
235-
vexpand: true;
224+
child: ListBox definitions_listbox {
225+
margin-start: 12;
226+
margin-end: 12;
227+
margin-bottom: 12;
228+
margin-top: 8;
229+
selection-mode: none;
230+
show-separators: false;
231+
vexpand: true;
236232

237-
styles [
238-
"boxed-list-separate",
239-
]
240-
}
233+
styles [
234+
"boxed-list-separate",
235+
]
241236
};
242237
}
243238

meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ else
2121
endif
2222

2323
dependency('gobject-introspection-1.0', version: '>= 1.35.0')
24-
dependency('gtk4', version: '>= 4.6')
25-
dependency('libadwaita-1', version: '>=1.0')
24+
dependency('gtk4', version: '>= 4.16')
25+
dependency('libadwaita-1', version: '>= 1.7')
2626
dependency('glib-2.0')
2727
dependency('pygobject-3.0', version: '>= 3.29.1')
2828

wordbook/base.py

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,57 @@ def ipa_to_espeak(ipa_string: str) -> str:
102102
s = ipa_string.strip().strip("/[]")
103103

104104
mapping = {
105-
"ˈ": "'", "ˌ": ",", "ː": ":", ".": "", "‿": "", "|": "", "‖": "",
106-
"tʃ": "tS", "dʒ": "dZ",
107-
"eɪ": "eI", "aɪ": "aI", "ɔɪ": "OI", "aʊ": "aU", "oʊ": "oU", "əʊ": "@U",
108-
"ɪə": "I@", "eə": "e@", "ɛə": "e@", "ʊə": "U@",
109-
"iː": "i:", "ɑː": "A:", "ɔː": "O:", "uː": "u:", "ɜː": "3:",
110-
"ɚ": "@r", "ɝ": "3r",
111-
"ɪ": "I", "ɛ": "E", "e": "e", "æ": "a", "ɑ": "A", "ɒ": "0", "ɔ": "O",
112-
"ʊ": "U", "ʌ": "V", "ɜ": "3", "ə": "@", "ɐ": "@", "a": "a",
113-
"θ": "T", "ð": "D", "ʃ": "S", "ʒ": "Z", "ŋ": "N", "ɹ": "r", "ɾ": "4",
114-
"ɫ": "l", "ʔ": "?", "ʍ": "W", "x": "x", "ç": "C",
105+
"ˈ": "'",
106+
"ˌ": ",",
107+
"ː": ":",
108+
".": "",
109+
"‿": "",
110+
"|": "",
111+
"‖": "",
112+
"tʃ": "tS",
113+
"dʒ": "dZ",
114+
"eɪ": "eI",
115+
"aɪ": "aI",
116+
"ɔɪ": "OI",
117+
"aʊ": "aU",
118+
"oʊ": "oU",
119+
"əʊ": "@U",
120+
"ɪə": "I@",
121+
"eə": "e@",
122+
"ɛə": "e@",
123+
"ʊə": "U@",
124+
"iː": "i:",
125+
"ɑː": "A:",
126+
"ɔː": "O:",
127+
"uː": "u:",
128+
"ɜː": "3:",
129+
"ɚ": "@r",
130+
"ɝ": "3r",
131+
"ɪ": "I",
132+
"ɛ": "E",
133+
"e": "e",
134+
"æ": "a",
135+
"ɑ": "A",
136+
"ɒ": "0",
137+
"ɔ": "O",
138+
"ʊ": "U",
139+
"ʌ": "V",
140+
"ɜ": "3",
141+
"ə": "@",
142+
"ɐ": "@",
143+
"a": "a",
144+
"θ": "T",
145+
"ð": "D",
146+
"ʃ": "S",
147+
"ʒ": "Z",
148+
"ŋ": "N",
149+
"ɹ": "r",
150+
"ɾ": "4",
151+
"ɫ": "l",
152+
"ʔ": "?",
153+
"ʍ": "W",
154+
"x": "x",
155+
"ç": "C",
115156
}
116157

117158
for ipa_sym, esp_sym in sorted(mapping.items(), key=lambda x: len(x[0]), reverse=True):

wordbook/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ wordbook_sources = [
4646
'base.py',
4747
'database.py',
4848
'main.py',
49+
'search_completion.py',
4950
'settings.py',
5051
'settings_window.py',
5152
'utils.py',

0 commit comments

Comments
 (0)