Ejemplo n.º 1
0
bool DateFilter::select_date(const Glib::ustring& title, std::string& isodate) {
	Gtk::Dialog dlg(title, true);
	Gtk::Calendar cal;
	cal.show();

	// select date
	if(!isodate.empty()) {
		guint year = atoi(isodate.substr(0,4).c_str());
		guint month = atoi(isodate.substr(4,2).c_str());
		guint day = atoi(isodate.substr(6,2).c_str());
		cal.select_month(month-1, year);
		cal.select_day(day);
	}

	dlg.get_vbox()->pack_start(cal, Gtk::PACK_SHRINK);
	dlg.add_button(Gtk::Stock::OK , Gtk::RESPONSE_OK);
	dlg.add_button(Gtk::Stock::CANCEL , Gtk::RESPONSE_CANCEL);
	
	dlg.show();

	if(dlg.run() == Gtk::RESPONSE_OK) {
		char date[10];
		guint year;
		guint month;
		guint day;
		cal.get_date(year, month, day);
		g_snprintf(date, sizeof(date), "%04i%02i%02i", year, month+1, day);
		isodate = date;

		return true;
	}
	
	return false;
}