Startup toggle
This commit is contained in:
parent
a26dd9af9a
commit
356381a83c
@ -2,11 +2,11 @@
|
|||||||
<schemalist>
|
<schemalist>
|
||||||
<schema id="com.github.pikaos-linux.pikawelcome" path="/com/github/pikaos-linux/pikawelcome/">
|
<schema id="com.github.pikaos-linux.pikawelcome" path="/com/github/pikaos-linux/pikawelcome/">
|
||||||
<key name="window-width" type="i">
|
<key name="window-width" type="i">
|
||||||
<default>700</default>
|
<default>1400</default>
|
||||||
<summary>Default window width</summary>
|
<summary>Default window width</summary>
|
||||||
</key>
|
</key>
|
||||||
<key name="window-height" type="i">
|
<key name="window-height" type="i">
|
||||||
<default>500</default>
|
<default>700</default>
|
||||||
<summary>Default window height</summary>
|
<summary>Default window height</summary>
|
||||||
</key>
|
</key>
|
||||||
<key name="is-maximized" type="b">
|
<key name="is-maximized" type="b">
|
||||||
|
@ -11,9 +11,10 @@ use std::rc::Rc;
|
|||||||
mod welcome_page;
|
mod welcome_page;
|
||||||
use welcome_page::welcome_page;
|
use welcome_page::welcome_page;
|
||||||
|
|
||||||
use crate::config::{APP_GITHUB, APP_ICON, VERSION};
|
use crate::config::{APP_GITHUB, APP_ICON, APP_ID, VERSION};
|
||||||
|
|
||||||
pub fn welcome_content_page(window: &adw::ApplicationWindow, content_box: >k::Box) {
|
pub fn welcome_content_page(window: &adw::ApplicationWindow, content_box: >k::Box) {
|
||||||
|
let glib_settings = gio::Settings::new(APP_ID);
|
||||||
let internet_connected = Rc::new(RefCell::new(false));
|
let internet_connected = Rc::new(RefCell::new(false));
|
||||||
|
|
||||||
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
||||||
@ -88,6 +89,12 @@ pub fn welcome_content_page(window: &adw::ApplicationWindow, content_box: >k::
|
|||||||
|
|
||||||
let sidebar_toggle_button = gtk::ToggleButton::builder()
|
let sidebar_toggle_button = gtk::ToggleButton::builder()
|
||||||
.icon_name("view-right-pane-symbolic")
|
.icon_name("view-right-pane-symbolic")
|
||||||
|
.visible(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let startup_switch = gtk::CheckButton::builder()
|
||||||
|
.label(t!("startup_switch_label"))
|
||||||
|
.active(glib_settings.boolean("startup-show"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let _sidebar_toggle_button_binding = welcome_content_page_split_view
|
let _sidebar_toggle_button_binding = welcome_content_page_split_view
|
||||||
@ -98,16 +105,23 @@ pub fn welcome_content_page(window: &adw::ApplicationWindow, content_box: >k::
|
|||||||
|
|
||||||
let welcome_content_page_split_view_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(BreakpointConditionLengthType::MaxWidth, 600.0, LengthUnit::Px));
|
let welcome_content_page_split_view_breakpoint = adw::Breakpoint::new(BreakpointCondition::new_length(BreakpointConditionLengthType::MaxWidth, 600.0, LengthUnit::Px));
|
||||||
welcome_content_page_split_view_breakpoint.add_setter(&welcome_content_page_split_view, "collapsed", &true.to_value());
|
welcome_content_page_split_view_breakpoint.add_setter(&welcome_content_page_split_view, "collapsed", &true.to_value());
|
||||||
|
welcome_content_page_split_view_breakpoint.add_setter(&startup_switch, "visible", &false.to_value());
|
||||||
|
welcome_content_page_split_view_breakpoint.add_setter(&sidebar_toggle_button, "visible", &true.to_value());
|
||||||
|
|
||||||
window.add_breakpoint(welcome_content_page_split_view_breakpoint);
|
window.add_breakpoint(welcome_content_page_split_view_breakpoint);
|
||||||
|
|
||||||
window_title_bar.pack_end(&credits_button);
|
window_title_bar.pack_end(&credits_button);
|
||||||
window_title_bar.pack_start(&sidebar_toggle_button);
|
window_title_bar.pack_start(&sidebar_toggle_button);
|
||||||
|
window_title_bar.pack_start(&startup_switch);
|
||||||
content_box.append(&welcome_content_page_split_view);
|
content_box.append(&welcome_content_page_split_view);
|
||||||
|
|
||||||
credits_button
|
credits_button
|
||||||
.connect_clicked(clone!(@weak credits_button => move |_| credits_window.present()));
|
.connect_clicked(clone!(@weak credits_button => move |_| credits_window.present()));
|
||||||
|
|
||||||
|
startup_switch.connect_toggled(clone!(@weak startup_switch => move |_| {
|
||||||
|
let _ = glib_settings.set_boolean("startup-show", startup_switch.is_active());
|
||||||
|
}));
|
||||||
|
|
||||||
let internet_connected_status = internet_connected.clone();
|
let internet_connected_status = internet_connected.clone();
|
||||||
|
|
||||||
let internet_loop_context = MainContext::default();
|
let internet_loop_context = MainContext::default();
|
||||||
|
@ -12,14 +12,6 @@ pub fn welcome_page(
|
|||||||
welcome_content_page_stack: >k::Stack,
|
welcome_content_page_stack: >k::Stack,
|
||||||
internet_connected: &Rc<RefCell<bool>>
|
internet_connected: &Rc<RefCell<bool>>
|
||||||
) {
|
) {
|
||||||
let welcome_page_box = gtk::Box::builder()
|
|
||||||
// that puts items vertically
|
|
||||||
.orientation(Orientation::Vertical)
|
|
||||||
.valign(gtk::Align::Center)
|
|
||||||
.hexpand(true)
|
|
||||||
.vexpand(true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let welcome_page_text = adw::StatusPage::builder()
|
let welcome_page_text = adw::StatusPage::builder()
|
||||||
.icon_name(DISTRO_ICON)
|
.icon_name(DISTRO_ICON)
|
||||||
.title(t!("welcome_page_text_title"))
|
.title(t!("welcome_page_text_title"))
|
||||||
@ -27,7 +19,15 @@ pub fn welcome_page(
|
|||||||
.build();
|
.build();
|
||||||
welcome_page_text.add_css_class("compact");
|
welcome_page_text.add_css_class("compact");
|
||||||
|
|
||||||
welcome_page_box.append(&welcome_page_text);
|
let welcome_page_scroll = gtk::ScrolledWindow::builder()
|
||||||
|
// that puts items vertically
|
||||||
|
.valign(gtk::Align::Center)
|
||||||
|
.hexpand(true)
|
||||||
|
.vexpand(true)
|
||||||
|
.child(&welcome_page_text)
|
||||||
|
.propagate_natural_width(true)
|
||||||
|
.propagate_natural_height(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
welcome_content_page_stack.add_titled(&welcome_page_box, Some("welcome_page"), &t!("welcome_page_title").to_string());
|
welcome_content_page_stack.add_titled(&welcome_page_scroll, Some("welcome_page"), &t!("welcome_page_title").to_string());
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user