[smuxi] Frontend-GNOME: moved user count from user list to window title
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi] Frontend-GNOME: moved user count from user list to window title
- Date: Sun, 11 May 2014 15:49:08 +0000 (UTC)
commit 32885265bd04e667b0c94caab64ee1d3b6056556
Author: Mirco Bauer <meebey meebey net>
Date: Fri Dec 6 00:21:30 2013 +0100
Frontend-GNOME: moved user count from user list to window title
BUG: the initial width of the user list is now incorrect and has to be fixed!
src/Frontend-GNOME/MainWindow.cs | 22 +++++++++++++++++++++
src/Frontend-GNOME/Views/Chats/GroupChatView.cs | 24 +++++++++++++---------
2 files changed, 36 insertions(+), 10 deletions(-)
---
diff --git a/src/Frontend-GNOME/MainWindow.cs b/src/Frontend-GNOME/MainWindow.cs
index e3c92fa..4cd9365 100644
--- a/src/Frontend-GNOME/MainWindow.cs
+++ b/src/Frontend-GNOME/MainWindow.cs
@@ -38,6 +38,7 @@ namespace Smuxi.Frontend.Gnome
private static readonly log4net.ILog f_Logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endif
private bool _IsFullscreen;
+ string f_NetworkStatus;
Gtk.Statusbar NetworkStatusbar { get; set; }
Gtk.Statusbar Statusbar { get; set; }
@@ -100,6 +101,7 @@ namespace Smuxi.Frontend.Gnome
}
NetworkStatusbar.Pop(0);
NetworkStatusbar.Push(0, value);
+ f_NetworkStatus = value;
}
}
@@ -351,6 +353,9 @@ namespace Smuxi.Frontend.Gnome
if (chatView == null) {
chatView = ChatViewManager.CurrentChatView;
}
+ if (protocolStatus == null) {
+ protocolStatus = f_NetworkStatus;
+ }
if (chatView == null) {
return;
}
@@ -360,6 +365,14 @@ namespace Smuxi.Frontend.Gnome
title = String.Empty;
} else if (chatView is ProtocolChatView) {
title = protocolStatus;
+ } else if (chatView is GroupChatView) {
+ var groupChatView = (GroupChatView) chatView;
+ var users = String.Format(_("{0} Users"),
+ groupChatView.Participants.Count);
+ title = String.Format("{0} ({1}) @ {2}",
+ chatView.Name,
+ users,
+ protocolStatus);
} else {
title = String.Format("{0} @ {1}",
chatView.Name,
@@ -578,6 +591,15 @@ namespace Smuxi.Frontend.Gnome
}
Entry.GrabFocus();
};
+ if (e.ChatView is GroupChatView) {
+ var groupChatView = (GroupChatView) e.ChatView;
+ groupChatView.ParticipantsChanged += (o, args) => {
+ if (ChatViewManager.CurrentChatView != groupChatView) {
+ return;
+ }
+ UpdateTitle(groupChatView, null);
+ };
+ }
UpdateProgressBar();
}
diff --git a/src/Frontend-GNOME/Views/Chats/GroupChatView.cs b/src/Frontend-GNOME/Views/Chats/GroupChatView.cs
index 88d96de..8964930 100644
--- a/src/Frontend-GNOME/Views/Chats/GroupChatView.cs
+++ b/src/Frontend-GNOME/Views/Chats/GroupChatView.cs
@@ -56,6 +56,8 @@ namespace Smuxi.Frontend.Gnome
protected Gtk.CellRendererText IdentityNameCellRenderer { get; set; }
Gtk.ScrolledWindow PersonScrolledWindow { get; set; }
+ public event EventHandler ParticipantsChanged;
+
public override bool HasSelection {
get {
return base.HasSelection ||
@@ -202,6 +204,7 @@ namespace Smuxi.Frontend.Gnome
return !person.IdentityName.StartsWith(key, StringComparison.InvariantCultureIgnoreCase);
};
tv.EnableSearch = true;
+ tv.HeadersVisible = false;
tv.RowActivated += new Gtk.RowActivatedHandler(OnPersonsRowActivated);
tv.FocusOutEvent += OnPersonTreeViewFocusOutEvent;
@@ -299,7 +302,7 @@ namespace Smuxi.Frontend.Gnome
_TopicTextView.Buffer.Text = String.Empty;
_PersonListStore.Clear();
- UpdatePersonCount();
+ OnParticipantsChanged(EventArgs.Empty);
}
public override void Sync()
@@ -365,7 +368,7 @@ namespace Smuxi.Frontend.Gnome
_PersonTreeView.SearchColumn = 0;
PersonScrolledWindow.CheckResize();
- UpdatePersonCount();
+ OnParticipantsChanged(EventArgs.Empty);
// TRANSLATOR: this string will be appended to the one above
status += String.Format(" {0}", _("done."));
@@ -398,12 +401,6 @@ namespace Smuxi.Frontend.Gnome
}
}
- protected void UpdatePersonCount()
- {
- _IdentityNameColumn.Title = String.Format(_("Person") + " ({0})",
- _PersonListStore.IterNChildren());
- }
-
public void AddPerson(PersonModel person)
{
Trace.Call(person);
@@ -415,7 +412,7 @@ namespace Smuxi.Frontend.Gnome
_PersonListStore.AppendValues(person);
Participants.Add(person);
- UpdatePersonCount();
+ OnParticipantsChanged(EventArgs.Empty);
}
public void UpdatePerson(PersonModel oldPerson, PersonModel newPerson)
@@ -487,7 +484,7 @@ namespace Smuxi.Frontend.Gnome
}
}
- UpdatePersonCount();
+ OnParticipantsChanged(EventArgs.Empty);
}
public override void ApplyConfig(UserConfig config)
@@ -596,6 +593,13 @@ namespace Smuxi.Frontend.Gnome
return person1.CompareTo(person2);
}
+ protected virtual void OnParticipantsChanged(EventArgs e)
+ {
+ if (ParticipantsChanged != null) {
+ ParticipantsChanged(this, EventArgs.Empty);
+ }
+ }
+
protected virtual void OnPersonsRowActivated(object sender, Gtk.RowActivatedArgs e)
{
Trace.Call(sender, e);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]