clean up some unnecessary stuff

This commit is contained in:
ouwou 2021-05-14 03:16:52 -04:00
parent f53b9742cb
commit 223a185124
13 changed files with 20 additions and 41 deletions

View File

@ -1,8 +0,0 @@
#pragma once
// for things that are used in stackswitchers to be able to be told when they're switched to
class INotifySwitched {
public:
virtual void on_switched_to() {};
};

View File

@ -5,6 +5,7 @@ using namespace std::string_literals;
GuildSettingsAuditLogPane::GuildSettingsAuditLogPane(Snowflake id)
: GuildID(id) {
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsAuditLogPane::OnMap));
set_name("guild-audit-log-pane");
set_hexpand(true);
set_vexpand(true);
@ -14,7 +15,7 @@ GuildSettingsAuditLogPane::GuildSettingsAuditLogPane(Snowflake id)
add(m_list);
}
void GuildSettingsAuditLogPane::on_switched_to() {
void GuildSettingsAuditLogPane::OnMap() {
if (m_requested) return;
m_requested = true;

View File

@ -1,14 +1,13 @@
#pragma once
#include <gtkmm.h>
#include "../../components//inotifyswitched.hpp"
#include "../../discord/objects.hpp"
class GuildSettingsAuditLogPane : public Gtk::ScrolledWindow, public INotifySwitched {
class GuildSettingsAuditLogPane : public Gtk::ScrolledWindow {
public:
GuildSettingsAuditLogPane(Snowflake id);
private:
void on_switched_to() override;
void OnMap();
bool m_requested = false;

View File

@ -10,6 +10,7 @@ GuildSettingsBansPane::GuildSettingsBansPane(Snowflake id)
, m_menu_unban("Unban")
, m_menu_copy_id("Copy ID")
, m_model(Gtk::ListStore::create(m_columns)) {
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsBansPane::OnMap));
set_name("guild-bans-pane");
set_hexpand(true);
set_vexpand(true);
@ -54,7 +55,7 @@ GuildSettingsBansPane::GuildSettingsBansPane(Snowflake id)
m_view.append_column("Reason", m_columns.m_col_reason);
}
void GuildSettingsBansPane::on_switched_to() {
void GuildSettingsBansPane::OnMap() {
if (m_requested) return;
m_requested = true;

View File

@ -1,15 +1,14 @@
#pragma once
#include <gtkmm.h>
#include "../../components/inotifyswitched.hpp"
#include "../../discord/snowflake.hpp"
#include "../../discord/ban.hpp"
class GuildSettingsBansPane : public Gtk::Box, public INotifySwitched {
class GuildSettingsBansPane : public Gtk::Box {
public:
GuildSettingsBansPane(Snowflake id);
private:
void on_switched_to() override;
void OnMap();
bool m_requested = false;

View File

@ -11,6 +11,7 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
, m_menu_delete("Delete")
, m_menu_copy_emoji_url("Copy Emoji URL")
, m_menu_show_emoji("Open in Browser") {
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsEmojisPane::OnMap));
set_name("guild-emojis-pane");
m_view_scroll.set_hexpand(true);
@ -97,7 +98,7 @@ GuildSettingsEmojisPane::GuildSettingsEmojisPane(Snowflake guild_id)
column->set_resizable(true);
}
void GuildSettingsEmojisPane::on_switched_to() {
void GuildSettingsEmojisPane::OnMap() {
m_view.grab_focus();
if (m_requested) return;

View File

@ -1,15 +1,13 @@
#pragma once
#include <gtkmm.h>
#include "../../components/inotifyswitched.hpp"
#include "../../discord/emoji.hpp"
class GuildSettingsEmojisPane : public Gtk::Box
, public INotifySwitched {
class GuildSettingsEmojisPane : public Gtk::Box {
public:
GuildSettingsEmojisPane(Snowflake guild_id);
private:
void on_switched_to() override;
void OnMap();
bool m_requested = false;

View File

@ -5,6 +5,7 @@ GuildSettingsInvitesPane::GuildSettingsInvitesPane(Snowflake id)
: GuildID(id)
, m_model(Gtk::ListStore::create(m_columns))
, m_menu_delete("Delete") {
signal_map().connect(sigc::mem_fun(*this, &GuildSettingsInvitesPane::OnMap));
set_name("guild-invites-pane");
set_hexpand(true);
set_vexpand(true);
@ -36,7 +37,7 @@ GuildSettingsInvitesPane::GuildSettingsInvitesPane(Snowflake id)
column->set_resizable(true);
}
void GuildSettingsInvitesPane::on_switched_to() {
void GuildSettingsInvitesPane::OnMap() {
if (m_requested) return;
m_requested = true;

View File

@ -1,14 +1,13 @@
#pragma once
#include <gtkmm.h>
#include "../../components/inotifyswitched.hpp"
#include "../../discord/objects.hpp"
class GuildSettingsInvitesPane : public Gtk::ScrolledWindow, public INotifySwitched {
class GuildSettingsInvitesPane : public Gtk::ScrolledWindow {
public:
GuildSettingsInvitesPane(Snowflake id);
private:
void on_switched_to() override;
void OnMap();
bool m_requested = false;

View File

@ -1,6 +1,5 @@
#include "guildsettingswindow.hpp"
#include "../abaddon.hpp"
#include "../components/inotifyswitched.hpp"
GuildSettingsWindow::GuildSettingsWindow(Snowflake id)
: m_main(Gtk::ORIENTATION_VERTICAL)
@ -42,11 +41,6 @@ GuildSettingsWindow::GuildSettingsWindow(Snowflake id)
m_switcher.set_margin_top(10);
m_switcher.show();
m_stack.property_visible_child().signal_changed().connect([this]() {
if (auto *w = dynamic_cast<INotifySwitched *>(m_stack.property_visible_child().get_value()))
w->on_switched_to();
});
m_pane_info.show();
m_pane_members.show();
m_pane_roles.show();

View File

@ -34,6 +34,7 @@ MutualFriendItem::MutualFriendItem(const UserData &user)
MutualFriendsPane::MutualFriendsPane(Snowflake id)
: UserID(id) {
signal_map().connect(sigc::mem_fun(*this, &MutualFriendsPane::OnMap));
add(m_list);
show_all_children();
}
@ -49,7 +50,7 @@ void MutualFriendsPane::OnFetchRelationships(const std::vector<UserData> &users)
}
}
void MutualFriendsPane::on_switched_to() {
void MutualFriendsPane::OnMap() {
if (m_requested) return;
m_requested = true;

View File

@ -1,6 +1,5 @@
#pragma once
#include <gtkmm.h>
#include "../../components/inotifyswitched.hpp"
#include "../../discord/objects.hpp"
class MutualFriendItem : public Gtk::Box {
@ -12,14 +11,14 @@ private:
Gtk::Label m_name;
};
class MutualFriendsPane : public Gtk::ScrolledWindow, public INotifySwitched {
class MutualFriendsPane : public Gtk::ScrolledWindow {
public:
MutualFriendsPane(Snowflake id);
Snowflake UserID;
private:
void on_switched_to() override;
void OnMap();
bool m_requested = false;

View File

@ -1,6 +1,5 @@
#include "profilewindow.hpp"
#include "../abaddon.hpp"
#include "../components/inotifyswitched.hpp"
ProfileWindow::ProfileWindow(Snowflake user_id)
: ID(user_id)
@ -71,11 +70,6 @@ ProfileWindow::ProfileWindow(Snowflake user_id)
m_switcher.set_halign(Gtk::ALIGN_START);
m_switcher.set_hexpand(true);
m_stack.property_visible_child().signal_changed().connect([this]() {
if (auto *w = dynamic_cast<INotifySwitched *>(m_stack.property_visible_child().get_value()))
w->on_switched_to();
});
m_stack.add(m_pane_info, "info", "User Info");
m_stack.add(m_pane_guilds, "guilds", "Mutual Servers");
m_stack.add(m_pane_friends, "friends", "Mutual Friends");