Skip to content

Commit

Permalink
improv: delete repo and repo selection
Browse files Browse the repository at this point in the history
- deleting a repo with a key is now possible.
- first repo is selected on app start.
  • Loading branch information
edfloreshz committed Sep 4, 2024
1 parent 1eb9be4 commit bf43779
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ impl Application for App {
}

fn init(core: Core, flags: Self::Flags) -> (Self, Command<Self::Message>) {
let mut commands = vec![];
let nav_model = segmented_button::ModelBuilder::default().build();
let mut app = App {
core,
Expand All @@ -247,7 +248,17 @@ impl Application for App {
app.create_nav_item(repository, "harddisk-symbolic");
}

(app, Command::none())
if let Some(entity) = app.nav_model.entity_at(0) {
app.nav_model.activate(entity)
}

if let Some(repository) = app.nav_model.active_data::<Repository>() {
commands.push(app.update(Message::Content(content::Message::SetRepository(
repository.clone(),
))));
}

(app, Command::batch(commands))
}

fn context_drawer(&self) -> Option<Element<Message>> {
Expand Down
2 changes: 2 additions & 0 deletions src/app/key_bind.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::HashMap;

use cosmic::iced::keyboard::key::Named;
use cosmic::iced::keyboard::Key;
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::menu::key_bind::Modifier;
Expand All @@ -22,6 +23,7 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
}
bind!([Ctrl], Key::Character("r".into()), CreateRepository);
bind!([Ctrl, Shift], Key::Character("r".into()), CreateSnapshot);
bind!([], Key::Named(Named::Delete), DeleteRepository);
bind!([Ctrl], Key::Character("w".into()), WindowClose);
bind!([Ctrl, Shift], Key::Character("n".into()), WindowNew);
bind!([Ctrl], Key::Character(",".into()), Settings);
Expand Down

0 comments on commit bf43779

Please sign in to comment.