From 7aefddddc67f19de7ad0b714700fc19c7d6c0488 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Tue, 14 Jan 2025 01:36:12 -0700 Subject: [PATCH] Stop using deprecated gtk apis --- include/modules/clock.hpp | 10 +++++----- src/modules/clock.cpp | 9 ++++----- src/modules/niri/workspaces.cpp | 2 +- src/modules/sway/workspaces.cpp | 2 +- src/modules/wlr/taskbar.cpp | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/modules/clock.hpp b/include/modules/clock.hpp index 0c62b6767..bfc725c01 100644 --- a/include/modules/clock.hpp +++ b/include/modules/clock.hpp @@ -24,8 +24,8 @@ class Clock final : public ALabel { const std::locale m_locale_; // tooltip const std::string m_tlpFmt_; - std::string m_tlpText_{""}; // tooltip text to print - const Glib::RefPtr m_tooltip_; // tooltip as a separate Gtk::Label + std::string m_tlpText_{""}; // tooltip text to print + Gtk::Label m_tooltip_; // tooltip as a separate Gtk::Label bool query_tlp_cb(int, int, bool, const Glib::RefPtr& tooltip); // Calendar const bool cldInTooltip_; // calendar in tooltip @@ -51,8 +51,8 @@ class Clock final : public ALabel { day cldBaseDay_{0}; // calendar Cached day. Is used when today is changing(midnight) std::string cldText_{""}; // calendar text to print CldMode cldMode_{CldMode::MONTH}; - auto get_calendar(const year_month_day& today, const year_month_day& ymd, - const time_zone* tz) -> const std::string; + auto get_calendar(const year_month_day& today, const year_month_day& ymd, const time_zone* tz) + -> const std::string; // get local time zone auto local_zone() -> const time_zone*; @@ -79,7 +79,7 @@ class Clock final : public ALabel { void tz_up(); void tz_down(); // Module Action Map - static inline std::map actionMap_{ + static inline std::map actionMap_{ {"mode", &waybar::modules::Clock::cldModeSwitch}, {"shift_up", &waybar::modules::Clock::cldShift_up}, {"shift_down", &waybar::modules::Clock::cldShift_down}, diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 7f5a4d558..46f82a11c 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -22,7 +22,6 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) : ALabel(config, "clock", id, "{:%H:%M}", 60, false, false, true), m_locale_{std::locale(config_["locale"].isString() ? config_["locale"].asString() : "")}, m_tlpFmt_{(config_["tooltip-format"].isString()) ? config_["tooltip-format"].asString() : ""}, - m_tooltip_{new Gtk::Label()}, cldInTooltip_{m_tlpFmt_.find("{" + kCldPlaceholder + "}") != std::string::npos}, cldYearShift_{January / 1 / 1900}, tzInTooltip_{m_tlpFmt_.find("{" + kTZPlaceholder + "}") != std::string::npos}, @@ -141,7 +140,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) bool waybar::modules::Clock::query_tlp_cb(int, int, bool, const Glib::RefPtr& tooltip) { - tooltip->set_custom(*m_tooltip_.get()); + tooltip->set_custom(m_tooltip_); return true; } @@ -174,7 +173,7 @@ auto waybar::modules::Clock::update() -> void { } m_tlpText_ = fmt_lib::vformat(m_locale_, m_tlpText_, fmt_lib::make_format_args(now)); - m_tooltip_->set_markup(m_tlpText_); + m_tooltip_.set_markup(m_tlpText_); label_.trigger_tooltip_query(); } @@ -199,8 +198,8 @@ const unsigned cldRowsInMonth(const year_month& ym, const weekday& firstdow) { return 2u + ceil((weekday{ym / 1} - firstdow) + ((ym / last).day() - day{0})).count(); } -auto cldGetWeekForLine(const year_month& ym, const weekday& firstdow, - const unsigned line) -> const year_month_weekday { +auto cldGetWeekForLine(const year_month& ym, const weekday& firstdow, const unsigned line) + -> const year_month_weekday { unsigned index{line - 2}; if (weekday{ym / 1} == firstdow) ++index; return ym / firstdow[index]; diff --git a/src/modules/niri/workspaces.cpp b/src/modules/niri/workspaces.cpp index d2fcad5d9..2b4e2497c 100644 --- a/src/modules/niri/workspaces.cpp +++ b/src/modules/niri/workspaces.cpp @@ -144,7 +144,7 @@ Gtk::Button &Workspaces::addButton(const Json::Value &ws) { button.set_relief(Gtk::RELIEF_NONE); if (!config_["disable-click"].asBool()) { const auto id = ws["id"].asUInt64(); - button.signal_pressed().connect([=] { + button.signal_clicked().connect([=] { try { // {"Action":{"FocusWorkspace":{"reference":{"Id":1}}}} Json::Value request(Json::objectValue); diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index dec5cddf0..8e3e670f5 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -361,7 +361,7 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) { button.set_name("sway-workspace-" + node["name"].asString()); button.set_relief(Gtk::RELIEF_NONE); if (!config_["disable-click"].asBool()) { - button.signal_pressed().connect([this, node] { + button.signal_clicked().connect([this, node] { try { if (node["target_output"].isString()) { ipc_.sendCmd(IPC_COMMAND, diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index 30e4ee488..fd1e886b9 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -598,8 +598,8 @@ bool Task::handle_motion_notify(GdkEventMotion *mn) { /* start drag in addition to other assigned action */ auto target_list = Gtk::TargetList::create(target_entries); auto refptr = Glib::RefPtr(target_list); - auto drag_context = - button.drag_begin(refptr, Gdk::DragAction::ACTION_MOVE, drag_start_button, (GdkEvent *)mn); + auto drag_context = button.drag_begin(refptr, Gdk::DragAction::ACTION_MOVE, drag_start_button, + (GdkEvent *)mn, -1, -1); } return false;