summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/channels.cpp25
-rw-r--r--src/components/channels.hpp5
2 files changed, 29 insertions, 1 deletions
diff --git a/src/components/channels.cpp b/src/components/channels.cpp
index 201e7c9..eb9d688 100644
--- a/src/components/channels.cpp
+++ b/src/components/channels.cpp
@@ -21,6 +21,10 @@ ChannelList::ChannelList()
, 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)
+#endif
, m_menu_dm_copy_id("_Copy ID", true)
, m_menu_dm_close("") // changes depending on if group or not
, m_menu_thread_copy_id("_Copy ID", true)
@@ -168,11 +172,15 @@ ChannelList::ChannelList()
#ifdef WITH_VOICE
m_menu_voice_channel_join.signal_activate().connect([this]() {
const auto id = static_cast<Snowflake>((*m_model->get_iter(m_path_for_menu))[m_columns.m_id]);
- printf("join voice: %llu\n", static_cast<uint64_t>(id));
m_signal_action_join_voice_channel.emit(id);
});
+ m_menu_voice_channel_disconnect.signal_activate().connect([this]() {
+ m_signal_action_disconnect_voice.emit();
+ });
+
m_menu_voice_channel.append(m_menu_voice_channel_join);
+ m_menu_voice_channel.append(m_menu_voice_channel_disconnect);
m_menu_voice_channel.show_all();
#endif
@@ -984,6 +992,17 @@ void ChannelList::OnChannelSubmenuPopup() {
#ifdef WITH_VOICE
void ChannelList::OnVoiceChannelSubmenuPopup() {
+ 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]);
+ auto &discord = Abaddon::Get().GetDiscordClient();
+ if (discord.IsConnectedToVoice()) {
+ m_menu_voice_channel_join.set_sensitive(false);
+ m_menu_voice_channel_disconnect.set_sensitive(discord.GetVoiceChannelID() == id);
+ } else {
+ m_menu_voice_channel_join.set_sensitive(true);
+ m_menu_voice_channel_disconnect.set_sensitive(false);
+ }
}
#endif
@@ -1041,6 +1060,10 @@ ChannelList::type_signal_action_open_new_tab ChannelList::signal_action_open_new
ChannelList::type_signal_action_join_voice_channel ChannelList::signal_action_join_voice_channel() {
return m_signal_action_join_voice_channel;
}
+
+ChannelList::type_signal_action_disconnect_voice ChannelList::signal_action_disconnect_voice() {
+ return m_signal_action_disconnect_voice;
+}
#endif
ChannelList::ModelColumns::ModelColumns() {
diff --git a/src/components/channels.hpp b/src/components/channels.hpp
index 8c34735..2d2b257 100644
--- a/src/components/channels.hpp
+++ b/src/components/channels.hpp
@@ -128,6 +128,7 @@ protected:
#ifdef WITH_VOICE
Gtk::Menu m_menu_voice_channel;
Gtk::MenuItem m_menu_voice_channel_join;
+ Gtk::MenuItem m_menu_voice_channel_disconnect;
#endif
Gtk::Menu m_menu_dm;
@@ -177,7 +178,10 @@ public:
#ifdef WITH_VOICE
using type_signal_action_join_voice_channel = sigc::signal<void, Snowflake>;
+ using type_signal_action_disconnect_voice = sigc::signal<void>;
+
type_signal_action_join_voice_channel signal_action_join_voice_channel();
+ type_signal_action_disconnect_voice signal_action_disconnect_voice();
#endif
type_signal_action_channel_item_select signal_action_channel_item_select();
@@ -195,5 +199,6 @@ private:
#ifdef WITH_VOICE
type_signal_action_join_voice_channel m_signal_action_join_voice_channel;
+ type_signal_action_disconnect_voice m_signal_action_disconnect_voice;
#endif
};