From 955b9239b9eac748d3e5ac4dc56864c906c81393 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 8 Aug 2022 00:40:20 -0400 Subject: [PATCH] hide browse icon when not in channel with perms --- res/css/main.css | 7 ++++++- src/components/chatinput.cpp | 17 +++++++++++++++++ src/components/chatinput.hpp | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/res/css/main.css b/res/css/main.css index 3765498..9398d48 100644 --- a/res/css/main.css +++ b/res/css/main.css @@ -122,7 +122,12 @@ color: #b9bbbe; } -.message-input { +/* 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; } diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index 75dda8d..87892e0 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -149,6 +149,14 @@ ChatInputText &ChatInputTextContainer::Get() { return m_input; } +void ChatInputTextContainer::ShowChooserIcon() { + m_upload_ev.show(); +} + +void ChatInputTextContainer::HideChooserIcon() { + m_upload_ev.hide(); +} + bool ChatInputTextContainer::GetChildPosition(Gtk::Widget *child, Gdk::Rectangle &pos) { Gtk::Allocation main_alloc; { @@ -470,6 +478,8 @@ ChatInput::ChatInput() m_attachments.signal_emptied().connect([this] { m_attachments_revealer.set_reveal_child(false); }); + + SetActiveChannel(Snowflake::Invalid); } void ChatInput::InsertText(const Glib::ustring &text) { @@ -526,6 +536,13 @@ void ChatInput::IndicateTooLarge() { void ChatInput::SetActiveChannel(Snowflake id) { m_active_channel = id; + if (CanAttachFiles()) { + m_input.Get().get_style_context()->add_class("with-browse-icon"); + m_input.ShowChooserIcon(); + } else { + m_input.Get().get_style_context()->remove_class("with-browse-icon"); + m_input.HideChooserIcon(); + } } void ChatInput::StartReplying() { diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp index f6c4358..807f958 100644 --- a/src/components/chatinput.hpp +++ b/src/components/chatinput.hpp @@ -103,6 +103,9 @@ public: // not proxying everythign lol!! ChatInputText &Get(); + void ShowChooserIcon(); + void HideChooserIcon(); + private: void ShowFileChooser(); bool GetChildPosition(Gtk::Widget *child, Gdk::Rectangle &pos);