Search code examples
c++gtkgtkmm

Gtkmm constantly check if the selected date on Gtk::Calendar changes


I have a calendar and next to it I have a list store with events/tasks with deadlines for each task, I want to create a function that constantly checks if the selected date on the calendar changes, so I can sort my events based on the date chosen by the user, I know how to retrieve the date using:

unsigned int y, m, d;
calendar.get_date(y, m, d);

I would like to always check in the background for whether the date changes.


Solution

  • You have 2 different options:

    • Listen to the signals that are emitted when a user changes the date. In the callback you provide, you can update your list. For example, calendar.signal_month_changed().connect(your_callback)

    • Listen to changes of the "year", "month" and "day" properties. For example, calendar.prop_year().signal_changed.connect(your_callback)