void ShowSource(ChatView chatView, MessageModel msg) { Trace.Call(chatView, msg); string sourceId; var time = (Int64) ((msg.TimeStamp - UnixEpoch).TotalMilliseconds * 1000L); if (Sources.TryGetValue(chatView, out sourceId)) { // update time of existing source App.SetSourceTime(sourceId, time); return; } // TODO: TEST ME! sourceId = chatView.ID; string iconName = null; string label = null; if (chatView is PersonChatView) { iconName = "smuxi-person-chat"; label = chatView.Name; } else if (chatView is GroupChatView) { iconName = "smuxi-group-chat"; var nick = GetNick(msg); if (nick == null) { label = chatView.Name; } else { label = String.Format("{0} ({1})", chatView.Name, nick); } } var theme = Gtk.IconTheme.Default; GLib.Icon icon = null; if (Frontend.HasSystemIconTheme && iconName != null && theme.HasIcon(iconName)) { icon = new GLib.ThemedIcon(iconName); } else if (iconName != null && theme.HasIcon(iconName)) { // icon wasn't in the system icon theme var iconInfo = theme.LookupIcon(iconName, 256, Gtk.IconLookupFlags.UseBuiltin); if (!String.IsNullOrEmpty(iconInfo.Filename) && File.Exists(iconInfo.Filename)) { icon = new GLib.FileIcon( GLib.FileFactory.NewForPath(iconInfo.Filename) ); } } App.AppendSource(sourceId, icon, label); App.SetSourceTime(sourceId, time); App.DrawAttention(sourceId); Sources.Add(chatView, sourceId); }
void ShowSource(ChatView chatView, MessageModel msg) { Trace.Call(chatView, msg); string sourceId; var time = (Int64)((msg.TimeStamp - UnixEpoch).TotalMilliseconds * 1000L); if (Sources.TryGetValue(chatView, out sourceId)) { // update time of existing source App.SetSourceTime(sourceId, time); return; } // TODO: TEST ME! sourceId = chatView.ID; string iconName = null; string label = null; if (chatView is PersonChatView) { iconName = "smuxi-person-chat"; label = chatView.Name; } else if (chatView is GroupChatView) { iconName = "smuxi-group-chat"; var nick = GetNick(msg); if (nick == null) { label = chatView.Name; } else { label = String.Format("{0} ({1})", chatView.Name, nick); } } var theme = Gtk.IconTheme.Default; GLib.Icon icon = null; if (Frontend.HasSystemIconTheme && iconName != null && theme.HasIcon(iconName)) { icon = new GLib.ThemedIcon(iconName); } else if (iconName != null && theme.HasIcon(iconName)) { // icon wasn't in the system icon theme var iconInfo = theme.LookupIcon(iconName, 256, Gtk.IconLookupFlags.UseBuiltin); if (!String.IsNullOrEmpty(iconInfo.Filename) && File.Exists(iconInfo.Filename)) { icon = new GLib.FileIcon( GLib.FileFactory.NewForPath(iconInfo.Filename) ); } } App.AppendSource(sourceId, icon, label); App.SetSourceTime(sourceId, time); App.DrawAttention(sourceId); Sources.Add(chatView, sourceId); }