mirror of
https://github.com/uowuo/abaddon.git
synced 2024-11-10 06:00:10 +00:00
very very rudimentary classic channels list
This commit is contained in:
parent
8b034e48e2
commit
182128705e
@ -1,12 +1,26 @@
|
||||
#include "channellist.hpp"
|
||||
|
||||
ChannelList::ChannelList() {
|
||||
ConnectSignals();
|
||||
|
||||
m_guilds.set_halign(Gtk::ALIGN_START);
|
||||
|
||||
m_guilds_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
||||
|
||||
m_guilds.signal_guild_selected().connect([this](Snowflake guild_id) {
|
||||
m_tree.SetSelectedGuild(guild_id);
|
||||
});
|
||||
|
||||
m_guilds.show();
|
||||
m_tree.show();
|
||||
add(m_tree);
|
||||
m_guilds_scroll.add(m_guilds);
|
||||
pack_start(m_guilds_scroll, false, false); // only take the space it needs
|
||||
pack_start(m_tree, true, true); // use all the remaining space
|
||||
}
|
||||
|
||||
void ChannelList::UpdateListing() {
|
||||
m_tree.UpdateListing();
|
||||
m_guilds.UpdateListing();
|
||||
}
|
||||
|
||||
void ChannelList::SetActiveChannel(Snowflake id, bool expand_to) {
|
||||
@ -18,13 +32,45 @@ void ChannelList::UseExpansionState(const ExpansionStateRoot &state) {
|
||||
}
|
||||
|
||||
ExpansionStateRoot ChannelList::GetExpansionState() const {
|
||||
m_tree.GetExpansionState();
|
||||
return m_tree.GetExpansionState();
|
||||
}
|
||||
|
||||
void ChannelList::UsePanedHack(Gtk::Paned &paned) {
|
||||
m_tree.UsePanedHack(paned);
|
||||
}
|
||||
|
||||
void ChannelList::SetClassic(bool value) {
|
||||
m_tree.SetClassic(value);
|
||||
m_guilds_scroll.set_visible(value);
|
||||
}
|
||||
|
||||
void ChannelList::ConnectSignals() {
|
||||
// TODO: if these all just travel upwards to the singleton then get rid of them but mayeb they dont
|
||||
m_tree.signal_action_open_new_tab().connect([this](Snowflake id) {
|
||||
m_signal_action_open_new_tab.emit(id);
|
||||
});
|
||||
|
||||
m_tree.signal_action_join_voice_channel().connect([this](Snowflake id) {
|
||||
m_signal_action_join_voice_channel.emit(id);
|
||||
});
|
||||
|
||||
m_tree.signal_action_disconnect_voice().connect([this]() {
|
||||
m_signal_action_disconnect_voice.emit();
|
||||
});
|
||||
|
||||
m_tree.signal_action_channel_item_select().connect([this](Snowflake id) {
|
||||
m_signal_action_channel_item_select.emit(id);
|
||||
});
|
||||
|
||||
m_tree.signal_action_guild_leave().connect([this](Snowflake id) {
|
||||
m_signal_action_guild_leave.emit(id);
|
||||
});
|
||||
|
||||
m_tree.signal_action_guild_settings().connect([this](Snowflake id) {
|
||||
m_signal_action_guild_settings.emit(id);
|
||||
});
|
||||
}
|
||||
|
||||
ChannelList::type_signal_action_open_new_tab ChannelList::signal_action_open_new_tab() {
|
||||
return m_signal_action_open_new_tab;
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/paned.h>
|
||||
#include "channellisttree.hpp"
|
||||
#include "classic/guildlist.hpp"
|
||||
#include "discord/snowflake.hpp"
|
||||
#include "state.hpp"
|
||||
|
||||
// Contains the actual ChannelListTree and the classic listing if enabled
|
||||
class ChannelList : public Gtk::Box {
|
||||
class ChannelList : public Gtk::HBox {
|
||||
// have to proxy public and signals to underlying tree... ew!!!
|
||||
public:
|
||||
ChannelList();
|
||||
@ -20,9 +21,16 @@ public:
|
||||
|
||||
void UsePanedHack(Gtk::Paned &paned);
|
||||
|
||||
void SetClassic(bool value);
|
||||
|
||||
private:
|
||||
void ConnectSignals();
|
||||
|
||||
ChannelListTree m_tree;
|
||||
|
||||
Gtk::ScrolledWindow m_guilds_scroll;
|
||||
GuildList m_guilds;
|
||||
|
||||
public:
|
||||
using type_signal_action_channel_item_select = sigc::signal<void, Snowflake>;
|
||||
using type_signal_action_guild_leave = sigc::signal<void, Snowflake>;
|
||||
|
@ -85,8 +85,10 @@ ChannelListTree::ChannelListTree()
|
||||
});
|
||||
|
||||
m_filter_model->set_visible_func([this](const Gtk::TreeModel::const_iterator &iter) -> bool {
|
||||
if (!m_classic) return true;
|
||||
|
||||
if ((*iter)[m_columns.m_type] == RenderType::Guild) {
|
||||
return (*iter)[m_columns.m_id] == 754921263616753776ULL;
|
||||
return (*iter)[m_columns.m_id] == m_classic_selected_guild;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -301,6 +303,16 @@ void ChannelListTree::UsePanedHack(Gtk::Paned &paned) {
|
||||
paned.property_position().signal_changed().connect(sigc::mem_fun(*this, &ChannelListTree::OnPanedPositionChanged));
|
||||
}
|
||||
|
||||
void ChannelListTree::SetClassic(bool value) {
|
||||
m_classic = value;
|
||||
m_filter_model->refilter();
|
||||
}
|
||||
|
||||
void ChannelListTree::SetSelectedGuild(Snowflake guild_id) {
|
||||
m_classic_selected_guild = guild_id;
|
||||
m_filter_model->refilter();
|
||||
}
|
||||
|
||||
void ChannelListTree::OnPanedPositionChanged() {
|
||||
m_view.queue_draw();
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ public:
|
||||
|
||||
void UsePanedHack(Gtk::Paned &paned);
|
||||
|
||||
void SetClassic(bool value);
|
||||
void SetSelectedGuild(Snowflake guild_id);
|
||||
|
||||
protected:
|
||||
void OnPanedPositionChanged();
|
||||
|
||||
@ -186,6 +189,9 @@ protected:
|
||||
|
||||
bool m_updating_listing = false;
|
||||
|
||||
bool m_classic = false;
|
||||
Snowflake m_classic_selected_guild;
|
||||
|
||||
Snowflake m_active_channel;
|
||||
|
||||
public:
|
||||
|
@ -6,18 +6,40 @@ GuildList::GuildList() {
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
void GuildList::UpdateListing() {
|
||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||
|
||||
Clear();
|
||||
|
||||
// does this function still even work ??lol
|
||||
const auto ids = discord.GetUserSortedGuilds();
|
||||
for (const auto id : ids) {
|
||||
AddGuild(id);
|
||||
}
|
||||
}
|
||||
|
||||
void GuildList::AddGuild(Snowflake id) {
|
||||
const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id);
|
||||
if (!guild.has_value()) return;
|
||||
|
||||
auto *item = Gtk::make_managed<GuildListGuildItem>(*guild);
|
||||
item->signal_button_press_event().connect([this, id](GdkEventButton *event) -> bool {
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) {
|
||||
m_signal_guild_selected.emit(id);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
item->show();
|
||||
add(*item);
|
||||
}
|
||||
|
||||
void GuildList::Clear() {
|
||||
const auto children = get_children();
|
||||
for (auto child : children) {
|
||||
for (auto *child : children) {
|
||||
delete child;
|
||||
}
|
||||
}
|
||||
|
||||
GuildList::type_signal_guild_selected GuildList::signal_guild_selected() {
|
||||
return m_signal_guild_selected;
|
||||
}
|
||||
|
@ -6,7 +6,17 @@ class GuildList : public Gtk::ListBox {
|
||||
public:
|
||||
GuildList();
|
||||
|
||||
void AddGuild(Snowflake id);
|
||||
void UpdateListing();
|
||||
|
||||
private:
|
||||
void AddGuild(Snowflake id);
|
||||
void Clear();
|
||||
|
||||
public:
|
||||
using type_signal_guild_selected = sigc::signal<void, Snowflake>;
|
||||
|
||||
type_signal_guild_selected signal_guild_selected();
|
||||
|
||||
private:
|
||||
type_signal_guild_selected m_signal_guild_selected;
|
||||
};
|
||||
|
@ -6,13 +6,6 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild)
|
||||
add(m_image);
|
||||
show_all_children();
|
||||
|
||||
signal_button_press_event().connect([this](GdkEventButton *event) -> bool {
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) {
|
||||
printf("Click %llu\n", (uint64_t)ID);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
set_tooltip_text(guild.Name);
|
||||
|
||||
UpdateIcon();
|
||||
|
@ -33,6 +33,8 @@ MainWindow::MainWindow()
|
||||
});
|
||||
#endif
|
||||
|
||||
// TEMP TEMP TEMP TEMP!!!!!!!!!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
|
||||
m_channel_list.SetClassic(true);
|
||||
m_channel_list.set_vexpand(true);
|
||||
m_channel_list.set_size_request(-1, -1);
|
||||
m_channel_list.show();
|
||||
|
Loading…
Reference in New Issue
Block a user