summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-01-12 00:11:59 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2021-01-12 00:11:59 -0500
commitd3c980b09e23a9c85c7a4cc8a9d61b268f11d2b7 (patch)
treecbcc187810f1aec2a097569d518d718f04a63930 /components
parent6dec601cf284bb3e7db2caa3683e6f00b4b1d103 (diff)
downloadabaddon-portaudio-d3c980b09e23a9c85c7a4cc8a9d61b268f11d2b7.tar.gz
abaddon-portaudio-d3c980b09e23a9c85c7a4cc8a9d61b268f11d2b7.zip
try and speed some stuff up
Diffstat (limited to 'components')
-rw-r--r--components/chatmessage.cpp73
-rw-r--r--components/memberlist.cpp27
2 files changed, 36 insertions, 64 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp
index 08ca0b9..40d706b 100644
--- a/components/chatmessage.cpp
+++ b/components/chatmessage.cpp
@@ -713,60 +713,37 @@ void ChatMessageItemContainer::HandleCustomEmojis(Gtk::TextView &tv) {
startpos = mend;
if (is_animated && show_animations) {
- auto pixbuf = img.GetAnimationFromURLIfCached(EmojiData::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize);
- if (pixbuf) {
- const auto it = buf->erase(start_it, end_it);
- const int alen = text.size();
- text = GetText(buf);
- const int blen = text.size();
- startpos -= (alen - blen);
+ const auto mark_start = buf->create_mark(start_it, false);
+ end_it.backward_char();
+ const auto mark_end = buf->create_mark(end_it, false);
+ const auto cb = [this, &tv, buf, mark_start, mark_end](const Glib::RefPtr<Gdk::PixbufAnimation> &pixbuf) {
+ auto start_it = mark_start->get_iter();
+ auto end_it = mark_end->get_iter();
+ end_it.forward_char();
+ buf->delete_mark(mark_start);
+ buf->delete_mark(mark_end);
+ auto it = buf->erase(start_it, end_it);
const auto anchor = buf->create_child_anchor(it);
auto img = Gtk::manage(new Gtk::Image(pixbuf));
img->show();
tv.add_child_at_anchor(*img, anchor);
- } else {
- const auto mark_start = buf->create_mark(start_it, false);
- end_it.backward_char();
- const auto mark_end = buf->create_mark(end_it, false);
- const auto cb = [this, &tv, buf, mark_start, mark_end](const Glib::RefPtr<Gdk::PixbufAnimation> &pixbuf) {
- auto start_it = mark_start->get_iter();
- auto end_it = mark_end->get_iter();
- end_it.forward_char();
- buf->delete_mark(mark_start);
- buf->delete_mark(mark_end);
- auto it = buf->erase(start_it, end_it);
- const auto anchor = buf->create_child_anchor(it);
- auto img = Gtk::manage(new Gtk::Image(pixbuf));
- img->show();
- tv.add_child_at_anchor(*img, anchor);
- };
- img.LoadAnimationFromURL(EmojiData::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize, sigc::track_obj(cb, tv));
- }
+ };
+ img.LoadAnimationFromURL(EmojiData::URLFromID(match.fetch(2), "gif"), EmojiSize, EmojiSize, sigc::track_obj(cb, tv));
} else {
- auto pixbuf = img.GetFromURLIfCached(EmojiData::URLFromID(match.fetch(2)));
- if (pixbuf) {
- const auto it = buf->erase(start_it, end_it);
- const int alen = text.size();
- text = GetText(buf);
- const int blen = text.size();
- startpos -= (alen - blen);
+ // can't erase before pixbuf is ready or else marks that are in the same pos get mixed up
+ const auto mark_start = buf->create_mark(start_it, false);
+ end_it.backward_char();
+ const auto mark_end = buf->create_mark(end_it, false);
+ const auto cb = [this, buf, mark_start, mark_end](const Glib::RefPtr<Gdk::Pixbuf> &pixbuf) {
+ auto start_it = mark_start->get_iter();
+ auto end_it = mark_end->get_iter();
+ end_it.forward_char();
+ buf->delete_mark(mark_start);
+ buf->delete_mark(mark_end);
+ auto it = buf->erase(start_it, end_it);
buf->insert_pixbuf(it, pixbuf->scale_simple(EmojiSize, EmojiSize, Gdk::INTERP_BILINEAR));
- } else {
- // can't erase before pixbuf is ready or else marks that are in the same pos get mixed up
- const auto mark_start = buf->create_mark(start_it, false);
- end_it.backward_char();
- const auto mark_end = buf->create_mark(end_it, false);
- const auto cb = [this, buf, mark_start, mark_end](const Glib::RefPtr<Gdk::Pixbuf> &pixbuf) {
- auto start_it = mark_start->get_iter();
- auto end_it = mark_end->get_iter();
- end_it.forward_char();
- buf->delete_mark(mark_start);
- buf->delete_mark(mark_end);
- auto it = buf->erase(start_it, end_it);
- buf->insert_pixbuf(it, pixbuf->scale_simple(EmojiSize, EmojiSize, Gdk::INTERP_BILINEAR));
- };
- img.LoadFromURL(EmojiData::URLFromID(match.fetch(2)), sigc::track_obj(cb, tv));
- }
+ };
+ img.LoadFromURL(EmojiData::URLFromID(match.fetch(2)), sigc::track_obj(cb, tv));
}
text = GetText(buf);
diff --git a/components/memberlist.cpp b/components/memberlist.cpp
index 80aec56..14fb1f4 100644
--- a/components/memberlist.cpp
+++ b/components/memberlist.cpp
@@ -144,23 +144,18 @@ void MemberList::UpdateMemberListInternal() {
m_id_to_row[data->ID] = row;
if (data->HasAvatar()) {
- auto buf = Abaddon::Get().GetImageManager().GetFromURLIfCached(data->GetAvatarURL("png", "16"));
- if (buf) {
- row->SetAvatarFromPixbuf(buf);
- } else {
- Snowflake id = data->ID;
- Abaddon::Get().GetImageManager().LoadFromURL(data->GetAvatarURL("png", "16"), [this, id](Glib::RefPtr<Gdk::Pixbuf> pbuf) {
- Glib::signal_idle().connect([this, id, pbuf]() -> bool {
- if (m_id_to_row.find(id) != m_id_to_row.end()) {
- auto *foundrow = static_cast<MemberListUserRow *>(m_id_to_row.at(id));
- if (foundrow != nullptr)
- foundrow->SetAvatarFromPixbuf(pbuf);
- }
-
- return false;
- });
+ Snowflake id = data->ID;
+ Abaddon::Get().GetImageManager().LoadFromURL(data->GetAvatarURL("png", "16"), [this, id](Glib::RefPtr<Gdk::Pixbuf> pbuf) {
+ Glib::signal_idle().connect([this, id, pbuf]() -> bool {
+ if (m_id_to_row.find(id) != m_id_to_row.end()) {
+ auto *foundrow = static_cast<MemberListUserRow *>(m_id_to_row.at(id));
+ if (foundrow != nullptr)
+ foundrow->SetAvatarFromPixbuf(pbuf);
+ }
+
+ return false;
});
- }
+ });
}
AttachUserMenuHandler(row, data->ID);