static void message_handler(DictionaryIterator *received, void *context) { bool refresh_window = 0; Tuple *tuple_show_date = dict_find(received, MESSAGE_KEY_ShowDate); Tuple *tuple_show_battery = dict_find(received, MESSAGE_KEY_ShowBattery); Tuple *tuple_use_bold_font = dict_find(received, MESSAGE_KEY_UseBoldFont); Tuple *tuple_use_larger_font = dict_find(received, MESSAGE_KEY_UseLargerFont); if (tuple_show_date) { refresh_window = 1; settings.show_date = (bool)tuple_show_date->value->int32; } if (tuple_show_battery) { refresh_window = 1; settings.show_battery = (bool)tuple_show_battery->value->int32; } if (tuple_use_bold_font) { refresh_window = 1; settings.use_bold_font = (bool)tuple_use_bold_font->value->int32; } if (tuple_use_larger_font) { refresh_window = 1; settings.use_larger_font = (bool)tuple_use_larger_font->value->int32; } persist_write_data(SETTINGS_KEY, &settings, sizeof(settings)); if (refresh_window) { main_window_destroy(); main_window_create(); } }
static void message_handler(DictionaryIterator *received, void *context) { bool refresh_window = 0; app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "this is message_handler"); /* options */ Tuple *tuple_black_on_white = dict_find(received, OPTION_BLACK_ON_WHITE); Tuple *tuple_show_date = dict_find(received, OPTION_SHOW_DATE); Tuple *tuple_show_battery = dict_find(received, OPTION_SHOW_BATTERY); Tuple *tuple_larger_clock_font = dict_find(received, OPTION_LARGER_CLOCK_FONT); /* options */ if (tuple_black_on_white) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_black_on_white"); refresh_window = 1; black_on_white = (bool)tuple_black_on_white->value->int32; } if (tuple_show_date) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_show_data"); refresh_window = 1; show_date = (bool)tuple_show_date->value->int32; } if (tuple_show_battery) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_show_battery"); refresh_window = 1; show_battery = (bool)tuple_show_battery->value->int32; } if (tuple_larger_clock_font) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "found tuple_larger_clock_font"); refresh_window = 1; larger_clock_font = (bool)tuple_larger_clock_font->value->int32; } /* options */ persist_write_bool(OPTION_BLACK_ON_WHITE, black_on_white); persist_write_bool(OPTION_SHOW_DATE, show_date); persist_write_bool(OPTION_SHOW_BATTERY, show_battery); persist_write_bool(OPTION_LARGER_CLOCK_FONT, larger_clock_font); if (refresh_window) { main_window_unload(s_main_window); main_window_destroy(); main_window_create(); main_window_load(s_main_window); } }
static void deinit(void) { app_message_deregister_callbacks(); main_window_destroy(); }
void game_destroy(game *game) { main_window_destroy(&game->main_window); gtk_main_quit(); }