chore: change workspace orientation to radio buttons
This commit is contained in:
parent
8e1bcafa9f
commit
9f8505b5a7
1 changed files with 21 additions and 21 deletions
|
|
@ -18,7 +18,7 @@ use tracing::error;
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
SetWorkspaceMode(WorkspaceMode),
|
SetWorkspaceMode(WorkspaceMode),
|
||||||
OrientationButtonSelected(cosmic::widget::segmented_button::Entity),
|
SetWorkspaceLayout(WorkspaceLayout),
|
||||||
SetShowName(bool),
|
SetShowName(bool),
|
||||||
SetShowNumber(bool),
|
SetShowNumber(bool),
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,6 @@ pub struct Page {
|
||||||
comp_workspace_config: WorkspaceConfig,
|
comp_workspace_config: WorkspaceConfig,
|
||||||
show_workspace_name: bool,
|
show_workspace_name: bool,
|
||||||
show_workspace_number: bool,
|
show_workspace_number: bool,
|
||||||
orientation_model: cosmic::widget::segmented_button::SingleSelectModel,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Page {
|
impl Default for Page {
|
||||||
|
|
@ -39,11 +38,6 @@ impl Default for Page {
|
||||||
error!(?err, "Failed to read config 'workspaces'");
|
error!(?err, "Failed to read config 'workspaces'");
|
||||||
WorkspaceConfig::default()
|
WorkspaceConfig::default()
|
||||||
});
|
});
|
||||||
let mut orientation_model = cosmic::widget::segmented_button::SingleSelectModel::builder()
|
|
||||||
.insert(|b| b.text(fl!("workspaces-orientation", "vertical")))
|
|
||||||
.insert(|b| b.text(fl!("workspaces-orientation", "horizontal")))
|
|
||||||
.build();
|
|
||||||
orientation_model.activate_position(0);
|
|
||||||
let config = cosmic_config::Config::new("com.system76.CosmicWorkspaces", 1).unwrap();
|
let config = cosmic_config::Config::new("com.system76.CosmicWorkspaces", 1).unwrap();
|
||||||
let show_workspace_name = config.get("show_workspace_name").unwrap_or_else(|err| {
|
let show_workspace_name = config.get("show_workspace_name").unwrap_or_else(|err| {
|
||||||
error!(?err, "Failed to read config 'show_workspace_name'");
|
error!(?err, "Failed to read config 'show_workspace_name'");
|
||||||
|
|
@ -59,7 +53,6 @@ impl Default for Page {
|
||||||
comp_workspace_config,
|
comp_workspace_config,
|
||||||
show_workspace_name,
|
show_workspace_name,
|
||||||
show_workspace_number,
|
show_workspace_number,
|
||||||
orientation_model,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,15 +93,8 @@ impl Page {
|
||||||
self.comp_workspace_config.workspace_mode = value;
|
self.comp_workspace_config.workspace_mode = value;
|
||||||
self.save_comp_config();
|
self.save_comp_config();
|
||||||
}
|
}
|
||||||
Message::OrientationButtonSelected(entity) => {
|
Message::SetWorkspaceLayout(value) => {
|
||||||
self.orientation_model.activate(entity);
|
self.comp_workspace_config.workspace_layout = value;
|
||||||
let horizontal_entity = self.orientation_model.entity_at(1).unwrap();
|
|
||||||
let layout = if self.orientation_model.active() == horizontal_entity {
|
|
||||||
WorkspaceLayout::Horizontal
|
|
||||||
} else {
|
|
||||||
WorkspaceLayout::Vertical
|
|
||||||
};
|
|
||||||
self.comp_workspace_config.workspace_layout = layout;
|
|
||||||
self.save_comp_config();
|
self.save_comp_config();
|
||||||
}
|
}
|
||||||
Message::SetShowName(value) => {
|
Message::SetShowName(value) => {
|
||||||
|
|
@ -159,13 +145,27 @@ fn multi_behavior() -> Section<crate::pages::Message> {
|
||||||
fn workspace_orientation() -> Section<crate::pages::Message> {
|
fn workspace_orientation() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("workspaces-orientation"))
|
.title(fl!("workspaces-orientation"))
|
||||||
.descriptions(vec![])
|
.descriptions(vec![
|
||||||
|
fl!("workspaces-orientation", "vertical").into(),
|
||||||
|
fl!("workspaces-orientation", "horizontal").into(),
|
||||||
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
|
let descriptions = §ion.descriptions;
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.add(
|
.add(settings::item_row(vec![radio(
|
||||||
cosmic::widget::segmented_control::horizontal(&page.orientation_model)
|
&*descriptions[0],
|
||||||
.on_activate(Message::OrientationButtonSelected),
|
WorkspaceLayout::Vertical,
|
||||||
|
Some(page.comp_workspace_config.workspace_layout),
|
||||||
|
Message::SetWorkspaceLayout,
|
||||||
)
|
)
|
||||||
|
.into()]))
|
||||||
|
.add(settings::item_row(vec![radio(
|
||||||
|
&*descriptions[1],
|
||||||
|
WorkspaceLayout::Horizontal,
|
||||||
|
Some(page.comp_workspace_config.workspace_layout),
|
||||||
|
Message::SetWorkspaceLayout,
|
||||||
|
)
|
||||||
|
.into()]))
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::DesktopWorkspaces)
|
.map(crate::pages::Message::DesktopWorkspaces)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue