3 /// Dialog wrapper class for user selection of device databases
7 Copyright (C) 2007-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "ConfigDlg.h"
23 #include "DatabaseSelectDlg.h"
26 #include <barry/barry.h>
28 ConfigDlg::ConfigDlg(const Barry::DatabaseDatabase
&dbdb
,
29 const Barry::ConfigFile
&config
)
31 , m_backupList(config
.GetBackupList())
32 , m_restoreList(config
.GetRestoreList())
33 , m_backupPath(config
.GetPath())
34 , m_promptBackupLabel(config
.PromptBackupLabel())
35 , m_autoSelectAll(config
.AutoSelectAll())
37 Glib::RefPtr
<Gnome::Glade::Xml
> xml
= LoadXml("ConfigDlg.glade");
40 xml
->get_widget("ConfigDlg", pD
);
43 xml
->get_widget("DeviceName", m_pDeviceNameEntry
);
44 m_pDeviceNameEntry
->set_text(config
.GetDeviceName());
46 xml
->get_widget("BackupPath", m_pBackupPath
);
47 m_pBackupPath
->set_current_folder(config
.GetPath());
49 xml
->get_widget("PromptBackupLabel", m_pPromptBackupLabelCheck
);
50 m_pPromptBackupLabelCheck
->set_active(config
.PromptBackupLabel());
52 Gtk::Button
*pButton
= 0;
53 xml
->get_widget("configure_backup", pButton
);
54 pButton
->signal_clicked().connect(
55 sigc::mem_fun(*this, &ConfigDlg::on_configure_backup
));
58 xml
->get_widget("configure_restore", pButton
);
59 pButton
->signal_clicked().connect(
60 sigc::mem_fun(*this, &ConfigDlg::on_configure_restore
));
63 ConfigDlg::~ConfigDlg()
69 int r_val
= m_pDialog
->run();
70 m_deviceName
= m_pDeviceNameEntry
->get_text();
71 m_backupPath
= m_pBackupPath
->get_filename();
72 m_promptBackupLabel
= m_pPromptBackupLabelCheck
->get_active();
76 void ConfigDlg::on_configure_backup()
78 DatabaseSelectDlg
dlg(m_dbdb
, m_backupList
, m_autoSelectAll
,
79 _("Select the device databases you wish to backup:"), true);
80 if( dlg
.run() == Gtk::RESPONSE_OK
) {
81 m_backupList
= dlg
.GetSelections();
82 m_autoSelectAll
= dlg
.AutoSelectAll();
86 void ConfigDlg::on_configure_restore()
88 DatabaseSelectDlg
dlg(m_dbdb
, m_restoreList
, m_autoSelectAll
,
89 _("Select the device databases you wish to recover. This selection acts like a filter, in that only the databases you select here will be restored, even if more exist in the backup data."), false);
90 if( dlg
.run() == Gtk::RESPONSE_OK
) {
91 m_restoreList
= dlg
.GetSelections();