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

« back to all changes in this revision

Viewing changes to src/gsc_preferences_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 <map>
8
13
#include <gtkmm/button.h>
27
32
 
28
33
 
29
34
 
 
35
/// Device Options tree view of the Preferences window
30
36
class GscPreferencesDeviceOptionsTreeView : public Gtk::TreeView {
31
37
        public:
32
38
 
33
 
                typedef GscPreferencesDeviceOptionsTreeView self_type;  // needed for CONNECT_VIRTUAL
34
 
 
35
 
                // glade/gtkbuilder needs this constructor
 
39
                typedef GscPreferencesDeviceOptionsTreeView self_type;  ///< Self type, needed for CONNECT_VIRTUAL
 
40
 
 
41
 
 
42
                /// Constructor, gtkbuilder/glade needs this.
36
43
                GscPreferencesDeviceOptionsTreeView(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
37
44
                                : Gtk::TreeView(gtkcobj), preferences_window(0)
38
45
                {
67
74
                }
68
75
 
69
76
 
 
77
                /// Set the parent window
70
78
                void set_preferences_window(GscPreferencesWindow* w)
71
79
                {
72
80
                        preferences_window = w;
73
81
                }
74
82
 
75
83
 
 
84
                /// Remove selected row
76
85
                void remove_selected_row()
77
86
                {
78
87
                        if (this->get_selection()->count_selected_rows()) {
82
91
                }
83
92
 
84
93
 
 
94
                /// Add a new row (for a new device)
85
95
                void add_new_row(const std::string& device, const std::string& type, const std::string& params, bool select = true)
86
96
                {
87
97
                        Gtk::TreeRow row = *(model->append());
96
106
                }
97
107
 
98
108
 
 
109
                /// Update selected row device entry
99
110
                void update_selected_row_device(const std::string& device)
100
111
                {
101
112
                        if (this->get_selection()->count_selected_rows()) {
106
117
                }
107
118
 
108
119
 
 
120
                /// Update selected row type entry
109
121
                void update_selected_row_type(const std::string& type)
110
122
                {
111
123
                        if (this->get_selection()->count_selected_rows()) {
116
128
                }
117
129
 
118
130
 
 
131
                /// Update selected row parameters entry
119
132
                void update_selected_row_params(const std::string& params)
120
133
                {
121
134
                        if (this->get_selection()->count_selected_rows()) {
125
138
                }
126
139
 
127
140
 
 
141
                /// Remove all rows
128
142
                void clear_all()
129
143
                {
130
144
                        model->clear();
131
145
                }
132
146
 
133
147
 
 
148
                /// Check whether there is a row selected
134
149
                bool has_selected_row()
135
150
                {
136
151
                        return this->get_selection()->count_selected_rows();
137
152
                }
138
153
 
139
154
 
 
155
                /// Set the device map (as loaded from config)
140
156
                void set_device_map(const device_option_map_t& devmap)
141
157
                {
142
158
                        clear_all();
151
167
                }
152
168
 
153
169
 
 
170
                /// Get the device map (to be saved to config)
154
171
                device_option_map_t get_device_map()
155
172
                {
156
173
                        device_option_map_t devmap;
175
192
 
176
193
 
177
194
 
178
 
                // callback
 
195
                /// Selection change callback
179
196
                void on_selection_changed()
180
197
                {
181
198
                        std::string dev, type, par;
194
211
                }
195
212
 
196
213
 
197
 
 
198
 
                Glib::RefPtr<Gtk::ListStore> model;
199
 
 
200
 
                Gtk::TreeModelColumn<Glib::ustring> col_device;
201
 
                Gtk::TreeModelColumn<Glib::ustring> col_type;
202
 
                Gtk::TreeModelColumn<std::string> col_parameters;
203
 
                Gtk::TreeModelColumn<std::string> col_device_real;
204
 
                Gtk::TreeModelColumn<std::string> col_type_real;
205
 
 
206
 
                GscPreferencesWindow* preferences_window;
 
214
        private:
 
215
 
 
216
                Glib::RefPtr<Gtk::ListStore> model;  ///< The list model
 
217
 
 
218
                Gtk::TreeModelColumn<Glib::ustring> col_device;  ///< Model column
 
219
                Gtk::TreeModelColumn<Glib::ustring> col_type;  ///< Model column
 
220
                Gtk::TreeModelColumn<std::string> col_parameters;  ///< Model column
 
221
                Gtk::TreeModelColumn<std::string> col_device_real;  ///< Model column
 
222
                Gtk::TreeModelColumn<std::string> col_type_real;  ///< Model column
 
223
 
 
224
                GscPreferencesWindow* preferences_window;  ///< The parent window
207
225
 
208
226
};
209
227
 
338
356
 
339
357
namespace {
340
358
 
 
359
        /// Set configuration in a smart way - don't set the defaults.
341
360
        template<typename T>
342
361
        inline void prefs_config_set(const std::string& path, const T& data)
343
362
        {
358
377
        }
359
378
 
360
379
 
 
380
        /// Get configuration for \c path
361
381
        template<typename T>
362
382
        inline bool prefs_config_get(const std::string& path, T& data)
363
383
        {
392
412
                        && (check = this->lookup_widget<Gtk::CheckButton*>("show_smart_capable_only_check")) )
393
413
                check->set_active(show_smart_capable_only);
394
414
 
 
415
        bool icons_show_device_name = 0;
 
416
        if ( prefs_config_get("gui/icons_show_device_name", icons_show_device_name)
 
417
                        && (check = this->lookup_widget<Gtk::CheckButton*>("show_device_name_under_icon_check")) )
 
418
                check->set_active(icons_show_device_name);
 
419
 
 
420
        bool icons_show_serial_number = 0;
 
421
        if ( prefs_config_get("gui/icons_show_serial_number", icons_show_serial_number)
 
422
                        && (check = this->lookup_widget<Gtk::CheckButton*>("show_serial_number_under_icon_check")) )
 
423
                check->set_active(icons_show_serial_number);
 
424
 
395
425
        bool win32_search_smartctl_in_smartmontools = 0;
396
426
        if ( prefs_config_get("system/win32_search_smartctl_in_smartmontools", win32_search_smartctl_in_smartmontools)
397
427
                        && (check = this->lookup_widget<Gtk::CheckButton*>("search_in_smartmontools_first_check")) )
442
472
        if ((check = this->lookup_widget<Gtk::CheckButton*>("show_smart_capable_only_check")))
443
473
                prefs_config_set("gui/show_smart_capable_only", bool(check->get_active()));
444
474
 
 
475
        if ((check = this->lookup_widget<Gtk::CheckButton*>("show_device_name_under_icon_check")))
 
476
                prefs_config_set("gui/icons_show_device_name", bool(check->get_active()));
 
477
 
 
478
        if ((check = this->lookup_widget<Gtk::CheckButton*>("show_serial_number_under_icon_check")))
 
479
                prefs_config_set("gui/icons_show_serial_number", bool(check->get_active()));
 
480
 
445
481
        if ((check = this->lookup_widget<Gtk::CheckButton*>("search_in_smartmontools_first_check")))
446
482
                prefs_config_set("system/win32_search_smartctl_in_smartmontools", bool(check->get_active()));
447
483
 
465
501
 
466
502
 
467
503
 
 
504
bool GscPreferencesWindow::on_delete_event_before(GdkEventAny* e)
 
505
{
 
506
        destroy(this);  // deletes this object and nullifies instance
 
507
        return true;  // event handled, don't call default virtual handler
 
508
}
 
509
 
 
510
 
 
511
 
 
512
void GscPreferencesWindow::on_window_cancel_button_clicked()
 
513
{
 
514
        destroy(this);
 
515
}
 
516
 
 
517
 
 
518
 
 
519
void GscPreferencesWindow::on_window_ok_button_clicked()
 
520
{
 
521
        export_config();
 
522
        destroy(this);
 
523
}
 
524
 
 
525
 
 
526
 
468
527
void GscPreferencesWindow::on_window_reset_all_button_clicked()
469
528
{
470
529
        Gtk::MessageDialog dialog(*this,
587
646
 
588
647
 
589
648
 
 
649
 
 
650
/// @}