2006-03-19 [colin] 2.0.0cvs156
authorColin Leroy <colin@colino.net>
Sun, 19 Mar 2006 10:20:05 +0000 (10:20 +0000)
committerColin Leroy <colin@colino.net>
Sun, 19 Mar 2006 10:20:05 +0000 (10:20 +0000)
* src/addressbook.c
- Sort case-unsensitive
- Put the sort arrow at opening too

ChangeLog
PATCHSETS
configure.ac
src/addressbook.c

index 0356bbd075da2b87a1e57917c6fa99aa990395eb..7cec1cb4aa0d7ed5710e2cc7c9f20b537aea1a9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-19 [colin]     2.0.0cvs156
+
+       * src/addressbook.c
+               - Sort case-unsensitive
+               - Put the sort arrow at opening too
+
 2006-03-19 [wwp]       2.0.0cvs155
 
        * src/addressbook.c
index 8eed7c9aea593888982333bb82ef0bf42dc9bc59..2f354c4e4cbd1897eb25c51bd660cb4fc89195ea 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.2.2.23 -r 1.2.2.24 src/gtk/filesel.c;  ) > 2.0.0cvs153.patchset
 ( cvs diff -u -r 1.96.2.103 -r 1.96.2.104 src/textview.c;  ) > 2.0.0cvs154.patchset
 ( cvs diff -u -r 1.60.2.50 -r 1.60.2.51 src/addressbook.c;  ) > 2.0.0cvs155.patchset
+( cvs diff -u -r 1.60.2.51 -r 1.60.2.52 src/addressbook.c;  ) > 2.0.0cvs156.patchset
index f8fec8a1f7abb1ad40e5fd98e7b829257522e08e..de106a2d098deaf4660cf241344fa2b88b6cc41c 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=155
+EXTRA_VERSION=156
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 4c590e13f2169a9d76c03aed5ea647430c4fcc43..159072f8ff318f53c4193159811d0124b5f9f8d9 100644 (file)
@@ -308,9 +308,6 @@ static gboolean addressbook_entry_key_pressed       (GtkWidget      *widget,
 static gint addressbook_treenode_compare_func  (GtkCList       *clist,
                                                 gconstpointer   ptr1,
                                                 gconstpointer   ptr2);
-static gint addressbook_list_compare_func      (GtkCList       *clist,
-                                                gconstpointer   ptr1,
-                                                gconstpointer   ptr2);
 static void addressbook_folder_load_one_person (GtkCTree *clist, 
                                                 ItemPerson *person,  
                                                 AddressTypeControlItem *atci, 
@@ -685,13 +682,27 @@ static void addressbook_size_allocate_cb(GtkWidget *widget,
        prefs_common.addressbookwin_height = allocation->height;
 }
 
+static gint list_case_sort(
+       GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2 )
+{
+       GtkCell *cell1 = ((GtkCListRow *)ptr1)->cell;
+       GtkCell *cell2 = ((GtkCListRow *)ptr2)->cell;
+       gchar *name1 = NULL, *name2 = NULL;
+
+       if( cell1 ) name1 = cell1->u.text;
+       if( cell2 ) name2 = cell2->u.text;
+       if( ! name1 ) return ( name2 != NULL );
+       if( ! name2 ) return -1;
+       return strcasecmp( name1, name2 );
+}
+
 static void addressbook_sort_list(GtkCList *clist, const gint col,
                const GtkSortType sort_type)
 {
        gint pos;
        GtkWidget *hbox, *label, *arrow;
 
-       gtk_clist_set_compare_func(clist, NULL);
+       gtk_clist_set_compare_func(clist, list_case_sort);
        gtk_clist_set_sort_type(clist, sort_type);
        gtk_clist_set_sort_column(clist, col);  
 
@@ -893,9 +904,8 @@ static void addressbook_create(void)
                                   COL_NAME_WIDTH);
        gtk_clist_set_column_width(GTK_CLIST(clist), COL_ADDRESS,
                                   COL_ADDRESS_WIDTH);
-       gtk_clist_set_compare_func(GTK_CLIST(clist),
-                                  addressbook_list_compare_func);
 
+       addressbook_sort_list(clist, COL_NAME, GTK_SORT_ASCENDING);
        g_signal_connect(G_OBJECT(GTK_CLIST(clist)->column[COL_NAME].button),
                "clicked", G_CALLBACK(addressbook_name_clicked), clist);
        g_signal_connect(G_OBJECT(GTK_CLIST(clist)->column[COL_ADDRESS].button),
@@ -3650,38 +3660,6 @@ static gint addressbook_treenode_compare_func(
        return g_utf8_collate( name1, name2 );
 }
 
-/*
-* Comparison using object names and types.
-*/
-static gint addressbook_list_compare_func(
-       GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2 )
-{
-       AddrItemObject *aio1 = ((GtkCListRow *)ptr1)->data;
-       AddrItemObject *aio2 = ((GtkCListRow *)ptr2)->data;
-       gchar *name1 = NULL, *name2 = NULL;
-
-       /* Order by cell contents */
-       name1 = ADDRITEM_NAME( aio1 );
-       name2 = ADDRITEM_NAME( aio2 );
-
-       if( aio1->type == aio2->type ) {
-               /* Order by name */
-               if( ! name1 ) return ( name2 != NULL );
-               if( ! name2 ) return -1;
-               return g_utf8_collate( name1, name2 );
-       }
-       else {
-               /* Order groups before person */
-               if( aio1->type == ITEMTYPE_GROUP ) {
-                       return -1;
-               }
-               else if( aio2->type == ITEMTYPE_GROUP ) {
-                       return 1;
-               }
-               return 0;
-       }
-}
-
 static void addressbook_new_book_cb( gpointer data, guint action, GtkWidget *widget ) {
        AdapterDSource *ads;
        AdapterInterface *adapter;