@@ -838,6 +838,7 @@ impl RnSettingsPanel {
838
838
}
839
839
) ) ;
840
840
841
+ imp. doc_show_format_borders_row . set_sensitive ( false ) ;
841
842
imp. doc_show_format_borders_row
842
843
. connect_active_notify ( clone ! (
843
844
#[ weak]
@@ -860,13 +861,17 @@ impl RnSettingsPanel {
860
861
. sync_create ( )
861
862
. build ( ) ;
862
863
864
+ imp. doc_format_border_color_button . set_sensitive ( false ) ;
863
865
imp. doc_format_border_color_button
864
866
. connect_rgba_notify ( clone ! (
865
867
#[ weak( rename_to=settingspanel) ]
866
868
self ,
867
869
#[ weak]
868
870
appwindow,
869
871
move |button| {
872
+ if !button. get_sensitive( ) {
873
+ return ;
874
+ }
870
875
let format_border_color = button. rgba( ) . into_compose_color( ) ;
871
876
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
872
877
return ;
@@ -892,10 +897,14 @@ impl RnSettingsPanel {
892
897
}
893
898
) ) ;
894
899
900
+ imp. doc_background_color_button . set_sensitive ( false ) ;
895
901
imp. doc_background_color_button . connect_rgba_notify ( clone ! (
896
902
#[ weak]
897
903
appwindow,
898
904
move |button| {
905
+ if !button. get_sensitive( ) {
906
+ return ;
907
+ }
899
908
let background_color = button. rgba( ) . into_compose_color( ) ;
900
909
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
901
910
return ;
@@ -917,14 +926,18 @@ impl RnSettingsPanel {
917
926
}
918
927
) ) ;
919
928
929
+ imp. doc_document_layout_row . set_sensitive ( false ) ;
920
930
imp. doc_document_layout_row
921
931
. get ( )
922
932
. connect_selected_item_notify ( clone ! (
923
933
#[ weak( rename_to=settings_panel) ]
924
934
self ,
925
935
#[ weak]
926
936
appwindow,
927
- move |_| {
937
+ move |row| {
938
+ if !row. get_sensitive( ) {
939
+ return ;
940
+ }
928
941
let document_layout = settings_panel. document_layout( ) ;
929
942
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
930
943
return ;
@@ -944,14 +957,18 @@ impl RnSettingsPanel {
944
957
}
945
958
) ) ;
946
959
960
+ imp. doc_background_patterns_row . set_sensitive ( false ) ;
947
961
imp. doc_background_patterns_row
948
962
. get ( )
949
963
. connect_selected_item_notify ( clone ! (
950
964
#[ weak( rename_to=settings_panel) ]
951
965
self ,
952
966
#[ weak]
953
967
appwindow,
954
- move |_| {
968
+ move |row| {
969
+ if !row. get_sensitive( ) {
970
+ return ;
971
+ }
955
972
let pattern = settings_panel. background_pattern( ) ;
956
973
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
957
974
return ;
@@ -1030,11 +1047,15 @@ impl RnSettingsPanel {
1030
1047
}
1031
1048
) ) ;
1032
1049
1050
+ imp. doc_background_pattern_color_button . set_sensitive ( false ) ;
1033
1051
imp. doc_background_pattern_color_button
1034
1052
. connect_rgba_notify ( clone ! (
1035
1053
#[ weak]
1036
1054
appwindow,
1037
1055
move |button| {
1056
+ if !button. get_sensitive( ) {
1057
+ return ;
1058
+ }
1038
1059
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
1039
1060
return ;
1040
1061
} ;
@@ -1058,6 +1079,8 @@ impl RnSettingsPanel {
1058
1079
}
1059
1080
) ) ;
1060
1081
1082
+ imp. doc_background_pattern_width_unitentry
1083
+ . set_sensitive ( false ) ;
1061
1084
imp. doc_background_pattern_width_unitentry
1062
1085
. get ( )
1063
1086
. connect_notify_local (
@@ -1066,6 +1089,9 @@ impl RnSettingsPanel {
1066
1089
#[ weak]
1067
1090
appwindow,
1068
1091
move |unit_entry, _| {
1092
+ if !unit_entry. get_sensitive( ) {
1093
+ return ;
1094
+ }
1069
1095
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
1070
1096
return ;
1071
1097
} ;
@@ -1092,6 +1118,8 @@ impl RnSettingsPanel {
1092
1118
) ,
1093
1119
) ;
1094
1120
1121
+ imp. doc_background_pattern_height_unitentry
1122
+ . set_sensitive ( false ) ;
1095
1123
imp. doc_background_pattern_height_unitentry
1096
1124
. get ( )
1097
1125
. connect_notify_local (
@@ -1100,6 +1128,9 @@ impl RnSettingsPanel {
1100
1128
#[ weak]
1101
1129
appwindow,
1102
1130
move |unit_entry, _| {
1131
+ if !unit_entry. get_sensitive( ) {
1132
+ return ;
1133
+ }
1103
1134
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
1104
1135
return ;
1105
1136
} ;
@@ -1144,12 +1175,17 @@ impl RnSettingsPanel {
1144
1175
}
1145
1176
) ) ;
1146
1177
1178
+ imp. background_pattern_invert_color_button
1179
+ . set_sensitive ( false ) ;
1147
1180
imp. background_pattern_invert_color_button
1148
1181
. get ( )
1149
1182
. connect_clicked ( clone ! (
1150
1183
#[ weak]
1151
1184
appwindow,
1152
- move |_| {
1185
+ move |button| {
1186
+ if !button. get_sensitive( ) {
1187
+ return ;
1188
+ }
1153
1189
let Some ( canvas) = appwindow. active_tab_canvas( ) else {
1154
1190
return ;
1155
1191
} ;
@@ -1184,6 +1220,26 @@ impl RnSettingsPanel {
1184
1220
) ) ;
1185
1221
}
1186
1222
1223
+ // All relevant buttons are set as sensitive : false upon startup
1224
+ // until the first tab is added. This way setting the correct values
1225
+ // in the doc part of the settings won't send back a widget flag
1226
+ // that modifies the store
1227
+ pub fn activate_doc_settings_buttons ( & self ) {
1228
+ let imp = self . imp ( ) ;
1229
+ imp. doc_show_format_borders_row . set_sensitive ( true ) ;
1230
+ imp. doc_format_border_color_button . set_sensitive ( true ) ;
1231
+ imp. doc_background_color_button . set_sensitive ( true ) ;
1232
+ imp. doc_document_layout_row . set_sensitive ( true ) ;
1233
+ imp. doc_background_patterns_row . set_sensitive ( true ) ;
1234
+ imp. doc_background_pattern_color_button . set_sensitive ( true ) ;
1235
+ imp. doc_background_pattern_width_unitentry
1236
+ . set_sensitive ( true ) ;
1237
+ imp. doc_background_pattern_height_unitentry
1238
+ . set_sensitive ( true ) ;
1239
+ imp. background_pattern_invert_color_button
1240
+ . set_sensitive ( true ) ;
1241
+ }
1242
+
1187
1243
fn setup_shortcuts ( & self , appwindow : & RnAppWindow ) {
1188
1244
let imp = self . imp ( ) ;
1189
1245
let penshortcut_stylus_button_primary_row = imp. penshortcut_stylus_button_primary_row . get ( ) ;
0 commit comments