static void draw_all(state *st){

    gtk_widget_set_size_request(st->drawing_area, st->width, st->height);
    st->cr = gdk_cairo_create(st->drawing_area->window);

    //draw_clock(st);
    draw_weather(st);
    cairo_destroy(st->cr);
}
Example #2
0
static void sync_tuple_changed_callback(const uint32_t key,
					const Tuple* new_values,
					const Tuple* old_values,
					void* context)
{
	bool update_battery = false;
	bool update_weather = false;
	bool update_signals = false;

	switch (key) {

	case PHONE_BATTERY_PERCENT:
		if (new_values && new_values->value) {
			phone_battery_state.charge_percent = new_values->value->uint8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s PHONE_BATTERY_PERCENT: %d",
				__FUNCTION__, phone_battery_state.charge_percent);
			update_battery = true;
		}
		break;
	case PHONE_BATTERY_CHARGING:
		if (new_values && new_values->value) {
			phone_battery_state.is_charging = new_values->value->uint8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s PHONE_BATTERY_CHARGING: %d",
				__FUNCTION__, phone_battery_state.is_charging);
			update_battery = true;
		}
		break;
	case PHONE_BATTERY_PLUGGED:
		if (new_values && new_values->value) {
			phone_battery_state.is_plugged = new_values->value->uint8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s PHONE_BATTERY_PLUGGED: %d",
				__FUNCTION__, phone_battery_state.is_plugged);
			update_battery = true;
		}
		break;

	case WEATHER_MESSAGE_ICON:
		// XXX Not actually using this yet
		if (new_values && new_values->value) {
			weather_info.icon = new_values->value->uint8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s WEATHER_MESSAGE_ICON: %d",
				__FUNCTION__, weather_info.icon);
			update_weather = true;
		}
		break;
	case WEATHER_MESSAGE_TEMPERATURE:
		if (new_values && new_values->value) {
			weather_info.temp = new_values->value->int8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s WEATHER_MESSAGE_TEMPERATURE: %d",
				__FUNCTION__, (int) weather_info.temp);
			update_weather = true;
		}
		break;
	case SIGNAL_STRENGTH_CELL:
		if (new_values && new_values->value) {
			signal_level_cell = new_values->value->uint8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s SIGNAL_LEVEL_CELL: %d",
				__FUNCTION__, signal_level_cell);
			update_signals = true;
		}
		break;
	case CELL_SERVICE_STATE:
		if (new_values && new_values->value) {
			cell_service_state = new_values->value->uint8;
			APP_LOG(APP_LOG_LEVEL_DEBUG, "%s CELL_SERVICE_STATE: %d",
				__FUNCTION__, cell_service_state);
			update_signals = true;
		}
		break;
	};

	if (update_battery) {
		layer_mark_dirty(status_phone_battery_layer);
	}

	if (update_weather) {
		draw_weather(weather_info);
	}

	if (update_signals) {
		draw_signals(signal_level_cell, cell_service_state);
	}
}