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

std::string PostUI::get_body (  )  const [private]

get current the body. since Pan posts WYSIWYG, pull from the view's lines rather than just using text_buffer_get_text(start,end)

Definition at line 129 of file post-ui.cc.

  std::string body;
  GtkTextBuffer * buf (_body_buf);
  GtkTextView * view (GTK_TEXT_VIEW(_body_view));

  // walk through all the complete lines...
  GtkTextIter body_start, body_end, line_start, line_end;
  gtk_text_buffer_get_bounds (buf, &body_start, &body_end);
  line_start = line_end = body_start;
  while ((gtk_text_view_forward_display_line (view, &line_end))) {
    char * line = gtk_text_buffer_get_text (buf, &line_start, &line_end, false);
    body += line;
    g_free (line);
    if (*body.rbegin() != '\n')
      body += '\n';
    line_start = line_end;

  // and maybe the last line doesn't have a linefeed yet...
  char * last_line = gtk_text_buffer_get_text (buf, &line_start, &body_end, false);
  if (last_line && *last_line)
    body += last_line;
  g_free (last_line);

  return body;

Generated by  Doxygen 1.6.0   Back to index