Logo Search packages:      
Sourcecode: gabber2 version File versions  Download package

Gabber::PlainTextView::PlainTextView ( Gtk::ScrolledWindow *  scr_win,
bool  stamp = true 
)

Create a new PlainTextView

Parameters:
scr_win The scrolled window to interact with.

Definition at line 40 of file PlainTextView.cc.

                                                                      : 
_scr_win(scroll_win), _view_height(0), _view_width(0), _goto_bottom(true),
_last_timestamp(0)
{
    _view = new Gtk::TextView();
    _buffer = _view->get_buffer();
    
    // initialize buffer uri/smiley parser
    _bufferparser = new TextBufferParser(_buffer);
    
    // initialize marks:
    _startmark         = _buffer->create_mark("startmark", _buffer->end());
    _bottom            = _buffer->create_mark("bottom", _buffer->end());
    _start_of_last_msg = _buffer->create_mark("start_of_last", _buffer->end());
    _buffer->create_mark("timestamp_start", _buffer->end());
    _buffer->create_mark("timestamp_end", _buffer->end());
    
    // Set TextView attributes:
    _view->set_wrap_mode(Gtk::WRAP_WORD);
    _view->set_editable(false);
    _view->set_cursor_visible(false);
    _view->set_left_margin(3); // this way letters won't touch the side edge
    _view->set_right_margin(3);
    _view->property_can_focus().set_value(false);

    // Figure out the line height
    // THEME/FONT SPECIFIC
    Glib::RefPtr<Pango::Layout> playout = Pango::Layout::create(_view->get_pango_context());
    Pango::Rectangle inkrect, logicalrect;
    playout->get_pixel_extents(inkrect, logicalrect);
    
    // save the line height for later use
    _font_lineheight = logicalrect.get_height();
    
    // Set the pixels_below_lines to be half of the line height.
    _view->set_pixels_below_lines(_font_lineheight/4);
    

    // the Gtk::ScrolledWindow contains our TextView widget:
    _scr_win->add(*_view);

    // Remote tag
    Glib::RefPtr<Gtk::TextBuffer::Tag> tag =  _buffer->create_tag("remote");
    tag->property_foreground().set_value("red");

    tag =  _buffer->create_tag("remote_seen");
    tag->property_foreground().set_value("burlywood");

    // Local tag
    tag =  _buffer->create_tag("local");
    tag->property_foreground().set_value("blue");

    tag =  _buffer->create_tag("local_seen");
    tag->property_foreground().set_value("LightSlateGrey");

    // Note tag
    tag = _buffer->create_tag("note");
    tag->property_foreground().set_value("dark green");

    tag = _buffer->create_tag("note_seen");
    tag->property_foreground().set_value("dark sea green");

    // /me tag
    tag = _buffer->create_tag("action");  
    tag = _buffer->create_tag("action_seen");  
    tag->property_foreground().set_value("grey40");

    // Composing tag
    tag = _buffer->create_tag("composing");
    tag->property_style().set_value(Pango::STYLE_ITALIC);

    // Seen tag
    tag = _buffer->create_tag("seen");
    tag->property_foreground().set_value("grey40");

    // Timestamp tag
    tag = _buffer->create_tag("timestamp");
    tag->property_foreground().set_value("dark grey");
    tag->property_justification().set_value(Gtk::JUSTIFY_CENTER);
    int sz = _view->get_pango_context()->get_font_description().get_size();
    tag->property_size().set_value(sz - (sz/4));

#ifdef OLD_SIGC
    _scr_win->get_vscrollbar()->signal_value_changed().connect(
        SigC::slot(*this, &PlainTextView::on_scroll_changed));
    _view->signal_size_allocate().connect(
        SigC::slot(*this, &PlainTextView::on_size_allocate));
#else
    _scr_win->get_vscrollbar()->signal_value_changed().connect(
        sigc::mem_fun(*this, &PlainTextView::on_scroll_changed));
    _view->signal_size_allocate().connect(
        sigc::mem_fun(*this, &PlainTextView::on_size_allocate));
#endif

    if (stamp)
        update_timestamp(time(NULL));
}


Generated by  Doxygen 1.6.0   Back to index