diff --git a/src/Frontend-GNOME-IRC/IrcPersonChatView.cs b/src/Frontend-GNOME-IRC/IrcPersonChatView.cs index 6b31a19..a145382 100644 --- a/src/Frontend-GNOME-IRC/IrcPersonChatView.cs +++ b/src/Frontend-GNOME-IRC/IrcPersonChatView.cs @@ -30,15 +30,22 @@ using System; using System.Globalization; using Smuxi.Engine; using Smuxi.Common; +using Gtk; namespace Smuxi.Frontend.Gnome { [ChatViewInfo(ChatType = ChatType.Person, ProtocolManagerType = typeof(IrcProtocolManager))] public class IrcPersonChatView : PersonChatView { + private PersonChatModel _personChat; + private IrcProtocolManager _IrcProtocolManager; + public IrcPersonChatView(PersonChatModel personChat) : base(personChat) { Trace.Call(personChat); + _personChat = personChat; + _IrcProtocolManager = (IrcProtocolManager)personChat.ProtocolManager; + OutputTextView.PopulatePopup += new PopulatePopupHandler(_OnOutputTextViewPopulatePopup, IntPtr.Zero); } public override void Close() @@ -50,5 +57,85 @@ namespace Smuxi.Frontend.Gnome // BUG: out of scope? Frontend.Session.RemoveChat(ChatModel); } + + public void _OnOutputTextViewPopulatePopup(object sender, PopulatePopupArgs a) + { + Menu menu = a.Menu; + + ImageMenuItem whois_item = new ImageMenuItem(_("_Whois")); + whois_item.Activated += new EventHandler(_OnContextMenuWhois); + menu.Append(whois_item); + + Gtk.ImageMenuItem ctcp_item = new Gtk.ImageMenuItem(_("_CTCP")); + Gtk.Menu ctcp_submenu = new Menu(); + Gtk.ImageMenuItem ctcp_version_item = new Gtk.ImageMenuItem(_("_Version")); + ctcp_version_item.Activated += _OnContextMenuCTCPVersionActivated; + ctcp_submenu.Append(ctcp_version_item); + + Gtk.ImageMenuItem ctcp_ping_item = new Gtk.ImageMenuItem(_("_Ping")); + ctcp_ping_item.Activated += _OnContextMenuCTCPPingActivated; + ctcp_submenu.Append(ctcp_ping_item); + + Gtk.ImageMenuItem ctcp_time_item = new Gtk.ImageMenuItem(_("_Time")); + ctcp_time_item.Activated += _OnContextMenuCTCPTimeActivated; + ctcp_submenu.Append(ctcp_time_item); + + ctcp_item.Submenu = ctcp_submenu; + menu.Append(ctcp_item); + + menu.ShowAll(); + } + + private void _OnContextMenuWhois(object sender, EventArgs e) + { + Trace.Call(sender, e); + + _IrcProtocolManager.CommandWhoIs( + new CommandModel( + Frontend.FrontendManager, + ChatModel, + _personChat.Person.ID + ) + ); + } + + private void _OnContextMenuCTCPVersionActivated(object sender, EventArgs e) + { + Trace.Call(sender, e); + + _IrcProtocolManager.CommandVersion( + new CommandModel( + Frontend.FrontendManager, + ChatModel, + _personChat.Person.ID + ) + ); + } + + private void _OnContextMenuCTCPPingActivated(object sender, EventArgs e) + { + Trace.Call(sender, e); + + _IrcProtocolManager.CommandPing( + new CommandModel( + Frontend.FrontendManager, + ChatModel, + _personChat.Person.ID + ) + ); + } + + private void _OnContextMenuCTCPTimeActivated(object sender, EventArgs e) + { + Trace.Call(sender, e); + + _IrcProtocolManager.CommandTime( + new CommandModel( + Frontend.FrontendManager, + ChatModel, + _personChat.Person.ID + ) + ); + } } } diff --git a/src/Frontend-GNOME/Chats/ChatView.cs b/src/Frontend-GNOME/Chats/ChatView.cs index b923b1d..da8f7cb 100644 --- a/src/Frontend-GNOME/Chats/ChatView.cs +++ b/src/Frontend-GNOME/Chats/ChatView.cs @@ -765,7 +765,7 @@ namespace Smuxi.Frontend.Gnome Close(); } - private static string _(string msg) + public static string _(string msg) { return Mono.Unix.Catalog.GetString(msg); }