Skip to content

Commit

Permalink
Improve tooltips on sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Feb 10, 2024
1 parent 1098e25 commit 52c0c9c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/frontend/running/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ impl FactoryComponent for FarmWidget {
if sector_index < init.plotted_total_sectors {
sector.add_css_class("plotted")
}
Self::update_sector_tooltip(&sector, sector_index);
sectors.push(sector);
}

Expand Down Expand Up @@ -429,12 +430,40 @@ impl FarmWidget {
sector.add_css_class(sector_state.css_class());
}
}

Self::update_sector_tooltip(sector, sector_index);
}
}

fn remove_sector_state(&self, sector_index: SectorIndex, sector_state: SectorState) {
if let Some(sector) = self.sectors.get(&sector_index) {
sector.remove_css_class(sector_state.css_class());

Self::update_sector_tooltip(sector, sector_index);
}
}

fn update_sector_tooltip(sector: &gtk::Box, sector_index: SectorIndex) {
if sector.has_css_class(SectorState::Downloading.css_class()) {
sector.set_tooltip_text(Some(&format!("Sector {sector_index}: downloading")));
} else if sector.has_css_class(SectorState::Encoding.css_class()) {
sector.set_tooltip_text(Some(&format!("Sector {sector_index}: encoding")));
} else if sector.has_css_class(SectorState::Writing.css_class()) {
sector.set_tooltip_text(Some(&format!("Sector {sector_index}: writing")));
} else if sector.has_css_class(SectorState::Expired.css_class()) {
sector.set_tooltip_text(Some(&format!(
"Sector {sector_index}: expired, waiting to be replotted"
)));
} else if sector.has_css_class(SectorState::AboutToExpire.css_class()) {
sector.set_tooltip_text(Some(&format!(
"Sector {sector_index}: about to expire, waiting to be replotted"
)));
} else if sector.has_css_class(SectorState::Plotted.css_class()) {
sector.set_tooltip_text(Some(&format!("Sector {sector_index}: up to date")));
} else {
sector.set_tooltip_text(Some(&format!(
"Sector {sector_index}: waiting to be plotted"
)));
}
}
}

0 comments on commit 52c0c9c

Please sign in to comment.