check if ancestor widget still exists in set-focus handler
[hildon] / hildon-widgets / hildon-number-editor.c
index 89920b2..ac54c2a 100644 (file)
@@ -44,6 +44,7 @@
 #include "hildon-composite-widget.h"
 #include <hildon-widgets/hildon-input-mode-hint.h>
 #include <hildon-widgets/hildon-defines.h>
+#include "hildon-libs-enum-types.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -126,7 +127,7 @@ static void
 hildon_number_editor_finalize (GObject *self);
 
 static gboolean
-hildon_number_editor_error_handler(HildonNumberEditor *editor,
+hildon_number_editor_range_error(HildonNumberEditor *editor,
                                   HildonNumberEditorErrorType type);
 
 static gboolean
@@ -221,7 +222,7 @@ hildon_number_editor_class_init(HildonNumberEditorClass * editor_class)
     widget_class->size_allocate = hildon_number_editor_size_allocate;
     widget_class->focus = hildon_composite_widget_focus;
 
-    editor_class->error_handler = hildon_number_editor_error_handler;
+    editor_class->range_error = hildon_number_editor_range_error;
 
     /* Because we derived our widget from GtkContainer, we should override 
        forall method */
@@ -242,10 +243,10 @@ hildon_number_editor_class_init(HildonNumberEditorClass * editor_class)
     HildonNumberEditor_signal[RANGE_ERROR] =
       g_signal_new("range_error", HILDON_TYPE_NUMBER_EDITOR,
                   G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
-                  (HildonNumberEditorClass, error_handler),
+                  (HildonNumberEditorClass, range_error),
                   g_signal_accumulator_true_handled, NULL,
-                  _hildon_marshal_BOOLEAN__INT,
-                  G_TYPE_BOOLEAN, 1, G_TYPE_INT);
+                  _hildon_marshal_BOOLEAN__ENUM,
+                  G_TYPE_BOOLEAN, 1, HILDON_TYPE_NUMBER_EDITOR_ERROR_TYPE);
 }
 
 static void
@@ -491,12 +492,16 @@ do_mouse_timeout (HildonNumberEditor *editor)
 {
     HildonNumberEditorPrivate *priv;
 
+    GDK_THREADS_ENTER ();
+    
     g_assert(HILDON_IS_NUMBER_EDITOR(editor));
 
     /* Update value based on button held */
     priv = HILDON_NUMBER_EDITOR_GET_PRIVATE(editor);
     change_numbers(editor, priv->button_type);
 
+    GDK_THREADS_LEAVE ();
+
     return TRUE;
 }
 
@@ -765,7 +770,7 @@ hildon_number_editor_entry_keypress (GtkWidget *widget, GdkEventKey *event,
 }
 
 static gboolean
-hildon_number_editor_error_handler(HildonNumberEditor *editor,
+hildon_number_editor_range_error(HildonNumberEditor *editor,
                                   HildonNumberEditorErrorType type)
 {
 
@@ -912,8 +917,10 @@ hildon_number_editor_set_value (HildonNumberEditor *editor, gint value)
 static gboolean
 hildon_number_editor_select_all (HildonNumberEditorPrivate *priv)
 {   
+    GDK_THREADS_ENTER ();
     gtk_editable_select_region(GTK_EDITABLE(priv->num_entry), 0, -1);
     priv->select_all_idle_id = 0;
+    GDK_THREADS_LEAVE ();
     return FALSE;
 }