tzwrapper.cc: fixed use of iterator after erase
[barry.git] / gui / src / BackupWindow.h
blobdd5409dca5f513364b28c1d9d1922d47904b48e9
1 ///
2 /// \file BackupWindow.h
3 /// GUI window class
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 <gtkmm.h>
23 #include <libglademm.h>
24 #include <memory>
25 #include <vector>
26 #include "DeviceBus.h"
27 #include "Thread.h"
29 class BackupWindow : public Gtk::Window
31 // external data
32 const Glib::RefPtr<Gnome::Glade::Xml> &m_xml;
34 // dispatcher for updating thread info
35 Glib::Dispatcher m_signal_update;
37 // Bus of Blackberry devices
38 DeviceBus m_bus;
40 // vector for storing Threads
41 std::vector<std::tr1::shared_ptr<Thread> > m_threads;
43 // signal exception handling connection
44 sigc::connection m_signal_handler_connection;
46 // Widget objects
47 Gtk::Statusbar *m_pStatusbar;
48 Gtk::Button *m_pBackupButton, *m_pRestoreButton,
49 *m_pConfigButton, *m_pDisconnectButton,
50 *m_pDisconnectAllButton, *m_pReloadButton;
51 Gtk::Label *m_pDeviceLabel;
52 Gtk::TreeView *m_pDeviceList;
54 // objects used by DeviceList
55 class Columns : public Gtk::TreeModel::ColumnRecord
57 public:
58 Gtk::TreeModelColumn<unsigned int> m_id;
59 Gtk::TreeModelColumn<Glib::ustring> m_pin;
60 Gtk::TreeModelColumn<Glib::ustring> m_name;
61 Gtk::TreeModelColumn<Glib::ustring> m_status;
62 Gtk::TreeModelColumn<unsigned int> m_percentage;
64 Columns()
66 add(m_id);
67 add(m_pin);
68 add(m_name);
69 add(m_status);
70 add(m_percentage);
73 Columns m_columns;
74 Glib::RefPtr<Gtk::ListStore> m_pListStore;
75 Glib::RefPtr<Gtk::TreeSelection> m_pDeviceSelection;
77 // number of devices
78 unsigned int m_device_count;
80 // pointer to active Thread;
81 Thread *m_pActive;
83 // whether scanned
84 bool m_scanned;
86 // statusbar message ID's
87 guint m_last_status_id;
89 protected:
90 void Scan();
91 bool Connect(Thread *);
92 void Disconnect(Thread *);
93 void CheckDeviceName(Thread *);
94 bool PromptForRestoreTarball(std::string &restoreFilename,
95 const std::string &start_path);
96 Thread *GetActive();
97 void StatusbarSet(const Glib::ustring& text);
98 bool CheckWorking(); // returns true if ok to proceed
100 public:
101 BackupWindow(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml);
102 ~BackupWindow();
104 // handler for exceptions that happen in signal calls
105 void signal_exception_handler();
107 // handler for treeview update requests
108 void treeview_update();
110 // signal handlers
111 void on_backup();
112 void on_restore();
113 void on_config();
114 void on_disconnect();
115 void on_disconnect_all();
116 void on_reload();
117 void on_device_change();
118 void on_file_quit();
119 void on_help_about();
120 bool on_startup();
122 // virtual overrides
123 virtual bool on_delete_event(GdkEventAny *event);