mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-27 14:25:34 +00:00
Implemented "Update Drive Database" item in main window menu.
This commit is contained in:
@@ -30,20 +30,12 @@ Add ability (through ctrl-C?) to copy selected rows from attributes and statisti
|
||||
in tab-separated format (for easy pasting into libreoffice).
|
||||
|
||||
|
||||
Add menu item - "update drive database"
|
||||
Run it in terminal in Linux for verbosity.
|
||||
xterm -hold -e 'update-smart-drivedb'
|
||||
require xterm in rpm/deb deps.
|
||||
|
||||
|
||||
Testing:
|
||||
If ETA time has elapsed, but it's still only at 10% completion,
|
||||
ETA 0 is displayed. Fix.
|
||||
Detect running tests on launch (maybe ask the user too? some tests
|
||||
may be stuck due to bad firmware, e.g. 3ware/windows).
|
||||
|
||||
Parse "==> WARNING"
|
||||
|
||||
|
||||
Parse all test data.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Standards-Version: 3.7.3
|
||||
|
||||
Package: gsmartcontrol
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, smartmontools (>= 5.43), menu
|
||||
Depends: ${shlibs:Depends}, smartmontools (>= 5.43), xterm, menu
|
||||
Description: Hard disk drive and SSD health inspection tool
|
||||
GSmartControl is a graphical user interface for smartctl (from smartmontools
|
||||
package), which is a tool for querying and controlling SMART
|
||||
|
||||
@@ -24,7 +24,7 @@ Group: Hardware/Other
|
||||
# SUSE / OpenSUSE. SLES also defines the correct suse_version.
|
||||
%if 0%{?suse_version}
|
||||
|
||||
Requires: smartmontools >= 5.43, polkit, bash
|
||||
Requires: smartmontools >= 5.43, polkit, bash, xterm
|
||||
BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm3-devel >= 3.4.0
|
||||
BuildRequires: update-desktop-files
|
||||
BuildRequires: fdupes
|
||||
@@ -35,7 +35,7 @@ BuildRequires: fdupes
|
||||
# Fedora, CentOS, RHEL
|
||||
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
|
||||
|
||||
Requires: smartmontools >= 5.43, polkit, bash
|
||||
Requires: smartmontools >= 5.43, polkit, bash, xterm
|
||||
BuildRequires: gcc-c++, pcre-devel, gtkmm30-devel >= 3.4.0
|
||||
|
||||
%endif
|
||||
|
||||
@@ -262,6 +262,7 @@ bool GscMainWindow::create_widgets()
|
||||
|
||||
" <menu action='options_menu'>"
|
||||
" <menuitem action='" APP_ACTION_NAME(action_executor_log) "' />"
|
||||
" <menuitem action='" APP_ACTION_NAME(action_update_drivedb) "' />"
|
||||
" <menuitem action='" APP_ACTION_NAME(action_preferences) "' />"
|
||||
" </menu>"
|
||||
|
||||
@@ -369,6 +370,10 @@ bool GscMainWindow::create_widgets()
|
||||
actiongroup_main->add((action_map[action_executor_log] = action),
|
||||
sigc::bind(sigc::mem_fun(*this, &self_type::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),
|
||||
sigc::bind(sigc::mem_fun(*this, &self_type::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("<alt>P"),
|
||||
sigc::bind(sigc::mem_fun(*this, &self_type::on_action_activated), action_preferences));
|
||||
@@ -602,6 +607,12 @@ void GscMainWindow::on_action_activated(GscMainWindow::action_t action_type)
|
||||
break;
|
||||
}
|
||||
|
||||
case action_update_drivedb:
|
||||
{
|
||||
run_update_drivedb();
|
||||
break;
|
||||
}
|
||||
|
||||
case action_preferences:
|
||||
{
|
||||
GscPreferencesWindow* win = GscPreferencesWindow::create(); // destroyed on close
|
||||
@@ -1125,6 +1136,35 @@ void GscMainWindow::rescan_devices()
|
||||
|
||||
|
||||
|
||||
void GscMainWindow::run_update_drivedb()
|
||||
{
|
||||
std::string smartctl_binary = get_smartctl_binary();
|
||||
|
||||
if (smartctl_binary.empty()) {
|
||||
gui_show_error_dialog("Error Updating Drive Database", "Smartctl binary is not specified in configuration.", this);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string update_binary;
|
||||
hz::FsPath path(smartctl_binary);
|
||||
if (path.is_absolute()) {
|
||||
update_binary = path.get_dirname() + "/";
|
||||
}
|
||||
update_binary += "update-smart-drivedb";
|
||||
update_binary = Glib::shell_quote(update_binary);
|
||||
|
||||
#ifndef _WIN32
|
||||
update_binary = "xterm -hold -e " + update_binary;
|
||||
#endif
|
||||
|
||||
hz::scoped_ptr<GError> spawn_error(0, g_error_free);
|
||||
if (!g_spawn_command_line_async(update_binary.c_str(), &spawn_error.get_ref())) {
|
||||
gui_show_error_dialog("Error Updating Drive Database", spawn_error->message, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GscMainWindow::add_device(const std::string& file, const std::string& type_arg, const std::string& extra_args)
|
||||
{
|
||||
#ifndef _WIN32 // win32 doesn't have device files, so skip the check
|
||||
|
||||
@@ -53,6 +53,10 @@ class GscMainWindow : public AppUIResWidget<GscMainWindow, false> {
|
||||
void rescan_devices();
|
||||
|
||||
|
||||
/// Execute update-smart-drivedb
|
||||
void run_update_drivedb();
|
||||
|
||||
|
||||
/// Manually add device file to icon list
|
||||
bool add_device(const std::string& file, const std::string& type_arg, const std::string& extra_args);
|
||||
|
||||
@@ -90,6 +94,7 @@ class GscMainWindow : public AppUIResWidget<GscMainWindow, false> {
|
||||
action_rescan_devices,
|
||||
|
||||
action_executor_log,
|
||||
action_update_drivedb,
|
||||
action_preferences,
|
||||
|
||||
action_general_help,
|
||||
|
||||
Reference in New Issue
Block a user