Skip to content

Commit f56bffb

Browse files
committed
make unseen hosts and services dimmed in thumbnail mode (fixes #1142)
1 parent 6ba3250 commit f56bffb

6 files changed

Lines changed: 75 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All Sniffnet releases with the relative changes are documented in this file.
99
- French ([#1123](https://github.com/GyulyVGC/sniffnet/pull/1123))
1010
- Spanish ([#1140](https://github.com/GyulyVGC/sniffnet/pull/1140))
1111
- Indonesian ([#1145](https://github.com/GyulyVGC/sniffnet/pull/1145))
12+
- Fix unseen hosts and services not appearing dimmed in thumbnail mode (fixes [#1142](https://github.com/GyulyVGC/sniffnet/issues/1142))
1213

1314
## [1.5.0] - 2026-04-14
1415
- Show which apps and programs are generating network traffic ([#1056](https://github.com/GyulyVGC/sniffnet/pull/1056) — fixes [#170](https://github.com/GyulyVGC/sniffnet/issues/170))

src/gui/components/ellipsized_text.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ where
1616
class: Theme::Class<'a>,
1717
}
1818

19-
impl<Theme, Renderer> EllipsizedText<'_, Theme, Renderer>
19+
impl<'a, Theme, Renderer> EllipsizedText<'a, Theme, Renderer>
2020
where
2121
Theme: widget::text::Catalog,
2222
Renderer: text::Renderer,
@@ -79,6 +79,11 @@ where
7979
self.format.wrapping = wrapping;
8080
self
8181
}
82+
83+
pub fn class(mut self, class: impl Into<Theme::Class<'a>>) -> Self {
84+
self.class = class.into();
85+
self
86+
}
8287
}
8388

8489
struct State<P: text::Paragraph> {

src/gui/pages/overview_page.rs

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -223,35 +223,39 @@ pub fn item_bar<'a>(
223223
data_info: &DataInfo,
224224
data_repr: DataRepr,
225225
first_entry_data_info: DataInfo,
226-
) -> Container<'a, Message, StyleType> {
227-
Container::new(
228-
Row::new()
229-
.height(ICONS_SIZE_BIG)
230-
.align_y(Alignment::Center)
231-
.spacing(5)
232-
.push(icon)
233-
.push(
234-
Column::new()
235-
.spacing(2)
236-
.push(
237-
Row::new()
238-
.push(
239-
EllipsizedText::new(item)
240-
.wrapping(Wrapping::Glyph)
241-
.width(Length::Fill),
242-
)
243-
.push(Text::new(
244-
data_repr.formatted_string(data_info.tot_data(data_repr)),
245-
)),
246-
)
247-
.push(get_bars(data_repr, &first_entry_data_info, data_info)),
248-
),
249-
)
250-
.class(if data_info.tot_data(DataRepr::Packets) == 0 {
251-
ContainerType::DimmedText
252-
} else {
253-
ContainerType::Standard
254-
})
226+
) -> Row<'a, Message, StyleType> {
227+
let is_dimmed = data_info.tot_data(DataRepr::Packets) == 0;
228+
Row::new()
229+
.height(ICONS_SIZE_BIG)
230+
.align_y(Alignment::Center)
231+
.spacing(5)
232+
.push(icon)
233+
.push(
234+
Column::new()
235+
.spacing(2)
236+
.push(
237+
Row::new()
238+
.push(
239+
EllipsizedText::new(item)
240+
.wrapping(Wrapping::Glyph)
241+
.width(Length::Fill)
242+
.class(if is_dimmed {
243+
TextType::Dimmed
244+
} else {
245+
TextType::Standard
246+
}),
247+
)
248+
.push(
249+
Text::new(data_repr.formatted_string(data_info.tot_data(data_repr)))
250+
.class(if is_dimmed {
251+
TextType::Dimmed
252+
} else {
253+
TextType::Standard
254+
}),
255+
),
256+
)
257+
.push(get_bars(data_repr, &first_entry_data_info, data_info)),
258+
)
255259
}
256260

257261
fn col_info(sniffer: &Sniffer) -> Container<'_, Message, StyleType> {

src/gui/pages/thumbnail_page.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::countries::country_utils::get_flag_tooltip;
88
use crate::gui::sniffer::Sniffer;
99
use crate::gui::styles::rule::RuleType;
1010
use crate::gui::styles::style_constants::FONT_SIZE_FOOTER;
11+
use crate::gui::styles::text::TextType;
1112
use crate::gui::styles::types::style_type::StyleType;
1213
use crate::gui::types::favorite::{Favorite, FavoriteItem};
1314
use crate::gui::types::message::Message;
@@ -96,12 +97,28 @@ fn host_col<'a>(sniffer: &Sniffer) -> Column<'a, Message, StyleType> {
9697

9798
thumbnail_hosts.push(thumbnail_host);
9899

99-
let flag = get_flag_tooltip(country, data_info_host, Language::default(), true, 1.0);
100+
let is_dimmed = data_info_host.data_info.tot_data(DataRepr::Packets) == 0;
101+
let opacity = if is_dimmed {
102+
sniffer
103+
.conf
104+
.settings
105+
.style
106+
.get_extension()
107+
.alpha_chart_badge
108+
} else {
109+
1.0
110+
};
111+
112+
let flag = get_flag_tooltip(country, data_info_host, Language::default(), true, opacity);
100113
let host_row = Row::new()
101114
.align_y(Alignment::Center)
102115
.spacing(5)
103116
.push(flag)
104-
.push(Text::new(text).size(FONT_SIZE_FOOTER));
117+
.push(Text::new(text).size(FONT_SIZE_FOOTER).class(if is_dimmed {
118+
TextType::Dimmed
119+
} else {
120+
TextType::Standard
121+
}));
105122
host_col = host_col.push(host_row);
106123

107124
if thumbnail_hosts.len() >= MAX_ENTRIES {
@@ -117,12 +134,20 @@ fn service_col<'a>(sniffer: &Sniffer) -> Column<'a, Message, StyleType> {
117134
let services = Favorite::Service.get_entries(sniffer);
118135
let n_entry = min(services.len(), MAX_ENTRIES);
119136
for fi in services.get(..n_entry).unwrap_or_default() {
120-
let FavoriteItem::Service((service, _)) = fi else {
137+
let FavoriteItem::Service((service, data_info)) = fi else {
121138
continue;
122139
};
123140

141+
let is_dimmed = data_info.tot_data(DataRepr::Packets) == 0;
142+
124143
service_col = service_col.push(
125-
Text::new(clip_text(&service.to_string(), MAX_CHARS_SERVICE)).size(FONT_SIZE_FOOTER),
144+
Text::new(clip_text(&service.to_string(), MAX_CHARS_SERVICE))
145+
.size(FONT_SIZE_FOOTER)
146+
.class(if is_dimmed {
147+
TextType::Dimmed
148+
} else {
149+
TextType::Standard
150+
}),
126151
);
127152
}
128153
service_col

src/gui/styles/container.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub enum ContainerType {
2525
HighlightedOnHeader,
2626
ModalBackground,
2727
AdapterAddress,
28-
DimmedText,
2928
}
3029

3130
impl ContainerType {
@@ -35,10 +34,6 @@ impl ContainerType {
3534
Style {
3635
text_color: Some(match self {
3736
ContainerType::Gradient(_) | ContainerType::Highlighted => colors.text_headers,
38-
ContainerType::DimmedText => Color {
39-
a: ext.alpha_chart_badge,
40-
..colors.text_body
41-
},
4237
_ => colors.text_body,
4338
}),
4439
background: Some(match self {
@@ -60,7 +55,7 @@ impl ContainerType {
6055
ContainerType::Modal | ContainerType::HighlightedOnHeader => {
6156
Background::Color(colors.primary)
6257
}
63-
ContainerType::Standard | ContainerType::Palette | ContainerType::DimmedText => {
58+
ContainerType::Standard | ContainerType::Palette => {
6459
Background::Color(Color::TRANSPARENT)
6560
}
6661
ContainerType::ModalBackground => Background::Color(Color {
@@ -86,7 +81,6 @@ impl ContainerType {
8681
},
8782
width: match self {
8883
ContainerType::Standard
89-
| ContainerType::DimmedText
9084
| ContainerType::ModalBackground
9185
| ContainerType::Gradient(_)
9286
| ContainerType::HighlightedOnHeader

src/gui/styles/text.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum TextType {
1919
Danger,
2020
Sponsor,
2121
Welcome(f32),
22+
Dimmed,
2223
}
2324

2425
/// Returns a formatted caption followed by subtitle, new line, tab, and desc
@@ -77,6 +78,10 @@ pub fn highlight(style: &StyleType, element: TextType) -> Color {
7778
TextType::Outgoing => colors.outgoing,
7879
TextType::Danger | TextType::Sponsor => ext.red_alert_color,
7980
TextType::Standard => colors.text_body,
81+
TextType::Dimmed => Color {
82+
a: ext.alpha_chart_badge,
83+
..colors.text_body
84+
},
8085
}
8186
}
8287

0 commit comments

Comments
 (0)