dialektos
Revision | 197cb0cf13437eeda244163b0b0f4d3ccaa787ec (tree) |
---|---|
Time | 2009-07-19 19:06:22 |
Author | Aiwota Programmer <aiwotaprog@tett...> |
Commiter | Aiwota Programmer |
Add open all menu and open all and close others menu in History.
@@ -197,6 +197,23 @@ void ApplicationFrameWork::on_history_menu_item_activate( | ||
197 | 197 | uri_opener::open(uri); |
198 | 198 | } |
199 | 199 | |
200 | +void ApplicationFrameWork::on_history_menu_items_activate( | |
201 | + const std::vector<std::string>& uris) const { | |
202 | + BOOST_FOREACH(const std::string& uri, uris) uri_opener::open(uri); | |
203 | +} | |
204 | + | |
205 | +void ApplicationFrameWork::on_history_menu_items_open_close_activate( | |
206 | + const std::vector<std::string>& uris) const { | |
207 | + | |
208 | + std::vector<ApplicationWindow*> closes; | |
209 | + | |
210 | + BOOST_FOREACH(ApplicationWindow& window, windows) | |
211 | + if (std::find(uris.begin(), uris.end(), window.get_uri()) == uris.end()) | |
212 | + closes.push_back(&window); | |
213 | + | |
214 | + on_history_menu_items_activate(uris); | |
215 | + close_windows(closes); | |
216 | +} | |
200 | 217 | |
201 | 218 | void ApplicationFrameWork::set_history_menus() { |
202 | 219 | Gtk::Menu* sub = history_menu_->get_submenu(); |
@@ -206,6 +223,9 @@ void ApplicationFrameWork::set_history_menus() { | ||
206 | 223 | typedef std::map<std::string, Gtk::Menu*> SubMenuType; |
207 | 224 | SubMenuType subs; |
208 | 225 | |
226 | + typedef std::map<std::string, std::vector<std::string> > UrisType; | |
227 | + UrisType uris; | |
228 | + | |
209 | 229 | BOOST_FOREACH(const history::Item& hitem, recents) { |
210 | 230 | std::auto_ptr<bbs_detail::Base> bbs = bbs_detail::judge(hitem.uri_); |
211 | 231 | if (!bbs->is_thread()) continue; |
@@ -245,6 +265,25 @@ void ApplicationFrameWork::set_history_menus() { | ||
245 | 265 | &ApplicationFrameWork::on_history_menu_item_activate), |
246 | 266 | hitem.uri_)); |
247 | 267 | subsub->append(*item); |
268 | + uris[board].push_back(hitem.uri_); | |
269 | + } | |
270 | + | |
271 | + BOOST_FOREACH(SubMenuType::value_type pair, subs) { | |
272 | + Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem("Open All")); | |
273 | + pair.second->append(*item); | |
274 | + item->show(); | |
275 | + item->signal_activate().connect(sigc::bind( | |
276 | + sigc::mem_fun(*this, | |
277 | + &ApplicationFrameWork::on_history_menu_items_activate), | |
278 | + uris[pair.first])); | |
279 | + | |
280 | + item = Gtk::manage(new Gtk::MenuItem("Open All & close others")); | |
281 | + pair.second->append(*item); | |
282 | + item->show(); | |
283 | + item->signal_activate().connect(sigc::bind( | |
284 | + sigc::mem_fun(*this, | |
285 | + &ApplicationFrameWork::on_history_menu_items_open_close_activate), | |
286 | + uris[pair.first])); | |
248 | 287 | } |
249 | 288 | } |
250 | 289 |
@@ -55,6 +55,9 @@ protected: | ||
55 | 55 | virtual void on_child_button_press(GdkEventButton*); |
56 | 56 | |
57 | 57 | void on_history_menu_item_activate(const std::string&); |
58 | + void on_history_menu_items_activate(const std::vector<std::string>&) const; | |
59 | + void on_history_menu_items_open_close_activate( | |
60 | + const std::vector<std::string>&) const; | |
58 | 61 | void set_history_menus(); |
59 | 62 | |
60 | 63 | Gtk::VBox vbox_; |
@@ -104,6 +104,19 @@ void ApplicationWindow::save() { | ||
104 | 104 | histories.to_xml(dir / ".dialektos" / "history.xml"); |
105 | 105 | } |
106 | 106 | |
107 | +void ApplicationWindow::close_windows( | |
108 | + const std::vector<ApplicationWindow*>& wins) { | |
109 | + BOOST_FOREACH(ApplicationWindow* window, wins) { | |
110 | + using namespace boost::lambda; | |
111 | + using boost::lambda::_1; | |
112 | + window->save_state(); | |
113 | + windows.erase_if(&_1 == window); | |
114 | + } | |
115 | + | |
116 | + if (!windows.empty()) save(); | |
117 | + if (windows.empty()) Gtk::Main::quit(); | |
118 | +} | |
119 | + | |
107 | 120 | //bool ApplicationWindow::is_same(const bbs_detail::Base& bbs) const { |
108 | 121 | // return false; |
109 | 122 | //} |
@@ -23,6 +23,7 @@ | ||
23 | 23 | |
24 | 24 | #include <gtkmm/window.h> |
25 | 25 | #include <boost/ptr_container/ptr_vector.hpp> |
26 | +#include <vector> | |
26 | 27 | #include "history_data.hxx" |
27 | 28 | |
28 | 29 |
@@ -43,9 +44,11 @@ protected: | ||
43 | 44 | ApplicationWindow(); |
44 | 45 | static void regist(ApplicationWindow* window); |
45 | 46 | static void save(); |
47 | + static void close_windows(const std::vector<ApplicationWindow*>&); | |
46 | 48 | virtual bool on_delete_event(GdkEventAny*); |
47 | 49 | private: |
48 | 50 | virtual bool is_same(const bbs_detail::Base& bbs) const = 0; |
51 | +public: | |
49 | 52 | virtual std::string get_uri() const = 0; |
50 | 53 | protected: |
51 | 54 | static boost::ptr_vector<ApplicationWindow> windows; |