diff -urpN --exclude=*~ ../aps-contacts-1.0/Contact_Browser.cxx ./Contact_Browser.cxx
--- ../aps-contacts-1.0/Contact_Browser.cxx	Wed May 30 09:39:04 2001
+++ ./Contact_Browser.cxx	Wed Aug  8 16:20:22 2001
@@ -1,4 +1,5 @@
 #include "Contact_Browser.h"
+#include "gui.h"
 #include <ctype.h>
 
 #if !defined(max)
@@ -66,7 +67,8 @@ std::map<std::string, std::string> Conta
 	name_percent = atoi(p["Contacts_list_columwidth"].c_str());
 	if(pt)
 		delete(pt);
-	pt = new Contacts_Phonetype(p);
+	pt = new Contacts_Selectype(contacts_selectphone_fixed,
+				    contacts_selectphone_custom);
 
 	fl_font(textfont(), textsize());
 	int temp;
@@ -83,27 +85,26 @@ void Contact_Browser::draw_row(int row, 
 	Contact_Info ci;
 	ci.read(ids[row - 1].id);
 
+	std::map<std::string, std::string> p;
+	if(preference_read(Contacts::prefer_file(), &p))
+		preference_preset(p);
+	Contacts_Selectype list_sel (contacts_selectlist_fixed,
+				     contacts_selectlist_custom);
+	std::vector<int> list_v = list_sel.get ("Contacts_List%d", p);
+
 	// Figure the name.
 	std::string name;
-	int size1 = ci.get(Contacts_Record::last_name).size();
-	int size2 = ci.get(Contacts_Record::first_name).size();
-	if(size1 && size2)
-		name = ci.get(Contacts_Record::last_name) + ", " + ci.get(Contacts_Record::first_name);
-	else
-		if(size1)
-			name = ci.get(Contacts_Record::last_name);
-		else
-			if(size2)
-				name = ci.get(Contacts_Record::first_name);
-			else {
-				name = ci.get(Contacts_Record::company);
-				if(!name.size()) {
-					name = ci.get(Contacts_Record::title);
-					if(!name.size())
-						name = _("Unnamed");
-				}
-			}
 
+	for (unsigned i=0; i < list_v.size (); i++) {
+		std::string str = ci.get(list_v[i]);
+		if (str.size () && name.size ())
+			name.append (", ");
+		name.append (str);
+	}
+	if (!name.size ()) {
+		name = _("Unnamed");
+	}
+		
 	// Figure the primary phone and phone category.
 	std::string phone_number;
 	std::string phone_cat;
diff -urpN --exclude=*~ ../aps-contacts-1.0/Contact_Browser.h ./Contact_Browser.h
--- ../aps-contacts-1.0/Contact_Browser.h	Wed May 30 09:39:04 2001
+++ ./Contact_Browser.h	Tue Aug  7 15:57:31 2001
@@ -36,7 +36,7 @@ class Contact_Browser : public Fl_Paged_
 	int space_w;
 	int double_u_w;
 	void draw_row(int r, int x, int y, int w, int h) const;
-	Contacts_Phonetype* pt;
+	Contacts_Selectype* pt;
 
 protected:
 	int handle(int event);
diff -urpN --exclude=*~ ../aps-contacts-1.0/data.cxx ./data.cxx
--- ../aps-contacts-1.0/data.cxx	Wed May 30 09:39:09 2001
+++ ./data.cxx	Fri Aug 10 14:29:17 2001
@@ -1,4 +1,4 @@
-// data.cxx
+// data.cxx  -*-c-indentation-style:"linux"-*-
 // code for Contacts' database interface
 //
 // Copyright (C) 2000 Agenda Computing Inc.
@@ -34,7 +34,6 @@
 struct Contacts_List_Data {
 	std::string str;
 	long id;
-	std::string name_;
 };
 
 static bool Contacts_List_cmp_nocase(const Contacts_List_Data& a,
@@ -44,19 +43,11 @@ static bool Contacts_List_cmp_nocase(con
 		if(r)
 			return (r<0);
 		else {
-			r = strcasecmp(a.name_.c_str(), b.name_.c_str());
-			if(r)
-				return (r<0);
-			else
-				return (a.id < b.id);
+			return (a.id < b.id);
 		}
 	} else {
 		if(a.str.empty() && b.str.empty()) {
-			int r = strcasecmp(a.name_.c_str(), b.name_.c_str());
-			if(r)
-				return (r<0);
-			else
-				return (a.id < b.id);
+			return (a.id < b.id);
 		} else {
 			if(a.str.empty())
 				return true;
@@ -90,9 +81,11 @@ void model_change_callback_unregister(Fl
 }
 
 int list_contacts(long category_id, std::vector<Contacts_ID_List>& lv, std::map<std::string, std::string>& p) {
+	Contacts_Selectype sort_sel (contacts_selectlist_fixed,
+				     contacts_selectlist_custom);
 	if(preference_read(Contacts::prefer_file(), &p))
 		preference_preset(p);
-	int sort_by_field = atoi(p["Contacts_sortby"].c_str());
+	std::vector<int> sort_v = sort_sel.get ("Contacts_Sort%d", p);
 
 	DB* dbp;
 	DBT key, content;
@@ -113,20 +106,9 @@ int list_contacts(long category_id, std:
 				Contacts_Record crec;
 				crec.load(rec.user_data().dptr());
 				Contacts_List_Data an_item;
-				an_item.str = crec.get(sort_by_field);
 				an_item.id = contact_id;
-				std::string name_parts[4] = {
-					crec.get(Contacts_Record::last_name),
-					crec.get(Contacts_Record::first_name),
-					crec.get(Contacts_Record::company),
-					crec.get(Contacts_Record::title)
-				};
-				for(int i = 0; i <4; i++) {
-					if(!name_parts[i].empty()) {
-						if(!an_item.name_.empty())
-							an_item.name_.append(" ");
-						an_item.name_.append(name_parts[i]);
-					}
+				for (unsigned i=0; i < sort_v.size (); i++) {
+					an_item.str.append (crec.get(sort_v[i]));
 				}
 				list_tmp.push_back(an_item);
 			}
@@ -401,131 +383,51 @@ void del_category(int category_id) {
 	return;
 }
 
-Contacts_Phonetype::Contacts_Phonetype(std::map<std::string, std::string> p) {
-	type_info info;
-	info.t = other;
-	info.type_name = _("Other");
-	info.abbr = "O";
-	v.push_back(info);
-	info.t = main_;
-	info.type_name = _("Main");
-	info.abbr = "M";
-	v.push_back(info);
-	info.t = home;
-	info.type_name = _("Home");
-	info.abbr = "H";
-	v.push_back(info);
-	info.t = work;
-	info.type_name = _("Work");
-	info.abbr = "W";
-	v.push_back(info);
-	info.t = fax;
-	info.type_name = _("Fax");
-	info.abbr = "F";
-	v.push_back(info);
-	info.t = email;
-	info.type_name = _("E-Mail");
-	info.abbr = "E";
-	v.push_back(info);
-	info.t = mobile;
-	info.type_name = _("Mobile");
-	info.abbr = "m";
-	v.push_back(info);
-	info.t = pager;
-	info.type_name = _("Pager");
-	info.abbr = "P";
-	v.push_back(info);
-	info.t = url;
-	info.type_name = _("URL");
-	info.abbr = "u";
-	v.push_back(info);
-	info.t = home_fax;
-	info.type_name = _("Home Fax");
-	info.abbr = "f";
-	v.push_back(info);
-	info.t = custom1;
-	info.type_name = p["Contacts_Custom1_label"];
-	info.abbr = p["Contacts_Custom1_abbr"];
-	v.push_back(info);
-	info.t = custom2;
-	info.type_name = p["Contacts_Custom2_label"];
-	info.abbr = p["Contacts_Custom2_abbr"];
-	v.push_back(info);
-	info.t = custom3;
-	info.type_name = p["Contacts_Custom3_label"];
-	info.abbr = p["Contacts_Custom3_abbr"];
-	v.push_back(info);
-	info.t = custom4;
-	info.type_name = p["Contacts_Custom4_label"];
-	info.abbr = p["Contacts_Custom4_abbr"];
-	v.push_back(info);
+Contacts_Selectype_Init contacts_selectphone_fixed[] = {
+	Contacts_Phonetype::other, "Other", "O",
+	Contacts_Phonetype::main_, "Main", "M",
+	Contacts_Phonetype::home, "Home", "H",
+	Contacts_Phonetype::work, "Work", "W",
+	Contacts_Phonetype::fax, "Fax", "F",
+	Contacts_Phonetype::email, "E-Mail", "E",
+	Contacts_Phonetype::mobile, "Mobile", "m",
+	Contacts_Phonetype::pager, "Pager", "P",
+	Contacts_Phonetype::url, "URL", "u",
+	Contacts_Phonetype::home_fax, "Home Fax", "f",
+	-1, "", "",
 };
 
-Contacts_Phonetype::Contacts_Phonetype() {
-	std::map<std::string, std::string> p;
-	if(preference_read(Contacts::prefer_file(), &p)) {
-		preference_preset(p);
-	}
-	type_info info;
-	info.t = other;
-	info.type_name = _("Other");
-	info.abbr = "O";
-	v.push_back(info);
-	info.t = main_;
-	info.type_name = _("Main");
-	info.abbr = "M";
-	v.push_back(info);
-	info.t = home;
-	info.type_name = _("Home");
-	info.abbr = "H";
-	v.push_back(info);
-	info.t = work;
-	info.type_name = _("Work");
-	info.abbr = "W";
-	v.push_back(info);
-	info.t = fax;
-	info.type_name = _("Fax");
-	info.abbr = "F";
-	v.push_back(info);
-	info.t = email;
-	info.type_name = _("E-Mail");
-	info.abbr = "E";
-	v.push_back(info);
-	info.t = mobile;
-	info.type_name = _("Mobile");
-	info.abbr = "m";
-	v.push_back(info);
-	info.t = pager;
-	info.type_name = _("Pager");
-	info.abbr = "P";
-	v.push_back(info);
-	info.t = url;
-	info.type_name = _("URL");
-	info.abbr = "u";
-	v.push_back(info);
-	info.t = home_fax;
-	info.type_name = _("Home Fax");
-	info.abbr = "f";
-	v.push_back(info);
-	info.t = custom1;
-	info.type_name = p["Contacts_Custom1_label"];
-	info.abbr = p["Contacts_Custom1_abbr"];
-	v.push_back(info);
-	info.t = custom2;
-	info.type_name = p["Contacts_Custom2_label"];
-	info.abbr = p["Contacts_Custom2_abbr"];
-	v.push_back(info);
-	info.t = custom3;
-	info.type_name = p["Contacts_Custom3_label"];
-	info.abbr = p["Contacts_Custom3_abbr"];
-	v.push_back(info);
-	info.t = custom4;
-	info.type_name = p["Contacts_Custom4_label"];
-	info.abbr = p["Contacts_Custom4_abbr"];
-	v.push_back(info);
+
+Contacts_Selectype_Init contacts_selectphone_custom[] = {
+	Contacts_Phonetype::custom1, "Contacts_Custom1_label", "Contacts_Custom1_abbr",
+	Contacts_Phonetype::custom2, "Contacts_Custom2_label", "Contacts_Custom2_abbr",
+	Contacts_Phonetype::custom3, "Contacts_Custom3_label", "Contacts_Custom3_abbr",
+	Contacts_Phonetype::custom4, "Contacts_Custom4_label", "Contacts_Custom4_abbr",
+	-1, "", "",
 };
 
-std::string Contacts_Phonetype::type2name(int type) {
+Contacts_Selectype::Contacts_Selectype(Contacts_Selectype_Init* fixed,
+				       Contacts_Selectype_Init* custom) {
+	type_info info;
+	for (Contacts_Selectype_Init* p = fixed; p && p->type != -1; p++) {
+		info.t = (Type)p->type;
+		info.type_name = _(p->type_name);
+		info.abbr = p->abbr;
+		v.push_back(info);
+	}
+	std::map<std::string, std::string> m;
+	if(preference_read(Contacts::prefer_file(), &m)) {
+		preference_preset(m);
+	}
+	for (Contacts_Selectype_Init* p = custom; p && p->type != -1; p++) {
+		info.t = (Type)p->type;
+		info.type_name = m[p->type_name];
+		info.abbr = m[p->abbr];
+		v.push_back(info);
+	}
+}
+
+std::string Contacts_Selectype::type2name(int type) {
 	int size = v.size();
 	for(int i = 0; i < size; i++) {
 		if(type == v[i].t)
@@ -534,7 +436,7 @@ std::string Contacts_Phonetype::type2nam
 	return v[0].type_name;
 }
 
-std::string Contacts_Phonetype::type2abbreviation(int type) {
+std::string Contacts_Selectype::type2abbreviation(int type) {
 	int size = v.size();
 	for(int i = 0; i < size; i++) {
 		if(type == v[i].t)
diff -urpN --exclude=*~ ../aps-contacts-1.0/data.h ./data.h
--- ../aps-contacts-1.0/data.h	Wed May 30 09:39:09 2001
+++ ./data.h	Wed Aug  8 16:30:18 2001
@@ -38,22 +38,28 @@ public:
 	std::string get(int p) {return Contacts_Record::get(p);}
 };
 
-class Contacts_Phonetype {
-public:
-	enum Type {other, main_, home, work, fax, email, mobile,
-		pager, url, home_fax, custom1 = 21, custom2 = 22,
-		custom3 = 23, custom4 = 24};
-private:
+class Contacts_Selectype_Init {
+ public:
+	int type;
+	char const* type_name;
+	char const* abbr;
+};
+
+
+class Contacts_Selectype {
+ public:
+	enum Type {};
+ private:	
 	struct type_info {
 		Type t;
 		std::string type_name;
 		std::string abbr;
 	};
 	std::vector<type_info> v;
-public:
-	Contacts_Phonetype();
-	Contacts_Phonetype(std::map<std::string, std::string> p);
-	~Contacts_Phonetype() { v.clear();}
+ public:
+	Contacts_Selectype(Contacts_Selectype_Init* fixed,
+			   Contacts_Selectype_Init* custom);
+	~Contacts_Selectype() { v.clear();}
 	std::string type2name(int type);
 	std::string type2abbreviation(int type);
 
@@ -78,8 +84,40 @@ public:
 			if(t == (int)v[i].t)
 				return i;
 		}
-		return other;
+		return 0;
+	}
+
+	Type name2type (std::string name) {
+		for (unsigned i = 0; i < v.size(); i++) {
+			if (v[i].type_name == name)
+				return (Type)v[i].t;
+		}
+		return (Type)0;
 	}
+
+	std::vector<int> get (char const* format, std::map<std::string, std::string> &m) {
+		char buf[48];
+		int i = 0;
+		std::vector<int> r;
+		while (1) {
+			sprintf (buf, format, i+1);
+			if (m[buf].empty ())
+				break;
+			r.push_back (name2type (m[buf]));
+			i++;
+		}
+		return r;
+	}
+};
+
+extern Contacts_Selectype_Init contacts_selectlist_fixed[];
+extern Contacts_Selectype_Init contacts_selectlist_custom[];
+
+class Contacts_Phonetype {
+ public:	
+	enum Type {other, main_, home, work, fax, email, mobile,
+		   pager, url, home_fax,
+		   custom1 = 23, custom2, custom3, custom4};
 };
 
 struct Contacts_ID_List {
diff -urpN --exclude=*~ ../aps-contacts-1.0/edit.cxx ./edit.cxx
--- ../aps-contacts-1.0/edit.cxx	Wed Aug  8 16:42:36 2001
+++ ./edit.cxx	Wed Aug  8 16:42:47 2001
@@ -1,4 +1,4 @@
-// edit.cxx
+// edit.cxx  -*-c-indentation-style:"linux"-*-
 // Code for Contacts editing contact information.
 //
 // Copyright (C) 2000 Agenda Computing Inc.
@@ -262,7 +262,7 @@ void Edit_View::add_choice( int key, int
 	((Fl_Widget*)mb[key])->size(width, height);
 	mb[key]->menu(NULL);
 	// put all type except customs
-	int size = phone_type_obj.size() - 4;
+ 	int size = phone_type_obj.size() - 4;
 	for(int i = 0; i < size; i++) {
 		mb[key]->add(phone_type_obj.pos2name(i).c_str(), 0, 0, (void*) key, 0);
 	}
@@ -439,7 +439,7 @@ void Edit_View::open(long id_contact, un
 	int toolbar_space_left = toolbar->w();
 	// setup Done button
 	Fl_Button* b = WidgetFactory::new_button(_("Done"), done_cb, (void*)this);
-	// setup Concel button
+	// setup Cancel button
 	WidgetFactory::new_button(_("Cancel"), cancel_cb, (void*)this);
 	toolbar_space_left -= 2 * b->w();
 
diff -urpN --exclude=*~ ../aps-contacts-1.0/gui.h ./gui.h
--- ../aps-contacts-1.0/gui.h	Wed May 30 09:39:11 2001
+++ ./gui.h	Wed Aug  8 16:16:03 2001
@@ -51,6 +51,9 @@ public:
 	static void plugins_cb(char* plugin_name, char* plugin_label, FILE* fp, void* data);
 };
 
+extern Contacts_Selectype_Init contacts_selectphone_fixed[];
+extern Contacts_Selectype_Init contacts_selectphone_custom[];
+
 class Edit_View {
 	Fl_App_Window* win;
 	long contact;
@@ -59,7 +62,7 @@ class Edit_View {
 	Fl_Input* input[25];
 	std::vector<int> category_list;
 	bool input_changed;
-	Contacts_Phonetype phone_type_obj;
+	Contacts_Selectype phone_type_obj;
 	char* custom_label[4];
 
 	void collect_data();
@@ -78,7 +81,11 @@ class Edit_View {
 	static void edit_category_cb(Fl_Widget*, void*);
 	static void model_chg_cb(Fl_Widget*, void*);
 public:
-	Edit_View():win(0) {for(int i = 0; i < 4; i++) custom_label[i] = 0;};
+	Edit_View():win(0),
+		phone_type_obj (contacts_selectphone_fixed,
+				contacts_selectphone_custom) {
+		for(int i = 0; i < 4; i++) custom_label[i] = 0;
+	};
 	~Edit_View() {
 		model_change_callback_unregister(model_chg_cb, win, this);
 		if(win) delete win;
diff -urpN --exclude=*~ ../aps-contacts-1.0/list.cxx ./list.cxx
--- ../aps-contacts-1.0/list.cxx	Wed May 30 09:39:12 2001
+++ ./list.cxx	Tue Aug  7 20:55:15 2001
@@ -36,8 +36,6 @@ class List_View {
 	Fl_Menu_Button* cat_mb;
 	Fl_Menu_Button* view_mb;
 	std::vector<int> category_list;
-	char sort_custom1_label[64];
-	char sort_custom2_label[64];
 
 	void get_category();
 	void update_browser();
@@ -193,22 +191,9 @@ void List_View::refresh() {
 	names->position(0);
 	int tmp = atoi(p["Contacts_sortby"].c_str());
 
-	strcpy(sort_custom1_label, p["Contacts_Custom1_label"].c_str());
-	strcpy(sort_custom2_label, p["Contacts_Custom2_label"].c_str());
-
 	Fl_Menu_Item mi[] = {
 		{_("About"), 0, about_cb, (void*)this, 0},
 		{_("Preferences"), 0, preferences_cb, (void*)this, FL_MENU_DIVIDER},
-		{_("Sort by"), 0, 0, 0, FL_SUBMENU },
-			{_("Last name"), 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{_("First name"), 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{_("City"), 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{_("State"), 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{_("Company"), 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{_("Title"), 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{sort_custom1_label, 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{sort_custom2_label, 0, pref_sort_cb, this, FL_MENU_RADIO },
-			{0},
 		{_("View Business Card"), 0, view_business_card_cb, this, 0},
 		{0},
 	};
diff -urpN --exclude=*~ ../aps-contacts-1.0/preferences.cxx ./preferences.cxx
--- ../aps-contacts-1.0/preferences.cxx	Wed May 30 09:39:12 2001
+++ ./preferences.cxx	Wed Aug  8 16:40:05 2001
@@ -1,4 +1,4 @@
-// preferences.cxx
+// preferences.cxx  -*-c-indentation-style:"linux"-*-
 // Code for Contacts setting preferences
 //
 // Copyright (C) 2000 Agenda Computing Inc.
@@ -53,12 +53,117 @@ void preference_preset(std::map<std::str
 	p["Contacts_list_columwidth"] = default_list_columwidth;
 	p["Contacts_sortby"] = "1";
 	p["Contacts_category"] = "255";
+	
+}
+
+Contacts_Selectype_Init contacts_selectlist_fixed[] = {
+	Contacts_Record::first_name, "First Name", "F",
+	Contacts_Record::last_name, "Last Name", "L",
+	Contacts_Record::company, "Company", "C",
+	Contacts_Record::title, "Title", "T",
+	-1, "", "",
+};
+
+Contacts_Selectype_Init contacts_selectlist_custom[] = {
+	Contacts_Record::custom1, "Contacts_Custom1_label", "Contacts_Custom1_abbr",
+	Contacts_Record::custom2, "Contacts_Custom2_label", "Contacts_Custom2_abbr",
+	Contacts_Record::custom3, "Contacts_Custom3_label", "Contacts_Custom3_abbr",
+	Contacts_Record::custom4, "Contacts_Custom4_label", "Contacts_Custom4_abbr",
+	-1, "", "",
+};
+
+
+class Select_Buttons {
+public:
+	bool b_input_changed;
+	int x;
+	int y;
+	int width;
+	void add_choice(int key, int type);
+	static void choice_cb(Fl_Widget*, void*);
+	static void setting_cb(Fl_Widget*, void*);
+	Fl_Menu_Button* mb[4];
+	Fl_Menu_Button* mb_channel;
+	Contacts_Selectype select_type_obj;
+
+	Select_Buttons (Contacts_Selectype_Init* fixed,
+			Contacts_Selectype_Init* custom)
+		: select_type_obj (fixed, custom) {
+	};
+	void get (char const* format, std::map<std::string, std::string>& m);
+	void set (char const* format, std::map<std::string, std::string>& m);
+};
+
+
+void Select_Buttons::choice_cb(Fl_Widget* w, void* data) {
+	Select_Buttons* o = (Select_Buttons*)data;
+	Fl_Menu_Button* m = (Fl_Menu_Button*)w;
+	m->label(m->text());
+	m->redraw();
+	int pos = m->value();
+	const Fl_Menu_Item* mi = m->menu();
+	int n = (long) (mi[pos].user_data());
+	// FIXME: 6
+	if(n < 6) {
+		o->mb_channel->replace(n, m->text());
+		o->mb_channel->label(o->mb_channel->text());
+		o->mb_channel->redraw();
+	}
+	o->b_input_changed = true;
+}
+
+void Select_Buttons::setting_cb(Fl_Widget*, void* data) {
+	Select_Buttons* o = (Select_Buttons*)data;
+	o->mb_channel->label( o->mb_channel->text());
+	o->mb_channel->redraw();
+	o->b_input_changed = true;
+}
+
+void Select_Buttons::add_choice(int key, int type) {
+	mb[key] = WidgetFactory::new_menu_button(x, y
+						 + (key + 1)
+						 * WidgetFactory::buttonheight(),
+						 "", choice_cb, (void*)this);
+	int height = mb[key]->h();
+	((Fl_Widget*)mb[key])->size(width, height);
+	mb[key]->menu(NULL);
+	int size = select_type_obj.size();
+	for(int i = 0; i < size; i++) {
+		mb[key]->add(select_type_obj.pos2name(i).c_str(),
+			     0, 0, (void*) key, 0);
+	}
+	mb[key]->value(select_type_obj.type2pos(type));
+	mb[key]->label(mb[key]->text());
+}
+
+void
+Select_Buttons::get (char const* format, std::map<std::string, std::string> &m)
+{
+	std::vector<int> v = select_type_obj.get (format, m);
+	int s = sizeof (mb) / sizeof (*mb);
+	for (int i = 0; i < s; i++) {
+		mb[i]->value (select_type_obj.type2pos (v[i]));
+	}
+}
+
+void
+Select_Buttons::set (char const* format, std::map<std::string, std::string> &m)
+{
+	char buf[48];
+	int s = sizeof (mb) / sizeof (*mb);
+	for (int i = 0; i < s; i++) {
+		sprintf (buf, format, i+1);
+		m[buf] = mb[i]->text ();
+	}
 }
 
 class Preferences_View {
 	Fl_App_Window* win;
 	Fl_Counter* sep_in;
 	Fl_Input* i_custom[4];
+	Select_Buttons list_sel;
+	Select_Buttons sort_sel;
+  
 	// custom field abbreviation is reserved 
 	bool b_input_changed;
 	static void done_cb(Fl_Widget*, void*);
@@ -69,13 +174,19 @@ class Preferences_View {
 	void update();
 public:
 	int open();
-	Preferences_View():win(0) {};
+	Preferences_View():win(0),
+			   list_sel (contacts_selectlist_fixed,
+				     contacts_selectlist_custom),
+			   sort_sel (contacts_selectlist_fixed,
+				     contacts_selectlist_custom) {
+	};
 	~Preferences_View() { if(win) delete win;};
 };
 
 void Preferences_View::done_cb(Fl_Widget*, void* data) {
 	Preferences_View* o = (Preferences_View*)data;
-	if(o->b_input_changed) {
+	if(o->b_input_changed || o->list_sel.b_input_changed
+		|| o->sort_sel.b_input_changed) {
 		std::map<std::string, std::string> p;
 		int wv = (int)o->sep_in->value();
 		char ch[27];
@@ -87,6 +198,8 @@ void Preferences_View::done_cb(Fl_Widget
 		p["Contacts_Custom3_label"] = o->i_custom[2]->value();
 		p["Contacts_Custom4_label"] = o->i_custom[3]->value();
 		p["Contacts_list_columwidth"] = ch;
+		o->list_sel.set ("Contacts_List%d", p);
+		o->sort_sel.set ("Contacts_Sort%d", p);
 		preference_write(Contacts::prefer_file(), &p);
 		model_changed();
 	}
@@ -137,6 +250,17 @@ void Preferences_View::update() {
 	i_custom[2]->value(f.c_str());
 	f = p["Contacts_Custom4_label"];
 	i_custom[3]->value(f.c_str());
+
+	list_sel.get ("Contacts_List%d", p);
+	sort_sel.get ("Contacts_Sort%d", p);
+
+	int s = sizeof (list_sel.mb) / sizeof (*list_sel.mb);
+	for (int i=0; i < s; i++) {
+		list_sel.mb[i]->label (list_sel.mb[i]->text ());
+		list_sel.mb[i]->redraw ();
+		sort_sel.mb[i]->label (sort_sel.mb[i]->text ());
+		sort_sel.mb[i]->redraw ();
+	}
 }
 
 int Preferences_View::open() {
@@ -166,7 +290,7 @@ int Preferences_View::open() {
 	sep_in->textsize(WidgetFactory::textsize());
 
 	// setup custom label setting
-	bgc = new Fl_Box(FL_FLAT_BOX, 10, 60, w -10, 20, _("Properties of custom fields:"));
+	bgc = new Fl_Box(FL_FLAT_BOX, 10, 40, w -10, 20, _("Properties of custom fields:"));
 	bgc->labelsize(WidgetFactory::labelsize());
 	bgc->color(FL_WHITE);
 	bgc->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
@@ -175,17 +299,83 @@ int Preferences_View::open() {
 	for(int i = 0; i < 4; i++) {
 		static char buf[4][6];
 		sprintf(buf[i], "%d: ", i + 1);
-		bgc = new Fl_Box(FL_FLAT_BOX, 0, i * h + 80, 40, WidgetFactory::buttonheight(), "");
+		bgc = new Fl_Box(FL_FLAT_BOX, 0, i * h + 60, 40, WidgetFactory::buttonheight(), "");
 		bgc->color(FL_WHITE);
-		i_custom[i] = WidgetFactory::new_input(40, i * h + 80,
+		i_custom[i] = WidgetFactory::new_input(40, i * h + 60,
 			w - 60, WidgetFactory::buttonheight(), buf[i]);
 		i_custom[i]->maximum_size(32);
 		i_custom[i]->callback(input_cb, this);
 		i_custom[i]->when(FL_WHEN_CHANGED);
 	}
+	
+	/* Urg: hardcoded window positions; how will this ever work
+	   on next generation agenda, with eg 30% bigger screen?  */
+	bgc = new Fl_Box(FL_FLAT_BOX, 0, 125, w -10, 20, _("List order:"));
+	bgc->labelsize(WidgetFactory::labelsize());
+	bgc->color(FL_WHITE);
+	bgc->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+	
+	list_sel.x = 0;
+	list_sel.y = 125;
+	list_sel.width = w/3;
+
+	int s = sizeof (list_sel.mb) / sizeof (*list_sel.mb);
+	for (int i=0; i < s; i++) {
+		list_sel.add_choice(i, contacts_selectlist_fixed[i].type);
+	}
+
+	bgc = new Fl_Box(FL_FLAT_BOX, w/2, 125, w -10, 20, _("Sort order:"));
+	bgc->labelsize(WidgetFactory::labelsize());
+	bgc->color(FL_WHITE);
+	bgc->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+	
+	sort_sel.x = w/2;
+	sort_sel.y = 125;
+	sort_sel.width = w/3;
+
+	for (int i=0; i < s; i++) {
+		sort_sel.add_choice(i, contacts_selectlist_fixed[i].type);
+	}
+
 	pref_sc->end();
         win->end();
 
+	// setup primary information show on list view selection.
+	list_sel.mb_channel = WidgetFactory::new_menu_button(0, 0);
+	list_sel.mb_channel->resize(list_sel.mb_channel->x(),
+				    list_sel.mb_channel->y(),
+				    w/3,
+				    list_sel.mb_channel->h());
+	//toolbar_space_left -= b->w() + 10 + WidgetFactory::pagekeywidth();
+	Fl_Menu_Item list_chs[] = {
+		{list_sel.mb[0]->label(), 0, Select_Buttons::setting_cb, (void*)&list_sel},
+		{list_sel.mb[1]->label(), 0, Select_Buttons::setting_cb, (void*)&list_sel},
+		{list_sel.mb[2]->label(), 0, Select_Buttons::setting_cb, (void*)&list_sel},
+		{list_sel.mb[3]->label(), 0, Select_Buttons::setting_cb, (void*)&list_sel},
+		{0}
+	};
+	list_sel.mb_channel->copy(list_chs);
+	list_sel.mb_channel->value(0);
+	list_sel.mb_channel->label(list_sel.mb_channel->text());
+
+	// setup primary information show on list order selection.
+	sort_sel.mb_channel = WidgetFactory::new_menu_button(0, 0);
+	sort_sel.mb_channel->resize(sort_sel.mb_channel->x(),
+				     sort_sel.mb_channel->y(),
+				    w/3,
+				    sort_sel.mb_channel->h());
+	//toolbar_space_left -= b->w() + 10 + WidgetFactory::pagekeywidth();
+	Fl_Menu_Item sort_chs[] = {
+		{sort_sel.mb[0]->label(), 0, Select_Buttons::setting_cb, (void*)&sort_sel},
+		{sort_sel.mb[1]->label(), 0, Select_Buttons::setting_cb, (void*)&sort_sel},
+		{sort_sel.mb[2]->label(), 0, Select_Buttons::setting_cb, (void*)&sort_sel},
+		{sort_sel.mb[3]->label(), 0, Select_Buttons::setting_cb, (void*)&sort_sel},
+		{0}
+	};
+	sort_sel.mb_channel->copy(sort_chs);
+	sort_sel.mb_channel->value(0);
+	sort_sel.mb_channel->label(sort_sel.mb_channel->text());
+
 	// setup Toolbar
         Fl_Dockable_Window* toolbar = WidgetFactory::new_toolbar();
         Fl_Button* b = WidgetFactory::new_button(_("Done"), done_cb, (void*)this);
@@ -198,6 +388,7 @@ int Preferences_View::open() {
 	new Fl_Box(0, 0, space_left - WidgetFactory::pagekeywidth(), WidgetFactory::buttonheight());
 	Fl_Page_UpDown_Button* pb = WidgetFactory::new_pagekey();
 	pref_sc->page_updown_button(pb);
+
 	toolbar->end();
 
 	win->add_dockable(toolbar, 1);
diff -urpN --exclude=*~ ../aps-contacts-1.0/view.cxx ./view.cxx
--- ../aps-contacts-1.0/view.cxx	Wed May 30 09:39:14 2001
+++ ./view.cxx	Wed Aug  8 16:20:22 2001
@@ -268,7 +268,8 @@ void Detail_View::update() {
 		feed("Not named yet!", 2);
 
 	browser->add("");
-	Contacts_Phonetype pt;
+	Contacts_Selectype pt (contacts_selectphone_fixed,
+			       contacts_selectphone_custom);
 	str = crec.get(Contacts_Record::phone1);
 	if(str.size())
 	{

