OSDN Git Service

'Show board' menuitem and 'Delete' menuitem are added.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Sun, 28 Jun 2009 21:00:30 +0000 (06:00 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Sun, 28 Jun 2009 21:00:30 +0000 (06:00 +0900)
src/thread_window.cxx
src/thread_window.hxx

index 999fae3..f666b25 100644 (file)
@@ -21,6 +21,7 @@
 #include "thread_window.hxx"
 
 #include <glibmm/convert.h>
+#include <gtkmm/stock.h>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/filesystem.hpp>
 #include <iostream>
@@ -29,6 +30,7 @@
 #include "thread_idx.hxx"
 #include "http_get.hxx"
 #include "misc.hxx"
+#include "uri_opener.hxx"
 
 
 namespace dialektos {
@@ -44,6 +46,26 @@ ThreadWindow::ThreadWindow(std::auto_ptr<bbs_detail::Base> bbs) :
   scrolled_(text_view_.get_adjustment()),
   bbs_(bbs), http_getter_(), idx_() {
 
+  // additional menuitems for board window
+  action_group_->add(Gtk::Action::create("FileDelete", Gtk::Stock::DELETE),
+      sigc::mem_fun(*this, &ThreadWindow::on_action_file_delete));
+  action_group_->add(
+      Gtk::Action::create("FileBoard", Gtk::Stock::GO_UP, "Show _Board"),
+      sigc::mem_fun(*this, &ThreadWindow::on_action_file_board));
+
+  Glib::ustring ui =
+    "<ui>"
+    "  <menubar name='MenuBar'>"
+    "    <menu action='MenuFile'>"
+    "      <menuitem action='FileDelete'/>"
+    "      <separator/>"
+    "      <menuitem action='FileBoard'/>"
+    "    </menu>"
+    "  </menubar>"
+    "</ui>";
+
+  ui_manager_->add_ui_from_string(ui);
+
   set_default_size(400,300);
 
   scrolled_.add(text_view_);
@@ -109,6 +131,26 @@ void ThreadWindow::on_action_view_stop() {
   if (http_getter_) http_getter_->cancel();
 }
 
+void ThreadWindow::on_action_file_delete() {
+  const boost::filesystem::path dat(bbs_->get_thread_file_path());
+  try {
+    if (boost::filesystem::exists(dat)) boost::filesystem::remove(dat);
+  } catch (const boost::filesystem::filesystem_error& e) {
+    std::cerr << e.what() << std::endl;
+  }
+
+  const boost::filesystem::path xml(bbs_->get_thread_idx_path());
+  try {
+    if (boost::filesystem::exists(xml)) boost::filesystem::remove(xml);
+  } catch (const boost::filesystem::filesystem_error& e) {
+    std::cerr << e.what() << std::endl;
+  }
+}
+
+void ThreadWindow::on_action_file_board() {
+  uri_opener::open(bbs_->get_board_uri());
+}
+
 void ThreadWindow::on_http_get_end(bool success) {
 //  const std::string uri = http_getter_->get_uri();
 //  const http::Header request_header = http_getter_->get_request_header();
index 8056a4a..b9e690f 100644 (file)
@@ -49,6 +49,8 @@ protected:
 
   virtual void on_action_view_refresh();
   virtual void on_action_view_stop();
+  void on_action_file_delete();
+  void on_action_file_board();
 private:
   virtual bool is_same(const bbs_detail::Base& bbs) const;
   virtual std::string get_uri() const;