blam r570 - in trunk: . libblam src



Author: cmartin
Date: Sat Apr 26 09:27:30 2008
New Revision: 570
URL: http://svn.gnome.org/viewvc/blam?rev=570&view=rev

Log:
Sort the channel list in managed code.

This removes the last dependency on libblam/blam-utils.c and
GTK+ devel files.


Removed:
   trunk/libblam/blam-utils.c
   trunk/libblam/blam-utils.h
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/libblam/Makefile.am
   trunk/src/ChannelList.cs
   trunk/src/Utils.cs

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Sat Apr 26 09:27:30 2008
@@ -221,7 +221,6 @@
 
 dnl libblam
 PKG_CHECK_MODULES(LIBBLAM,
-		  gtk+-2.0 >= 2.2
                   $MOZILLA-gtkmozembed)
 AC_SUBST(LIBBLAM_CFLAGS)
 AC_SUBST(LIBBLAM_LIBS)

Modified: trunk/libblam/Makefile.am
==============================================================================
--- trunk/libblam/Makefile.am	(original)
+++ trunk/libblam/Makefile.am	Sat Apr 26 09:27:30 2008
@@ -21,8 +21,6 @@
 libblam_la_SOURCES =				\
         blam-gecko-utils.cpp                    \
         blam-gecko-utils.h                      \
-	blam-utils.c                            \
-	blam-utils.h                            \
 	bacon-message-connection.c              \
 	bacon-message-connection.h
 

Modified: trunk/src/ChannelList.cs
==============================================================================
--- trunk/src/ChannelList.cs	(original)
+++ trunk/src/ChannelList.cs	Sat Apr 26 09:27:30 2008
@@ -69,10 +69,8 @@
             this.HeadersVisible = false;
 
             // Sort the list
-            mChannelSortFunc = new SortFunc (ChannelSortFunc);
-            Utils.TreeSetSortFunc (this.Model.Handle, 1, 
-                                   mChannelSortFunc);
-            ((ListStore)this.Model).SetSortColumnId (1, SortType.Ascending);    
+            (Model as ListStore).DefaultSortFunc = ChannelSort;
+            ((ListStore)this.Model).SetSortColumnId (-1, SortType.Ascending);
 
             // Right click popup
             this.popupMenu = new ChannelMenu();
@@ -86,6 +84,12 @@
             GLib.Idle.Add(new GLib.IdleHandler(IdleAdd));
         }
 
+        private void ForceResort()
+        {
+            (Model as ListStore).SetSortColumnId(-1, SortType.Descending);
+            (Model as ListStore).SetSortColumnId(-1, SortType.Ascending);
+        }
+
         private bool IdleAdd()
         {
             while (channelEnumerator.MoveNext ()) {
@@ -120,6 +124,9 @@
             if (!iter.Equals(TreeIter.Zero)) {
                 this.Model.EmitRowChanged (this.Model.GetPath(iter), iter);
             }
+
+            ForceResort();
+
         }
 
         public void Remove (Channel channel)
@@ -210,16 +217,12 @@
             }
         }
 
-        private SortFunc mChannelSortFunc;
-        private int ChannelSortFunc (IntPtr a, IntPtr b)
+        private int ChannelSort(TreeModel model, TreeIter ia, TreeIter ib)
         {
-            TreeIter iterA = TreeIter.New (a);
-            TreeIter iterB = TreeIter.New (b);
-
-            Channel channelA = (Channel)this.Model.GetValue (iterA, 0);
-            Channel channelB = (Channel)this.Model.GetValue (iterB, 0);
+            Channel a = Model.GetValue(ia, 0) as Channel;
+            Channel b = Model.GetValue(ib, 0) as Channel;
 
-            return channelA.Name.CompareTo (channelB.Name);
+            return a.Name.CompareTo(b.Name);
         }
 
         protected override bool OnButtonPressEvent (EventButton bEvent)

Modified: trunk/src/Utils.cs
==============================================================================
--- trunk/src/Utils.cs	(original)
+++ trunk/src/Utils.cs	Sat Apr 26 09:27:30 2008
@@ -23,16 +23,6 @@
 
     public class Utils {
 
-	[DllImport("libblam.so")]
-	    static extern void blam_tree_model_set_sort_func (IntPtr w,
-							      int col,
-							      SortFunc func);
-	public static void TreeSetSortFunc (IntPtr w, int col, SortFunc f)
-	{
-	    blam_tree_model_set_sort_func (w, col, f);
-	}
-
-        
         [DllImport("libblam.so")]
             static extern void blam_gecko_utils_init_services ();
         public static void GeckoInit ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]