Skip to content

Commit

Permalink
Sync with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ryze312 committed Jul 11, 2024
2 parents 8d4384e + 68db143 commit d6ae366
Show file tree
Hide file tree
Showing 39 changed files with 910 additions and 294 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# Build directory contents
build/*

# User-specific files
*.rsuser
*.suo
Expand Down
7 changes: 7 additions & 0 deletions .lapce/gen_compile_commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# Use this script to create the compile_commands.json file.
# This is necessary for clangd completion.

cmake . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=True
24 changes: 24 additions & 0 deletions .lapce/run.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The run config is used for both run mode and debug mode

[[configs]]
name = "cmake-debug"
program = "sh"
args = [".lapce/gen_compile_commands.sh"]

[configs.env]
CC = "/usr/bin/clang"
CXX = "/usr/bin/clang++"

[[configs]]
name = "cmake"
program = "cmake"
args = ["--build", "build"]

[configs.env]
CC = "/usr/bin/clang"
CXX = "/usr/bin/clang++"

[[configs]]
name = "run"
type = "lldb"
program = "build/abaddon"
1 change: 1 addition & 0 deletions compile_commands.json
10 changes: 8 additions & 2 deletions src/abaddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "windows/profilewindow.hpp"
#include "windows/pinnedwindow.hpp"
#include "windows/threadswindow.hpp"
#include "windows/voicewindow.hpp"
#include "windows/voice/voicewindow.hpp"
#include "startup.hpp"
#include "notifications/notifications.hpp"
#include "remoteauth/remoteauthdialog.hpp"
Expand Down Expand Up @@ -1182,9 +1182,14 @@ void Abaddon::on_window_hide() {
}

int main(int argc, char **argv) {
if (std::getenv("ABADDON_NO_FC") == nullptr)
if (std::getenv("ABADDON_NO_FC") == nullptr) {
Platform::SetupFonts();
}

// windows doesnt have langinfo.h so some localization falls back to translation strings
// i dont like the default translation so this lets us use strftime

#ifdef _WIN32
char *systemLocale = std::setlocale(LC_ALL, "");
try {
if (systemLocale != nullptr) {
Expand All @@ -1198,6 +1203,7 @@ int main(int argc, char **argv) {
}
} catch (...) {}
}
#endif

#if defined(_WIN32) && defined(_MSC_VER)
TCHAR buf[2] { 0 };
Expand Down
41 changes: 24 additions & 17 deletions src/components/channellist/cellrendererchannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ void CellRendererChannels::get_preferred_width_vfunc(Gtk::Widget &widget, int &m
return get_preferred_width_vfunc_channel(widget, minimum_width, natural_width);
case RenderType::Thread:
return get_preferred_width_vfunc_thread(widget, minimum_width, natural_width);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_width_vfunc_voice_channel(widget, minimum_width, natural_width);
case RenderType::VoiceParticipant:
return get_preferred_width_vfunc_voice_participant(widget, minimum_width, natural_width);
#endif
case RenderType::DMHeader:
return get_preferred_width_vfunc_dmheader(widget, minimum_width, natural_width);
case RenderType::DM:
Expand All @@ -147,12 +146,11 @@ void CellRendererChannels::get_preferred_width_for_height_vfunc(Gtk::Widget &wid
return get_preferred_width_for_height_vfunc_channel(widget, height, minimum_width, natural_width);
case RenderType::Thread:
return get_preferred_width_for_height_vfunc_thread(widget, height, minimum_width, natural_width);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_width_for_height_vfunc_voice_channel(widget, height, minimum_width, natural_width);
case RenderType::VoiceParticipant:
return get_preferred_width_for_height_vfunc_voice_participant(widget, height, minimum_width, natural_width);
#endif
case RenderType::DMHeader:
return get_preferred_width_for_height_vfunc_dmheader(widget, height, minimum_width, natural_width);
case RenderType::DM:
Expand All @@ -172,12 +170,11 @@ void CellRendererChannels::get_preferred_height_vfunc(Gtk::Widget &widget, int &
return get_preferred_height_vfunc_channel(widget, minimum_height, natural_height);
case RenderType::Thread:
return get_preferred_height_vfunc_thread(widget, minimum_height, natural_height);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_height_vfunc_voice_channel(widget, minimum_height, natural_height);
case RenderType::VoiceParticipant:
return get_preferred_height_vfunc_voice_participant(widget, minimum_height, natural_height);
#endif
case RenderType::DMHeader:
return get_preferred_height_vfunc_dmheader(widget, minimum_height, natural_height);
case RenderType::DM:
Expand All @@ -197,12 +194,11 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc(Gtk::Widget &wid
return get_preferred_height_for_width_vfunc_channel(widget, width, minimum_height, natural_height);
case RenderType::Thread:
return get_preferred_height_for_width_vfunc_thread(widget, width, minimum_height, natural_height);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
case RenderType::VoiceStage:
return get_preferred_height_for_width_vfunc_voice_channel(widget, width, minimum_height, natural_height);
case RenderType::VoiceParticipant:
return get_preferred_height_for_width_vfunc_voice_participant(widget, width, minimum_height, natural_height);
#endif
case RenderType::DMHeader:
return get_preferred_height_for_width_vfunc_dmheader(widget, width, minimum_height, natural_height);
case RenderType::DM:
Expand All @@ -222,12 +218,12 @@ void CellRendererChannels::render_vfunc(const Cairo::RefPtr<Cairo::Context> &cr,
return render_vfunc_channel(cr, widget, background_area, cell_area, flags);
case RenderType::Thread:
return render_vfunc_thread(cr, widget, background_area, cell_area, flags);
#ifdef WITH_VOICE
case RenderType::VoiceChannel:
return render_vfunc_voice_channel(cr, widget, background_area, cell_area, flags);
return render_vfunc_voice_channel(cr, widget, background_area, cell_area, flags, "\U0001F50A");
case RenderType::VoiceStage:
return render_vfunc_voice_channel(cr, widget, background_area, cell_area, flags, "\U0001F4E1");
case RenderType::VoiceParticipant:
return render_vfunc_voice_participant(cr, widget, background_area, cell_area, flags);
#endif
case RenderType::DMHeader:
return render_vfunc_dmheader(cr, widget, background_area, cell_area, flags);
case RenderType::DM:
Expand Down Expand Up @@ -563,8 +559,6 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex
}
}

#ifdef WITH_VOICE

// voice channel

void CellRendererChannels::get_preferred_width_vfunc_voice_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const {
Expand All @@ -583,7 +577,7 @@ void CellRendererChannels::get_preferred_height_for_width_vfunc_voice_channel(Gt
m_renderer_text.get_preferred_height_for_width(widget, width, minimum_height, natural_height);
}

void CellRendererChannels::render_vfunc_voice_channel(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) {
void CellRendererChannels::render_vfunc_voice_channel(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags, const char *emoji) {
// channel name text
Gtk::Requisition minimum_size, natural_size;
m_renderer_text.get_preferred_size(widget, minimum_size, natural_size);
Expand All @@ -600,7 +594,7 @@ void CellRendererChannels::render_vfunc_voice_channel(const Cairo::RefPtr<Cairo:
Pango::FontDescription font;
font.set_family("sans 14");

auto layout = widget.create_pango_layout("\U0001F50A");
auto layout = widget.create_pango_layout(emoji);
layout->set_font_description(font);
layout->set_alignment(Pango::ALIGN_LEFT);
cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
Expand All @@ -612,6 +606,21 @@ void CellRendererChannels::render_vfunc_voice_channel(const Cairo::RefPtr<Cairo:
layout->show_in_cairo_context(cr);

RenderExpander(24, cr, widget, background_area, property_expanded());

// unread
if (!Abaddon::Get().GetSettings().Unreads) return;

const auto id = m_property_id.get_value();
const auto unread_state = Abaddon::Get().GetDiscordClient().GetUnreadStateForChannel(id);

if (unread_state < 1) return;

auto *paned = dynamic_cast<Gtk::Paned *>(widget.get_ancestor(Gtk::Paned::get_type()));
if (paned != nullptr) {
const auto edge = std::min(paned->get_position(), cell_area.get_width());

unread_render_mentions(cr, widget, unread_state, edge, cell_area);
}
}

// voice participant
Expand Down Expand Up @@ -714,8 +723,6 @@ void CellRendererChannels::render_vfunc_voice_participant(const Cairo::RefPtr<Ca
}
}

#endif

// dm header

void CellRendererChannels::get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const {
Expand Down
12 changes: 4 additions & 8 deletions src/components/channellist/cellrendererchannels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <gtkmm/cellrendererpixbuf.h>
#include <gtkmm/cellrenderertext.h>
#include "discord/snowflake.hpp"
#include "discord/voicestateflags.hpp"
#include "discord/voicestate.hpp"
#include "misc/bitwise.hpp"

enum class RenderType : uint8_t {
Expand All @@ -15,12 +15,9 @@ enum class RenderType : uint8_t {
Category,
TextChannel,
Thread,

// TODO: maybe enable anyways but without ability to join if no voice support
#ifdef WITH_VOICE
VoiceChannel,
VoiceStage, // identical to non-stage except for icon
VoiceParticipant,
#endif

DMHeader,
DM,
Expand Down Expand Up @@ -107,7 +104,6 @@ class CellRendererChannels : public Gtk::CellRenderer {
const Gdk::Rectangle &cell_area,
Gtk::CellRendererState flags);

#ifdef WITH_VOICE
// voice channel
void get_preferred_width_vfunc_voice_channel(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
void get_preferred_width_for_height_vfunc_voice_channel(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const;
Expand All @@ -117,7 +113,8 @@ class CellRendererChannels : public Gtk::CellRenderer {
Gtk::Widget &widget,
const Gdk::Rectangle &background_area,
const Gdk::Rectangle &cell_area,
Gtk::CellRendererState flags);
Gtk::CellRendererState flags,
const char *emoji);

// voice participant
void get_preferred_width_vfunc_voice_participant(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
Expand All @@ -129,7 +126,6 @@ class CellRendererChannels : public Gtk::CellRenderer {
const Gdk::Rectangle &background_area,
const Gdk::Rectangle &cell_area,
Gtk::CellRendererState flags);
#endif

// dm header
void get_preferred_width_vfunc_dmheader(Gtk::Widget &widget, int &minimum_width, int &natural_width) const;
Expand Down
Loading

0 comments on commit d6ae366

Please sign in to comment.