summaryrefslogtreecommitdiff
path: root/src/components/chatinput.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-12-15 01:36:06 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2023-12-15 01:36:06 -0500
commitaf31402b7f1d9d118f07f0fd6554319dbd6b44b6 (patch)
tree309ef8ee1b4dc7e787193f4eaffa219f0b68213d /src/components/chatinput.cpp
parent8324172a90752403edcec2203a2abb386046cc8f (diff)
parent4bce7b7523caa26023b1a2f5e02e6646ed29f5e0 (diff)
downloadabaddon-portaudio-af31402b7f1d9d118f07f0fd6554319dbd6b44b6.tar.gz
abaddon-portaudio-af31402b7f1d9d118f07f0fd6554319dbd6b44b6.zip
Merge branch 'master' into theming
Diffstat (limited to 'src/components/chatinput.cpp')
-rw-r--r--src/components/chatinput.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp
index b6beaa5..1db03ed 100644
--- a/src/components/chatinput.cpp
+++ b/src/components/chatinput.cpp
@@ -262,7 +262,7 @@ std::vector<ChatSubmitParams::Attachment> ChatInputAttachmentContainer::GetAttac
for (auto *x : m_attachments) {
if (!x->GetFile()->query_exists())
puts("bad!");
- ret.push_back({ x->GetFile(), x->GetType(), x->GetFilename() });
+ ret.push_back({ x->GetFile(), x->GetType(), x->GetFilename(), x->GetDescription() });
}
return ret;
}
@@ -310,6 +310,7 @@ ChatInputAttachmentItem::ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &
, m_img(Gtk::make_managed<Gtk::Image>())
, m_type(is_extant ? ChatSubmitParams::ExtantFile : ChatSubmitParams::PastedImage)
, m_filename("unknown.png")
+ , m_is_image(true)
, m_label("unknown.png")
, m_box(Gtk::ORIENTATION_VERTICAL) {
get_style_context()->add_class("attachment-item");
@@ -356,10 +357,18 @@ std::string ChatInputAttachmentItem::GetFilename() const {
return m_filename;
}
+std::optional<std::string> ChatInputAttachmentItem::GetDescription() const {
+ return m_description.empty() ? std::nullopt : std::optional<std::string>(m_description);
+}
+
bool ChatInputAttachmentItem::IsTemp() const noexcept {
return m_type == ChatSubmitParams::PastedImage;
}
+bool ChatInputAttachmentItem::IsImage() const noexcept {
+ return m_is_image;
+}
+
void ChatInputAttachmentItem::RemoveIfTemp() {
if (IsTemp())
m_file->remove();
@@ -387,12 +396,22 @@ void ChatInputAttachmentItem::SetupMenu() {
}
});
+ m_menu_set_alt_text.set_label("Change Alt-Text");
+ m_menu_set_alt_text.signal_activate().connect([this]() {
+ const auto description = Abaddon::Get().ShowTextPrompt("Enter description (alt-text) for attachment", "Enter alt-text", m_description);
+ if (description.has_value()) {
+ m_description = *description;
+ }
+ });
+
m_menu.add(m_menu_set_filename);
+ m_menu.add(m_menu_set_alt_text);
m_menu.add(m_menu_remove);
m_menu.show_all();
signal_button_press_event().connect([this](GdkEventButton *ev) -> bool {
if (ev->button == GDK_BUTTON_SECONDARY) {
+ m_menu_set_alt_text.set_visible(IsImage());
m_menu.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev));
return true;
}