mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-27 06:15:45 +00:00
"Perform Tests" menu item is correctly disabled now if self-tests are not supported; if support is unknown, an appropriate message is shown after the Info window is displayed.
This commit is contained in:
@@ -925,6 +925,20 @@ bool StorageDevice::get_test_is_active() const
|
||||
|
||||
|
||||
|
||||
StorageDevice::SelfTestSupportStatus StorageDevice::get_self_test_support_status() const
|
||||
{
|
||||
if (get_parse_status() == ParseStatus::Full) {
|
||||
return property_repository_.has_properties_for_section(StoragePropertySection::SelftestLog) ?
|
||||
SelfTestSupportStatus::Supported : SelfTestSupportStatus::Unsupported;
|
||||
}
|
||||
if (get_parse_status() == ParseStatus::Basic) {
|
||||
return get_smart_status() == SmartStatus::Enabled ? SelfTestSupportStatus::Unknown : SelfTestSupportStatus::Unsupported;
|
||||
}
|
||||
return StorageDevice::SelfTestSupportStatus::Unknown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string StorageDevice::get_save_filename() const
|
||||
{
|
||||
const std::string model = this->get_model_name(); // may be empty
|
||||
|
||||
@@ -70,6 +70,14 @@ class StorageDevice {
|
||||
};
|
||||
|
||||
|
||||
/// Status of self-test support
|
||||
enum class SelfTestSupportStatus {
|
||||
Unknown, ///< Full info not parsed yet
|
||||
Supported, ///< Supported
|
||||
Unsupported, ///< Not supported
|
||||
};
|
||||
|
||||
|
||||
/// Constructor
|
||||
explicit StorageDevice(std::string dev_or_vfile, bool is_virtual = false);
|
||||
|
||||
@@ -232,6 +240,10 @@ class StorageDevice {
|
||||
[[nodiscard]] bool get_test_is_active() const;
|
||||
|
||||
|
||||
/// Get whether the tests are supported, based on parsed properties
|
||||
[[nodiscard]] SelfTestSupportStatus get_self_test_support_status() const;
|
||||
|
||||
|
||||
/// Get the recommended filename to save output to. Includes model and date.
|
||||
[[nodiscard]] std::string get_save_filename() const;
|
||||
|
||||
|
||||
@@ -404,11 +404,16 @@ void GscInfoWindow::fill_ui_with_info(bool scan, bool clear_ui, bool clear_tests
|
||||
note_page_box->set_visible(has_statistics);
|
||||
}
|
||||
|
||||
bool has_selftest = prop_repo.has_properties_for_section(StoragePropertySection::SelftestLog);
|
||||
const bool has_selftest = (drive_->get_self_test_support_status() == StorageDevice::SelfTestSupportStatus::Supported);
|
||||
if (note_page_box = lookup_widget("test_tab_vbox"); note_page_box != nullptr) {
|
||||
// Some USB flash drives erroneously report SMART as enabled.
|
||||
// note_page_box->set_visible(drive->get_smart_status() == StorageDevice::Status::Enabled);
|
||||
note_page_box->set_visible(has_selftest);
|
||||
if (has_selftest) {
|
||||
book_selftest_page_no_ = 4;
|
||||
} else {
|
||||
book_selftest_page_no_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
const bool has_ata_error_log = prop_repo.has_properties_for_section(StoragePropertySection::AtaErrorLog);
|
||||
@@ -781,8 +786,13 @@ void GscInfoWindow::refresh_info(bool clear_tests_too)
|
||||
|
||||
void GscInfoWindow::show_tests()
|
||||
{
|
||||
if (auto* book = lookup_widget<Gtk::Notebook*>("main_notebook"))
|
||||
book->set_current_page(3); // the Tests tab
|
||||
if (auto* book = lookup_widget<Gtk::Notebook*>("main_notebook")) {
|
||||
if (book_selftest_page_no_ >= 0) {
|
||||
book->set_current_page(book_selftest_page_no_); // the Tests tab
|
||||
} else {
|
||||
gui_show_warn_dialog(_("Self-Tests Not Supported"), _("Self-tests are not supported on this drive."), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -310,6 +310,8 @@ class GscInfoWindow : public AppBuilderWidget<GscInfoWindow, true> {
|
||||
|
||||
/// Columns of treeviews inside GscInfoWindow
|
||||
std::unique_ptr<GscInfoWindowColumns> columns_;
|
||||
|
||||
int book_selftest_page_no_ = -1; ///< The page number of the self-test log in the notebook
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -731,16 +731,20 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
|
||||
{
|
||||
Glib::RefPtr<Gtk::Action> action;
|
||||
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_perform_tests))))
|
||||
action->set_sensitive(smart_status == StorageDevice::SmartStatus::Enabled);
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_reread_device_data))))
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_perform_tests)))) {
|
||||
auto status = drive->get_self_test_support_status();
|
||||
action->set_sensitive(status != StorageDevice::SelfTestSupportStatus::Unsupported);
|
||||
}
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_reread_device_data)))) {
|
||||
action->set_visible(drive && !is_virtual);
|
||||
}
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_remove_device)))) {
|
||||
action->set_visible(drive && drive->get_is_manually_added());
|
||||
// action->set_sensitive(drive && drive->get_is_manually_added());
|
||||
}
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_remove_virtual_device))))
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_remove_virtual_device)))) {
|
||||
action->set_visible(drive && is_virtual);
|
||||
}
|
||||
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_smart)))) {
|
||||
action->set_sensitive(drive && drive->get_smart_switch_supported());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user