Merge branch 'master' into classic-channels

This commit is contained in:
ouwou committed 2023-12-27 01:57:22 -05:00
commit 1bb749687b
51 files changed
+735 -1018

No files matched your search

+7
View File
@@ -29,6 +29,7 @@ jobs:
if_true: >-
git
make
unzip
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
@@ -41,6 +42,7 @@ jobs:
if_false: >-
git
make
unzip
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
@@ -95,6 +97,11 @@ jobs:
mkdir -p 16x16/devices 24x24/devices 32x32/devices 48x48/devices 64x64/devices 96x96/devices scalable/devices
mkdir -p 16x16/status 24x24/status 32x32/status 48x48/status 64x64/status 96x96/status scalable/status
cd ${GITHUB_WORKSPACE}
wget https://github.com/rtlewis1/GTK/archive/refs/heads/Material-Black-Colors-Desktop.zip
unzip Material-Black-Colors-Desktop.zip 'GTK-Material-Black-Colors-Desktop/Material-Black-Cherry/**/*'
mkdir -p ${artifact_dir}/share/themes
mv ./GTK-Material-Black-Colors-Desktop/Material-Black-Cherry ${artifact_dir}/share/themes/Material-Black-Cherry
cp -r ci/tree/. ${artifact_dir}
cp ci/gtk-for-windows/gtk-nsis-pack/share/icons/Adwaita/index.theme ${artifact_dir}/share/icons/Adwaita/index.theme
cat "ci/used-icons.txt" | sed 's/\r$//' | xargs -I % cp ci/gtk-for-windows/gtk-nsis-pack/share/icons/Adwaita/16x16/%.symbolic.png ${artifact_dir}/share/icons/Adwaita/16x16/%.symbolic.png || :
cat "ci/used-icons.txt" | sed 's/\r$//' | xargs -I % cp ci/gtk-for-windows/gtk-nsis-pack/share/icons/Adwaita/24x24/%.symbolic.png ${artifact_dir}/share/icons/Adwaita/24x24/%.symbolic.png || :
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

+11 -9
View File
@@ -2,7 +2,16 @@
---
Alternative Discord client made in C++ with GTK
<img src="/.readme/s3.png">
<table>
<tr>
<td><img src="/.readme/s5.png"></td>
<td><img src="/.readme/s6.png"></td>
</tr>
<tr>
<td><img src="/.readme/s7.png"></td>
<td><img src="/.readme/s8.png"></td>
</tr>
</table>
<a href="https://discord.gg/wkCU3vuzG5"><img src="https://discord.com/api/guilds/858156817711890443/widget.png?style=shield"></a>
@@ -11,7 +20,7 @@ Current features:
* Not Electron
* Voice support
* Handles most types of chat messages including embeds, images, and replies
* Completely styleable/customizable with CSS (if you have a system GTK theme it won't really use it though)
* Completely styleable/customizable
* Identifies to Discord as the web client unlike other clients so less likely to be falsely flagged as spam<sup>1</sup>
* Set status
* Unread and mention indicators
@@ -199,11 +208,6 @@ spam filter's wrath:
| `.embed-field-value` | The value of an embed field |
| `.embed-footer` | The footer of an embed |
| `.member-list` | Container of the member list |
| `.status-indicator` | The status indicator |
| `.online` | Applied to status indicators when the associated user is online |
| `.idle` | Applied to status indicators when the associated user is away |
| `.dnd` | Applied to status indicators when the associated user is on do not disturb |
| `.offline` | Applied to status indicators when the associated user is offline |
| `.typing-indicator` | The typing indicator (also used for replies) |
Used in reorderable list implementation:
@@ -306,10 +310,8 @@ For example, memory_db would be set by adding `memory_db = true` under the line
| Setting | Type | Description |
|-------------------------|--------|-----------------------------------------------------|
| `linkcolor` | string | color to use for links in messages |
| `expandercolor` | string | color to use for the expander in the channel list |
| `nsfwchannelcolor` | string | color to use for NSFW channels in the channel list |
| `channelcolor` | string | color to use for SFW channels in the channel list |
| `mentionbadgecolor` | string | background color for mention badges |
| `mentionbadgetextcolor` | string | color to use for number displayed on mention badges |
| `unreadcolor` | string | color to use for the unread indicator |
+4 -1
View File
@@ -38,6 +38,7 @@
/bin/libidn2-0.dll
/bin/libintl-8.dll
/bin/libjpeg-8.dll
/bin/liblzma-5.dll
/bin/libnghttp2-14.dll
/bin/libopus-0.dll
/bin/libpango-1.0-0.dll
@@ -49,8 +50,9 @@
/bin/libpixman-1-0.dll
/bin/libpng16-16.dll
/bin/libpsl-5.dll
/bin/librsvg-2-2.dll
/bin/libsigc-2.0-0.dll
/bin/libsodium-23.dll
/bin/libsodium-26.dll
/bin/libspdlog.dll
/bin/libsqlite3-0.dll
/bin/libssh2-1.dll
@@ -59,6 +61,7 @@
/bin/libthai-0.dll
/bin/libunistring-5.dll
/bin/libwinpthread-1.dll
/bin/libxml2-2.dll
/bin/libzstd.dll
/bin/zlib1.dll
/../usr/bin/msys-2.0.dll
+2
View File
@@ -0,0 +1,2 @@
[Settings]
gtk-theme-name=Material-Black-Cherry
-97
View File
@@ -1,97 +0,0 @@
/*
application wide stuff
has to be separate to allow main.css to override certain things
*/
.app-window label:not(:disabled) {
color: @text_color;
}
.app-window entry {
background: @secondary_color;
color: @text_color;
border: 1px solid #1c2e40;
}
.app-window button {
background: @secondary_color;
color: @text_color;
text-shadow: none;
box-shadow: none;
}
.app-window button:checked {
border-top: 0px;
border-left: 0px;
border-right: 0px;
border-bottom: 3px solid #39a2ed;
color: #ffffff;
}
.app-window button:not(:checked) {
border: 3px #0000ff;
}
.app-window.background {
background: @background_color;
}
.app-window treeview {
color: @text_color;
}
.app-window treeview:not(:selected) {
background: @secondary_color;
}
.app-window list, .app-popup list {
background: @secondary_color;
}
.app-window paned separator {
background: @background_color;
}
.app-window scrollbar {
background: @background_color;
border-left: 1px solid transparent;
}
.app-window menubar, menu {
background: @background_color;
color: #cccccc;
}
.app-window textview text {
caret-color: #ababab;
}
.app-window check,
.app-window radio {
background-clip: padding-box;
background: @secondary_color;
border-color: #070707;
box-shadow: 0 1px rgba(0, 0, 0, 0);
color: #dddddd;
}
.app-window check:checked,
.app-window radio:checked {
background-clip: border-box;
background: #0b4285;
border-color: #092444;
box-shadow: 0 1px rgba(0, 0, 0, 0);
color: #dddddd;
}
.app-window colorswatch {
box-shadow: 0 1px rgba(0, 0, 0, 0);
}
.app-window scale {
padding-top: 0px;
padding-bottom: 0px;
margin-top: 0px;
margin-bottom: 0px;
color: @text_color;
}
-35
View File
@@ -1,35 +0,0 @@
.embed {
border-radius: 5px;
padding: 10px;
}
.embed-footer {
margin-top: 5px;
font-size: 11px;
}
.embed-author {
margin-bottom: 10px;
font-size: 12px;
}
.message-attachment-box {
border: 1px solid #aaaaaa;
padding: 2px 5px 2px 5px;
}
.status-indicator.dnd {
color: #982929;
}
.status-indicator.online {
color: #43B581;
}
.status-indicator.offline {
color: #808080;
}
.status-indicator.idle {
color: #FAA61A;
}
+72 -326
View File
@@ -1,12 +1,7 @@
@define-color background_color #141414;
@define-color secondary_color #111111;
@define-color text_color #fbfbfb;
.embed {
background-color: rgba(0, 0, 0, 0.2);
color: #cbcbcb;
border-radius: 5px;
padding: 10px;
background-color: rgba(0.0, 0.0, 0.0, 0.1);
}
.embed-footer {
@@ -19,140 +14,7 @@
font-size: 12px;
}
.channel-list {
background-color: @secondary_color;
}
.channel-row-label {
padding: 5px;
}
.channel-row-label, .channel-row-label text {
color: @text_color;
background: rgba(0, 0, 0, 0);
}
.channel-row-label.nsfw text {
color: #ed6666;
}
.channel-row:focus {
background-color: #34495e;
}
.channel-row-category {
padding-left: 15px;
color: #ff5370;
}
.channel-row-channel {
padding-left: 30px;
}
.messages, .message-container {
background-color: @background_color;
}
.messages {
padding: 15px;
}
.message-container-extra {
color: #78909c;
}
.message-container-timestamp {
color: #78909c;
}
.message-text {
/* this isnt stricly necessary but it fixes emoji clipping */
padding-bottom: 5px;
}
.message-text:not(.failed) text, .message-reply {
color: @text_color;
}
.message-text.pending text {
color: shade(@text_color, 0.5);
}
.message-text.failed text {
color: #b72d4f;
}
.message-reply {
border-left: 2px solid gray;
padding-left: 20px;
padding-top: 6px;
padding-bottom: 6px;
opacity: 0.7;
}
.message-text + .message-text {
padding-top: 5px;
}
.message-text text {
background-color: @background_color;
}
.message-input, .message-input textview, .message-input textview text {
background-color: #242424;
color: #adadad;
border-radius: 3px;
border: 1px solid transparent;
}
.message-input {
border: 1px solid #444444;
margin-right: 15px;
}
.message-input.replying {
border: 1px solid #026FB9;
}
.message-input.editing {
border: 1px solid #b9026f;
}
.message-input.bad-input {
border: 1px solid #dd3300;
}
.message-input-browse-icon {
color: #b9bbbe;
margin-left: 5px;
margin-top: 11px;
}
/* i dont think theres a way to circumvent having to do this to adjust around the browse icon */
.message-input:not(.with-browser-icon) {
padding: 0px 0px 0px 5px;
}
.message-input.with-browse-icon {
padding: 0px 0px 0px 30px;
}
.members {
background-color: @background_color;
}
.members-row-label {
color: @text_color;
padding: 5px;
}
.members-row-member {
padding: 0;
padding-left: 15px;
}
.message-attachment-box {
color: #aaaaaa;
border: 1px solid #aaaaaa;
padding: 2px 5px 2px 5px;
}
@@ -161,61 +23,6 @@
margin: 5px;
}
.message-component {
margin: 5px;
}
.message-component.primary {
background: #5865F2;
}
.message-component.secondary, .message-component.link {
background: #4F545C;
}
.message-component.success {
background: #43B581;
}
.message-component.danger {
background: #F04747;
}
.reaction-box {
padding: 2px 5px 2px 5px;
margin: 0px 0px 0px 0px;
background-color: rgba(0.4, 0.4, 0.4, 0.4);
border-radius: 5px;
border: 1px solid transparent;
}
.reaction-box.reacted {
border: 1px solid white;
}
.reaction-count {
color: @text_color;
}
.completer {
background-color: @secondary_color;
padding: 5px;
}
.completer-entry {
color: @text_color;
}
.completer-entry-image {
margin-right: 6px;
}
.typing-indicator {
margin-top: 10px;
margin-bottom: -7px;
color: @text_color;
}
.status-indicator.dnd {
color: #982929;
}
@@ -232,6 +39,26 @@
color: #FAA61A;
}
.message-input textview, .message-input textview text {
background-color: inherit;
}
.message-text, .message-text text {
background: inherit;
}
.message-input textview {
padding: 10px 5px;
}
.message-reply {
border-left: 2px solid gray;
padding-left: 10px;
padding-top: 6px;
padding-bottom: 6px;
opacity: 0.8;
}
.profile-main-container {
padding: 20px;
}
@@ -242,31 +69,13 @@
}
.profile-username-nondisplay {
margin-left: 10px;
}
.profile-badge {
margin-right: 10px;
margin-left: 10px;
}
.profile-switcher {
padding-top: 5px;
}
.profile-connections {
margin-top: 10px;
}
.profile-connection {
background: @secondary_color;
border-radius: 15px;
margin-right: 20px;
}
.profile-connection box {
padding: 5px;
}
.profile-stack {
padding-top: 5px;
}
@@ -276,126 +85,63 @@
padding-bottom: 5px;
}
.profile-notes-text, .profile-notes-text text {
background: @secondary_color;
}
.profile-notes-text text {
border-radius: 5px;
border: 1px solid #36515e;
color: @text_color;
padding-bottom: 5px;
}
.profile-badges {
padding-left: 5px;
}
.guild-members-pane-info {
padding: 10px;
.profile-badge {
margin-right: 5px;
}
.drag-hover-top {
background: linear-gradient(to bottom, rgba(255, 66, 66, 0.65) 0%, rgba(0, 0, 0, 0) 35%);
}
.drag-hover-bottom {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 65%, rgba(255, 66, 66, 0.65) 100%);
}
.friends-list list {
background: @background_color;
padding-left: 10px;
}
.friends-list-row-bot {
color: #ff0000;
}
.channel-tab-switcher .box {
margin: -7px -1px -7px -1px;
background: #2a2a2a;
border: 1px solid black;
}
.channel-tab-switcher tab:hover {
box-shadow: inset 0 -6px #17633e;
}
.channel-tab-switcher tab:checked {
box-shadow: inset 0 -6px #2feb90;
}
.channel-tab-switcher tab {
background: #1A1A1A;
border: 1px solid #808080;
min-height: 35px;
}
.channel-tab-switcher tab.needs-attention:not(:checked) {
font-weight: bold;
animation: 150ms ease-in;
/* background-image: radial-gradient(ellipse at bottom, #FF5370, #1A1A1A 30%); */
box-shadow: inset 0 -6px red;
}
.channel-tab-switcher tab > button {
border: none;
padding: 0;
margin: 5px;
min-width: 16px;
min-height: 16px;
color: #FF5370;
background-color: rgba(0.21, 0.21, 0.21, 0.5);
}
.channel-tab-switcher tab > button:hover {
background-color: alpha(#ff0000, 0.5);
}
.message-progress {
border: none;
margin-bottom: -8px;
}
.message-progress trough {
border: none;
background-color: transparent;
}
.message-progress progress {
border: none;
background-color: #dd3300;
margin-left: 1px;
}
.voice-info {
background-color: #0B0B0B;
padding: 5px;
border: 1px solid #202020;
}
.voice-info-disconnect-image {
color: #DDDDDD;
}
.voice-info-status {
font-weight: bold;
}
.voice-info-location {
}
.voice-state-server {
color: red;
}
spinbutton {
color: @text_color;
.profile-connections {
margin-top: 10px;
}
.emoji-picker, .emoji-picker stack box {
background-color: @background_color;
.profile-connection {
padding: 5px;
border-radius: 10px;
border: 1px solid @theme_fg_color;
}
.profile-connection-image {
padding-right: 5px;
}
.reaction-box {
padding: 2px 5px 2px 5px;
border-radius: 5px;
border: 1px solid @theme_fg_color;
}
.reaction-box.reacted {
border: 1px solid #5865f2;
background-color: alpha(@theme_selected_bg_color, 0.5);
}
.set-status-dialog .dialog-vbox {
padding: 5px;
}
.set-status-dialog .dialog-action-area {
margin: 10px 5px 5px 5px;
}
.voice-settings-window > box {
padding: 5px;
}
.voice-settings-window scale {
margin-right: 8px;
}
.message-input scrollbar.vertical slider {
min-height: 0px;
}
.message-text.pending {
color: alpha(currentColor, 0.5);
}
.message-text.failed {
color: red;
}
+1 -12
View File
@@ -177,6 +177,7 @@ static void MainEventHandler(GdkEvent *event, void *main_window) {
int Abaddon::StartGTK() {
m_gtk_app = Gtk::Application::create("com.github.uowuo.abaddon");
Glib::set_application_name(APP_TITLE);
#ifdef WITH_LIBHANDY
m_gtk_app->signal_activate().connect([] {
@@ -191,13 +192,6 @@ int Abaddon::StartGTK() {
dlg.run();
});
m_css_low_provider = Gtk::CssProvider::create();
m_css_low_provider->signal_parsing_error().connect([](const Glib::RefPtr<const Gtk::CssSection> &section, const Glib::Error &error) {
Gtk::MessageDialog dlg("low-priority css failed parsing (" + error.what() + ")", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dlg.set_position(Gtk::WIN_POS_CENTER);
dlg.run();
});
#ifdef _WIN32
bool png_found = false;
bool gif_found = false;
@@ -253,7 +247,6 @@ int Abaddon::StartGTK() {
Gtk::MessageDialog dlg(*m_main_window, "The audio engine could not be initialized!", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dlg.set_position(Gtk::WIN_POS_CENTER);
dlg.run();
return 1;
}
#endif
@@ -1086,10 +1079,6 @@ void Abaddon::ActionReloadCSS() {
Gtk::StyleContext::remove_provider_for_screen(Gdk::Screen::get_default(), m_css_provider);
m_css_provider->load_from_path(GetCSSPath("/" + GetSettings().MainCSS));
Gtk::StyleContext::add_provider_for_screen(Gdk::Screen::get_default(), m_css_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk::StyleContext::remove_provider_for_screen(Gdk::Screen::get_default(), m_css_low_provider);
m_css_low_provider->load_from_path(GetCSSPath("/application-low-priority.css"));
Gtk::StyleContext::add_provider_for_screen(Gdk::Screen::get_default(), m_css_low_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1);
} catch (Glib::Error &e) {
Gtk::MessageDialog dlg(*m_main_window, "css failed to load (" + e.what() + ")", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dlg.set_position(Gtk::WIN_POS_CENTER);
-1
View File
@@ -182,7 +182,6 @@ private:
mutable std::mutex m_mutex;
Glib::RefPtr<Gtk::Application> m_gtk_app;
Glib::RefPtr<Gtk::CssProvider> m_css_provider;
Glib::RefPtr<Gtk::CssProvider> m_css_low_provider; // registered with a lower priority to allow better customization
Glib::RefPtr<Gtk::StatusIcon> m_tray;
std::unique_ptr<MainWindow> m_main_window; // wah wah cant create a gtkstylecontext fuck you
+40 -10
View File
@@ -8,7 +8,7 @@
#include "manager.hpp"
#include <array>
#include <glibmm/main.h>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <miniaudio.h>
#include <opus.h>
#include <cstring>
@@ -61,9 +61,37 @@ void capture_data_callback(ma_device *pDevice, void *pOutput, const void *pInput
mgr->m_rtp_timestamp += 480;
}
AudioManager::AudioManager() {
void mgr_log_callback(void *pUserData, ma_uint32 level, const char *pMessage) {
auto *log = static_cast<spdlog::logger *>(pUserData);
gchar *msg = g_strstrip(g_strdup(pMessage));
switch (level) {
case MA_LOG_LEVEL_DEBUG:
log->debug(msg);
break;
case MA_LOG_LEVEL_INFO:
log->info(msg);
break;
case MA_LOG_LEVEL_WARNING:
log->warn(msg);
break;
case MA_LOG_LEVEL_ERROR:
log->error(msg);
default:
break;
}
g_free(msg);
}
AudioManager::AudioManager()
: m_log(spdlog::stdout_color_mt("miniaudio")) {
m_ok = true;
ma_log_init(nullptr, &m_ma_log);
ma_log_register_callback(&m_ma_log, ma_log_callback_init(mgr_log_callback, m_log.get()));
#ifdef WITH_RNNOISE
RNNoiseInitialize();
#endif
@@ -77,7 +105,9 @@ AudioManager::AudioManager() {
}
opus_encoder_ctl(m_encoder, OPUS_SET_BITRATE(64000));
if (ma_context_init(nullptr, 0, nullptr, &m_context) != MA_SUCCESS) {
auto ctx_cfg = ma_context_config_init();
ctx_cfg.pLog = &m_ma_log;
if (ma_context_init(nullptr, 0, &ctx_cfg, &m_context) != MA_SUCCESS) {
spdlog::get("audio")->error("failed to initialize context");
m_ok = false;
return;
@@ -99,14 +129,14 @@ AudioManager::AudioManager() {
m_playback_id = *playback_id;
m_playback_config.playback.pDeviceID = &m_playback_id;
if (ma_device_init(&m_context, &m_playback_config, &m_playback_device) != MA_SUCCESS) {
spdlog::get("audio")->error("failed to initialize playback device");
if (auto code = ma_device_init(&m_context, &m_playback_config, &m_playback_device); code != MA_SUCCESS) {
spdlog::get("audio")->error("failed to initialize playback device (code: {})", static_cast<int>(code));
m_ok = false;
return;
}
if (ma_device_start(&m_playback_device) != MA_SUCCESS) {
spdlog::get("audio")->error("failed to start playback");
if (auto code = ma_device_start(&m_playback_device); code != MA_SUCCESS) {
spdlog::get("audio")->error("failed to start playback (code: {})", static_cast<int>(code));
ma_device_uninit(&m_playback_device);
m_ok = false;
return;
@@ -129,8 +159,8 @@ AudioManager::AudioManager() {
m_capture_id = *capture_id;
m_capture_config.capture.pDeviceID = &m_capture_id;
if (ma_device_init(&m_context, &m_capture_config, &m_capture_device) != MA_SUCCESS) {
spdlog::get("audio")->error("failed to initialize capture device");
if (auto code = ma_device_init(&m_context, &m_capture_config, &m_capture_device); code != MA_SUCCESS) {
spdlog::get("audio")->error("failed to initialize capture device (code: {})", static_cast<int>(code));
m_ok = false;
return;
}
@@ -185,7 +215,7 @@ void AudioManager::SetOpusBuffer(uint8_t *ptr) {
}
void AudioManager::FeedMeOpus(uint32_t ssrc, const std::vector<uint8_t> &data) {
if (!m_should_playback) return;
if (!m_should_playback || ma_device_get_state(&m_playback_device) != ma_device_state_started) return;
std::lock_guard<std::mutex> _(m_mutex);
if (m_muted_ssrcs.find(ssrc) != m_muted_ssrcs.end()) return;
+4
View File
@@ -14,6 +14,7 @@
#include <miniaudio.h>
#include <opus.h>
#include <sigc++/sigc++.h>
#include <spdlog/spdlog.h>
#ifdef WITH_RNNOISE
#include <rnnoise.h>
@@ -163,6 +164,9 @@ private:
#endif
std::atomic<uint32_t> m_rtp_timestamp = 0;
ma_log m_ma_log;
std::shared_ptr<spdlog::logger> m_log;
public:
using type_signal_opus_packet = sigc::signal<void(int payload_size)>;
type_signal_opus_packet signal_opus_packet();
+32 -2
View File
@@ -6,7 +6,8 @@ CellRendererMemberList::CellRendererMemberList()
, m_property_id(*this, "id")
, m_property_name(*this, "name")
, m_property_pixbuf(*this, "pixbuf")
, m_property_color(*this, "color") {
, m_property_color(*this, "color")
, m_property_status(*this, "status") {
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
property_xpad() = 2;
property_ypad() = 2;
@@ -35,6 +36,10 @@ Glib::PropertyProxy<Gdk::RGBA> CellRendererMemberList::property_color() {
return m_property_color.get_proxy();
}
Glib::PropertyProxy<PresenceStatus> CellRendererMemberList::property_status() {
return m_property_status.get_proxy();
}
void CellRendererMemberList::get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const {
switch (m_property_type.get_value()) {
case MemberListRenderType::Role:
@@ -117,8 +122,9 @@ void CellRendererMemberList::get_preferred_height_for_width_vfunc_member(Gtk::Wi
}
void CellRendererMemberList::render_vfunc_member(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) {
// Text
Gdk::Rectangle text_cell_area = cell_area;
text_cell_area.set_x(22);
text_cell_area.set_x(31);
const auto color = m_property_color.get_value();
if (color.get_alpha_u() > 0) {
m_renderer_text.property_foreground_rgba().set_value(color);
@@ -126,6 +132,30 @@ void CellRendererMemberList::render_vfunc_member(const Cairo::RefPtr<Cairo::Cont
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
m_renderer_text.property_foreground_set().set_value(false);
// Status indicator
// TODO: reintroduce custom status colors... somehow
cr->begin_new_path();
switch (m_property_status.get_value()) {
case PresenceStatus::Online:
cr->set_source_rgb(33.0 / 255.0, 157.0 / 255.0, 86.0 / 255.0);
break;
case PresenceStatus::Idle:
cr->set_source_rgb(230.0 / 255.0, 170.0 / 255.0, 48.0 / 255.0);
break;
case PresenceStatus::DND:
cr->set_source_rgb(233.0 / 255.0, 61.0 / 255.0, 65.0 / 255.0);
break;
case PresenceStatus::Offline:
cr->set_source_rgb(122.0 / 255.0, 126.0 / 255.0, 135.0 / 255.0);
break;
}
cr->arc(background_area.get_x() + 6.0 + 16.0 + 6.0, background_area.get_y() + background_area.get_height() / 2.0, 2.0, 0.0, 2 * (4 * std::atan(1)));
cr->close_path();
cr->fill_preserve();
cr->stroke();
// Icon
const double icon_x = background_area.get_x() + 6.0;
const double icon_y = background_area.get_y() + background_area.get_height() / 2.0 - 8.0;
Gdk::Cairo::set_source_pixbuf(cr, m_property_pixbuf.get_value(), icon_x, icon_y);
@@ -1,5 +1,6 @@
#pragma once
#include <gtkmm/cellrenderer.h>
#include "discord/activity.hpp"
enum class MemberListRenderType : uint8_t {
Role,
@@ -16,6 +17,7 @@ public:
Glib::PropertyProxy<Glib::ustring> property_name();
Glib::PropertyProxy<Glib::RefPtr<Gdk::Pixbuf>> property_pixbuf();
Glib::PropertyProxy<Gdk::RGBA> property_color();
Glib::PropertyProxy<PresenceStatus> property_status();
protected:
void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override;
@@ -56,6 +58,7 @@ private:
Glib::Property<Glib::ustring> m_property_name;
Glib::Property<Glib::RefPtr<Gdk::Pixbuf>> m_property_pixbuf;
Glib::Property<Gdk::RGBA> m_property_color;
Glib::Property<PresenceStatus> m_property_status;
using type_signal_render = sigc::signal<void(uint64_t)>;
type_signal_render m_signal_render;
@@ -7,6 +7,49 @@ constexpr static double M_PI = 3.14159265358979;
constexpr static double M_PI_H = M_PI / 2.0;
constexpr static double M_PI_3_2 = M_PI * 3.0 / 2.0;
void AddUnreadIndicator(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area) {
static const auto color_setting = Gdk::RGBA(Abaddon::Get().GetSettings().UnreadIndicatorColor);
const auto color = color_setting.get_alpha_u() > 0 ? color_setting : widget.get_style_context()->get_background_color(Gtk::STATE_FLAG_SELECTED);
cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
const auto x = background_area.get_x();
const auto y = background_area.get_y();
const auto w = background_area.get_width();
const auto h = background_area.get_height();
cr->rectangle(x, y, 3, h);
cr->fill();
}
void RenderExpander(int x_offset, const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, bool is_expanded) {
constexpr static int len = 5;
int x1, y1, x2, y2, x3, y3;
if (is_expanded) {
x1 = background_area.get_x() + x_offset;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + x_offset + len;
y2 = background_area.get_y() + background_area.get_height() / 2 + len;
x3 = background_area.get_x() + x_offset + len * 2;
y3 = background_area.get_y() + background_area.get_height() / 2 - len;
} else {
x1 = background_area.get_x() + x_offset;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + x_offset + len * 2;
y2 = background_area.get_y() + background_area.get_height() / 2;
x3 = background_area.get_x() + x_offset;
y3 = background_area.get_y() + background_area.get_height() / 2 + len;
}
cr->move_to(x1, y1);
cr->line_to(x2, y2);
cr->line_to(x3, y3);
auto expander_color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelsExpanderColor);
if (expander_color.get_alpha_u() == 0) {
expander_color = widget.get_style_context()->get_background_color(Gtk::STATE_FLAG_SELECTED);
}
cr->set_source_rgb(expander_color.get_red(), expander_color.get_green(), expander_color.get_blue());
cr->stroke();
}
CellRendererChannels::CellRendererChannels()
: Glib::ObjectBase(typeid(CellRendererChannels))
, Gtk::CellRenderer()
@@ -207,30 +250,7 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc_folder(Gtk::Widg
}
void CellRendererChannels::render_vfunc_folder(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) {
constexpr static int len = 5;
int x1, y1, x2, y2, x3, y3;
if (property_expanded()) {
x1 = background_area.get_x() + 7;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + 7 + len;
y2 = background_area.get_y() + background_area.get_height() / 2 + len;
x3 = background_area.get_x() + 7 + len * 2;
y3 = background_area.get_y() + background_area.get_height() / 2 - len;
} else {
x1 = background_area.get_x() + 7;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + 7 + len * 2;
y2 = background_area.get_y() + background_area.get_height() / 2;
x3 = background_area.get_x() + 7;
y3 = background_area.get_y() + background_area.get_height() / 2 + len;
}
cr->move_to(x1, y1);
cr->line_to(x2, y2);
cr->line_to(x3, y3);
const auto expander_color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelsExpanderColor);
cr->set_source_rgb(expander_color.get_red(), expander_color.get_green(), expander_color.get_blue());
cr->stroke();
RenderExpander(7, cr, widget, background_area, property_expanded());
Gtk::Requisition text_minimum, text_natural;
m_renderer_text.get_preferred_size(widget, text_minimum, text_natural);
@@ -241,11 +261,8 @@ void CellRendererChannels::render_vfunc_folder(const Cairo::RefPtr<Cairo::Contex
Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h);
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor);
if (m_property_color.get_value().has_value()) {
m_renderer_text.property_foreground_rgba() = *m_property_color.get_value();
} else {
m_renderer_text.property_foreground_rgba() = color;
}
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
m_renderer_text.property_foreground_set() = false;
@@ -325,8 +342,6 @@ void CellRendererChannels::render_vfunc_guild(const Cairo::RefPtr<Cairo::Context
static_cast<int>(text_w),
static_cast<int>(text_h));
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor);
m_renderer_text.property_foreground_rgba() = color;
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
const bool hover_only = Abaddon::Get().GetSettings().AnimatedGuildHoverOnly;
@@ -373,14 +388,9 @@ void CellRendererChannels::render_vfunc_guild(const Cairo::RefPtr<Cairo::Context
const auto has_unread = discord.GetUnreadStateForGuild(id, total_mentions);
if (has_unread && !discord.IsGuildMuted(id)) {
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().UnreadIndicatorColor);
cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
const auto x = background_area.get_x();
const auto y = background_area.get_y();
const auto w = background_area.get_width();
const auto h = background_area.get_height();
cr->rectangle(x, y + h / 2.0 - 24.0 / 2.0, 3.0, 24.0);
cr->fill();
auto area = background_area;
area.set_y(area.get_y() + area.get_height() / 2.0 - 24.0 / 2.0);
AddUnreadIndicator(cr, widget, area);
}
if (total_mentions < 1) return;
@@ -410,42 +420,8 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc_category(Gtk::Wi
m_renderer_text.get_preferred_height_for_width(widget, width, minimum_height, natural_height);
}
void AddUnreadIndicator(const Cairo::RefPtr<Cairo::Context> &cr, const Gdk::Rectangle &background_area) {
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().UnreadIndicatorColor);
cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
const auto x = background_area.get_x();
const auto y = background_area.get_y();
const auto w = background_area.get_width();
const auto h = background_area.get_height();
cr->rectangle(x, y, 3, h);
cr->fill();
}
void CellRendererChannels::render_vfunc_category(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) {
// todo: figure out how Gtk::Arrow is rendered because i like it better :^)
constexpr static int len = 5;
int x1, y1, x2, y2, x3, y3;
if (property_expanded()) {
x1 = background_area.get_x() + 7;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + 7 + len;
y2 = background_area.get_y() + background_area.get_height() / 2 + len;
x3 = background_area.get_x() + 7 + len * 2;
y3 = background_area.get_y() + background_area.get_height() / 2 - len;
} else {
x1 = background_area.get_x() + 7;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + 7 + len * 2;
y2 = background_area.get_y() + background_area.get_height() / 2;
x3 = background_area.get_x() + 7;
y3 = background_area.get_y() + background_area.get_height() / 2 + len;
}
cr->move_to(x1, y1);
cr->line_to(x2, y2);
cr->line_to(x3, y3);
const auto expander_color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelsExpanderColor);
cr->set_source_rgb(expander_color.get_red(), expander_color.get_green(), expander_color.get_blue());
cr->stroke();
RenderExpander(7, cr, widget, background_area, property_expanded());
Gtk::Requisition text_minimum, text_natural;
m_renderer_text.get_preferred_size(widget, text_minimum, text_natural);
@@ -457,23 +433,14 @@ void CellRendererChannels::render_vfunc_category(const Cairo::RefPtr<Cairo::Cont
Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h);
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor);
auto &discord = Abaddon::Get().GetDiscordClient();
const auto id = m_property_id.get_value();
if (discord.IsChannelMuted(m_property_id.get_value())) {
auto muted = color;
muted.set_red(muted.get_red() * 0.5);
muted.set_green(muted.get_green() * 0.5);
muted.set_blue(muted.get_blue() * 0.5);
m_renderer_text.property_foreground_rgba() = muted;
} else {
if (!discord.IsChannelMuted(m_property_id.get_value())) {
if (discord.GetUnreadChannelsCountForCategory(id) > 0) {
AddUnreadIndicator(cr, background_area);
AddUnreadIndicator(cr, widget, background_area);
}
m_renderer_text.property_foreground_rgba() = color;
}
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
m_renderer_text.property_foreground_set() = false;
}
// text channel
@@ -509,23 +476,14 @@ void CellRendererChannels::render_vfunc_channel(const Cairo::RefPtr<Cairo::Conte
const auto id = m_property_id.get_value();
const bool is_muted = discord.IsChannelMuted(id);
static const auto sfw_unmuted = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor);
m_renderer_text.property_sensitive() = false;
static const auto nsfw_color = Gdk::RGBA(Abaddon::Get().GetSettings().NSFWChannelColor);
if (m_property_nsfw.get_value())
m_renderer_text.property_foreground_rgba() = nsfw_color;
else
m_renderer_text.property_foreground_rgba() = sfw_unmuted;
if (is_muted) {
auto col = m_renderer_text.property_foreground_rgba().get_value();
col.set_red(col.get_red() * 0.5);
col.set_green(col.get_green() * 0.5);
col.set_blue(col.get_blue() * 0.5);
m_renderer_text.property_foreground_rgba() = col;
}
auto color = widget.get_style_context()->get_color(Gtk::STATE_FLAG_NORMAL);
if (property_nsfw()) color = nsfw_color;
if (is_muted) color.set_alpha(0.6);
m_renderer_text.property_foreground_rgba() = color;
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
// unset foreground to default so properties dont bleed
m_renderer_text.property_foreground_set() = false;
// unread
@@ -535,7 +493,7 @@ void CellRendererChannels::render_vfunc_channel(const Cairo::RefPtr<Cairo::Conte
if (unread_state < 0) return;
if (!is_muted) {
AddUnreadIndicator(cr, background_area);
AddUnreadIndicator(cr, widget, background_area);
}
if (unread_state < 1) return;
@@ -580,18 +538,7 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex
const auto id = m_property_id.get_value();
const bool is_muted = discord.IsChannelMuted(id);
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor);
if (Abaddon::Get().GetDiscordClient().IsChannelMuted(m_property_id.get_value())) {
auto muted = color;
muted.set_red(muted.get_red() * 0.5);
muted.set_green(muted.get_green() * 0.5);
muted.set_blue(muted.get_blue() * 0.5);
m_renderer_text.property_foreground_rgba() = muted;
} else {
m_renderer_text.property_foreground_rgba() = color;
}
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
m_renderer_text.property_foreground_set() = false;
// unread
if (!Abaddon::Get().GetSettings().Unreads) return;
@@ -600,14 +547,7 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex
if (unread_state < 0) return;
if (!is_muted) {
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().UnreadIndicatorColor);
cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
const auto x = background_area.get_x();
const auto y = background_area.get_y();
const auto w = background_area.get_width();
const auto h = background_area.get_height();
cr->rectangle(x, y, 3, h);
cr->fill();
AddUnreadIndicator(cr, widget, background_area);
}
if (unread_state < 1) return;
@@ -667,31 +607,7 @@ void CellRendererChannels::render_vfunc_voice_channel(const Cairo::RefPtr<Cairo:
cell_area.get_y() + cell_area.get_height() / 2.0 - height / 2.0);
layout->show_in_cairo_context(cr);
// expander
constexpr static int len = 5;
constexpr static int offset = 24;
int x1, y1, x2, y2, x3, y3;
if (property_expanded()) {
x1 = background_area.get_x() + offset;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + offset + len;
y2 = background_area.get_y() + background_area.get_height() / 2 + len;
x3 = background_area.get_x() + offset + len * 2;
y3 = background_area.get_y() + background_area.get_height() / 2 - len;
} else {
x1 = background_area.get_x() + offset;
y1 = background_area.get_y() + background_area.get_height() / 2 - len;
x2 = background_area.get_x() + offset + len * 2;
y2 = background_area.get_y() + background_area.get_height() / 2;
x3 = background_area.get_x() + offset;
y3 = background_area.get_y() + background_area.get_height() / 2 + len;
}
cr->move_to(x1, y1);
cr->line_to(x2, y2);
cr->line_to(x3, y3);
const auto expander_color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelsExpanderColor);
cr->set_source_rgb(expander_color.get_red(), expander_color.get_green(), expander_color.get_blue());
cr->stroke();
RenderExpander(24, cr, widget, background_area, property_expanded());
}
// voice participant
@@ -897,18 +813,7 @@ void CellRendererChannels::render_vfunc_dm(const Cairo::RefPtr<Cairo::Context> &
const auto id = m_property_id.get_value();
const bool is_muted = discord.IsChannelMuted(id);
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().ChannelColor);
if (Abaddon::Get().GetDiscordClient().IsChannelMuted(m_property_id.get_value())) {
auto muted = color;
muted.set_red(muted.get_red() * 0.5);
muted.set_green(muted.get_green() * 0.5);
muted.set_blue(muted.get_blue() * 0.5);
m_renderer_text.property_foreground_rgba() = muted;
} else {
m_renderer_text.property_foreground_rgba() = color;
}
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
m_renderer_text.property_foreground_set() = false;
Gdk::Cairo::set_source_pixbuf(cr, m_property_pixbuf.get_value(), icon_x, icon_y);
cr->rectangle(icon_x, icon_y, icon_w, icon_h);
@@ -921,14 +826,7 @@ void CellRendererChannels::render_vfunc_dm(const Cairo::RefPtr<Cairo::Context> &
if (unread_state < 0) return;
if (!is_muted) {
static const auto color = Gdk::RGBA(Abaddon::Get().GetSettings().UnreadIndicatorColor);
cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
const auto x = background_area.get_x();
const auto y = background_area.get_y();
const auto w = background_area.get_width();
const auto h = background_area.get_height();
cr->rectangle(x, y, 3, h);
cr->fill();
AddUnreadIndicator(cr, widget, background_area);
}
}
@@ -955,8 +853,11 @@ void CellRendererChannels::unread_render_mentions(const Cairo::RefPtr<Cairo::Con
int width, height;
layout->get_pixel_size(width, height);
{
static const auto bg = Gdk::RGBA(Abaddon::Get().GetSettings().MentionBadgeColor);
static const auto text = Gdk::RGBA(Abaddon::Get().GetSettings().MentionBadgeTextColor);
static const auto badge_setting = Gdk::RGBA(Abaddon::Get().GetSettings().MentionBadgeColor);
static const auto text_setting = Gdk::RGBA(Abaddon::Get().GetSettings().MentionBadgeTextColor);
auto bg = badge_setting.get_alpha_u() > 0 ? badge_setting : widget.get_style_context()->get_background_color(Gtk::STATE_FLAG_SELECTED);
auto text = text_setting.get_alpha_u() > 0 ? text_setting : widget.get_style_context()->get_color(Gtk::STATE_FLAG_SELECTED);
const auto x = cell_area.get_x() + edge - width - MentionsRightPad;
const auto y = cell_area.get_y() + cell_area.get_height() / 2.0 - height / 2.0 - 1;
@@ -1,6 +1,5 @@
#include "channellisttree.hpp"
#include "imgmanager.hpp"
#include "components/statusindicator.hpp"
#include <algorithm>
#include <map>
#include <unordered_map>
+34 -48
View File
@@ -20,7 +20,7 @@ ChatInputText::ChatInputText() {
m_textview.signal_key_press_event().connect(cb, false);
m_textview.set_hexpand(false);
m_textview.set_halign(Gtk::ALIGN_FILL);
m_textview.set_valign(Gtk::ALIGN_CENTER);
m_textview.set_valign(Gtk::ALIGN_FILL);
m_textview.set_wrap_mode(Gtk::WRAP_WORD_CHAR);
m_textview.show();
add(m_textview);
@@ -113,30 +113,25 @@ ChatInputTextContainer::ChatInputTextContainer() {
};
m_input.signal_key_press_proxy().connect(cb);
m_upload_button.set_image(m_upload_img);
m_upload_button.set_halign(Gtk::ALIGN_CENTER);
m_upload_button.set_valign(Gtk::ALIGN_CENTER);
m_upload_button.get_style_context()->add_class(GTK_STYLE_CLASS_FLAT);
m_upload_img.property_icon_name() = "document-send-symbolic";
m_upload_img.property_icon_size() = Gtk::ICON_SIZE_LARGE_TOOLBAR;
m_upload_img.get_style_context()->add_class("message-input-browse-icon");
AddPointerCursor(m_upload_ev);
m_upload_ev.signal_button_press_event().connect([this](GdkEventButton *ev) -> bool {
if (ev->button == GDK_BUTTON_PRIMARY) {
ShowFileChooser();
// return focus
m_input.grab_focus();
return true;
}
return false;
m_upload_button.signal_clicked().connect([this]() {
ShowFileChooser();
m_input.grab_focus();
});
m_upload_ev.add(m_upload_img);
add_overlay(m_upload_ev);
add(m_input);
m_upload_box.pack_start(m_upload_button);
pack_start(m_upload_box, false, false);
pack_start(m_input);
show_all_children();
// stop the overlay from using (start) padding
signal_get_child_position().connect(sigc::mem_fun(*this, &ChatInputTextContainer::GetChildPosition), false);
}
void ChatInputTextContainer::ShowFileChooser() {
@@ -160,39 +155,11 @@ ChatInputText &ChatInputTextContainer::Get() {
}
void ChatInputTextContainer::ShowChooserIcon() {
m_upload_ev.show();
m_upload_button.show();
}
void ChatInputTextContainer::HideChooserIcon() {
m_upload_ev.hide();
}
bool ChatInputTextContainer::GetChildPosition(Gtk::Widget *child, Gdk::Rectangle &pos) {
Gtk::Allocation main_alloc;
{
auto *grandchild = m_input.get_child();
int x, y;
if (grandchild->translate_coordinates(m_input, 0, 0, x, y)) {
main_alloc.set_x(x);
main_alloc.set_y(y);
} else {
main_alloc.set_x(0);
main_alloc.set_y(0);
}
main_alloc.set_width(grandchild->get_allocated_width());
main_alloc.set_height(grandchild->get_allocated_height());
}
Gtk::Requisition min, req;
child->get_preferred_size(min, req);
// let css move it around
pos.set_x(0);
pos.set_y(0);
pos.set_width(std::max(min.width, std::min(main_alloc.get_width(), req.width)));
pos.set_height(std::max(min.height, std::min(main_alloc.get_height(), req.height)));
return true;
m_upload_button.hide();
}
ChatInputTextContainer::type_signal_add_attachment ChatInputTextContainer::signal_add_attachment() {
@@ -295,7 +262,7 @@ std::vector<ChatSubmitParams::Attachment> ChatInputAttachmentContainer::GetAttac
for (auto *x : m_attachments) {
if (!x->GetFile()->query_exists())
puts("bad!");
ret.push_back({ x->GetFile(), x->GetType(), x->GetFilename() });
ret.push_back({ x->GetFile(), x->GetType(), x->GetFilename(), x->GetDescription() });
}
return ret;
}
@@ -343,6 +310,7 @@ ChatInputAttachmentItem::ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &
, m_img(Gtk::make_managed<Gtk::Image>())
, m_type(is_extant ? ChatSubmitParams::ExtantFile : ChatSubmitParams::PastedImage)
, m_filename("unknown.png")
, m_is_image(true)
, m_label("unknown.png")
, m_box(Gtk::ORIENTATION_VERTICAL) {
get_style_context()->add_class("attachment-item");
@@ -389,10 +357,18 @@ std::string ChatInputAttachmentItem::GetFilename() const {
return m_filename;
}
std::optional<std::string> ChatInputAttachmentItem::GetDescription() const {
return m_description.empty() ? std::nullopt : std::optional<std::string>(m_description);
}
bool ChatInputAttachmentItem::IsTemp() const noexcept {
return m_type == ChatSubmitParams::PastedImage;
}
bool ChatInputAttachmentItem::IsImage() const noexcept {
return m_is_image;
}
void ChatInputAttachmentItem::RemoveIfTemp() {
if (IsTemp())
m_file->remove();
@@ -420,12 +396,22 @@ void ChatInputAttachmentItem::SetupMenu() {
}
});
m_menu_set_alt_text.set_label("Change Alt-Text");
m_menu_set_alt_text.signal_activate().connect([this]() {
const auto description = Abaddon::Get().ShowTextPrompt("Enter description (alt-text) for attachment", "Enter alt-text", m_description);
if (description.has_value()) {
m_description = *description;
}
});
m_menu.add(m_menu_set_filename);
m_menu.add(m_menu_set_alt_text);
m_menu.add(m_menu_remove);
m_menu.show_all();
signal_button_press_event().connect([this](GdkEventButton *ev) -> bool {
if (ev->button == GDK_BUTTON_SECONDARY) {
m_menu_set_alt_text.set_visible(IsImage());
m_menu.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev));
return true;
}
+13 -7
View File
@@ -7,10 +7,13 @@ public:
ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &file);
ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &file, const Glib::RefPtr<Gdk::Pixbuf> &pb, bool is_extant = false);
[[nodiscard]] Glib::RefPtr<Gio::File> GetFile() const;
[[nodiscard]] ChatSubmitParams::AttachmentType GetType() const;
[[nodiscard]] std::string GetFilename() const;
[[nodiscard]] bool IsTemp() const noexcept;
Glib::RefPtr<Gio::File> GetFile() const;
ChatSubmitParams::AttachmentType GetType() const;
std::string GetFilename() const;
std::optional<std::string> GetDescription() const;
bool IsTemp() const noexcept;
bool IsImage() const noexcept;
void RemoveIfTemp();
private:
@@ -21,6 +24,7 @@ private:
Gtk::Menu m_menu;
Gtk::MenuItem m_menu_remove;
Gtk::MenuItem m_menu_set_filename;
Gtk::MenuItem m_menu_set_alt_text;
Gtk::Box m_box;
Gtk::Label m_label;
@@ -29,6 +33,8 @@ private:
Glib::RefPtr<Gio::File> m_file;
ChatSubmitParams::AttachmentType m_type;
std::string m_filename;
std::string m_description;
bool m_is_image = false;
private:
using type_signal_item_removed = sigc::signal<void>;
@@ -98,7 +104,7 @@ private:
};
// file upload, text
class ChatInputTextContainer : public Gtk::Overlay {
class ChatInputTextContainer : public Gtk::Box {
public:
ChatInputTextContainer();
@@ -110,9 +116,9 @@ public:
private:
void ShowFileChooser();
bool GetChildPosition(Gtk::Widget *child, Gdk::Rectangle &pos);
Gtk::EventBox m_upload_ev;
Gtk::Box m_upload_box;
Gtk::Button m_upload_button;
Gtk::Image m_upload_img;
ChatInputText m_input;
+21 -12
View File
@@ -46,6 +46,9 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d
for (const auto &a : data.Attachments) {
if (IsURLViewableImage(a.ProxyURL) && a.Width.has_value() && a.Height.has_value()) {
auto *widget = container->CreateImageComponent(a.ProxyURL, a.URL, *a.Width, *a.Height);
if (a.Description.has_value()) {
widget->set_tooltip_text(*a.Description);
}
container->m_main.add(*widget);
} else {
auto *widget = container->CreateAttachmentComponent(a);
@@ -361,7 +364,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const EmbedData &emb
}
return false;
});
static auto color = Abaddon::Get().GetSettings().LinkColor;
const auto color = title_label->get_style_context()->get_color(Gtk::STATE_FLAG_LINK);
title_label->override_color(Gdk::RGBA(color));
title_label->set_markup("<b>" + Glib::Markup::escape_text(*embed.Title) + "</b>");
}
@@ -620,7 +623,11 @@ Gtk::Widget *ChatMessageItemContainer::CreateReactionsComponent(const Message &d
} else { // custom
ev->set_tooltip_text(reaction.Emoji.Name);
auto img = Gtk::manage(new LazyImage(reaction.Emoji.GetURL(), 16, 16));
auto *img = Gtk::make_managed<LazyImage>(reaction.Emoji.GetURL(), 16, 16);
if (reaction.Emoji.IsEmojiAnimated() && Abaddon::Get().GetSettings().ShowAnimations) {
img->SetURL(reaction.Emoji.GetURL("gif"));
img->SetAnimated(true);
}
img->set_can_focus(false);
box->add(*img);
}
@@ -657,7 +664,12 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data)
if (role.has_value()) {
const auto author = discord.GetUser(author_id);
if (author.has_value()) {
return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + "</span></b>";
const auto is_mention = !data.Interaction.has_value() && data.DoesMention(author_id);
if (is_mention) {
return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">@" + author->GetDisplayNameEscaped(guild_id) + "</span></b>";
} else {
return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + "</span></b>";
}
}
}
}
@@ -713,16 +725,12 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data)
HandleChannelMentions(buf);
text = Glib::Markup::escape_text(buf->get_text());
}
// getting markup out of a textbuffer seems like something that to me should be really simple
// but actually is horribly annoying. replies won't have mention colors because you can't do this
// also no emojis because idk how to make a textview act like a label
// which of course would not be an issue if i could figure out how to get fonts to work on this god-forsaken framework
// oh well
// but ill manually get colors for the user who is being replied to
if (referenced.GuildID.has_value())
if (referenced.GuildID.has_value()) {
lbl->set_markup(get_author_markup(referenced.Author.ID, *referenced.GuildID) + ": " + text);
else
} else {
lbl->set_markup(get_author_markup(referenced.Author.ID) + ": " + text);
}
}
} else {
lbl->set_markup("<i>reply unavailable</i>");
@@ -848,7 +856,8 @@ void ChatMessageItemContainer::HandleLinks(Gtk::TextView &tv) {
std::string link = match.fetch(0);
auto tag = buf->create_tag();
m_link_tagmap[tag] = link;
tag->property_foreground_rgba() = Gdk::RGBA(Abaddon::Get().GetSettings().LinkColor);
const auto color = tv.get_style_context()->get_color(Gtk::STATE_FLAG_LINK);
tag->property_foreground_rgba() = color;
tag->set_property("underline", 1); // stupid workaround for vcpkg bug (i think)
const auto chars_start = g_utf8_pointer_to_offset(text.c_str(), text.c_str() + mstart);
+8 -2
View File
@@ -5,7 +5,7 @@
#include "chatlist.hpp"
#include "constants.hpp"
#ifdef WITH_LIBHANDY
#include "channeltabswitcherhandy.hpp"
#include "channeltabswitcherhandy.hpp"
#endif
ChatWindow::ChatWindow() {
@@ -109,7 +109,13 @@ ChatWindow::ChatWindow() {
m_main->add(*m_meta);
m_main->add(m_progress);
m_progress.show();
m_progress.signal_start().connect([this]() {
m_progress.show();
});
m_progress.signal_stop().connect([this]() {
m_progress.hide();
});
m_main->show();
}
+18 -1
View File
@@ -28,6 +28,7 @@ MemberList::MemberList()
column->add_attribute(renderer->property_name(), m_columns.m_name);
column->add_attribute(renderer->property_pixbuf(), m_columns.m_pixbuf);
column->add_attribute(renderer->property_color(), m_columns.m_color);
column->add_attribute(renderer->property_status(), m_columns.m_status);
m_view.append_column(*column);
m_model->set_sort_column(m_columns.m_sort, Gtk::SORT_ASCENDING);
@@ -44,6 +45,8 @@ MemberList::MemberList()
m_menu_role_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]));
});
Abaddon::Get().GetDiscordClient().signal_presence_update().connect(sigc::mem_fun(*this, &MemberList::OnPresenceUpdate));
}
Gtk::Widget *MemberList::GetRoot() {
@@ -73,6 +76,7 @@ void MemberList::UpdateMemberList() {
row[m_columns.m_color] = color_transparent;
row[m_columns.m_av_requested] = false;
row[m_columns.m_pixbuf] = Abaddon::Get().GetImageManager().GetPlaceholder(16);
row[m_columns.m_status] = Abaddon::Get().GetDiscordClient().GetUserStatus(user.ID);
m_pending_avatars[user.ID] = row_iter;
}
}
@@ -126,6 +130,7 @@ void MemberList::UpdateMemberList() {
row[m_columns.m_id] = user.ID;
row[m_columns.m_name] = user.GetDisplayNameEscaped();
row[m_columns.m_pixbuf] = Abaddon::Get().GetImageManager().GetPlaceholder(16);
row[m_columns.m_status] = Abaddon::Get().GetDiscordClient().GetUserStatus(user.ID);
row[m_columns.m_av_requested] = false;
if (const auto iter = user_to_color.find(user.ID); iter != user_to_color.end()) {
row[m_columns.m_color] = IntToRGBA(iter->second);
@@ -241,12 +246,24 @@ int MemberList::SortFunc(const Gtk::TreeModel::iterator &a, const Gtk::TreeModel
return 0;
}
void MemberList::OnPresenceUpdate(const UserData &user, PresenceStatus status) {
for (auto &role : m_model->children()) {
for (auto &member : role.children()) {
if ((*member)[m_columns.m_id] == user.ID) {
(*member)[m_columns.m_status] = status;
return;
}
}
}
}
MemberList::ModelColumns::ModelColumns() {
add(m_type);
add(m_id);
add(m_name);
add(m_pixbuf);
add(m_av_requested);
add(m_color);
add(m_status);
add(m_sort);
add(m_av_requested);
}
+3
View File
@@ -26,6 +26,8 @@ private:
int SortFunc(const Gtk::TreeModel::iterator &a, const Gtk::TreeModel::iterator &b);
void OnPresenceUpdate(const UserData &user, PresenceStatus status);
class ModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
ModelColumns();
@@ -35,6 +37,7 @@ private:
Gtk::TreeModelColumn<Glib::ustring> m_name;
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf>> m_pixbuf;
Gtk::TreeModelColumn<Gdk::RGBA> m_color;
Gtk::TreeModelColumn<PresenceStatus> m_status;
Gtk::TreeModelColumn<int> m_sort;
Gtk::TreeModelColumn<bool> m_av_requested;
+18 -1
View File
@@ -5,12 +5,19 @@ MessageUploadProgressBar::MessageUploadProgressBar() {
auto &discord = Abaddon::Get().GetDiscordClient();
discord.signal_message_progress().connect([this](const std::string &nonce, float percent) {
if (nonce == m_last_nonce) {
if (!m_active) {
m_active = true;
m_signal_start.emit();
}
set_fraction(percent);
}
});
discord.signal_message_send_fail().connect([this](const std::string &nonce, float) {
if (nonce == m_last_nonce)
if (nonce == m_last_nonce) {
set_fraction(0.0);
m_active = false;
m_signal_stop.emit();
}
});
discord.signal_message_create().connect([this](const Message &msg) {
if (msg.IsPending) {
@@ -18,6 +25,16 @@ MessageUploadProgressBar::MessageUploadProgressBar() {
} else if (msg.Nonce.has_value() && (*msg.Nonce == m_last_nonce)) {
m_last_nonce = "";
set_fraction(0.0);
m_active = false;
m_signal_stop.emit();
}
});
}
MessageUploadProgressBar::type_signal_start MessageUploadProgressBar::signal_start() {
return m_signal_start;
}
MessageUploadProgressBar::type_signal_stop MessageUploadProgressBar::signal_stop() {
return m_signal_stop;
}
+11
View File
@@ -6,5 +6,16 @@ public:
MessageUploadProgressBar();
private:
bool m_active = false;
std::string m_last_nonce;
using type_signal_start = sigc::signal<void()>;
using type_signal_stop = sigc::signal<void()>;
type_signal_start m_signal_start;
type_signal_stop m_signal_stop;
public:
type_signal_start signal_start();
type_signal_stop signal_stop();
};
-122
View File
@@ -1,122 +0,0 @@
#include "statusindicator.hpp"
static const constexpr int Diameter = 8;
StatusIndicator::StatusIndicator(Snowflake user_id)
: Glib::ObjectBase("statusindicator")
, Gtk::Widget()
, m_id(user_id)
, m_status(static_cast<PresenceStatus>(-1)) {
set_has_window(true);
set_name("status-indicator");
get_style_context()->add_class("status-indicator");
Abaddon::Get().GetDiscordClient().signal_guild_member_list_update().connect(sigc::hide(sigc::mem_fun(*this, &StatusIndicator::CheckStatus)));
auto cb = [this](const UserData &user, PresenceStatus status) {
if (user.ID == m_id) CheckStatus();
};
Abaddon::Get().GetDiscordClient().signal_presence_update().connect(sigc::track_obj(cb, *this));
CheckStatus();
}
void StatusIndicator::CheckStatus() {
const auto status = Abaddon::Get().GetDiscordClient().GetUserStatus(m_id);
const auto last_status = m_status;
get_style_context()->remove_class("online");
get_style_context()->remove_class("dnd");
get_style_context()->remove_class("idle");
get_style_context()->remove_class("offline");
get_style_context()->add_class(GetPresenceString(status));
m_status = status;
if (last_status != m_status)
queue_draw();
}
Gtk::SizeRequestMode StatusIndicator::get_request_mode_vfunc() const {
return Gtk::Widget::get_request_mode_vfunc();
}
void StatusIndicator::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const {
minimum_width = 0;
natural_width = Diameter;
}
void StatusIndicator::get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const {
minimum_height = 0;
natural_height = Diameter;
}
void StatusIndicator::get_preferred_height_vfunc(int &minimum_height, int &natural_height) const {
minimum_height = 0;
natural_height = Diameter;
}
void StatusIndicator::get_preferred_width_for_height_vfunc(int height, int &minimum_width, int &natural_width) const {
minimum_width = 0;
natural_width = Diameter;
}
void StatusIndicator::on_size_allocate(Gtk::Allocation &allocation) {
set_allocation(allocation);
if (m_window)
m_window->move_resize(allocation.get_x(), allocation.get_y(), allocation.get_width(), allocation.get_height());
}
void StatusIndicator::on_map() {
Gtk::Widget::on_map();
}
void StatusIndicator::on_unmap() {
Gtk::Widget::on_unmap();
}
void StatusIndicator::on_realize() {
set_realized(true);
if (!m_window) {
GdkWindowAttr attributes;
std::memset(&attributes, 0, sizeof(attributes));
auto allocation = get_allocation();
attributes.x = allocation.get_x();
attributes.y = allocation.get_y();
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
attributes.event_mask = get_events() | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
m_window = Gdk::Window::create(get_parent_window(), &attributes, GDK_WA_X | GDK_WA_Y);
set_window(m_window);
m_window->set_user_data(gobj());
}
}
void StatusIndicator::on_unrealize() {
m_window.reset();
Gtk::Widget::on_unrealize();
}
bool StatusIndicator::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) {
const auto allocation = get_allocation();
const auto width = allocation.get_width();
const auto height = allocation.get_height();
const auto color = get_style_context()->get_color(Gtk::STATE_FLAG_NORMAL);
cr->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
cr->arc(width / 2.0, height / 2.0, width / 3.0, 0.0, 2 * (4 * std::atan(1)));
cr->close_path();
cr->fill_preserve();
cr->stroke();
return true;
}
-29
View File
@@ -1,29 +0,0 @@
#pragma once
#include "discord/snowflake.hpp"
#include "discord/activity.hpp"
class StatusIndicator : public Gtk::Widget {
public:
StatusIndicator(Snowflake user_id);
~StatusIndicator() override = default;
protected:
Gtk::SizeRequestMode get_request_mode_vfunc() const override;
void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const override;
void get_preferred_width_for_height_vfunc(int height, int &minimum_width, int &natural_width) const override;
void get_preferred_height_vfunc(int &minimum_height, int &natural_height) const override;
void get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const override;
void on_size_allocate(Gtk::Allocation &allocation) override;
void on_map() override;
void on_unmap() override;
void on_realize() override;
void on_unrealize() override;
bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr) override;
Glib::RefPtr<Gdk::Window> m_window;
void CheckStatus();
Snowflake m_id;
PresenceStatus m_status;
};
+28 -13
View File
@@ -1,17 +1,31 @@
#include "setstatus.hpp"
static const std::array feelings = {
"wonderful",
"splendiferous",
"delicious",
"outstanding",
"amazing",
"great",
"marvelous",
"superb",
"out of this world",
"stupendous",
"tip-top",
"horrible",
};
SetStatusDialog::SetStatusDialog(Gtk::Window &parent)
: Gtk::Dialog("Set Status", parent, true)
, m_layout(Gtk::ORIENTATION_VERTICAL)
, m_bottom(Gtk::ORIENTATION_HORIZONTAL)
, m_ok("OK")
, m_cancel("Cancel")
, m_bbox(Gtk::ORIENTATION_HORIZONTAL) {
set_default_size(300, 50);
, m_cancel("Cancel") {
set_default_size(350, 200);
get_style_context()->add_class("app-window");
get_style_context()->add_class("app-popup");
get_style_context()->add_class("set-status-dialog");
m_text.set_placeholder_text("Status text");
m_text.set_placeholder_text("I feel " + Glib::ustring(feelings[rand() % feelings.size()]) + "!");
m_status_combo.append("online", "Online");
m_status_combo.append("dnd", "Do Not Disturb");
@@ -35,16 +49,17 @@ SetStatusDialog::SetStatusDialog(Gtk::Window &parent)
response(Gtk::RESPONSE_CANCEL);
});
m_bbox.pack_start(m_ok, Gtk::PACK_SHRINK);
m_bbox.pack_start(m_cancel, Gtk::PACK_SHRINK);
m_bbox.set_layout(Gtk::BUTTONBOX_END);
m_layout.pack_start(*Gtk::make_managed<Gtk::Label>("How are you, " + Abaddon::Get().GetDiscordClient().GetUserData().GetDisplayName() + "?", Gtk::ALIGN_START));
m_layout.pack_start(m_text);
m_layout.pack_start(*Gtk::make_managed<Gtk::Label>("Status", Gtk::ALIGN_START));
m_layout.pack_start(m_status_combo);
m_layout.pack_start(*Gtk::make_managed<Gtk::Label>("Activity", Gtk::ALIGN_START));
m_layout.pack_start(m_type_combo);
m_bottom.add(m_status_combo);
m_bottom.add(m_type_combo);
m_bottom.add(m_bbox);
m_layout.add(m_text);
m_layout.add(m_bottom);
get_content_area()->add(m_layout);
get_action_area()->pack_start(m_ok, Gtk::PACK_SHRINK);
get_action_area()->pack_start(m_cancel, Gtk::PACK_SHRINK);
get_action_area()->set_layout(Gtk::BUTTONBOX_START);
show_all_children();
}
+1 -3
View File
@@ -8,14 +8,12 @@ public:
PresenceStatus GetStatusType() const;
std::string GetActivityName() const;
protected:
private:
Gtk::Box m_layout;
Gtk::Box m_bottom;
Gtk::Entry m_text;
Gtk::ComboBoxText m_status_combo;
Gtk::ComboBoxText m_type_combo;
Gtk::Button m_ok;
Gtk::Button m_cancel;
Gtk::ButtonBox m_bbox;
};
+28
View File
@@ -49,6 +49,34 @@ enum class AuditLogActionType {
THREAD_CREATE = 110,
THREAD_UPDATE = 111,
THREAD_DELETE = 112,
// Unhandled:
APPLICATION_COMMAND_PERMISSION_UPDATE = 121,
SOUNDBOARD_SOUND_CREATE = 130,
SOUNDBOARD_SOUND_UPDATE = 131,
SOUNDBOARD_SOUND_DELETE = 132,
AUTO_MODERATION_RULE_CREATE = 140,
AUTO_MODERATION_RULE_UPDATE = 141,
AUTO_MODERATION_RULE_DELETE = 142,
AUTO_MODERATION_BLOCK_MESSAGE = 143,
AUTO_MODERATION_FLAG_TO_CHANNEL = 144,
AUTO_MODERATION_USER_COMMUNICATION_DISABLED = 145,
AUTO_MODERATION_QUARANTINE_USER = 146,
CREATOR_MONETIZATION_REQUEST_CREATED = 150,
CREATOR_MONETIZATION_TERMS_ACCEPTED = 151,
ONBOARDING_PROMPT_CREATE = 163,
ONBOARDING_PROMPT_UPDATE = 164,
ONBOARDING_PROMPT_DELETE = 165,
ONBOARDING_CREATE = 166,
ONBOARDING_UPDATE = 167,
GUILD_HOME_FEATURE_ITEM = 171,
GUILD_HOME_REMOVE_ITEM = 172,
HARMFUL_LINKS_BLOCKED_MESSAGE = 180,
HOME_SETTINGS_CREATE = 190,
HOME_SETTINGS_UPDATE = 191,
VOICE_CHANNEL_STATUS_CREATE = 192,
VOICE_CHANNEL_STATUS_DELETE = 193,
CLYDE_AI_PROFILE_UPDATE = 194
};
struct AuditLogChange {
+5
View File
@@ -20,6 +20,11 @@ enum class ChannelType : int {
GUILD_PUBLIC_THREAD = 11,
GUILD_PRIVATE_THREAD = 12,
GUILD_STAGE_VOICE = 13,
// Unimplemented:
GUILD_DIRECTORY = 14,
GUILD_FORUM = 15,
GUILD_MEDIA = 16,
};
enum class StagePrivacy {
+2
View File
@@ -1,4 +1,5 @@
#pragma once
#include <optional>
#include <vector>
#include <string>
#include <glibmm/ustring.h>
@@ -15,6 +16,7 @@ struct ChatSubmitParams {
Glib::RefPtr<Gio::File> File;
AttachmentType Type;
std::string Filename;
std::optional<std::string> Description;
};
bool Silent = false;
+8 -2
View File
@@ -518,6 +518,7 @@ void DiscordClient::SendChatMessageAttachments(const ChatSubmitParams &params, c
CreateMessageObject obj;
obj.Content = params.Message;
obj.Nonce = nonce;
obj.Attachments.emplace();
if (params.Silent) {
obj.Flags |= MessageFlags::SUPPRESS_NOTIFICATIONS;
}
@@ -541,11 +542,16 @@ void DiscordClient::SendChatMessageAttachments(const ChatSubmitParams &params, c
m_generic_dispatch.emit();
});
req.make_form();
req.add_field("payload_json", nlohmann::json(obj).dump().c_str(), CURL_ZERO_TERMINATED);
for (size_t i = 0; i < params.Attachments.size(); i++) {
auto &attachment = params.Attachments.at(i);
const auto field_name = "files[" + std::to_string(i) + "]";
req.add_file(field_name, params.Attachments.at(i).File, params.Attachments.at(i).Filename);
req.add_file(field_name, attachment.File, attachment.Filename);
obj.Attachments->push_back({ static_cast<int>(i), attachment.Description });
}
req.add_field("payload_json", nlohmann::json(obj).dump().c_str(), CURL_ZERO_TERMINATED);
m_http.Execute(std::move(req), [this, params, nonce, callback](const http::response_type &res) {
for (const auto &attachment : params.Attachments) {
if (attachment.Type == ChatSubmitParams::AttachmentType::PastedImage) {
+4
View File
@@ -49,3 +49,7 @@ std::string EmojiData::URLFromID(Snowflake emoji_id, const char *ext, const char
std::string EmojiData::URLFromID(const Glib::ustring &emoji_id, const char *ext, const char *size) {
return URLFromID(emoji_id.raw(), ext, size);
}
bool EmojiData::IsEmojiAnimated() const noexcept {
return IsAnimated.has_value() && *IsAnimated;
}
+2
View File
@@ -22,4 +22,6 @@ struct EmojiData {
static std::string URLFromID(const std::string &emoji_id, const char *ext = "png", const char *size = nullptr);
static std::string URLFromID(Snowflake emoji_id, const char *ext = "png", const char *size = nullptr);
static std::string URLFromID(const Glib::ustring &emoji_id, const char *ext = "png", const char *size = nullptr);
bool IsEmojiAnimated() const noexcept;
};
+2
View File
@@ -128,6 +128,7 @@ void to_json(nlohmann::json &j, const AttachmentData &m) {
j["proxy_url"] = m.ProxyURL;
JS_IF("height", m.Height);
JS_IF("width", m.Width);
JS_IF("description", m.Description);
}
void from_json(const nlohmann::json &j, AttachmentData &m) {
@@ -138,6 +139,7 @@ void from_json(const nlohmann::json &j, AttachmentData &m) {
JS_D("proxy_url", m.ProxyURL);
JS_ON("height", m.Height);
JS_ON("width", m.Width);
JS_ON("description", m.Description);
}
void from_json(const nlohmann::json &j, MessageReferenceData &m) {
+25 -2
View File
@@ -33,6 +33,28 @@ enum class MessageType {
INLINE_REPLY = 19, // yep
APPLICATION_COMMAND = 20, // yep
THREAD_STARTER_MESSAGE = 21, // nope
GUILD_INVITE_REMINDER = 22, // nope
CONTEXT_MENU_COMMAND = 23, // nope
AUTO_MODERATION_ACTION = 24, // nope
ROLE_SUBSCRIPTION_PURCHASE = 25, // nope
INTERACTION_PREMIUM_UPSELL = 26, // nope
STAGE_START = 27, // nope
STAGE_END = 28, // nope
STAGE_SPEAKER = 29, // nope
STAGE_TOPIC = 31, // nope
GUILD_APPLICATION_PREMIUM_SUBSCRIPTION = 32, // nope
PRIVATE_CHANNEL_INTEGRATION_ADDED = 33, // nope
PRIVATE_CHANNEL_INTEGRATION_REMOVED = 34, // nope
PREMIUM_REFERRAL = 35, // nope
GUILD_INCIDENT_ALERT_MODE_ENABLED = 36, // nope
GUILD_INCIDENT_ALERT_MODE_DISABLED = 37, // nope
GUILD_INCIDENT_REPORT_RAID = 38, // nope
GUILD_INCIDENT_REPORT_FALSE_ALARM = 39, // nope
GUILD_DEADCHAT_REVIVE_PROMPT = 40, // nope
CUSTOM_GIFT = 41, // nope
GUILD_GAMING_STATS_PROMPT = 42, // nope
POLL = 43, // nope
PURCHASE_NOTIFICATION = 44, // nope
};
enum class MessageFlags {
@@ -146,8 +168,9 @@ struct AttachmentData {
int Bytes;
std::string URL;
std::string ProxyURL;
std::optional<int> Height; // null
std::optional<int> Width; // null
std::optional<int> Height; // null
std::optional<int> Width; // null
std::optional<std::string> Description; // alt text
friend void to_json(nlohmann::json &j, const AttachmentData &m);
friend void from_json(const nlohmann::json &j, AttachmentData &m);
+6
View File
@@ -306,9 +306,15 @@ void to_json(nlohmann::json &j, const HeartbeatMessage &m) {
j["d"] = m.Sequence;
}
void to_json(nlohmann::json &j, const CreateMessageAttachmentObject &m) {
j["id"] = m.ID;
JS_IF("description", m.Description);
}
void to_json(nlohmann::json &j, const CreateMessageObject &m) {
j["content"] = m.Content;
j["flags"] = m.Flags;
JS_IF("attachments", m.Attachments);
JS_IF("message_reference", m.MessageReference);
JS_IF("nonce", m.Nonce);
}
+15
View File
@@ -53,6 +53,13 @@ enum class GatewayOp : int {
EmbeddedActivityClose = 26,
EmbeddedActivityUpdate = 27,
RequestForumUnreads = 28,
RemoteCommand = 29,
GetDeletedEntityIDsNotMatchingHash = 30,
RequestSoundboardSounds = 31,
SpeedTestCreate = 32,
SpeedTestDelete = 33,
RequestLastMessages = 34,
SearchRecentMembers = 35,
};
enum class GatewayEvent : int {
@@ -426,11 +433,19 @@ struct HeartbeatMessage : GatewayMessage {
friend void to_json(nlohmann::json &j, const HeartbeatMessage &m);
};
struct CreateMessageAttachmentObject {
int ID;
std::optional<std::string> Description;
friend void to_json(nlohmann::json &j, const CreateMessageAttachmentObject &m);
};
struct CreateMessageObject {
std::string Content;
MessageFlags Flags = MessageFlags::NONE;
std::optional<MessageReferenceData> MessageReference;
std::optional<std::string> Nonce;
std::optional<std::vector<CreateMessageAttachmentObject>> Attachments;
friend void to_json(nlohmann::json &j, const CreateMessageObject &m);
};
+120 -55
View File
@@ -7,44 +7,57 @@
constexpr static uint64_t PERMISSION_MAX_BIT = 36;
enum class Permission : uint64_t {
NONE = 0,
CREATE_INSTANT_INVITE = (1ULL << 0), // Allows creation of instant invites
KICK_MEMBERS = (1ULL << 1), // Allows kicking members
BAN_MEMBERS = (1ULL << 2), // Allows banning members
ADMINISTRATOR = (1ULL << 3), // Allows all permissions and bypasses channel permission overwrites
MANAGE_CHANNELS = (1ULL << 4), // Allows management and editing of channels
MANAGE_GUILD = (1ULL << 5), // Allows management and editing of the guild
ADD_REACTIONS = (1ULL << 6), // Allows for the addition of reactions to messages
VIEW_AUDIT_LOG = (1ULL << 7), // Allows for viewing of audit logs
PRIORITY_SPEAKER = (1ULL << 8), // Allows for using priority speaker in a voice channel
STREAM = (1ULL << 9), // Allows the user to go live
VIEW_CHANNEL = (1ULL << 10), // Allows guild members to view a channel, which includes reading messages in text channels
SEND_MESSAGES = (1ULL << 11), // Allows for sending messages in a channel
SEND_TTS_MESSAGES = (1ULL << 12), // Allows for sending of /tts messages
MANAGE_MESSAGES = (1ULL << 13), // Allows for deletion of other users messages
EMBED_LINKS = (1ULL << 14), // Links sent by users with this permission will be auto-embedded
ATTACH_FILES = (1ULL << 15), // Allows for uploading images and files
READ_MESSAGE_HISTORY = (1ULL << 16), // Allows for reading of message history
MENTION_EVERYONE = (1ULL << 17), // Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel
USE_EXTERNAL_EMOJIS = (1ULL << 18), // Allows the usage of custom emojis from other servers
VIEW_GUILD_INSIGHTS = (1ULL << 19), // Allows for viewing guild insights
CONNECT = (1ULL << 20), // Allows for joining of a voice channel
SPEAK = (1ULL << 21), // Allows for speaking in a voice channel
MUTE_MEMBERS = (1ULL << 22), // Allows for muting members in a voice channel
DEAFEN_MEMBERS = (1ULL << 23), // Allows for deafening of members in a voice channel
MOVE_MEMBERS = (1ULL << 24), // Allows for moving of members between voice channels
USE_VAD = (1ULL << 25), // Allows for using voice-activity-detection in a voice channel
CHANGE_NICKNAME = (1ULL << 26), // Allows for modification of own nickname
MANAGE_NICKNAMES = (1ULL << 27), // Allows for modification of other users nicknames
MANAGE_ROLES = (1ULL << 28), // Allows management and editing of roles
MANAGE_WEBHOOKS = (1ULL << 29), // Allows management and editing of webhooks
MANAGE_EMOJIS = (1ULL << 30), // Allows management and editing of emojis
USE_SLASH_COMMANDS = (1ULL << 31), // Allows members to use slash commands in text channels
REQUEST_TO_SPEAK = (1ULL << 32), // Allows for requesting to speak in stage channels
MANAGE_THREADS = (1ULL << 34), // Allows for deleting and archiving threads, and viewing all private threads
USE_PUBLIC_THREADS = (1ULL << 35), // Allows for creating and participating in threads
USE_PRIVATE_THREADS = (1ULL << 36), // Allows for creating and participating in private threads
CREATE_INSTANT_INVITE = (1ULL << 0), // Allows creation of instant invites
KICK_MEMBERS = (1ULL << 1), // Allows kicking members
BAN_MEMBERS = (1ULL << 2), // Allows banning members
ADMINISTRATOR = (1ULL << 3), // Allows all permissions and bypasses channel permission overwrites
MANAGE_CHANNELS = (1ULL << 4), // Allows management and editing of channels
MANAGE_GUILD = (1ULL << 5), // Allows management and editing of the guild
ADD_REACTIONS = (1ULL << 6), // Allows for the addition of reactions to messages
VIEW_AUDIT_LOG = (1ULL << 7), // Allows for viewing of audit logs
PRIORITY_SPEAKER = (1ULL << 8), // Allows for using priority speaker in a voice channel
STREAM = (1ULL << 9), // Allows the user to go live
VIEW_CHANNEL = (1ULL << 10), // Allows guild members to view a channel, which includes reading messages in text channels
SEND_MESSAGES = (1ULL << 11), // Allows for sending messages in a channel
SEND_TTS_MESSAGES = (1ULL << 12), // Allows for sending of /tts messages
MANAGE_MESSAGES = (1ULL << 13), // Allows for deletion of other users messages
EMBED_LINKS = (1ULL << 14), // Links sent by users with this permission will be auto-embedded
ATTACH_FILES = (1ULL << 15), // Allows for uploading images and files
READ_MESSAGE_HISTORY = (1ULL << 16), // Allows for reading of message history
MENTION_EVERYONE = (1ULL << 17), // Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel
USE_EXTERNAL_EMOJIS = (1ULL << 18), // Allows the usage of custom emojis from other servers
VIEW_GUILD_INSIGHTS = (1ULL << 19), // Allows for viewing guild insights
CONNECT = (1ULL << 20), // Allows for joining of a voice channel
SPEAK = (1ULL << 21), // Allows for speaking in a voice channel
MUTE_MEMBERS = (1ULL << 22), // Allows for muting members in a voice channel
DEAFEN_MEMBERS = (1ULL << 23), // Allows for deafening of members in a voice channel
MOVE_MEMBERS = (1ULL << 24), // Allows for moving of members between voice channels
USE_VAD = (1ULL << 25), // Allows for using voice-activity-detection in a voice channel
CHANGE_NICKNAME = (1ULL << 26), // Allows for modification of own nickname
MANAGE_NICKNAMES = (1ULL << 27), // Allows for modification of other users nicknames
MANAGE_ROLES = (1ULL << 28), // Allows management and editing of roles
MANAGE_WEBHOOKS = (1ULL << 29), // Allows management and editing of webhooks
MANAGE_GUILD_EXPRESSIONS = (1ULL << 30), // Allows management and editing of emojis, stickers, and soundboard sounds
USE_APPLICATION_COMMANDS = (1ULL << 31), // Allows members to use application commands, including slash commands and context menu commands
REQUEST_TO_SPEAK = (1ULL << 32), // Allows for requesting to speak in stage channels
MANAGE_EVENTS = (1ULL << 33), // Allows for creating, editing, and deleting scheduled events
MANAGE_THREADS = (1ULL << 34), // Allows for deleting and archiving threads, and viewing all private threads
CREATE_PUBLIC_THREADS = (1ULL << 35), // Allows for creating public and announcement threads
CREATE_PRIVATE_THREADS = (1ULL << 36), // Allows for creating private threads
USE_EXTERNAL_STICKERS = (1ULL << 37), // Allows the usage of custom stickers from other servers
SEND_MESSAGES_IN_THREADS = (1ULL << 38), // Allows for sending messages in threads
USE_EMBEDDED_ACTIVITIES = (1ULL << 39), // Allows for using Activities (applications with the EMBEDDED flag) in a voice channel
MODERATE_MEMBERS = (1ULL << 40), // Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels
VIEW_CREATOR_MONETIZATION_ANALYTICS = (1ULL << 41), // Allows for viewing role subscription insights
USE_SOUNDBOARD = (1ULL << 42), // Allows for using soundboard in a voice channel
CREATE_GUILD_EXPRESSIONS = (1ULL << 43), // undocumented. Present in client
CREATE_EVENTS = (1ULL << 44), // undocumented. Present in client
USE_EXTERNAL_SOUNDS = (1ULL << 45), // Allows the usage of custom soundboard sounds from other servers
SEND_VOICE_MESSAGES = (1ULL << 46), // Allows sending voice messages
USE_CLYDE_AI = (1ULL << 47), // undocumented
SET_VOICE_CHANNEL_STATUS = (1ULL << 48), // undocumented. Present in Client
ALL = 0x1FFFFFFFFFULL,
ALL = 0x1FFFFFFFFFFFFULL,
};
template<>
@@ -91,7 +104,7 @@ constexpr const char *GetPermissionString(Permission perm) {
case Permission::STREAM:
return "Video";
case Permission::VIEW_CHANNEL:
return "View Channel";
return "View Channels";
case Permission::SEND_MESSAGES:
return "Send Messages";
case Permission::SEND_TTS_MESSAGES:
@@ -130,16 +143,42 @@ constexpr const char *GetPermissionString(Permission perm) {
return "Manage Roles";
case Permission::MANAGE_WEBHOOKS:
return "Manage Webhooks";
case Permission::MANAGE_EMOJIS:
return "Manage Emojis";
case Permission::USE_SLASH_COMMANDS:
return "Use Slash Commands";
case Permission::MANAGE_GUILD_EXPRESSIONS:
return "Manage Expressions";
case Permission::USE_APPLICATION_COMMANDS:
return "Use Application Commands";
case Permission::MANAGE_EVENTS:
return "Manage Events";
case Permission::MANAGE_THREADS:
return "Manage Threads";
case Permission::USE_PUBLIC_THREADS:
return "Use Public Threads";
case Permission::USE_PRIVATE_THREADS:
return "Use Private Threads";
case Permission::CREATE_PUBLIC_THREADS:
return "Create Public Threads";
case Permission::CREATE_PRIVATE_THREADS:
return "Create Private Threads";
case Permission::USE_EXTERNAL_STICKERS:
return "Use External Stickers";
case Permission::SEND_MESSAGES_IN_THREADS:
return "Send Messages In Threads";
case Permission::USE_EMBEDDED_ACTIVITIES:
return "Use Activities";
case Permission::MODERATE_MEMBERS:
return "Timeout Members";
// case Permission::VIEW_CREATOR_MONETIZATION_ANALYTICS:
// return "";
case Permission::USE_SOUNDBOARD:
return "Use Soundboard";
case Permission::CREATE_GUILD_EXPRESSIONS:
return "Create Expressions";
case Permission::CREATE_EVENTS:
return "Create Events";
case Permission::USE_EXTERNAL_SOUNDS:
return "Use External Sounds";
case Permission::SEND_VOICE_MESSAGES:
return "Send Voice Messages";
// case Permission::USE_CLYDE_AI:
// return "";
case Permission::SET_VOICE_CHANNEL_STATUS:
return "Set Voice Channel Status";
default:
return "Unknown Permission";
}
@@ -209,16 +248,42 @@ constexpr const char *GetPermissionDescription(Permission perm) {
return "Allows members to create new roles and edit or delete roles lower than their highest role. Also allows members to change permissions of individual channels that they have access to.";
case Permission::MANAGE_WEBHOOKS:
return "Allows members to create, edit, or delete webhooks, which can post messages from other apps or sites into this server.";
case Permission::MANAGE_EMOJIS:
return "Allows members to add or remove custom emojis in this server.";
case Permission::USE_SLASH_COMMANDS:
return "Allows members to use slash commands in text channels.";
case Permission::MANAGE_GUILD_EXPRESSIONS:
return "Allows members to add or remove custom emoji, stickers, and sounds in this server.";
case Permission::USE_APPLICATION_COMMANDS:
return "Allows members to use commands from applications, including slash commands and context menu commands.";
case Permission::MANAGE_EVENTS:
return "Allows members to edit and cancel events.";
case Permission::MANAGE_THREADS:
return "Allows members to rename, delete, archive/unarchive, and turn on slow mode for threads.";
case Permission::USE_PUBLIC_THREADS:
return "Allows members to talk in threads. The \"Send Messages\" permission must be enabled for members to start new threads; if it's disabled, they can only respond to existing threads.";
case Permission::USE_PRIVATE_THREADS:
return "Allows members to create and chat in private threads. The \"Send Messages\" permission must be enabled for members to start new private threads; if it's disabled, they can only respond to private threads they're added to.";
return "Allows members to rename, delete, close, and turn on slow mode for threads. They can also view private threads";
case Permission::CREATE_PUBLIC_THREADS:
return "Allows members to create threads that everyone in a channel can view.";
case Permission::CREATE_PRIVATE_THREADS:
return "Allows members to create invite-only threads.";
case Permission::USE_EXTERNAL_STICKERS:
return "Allows members to use stickers from other servers, if they're a Discord Nitro member.";
case Permission::SEND_MESSAGES_IN_THREADS:
return "Allows members to send messages in threads.";
case Permission::USE_EMBEDDED_ACTIVITIES:
return "Allows members to use Activities in this server.";
case Permission::MODERATE_MEMBERS:
return "When you put a user in timeout they will not be able to send messages in chat, reply within threads, react to messages, or speak in voice or Stage channels.";
// case Permission::VIEW_CREATOR_MONETIZATION_ANALYTICS:
// return "";
case Permission::USE_SOUNDBOARD:
return "Allows members to send sounds from server soundboard.";
case Permission::CREATE_GUILD_EXPRESSIONS:
return "Allows members to add custom emoji, stickers, and sounds in this server.";
case Permission::CREATE_EVENTS:
return "Allows members to create events.";
case Permission::USE_EXTERNAL_SOUNDS:
return "Allows members to use sounds from other servers, if they're a Discord Nitro member.";
case Permission::SEND_VOICE_MESSAGES:
return "Allows members to send voice messages.";
// case Permission::USE_CLYDE_AI:
// return "";
case Permission::SET_VOICE_CHANNEL_STATUS:
return "Allows members to create and edit voice channel status.";
default:
return "";
}
+24 -8
View File
@@ -368,6 +368,7 @@ void Store::SetMessage(Snowflake id, const Message &message) {
s->Bind(6, a.ProxyURL);
s->Bind(7, a.Height);
s->Bind(8, a.Width);
s->Bind(9, a.Description);
if (!s->Insert())
fprintf(stderr, "message attachment insert failed for %" PRIu64 "/%" PRIu64 ": %s\n", static_cast<uint64_t>(id), static_cast<uint64_t>(a.ID), m_db.ErrStr());
s->Reset();
@@ -975,7 +976,7 @@ Message Store::GetMessageBound(std::unique_ptr<Statement> &s) const {
s->Get(5, r.Timestamp);
s->Get(6, r.EditedTimestamp);
// s->Get(7, r.IsTTS);
// s->Get(8, r.DoesMentionEveryone);
s->Get(8, r.DoesMentionEveryone);
s->GetJSON(9, r.Embeds);
s->Get(10, r.IsPinned);
s->Get(11, r.WebhookID);
@@ -1021,6 +1022,7 @@ Message Store::GetMessageBound(std::unique_ptr<Statement> &s) const {
s->Get(5, q.ProxyURL);
s->Get(6, q.Height);
s->Get(7, q.Width);
s->Get(8, q.Description);
}
s->Reset();
}
@@ -1056,11 +1058,12 @@ Message Store::GetMessageBound(std::unique_ptr<Statement> &s) const {
while (s->FetchOne()) {
size_t idx;
ReactionData q;
s->Get(0, q.Emoji.ID);
s->Get(1, q.Emoji.Name);
s->Get(2, q.Count);
s->Get(3, q.HasReactedWith);
s->Get(4, idx);
s->Get(0, q.Count);
s->Get(1, q.HasReactedWith);
s->Get(2, idx);
s->Get(3, q.Emoji.ID);
s->Get(4, q.Emoji.Name);
s->Get(5, q.Emoji.IsAnimated);
tmp[idx] = q;
}
s->Reset();
@@ -1508,6 +1511,7 @@ bool Store::CreateTables() {
proxy TEXT NOT NULL,
height INTEGER,
width INTEGER,
description TEXT,
PRIMARY KEY(message, id)
)
)";
@@ -2211,7 +2215,7 @@ bool Store::CreateStatements() {
m_stmt_set_attachment = std::make_unique<Statement>(m_db, R"(
REPLACE INTO attachments VALUES (
?, ?, ?, ?, ?, ?, ?, ?
?, ?, ?, ?, ?, ?, ?, ?, ?
)
)");
if (!m_stmt_set_attachment->OK()) {
@@ -2291,7 +2295,19 @@ bool Store::CreateStatements() {
}
m_stmt_get_reactions = std::make_unique<Statement>(m_db, R"(
SELECT emoji_id, name, count, me, idx FROM reactions WHERE message = ?
SELECT
reactions.count,
reactions.me,
reactions.idx,
emojis.id,
emojis.name,
emojis.animated
FROM
reactions
INNER JOIN
emojis ON reactions.emoji_id = emojis.id
WHERE
message = ?
)");
if (!m_stmt_get_reactions->OK()) {
fprintf(stderr, "failed to prepare get reactions statement: %s\n", m_db.ErrStr());
+3
View File
@@ -7,9 +7,11 @@ enum class EPremiumType {
None = 0,
NitroClassic = 1,
Nitro = 2,
Basic = 3,
};
struct UserData {
// todo: enum class? (for consistencys sake)
enum {
DiscordEmployee = 1 << 0,
PartneredServerOwner = 1 << 1,
@@ -29,6 +31,7 @@ struct UserData {
Spammer = 1 << 20,
DisablePremium = 1 << 21,
ActiveDeveloper = 1 << 22,
ApplicationCommandBadge = 1 << 23,
Quarantined = 1ULL << 44,
MaxFlag_PlusOne,
-4
View File
@@ -68,9 +68,7 @@ void SettingsManager::ReadSettings() {
SMINT("http", "concurrent", CacheHTTPConcurrency);
SMSTR("http", "user_agent", UserAgent);
SMSTR("style", "expandercolor", ChannelsExpanderColor);
SMSTR("style", "linkcolor", LinkColor);
SMSTR("style", "nsfwchannelcolor", NSFWChannelColor);
SMSTR("style", "channelcolor", ChannelColor);
SMSTR("style", "mentionbadgecolor", MentionBadgeColor);
SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor);
SMSTR("style", "unreadcolor", UnreadIndicatorColor);
@@ -159,9 +157,7 @@ void SettingsManager::Close() {
SMINT("http", "concurrent", CacheHTTPConcurrency);
SMSTR("http", "user_agent", UserAgent);
SMSTR("style", "expandercolor", ChannelsExpanderColor);
SMSTR("style", "linkcolor", LinkColor);
SMSTR("style", "nsfwchannelcolor", NSFWChannelColor);
SMSTR("style", "channelcolor", ChannelColor);
SMSTR("style", "mentionbadgecolor", MentionBadgeColor);
SMSTR("style", "mentionbadgetextcolor", MentionBadgeTextColor);
SMSTR("style", "unreadcolor", UnreadIndicatorColor);
+5 -8
View File
@@ -38,14 +38,11 @@ public:
std::string UserAgent { "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36" };
// [style]
// TODO: convert to StyleProperty... or maybe not? i still cant figure out what the "correct" method is for this
std::string LinkColor { "rgba(40, 200, 180, 255)" };
std::string ChannelsExpanderColor { "rgba(255, 83, 112, 255)" };
std::string NSFWChannelColor { "#ed6666" };
std::string ChannelColor { "#fbfbfb" };
std::string MentionBadgeColor { "#b82525" };
std::string MentionBadgeTextColor { "#fbfbfb" };
std::string UnreadIndicatorColor { "#ffffff" };
std::string ChannelsExpanderColor { "rgba(255, 83, 112, 0)" };
std::string NSFWChannelColor { "#970d0d" };
std::string MentionBadgeColor { "rgba(184, 37, 37, 0)" };
std::string MentionBadgeTextColor { "rgba(251, 251, 251, 0)" };
std::string UnreadIndicatorColor { "rgba(255, 255, 255, 0)" };
// [notifications]
#ifdef _WIN32
+4 -4
View File
@@ -29,7 +29,7 @@ std::optional<std::pair<std::string, std::string>> ParseCookie(const Glib::ustri
}
std::optional<Glib::ustring> GetJavascriptFileFromAppPage(const Glib::ustring &contents) {
auto regex = Glib::Regex::create(R"(/assets/\w{20}.js)");
auto regex = Glib::Regex::create(R"(/assets/\w+\.?\w{20}\.js)");
std::vector<Glib::ustring> matches;
// regex->match_all doesnt work for some reason
@@ -43,8 +43,8 @@ std::optional<Glib::ustring> GetJavascriptFileFromAppPage(const Glib::ustring &c
start_position += str.size();
}
if (matches.size() >= 6) {
return matches[matches.size() - 6];
if (matches.size() >= 10) {
return matches[matches.size() - 10];
}
return {};
@@ -64,7 +64,7 @@ std::optional<uint32_t> GetBuildNumberFromJSURL(const Glib::ustring &url, const
auto res = req.execute();
if (res.error) return {};
auto regex = Glib::Regex::create("buildNumber:\"(\\d+)\"");
auto regex = Glib::Regex::create(R"(Build Number: "\).concat\("(\d+))");
Glib::MatchInfo match;
Glib::ustring string = res.text;
if (regex->match(string, match)) {
+3 -3
View File
@@ -34,7 +34,7 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
discord.signal_guild_emojis_update().connect(sigc::hide<0>(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnFetchEmojis)));
const auto self_id = discord.GetUserData().ID;
const bool can_manage = discord.HasGuildPermission(self_id, GuildID, Permission::MANAGE_EMOJIS);
const bool can_manage = discord.HasGuildPermission(self_id, GuildID, Permission::MANAGE_GUILD_EXPRESSIONS);
m_menu_delete.set_sensitive(can_manage);
m_search.set_placeholder_text("Filter");
@@ -104,7 +104,7 @@ void GuildSettingsEmojisPane::OnMap() {
auto &discord = Abaddon::Get().GetDiscordClient();
const auto self_id = discord.GetUserData().ID;
const bool can_manage = discord.HasGuildPermission(self_id, GuildID, Permission::MANAGE_EMOJIS);
const bool can_manage = discord.HasGuildPermission(self_id, GuildID, Permission::MANAGE_GUILD_EXPRESSIONS);
m_menu_delete.set_sensitive(can_manage);
discord.FetchGuildEmojis(GuildID, sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnFetchEmojis));
@@ -228,7 +228,7 @@ bool GuildSettingsEmojisPane::OnTreeButtonPress(GdkEventButton *event) {
if (event->button == GDK_BUTTON_SECONDARY) {
auto &discord = Abaddon::Get().GetDiscordClient();
const auto self_id = discord.GetUserData().ID;
const bool can_manage = discord.HasGuildPermission(self_id, GuildID, Permission::MANAGE_EMOJIS);
const bool can_manage = discord.HasGuildPermission(self_id, GuildID, Permission::MANAGE_GUILD_EXPRESSIONS);
m_menu_delete.set_sensitive(can_manage);
auto selection = m_view.get_selection();
+32 -20
View File
@@ -258,49 +258,61 @@ GuildSettingsRolesPaneInfo::GuildSettingsRolesPaneInfo(Snowflake guild_id)
// fuck you clang-format you suck
// clang-format off
add_perms("General", LEFT, {
add_perms("General", RIGHT, {
Permission::VIEW_CHANNEL,
Permission::MANAGE_CHANNELS,
Permission::MANAGE_ROLES,
Permission::MANAGE_EMOJIS,
Permission::CREATE_GUILD_EXPRESSIONS,
Permission::MANAGE_GUILD_EXPRESSIONS,
Permission::VIEW_AUDIT_LOG,
Permission::VIEW_GUILD_INSIGHTS,
Permission::MANAGE_WEBHOOKS,
Permission::MANAGE_GUILD });
add_perms("Text Channels", LEFT, {
Permission::SEND_MESSAGES,
Permission::SEND_MESSAGES_IN_THREADS,
Permission::CREATE_PUBLIC_THREADS,
Permission::CREATE_PRIVATE_THREADS,
Permission::EMBED_LINKS,
Permission::ATTACH_FILES,
Permission::ADD_REACTIONS,
Permission::USE_EXTERNAL_EMOJIS,
Permission::USE_EXTERNAL_STICKERS,
Permission::MENTION_EVERYONE,
Permission::MANAGE_MESSAGES,
Permission::MANAGE_THREADS,
Permission::READ_MESSAGE_HISTORY,
Permission::SEND_TTS_MESSAGES,
Permission::USE_APPLICATION_COMMANDS,
Permission::SEND_VOICE_MESSAGES, });
add_perms("Membership", LEFT, {
Permission::CREATE_INSTANT_INVITE,
Permission::CHANGE_NICKNAME,
Permission::MANAGE_NICKNAMES,
Permission::KICK_MEMBERS,
Permission::BAN_MEMBERS });
Permission::BAN_MEMBERS,
Permission::MODERATE_MEMBERS });
add_perms("Text Channels", RIGHT, {
Permission::SEND_MESSAGES,
Permission::USE_PUBLIC_THREADS,
Permission::USE_PRIVATE_THREADS,
Permission::EMBED_LINKS,
Permission::ATTACH_FILES,
Permission::ADD_REACTIONS,
Permission::USE_EXTERNAL_EMOJIS,
Permission::MENTION_EVERYONE,
Permission::MANAGE_MESSAGES,
Permission::MANAGE_THREADS,
Permission::READ_MESSAGE_HISTORY,
Permission::SEND_TTS_MESSAGES,
Permission::USE_SLASH_COMMANDS });
add_perms("Advanced", LEFT, { Permission::ADMINISTRATOR });
add_perms("Voice Channels", RIGHT, {
Permission::CONNECT,
Permission::SPEAK,
Permission::STREAM,
Permission::USE_EMBEDDED_ACTIVITIES,
Permission::USE_SOUNDBOARD,
Permission::USE_EXTERNAL_SOUNDS,
Permission::USE_VAD,
Permission::PRIORITY_SPEAKER,
Permission::MUTE_MEMBERS,
Permission::DEAFEN_MEMBERS,
Permission::MOVE_MEMBERS });
Permission::MOVE_MEMBERS,
Permission::SET_VOICE_CHANNEL_STATUS });
add_perms("Advanced", LEFT, { Permission::ADMINISTRATOR });
add_perms("Events", RIGHT, {
Permission::CREATE_EVENTS,
Permission::MANAGE_EVENTS, });
// clang-format on
+21 -6
View File
@@ -12,6 +12,7 @@
VoiceSettingsWindow::VoiceSettingsWindow()
: m_main(Gtk::ORIENTATION_VERTICAL) {
get_style_context()->add_class("app-window");
get_style_context()->add_class("voice-settings-window");
set_default_size(300, 300);
m_encoding_mode.append("Voice");
@@ -111,14 +112,28 @@ VoiceSettingsWindow::VoiceSettingsWindow()
m_gain.set_increments(1.0, 5.0);
m_gain.set_range(0.0, 6969696969.0);
m_gain.set_value(Abaddon::Get().GetAudio().GetCaptureGain() * 100.0);
m_gain.signal_value_changed().connect([this]() {
const auto cb = [this]() {
spdlog::get("ui")->warn("emit");
m_signal_gain.emit(m_gain.get_value() / 100.0);
});
};
// m_gain.signal_value_changed can be fired during destruction. thankfully signals are trackable
m_gain.signal_value_changed().connect(sigc::track_obj(cb, *this, m_signal_gain));
m_main.add(m_encoding_mode);
m_main.add(m_signal);
m_main.add(m_bitrate);
m_main.add(m_gain);
auto *layout = Gtk::make_managed<Gtk::HBox>();
auto *labels = Gtk::make_managed<Gtk::VBox>();
auto *widgets = Gtk::make_managed<Gtk::VBox>();
layout->pack_start(*labels, false, true, 5);
layout->pack_start(*widgets);
labels->pack_start(*Gtk::make_managed<Gtk::Label>("Coding Mode", Gtk::ALIGN_END));
labels->pack_start(*Gtk::make_managed<Gtk::Label>("Signal Hint", Gtk::ALIGN_END));
labels->pack_start(*Gtk::make_managed<Gtk::Label>("Bitrate", Gtk::ALIGN_END));
labels->pack_start(*Gtk::make_managed<Gtk::Label>("Gain", Gtk::ALIGN_END));
widgets->pack_start(m_encoding_mode);
widgets->pack_start(m_signal);
widgets->pack_start(m_bitrate);
widgets->pack_start(m_gain);
m_main.add(*layout);
add(m_main);
show_all_children();
+30 -10
View File
@@ -181,7 +181,7 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
m_mix_mono.set_active(audio.GetMixMono());
m_mix_mono.signal_toggled().connect([this]() {
Abaddon::Get().GetAudio().SetMixMono(m_mix_mono.get_active());
Abaddon::Get().GetAudio().SetMixMono(m_mix_mono.get_active());
});
auto *playback_renderer = Gtk::make_managed<Gtk::CellRendererText>();
@@ -225,20 +225,40 @@ VoiceWindow::VoiceWindow(Snowflake channel_id)
window->show();
});
auto *sliders_container = Gtk::make_managed<Gtk::HBox>();
auto *sliders_labels = Gtk::make_managed<Gtk::VBox>();
auto *sliders_sliders = Gtk::make_managed<Gtk::VBox>();
sliders_container->pack_start(*sliders_labels, false, true, 2);
sliders_container->pack_start(*sliders_sliders);
sliders_labels->pack_start(*Gtk::make_managed<Gtk::Label>("Threshold", Gtk::ALIGN_END));
sliders_labels->pack_start(*Gtk::make_managed<Gtk::Label>("Gain", Gtk::ALIGN_END));
sliders_sliders->pack_start(m_vad_param);
sliders_sliders->pack_start(m_capture_gain);
auto *combos_container = Gtk::make_managed<Gtk::HBox>();
auto *combos_labels = Gtk::make_managed<Gtk::VBox>();
auto *combos_combos = Gtk::make_managed<Gtk::VBox>();
combos_container->pack_start(*combos_labels, false, true, 6);
combos_container->pack_start(*combos_combos, Gtk::PACK_EXPAND_WIDGET, 6);
combos_labels->pack_start(*Gtk::make_managed<Gtk::Label>("VAD Method", Gtk::ALIGN_END));
combos_labels->pack_start(*Gtk::make_managed<Gtk::Label>("Output Device", Gtk::ALIGN_END));
combos_labels->pack_start(*Gtk::make_managed<Gtk::Label>("Input Device", Gtk::ALIGN_END));
combos_combos->pack_start(m_vad_combo);
combos_combos->pack_start(m_playback_combo);
combos_combos->pack_start(m_capture_combo);
m_scroll.add(m_user_list);
m_controls.add(m_mute);
m_controls.add(m_deafen);
m_controls.add(m_noise_suppression);
m_controls.add(m_mix_mono);
m_main.add(m_menu_bar);
m_main.add(m_controls);
m_main.add(m_vad_value);
m_main.add(m_vad_param);
m_main.add(m_capture_gain);
m_main.add(m_scroll);
m_main.add(m_vad_combo);
m_main.add(m_playback_combo);
m_main.add(m_capture_combo);
m_main.pack_start(m_menu_bar);
m_main.pack_start(m_controls);
m_main.pack_start(m_vad_value);
m_main.pack_start(*Gtk::make_managed<Gtk::Label>("Input Settings"));
m_main.pack_start(*sliders_container);
m_main.pack_start(m_scroll);
m_main.pack_start(*combos_container, Gtk::PACK_EXPAND_WIDGET, 2);
add(m_main);
show_all_children();