blam r674 - trunk/src
- From: cmartin svn gnome org
- To: svn-commits-list gnome org
- Subject: blam r674 - trunk/src
- Date: Sun, 8 Mar 2009 23:46:54 +0000 (UTC)
Author: cmartin
Date: Sun Mar 8 23:46:54 2009
New Revision: 674
URL: http://svn.gnome.org/viewvc/blam?rev=674&view=rev
Log:
Implement taking a channel out of a group.
If we detect that the drop was between two rows, we take it out.
Modified:
trunk/src/ChannelList.cs
Modified: trunk/src/ChannelList.cs
==============================================================================
--- trunk/src/ChannelList.cs (original)
+++ trunk/src/ChannelList.cs Sun Mar 8 23:46:54 2009
@@ -115,25 +115,39 @@
TreePath path;
TreeViewDropPosition pos;
TreeIter iter, tmp_iter;
- IChannel chan = GetSelected();
- tmp_iter = chan.Iter;
+ IChannel src = GetSelected();
+ tmp_iter = src.Iter;
GetDestRowAtPos(args.X, args.Y, out path, out pos);
Model.GetIter(out iter, path);
- ChannelGroup group = Model.GetValue(iter, 0) as ChannelGroup;
+ IChannel dst = Model.GetValue(iter, 0) as ChannelGroup;
- /*
- * A channel can't become a group and a group can't be
- * inside another group.
- * FIXME: Make it possible for a group to be inside another group.
- */
- if(Model.GetValue(iter, 0) is Channel || GetSelected() is ChannelGroup){
- return;
+ /* 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;
+ }
+ }
+ } else {
+ /*
+ * A channel can't become a group and a group can't be
+ * inside another group.
+ * FIXME: Make it possible for a group to be inside another group.
+ */
+ if(dst is Channel || src is ChannelGroup){
+ return;
+ }
+
+ src.Iter = (Model as TreeStore).AppendValues(iter, src);
+ (dst as ChannelGroup).Channels.Add(src);
+ (Model as TreeStore).Remove(ref tmp_iter);
+ Model.EmitRowChanged(path, iter);
}
-
- chan.Iter = (Model as TreeStore).AppendValues(iter, chan);
- group.Channels.Add(chan);
- Model.EmitRowChanged(path, iter);
- (Model as TreeStore).Remove(ref tmp_iter);
}
private bool IdleAdd()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]