summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-05-11 15:05:32 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-05-11 15:05:32 -0400
commit8b488a5ca9036caf17ecee000cca6a7eba94d28a (patch)
treee4f41ab0c22403a91f6d54630ede2f9bee608a17 /src/components
parent1d8ef79da68a89c4561b9079b795d05484ddc419 (diff)
downloadabaddon-portaudio-8b488a5ca9036caf17ecee000cca6a7eba94d28a.tar.gz
abaddon-portaudio-8b488a5ca9036caf17ecee000cca6a7eba94d28a.zip
add icons to dms
Diffstat (limited to 'src/components')
-rw-r--r--src/components/channeltabswitcherhandy.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/components/channeltabswitcherhandy.cpp b/src/components/channeltabswitcherhandy.cpp
index 7488d6f..14cf9d9 100644
--- a/src/components/channeltabswitcherhandy.cpp
+++ b/src/components/channeltabswitcherhandy.cpp
@@ -164,19 +164,26 @@ void ChannelTabSwitcherHandy::OnPageIconLoad(HdyTabPage *page, const Glib::RefPt
}
void ChannelTabSwitcherHandy::CheckPageIcon(HdyTabPage *page, const ChannelData &data) {
+ std::optional<std::string> icon_url;
+
if (data.GuildID.has_value()) {
if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(*data.GuildID); guild.has_value() && guild->HasIcon()) {
- auto *child_widget = hdy_tab_page_get_child(page);
- if (child_widget == nullptr) return; // probably wont happen :---)
- // i think this works???
- auto *trackable = Glib::wrap(GTK_WIDGET(child_widget));
-
- Abaddon::Get().GetImageManager().LoadFromURL(
- guild->GetIconURL("png", "16"),
- sigc::track_obj([this, page](const Glib::RefPtr<Gdk::Pixbuf> &pb) { OnPageIconLoad(page, pb); },
- *trackable));
- return;
+ icon_url = guild->GetIconURL("png", "16");
}
+ } else if (data.IsDM()) {
+ icon_url = data.GetIconURL();
+ }
+
+ if (icon_url.has_value()) {
+ auto *child_widget = hdy_tab_page_get_child(page);
+ if (child_widget == nullptr) return; // probably wont happen :---)
+ // i think this works???
+ auto *trackable = Glib::wrap(GTK_WIDGET(child_widget));
+ Abaddon::Get().GetImageManager().LoadFromURL(
+ *icon_url,
+ sigc::track_obj([this, page](const Glib::RefPtr<Gdk::Pixbuf> &pb) { OnPageIconLoad(page, pb); },
+ *trackable));
+
return;
}