/*
- * This file is part of hildon-libs
+ * This file is a part of hildon
*
* Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; version 2.1 of
- * the License.
+ * the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
/**
* SECTION:hildon-time-picker
- * @short_description: A dialog popup widget which lets the user set the time
+ * @short_description: A dialog popup widget which lets the user set the time.
* @see_also: #HildonTimeEditor
*
* #HildonTimePicker is a dialog popup widget which lets the user set the time,
* using up/down arrows on hours and minutes. There are two arrows for minutes,
* so that minutes can be added also in 10 min increments.This widget is mainly
* used as a part of #HildonTimeEditor implementation.
+ *
+ * <example>
+ * <title>HildonTimePicker example</title>
+ * <programlisting>
+ * <!-- -->
+ * parent = gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW);
+ * picker = hildon_time_picker_new (GTK_WINDOW (parent));
+ * <!-- -->
+ * hildon_time_editor_get_time (editor, &h, &m, &s);
+ * hildon_time_picker_set_time( HILDON_TIME_PICKER( picker ), h, m );
+ * <!-- -->
+ * result = gtk_dialog_run (GTK_DIALOG (picker));
+ * switch (result)
+ * {
+ * case GTK_RESPONSE_OK:
+ * case GTK_RESPONSE_ACCEPT:
+ * hildon_time_picker_get_time(HILDON_TIME_PICKER (picker), &h, &m );
+ * foo_set_time(h,m);
+ * break;
+ * default:
+ * break;
+ * }
+ * <!-- -->
+ * gtk_widget_destroy( picker );
+ * <!-- -->
+ * </programlisting>
+ * </example>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include "hildon-time-picker.h"
-#include "hildon-defines.h"
-#include "hildon-private.h"
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include <gdk/gdk.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <langinfo.h>
#include <libintl.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "hildon-time-picker.h"
+#include "hildon-defines.h"
#include "hildon-time-picker-private.h"
+#include "hildon-time-editor.h"
#define _(String) \
- dgettext(PACKAGE, String)
+ dgettext("hildon-libs", String)
#define DEFAULT_HOURS 1
gpointer unused);
static void
-hildon_time_picker_map (GtkWidget *widget);
+hildon_time_picker_realize (GtkWidget *widget);
+
+static void
+hildon_time_picker_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
static void
frame_size_request (GtkWidget *widget,
{ 0, 0 }
};
+/**
+ * hildon_time_picker_get_type:
+ *
+ * Returns the type of HildonTimePicker.
+ *
+ * Returns: HildonTimePicker type
+ */
GType G_GNUC_CONST
hildon_time_picker_get_type (void)
{
gobject_class->finalize = hildon_time_picker_finalize;
gobject_class->get_property = hildon_time_picker_get_property;
gobject_class->set_property = hildon_time_picker_set_property;
- widget_class->map = hildon_time_picker_map;
+ widget_class->realize = hildon_time_picker_realize;
+ widget_class->style_set = hildon_time_picker_style_set;
/**
* HildonTimePicker:minutes:
{
HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
gint widget_group_table_column_pos[WIDGET_GROUP_COUNT];
- GtkSettings *settings = NULL;
GtkDialog *dialog = GTK_DIALOG (picker);
GtkTable *table = NULL;
GtkWidget *maintocenter, *colon_label;
/* Label between hour and minutes */
colon_label = gtk_label_new (NULL);
- _hildon_time_editor_get_time_separators (GTK_LABEL(colon_label), NULL);
+ hildon_time_editor_get_time_separators (GTK_LABEL(colon_label), NULL);
gtk_table_attach (table, colon_label, 2, 3, 1, 2,
GTK_SHRINK, GTK_SHRINK, 6, 0); /* FIXME: magic */
priv->minutes = 0;
priv->mul = 0;
- priv->key_repeat = 0;
priv->start_key_repeat = FALSE;
priv->timer_id = 0;
priv->button_press = FALSE;
gtk_widget_pop_composite_child ();
- /* Get button press repeater timeout from settings (in milliseconds) */
- settings = gtk_settings_get_default ();
- g_object_get (settings, "gtk-update-timeout", &priv->key_repeat, NULL);
-
/* This dialog isn't modal */
- gtk_window_set_modal (GTK_WINDOW(dialog), FALSE);
+ gtk_window_set_modal (GTK_WINDOW (dialog), FALSE);
/* And final dialog packing */
gtk_dialog_set_has_separator (dialog, FALSE);
gtk_dialog_add_button (dialog, _("ecdg_bd_time_picker_close"),
}
static void
-hildon_time_picker_map (GtkWidget *widget)
+hildon_time_picker_realize (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (parent_class)->realize(widget);
+
+ /* We only want the border for the dialog. */
+ gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
+}
+
+static void
+hildon_time_picker_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
{
guint width, height;
gint i, button;
HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (widget);
g_assert (priv);
- /* Widget is now mapped. Set border for the dialog. */
- gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
+ GTK_WIDGET_CLASS (parent_class)->style_set(widget, previous_style);
/* Update hour/minute up/down buttons sizes from style properties */
gtk_widget_style_get (widget,
}
}
}
-
- GTK_WIDGET_CLASS (parent_class)->map(widget);
}
/*
HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
gint i, button;
gint newval = 0;
+ gint key_repeat = 0;
/* Make sure we don't add repeat timer twice. Normally it shouldn't
happen but WM can cause button release to be lost. */
hildon_time_picker_change_time (picker, newval);
+ /* Get button press repeater timeout from settings (in milliseconds) */
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-timeout-repeat", &key_repeat, NULL);
+
+ key_repeat *= 8;
+
/* Keep changing the time as long as button is being pressed.
The first repeat takes 3 times longer to start than the rest. */
- priv->timer_id = g_timeout_add (priv->key_repeat * 3,
+
+ priv->timer_id = g_timeout_add (key_repeat * 3,
hildon_time_picker_key_repeat_timeout,
picker);
HildonTimePicker *picker;
HildonTimePickerPrivate *priv = NULL;
gint newval = 0;
+ gint key_repeat = 0;
picker = HILDON_TIME_PICKER(tpicker);
g_assert(picker != NULL);
if (priv->start_key_repeat)
{
+ /* Get button press repeater timeout from settings (in milliseconds) */
+ g_object_get (gtk_widget_get_settings ((GtkWidget *) tpicker),
+ "gtk-timeout-repeat", &key_repeat, NULL);
+
+ key_repeat *= 8;
+
/* This is the first repeat. Shorten the timeout to key_repeat
(instead of the first time's 3*key_repeat) */
- priv->timer_id = g_timeout_add (priv->key_repeat,
+ priv->timer_id = g_timeout_add (key_repeat,
hildon_time_picker_key_repeat_timeout,
picker);
priv->start_key_repeat = FALSE;