From c5d45b748d90c79f881c4e054b425d68801dad14 Mon Sep 17 00:00:00 2001 From: Rubén Beltrán del Río Date: Thu, 26 Mar 2026 18:13:49 +0100 Subject: Spin header into its own component --- src/actions.rs | 3 +- src/components/header.rs | 234 +++++++++++++++++++++++++++ src/components/mod.rs | 16 ++ src/handlers/mod.rs | 1 + src/handlers/preferences.rs | 70 ++++++++ src/handlers/view.rs | 21 ++- src/main.rs | 377 ++++++++++---------------------------------- 7 files changed, 417 insertions(+), 305 deletions(-) create mode 100644 src/components/header.rs create mode 100644 src/components/mod.rs create mode 100644 src/handlers/preferences.rs (limited to 'src') diff --git a/src/actions.rs b/src/actions.rs index 1d60820..33289b1 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -15,6 +15,7 @@ // along with this program. If not, see . use std::path::PathBuf; +use wmap_renderer::StageType; use crate::preferences::UserPreferences; @@ -43,7 +44,7 @@ impl ImageFormat { #[derive(Debug, Clone)] pub enum Action { ChangeOrientation, - StageTypeSelected(usize), + StageTypeSelected(StageType), SourceChanged, Zoom(f64), ZoomOut, diff --git a/src/components/header.rs b/src/components/header.rs new file mode 100644 index 0000000..7a39490 --- /dev/null +++ b/src/components/header.rs @@ -0,0 +1,234 @@ +use gtk::{gio, prelude::*}; +use relm4::prelude::*; +use relm4::actions::{ActionablePlus, RelmAction}; + +use wmap_renderer::StageType; + +use crate::tr; +use crate::preferences::models::{CustomStage, Template}; +use crate::stages::{ALL_STAGE_TYPES, LocalizedStageType}; + +use crate::{ + ChangeOrientationAction, ExportImageAction, actions::Action +}; +use crate::icon_names::shipped::{ + IMAGE_REGULAR, MENU_LARGE, SPLIT_HORIZONTAL_REGULAR, SPLIT_VERTICAL_REGULAR +}; + +// Model and Input Messages + +pub struct Header { + stage_type_list: gtk::StringList, + available_stage_types: Vec, + orientation: gtk::Orientation, + horizontal_layout_enabled: bool, + templates_menu: gio::Menu, + main_menu: gio::Menu, + layout_action: RelmAction +} + +pub struct HeaderInit { + pub layout_action: RelmAction, + pub custom_stages: Vec, + pub templates: Vec