diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-06-17 03:50:50 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-06-17 03:50:50 -0400 |
commit | eb9ad703be7769958bee959ce2f83f5325ef206b (patch) | |
tree | 837dd8ffbbb8b53a33379c61c4ce3dc36fff59ec /src/components/channellist | |
parent | f8de54e47eadc40fad4027a34902476527f48a5c (diff) | |
download | abaddon-portaudio-eb9ad703be7769958bee959ce2f83f5325ef206b.tar.gz abaddon-portaudio-eb9ad703be7769958bee959ce2f83f5325ef206b.zip |
show voice channels and participants even if compiled without audio
Diffstat (limited to 'src/components/channellist')
-rw-r--r-- | src/components/channellist/cellrendererchannels.cpp | 14 | ||||
-rw-r--r-- | src/components/channellist/cellrendererchannels.hpp | 6 | ||||
-rw-r--r-- | src/components/channellist/channellisttree.cpp | 53 | ||||
-rw-r--r-- | src/components/channellist/channellisttree.hpp | 8 |
4 files changed, 10 insertions, 71 deletions
diff --git a/src/components/channellist/cellrendererchannels.cpp b/src/components/channellist/cellrendererchannels.cpp index bb2b9ba..8758a7d 100644 --- a/src/components/channellist/cellrendererchannels.cpp +++ b/src/components/channellist/cellrendererchannels.cpp @@ -122,12 +122,10 @@ void CellRendererChannels::get_preferred_width_vfunc(Gtk::Widget &widget, int &m return get_preferred_width_vfunc_channel(widget, minimum_width, natural_width); case RenderType::Thread: return get_preferred_width_vfunc_thread(widget, minimum_width, natural_width); -#ifdef WITH_VOICE case RenderType::VoiceChannel: return get_preferred_width_vfunc_voice_channel(widget, minimum_width, natural_width); case RenderType::VoiceParticipant: return get_preferred_width_vfunc_voice_participant(widget, minimum_width, natural_width); -#endif case RenderType::DMHeader: return get_preferred_width_vfunc_dmheader(widget, minimum_width, natural_width); case RenderType::DM: @@ -147,12 +145,10 @@ void CellRendererChannels::get_preferred_width_for_height_vfunc(Gtk::Widget &wid return get_preferred_width_for_height_vfunc_channel(widget, height, minimum_width, natural_width); case RenderType::Thread: return get_preferred_width_for_height_vfunc_thread(widget, height, minimum_width, natural_width); -#ifdef WITH_VOICE case RenderType::VoiceChannel: return get_preferred_width_for_height_vfunc_voice_channel(widget, height, minimum_width, natural_width); case RenderType::VoiceParticipant: return get_preferred_width_for_height_vfunc_voice_participant(widget, height, minimum_width, natural_width); -#endif case RenderType::DMHeader: return get_preferred_width_for_height_vfunc_dmheader(widget, height, minimum_width, natural_width); case RenderType::DM: @@ -172,12 +168,10 @@ void CellRendererChannels::get_preferred_height_vfunc(Gtk::Widget &widget, int & return get_preferred_height_vfunc_channel(widget, minimum_height, natural_height); case RenderType::Thread: return get_preferred_height_vfunc_thread(widget, minimum_height, natural_height); -#ifdef WITH_VOICE case RenderType::VoiceChannel: return get_preferred_height_vfunc_voice_channel(widget, minimum_height, natural_height); case RenderType::VoiceParticipant: return get_preferred_height_vfunc_voice_participant(widget, minimum_height, natural_height); -#endif case RenderType::DMHeader: return get_preferred_height_vfunc_dmheader(widget, minimum_height, natural_height); case RenderType::DM: @@ -197,12 +191,10 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc(Gtk::Widget &wid return get_preferred_height_for_width_vfunc_channel(widget, width, minimum_height, natural_height); case RenderType::Thread: return get_preferred_height_for_width_vfunc_thread(widget, width, minimum_height, natural_height); -#ifdef WITH_VOICE case RenderType::VoiceChannel: return get_preferred_height_for_width_vfunc_voice_channel(widget, width, minimum_height, natural_height); case RenderType::VoiceParticipant: return get_preferred_height_for_width_vfunc_voice_participant(widget, width, minimum_height, natural_height); -#endif case RenderType::DMHeader: return get_preferred_height_for_width_vfunc_dmheader(widget, width, minimum_height, natural_height); case RenderType::DM: @@ -222,12 +214,10 @@ void CellRendererChannels::render_vfunc(const Cairo::RefPtr<Cairo::Context> &cr, return render_vfunc_channel(cr, widget, background_area, cell_area, flags); case RenderType::Thread: return render_vfunc_thread(cr, widget, background_area, cell_area, flags); -#ifdef WITH_VOICE case RenderType::VoiceChannel: return render_vfunc_voice_channel(cr, widget, background_area, cell_area, flags); case RenderType::VoiceParticipant: return render_vfunc_voice_participant(cr, widget, background_area, cell_area, flags); -#endif case RenderType::DMHeader: return render_vfunc_dmheader(cr, widget, background_area, cell_area, flags); case RenderType::DM: @@ -563,8 +553,6 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex } } -#ifdef WITH_VOICE - // voice channel void CellRendererChannels::get_preferred_width_vfunc_voice_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const { @@ -714,8 +702,6 @@ void CellRendererChannels::render_vfunc_voice_participant(const Cairo::RefPtr<Ca } } -#endif - // dm header void CellRendererChannels::get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const { diff --git a/src/components/channellist/cellrendererchannels.hpp b/src/components/channellist/cellrendererchannels.hpp index a313dc7..ebe4957 100644 --- a/src/components/channellist/cellrendererchannels.hpp +++ b/src/components/channellist/cellrendererchannels.hpp @@ -15,12 +15,8 @@ enum class RenderType : uint8_t { Category, TextChannel, Thread, - -// TODO: maybe enable anyways but without ability to join if no voice support -#ifdef WITH_VOICE VoiceChannel, VoiceParticipant, -#endif DMHeader, DM, @@ -107,7 +103,6 @@ protected: const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags); -#ifdef WITH_VOICE // voice channel void get_preferred_width_vfunc_voice_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const; void get_preferred_width_for_height_vfunc_voice_channel(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const; @@ -129,7 +124,6 @@ protected: const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags); -#endif // dm header void get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const; diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index e5bc06e..611dc03 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -26,11 +26,9 @@ ChannelListTree::ChannelListTree() , m_menu_channel_open_tab("Open in New _Tab", true) , m_menu_dm_open_tab("Open in New _Tab", true) #endif -#ifdef WITH_VOICE , m_menu_voice_channel_join("_Join", true) , m_menu_voice_channel_disconnect("_Disconnect", true) , m_menu_voice_open_chat("Open _Chat", true) -#endif , m_menu_dm_copy_id("_Copy ID", true) , m_menu_dm_close("") // changes depending on if group or not #ifdef WITH_VOICE @@ -209,6 +207,7 @@ ChannelListTree::ChannelListTree() m_menu_voice_channel_disconnect.signal_activate().connect([this]() { m_signal_action_disconnect_voice.emit(); }); +#endif m_menu_voice_open_chat.signal_activate().connect([this]() { const auto id = static_cast<Snowflake>((*m_model->get_iter(m_path_for_menu))[m_columns.m_id]); @@ -219,7 +218,6 @@ ChannelListTree::ChannelListTree() m_menu_voice_channel.append(m_menu_voice_channel_disconnect); m_menu_voice_channel.append(m_menu_voice_open_chat); m_menu_voice_channel.show_all(); -#endif m_menu_dm_copy_id.signal_activate().connect([this] { Gtk::Clipboard::get()->set_text(std::to_string((*m_model->get_iter(m_path_for_menu))[m_columns.m_id])); @@ -362,10 +360,8 @@ int ChannelListTree::SortFunc(const Gtk::TreeModel::iterator &a, const Gtk::Tree const int64_t b_sort = (*b)[m_columns.m_sort]; if (a_type == RenderType::DMHeader) return -1; if (b_type == RenderType::DMHeader) return 1; -#ifdef WITH_VOICE if (a_type == RenderType::TextChannel && b_type == RenderType::VoiceChannel) return -1; if (b_type == RenderType::TextChannel && a_type == RenderType::VoiceChannel) return 1; -#endif return static_cast<int>(std::clamp(a_sort - b_sort, int64_t(-1), int64_t(1))); } @@ -497,13 +493,9 @@ void ChannelListTree::UpdateChannel(Snowflake id) { auto channel = Abaddon::Get().GetDiscordClient().GetChannel(id); if (!iter || !channel.has_value()) return; if (channel->Type == ChannelType::GUILD_CATEGORY) return UpdateChannelCategory(*channel); - // TODO: theres like 4 different fucking ways of checking if somethin g is text or voice can i fix that How stupid . - // fun fact clang-format is indenting me right now i wonder why ,,,,,,,,,,, -#ifdef WITH_VOICE + // TODO: theres like 4 different fucking ways of checking if somethin g is text or voice can i fix that How stupid . + // fun fact clang-format is indenting me right now i wonder why ,,,,,,,,,,, if (!channel->IsText() && channel->Type != ChannelType::GUILD_VOICE) return; -#else - if (!channel->IsText()) return; -#endif // refresh stuff that might have changed const bool is_orphan_TMP = !channel->ParentID.has_value(); @@ -525,11 +517,7 @@ void ChannelListTree::UpdateChannel(Snowflake id) { void ChannelListTree::UpdateCreateChannel(const ChannelData &channel) { if (channel.Type == ChannelType::GUILD_CATEGORY) return (void)UpdateCreateChannelCategory(channel); if (channel.Type == ChannelType::DM || channel.Type == ChannelType::GROUP_DM) return UpdateCreateDMChannel(channel); -#ifdef WITH_VOICE if (channel.Type != ChannelType::GUILD_TEXT && channel.Type != ChannelType::GUILD_NEWS && channel.Type != ChannelType::GUILD_VOICE) return; -#else - if (channel.Type != ChannelType::GUILD_TEXT && channel.Type != ChannelType::GUILD_NEWS) return; -#endif Gtk::TreeRow channel_row; bool orphan; @@ -542,11 +530,7 @@ void ChannelListTree::UpdateCreateChannel(const ChannelData &channel) { auto iter = GetIteratorForGuildFromID(*channel.GuildID); channel_row = *m_model->append(iter->children()); } -#ifdef WITH_VOICE channel_row[m_columns.m_type] = IsTextChannel(channel.Type) ? RenderType::TextChannel : RenderType::VoiceChannel; -#else - channel_row[m_columns.m_type] = RenderType::TextChannel; -#endif channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); channel_row[m_columns.m_nsfw] = channel.NSFW(); @@ -642,7 +626,6 @@ void ChannelListTree::OnThreadListSync(const ThreadListSyncData &data) { } } -#ifdef WITH_VOICE void ChannelListTree::OnVoiceUserConnect(Snowflake user_id, Snowflake channel_id) { auto parent_iter = GetIteratorForRowFromIDOfType(channel_id, RenderType::VoiceChannel); if (!parent_iter) parent_iter = GetIteratorForRowFromIDOfType(channel_id, RenderType::DM); @@ -664,7 +647,6 @@ void ChannelListTree::OnVoiceStateSet(Snowflake user_id, Snowflake channel_id, V (*iter)[m_columns.m_voice_flags] = flags; } } -#endif void ChannelListTree::DeleteThreadRow(Snowflake id) { auto iter = GetIteratorForRowFromID(id); @@ -926,11 +908,7 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const for (const auto &channel_ : *guild.Channels) { const auto channel = discord.GetChannel(channel_.ID); if (!channel.has_value()) continue; -#ifdef WITH_VOICE if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS || channel->Type == ChannelType::GUILD_VOICE) { -#else - if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS) { -#endif if (channel->ParentID.has_value()) categories[*channel->ParentID].push_back(*channel); else @@ -957,7 +935,6 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const } }; -#ifdef WITH_VOICE auto add_voice_participants = [this, &discord](const ChannelData &channel, const Gtk::TreeNodeChildren &root) { for (auto user_id : discord.GetUsersInVoiceChannel(channel.ID)) { if (const auto user = discord.GetUser(user_id); user.has_value()) { @@ -965,21 +942,17 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const } } }; -#endif for (const auto &channel : orphan_channels) { auto channel_row = *m_model->append(guild_row.children()); if (IsTextChannel(channel.Type)) { channel_row[m_columns.m_type] = RenderType::TextChannel; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); - } -#ifdef WITH_VOICE - else { + } else { channel_row[m_columns.m_type] = RenderType::VoiceChannel; channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel.Name); add_voice_participants(channel, channel_row->children()); } -#endif channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_sort] = *channel.Position + OrphanChannelSortOffset; channel_row[m_columns.m_nsfw] = channel.NSFW(); @@ -1004,14 +977,11 @@ Gtk::TreeModel::iterator ChannelListTree::AddGuild(const GuildData &guild, const if (IsTextChannel(channel.Type)) { channel_row[m_columns.m_type] = RenderType::TextChannel; channel_row[m_columns.m_name] = "#" + Glib::Markup::escape_text(*channel.Name); - } -#ifdef WITH_VOICE - else { + } else { channel_row[m_columns.m_type] = RenderType::VoiceChannel; channel_row[m_columns.m_name] = Glib::Markup::escape_text(*channel.Name); add_voice_participants(channel, channel_row->children()); } -#endif channel_row[m_columns.m_id] = channel.ID; channel_row[m_columns.m_sort] = *channel.Position; channel_row[m_columns.m_nsfw] = channel.NSFW(); @@ -1049,7 +1019,6 @@ Gtk::TreeModel::iterator ChannelListTree::CreateThreadRow(const Gtk::TreeNodeChi return thread_iter; } -#ifdef WITH_VOICE Gtk::TreeModel::iterator ChannelListTree::CreateVoiceParticipantRow(const UserData &user, const Gtk::TreeNodeChildren &parent) { auto row = *m_model->append(parent); row[m_columns.m_type] = RenderType::VoiceParticipant; @@ -1071,7 +1040,6 @@ Gtk::TreeModel::iterator ChannelListTree::CreateVoiceParticipantRow(const UserDa return row; } -#endif void ChannelListTree::UpdateChannelCategory(const ChannelData &channel) { auto iter = GetIteratorForRowFromID(channel.ID); @@ -1215,13 +1183,11 @@ void ChannelListTree::AddPrivateChannels() { row[m_columns.m_icon] = img.GetPlaceholder(DMIconSize); row[m_columns.m_expanded] = true; -#ifdef WITH_VOICE for (auto user_id : discord.GetUsersInVoiceChannel(dm_id)) { if (const auto user = discord.GetUser(user_id); user.has_value()) { CreateVoiceParticipantRow(*user, row->children()); } } -#endif SetDMChannelIcon(iter, *dm); } @@ -1352,12 +1318,10 @@ bool ChannelListTree::OnButtonPressEvent(GdkEventButton *ev) { OnChannelSubmenuPopup(); m_menu_channel.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); break; -#ifdef WITH_VOICE case RenderType::VoiceChannel: OnVoiceChannelSubmenuPopup(); m_menu_voice_channel.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev)); break; -#endif case RenderType::DM: { OnDMSubmenuPopup(); const auto channel = Abaddon::Get().GetDiscordClient().GetChannel(static_cast<Snowflake>(row[m_columns.m_id])); @@ -1450,8 +1414,8 @@ void ChannelListTree::OnChannelSubmenuPopup() { m_menu_channel_toggle_mute.set_label("Mute"); } -#ifdef WITH_VOICE void ChannelListTree::OnVoiceChannelSubmenuPopup() { +#ifdef WITH_VOICE const auto iter = m_model->get_iter(m_path_for_menu); if (!iter) return; const auto id = static_cast<Snowflake>((*iter)[m_columns.m_id]); @@ -1463,8 +1427,11 @@ void ChannelListTree::OnVoiceChannelSubmenuPopup() { m_menu_voice_channel_join.set_sensitive(true); m_menu_voice_channel_disconnect.set_sensitive(false); } -} +#else + m_menu_voice_channel_join.set_sensitive(false); + m_menu_voice_channel_disconnect.set_sensitive(false); #endif +} void ChannelListTree::OnDMSubmenuPopup() { auto iter = m_model->get_iter(m_path_for_menu); diff --git a/src/components/channellist/channellisttree.hpp b/src/components/channellist/channellisttree.hpp index 17acb46..abceca9 100644 --- a/src/components/channellist/channellisttree.hpp +++ b/src/components/channellist/channellisttree.hpp @@ -104,10 +104,7 @@ protected: Gtk::TreeModel::iterator AddGuild(const GuildData &guild, const Gtk::TreeNodeChildren &root); Gtk::TreeModel::iterator UpdateCreateChannelCategory(const ChannelData &channel); Gtk::TreeModel::iterator CreateThreadRow(const Gtk::TreeNodeChildren &children, const ChannelData &channel); - -#ifdef WITH_VOICE Gtk::TreeModel::iterator CreateVoiceParticipantRow(const UserData &user, const Gtk::TreeNodeChildren &parent); -#endif void UpdateChannelCategory(const ChannelData &channel); @@ -162,12 +159,10 @@ protected: Gtk::MenuItem m_menu_channel_open_tab; #endif -#ifdef WITH_VOICE Gtk::Menu m_menu_voice_channel; Gtk::MenuItem m_menu_voice_channel_join; Gtk::MenuItem m_menu_voice_channel_disconnect; Gtk::MenuItem m_menu_voice_open_chat; -#endif Gtk::Menu m_menu_dm; Gtk::MenuItem m_menu_dm_copy_id; @@ -195,10 +190,7 @@ protected: void OnChannelSubmenuPopup(); void OnDMSubmenuPopup(); void OnThreadSubmenuPopup(); - -#ifdef WITH_VOICE void OnVoiceChannelSubmenuPopup(); -#endif bool m_updating_listing = false; |