2 * This file is part of hildon-libs
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * SECTION:hildon-time-picker
27 * @short_description: A dialog popup widget which lets the user set the time
28 * @see_also: #HildonTimeEditor
30 * #HildonTimePicker is a dialog popup widget which lets the user set the time,
31 * using up/down arrows on hours and minutes. There are two arrows for minutes,
32 * so that minutes can be added also in 10 min increments.This widget is mainly
33 * used as a part of #HildonTimeEditor implementation.
40 #include "hildon-time-picker.h"
41 #include "hildon-defines.h"
43 #include <gdk/gdkkeysyms.h>
51 #include "hildon-time-picker-private.h"
52 #include "hildon-time-editor.h"
55 dgettext(PACKAGE, String)
57 #define DEFAULT_HOURS 1
59 #define DEFAULT_MINUTES 1
61 #define DEFAULT_ARROW_WIDTH 26
63 #define DEFAULT_ARROW_HEIGHT 26
65 #define MINS_IN_1H (60)
67 #define MINS_IN_24H (MINS_IN_1H * 24)
69 #define MINS_IN_12H (MINS_IN_1H * 12)
71 #define HILDON_TIME_PICKER_LABEL_X_PADDING 0
73 #define HILDON_TIME_PICKER_LABEL_Y_PADDING 1
76 hildon_time_picker_class_init (HildonTimePickerClass *klass);
79 hildon_time_picker_init (HildonTimePicker *picker);
82 hildon_time_picker_key_repeat_timeout (gpointer tpicker);
85 hildon_time_picker_change_time (HildonTimePicker *picker,
89 hildon_time_picker_ampm_release (GtkWidget *widget,
91 HildonTimePicker *picker);
94 hildon_time_picker_arrow_press (GtkWidget *widget,
96 HildonTimePicker *picker);
99 hildon_time_picker_arrow_release (GtkWidget *widget,
101 HildonTimePicker *picker);
104 hildon_time_picker_finalize (GObject *object);
107 hildon_time_picker_get_property (GObject *object,
113 hildon_time_picker_set_property (GObject *object,
119 hildon_time_picker_event_box_focus_in (GtkWidget *widget,
124 hildon_time_picker_event_box_focus_out (GtkWidget *widget,
129 hildon_time_picker_event_box_key_press (GtkWidget *widget,
131 HildonTimePicker *picker);
134 hildon_time_picker_event_box_key_release (GtkWidget *widget,
136 HildonTimePicker *picker);
139 hildon_time_picker_event_box_button_press (GtkWidget *widget,
144 hildon_time_picker_map (GtkWidget *widget);
147 frame_size_request (GtkWidget *widget,
148 GtkRequisition *requistion);
150 static GtkDialogClass* parent_class;
158 static const gint button_multipliers[WIDGET_GROUP_COUNT][2] =
160 { MINS_IN_1H, -MINS_IN_1H },
167 hildon_time_picker_get_type (void)
169 static GType picker_type = 0;
173 static const GTypeInfo picker_info =
175 sizeof (HildonTimePickerClass),
176 NULL, /* base_init */
177 NULL, /* base_finalize */
178 (GClassInitFunc)hildon_time_picker_class_init,
179 NULL, /* class_finalize */
180 NULL, /* class_data */
181 sizeof (HildonTimePicker),
183 (GInstanceInitFunc)hildon_time_picker_init,
185 picker_type = g_type_register_static( GTK_TYPE_DIALOG, "HildonTimePicker",
193 hildon_time_picker_class_init (HildonTimePickerClass *klass)
195 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
196 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
197 parent_class = g_type_class_peek_parent (klass);
199 gobject_class->finalize = hildon_time_picker_finalize;
200 gobject_class->get_property = hildon_time_picker_get_property;
201 gobject_class->set_property = hildon_time_picker_set_property;
202 widget_class->map = hildon_time_picker_map;
205 * HildonTimePicker:minutes:
207 * Currently selected time in minutes since midnight.
209 g_object_class_install_property (gobject_class, PROP_MINUTES,
210 g_param_spec_uint ("minutes",
212 "The selected time in minutes "
215 G_PARAM_READABLE | G_PARAM_WRITABLE) );
217 gtk_widget_class_install_style_property (widget_class,
218 g_param_spec_uint ("arrow-width",
220 "Increase/decrease arrows width.",
225 gtk_widget_class_install_style_property (widget_class,
226 g_param_spec_uint ("arrow-height",
228 "Increase/decrease arrows height.",
230 DEFAULT_ARROW_HEIGHT,
233 g_type_class_add_private (klass, sizeof (HildonTimePickerPrivate));
236 /* Okay, this is really bad. We make the requisition of the frames a bit larger
237 * so that it doesn't "change" when digits are changed (see #37489). It's a
238 * really bad solution to a problem, but the whole layout of the time picker is
239 * on crack anyways */
241 frame_size_request (GtkWidget *widget,
242 GtkRequisition *requistion)
244 int framed = requistion->width / 10;
245 requistion->width = (framed + 1) * 10;
249 hildon_time_picker_init (HildonTimePicker *picker)
251 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
252 gint widget_group_table_column_pos[WIDGET_GROUP_COUNT];
253 GtkSettings *settings = NULL;
254 GtkDialog *dialog = GTK_DIALOG (picker);
255 GtkTable *table = NULL;
256 GtkWidget *maintocenter, *colon_label;
257 const struct tm *local = NULL;
263 widget_group_table_column_pos[WIDGET_GROUP_HOURS] = 1;
264 widget_group_table_column_pos[WIDGET_GROUP_10_MINUTES] = 3;
265 widget_group_table_column_pos[WIDGET_GROUP_1_MINUTES] = 4;
266 widget_group_table_column_pos[WIDGET_GROUP_AMPM] = 5;
268 /* Get AM/PM strings from locale. If they're set, the time is wanted
270 priv->am_symbol = g_strdup (nl_langinfo (AM_STR));
271 priv->pm_symbol = g_strdup (nl_langinfo (PM_STR));
273 priv->show_ampm = priv->am_symbol[0] != '\0';
276 /* Check if AM/PM should be before or after time.
277 %p is the AM/PM string, so we assume that if the format string
278 begins with %p it's in the beginning, and in any other case it's
279 in the end (although that's not necessarily the case). */
280 if (strncmp (nl_langinfo (T_FMT_AMPM), "%p", 2) == 0)
282 /* Before time. Update column position. */
283 priv->ampm_left = TRUE;
284 widget_group_table_column_pos[WIDGET_GROUP_AMPM] = 0;
288 gtk_widget_push_composite_child ();
290 /* Pack all our internal widgets into a table */
291 table = GTK_TABLE (gtk_table_new (3, 6, FALSE));
293 /* Put everything centered into window */
294 maintocenter = gtk_alignment_new (0.5, 0, 0, 0);
296 /* Create our internal widgets */
297 for (i = 0; i < WIDGET_GROUP_COUNT; i++)
299 HildonTimePickerWidgetGroup *group = &priv->widgets[i];
300 gint table_column = widget_group_table_column_pos[i];
302 /* Create frame and attach to table. With AM/PM label we're attaching
304 group->frame = gtk_frame_new (NULL);
305 if (i != WIDGET_GROUP_AMPM)
307 gtk_table_attach (table, group->frame, table_column, table_column + 1,
308 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0);
312 /* FIXME: is it needed to force it to 0 here? */
313 gtk_container_set_border_width (GTK_CONTAINER(group->frame), 0);
315 /* Create eventbox inside frame */
316 group->eventbox = gtk_event_box_new ();
317 gtk_container_add (GTK_CONTAINER (group->frame), group->eventbox);
319 g_object_set (group->eventbox, "can-focus", TRUE, NULL);
320 gtk_widget_set_events (group->eventbox,
321 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_PRESS_MASK);
323 /* Connect signals to eventbox */
324 g_signal_connect (group->eventbox, "key-release-event",
325 G_CALLBACK (hildon_time_picker_event_box_key_release),
327 g_signal_connect (group->eventbox, "key-press-event",
328 G_CALLBACK (hildon_time_picker_event_box_key_press),
330 g_signal_connect (group->eventbox, "focus-in-event",
331 G_CALLBACK (hildon_time_picker_event_box_focus_in),
333 g_signal_connect (group->eventbox, "focus-out-event",
334 G_CALLBACK (hildon_time_picker_event_box_focus_out),
336 g_signal_connect (group->eventbox, "button-press-event",
337 G_CALLBACK (hildon_time_picker_event_box_button_press),
340 /* Create label inside eventbox */
341 group->label = GTK_LABEL (gtk_label_new (NULL));
342 g_signal_connect (group->frame, "size-request",
343 G_CALLBACK (frame_size_request),
345 gtk_misc_set_alignment (GTK_MISC (group->label), 0.5, 0.5);
346 gtk_container_add (GTK_CONTAINER (group->eventbox), GTK_WIDGET (group->label));
348 if (i != WIDGET_GROUP_AMPM)
352 /* Add some padding to hour and minute labels, and make them bigger */
353 gtk_misc_set_padding(GTK_MISC (group->label),
354 HILDON_TIME_PICKER_LABEL_X_PADDING,
355 HILDON_TIME_PICKER_LABEL_Y_PADDING);
357 gtk_widget_set_name (GTK_WIDGET(group->label), "osso-LargeFont");
359 /* Create up and down buttons for hours and mins */
360 for (button = 0; button < BUTTON_COUNT; button++)
362 gint table_row = button == BUTTON_UP ? 0 : 2;
364 group->buttons[button] = gtk_button_new ();
365 gtk_table_attach (table, group->buttons[button],
366 table_column, table_column + 1,
367 table_row, table_row + 1,
368 GTK_SHRINK, GTK_SHRINK, 0, 0);
369 g_object_set (group->buttons[button], "can-focus", FALSE, NULL);
371 /* Connect signals */
372 g_signal_connect(group->buttons[button], "button-press-event",
373 G_CALLBACK (hildon_time_picker_arrow_press), picker);
374 g_signal_connect(group->buttons[button], "button-release-event",
375 G_CALLBACK (hildon_time_picker_arrow_release), picker);
378 gtk_widget_set_name (group->buttons[BUTTON_UP],
379 "hildon-time-picker-up");
380 gtk_widget_set_name (group->buttons[BUTTON_DOWN],
381 "hildon-time-picker-down");
385 /* Label between hour and minutes */
386 colon_label = gtk_label_new (NULL);
387 hildon_time_editor_get_time_separators (GTK_LABEL(colon_label), NULL);
389 gtk_table_attach (table, colon_label, 2, 3, 1, 2,
390 GTK_SHRINK, GTK_SHRINK, 6, 0); /* FIXME: magic */
391 gtk_widget_set_name (colon_label, "osso-LargeFont" );
395 priv->key_repeat = 0;
396 priv->start_key_repeat = FALSE;
398 priv->button_press = FALSE;
400 gtk_table_set_row_spacing (table, 0, 6);
401 gtk_table_set_row_spacing (table, 1, 6);
405 gint table_column = widget_group_table_column_pos[WIDGET_GROUP_AMPM];
406 GtkWidget *ampmtotop = NULL;
408 /* Show the AM/PM label centered vertically */
409 ampmtotop = gtk_alignment_new (0, 0.5, 0, 0);
410 gtk_table_attach (table, ampmtotop, table_column, table_column + 1,
411 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
412 gtk_container_add (GTK_CONTAINER (ampmtotop),
413 priv->widgets[WIDGET_GROUP_AMPM].frame);
415 if (table_column != 0)
416 gtk_table_set_col_spacing (table, table_column - 1, 9);
418 /* Connect AM/PM signal handlers */
419 g_signal_connect (priv->widgets[WIDGET_GROUP_AMPM].eventbox,
420 "button-release-event",
421 G_CALLBACK(hildon_time_picker_ampm_release), picker);
424 gtk_widget_pop_composite_child ();
426 /* Get button press repeater timeout from settings (in milliseconds) */
427 settings = gtk_settings_get_default ();
428 g_object_get (settings, "gtk-timeout-update", &priv->key_repeat, NULL);
430 /* This dialog isn't modal */
431 gtk_window_set_modal (GTK_WINDOW(dialog), FALSE);
432 /* And final dialog packing */
433 gtk_dialog_set_has_separator (dialog, FALSE);
434 gtk_dialog_add_button (dialog, _("ecdg_bd_time_picker_close"),
437 gtk_container_add (GTK_CONTAINER (maintocenter), GTK_WIDGET(table));
438 gtk_box_pack_start (GTK_BOX (dialog->vbox), maintocenter, TRUE, FALSE, 0);
440 /* Set default time to current time */
442 local = localtime (&stamp);
443 hildon_time_picker_set_time (picker, local->tm_hour, local->tm_min);
445 gtk_widget_show_all (maintocenter);
449 hildon_time_picker_set_property (GObject *object,
454 HildonTimePicker *picker = HILDON_TIME_PICKER (object);
460 hildon_time_picker_change_time (picker, g_value_get_uint(value));
464 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
470 hildon_time_picker_finalize (GObject *object)
472 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (object);
476 /* Make sure the timer is stopped */
478 g_source_remove(priv->timer_id);
480 g_free(priv->am_symbol);
481 g_free(priv->pm_symbol);
483 if (G_OBJECT_CLASS(parent_class)->finalize)
484 G_OBJECT_CLASS(parent_class)->finalize(object);
488 hildon_time_picker_get_property (GObject *object,
493 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (object);
499 g_value_set_uint (value, priv->minutes);
503 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
509 hildon_time_picker_map (GtkWidget *widget)
513 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (widget);
516 /* Widget is now mapped. Set border for the dialog. */
517 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
519 /* Update hour/minute up/down buttons sizes from style properties */
520 gtk_widget_style_get (widget,
521 "arrow-width", &width,
522 "arrow-height", &height, NULL);
524 for (i = 0; i < WIDGET_GROUP_COUNT; i++)
526 if (priv->widgets[i].buttons[0] != NULL)
528 for (button = 0; button < BUTTON_COUNT; button++)
530 gtk_widget_set_size_request (priv->widgets[i].buttons[button], width, height);
535 GTK_WIDGET_CLASS (parent_class)->map(widget);
539 * Clicked hour/minute field. Move focus to it.
542 hildon_time_picker_event_box_button_press (GtkWidget *widget,
546 gtk_widget_grab_focus (widget);
551 * Clicked AM/PM label. Move focus to it and move the time by 12 hours.
554 hildon_time_picker_ampm_release (GtkWidget *widget,
556 HildonTimePicker *picker)
558 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
561 gtk_widget_grab_focus (widget);
562 hildon_time_picker_change_time (picker, priv->minutes > MINS_IN_12H ?
563 priv->minutes - MINS_IN_12H :
564 priv->minutes + MINS_IN_12H);
570 hildon_time_picker_arrow_press (GtkWidget *widget,
572 HildonTimePicker *picker)
574 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
578 /* Make sure we don't add repeat timer twice. Normally it shouldn't
579 happen but WM can cause button release to be lost. */
580 if (priv->button_press )
583 priv->start_key_repeat = priv->button_press = TRUE;
585 /* Find the widget which was clicked */
587 for (i = 0; i < WIDGET_GROUP_COUNT; i++)
589 for (button = 0; button < BUTTON_COUNT; button++)
591 if (priv->widgets[i].buttons[button] == widget)
593 /* Update multiplier and move the focus to the clicked field */
594 priv->mul = button_multipliers[i][button];
595 gtk_widget_grab_focus (priv->widgets[i].eventbox);
600 g_assert (priv->mul != 0);
602 /* Change the time now, wrapping if needed. */
603 newval = priv->minutes + priv->mul;
605 newval += MINS_IN_24H;
607 hildon_time_picker_change_time (picker, newval);
609 /* Keep changing the time as long as button is being pressed.
610 The first repeat takes 3 times longer to start than the rest. */
611 priv->timer_id = g_timeout_add (priv->key_repeat * 3,
612 hildon_time_picker_key_repeat_timeout,
619 hildon_time_picker_arrow_release (GtkWidget *widget,
621 HildonTimePicker *picker)
623 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
628 /* Stop repeat timer */
629 g_source_remove (priv->timer_id);
633 priv->button_press = FALSE;
638 hildon_time_picker_event_box_focus_in (GtkWidget *widget,
642 /* Draw the widget in selected state so focus shows clearly. */
643 gtk_widget_set_state (widget, GTK_STATE_SELECTED);
648 hildon_time_picker_event_box_focus_out (GtkWidget *widget,
652 /* Draw the widget in normal state */
653 gtk_widget_set_state( widget, GTK_STATE_NORMAL );
658 hildon_time_picker_lookup_eventbox_group (HildonTimePicker *picker,
662 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
666 for (i = 0; i < WIDGET_GROUP_COUNT; i++)
668 if (priv->widgets[i].eventbox == widget)
675 hildon_time_picker_event_box_key_press (GtkWidget *widget,
677 HildonTimePicker *picker)
679 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
680 HildonTimePickerWidgetGroup *group;
685 /* If mouse button is already being pressed, ignore this keypress */
689 group_idx = hildon_time_picker_lookup_eventbox_group (picker, widget);
690 group = group_idx < 0 ? NULL : &priv->widgets[group_idx];
692 /* Handle keypresses in hour/minute/AMPM fields */
693 switch (event->keyval)
699 gint button = event->keyval == GDK_Up ? BUTTON_UP : BUTTON_DOWN;
701 if (group->buttons[button] != NULL)
703 /* Fake a button up/down press */
704 hildon_time_picker_arrow_press (group->buttons[button], NULL, picker);
705 gtk_widget_set_state (group->buttons[button], GTK_STATE_SELECTED);
709 /* Fake a AM/PM button release */
710 g_assert (group_idx == WIDGET_GROUP_AMPM);
711 hildon_time_picker_ampm_release (group->eventbox, NULL, picker);
717 /* If we're in leftmost field, stop this keypress signal.
718 Otherwise let the default key handler move focus to field in left. */
719 if (priv->show_ampm && priv->ampm_left)
721 /* AM/PM is the leftmost field */
722 if (group_idx == WIDGET_GROUP_AMPM)
727 /* Hours is the leftmost field */
728 if (group_idx == WIDGET_GROUP_HOURS)
734 /* If we're in rightmost field, stop this keypress signal.
735 Otherwise let the default key handler move focus to field in right. */
736 if (priv->show_ampm && !priv->ampm_left)
738 /* AM/PM is the rightmost field */
739 if (group_idx == WIDGET_GROUP_AMPM)
744 /* 1-minutes is the leftmost field */
745 if (group_idx == WIDGET_GROUP_1_MINUTES)
751 gtk_dialog_response (GTK_DIALOG (picker), GTK_RESPONSE_CANCEL);
755 gtk_dialog_response (GTK_DIALOG (picker), GTK_RESPONSE_OK);
763 hildon_time_picker_event_box_key_release (GtkWidget *widget,
765 HildonTimePicker *picker)
767 HildonTimePickerWidgetGroup *group;
769 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
773 /* Fake a button release if in key-press handler we faked a button press. */
774 switch( event->keyval )
778 group_idx = hildon_time_picker_lookup_eventbox_group (picker, widget);
781 gint button = event->keyval == GDK_Up ? BUTTON_UP : BUTTON_DOWN;
783 group = &priv->widgets[group_idx];
784 if (group->buttons[button] != NULL)
786 /* Fake a button up/down press */
787 gtk_widget_set_state (group->buttons[button], GTK_STATE_NORMAL);
788 hildon_time_picker_arrow_release (group->buttons[button], NULL, picker);
796 /* Button up/down is being pressed. Update the time. */
798 hildon_time_picker_key_repeat_timeout (gpointer tpicker)
800 HildonTimePicker *picker;
801 HildonTimePickerPrivate *priv = NULL;
804 picker = HILDON_TIME_PICKER(tpicker);
805 g_assert(picker != NULL);
807 priv = HILDON_TIME_PICKER_GET_PRIVATE (tpicker);
810 GDK_THREADS_ENTER ();
812 /* Change the time, wrapping if needed */
813 newval = priv->minutes + priv->mul;
815 newval += MINS_IN_24H;
817 hildon_time_picker_change_time (picker, newval);
819 if (priv->start_key_repeat)
821 /* This is the first repeat. Shorten the timeout to key_repeat
822 (instead of the first time's 3*key_repeat) */
823 priv->timer_id = g_timeout_add (priv->key_repeat,
824 hildon_time_picker_key_repeat_timeout,
826 priv->start_key_repeat = FALSE;
828 GDK_THREADS_LEAVE ();
832 GDK_THREADS_LEAVE ();
837 hildon_time_picker_change_time (HildonTimePicker *picker,
840 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
844 gboolean ampm = TRUE;
848 /* If the minutes isn't in valid range, wrap them. */
849 minutes %= MINS_IN_24H;
851 if (priv->minutes == minutes)
854 /* Minutes changed. Update widgets to show the new time. */
855 priv->minutes = minutes;
859 /* am < 12:00 <= pm */
860 ampm = !((guint)(minutes / MINS_IN_12H));
861 /* 12:00 - 23:59 -> 00:00 - 11:59 */
862 minutes %= MINS_IN_12H;
863 if (minutes < MINS_IN_1H )
864 /* 00:mm is always shown as 12:mm */
865 minutes += MINS_IN_12H;
867 /* Update the AM/PM label */
868 gtk_label_set_text (priv->widgets[WIDGET_GROUP_AMPM].label,
869 ampm ? priv->am_symbol : priv->pm_symbol);
872 /* Update hour and minute fields */
873 hours = minutes / MINS_IN_1H;
874 minutes %= MINS_IN_1H;
876 snprintf(str, sizeof (str), "%02d", hours);
877 gtk_label_set_text (priv->widgets[WIDGET_GROUP_HOURS].label, str);
879 snprintf(str, sizeof (str), "%d", minutes / 10);
880 gtk_label_set_text (priv->widgets[WIDGET_GROUP_10_MINUTES].label, str);
882 snprintf(str, sizeof (str), "%d", minutes % 10);
883 gtk_label_set_text(priv->widgets[WIDGET_GROUP_1_MINUTES].label, str);
885 g_object_notify (G_OBJECT(picker), "minutes");
889 * hildon_time_picker_new:
890 * @parent: parent window
892 * #HildonTimePicker shows time picker dialog. The close button is placed
893 * in the dialog's action area and time picker is placed in dialogs vbox.
894 * The actual time picker consists of two #GtkLabel fields - one for hours
895 * and one for minutes - and an AM/PM button. A colon (:) is placed
896 * between hour and minute fields.
898 * Returns: pointer to a new #HildonTimePicker widget.
901 hildon_time_picker_new (GtkWindow *parent)
903 GtkWidget *widget = g_object_new (HILDON_TYPE_TIME_PICKER,
904 "minutes", 360, NULL );
907 gtk_window_set_transient_for (GTK_WINDOW(widget), parent);
909 return GTK_WIDGET (widget);
913 * hildon_time_picker_set_time:
914 * @picker: the #HildonTimePicker widget
918 * Sets the time of the #HildonTimePicker widget.
921 hildon_time_picker_set_time (HildonTimePicker *picker,
925 g_return_if_fail (HILDON_IS_TIME_PICKER(picker));
926 hildon_time_picker_change_time (picker, hours * MINS_IN_1H + minutes);
930 * hildon_time_picker_get_time:
931 * @picker: the #HildonTimePicker widget
935 * Gets the time of the #HildonTimePicker widget.
938 hildon_time_picker_get_time (HildonTimePicker *picker,
943 g_return_if_fail (HILDON_IS_TIME_PICKER (picker));
945 HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
948 current = priv->minutes;
949 *hours = current / MINS_IN_1H;
950 *minutes = current % MINS_IN_1H;