Skip to content

Commit

Permalink
Stop using deprecated gtk apis
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Jan 14, 2025
1 parent a4241d7 commit 7aefddd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
10 changes: 5 additions & 5 deletions include/modules/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gtk::Label> 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<Gtk::Tooltip>& tooltip);
// Calendar
const bool cldInTooltip_; // calendar in tooltip
Expand All @@ -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*;
Expand All @@ -79,7 +79,7 @@ class Clock final : public ALabel {
void tz_up();
void tz_down();
// Module Action Map
static inline std::map<const std::string, void (waybar::modules::Clock::*const)()> actionMap_{
static inline std::map<const std::string, void (waybar::modules::Clock::* const)()> actionMap_{
{"mode", &waybar::modules::Clock::cldModeSwitch},
{"shift_up", &waybar::modules::Clock::cldShift_up},
{"shift_down", &waybar::modules::Clock::cldShift_down},
Expand Down
9 changes: 4 additions & 5 deletions src/modules/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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<Gtk::Tooltip>& tooltip) {
tooltip->set_custom(*m_tooltip_.get());
tooltip->set_custom(m_tooltip_);
return true;
}

Expand Down Expand Up @@ -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();
}

Expand All @@ -199,8 +198,8 @@ const unsigned cldRowsInMonth(const year_month& ym, const weekday& firstdow) {
return 2u + ceil<weeks>((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];
Expand Down
2 changes: 1 addition & 1 deletion src/modules/niri/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/sway/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/wlr/taskbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gtk::TargetList>(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;
Expand Down

0 comments on commit 7aefddd

Please sign in to comment.