Skip to content

Commit cb7acff

Browse files
authored
Merge pull request #236 from akaza-im/delete-dict
辞書削除機能
2 parents 77b6434 + 50b2085 commit cb7acff

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

akaza-conf/src/conf.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ fn build_core_pane(config: Arc<Mutex<Config>>) -> Result<Grid> {
245245
}
246246

247247
fn build_dict_pane(config: Arc<Mutex<Config>>) -> Result<ScrolledWindow> {
248+
// TODO ここは TreeView 使った方がすっきり書けるはずだが、僕の GTK+ 力が引くすぎて対応できていない。
249+
// 誰かすっきり使い易くしてほしい。
248250
fn add_row(grid: &Grid, dict_config: &DictConfig, config: &Arc<Mutex<Config>>, i: usize) {
249251
grid.attach(
250252
&Label::builder()
@@ -324,6 +326,27 @@ fn build_dict_pane(config: Arc<Mutex<Config>>) -> Result<ScrolledWindow> {
324326
}
325327
grid.attach(&cbt, 3, i as i32, 1, 1);
326328
}
329+
330+
{
331+
let delete_btn = {
332+
let path = dict_config.path.clone();
333+
let config = config.clone();
334+
let delete_btn = Button::with_label("削除");
335+
let grid = grid.clone();
336+
delete_btn.connect_clicked(move |_| {
337+
let mut config = config.lock().unwrap();
338+
for (i, dict) in &mut config.engine.dicts.iter().enumerate() {
339+
if dict.path == path {
340+
config.engine.dicts.remove(i);
341+
grid.remove_row(i as i32);
342+
break;
343+
}
344+
}
345+
});
346+
delete_btn
347+
};
348+
grid.attach(&delete_btn, 4, i as i32, 1, 1);
349+
}
327350
}
328351

329352
let scroll = ScrolledWindow::new();

0 commit comments

Comments
 (0)