hildon_number_editor_error_handler(HildonNumberEditor *editor,
HildonNumberEditorErrorType type);
+static gboolean
+hildon_number_editor_select_all (HildonNumberEditorPrivate *priv);
+
enum
{
RANGE_ERROR,
gint end;
gint default_val;
gint button_type;
- gint button_event_id;
+
+ guint button_event_id;
+ guint select_all_idle_id;
gboolean negative;
};
if (priv->button_event_id)
g_source_remove (priv->button_event_id);
+ if (priv->select_all_idle_id)
+ g_source_remove (priv->select_all_idle_id);
+
/* Call parent class finalize, if have one */
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize(self);
GTK_WIDGET_UNSET_FLAGS( priv->minus, GTK_CAN_FOCUS );
GTK_WIDGET_UNSET_FLAGS( priv->plus, GTK_CAN_FOCUS );
- priv->button_event_id = -1;
+ priv->button_event_id = 0;
+ priv->select_all_idle_id = 0;
gtk_widget_set_parent(priv->minus, GTK_WIDGET(editor));
gtk_widget_set_parent(priv->num_entry, GTK_WIDGET(editor));
HildonNumberEditorPrivate *priv =
HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
- if (priv->button_event_id != -1)
+ if (priv->button_event_id)
{
g_source_remove(priv->button_event_id);
- priv->button_event_id = -1;
+ priv->button_event_id = 0;
}
return FALSE;
}
else
priv->button_type = -1;
- if (priv->button_event_id == -1)
+ if (!priv->button_event_id)
{
do_mouse_timeout(editor);
priv->button_event_id = g_timeout_add (timeout,
}
static void
+add_select_all_idle (HildonNumberEditorPrivate *priv)
+{
+ if (!priv->select_all_idle_id)
+ {
+ priv->select_all_idle_id =
+ g_idle_add((GSourceFunc) hildon_number_editor_select_all, priv);
+ }
+}
+
+static void
hildon_number_editor_entry_changed (GtkWidget *widget, gpointer data)
{
HildonNumberEditor *editor;
0, MAXIMUM_VALUE_EXCEED, &r);
tmpstr = integer_to_string(priv->end);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), tmpstr);
+ add_select_all_idle(priv);
if (tmpstr)
g_free(tmpstr);
}
0, MINIMUM_VALUE_EXCEED, &r);
tmpstr = integer_to_string(priv->start);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), tmpstr);
+ add_select_all_idle(priv);
if (tmpstr)
g_free(tmpstr);
}
0, ERRONEOUS_VALUE, &r);
tmpstr = integer_to_string(priv->start);
gtk_entry_set_text(GTK_ENTRY(priv->num_entry), tmpstr);
+ add_select_all_idle(priv);
if (tmpstr)
g_free(tmpstr);
}
g_strdup_printf(_("Ckct_ib_set_a_value_within_range"), min, max);
break;
}
-
+
if (err_msg)
{
gtk_infoprint(GTK_WINDOW(gtk_widget_get_ancestor(GTK_WIDGET(editor),
if (str)
g_free(str);
}
+
+/* When calling gtk_entry_set_text, the entry widget does things that can
+ * cause the whole widget to redraw. This redrawing is delayed and if any
+ * selections are made right after calling the gtk_entry_set_text the
+ * setting of the selection might seem to have no effect.
+ *
+ * If the selection is delayed with a lower priority than the redrawing,
+ * the selection should stick. Calling this function with g_idle_add should
+ * do it.
+ */
+static gboolean
+hildon_number_editor_select_all (HildonNumberEditorPrivate *priv)
+{
+ gtk_editable_select_region(GTK_EDITABLE(priv->num_entry), 0, -1);
+ priv->select_all_idle_id = 0;
+ return FALSE;
+}
+