Skip to content

Commit

Permalink
Calculate editor window title from glyph name
Browse files Browse the repository at this point in the history
This will now update when the glyph name changes.

This depends on linebender/druid#869
  • Loading branch information
cmyr committed Apr 23, 2020
1 parent 088fe68 commit a378dfa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
norad = { git = "https://github.com/linebender/norad.git", rev = "4a133aef", features = ["druid"] }
druid = { git = "https://github.com/xi-editor/druid.git", rev = "1384e6cd", version = "0.6" }
druid = { git = "https://github.com/xi-editor/druid.git", rev = "7445345", version = "0.6" }
log = "0.4.8"
plist = "0.5"
serde = "1.0"
Expand Down
13 changes: 10 additions & 3 deletions src/app_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::sync::Arc;

use druid::{
AppDelegate, Command, DelegateCtx, Env, FileInfo, LocalizedString, Selector, Target, Widget,
WindowDesc, WindowId,
AppDelegate, Command, DelegateCtx, Env, FileInfo, Selector, Target, Widget, WindowDesc,
WindowId,
};

use druid::kurbo::Size;
Expand Down Expand Up @@ -76,8 +76,15 @@ impl AppDelegate<AppState> for Delegate {
}
None => {
let session = data.workspace.get_or_create_session(&payload);
let session_id = session.id;
let new_win = WindowDesc::new(move || make_editor(&session))
.title(LocalizedString::new("").with_placeholder(payload.to_string()))
.title(move |d: &AppState, _: &_| {
d.workspace
.sessions
.get(&session_id)
.map(|s| s.name.to_string())
.unwrap_or_else(|| "Unknown".to_string())
})
.window_size(Size::new(900.0, 800.0))
.menu(crate::menus::make_menu(&data));

Expand Down
1 change: 1 addition & 0 deletions src/widgets/maybe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct Maybe<T> {
widget: MaybeWidget<T>,
}

#[allow(clippy::large_enum_variant)]
enum MaybeWidget<T> {
Some(WidgetPod<T, Box<dyn Widget<T>>>),
None(WidgetPod<(), Box<dyn Widget<()>>>),
Expand Down

0 comments on commit a378dfa

Please sign in to comment.