PsppireValueEntry: Clear the entry, when the underlying model changes.
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 23 Apr 2012 19:08:21 +0000 (21:08 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 24 Apr 2012 19:06:06 +0000 (21:06 +0200)
Since the labels will have changed, the existing text is most likely
inappropriate.

src/ui/gui/psppire-value-entry.c

index 675df83966ef3aa7e49e27e644bfec7cec59b99f..4cc8be9871acb1f9c90e151626e407709e2f8101 100644 (file)
@@ -243,6 +243,7 @@ psppire_value_entry_refresh_model (PsppireValueEntry *obj)
 {
   GtkWidget *entry = gtk_bin_get_child (GTK_BIN (obj));
   GtkTreeModel *model;
+  GtkTreeModel *old_model;
 
   if (val_labs_count (obj->val_labs) > 0)
     {
@@ -270,6 +271,14 @@ psppire_value_entry_refresh_model (PsppireValueEntry *obj)
   else
     model = NULL;
 
+  old_model = gtk_combo_box_get_model (GTK_COMBO_BOX (obj));
+
+  if (old_model != model)
+    {
+      GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (obj)));
+      gtk_entry_set_text (entry, "");
+    }
+
   gtk_combo_box_set_model (GTK_COMBO_BOX (obj), model);
   gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (obj), COL_LABEL);
   gtk_widget_set_sensitive (entry, model != NULL);