Skip to content

Commit

Permalink
properly reset copy icon
Browse files Browse the repository at this point in the history
  • Loading branch information
feschber committed Apr 12, 2024
1 parent 5b76c3b commit e537cdb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/frontend/gtk/window/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ impl Window {
#[template_callback]
fn handle_copy_hostname(&self, button: &Button) {
if let Ok(hostname) = hostname::get() {
let prev_icon = button.icon_name().unwrap();
let display = gdk::Display::default().unwrap();
let clipboard = display.clipboard();
clipboard.set_text(hostname.to_str().expect("hostname: invalid utf8"));
button.set_icon_name("emblem-ok-symbolic");
button.set_css_classes(&["success"]);
glib::spawn_future_local(clone!(@weak button => async move {
glib::timeout_future_seconds(1).await;
button.set_icon_name(&prev_icon);
button.set_icon_name("edit-copy-symbolic");
button.set_css_classes(&[]);
}));
}
Expand Down

0 comments on commit e537cdb

Please sign in to comment.