blam r678 - trunk/src
- From: cmartin svn gnome org
- To: svn-commits-list gnome org
- Subject: blam r678 - trunk/src
- Date: Tue, 10 Mar 2009 01:39:19 +0000 (UTC)
Author: cmartin
Date: Tue Mar 10 01:39:19 2009
New Revision: 678
URL: http://svn.gnome.org/viewvc/blam?rev=678&view=rev
Log:
Fix a couple of DnD corner cases.
Make moving to into the same group and out of a group not fail horribly.
Modified:
trunk/src/Channel.cs
trunk/src/ChannelGroup.cs
trunk/src/ChannelList.cs
Modified: trunk/src/Channel.cs
==============================================================================
--- trunk/src/Channel.cs (original)
+++ trunk/src/Channel.cs Tue Mar 10 01:39:19 2009
@@ -91,6 +91,7 @@
}
}
+ [XmlIgnore]
public Gtk.TreeIter Iter {
get {
return mIter;
Modified: trunk/src/ChannelGroup.cs
==============================================================================
--- trunk/src/ChannelGroup.cs (original)
+++ trunk/src/ChannelGroup.cs Tue Mar 10 01:39:19 2009
@@ -18,6 +18,7 @@
[XmlElement("Channel", typeof(Channel))] public ArrayList Channels;
private ArrayList dummy;
private Gtk.TreeIter mIter;
+ private IChannel mParent = null;
public ArrayList Items {
get { /* FIXME: Cache this value. */
@@ -79,6 +80,7 @@
}
}
+ [XmlIgnore]
public Gtk.TreeIter Iter {
get {
return mIter;
@@ -88,6 +90,11 @@
}
}
+ public void Add(IChannel chan)
+ {
+ Channels.Add(chan);
+ }
+
public ChannelGroup() : base()
{
if(Channels == null)
Modified: trunk/src/ChannelList.cs
==============================================================================
--- trunk/src/ChannelList.cs (original)
+++ trunk/src/ChannelList.cs Tue Mar 10 01:39:19 2009
@@ -123,40 +123,35 @@
/* We wan't to take a channel out of a group. */
if(pos == TreeViewDropPosition.After || pos == TreeViewDropPosition.Before){
- src.Iter = (Model as TreeStore).AppendValues(src);
- (Model as TreeStore).Remove(ref tmp_iter);
- /* Remove from the group. */
- foreach(ChannelGroup grp in Blam.Application.TheApp.CCollection.Groups){
- if(grp.Channels.Contains(src as Channel)){
- grp.Channels.Remove(src as Channel);
- break;
- }
+ TreePath tmp_path = path.Copy();
+ tmp_path.Up();
+ TreePath tmp_path_src = Model.GetPath(src.Iter).Copy();
+ tmp_path_src.Up();
+ if(Model.GetPath(src.Iter).Depth == 1 || // Outside any group.
+ tmp_path == tmp_path_src){ // Same parent.
+ return;
}
- } else {
+
+ Blam.Application.TheApp.CCollection.Remove(src);
+ Blam.Application.TheApp.CCollection.Add(src);
+ } else { /* Move into a group or between groups. */
/*
* A channel can't become a group and a group can't be
- * inside another group.
+ * inside another group and it doesn't make sense to move
+ * it into the same group.
* FIXME: Make it possible for a group to be inside another group.
*/
- if(dst is Channel || src is ChannelGroup || dst == null){
+ TreePath tmp_path_src = Model.GetPath(src.Iter).Copy();
+ tmp_path_src.Up();
+ if(dst is Channel || src is ChannelGroup || dst == null ||
+ path == tmp_path_src){ // Move to the same group
return;
}
- /*
- * If the channel was inside a group, we need to delete it there as well.
- * FIXME: Move this code into a helper function.
- */
- foreach(ChannelGroup grp in Blam.Application.TheApp.CCollection.Groups){
- if(grp.Channels.Contains(src as Channel)){
- grp.Channels.Remove(src as Channel);
- break;
- }
- }
-
- src.Iter = (Model as TreeStore).AppendValues(iter, src);
- (dst as ChannelGroup).Channels.Add(src);
- (Model as TreeStore).Remove(ref tmp_iter);
+ Blam.Application.TheApp.CCollection.Remove(src);
+ (dst as ChannelGroup).Add(src);
+ src.Iter = (Model as TreeStore).AppendValues(dst.Iter, src);
Model.EmitRowChanged(path, iter);
}
}
@@ -178,8 +173,7 @@
public void Add (IChannel channel)
{
- TreeIter iter = (this.Model as TreeStore).AppendValues(channel);
- channel.Iter = iter;
+ channel.Iter = (this.Model as TreeStore).AppendValues(channel);
}
public void AddGroup(IChannel channel)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]