#ifndef TEXT_VIEW_HXX
#define TEXT_VIEW_HXX
+#include <sigc++/signal.h>
+#include <string>
#include "text_view_popupable.hxx"
class TextView: public Popupable {
typedef Popupable SuperClass;
+ typedef sigc::signal<void ,const std::string&> SignalUriClicked;
public:
TextView();
virtual ~TextView();
int get_displayed_res_num() const;
void jump_to_res_num(int res_num);
+ SignalUriClicked& signal_uri_clicked() { return sig_uri_clicked_; }
protected:
virtual void on_anchor_click_event(const text_element::Anchor& elem);
+
+private:
+ SignalUriClicked sig_uri_clicked_;
};
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
+#include <boost/format.hpp>
#include <iostream>
#include <fstream>
+#include <sstream>
+#include <cstdlib>
#include "bbs_detail_base.hxx"
#include "thread_idx.hxx"
#include "http_get.hxx"
ui_manager_->add_ui_from_string(ui);
- scrolled_.add(*text_view_);
add(scrolled_);
-
- text_view_->signal_button_press_event().connect_notify(
- sigc::mem_fun(*this, &ThreadWindow::on_child_button_press));
+ initialize_text_view();
ThreadWindowState state;
state.from_xml(boost::filesystem::path(bbs_->get_thread_state_path()));
text_view_->jump_to_res_num(state.displayed_res_num);
}
+void ThreadWindow::initialize_text_view() {
+ scrolled_.add(*text_view_);
+
+ text_view_->signal_button_press_event().connect_notify(
+ sigc::mem_fun(*this, &ThreadWindow::on_child_button_press));
+ text_view_->signal_uri_clicked().connect(
+ sigc::mem_fun(*this, &ThreadWindow::on_uri_clicked));
+
+ text_view_->show();
+}
+
bool ThreadWindow::load() {
using namespace boost::posix_time;
ptime start = microsec_clock::local_time();
scrolled_.remove(*text_view_);
text_view_.reset(new text_view::TextView);
scrolled_.set_adjustment(text_view_->get_adjustment());
- scrolled_.add(*text_view_);
- text_view_->signal_button_press_event().connect_notify(
- sigc::mem_fun(*this, &ThreadWindow::on_child_button_press));
- text_view_->show();
+ initialize_text_view();
}
bbs_->load_thread_from_string(response.get_content(), *text_view_);
}
}
+void ThreadWindow::on_uri_clicked(const std::string& uri) const {
+ if (uri_opener::open(uri)) return;
+ std::stringstream ss;
+ ss << boost::format("gnome-open %1%") % uri;
+ std::system(ss.str().c_str());
+}
} // namespace dialektos
void on_action_file_delete();
void on_action_file_board();
private:
+ void initialize_text_view();
virtual bool is_same(const bbs_detail::Base& bbs) const;
virtual std::string get_uri() const;
void save_content(const http::Response&);
void inform_to_board(const ThreadIdx& idx) const;
+ void on_uri_clicked(const std::string& uri) const;
+
boost::scoped_ptr<text_view::TextView> text_view_;
ScrolledContainer scrolled_;
boost::scoped_ptr<bbs_detail::Base> bbs_;