Added tooltips to both the labels and the entries in Add Device and Preferences

dialogs.
Changed the tooltips to avoid showing unsupported values for that OS.
Fixed usb drive re-detection with scsi (regression from previous commit).
Fixed invalid regexps in tw_cli output parsing (fixes 3ware in windows).
Added support for "Product" field of USB drives (used instead of Device in
newer smartctl).
This commit is contained in:
Alexander Shaduri
2011-04-18 12:14:20 +00:00
parent ff466a1d2d
commit 8ae3c42100
8 changed files with 111 additions and 69 deletions
+10 -2
View File
@@ -36,14 +36,22 @@ Bugs / patches:
TODO:
Add debian/ubuntu's su-to-root support to gsmartcontrol-root.
Add debian/ubuntu's su-to-root support to gsmartcontrol-root.
Set tooltips wherever we have "No description available".
!!! Allow quitting when test is running (ask first).
+"Add Device" window needs tooltips on both labels and entries.
+ Don't mention -d 3ware on windows in the tooltip.
+ Both points go for the preferences window as well.
+Fixed usb drive re-detection with scsi.
+Fixed invalid regexps in tw_cli parsing.
+Added support for "Product" field of USB drives (used instead of Device in newer smartctl)
Testing:
If ETA time has elapsed, but it's still only at 10% completion,
@@ -109,11 +109,11 @@ std::string execute_smartctl(const std::string& device, const std::string& devic
if (!smartctl_ex->execute() || !smartctl_ex->get_error_msg().empty()) {
debug_out_warn("app", DBG_FUNC_MSG << "Error while executing smartctl binary.\n");
std::string output = smartctl_ex->get_stdout_str();
smartctl_output = smartctl_ex->get_stdout_str();
// check if it's a device permission error.
// Smartctl open device: /dev/sdb failed: Permission denied
if (app_pcre_match("/Smartctl open device.+Permission denied/mi", output)) {
if (app_pcre_match("/Smartctl open device.+Permission denied/mi", smartctl_output)) {
return "Permission denied while opening device.";
}
@@ -116,8 +116,8 @@ std::string get_scan_open_multiport_devices(std::vector<StorageDeviceRefPtr>& dr
// /dev/sda -d sat # /dev/sda [SAT], ATA device
// we only pick the ones with ports
pcrecpp::RE port_re = app_pcre_re("/^(\\/dev/\\[a-z0-9]),([0-9])+[ \\t]+-d[ \\t]+([^\\t\\n]+)/i");
pcrecpp::RE dev_re = app_pcre_re("/^\\/dev\\/sd([a-z])$/");
pcrecpp::RE port_re = app_pcre_re("/^(/dev/[a-z0-9]),([0-9])+[ \\t]+-d[ \\t]+([^\\t\\n]+)/i");
pcrecpp::RE dev_re = app_pcre_re("/^/dev/sd([a-z])$/");
for (std::size_t i = 0; i < lines.size(); ++i) {
std::string dev, port_str, type;
+1 -1
View File
@@ -228,7 +228,7 @@ std::string StorageDevice::parse_basic_data(bool do_set_properties, bool emit_si
if (app_pcre_match("/^Device Model:[ \\t]*(.*)$/mi", info_output_, &model)) { // HD's and cdroms
model_name_ = hz::string_remove_adjacent_duplicates_copy(hz::string_trim_copy(model), ' ');
} else if (app_pcre_match("/^Device:[ \\t]*(.*)$/mi", info_output_, &model)) { // usb flash drives
} else if (app_pcre_match("/^(?:Device|Product):[ \\t]*(.*)$/mi", info_output_, &model)) { // usb flash drives
model_name_ = hz::string_remove_adjacent_duplicates_copy(hz::string_trim_copy(model), ' ');
}
+24 -9
View File
@@ -38,18 +38,33 @@ GscAddDeviceWindow::GscAddDeviceWindow(BaseObjectType* gtkcobj, const app_ui_res
APP_UI_RES_AUTO_CONNECT(device_name_browse_button, clicked);
Glib::ustring device_name_tooltip = "Device name, e.g. %s.";
#ifdef _WIN32
device_name_tooltip = hz::string_sprintf(device_name_tooltip.c_str(), "\"pd0\" for the first physical drive");
#else
device_name_tooltip = hz::string_sprintf(device_name_tooltip.c_str(), "\"/dev/sda\" or \"/dev/twa0\"");
Glib::ustring device_name_tooltip = "Device name";
#if defined CONFIG_KERNEL_FAMILY_WINDOWS
device_name_tooltip = "Device name (for example, use \"pd0\" for the first physical drive)";
#elif defined CONFIG_KERNEL_LINUX
device_name_tooltip = "Device name (for example, /dev/sda or /dev/twa0)";
#endif
Gtk::Label* device_name_label = lookup_widget<Gtk::Label*>("device_name_label");
app_gtkmm_set_widget_tooltip(*device_name_label, device_name_tooltip);
if (Gtk::Label* device_name_label = lookup_widget<Gtk::Label*>("device_name_label")) {
app_gtkmm_set_widget_tooltip(*device_name_label, device_name_tooltip);
}
Gtk::Entry* device_name_entry = 0;
APP_UI_RES_AUTO_CONNECT(device_name_entry, changed);
if (device_name_entry) {
app_gtkmm_set_widget_tooltip(*device_name_entry, device_name_tooltip);
}
Glib::ustring device_type_tooltip = "Smartctl -d option parameter";
#if defined CONFIG_KERNEL_LINUX
device_type_tooltip = "Smartctl -d option parameter. For example, use 3ware,1 for a second drive behind a 3ware RAID controller.";
#endif
if (Gtk::Label* device_type_label = lookup_widget<Gtk::Label*>("device_type_label")) {
app_gtkmm_set_widget_tooltip(*device_type_label, device_type_tooltip);
}
if (Gtk::Entry* device_type_entry = lookup_widget<Gtk::Entry*>("device_type_entry")) {
app_gtkmm_set_widget_tooltip(*device_type_entry, device_type_tooltip);
}
// Accelerators
@@ -61,7 +76,7 @@ GscAddDeviceWindow::GscAddDeviceWindow(BaseObjectType* gtkcobj, const app_ui_res
}
#ifndef _WIN32
#ifdef _WIN32
// "Browse" doesn't make sense in win32, hide it.
if (device_name_browse_button) {
device_name_browse_button->hide();
+26 -7
View File
@@ -240,20 +240,39 @@ GscPreferencesWindow::GscPreferencesWindow(BaseObjectType* gtkcobj, const app_ui
Gtk::Button* device_options_remove_device_button = 0;
APP_UI_RES_AUTO_CONNECT(device_options_remove_device_button, clicked);
Gtk::Entry* device_options_device_entry = 0;
APP_UI_RES_AUTO_CONNECT(device_options_device_entry, changed);
Glib::ustring device_options_tooltip = "Device name, e.g. %s.";
#ifdef _WIN32
device_options_tooltip = hz::string_sprintf(device_options_tooltip.c_str(), "\"pd0\" for the first physical drive");
#else
device_options_tooltip = hz::string_sprintf(device_options_tooltip.c_str(), "\"/dev/sda\"");
Glib::ustring device_options_tooltip = "Device name";
#if defined CONFIG_KERNEL_FAMILY_WINDOWS
device_options_tooltip = "Device name (for example, use \"pd0\" for the first physical drive)";
#elif defined CONFIG_KERNEL_LINUX
device_options_tooltip = "Device name (for example, /dev/sda or /dev/twa0)";
#endif
Gtk::Label* device_options_device_label = lookup_widget<Gtk::Label*>("device_options_device_label");
app_gtkmm_set_widget_tooltip(*device_options_device_label, device_options_tooltip);
if (Gtk::Label* device_options_device_label = lookup_widget<Gtk::Label*>("device_options_device_label")) {
app_gtkmm_set_widget_tooltip(*device_options_device_label, device_options_tooltip);
}
if (device_options_device_entry) {
app_gtkmm_set_widget_tooltip(*device_options_device_entry, device_options_tooltip);
}
Gtk::Entry* device_options_type_entry = 0;
APP_UI_RES_AUTO_CONNECT(device_options_type_entry, changed);
Glib::ustring device_type_tooltip = "Match only this type of device (as specified to -d smartctl parameter)";
#if defined CONFIG_KERNEL_LINUX
device_type_tooltip = "Match only this type of device (as specified to -d smartctl parameter). Leave empty for all types. This can be used to specify a drive behind a RAID device, e.g. \"3ware,2\".";
#endif
if (Gtk::Label* device_options_type_label = lookup_widget<Gtk::Label*>("device_options_type_label")) {
app_gtkmm_set_widget_tooltip(*device_options_type_label, device_type_tooltip);
}
if (device_options_type_entry) {
app_gtkmm_set_widget_tooltip(*device_options_type_entry, device_type_tooltip);
}
Gtk::Entry* device_options_parameter_entry = 0;
APP_UI_RES_AUTO_CONNECT(device_options_parameter_entry, changed);
@@ -19,44 +19,31 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkEntry" id="smartctl_params_entry">
<widget class="GtkComboBoxEntry" id="device_type_combo">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<child internal-child="entry">
<widget class="GtkEntry" id="device_type_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<widget class="GtkLabel" id="device_name_label">
<property name="visible">True</property>
<property name="tooltip_text">Additional smartctl parameters</property>
<property name="tooltip" translatable="yes">Additional smartctl parameters</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Smartctl parameters:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="tooltip_text">Smartctl -d option, e.g. 3ware,2 for a third drive behind a 3ware RAID controller</property>
<property name="tooltip" translatable="yes">Smartctl -d option, e.g. 3ware,2 for a third drive behind a 3ware RAID controller</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Device _type:</property>
<property name="label" translatable="yes">Device _name:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@@ -93,32 +80,45 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="device_name_label">
<widget class="GtkLabel" id="device_type_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Device _name:</property>
<property name="label" translatable="yes">Device _type:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkComboBoxEntry" id="device_type_combo">
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<child internal-child="entry">
<widget class="GtkEntry" id="device_type_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
</child>
<property name="tooltip_text">Additional smartctl parameters</property>
<property name="tooltip" translatable="yes">Additional smartctl parameters</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Smartctl parameters:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="smartctl_params_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text">Additional smartctl parameters</property>
<property name="tooltip" translatable="yes">Additional smartctl parameters</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</widget>
@@ -171,8 +171,8 @@
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="tooltip_text">Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl.</property>
<property name="tooltip" translatable="yes">Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl.</property>
<property name="tooltip_text">Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl. Must be shell-escaped.</property>
<property name="tooltip" translatable="yes">Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl. Must be shell-escaped.</property>
<property name="label" translatable="yes">Smartctl parameters:</property>
<property name="use_underline">True</property>
</widget>
@@ -185,8 +185,8 @@
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="tooltip_text">A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's $PATH.</property>
<property name="tooltip" translatable="yes">A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's $PATH.</property>
<property name="tooltip_text">A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's PATH.</property>
<property name="tooltip" translatable="yes">A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's PATH.</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">S_martctl binary:</property>
<property name="use_underline">True</property>
@@ -399,6 +399,8 @@
<widget class="GtkEntry" id="device_options_parameter_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text">Smartctl parameters (for example, "-T permissive" or "-d usbsunplus")</property>
<property name="tooltip" translatable="yes">Smartctl parameters (for example, "-T permissive" or "-d usbsunplus")</property>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -410,8 +412,8 @@
<child>
<widget class="GtkLabel" id="label67">
<property name="visible">True</property>
<property name="tooltip_text">Smartctl parameters for this device. For example, to use older smartctl versions with libata devices, use "-d ata".</property>
<property name="tooltip" translatable="yes">Smartctl parameters for this device. For example, to use older smartctl versions with libata devices, use "-d ata".</property>
<property name="tooltip_text">Smartctl parameters (for example, "-T permissive" or "-d usbsunplus")</property>
<property name="tooltip" translatable="yes">Smartctl parameters (for example, "-T permissive" or "-d usbsunplus")</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Parameters:</property>
<property name="use_underline">True</property>
@@ -446,10 +448,8 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label66">
<widget class="GtkLabel" id="device_options_type_label">
<property name="visible">True</property>
<property name="tooltip_text">Match only this type of device (as specified to -d smartctl parameter). Leave empty for all types. This can be used to specify a drive behind a RAID device, e.g. 3ware,2.</property>
<property name="tooltip" translatable="yes">Match only this type of device (as specified to -d smartctl parameter). Leave empty for all types. This can be used to specify a drive behind a RAID device, e.g. 3ware,2.</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">_Type:</property>
<property name="use_underline">True</property>