From 18 Jan, 2021 0:00 UTC: All services will be temporary unavailable for maintenance
  • R/O
  • HTTP
  • SSH
  • HTTPS

dialektos: Commit

dialektos


Commit MetaInfo

Revision2e6da66bfbde853b7a0abaa5d70daef660599651 (tree)
Time2009-07-17 05:45:24
AuthorAiwota Programmer <aiwotaprog@tett...>
CommiterAiwota Programmer

Log Message

History menus are organized by boards.

Change Summary

Incremental Difference

--- a/src/application_framework.cxx
+++ b/src/application_framework.cxx
@@ -32,6 +32,8 @@
3232 #include <iostream>
3333 #include "bookmark_window.hxx"
3434 #include "uri_opener.hxx"
35+#include "bbs_detail_judge.hxx"
36+#include "bbs_detail_base.hxx"
3537
3638
3739 namespace dialektos {
@@ -200,14 +202,49 @@ void ApplicationFrameWork::set_history_menus() {
200202 Gtk::Menu* sub = history_menu_->get_submenu();
201203 sub->items().clear();
202204 std::vector<history::Item> recents = histories.get_recent();
205+
206+ typedef std::map<std::string, Gtk::Menu*> SubMenuType;
207+ SubMenuType subs;
208+
203209 BOOST_FOREACH(const history::Item& hitem, recents) {
204- Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(hitem.name_));
210+ std::auto_ptr<bbs_detail::Base> bbs = bbs_detail::judge(hitem.uri_);
211+ if (!bbs->is_thread()) continue;
212+
213+ const std::string board = bbs->get_board_id();
214+ SubMenuType::iterator it = subs.find(board);
215+ Gtk::Menu* subsub;
216+ if (it != subs.end()) {
217+ subsub = it->second;
218+ if (subsub->items().size() == 10) continue;
219+ }
220+ else {
221+ Gtk::MenuItem* subitem = Gtk::manage(new Gtk::MenuItem(board));
222+ sub->append(*subitem);
223+ subitem->show();
224+ subsub = Gtk::manage(new Gtk::Menu());
225+ subitem->set_submenu(*subsub);
226+ subs.insert(std::make_pair(board, subsub));
227+
228+ // menut item for threads list
229+ Gtk::MenuItem* menuitem =
230+ Gtk::manage(new Gtk::MenuItem(bbs->get_board_uri()));
231+ subsub->append(*menuitem);
232+ menuitem->show();
233+ menuitem->signal_activate().connect(sigc::bind(
234+ sigc::mem_fun(*this,
235+ &ApplicationFrameWork::on_history_menu_item_activate),
236+ bbs->get_board_uri()));
237+ }
238+
239+ Glib::ustring label = hitem.name_;
240+ Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(
241+ label.size() > 40 ? label.substr(0, 40) + "..." : label));
205242 item->show();
206243 item->signal_activate().connect(sigc::bind(
207244 sigc::mem_fun(*this,
208245 &ApplicationFrameWork::on_history_menu_item_activate),
209246 hitem.uri_));
210- sub->append(*item);
247+ subsub->append(*item);
211248 }
212249 }
213250
--- a/src/bbs_detail_base.cxx
+++ b/src/bbs_detail_base.cxx
@@ -158,6 +158,10 @@ std::string Base::get_board_idx_dir_path() const {
158158 return dir.file_string();
159159 }
160160
161+std::string Base::get_board_id() const {
162+ return board_;
163+}
164+
161165 const std::string& Base::get_encoding() const {
162166 return encoding;
163167 }
--- a/src/bbs_detail_base.hxx
+++ b/src/bbs_detail_base.hxx
@@ -55,6 +55,7 @@ public:
5555 virtual std::string get_board_uri() const;
5656 virtual std::string get_board_subject_idx_path() const;
5757 virtual std::string get_board_idx_dir_path() const;
58+ virtual std::string get_board_id() const;
5859 virtual http::Header get_board_subject_request_header() const;
5960 virtual http::Header get_thread_dat_request_header() const;
6061 virtual std::string get_title_from_string(const std::string& dat) const;
--- a/src/history_data.cxx
+++ b/src/history_data.cxx
@@ -119,8 +119,7 @@ std::vector<Item> Data::get_recent() const {
119119 order.push_back(pair.second);
120120
121121 std::sort(order.begin(), order.end(), std::not2(CompareTime()));
122- return std::vector<Item>(order.begin(),
123- order.size() > 10 ? order.begin()+10 : order.end());
122+ return order;
124123 }
125124
126125
Show on old repository browser