• R/O
  • HTTP
  • SSH
  • HTTPS

dialektos: Commit

dialektos


Commit MetaInfo

Revision197cb0cf13437eeda244163b0b0f4d3ccaa787ec (tree)
Time2009-07-19 19:06:22
AuthorAiwota Programmer <aiwotaprog@tett...>
CommiterAiwota Programmer

Log Message

Add open all menu and open all and close others menu in History.

Change Summary

Incremental Difference

--- a/src/application_framework.cxx
+++ b/src/application_framework.cxx
@@ -197,6 +197,23 @@ void ApplicationFrameWork::on_history_menu_item_activate(
197197 uri_opener::open(uri);
198198 }
199199
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+}
200217
201218 void ApplicationFrameWork::set_history_menus() {
202219 Gtk::Menu* sub = history_menu_->get_submenu();
@@ -206,6 +223,9 @@ void ApplicationFrameWork::set_history_menus() {
206223 typedef std::map<std::string, Gtk::Menu*> SubMenuType;
207224 SubMenuType subs;
208225
226+ typedef std::map<std::string, std::vector<std::string> > UrisType;
227+ UrisType uris;
228+
209229 BOOST_FOREACH(const history::Item& hitem, recents) {
210230 std::auto_ptr<bbs_detail::Base> bbs = bbs_detail::judge(hitem.uri_);
211231 if (!bbs->is_thread()) continue;
@@ -245,6 +265,25 @@ void ApplicationFrameWork::set_history_menus() {
245265 &ApplicationFrameWork::on_history_menu_item_activate),
246266 hitem.uri_));
247267 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]));
248287 }
249288 }
250289
--- a/src/application_framework.hxx
+++ b/src/application_framework.hxx
@@ -55,6 +55,9 @@ protected:
5555 virtual void on_child_button_press(GdkEventButton*);
5656
5757 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;
5861 void set_history_menus();
5962
6063 Gtk::VBox vbox_;
--- a/src/application_window.cxx
+++ b/src/application_window.cxx
@@ -104,6 +104,19 @@ void ApplicationWindow::save() {
104104 histories.to_xml(dir / ".dialektos" / "history.xml");
105105 }
106106
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+
107120 //bool ApplicationWindow::is_same(const bbs_detail::Base& bbs) const {
108121 // return false;
109122 //}
--- a/src/application_window.hxx
+++ b/src/application_window.hxx
@@ -23,6 +23,7 @@
2323
2424 #include <gtkmm/window.h>
2525 #include <boost/ptr_container/ptr_vector.hpp>
26+#include <vector>
2627 #include "history_data.hxx"
2728
2829
@@ -43,9 +44,11 @@ protected:
4344 ApplicationWindow();
4445 static void regist(ApplicationWindow* window);
4546 static void save();
47+ static void close_windows(const std::vector<ApplicationWindow*>&);
4648 virtual bool on_delete_event(GdkEventAny*);
4749 private:
4850 virtual bool is_same(const bbs_detail::Base& bbs) const = 0;
51+public:
4952 virtual std::string get_uri() const = 0;
5053 protected:
5154 static boost::ptr_vector<ApplicationWindow> windows;
Show on old repository browser