/* * Copyright 2013 Canonical Ltd. * * Authors: * Charles Kerr * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include // bindtextdomain() #include #include #include #include // exit() using namespace unity::indicator::datetime; int main(int /*argc*/, char** /*argv*/) { // Work around a deadlock in glib's type initialization. // It can be removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is fixed. g_type_ensure(G_TYPE_DBUS_CONNECTION); // boilerplate i18n setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain(GETTEXT_PACKAGE); // build the state, actions, and menufactory std::shared_ptr state(new State); std::shared_ptr live_settings(new LiveSettings); std::shared_ptr live_timezones(new LiveTimezones(live_settings, TIMEZONE_FILE)); std::shared_ptr live_clock(new LiveClock(live_timezones)); state->settings = live_settings; state->clock = live_clock; state->locations.reset(new SettingsLocations(live_settings, live_timezones)); std::shared_ptr eds_planner(new PlannerEds(live_clock)); eds_planner->time = live_clock->localtime(); state->planner = eds_planner; std::shared_ptr actions(new LiveActions(state)); MenuFactory factory(actions, state); // snap decisions ClockWatcherImpl clock_watcher(state); Snap snap; clock_watcher.alarm_reached().connect([&snap,&eds_planner](const Appointment& appt){ eds_planner->block_appointment(appt); // when we show a snap decision, take it out of the menu auto snap_show = [](const Appointment& a){url_dispatch_send(a.url.c_str(), nullptr, nullptr);}; auto snap_dismiss = [](const Appointment&){}; snap(appt, snap_show, snap_dismiss); }); // create the menus std::vector> menus; for(int i=0, n=Menu::NUM_PROFILES; i