+2006-01-03 Luc Pionchon <luc.pionchon@nokia.com>
+
+ * hildon-widgets/hildon-calendar-popup.c
+ * hildon-widgets/hildon-color-button.c
+ * hildon-widgets/hildon-color-popup.c
+ * hildon-widgets/hildon-color-selector.c
+ * hildon-widgets/hildon-composite-widget.c
+ * hildon-widgets/hildon-controlbar.c
+ * hildon-widgets/hildon-date-editor.c
+ * hildon-widgets/hildon-dialoghelp.c
+ * hildon-widgets/hildon-file-details-dialog.c
+ * hildon-widgets/hildon-font-selection-dialog.c
+ * hildon-widgets/hildon-get-password-dialog.c
+ * hildon-widgets/hildon-grid-item.c
+ * hildon-widgets/hildon-grid.c
+ * hildon-widgets/hildon-hvolumebar.c
+ * hildon-widgets/hildon-name-password-dialog.c
+ * hildon-widgets/hildon-note.c
+ * hildon-widgets/hildon-number-editor.c
+ * hildon-widgets/hildon-range-editor.c
+ * hildon-widgets/hildon-scroll-area.c
+ * hildon-widgets/hildon-seekbar.c
+ * hildon-widgets/hildon-set-password-dialog.c
+ * hildon-widgets/hildon-sort-dialog.c
+ * hildon-widgets/hildon-time-editor.c
+ * hildon-widgets/hildon-time-picker.c
+ * hildon-widgets/hildon-volumebar-private.h
+ * hildon-widgets/hildon-volumebar-range.c
+ * hildon-widgets/hildon-volumebar.c
+ * hildon-widgets/hildon-vvolumebar.c
+ * hildon-widgets/hildon-weekday-picker.c
+ * hildon-widgets/hildon-wizard-dialog.c
+ commented code
+
2005-12-28 Luc Pionchon <luc.pionchon@nokia.com>
* configure.ac: 0.10.0
#include <time.h>
#include <libintl.h>
#include <hildon-widgets/hildon-calendar-popup.h>
-#include <hildon-widgets/gtk-infoprint.h>
+#include <hildon-widgets/gtk-infoprint.h> /* FIXME: broken include ? */
#define _(String) dgettext(PACKAGE, String)
init_dmy(year, month, day, &dtmp, &mtmp, &ytmp);
+ /* Create new HildonCalendarPopup */
cal = HILDON_CALENDAR_POPUP(g_object_new(HILDON_CALENDAR_POPUP_TYPE,
NULL));
priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
g_return_if_fail(HILDON_IS_CALENDAR_POPUP(cal));
priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
+
+ /* Remove all visual markers */
gtk_calendar_clear_marks(GTK_CALENDAR(priv->cal));
+ /* Set a new date */
gtk_calendar_select_month(GTK_CALENDAR(priv->cal), month - 1, year);
gtk_calendar_select_day(GTK_CALENDAR(priv->cal), day);
}
g_type_class_add_private(cal_class,
sizeof(HildonCalendarPopupPrivate));
+ /* Install new properties for the GObject_class */
g_object_class_install_property(object_class, PROP_MIN_YEAR,
g_param_spec_uint("min-year",
"Minimum valid year",
priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
+ /* set the domain directory for different language */
if (set_domain) {
(void) bindtextdomain(PACKAGE, LOCALEDIR);
set_domain = 0;
cal = HILDON_CALENDAR_POPUP(data);
priv = HILDON_CALENDAR_POPUP_GET_PRIVATE(cal);
+ /* Handle Return_key press as OK response */
if (event->keyval == GDK_Return) {
priv->can_exit = TRUE;
gtk_dialog_response(GTK_DIALOG(cal), GTK_RESPONSE_OK);
return TRUE;
}
+ /* Handle Esc and F1-8 key press as CANCEL response */
if ((event->keyval == GDK_Escape) || (event->keyval == GDK_F1) ||
(event->keyval == GDK_F2) || (event->keyval == GDK_F3) ||
(event->keyval == GDK_F4) || (event->keyval == GDK_F5) ||
{
GDate date;
+ /* Initialize the date with a valid selected date */
if (g_date_valid_dmy(day, month, year)) {
*d = day;
*m = month;
*y = year;
- } else {
+ } else {
+
+ /* If selected date is invalid initialize the date with current date */
g_date_clear(&date, 1);
g_date_set_time(&date, time(NULL));
switch (property_id) {
case PROP_DAY:
- g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
+ g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
break;
case PROP_MONTH:
- g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
+ g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
break;
case PROP_YEAR:
- g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
+ g_object_set_property(G_OBJECT(priv->cal), pspec->name, value);
break;
case PROP_MIN_YEAR:
- g_object_set_property(G_OBJECT(priv->cal), "min-year", value);
- break;
+ g_object_set_property(G_OBJECT(priv->cal), "min-year", value);
+ break;
case PROP_MAX_YEAR:
- g_object_set_property(G_OBJECT(priv->cal), "max-year", value);
- break;
+ g_object_set_property(G_OBJECT(priv->cal), "max-year", value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
switch (property_id) {
case PROP_DAY:
- g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
+ g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
break;
case PROP_MONTH:
- g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
+ g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
break;
case PROP_YEAR:
- g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
+ g_object_get_property(G_OBJECT(priv->cal), pspec->name, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
gtk_widget_set_size_request(GTK_WIDGET(cb->priv->drawing_area),
COLOR_FIELD_WIDTH, COLOR_FIELD_HEIGHT);
+ /* Connect the callback function for exposure event */
g_signal_connect(G_OBJECT(cb->priv->drawing_area), "expose-event",
G_CALLBACK(hildon_color_field_expose_event), cb);
gtk_widget_pop_composite_child();
}
+/* Free memory used by HildonColorButton */
static void
hildon_color_button_finalize(GObject *object)
{
GTK_WIDGET_CLASS(parent_class)->realize(widget);
+ /* Create new graphics context if it doesn't exist */
if (!cb->priv->gc)
cb->priv->gc = gdk_gc_new(widget->window);
hildon_color_button_recolor_pixbuf(cb);
}
+/* Make the widget sensitive with the keyboard event */
static gboolean
hildon_color_button_mnemonic_activate( GtkWidget *widget,
gboolean group_cycling )
GdkPixbuf *pb = cb->priv->pixbuf;
GdkColor *color = &cb->priv->color;
+ /* Initialize the base color */
r = (color->red >> 8);
g = (color->green >> 8);
b = (color->blue >> 8);
pixels = gdk_pixbuf_get_pixels(pb);
rowstride = gdk_pixbuf_get_rowstride(pb);
+ /* Queue drawing of the widget */
for (j=0; j<COLOR_FIELD_HEIGHT; j++)
for (i=0; i<COLOR_FIELD_WIDTH; i++)
{
- *(j * rowstride + pixels + i * 3) = r;
- *(j * rowstride + pixels + i * 3 + 1) = g;
- *(j * rowstride + pixels + i * 3 + 2) = b;
+ *(rowstride * j + pixels + i * 3) = r;
+ *(rowstride * j + pixels + i * 3 + 1) = g;
+ *(rowstride * j + pixels + i * 3 + 2) = b;
}
gtk_widget_queue_draw(GTK_WIDGET(cb));
}
+/* Popup a color selector dialog on button click */
static void
hildon_color_button_clicked(GtkButton *button)
{
HildonColorButton *cb = HILDON_COLOR_BUTTON(button);
HildonColorSelector *csd = HILDON_COLOR_SELECTOR(cb->priv->dialog);
+ /* Popup the color selector dialog */
if (!csd)
{
GtkWidget *parent = gtk_widget_get_toplevel(GTK_WIDGET(cb));
gtk_window_set_transient_for(GTK_WINDOW(csd), GTK_WINDOW(parent));
}
+ /* Set the initial color for the color selector dialog */
hildon_color_selector_set_color(csd, &cb->priv->color);
result = gtk_dialog_run(GTK_DIALOG(csd));
+
+ /* Update the color for color button if selection was made */
if (result == GTK_RESPONSE_OK)
{
cb->priv->color = *hildon_color_selector_get_color(csd);
gtk_widget_hide(GTK_WIDGET(csd));
}
+/* Set_property function for HildonColorButtonClass initialization */
static void
hildon_color_button_set_property(GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec)
}
}
+/* Get_property function for HildonColorButtonClass initialization */
static void
hildon_color_button_get_property(GObject *object, guint param_id,
GValue *value, GParamSpec *pspec)
#define HILDON_COLOR_CONTROLBAR_MIN 0
#define HILDON_COLOR_LABELS_LEFT_PAD 35
#define HILDON_COLOR_PALETTE_POS_PAD 45
-#define HILDON_COLOR_BAR_WIDTH 449
+#define HILDON_COLOR_BAR_WIDTH 449
/*
* Private function prototype definitions
current_color = initial_color;
+ /* Create control bars for HildonColorPopup */
popup_data->ctrlbar_red = hildon_controlbar_new ();
popup_data->ctrlbar_green = hildon_controlbar_new ();
popup_data->ctrlbar_blue = hildon_controlbar_new ();
area = gtk_drawing_area_new();
layout = GTK_TABLE(gtk_table_new(12, 2, FALSE));
+ /* Set widgets' size */
gtk_widget_set_size_request (area,
HILDON_COLOR_PALETTE_SIZE,
HILDON_COLOR_PALETTE_SIZE);
gtk_widget_set_size_request(popup_data->ctrlbar_blue,
HILDON_COLOR_BAR_WIDTH, -1);
+ /* Create labels for three kinds of color */
l_red = gtk_label_new( _("Ecdg_fi_5bit_colour_selector_red"));
l_green = gtk_label_new(_("Ecdg_fi_5bit_colour_selector_green"));
l_blue = gtk_label_new(_("Ecdg_fi_5bit_colour_selector_blue"));
gtk_misc_set_alignment(GTK_MISC(l_green), 0.08f, 0.5f);
gtk_misc_set_alignment(GTK_MISC(l_blue), 0.08f, 0.5f);
+ /* Add labels and control bars to the layout table */
gtk_table_attach_defaults(layout, l_red, 0, 1, 0, 2);
gtk_table_attach_defaults(layout, popup_data->ctrlbar_red, 0, 1, 2, 4);
gtk_table_attach_defaults(layout, l_green, 0, 1, 4, 6);
gtk_table_attach_defaults(layout, popup_data->ctrlbar_blue, 0, 1, 10, 12);
gtk_table_attach(layout, area, 1, 2, 3, 11, GTK_SHRINK, GTK_SHRINK, 0, 0);
- /* control bars */
+ /* Give the maximum and minimum limits for each control bar */
hildon_controlbar_set_range (HILDON_CONTROLBAR(popup_data->ctrlbar_red),
HILDON_COLOR_CONTROLBAR_MIN,
HILDON_COLOR_CONTROLBAR_MAX);
HILDON_COLOR_CONTROLBAR_MIN,
HILDON_COLOR_CONTROLBAR_MAX);
+ /* Give the initial values for each control bar */
hildon_controlbar_set_value (HILDON_CONTROLBAR(popup_data->ctrlbar_red),
(current_color->red >> 11)&0x1F);
hildon_controlbar_set_value (HILDON_CONTROLBAR(popup_data->ctrlbar_green),
hildon_controlbar_set_value (HILDON_CONTROLBAR(popup_data->ctrlbar_blue),
(current_color->blue >> 11)&0x1F);
- /* controlbars callbacks */
+ /* Register controlbar callbacks */
g_signal_connect_swapped(popup_data->ctrlbar_red, "value-changed",
G_CALLBACK(gtk_widget_queue_draw), area);
g_signal_connect_swapped(popup_data->ctrlbar_green, "value-changed",
g_signal_connect_swapped(popup_data->ctrlbar_blue, "value-changed",
G_CALLBACK(gtk_widget_queue_draw), area);
+ /* Attach expose_event callback function to drawing area */
g_signal_connect (area, "expose_event",
G_CALLBACK(hildon_popup_palette_expose),
popup_data);
+ /* Create popup dialog */
popup = gtk_dialog_new_with_buttons (_("ecdg_ti_5bit_colour_selector"),
GTK_WINDOW(parent),
GTK_DIALOG_DESTROY_WITH_PARENT |
NULL);
gtk_dialog_set_default_response(GTK_DIALOG(popup), GTK_RESPONSE_OK);
+
+ /* Add layout table to the Vbox of the popup dialog */
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(popup)->vbox),
GTK_WIDGET(layout), TRUE, TRUE, 0);
+
+ /* Show thw Vbox of the popup dialog */
gtk_widget_show_all(GTK_DIALOG(popup)->vbox);
return popup;
HILDON_CONTROLBAR(popup_data->ctrlbar_blue)) << 11;
}
+/* expose_event callback function */
static gboolean
hildon_popup_palette_expose (GtkWidget * widget,
GdkEventExpose *event, gpointer data)
GdkColor color;
GdkGC * gc = gdk_gc_new (widget->window);
+ /* Get the current color value */
hildon_color_popup_set_color_from_sliders(&color, data);
gdk_gc_set_rgb_fg_color(gc, &color);
- /* draw the color */
+ /* draw the color area */
gdk_draw_rectangle( widget->window, gc, TRUE /* filled */,
1, 1, widget->allocation.width - 2,
widget->allocation.height - 2);
color.pixel = color.red = color.green = color.blue = 0;
gdk_gc_set_rgb_fg_color(gc, &color);
- /* frames on color box */
+ /* Draw frames on color box */
gdk_draw_rectangle( widget->window, gc, FALSE,
0, 0, widget->allocation.width - 1,
widget->allocation.height - 1);
+ /* Free memory used by the graphics contexts */
g_object_unref(gc);
}
g_assert(HILDON_IS_COLOR_SELECTOR(selector));
- /* We have to be really carefull. At least gconftool's
+ /* We have to be really careful. At least gconftool's
stress test may generate unexpected value setups */
- if (value == NULL || value->type != GCONF_VALUE_LIST ||
- gconf_value_get_list_type(value) != GCONF_VALUE_STRING)
+ if (value == NULL
+ || value->type != GCONF_VALUE_LIST
+ || gconf_value_get_list_type(value) != GCONF_VALUE_STRING)
list = NULL;
else
list = gconf_value_get_list(value);
+ /* Use list to fill in the selector's color property */
for ( i = 0; i < HILDON_CUSTOM_COLOR_NUM; ++i)
{
const gchar *color_string = NULL;
GCONF_CLIENT_PRELOAD_NONE,
NULL);
+ /* Use the value directed by GConfValue to set the color */
value = gconf_client_get(selector->priv->client,
HILDON_COLOR_GCONF_KEYS, NULL);
gtk_widget_add_events (selector->priv->drawing_area,
GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
+ /* Arrange size of the drawing area */
gtk_widget_set_size_request (selector->priv->drawing_area,
(HILDON_COLOR_SELECTOR_BOX_W *
HILDON_COLOR_SELECTOR_COLS) +
gtk_box_pack_start (GTK_BOX(hbox), selector->priv->drawing_area,
FALSE, FALSE, 0);
+ /* Register callback functions for the drawing area */
g_signal_connect (selector->priv->drawing_area, "expose_event",
G_CALLBACK(hildon_color_selector_expose), selector);
g_signal_connect (selector->priv->drawing_area, "button_press_event",
g_return_if_fail(HILDON_IS_COLOR_SELECTOR(selector));
g_return_if_fail(color);
+ /* Select the specified color */
for (i = 0;
i < (HILDON_BASE_COLOR_NUM + HILDON_CUSTOM_COLOR_NUM);
++i)
selector->priv->color[i].blue == color->blue)
{
selector->priv->index = i;
+
+ /* The modify button is active if the color index is bigger than
+ * the number of base colours.
+ */
gtk_widget_set_sensitive(selector->priv->modify_button,
selector->priv->index >= HILDON_BASE_COLOR_NUM);
gtk_widget_queue_draw(selector->priv->drawing_area);
break;
}
}
-
+
+ /* Notify the color selector that the color has changed */
g_object_notify (G_OBJECT (selector), "color");
}
return TRUE;
}
+/* Handle key press of right, left, up, down and return */
static gboolean key_pressed(GtkWidget * widget,
GdkEventKey * event)
{
if (GTK_WIDGET_HAS_FOCUS(selector->priv->drawing_area) == FALSE)
return GTK_WIDGET_CLASS(parent_class)->key_press_event(widget, event);
- /* go for if available index otherwise stop keypress handler because
- wrapping around is not allowed. */
+ /* Since wrapping is not allowed,
+ * move only if the next index is a valid one.
+ */
switch (event->keyval) {
case GDK_KP_Right:
case GDK_Right:
selector->priv->index =
HILDON_BASE_COLOR_NUM + HILDON_CUSTOM_COLOR_NUM - 1;
}
+ /* The modify button is active if the color index is bigger than
+ * the number of base colours.
+ */
gtk_widget_set_sensitive(selector->priv->modify_button,
selector->priv->index >= HILDON_BASE_COLOR_NUM);
g_return_if_fail(HILDON_IS_COLOR_SELECTOR(selector));
+ /* Get the selection coordinates */
x = ( (event_x - HILDON_COLOR_SELECTOR_BOX_BORDER) /
(HILDON_COLOR_SELECTOR_BOX_BORDER * 2 +
HILDON_COLOR_SELECTOR_BOX_W)
HILDON_COLOR_SELECTOR_BOX_H)
);
+ /* Get the row and column numbers for the selected color */
if (x > (HILDON_COLOR_SELECTOR_COLS + HILDON_CUSTOM_COLOR_NUM - 1))
{
x = HILDON_COLOR_SELECTOR_COLS + HILDON_CUSTOM_COLOR_NUM - 1;
y = 0;
}
+ /* If a custom colour is selected, open a popup to modify the colour */
if (!motion &&
selector->priv->index >= HILDON_BASE_COLOR_NUM &&
selector->priv->index == (x + y * HILDON_COLOR_SELECTOR_COLS))
HildonColorPopup popupdata;
GtkWidget *popup;
+ /* Create a HildonColorPopup dialog */
popup = hildon_color_popup_new(GTK_WINDOW(colselector),
hildon_color_selector_get_color(colselector), &popupdata);
}
color = hildon_color_selector_get_color(colselector);
+
+ /* Get the current color value */
hildon_color_popup_set_color_from_sliders(color, &popupdata);
/* If we modified a base color we just accept the dialog */
gtk_widget_destroy (popup);
gtk_window_present (GTK_WINDOW(colselector));
}
+
static void
hildon_color_selector_set_property(GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec)
GtkWidget *toplevel = NULL;
GtkWidget *focus_widget = NULL;
+ /* Get the topmost parent widget */
toplevel = gtk_widget_get_toplevel (widget);
if (!GTK_IS_WINDOW(toplevel))
return GTK_WIDGET_CLASS (g_type_class_peek_parent (
GTK_WIDGET_GET_CLASS (widget)))->focus (widget, direction);
-
+ /* Get focus widget in the topmost parent widget */
focus_widget = GTK_WINDOW (toplevel)->focus_widget;
if (!GTK_IS_WIDGET (focus_widget))
GtkRange *range;
HildonControlbarPrivate *priv;
+ /* Initialize the private property */
priv = HILDON_CONTROLBAR_GET_PRIVATE(controlbar);
priv->button_press = FALSE;
priv->old_value = 0;
gtk_scale_set_draw_value (GTK_SCALE (obj), FALSE);
+ /* Initialize the GtkAdjustment of the controlbar*/
adj = GTK_RANGE(obj)->adjustment;
adj->step_increment = HILDON_CONTROLBAR_STEP_INCREMENT;
adj->page_increment = HILDON_CONTROLBAR_PAGE_INCREMENT;
{
HildonControlbarPrivate *priv = HILDON_CONTROLBAR_GET_PRIVATE(range);
+ /* Change the controlbar value if the adjusted value is large enough
+ * otherwise, keep the old value
+ */
if( ABS(ceil(adj->value) - priv->old_value) >= 1 )
{
priv->old_value = ceil(adj->value);
priv = HILDON_CONTROLBAR_GET_PRIVATE(range);
+ /* Emit a signal when upper or lower limit is reached */
switch (scroll)
{
case GTK_SCROLL_STEP_FORWARD :
GValue *value, GParamSpec *pspec );
static void hildon_date_editor_set_property (GObject *object, guint param_id,
const GValue *value, GParamSpec *pspec);
+
static gboolean
hildon_date_editor_mnemonic_activate(GtkWidget *widget, gboolean group_cycling);
hildon_child_forall(GtkContainer * container,
gboolean include_internals,
GtkCallback callback, gpointer callback_data);
+
static void hildon_date_editor_destroy(GtkObject * self);
+
static void
hildon_date_editor_size_allocate(GtkWidget * widget,
GtkAllocation * allocation);
static gboolean
_hildon_date_editor_entry_select_all(GtkWidget *widget);
+/* Property indices */
enum
{
PROP_DAY = 1,
};
struct _HildonDateEditorPrivate {
- guint year; /* current year in the entry */
- guint month; /* current month in the entry */
- guint day; /* current day in the entry */
+ /* Cache of values in the entries, used in setting only parts of the date */
+ guint year; /* current year in the entry */
+ guint month; /* current month in the entry */
+ guint day; /* current day in the entry */
- guint y_orig; /* roll back value for year (if entry has illegal
- value) */
+ guint y_orig; /* roll back value for year (if entry has illegal value) */
guint m_orig; /* roll back value for month */
guint d_orig; /* roll back value for day */
gint button_press; /* wheter to show pressed image */
- gboolean editor_pressed;
- gboolean valid_value;
+ gboolean editor_pressed; /* user activated picker using return */
+ gboolean valid_value; /* FIXME: XXX This is always true, not used */
- GtkWidget *frame; /* borders around the date */
- GtkWidget *d_event_box_image; /* icon */
- GtkWidget *d_box_date; /* hbox for date */
+ GtkWidget *frame; /* borders around the date */
+ GtkWidget *d_event_box_image; /* icon */
+ GtkWidget *d_box_date; /* hbox for date */
GtkWidget *d_entry; /* GtkEntry for day */
GtkWidget *m_entry; /* GtkEntry for month */
GtkWidget *my_delim; /* Delimeter between month and year entries */
GtkWidget *d_image; /* normal icon image */
- GtkWidget *d_image_pressed;
- guint locale_type;
+ GtkWidget *d_image_pressed; /* icon while button held down */
+ guint locale_type; /* Locale used (day, month, year order) */
- gboolean skip_validation;
+ gboolean skip_validation; /* don't validate date at all */
- gint min_year;
- gint max_year;
+ gint min_year; /* minimum year allowed */
+ gint max_year; /* maximum year allowed */
};
enum {
if (val <= priv->max_year)
{
priv->min_year = val;
+ /* Clamp current year */
if (hildon_date_editor_get_year (editor) < priv->min_year)
hildon_date_editor_set_year (editor, priv->min_year);
}
if (val >= priv->min_year)
{
priv->max_year = val;
+ /* Clamp current year */
if (hildon_date_editor_get_year (editor) > priv->max_year)
hildon_date_editor_set_year (editor, priv->max_year);
}
}
}
+/* FIXME: Mnemonics aren't used */
static gboolean
hildon_date_editor_mnemonic_activate(GtkWidget *widget, gboolean group_cycling)
GtkWidget *entry;
HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(widget);
+ /* Set focus to first entry */
if( priv->locale_type == MONTH_DAY_YEAR )
entry = priv->m_entry;
else
G_OBJECT_CLASS(parent_class)->finalize(object);
}
+/* Extract day, month, year order from date format string */
static guint
hildon_date_editor_check_locale_settings(HildonDateEditor * editor)
{
/**
* hildon_date_editor_new:
*
- * This function creates a new time editor. The current system date
+ * Creates a new time editor. The current system date
* is shown in the editor.
*
* Return value: Pointer to a new @HildonDateEditor widget.
* @month: month
* @day: day
*
- * This function sets the date shown in the editor. The function returns
- * if the date specified by the arguments is not valid, the
- * function returns.
+ * Sets the date shown in the editor.
**/
void hildon_date_editor_set_date(HildonDateEditor * date,
guint year, guint month, guint day)
* @month: month
* @day: day
*
- * This function returns the year, month, and day currently on the
+ * Returns the year, month, and day currently on the
* date editor.
**/
void hildon_date_editor_get_date(HildonDateEditor * date,
priv = HILDON_DATE_EDITOR_GET_PRIVATE(date);
- /*dont know why these variable are used, i think it makes more
- * sense to directly get the content from the current text entry field*/
+ /* FIXME: XXX This should use the commented out values, really */
*year = /*priv->year;*/
(guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)));
*month = /*priv->month;*/
priv = HILDON_DATE_EDITOR_GET_PRIVATE(ed);
if (event->button == 1 && !priv->button_press) {
+ /* Show pressed image */
gtk_container_remove(GTK_CONTAINER(priv->d_event_box_image),
priv->d_image);
gtk_container_add(GTK_CONTAINER(priv->d_event_box_image),
priv = HILDON_DATE_EDITOR_GET_PRIVATE(ed);
if (priv->valid_value && event->button == 1) {
-
- /* We might not get focus because unvalid values in entries */
+ /* We might not get focus because of invalid values in entries */
if (GTK_WIDGET_HAS_FOCUS(widget))
g_idle_add((GSourceFunc)
_hildon_date_editor_entry_select_all, GTK_ENTRY(widget));
popup = hildon_calendar_popup_new(GTK_WINDOW(parent), y, m, d);
g_value_init(&val, G_TYPE_INT);
+ /* Set max/min year in calendar popup to date editor values */
g_object_get_property(G_OBJECT(data), "min-year", &val);
g_object_set_property(G_OBJECT(popup), "min-year", &val);
g_object_get_property(G_OBJECT(data), "max-year", &val);
g_object_set_property(G_OBJECT(popup), "max-year", &val);
+ /* Pop up calendar */
result = gtk_dialog_run(GTK_DIALOG(popup));
switch (result) {
case GTK_RESPONSE_OK:
HildonDateEditorPrivate *priv;
gint d, m, y;
- gboolean r; /*return value storage needed, but no real use*/
+ gboolean r; /* temp return values for signals */
g_return_if_fail(data);
g_return_if_fail(widget);
m = atoi(gtk_entry_get_text(GTK_ENTRY(priv->m_entry)));
y = atoi(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)));
- /*NOTICE we could/should use hildon_date_editor_set_year and such functions
- * to set the date, instead of use gtk_entry_set_text, and then change the priv member
- * but hildon_date_editor_set_year and such functions check if the date is valid,
- * we do want to do date validation check here according to spec*/
+ /* We could/should use hildon_date_editor_set_year and such functions
+ * to set the date, instead of use gtk_entry_set_text, and then change
+ * the priv member but hildon_date_editor_set_year and such functions
+ * check if the date is valid, we do want to do date validation check
+ * here according to spec */
+
+ /* Validate day */
if(GTK_WIDGET(widget) == priv->d_entry)
{
if(d > 0 && d < 32) {
g_idle_add ((GSourceFunc)
_hildon_date_editor_entry_select_all,
priv->d_entry);
+ /* Set focus back to invalid entry */
gtk_widget_grab_focus(priv->d_entry);
return;
}
+ /* Validate month */
if(GTK_WIDGET(widget) == priv->m_entry)
{
if(m > 0 && m < 13)
g_idle_add ((GSourceFunc)
_hildon_date_editor_entry_select_all,
priv->m_entry);
+ /* Set focus back to invalid entry */
gtk_widget_grab_focus(priv->m_entry);
return;
}
+ /* Validate year */
if(GTK_WIDGET(widget) == priv->y_entry)
{
if(y >= priv->min_year && y <= priv->max_year) {
g_idle_add ((GSourceFunc)
_hildon_date_editor_entry_select_all,
priv->y_entry);
+ /* Set focus back to invalid entry */
gtk_widget_grab_focus(priv->y_entry);
return;
}
{
HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(data);
+ /* If day entry is full, move to next entry or validate */
if (strlen(gtk_entry_get_text(GTK_ENTRY(ed))) == DAY_ENTRY_WIDTH)
{
if (priv->locale_type == DAY_MONTH_YEAR)
{
HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(data);
+ /* If month entry is full, move to next entry */
if (strlen(gtk_entry_get_text(GTK_ENTRY(ed))) == MONTH_ENTRY_WIDTH)
{
if (priv->locale_type == DAY_MONTH_YEAR)
{
HildonDateEditorPrivate *priv = HILDON_DATE_EDITOR_GET_PRIVATE(data);
+ /* If year entry is full, move to next entry or validate */
if (strlen(gtk_entry_get_text(GTK_ENTRY(ed))) == YEAR_ENTRY_WIDTH)
{
if (priv->locale_type == YEAR_MONTH_DAY)
if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return ||
event->keyval == GDK_ISO_Enter) {
if (priv->editor_pressed) {
+ /* Show normal icon instead of pressed */
gtk_container_remove(GTK_CONTAINER(priv->d_event_box_image),
priv->d_image_pressed);
gtk_container_add(GTK_CONTAINER(priv->d_event_box_image),
if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter) {
if (!priv->editor_pressed) {
+ /* Show pressed icon */
gtk_container_remove(GTK_CONTAINER(priv->d_event_box_image),
priv->d_image);
gtk_container_add(GTK_CONTAINER(priv->d_event_box_image),
gint pos =
gtk_editable_get_position(GTK_EDITABLE(priv->d_entry));
if (pos == 0) {
+ /* Switch to previous entry */
gtk_editable_select_region(GTK_EDITABLE(priv->d_entry), 0,
0);
if (priv->locale_type == DAY_MONTH_YEAR) {
gint pos =
gtk_editable_get_position(GTK_EDITABLE(priv->m_entry));
- /* switch to day entry */
if (pos == 0) {
+ /* Switch to previous entry */
gtk_editable_select_region(GTK_EDITABLE(priv->m_entry), 0,
0);
if (priv->locale_type == DAY_MONTH_YEAR) {
gint pos =
gtk_editable_get_position(GTK_EDITABLE(priv->y_entry));
- /* switch to month entry */
if (pos == 0) {
+ /* Switch to previous entry */
gtk_editable_select_region(GTK_EDITABLE(priv->y_entry), 0,
0);
if (priv->locale_type == DAY_MONTH_YEAR) {
g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(priv->d_entry)),
len);
- /* switch to month entry */
if ((pos == len) || (pos > chars)) {
- gtk_editable_select_region(GTK_EDITABLE(priv->d_entry), 0,
- 0);
+ /* Switch to next entry */
+ gtk_editable_select_region(GTK_EDITABLE(priv->d_entry), 0, 0);
if (priv->locale_type == DAY_MONTH_YEAR) {
gtk_widget_grab_focus(priv->m_entry);
- gtk_editable_set_position(GTK_EDITABLE(priv->m_entry),
- 0);
+ gtk_editable_set_position(GTK_EDITABLE(priv->m_entry), 0);
} else {
gtk_widget_grab_focus(priv->y_entry);
- gtk_editable_set_position(GTK_EDITABLE(priv->y_entry),
- 0);
+ gtk_editable_set_position(GTK_EDITABLE(priv->y_entry), 0);
}
return TRUE;
}
g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(priv->m_entry)),
len);
- /* switch to year entry */
if ((pos == len) || (pos > chars)) {
+ /* Switch to next entry */
gtk_editable_select_region(GTK_EDITABLE(priv->m_entry), 0,
0);
if (priv->locale_type == DAY_MONTH_YEAR) {
g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)),
len);
- /* switch to day entry */
if ((pos == len) || (pos > chars)) {
+ /* Switch to next entry */
gtk_editable_select_region(GTK_EDITABLE(priv->y_entry), 0,
0);
if (priv->locale_type == DAY_MONTH_YEAR) {
return FALSE;
}
+ /* The first "validation" */
hildon_date_editor_entry_validate(GTK_EDITABLE(widget), ed);
- /*date validation starts*/
+ /*date validation starts */
d = atoi(gtk_entry_get_text(GTK_ENTRY(priv->d_entry)));
m = atoi(gtk_entry_get_text(GTK_ENTRY(priv->m_entry)));
y = atoi(gtk_entry_get_text(GTK_ENTRY(priv->y_entry)));
- /*the only reason why a date is not valid is because that
- * some months dont have 31st 30th or even 29th(since we
+ /* The only reason why a date is not valid is because that
+ * some months don't have 31st 30th or even 29th (since we
* have done max and min range checking for each field), for
* now we will only fix day field, if trying to fix day
* field fails to make the date valid, we will set the
* date to be current date, if any value is 0, that means
- * this entry is empty, therefore skip validation*/
+ * this entry is empty, therefore skip validation */
if(d != 0 && m != 0 && y != 0 && !g_date_valid_dmy(d, m, y))
{
max_d = g_date_get_days_in_month(m,y);
+ /* Clamp to max day */
if(priv->d_orig <= max_d && priv->d_orig > 0)
new_d = priv->d_orig;
else
y = g_date_get_day(&gd);
}
+ /* Set focus back to day entry */
gtk_widget_grab_focus(priv->d_entry);
g_idle_add((GSourceFunc)
_hildon_date_editor_entry_select_all, priv->d_entry);
gtk_widget_get_child_requisition(widget, &max_req);
+ /* Center vertically */
f_alloc.y = img_alloc.y = allocation->y +
MAX(allocation->height - max_req.height, 0) / 2;
+ /* Center horizontally */
f_alloc.x = img_alloc.x = allocation->x +
MAX(allocation->width - max_req.width, 0) / 2;
gtk_widget_size_allocate(priv->frame, &f_alloc);
}
- /* allocate entry box */
+ /* allocate icon */
if (priv->d_event_box_image)
if (GTK_WIDGET_VISIBLE(priv->d_event_box_image)) {
gtk_widget_get_child_requisition(priv->d_event_box_image,
gtk_widget_size_allocate(priv->d_event_box_image, &img_alloc);
}
+ /* Allocate delimiters between entries */
priv->dm_delim->allocation.height = max_req.height;
priv->my_delim->allocation.height = max_req.height;
priv->my_delim->allocation.y = priv->d_entry->allocation.y-5;
* @editor: the @HildonDateEditor widget
* @year: year
*
- * This function sets the year shown in the editor.
+ * Sets the year shown in the editor.
*
* Return: Returns TRUE if the year is valid.
**/
* @editor: the @HildonDateEditor widget
* @month: month
*
- * This function sets the month shown in the editor.
+ * Sets the month shown in the editor.
*
* Return: Returns TRUE if the month is valid.
**/
* @editor: the @HildonDateEditor widget
* @day: day
*
- * This function sets the day shown in the editor.
+ * Sets the day shown in the editor.
*
* Return: Returns TRUE if the day is valid.
**/
* hildon_date_editor_get_year:
* @editor: the @HildonDateEditor widget
*
- * This function gets the year shown in the editor.
+ * Gets the year shown in the editor.
*
* Return: Returns the current year shown in the editor.
**/
* hildon_date_editor_get_month:
* @editor: the @HildonDateEditor widget
*
- * This function gets the month shown in the editor.
+ * Gets the month shown in the editor.
*
* Return: Returns the current month shown in the editor.
**/
* hildon_date_editor_get_day:
* @editor: the @HildonDateEditor widget
*
- * This function gets the day shown in the editor.
+ * Gets the day shown in the editor.
*
* Return: Returns the current day shown in the editor.
**/
return (guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->d_entry)));
}
+/* Idle callback */
static gboolean
_hildon_date_editor_entry_select_all (GtkWidget *widget)
{
int i = 0;
int help_enabled = 0;
+ /* Create help signal if it didn't exist */
if (help_signal == 0) {
help_signal = g_signal_new("help", GTK_TYPE_DIALOG,
G_SIGNAL_ACTION, (guint) - 1, NULL,
window = GTK_WIDGET(dialog)->window;
display = gdk_drawable_get_display (window);
+ /* Create a list of atoms stored in GdkWindow */
XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
&list, &amount);
protocols = (Atom *) malloc ((amount+1) * sizeof (Atom));
helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
+ /* Enable the dialoghelp if help_atom is in the atoms' list */
for (i=0; i<amount; i++)
{
protocols[n++] = list[i];
}
XFree (list);
+ /* Add the help_atom to the atoms' list if it was not in it */
if (!help_enabled)
{
protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
}
+ /* Replace the protocol property of the GdkWindow with the new atoms' list */
XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
free (protocols);
+ /* Add a callback function as event filter */
gdk_window_add_filter(window, handle_xevent, dialog);
}
window = GTK_WIDGET(dialog)->window;
display = gdk_drawable_get_display (window);
+ /* Create a list of atoms stored in GdkWindow */
XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
&list, &amount);
helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
protocols = (Atom *) malloc (amount * sizeof (Atom));
+ /* Remove the help_atom if it is in the atoms' list */
for (i=0; i<amount; i++)
{
if (list[i] != helpatom)
}
XFree (list);
+ /* Replace the protocol property of the GdkWindow with the new atoms' list */
XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
free (protocols);
+ /* Remove the event filter */
gdk_window_remove_filter(window, handle_xevent, dialog);
}
GnomeVFSFileInfo *info;
gboolean result = FALSE;
+ /* Get information about file */
info = gnome_vfs_file_info_new ();
if (gnome_vfs_get_file_info(uri, info,
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS) == GNOME_VFS_OK)
+
+ /* Detect that the file is writable or not */
result = ((info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE)
== GNOME_VFS_PERM_ACCESS_WRITABLE);
GnomeVFSFileInfo *info;
GnomeVFSResult result;
+ /* Get the value of cells referenced by a tree_modle */
gtk_tree_model_get(GTK_TREE_MODEL(self->priv->model), &iter,
HILDON_FILE_SYSTEM_MODEL_COLUMN_URI, &uri, -1);
result = gnome_vfs_get_file_info(uri, info,
GNOME_VFS_FILE_INFO_DEFAULT);
+ /* Change the file information */
if (result == GNOME_VFS_OK)
{
if (readonly)
GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
}
- /* No errors are defined in the specs, but the previous operations can still fail */
if (result != GNOME_VFS_OK)
gtk_infoprint(GTK_WINDOW(self), gnome_vfs_result_to_string(result));
priv = HILDON_FILE_DETAILS_DIALOG(widget)->priv;
+ /* Map the GtkWidget */
GTK_WIDGET_CLASS(file_details_dialog_parent_class)->map(widget);
+ /* Set the first page as default and
+ * make the GtkNotebook focusable if it shows tabs */
if (gtk_notebook_get_show_tabs(priv->notebook))
{
gtk_notebook_set_current_page(priv->notebook, 0);
gtk_widget_grab_focus(GTK_WIDGET(priv->notebook));
}
else
+ /* Otherwise make one GtkButton in the dialog
+ * sensitive with the keyboard event */
gtk_widget_grab_focus(priv->ok_button);
}
file_details_dialog_parent_class = g_type_class_peek_parent(klass);
gobject_class = G_OBJECT_CLASS(klass);
+
gobject_class->finalize = hildon_file_details_dialog_finalize;
gobject_class->get_property = hildon_file_details_dialog_get_property;
gobject_class->set_property = hildon_file_details_dialog_set_property;
HildonFileDetailsDialogPrivate *priv;
+ /* Initialize the private property */
self->priv = priv =
G_TYPE_INSTANCE_GET_PRIVATE(self, \
HILDON_TYPE_FILE_DETAILS_DIALOG, HildonFileDetailsDialogPrivate);
gtk_box_pack_start(GTK_BOX(hbox_device), priv->file_device_image, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox_device), priv->file_device, TRUE, TRUE, 0);
- /* Tab one */
+ /* Create captions for the dialog */
caption_name = hildon_caption_new(group, _("ckdg_fi_properties_name_prompt"),
priv->file_name, NULL, HILDON_CAPTION_OPTIONAL);
caption_type = hildon_caption_new(group, _("ckdg_fi_properties_type_prompt"),
g_object_unref(group);
+ /* Pack captions to the dialog */
gtk_box_pack_start(GTK_BOX(vbox), caption_name, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), caption_type, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), caption_location, FALSE, TRUE, 0);
gobject_class->get_property = hildon_font_selection_dialog_get_property;
gobject_class->set_property = hildon_font_selection_dialog_set_property;
+ /* Install property to the class */
g_object_class_install_property(gobject_class, PROP_FAMILY,
g_param_spec_string("family",
"Font family", "String defines"
group =
GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
- /*Tab one*/
+ /* Build the first page of the GtkNotebook: font style */
priv->cbx_font_type = gtk_combo_box_new_text();
hildon_font_selection_dialog_show_available_fonts(fontsel);
caption_control = hildon_caption_new(group,
gtk_box_pack_start(GTK_BOX(vbox_tab[0]), caption_control,
FALSE, FALSE, 0);
- /*Tab two*/
+ /* Build the second page of the GtkNotebook: font formatting */
priv->chk_bold = gtk_check_button_new();
caption_control = hildon_caption_new(group,
_("ecdg_fi_font_bold"),
g_signal_connect(G_OBJECT(priv->chk_underline), "clicked",
G_CALLBACK(toggle_clicked), NULL);
- /*Tab three*/
+ /* Build the third page of the GtkNotebook: other font properties */
priv->chk_strikethrough = gtk_check_button_new();
caption_control =
hildon_caption_new(group, _("ecdg_fi_font_strikethrough"),
"rise", &p_rise, "rise-set", & r_s,
NULL);
- /*settings*/
+ /* Check that the given values are valid.
+ * If not, set the combobox row indicator to 'inconsistent' */
if(ff_s)
{
gint new_f = -1;
gint size, weight, style, underline, strikethrough, rise;
gint new_f = -1, new_size = -1, new_rise = -1;
+ /* Check that the given values are valid.
+ * If not, set the combobox row indicator to 'inconsistent' */
switch(attr->klass->type)
{
case PANGO_ATTR_FAMILY:
settings_init(&settings, fsd);
iter = begin;
- if(gtk_text_iter_compare(&iter, &end) == 0)/*if no selection*/
+
+ /* Keep original settings if the selection includes nothing */
+ if(gtk_text_iter_compare(&iter, &end) == 0)
{
GSList *slist;
g_slist_free(slist);
}
+ /* Apply the user settings to the selected text */
while(gtk_text_iter_compare(&iter, &end) < 0)
{
GSList *slist;
*
*/
-/*
- * HILDON DOC
- * @shortdesc: GetPasswordDialog is a dialog for getting the user
- * password.
- * @longdesc: GetPasswordDialog implements two specified dialogs,
- * which are pretty much functionally the same, but have
- * different outlooks.
- */
#include <glib.h>
#include <errno.h>
#include <stdio.h>
#include <gtk/gtk.h>
+
+/* FIXME: These two includes are broken */
#include <hildon-lgpl/hildon-widgets/gtk-infoprint.h>
#include <hildon-lgpl/hildon-widgets/hildon-input-mode-hint.h>
static void
hildon_get_password_dialog_class_init(HildonGetPasswordDialogClass *
class);
-
static void hildon_get_password_dialog_init(HildonGetPasswordDialog *
widget);
-
static void hildon_get_password_set_property(GObject * object,
guint prop_id,
const GValue * value,
static void hildon_get_password_get_property(GObject * object,
guint prop_id, GValue * value,
GParamSpec * pspec);
-
void hildon_get_password_dialog_set_domain(HildonGetPasswordDialog *dialog,
gchar *domain);
priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
switch (prop_id) {
- case PROP_DOMAIN: /* Implemented othervise, here just for completeness */
+ case PROP_DOMAIN:
+ /* Set label text representing password domain */
gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
break;
case PROP_PASSWORD:
g_value_get_string(value));
break;
case PROP_NUMBERS_ONLY:
+ /* FIXME: This is broken, property value is not used in any way */
g_object_set( G_OBJECT
(gtk_bin_get_child(GTK_BIN(priv->passwordEntry))),
"input-mode", HILDON_INPUT_MODE_HINT_NUMERIC, NULL );
hildon_get_password_dialog_set_caption(dialog, g_value_get_string(value));
break;
case PROP_MAX_CHARS:
+ /* FIXME: This is broken. set_max_characters wants an int, not string */
hildon_get_password_dialog_set_max_characters(dialog,
g_value_get_string(value));
break;
parent_class = g_type_class_peek_parent(class);
+ /* Override virtual functions */
object_class->set_property = hildon_get_password_set_property;
object_class->get_property = hildon_get_password_get_property;
+ /* Install new properties */
+ /* FIXME: Why this is not READWRITE */
g_object_class_install_property
(object_class,
PROP_DOMAIN,
NULL,
G_PARAM_WRITABLE));
-
g_object_class_install_property
(object_class,
PROP_PASSWORD,
"DEFAULT",
G_PARAM_READWRITE));
+ /* FIXME: Why this is not READWRITE?? */
g_object_class_install_property
(object_class,
PROP_NUMBERS_ONLY,
0,
G_PARAM_READWRITE));
+ /* Install private structure */
g_type_class_add_private(class,
sizeof(HildonGetPasswordDialogPrivate));
}
{
GtkSizeGroup * group;
GtkWidget *control;
-
+
+ /* Cache private pointer for faster member access */
HildonGetPasswordDialogPrivate *priv =
HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+ /* Sizegroup for captions */
group = GTK_SIZE_GROUP(gtk_size_group_new
(GTK_SIZE_GROUP_HORIZONTAL));
+ /* Initial properties for the dialog */
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
-
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-
-
gtk_window_set_title(GTK_WINDOW(dialog),
_(HILDON_GET_PASSWORD_DIALOG_TITLE));
+ /* Optional password domain label */
priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
+ /* Create buttons */
priv->okButton =
GTK_BUTTON(gtk_dialog_add_button(GTK_DIALOG(dialog),
_(HILDON_GET_PASSWORD_DIALOG_OK),
_(HILDON_GET_PASSWORD_DIALOG_CANCEL),
GTK_RESPONSE_CANCEL));
+ /* Create password text entry */
control = gtk_entry_new();
gtk_entry_set_visibility(GTK_ENTRY(control), FALSE);
priv->passwordEntry = HILDON_CAPTION
HILDON_CAPTION_OPTIONAL));
hildon_caption_set_separator(HILDON_CAPTION(priv->passwordEntry), "");
+
+ /* Do the basic layout */
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
+
+ /* FIXME: Do not leak group */
}
/* Public functions */
if (get_old_password_title == FALSE) {
HildonGetPasswordDialogPrivate *priv;
+
+ /* Override "get old password" defaults set in dialog_init */
+ /* FIXME: This behaviour is confusing */
gtk_window_set_title(GTK_WINDOW(dialog),
_(HILDON_GET_PASSWORD_VERIFY_DIALOG_TITLE));
priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
hildon_caption_set_label(priv->passwordEntry,
_(HILDON_GET_PASSWORD_VERIFY_DIALOG_PASSWORD)
);
- } /* The other logical strings are set in class init */
+ }
if (parent != NULL) {
gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+ /* Retrieve the password entry widget */
entry1 = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(
priv->passwordEntry)));
gchar *new_title)
{
+ /* FIXME: This method is completely useless, should be deprecated/removed */
g_return_if_fail (new_title !=NULL);
gtk_window_set_title(GTK_WINDOW(dialog),
new_title);
-
}
/**
g_return_if_fail(max_characters >0);
g_return_if_fail(dialog);
+ /* Apply the given length to password entry */
gtk_entry_set_max_length(GTK_ENTRY
(hildon_caption_get_control
(priv->passwordEntry)),
max_characters);
+ /* Connect callback to show error banner if the limit is exceeded */
g_signal_connect(GTK_ENTRY
(hildon_caption_get_control
(priv->passwordEntry)),
focused = priv->icon;
}
+ /* Determine the coordinates and size of clip */
switch (priv->label_pos) {
case HILDON_GRID_ITEM_LABEL_POS_BOTTOM:
clip.x = focused->allocation.x - priv->focus_margin;
break;
}
+ /* Build painting box for the exposure event */
gtk_paint_box(focused->style,
gtk_widget_get_toplevel(focused)->window,
GTK_STATE_SELECTED,
l_req.width = l_req.height = 0;
}
+ /* Determine icon and label allocation based on label position */
switch (priv->label_pos) {
case HILDON_GRID_ITEM_LABEL_POS_BOTTOM:
i_alloc.x = (allocation->width - priv->icon_width) / 2 +
item = HILDON_GRID_ITEM(container);
priv = HILDON_GRID_ITEM_GET_PRIVATE(item);
+ /* Connect callback functions to the item */
if (priv->icon != NULL) {
(*callback) (priv->icon, callback_data);
}
container_class->child_type = hildon_grid_child_type;
container_class->set_focus_child = hildon_grid_set_focus_child;
+ /* Install properties to the class */
g_object_class_install_property(gobject_class, PROP_EMPTY_LABEL,
g_param_spec_string("empty_label",
"Empty label",
priv->label_pos = label_pos;
+ /* Set label position to each HildonGridItem */
for (list = priv->children; list != NULL; list = list->next) {
child = ((HildonGridChild *) list->data)->widget;
priv = HILDON_GRID_GET_PRIVATE(grid);
container = GTK_CONTAINER(grid);
+ /* If grid has no children,
+ * propagate the expose event to the label is one exists */
if (priv->children == NULL || g_list_length(priv->children) == 0) {
if (priv->empty_label != NULL) {
gtk_container_propagate_expose(container,
}
child->widget = widget;
- _hildon_grid_item_set_label_pos(HILDON_GRID_ITEM(widget),
- priv->label_pos);
- _hildon_grid_item_set_focus_margin(HILDON_GRID_ITEM(widget),
- priv->focus_margin);
- _hildon_grid_item_set_icon_width(HILDON_GRID_ITEM(widget),
- priv->icon_width);
- _hildon_grid_item_set_emblem_size(HILDON_GRID_ITEM(widget),
- priv->emblem_size);
+ _hildon_grid_item_set_label_pos (HILDON_GRID_ITEM(widget), priv->label_pos);
+ _hildon_grid_item_set_focus_margin(HILDON_GRID_ITEM(widget), priv->focus_margin);
+ _hildon_grid_item_set_icon_width (HILDON_GRID_ITEM(widget), priv->icon_width);
+ _hildon_grid_item_set_emblem_size (HILDON_GRID_ITEM(widget), priv->emblem_size);
+
+ /* Add the new item to the grid */
priv->children = g_list_append(priv->children, child);
gtk_widget_set_parent(widget, GTK_WIDGET(grid));
list != NULL; list = list->next, index++) {
child = (HildonGridChild *) list->data;
child_widget = child->widget;
+
+ /* Remove the Item if it is found in the grid */
if (child_widget == widget) {
gtk_widget_unparent(child_widget);
priv->children = g_list_remove_link(priv->children, list);
}
}
+ /* Emit warning if the item is not found */
if (!deleted) {
g_warning("tried to remove unexisting item");
return;
priv = HILDON_GRID_GET_PRIVATE(grid);
container = GTK_CONTAINER(grid);
+ /* If widget is NULL -> unfocus */
if (widget == NULL && container->focus_child != NULL)
GTK_WIDGET_UNSET_FLAGS(container->focus_child, GTK_HAS_FOCUS);
return;
}
+ /* Get the child index which the user wanted to focus */
priv->focus_index = get_child_index(priv, widget);
gtk_widget_grab_focus(widget);
grid = HILDON_GRID(container);
priv = HILDON_GRID_GET_PRIVATE(grid);
+ /* Connect callback functions */
if (include_internals) {
if (priv->scrollbar != NULL) {
(*callback) (priv->scrollbar, callback_data);
* . 1 # 2 . 1 # # 1 # # # 1 # # #
* . . . . . 2 . . . . 2 .
*
- * '.' = item, '#' = dimmed item,
- * '1' = starting position, '2' = final position
+ * '.' = item,
+ * '#' = dimmed item,
+ * '1' = starting position,
+ * '2' = final position
*
* ...although only the first example is implemented right now.
*
empty_grids = priv->num_columns * priv->area_rows - child_count +
priv->first_index;
+ /* Determine the position of the new row */
if (priv->focus_index < priv->first_index) {
new_row = priv->focus_index / priv->num_columns;
} else if (priv->focus_index >= priv->first_index +
#include "hildon-volumebar-private.h"
/* Defines for normal version of HVolumebar */
+/* Toggle button */
#define DEFAULT_TBUTTON_WIDTH 26
#define DEFAULT_TBUTTON_HEIGHT 26
+/* Volume bar */
#define MINIMUM_BAR_WIDTH 147
#define DEFAULT_BAR_HEIGHT 58
#define DEFAULT_ENDING_SIZE 20
+/* Gap to leave for mute button */
#define VERTICAL_MUTE_GAP 16
#define HORIZONTAL_MUTE_GAP 6
+/* Sizes inside a toolbar */
+/* Toggle button */
#define TOOL_DEFAULT_TBUTTON_WIDTH 26
#define TOOL_DEFAULT_TBUTTON_HEIGHT 26
+/* Volumebar */
#define TOOL_MINIMUM_BAR_WIDTH 121
#define TOOL_DEFAULT_BAR_HEIGHT 40
#define TOOL_DEFAULT_ENDING_SIZE 0
static void
hildon_hvolumebar_mute(GtkWidget * widget, HildonHVolumebar * self);
-/* new */
static gboolean hildon_hvolumebar_expose(GtkWidget * widget,
GdkEventExpose * event);
static void hildon_hvolumebar_size_request(GtkWidget * widget,
parent = gtk_widget_get_ancestor(GTK_WIDGET(widget), GTK_TYPE_TOOLBAR);
+ /* Check if the volumebar is in a toolbar */
if (parent)
priv->is_toolbar = TRUE;
priv = HILDON_VOLUMEBAR_GET_PRIVATE(HILDON_VOLUMEBAR(widget));
if (GTK_WIDGET_DRAWABLE(widget)) {
+ /* Paint background */
gtk_paint_box(widget->style, widget->window,
GTK_WIDGET_STATE(priv->volumebar), GTK_SHADOW_OUT,
NULL, widget, "background",
widget->allocation.width,
widget->allocation.height);
+ /* The contents of the widget can paint themselves */
(*GTK_WIDGET_CLASS(parent_class)->expose_event) (widget, event);
}
priv = HILDON_VOLUMEBAR_GET_PRIVATE(HILDON_VOLUMEBAR(widget));
+ /* Volumebar has different dimensions in toolbar */
requisition->width = (priv->is_toolbar
? TOOL_MINIMUM_BAR_WIDTH
: MINIMUM_BAR_WIDTH);
button_allocation.x = 0;
button_allocation.width = 0;
+ /* Center the widget vertically */
if (priv->is_toolbar && allocation->height > TOOL_DEFAULT_BAR_HEIGHT) {
allocation->y += (allocation->height - TOOL_DEFAULT_BAR_HEIGHT) / 2;
allocation->height = TOOL_DEFAULT_BAR_HEIGHT;
}
-
if (!priv->is_toolbar && allocation->height > DEFAULT_BAR_HEIGHT) {
allocation->y += (allocation->height - DEFAULT_BAR_HEIGHT) / 2;
allocation->height = DEFAULT_BAR_HEIGHT;
if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton)) {
+ /* Allocate space for the mute button */
if (priv->is_toolbar) {
button_allocation.x = allocation->x;
button_allocation.y = allocation->y + TOOL_VERTICAL_MUTE_GAP;
}
if (priv->volumebar && GTK_WIDGET_VISIBLE(priv->volumebar)) {
+ /* Allocate space for the slider */
range_allocation.y = allocation->y;
if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton))
{
+ /* Leave room for the mute button */
range_allocation.x = button_allocation.x
+ button_allocation.width
+ HORIZONTAL_MUTE_GAP;
if (priv->is_toolbar)
{
+ /* In toolbar with mute button */
range_allocation.width = MAX(0,
allocation->width
- 2 * TOOL_DEFAULT_ENDING_SIZE
else
{
+ /* Standalone with mute button */
range_allocation.width = MAX(0,
allocation->width
- 2 * DEFAULT_ENDING_SIZE
{
if (priv->is_toolbar)
{
+ /* In toolbar without mute button */
range_allocation.x = allocation->x;
range_allocation.width = MAX(0,
else
{
-
+ /* Standalone without mute button */
range_allocation.x = allocation->x + DEFAULT_ENDING_SIZE;
range_allocation.width = MAX(0,
*
*/
-/* HILDON DOC
- * @shortdesc: NamePasswordDialog is a dialog for getting the user name
- * and password.
- * @longdesc: NamePasswordDialog is a simple dummy dialog for getting
- * name&password from the user.
- */
-
#include <glib.h>
#include <gtk/gtk.h>
#include <errno.h>
HildonCaption *passwordEntry;
};
+/* Macro to access the private data of the object instance */
#define HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), HILDON_TYPE_NAME_PASSWORD_DIALOG,\
HildonNamePasswordDialogPrivate))
guint prop_id,
GValue * value,
GParamSpec * pspec);
+
static void
hildon_name_password_dialog_set_property(GObject * object,
guint prop_id,
switch (prop_id) {
case PROP_CONTENT:
+
+ /* Set the password domain text
+ FIXME: Why this is labeled as CONTENT?? */
gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
break;
case PROP_NAME:
+
+ /* Set the current username displayed in the dialog */
+ /* FIXME: Remove the combination of tabs/spaces to make the code look nice */
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(
priv->nameEntry))),
g_value_get_string(value));
break;
case PROP_PASSWORD:
+
+ /* Set the currently entered password */
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(
priv->passwordEntry))),
g_value_set_string(value, string);
break;
case PROP_NAME:
+ /* FIXME: 1) intendation, 2) use g_object_get_property for entry */
string = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(
priv->nameEntry))));
g_value_set_string(value, string);
break;
case PROP_PASSWORD:
+ /* FIXME: 1) intendation, 2) use g_object_get_property for entry */
string = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(
priv->passwordEntry))));
parent_class = g_type_class_peek_parent(class);
+ /* Override virtual functions */
object_class->set_property = hildon_name_password_dialog_set_property;
object_class->get_property = hildon_name_password_dialog_get_property;
- /* properties */
+ /* Install new properties */
g_object_class_install_property(object_class,
PROP_CONTENT,
g_param_spec_string ("content",
"DEFAULT",
G_PARAM_READWRITE));
+ /* Install private data structure */
g_type_class_add_private(class,
sizeof(HildonNamePasswordDialogPrivate));
}
static void
hildon_name_password_dialog_init(HildonNamePasswordDialog * dialog)
{
+ /* Access private structure */
HildonNamePasswordDialogPrivate *priv =
HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+ /* Size group for captions */
GtkSizeGroup *group =
GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
GtkWidget *control;
+ /* Initialize dialog */
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
gtk_window_set_title(GTK_WINDOW(dialog), _(HILDON_NAME_PASSWORD_DIALOG_TITLE));
-
+
+ /* Optional domain name label */
priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
-
+
+ /* Create buttons */
priv->okButton =
GTK_BUTTON(gtk_dialog_add_button(GTK_DIALOG(dialog),
_(HILDON_NAME_PASSWORD_DIALOG_OK),
_(HILDON_NAME_PASSWORD_DIALOG_CANCEL),
GTK_RESPONSE_CANCEL));
+ /* Setup user name entry */
control = gtk_entry_new();
priv->nameEntry = HILDON_CAPTION(hildon_caption_new
(group,
HILDON_CAPTION_OPTIONAL));
hildon_caption_set_separator(priv->nameEntry, "");
+ /* Setup password entry */
control = gtk_entry_new();
gtk_entry_set_visibility(GTK_ENTRY(control), FALSE);
priv->passwordEntry =
HILDON_CAPTION_OPTIONAL));
hildon_caption_set_separator(priv->passwordEntry, "");
+ /* Build layout */
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
gtk_widget_show_all(GTK_DIALOG(dialog)->action_area);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ /* FIXME: Do not leak group */
}
+
GType hildon_name_password_dialog_get_type(void)
{
static GType dialog_type = 0;
{
HildonNamePasswordDialogPrivate *priv =
HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+ /* FIXME: Intendation */
return gtk_entry_get_text(GTK_ENTRY(
(gtk_bin_get_child
(GTK_BIN(
{
HildonNamePasswordDialogPrivate *priv =
HILDON_NAME_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+
+ /* FIXME: Intendation */
return gtk_entry_get_text(GTK_ENTRY
(gtk_bin_get_child
(GTK_BIN(
/*
* @file hildon-note.c
*
- * This file contains API for conformation, information
- * and cancel notes.
- *
- * 9/2004 Removed animation type of cancel note as separate task.
+ * This file contains API for confirmation, information and cancel notes.
*/
#ifdef HAVE_CONFIG_H
#include <unistd.h>
#include <signal.h>
-/* Can these be included from somewhere? */
+/* FIXME: Can these be included from somewhere? */
#define CONFIRMATION_SOUND_PATH "/usr/share/sounds/ui-confirmation_note.wav"
#define INFORMATION_SOUND_PATH "/usr/share/sounds/ui-information_note.wav"
/* This function is just a modified version of two_lines_truncate
* in gtk-infoprint.c */
+/* FIXME: factor this code, we now have _one, _two, _three, _five _line _truncate (...) */
static void
hildon_note_five_line_truncate(const HildonNote * note, const gchar * text)
{
if (priv->original_description != NULL)
g_free(priv->original_description);
+ /* Save original text */
priv->original_description = g_strdup(text);
if (text == NULL) {
layout = pango_layout_new(context);
pango_layout_set_text(layout, str, -1);
+ /* Set wrapping options */
pango_layout_set_width(layout, max_width * PANGO_SCALE);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
last_line = MIN(4, pango_layout_get_line_count(layout) - 1);
+ /* Copy first 5 lines */
for (current_line = 0;
current_line <= last_line;
current_line++) {
g_object_unref(layout);
+ /* Create new layout starting from last line */
layout = pango_layout_new(context);
pango_layout_set_text(layout, lines[last_line], -1);
PangoLayoutLine *line;
gint index = 0;
- /* Here we ellipsize the last line... */
+ /* Cut text, add ellipsis to last line */
if (pango_layout_get_line_count(layout) > 1) {
gchar *templine = NULL;
g_free(templine);
}
+ /* Find point where to add ellipsis so it would fit,
+ if it doesn't already */
if (pango_layout_xy_to_index(layout,
max_width * PANGO_SCALE, 0,
&index, NULL) == TRUE) {
ellipsiswidth, 0, &index,
NULL);
g_object_unref(G_OBJECT(ellipsis));
+ /* Cut text from that point and add ellipsis */
tempresult = g_strndup(lines[last_line], index);
lines[last_line] = g_strconcat(tempresult,
ELLIPSATION_STRING,
}
}
+ /* Remove newlines */
for (current_line = 0; current_line <= last_line; current_line++)
g_strchomp(lines[current_line]);
+ /* Get resulting string */
result = g_strconcat(lines[0], "\n",
lines[1], "\n",
lines[2], "\n",
if (priv->original_description != NULL)
g_free(priv->original_description);
+ /* Save original text */
priv->original_description = g_strdup(text);
str = g_strdup(text == NULL ? "" : text);
layout = pango_layout_new(context);
pango_layout_set_text(layout, str, -1);
+ /* Set wrapping options */
pango_layout_set_width(layout, max_width * PANGO_SCALE);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
+ /* Cut string and add ellipsis if more than one line */
if (pango_layout_get_line_count(layout) > 1) {
gchar *templine = NULL;
g_free(templine);
}
+ /* Find point where to add ellipsis so it would fit,
+ if it doesn't already */
if (pango_layout_xy_to_index(layout,
max_width * PANGO_SCALE, 0,
&index, NULL) == TRUE) {
ellipsiswidth, 0, &index,
NULL);
g_object_unref(G_OBJECT(ellipsis));
+ /* Cut text from that point and add ellipsis (again) */
tempresult = g_strndup(str, index);
str = g_strconcat(tempresult,
ELLIPSATION_STRING,
static GType notetype = 0;
if (notetype == 0) {
static const GEnumValue values[] = {
- { HILDON_NOTE_CONFIRMATION_TYPE,
- "HILDON_NOTE_CONFIRMATION_TYPE",
- "confirmation" },
- { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
- "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE",
- "confirmation-button" },
- { HILDON_NOTE_INFORMATION_TYPE,
- "HILDON_NOTE_INFORMATION_TYPE",
- "note-information" },
- { HILDON_NOTE_INFORMATION_THEME_TYPE,
- "HILDON_NOTE_INFORMATION_THEME_TYPE",
- "note-information-theme" },
- { HILDON_NOTE_PROGRESSBAR_TYPE,
- "HILDON_NOTE_PROGRESSBAR_TYPE",
- "note-progressbar" },
+ { HILDON_NOTE_CONFIRMATION_TYPE, "HILDON_NOTE_CONFIRMATION_TYPE", "confirmation" },
+ { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE, "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE", "confirmation-button" },
+ { HILDON_NOTE_INFORMATION_TYPE, "HILDON_NOTE_INFORMATION_TYPE", "note-information" },
+ { HILDON_NOTE_INFORMATION_THEME_TYPE, "HILDON_NOTE_INFORMATION_THEME_TYPE", "note-information-theme" },
+ { HILDON_NOTE_PROGRESSBAR_TYPE, "HILDON_NOTE_PROGRESSBAR_TYPE", "note-progressbar" },
{ 0, NULL, NULL }
};
notetype = g_enum_register_static ("HildonNoteType", values);
/**
* HildonNote:progressbar:
*
- * Progresbar for note.
+ * Progressbar for note.
*/
g_object_class_install_property(object_class,
PROP_HILDON_NOTE_PROGRESSBAR,
g_param_spec_object("progressbar",
"Progressbar widget",
- "The progressbar that appear in the note dialog",
+ "The progressbar that appears in the note dialog",
GTK_TYPE_PROGRESS_BAR,
G_PARAM_READWRITE));
}
{
GTK_WIDGET_CLASS (parent_class)->realize (widget);
+ /* Add border */
gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
}
priv->note_n == HILDON_NOTE_INFORMATION_TYPE) {
if (priv->note_n == HILDON_NOTE_CONFIRMATION_TYPE) {
- /* ok button clickable with mouse or whatever */
+ /* Add clickable OK button */
priv->okButton =
gtk_dialog_add_button(GTK_DIALOG(note),
_("Ecdg_bd_confirmation_note_ok"),
GTK_RESPONSE_OK);
- /* cancel button clickable with mouse or whatever */
+ /* Add clickable Cancel button */
priv->cancelButton =
gtk_dialog_add_button(GTK_DIALOG(note),
_("Ecdg_bd_confirmation_note_cancel"),
} else if (priv->note_n == HILDON_NOTE_INFORMATION_TYPE ||
priv->note_n == HILDON_NOTE_INFORMATION_THEME_TYPE ) {
priv->okButton = NULL;
- /* cancel button clickable with mouse or whatever */
+ /* Add clickable OK button (cancel really,
+ but doesn't matter since this is info) */
priv->cancelButton =
gtk_dialog_add_button(GTK_DIALOG(note),
_("Ecdg_bd_information_note_ok"),
priv->note_n == HILDON_NOTE_INFORMATION_THEME_TYPE) &&
priv->icon)
{
+ /* Information with custom icon */
item = gtk_image_new_from_icon_name(priv->icon,
HILDON_ICON_SIZE_BIG_NOTE);
}
else {
+ /* Use default icon */
if (priv->note_n == HILDON_NOTE_CONFIRMATION_TYPE ||
priv->note_n == HILDON_NOTE_CONFIRMATION_BUTTON_TYPE)
{
}
if (IsHorizontal) {
+ /* Pack item with label horizontally */
priv->box = gtk_hbox_new(FALSE, BOX_SPACING);
gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
gtk_box_pack_start(GTK_BOX(priv->box), priv->label, FALSE, FALSE, 0);
} else {
+ /* Pack item with label vertically */
priv->box = gtk_vbox_new(FALSE, BOX_SPACING);
gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
gtk_box_pack_start(GTK_BOX(priv->box), priv->label, FALSE, FALSE, 0);
*
* Return value: A #GtkWidget pointer of the note.
*/
+
+/* FIXME: XXX This doc seems to be wrong, the two buttons aren't added so it
+ * would only contain the "additional" buttons? */
+
GtkWidget *hildon_note_new_confirmation_add_buttons(GtkWindow * parent,
const gchar *
description, ...)
if (parent != NULL)
gtk_window_set_transient_for(GTK_WINDOW(conf_note), parent);
+ /* Add the buttons from varargs */
va_start(args, description);
while (TRUE) {
#define SPACE_BORDER 6
#define NUMBER_EDITOR_HEIGHT 30
+/* Size of plus and minus buttons */
#define BUTTON_HEIGHT 30
#define BUTTON_WIDTH 30
guint prop_id,
GValue * value, GParamSpec * pspec);
+/* Signal indices */
enum
{
RANGE_ERROR,
LAST_SIGNAL
};
+/* Property indices */
enum {
PROP_0,
PROP_VALUE
struct _HildonNumberEditorPrivate
{
+ /* Child widgets */
GtkWidget *num_entry;
GtkWidget *plus;
GtkWidget *minus;
- gint start;
- gint end;
+ gint start; /* Minimum */
+ gint end; /* Maximum */
gint default_val;
- gint button_type;
+ gint button_type; /* Type of button pressed: 1 = plus, -1 = minus */
- guint button_event_id;
- guint select_all_idle_id;
+ /* Timer IDs */
+ guint button_event_id; /* Repeat change when button is held */
+ guint select_all_idle_id; /* Selection repaint hack
+ see hildon_number_editor_select_all */
- gboolean negative;
+ gboolean negative; /* FIXME: XXX This is unused */
};
if (!include_internals)
return;
+ /* Enumerate child widgets */
(*callback) (priv->minus, callback_data);
(*callback) (priv->num_entry, callback_data);
(*callback) (priv->plus, callback_data);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(self);
+ /* Free child widgets */
if (priv->minus)
{
gtk_widget_unparent(priv->minus);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(self);
- /* Free timer */
+ /* Free timers */
if (priv->button_event_id)
g_source_remove (priv->button_event_id);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(editor), GTK_NO_WINDOW);
+ /* Create child widgets */
priv->num_entry = gtk_entry_new();
priv->minus = gtk_button_new();
priv->plus = gtk_button_new();
gtk_widget_set_parent(priv->num_entry, GTK_WIDGET(editor));
gtk_widget_set_parent(priv->plus, GTK_WIDGET(editor));
+ /* Connect child widget signals */
g_signal_connect(GTK_OBJECT(priv->num_entry), "changed",
G_CALLBACK(hildon_number_editor_entry_changed),
editor);
gboolean group_cycle)
{
HildonNumberEditorPrivate *priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(widget);
+ /* Focus and select all of number entry on activation */
gtk_widget_grab_focus(priv->num_entry);
gtk_editable_select_region(GTK_EDITABLE(priv->num_entry), 0, -1);
return TRUE;
HildonNumberEditorPrivate *priv =
HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
+ /* Stop repetition timer */
if (priv->button_event_id)
{
g_source_remove(priv->button_event_id);
hildon_number_editor_button_pressed (GtkWidget *widget, GdkEventButton *event,
gpointer data)
{
+ /* FIXME: XXX Why aren't we using hildon_number_editor_start_timer here? XXX */
/* Need to fetch current value from entry and increment or decrement
it */
HildonNumberEditor *editor;
settings = gtk_settings_get_default();
g_object_get(settings, "gtk-initial-timeout", &timeout, NULL);
+ /* Save type of button pressed */
if (GTK_BUTTON(widget) == GTK_BUTTON(priv->plus))
priv->button_type = 1;
else
priv->button_type = -1;
+ /* Start repetition timer */
if (!priv->button_event_id)
{
do_mouse_timeout(editor);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
success = TRUE;
+ /* Update value based on button held */
if (priv->button_type == 1)
{
if (change_numbers(editor, 1, -1) == FALSE)
HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
nvalue = atoi(GTK_ENTRY(priv->num_entry)->text);
+ /* Update value */
if (type == 1)
{
if (nvalue < priv->end)
}
}
- /* write value to num_entry */
+ /* Write updated value to num_entry */
snvalue = integer_to_string(nvalue);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), snvalue);
if (strlen(tmpstr) > 0)
{
tmpstr = NULL;
+ /* Try to convert entry text to number */
value = strtol(GTK_ENTRY(priv->num_entry)->text, &tail, 10);
+ /* Check if conversion succeeded or value contains minus sign */
if (!strncmp(tail, "\0", 1) || !strncmp(tail, "-", 1))
{
+ /* Check if value isn't in allowed range */
if (atoi(GTK_ENTRY(priv->num_entry)->text) > priv->end)
{
g_signal_emit(editor,HildonNumberEditor_signal[RANGE_ERROR],
editor = HILDON_NUMBER_EDITOR(widget);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
+ /* Requested size is size of all child widgets plus border space */
gtk_widget_size_request(priv->minus, &req);
requisition->width = req.width;
requisition->width += req.width;
requisition->width += SPACE_BORDER * 2;
+
+ /* FIXME: XXX Height is fixed */
requisition->height = NUMBER_EDITOR_HEIGHT;
}
+/* Update @alloc->width so widget fits, update @alloc->x to point to free space */
static void
set_widget_allocation (GtkWidget *widget, GtkAllocation *alloc,
GtkAllocation *allocation)
gtk_widget_get_child_requisition(widget, &child_requisition);
+ /* Fit to widget width */
if (allocation->width + allocation->x >
alloc->x + child_requisition.width)
alloc->width = child_requisition.width;
}
gtk_widget_size_allocate(widget, alloc);
+ /* Update x position */
alloc->x += alloc->width;
}
widget->allocation = *allocation;
-/*Init start values*/
+ /* Add upper border */
alloc.y = widget->allocation.y + widget->style->ythickness;
+ /* Fix height */
if (widget->allocation.height > NUMBER_EDITOR_HEIGHT)
{
alloc.height = NUMBER_EDITOR_HEIGHT - widget->style->ythickness * 2;
}
else
alloc.height = widget->allocation.height - widget->style->ythickness * 2;
-
-
if (alloc.height < 0)
alloc.height = 0;
+ /* Add left border */
alloc.x = allocation->x + widget->style->xthickness;
+ /* Allocate positions for widgets (left-to-right) */
set_widget_allocation(priv->minus, &alloc, &widget->allocation);
alloc.x += SPACE_BORDER;
editor = HILDON_NUMBER_EDITOR(data);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
- /* empty entry, must infoprint error message */
+ /* If entry is empty, emit error signal */
if (!strlen(GTK_ENTRY(priv->num_entry)->text))
{
g_signal_emit(editor, HildonNumberEditor_signal[RANGE_ERROR],
0, ERRONEOUS_VALUE, &r);
- /* Changing to default value */
+ /* Change to default value */
str = integer_to_string(priv->default_val);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), str);
gtk_editable_select_region(GTK_EDITABLE(priv->num_entry), 0, -1);
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(data);
tmp_pos = gtk_editable_get_position( GTK_EDITABLE(priv->num_entry) );
+ /* Change value when left or right key pressed and cursor is at boundary */
if( (event->keyval == GDK_Left) || (event->keyval == GDK_Right) )
{
if( ((event->keyval == GDK_Left) && tmp_pos == 0 ) ||
return FALSE;
}
+ /* Allow numbers, minus key and editing keys */
scnd_chr = gtk_editable_get_chars( GTK_EDITABLE(priv->num_entry),
0, 1 );
if (event->keyval == GDK_minus || event->keyval == GDK_KP_Subtract)
else if ((event->keyval == GDK_Up) || (event->keyval == GDK_Down)
|| (event->keyval == GDK_KP_Up) || (event->keyval == GDK_KP_Down))
ret_val = FALSE;
- else if (((event->keyval >= GDK_0) && (event->keyval <= GDK_9)) ||
- ((event->keyval >= GDK_KP_0) && (event->keyval <= GDK_KP_9))
+ else if ( ( (event->keyval >= GDK_0) && (event->keyval <= GDK_9) )
+ || ( (event->keyval >= GDK_KP_0) && (event->keyval <= GDK_KP_9) )
|| (event->keyval == GDK_BackSpace)
|| (event->keyval == GDK_Delete)
|| (event->keyval == GDK_Return)
- || (((event->keyval == GDK_minus)
- || (event->keyval == GDK_KP_Subtract))))
+ || (((event->keyval == GDK_minus) || (event->keyval == GDK_KP_Subtract)))
+ )
ret_val = FALSE;
else
ret_val = TRUE;
min = priv->start;
max = priv->end;
- /* Construct different error message */
+ /* Construct error message */
switch (type)
{
case MAXIMUM_VALUE_EXCEED:
break;
}
+ /* Infoprint error */
if (err_msg)
{
gtk_infoprint(GTK_WINDOW(gtk_widget_get_ancestor(GTK_WIDGET(editor),
* @min: Minimum accepted value
* @max: Maximum accepted value
*
- * This function creates new number editor
+ * Creates new number editor
*
* Return value: a new #HildonNumberEditor widget.
*/
* @min: Minimum accepted value
* @max: Maximum accepted value
*
- * This function set accepted number range for editor
+ * Sets accepted number range for editor
*/
void
hildon_number_editor_set_range (HildonNumberEditor *editor, gint min, gint max)
g_return_if_fail(HILDON_IS_NUMBER_EDITOR(editor));
+ /* Sort min and max */
if (min > max)
{
gint temp = min;
priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
- /* we need to store user inputted values */
+ /* Set preferences */
priv->start = min;
priv->end = max;
priv->default_val = min;
priv->negative = min < 0 ? TRUE : FALSE;
+ /* Find maximum allowed length of value */
str = integer_to_string(max);
str2 = integer_to_string(min);
a = strlen(str);
entry_len = b;
+ /* Set maximum size of entry */
gtk_entry_set_width_chars(GTK_ENTRY(priv->num_entry), entry_len);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), str);
* hildon_number_editor_get_value:
* @editor: pointer to #HildonNumberEditor
*
- * This function returns current value of number editor
- *
* Return value: Current NumberEditor value
*/
gint
* @editor: pointer to #HildonNumberEditor
* @value: numeric value for number editor
*
- * This function sets numeric value to number editor
+ * Sets numeric value for number editor
*/
void
hildon_number_editor_set_value (HildonNumberEditor *editor, gint value)
g_return_if_fail(value >= priv->start);
priv->default_val = value;
-
+
+ /* Update text in entry to new value */
str = integer_to_string(value);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), str);
if (str)
*/
/* HILDON DOC
- * @desc: Range Editor is used to define the range some attribute. Accepted
+ * @desc: Range Editor is used to define the range of some attribute. Accepted
* number type is integer and '-' character is also acceptable. Range can
* be used in application area and in dialog.
*
#define DEFAULT_PADDING 3
#define DEFAULT_START -999
-#define DEFAULT_END 999
+#define DEFAULT_END 999
#define DEFAULT_LENGTH 4
#define HILDON_RANGE_EDITOR_GET_PRIVATE(obj) \
typedef struct _HildonRangeEditorPrivate HildonRangeEditorPrivate;
+/* Property indices */
enum
{
PROP_LOWER = 1,
PROP_SEPARATOR
};
-/*our parent class*/
static GtkContainerClass *parent_class = NULL;
/*Init functions*/
/* Private struct */
struct _HildonRangeEditorPrivate
{
- GtkWidget *start_entry;
- GtkWidget *end_entry;
+ GtkWidget *start_entry; /* Entry for lower value */
+ GtkWidget *end_entry; /* Entry for higher value */
+
GtkWidget *label;
- gint range_limits_start;
- gint range_limits_end;
- gboolean bp;
+
+ gint range_limits_start; /* Minimum value allowed for range start/end */
+ gint range_limits_end; /* Maximum value allowed for range start/end */
+
+ gboolean bp; /* Button pressed, don't overwrite selection */
};
/* Private functions */
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(editor_class);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS(editor_class);
- /* set the global parent_class */
parent_class = g_type_class_peek_parent(editor_class);
- /* now the object stuff */
g_type_class_add_private(editor_class,
sizeof(HildonRangeEditorPrivate));
HildonRangeEditor *editor)
{
HildonRangeEditorPrivate *priv = HILDON_RANGE_EDITOR_GET_PRIVATE(editor);
+ /* Update internal value */
hildon_range_editor_set_range( editor,
g_strtod(GTK_ENTRY(priv->start_entry)->text, NULL),
g_strtod(GTK_ENTRY(priv->end_entry)->text, NULL));
return FALSE;
}
+/* FIXME: XXX Mnemonics aren't used */
static gboolean
hildon_range_editor_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
gtk_widget_size_request(priv->end_entry, &mreq);
gtk_widget_size_request(priv->label, &lab_req);
+ /* Width for entries and separator label and border */
requisition->width = mreq.width * 2 + lab_req.width +
widget->style->xthickness * 2;
+ /* Add vertical border */
requisition->height = mreq.height + widget->style->ythickness * 2;
+ /* Fit label height */
requisition->height = MAX (requisition->height, lab_req.height);
}
widget->allocation = *allocation;
+ /* Allocate entries, left-to-right */
if (priv->start_entry && GTK_WIDGET_VISIBLE(priv->start_entry))
{
GtkRequisition child_requisition;
child2_allocation.x = child1_allocation.x + child1_allocation.width;
child2_allocation.y = allocation->y;
+ /* Add spacing */
child2_allocation.width = child_requisition.width + 4;
child2_allocation.height = allocation->height;
}
}
+/* Button released inside entries */
static gboolean
hildon_range_editor_released(GtkEditable *editable, GdkEventButton *event,
HildonRangeEditor *editor)
HildonRangeEditor *editor)
{
HildonRangeEditorPrivate *priv;
- GtkWidget *wdgt;
+ GtkWidget *wdgt; /* Next widget */
gint pos;
gchar *str;
(event->keyval == GDK_ISO_Left_Tab|| (pos == 0 &&
(event->keyval == GDK_Left || event->keyval == GDK_KP_Left)))))
{
+ /* Set focus to next widget */
gtk_widget_grab_focus(wdgt);
if (widget == priv->start_entry)
{
+ /* Select all, move cursor to end */
gtk_editable_set_position(GTK_EDITABLE(wdgt), -1);
gtk_editable_select_region(GTK_EDITABLE(wdgt), 0, -1);
}
else
{
+ /* Select none (or all??), move cursor to beginning */
gtk_editable_set_position(GTK_EDITABLE(wdgt), 0);
gtk_editable_select_region(GTK_EDITABLE(wdgt), -1, 0);
}
}
- else if ((event->keyval >= GDK_0 && event->keyval <= GDK_9) ||
+ else if ((event->keyval >= GDK_0 && event->keyval <= GDK_9) ||
(event->keyval >= GDK_KP_0 && event->keyval <= GDK_KP_9) ||
(event->keyval == GDK_minus || event->keyval == GDK_KP_Subtract) ||
- event->keyval == GDK_Up || event->keyval == GDK_Down ||
- event->keyval == GDK_Right || event->keyval == GDK_KP_Right ||
- event->keyval == GDK_Left || event->keyval == GDK_KP_Left ||
- event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)
+ event->keyval == GDK_Up ||
+ event->keyval == GDK_Down ||
+ event->keyval == GDK_Right ||
+ event->keyval == GDK_KP_Right ||
+ event->keyval == GDK_Left ||
+ event->keyval == GDK_KP_Left ||
+ event->keyval == GDK_BackSpace ||
+ event->keyval == GDK_Delete)
{
return FALSE;
}
* hildon_range_editor_get_type:
* @Returns : GType of #HildonRangeEditor.
*
- * Initialises, and returns the type of a hildon range editor.
+ * Initializes, and returns the type of a hildon range editor.
*/
GType
hildon_range_editor_get_type (void)
else
g_sprintf (range, "%d", priv->range_limits_start);
+ /* Update entry text with new value */
gtk_entry_set_text (GTK_ENTRY (priv->start_entry), range);
g_object_notify (G_OBJECT (editor), "lower");
}
else
g_sprintf (range, "%d", priv->range_limits_end);
+ /* Update entry text with new value */
gtk_entry_set_text (GTK_ENTRY (priv->end_entry), range);
g_object_notify (G_OBJECT (editor), "higher");
}
hildon_range_editor_set_max (editor, value);
else
{
+ /* Calculate length of entry so minimum would fit */
g_sprintf (end_range, "%d", priv->range_limits_end);
end_entry = GTK_ENTRY (priv->end_entry);
length = MAX (strlen (start_range), strlen (end_range));
gtk_entry_set_max_length (end_entry, length);
}
+ /* Update lower value if it isn't in range */
if (hildon_range_editor_get_lower (editor) < value)
gtk_entry_set_text (start_entry, start_range);
hildon_range_editor_set_min (editor, value);
else
{
+ /* Calculate length of entry so maximum would fit */
g_sprintf (start_range, "%d", priv->range_limits_start);
start_entry = GTK_ENTRY (priv->start_entry);
length = MAX (strlen (end_range), strlen (start_range));
gtk_entry_set_max_length (end_entry, length);
}
+ /* Update higher value if it isn't in range */
if (hildon_range_editor_get_higher (editor) > value)
gtk_entry_set_text (end_entry, end_range);
*
*/
-/* hildon-scroll-area.c
- *
- */
-
#include "hildon-scroll-area.h"
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtkfixed.h>
typedef struct
{
GtkWidget *fixed;
+
+ /* Scrolled windows */
GtkWidget *swouter;
GtkWidget *swinner;
+
+ /* Widget that's being contained */
GtkWidget *child;
+ /* Vertical adjustment for scrolled windows */
GtkAdjustment *outadj;
GtkAdjustment *inadj;
GtkRequisition *req,
HildonScrollArea *sc)
{
+ /* Limit height to fixed height */
gint new_req = MAX (req->height, sc->fixed->allocation.height);
gtk_widget_set_size_request (sc->fixed, -1, req->height);
+ /* Request inner scrolled window at most page size */
gtk_widget_set_size_request (sc->swinner, -1,
MIN (sc->outadj->page_size, new_req));
}
GtkRequisition req;
gtk_widget_size_request (sc->child, &req);
+ /* Update inner adjustment position based on outer one, update fixed position */
if ((sc->outadj->value + sc->outadj->page_size) > sc->fixed->allocation.y
&& sc->outadj->value < (sc->fixed->allocation.y + req.height))
{
static void hildon_scroll_area_inner_value_changed (GtkAdjustment *adjustment,
HildonScrollArea *sc)
{
+ /* Update outer adjustment based on inner adjustment position */
if (sc->outadj->value != sc->fixed->allocation.y + adjustment->value)
gtk_adjustment_set_value (sc->outadj,
sc->fixed->allocation.y + adjustment->value);
static gboolean hildon_seekbar_keypress(GtkWidget * widget,
GdkEventKey * event);
-/* private stuff */
-/*
- * Some constants
- * These should be named so that they are quite self
- * explanatory
- */
#define MINIMUM_WIDTH 115
#define DEFAULT_HEIGHT 58
+
/* Toolbar width and height defines */
#define TOOL_MINIMUM_WIDTH 75
#define TOOL_DEFAULT_HEIGHT 40
#define TOOL_EXTRA_SIDE_BORDER 0
/* the number of steps it takes to move from left to right */
-#define SECONDS_PER_MINUTE 60
#define NUM_STEPS 20
+#define SECONDS_PER_MINUTE 60
+
/* the number of digits precision for the internal range.
* note, this needs to be enough so that the step size for
* small total_times doesn't get rounded off. Currently set to 3
* add one for safety */
#define MAX_ROUND_DIGITS 3
-/* enum for properties */
+/* Property indices */
enum {
PROP_TOTAL_TIME = 1,
PROP_POSITION,
/* private variables */
struct _HildonSeekbarPrivate {
- GtkWidget *label;
- gboolean draw_value;
- gboolean is_toolbar;
+ GtkWidget *label; /* FIXME: XXX This is unused */
+ gboolean draw_value; /* FIXME: XXX This is unused */
+
+ gboolean is_toolbar; /* TRUE if this widget is inside a toolbar */
+
guint fraction; /* This is the amount of time that has progressed from
the beginning. It should be an integer between the
minimum and maximum values of the corresponding
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(seekbar_class);
GObjectClass *object_class = G_OBJECT_CLASS(seekbar_class);
- /* set the global parent_class */
parent_class = g_type_class_peek_parent(seekbar_class);
g_type_class_add_private(seekbar_class, sizeof(HildonSeekbarPrivate));
- /* setup our widgets v-table */
widget_class->size_request = hildon_seekbar_size_request;
widget_class->size_allocate = hildon_seekbar_size_allocate;
widget_class->expose_event = hildon_seekbar_expose;
hildon_seekbar_button_release_event;
widget_class->key_press_event = hildon_seekbar_keypress;
- /* now the object stuff */
object_class->set_property = hildon_seekbar_set_property;
object_class->get_property = hildon_seekbar_get_property;
object_class->finalize = hildon_seekbar_finalize;
- /* install the properties */
g_object_class_install_property(object_class, PROP_TOTAL_TIME,
g_param_spec_double("total_time",
"total time",
priv = HILDON_SEEKBAR_GET_PRIVATE(seekbar);
+ /* Initialize range widget */
range->orientation = GTK_ORIENTATION_HORIZONTAL;
range->flippable = TRUE;
range->has_stepper_a = TRUE;
gtk_scale_set_draw_value (GTK_SCALE (seekbar), FALSE);
}
-/* is this even necessary? */
+/* FIXME: XXX This isn't necessary */
static void hildon_seekbar_finalize( GObject *obj_self )
{
HildonSeekbar *self;
}
-/* handle keypress events */
static gboolean hildon_seekbar_keypress(GtkWidget * widget,
GdkEventKey * event)
{
event));
}
-/* handle setting of seekbar properties */
static void
hildon_seekbar_set_property(GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
/**
* hildon_seekbar_new:
*
- * Creates a new #HildonSeekbar widget.
+ * Create a new #HildonSeekbar widget.
*
* Return value: A #GtkWidget pointer of #HildonSeekbar widget.
*/
GtkWidget *hildon_seekbar_new(void)
{
- /* return a new object */
return g_object_new(HILDON_TYPE_SEEKBAR, NULL);
}
* hildon_seekbar_get_total_time:
* @seekbar: Pointer to #HildonSeekbar widget.
*
- * Accessor method for getting total playing time of stream
- * in seconds.
+ * Get total playing time of stream in seconds.
*
* Returns: Total time as gint.
**/
* @seekbar: Pointer to #HildonSeekbar widget.
* @time: Time within range of > 0 && < G_MAXINT
*
- * Accessor method for setting total playing time of stream
- * in seconds.
+ * Set total playing time of stream in seconds.
*
**/
void hildon_seekbar_set_total_time(HildonSeekbar *seekbar, gint time)
adj = GTK_RANGE(widget)->adjustment;
adj->upper = time;
+ /* Clamp position to total time */
if (adj->value > time) {
adj->value = time;
value_changed = TRUE;
}
+ /* Calculate new step value */
adj->step_increment = adj->upper / NUM_STEPS;
adj->page_increment = adj->step_increment;
gtk_adjustment_changed(adj);
+ /* Update range widget position/fraction */
if (value_changed) {
gtk_adjustment_value_changed(adj);
hildon_seekbar_set_fraction(seekbar,
* hildon_seekbar_get_fraction:
* @seekbar: Pointer to #HildonSeekbar widget.
*
- * Accessor method for getting current fraction related to the progress indicator.
- * It should be between min and max of seekbar range.
+ * Get current fraction related to the progress indicator.
*
* Returns: Current fraction.
**/
* @seekbar: Pointer to #HildonSeekbar widget.
* @fraction: The new position of the progress indicator.
*
- * Method for setting current value related to the progress indicator.
+ * Set current fraction value related to the progress indicator.
* It should be between the minimal and maximal values of the range in seekbar.
**/
void hildon_seekbar_set_fraction( HildonSeekbar *seekbar, guint fraction )
fraction = CLAMP(fraction, range->adjustment->lower,
range->adjustment->upper);
+ /* Update stream position of range widget */
osso_gtk_range_set_stream_position( range, fraction );
if (fraction < hildon_seekbar_get_position(seekbar))
* hildon_seekbar_get_position:
* @seekbar: Pointer to #HildonSeekbar widget.
*
- * Accessor method for getting current position in stream
- * in seconds.
- *
+ * Get current position in stream in seconds.
*
* Returns: Current position in stream in seconds.
**/
* @seekbar: Pointer to #HildonSeekbar widget.
* @time: Time within range of >= 0 && < G_MAXINT
*
- * Accessor method for setting current position in stream
- * in seconds.
+ * Set current position in stream in seconds.
**/
void hildon_seekbar_set_position(HildonSeekbar *seekbar, gint time)
{
if (GTK_WIDGET_CLASS(parent_class)->size_request)
GTK_WIDGET_CLASS(parent_class)->size_request(widget, req);
+ /* Request minimum size, depending on whether the widget is in a
+ * toolbar or not */
req->width = priv->is_toolbar ? TOOL_MINIMUM_WIDTH : MINIMUM_WIDTH;
req->height = priv->is_toolbar ? TOOL_DEFAULT_HEIGHT : DEFAULT_HEIGHT;
}
priv = HILDON_SEEKBAR_GET_PRIVATE(HILDON_SEEKBAR(widget));
+ /* Center vertically */
if (priv->is_toolbar == TRUE)
{
if (allocation->height > TOOL_DEFAULT_HEIGHT) {
}
}
+ /* Add space for border */
if (priv->is_toolbar == TRUE)
{
allocation->x += TOOL_EXTRA_SIDE_BORDER;
EXTRA_SIDE_BORDER;
if (GTK_WIDGET_DRAWABLE(widget)) {
+ /* Paint border */
gtk_paint_box(widget->style, widget->window,
GTK_WIDGET_STATE(widget), GTK_SHADOW_OUT,
NULL, widget, "seekbar",
return FALSE;
}
-/*
- * Event handler for button_press_event
- */
static gboolean
hildon_seekbar_button_press_event(GtkWidget * widget,
GdkEventButton * event)
self = HILDON_SEEKBAR(widget);
priv = HILDON_SEEKBAR_GET_PRIVATE(self);
+ /* hack, translate first mouse button to second? */
event->button = event->button == 1 ? 2 : event->button;
/* call the parent handler */
return result;
}
-/*
- * Event handler for button_release_event
- */
static gboolean
hildon_seekbar_button_release_event(GtkWidget * widget,
GdkEventButton * event)
#include <stdio.h>
#include <hildon-widgets/hildon-caption.h>
-#include <hildon-widgets/gtk-infoprint.h>
+#include <hildon-widgets/gtk-infoprint.h> /* FIXME: broken include? */
#include <hildon-widgets/hildon-set-password-dialog.h>
#include <hildon-widgets/hildon-note.h>
#include <hildon-widgets/hildon-defines.h>
GParamSpec * pspec);
/* Private struct */
-
struct _HildonSetPasswordDialogPrivate {
- /* Checkbox tab */
GtkWidget *checkboxCaption;
GtkWidget *checkbox;
GtkLabel *domainLabel;
- /* Tab one */
GtkWidget *pwd1stEntry;
GtkWidget *pwd1stCaption;
gchar *pwd1stCaption_string;
- /* Tab two */
GtkWidget *pwd2ndEntry;
GtkWidget *pwd2ndCaption;
gchar *pwd2ndCaption_string;
- /* OK/Cancel buttons */
GtkWidget *okButton;
GtkWidget *cancelButton;
gboolean protection;
-
};
enum {
switch (prop_id) {
case PROP_DOMAIN:
+ /* Update domain label to display new value */
gtk_label_set_text(priv->domainLabel, g_value_get_string(value));
break;
case PROP_PASSWORD:
+ /* Update password entry to display new value */
gtk_entry_set_text(GTK_ENTRY(priv->pwd1stEntry), g_value_get_string(value));
break;
case PROP_HILDON_PASSWORD_DIALOG:
+ /* FIXME: UI is not updated to reflect the new state */
priv->protection = g_value_get_boolean(value);
break;
default:
HildonSetPasswordDialogPrivate *priv;
const gchar *string;
+ /* Access private structure */
priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
switch (prop_id) {
case PROP_DOMAIN:
string = gtk_label_get_text(priv->domainLabel);
g_value_set_string(value, string);
+ /* FIXME: break missing */
case PROP_PASSWORD:
string = gtk_entry_get_text(GTK_ENTRY(priv->pwd1stEntry));
g_value_set_string(value, string);
break;
case PROP_HILDON_PASSWORD_DIALOG:
+ /* FIXME: Set the value to itself, i.e. do nothing */
g_value_set_boolean(value, g_value_get_boolean(value));
break;
default:
HildonSetPasswordDialogPrivate *priv;
GtkSizeGroup *group;
+ /* Chain to parent constructor */
parent_class = G_OBJECT_CLASS(g_type_class_peek_parent
(g_type_class_peek(type)));
dialog = parent_class->constructor(type, n_construct_properties,
construct_properties);
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-
priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
-
priv->checkbox = NULL;
+ /* Size group for labels */
group = GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL));
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+ /* Setup and pack domain label */
priv->domainLabel = GTK_LABEL(gtk_label_new(NULL));
-
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
GTK_WIDGET(priv->domainLabel), FALSE, FALSE, 0);
-
gtk_widget_show(GTK_WIDGET(priv->domainLabel));
if (priv->protection == TRUE) {
- /* create checkbox */
+ /* Use Change Password Dialog strings */
priv->pwd1stCaption_string = _(HILDON_SET_MODIFY_PASSWORD_DIALOG_PASSWORD);
priv->pwd2ndCaption_string = _(HILDON_SET_MODIFY_PASSWORD_DIALOG_VERIFY_PASSWORD);
+ /* Setup checkbox to enable/disable password protection */
priv->checkbox = gtk_check_button_new();
-
gtk_widget_show(priv->checkbox);
-
priv->checkboxCaption = hildon_caption_new
(group,
_(HILDON_SET_MODIFY_PASSWORD_DIALOG_LABEL),
priv->checkbox,
NULL, HILDON_CAPTION_OPTIONAL);
hildon_caption_set_separator(HILDON_CAPTION(priv->checkboxCaption), "");
-
gtk_signal_connect(GTK_OBJECT(priv->checkbox), "toggled",
G_CALLBACK(hildon_checbox_toggled), dialog);
-
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
priv->checkboxCaption, TRUE, TRUE, 0);
gtk_widget_show(priv->checkboxCaption);
-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->checkbox),
TRUE);
} else {
+ /* Use Set Password Dialog strings */
priv->pwd1stCaption_string = _(HILDON_SET_PASSWORD_DIALOG_PASSWORD);
priv->pwd2ndCaption_string = _(HILDON_SET_PASSWORD_DIALOG_VERIFY_PASSWORD);
}
-
- /* create tab1 */
+ /* Create the password field */
priv->pwd1stEntry = gtk_entry_new();
gtk_widget_show(priv->pwd1stEntry);
-
priv->pwd1stCaption = hildon_caption_new(group,
priv->pwd1stCaption_string,
priv->pwd1stEntry,
NULL, HILDON_CAPTION_OPTIONAL);
hildon_caption_set_separator(HILDON_CAPTION(priv->pwd1stCaption), "");
-
gtk_entry_set_visibility(GTK_ENTRY(priv->pwd1stEntry), FALSE);
-
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
priv->pwd1stCaption, TRUE, TRUE, 0);
gtk_widget_show(priv->pwd1stCaption);
- /* create tab2 */
+ /* Create the password verify field */
priv->pwd2ndEntry = gtk_entry_new();
gtk_widget_show(priv->pwd2ndEntry);
-
priv->pwd2ndCaption = hildon_caption_new(group,
priv->pwd2ndCaption_string,
priv->pwd2ndEntry,
NULL, HILDON_CAPTION_OPTIONAL);
hildon_caption_set_separator(HILDON_CAPTION(priv->pwd2ndCaption), "");
-
gtk_entry_set_visibility(GTK_ENTRY(priv->pwd2ndEntry), FALSE);
-
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
priv->pwd2ndCaption, TRUE, TRUE, 0);
-
gtk_widget_show(priv->pwd2ndCaption);
+ /* Set dialog title */
gtk_window_set_title(GTK_WINDOW(dialog),
_(priv->protection
? HILDON_SET_MODIFY_PASSWORD_DIALOG_TITLE
gtk_widget_show(priv->okButton);
gtk_widget_show(priv->cancelButton);
+ /* FIXME: Do not leak size group */
return dialog;
}
parent_class = g_type_class_peek_parent(class);
+ /* Override virtual methods */
object_class->set_property = hildon_set_password_set_property;
object_class->get_property = hildon_set_password_get_property;
object_class->constructor = hildon_set_password_dialog_constructor;
-
+ /* Install new properties */
g_object_class_install_property(object_class,
PROP_DOMAIN,
g_param_spec_string ("domain",
"DEFAULT",
G_PARAM_READWRITE));
+ /* Install private structure */
g_type_class_add_private(class,
sizeof(HildonSetPasswordDialogPrivate));
}
-
+/* FIXME: More code from constructor should be moved here.
+ {get,set}_property currently contain weirdnesses that
+ happen because the needed widgets are not created yet. */
static void
hildon_set_password_dialog_init(HildonSetPasswordDialog * dialog)
{
priv->protection = FALSE;
}
+/* We come here when response button is clicked and dialog
+ is used to change existing password. */
static void
hildon_set_password_response_change(GtkDialog * dialog, gint arg1,
GtkWindow * parent)
GtkEntry *pwd2ndEntry;
gchar *text1;
gchar *text2;
-
HildonNote *note;
gint i;
-
HildonSetPasswordDialogPrivate *priv;
priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+ /* Password and verification */
pwd1stEntry = GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(priv->pwd1stCaption)));
-
pwd2ndEntry = GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(priv->pwd2ndCaption)));
-
text1 = GTK_ENTRY(pwd1stEntry)->text;
text2 = GTK_ENTRY(pwd2ndEntry)->text;
+
+ /* User accepted the dialog */
if (arg1 == GTK_RESPONSE_OK){
+ /* Is the checkbox marked, so password protection is still in use? */
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbox))){
+ /* Yes, Something is given as password as well? */
if(strcmp(text1, "" ) != 0){
if(strcmp (text1, text2) == 0){
+ /* Passwords match, so accept change password */
priv->protection = TRUE;
} else if(strcmp(text2, "" ) == 0){
+ /* Second field is empty, so show error, but don't clear fields */
g_signal_stop_emission_by_name(G_OBJECT(dialog),
"response");
gtk_infoprint (NULL,
_(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
gtk_widget_grab_focus(GTK_WIDGET(pwd2ndEntry));
} else{
+ /* Error: Passwords don't match, so start over */
g_signal_stop_emission_by_name(G_OBJECT(dialog),
"response");
gtk_entry_set_text(pwd1stEntry, "");
gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
}
} else {
+ /* No, the password is empty */
g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
if (strcmp(text2, "") == 0) {
+ /* Error: Both fields are empty */
gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_EMPTY));
} else {
+ /* Error: Second field doesn't match
+ the empty first field, so start over */
gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
gtk_entry_set_text(pwd2ndEntry, "");
}
gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
}
} else{
+ /* No, user wants to remove password protection.
+ Confirm remove password protection */
note = HILDON_NOTE(hildon_note_new_confirmation
(GTK_WINDOW(dialog),
_(HILDON_SET_PASSWORD_DIALOG_REMOVE_PROTECTION
_(HILDON_REMOVE_PROTECTION_CONFIRMATION_REMOVE),
_(HILDON_REMOVE_PROTECTION_CONFIRMATION_CANCEL));
+ /* Display confirmation note */
i = gtk_dialog_run(GTK_DIALOG(note));
gtk_widget_destroy(GTK_WIDGET(note));
if (i == GTK_RESPONSE_OK)
+ /* Remove password protection */
priv->protection = FALSE;
else {
+ /* Remove password protection cancelled */
priv->protection = TRUE;
g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
}
}
} else {
+ /* Watch out for fading boolean values */
priv->protection = TRUE;
}
}
+/* We come here when response button is clicked and dialog
+ is used to set new password. */
static void
hildon_set_password_response_set(GtkDialog * dialog, gint arg1,
GtkWindow * parent)
priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+ /* Password and confirmation */
pwd1stEntry = GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(priv->pwd1stCaption)));
-
pwd2ndEntry = GTK_ENTRY(gtk_bin_get_child
(GTK_BIN(priv->pwd2ndCaption)));
-
text1 = GTK_ENTRY(pwd1stEntry)->text;
text2 = GTK_ENTRY(pwd2ndEntry)->text;
if (arg1 == GTK_RESPONSE_OK) {
+ /* User provided something for password? */
if (strcmp (text1, "") != 0) {
if (strcmp (text1, text2) == 0) {
+ /* Passwords match, so accept set password */
priv->protection = TRUE;
} else if (strcmp (text2, "") == 0) {
+ /* Second field is empty, so show error,
+ but don't clear the fields */
g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
gtk_widget_grab_focus (GTK_WIDGET (priv->pwd2ndEntry));
} else {
+ /* Error: Passwords don't match, so start over */
g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
gtk_entry_set_text(pwd1stEntry, "");
gtk_entry_set_text(pwd2ndEntry, "");
gtk_widget_grab_focus(GTK_WIDGET(priv->pwd1stEntry));
}
} else {
- g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
+ /* First field is empty */
+ g_signal_stop_emission_by_name(G_OBJECT(dialog), "response");
if (strcmp(text2, "") == 0) {
+ /* Error: Both fields are empty */
gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_EMPTY));
} else {
+ /* Error: Second field doesn't match
+ the empty first field, so start over */
gtk_infoprint (NULL, _(HILDON_SET_PASSWORD_DIALOG_MISMATCH));
gtk_entry_set_text(pwd2ndEntry, "");
}
gtk_widget_grab_focus(GTK_WIDGET(pwd1stEntry));
}
} else {
+ /* Watch out for fading boolean values */
priv->protection = FALSE;
}
}
dialog = HILDON_SET_PASSWORD_DIALOG(data);
priv = HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
+ /* If the user enabled/disabled the password protection feature
+ we enable/disable password entries accordingly */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd1stEntry), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(priv->pwd2ndEntry), TRUE);
(HILDON_TYPE_SET_PASSWORD_DIALOG, "modify_protection",
modify_protection, NULL);
+ /* Different types of password dialogs use different callbacks */
+ /* FIXME: Why this is done here and not in init/constructor?? */
if (modify_protection == TRUE) {
g_signal_connect(G_OBJECT(dialog), "response",
G_CALLBACK(hildon_set_password_response_change),
{
GtkWidget *dialog;
+ /* FIXME: Change the simpler generator function to call more
+ complex one, so we can avoid additional g_object_set */
dialog = hildon_set_password_dialog_new(parent,
modify_protection);
if(password != NULL)
{
HildonSetPasswordDialogPrivate *priv =
HILDON_SET_PASSWORD_DIALOG_GET_PRIVATE(dialog);
- gtk_label_set_text(priv->domainLabel, domain);
-
+ gtk_label_set_text(priv->domainLabel, domain);
}
*
* This file contains API for Hildon Sort dialog.
* @desc: The sort dialog is used to define the order in which item are
- * shown in a list. Choise lists always display the current value when
+ * shown in a list. Choice lists always display the current value when
* the dialog is opened.
*
*/
#include <hildon-widgets/hildon-defines.h>
#include <hildon-widgets/hildon-time-editor.h>
#include <hildon-widgets/hildon-time-picker.h>
-#include <hildon-widgets/gtk-infoprint.h>
+#include <hildon-widgets/gtk-infoprint.h> /* FIXME: broken include ? */
#include <hildon-widgets/hildon-input-mode-hint.h>
#include "hildon-composite-widget.h"
#include "hildon-date-editor.h"
#define TIME_EDITOR_RBORDER 1
#define TIME_EDITOR_HEIGHT 28
#define TIME_EDITOR_CLOCK_BORDER 6
-#define ENTRY_BORDER 2
+#define ENTRY_BORDER 2
#define ICON_WIDTH 26
#define ICON_HEIGHT 26
#define ICON_PRESSED 4
#define MIN_DURATION 0
#define MAX_DURATION (3600 * 99) + (60 * 59) + 59
+/* Default values for properties */
+/* FIXME: _TIME_LOWER/UPPER_VALUEs aren't really used for anything. */
#define HILDON_TIME_EDITOR_TICKS_VALUE 0
#define HILDON_TIME_EDITOR_SHOW_SECONDS TRUE
#define HILDON_TIME_EDITOR_DURATION_MODE FALSE
#define HOURS_MAX_24 23
#define HOURS_MAX_12 12
-#define HOURS_MIN_24 0
-#define HOURS_MIN_12 1
+#define HOURS_MIN_24 0
+#define HOURS_MIN_12 1
#define MINUTES_MAX 59
#define SECONDS_MAX 59
#define MINUTES_MIN 0
gboolean ampm_pos_after; /* is the am/pm shown after others */
gboolean clock_24h; /* whether to show a 24h clock */
gboolean am; /* TRUE == showing am, FALSE == pm */
- gboolean valid_value; /* If entry has an valid value */
+ gboolean valid_value; /* If entry has an valid value. FIXME: unused */
gboolean validated; /* If the current value has been validated */
/**
* HildonTimeEditor:ticks:
*
- * TimeEditor current duration (or time since midnight) value.
+ * If editor is in duration mode, contains the duration seconds.
+ * If not, contains seconds since midnight.
*/
g_object_class_install_property( object_class, PROP_TICKS,
g_param_spec_uint("ticks",
/**
* HildonTimeEditor:show_seconds:
*
- * TimeEditor show_seconds property.
+ * Controls whether seconds are shown in the editor
*/
g_object_class_install_property( object_class, PROP_SHOW_SECONDS,
g_param_spec_boolean("show_seconds",
/**
* HildonTimeEditor:duration_mode:
*
- * TimeEditor duration mode indicator.
+ * Controls whether the TimeEditor is in duration mode
*/
g_object_class_install_property( object_class, PROP_DURATION_MODE,
g_param_spec_boolean("duration_mode",
/**
* HildonTimeEditor:duration_min:
*
- * TimeEditor minimum duration value.
+ * Minimum allowed duration value.
*/
+ /* FIXME: min/max values should be MIN_DURATION/MAX_DURATION */
g_object_class_install_property( object_class, PROP_DURATION_MIN,
g_param_spec_uint("duration_min",
"Minumum duration value",
/**
* HildonTimeEditor:duration_max:
*
- * TimeEditor maximum duration value.
+ * Maximum allowed duration value.
*/
g_object_class_install_property( object_class, PROP_DURATION_MAX,
g_param_spec_uint("duration_max",
{
HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE(widget);
+ /* Forward this tap_and_hold_setup signal to all our child widgets */
gtk_widget_tap_and_hold_setup(priv->h_entry, menu, func,
GTK_TAP_AND_HOLD_NO_SIGNALS);
gtk_widget_tap_and_hold_setup(priv->m_entry, menu, func,
gtk_widget_push_composite_child();
+ /* Setup defaults and create widgets */
priv->ticks = 0;
priv->show_s = FALSE;
priv->ampm_pos_after = TRUE;
gtk_container_add(GTK_CONTAINER(priv->iconbutton), priv->icon);
gtk_container_add(GTK_CONTAINER(priv->eventbox), priv->ampm);
+ /* No frames for entries, so that they all appear to be inside one
+ long entry */
gtk_entry_set_has_frame(GTK_ENTRY(priv->h_entry), FALSE);
gtk_entry_set_has_frame(GTK_ENTRY(priv->m_entry), FALSE);
gtk_entry_set_has_frame(GTK_ENTRY(priv->s_entry), FALSE);
+ /* Set H:M:S entries to accept only numeric characters */
g_object_set (G_OBJECT(priv->h_entry), "input-mode",
HILDON_INPUT_MODE_HINT_NUMERIC, NULL);
g_object_set (G_OBJECT(priv->m_entry), "input-mode",
G_CALLBACK (hildon_time_editor_entry_changed),
editor);
+ /* Set ourself as the parent of all the widgets we created */
gtk_widget_set_parent(priv->iconbutton, GTK_WIDGET(editor));
gtk_widget_set_parent(priv->label, GTK_WIDGET(editor));
gtk_widget_set_parent(priv->m_entry, GTK_WIDGET(editor));
gtk_widget_set_parent(priv->h_entry, GTK_WIDGET(editor));
+ /* Show created widgets */
gtk_widget_show(priv->h_entry);
gtk_widget_show(priv->m_entry);
gtk_widget_show_all(priv->iconbutton);
gtk_widget_set_parent(priv->frame, GTK_WIDGET(editor));
gtk_widget_show_all(priv->frame);
- /* Check if we are in am/pm time locale */
+ /* Update AM/PM settings from locale */
if (!hildon_time_editor_check_locale(editor)) {
+ /* Using 24h clock */
priv->clock_24h = FALSE;
gtk_widget_show_all(priv->eventbox);
}
- { /* get current time */
+ /* set the default time to current time. */
+ {
time_t tm;
struct tm *stm;
stm = localtime(&tm);
if (stm) {
+ /* convert current time to ticks */
ticks = stm->tm_hour * 3600;
ticks = ticks + stm->tm_min * 60;
ticks = ticks + stm->tm_sec;
hildon_time_editor_set_ticks (editor, ticks);
+ /* H:M:S fields all take exactly two characters */
gtk_entry_set_max_length(GTK_ENTRY(priv->h_entry), 2);
gtk_entry_set_width_chars(GTK_ENTRY(priv->h_entry), 2);
gtk_entry_set_max_length(GTK_ENTRY(priv->m_entry), 2);
gtk_entry_set_max_length(GTK_ENTRY(priv->s_entry), 2);
gtk_entry_set_width_chars(GTK_ENTRY(priv->s_entry), 2);
+ /* Fix appearance */
hildon_time_editor_add_style();
gtk_widget_set_name(GTK_WIDGET(priv->iconbutton),
"hildon-time-editor-icon");
gboolean group_cycling)
{
HildonTimeEditorPrivate *priv = HILDON_TIME_EDITOR_GET_PRIVATE(widget);
+
+ /* Select hour field when mnemonic is activated
+ FIXME: why? Hildon doesn't even support mnemonics */
gtk_widget_grab_focus( priv->h_entry );
gtk_editable_select_region(GTK_EDITABLE(priv->h_entry), 0, 2);
return TRUE;
static void hildon_time_editor_add_style(void)
{
+ /* We want to make time editor appear like it's inside one GtkEntry
+ field. */
gtk_rc_parse_string(" style \"hildon-time-editor-icon\" {"
" GtkButton::default_border = { 0, 0, 0, 0 }"
" xthickness = 0"
" style \"hildon-time-editor-icon\"");
}
+/* Convert ticks to H:M:S. Ticks = seconds since 00:00:00. */
static void ticks_to_time (guint ticks,
guint *hours,
guint *minutes,
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
- /* Validate the value if it is not already validated */
+ /* Validate the value if it is not already validated.
+ FIXME: We're changing the ticks, it can't have been validated yet!
+ This code is currently validating the previously set ticks, which is
+ wrong. */
if (!priv->validated) {
if (priv->duration_mode) {
+ /* Validate duration. If it's too low or too high, set it to
+ min/max value. */
validation = hildon_time_editor_validate_duration (editor, ticks);
switch(validation) {
case VALIDATION_DURATION_MIN:
break;
}
} else {
+ /* Check if given time is in valid range. FIXME: Since we're
+ converting to H:M:S from ticks, only hours can be too large.
+ We're also just duplicating the check from validate_time()
+ here, so the call is pretty much useless. */
ticks_to_time (ticks, &h, &m, &s);
validation = hildon_time_editor_validate_time (editor, h, m, s, TRUE);
switch (validation) {
case VALIDATION_TIME_HOURS:
+ /* ticks value was too large. Set hour to maximum allowed.
+ FIXME: The maximum hour is still 23 here even with 12h
+ clock. The hour is converted to AM/PM value later. */
if (priv->clock_24h) {
if (h > HOURS_MAX_24) {
h = HOURS_MAX_24;
priv->ticks = (3600 * h) + (60 * m) + s;
break;
case VALIDATION_TIME_MINUTES:
+ /* FIXME: we never get here */
if (m > MINUTES_MAX) {
m = MINUTES_MAX;
} else if (m < MINUTES_MIN) {
}
break;
case VALIDATION_TIME_SECONDS:
+ /* FIXME: we never get here */
if (s > SECONDS_MAX) {
s = SECONDS_MAX;
} else if (s < SECONDS_MIN) {
priv->ticks = ticks;
}
+ /* ticks may have been modified, fix H:M:S variables.
+ FIXME: once is enough.. */
ticks_to_time (priv->ticks, &h, &m, &s);
ticks_to_time (priv->ticks, &h, &m, &s);
if (!priv->clock_24h && !priv->duration_mode)
{
+ /* Convert 24h H:M:S values to 12h mode, and update AM/PM state */
convert_to_12h (&h, &m, &s, &priv->am);
}
+ /* Set H:M:S values to entries */
g_snprintf(hours, 3, "%02u", h);
g_snprintf(minutes, 3, "%02u", m);
g_snprintf(seconds, 3, "%02u", s);
priv->valid_value = TRUE;
priv->validated = FALSE;
- /* set current time (am/pm) */
+ /* Update AM/PM label in case we're in 12h mode */
gtk_label_set_label(GTK_LABEL(priv->ampm), priv->am ? priv->am_symbol :
priv->pm_symbol);
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
+ /* show/hide seconds field and its ':' label if the value changed. */
if (!priv->show_s && show_seconds) {
priv->show_s = TRUE;
} else
return;
+ /* Our width changed, do a resize. */
gtk_widget_queue_resize(GTK_WIDGET(editor));
g_object_notify (G_OBJECT (editor), "show_seconds");
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
- /* switch to duration editor mode */
if (duration_mode && !priv->duration_mode) {
+ /* Switch to duration editor mode. */
priv->duration_mode = duration_mode;
+ /* FIXME: Why do we reset the duration range here? */
hildon_time_editor_set_duration_range(editor, MIN_DURATION,
MAX_DURATION);
+ /* There's no AM/PM label or time picker icon in duration mode.
+ Make sure they're hidden. */
if (!priv->clock_24h)
gtk_widget_hide(GTK_WIDGET(priv->ampm));
gtk_widget_hide(GTK_WIDGET(priv->eventbox));
gtk_widget_hide(GTK_WIDGET(priv->icon));
- /* Show seconds for duration editor */
+ /* Duration mode has seconds by default. */
hildon_time_editor_set_show_seconds(editor, TRUE);
}
- /* switch to time editor mode */
else if (!duration_mode && priv->duration_mode) {
+ /* Switch to time editor mode. */
guint ticks;
time_t tm;
struct tm *stm;
-
+
priv->duration_mode = duration_mode;
+ /* Make sure AM/PM label and time picker icons are visible if needed */
if (!priv->clock_24h)
gtk_widget_show(GTK_WIDGET(priv->ampm));
gtk_widget_show(GTK_WIDGET(priv->icon));
- /* Put the ticks to match current time, anything set in the
- * duration mode is bound to be invalid or useless in time mode
+ /* Reset the ticks to current time. Anything set in duration mode
+ * is bound to be invalid or useless in time mode.
*/
tm = time(NULL);
stm = localtime(&tm);
+ /* FIXME: stm is practically always non-NULL. Just do
+ guint ticks = 0 above */
ticks = HILDON_TIME_EDITOR_TIME_LOWER_VALUE;
if (stm) {
hildon_time_editor_set_ticks (editor, ticks);
}
+ /* Our width may have changed, do a resize. */
gtk_widget_queue_resize(GTK_WIDGET(editor));
g_object_notify (G_OBJECT (editor), "duration_mode");
* @seconds: seconds
*
* This function sets the time on an existing time editor. If the
- * time specified by the arguments is invalid, the function returns
- * without doing anything else. The time is assumed to be in 24h format.
+ * time specified by the arguments is invalid, it's fixed.
+ * The time is assumed to be in 24h format.
*
**/
hildon_time_editor_set_duration_min (editor, min_seconds);
if (priv->duration_mode) {
- /* Set minimum allowed value for duration editor */
+ /* Set minimum allowed value for duration editor.
+ FIXME: Shouldn't it be changed only if it's not in range?
+ If not, update the API documentation above. */
hildon_time_editor_set_ticks(editor, min_seconds);
}
}
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
+ /* Update AM/PM symbols */
priv->am_symbol = g_strdup(nl_langinfo(AM_STR));
priv->pm_symbol = g_strdup(nl_langinfo(PM_STR));
if (!strcmp(priv->am_symbol, ""))
return TRUE;
else {
+ /* 12h clock mode. Check if AM/PM should be before or after time.
+ %p is the AM/PM string, so we assume that if the format string
+ begins with %p it's in the beginning, and in any other case it's
+ in the end (although that's not necessarily the case).
+ FIXME: no need to g_strdup() here. */
t_fm = g_strdup(nl_langinfo(T_FMT_AMPM));
- /* Check what format am/pm time should be */
if (!strncmp(t_fm, "%p", 2))
priv->ampm_pos_after = FALSE;
+
+ /* We want to show AM/PM in lowercase. FIXME: leaks memory. */
priv->am_symbol =
g_ascii_strdown((const gchar *) priv->am_symbol, -1);
priv->pm_symbol =
GdkEventFocus * event,
gpointer data)
{
+ /* If we were trying to move away from a field with invalid value,
+ we get moved back to it. Here we want to select the text in the field.
+ The !button check checks that the entry wasn't focused with a mouse
+ click.
+
+ The selection happens temporarily if we got here with left/right
+ keys, but it gets immediately unselected within same call due to some
+ inner entry/clipboard magic. */
if (!GTK_ENTRY(widget)->button)
gtk_editable_select_region(GTK_EDITABLE(widget), 0, 2);
}
+/* Update ticks from current H:M:S entries. If they're invalid, show an
+ infoprint and update the fields unless they're empty. */
void
hildon_time_editor_validate (HildonTimeEditor *editor)
{
/* No empty values thank you */
if (strlen(GTK_ENTRY(priv->h_entry)->text) == 0)
{
+ /* Empty hour field */
if (!priv->duration_mode)
{
if (priv->clock_24h)
_("Ckct_ib_set_a_value_within_range"),
min_hours, max_hours);
}
+ /* FIXME: No point in setting the ticks to current value. */
hildon_time_editor_set_ticks (editor, priv->ticks);
gtk_widget_grab_focus (priv->h_entry);
}
else if (strlen(GTK_ENTRY(priv->m_entry)->text) == 0)
{
+ /* Empty minute field */
if (!priv->duration_mode)
{
gtk_infoprintf(window,
_("Ckct_ib_set_a_value_within_range"),
min_minutes, max_minutes);
}
+ /* FIXME: No point in setting the ticks to current value. */
hildon_time_editor_set_ticks (editor, priv->ticks);
gtk_widget_grab_focus (priv->m_entry);
}
else if (strlen(GTK_ENTRY(priv->s_entry)->text) == 0)
{
+ /* Empty seconds field */
if (!priv->duration_mode)
{
gtk_infoprintf(window,
_("Ckct_ib_set_a_value_within_range"),
min_seconds, max_seconds);
}
+ /* FIXME: No point in setting the ticks to current value. */
hildon_time_editor_set_ticks (editor, priv->ticks);
gtk_widget_grab_focus (priv->s_entry);
}
- /* Do the validation dance! */
else
{
if (priv->duration_mode)
{
+ /* Ensure that duration is in valid range. If it's not, just set
+ it to its min/max value. Too large minute and second values are
+ also just wrapped up. */
validation = hildon_time_editor_validate_duration (editor,
h*3600 + m*60 + s);
}
else
{
+ /* Validate H:M:S values. FIXME: More than one field can be broken,
+ should we update them? Although maybe not needed since focus is
+ moved back to the first broken field, and next validation moves
+ to next field.. */
validation = hildon_time_editor_validate_time (editor, h, m, s, priv->clock_24h);
switch (validation)
{
case VALIDATION_TIME_HOURS:
+ /* At least hour field is too large. */
if (priv->clock_24h)
{
if (h > HOURS_MAX_24)
if (!priv->clock_24h)
convert_to_24h (&h, &m, &s, priv->am);
hildon_time_editor_set_time (editor, h, m, s);
+ /* Move focus back to hour field */
gtk_widget_grab_focus (priv->h_entry);
gtk_editable_select_region(GTK_EDITABLE(priv->h_entry), 0, 2);
break;
if (!priv->clock_24h)
convert_to_24h (&h, &m, &s, priv->am);
hildon_time_editor_set_time (editor, h, m, s);
+ /* Move focus back to minute field */
gtk_widget_grab_focus (priv->m_entry);
gtk_editable_select_region(GTK_EDITABLE(priv->m_entry), 0, 2);
break;
if (!priv->clock_24h)
convert_to_24h (&h, &m, &s, priv->am);
hildon_time_editor_set_time (editor, h, m, s);
+ /* Move focus back to second field */
gtk_widget_grab_focus (priv->s_entry);
gtk_editable_select_region(GTK_EDITABLE(priv->s_entry), 0, 2);
break;
default:
+ /* Given time is valid. */
if (!priv->clock_24h)
{
convert_to_24h (&h, &m, &s, priv->am);
editor = HILDON_TIME_EDITOR(data);
+ /* Validate the given time and update ticks. */
hildon_time_editor_validate (editor);
return FALSE;
editor = HILDON_TIME_EDITOR(data);
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
- /* validate to set the time and get infoprints
- * if the user was editing the value
- */
+ /* First validate the given time and update ticks. */
hildon_time_editor_validate (editor);
+
+ /* Apply the AM/PM change by moving the current time by 12 hours */
if (priv->am) {
if (priv->ticks >= (12*3600))
{
+ /* FIXME: never reached */
hildon_time_editor_set_ticks (editor, priv->ticks - 12*3600);
} else
{
+ /* 00:00 .. 11:59 -> 12:00 .. 23:59 */
hildon_time_editor_set_ticks (editor, priv->ticks + 12*3600);
}
} else {
+ /* 12:00 .. 23:59 -> 00:00 .. 11:59 */
hildon_time_editor_set_ticks (editor, priv->ticks - 12*3600);
}
return FALSE;
if (priv->duration_mode)
return FALSE;
+ /* Launch HildonTimePicker dialog */
parent = gtk_widget_get_ancestor(GTK_WIDGET(editor), GTK_TYPE_WINDOW);
picker = hildon_time_picker_new(GTK_WINDOW(parent));
switch (result) {
case GTK_RESPONSE_OK:
case GTK_RESPONSE_ACCEPT:
+ /* Use the selected time */
hildon_time_picker_get_time(HILDON_TIME_PICKER(picker), &h, &m);
hildon_time_editor_set_time(editor, h, m, 0);
break;
priv = HILDON_TIME_EDITOR_GET_PRIVATE (editor);
/* If the focus has been grabbed back before the "clicked"
- * signal gets processed, don't highlight the text
+ * signal gets processed, don't highlight the text.
+ * This happens when input in one H:M:S field is invalid and we're
+ * trying to move to another field. The focus moves back to the invalid
+ * field.
*/
if (gtk_widget_is_focus (widget))
gtk_editable_select_region(GTK_EDITABLE(widget), 0, 2);
editor = HILDON_TIME_EDITOR(widget);
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
+ /* Call size_request for each of our child widget. We don't use all of
+ the return values. */
gtk_widget_size_request(priv->frame, &req);
+ /* FIXME: next line is useless */
*requisition = req;
+ /* Calculate our width. First reserve some space for borders */
requisition->width = TIME_EDITOR_LBORDER + TIME_EDITOR_RBORDER;
+ /* Add each child widget's width */
gtk_widget_size_request(priv->h_entry, &req);
requisition->width += req.width;
if (priv->iconbutton && GTK_WIDGET_VISIBLE(priv->iconbutton))
{
gtk_widget_size_request(priv->iconbutton, &req);
+ /* Hardcoded icon button size.. */
requisition->width += ICON_WIDTH + ICON_PRESSED +
TIME_EDITOR_CLOCK_BORDER;
}
if (priv->show_s) {
+ /* Add width for seconds entry + label */
gtk_widget_size_request(priv->s_entry, &req);
requisition->width += req.width;
}
if (!priv->clock_24h && !priv->duration_mode) {
+ /* Add width for AM/PM label */
gtk_widget_size_request(priv->eventbox, &req);
requisition->width += req.width + 4;
}
+ /* Hardcoded height.. */
requisition->height = TIME_EDITOR_HEIGHT + widget->style->ythickness * 2;
}
{
GtkRequisition child_requisition;
+ /* Get this widget's wanted width */
gtk_widget_get_child_requisition(widget, &child_requisition);
+ /* allocation = whole time editor's allocation.
+ alloc = allocation for this one child widget. */
if (allocation->width + allocation->x >
alloc->x + child_requisition.width)
+ /* We have enough space */
alloc->width = child_requisition.width;
else {
+ /* Not enough space. Give it as much as there's left. If this isn't
+ the rightmost child widget, the rest get zero width. */
alloc->width = allocation->width - (alloc->x - allocation->x);
if (alloc->width < 0)
alloc->width = 0;
}
+ /* Allocate the widget and update alloc->x to contain the X position
+ for the next child widget. */
gtk_widget_size_allocate(widget, alloc);
alloc->x += alloc->width;
}
widget->allocation = *allocation;
- /*Init start values*/
+ /* Set alloc to contain frame's size and position.
+ Leave ythickness pixels of padding at top and bottom */
alloc.y = widget->allocation.y + widget->style->ythickness;
if (widget->allocation.height > (TIME_EDITOR_HEIGHT +
widget->style->ythickness * 2)) {
+ /* We have more vertical space than needed, move to center */
alloc.height = TIME_EDITOR_HEIGHT;
alloc.y +=
(widget->allocation.height - TIME_EDITOR_HEIGHT) / 2;
alloc.height =
widget->allocation.height - widget->style->ythickness * 2;
+ /* Make sure the height didn't get negative (even padding doesn't fit) */
if (alloc.height < 0)
alloc.height = 0;
+ /* Get the whole widget's wanted width and set our X position */
gtk_widget_get_child_requisition(widget, &child_requisition);
if (allocation->width > child_requisition.width) {
+ /* We have more horizontal space than needed, move to center */
mod_w = (allocation->width - child_requisition.width) / 2;
alloc.x = allocation->x + mod_w;
} else
alloc.x = allocation->x;
- /** frame **/
+ /* FIXME: below check is always true */
if (priv->frame && GTK_WIDGET_VISIBLE(priv->frame))
{
+ /* Frame's width is widget's full width minus the space reserved for
+ time picker icon and borders. */
alloc.width = child_requisition.width -
TIME_EDITOR_CLOCK_BORDER - ICON_WIDTH - ICON_PRESSED;
gtk_widget_size_allocate(priv->frame, &alloc);
}
- /** icon **/
+ /* FIXME: below check is always true (priv->icon may be hidden though) */
if (priv->iconbutton && GTK_WIDGET_VISIBLE(priv->iconbutton)) {
gtk_widget_get_child_requisition(priv->iconbutton,
&child_requisition);
+ /* Place icon button after time fields and some border */
child_alloc.x = alloc.x + alloc.width + TIME_EDITOR_CLOCK_BORDER;
+ /* Make the icon centered vertically */
if(alloc.height > ICON_HEIGHT)
child_alloc.y = alloc.y + (alloc.height - ICON_HEIGHT) / 2 -1;
else
gtk_widget_size_allocate(priv->iconbutton, &child_alloc);
}
- /* allocation of child widgets */
+ /* Allocate widgets appearing inside frame.
+ child_alloc.x keeps the position where the next widget should placed.
+ Widget heights start from a constant, but they change a bit:
+
+ - Labels already add ythickness internally, so we give labels that
+ much more height.
+ - For entries we want ENTRY_BORDER amount of padding at top and bottom.
+ */
child_alloc.x = alloc.x + TIME_EDITOR_LBORDER;
child_alloc.y = alloc.y;
child_alloc.height = TIME_EDITOR_HEIGHT;
child_alloc.width = -1;
- /* am/pm label (when first) */
+ /* Start with AM/PM label when it comes before time */
if (!priv->duration_mode) {
if (!priv->clock_24h && !priv->ampm_pos_after)
{
+ /* FIXME: ythickness modification missing from here */
set_widget_allocation(priv->eventbox, &child_alloc,
&widget->allocation);
}
}
- /* hours */
+ /* FIXME: below check is always true */
if (priv->h_entry && GTK_WIDGET_VISIBLE(priv->h_entry))
{
+ /* Allocate hours entry. */
child_alloc.y += ENTRY_BORDER;
child_alloc.height -= ENTRY_BORDER * 2;
set_widget_allocation(priv->h_entry, &child_alloc,
child_alloc.height += ENTRY_BORDER * 2;
}
- /* first separator label */
+ /* FIXME: below check is always true */
if (priv->label && GTK_WIDGET_VISIBLE(priv->label))
{
- /* We'll have to subtract the ythickness from the labels
- * allocation or it'll be there twice
- */
+ /* Allocate the label between H:M. */
child_alloc.y -= widget->style->ythickness;
set_widget_allocation(priv->label, &child_alloc,
&widget->allocation);
child_alloc.y += widget->style->ythickness;
}
- /* minutes */
+ /* FIXME: below check is always true */
if (priv->m_entry && GTK_WIDGET_VISIBLE(priv->m_entry))
{
- /* Entries have a little different allocation requirements
- * so we'll have to accommodate. This is done per entry
- * so that the "running" width value of the allocation isn't lost
- * FIXME: Rearrange this code so it could be done just once
- */
+ /* Allocate minutes entry. */
child_alloc.y += ENTRY_BORDER;
child_alloc.height -= ENTRY_BORDER * 2;
set_widget_allocation(priv->m_entry, &child_alloc,
}
if (priv->show_s) {
- /* second separator label */
+ /* Seconds are shown */
+ /* FIXME: below check is always true */
if (priv->label2)
{
+ /* Allocate the label between M:S. */
child_alloc.y -= widget->style->ythickness;
set_widget_allocation(priv->label2, &child_alloc,
&widget->allocation);
child_alloc.y += widget->style->ythickness;
}
- /* seconds */
+ /* FIXME: below check is always true */
if (priv->s_entry)
{
+ /* Allocate seconds entry. */
child_alloc.y += ENTRY_BORDER;
child_alloc.height -= ENTRY_BORDER * 2;
set_widget_allocation(priv->s_entry, &child_alloc,
}
}
- /* am/pm label (when last) */
+ /* Finish with AM/PM label when it comes after time */
if (!priv->duration_mode) {
if (!priv->clock_24h && priv->ampm_pos_after)
{
pos = gtk_editable_get_position(GTK_EDITABLE(widget));
if (event->keyval == GDK_Return) {
- /* Check that we have correct values in entries */
+ /* Return key popups up time picker dialog. Visually it looks as if
+ the time picker icon was clicked. Before opening the time picker
+ the fields are first validated and fixed. */
hildon_time_editor_validate (editor);
_gtk_button_set_depressed(GTK_BUTTON(priv->iconbutton), TRUE);
hildon_time_editor_icon_clicked(widget, data);
if (event->keyval == GDK_KP_Enter)
return FALSE;
- /* We don't want wrap */
+ /* Left/right keys may move focus to next/previous entry (see below).
+ Here we're disabling wrapping from leftmost entry to rightmost, and
+ vice versa. FIXME: Just delete this code, and the wrapping handling
+ code from below.. */
if (event->keyval == GDK_KP_Left || event->keyval == GDK_Left) {
if (pos == 0 && widget == priv->h_entry) {
return TRUE;
}
}
- /* numeric key pressed */
+ /* If entry is filled with number hardware key press,
+ validate the entry. */
if (event->keyval >= GDK_0 && event->keyval <= GDK_9) {
GtkWidgetClass *c = GTK_WIDGET_GET_CLASS(widget);
gtk_widget_grab_focus(priv->s_entry);
gtk_editable_set_position(GTK_EDITABLE(priv->s_entry), 0);
} else {
+ /* FIXME: the code is wrapping focus to leftmost entry, but this
+ code path is blocked at the beginning of this function */
gtk_widget_grab_focus(priv->h_entry);
gtk_editable_set_position(GTK_EDITABLE(priv->h_entry), 0);
}
else if (widget == priv->s_entry &&
(event->keyval == GDK_Right || event->keyval == GDK_KP_Right)
&& pos >= GTK_ENTRY(priv->s_entry)->text_length) {
+ /* FIXME: the code is wrapping focus to leftmost entry, but this
+ code path is blocked at the beginning of this function */
gtk_widget_grab_focus(priv->h_entry);
gtk_editable_set_position(GTK_EDITABLE(priv->h_entry), 0);
return TRUE;
else if (widget == priv->h_entry &&
(event->keyval == GDK_Left || event->keyval == GDK_KP_Left) &&
pos <= 0) {
+ /* FIXME: the code is wrapping focus to rightmost entry, but this
+ code path is blocked at the beginning of this function */
if (priv->show_s) {
gtk_widget_grab_focus(priv->s_entry);
gtk_editable_set_position(GTK_EDITABLE(priv->s_entry), -1);
return TRUE;
}
/* pass other arrow key presses and backspace and del onwards */
- else if (event->keyval == GDK_Left || event->keyval == GDK_KP_Left ||
- event->keyval == GDK_Right || event->keyval == GDK_KP_Right ||
- event->keyval == GDK_Up || event->keyval == GDK_KP_Up ||
- event->keyval == GDK_Down || event->keyval == GDK_KP_Down ||
- event->keyval == GDK_BackSpace || event->keyval == GDK_Delete
- || event->keyval == GDK_KP_Delete)
+ else if (event->keyval == GDK_Left ||
+ event->keyval == GDK_KP_Left ||
+ event->keyval == GDK_Right ||
+ event->keyval == GDK_KP_Right ||
+ event->keyval == GDK_Up ||
+ event->keyval == GDK_KP_Up ||
+ event->keyval == GDK_Down ||
+ event->keyval == GDK_KP_Down ||
+ event->keyval == GDK_BackSpace ||
+ event->keyval == GDK_Delete ||
+ event->keyval == GDK_KP_Delete)
return FALSE; /* pass the keypress on */
/* ingore other keys */
return TRUE;
}
+
+/* Returns VALIDATION_OK if ticks is ok,
+ VALIDATION_DURATION_MIN if it's too low,
+ VALIDATION_DURATION_MAX if it's too high. */
static HildonValidation
hildon_time_editor_validate_duration (HildonTimeEditor * editor, guint ticks)
{
return (VALIDATION_OK);
}
-
+/* Returns VALIDATION_OK if given H:M:S values are valid, or
+ VALIDATION_TIME_HOURS,
+ VALIDATION_TIME_MINUTES or
+ VALIDATION_TIME_SECONDS
+ if some of them contain values out of valid range */
static HildonValidation
hildon_time_editor_validate_time (HildonTimeEditor * editor,
guint hours,
priv->validated = FALSE;
+ /* Check that hours are within allowed range (0..12/23) */
if (mode_24h) {
if (hours < HOURS_MIN_24 || hours > HOURS_MAX_24)
return VALIDATION_TIME_HOURS;
return VALIDATION_TIME_HOURS;
}
+ /* Check that minutes are within allowed range (0..59) */
if (minutes < MINUTES_MIN || minutes > MINUTES_MAX)
return VALIDATION_TIME_MINUTES;
+ /* Check that seconds are within allowed range (0..59) */
if (seconds < SECONDS_MIN || seconds > SECONDS_MAX)
return VALIDATION_TIME_SECONDS;
editor = HILDON_TIME_EDITOR(user_data);
+ /* Do nothing. We can't validate it immediately after each change or
+ eg. changing hour in steps 19->29->22 would give errors in 29 step.
+ FIXME: just remove this function. */
/* hildon_time_editor_validate (editor);*/
}
priv = HILDON_TIME_EDITOR_GET_PRIVATE(editor);
+ /* Get duration min/max values as H:M:S. These are only used in
+ duration mode. */
max_hours = priv->duration_max / 3600;
max_minutes = (priv->duration_max - (max_hours * 3600)) / 60;
max_seconds = priv->duration_max - (max_hours * 3600) - (max_minutes * 60);
*/
if (!gtk_widget_is_focus (priv->h_entry))
{
+ /* Hour field isn't focused, use it for getting min/max mins/seconds.
+ If hour isn't exactly the min/max hour value, the M:S fields
+ are 00:00/59:59 */
if ((guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->h_entry))) < max_hours)
{
max_minutes = 59;
}
if (!gtk_widget_is_focus (priv->m_entry))
{
+ /* Minute field isn't focused, use it for getting min/max seconds. */
if ((guint) atoi(gtk_entry_get_text(GTK_ENTRY(priv->m_entry))) < max_minutes)
{
max_seconds = 59;
static void
convert_to_12h (guint *h, guint *m, guint *s, gboolean *am)
{
- /* 0000 to 0059
- * add 12 hours
- */
- if (*h == 0)
+ if (*h == 0) /* 00:00 to 00:59 add 12 hours */
{
*h += 12;
*am = TRUE;
}
- /* 0100 to 1159
- * straight to am
- */
- else if (*h >= 1 && *h < 12)
+ else if (*h >= 1 && *h < 12) /* 01:00 to 11:59 straight to am */
{
*am = TRUE;
}
- /* 1200 to 1259
- * straight to pm
- */
- else if (*h >= 12 && *h < 13)
+ else if (*h >= 12 && *h < 13) /* 12:00 to 12:59 straight to pm */
{
*am = FALSE;
}
- /* 1300 to 23:59
- * subtract 12 hours
- */
- else if (*h >= 13 && *h < 24 )
+ else if (*h >= 13 && *h < 24 ) /* 13:00 to 23:59 subtract 12 hours */
{
*h -= 12;
*am = FALSE;
static void
convert_to_24h (guint *h, guint *m, guint *s, gboolean am)
{
- /* 12 midnight - 12:59 AM
- * subtract 12 hours
- */
- if (*h == 12 && am)
+ if (*h == 12 && am) /* 12 midnight - 12:59 AM subtract 12 hours */
{
*h -= 12;
}
- /* 1:00 PM - 11:59 AM
- * add 12 hours
- */
- else if (!am && *h >= 1 && *h < 12)
+ else if (!am && *h >= 1 && *h < 12) /* 1:00 PM - 11:59 AM add 12 hours */
{
*h += 12;
}
gchar *pm_symbol;
guint key_repeat;
- guint minutes;
+ guint minutes; /* time in minutes since midnight */
gint mul;
guint timer_id;
enum
{
PROP_MINUTES = 1,
- PROP_AMPM
+ PROP_AMPM /* FIXME: unused */
};
/**
* HildonTimePicker:minutes:
*
- * Currently selected minutes.
+ * Currently selected time in minutes since midnight.
*/
g_object_class_install_property( gobject_class, PROP_MINUTES,
g_param_spec_uint("minutes",
"Current minutes",
- "The selected minutes",
+ "The selected time in minutes "
+ "since midnight",
0, 1440, 0,
G_PARAM_READABLE | G_PARAM_WRITABLE) );
gtk_widget_push_composite_child();
+ /* Pack all our internal widgets into a table */
priv->child[TABLE] = gtk_table_new( 3, 6, FALSE );
table = GTK_TABLE(priv->child[TABLE]);
+ /* Put everything centered into window */
maintocenter = gtk_alignment_new( 0.5, 0, 0, 0 );
+ /* Create our internal widgets */
for( i = FRAME_HOURS; i <= FRAME_LMINUTES; i++ )
{
priv->child[i] = gtk_frame_new( NULL );
for( i = LABEL_HOURS; i <= LABEL_LMINUTES; i++ )
{
+ /* minute fields are "0" initially */
priv->child[i] = gtk_label_new( "0" );
+ /* Add 1 pixel of padding on top and bottom of labels */
gtk_misc_set_padding( GTK_MISC( priv->child[i] ), 0, 1 );
gtk_widget_set_name( priv->child[i], "osso-LargeFont" );
}
+ /* Hour field defaults to "00" */
gtk_label_set_text (GTK_LABEL (priv->child[LABEL_HOURS]), "00");
+ /* Label between hour and minutes */
priv->child[LABEL_COLON] = gtk_label_new(_("Ecdg_ti_time_picker_separator"));
gtk_widget_set_name( priv->child[LABEL_COLON], "osso-LargeFont" );
priv->timer_id = 0;
priv->button_press = FALSE;
- /* Load locales */
+ /* Get AM/PM strings from locale. If they're set, the time is wanted
+ in 12 hour mode. */
priv->am_symbol = nl_langinfo(AM_STR);
priv->pm_symbol = nl_langinfo(PM_STR);
priv->c12h = priv->am_symbol[0] == '\0' ? FALSE : TRUE;
+ /* Get current time for initializing fields */
stamp = time( NULL );
local = localtime( &stamp );
- gtk_table_attach( table, priv->child[BUTTON_HOURS_UP], 1, 2, 0, 1,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[FRAME_HOURS], 1, 2, 1, 2,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[BUTTON_HOURS_DOWN], 1, 2, 2, 3,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[LABEL_COLON], 2, 3, 1, 2,
- GTK_SHRINK, GTK_SHRINK, 6, 0 );
- gtk_table_attach( table, priv->child[BUTTON_MMINUTES_UP], 3, 4, 0, 1,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[FRAME_MMINUTES], 3, 4, 1, 2,
- GTK_FILL, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[BUTTON_MMINUTES_DOWN], 3, 4, 2, 3,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
-
- gtk_table_attach( table, priv->child[BUTTON_LMINUTES_UP], 4, 5, 0, 1,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[FRAME_LMINUTES], 4, 5, 1, 2,
- GTK_FILL, GTK_SHRINK, 0, 0 );
- gtk_table_attach( table, priv->child[BUTTON_LMINUTES_DOWN], 4, 5, 2, 3,
- GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ /* Pack widgets into table */
+ gtk_table_attach( table, priv->child[BUTTON_HOURS_UP], 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[FRAME_HOURS], 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[BUTTON_HOURS_DOWN], 1, 2, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[LABEL_COLON], 2, 3, 1, 2, GTK_SHRINK, GTK_SHRINK, 6, 0 );
+ gtk_table_attach( table, priv->child[BUTTON_MMINUTES_UP], 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[FRAME_MMINUTES], 3, 4, 1, 2, GTK_FILL, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[BUTTON_MMINUTES_DOWN], 3, 4, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[BUTTON_LMINUTES_UP], 4, 5, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[FRAME_LMINUTES], 4, 5, 1, 2, GTK_FILL, GTK_SHRINK, 0, 0 );
+ gtk_table_attach( table, priv->child[BUTTON_LMINUTES_DOWN], 4, 5, 2, 3, GTK_SHRINK, GTK_SHRINK, 0, 0 );
gtk_table_set_row_spacing( table, 0, 6 );
gtk_table_set_row_spacing( table, 1, 6 );
+ /* Put minute labels and buttons into same size group, so they each have
+ the exact same horizontal width. */
size_group = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL );
gtk_size_group_add_widget( size_group, priv->child[BUTTON_MMINUTES_UP] );
gtk_size_group_add_widget( size_group, priv->child[FRAME_MMINUTES] );
{
GtkWidget *ampmtotop = NULL;
guint placement = 0;
+
+ /* 12h clock mode. Check if AM/PM should be before or after time.
+ %p is the AM/PM string, so we assume that if the format string
+ begins with %p it's in the beginning, and in any other case it's
+ in the end (although that's not necessarily the case). */
priv->ampm_pos = strncmp(nl_langinfo(T_FMT_AMPM), "%p", 2) ? TRUE : FALSE;
+ /* Show the AM/PM label centered vertically */
ampmtotop = gtk_alignment_new( 0, 0.5, 0, 0 );
priv->child[FRAME_AMPM] = gtk_frame_new( NULL );
priv->child[EBOX_AMPM] = gtk_event_box_new();
priv->child[LABEL_AMPM] = gtk_label_new( priv->pm_symbol );
+ /* Pack AM/PM widgets. If AM/PM is before time, pack them into table
+ position 0..1. If it's after time, pack to 5..6 */
placement = priv->ampm_pos * 5;
gtk_container_add( GTK_CONTAINER(ampmtotop), priv->child[FRAME_AMPM] );
GTK_SHRINK, GTK_SHRINK, 0, 0 );
gtk_table_set_col_spacing( table, placement - 1, 6 );
+ /* Connect AM/PM signal handlers */
g_signal_connect( G_OBJECT(priv->child[EBOX_AMPM]), "button-release-event",
(GCallback)hildon_time_picker_ampm_release, picker );
g_signal_connect( G_OBJECT(priv->child[EBOX_AMPM]), "focus-out-event",
(GCallback)hildon_time_picker_event_box_key_press,
picker );
+ /* Set AM/PM evenbox focusable */
g_object_set( G_OBJECT(priv->child[EBOX_AMPM]), "can-focus", TRUE, NULL );
gtk_widget_set_events( priv->child[EBOX_AMPM],
GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_PRESS_MASK );
gtk_widget_pop_composite_child();
+ /* Set default time to current time */
hildon_time_picker_set_time( picker, local->tm_hour, local->tm_min );
+ /* 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 );
+ /* Handle hour and minute fields */
for( i = 0; i < 3; i++ )
{
gtk_container_add( GTK_CONTAINER(priv->child[FRAME_HOURS + i]),
"hildon-time-picker-down" );
}
+ /* Handle hour/minute up/down buttons */
for( i = BUTTON_HOURS_UP; i <= BUTTON_LMINUTES_DOWN; i++ )
{
g_object_set( G_OBJECT(priv->child[i]), "can-focus", FALSE, NULL );
(GCallback)hildon_time_picker_arrow_release, picker );
}
+ /* Handle hour/minute eventboxes */
for( i = EBOX_HOURS; i <= EBOX_LMINUTES; i++ )
{
g_object_set( G_OBJECT(priv->child[i]), "can-focus", TRUE, NULL );
GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_PRESS_MASK );
}
+ /* This dialog isn't modal */
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"),
GTK_RESPONSE_OK );
gtk_container_add( GTK_CONTAINER(maintocenter), priv->child[TABLE] );
gtk_box_pack_start( GTK_BOX(dialog->vbox), maintocenter, TRUE, FALSE, 0 );
+ /* FIXME: no point in setting the time to its current value */
hildon_time_picker_change_time (picker, priv->minutes);
gtk_widget_show_all( maintocenter );
gint i;
HildonTimePickerPrivate *priv = HILDON_TIME_PICKER(widget)->priv;
+ /* Widget is now mapped. Set border for the dialog. */
gdk_window_set_decorations( widget->window, GDK_DECOR_BORDER );
+ /* Update hour/minute up/down buttons sizes from style properties */
gtk_widget_style_get( widget,
"arrow-width", &width,
"arrow-height", &height, NULL );
hildon_time_picker_event_box_press( GtkWidget *widget, GdkEventKey *event,
gpointer data )
{
+ /* Clicked hour/minute field. Move focus to it. */
gtk_widget_grab_focus( widget );
return FALSE;
}
hildon_time_picker_ampm_release( GtkWidget *widget, GdkEvent *event,
HildonTimePicker *picker )
{
+ /* Clicked AM/PM label. Move focus to it and move the time by 12 hours. */
gtk_widget_grab_focus( widget );
hildon_time_picker_change_time( picker, picker->priv->minutes > 720 ?
picker->priv->minutes - 720 :
HildonTimePickerPrivate *priv = picker->priv;
gint newval = 0;
+ /* Make sure we don't add repeat timer twice. Normally it shouldn't
+ happen but WM can cause button release to be lost. */
if( priv->button_press )
return FALSE;
priv->start_key_repeat = priv->button_press = TRUE;
+ /* Move the focus to field whose arrow was clicked, and get the minute
+ change multiplier. */
if( widget == priv->child[BUTTON_HOURS_UP] )
{
priv->mul = 60;
gtk_widget_grab_focus( priv->child[EBOX_LMINUTES] );
}
+ /* Change the time now, wrapping if needed. */
newval = priv->minutes + priv->mul;
if( newval < 0 )
newval += 1440;
hildon_time_picker_change_time( picker, newval );
+ /* 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, hildon_time_picker_timeout, picker );
return FALSE;
}
HildonTimePickerPrivate *priv = picker->priv;
if( priv->timer_id )
{
+ /* Stop repeat timer */
g_source_remove( priv->timer_id );
priv->timer_id = 0;
}
hildon_time_picker_event_box_focus_in( GtkWidget *widget, GdkEvent *event,
gpointer data )
{
+ /* Draw the widget in selected state so focus shows clearly. */
gtk_widget_set_state( widget, GTK_STATE_SELECTED );
return FALSE;
}
hildon_time_picker_event_box_focus_out( GtkWidget *widget, GdkEvent *event,
gpointer data )
{
+ /* Draw the widget in normal state */
gtk_widget_set_state( widget, GTK_STATE_NORMAL );
return FALSE;
}
{
HildonTimePickerPrivate *priv = picker->priv;
+ /* If mouse button is already being pressed, ignore this keypress */
if( priv->timer_id )
return TRUE;
+ /* Handle keypresses in hour/minute/AMPM fields */
switch( event->keyval )
{
case GDK_Up:
if( widget == priv->child[EBOX_HOURS] )
{
+ /* Fake a hour button up press */
hildon_time_picker_arrow_press( priv->child[BUTTON_HOURS_UP], NULL,
picker );
gtk_widget_set_state( priv->child[BUTTON_HOURS_UP], GTK_STATE_SELECTED );
}
else if( widget == priv->child[EBOX_MMINUTES] )
{
+ /* Fake a 10-minute button up press */
hildon_time_picker_arrow_press( priv->child[BUTTON_MMINUTES_UP], NULL,
picker );
gtk_widget_set_state( priv->child[BUTTON_MMINUTES_UP],
}
else if( widget == priv->child[EBOX_LMINUTES] )
{
+ /* Fake a minute button up press */
hildon_time_picker_arrow_press( priv->child[BUTTON_LMINUTES_UP], NULL,
picker );
gtk_widget_set_state( priv->child[BUTTON_LMINUTES_UP],
GTK_STATE_SELECTED );
}
else
+ /* Fake a AM/PM button release */
hildon_time_picker_ampm_release( priv->child[EBOX_AMPM], NULL, picker );
return TRUE;
case GDK_Down:
if( widget == priv->child[EBOX_HOURS] )
{
+ /* Fake a hour button down press */
hildon_time_picker_arrow_press( priv->child[BUTTON_HOURS_DOWN], NULL,
picker );
gtk_widget_set_state( priv->child[BUTTON_HOURS_DOWN],
}
else if( widget == priv->child[EBOX_MMINUTES] )
{
+ /* Fake a 10-minute button down press */
hildon_time_picker_arrow_press( priv->child[BUTTON_MMINUTES_DOWN], NULL,
picker );
gtk_widget_set_state( priv->child[BUTTON_MMINUTES_DOWN],
}
else if( widget == priv->child[EBOX_LMINUTES] )
{
+ /* Fake a minute button down press */
hildon_time_picker_arrow_press( priv->child[BUTTON_LMINUTES_DOWN], NULL,
picker );
gtk_widget_set_state( priv->child[BUTTON_LMINUTES_DOWN],
GTK_STATE_SELECTED );
}
else
+ /* Fake a AM/PM button release */
hildon_time_picker_ampm_release( priv->child[EBOX_AMPM], NULL, picker );
return TRUE;
case GDK_Left:
+ /* If we're in leftmost field, stop this keypress signal.
+ Otherwise let the default key handler move focus to field in left. */
if( priv->c12h )
{
if( !priv->ampm_pos )
break;
case GDK_Right:
+ /* If we're in rightmost field, stop this keypress signal.
+ Otherwise let the default key handler move focus to field in right. */
if( priv->c12h )
{
if( priv->ampm_pos )
{
gint i;
+ /* Fake a button release if in key-press handler we faked a button press. */
switch( event->keyval )
{
case GDK_Up:
return FALSE;
}
+/* Button up/down is being pressed. Update the time. */
static gboolean
-hildon_time_picker_timeout( gpointer data )
+hildon_time_picker_timeout( gpointer data )/* FIXME: use meaningful name */
{
HildonTimePicker *picker = NULL;
HildonTimePickerPrivate *priv = NULL;
gint newval = 0;
+ /* FIXME: the following condition never occurs */
+ /* luc: function should check its parameters. Otherwise document the use of the function "parameter must not be NULL". */
if( !data )
return FALSE;
picker = HILDON_TIME_PICKER(data);
priv = picker->priv;
+ /* FIXME: the following condition never occurs */
if( !picker->priv->timer_id )
return FALSE;
+ /* Change the time, wrapping if needed */
newval = priv->minutes + priv->mul;
if( newval < 0 )
- newval += 1440;
+ newval += 1440;/*FIXME: document, or use 24*60 if this is the case */
hildon_time_picker_change_time( picker, newval );
if( priv->start_key_repeat )
{
+ /* 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, hildon_time_picker_timeout, picker );
priv->start_key_repeat = FALSE;
return FALSE;
guint hours = 0;
gboolean ampm = TRUE;
+ /* If the minutes isn't in valid range, wrap them. */
minutes %= 1440;
if( priv->minutes == minutes )
return;
+ /* Minutes changed. Update widgets to show the new time. */
priv->minutes = minutes;
if( priv->c12h )
{
+ /* am < 12:00 (720 minutes) <= pm */
ampm = !((guint)(minutes / 720));
+ /* 12:00 - 23:59 -> 00:00 - 11:59 */
minutes %= 720;
if( minutes < 60 )
+ /* 00:mm is always shown as 12:mm */
minutes += 720;
+ /* Update the AM/PM label */
gtk_label_set_text( GTK_LABEL(priv->child[LABEL_AMPM]),
ampm ? priv->am_symbol : priv->pm_symbol );
}
+ /* Update hour and minute fields */
hours = minutes / 60;
minutes %= 60;
struct _HildonVolumebarPrivate {
HildonVolumebarRange *volumebar;
- GtkOrientation orientation;
- GtkOrientation ownorientation;
+ GtkOrientation orientation; /* Orientation of range *//* FIXME: XXX This isn't needed */
+ GtkOrientation ownorientation;/* Orientation of widget *//* FIXME: XXX This isn't needed */
+
GtkToggleButton *tbutton;
- gboolean is_toolbar;
+ gboolean is_toolbar;/* Is inside toolbar (for horizontal volumebar) */
};
#endif /* __HILDON_VOLUMEBAR_PRIVATE__ */
*
* Purpose of this widget is to act as an "container" for GtkScale
* widget. #HildonVolumebarRange changes some event parameters so
- * that #HildonVolumebar can meet it's specifications.
+ * that #HildonVolumebar can meet its specifications.
*
* Currently #HildonVolumebarRange models range of [0..100].
*
static void
hildon_volumebar_range_init(HildonVolumebarRange * volumerange)
{
-
+ /* stepper_a = "less", stepper_d = "more" */
GTK_RANGE(volumerange)->has_stepper_a = TRUE;
GTK_RANGE(volumerange)->has_stepper_d = TRUE;
gboolean hildon_volumebar_range_keypress(GtkWidget * widget,
GdkEventKey * event)
{
+ /* Accept arrow keys only if they match the orientation of the widget */
if (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (event->keyval == GDK_Up || event->keyval == GDK_Down) {
GTK_RANGE(self)->orientation = orientation;
- /* invert vertical range */
+ /* Default vertical range is upside down for purposes of this widget */
gtk_range_set_inverted(GTK_RANGE(self),
(orientation == GTK_ORIENTATION_VERTICAL));
{
gboolean result = FALSE;
- event->button = event->button == 1 ? 2 : event->button;
+ /* FIXME: Ugly hack to trick GtkRange event handler */
+ event->button = (event->button == 1) ? 2 : event->button;
if (GTK_WIDGET_CLASS(parent_class)->button_press_event) {
result =
GTK_WIDGET_CLASS(parent_class)->button_press_event(widget,
{
gboolean result = FALSE;
+ /* FIXME: Ugly hack to trick GtkRange event handler */
event->button = event->button == 1 ? 2 : event->button;
if (GTK_WIDGET_CLASS(parent_class)->button_release_event) {
result =
GtkContainer */
GTK_WIDGET_SET_FLAGS(GTK_WIDGET(volumebar), GTK_NO_WINDOW);
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(volumebar), GTK_CAN_FOCUS);
-
+
+ /* Initialize mute button */
priv->tbutton = GTK_TOGGLE_BUTTON(gtk_toggle_button_new());
g_object_set (G_OBJECT (priv->tbutton), "can-focus", FALSE, NULL);
}
g_return_if_fail(callback != NULL);
+ /* No external children */
if (!include_internals)
return;
+ /* Execute callback for both internals */
(*callback) (GTK_WIDGET(priv->tbutton), callback_data);
(*callback) (GTK_WIDGET(priv->volumebar), callback_data);
}
switch (prop_id) {
case PROP_HILDON_HAS_MUTE:
+ /* Mute button always exists, but might be hidden */
if (g_value_get_boolean(value))
gtk_widget_show(GTK_WIDGET(priv->tbutton));
else
priv = HILDON_VOLUMEBAR_GET_PRIVATE(self);
- /* No need to clamp the level to legal values here as volumebarrange
- * will do it anyway. And here we don't know the correct values anyway.
- */
hildon_volumebar_range_set_level(priv->volumebar, level);
}
*
* Gets the volumelevel of this #HildonVolumebar.
*
- * Return value: Volume level.
+ * Return value: Volume level or -1 on error.
**/
gdouble
hildon_volumebar_get_level(HildonVolumebar * self)
g_return_if_fail(self);
priv = HILDON_VOLUMEBAR_GET_PRIVATE(self);
+
+ /* Slider should be insensitive when mute is on */
gtk_widget_set_sensitive(GTK_WIDGET(priv->volumebar), !mute);
focusable = GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (priv->volumebar));
if (mute){
if (focusable){
-
+ /* Make mute button focusable since the slider isn't anymore */
g_object_set (G_OBJECT (priv->tbutton), "can-focus", TRUE, NULL);
gtk_widget_grab_focus (GTK_WIDGET(priv->tbutton));
}
{
g_object_set (G_OBJECT (priv->tbutton), "can-focus", FALSE, NULL);
+ /* Mute off grabs focus */
if (focusable){
gtk_widget_grab_focus (GTK_WIDGET (self));
}
else{
+ /* If volumebar is not focusable, focus the parent window instead */
GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (self),
GTK_TYPE_WINDOW);
gtk_window_set_focus (GTK_WINDOW (win), NULL);
}
}
+ /* Update mute button state and redraw */
gtk_toggle_button_set_active(priv->tbutton, mute);
gtk_widget_queue_draw (GTK_WIDGET (self));
static void
mute_toggled (HildonVolumebar *self)
{
- /* only call hildon_volumebar_set_mute. everything is done there */
hildon_volumebar_set_mute (self, hildon_volumebar_get_mute(self));
}
g_return_val_if_fail(event, FALSE);
priv = HILDON_VOLUMEBAR_GET_PRIVATE(widget);
-
+
+ /* Enter key toggles mute button (unless it is hidden) */
if (event->keyval == GDK_Return && GTK_WIDGET_VISIBLE(priv->tbutton)) {
gtk_toggle_button_set_active(priv->tbutton,
!hildon_volumebar_get_mute(HILDON_VOLUMEBAR(widget)));
#include "hildon-volumebar-range.h"
#include "hildon-volumebar-private.h"
+/* Volume bar */
#define DEFAULT_BAR_WIDTH 58
#define MINIMUM_BAR_HEIGHT 165
+/* Toggle button */
#define DEFAULT_VERTICAL_TBUTTON_WIDTH 26
#define DEFAULT_VERTICAL_TBUTTON_HEIGHT 26
#define DEFAULT_ENDING_SIZE 20
+/* Gap to leave for mute button */
#define HORIZONTAL_MUTE_GAP 16
#define VERTICAL_MUTE_GAP 6
vvolumebar);
g_signal_connect(G_OBJECT(priv->tbutton), "toggled",
G_CALLBACK(hildon_vvolumebar_mute), vvolumebar);
- /* end here */
gtk_widget_show(GTK_WIDGET(priv->volumebar));
}
priv = HILDON_VOLUMEBAR_GET_PRIVATE(HILDON_VOLUMEBAR(widget));
if (GTK_WIDGET_DRAWABLE(widget)) {
+ /* Paint background */
gtk_paint_box(widget->style, widget->window,
GTK_WIDGET_STATE(priv->volumebar), GTK_SHADOW_OUT,
NULL, widget, "background",
widget->allocation.width,
widget->allocation.height);
+ /* The contents of the widget can paint themselves */
(*GTK_WIDGET_CLASS(parent_class)->expose_event) (widget, event);
}
vbar = HILDON_VOLUMEBAR(widget);
priv = HILDON_VOLUMEBAR_GET_PRIVATE(vbar);
+ /* Center the widget horizontally */
if (allocation->width > DEFAULT_BAR_WIDTH) {
allocation->x +=
(allocation->width - DEFAULT_BAR_WIDTH) / 2;
widget->allocation = *allocation;
if (priv->volumebar && GTK_WIDGET_VISIBLE(priv->volumebar)) {
+ /* Allocate space for the slider */
range_allocation.x = allocation->x;
range_allocation.y = allocation->y + DEFAULT_ENDING_SIZE;
if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton))
{
+ /* Leave room for the mute button */
range_allocation.height = MAX(0,
allocation->height
- 2 * DEFAULT_ENDING_SIZE
}
if (priv->tbutton && GTK_WIDGET_VISIBLE(priv->tbutton)) {
+ /* Allocate space for the mute button */
button_allocation.x = allocation->x + HORIZONTAL_MUTE_GAP;
button_allocation.y = allocation->y + allocation->height -
VERTICAL_MUTE_GAP - 2 * DEFAULT_ENDING_SIZE;
*
*/
-/*
- * TODO:
- * - Must check if graphics should be added to widgets weekday
- * buttons
- *
- */
-
-/* HILDON DOC
- * @shortdesc: Weekday Picker is a widget for selecting weekdays
- * @longdesc: Weekday Picker is a widget for selecting weekdays.
- * It shows seven toggle buttons that can have state on or off.
- *
- * @seealso: #HildonTimePicker
- */
-
/* GDate numbers days from 1 to 7 and G_DATE_MONDAY is 1st day. However
according to locale settings first day is sunday. To get around this
problem, we addjust GDate days numbering to be same as locale
static void
hildon_weekday_picker_class_init(HildonWeekdayPickerClass * picker_class);
-
static void
hildon_weekday_picker_init(HildonWeekdayPicker * picker);
-
static void
hildon_weekday_picker_size_allocate(GtkWidget * widget,
GtkAllocation * allocation);
-
static void
hildon_weekday_picker_size_request(GtkWidget * widget,
GtkRequisition * requisition);
-
static void
hildon_weekday_picker_forall(GtkContainer * container,
gboolean include_internals,
GtkCallback callback, gpointer callback_data);
-
static void
hildon_weekday_picker_destroy(GtkObject * self);
-
static gboolean
hildon_weekday_picker_mnemonic_activate(GtkWidget *widget,
gboolean group_cycling);
-
static void
button_toggle(GtkToggleButton * togglebutton, gpointer data);
g_type_class_add_private(picker_class,
sizeof(HildonWeekdayPickerPrivate));
+ /* Override virtual methods */
widget_class->mnemonic_activate = hildon_weekday_picker_mnemonic_activate;
widget_class->size_request = hildon_weekday_picker_size_request;
widget_class->size_allocate = hildon_weekday_picker_size_allocate;
GTK_OBJECT_CLASS(picker_class)->destroy =
hildon_weekday_picker_destroy;
+ /* Create a signal for reporting user actions */
signals[SELECTION_CHANGED_SIGNAL] = g_signal_new("selection_changed",
G_OBJECT_CLASS_TYPE
(object_class),
/* Check our first weekday */
day = *nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
+ /* Use localized short names for weekdays */
wdays[1] = nl_langinfo(ABDAY_1);
wdays[2] = nl_langinfo(ABDAY_2);
wdays[3] = nl_langinfo(ABDAY_3);
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* Initialize and pack day buttons */
for (i = 1; i <= 7; i++) {
priv->buttons[i] = gtk_toggle_button_new_with_label(wdays[day]);
priv->dayorder[i] = day++;
}
GTK_WIDGET_SET_FLAGS(picker, GTK_NO_WINDOW);
+
+ /* FIXME: Do not leak sizegroup */
}
/**
return g_object_new(HILDON_WEEKDAY_PICKER_TYPE, NULL);
}
+/* FIXME: mnemonic actionvation is no longer used by hildon libraries */
static gboolean
hildon_weekday_picker_mnemonic_activate(GtkWidget *widget,
gboolean group_cycling)
picker = HILDON_WEEKDAY_PICKER(container);
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* We only have internal children */
if (!include_internals)
return;
+ /* Activate callback for each day button */
for (i = 1; i <= 7; ++i) {
(*callback) (priv->buttons[i], callback_data);
}
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(self);
+ /* Destroy internal children... */
for (i = 1; i <= 7; ++i) {
if (priv->buttons[i])
{
}
}
+ /* ... and chain to parent. */
if (GTK_OBJECT_CLASS(parent_class)->destroy)
GTK_OBJECT_CLASS(parent_class)->destroy(self);
requisition->width = 0;
requisition->height = 0;
+ /* Request an area that is as wide as all of the buttons
+ together and tall enough to hold heightest button */
for (i = 1; i <= 7; ++i) {
gtk_widget_size_request(priv->buttons[i], &req);
requisition->width += req.width;
sval = 1;
else
sval = 7;
+
+ /* Allocate day buttons side by side honouring the text direction */
for (i = 1; i <= 7; ++i) {
gtk_widget_get_child_requisition(priv->buttons[sval],
&child_requisition);
}
}
+/* FIXME: rewrite this */
static void
button_toggle(GtkToggleButton * button, gpointer data)
{
picker = HILDON_WEEKDAY_PICKER(data);
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* FIXME: this is just copy paste from several other places */
for (i = 1; i <= 7; ++i) {
if (GTK_WIDGET(button) == priv->buttons[i]) {
priv->days ^= wdays[i];
/**
* hildon_weekday_picker_set_day:
* @picker: the @HildonWeekdayPicker widget
- * @day: Day to be set
+ * @day: Day to be set active
*
- * Select specified weekday.
+ * Set specified weekday active.
*/
void
hildon_weekday_picker_set_day(HildonWeekdayPicker * picker,
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* Adjust between GDate and locale (shift one day),
+ FIXME: would be more elegant to use GDate as internal representation */
if (day == G_DATE_SUNDAY)
day = G_DATE_MONDAY;
else
day++;
+ /* FIXME: this is just copy paste from several other places
+ the above also! */
for (i = 1; i <= 7; i++) {
if (priv->dayorder[i] == day) {
if (!(priv->days & wdays[i]))
/**
* hildon_weekday_picker_unset_day:
* @picker: the @HildonWeekdayPicker widget
- * @day: Day to be unset
+ * @day: Day to be set inactive
*
- * Unselect specified weekday.
+ * Set specified weekday inactive.
*/
void
hildon_weekday_picker_unset_day(HildonWeekdayPicker * picker,
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* Adjust between GDate and locale (shift one day),
+ FIXME: would be more elegant to use GDate as internal representation */
if (day == G_DATE_SUNDAY)
day = G_DATE_MONDAY;
else
day++;
+ /* FIXME: this is just copy paste from several other places
+ the above also! */
for (i = 1; i <= 7; i++) {
if (priv->dayorder[i] == day) {
if (priv->days & wdays[i])
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* Adjust between GDate and locale (shift one day),
+ FIXME: would be more elegant to use GDate as internal representation */
if (day == G_DATE_SUNDAY)
day = G_DATE_MONDAY;
else
day++;
+ /* FIXME: this is just copy paste from several other places
+ the above also! */
for (i = 1; i <= 7; i++) {
if (priv->dayorder[i] == day) {
is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
* hildon_weekday_picker_set_all:
* @picker: the @HildonWeekdayPicker widget
*
- * Set all weekdays.
+ * Set all weekdays active.
*/
void
hildon_weekday_picker_set_all(HildonWeekdayPicker * picker)
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* FIXME: this is just copy paste from several other places */
for (i = 1; i <= 7; i++) {
if (!(priv->days & wdays[i]))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
* hildon_weekday_picker_unset_all:
* @picker: the @HildonWeekdayPicker widget
*
- * Unset all weekdays.
+ * Set all weekdays inactive.
*/
void
hildon_weekday_picker_unset_all(HildonWeekdayPicker * picker)
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* FIXME: this is just copy paste from several other places */
for (i = 1; i <= 7; i++) {
if (priv->days & wdays[i])
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
}
/**
- * hildon_weekday_picker_set_all:
+ * hildon_weekday_picker_isset_day:
* @picker: the @HildonWeekdayPicker widget
* @day: Day to be checked.
*
- * Check if the specified weekday is set.
+ * Check if the specified weekday is set active.
*
- * Return value: TRUE if the day is set.
+ * Return value: TRUE if the day is set, FALSE is day is not set.
*/
gboolean
hildon_weekday_picker_isset_day(HildonWeekdayPicker * picker,
priv = HILDON_WEEKDAY_PICKER_GET_PRIVATE(picker);
+ /* Adjust between GDate and locale (shift one day),
+ FIXME: would be more elegant to use GDate as internal representation */
if (day == G_DATE_SUNDAY)
day = G_DATE_MONDAY;
else
day++;
+ /* FIXME: this is just copy paste from several other places
+ the above also! */
for (i = 1; i <= 7; i++) {
if ( priv->dayorder[i] == day &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
g_type_class_add_private(wizard_dialog_class,
sizeof(HildonWizardDialogPrivate));
+ /* Override virtual methods */
object_class->set_property = hildon_wizard_dialog_set_property;
object_class->get_property = hildon_wizard_dialog_get_property;
object_class->finalize = hildon_wizard_dialog_finalize;
+ /**
+ * HildonWizardDialog:wizard-name:
+ *
+ * The name of the wizard.
+ */
g_object_class_install_property(object_class, PROP_WIZARD_NAME,
g_param_spec_string("wizard-name",
"Wizard Name",
- "Set the HildonWizardDialog name",
+ "The name of the HildonWizardDialog",
NULL,
G_PARAM_READWRITE));
+ /**
+ * HildonWizardDialog:wizard-notebook:
+ *
+ * The notebook object, which is used by the HildonWizardDialog.
+ */
g_object_class_install_property(object_class, PROP_WIZARD_NOTEBOOK,
g_param_spec_object("wizard-notebook",
"Wizard Notebook",
- "Set the GtkNotebook to be used in the "
+ "GtkNotebook object to be used in the "
"HildonWizardDialog",
GTK_TYPE_NOTEBOOK, G_PARAM_READWRITE));
}
static void hildon_wizard_dialog_init(HildonWizardDialog * wizard_dialog)
{
+ /* Initialize private structure for faster member access */
HildonWizardDialogPrivate *priv =
G_TYPE_INSTANCE_GET_PRIVATE(wizard_dialog,
HILDON_TYPE_WIZARD_DIALOG,
HildonWizardDialogPrivate);
GtkDialog *dialog = GTK_DIALOG(wizard_dialog);
+
+ /* Init internal widgets */
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
-
gtk_dialog_set_has_separator(dialog, FALSE);
-
wizard_dialog->priv = priv;
priv->box = GTK_BOX(gtk_hbox_new(FALSE, 0));
priv->image = gtk_image_new_from_icon_name("qgn_widg_wizard",
HILDON_ICON_SIZE_WIDG_WIZARD);
+
+ /* Default values for user provided properties */
priv->notebook = NULL;
priv->wizard_name = NULL;
+ /* Build wizard layout */
gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox),
GTK_WIDGET(priv->box));
gtk_box_pack_start_defaults(GTK_BOX(priv->box), GTK_WIDGET(vbox));
gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(priv->image), FALSE, FALSE, 0);
+ /* Initialize cancel button */
gtk_dialog_add_button(dialog, _("Ecdg_bd_wizard_cancel"),
HILDON_WIZARD_DIALOG_CANCEL);
+ /* Initialize previous button */
priv->previous_button =
gtk_button_new_with_label(_("Ecdg_bd_wizard_previous"));
gtk_box_pack_start(GTK_BOX(dialog->action_area),
priv->previous_button, FALSE, TRUE, 0);
-
g_signal_connect(priv->previous_button, "clicked",
G_CALLBACK(direction_button_clicked), wizard_dialog);
+ /* Initialize next button */
priv->next_button =
gtk_button_new_with_label(_("Ecdg_bd_wizard_next"));
gtk_box_pack_start(GTK_BOX(dialog->action_area),
priv->next_button, FALSE, TRUE, 0);
-
g_signal_connect(priv->next_button, "clicked",
G_CALLBACK(direction_button_clicked), wizard_dialog);
+ /* Initialize finish button */
gtk_dialog_add_button(dialog, _("Ecdg_bd_wizard_finish"),
HILDON_WIZARD_DIALOG_FINISH);
+ /* Set initial button states */
gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard_dialog),
HILDON_WIZARD_DIALOG_FINISH,
FALSE);
switch (property_id) {
case PROP_WIZARD_NAME:
+
+ /* Set new wizard name. This name will appear in titlebar */
if (priv->wizard_name)
g_free(priv->wizard_name);
priv->wizard_name = g_strdup((gchar *) g_value_get_string(value));
+
+ /* We need notebook in order to create title, since page information
+ is used in title generation */
if (priv->notebook)
hildon_wizard_dialog_create_title(HILDON_WIZARD_DIALOG
(object));
break;
case PROP_WIZARD_NOTEBOOK:
priv->notebook = GTK_NOTEBOOK(g_value_get_object(value));
+
+ /* Set the default properties for the notebook (disable tabs,
+ * and remove borders) to make it look like a nice wizard widget */
gtk_notebook_set_show_tabs(priv->notebook, FALSE);
gtk_notebook_set_show_border(priv->notebook, FALSE);
gtk_box_pack_start_defaults(GTK_BOX(priv->box),
GTK_WIDGET(priv->notebook));
-
+
+ /* Update dialog title to reflact current page stats etc */
if (priv->wizard_name)
hildon_wizard_dialog_create_title(HILDON_WIZARD_DIALOG
(object));
gchar *str = NULL;
HildonWizardDialogPrivate *priv = wizard_dialog->priv;
GtkNotebook *notebook = priv->notebook;
- /*
- const gchar *step = _("step");
- const gchar *welcome = _("Welcome");
- const gchar *wizard_completed = _("Wizard completed");
- */
+
if (!notebook)
return;
+
+ /* Get page information, we'll need that when creating title */
pages = gtk_notebook_get_n_pages(notebook);
current = gtk_notebook_get_current_page(priv->notebook);
if (current < 0)
current = 0;
+ /* the welcome title on the initial page */
if (current == 0) {
str = g_strdup_printf(_("Ecdg_ti_wizard_welcome"),
priv->wizard_name, pages);
} else if (current + 1 == pages) {
+
+ /* Other pages contain step information.
+ FIXME: why the follwing two blocks are identical */
gchar *steps = (gchar *) gtk_notebook_get_tab_label_text(notebook,
gtk_notebook_get_nth_page(notebook, current));
str = g_strdup_printf(_("Ecdg_ti_wizard_step"),
str = g_strdup_printf(_("Ecdg_ti_wizard_step"),
priv->wizard_name, current + 1, pages, steps);
}
- /*
- if (current == 0)
- str = g_strdup_printf("%s %s %d/%d %s", priv->wizard_name, step,
- current + 1, pages, welcome);
- else if (current + 1 == pages)
- str = g_strdup_printf("%s %s %d/%d %s",
- priv->wizard_name, step, current + 1, pages,
- wizard_completed);
- else {
- gchar *steps = (gchar *) gtk_notebook_get_tab_label_text(notebook,
- gtk_notebook_get_nth_page(notebook, current));
- str = g_strdup_printf("%s %s %d/%d: %s", priv->wizard_name, step,
- current + 1, pages, steps);
- }
- */
+
+ /* Update the dialog to display the generated title */
gtk_window_set_title(GTK_WINDOW(wizard_dialog), str);
g_free(str);
}
+/* This function is called when next/previous buttons are clicked.
+ We dim buttons based on our new page.
+
+ FIXME: Why on earth these buttons are not response buttos like
+ other buttons in action area?? Now they cannot be conveniently
+ dimmed.
+*/
static void direction_button_clicked(GtkWidget *widget,
HildonWizardDialog *wizard_dialog)
{
gint current = 0;
gint last = gtk_notebook_get_n_pages(notebook) - 1;
+ /* Previous button clicked, we probably are on the first page now */
if (widget == priv->previous_button)
{
gtk_notebook_prev_page(notebook);
current = gtk_notebook_get_current_page(notebook);
+
+ /* If we are on the first page, we disable previous button. */
if (current == 0)
{
gtk_widget_set_sensitive(priv->previous_button, FALSE);
HILDON_WIZARD_DIALOG_FINISH,
FALSE);
}
+
+ /* We want next button to be enabled, unless this is also
+ our last (and only) page. */
if (current != last)
gtk_widget_set_sensitive(priv->next_button, TRUE);
}
- else /* Next button */
+ else /* handle the "Next" button */
{
+ /* Move forward */
gtk_notebook_next_page(notebook);
current = gtk_notebook_get_current_page(notebook);
+
+ /* If we actually moved somewhere else than to the first page,
+ we allow user to go backwards and also finish the dialog.
+ FIXME: Is this the desired behaviour? */
if (gtk_notebook_get_current_page(notebook) != 0)
{
gtk_widget_set_sensitive(priv->previous_button, TRUE);
HILDON_WIZARD_DIALOG_FINISH,
TRUE);
}
+
+ /* If we ended up to the last page, going forward must be disabled */
if (current == last)
gtk_widget_set_sensitive(priv->next_button, FALSE);
}
+ /* We show the default image on first and last pages */
if (current == last || current == 0)
gtk_widget_show(GTK_WIDGET(priv->image));
else
gtk_widget_hide(GTK_WIDGET(priv->image));
+
+ /* New page number may appear in the title, update it */
hildon_wizard_dialog_create_title(wizard_dialog);
}
GtkWidget *widget;
g_return_val_if_fail(GTK_IS_NOTEBOOK(notebook), NULL);
+
widget = GTK_WIDGET(g_object_new(HILDON_TYPE_WIZARD_DIALOG,
"wizard-name", wizard_name,
"wizard-notebook", notebook, NULL));