mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-04 11:33:27 +03:00
Merge branch 'master' into friends
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// for things that are used in stackswitchers to be able to be told when they're switched to
|
||||
|
||||
class INotifySwitched {
|
||||
public:
|
||||
virtual void on_switched_to() {};
|
||||
};
|
||||
@@ -20,7 +20,7 @@ void from_json(const nlohmann::json &j, AuditLogOptions &m) {
|
||||
void from_json(const nlohmann::json &j, AuditLogEntry &m) {
|
||||
JS_N("target_id", m.TargetID);
|
||||
JS_O("changes", m.Changes);
|
||||
JS_D("user_id", m.UserID);
|
||||
JS_N("user_id", m.UserID);
|
||||
JS_D("id", m.ID);
|
||||
JS_D("action_type", m.Type);
|
||||
JS_O("options", m.Options);
|
||||
|
||||
@@ -40,6 +40,9 @@ enum class AuditLogActionType {
|
||||
INTEGRATION_CREATE = 80,
|
||||
INTEGRATION_UPDATE = 81,
|
||||
INTEGRATION_DELETE = 82,
|
||||
STAGE_INSTANCE_CREATE = 83,
|
||||
STAGE_INSTANCE_UPDATE = 84,
|
||||
STAGE_INSTANCE_DELETE = 85,
|
||||
};
|
||||
|
||||
struct AuditLogChange {
|
||||
@@ -66,7 +69,7 @@ struct AuditLogOptions {
|
||||
struct AuditLogEntry {
|
||||
Snowflake ID;
|
||||
std::string TargetID; // null
|
||||
Snowflake UserID;
|
||||
std::optional<Snowflake> UserID;
|
||||
AuditLogActionType Type;
|
||||
std::optional<std::string> Reason;
|
||||
std::optional<std::vector<AuditLogChange>> Changes;
|
||||
|
||||
@@ -21,6 +21,22 @@ enum class ChannelType : int {
|
||||
GUILD_STAGE_VOICE = 13,
|
||||
};
|
||||
|
||||
enum class StagePrivacy {
|
||||
PUBLIC = 1,
|
||||
GUILD_ONLY = 2,
|
||||
};
|
||||
|
||||
constexpr const char *GetStagePrivacyDisplayString(StagePrivacy e) {
|
||||
switch (e) {
|
||||
case StagePrivacy::PUBLIC:
|
||||
return "Public";
|
||||
case StagePrivacy::GUILD_ONLY:
|
||||
return "Guild Only";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
struct ChannelData {
|
||||
Snowflake ID;
|
||||
ChannelType Type;
|
||||
|
||||
@@ -102,7 +102,7 @@ void to_json(nlohmann::json &j, const UpdateStatusMessage &m) {
|
||||
j["d"]["status"] = "online";
|
||||
break;
|
||||
case PresenceStatus::Offline:
|
||||
j["d"]["status"] = "offline";
|
||||
j["d"]["status"] = "invisible";
|
||||
break;
|
||||
case PresenceStatus::Idle:
|
||||
j["d"]["status"] = "idle";
|
||||
|
||||
@@ -5,6 +5,7 @@ using namespace std::string_literals;
|
||||
|
||||
GuildSettingsAuditLogPane::GuildSettingsAuditLogPane(Snowflake id)
|
||||
: GuildID(id) {
|
||||
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsAuditLogPane::OnMap));
|
||||
set_name("guild-audit-log-pane");
|
||||
set_hexpand(true);
|
||||
set_vexpand(true);
|
||||
@@ -14,7 +15,7 @@ GuildSettingsAuditLogPane::GuildSettingsAuditLogPane(Snowflake id)
|
||||
add(m_list);
|
||||
}
|
||||
|
||||
void GuildSettingsAuditLogPane::on_switched_to() {
|
||||
void GuildSettingsAuditLogPane::OnMap() {
|
||||
if (m_requested) return;
|
||||
m_requested = true;
|
||||
|
||||
@@ -33,7 +34,11 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
auto label = Gtk::manage(new Gtk::Label);
|
||||
label->set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
|
||||
auto user = *discord.GetUser(entry.UserID);
|
||||
Glib::ustring user_markup = "<b>Unknown User</b>";
|
||||
if (entry.UserID.has_value()) {
|
||||
if (auto user = discord.GetUser(*entry.UserID); user.has_value())
|
||||
user_markup = discord.GetUser(*entry.UserID)->GetEscapedBoldString<false>();
|
||||
}
|
||||
|
||||
// spaghetti moment
|
||||
Glib::ustring markup;
|
||||
@@ -41,7 +46,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
switch (entry.Type) {
|
||||
case AuditLogActionType::GUILD_UPDATE: {
|
||||
markup =
|
||||
user.GetEscapedBoldString<false>() +
|
||||
user_markup +
|
||||
" made changes to <b>" +
|
||||
Glib::Markup::escape_text(guild.Name) +
|
||||
"</b>";
|
||||
@@ -63,7 +68,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
} break;
|
||||
case AuditLogActionType::CHANNEL_CREATE: {
|
||||
const auto type = *entry.GetNewFromKey<ChannelType>("type");
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created a " + (type == ChannelType::GUILD_VOICE ? "voice" : "text") +
|
||||
" channel <b>#" +
|
||||
Glib::Markup::escape_text(*entry.GetNewFromKey<std::string>("name")) +
|
||||
@@ -83,12 +88,12 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
case AuditLogActionType::CHANNEL_UPDATE: {
|
||||
const auto target_channel = discord.GetChannel(entry.TargetID);
|
||||
if (target_channel.has_value()) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" made changes to <b>#" +
|
||||
Glib::Markup::escape_text(*target_channel->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" made changes to <b><#" +
|
||||
entry.TargetID +
|
||||
"></b>";
|
||||
@@ -126,7 +131,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::CHANNEL_DELETE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" removed <b>#" +
|
||||
Glib::Markup::escape_text(*entry.GetOldFromKey<std::string>("name")) +
|
||||
"</b>";
|
||||
@@ -134,11 +139,11 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
case AuditLogActionType::CHANNEL_OVERWRITE_CREATE: {
|
||||
const auto channel = discord.GetChannel(entry.TargetID);
|
||||
if (channel.has_value()) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created channel overrides for <b>#" +
|
||||
Glib::Markup::escape_text(*channel->Name) + "</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created channel overrides for <b><#" +
|
||||
entry.TargetID + "></b>";
|
||||
}
|
||||
@@ -146,11 +151,11 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
case AuditLogActionType::CHANNEL_OVERWRITE_UPDATE: {
|
||||
const auto channel = discord.GetChannel(entry.TargetID);
|
||||
if (channel.has_value()) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated channel overrides for <b>#" +
|
||||
Glib::Markup::escape_text(*channel->Name) + "</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated channel overrides for <b><#" +
|
||||
entry.TargetID + "></b>";
|
||||
}
|
||||
@@ -158,24 +163,24 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
case AuditLogActionType::CHANNEL_OVERWRITE_DELETE: {
|
||||
const auto channel = discord.GetChannel(entry.TargetID);
|
||||
if (channel.has_value()) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" removed channel overrides for <b>#" +
|
||||
Glib::Markup::escape_text(*channel->Name) + "</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" removed channel overrides for <b><#" +
|
||||
entry.TargetID + "></b>";
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_KICK: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" kicked <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_PRUNE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" pruned <b>" +
|
||||
*entry.Options->MembersRemoved +
|
||||
"</b> members";
|
||||
@@ -185,21 +190,21 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_BAN_ADD: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" banned <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_BAN_REMOVE: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" removed the ban for <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_UPDATE: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b>";
|
||||
@@ -221,7 +226,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_ROLE_UPDATE: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated roles for <b>" +
|
||||
target_user->GetEscapedString() + "</b>";
|
||||
if (entry.Changes.has_value())
|
||||
@@ -239,7 +244,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_MOVE: {
|
||||
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" moved <b>" +
|
||||
*entry.Options->Count +
|
||||
" user" +
|
||||
@@ -249,27 +254,27 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::MEMBER_DISCONNECT: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" disconnected <b>" +
|
||||
*entry.Options->Count +
|
||||
"</b> users from voice";
|
||||
} break;
|
||||
case AuditLogActionType::BOT_ADD: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" added <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b> to the server";
|
||||
} break;
|
||||
case AuditLogActionType::ROLE_CREATE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created the role <b>" +
|
||||
*entry.GetNewFromKey<std::string>("name") +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::ROLE_UPDATE: {
|
||||
const auto role = discord.GetRole(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated the role <b>" +
|
||||
(role.has_value() ? Glib::Markup::escape_text(role->Name) : Glib::ustring(entry.TargetID)) +
|
||||
"</b>";
|
||||
@@ -297,14 +302,14 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::ROLE_DELETE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted the role <b>" +
|
||||
*entry.GetOldFromKey<std::string>("name") +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::INVITE_CREATE: {
|
||||
const auto code = *entry.GetNewFromKey<std::string>("code");
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created an invite <b>" + code + "</b>";
|
||||
if (entry.Changes.has_value())
|
||||
for (const auto &change : *entry.Changes) {
|
||||
@@ -328,13 +333,13 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::INVITE_DELETE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted an invite <b>" +
|
||||
*entry.GetOldFromKey<std::string>("code") +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::WEBHOOK_CREATE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created the webhook <b>" +
|
||||
Glib::Markup::escape_text(*entry.GetNewFromKey<std::string>("name")) +
|
||||
"</b>";
|
||||
@@ -356,12 +361,12 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
webhookptr = &webhook;
|
||||
}
|
||||
if (webhookptr != nullptr) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated the webhook <b>" +
|
||||
Glib::Markup::escape_text(webhookptr->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated a webhook";
|
||||
}
|
||||
if (entry.Changes.has_value())
|
||||
@@ -385,19 +390,19 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::WEBHOOK_DELETE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted the webhook <b>" +
|
||||
Glib::Markup::escape_text(*entry.GetOldFromKey<std::string>("name")) +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::EMOJI_CREATE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" created the emoji <b>" +
|
||||
Glib::Markup::escape_text(*entry.GetNewFromKey<std::string>("name")) +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::EMOJI_UPDATE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" updated the emoji <b>" +
|
||||
Glib::Markup::escape_text(*entry.GetOldFromKey<std::string>("name")) +
|
||||
"</b>";
|
||||
@@ -408,7 +413,7 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
"</b>");
|
||||
} break;
|
||||
case AuditLogActionType::EMOJI_DELETE: {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted the emoji <b>" +
|
||||
Glib::Markup::escape_text(*entry.GetOldFromKey<std::string>("name")) +
|
||||
"</b>";
|
||||
@@ -417,26 +422,26 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||
const auto count = *entry.Options->Count;
|
||||
if (channel.has_value()) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted <b>" + count + "</b> messages in <b>#" +
|
||||
Glib::Markup::escape_text(*channel->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted <b>" + count + "</b> messages";
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::MESSAGE_BULK_DELETE: {
|
||||
const auto channel = discord.GetChannel(entry.TargetID);
|
||||
if (channel.has_value()) {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted <b>" +
|
||||
*entry.Options->Count +
|
||||
"</b> messages in <b>#" +
|
||||
Glib::Markup::escape_text(*channel->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" deleted <b>" +
|
||||
*entry.Options->Count +
|
||||
"</b> messages";
|
||||
@@ -444,18 +449,94 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
||||
} break;
|
||||
case AuditLogActionType::MESSAGE_PIN: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" pinned a message by <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::MESSAGE_UNPIN: {
|
||||
const auto target_user = discord.GetUser(entry.TargetID);
|
||||
markup = user.GetEscapedBoldString<false>() +
|
||||
markup = user_markup +
|
||||
" unpinned a message by <b>" +
|
||||
target_user->GetEscapedString() +
|
||||
"</b>";
|
||||
} break;
|
||||
case AuditLogActionType::STAGE_INSTANCE_CREATE: {
|
||||
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||
if (channel.has_value()) {
|
||||
markup = user_markup +
|
||||
" started the stage for <b>" +
|
||||
Glib::Markup::escape_text(*channel->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user_markup +
|
||||
" started the stage for <b>" +
|
||||
std::to_string(*entry.Options->ChannelID) +
|
||||
"</b>";
|
||||
}
|
||||
|
||||
if (entry.Changes.has_value()) {
|
||||
for (const auto &change : *entry.Changes) {
|
||||
if (change.Key == "topic" && change.NewValue.has_value()) {
|
||||
extra_markup.push_back(
|
||||
"Set the topic to <b>" +
|
||||
Glib::Markup::escape_text(change.NewValue->get<std::string>()) +
|
||||
"</b>");
|
||||
} else if (change.Key == "privacy_level" && change.NewValue.has_value()) {
|
||||
Glib::ustring str = Glib::Markup::escape_text(GetStagePrivacyDisplayString(change.NewValue->get<StagePrivacy>()));
|
||||
extra_markup.push_back(
|
||||
"Set the privacy level to <b>" +
|
||||
str +
|
||||
"</b>");
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::STAGE_INSTANCE_UPDATE: {
|
||||
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||
if (channel.has_value()) {
|
||||
markup = user_markup +
|
||||
" updated the stage for <b>" +
|
||||
Glib::Markup::escape_text(*channel->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user_markup +
|
||||
" updated the stage for <b>" +
|
||||
std::to_string(*entry.Options->ChannelID) +
|
||||
"</b>";
|
||||
}
|
||||
|
||||
if (entry.Changes.has_value()) {
|
||||
for (const auto &change : *entry.Changes) {
|
||||
if (change.Key == "topic" && change.NewValue.has_value()) {
|
||||
extra_markup.push_back(
|
||||
"Set the topic to <b>" +
|
||||
Glib::Markup::escape_text(change.NewValue->get<std::string>()) +
|
||||
"</b>");
|
||||
} else if (change.Key == "privacy_level" && change.NewValue.has_value()) {
|
||||
Glib::ustring str = Glib::Markup::escape_text(GetStagePrivacyDisplayString(change.NewValue->get<StagePrivacy>()));
|
||||
extra_markup.push_back(
|
||||
"Set the privacy level to <b>" +
|
||||
str +
|
||||
"</b>");
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case AuditLogActionType::STAGE_INSTANCE_DELETE: {
|
||||
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||
if (channel.has_value()) {
|
||||
markup = user_markup +
|
||||
" ended the stage for <b>" +
|
||||
Glib::Markup::escape_text(*channel->Name) +
|
||||
"</b>";
|
||||
} else {
|
||||
markup = user_markup +
|
||||
" ended the stage for <b>" +
|
||||
std::to_string(*entry.Options->ChannelID) +
|
||||
"</b>";
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
markup = "<i>Unknown action</i>";
|
||||
break;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "../../components//inotifyswitched.hpp"
|
||||
#include "../../discord/objects.hpp"
|
||||
|
||||
class GuildSettingsAuditLogPane : public Gtk::ScrolledWindow, public INotifySwitched {
|
||||
class GuildSettingsAuditLogPane : public Gtk::ScrolledWindow {
|
||||
public:
|
||||
GuildSettingsAuditLogPane(Snowflake id);
|
||||
|
||||
private:
|
||||
void on_switched_to() override;
|
||||
void OnMap();
|
||||
|
||||
bool m_requested = false;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ GuildSettingsBansPane::GuildSettingsBansPane(Snowflake id)
|
||||
, m_menu_unban("Unban")
|
||||
, m_menu_copy_id("Copy ID")
|
||||
, m_model(Gtk::ListStore::create(m_columns)) {
|
||||
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsBansPane::OnMap));
|
||||
set_name("guild-bans-pane");
|
||||
set_hexpand(true);
|
||||
set_vexpand(true);
|
||||
@@ -54,7 +55,7 @@ GuildSettingsBansPane::GuildSettingsBansPane(Snowflake id)
|
||||
m_view.append_column("Reason", m_columns.m_col_reason);
|
||||
}
|
||||
|
||||
void GuildSettingsBansPane::on_switched_to() {
|
||||
void GuildSettingsBansPane::OnMap() {
|
||||
if (m_requested) return;
|
||||
m_requested = true;
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "../../components/inotifyswitched.hpp"
|
||||
#include "../../discord/snowflake.hpp"
|
||||
#include "../../discord/ban.hpp"
|
||||
|
||||
class GuildSettingsBansPane : public Gtk::Box, public INotifySwitched {
|
||||
class GuildSettingsBansPane : public Gtk::Box {
|
||||
public:
|
||||
GuildSettingsBansPane(Snowflake id);
|
||||
|
||||
private:
|
||||
void on_switched_to() override;
|
||||
void OnMap();
|
||||
|
||||
bool m_requested = false;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
|
||||
, m_menu_delete("Delete")
|
||||
, m_menu_copy_emoji_url("Copy Emoji URL")
|
||||
, m_menu_show_emoji("Open in Browser") {
|
||||
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnMap));
|
||||
set_name("guild-emojis-pane");
|
||||
|
||||
m_view_scroll.set_hexpand(true);
|
||||
@@ -97,7 +98,7 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
|
||||
column->set_resizable(true);
|
||||
}
|
||||
|
||||
void GuildSettingsEmojisPane::on_switched_to() {
|
||||
void GuildSettingsEmojisPane::OnMap() {
|
||||
m_view.grab_focus();
|
||||
|
||||
if (m_requested) return;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "../../components/inotifyswitched.hpp"
|
||||
#include "../../discord/emoji.hpp"
|
||||
|
||||
class GuildSettingsEmojisPane : public Gtk::Box
|
||||
, public INotifySwitched {
|
||||
class GuildSettingsEmojisPane : public Gtk::Box {
|
||||
public:
|
||||
GuildSettingsEmojisPane(Snowflake guild_id);
|
||||
|
||||
private:
|
||||
void on_switched_to() override;
|
||||
void OnMap();
|
||||
|
||||
bool m_requested = false;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ GuildSettingsInvitesPane::GuildSettingsInvitesPane(Snowflake id)
|
||||
: GuildID(id)
|
||||
, m_model(Gtk::ListStore::create(m_columns))
|
||||
, m_menu_delete("Delete") {
|
||||
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsInvitesPane::OnMap));
|
||||
set_name("guild-invites-pane");
|
||||
set_hexpand(true);
|
||||
set_vexpand(true);
|
||||
@@ -36,7 +37,7 @@ GuildSettingsInvitesPane::GuildSettingsInvitesPane(Snowflake id)
|
||||
column->set_resizable(true);
|
||||
}
|
||||
|
||||
void GuildSettingsInvitesPane::on_switched_to() {
|
||||
void GuildSettingsInvitesPane::OnMap() {
|
||||
if (m_requested) return;
|
||||
m_requested = true;
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "../../components/inotifyswitched.hpp"
|
||||
#include "../../discord/objects.hpp"
|
||||
|
||||
class GuildSettingsInvitesPane : public Gtk::ScrolledWindow, public INotifySwitched {
|
||||
class GuildSettingsInvitesPane : public Gtk::ScrolledWindow {
|
||||
public:
|
||||
GuildSettingsInvitesPane(Snowflake id);
|
||||
|
||||
private:
|
||||
void on_switched_to() override;
|
||||
void OnMap();
|
||||
|
||||
bool m_requested = false;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "guildsettingswindow.hpp"
|
||||
#include "../abaddon.hpp"
|
||||
#include "../components/inotifyswitched.hpp"
|
||||
|
||||
GuildSettingsWindow::GuildSettingsWindow(Snowflake id)
|
||||
: m_main(Gtk::ORIENTATION_VERTICAL)
|
||||
@@ -42,11 +41,6 @@ GuildSettingsWindow::GuildSettingsWindow(Snowflake id)
|
||||
m_switcher.set_margin_top(10);
|
||||
m_switcher.show();
|
||||
|
||||
m_stack.property_visible_child().signal_changed().connect([this]() {
|
||||
if (auto *w = dynamic_cast<INotifySwitched *>(m_stack.property_visible_child().get_value()))
|
||||
w->on_switched_to();
|
||||
});
|
||||
|
||||
m_pane_info.show();
|
||||
m_pane_members.show();
|
||||
m_pane_roles.show();
|
||||
|
||||
@@ -34,6 +34,7 @@ MutualFriendItem::MutualFriendItem(const UserData &user)
|
||||
|
||||
MutualFriendsPane::MutualFriendsPane(Snowflake id)
|
||||
: UserID(id) {
|
||||
signal_map().connect(sigc::mem_fun(*this, &MutualFriendsPane::OnMap));
|
||||
add(m_list);
|
||||
show_all_children();
|
||||
}
|
||||
@@ -49,7 +50,7 @@ void MutualFriendsPane::OnFetchRelationships(const std::vector<UserData> &users)
|
||||
}
|
||||
}
|
||||
|
||||
void MutualFriendsPane::on_switched_to() {
|
||||
void MutualFriendsPane::OnMap() {
|
||||
if (m_requested) return;
|
||||
m_requested = true;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <gtkmm.h>
|
||||
#include "../../components/inotifyswitched.hpp"
|
||||
#include "../../discord/objects.hpp"
|
||||
|
||||
class MutualFriendItem : public Gtk::Box {
|
||||
@@ -12,14 +11,14 @@ private:
|
||||
Gtk::Label m_name;
|
||||
};
|
||||
|
||||
class MutualFriendsPane : public Gtk::ScrolledWindow, public INotifySwitched {
|
||||
class MutualFriendsPane : public Gtk::ScrolledWindow {
|
||||
public:
|
||||
MutualFriendsPane(Snowflake id);
|
||||
|
||||
Snowflake UserID;
|
||||
|
||||
private:
|
||||
void on_switched_to() override;
|
||||
void OnMap();
|
||||
|
||||
bool m_requested = false;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "profilewindow.hpp"
|
||||
#include "../abaddon.hpp"
|
||||
#include "../components/inotifyswitched.hpp"
|
||||
|
||||
ProfileWindow::ProfileWindow(Snowflake user_id)
|
||||
: ID(user_id)
|
||||
@@ -71,11 +70,6 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
|
||||
m_switcher.set_halign(Gtk::ALIGN_START);
|
||||
m_switcher.set_hexpand(true);
|
||||
|
||||
m_stack.property_visible_child().signal_changed().connect([this]() {
|
||||
if (auto *w = dynamic_cast<INotifySwitched *>(m_stack.property_visible_child().get_value()))
|
||||
w->on_switched_to();
|
||||
});
|
||||
|
||||
m_stack.add(m_pane_info, "info", "User Info");
|
||||
m_stack.add(m_pane_guilds, "guilds", "Mutual Servers");
|
||||
m_stack.add(m_pane_friends, "friends", "Mutual Friends");
|
||||
|
||||
Reference in New Issue
Block a user