Bumped copyright dates for 2013
[barry.git] / gui / src / ConfigDlg.cc
blobfa78df7cb08fd7e5aa2a95a93a8982d96d5162c0
1 ///
2 /// \file ConfigDlg.cc
3 /// Dialog wrapper class for user selection of device databases
4 ///
6 /*
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"
24 #include "util.h"
25 #include "i18n.h"
26 #include <barry/barry.h>
28 ConfigDlg::ConfigDlg(const Barry::DatabaseDatabase &dbdb,
29 const Barry::ConfigFile &config)
30 : m_dbdb(dbdb)
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");
39 Gtk::Dialog *pD = 0;
40 xml->get_widget("ConfigDlg", pD);
41 m_pDialog.reset(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));
57 pButton = 0;
58 xml->get_widget("configure_restore", pButton);
59 pButton->signal_clicked().connect(
60 sigc::mem_fun(*this, &ConfigDlg::on_configure_restore));
63 ConfigDlg::~ConfigDlg()
67 int ConfigDlg::run()
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();
73 return r_val;
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();