int
main (int argc, char **args)
{
    gtk_init (&argc, &args);
    
    GtkDialog *dialog = GTK_DIALOG (gtk_dialog_new ());
    HildonTimeEditor *time_editor = HILDON_TIME_EDITOR (hildon_time_editor_new ());

    gtk_box_pack_start (GTK_BOX (dialog->vbox), GTK_WIDGET (time_editor), FALSE, FALSE, 0);
    gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CANCEL);

    gtk_widget_show_all (GTK_WIDGET (dialog));
    gtk_dialog_run (dialog);
    
    return 0;
}
예제 #2
0
void
dates_details_time_cb (DatesData *d, ECalComponentDateTime *time)
{
#ifndef WITH_HILDON
    gint i, hour, minute;
    gchar buffer[33];
    GtkCalendar *calendar;
	
    calendar = GTK_CALENDAR (d->time_calendar);
	
    /* Set time widgets */	
    gtk_calendar_select_month (calendar, time->value->month - 1,
			       time->value->year);
    gtk_calendar_select_day (calendar, time->value->day);

    g_snprintf (buffer, 33, "%d", time->value->hour);
    gtk_entry_set_text (GTK_ENTRY (d->hour_entry), buffer);
    i = time->value->minute / 10;
    g_snprintf (buffer, 33, "%d", i);
    gtk_entry_set_text (GTK_ENTRY (d->lminute_entry), buffer);
    i = time->value->minute - (i * 10);
    g_snprintf (buffer, 33, "%d", i);
    gtk_entry_set_text (GTK_ENTRY (d->rminute_entry), buffer);
    gtk_widget_show (d->time_table);
#else
    HildonDateEditor *date_edit = HILDON_DATE_EDITOR (d->time_date_editor);
    HildonTimeEditor *time_edit = HILDON_TIME_EDITOR (d->time_time_editor);
	
    /* Set date */
    hildon_date_editor_set_year (date_edit, time->value->year);
    hildon_date_editor_set_month (date_edit, time->value->month);
    hildon_date_editor_set_day (date_edit, time->value->day);
	
    /* Set time */
    hildon_time_editor_set_time (time_edit, time->value->hour,
				 time->value->minute, 0);
    hildon_time_editor_set_show_seconds (time_edit, FALSE);
#endif
	
    gtk_widget_hide (d->time_forever_checkbutton);

    /* Run dialog */
	dates_platform_time_dlg (d, TRUE);
	
    /* Retrieve time */
#ifndef WITH_HILDON
    gtk_calendar_get_date (calendar,
			   (guint *)(&time->value->year),
			   (guint *)(&time->value->month),
			   (guint *)(&time->value->day));
    time->value->month += 1;
	
    hour = atoi (gtk_entry_get_text (GTK_ENTRY (d->hour_entry)));
    if ((hour >= 0) && (hour <= 23))
	time->value->hour = hour;
    minute = (atoi (gtk_entry_get_text (GTK_ENTRY (d->lminute_entry))) * 10) +
	atoi (gtk_entry_get_text (GTK_ENTRY (d->rminute_entry)));
    if ((minute >= 0) && (minute <= 59))
	time->value->minute = minute;
#else
    time->value->year = hildon_date_editor_get_year (date_edit);
    time->value->month = hildon_date_editor_get_month (date_edit);
    time->value->day = hildon_date_editor_get_day (date_edit);
	
    hildon_time_editor_get_time (time_edit,
				 (guint *)(&time->value->hour),
				 (guint *)(&time->value->minute),
				 (guint *)(&time->value->second));
#endif
}