diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-07-05 16:42:31 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-07-05 16:42:31 -0400 |
commit | 7b127439eae79fbe51c9bfc58f2ac8279a8dd64c (patch) | |
tree | b9865eb2a176dc2aae9442fcda16a1eab2cf4475 | |
parent | 09872cf4261d680fc6e38db6c4dcf0b24451f6b4 (diff) | |
parent | 9f66990af2cea19e4f9ebe04cd61e85d1afeb6c1 (diff) | |
download | abaddon-portaudio-7b127439eae79fbe51c9bfc58f2ac8279a8dd64c.tar.gz abaddon-portaudio-7b127439eae79fbe51c9bfc58f2ac8279a8dd64c.zip |
Merge branch 'master' into channels-list
-rw-r--r-- | abaddon.cpp | 5 | ||||
-rw-r--r-- | abaddon.hpp | 1 | ||||
-rw-r--r-- | components/chatmessage.cpp | 157 | ||||
-rw-r--r-- | components/chatmessage.hpp | 22 | ||||
-rw-r--r-- | windows/mainwindow.cpp | 10 | ||||
-rw-r--r-- | windows/mainwindow.hpp | 6 |
6 files changed, 88 insertions, 113 deletions
diff --git a/abaddon.cpp b/abaddon.cpp index 4e900dc..a34ec2c 100644 --- a/abaddon.cpp +++ b/abaddon.cpp @@ -98,7 +98,6 @@ int Abaddon::StartGTK() { m_main_window->signal_action_reload_css().connect(sigc::mem_fun(*this, &Abaddon::ActionReloadCSS)); m_main_window->signal_action_join_guild().connect(sigc::mem_fun(*this, &Abaddon::ActionJoinGuildDialog)); m_main_window->signal_action_set_status().connect(sigc::mem_fun(*this, &Abaddon::ActionSetStatus)); - m_main_window->signal_action_reload_settings().connect(sigc::mem_fun(*this, &Abaddon::ActionReloadSettings)); m_main_window->signal_action_add_recipient().connect(sigc::mem_fun(*this, &Abaddon::ActionAddRecipient)); m_main_window->signal_action_view_pins().connect(sigc::mem_fun(*this, &Abaddon::ActionViewPins)); @@ -636,10 +635,6 @@ bool Abaddon::ShowConfirm(const Glib::ustring &prompt, Gtk::Window *window) { return dlg.run() == Gtk::RESPONSE_OK; } -void Abaddon::ActionReloadSettings() { - m_settings.Reload(); -} - void Abaddon::ActionReloadCSS() { try { Gtk::StyleContext::remove_provider_for_screen(Gdk::Screen::get_default(), m_css_provider); diff --git a/abaddon.hpp b/abaddon.hpp index 1d14c33..aebb9e1 100644 --- a/abaddon.hpp +++ b/abaddon.hpp @@ -50,7 +50,6 @@ public: bool ShowConfirm(const Glib::ustring &prompt, Gtk::Window *window = nullptr); - void ActionReloadSettings(); void ActionReloadCSS(); ImageManager &GetImageManager(); diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index e61ba3f..590e695 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -11,9 +11,9 @@ constexpr static int EmbedImageHeight = 300; constexpr static int ThumbnailSize = 100; constexpr static int StickerComponentSize = 160; -ChatMessageItemContainer::ChatMessageItemContainer() { - m_main = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); - add(*m_main); +ChatMessageItemContainer::ChatMessageItemContainer() + : m_main(Gtk::ORIENTATION_VERTICAL) { + add(m_main); m_link_menu_copy = Gtk::manage(new Gtk::MenuItem("Copy Link")); m_link_menu_copy->signal_activate().connect(sigc::mem_fun(*this, &ChatMessageItemContainer::on_link_menu_copy)); @@ -33,13 +33,13 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d if (data.Content.size() > 0 || data.Type != MessageType::DEFAULT) { container->m_text_component = container->CreateTextComponent(data); container->AttachEventHandlers(*container->m_text_component); - container->m_main->add(*container->m_text_component); + container->m_main.add(*container->m_text_component); } if ((data.MessageReference.has_value() || data.Interaction.has_value()) && data.Type != MessageType::CHANNEL_FOLLOW_ADD) { auto *widget = container->CreateReplyComponent(data); - container->m_main->add(*widget); - container->m_main->child_property_position(*widget) = 0; // eek + container->m_main.add(*widget); + container->m_main.child_property_position(*widget) = 0; // eek } // there should only ever be 1 embed (i think?) @@ -48,11 +48,11 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d if (IsEmbedImageOnly(embed)) { auto *widget = container->CreateImageComponent(*embed.Thumbnail->ProxyURL, *embed.Thumbnail->URL, *embed.Thumbnail->Width, *embed.Thumbnail->Height); container->AttachEventHandlers(*widget); - container->m_main->add(*widget); + container->m_main.add(*widget); } else { container->m_embed_component = container->CreateEmbedComponent(embed); container->AttachEventHandlers(*container->m_embed_component); - container->m_main->add(*container->m_embed_component); + container->m_main.add(*container->m_embed_component); } } @@ -61,10 +61,10 @@ 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); - container->m_main->add(*widget); + container->m_main.add(*widget); } else { auto *widget = container->CreateAttachmentComponent(a); - container->m_main->add(*widget); + container->m_main.add(*widget); } } @@ -82,12 +82,12 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d if (data.StickerItems.has_value()) { auto *widget = container->CreateStickersComponent(*data.StickerItems); - container->m_main->add(*widget); + container->m_main.add(*widget); } if (data.Reactions.has_value() && data.Reactions->size() > 0) { container->m_reactions_component = container->CreateReactionsComponent(data); - container->m_main->add(*container->m_reactions_component); + container->m_main.add(*container->m_reactions_component); } container->UpdateAttributes(); @@ -109,7 +109,7 @@ void ChatMessageItemContainer::UpdateContent() { if (data->Embeds.size() == 1) { m_embed_component = CreateEmbedComponent(data->Embeds[0]); AttachEventHandlers(*m_embed_component); - m_main->add(*m_embed_component); + m_main.add(*m_embed_component); } } @@ -121,7 +121,7 @@ void ChatMessageItemContainer::UpdateReactions() { if (data->Reactions.has_value() && data->Reactions->size() > 0) { m_reactions_component = CreateReactionsComponent(*data); m_reactions_component->show_all(); - m_main->add(*m_reactions_component); + m_main.add(*m_reactions_component); } } @@ -145,7 +145,7 @@ void ChatMessageItemContainer::UpdateAttributes() { m_attrib_label = Gtk::manage(new Gtk::Label); m_attrib_label->set_halign(Gtk::ALIGN_START); m_attrib_label->show(); - m_main->add(*m_attrib_label); // todo: maybe insert markup into existing text widget's buffer if the circumstances are right (or pack horizontally) + m_main.add(*m_attrib_label); // todo: maybe insert markup into existing text widget's buffer if the circumstances are right (or pack horizontally) } if (deleted) @@ -1019,26 +1019,20 @@ void ChatMessageItemContainer::AttachEventHandlers(Gtk::Widget &widget) { widget.signal_button_press_event().connect(on_button_press_event, false); } -ChatMessageHeader::ChatMessageHeader(const Message &data) { +ChatMessageHeader::ChatMessageHeader(const Message &data) + : m_main_box(Gtk::ORIENTATION_HORIZONTAL) + , m_content_box(Gtk::ORIENTATION_VERTICAL) + , m_meta_box(Gtk::ORIENTATION_HORIZONTAL) + , m_avatar(Abaddon::Get().GetImageManager().GetPlaceholder(AvatarSize)) { UserID = data.Author.ID; ChannelID = data.ChannelID; - m_main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - m_content_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); - m_content_box_ev = Gtk::manage(new Gtk::EventBox); - m_meta_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - m_meta_ev = Gtk::manage(new Gtk::EventBox); - m_author = Gtk::manage(new Gtk::Label); - m_timestamp = Gtk::manage(new Gtk::Label); - m_avatar_ev = Gtk::manage(new Gtk::EventBox); - const auto author = Abaddon::Get().GetDiscordClient().GetUser(UserID); auto &img = Abaddon::Get().GetImageManager(); - m_avatar = Gtk::manage(new Gtk::Image(img.GetPlaceholder(AvatarSize))); auto cb = [this](const Glib::RefPtr<Gdk::Pixbuf> &pb) { m_static_avatar = pb->scale_simple(AvatarSize, AvatarSize, Gdk::INTERP_BILINEAR); - m_avatar->property_pixbuf() = m_static_avatar; + m_avatar.property_pixbuf() = m_static_avatar; }; img.LoadFromURL(author->GetAvatarURL(data.GuildID), sigc::track_obj(cb, *this)); @@ -1050,21 +1044,21 @@ ChatMessageHeader::ChatMessageHeader(const Message &data) { } get_style_context()->add_class("message-container"); - m_author->get_style_context()->add_class("message-container-author"); - m_timestamp->get_style_context()->add_class("message-container-timestamp"); - m_avatar->get_style_context()->add_class("message-container-avatar"); + m_author.get_style_context()->add_class("message-container-author"); + m_timestamp.get_style_context()->add_class("message-container-timestamp"); + m_avatar.get_style_context()->add_class("message-container-avatar"); - m_avatar->set_valign(Gtk::ALIGN_START); - m_avatar->set_margin_right(10); + m_avatar.set_valign(Gtk::ALIGN_START); + m_avatar.set_margin_right(10); - m_author->set_markup(data.Author.GetEscapedBoldName()); - m_author->set_single_line_mode(true); - m_author->set_line_wrap(false); - m_author->set_ellipsize(Pango::ELLIPSIZE_END); - m_author->set_xalign(0.f); - m_author->set_can_focus(false); + m_author.set_markup(data.Author.GetEscapedBoldName()); + m_author.set_single_line_mode(true); + m_author.set_line_wrap(false); + m_author.set_ellipsize(Pango::ELLIPSIZE_END); + m_author.set_xalign(0.f); + m_author.set_can_focus(false); - m_meta_ev->signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press)); + m_meta_ev.signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press)); if (author->IsBot || data.WebhookID.has_value()) { m_extra = Gtk::manage(new Gtk::Label); @@ -1079,59 +1073,59 @@ ChatMessageHeader::ChatMessageHeader(const Message &data) { else if (data.WebhookID.has_value()) m_extra->set_markup("<b>Webhook</b>"); - m_timestamp->set_text(data.ID.GetLocalTimestamp()); - m_timestamp->set_hexpand(true); - m_timestamp->set_halign(Gtk::ALIGN_END); - m_timestamp->set_ellipsize(Pango::ELLIPSIZE_END); - m_timestamp->set_opacity(0.5); - m_timestamp->set_single_line_mode(true); - m_timestamp->set_margin_start(12); - m_timestamp->set_can_focus(false); + m_timestamp.set_text(data.ID.GetLocalTimestamp()); + m_timestamp.set_hexpand(true); + m_timestamp.set_halign(Gtk::ALIGN_END); + m_timestamp.set_ellipsize(Pango::ELLIPSIZE_END); + m_timestamp.set_opacity(0.5); + m_timestamp.set_single_line_mode(true); + m_timestamp.set_margin_start(12); + m_timestamp.set_can_focus(false); - m_main_box->set_hexpand(true); - m_main_box->set_vexpand(true); - m_main_box->set_can_focus(true); + m_main_box.set_hexpand(true); + m_main_box.set_vexpand(true); + m_main_box.set_can_focus(true); - m_meta_box->set_hexpand(true); - m_meta_box->set_can_focus(false); + m_meta_box.set_hexpand(true); + m_meta_box.set_can_focus(false); - m_content_box->set_can_focus(false); + m_content_box.set_can_focus(false); const auto on_enter_cb = [this](const GdkEventCrossing *event) -> bool { if (m_anim_avatar) - m_avatar->property_pixbuf_animation() = m_anim_avatar; + m_avatar.property_pixbuf_animation() = m_anim_avatar; return false; }; const auto on_leave_cb = [this](const GdkEventCrossing *event) -> bool { if (m_anim_avatar) - m_avatar->property_pixbuf() = m_static_avatar; + m_avatar.property_pixbuf() = m_static_avatar; return false; }; - m_content_box_ev->add_events(Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); - m_meta_ev->add_events(Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); - m_avatar_ev->add_events(Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); + m_content_box_ev.add_events(Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); + m_meta_ev.add_events(Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); + m_avatar_ev.add_events(Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); if (Abaddon::Get().GetSettings().GetShowAnimations()) { - m_content_box_ev->signal_enter_notify_event().connect(on_enter_cb); - m_content_box_ev->signal_leave_notify_event().connect(on_leave_cb); - m_meta_ev->signal_enter_notify_event().connect(on_enter_cb); - m_meta_ev->signal_leave_notify_event().connect(on_leave_cb); - m_avatar_ev->signal_enter_notify_event().connect(on_enter_cb); - m_avatar_ev->signal_leave_notify_event().connect(on_leave_cb); + m_content_box_ev.signal_enter_notify_event().connect(on_enter_cb); + m_content_box_ev.signal_leave_notify_event().connect(on_leave_cb); + m_meta_ev.signal_enter_notify_event().connect(on_enter_cb); + m_meta_ev.signal_leave_notify_event().connect(on_leave_cb); + m_avatar_ev.signal_enter_notify_event().connect(on_enter_cb); + m_avatar_ev.signal_leave_notify_event().connect(on_leave_cb); } - m_meta_box->add(*m_author); + m_meta_box.add(m_author); if (m_extra != nullptr) - m_meta_box->add(*m_extra); + m_meta_box.add(*m_extra); - m_meta_box->add(*m_timestamp); - m_meta_ev->add(*m_meta_box); - m_content_box->add(*m_meta_ev); - m_avatar_ev->add(*m_avatar); - m_main_box->add(*m_avatar_ev); - m_content_box_ev->add(*m_content_box); - m_main_box->add(*m_content_box_ev); - add(*m_main_box); + m_meta_box.add(m_timestamp); + m_meta_ev.add(m_meta_box); + m_content_box.add(m_meta_ev); + m_avatar_ev.add(m_avatar); + m_main_box.add(m_avatar_ev); + m_content_box_ev.add(m_content_box); + m_main_box.add(m_content_box_ev); + add(m_main_box); set_margin_bottom(8); @@ -1143,8 +1137,8 @@ ChatMessageHeader::ChatMessageHeader(const Message &data) { auto guild_member_update_cb = [this](const auto &, const auto &) { UpdateNameColor(); }; discord.signal_guild_member_update().connect(sigc::track_obj(guild_member_update_cb, *this)); UpdateNameColor(); - AttachUserMenuHandler(*m_meta_ev); - AttachUserMenuHandler(*m_avatar_ev); + AttachUserMenuHandler(m_meta_ev); + AttachUserMenuHandler(m_avatar_ev); } void ChatMessageHeader::UpdateNameColor() { @@ -1161,7 +1155,7 @@ void ChatMessageHeader::UpdateNameColor() { else md = "<span weight='bold'>" + user->GetEscapedName() + "</span>"; - m_author->set_markup(md); + m_author.set_markup(md); } std::vector<Gtk::Widget *> ChatMessageHeader::GetChildContent() { @@ -1202,12 +1196,13 @@ ChatMessageHeader::type_signal_action_open_user_menu ChatMessageHeader::signal_a void ChatMessageHeader::AddContent(Gtk::Widget *widget, bool prepend) { m_content_widgets.push_back(widget); - widget->signal_unmap().connect([this, widget]() { + const auto cb = [this, widget]() { m_content_widgets.erase(std::remove(m_content_widgets.begin(), m_content_widgets.end(), widget), m_content_widgets.end()); - }); - m_content_box->add(*widget); + }; + widget->signal_unmap().connect(sigc::track_obj(cb, *this, *widget), false); + m_content_box.add(*widget); if (prepend) - m_content_box->reorder_child(*widget, 1); + m_content_box.reorder_child(*widget, 1); if (auto *x = dynamic_cast<ChatMessageItemContainer *>(widget)) { if (x->ID > NewestID) NewestID = x->ID; diff --git a/components/chatmessage.hpp b/components/chatmessage.hpp index 3868094..f319449 100644 --- a/components/chatmessage.hpp +++ b/components/chatmessage.hpp @@ -58,8 +58,8 @@ protected: void AttachEventHandlers(Gtk::Widget &widget); - Gtk::EventBox *m_ev; - Gtk::Box *m_main; + Gtk::EventBox *_ev; + Gtk::Box m_main; Gtk::Label *m_attrib_label = nullptr; Gtk::TextView *m_text_component = nullptr; @@ -99,16 +99,16 @@ protected: std::vector<Gtk::Widget *> m_content_widgets; - Gtk::Box *m_main_box; - Gtk::Box *m_content_box; - Gtk::EventBox *m_content_box_ev; - Gtk::Box *m_meta_box; - Gtk::EventBox *m_meta_ev; - Gtk::Label *m_author; - Gtk::Label *m_timestamp; + Gtk::Box m_main_box; + Gtk::Box m_content_box; + Gtk::EventBox m_content_box_ev; + Gtk::Box m_meta_box; + Gtk::EventBox m_meta_ev; + Gtk::Label m_author; + Gtk::Label m_timestamp; Gtk::Label *m_extra = nullptr; - Gtk::Image *m_avatar; - Gtk::EventBox *m_avatar_ev; + Gtk::Image m_avatar; + Gtk::EventBox m_avatar_ev; Glib::RefPtr<Gdk::Pixbuf> m_static_avatar; Glib::RefPtr<Gdk::PixbufAnimation> m_anim_avatar; diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp index 4d6a1dc..35846b7 100644 --- a/windows/mainwindow.cpp +++ b/windows/mainwindow.cpp @@ -32,10 +32,8 @@ MainWindow::MainWindow() m_menu_file.set_label("File"); m_menu_file.set_submenu(m_menu_file_sub); - m_menu_file_reload_settings.set_label("Reload Settings"); m_menu_file_reload_css.set_label("Reload CSS"); m_menu_file_clear_cache.set_label("Clear file cache"); - m_menu_file_sub.append(m_menu_file_reload_settings); m_menu_file_sub.append(m_menu_file_reload_css); m_menu_file_sub.append(m_menu_file_clear_cache); @@ -76,10 +74,6 @@ MainWindow::MainWindow() m_signal_action_set_status.emit(); }); - m_menu_file_reload_settings.signal_activate().connect([this] { - m_signal_action_reload_settings.emit(); - }); - m_menu_file_clear_cache.signal_activate().connect([this] { Abaddon::Get().GetImageManager().ClearCache(); }); @@ -312,10 +306,6 @@ MainWindow::type_signal_action_set_status MainWindow::signal_action_set_status() return m_signal_action_set_status; } -MainWindow::type_signal_action_reload_settings MainWindow::signal_action_reload_settings() { - return m_signal_action_reload_settings; -} - MainWindow::type_signal_action_add_recipient MainWindow::signal_action_add_recipient() { return m_signal_action_add_recipient; } diff --git a/windows/mainwindow.hpp b/windows/mainwindow.hpp index 25c1acb..fa3d331 100644 --- a/windows/mainwindow.hpp +++ b/windows/mainwindow.hpp @@ -41,9 +41,8 @@ public: typedef sigc::signal<void> type_signal_action_reload_css; typedef sigc::signal<void> type_signal_action_join_guild; typedef sigc::signal<void> type_signal_action_set_status; - typedef sigc::signal<void> type_signal_action_reload_settings; typedef sigc::signal<void, Snowflake> type_signal_action_add_recipient; // channel id - typedef sigc::signal<void, Snowflake> type_signal_action_view_pins; // channel id + typedef sigc::signal<void, Snowflake> type_signal_action_view_pins; // channel id type_signal_action_connect signal_action_connect(); type_signal_action_disconnect signal_action_disconnect(); @@ -51,7 +50,6 @@ public: type_signal_action_reload_css signal_action_reload_css(); type_signal_action_join_guild signal_action_join_guild(); type_signal_action_set_status signal_action_set_status(); - type_signal_action_reload_settings signal_action_reload_settings(); type_signal_action_add_recipient signal_action_add_recipient(); type_signal_action_view_pins signal_action_view_pins(); @@ -62,7 +60,6 @@ protected: type_signal_action_reload_css m_signal_action_reload_css; type_signal_action_join_guild m_signal_action_join_guild; type_signal_action_set_status m_signal_action_set_status; - type_signal_action_reload_settings m_signal_action_reload_settings; type_signal_action_add_recipient m_signal_action_add_recipient; type_signal_action_view_pins m_signal_action_view_pins; @@ -92,7 +89,6 @@ protected: Gtk::MenuItem m_menu_file; Gtk::Menu m_menu_file_sub; - Gtk::MenuItem m_menu_file_reload_settings; Gtk::MenuItem m_menu_file_reload_css; Gtk::MenuItem m_menu_file_clear_cache; |