/* Copyright (C) 1998-2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
#include
namespace
{
extern "C"
{
static gchar* SignalProxy_Details_gtk_callback(GtkCalendar*, guint year, guint month, guint day,
gpointer user_data)
{
auto the_slot = static_cast(user_data);
try
{
const auto temp = (*the_slot)(year, month, day);
return g_strdup(temp.c_str()); //Freed by GtkCalendar.
}
catch(...)
{
Glib::exception_handlers_invoke();
}
return nullptr; // arbitrary value
}
static void SignalProxy_Details_gtk_callback_destroy(void* data)
{
delete static_cast(data);
}
} // extern "C"
} // anonymous namespace
namespace Gtk
{
void Calendar::get_date(Glib::Date& date) const
{
guint year = 0;
guint month = 0;
guint day = 0;
get_date(year, month, day);
date.set_year(year);
date.set_month(static_cast(Glib::Date::JANUARY + month)); // Month from 1 to 12 instead from 0 to 11
date.set_day(day);
}
void Calendar::set_detail_func(const SlotDetails& slot)
{
auto slot_copy = new SlotDetails(slot);
gtk_calendar_set_detail_func(gobj(), &SignalProxy_Details_gtk_callback, slot_copy, &SignalProxy_Details_gtk_callback_destroy);
}
} //namespace Gtk