summaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-02-05 01:32:08 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2021-02-05 01:32:08 -0500
commitc827bd4943267dec26e2b67d97e2b534b3dbf69a (patch)
tree3fcaeea8497c818d8b92f78a47522649302fb7b5 /windows
parent64adcffe4272d109f296ff46fbc52eea5cf367bd (diff)
downloadabaddon-portaudio-c827bd4943267dec26e2b67d97e2b534b3dbf69a.tar.gz
abaddon-portaudio-c827bd4943267dec26e2b67d97e2b534b3dbf69a.zip
move connection item to own class, add verified check icon
also try and fix build
Diffstat (limited to 'windows')
-rw-r--r--windows/profile/userinfopane.cpp121
-rw-r--r--windows/profile/userinfopane.hpp12
2 files changed, 82 insertions, 51 deletions
diff --git a/windows/profile/userinfopane.cpp b/windows/profile/userinfopane.cpp
index 00652ad..00209af 100644
--- a/windows/profile/userinfopane.cpp
+++ b/windows/profile/userinfopane.cpp
@@ -2,6 +2,73 @@
#include <unordered_set>
#include "../../abaddon.hpp"
+ConnectionItem::ConnectionItem(const ConnectionData &conn)
+ : m_name(conn.Name)
+ , m_box(Gtk::ORIENTATION_HORIZONTAL) {
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+ try {
+ pixbuf = Gdk::Pixbuf::create_from_file("./res/" + conn.Type + ".png", 32, 32);
+ } catch (const Glib::Exception &e) {}
+ std::string url;
+ if (conn.Type == "github")
+ url = "https://github.com/" + conn.Name;
+ else if (conn.Type == "steam")
+ url = "https://steamcommunity.com/profiles/" + conn.ID;
+ else if (conn.Type == "twitch")
+ url = "https://twitch.tv/" + conn.Name;
+ else if (conn.Type == "twitter")
+ url = "https://twitter.com/i/user/" + conn.ID;
+ else if (conn.Type == "spotify")
+ url = "https://open.spotify.com/user/" + conn.ID;
+ else if (conn.Type == "reddit")
+ url = "https://reddit.com/u/" + conn.Name;
+ else if (conn.Type == "youtube")
+ url = "https://www.youtube.com/channel/" + conn.ID;
+ else if (conn.Type == "facebook")
+ url = "https://www.facebook.com/" + conn.ID;
+ if (pixbuf) {
+ m_image = Gtk::manage(new Gtk::Image(pixbuf));
+ m_image->get_style_context()->add_class("profile-connection-image");
+ m_box.add(*m_image);
+ }
+ m_box.set_halign(Gtk::ALIGN_START);
+ m_box.set_size_request(200, -1);
+ m_box.get_style_context()->add_class("profile-connection");
+ m_name.get_style_context()->add_class("profile-connection-label");
+ m_name.set_valign(Gtk::ALIGN_CENTER);
+ m_name.set_single_line_mode(true);
+ m_name.set_ellipsize(Pango::ELLIPSIZE_END);
+ m_box.add(m_name);
+ if (url != "") {
+ auto cb = [this, url](GdkEventButton *event) -> bool {
+ if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) {
+ LaunchBrowser(url);
+ return true;
+ }
+ return false;
+ };
+ signal_button_press_event().connect(sigc::track_obj(cb, *this));
+ AddPointerCursor(*this);
+ }
+ m_overlay.add(m_box);
+ if (conn.IsVerified) {
+ try {
+ static auto pb = Gdk::Pixbuf::create_from_file("./res/checkmark.png", 24, 24);
+ m_check = Gtk::manage(new Gtk::Image(pb));
+ m_check->get_style_context()->add_class("profile-connection-check");
+ m_check->set_margin_end(25);
+ m_check->set_valign(Gtk::ALIGN_CENTER);
+ m_check->set_halign(Gtk::ALIGN_END);
+ m_check->show();
+ m_overlay.add_overlay(*m_check);
+ } catch (const Glib::Exception &e) {}
+ }
+ m_overlay.set_hexpand(false);
+ m_overlay.set_halign(Gtk::ALIGN_START);
+ add(m_overlay);
+ show_all_children();
+}
+
ConnectionsContainer::ConnectionsContainer() {
get_style_context()->add_class("profile-connections");
set_column_homogeneous(true);
@@ -32,57 +99,9 @@ void ConnectionsContainer::SetConnections(const std::vector<ConnectionData> &con
for (int i = 0; i < connections.size(); i++) {
const auto &conn = connections[i];
if (supported_services.find(conn.Type) == supported_services.end()) continue;
- Glib::RefPtr<Gdk::Pixbuf> pixbuf;
- try {
- pixbuf = Gdk::Pixbuf::create_from_file("./res/" + conn.Type + ".png", 32, 32);
- } catch (const Glib::Exception &e) {}
- std::string url;
- if (conn.Type == "github")
- url = "https://github.com/" + conn.Name;
- else if (conn.Type == "steam")
- url = "https://steamcommunity.com/profiles/" + conn.ID;
- else if (conn.Type == "twitch")
- url = "https://twitch.tv/" + conn.Name;
- else if (conn.Type == "twitter")
- url = "https://twitter.com/i/user/" + conn.ID;
- else if (conn.Type == "spotify")
- url = "https://open.spotify.com/user/" + conn.ID;
- else if (conn.Type == "reddit")
- url = "https://reddit.com/u/" + conn.Name;
- else if (conn.Type == "youtube")
- url = "https://www.youtube.com/channel/" + conn.ID;
- else if (conn.Type == "facebook")
- url = "https://www.facebook.com/" + conn.ID;
- auto *ev = Gtk::manage(new Gtk::EventBox);
- auto *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
- if (pixbuf) {
- auto *img = Gtk::manage(new Gtk::Image(pixbuf));
- img->get_style_context()->add_class("profile-connection-image");
- box->add(*img);
- }
- auto *lbl = Gtk::manage(new Gtk::Label(conn.Name));
- box->set_halign(Gtk::ALIGN_START);
- box->set_size_request(200, -1);
- box->get_style_context()->add_class("profile-connection");
- lbl->get_style_context()->add_class("profile-connection-label");
- lbl->set_valign(Gtk::ALIGN_CENTER);
- lbl->set_single_line_mode(true);
- lbl->set_ellipsize(Pango::ELLIPSIZE_END);
- box->add(*lbl);
- if (url != "") {
- auto cb = [this, url](GdkEventButton *event) -> bool {
- if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) {
- LaunchBrowser(url);
- return true;
- }
- return false;
- };
- ev->signal_button_press_event().connect(sigc::track_obj(cb, *ev));
- AddPointerCursor(*ev);
- }
- ev->add(*box);
- ev->show_all();
- attach(*ev, i % 2, i / 2, 1, 1);
+ auto widget = Gtk::manage(new ConnectionItem(conn));
+ widget->show();
+ attach(*widget, i % 2, i / 2, 1, 1);
}
set_halign(Gtk::ALIGN_FILL);
diff --git a/windows/profile/userinfopane.hpp b/windows/profile/userinfopane.hpp
index ae88c70..a93387b 100644
--- a/windows/profile/userinfopane.hpp
+++ b/windows/profile/userinfopane.hpp
@@ -2,6 +2,18 @@
#include <gtkmm.h>
#include "../../discord/objects.hpp"
+class ConnectionItem : public Gtk::EventBox {
+public:
+ ConnectionItem(const ConnectionData &connection);
+
+private:
+ Gtk::Overlay m_overlay;
+ Gtk::Box m_box;
+ Gtk::Label m_name;
+ Gtk::Image *m_image = nullptr;
+ Gtk::Image *m_check = nullptr;
+};
+
class ConnectionsContainer : public Gtk::Grid {
public:
ConnectionsContainer();