diff --git a/src/applib/app_gtkmm_utils.cpp b/src/applib/app_gtkmm_utils.cpp
index aec078c..1c6f340 100644
--- a/src/applib/app_gtkmm_utils.cpp
+++ b/src/applib/app_gtkmm_utils.cpp
@@ -69,9 +69,10 @@ namespace {
/// the potentially invalid utf-8 data.
inline gchar* gsc_g_utf8_make_valid (const gchar* name)
{
- GString* str;
- const gchar* remainder, *invalid;
- gint remaining_bytes, valid_bytes;
+ GString* str = nullptr;
+ const gchar* remainder = nullptr;
+ const gchar* invalid = nullptr;
+ gint remaining_bytes = 0, valid_bytes = 0;
g_return_val_if_fail (name != nullptr, nullptr);
@@ -80,7 +81,7 @@ namespace {
remaining_bytes = gint(std::strlen(name));
while (remaining_bytes != 0) {
- if (g_utf8_validate (remainder, remaining_bytes, &invalid))
+ if (g_utf8_validate (remainder, remaining_bytes, &invalid) == TRUE)
break;
valid_bytes = gint(invalid - remainder);
diff --git a/src/applib/storage_property_descr.cpp b/src/applib/storage_property_descr.cpp
index 1bd869d..e669475 100644
--- a/src/applib/storage_property_descr.cpp
+++ b/src/applib/storage_property_descr.cpp
@@ -25,14 +25,18 @@ Copyright:
namespace {
- const std::string s_unc_text = Glib::Markup::escape_text(
- _("When a drive encounters a surface error, it marks that sector as \"unstable\" (also known as \"pending reallocation\"). "
- "If the sector is successfully read from or written to at some later point, it is unmarked. If the sector continues to be inaccessible, "
- "the drive reallocates (remaps) it to a specially reserved area as soon as it has a chance (usually during write request or successful read), "
- "transferring the data so that no changes are reported to the operating system. This is why you generally don't see \"bad blocks\" "
- "on modern drives - if you do, it means that either they have not been remapped yet, or the drive is out of reserved area."
- "\n\nNote: SSDs reallocate blocks as part of their normal operation, so low reallocation counts are not critical for them."));
-
+ /// Get text related to "uncorrectable sectors"
+ const std::string& get_uncorrectable_text()
+ {
+ static const std::string text = Glib::Markup::escape_text(
+ _("When a drive encounters a surface error, it marks that sector as \"unstable\" (also known as \"pending reallocation\"). "
+ "If the sector is successfully read from or written to at some later point, it is unmarked. If the sector continues to be inaccessible, "
+ "the drive reallocates (remaps) it to a specially reserved area as soon as it has a chance (usually during write request or successful read), "
+ "transferring the data so that no changes are reported to the operating system. This is why you generally don't see \"bad blocks\" "
+ "on modern drives - if you do, it means that either they have not been remapped yet, or the drive is out of reserved area."
+ "\n\nNote: SSDs reallocate blocks as part of their normal operation, so low reallocation counts are not critical for them."));
+ return text;
+ }
/// Attribute description for attribute database
@@ -97,7 +101,7 @@ namespace {
// Reallocated Sector Count (smartctl)
add(5, StorageAttribute::DiskType::Hdd, "Reallocated_Sector_Ct", "Reallocated Sector Count", "attr_reallocated_sector_count",
"Number of reallocated sectors (Raw value). Non-zero Raw value indicates a disk surface failure."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
// SSD: Reallocated Sector Count (smartctl)
add(5, StorageAttribute::DiskType::Ssd, "Reallocated_Sector_Ct", "Reallocated Sector Count", "attr_reallocated_sector_count",
"Number of reallocated sectors (Raw value). High Raw value indicates an old age for an SSD.");
@@ -524,7 +528,7 @@ namespace {
add(196, StorageAttribute::DiskType::Any, "Reallocated_Event_Count", "Reallocation Event Count", "attr_reallocation_event_count",
"Number of reallocation (remap) operations. Raw value should show the total number of attempts "
"(both successful and unsuccessful) to reallocate sectors. An increase in Raw value indicates a disk surface failure."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
// Indilinx Barefoot SSD: Erase_Failure_Blk_Ct (smartctl) (description?)
add(196, StorageAttribute::DiskType::Ssd, "Erase_Failure_Blk_Ct", "Erase Failure Block Count", "",
"Number of flash erase failures.");
@@ -536,7 +540,7 @@ namespace {
"Number of "unstable" (waiting to be remapped) sectors (Raw value). "
"If the unstable sector is subsequently read from or written to successfully, this value is decreased and the sector is not remapped. "
"An increase in Raw value indicates a disk surface failure."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
// Indilinx Barefoot SSD: Read_Failure_Blk_Ct (smartctl) (description?)
add(197, StorageAttribute::DiskType::Ssd, "Read_Failure_Blk_Ct", "Read Failure Block Count", "",
"Number of blocks that failed to be read.");
@@ -545,7 +549,7 @@ namespace {
add(197, "Total_Pending_Sectors", "Total Pending Sectors", "attr_total_pending_sectors",
"Number of "unstable" (waiting to be remapped) sectors and already remapped sectors (Raw value). "
"An increase in Raw value indicates a disk surface failure."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
// OCZ SSD (smartctl)
add(197, StorageAttribute::DiskType::Ssd, "Total_Unc_Read_Failures", "Total Uncorrectable Read Failures", "",
"");
@@ -555,13 +559,13 @@ namespace {
"An increase in Raw value indicates a disk surface failure. "
"The value may be decreased automatically when the errors are corrected (e.g., when an unreadable sector is "
"reallocated and the next Offline test is run to see the change)."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
// Samsung: Offline Uncorrectable (smartctl). From smartctl man page:
// unlike Current_Pending_Sector, this won't decrease on reallocation.
add(198, "Total_Offl_Uncorrectabl", "Total Offline Uncorrectable", "attr_total_attr_offline_uncorrectable",
"Number of sectors which couldn't be corrected during Offline Data Collection (Raw value), currently and in the past. "
"An increase in Raw value indicates a disk surface failure."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
// Sandforce SSD: Uncorrectable_Sector_Ct (smartctl) (same description?)
add(198, StorageAttribute::DiskType::Ssd, "Uncorrectable_Sector_Ct");
// Indilinx Barefoot SSD: Read_Sectors_Tot_Ct (smartctl) (description?)
@@ -1252,7 +1256,7 @@ namespace {
"The number of logical sectors that have been reallocated after device manufacture.\n\n"
"If the value is normalized, this is the whole number percentage of the available logical sector reallocation "
"resources that have been used (i.e., 0-100)."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
add("Read Recovery Attempts", "", "",
"The number of logical sectors that require three or more attempts to read the data from the media for each read command. "
@@ -1266,7 +1270,7 @@ namespace {
add("Number of Realloc. Candidate Logical Sectors", "Number of Reallocation Candidate Logical Sectors", "",
"The number of logical sectors that are candidates for reallocation. "
"A reallocation candidate sector is a logical sector that the device has determined may need to be reallocated."
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
add("Number of High Priority Unload Events", "", "",
"The number of emergency head unload events.");
@@ -1277,7 +1281,7 @@ namespace {
"The number of errors that are reported as an Uncorrectable Error. "
"Uncorrectable errors that occur during background activity shall not be counted. "
"Uncorrectable errors reported by reads to flagged uncorrectable logical blocks should not be counted"
- "\n\n" + s_unc_text);
+ "\n\n" + get_uncorrectable_text());
add("Resets Between Cmd Acceptance and Completion", "", "",
"The number of software reset or hardware reset events that occur while one or more commands have "
diff --git a/src/gsc_executor_log_window.cpp b/src/gsc_executor_log_window.cpp
index 1c4700d..17ff125 100644
--- a/src/gsc_executor_log_window.cpp
+++ b/src/gsc_executor_log_window.cpp
@@ -116,7 +116,7 @@ void GscExecutorLogWindow::show_last()
{
auto* treeview = this->lookup_widget("command_list_treeview");
- if (treeview && !list_store->children().empty()) {
+ if (treeview != nullptr && !list_store->children().empty()) {
// Gtk::TreeRow row = *(list_store->children().rbegin()); // this causes invalid read error in valgrind
Gtk::TreeRow row = *(--(list_store->children().end()));
selection->select(row);
@@ -185,7 +185,7 @@ void GscExecutorLogWindow::on_window_close_button_clicked()
void GscExecutorLogWindow::on_window_save_current_button_clicked()
{
- if (!selection->count_selected_rows())
+ if (selection->count_selected_rows() == 0)
return;
Gtk::TreeIter iter = selection->get_selected();
@@ -210,7 +210,7 @@ void GscExecutorLogWindow::on_window_save_current_button_clicked()
_("Save Data As..."), this->gobj(), GTK_FILE_CHOOSER_ACTION_SAVE, nullptr, nullptr),
&g_object_unref);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), true);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), specific_filter->gobj());
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), all_filter->gobj());
@@ -328,7 +328,7 @@ void GscExecutorLogWindow::on_window_save_all_button_clicked()
_("Save Data As..."), this->gobj(), GTK_FILE_CHOOSER_ACTION_SAVE, nullptr, nullptr),
&g_object_unref);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), true);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), specific_filter->gobj());
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), all_filter->gobj());
@@ -412,7 +412,7 @@ void GscExecutorLogWindow::on_tree_selection_changed()
{
this->clear_view_widgets();
- if (selection->count_selected_rows()) {
+ if (selection->count_selected_rows() > 0) {
Gtk::TreeIter iter = selection->get_selected();
Gtk::TreeRow row = *iter;
@@ -435,12 +435,12 @@ void GscExecutorLogWindow::on_tree_selection_changed()
}
}
- if (auto command_entry = this->lookup_widget("command_entry")) {
+ if (auto* command_entry = this->lookup_widget("command_entry")) {
std::string cmd_text = entry->command + " " + entry->parameters;
command_entry->set_text(app_output_make_valid(cmd_text));
}
- if (auto window_save_current_button = this->lookup_widget("window_save_current_button"))
+ if (auto* window_save_current_button = this->lookup_widget("window_save_current_button"))
window_save_current_button->set_sensitive(true);
}
diff --git a/src/gsc_info_window.cpp b/src/gsc_info_window.cpp
index 4767286..a3bd4da 100644
--- a/src/gsc_info_window.cpp
+++ b/src/gsc_info_window.cpp
@@ -92,8 +92,11 @@ namespace {
label->set_can_focus(false);
std::string fg;
- if (app_property_get_label_highlight_color(label_string.property->warning, fg))
- label->set_markup("" + label_text + "");
+ if (app_property_get_label_highlight_color(label_string.property->warning, fg)) {
+ label->set_markup(
+ std::string("")
+ .append(label_text).append("") );
+ }
vbox->pack_start(*label, false, false);
// set it after packing, else the old tooltips api won't have anything to attach them to.
@@ -164,7 +167,7 @@ namespace {
auto* treeview = window->lookup_widget("error_log_treeview");
auto* textview = window->lookup_widget("error_log_textview");
Glib::RefPtr buffer;
- if (treeview && textview && (buffer = textview->get_buffer())) {
+ if (treeview != nullptr && textview != nullptr && (buffer = textview->get_buffer())) {
Gtk::TreeModel::iterator iter = treeview->get_selection()->get_selected();
if (iter) {
Glib::RefPtr mark = buffer->get_mark((*iter)[mark_name_column]);
@@ -522,7 +525,7 @@ void GscInfoWindow::clear_ui_info(bool clear_tests_too)
auto* label_vbox = lookup_widget("statistics_label_vbox");
app_set_top_labels(label_vbox, std::vector());
- if (auto treeview = lookup_widget("statistics_treeview")) {
+ if (auto* treeview = lookup_widget("statistics_treeview")) {
treeview->remove_all_columns();
treeview->unset_model();
}
@@ -560,7 +563,7 @@ void GscInfoWindow::clear_ui_info(bool clear_tests_too)
auto* test_description_textview = lookup_widget("test_description_textview");
- if (test_description_textview && test_description_textview->get_buffer())
+ if (test_description_textview != nullptr && test_description_textview->get_buffer())
test_description_textview->get_buffer()->set_text(""); // set on test selection
if (auto* test_completion_progressbar = lookup_widget("test_completion_progressbar")) {
@@ -753,7 +756,7 @@ void GscInfoWindow::on_save_info_button_clicked()
_("Save Data As..."), this->gobj(), GTK_FILE_CHOOSER_ACTION_SAVE, nullptr, nullptr),
&g_object_unref);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), true);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), specific_filter->gobj());
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), all_filter->gobj());
@@ -857,7 +860,7 @@ void GscInfoWindow::on_test_type_combo_changed()
}
auto* test_description_textview = lookup_widget("test_description_textview");
- if (test_description_textview && test_description_textview->get_buffer())
+ if (test_description_textview != nullptr && test_description_textview->get_buffer())
test_description_textview->get_buffer()->set_text(row[test_combo_col_description]);
}
}
@@ -1616,7 +1619,7 @@ WarningLevel GscInfoWindow::fill_ui_capabilities(const std::vectorset_search_column(col_name.index());
- auto cr_name = dynamic_cast(treeview->get_column_cell_renderer(num_tree_cols - 1));
+ auto* cr_name = dynamic_cast(treeview->get_column_cell_renderer(num_tree_cols - 1));
if (cr_name)
cr_name->property_weight() = Pango::WEIGHT_BOLD ;
@@ -1796,7 +1799,7 @@ gboolean GscInfoWindow::test_idle_callback(void* data)
DBG_ASSERT(self);
if (!self->current_test) // shouldn't happen
- return false; // stop
+ return FALSE; // stop
auto* test_completion_progressbar =
self->lookup_widget("test_completion_progressbar");
@@ -1879,7 +1882,7 @@ gboolean GscInfoWindow::test_idle_callback(void* data)
if (active) {
- return true; // continue the idle callback
+ return TRUE; // continue the idle callback
}
@@ -1953,7 +1956,7 @@ gboolean GscInfoWindow::test_idle_callback(void* data)
self->refresh_info(false); // don't clear the tests tab
- return false; // stop idle callback
+ return FALSE; // stop idle callback
}
diff --git a/src/gsc_init.cpp b/src/gsc_init.cpp
index b7fcc27..35dbcfb 100644
--- a/src/gsc_init.cpp
+++ b/src/gsc_init.cpp
@@ -52,32 +52,27 @@ Copyright:
namespace {
/// Config file in user's HOME
- hz::fs::path s_home_config_file;
+ inline const hz::fs::path& get_home_config_file()
+ {
+ static hz::fs::path home_config_file = hz::fs_get_user_config_dir() / "gsmartcontrol" / "gsmartcontrol2.conf";
+ return home_config_file;
+ }
- /// Libdebug channel buffer
- DebugChannelBasePtr s_debug_buf_channel;
/// Libdebug channel buffer stream
- std::unique_ptr s_debug_buf_channel_stream;
-
-
- inline void app_get_debug_buf_channel_stream()
+ inline std::ostringstream& get_debug_buf_channel_stream()
{
- if (!s_debug_buf_channel_stream) {
- s_debug_buf_channel_stream = std::make_unique();
- }
+ static std::ostringstream stream;
+ return stream;
}
/// Get libdebug buffer channel (create new one if unavailable).
- inline DebugChannelBasePtr app_get_debug_buf_channel()
+ inline DebugChannelBasePtr get_debug_buf_channel()
{
- if (!s_debug_buf_channel) {
- app_get_debug_buf_channel_stream();
- s_debug_buf_channel = std::make_shared(*s_debug_buf_channel_stream);
- }
- return s_debug_buf_channel;
+ static DebugChannelBasePtr channel = std::make_shared(get_debug_buf_channel_stream());
+ return channel;
}
}
@@ -86,9 +81,7 @@ namespace {
std::string app_get_debug_buffer_str()
{
- app_get_debug_buf_channel_stream();
- DebugChannelBasePtr channel = app_get_debug_buf_channel();
- return s_debug_buf_channel_stream->str();
+ return get_debug_buf_channel_stream().str();
}
@@ -101,8 +94,6 @@ namespace {
/// Find the configuration files and load them.
inline bool app_init_config()
{
- s_home_config_file = hz::fs_get_user_config_dir() / "gsmartcontrol" / "gsmartcontrol2.conf";
-
// Default system-wide settings. This file is empty by default.
hz::fs::path global_config_file;
#ifdef _WIN32
@@ -112,7 +103,8 @@ namespace {
#endif
debug_out_dump("app", DBG_FUNC_MSG << "Global config file: \"" << global_config_file.u8string() << "\"\n");
- debug_out_dump("app", DBG_FUNC_MSG << "Local config file: \"" << s_home_config_file.u8string() << "\"\n");
+ debug_out_dump("app",
+ DBG_FUNC_MSG << "Local config file: \"" << get_home_config_file().u8string() << "\"\n");
// load global first
std::error_code ec;
@@ -121,12 +113,12 @@ namespace {
}
// load local
- if (hz::fs::exists(s_home_config_file, ec) && hz::fs_path_is_readable(s_home_config_file, ec)) {
- rconfig::load_from_file(s_home_config_file);
+ if (hz::fs::exists(get_home_config_file(), ec) && hz::fs_path_is_readable(get_home_config_file(), ec)) {
+ rconfig::load_from_file(get_home_config_file());
} else {
// create the parent directories of the config file
- hz::fs::path config_loc = s_home_config_file.parent_path();
+ hz::fs::path config_loc = get_home_config_file().parent_path();
if (!hz::fs::exists(config_loc, ec)) {
hz::fs::create_directories(config_loc, ec);
hz::fs::permissions(config_loc, hz::fs::perms::owner_all, ec);
@@ -137,7 +129,7 @@ namespace {
rconfig::dump_config();
- rconfig::autosave_set_config_file(s_home_config_file);
+ rconfig::autosave_set_config_file(get_home_config_file());
int autosave_timeout_sec = rconfig::get_data("system/config_autosave_timeout_sec");
if (autosave_timeout_sec > 0) {
rconfig::autosave_start(std::chrono::seconds(autosave_timeout_sec));
@@ -206,10 +198,10 @@ namespace {
/// Command-line argument values
struct CmdArgs {
// Note: Use GLib types here:
- gboolean arg_locale = true; ///< if false, disable using system locale
- gboolean arg_version = false; ///< if true, show version and exit
- gboolean arg_scan = true; ///< if false, don't scan the system for drives on startup
- gboolean arg_hide_tabs = true; ///< if true, hide additional info tabs when smart is disabled. false may help debugging.
+ gboolean arg_locale = TRUE; ///< if false, disable using system locale
+ gboolean arg_version = FALSE; ///< if true, show version and exit
+ gboolean arg_scan = TRUE; ///< if false, don't scan the system for drives on startup
+ gboolean arg_hide_tabs = TRUE; ///< if true, hide additional info tabs when smart is disabled. false may help debugging.
gchar** arg_add_virtual = nullptr; ///< load smartctl data from these files as virtual drives
gchar** arg_add_device = nullptr; ///< add these device files manually
double arg_gdk_scale = std::numeric_limits::quiet_NaN(); ///< The value of GDK_SCALE environment variable
@@ -221,8 +213,7 @@ namespace {
/// Parse command-line arguments (fills \c args)
inline bool parse_cmdline_args(CmdArgs& args, int& argc, char**& argv)
{
- static const GOptionEntry arg_entries[] =
- {
+ static const std::vector arg_entries = {
{ "no-locale", 'l', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &(args.arg_locale),
N_("Don't use system locale"), nullptr },
{ "version", 'V', 0, G_OPTION_ARG_NONE, &(args.arg_version),
@@ -251,10 +242,10 @@ namespace {
GOptionContext* context = g_option_context_new("- A GTK+ GUI for smartmontools");
// our options
- g_option_context_add_main_entries(context, arg_entries, nullptr);
+ g_option_context_add_main_entries(context, arg_entries.data(), nullptr);
// gtk options
- g_option_context_add_group(context, gtk_get_option_group(false));
+ g_option_context_add_group(context, gtk_get_option_group(FALSE));
// libdebug options; this will also automatically apply them
g_option_context_add_group(context, debug_get_option_group());
@@ -268,7 +259,7 @@ namespace {
error_text += "\n\n";
g_error_free(error);
- gchar* help_text = g_option_context_get_help(context, true, nullptr);
+ gchar* help_text = g_option_context_get_help(context, TRUE, nullptr);
if (help_text) {
error_text += help_text;
g_free(help_text);
@@ -331,7 +322,7 @@ bool app_init_and_loop(int& argc, char**& argv)
// Note that changing GTK locale after it's inited isn't really supported by GTK,
// but we have no other choice - glib needs system locale when parsing the
// arguments, and gtk is inited while the parsing is performed.
- if (!args.arg_locale) {
+ if (args.arg_locale == FALSE) {
hz::locale_c_set("C");
} else {
// change the C++ locale to match the C one.
@@ -339,7 +330,7 @@ bool app_init_and_loop(int& argc, char**& argv)
}
- if (args.arg_version) {
+ if (args.arg_version == TRUE) {
// show version information and exit
app_print_version_info();
return true;
@@ -355,7 +346,7 @@ bool app_init_and_loop(int& argc, char**& argv)
// Add special debug channel to collect all libdebug output into a buffer.
- debug_add_channel("all", debug_level::all, app_get_debug_buf_channel());
+ debug_add_channel("all", debug_level::all, get_debug_buf_channel());
@@ -407,14 +398,15 @@ bool app_init_and_loop(int& argc, char**& argv)
// Redirect all GTK+/Glib and related messages to libdebug.
// Do this before GTK+ init, to capture its possible warnings as well.
- static const char* const gtkdomains[] = {
+ const std::vector gtkdomains = {
// no atk or cairo, they don't log. libgnomevfs may be loaded by gtk file chooser.
"GLib", "GModule", "GLib-GObject", "GLib-GRegex", "GLib-GIO", "GThread",
"Pango", "Gtk", "Gdk", "GdkPixbuf", "libgnomevfs",
- "glibmm", "giomm", "atkmm", "pangomm", "gdkmm", "gtkmm" };
+ "glibmm", "giomm", "atkmm", "pangomm", "gdkmm", "gtkmm"
+ };
- for (std::size_t i = 0, m = G_N_ELEMENTS(gtkdomains); i < m; ++i) {
- g_log_set_handler(gtkdomains[i], GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+ for (const auto* domain : gtkdomains) {
+ g_log_set_handler(domain, GLogLevelFlags(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
| G_LOG_FLAG_RECURSION), glib_message_handler, nullptr);
}
@@ -573,7 +565,7 @@ void app_quit()
#if defined ENABLE_GLIB && ENABLE_GLIB
rconfig::autosave_force_now();
#else
- rconfig::save_to_file(s_home_config_file);
+ rconfig::save_to_file(get_home_config_file());
#endif
// exit the main loop
diff --git a/src/gsc_main_window.cpp b/src/gsc_main_window.cpp
index 1fe5da3..02c5e01 100644
--- a/src/gsc_main_window.cpp
+++ b/src/gsc_main_window.cpp
@@ -155,7 +155,7 @@ GscMainWindow::~GscMainWindow()
// This is needed because for some reason, if any icon is selected,
// on_iconview_selection_changed() is called even after the window is deleted,
// causing crash on exit.
- iconview->clear_all();
+ iconview_->clear_all();
}
@@ -163,8 +163,8 @@ GscMainWindow::~GscMainWindow()
void GscMainWindow::populate_iconview(bool smartctl_valid)
{
if (!smartctl_valid) {
- iconview->set_empty_view_message(GscMainWindowIconView::Message::no_smartctl);
- iconview->clear_all(); // the message won't be shown without invalidating the region.
+ iconview_->set_empty_view_message(GscMainWindowIconView::Message::no_smartctl);
+ iconview_->clear_all(); // the message won't be shown without invalidating the region.
while (Gtk::Main::events_pending()) // give expose event the time it needs
Gtk::Main::iteration();
@@ -173,8 +173,8 @@ void GscMainWindow::populate_iconview(bool smartctl_valid)
rescan_devices(); // scan for devices and fill the iconview
} else {
- iconview->set_empty_view_message(GscMainWindowIconView::Message::scan_disabled);
- iconview->clear_all(); // the message won't be shown without invalidating the region.
+ iconview_->set_empty_view_message(GscMainWindowIconView::Message::scan_disabled);
+ iconview_->clear_all(); // the message won't be shown without invalidating the region.
while (Gtk::Main::events_pending()) // give expose event the time it needs
Gtk::Main::iteration();
}
@@ -203,7 +203,7 @@ void GscMainWindow::populate_iconview(bool smartctl_valid)
}
// update the menus (group sensitiveness, etc...)
- iconview->update_menu_actions();
+ iconview_->update_menu_actions();
this->update_status_widgets();
}
@@ -218,8 +218,10 @@ bool GscMainWindow::create_widgets()
{
// --------------------------------- Icon View
- get_ui()->get_widget_derived("drive_iconview", iconview); // fill our iconview and do the rest
- iconview->set_main_window(this);
+ get_ui()->get_widget_derived("drive_iconview", iconview_); // fill our iconview and do the rest
+ DBG_ASSERT_RETURN(iconview_, false);
+
+ iconview_->set_main_window(this);
// --------------------------------- Action widgets
@@ -281,115 +283,115 @@ bool GscMainWindow::create_widgets()
// Action groups
- actiongroup_main = Gtk::ActionGroup::create("main_actions");
- actiongroup_device = Gtk::ActionGroup::create("device_actions");
+ actiongroup_main_ = Gtk::ActionGroup::create("main_actions");
+ actiongroup_device_ = Gtk::ActionGroup::create("device_actions");
Glib::RefPtr action;
// Add actions
- actiongroup_main->add(Gtk::Action::create("file_menu", _("_File")));
+ actiongroup_main_->add(Gtk::Action::create("file_menu", _("_File")));
action = Gtk::Action::create(APP_ACTION_NAME(action_quit), Gtk::Stock::QUIT);
- actiongroup_main->add((action_map[action_quit] = action), Gtk::AccelKey("Q"),
+ actiongroup_main_->add((action_map_[action_quit] = action), Gtk::AccelKey("Q"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_quit));
- actiongroup_main->add(Gtk::Action::create("device_menu", _("_Device")));
+ actiongroup_main_->add(Gtk::Action::create("device_menu", _("_Device")));
action = Gtk::Action::create(APP_ACTION_NAME(action_view_details), Gtk::Stock::INFO, _("_View details"),
_("View detailed information"));
- actiongroup_device->add((action_map[action_view_details] = action), Gtk::AccelKey("V"),
+ actiongroup_device_->add((action_map_[action_view_details] = action), Gtk::AccelKey("V"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_view_details));
action = Gtk::ToggleAction::create(APP_ACTION_NAME(action_enable_smart), _("Enable SMART"),
_("Toggle SMART status. The status will be preserved at least until reboot (unless you toggle it again)."));
lookup_widget("status_smart_enabled_check")->set_related_action(action);
- actiongroup_device->add((action_map[action_enable_smart] = action), Gtk::AccelKey("M"),
+ actiongroup_device_->add((action_map_[action_enable_smart] = action), Gtk::AccelKey("M"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_enable_smart));
action = Gtk::ToggleAction::create(APP_ACTION_NAME(action_enable_aodc), _("Enable Auto Offline Data Collection"),
_("Toggle Automatic Offline Data Collection which will update \"offline\" SMART attributes every four hours"));
lookup_widget("status_aodc_enabled_check")->set_related_action(action);
- actiongroup_device->add((action_map[action_enable_aodc] = action), Gtk::AccelKey("F"),
+ actiongroup_device_->add((action_map_[action_enable_aodc] = action), Gtk::AccelKey("F"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_enable_aodc));
action = Gtk::Action::create(APP_ACTION_NAME(action_reread_device_data), Gtk::Stock::REFRESH, _("Re-read Data"),
_("Re-read basic SMART data"));
- actiongroup_device->add((action_map[action_reread_device_data] = action), Gtk::AccelKey("E"),
+ actiongroup_device_->add((action_map_[action_reread_device_data] = action), Gtk::AccelKey("E"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_reread_device_data));
action = Gtk::Action::create(APP_ACTION_NAME(action_perform_tests), _("Perform _Tests..."),
_("Perform various self-tests on the drive"));
- actiongroup_device->add((action_map[action_perform_tests] = action), Gtk::AccelKey("T"),
+ actiongroup_device_->add((action_map_[action_perform_tests] = action), Gtk::AccelKey("T"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_perform_tests));
action = Gtk::Action::create(APP_ACTION_NAME(action_remove_device), Gtk::Stock::REMOVE, _("Re_move Added Device"),
_("Remove previously added device"));
- actiongroup_device->add((action_map[action_remove_device] = action), Gtk::AccelKey("W"),
+ actiongroup_device_->add((action_map_[action_remove_device] = action), Gtk::AccelKey("W"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_remove_device));
action = Gtk::Action::create(APP_ACTION_NAME(action_remove_virtual_device), Gtk::Stock::REMOVE, _("Re_move Virtual Device"),
_("Remove previously loaded virtual device"));
- actiongroup_device->add((action_map[action_remove_virtual_device] = action), Gtk::AccelKey("Delete"),
+ actiongroup_device_->add((action_map_[action_remove_virtual_device] = action), Gtk::AccelKey("Delete"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_remove_virtual_device));
// ---
action = Gtk::Action::create(APP_ACTION_NAME(action_add_device), Gtk::Stock::OPEN, _("_Add Device..."),
_("Manually add device to device list"));
- actiongroup_main->add((action_map[action_add_device] = action), Gtk::AccelKey("D"),
+ actiongroup_main_->add((action_map_[action_add_device] = action), Gtk::AccelKey("D"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_add_device));
action = Gtk::Action::create(APP_ACTION_NAME(action_load_virtual), Gtk::Stock::OPEN, _("_Load Smartctl Output as Virtual Device..."),
_("Load smartctl output from a text file as a read-only virtual device"));
- actiongroup_main->add((action_map[action_load_virtual] = action), Gtk::AccelKey("O"),
+ actiongroup_main_->add((action_map_[action_load_virtual] = action), Gtk::AccelKey("O"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_load_virtual));
action = Gtk::Action::create(APP_ACTION_NAME(action_rescan_devices), Gtk::Stock::REFRESH, _("_Re-scan Device List"),
_("Re-scan device list"));
- actiongroup_main->add((action_map[action_rescan_devices] = action), Gtk::AccelKey("R"),
+ actiongroup_main_->add((action_map_[action_rescan_devices] = action), Gtk::AccelKey("R"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_rescan_devices));
- actiongroup_main->add(Gtk::Action::create("options_menu", _("_Options")));
+ actiongroup_main_->add(Gtk::Action::create("options_menu", _("_Options")));
action = Gtk::Action::create(APP_ACTION_NAME(action_executor_log), _("View Execution Log"));
- actiongroup_main->add((action_map[action_executor_log] = action),
+ actiongroup_main_->add((action_map_[action_executor_log] = action),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_executor_log));
action = Gtk::Action::create(APP_ACTION_NAME(action_update_drivedb), _("Update Drive Database"));
- actiongroup_main->add((action_map[action_update_drivedb] = action),
+ actiongroup_main_->add((action_map_[action_update_drivedb] = action),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_update_drivedb));
action = Gtk::Action::create(APP_ACTION_NAME(action_preferences), Gtk::Stock::PREFERENCES);
- actiongroup_main->add((action_map[action_preferences] = action), Gtk::AccelKey("P"),
+ actiongroup_main_->add((action_map_[action_preferences] = action), Gtk::AccelKey("P"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_preferences));
- actiongroup_main->add(Gtk::Action::create("help_menu", _("_Help")));
+ actiongroup_main_->add(Gtk::Action::create("help_menu", _("_Help")));
action = Gtk::Action::create(APP_ACTION_NAME(action_online_documentation), Gtk::Stock::HELP);
- actiongroup_main->add((action_map[action_online_documentation] = action), Gtk::AccelKey("F1"),
+ actiongroup_main_->add((action_map_[action_online_documentation] = action), Gtk::AccelKey("F1"),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_online_documentation));
action = Gtk::Action::create(APP_ACTION_NAME(action_support), _("Support"));
- actiongroup_main->add((action_map[action_support] = action),
+ actiongroup_main_->add((action_map_[action_support] = action),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_support));
action = Gtk::Action::create(APP_ACTION_NAME(action_about), Gtk::Stock::ABOUT);
- actiongroup_main->add((action_map[action_about] = action),
+ actiongroup_main_->add((action_map_[action_about] = action),
sigc::bind(sigc::mem_fun(*this, &GscMainWindow::on_action_activated), action_about));
// create uimanager
- ui_manager = Gtk::UIManager::create();
- ui_manager->insert_action_group(actiongroup_main);
- ui_manager->insert_action_group(actiongroup_device);
+ ui_manager_ = Gtk::UIManager::create();
+ ui_manager_->insert_action_group(actiongroup_main_);
+ ui_manager_->insert_action_group(actiongroup_device_);
// add accelerator group to our window so that they work
- add_accel_group(ui_manager->get_accel_group());
+ add_accel_group(ui_manager_->get_accel_group());
try {
- ui_manager->add_ui_from_string(ui_info);
+ ui_manager_->add_ui_from_string(ui_info);
}
catch(Glib::Error& ex)
{
@@ -399,14 +401,14 @@ bool GscMainWindow::create_widgets()
// add some more accelerators (in addition to existing ones)
- Gtk::Widget* rescan_item = ui_manager->get_widget("/main_menubar/device_menu/" APP_ACTION_NAME(action_rescan_devices));
+ Gtk::Widget* rescan_item = ui_manager_->get_widget("/main_menubar/device_menu/" APP_ACTION_NAME(action_rescan_devices));
if (rescan_item)
rescan_item->add_accelerator("activate", get_accel_group(), GDK_KEY_F5, Gdk::ModifierType(0), Gtk::AccelFlags(0));
// look after the created widgets
auto* menubar_vbox = lookup_widget("menubar_vbox");
- Gtk::Widget* menubar = ui_manager->get_widget("/main_menubar");
+ Gtk::Widget* menubar = ui_manager_->get_widget("/main_menubar");
if (menubar_vbox && menubar) {
menubar_vbox->pack_start(*menubar, Gtk::PACK_EXPAND_WIDGET);
menubar->set_hexpand(true);
@@ -416,7 +418,7 @@ bool GscMainWindow::create_widgets()
// Set tooltips on menu items - gtk does that only on toolbar items.
Glib::ustring tooltip_text;
- std::vector > groups = ui_manager->get_action_groups();
+ std::vector > groups = ui_manager_->get_action_groups();
for (auto& group : groups) {
std::vector > actions = group->get_actions();
for (auto& group_action : actions) {
@@ -434,25 +436,25 @@ bool GscMainWindow::create_widgets()
// create and add labels
auto* name_label_box = lookup_widget("status_name_label_hbox");
- name_label = Gtk::manage(new Gtk::Label(_("No drive selected"), Gtk::ALIGN_START));
- name_label->set_line_wrap(true);
- name_label->set_selectable(true);
- name_label->show();
- name_label_box->pack_start(*name_label, true, true);
+ name_label_ = Gtk::manage(new Gtk::Label(_("No drive selected"), Gtk::ALIGN_START));
+ name_label_->set_line_wrap(true);
+ name_label_->set_selectable(true);
+ name_label_->show();
+ name_label_box->pack_start(*name_label_, true, true);
auto* health_label_box = lookup_widget("status_health_label_hbox");
- health_label = Gtk::manage(new Gtk::Label(_("No drive selected"), Gtk::ALIGN_START));
- health_label->set_line_wrap(true);
- health_label->set_selectable(true);
- health_label->show();
- health_label_box->pack_start(*health_label, true, true);
+ health_label_ = Gtk::manage(new Gtk::Label(_("No drive selected"), Gtk::ALIGN_START));
+ health_label_->set_line_wrap(true);
+ health_label_->set_selectable(true);
+ health_label_->show();
+ health_label_box->pack_start(*health_label_, true, true);
auto* family_label_box = lookup_widget("status_family_label_hbox");
- family_label = Gtk::manage(new Gtk::Label(_("No drive selected"), Gtk::ALIGN_START));
- family_label->set_line_wrap(true);
- family_label->set_selectable(true);
- family_label->show();
- family_label_box->pack_start(*family_label, true, true);
+ family_label_ = Gtk::manage(new Gtk::Label(_("No drive selected"), Gtk::ALIGN_START));
+ family_label_->set_line_wrap(true);
+ family_label_->set_selectable(true);
+ family_label_->show();
+ family_label_box->pack_start(*family_label_, true, true);
return true;
}
@@ -489,12 +491,12 @@ void GscMainWindow::on_action_activated(GscMainWindow::action_t action_type)
if (!this->action_handling_enabled_) // check if we should do something
return;
- if (action_map.find(action_type) == action_map.end()) {
+ if (action_map_.find(action_type) == action_map_.end()) {
debug_out_error("app", DBG_FUNC_MSG << "Invalid action activated: " << static_cast(action_type) << ".\n");
return;
}
- Glib::RefPtr action = action_map[action_type];
+ Glib::RefPtr action = action_map_[action_type];
if (!action) {
debug_out_error("app", DBG_FUNC_MSG << "Action is NULL for action type " << static_cast(action_type) << ".\n");
return;
@@ -513,18 +515,18 @@ void GscMainWindow::on_action_activated(GscMainWindow::action_t action_type)
break;
case action_view_details:
- if (iconview)
- this->show_device_info_window(iconview->get_selected_drive());
+ if (iconview_)
+ this->show_device_info_window(iconview_->get_selected_drive());
break;
case action_enable_smart: // this may be invoked on menu manipulation
on_action_enable_smart_toggled(dynamic_cast(
- actiongroup_device->get_action(APP_ACTION_NAME(action_enable_smart)).operator->()));
+ actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_smart)).operator->()));
break;
case action_enable_aodc: // this may be invoked on menu manipulation
on_action_enable_aodc_toggled(dynamic_cast(
- actiongroup_device->get_action(APP_ACTION_NAME(action_enable_aodc)).operator->()));
+ actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_aodc)).operator->()));
break;
case action_reread_device_data:
@@ -532,26 +534,26 @@ void GscMainWindow::on_action_activated(GscMainWindow::action_t action_type)
break;
case action_perform_tests:
- if (iconview) {
- GscInfoWindow* win = this->show_device_info_window(iconview->get_selected_drive());
+ if (iconview_) {
+ GscInfoWindow* win = this->show_device_info_window(iconview_->get_selected_drive());
if (win) // won't be created if test is already running
win->show_tests();
}
break;
case action_remove_device:
- if (iconview) {
- StorageDevicePtr drive = iconview->get_selected_drive();
+ if (iconview_) {
+ StorageDevicePtr drive = iconview_->get_selected_drive();
if (drive && drive->get_is_manually_added() && !drive->get_test_is_active())
- iconview->remove_selected_drive();
+ iconview_->remove_selected_drive();
}
break;
case action_remove_virtual_device:
- if (iconview) {
- StorageDevicePtr drive = iconview->get_selected_drive();
+ if (iconview_) {
+ StorageDevicePtr drive = iconview_->get_selected_drive();
if (drive && drive->get_is_virtual())
- iconview->remove_selected_drive();
+ iconview_->remove_selected_drive();
}
break;
@@ -623,12 +625,12 @@ void GscMainWindow::on_action_activated(GscMainWindow::action_t action_type)
void GscMainWindow::on_action_enable_smart_toggled(Gtk::ToggleAction* action)
{
- if (!action || !iconview)
+ if (!action || !iconview_)
return;
if (!action->get_sensitive()) // it's insensitive, nothing to do (this shouldn't happen).
return;
- StorageDevicePtr drive = iconview->get_selected_drive();
+ StorageDevicePtr drive = iconview_->get_selected_drive();
// we should be protected from these by disabled actions, but still...
if (!drive || drive->get_is_virtual() || drive->get_test_is_active())
@@ -661,12 +663,12 @@ void GscMainWindow::on_action_enable_smart_toggled(Gtk::ToggleAction* action)
void GscMainWindow::on_action_enable_aodc_toggled(Gtk::ToggleAction* action)
{
- if (!action || !iconview)
+ if (!action || !iconview_)
return;
if (!action->get_sensitive()) // it's insensitive, nothing to do (this shouldn't happen).
return;
- StorageDevicePtr drive = iconview->get_selected_drive();
+ StorageDevicePtr drive = iconview_->get_selected_drive();
// we should be protected from these by disabled actions, but still...
if (!drive || drive->get_is_virtual() || drive->get_test_is_active())
@@ -767,10 +769,10 @@ void GscMainWindow::on_action_enable_aodc_toggled(Gtk::ToggleAction* action)
void GscMainWindow::on_action_reread_device_data()
{
- if (!iconview)
+ if (!iconview_)
return;
- StorageDevicePtr drive = iconview->get_selected_drive();
+ StorageDevicePtr drive = iconview_->get_selected_drive();
if (!drive->get_is_virtual() && !drive->get_test_is_active()) { // disallow on virtual and testing
std::shared_ptr ex(new SmartctlExecutorGui());
@@ -790,12 +792,12 @@ void GscMainWindow::on_action_reread_device_data()
Gtk::Menu* GscMainWindow::get_popup_menu(const StorageDevicePtr& drive)
{
- if (!ui_manager)
+ if (!ui_manager_)
return nullptr;
if (drive) {
- return dynamic_cast(ui_manager->get_widget("/device_popup"));
+ return dynamic_cast(ui_manager_->get_widget("/device_popup"));
}
- return dynamic_cast(ui_manager->get_widget("/empty_area_popup"));
+ return dynamic_cast(ui_manager_->get_widget("/empty_area_popup"));
}
@@ -810,12 +812,12 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
// if no drive is selected or if a test is being run on selected drive, disallow.
if (!drive || drive->get_test_is_active()) {
- actiongroup_device->set_sensitive(false);
+ actiongroup_device_->set_sensitive(false);
break; // nothing else to do here
}
// make everything sensitive, then disable one by one
- actiongroup_device->set_sensitive(true);
+ actiongroup_device_->set_sensitive(true);
bool is_virtual = (drive && drive->get_is_virtual());
@@ -833,20 +835,20 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
{
Glib::RefPtr action;
- if ((action = actiongroup_device->get_action(APP_ACTION_NAME(action_perform_tests))))
+ if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_perform_tests))))
action->set_sensitive(smart_status == StorageDevice::Status::enabled);
- if ((action = actiongroup_device->get_action(APP_ACTION_NAME(action_reread_device_data))))
+ 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)))) {
+ 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)))) {
+ if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_smart)))) {
action->set_sensitive(smart_status != StorageDevice::Status::unsupported);
}
- if ((action = actiongroup_device->get_action(APP_ACTION_NAME(action_enable_aodc))))
+ if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_aodc))))
action->set_sensitive(aodc_status != StorageDevice::Status::unsupported);
}
@@ -854,7 +856,7 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
// smart toggle status
{
Gtk::ToggleAction* action = dynamic_cast(
- actiongroup_device->get_action(APP_ACTION_NAME(action_enable_smart)).operator->());
+ actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_smart)).operator->());
if (action) {
action->set_active(smart_status == StorageDevice::Status::enabled);
}
@@ -864,12 +866,12 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
// aodc toggle status
{
Gtk::ToggleAction* action = dynamic_cast(
- actiongroup_device->get_action(APP_ACTION_NAME(action_enable_aodc)).operator->());
+ actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_aodc)).operator->());
if (action) {
- Gtk::CheckMenuItem* dev_odc_item = dynamic_cast(ui_manager->get_widget(
+ Gtk::CheckMenuItem* dev_odc_item = dynamic_cast(ui_manager_->get_widget(
"/main_menubar/device_menu/" APP_ACTION_NAME(action_enable_aodc)));
- Gtk::CheckMenuItem* popup_odc_item = dynamic_cast(ui_manager->get_widget(
+ Gtk::CheckMenuItem* popup_odc_item = dynamic_cast(ui_manager_->get_widget(
"/device_popup/" APP_ACTION_NAME(action_enable_aodc)));
auto* status_aodc_check = lookup_widget("status_aodc_enabled_check");
@@ -898,7 +900,7 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
// update statusbar with selected drive info
void GscMainWindow::update_status_widgets()
{
- if (!iconview)
+ if (!iconview_)
return;
// Gtk::Label* name_label = this->lookup_widget("status_name_label");
@@ -906,14 +908,14 @@ void GscMainWindow::update_status_widgets()
// Gtk::Label* family_label = this->lookup_widget("status_family_label");
// Gtk::Statusbar* statusbar = this->lookup_widget("window_statusbar");
- StorageDevicePtr drive = iconview->get_selected_drive();
+ StorageDevicePtr drive = iconview_->get_selected_drive();
if (!drive) {
- if (name_label)
- name_label->set_text(_("No drive selected"));
- if (health_label)
- health_label->set_text(_("No drive selected"));
- if (family_label)
- family_label->set_text(_("No drive selected"));
+ if (name_label_)
+ name_label_->set_text(_("No drive selected"));
+ if (health_label_)
+ health_label_->set_text(_("No drive selected"));
+ if (family_label_)
+ family_label_->set_text(_("No drive selected"));
// if (statusbar)
// statusbar->pop();
return;
@@ -934,19 +936,19 @@ void GscMainWindow::update_status_widgets()
+ (drive_letters_str.empty() ? "" : (" (" + drive_letters_str + ")"))
+ (size.empty() ? "" : (", " + size))
+ (model.empty() ? "" : (", " + model));
- if (name_label) {
- name_label->set_markup(info_str);
- app_gtkmm_set_widget_tooltip(*name_label, info_str, false); // in case it doesn't fit
+ if (name_label_) {
+ name_label_->set_markup(info_str);
+ app_gtkmm_set_widget_tooltip(*name_label_, info_str, false); // in case it doesn't fit
}
StorageProperty health_prop = drive->get_health_property();
- if (health_label) {
+ if (health_label_) {
if (health_prop.generic_name == "overall_health") {
- health_label->set_text(health_prop.format_value());
+ health_label_->set_text(health_prop.format_value());
std::string fg;
if (app_property_get_label_highlight_color(health_prop.warning, fg)) {
- health_label->set_markup(""+ health_label->get_text() + "");
+ health_label_->set_markup(""+ health_label_->get_text() + "");
}
// don't set description tooltip - we already have the basic one.
// unless it's failing.
@@ -955,17 +957,17 @@ void GscMainWindow::update_status_widgets()
if (health_prop.warning != WarningLevel::none) {
std::string tooltip_str = storage_property_get_warning_reason(health_prop)
+ "\n\n" + _("View details for more information.");
- app_gtkmm_set_widget_tooltip(*health_label, tooltip_str, true);
+ app_gtkmm_set_widget_tooltip(*health_label_, tooltip_str, true);
}
} else {
- health_label->set_text(C_("health_status", "Unknown"));
+ health_label_->set_text(C_("health_status", "Unknown"));
}
}
- if (family_label) {
- family_label->set_text(family);
- app_gtkmm_set_widget_tooltip(*family_label, family, false); // in case it doesn't fit
+ if (family_label_) {
+ family_label_->set_text(family);
+ app_gtkmm_set_widget_tooltip(*family_label_, family, false); // in case it doesn't fit
}
// std::string status_str = " " + device + (size.empty() ? "" : (", " + size)) + (family_fallback.empty() ? "" : (", " + family_fallback));
@@ -1010,13 +1012,13 @@ void GscMainWindow::rescan_devices()
// hz::string_split(match_str, ';', match_patterns, true);
hz::string_split(blacklist_str, ';', blacklist_patterns, true);
- iconview->set_empty_view_message(GscMainWindowIconView::Message::scanning);
+ iconview_->set_empty_view_message(GscMainWindowIconView::Message::scanning);
- iconview->clear_all(); // clear previous icons, invalidate region to update the message.
+ iconview_->clear_all(); // clear previous icons, invalidate region to update the message.
while (Gtk::Main::events_pending()) // give expose event the time it needs
Gtk::Main::iteration();
- this->drives.clear();
+ this->drives_.clear();
// populate the icon area with drive icons
StorageDetector sd;
@@ -1026,7 +1028,7 @@ void GscMainWindow::rescan_devices()
auto ex_factory = std::make_shared(true, this); // run it with GUI support
- std::string error_msg = sd.detect_and_fetch_basic_data(drives, ex_factory);
+ std::string error_msg = sd.detect_and_fetch_basic_data(drives_, ex_factory);
bool error = false;
@@ -1053,19 +1055,19 @@ void GscMainWindow::rescan_devices()
// add them anyway, in case the error was only on one drive.
} else { // if (!error) {
// add them to iconview
- for (auto& drive : drives) {
+ for (auto& drive : drives_) {
if (rconfig::get_data("gui/show_smart_capable_only")) {
if (drive->get_smart_status() != StorageDevice::Status::unsupported)
- iconview->add_entry(drive);
+ iconview_->add_entry(drive);
} else {
- iconview->add_entry(drive);
+ iconview_->add_entry(drive);
}
}
}
// in case there are no drives in the system.
- if (iconview->get_num_icons() == 0)
- iconview->set_empty_view_message(GscMainWindowIconView::Message::no_drives_found);
+ if (iconview_->get_num_icons() == 0)
+ iconview_->set_empty_view_message(GscMainWindowIconView::Message::no_drives_found);
this->scanning_ = false;
}
@@ -1082,9 +1084,8 @@ void GscMainWindow::run_update_drivedb()
}
hz::fs::path update_binary_path = hz::fs::u8path("update-smart-drivedb");
- auto smartctl_path = smartctl_binary;
- if (smartctl_path.is_absolute()) {
- update_binary_path = smartctl_path.parent_path() / update_binary_path;
+ if (smartctl_binary.is_absolute()) {
+ update_binary_path = smartctl_binary.parent_path() / update_binary_path;
}
std::string update_binary = Glib::shell_quote(update_binary_path.u8string());
@@ -1129,8 +1130,8 @@ bool GscMainWindow::add_device(const std::string& file, const std::string& type_
gsc_executor_error_dialog_show(_("An error occurred while adding the device"), error_msg, this);
} else {
- this->drives.push_back(drive);
- this->iconview->add_entry(drive, true); // add it, scroll and select it.
+ this->drives_.push_back(drive);
+ this->iconview_->add_entry(drive, true); // add it, scroll and select it.
}
return true;
@@ -1162,9 +1163,9 @@ bool GscMainWindow::add_virtual_drive(const std::string& file)
return false;
}
- this->drives.push_back(drive);
+ this->drives_.push_back(drive);
- this->iconview->add_entry(drives.back(), true); // add it, scroll and select it.
+ this->iconview_->add_entry(drives_.back(), true); // add it, scroll and select it.
return true;
}
@@ -1174,12 +1175,11 @@ bool GscMainWindow::add_virtual_drive(const std::string& file)
bool GscMainWindow::testing_active() const
{
- for (const auto& drive : drives) {
- if (drive && drive->get_test_is_active()) {
- return true;
- }
- }
- return false;
+ return std::all_of(drives_.cbegin(), drives_.cend(),
+ [](const auto& drive)
+ {
+ return drive && drive->get_test_is_active();
+ });
}
@@ -1261,8 +1261,8 @@ GscInfoWindow* GscMainWindow::show_device_info_window(const StorageDevicePtr& dr
void GscMainWindow::show_prefs_updated_message()
{
- iconview->set_empty_view_message(GscMainWindowIconView::Message::please_rescan);
- iconview->clear_all(); // the message won't be shown without invalidating the region.
+ iconview_->set_empty_view_message(GscMainWindowIconView::Message::please_rescan);
+ iconview_->clear_all(); // the message won't be shown without invalidating the region.
while (Gtk::Main::events_pending()) // give expose event the time it needs
Gtk::Main::iteration();
}
@@ -1304,7 +1304,7 @@ void GscMainWindow::show_load_virtual_file_chooser()
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), specific_filter->gobj());
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), all_filter->gobj());
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog.get()), true);
+ gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog.get()), TRUE);
if (!last_dir.empty()) {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog.get()), last_dir.c_str());
diff --git a/src/gsc_main_window.h b/src/gsc_main_window.h
index 459506d..9f8314f 100644
--- a/src/gsc_main_window.h
+++ b/src/gsc_main_window.h
@@ -155,18 +155,18 @@ class GscMainWindow : public AppBuilderWidget {
private:
- GscMainWindowIconView* iconview = nullptr; ///< The main icon view
- std::vector drives; ///< Scanned drives
+ GscMainWindowIconView* iconview_ = nullptr; ///< The main icon view
+ std::vector drives_; ///< Scanned drives
- Glib::RefPtr ui_manager; ///< UI manager
- Glib::RefPtr actiongroup_main; ///< Action group
- Glib::RefPtr actiongroup_device; ///< Action group
+ Glib::RefPtr ui_manager_; ///< UI manager
+ Glib::RefPtr actiongroup_main_; ///< Action group
+ Glib::RefPtr actiongroup_device_; ///< Action group
bool action_handling_enabled_ = true; ///< Whether action handling is enabled or not
- std::map > action_map; ///< Used by on_action_activated().
+ std::map > action_map_; ///< Used by on_action_activated().
- Gtk::Label* name_label = nullptr; ///< A UI label
- Gtk::Label* health_label = nullptr; ///< A UI label
- Gtk::Label* family_label = nullptr; ///< A UI label
+ Gtk::Label* name_label_ = nullptr; ///< A UI label
+ Gtk::Label* health_label_ = nullptr; ///< A UI label
+ Gtk::Label* family_label_ = nullptr; ///< A UI label
bool scanning_ = false; ///< If the scanning is in process or not
diff --git a/src/gsc_preferences_window.cpp b/src/gsc_preferences_window.cpp
index a570b0d..1dfde6e 100644
--- a/src/gsc_preferences_window.cpp
+++ b/src/gsc_preferences_window.cpp
@@ -79,7 +79,7 @@ class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
/// Remove selected row
void remove_selected_row()
{
- if (this->get_selection()->count_selected_rows()) {
+ if (this->get_selection()->count_selected_rows() > 0) {
Gtk::TreeIter iter = this->get_selection()->get_selected();
model->erase(iter);
}
@@ -104,7 +104,7 @@ class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
/// Update selected row device entry
void update_selected_row_device(const std::string& device)
{
- if (this->get_selection()->count_selected_rows()) {
+ if (this->get_selection()->count_selected_rows() > 0) {
Gtk::TreeRow row = *(this->get_selection()->get_selected());
row[col_device] = (device.empty() ? "<"s + C_("name", "empty") + ">" : device);
row[col_device_real] = device;
@@ -115,7 +115,7 @@ class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
/// Update selected row type entry
void update_selected_row_type(const std::string& type)
{
- if (this->get_selection()->count_selected_rows()) {
+ if (this->get_selection()->count_selected_rows() > 0) {
Gtk::TreeRow row = *(this->get_selection()->get_selected());
row[col_type] = (type.empty() ? "<"s + C_("types", "all") + ">" : type);
row[col_type_real] = type;
@@ -126,7 +126,7 @@ class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
/// Update selected row parameters entry
void update_selected_row_params(const std::string& params)
{
- if (this->get_selection()->count_selected_rows()) {
+ if (this->get_selection()->count_selected_rows() > 0) {
Gtk::TreeRow row = *(this->get_selection()->get_selected());
row[col_parameters] = params;
}
@@ -184,7 +184,7 @@ class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
void on_selection_changed()
{
std::string dev, type, par;
- if (this->get_selection()->count_selected_rows()) {
+ if (this->get_selection()->count_selected_rows() > 0) {
Gtk::TreeRow row = *(this->get_selection()->get_selected());
dev = row[col_device_real];
type = row[col_type_real];
diff --git a/src/gsc_text_window.h b/src/gsc_text_window.h
index bfd83e3..2b68c78 100644
--- a/src/gsc_text_window.h
+++ b/src/gsc_text_window.h
@@ -153,7 +153,7 @@ class GscTextWindow : public AppBuilderWidget, Ins
_("Save Data As..."), this->gobj(), GTK_FILE_CHOOSER_ACTION_SAVE, nullptr, nullptr),
&g_object_unref);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), true);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog.get()), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), specific_filter->gobj());
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog.get()), all_filter->gobj());