+static gboolean weight_completion_cb(GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, struct ws_widget *ws_widget)
+{
+ const char *desc;
+ unsigned int weight;
+
+ gtk_tree_model_get(model, iter, WS_DESC, &desc, WS_WEIGHT, &weight, -1);
+ add_weightsystem(ws_widget, desc, weight);
+ return TRUE;
+}
+
+static void weight_activate_cb(GtkComboBox *combo_box, gpointer data)
+{
+ struct ws_widget *ws_widget = data;
+ weight_cb(ws_widget->description, data);
+}
+
+static void ws_widget(GtkWidget *vbox, struct ws_widget *ws_widget, GtkListStore *model)
+{
+ GtkWidget *frame, *hbox;
+ GtkEntryCompletion *completion;
+ GtkWidget *widget;
+ GtkEntry *entry;
+
+ /*
+ * weight_system: description and weight
+ */
+ frame = gtk_frame_new("Weight");
+
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_container_add(GTK_CONTAINER(frame), hbox);
+
+ widget = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
+ gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
+
+ ws_widget->description = GTK_COMBO_BOX(widget);
+ g_signal_connect(widget, "changed", G_CALLBACK(weight_cb), ws_widget);
+
+ entry = GTK_ENTRY(GTK_BIN(widget)->child);
+ g_signal_connect(entry, "activate", G_CALLBACK(weight_activate_cb), ws_widget);
+
+ completion = gtk_entry_completion_new();
+ gtk_entry_completion_set_text_column(completion, 0);
+ gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(model));
+ g_signal_connect(completion, "match-selected", G_CALLBACK(weight_completion_cb), ws_widget);
+ gtk_entry_set_completion(entry, completion);
+
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
+
+ if ( output_units.weight == KG)
+ widget = create_spinbutton(hbox, "kg", 0, 50, 0.5);
+ else
+ widget = create_spinbutton(hbox, "lbs", 0, 110, 1);
+ ws_widget->weight = GTK_SPIN_BUTTON(widget);