Skip to content

Commit

Permalink
fixing lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Sep 20, 2024
1 parent b41d39e commit 1b29f86
Show file tree
Hide file tree
Showing 29 changed files with 203 additions and 224 deletions.
2 changes: 1 addition & 1 deletion src/chart/types/traffic_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl TrafficChart {
min - gap..max + gap
}

fn font(&self, size: f64) -> TextStyle<'static> {
fn font<'a>(&self, size: f64) -> TextStyle<'a> {
(FONT_FAMILY_NAME, size)
.into_font()
.style(self.style.get_font_weight())
Expand Down
12 changes: 6 additions & 6 deletions src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ use crate::translations::translations_2::{
};
use crate::{Language, StyleType};

fn get_flag_from_country(
fn get_flag_from_country<'a>(
country: Country,
width: f32,
is_local: bool,
is_loopback: bool,
traffic_type: TrafficType,
language: Language,
) -> (Svg<'static, StyleType>, String) {
) -> (Svg<'a, StyleType>, String) {
#![allow(clippy::too_many_lines)]
let mut tooltip = country.to_string();
let mut svg_style = SvgType::Standard;
Expand Down Expand Up @@ -310,13 +310,13 @@ fn get_flag_from_country(
(svg, tooltip)
}

pub fn get_flag_tooltip(
pub fn get_flag_tooltip<'a>(
country: Country,
host_info: &DataInfoHost,
language: Language,
font: Font,
thumbnail: bool,
) -> Tooltip<'static, Message, StyleType> {
) -> Tooltip<'a, Message, StyleType> {
let width = if thumbnail {
FLAGS_WIDTH_SMALL
} else {
Expand Down Expand Up @@ -355,13 +355,13 @@ pub fn get_flag_tooltip(
tooltip
}

pub fn get_computer_tooltip(
pub fn get_computer_tooltip<'a>(
is_my_address: bool,
is_local: bool,
traffic_type: TrafficType,
language: Language,
font: Font,
) -> Tooltip<'static, Message, StyleType> {
) -> Tooltip<'a, Message, StyleType> {
let content = Svg::new(Handle::from_memory(Vec::from(
match (is_my_address, is_local, traffic_type) {
(true, _, _) => COMPUTER,
Expand Down
10 changes: 5 additions & 5 deletions src/gui/components/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use crate::utils::types::file_info::FileInfo;
use crate::utils::types::icon::Icon;
use crate::{Language, StyleType};

pub fn button_hide(
pub fn button_hide<'a>(
message: Message,
language: Language,
font: Font,
) -> Tooltip<'static, Message, StyleType> {
) -> Tooltip<'a, Message, StyleType> {
Tooltip::new(
button(
Text::new("×")
Expand All @@ -38,14 +38,14 @@ pub fn button_hide(
.class(ContainerType::Tooltip)
}

pub fn button_open_file(
pub fn button_open_file<'a>(
old_file: String,
file_info: FileInfo,
language: Language,
font: Font,
is_editable: bool,
action: fn(String) -> Message,
) -> Tooltip<'static, Message, StyleType> {
) -> Tooltip<'a, Message, StyleType> {
let mut tooltip_str = "";
let mut tooltip_style = ContainerType::Standard;

Expand All @@ -71,7 +71,7 @@ pub fn button_open_file(
.class(tooltip_style)
}

pub fn row_open_link_tooltip(text: &'static str, font: Font) -> Row<'static, Message, StyleType> {
pub fn row_open_link_tooltip(text: &'static str, font: Font) -> Row<Message, StyleType> {
Row::new()
.align_y(Alignment::Center)
.spacing(10)
Expand Down
20 changes: 10 additions & 10 deletions src/gui/components/footer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ use crate::utils::types::icon::Icon;
use crate::utils::types::web_page::WebPage;
use crate::{Language, SNIFFNET_TITLECASE};

pub fn footer(
pub fn footer<'a>(
thumbnail: bool,
language: Language,
color_gradient: GradientType,
font: Font,
font_footer: Font,
newer_release_available: &Arc<Mutex<Option<bool>>>,
) -> Container<'static, Message, StyleType> {
newer_release_available: Arc<Mutex<Option<bool>>>,
) -> Container<'a, Message, StyleType> {
if thumbnail {
return thumbnail_footer();
}
Expand Down Expand Up @@ -59,7 +59,7 @@ pub fn footer(
.class(ContainerType::Gradient(color_gradient))
}

fn get_button_website(font: Font) -> Tooltip<'static, Message, StyleType> {
fn get_button_website<'a>(font: Font) -> Tooltip<'a, Message, StyleType> {
let content = button(
Icon::Globe
.to_text()
Expand All @@ -80,7 +80,7 @@ fn get_button_website(font: Font) -> Tooltip<'static, Message, StyleType> {
.class(ContainerType::Tooltip)
}

fn get_button_github(font: Font) -> Tooltip<'static, Message, StyleType> {
fn get_button_github<'a>(font: Font) -> Tooltip<'a, Message, StyleType> {
let content = button(
Icon::GitHub
.to_text()
Expand All @@ -101,7 +101,7 @@ fn get_button_github(font: Font) -> Tooltip<'static, Message, StyleType> {
.class(ContainerType::Tooltip)
}

fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, StyleType> {
fn get_button_sponsor<'a>(font: Font) -> Tooltip<'a, Message, StyleType> {
let content = button(
Text::new('❤'.to_string())
.font(font)
Expand All @@ -124,12 +124,12 @@ fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, StyleType> {
.class(ContainerType::Tooltip)
}

fn get_release_details(
fn get_release_details<'a>(
language: Language,
font: Font,
font_footer: Font,
newer_release_available: &Arc<Mutex<Option<bool>>>,
) -> Row<'static, Message, StyleType> {
newer_release_available: Arc<Mutex<Option<bool>>>,
) -> Row<'a, Message, StyleType> {
let mut ret_val = Row::new()
.align_y(Alignment::Center)
.height(Length::Fill)
Expand Down Expand Up @@ -170,6 +170,6 @@ fn get_release_details(
ret_val
}

fn thumbnail_footer() -> Container<'static, Message, StyleType> {
fn thumbnail_footer<'a>() -> Container<'a, Message, StyleType> {
Container::new(horizontal_space()).height(0)
}
16 changes: 8 additions & 8 deletions src/gui/components/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::translations::translations_3::thumbnail_mode_translation;
use crate::utils::types::icon::Icon;
use crate::{Language, StyleType, SNIFFNET_TITLECASE};

pub fn header(sniffer: &Sniffer) -> Container<'static, Message, StyleType> {
pub fn header<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> {
let thumbnail = sniffer.thumbnail;
let ConfigSettings {
style,
Expand Down Expand Up @@ -78,7 +78,7 @@ pub fn header(sniffer: &Sniffer) -> Container<'static, Message, StyleType> {
.class(ContainerType::Gradient(color_gradient))
}

fn get_button_reset(font: Font, language: Language) -> Tooltip<'static, Message, StyleType> {
fn get_button_reset<'a>(font: Font, language: Language) -> Tooltip<'a, Message, StyleType> {
let content = button(
Icon::ArrowBack
.to_text()
Expand All @@ -101,11 +101,11 @@ fn get_button_reset(font: Font, language: Language) -> Tooltip<'static, Message,
.class(ContainerType::Tooltip)
}

pub fn get_button_settings(
pub fn get_button_settings<'a>(
font: Font,
language: Language,
open_overlay: SettingsPage,
) -> Tooltip<'static, Message, StyleType> {
) -> Tooltip<'a, Message, StyleType> {
let content = button(
Icon::Settings
.to_text()
Expand All @@ -127,11 +127,11 @@ pub fn get_button_settings(
.class(ContainerType::Tooltip)
}

pub fn get_button_minimize(
pub fn get_button_minimize<'a>(
font: Font,
language: Language,
thumbnail: bool,
) -> Tooltip<'static, Message, StyleType> {
) -> Tooltip<'a, Message, StyleType> {
let size = if thumbnail { 20 } else { 24 };
let button_size = if thumbnail { 30 } else { 40 };
let icon = if thumbnail {
Expand Down Expand Up @@ -167,13 +167,13 @@ pub fn get_button_minimize(
.class(tooltip_style)
}

fn thumbnail_header(
fn thumbnail_header<'a>(
font: Font,
font_headers: Font,
language: Language,
color_gradient: GradientType,
unread_notifications: usize,
) -> Container<'static, Message, StyleType> {
) -> Container<'a, Message, StyleType> {
Container::new(
Row::new()
.align_y(Alignment::Center)
Expand Down
14 changes: 7 additions & 7 deletions src/gui/components/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ use crate::translations::translations::{
};
use crate::{Language, StyleType};

pub fn get_exit_overlay(
pub fn get_exit_overlay<'a>(
color_gradient: GradientType,
font: Font,
font_headers: Font,
language: Language,
) -> Container<'static, Message, StyleType> {
) -> Container<'a, Message, StyleType> {
let row_buttons = confirm_button_row(language, font, Message::Reset);

let content = Column::new()
Expand All @@ -49,12 +49,12 @@ pub fn get_exit_overlay(
.class(ContainerType::Modal)
}

pub fn get_clear_all_overlay(
pub fn get_clear_all_overlay<'a>(
color_gradient: GradientType,
font: Font,
font_headers: Font,
language: Language,
) -> Container<'static, Message, StyleType> {
) -> Container<'a, Message, StyleType> {
let row_buttons = confirm_button_row(language, font, Message::ClearAllNotifications);

let content = Column::new()
Expand Down Expand Up @@ -87,7 +87,7 @@ fn get_modal_header(
color_gradient: GradientType,
language: Language,
title: &'static str,
) -> Container<'static, Message, StyleType> {
) -> Container<Message, StyleType> {
Container::new(
Row::new()
.push(horizontal_space())
Expand All @@ -111,11 +111,11 @@ fn get_modal_header(
.class(ContainerType::Gradient(color_gradient))
}

fn confirm_button_row(
fn confirm_button_row<'a>(
language: Language,
font: Font,
message: Message,
) -> Row<'static, Message, StyleType> {
) -> Row<'a, Message, StyleType> {
Row::new()
.height(Length::Fill)
.align_y(Alignment::Center)
Expand Down
20 changes: 10 additions & 10 deletions src/gui/components/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use crate::gui::styles::text::TextType;
use crate::gui::types::message::Message;
use crate::{Language, RunningPage, StyleType};

pub fn get_settings_tabs(
pub fn get_settings_tabs<'a>(
active: SettingsPage,
font: Font,
language: Language,
) -> Row<'static, Message, StyleType> {
) -> Row<'a, Message, StyleType> {
let mut tabs = Row::new()
.width(Length::Fill)
.align_y(Alignment::Start)
Expand All @@ -30,13 +30,13 @@ pub fn get_settings_tabs(
tabs
}

pub fn get_pages_tabs(
pub fn get_pages_tabs<'a>(
active: RunningPage,
font: Font,
font_headers: Font,
language: Language,
unread_notifications: usize,
) -> Row<'static, Message, StyleType> {
) -> Row<'a, Message, StyleType> {
let mut tabs = Row::new()
.width(Length::Fill)
.align_y(Alignment::Start)
Expand All @@ -62,14 +62,14 @@ pub fn get_pages_tabs(
tabs
}

fn new_page_tab(
fn new_page_tab<'a>(
page: RunningPage,
active: bool,
language: Language,
font: Font,
font_headers: Font,
unread: Option<usize>,
) -> Button<'static, Message, StyleType> {
) -> Button<'a, Message, StyleType> {
let mut content = Row::new()
.height(Length::Fill)
.align_y(Alignment::Center)
Expand Down Expand Up @@ -121,12 +121,12 @@ fn new_page_tab(
.on_press(page.action())
}

fn new_settings_tab(
fn new_settings_tab<'a>(
page: SettingsPage,
active: bool,
language: Language,
font: Font,
) -> Button<'static, Message, StyleType> {
) -> Button<'a, Message, StyleType> {
let content = Row::new()
.height(Length::Fill)
.align_y(Alignment::Center)
Expand Down Expand Up @@ -169,10 +169,10 @@ fn new_settings_tab(
.on_press(page.action())
}

pub fn notifications_badge(
pub fn notifications_badge<'a>(
font_headers: Font,
num: usize,
) -> Container<'static, Message, StyleType> {
) -> Container<'a, Message, StyleType> {
Container::new(
Text::new(num.to_string())
.font(font_headers)
Expand Down
Loading

0 comments on commit 1b29f86

Please sign in to comment.