Debian Codegraph @

gtk/src/calendar.ccg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18
19 namespace
20 {
21 extern "C"
22 {
23 static gchar* SignalProxy_Details_gtk_callback(GtkCalendar*, guint year, guint month, guint day,
24 gpointer user_data)
25 {
26 auto the_slot = static_cast<Gtk::Calendar::SlotDetails*>(user_data);
27
28 try
29 {
30 const auto temp = (*the_slot)(year, month, day);
31 return g_strdup(temp.c_str()); //Freed by GtkCalendar.
32 }
33 catch(...)
34 {
35 Glib::exception_handlers_invoke();
36 }
37 return nullptr; // arbitrary value
38 }
39
40 static void SignalProxy_Details_gtk_callback_destroy(void* data)
41 {
42 delete static_cast<Gtk::Calendar::SlotDetails*>(data);
43 }
44
45 } // extern "C"
46 } // anonymous namespace
47
48 namespace Gtk
49 {
50
51 void Calendar::get_date(Glib::Date& date) const
52 {
53 guint year = 0;
54 guint month = 0;
55 guint day = 0;
56
57 get_date(year, month, day);
58
59 date.set_year(year);
60 date.set_month(static_cast<Glib::Date::Month>(Glib::Date::JANUARY + month)); // Month from 1 to 12 instead from 0 to 11
61 date.set_day(day);
62 }
63
64 void Calendar::set_detail_func(const SlotDetails& slot)
65 {
66 auto slot_copy = new SlotDetails(slot);
67 gtk_calendar_set_detail_func(gobj(), &SignalProxy_Details_gtk_callback, slot_copy, &SignalProxy_Details_gtk_callback_destroy);
68 }
69
70 } //namespace Gtk