~ubuntu-branches/debian/sid/gsmartcontrol/sid

« back to all changes in this revision

Viewing changes to src/gsc_info_window.cpp

  • Committer: Package Import Robot
  • Author(s): Giuseppe Iuculano
  • Date: 2013-05-31 11:41:52 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130531114152-5ljhkuswwpt4kdwo
Tags: 0.8.7-1
* [314881d] Updated debian/watch
* [18ebada] Imported Upstream version 0.8.7
* [c2a1f1b] debian/rules: Provide build-arch and build-indep
* [d3036a4] Enabled Hardening Options
* [2edfb87] Refreshed patches and removed patches apllied upstream
* [ac3b953] Bump to standard versions 3.9.4
* [292c276] Remove quilt from depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**************************************************************************
2
2
 Copyright:
3
 
      (C) 2008 - 2011  Alexander Shaduri <ashaduri 'at' gmail.com>
 
3
      (C) 2008 - 2012  Alexander Shaduri <ashaduri 'at' gmail.com>
4
4
 License: See LICENSE_gsmartcontrol.txt
5
5
***************************************************************************/
 
6
/// \file
 
7
/// \author Alexander Shaduri
 
8
/// \ingroup gsc
 
9
/// \weakgroup gsc
 
10
/// @{
6
11
 
7
12
#include <vector>  // better use vector, it's needed by others too
8
13
#include <algorithm>  // std::min, std::max
29
34
 
30
35
 
31
36
 
 
37
/// A label for StorageProperty
32
38
struct PropertyLabel {
 
39
        /// Constructor
33
40
        PropertyLabel(const std::string& label_, const StorageProperty* prop) :
34
41
                label(label_), property(prop)
35
42
        { }
36
43
 
37
 
        std::string label;
38
 
        const StorageProperty* property;
 
44
        std::string label;  ///< Label text
 
45
        const StorageProperty* property;  ///< Storage property
39
46
};
40
47
 
41
48
 
 
49
/// A vector of PropertyLabel objects
42
50
typedef std::vector<PropertyLabel> label_list_t;
43
51
 
44
52
 
47
55
namespace {
48
56
 
49
57
 
 
58
        /// Set "top" labels - the generic text at the top of each tab page.
50
59
        inline void app_set_top_labels(Gtk::VBox* vbox, const label_list_t& label_strings)
51
60
        {
52
61
                if (!vbox)
93
102
 
94
103
 
95
104
 
 
105
        /// Cell renderer functions for attribute cells
96
106
        inline void app_attr_cell_renderer_func(Gtk::CellRenderer* cr, const Gtk::TreeModel::iterator& iter,
97
107
                        Gtk::TreeModelColumn<const StorageProperty*> storage_column)
98
108
        {
115
125
        }
116
126
 
117
127
 
 
128
 
 
129
        /// Highlight a tab label according to \c warning
118
130
        inline void app_highlight_tab_label(Gtk::Widget* label_widget,
119
131
                        StorageProperty::warning_t warning, const Glib::ustring& original_label)
120
132
        {
134
146
 
135
147
 
136
148
 
137
 
        // scroll to appropriate error in text when row is selected in tree.
 
149
        /// Scroll to appropriate error in text when row is selected in tree.
138
150
        inline void on_error_log_treeview_row_selected(GscInfoWindow* window,
139
151
                        Gtk::TreeModelColumn<Glib::ustring> mark_name_column)
140
152
        {
158
170
 
159
171
 
160
172
 
161
 
// glade/gtkbuilder needs this constructor
162
173
GscInfoWindow::GscInfoWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
163
174
                : AppUIResWidget<GscInfoWindow, true>(gtkcobj, ref_ui),
164
175
                device_name_label(0), test_force_bar_update(true)
259
270
 
260
271
 
261
272
 
262
 
 
263
 
 
264
 
// fill the dialog with info from "drive".
 
273
void GscInfoWindow::set_drive(StorageDeviceRefPtr d)
 
274
{
 
275
        if (drive)  // if an old drive is present, disconnect our callback from it.
 
276
                drive_changed_connection.disconnect();
 
277
        drive = d;
 
278
        drive_changed_connection = drive->signal_changed.connect(sigc::mem_fun(this,
 
279
                        &GscInfoWindow::on_drive_changed));
 
280
}
 
281
 
 
282
 
 
283
 
265
284
void GscInfoWindow::fill_ui_with_info(bool scan, bool clear_ui, bool clear_tests)
266
285
{
267
286
        debug_out_info("app", DBG_FUNC_MSG << "Scan " << (scan ? "" : "not ") << "requested.\n");
1238
1257
 
1239
1258
 
1240
1259
 
1241
 
 
1242
 
// show tests tab.
 
1260
void GscInfoWindow::refresh_info(bool clear_tests_too)
 
1261
{
 
1262
        this->set_sensitive(false);  // make insensitive until filled. helps with pressed F5 problem.
 
1263
 
 
1264
        // this->clear_ui_info();  // no need, fill_ui_with_info() will call it.
 
1265
        this->fill_ui_with_info(true, true, clear_tests_too);
 
1266
 
 
1267
        this->set_sensitive(true);  // make sensitive again.
 
1268
}
 
1269
 
 
1270
 
 
1271
 
1243
1272
void GscInfoWindow::show_tests()
1244
1273
{
1245
1274
        Gtk::Notebook* book = lookup_widget<Gtk::Notebook*>("main_notebook");
1261
1290
 
1262
1291
 
1263
1292
 
 
1293
void GscInfoWindow::on_refresh_info_button_clicked()
 
1294
{
 
1295
        this->refresh_info();
 
1296
}
 
1297
 
 
1298
 
1264
1299
 
1265
1300
void GscInfoWindow::on_view_output_button_clicked()
1266
1301
{
1267
1302
        GscTextWindow<SmartctlOutputInstance>* win = GscTextWindow<SmartctlOutputInstance>::create();
1268
1303
        // make save visible and enable monospace font
1269
1304
 
1270
 
        std::string buf_text = this->drive->get_full_output();
1271
 
        // We receive locale'd thousands separators in win32, so convert them.
1272
 
        #ifdef _WIN32
1273
 
        try {
1274
 
                buf_text = Glib::locale_to_utf8(buf_text);
1275
 
        } catch (Glib::ConvertError& e) {
1276
 
                buf_text = "";  // inserting invalid utf8 may trigger a segfault, so empty better.
1277
 
        }
1278
 
        #endif
1279
 
        win->set_text("Smartctl Output", buf_text, true, true);
 
1305
        win->set_text("Smartctl Output", this->drive->get_full_output(), true, true);
1280
1306
 
1281
1307
        std::string filename = drive->get_save_filename();
1282
1308
        if (!filename.empty())
1692
1718
 
1693
1719
 
1694
1720
 
1695
 
 
 
1721
/// @}