diff --git a/crates/rnote-ui/src/appwindow/mod.rs b/crates/rnote-ui/src/appwindow/mod.rs index d8b7e23bb3..b907d28c4a 100644 --- a/crates/rnote-ui/src/appwindow/mod.rs +++ b/crates/rnote-ui/src/appwindow/mod.rs @@ -240,6 +240,7 @@ impl RnAppWindow { // Anything that needs to be done right before showing the appwindow self.refresh_ui(); + imp.sidebar.get().activate_doc_settings_buttons(); } fn setup_icon_theme(&self) { diff --git a/crates/rnote-ui/src/settingspanel/mod.rs b/crates/rnote-ui/src/settingspanel/mod.rs index 71e54e78ac..5b454b52be 100644 --- a/crates/rnote-ui/src/settingspanel/mod.rs +++ b/crates/rnote-ui/src/settingspanel/mod.rs @@ -838,6 +838,7 @@ impl RnSettingsPanel { } )); + imp.doc_show_format_borders_row.set_sensitive(false); imp.doc_show_format_borders_row .connect_active_notify(clone!( #[weak] @@ -860,6 +861,7 @@ impl RnSettingsPanel { .sync_create() .build(); + imp.doc_format_border_color_button.set_sensitive(false); imp.doc_format_border_color_button .connect_rgba_notify(clone!( #[weak(rename_to=settingspanel)] @@ -867,6 +869,9 @@ impl RnSettingsPanel { #[weak] appwindow, move |button| { + if !button.get_sensitive() { + return; + } let format_border_color = button.rgba().into_compose_color(); let Some(canvas) = appwindow.active_tab_canvas() else { return; @@ -892,10 +897,14 @@ impl RnSettingsPanel { } )); + imp.doc_background_color_button.set_sensitive(false); imp.doc_background_color_button.connect_rgba_notify(clone!( #[weak] appwindow, move |button| { + if !button.get_sensitive() { + return; + } let background_color = button.rgba().into_compose_color(); let Some(canvas) = appwindow.active_tab_canvas() else { return; @@ -917,6 +926,7 @@ impl RnSettingsPanel { } )); + imp.doc_document_layout_row.set_sensitive(false); imp.doc_document_layout_row .get() .connect_selected_item_notify(clone!( @@ -924,7 +934,10 @@ impl RnSettingsPanel { self, #[weak] appwindow, - move |_| { + move |row| { + if !row.get_sensitive() { + return; + } let document_layout = settings_panel.document_layout(); let Some(canvas) = appwindow.active_tab_canvas() else { return; @@ -944,6 +957,7 @@ impl RnSettingsPanel { } )); + imp.doc_background_patterns_row.set_sensitive(false); imp.doc_background_patterns_row .get() .connect_selected_item_notify(clone!( @@ -951,7 +965,10 @@ impl RnSettingsPanel { self, #[weak] appwindow, - move |_| { + move |row| { + if !row.get_sensitive() { + return; + } let pattern = settings_panel.background_pattern(); let Some(canvas) = appwindow.active_tab_canvas() else { return; @@ -1030,11 +1047,15 @@ impl RnSettingsPanel { } )); + imp.doc_background_pattern_color_button.set_sensitive(false); imp.doc_background_pattern_color_button .connect_rgba_notify(clone!( #[weak] appwindow, move |button| { + if !button.get_sensitive() { + return; + } let Some(canvas) = appwindow.active_tab_canvas() else { return; }; @@ -1058,6 +1079,8 @@ impl RnSettingsPanel { } )); + imp.doc_background_pattern_width_unitentry + .set_sensitive(false); imp.doc_background_pattern_width_unitentry .get() .connect_notify_local( @@ -1066,6 +1089,9 @@ impl RnSettingsPanel { #[weak] appwindow, move |unit_entry, _| { + if !unit_entry.get_sensitive() { + return; + } let Some(canvas) = appwindow.active_tab_canvas() else { return; }; @@ -1092,6 +1118,8 @@ impl RnSettingsPanel { ), ); + imp.doc_background_pattern_height_unitentry + .set_sensitive(false); imp.doc_background_pattern_height_unitentry .get() .connect_notify_local( @@ -1100,6 +1128,9 @@ impl RnSettingsPanel { #[weak] appwindow, move |unit_entry, _| { + if !unit_entry.get_sensitive() { + return; + } let Some(canvas) = appwindow.active_tab_canvas() else { return; }; @@ -1144,12 +1175,17 @@ impl RnSettingsPanel { } )); + imp.background_pattern_invert_color_button + .set_sensitive(false); imp.background_pattern_invert_color_button .get() .connect_clicked(clone!( #[weak] appwindow, - move |_| { + move |button| { + if !button.get_sensitive() { + return; + } let Some(canvas) = appwindow.active_tab_canvas() else { return; }; @@ -1184,6 +1220,26 @@ impl RnSettingsPanel { )); } + // All relevant buttons are set as sensitive : false upon startup + // until the first tab is added. This way setting the correct values + // in the doc part of the settings won't send back a widget flag + // that modifies the store + pub fn activate_doc_settings_buttons(&self) { + let imp = self.imp(); + imp.doc_show_format_borders_row.set_sensitive(true); + imp.doc_format_border_color_button.set_sensitive(true); + imp.doc_background_color_button.set_sensitive(true); + imp.doc_document_layout_row.set_sensitive(true); + imp.doc_background_patterns_row.set_sensitive(true); + imp.doc_background_pattern_color_button.set_sensitive(true); + imp.doc_background_pattern_width_unitentry + .set_sensitive(true); + imp.doc_background_pattern_height_unitentry + .set_sensitive(true); + imp.background_pattern_invert_color_button + .set_sensitive(true); + } + fn setup_shortcuts(&self, appwindow: &RnAppWindow) { let imp = self.imp(); let penshortcut_stylus_button_primary_row = imp.penshortcut_stylus_button_primary_row.get(); diff --git a/crates/rnote-ui/src/sidebar.rs b/crates/rnote-ui/src/sidebar.rs index c3955a4618..dce47c90f5 100644 --- a/crates/rnote-ui/src/sidebar.rs +++ b/crates/rnote-ui/src/sidebar.rs @@ -124,4 +124,10 @@ impl RnSidebar { } )); } + + pub(crate) fn activate_doc_settings_buttons(&self) { + let imp = self.imp(); + + imp.settings_panel.get().activate_doc_settings_buttons(); + } }