Skip to content

Commit

Permalink
displaying received png in chat
Browse files Browse the repository at this point in the history
-missing option to "Save As" the images
  • Loading branch information
notsecure committed May 27, 2014
1 parent 9f148af commit ad7108b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/ui/ConversationView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@ namespace Venom {
}

public void add_filetransfer(FileTransferChatEntry entry) {
entry.filetransfer_completed.connect((entry, ft) => {
if(ft.name.has_suffix(".png")) {
if(!ft.isfile) {
try {
Gdk.PixbufLoader loader = new Gdk.PixbufLoader.with_mime_type("image/png");
loader.write(ft.data);
loader.close();

int position;
conversation_list.child_get(entry, "position", out position);

Gtk.Image image = new Gtk.Image.from_pixbuf(loader.get_pixbuf());
conversation_list.pack_start(image, false, false, 0);
conversation_list.reorder_child(image, position + 1);
image.set_visible(true);

} catch (Error error) {
stderr.printf("Error: %s\n", error.message);
}
}
}
});

conversation_list.pack_start(entry, false, false, 0);
entry.set_visible(true);

Expand Down
2 changes: 2 additions & 0 deletions src/ui/FileTransferChatEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace Venom {

public signal void filetransfer_accepted(FileTransfer ft);
public signal void filetransfer_rejected(FileTransfer ft);
public signal void filetransfer_completed(FileTransferChatEntry entry, FileTransfer ft);

public FileTransferChatEntry(FileTransfer ft){
this.ft = ft;
Expand Down Expand Up @@ -87,6 +88,7 @@ namespace Venom {
}
progress_bar.visible = false;
disable_buttons();
filetransfer_completed(this, ft);
} break;
case FileTransferStatus.REJECTED: {
size_or_status_label.set_text("File was rejected");
Expand Down

0 comments on commit ad7108b

Please sign in to comment.