2 /* Circ.Frontend.GtkSharp : GTK# frontend for Circ
3 * Copyright (C) 2007 LAVAL Jérémie
5 * This file is licensed under the terms of the LGPL.
7 * For the complete licence see the file COPYING.
12 using Circ
.Controller
;
16 namespace Circ
.Frontend
.GtkSharp
18 public partial class ChannelPanel
: IDiscussionPanel
21 TransformationPool
<GtkText
> pool
= new TransformationPool
<GtkText
>();
23 public void SendMessage(string message
)
25 ctrl
.Backend
.SendMessage(message
);
28 public void AddNewMessage(DateTime timestamp
, string author
, string mess
, bool hl
)
30 Gtk
.Application
.Invoke( delegate {
31 TextIter end
= buffer
.EndIter
;
32 string message
= mess
+ Environment
.NewLine
;
34 buffer
.InsertWithTagsByName(ref end
, FormatDate(ref timestamp
), "time");
35 buffer
.InsertWithTagsByName(ref end
, author
+ " : ", "author");
37 buffer
.InsertWithTagsByName(ref end
, message
, "hl");
41 buffer
.InsertWithTagsByName(ref end
, message
, "message");
42 messages
.ScrollToEnd();
46 public void AddSelfMessage(string whoami
, string message
)
48 Gtk
.Application
.Invoke( delegate {
49 TextIter end
= buffer
.EndIter
;
50 string mess
= message
+ Environment
.NewLine
;
52 DateTime timestamp
= DateTime
.Now
;
53 buffer
.InsertWithTagsByName(ref end
, FormatDate(ref timestamp
), "time");
54 buffer
.InsertWithTagsByName(ref end
, whoami
+ mess
, "itsme");
56 messages
.ScrollToEnd();
60 string FormatDate(ref DateTime timestamp
)
62 return '[' + timestamp
.ToString("T") + "] ";
67 ((Window
)this.Toplevel
).UrgencyHint
= true;
68 // TODO: reorganize notebook tabs like lasts said
69 /*Label tmp = (Label)((ServerPanel)this.Parent).GetMenuWidget(this);
70 tmp.Markup = "<span foreground=\"red\">" + tmp.Text + "</span>";*/
72 /*string FormatMessage(string timestamp, string author, string message)
74 System.Text.StringBuilder sb = new System.Text.StringBuilder(timestamp.Length +
75 author.Length + message.Length + 10)
83 sb.AppendLine(message);
88 public void AddNewNotice(string notice
)
90 Gtk
.Application
.Invoke( delegate(object sen
, EventArgs ee
) {
91 TextIter end
= buffer
.EndIter
;
92 buffer
.InsertWithTagsByName(ref end
, '*' + notice
+ Environment
.NewLine
,
94 messages
.ScrollToEnd();
98 public void ChangeTopic(string topic
, string author
, DateTime timestamp
)
100 Gtk
.Application
.Invoke(delegate {
101 System
.Text
.StringBuilder sb
= new System
.Text
.StringBuilder(topic
);
102 sb
.Replace('\n', ' ');
103 sb
.Replace('\r', ' ');
104 sb
.Replace(Environment
.NewLine
, " ");
105 this.topicEntry
.Text
= sb
.ToString();
109 public void AddUser(string[] users
)
111 this.users
.AddUser(users
);
114 public void AddUser(string user
)
116 this.users
.AddUser(user
);
119 public void RemoveUser(string users
)
121 this.users
.RemoveUser(users
);
124 public bool UseEmoticons
{
133 public bool UseUrlHighlight
{
142 public void DoAutocompletation(object sender
, KeyPressEventArgs e
)
144 if (e
.Event
.Key
!= Gdk
.Key
.Tab
)
147 Entry temp
= (Entry
) sender
;
148 // TODO: build it using the Nick Tree
149 foreach (string user
in users
.Users
) {
150 if (user
.Length
> temp
.Text
.Length
&& (user
.StartsWith(temp
.Text
, StringComparison
.Ordinal
) ||
151 user
.Equals(temp
.Text
, StringComparison
.Ordinal
)))
152 temp
.Text
= user
+ ": ";
158 internal string ChannelName
{
160 return ctrl
.Backend
.Name
;
164 internal ServerPanel ServerPanel
{