summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/chatwindow.cpp11
-rw-r--r--src/components/chatwindow.hpp2
-rw-r--r--src/components/progressbar.cpp24
-rw-r--r--src/components/progressbar.hpp11
4 files changed, 45 insertions, 3 deletions
diff --git a/src/components/chatwindow.cpp b/src/components/chatwindow.cpp
index d9d490b..5cbeea1 100644
--- a/src/components/chatwindow.cpp
+++ b/src/components/chatwindow.cpp
@@ -9,7 +9,8 @@
#endif
ChatWindow::ChatWindow() {
- Abaddon::Get().GetDiscordClient().signal_message_send_fail().connect(sigc::mem_fun(*this, &ChatWindow::OnMessageSendFail));
+ auto &discord = Abaddon::Get().GetDiscordClient();
+ discord.signal_message_send_fail().connect(sigc::mem_fun(*this, &ChatWindow::OnMessageSendFail));
m_main = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_chat = Gtk::manage(new ChatList);
@@ -59,11 +60,11 @@ ChatWindow::ChatWindow() {
m_input->show();
m_completer.SetBuffer(m_input->GetBuffer());
- m_completer.SetGetChannelID([this]() -> auto {
+ m_completer.SetGetChannelID([this]() {
return m_active_channel;
});
- m_completer.SetGetRecentAuthors([this]() -> auto {
+ m_completer.SetGetRecentAuthors([this]() {
return m_chat->GetRecentAuthors();
});
@@ -109,6 +110,10 @@ ChatWindow::ChatWindow() {
m_main->add(m_completer);
m_main->add(*m_input);
m_main->add(*m_meta);
+ m_main->add(m_progress);
+
+ m_progress.show();
+
m_main->show();
}
diff --git a/src/components/chatwindow.hpp b/src/components/chatwindow.hpp
index 917456b..802826b 100644
--- a/src/components/chatwindow.hpp
+++ b/src/components/chatwindow.hpp
@@ -6,6 +6,7 @@
#include "discord/chatsubmitparams.hpp"
#include "completer.hpp"
#include "state.hpp"
+#include "progressbar.hpp"
#ifdef WITH_LIBHANDY
class ChannelTabSwitcherHandy;
@@ -79,6 +80,7 @@ protected:
ChatInputIndicator *m_input_indicator;
RateLimitIndicator *m_rate_limit_indicator;
Gtk::Box *m_meta;
+ MessageUploadProgressBar m_progress;
#ifdef WITH_LIBHANDY
ChannelTabSwitcherHandy *m_tab_switcher;
diff --git a/src/components/progressbar.cpp b/src/components/progressbar.cpp
new file mode 100644
index 0000000..aa5d748
--- /dev/null
+++ b/src/components/progressbar.cpp
@@ -0,0 +1,24 @@
+#include "progressbar.hpp"
+#include "abaddon.hpp"
+
+MessageUploadProgressBar::MessageUploadProgressBar() {
+ get_style_context()->add_class("message-progress");
+ auto &discord = Abaddon::Get().GetDiscordClient();
+ discord.signal_message_progress().connect([this](const std::string &nonce, float percent) {
+ if (nonce == m_last_nonce) {
+ set_fraction(percent);
+ }
+ });
+ discord.signal_message_send_fail().connect([this](const std::string &nonce, float) {
+ if (nonce == m_last_nonce)
+ set_fraction(0.0);
+ });
+ discord.signal_message_create().connect([this](const Message &msg) {
+ if (msg.IsPending) {
+ m_last_nonce = *msg.Nonce;
+ } else if (msg.Nonce.has_value() && (*msg.Nonce == m_last_nonce)) {
+ m_last_nonce = "";
+ set_fraction(0.0);
+ }
+ });
+}
diff --git a/src/components/progressbar.hpp b/src/components/progressbar.hpp
new file mode 100644
index 0000000..b73521b
--- /dev/null
+++ b/src/components/progressbar.hpp
@@ -0,0 +1,11 @@
+#pragma once
+#include <gtkmm/progressbar.h>
+#include <string>
+
+class MessageUploadProgressBar : public Gtk::ProgressBar {
+public:
+ MessageUploadProgressBar();
+
+private:
+ std::string m_last_nonce;
+};