blam r640 - in trunk: . src
- From: cmartin svn gnome org
- To: svn-commits-list gnome org
- Subject: blam r640 - in trunk: . src
- Date: Sun, 14 Sep 2008 21:16:59 +0000 (UTC)
Author: cmartin
Date: Sun Sep 14 21:16:59 2008
New Revision: 640
URL: http://svn.gnome.org/viewvc/blam?rev=640&view=rev
Log:
Implement adding a channel to a group.
This code is ugly and uses unmanaged memory, but I saw no
other way to pass the information.
Modified:
trunk/ChangeLog
trunk/src/ChannelList.cs
Modified: trunk/src/ChannelList.cs
==============================================================================
--- trunk/src/ChannelList.cs (original)
+++ trunk/src/ChannelList.cs Sun Sep 14 21:16:59 2008
@@ -352,7 +352,7 @@
return false;
}
- private TreeIter FindChannel(IChannel channel)
+ public TreeIter FindChannel(IChannel channel)
{
findChannel = channel;
foundIter = TreeIter.Zero;
@@ -378,8 +378,12 @@
public event MenuItemSelectedHandler RemoveSelected;
public event MenuItemSelectedHandler RefreshSelected;
+ private ArrayList allocs;
+
public void Activate (Gdk.EventButton eb)
{
+ allocs = new ArrayList();
+
Gtk.Menu popup_menu = new Gtk.Menu ();
GtkUtil.AppendMenuItem (popup_menu,
@@ -400,10 +404,58 @@
Catalog.GetString ("Remo_ve"),
"gtk-remove",
new EventHandler (EmitRemoveCb), true);
+ popup_menu.Append(BuildGroupMenu());
popup_menu.Popup (null, null, null,
eb.Button, eb.Time);
}
+ private Gtk.MenuItem BuildGroupMenu()
+ {
+ MenuItem item = new MenuItem(Catalog.GetString("M_ove to group"));
+ Menu menu = new Menu();
+
+ foreach(ChannelGroup group in Application.TheApp.CCollection.Groups){
+ MenuItem i = new MenuItem(group.Name);
+ i.UserData = Marshal.StringToHGlobalUni(group.Name);
+ allocs.Add(i.UserData);
+ i.Activated += MoveChannelToGroupCb;
+ i.Sensitive = true;
+ menu.Append(i);
+ i.Show();
+ }
+
+ item.Sensitive = true;
+ item.Submenu = menu;
+ item.Show();
+
+ return item;
+ }
+
+ public void MoveChannelToGroupCb(object obj, EventArgs args)
+ {
+ MenuItem item = obj as MenuItem;
+ string groupname = Marshal.PtrToStringUni(item.UserData);
+ TreeModel model;
+ TreeIter iter;
+ Application.TheApp.ChannelList.Selection.GetSelected(out model, out iter);
+ Channel chan = model.GetValue(iter, 0) as Channel;
+
+ foreach(ChannelGroup group in Application.TheApp.CCollection.Groups){
+ if(group.Name == groupname){
+ group.Channels.Add(chan);
+ iter = Application.TheApp.ChannelList.FindChannel(group as IChannel);
+ (model as TreeStore).AppendValues(iter, chan);
+ model.EmitRowChanged(model.GetPath(iter), iter);
+ }
+ }
+
+ Application.TheApp.CCollection.Remove(chan as IChannel);
+
+ foreach(IntPtr ptr in allocs){
+ Marshal.FreeHGlobal(ptr);
+ }
+ }
+
public void EmitMarkAsReadCb (object obj, EventArgs args)
{
if (MarkAsReadSelected != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]