PsppireValueEntry: Remove unnecessary function calls
[pspp] / src / ui / gui / psppire-value-entry.c
index 675df83966ef3aa7e49e27e644bfec7cec59b99f..322cb3a3b4eb13cfea28f9f05a0792b96ac7d47f 100644 (file)
@@ -216,6 +216,7 @@ psppire_value_entry_init (PsppireValueEntry *obj)
   obj->format = F_8_0;
   obj->encoding = NULL;
   obj->cur_value = NULL;
+  gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (obj), COL_LABEL);
 
   g_signal_connect (buffer, "notify::text",
                     G_CALLBACK (psppire_value_entry_text_changed), obj);
@@ -241,8 +242,8 @@ psppire_value_entry_new (void)
 static void
 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,9 +271,15 @@ 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);
 }
 
 void
@@ -310,9 +317,7 @@ void
 psppire_value_entry_set_value_labels (PsppireValueEntry *obj,
                                       const struct val_labs *val_labs)
 {
-  if (val_labs != NULL
-      ? obj->val_labs == NULL || !val_labs_equal (obj->val_labs, val_labs)
-      : obj->val_labs != NULL)
+  if (!val_labs_equal (obj->val_labs, val_labs))
     {
       obj->cur_value = NULL;