some refactore

This commit is contained in:
2026-02-05 14:33:19 +01:00
parent ce0643b6ac
commit 64b3babd3d
27 changed files with 239 additions and 141 deletions

View File

@@ -36,8 +36,13 @@ add_library(bar_lib)
target_sources(bar_lib
PUBLIC
src/app.cpp
src/bar/bar.cpp
src/components/button/iconButton.cpp
src/components/button/textButton.cpp
src/components/button/tabButton.cpp
src/connection/httpConnection.cpp
src/connection/dbus/notification.cpp
src/connection/dbus/mpris.cpp
@@ -63,7 +68,6 @@ target_sources(bar_lib
src/components/popover.cpp
src/components/workspaceIndicator.cpp
src/components/base/button.cpp
)
include_directories(bar_lib PRIVATE
include

View File

@@ -4,6 +4,7 @@
#include <gtkmm.h>
#include <memory>
#include "components/button/iconButton.hpp"
#include "widgets/clock.hpp"
#include "widgets/date.hpp"
#include "widgets/tray.hpp"
@@ -27,8 +28,8 @@ class Bar : public Gtk::Window {
Clock clock;
Date date;
WebWidget homeAssistant{"\uf024", "Home Assistant", "https://home.rivercry.com"};
ControlCenter controlCenter{"\ue062", "Control Center"};
WebWidget homeAssistant{Icon::HOME_ASSISTANT, "Home Assistant", "https://home.rivercry.com"};
ControlCenter controlCenter{Icon::CONTROL_CENTER, "Control Center"};
std::shared_ptr<TrayWidget> trayWidget = nullptr;
std::shared_ptr<VolumeWidget> volumeWidget = nullptr;

View File

@@ -1,18 +0,0 @@
#pragma once
#include <gtkmm/button.h>
#include "gtkmm/image.h"
#include "sigc++/signal.h"
class Button : public Gtk::Button {
public:
Button(const std::string label);
Button(Gtk::Image &image);
sigc::signal<void()> onClickedSignal;
private:
void on_clicked() {
onClickedSignal.emit();
}
};

View File

@@ -0,0 +1,12 @@
#pragma once
#include <string>
#include "components/button/textButton.hpp"
#include "components/types/icon.hpp"
class IconButton : public TextButton {
public:
IconButton(Icon::Type icon, std::string fontFamilyCss = "materia-icons");
void setIcon(Icon::Type icon);
};

View File

@@ -0,0 +1,9 @@
#pragma once
#include "components/button/iconButton.hpp"
class TabButton : public IconButton {
public:
TabButton(Icon::Type icon);
void setActive(bool active);
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include <string>
#include "gtkmm/button.h"
class TextButton : public Gtk::Button {
public:
TextButton(const std::string &label);
void setText(const std::string &text);
};

View File

@@ -3,11 +3,12 @@
#include <gtkmm/button.h>
#include <gtkmm/popover.h>
#include <string>
#include "components/base/button.hpp"
#include "components/button/iconButton.hpp"
#include "components/button/textButton.hpp"
class Popover : public Button {
class Popover : public IconButton {
public:
Popover(const std::string icon, std::string name);
Popover(Icon::Type icon, std::string name);
~Popover() override;
protected:

View File

@@ -0,0 +1,48 @@
#include <fcntl.h>
#include <map>
#include <string>
class Icon {
public:
enum Type {
HOME_ASSISTANT,
CONTROL_CENTER,
SKIP_PREVIOUS,
SKIP_NEXT,
PLAY_ARROW,
PAUSE,
PLAY_CIRCLE,
EMPTY_DASHBOARD,
SAVE,
CONTENT_COPY,
};
static const std::string toString(Type type) {
return typeToString[type];
}
private:
static inline std::map<Type, const std::string> typeToString = {
{HOME_ASSISTANT, "\uf024"},
{CONTROL_CENTER, "\ue062"},
{SKIP_PREVIOUS, "\ue045"},
{SKIP_NEXT, "\ue044"},
{PLAY_ARROW, "\ue037"},
{PAUSE, "\ue034"},
{PLAY_CIRCLE, "\ue1c4"},
{EMPTY_DASHBOARD, "\uf844"},
{SAVE, "\ue161"},
{CONTENT_COPY, "\ue14d"},
};
};

View File

@@ -1,27 +1,30 @@
#pragma once
#include "components/button/iconButton.hpp"
#include "components/button/tabButton.hpp"
#include "components/popover.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/label.h"
#include "gtkmm/scrolledwindow.h"
#include "gtkmm/stack.h"
#include "widgets/controlCenter/mediaControl.hpp"
#include "widgets/weather.hpp"
#include <memory>
#include <unordered_map>
class ControlCenter : public Popover {
public:
ControlCenter(std::string icon, std::string name);
ControlCenter(Icon::Type icon, std::string name);
private:
Gtk::ScrolledWindow scrollview;
Gtk::Box container;
Gtk::Box tabRow;
Gtk::Stack contentStack;
Gtk::Box controlCenterContainer;
WeatherWidget weatherWidget;
Gtk::Button mediaControl;
Gtk::Button testTabButton;
std::unique_ptr<TabButton> mediaControl;
std::unique_ptr<TabButton> testTabButton;
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
std::unordered_map<std::string, MediaControlWidget*> mediaWidgets;

View File

@@ -7,6 +7,7 @@
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
#include "components/button/iconButton.hpp"
#include "connection/dbus/mpris.hpp"
class MediaControlWidget : public Gtk::Box {
@@ -48,9 +49,9 @@ class MediaControlWidget : public Gtk::Box {
// playback controls
Gtk::Box bottomContainer;
Gtk::Button previousButton;
Gtk::Button playPauseButton;
Gtk::Button nextButton;
std::unique_ptr<IconButton> previousButton;
std::unique_ptr<IconButton> playPauseButton;
std::unique_ptr<IconButton> nextButton;
Gtk::ScrolledWindow imageWrapper;

View File

@@ -17,12 +17,12 @@
#include <string>
#include <vector>
#include "components/button/iconButton.hpp"
#include "connection/dbus/tray.hpp"
#include "components/base/button.hpp"
class TrayIconWidget : public Button {
class TrayIconWidget : public IconButton {
public:
TrayIconWidget(std::string id);
TrayIconWidget(Icon::Type icon, std::string id);
~TrayIconWidget() override;
void update(const TrayService::Item &item);

View File

@@ -3,9 +3,10 @@
#include <gtkmm/button.h>
#include <gtkmm/popover.h>
#include "components/button/iconButton.hpp"
#include "components/popover.hpp"
class WebWidget : public Popover {
public:
WebWidget(std::string icon, std::string title, std::string url);
WebWidget(Icon::Type icon, std::string title, std::string url);
};

View File

@@ -23,11 +23,13 @@ window {
.material-icons {
font-family: var(--icon-font-material);
font-size: 18px;
}
.icon-button {
font-size: 16px;
}
.tab-icon {
font-family: var(--icon-font-material);
font-size: 20px;
margin-right: 6px;
border-radius: 4px;
@@ -35,13 +37,7 @@ window {
padding: 2px 4px;
}
.tab-icon:hover {
background-color: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.control-center-tab-row {
/* mordern and sleek */
background-color: rgba(50, 50, 50, 0.8);
border-radius: 8px;
padding: 2px 4px;
@@ -58,7 +54,6 @@ window {
popover {
margin-top: 4px;
font-family: var(--text-font);
/* padding: 6px; TODO: create better padding*/
border-radius: 8px;
background: rgba(25, 25, 25, 0.8);
@@ -105,8 +100,6 @@ popover {
}
.control-center-seek-bar {
min-height: 6px;
min-width: 120px;
margin: 0 6px;
border-bottom: 1px solid var(--color-border);
}
@@ -139,8 +132,14 @@ tooltip {
}
button {
font-size: 20px;
padding: 3px 6px;
font-size: 14px;
padding: 4px 8px;
border-radius: 4px;
color: #ffffff;
transition:
background-color 0.2s,
color 0.2s,
border-color 0.2s;
}
#spacer {
@@ -151,14 +150,8 @@ button {
}
.button:hover {
background-color: #111111;
}
.flat-button {
background-color: #333333;
color: #ffffff;
padding: 2px 4px;
border-radius: 10px;
background-color: rgba(255, 255, 255, 0.1);
box-shadow: none;
}
.workspace-pill {

View File

@@ -5,6 +5,7 @@
#include <gtkmm/label.h>
#include <gtkmm/window.h>
#include "components/button/textButton.hpp"
#include "helpers/system.hpp"
#include "widgets/date.hpp"
#include "widgets/spacer.hpp"

View File

@@ -1,14 +0,0 @@
#include "components/base/button.hpp"
#include "sigc++/functors/mem_fun.h"
Button::Button(const std::string label) : Gtk::Button(label) {
signal_clicked().connect(sigc::mem_fun(*this, &Button::on_clicked));
this->add_css_class("button");
}
Button::Button(Gtk::Image &image) : Gtk::Button() {
set_child(image);
signal_clicked().connect(sigc::mem_fun(*this, &Button::on_clicked));
this->add_css_class("button");
}

View File

@@ -0,0 +1,10 @@
#include "components/button/iconButton.hpp"
IconButton::IconButton(Icon::Type icon, std::string fontFamilyCss) : TextButton(Icon::toString(icon)) {
this->get_style_context()->add_class(fontFamilyCss);
this->add_css_class("icon-button");
}
void IconButton::setIcon(Icon::Type icon) {
this->set_label(Icon::toString(icon));
}

View File

@@ -0,0 +1,13 @@
#include "components/button/tabButton.hpp"
TabButton::TabButton(Icon::Type icon) : IconButton(icon) {
add_css_class("tab-icon");
}
void TabButton::setActive(bool active) {
if (active) {
this->add_css_class("active-button");
} else {
this->remove_css_class("active-button");
}
}

View File

@@ -0,0 +1,9 @@
#include "components/button/textButton.hpp"
TextButton::TextButton(const std::string &label) : Gtk::Button(label) {
add_css_class("button");
}
void TextButton::setText(const std::string &text) {
this->set_label(text);
}

View File

@@ -1,6 +1,7 @@
#include "components/popover.hpp"
#include "components/button/iconButton.hpp"
Popover::Popover(const std::string icon, std::string name): Button(icon) {
Popover::Popover(Icon::Type icon, std::string name): IconButton(icon) {
signal_clicked().connect(sigc::mem_fun(*this, &Popover::on_toggle_window));
set_name(name);

View File

@@ -1,32 +1,40 @@
#include "widgets/controlCenter/controlCenter.hpp"
#include "components/button/iconButton.hpp"
#include "components/button/tabButton.hpp"
ControlCenter::ControlCenter(std::string icon, std::string name)
ControlCenter::ControlCenter(Icon::Type icon, std::string name)
: Popover(icon, name) {
this->popover->add_css_class("control-center-popover");
this->container.set_orientation(Gtk::Orientation::VERTICAL);
this->container.set_spacing(10);
this->popover->set_hexpand(false);
this->popover->set_size_request(240, -1);
this->scrollview.set_child(this->container);
this->scrollview.set_min_content_width(220);
this->scrollview.set_max_content_width(220);
this->scrollview.set_size_request(220, -1);
this->scrollview.set_policy(
Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
this->scrollview.set_hexpand(false);
this->scrollview.set_vexpand(true);
this->scrollview.set_propagate_natural_height(true);
set_popover_child(this->container);
set_popover_child(this->scrollview);
this->tabRow.set_orientation(Gtk::Orientation::HORIZONTAL);
this->tabRow.set_spacing(4);
this->tabRow.set_margin_bottom(4);
this->tabRow.add_css_class("control-center-tab-row");
this->mediaControl.set_label("\uf5d3"); // control icon
this->mediaControl.add_css_class("tab-icon");
this->testTabButton.set_label("\uE5CA"); // test icon
this->testTabButton.add_css_class("tab-icon");
this->mediaControl = std::make_unique<TabButton>(Icon::PLAY_CIRCLE);
this->testTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
this->tabRow.append(this->mediaControl);
this->tabRow.append(this->testTabButton);
this->tabRow.append(*this->mediaControl);
this->tabRow.append(*this->testTabButton);
this->container.append(this->tabRow);
this->contentStack.set_hhomogeneous(false);
this->contentStack.set_hhomogeneous(true);
this->contentStack.set_vhomogeneous(false);
this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE);
this->contentStack.set_transition_duration(150);
@@ -41,11 +49,11 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
this->container.append(this->contentStack);
this->mediaControl.signal_clicked().connect([this]() {
this->mediaControl->signal_clicked().connect([this]() {
this->setActiveTab("controls");
});
this->testTabButton.signal_clicked().connect([this]() {
this->testTabButton->signal_clicked().connect([this]() {
this->setActiveTab("test");
});
@@ -68,13 +76,13 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
void ControlCenter::setActiveTab(const std::string &tab_name) {
this->contentStack.set_visible_child(tab_name);
this->mediaControl.remove_css_class("active-button");
this->testTabButton.remove_css_class("active-button");
this->mediaControl->setActive(false);
this->testTabButton->setActive(false);
if (tab_name == "controls") {
this->mediaControl.add_css_class("active-button");
this->mediaControl->setActive(true);
} else if (tab_name == "test") {
this->testTabButton.add_css_class("active-button");
this->testTabButton->setActive(true);
}
}

View File

@@ -1,15 +1,34 @@
#include "widgets/controlCenter/mediaControl.hpp"
#include "components/button/iconButton.hpp"
#include "helpers/string.hpp"
#include "services/textureCache.hpp"
namespace {
std::string formatTimeUs(int64_t time_us) {
if (time_us < 0) {
time_us = 0;
}
int64_t totalSeconds = time_us / 1000000;
int64_t hours = totalSeconds / 3600;
int64_t minutes = (totalSeconds / 60) % 60;
int64_t seconds = totalSeconds % 60;
if (hours > 0) {
return std::to_string(hours) + ":" +
(minutes < 10 ? "0" : "") + std::to_string(minutes) + ":" +
(seconds < 10 ? "0" : "") + std::to_string(seconds);
}
return std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds);
}
} // namespace
MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controller)
: Gtk::Box(Gtk::Orientation::VERTICAL) {
this->mprisController = std::move(controller);
this->set_orientation(Gtk::Orientation::VERTICAL);
this->set_size_request(200, -1);
this->set_hexpand(false);
this->set_vexpand(false);
this->add_css_class("control-center-player-container");
@@ -88,6 +107,10 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
}
});
this->previousButton = std::make_unique<IconButton>(Icon::SKIP_PREVIOUS);
this->playPauseButton = std::make_unique<IconButton>(Icon::PLAY_ARROW);
this->nextButton = std::make_unique<IconButton>(Icon::SKIP_NEXT);
this->bottomContainer.set_orientation(Gtk::Orientation::HORIZONTAL);
this->bottomContainer.set_vexpand(false);
this->bottomContainer.set_hexpand(false);
@@ -95,26 +118,17 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
this->bottomContainer.set_homogeneous(true);
this->topContainer.set_vexpand(false);
this->topContainer.set_hexpand(true);
this->bottomContainer.append(this->previousButton);
this->bottomContainer.append(this->playPauseButton);
this->bottomContainer.append(this->nextButton);
this->bottomContainer.append(*this->previousButton);
this->bottomContainer.append(*this->playPauseButton);
this->bottomContainer.append(*this->nextButton);
this->previousButton.set_label("\u23EE"); // Previous track symbol
this->previousButton.add_css_class("button");
this->previousButton.add_css_class("material-icons");
this->playPauseButton.set_label("\u23EF"); // Play/Pause symbol
this->playPauseButton.add_css_class("button");
this->playPauseButton.add_css_class("material-icons");
this->nextButton.set_label("\u23ED"); // Next track symbol
this->nextButton.add_css_class("button");
this->nextButton.add_css_class("material-icons");
this->previousButton.signal_clicked().connect([this]() {
this->previousButton->signal_clicked().connect([this]() {
this->mprisController->previous_song();
});
this->playPauseButton.signal_clicked().connect([this]() {
this->playPauseButton->signal_clicked().connect([this]() {
this->mprisController->toggle_play();
});
this->nextButton.signal_clicked().connect([this]() {
this->nextButton->signal_clicked().connect([this]() {
this->mprisController->next_song();
});
@@ -179,10 +193,7 @@ void MediaControlWidget::onSpotifyMprisUpdated(const MprisPlayer2Message &messag
void MediaControlWidget::setCurrentPosition(int64_t position_us) {
this->currentPositionUs = position_us;
int64_t seconds = (position_us / 1000000) % 60;
int64_t minutes = (position_us / (1000000 * 60)) % 60;
this->currentTimeLabel.set_text(
std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds));
this->currentTimeLabel.set_text(formatTimeUs(position_us));
if (totalLengthUs > 0) {
double fraction = static_cast<double>(currentPositionUs) / static_cast<double>(totalLengthUs);
this->suppressSeekSignal = true;
@@ -193,10 +204,7 @@ void MediaControlWidget::setCurrentPosition(int64_t position_us) {
void MediaControlWidget::setTotalLength(int64_t length_us) {
this->totalLengthUs = length_us;
int64_t seconds = (length_us / 1000000) % 60;
int64_t minutes = (length_us / (1000000 * 60)) % 60;
this->totalTimeLabel.set_text(
std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds));
this->totalTimeLabel.set_text(formatTimeUs(length_us));
}
void MediaControlWidget::resetSeekTimer(int64_t start_position_us) {
@@ -248,20 +256,21 @@ void MediaControlWidget::onRunningStateChanged(MprisController::PlaybackStatus s
}
void MediaControlWidget::onPlay() {
this->playPauseButton.set_label("\u23F8"); // Pause symbol
// strart seek timer if not already running
this->playPauseButton->setIcon(Icon::PAUSE);
this->resetSeekTimer(currentPositionUs);
}
void MediaControlWidget::onPause() {
this->playPauseButton.set_label("\u23F5"); // Play symbol
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
}
void MediaControlWidget::onStop() {
this->playPauseButton.set_label("\u23F9"); // stop symbol
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}

View File

@@ -8,7 +8,6 @@
#include "gdkmm/monitor.h"
#include "glibmm/main.h"
#include "glibmm/object.h"
#include "gtk4-layer-shell.h"
#include "gtkmm/button.h"
#include "gtkmm/cssprovider.h"

View File

@@ -2,6 +2,7 @@
#include <memory>
#include <spdlog/spdlog.h>
#include "components/button/iconButton.hpp"
#include "glibmm/datetime.h"
#include "glibmm/fileutils.h"
@@ -85,12 +86,8 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
auto buttonBox = Gtk::make_managed<Gtk::Box>();
buttonBox->set_spacing(10);
// material icons unicode
auto saveToClipboardLabel = Gtk::make_managed<Gtk::Label>("\uF0EA"); // content copy icon
auto saveToFileLabel = Gtk::make_managed<Gtk::Label>("\uF1C5"); // save icon
auto saveToClipboardButton = Gtk::make_managed<Gtk::Button>();
saveToClipboardButton->set_child(*saveToClipboardLabel);
auto saveToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
saveToClipboardButton->signal_clicked().connect([this]() {
copyToClipboard(this->copiedImage);
spdlog::info("Copied image to clipboard");
@@ -101,8 +98,7 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
saveToClipboardButton->add_css_class("notification-button");
saveToClipboardButton->add_css_class("notification-icon-button");
auto saveToFileButton = Gtk::make_managed<Gtk::Button>();
saveToFileButton->set_child(*saveToFileLabel);
auto saveToFileButton = Gtk::make_managed<IconButton>(Icon::SAVE);
saveToFileButton->signal_clicked().connect([this]() {
// xdg-pic/screenshot // use env
auto xdgPicturesDir = Glib::get_user_special_dir(Glib::UserDirectory::PICTURES);
@@ -136,9 +132,7 @@ void CopyNotification::createTextNotification(NotifyMessage notify) {
textLabel->set_margin_bottom(10);
contentBox->append(*textLabel);
auto copyToClipboardButton = Gtk::make_managed<Gtk::Button>();
auto copyToClipboardLabel = Gtk::make_managed<Gtk::Label>("\uF0EA"); // content copy icon
copyToClipboardButton->set_child(*copyToClipboardLabel);
auto copyToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
copyToClipboardButton->signal_clicked().connect([this]() {
copyToClipboard(this->copiedText);
this->signal_close.emit(this->notificationId);

View File

@@ -1,11 +1,12 @@
#include "widgets/notification/notificationWindow.hpp"
#include <cstdint>
#include <sys/types.h>
#include "components/button/iconButton.hpp"
#include "components/button/textButton.hpp"
#include "helpers/string.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/gestureclick.h"
#include "gtkmm/image.h"
#include "gtkmm/label.h"
@@ -71,8 +72,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
std::string action_id = notify.actions[i];
std::string action_label = notify.actions[i + 1];
auto btn = Gtk::make_managed<Gtk::Button>();
btn->set_label(action_label);
auto btn = Gtk::make_managed<TextButton>(action_label);
btn->add_css_class("notification-button");

View File

@@ -1,6 +1,7 @@
#include "widgets/notification/spotifyNotification.hpp"
#include <sys/types.h>
#include "components/button/iconButton.hpp"
#include "helpers/string.hpp"
#include "services/textureCache.hpp"
@@ -58,7 +59,7 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
buttonBox->set_hexpand(true);
buttonBox->set_halign(Gtk::Align::CENTER);
auto backButton = Gtk::make_managed<Gtk::Button>("\ue045");
auto backButton = Gtk::make_managed<IconButton>(Icon::SKIP_PREVIOUS);
backButton->add_css_class("notification-icon-button");
backButton->add_css_class("notification-button");
backButton->signal_clicked().connect([this, mpris]() {
@@ -68,7 +69,7 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
}
});
auto playPauseButton = Gtk::make_managed<Gtk::Button>("\ue037");
auto playPauseButton = Gtk::make_managed<IconButton>(Icon::PLAY_ARROW);
playPauseButton->add_css_class("notification-icon-button");
playPauseButton->add_css_class("notification-button");
playPauseButton->signal_clicked().connect([playPauseButton, mpris]() {
@@ -77,15 +78,15 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
static bool isPlaying = false;
if (isPlaying) {
playPauseButton->set_label("\ue037");
playPauseButton->setIcon(Icon::PLAY_ARROW);
} else {
playPauseButton->set_label("\ue034");
playPauseButton->setIcon(Icon::PAUSE);
}
isPlaying = !isPlaying;
}
});
auto nextButton = Gtk::make_managed<Gtk::Button>("\ue044");
auto nextButton = Gtk::make_managed<IconButton>(Icon::SKIP_NEXT);
nextButton->add_css_class("notification-icon-button");
nextButton->add_css_class("notification-button");
nextButton->signal_clicked().connect([this, mpris]() {

View File

@@ -7,7 +7,6 @@
#include <graphene.h>
#include <utility>
#include <spdlog/spdlog.h>
#include "components/base/button.hpp"
namespace {
bool is_wayland_display(GtkWidget *widget) {
@@ -182,8 +181,7 @@ void log_menu_tree(const std::vector<TrayService::MenuNode> &nodes,
}
} // namespace
TrayIconWidget::TrayIconWidget( std::string id)
: Button(id), id(std::move(id)),
TrayIconWidget::TrayIconWidget(Icon::Type icon, std::string id) : IconButton(icon), id(std::move(id)),
container(Gtk::Orientation::HORIZONTAL) {
aliveFlag = std::make_shared<bool>(true);
set_has_frame(false);
@@ -592,7 +590,7 @@ void TrayWidget::on_item_added(const TrayService::Item &item) {
return;
}
auto icon = std::make_unique<TrayIconWidget>(item.id);
auto icon = std::make_unique<TrayIconWidget>(Icon::Type::CONTENT_COPY, item.id);
icon->update(item);
auto *raw = icon.get();
append(*raw);

View File

@@ -2,8 +2,9 @@
#include <gtkmm/label.h>
#include <webkit/webkit.h>
#include "components/button/iconButton.hpp"
WebWidget::WebWidget(std::string icon, std::string name, std::string url) : Popover(icon, name) {
WebWidget::WebWidget(Icon::Type icon, std::string name, std::string url) : Popover(icon, name) {
auto webview = webkit_web_view_new();
gtk_widget_set_hexpand(webview, true);
gtk_widget_set_vexpand(webview, true);