func OpenFileInBuffer(tb *gtk.TextBuffer, f string) (err error) { var ( part []byte prefix bool start gtk.TextIter ) file, err := os.Open(f) if err != nil { return } tb.GetStartIter(&start) reader := bufio.NewReader(file) buffer := bytes.NewBuffer(make([]byte, 1024)) for { if part, prefix, err = reader.ReadLine(); err != nil { return err } buffer.Write(part) if !prefix { tb.Insert(&start, buffer.String()+"\n") buffer.Reset() } } file.Close() return nil }
func display(t *tweet, buffer *gtk.TextBuffer, tag *gtk.TextTag) { var iter gtk.TextIter pixbufbytes, resp := readURL(t.User.ProfileImageUrl) buffer.GetStartIter(&iter) if resp != nil { buffer.InsertPixbuf(&iter, bytes2pixbuf(pixbufbytes, resp.Header.Get("Content-Type"))) } buffer.Insert(&iter, " ") buffer.InsertWithTag(&iter, t.User.ScreenName, tag) buffer.Insert(&iter, ":"+t.Text+"\n") gtk.MainIterationDo(false) }