2 * This file is a part of hildon
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser Public License as published by
8 * the Free Software Foundation; version 2 of the license.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser Public License for more details.
17 #include "hildon-time-selector.h"
18 #include "hildon-touch-selector.h"
19 #include "hildon-picker-button.h"
20 #include "hildon-time-button.h"
22 G_DEFINE_TYPE (HildonTimeButton, hildon_time_button, HILDON_TYPE_PICKER_BUTTON)
25 #define GET_PRIVATE(o) \
26 (G_TYPE_INSTANCE_GET_PRIVATE ((o), HILDON_TYPE_TIME_BUTTON, HildonTimeButtonPrivate))
27 typedef struct _HildonTimeButtonPrivate HildonTimeButtonPrivate;
29 struct _HildonTimeButtonPrivate
36 hildon_time_button_get_property (GObject * object, guint property_id,
37 GValue * value, GParamSpec * pspec)
39 switch (property_id) {
41 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
46 hildon_time_button_set_property (GObject * object, guint property_id,
47 const GValue * value, GParamSpec * pspec)
49 switch (property_id) {
51 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
57 hildon_time_button_class_init (HildonTimeButtonClass * klass)
60 GObjectClass *object_class = G_OBJECT_CLASS (klass);
62 g_type_class_add_private (klass, sizeof (HildonTimeButtonPrivate));
64 object_class->get_property = hildon_time_button_get_property;
65 object_class->set_property = hildon_time_button_set_property;
70 hildon_time_button_init (HildonTimeButton * self)
72 GtkWidget *time_selector;
74 time_selector = hildon_time_selector_new ();
76 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (self),
77 HILDON_TOUCH_SELECTOR (time_selector));
81 hildon_time_button_new (HildonButtonFlags flags)
83 return g_object_new (HILDON_TYPE_TIME_BUTTON,
84 "title", "Time", "arrangement-flags", flags, NULL);
88 hildon_time_button_get_time (HildonTimeButton * button,
89 guint * hours, guint * minutes)
91 HildonTouchSelector *selector;
93 g_return_if_fail (HILDON_IS_TIME_BUTTON (button));
95 selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (button));
97 hildon_time_selector_get_time (HILDON_TIME_SELECTOR (selector), hours, minutes);
101 hildon_time_button_set_time (HildonTimeButton * button,
102 guint hours, guint minutes)
104 HildonTouchSelector *selector;
107 g_return_if_fail (HILDON_IS_TIME_BUTTON (button));
109 selector = hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (button));
111 hildon_time_selector_set_time (HILDON_TIME_SELECTOR (selector), hours, minutes);
112 time = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector));
114 hildon_button_set_value (HILDON_BUTTON (button), time);