diff --git a/Configuration/UserConfig.cs b/Configuration/UserConfig.cs index fb5d1850..f9dac462 100644 --- a/Configuration/UserConfig.cs +++ b/Configuration/UserConfig.cs @@ -19,6 +19,7 @@ sealed class UserConfig{ // START OF CONFIGURATION public WindowState BrowserWindow { get; set; } + public bool DisplayNotificationColumn { get; set; } public bool DisplayNotificationTimer { get; set; } public bool NotificationTimerCountDown { get; set; } public bool NotificationNonIntrusiveMode { get; set; } diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 657d4819..30d6a52c 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -57,10 +57,10 @@ public void OpenContextMenu(){ form.InvokeAsyncSafe(form.OpenContextMenu); } - public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){ + public void OnTweetPopup(string columnName, string tweetHtml, string tweetUrl, int tweetCharacters){ notification.InvokeAsyncSafe(() => { form.OnTweetNotification(); - notification.ShowNotification(new TweetNotification(tweetHtml, tweetUrl, tweetCharacters)); + notification.ShowNotification(new TweetNotification(columnName, tweetHtml, tweetUrl, tweetCharacters)); }); } diff --git a/Core/Notification/FormNotificationBase.cs b/Core/Notification/FormNotificationBase.cs index 3eb3cfc8..71bd977a 100644 --- a/Core/Notification/FormNotificationBase.cs +++ b/Core/Notification/FormNotificationBase.cs @@ -71,6 +71,7 @@ public bool IsNotificationVisible{ protected readonly Form owner; protected readonly ChromiumWebBrowser browser; + private string currentColumn; private int pauseCounter; public bool IsPaused{ @@ -151,6 +152,7 @@ public virtual void HideNotification(bool loadBlank){ } Location = ControlExtensions.InvisibleLocation; + currentColumn = null; } public virtual void FinishCurrentNotification(){} @@ -175,6 +177,7 @@ protected virtual string GetTweetHTML(TweetNotification tweet){ protected virtual void LoadTweet(TweetNotification tweet){ CurrentUrl = tweet.Url; CurrentQuotedTweetUrl = string.Empty; // load from JS + currentColumn = tweet.Column; browser.LoadHtml(GetTweetHTML(tweet), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks); } @@ -196,7 +199,7 @@ protected virtual void OnNotificationReady(){ } protected virtual void UpdateTitle(){ - Text = Program.BrandName; + Text = string.IsNullOrEmpty(currentColumn) || !Program.UserConfig.DisplayNotificationColumn ? Program.BrandName : Program.BrandName+" - "+currentColumn; } public void DisplayTooltip(string text){ diff --git a/Core/Notification/FormNotificationMain.cs b/Core/Notification/FormNotificationMain.cs index d71330be..4b0a4df5 100644 --- a/Core/Notification/FormNotificationMain.cs +++ b/Core/Notification/FormNotificationMain.cs @@ -165,6 +165,8 @@ public void ShowNotificationForSettings(bool reset){ else{ PrepareAndDisplayWindow(); } + + UpdateTitle(); } public override void HideNotification(bool loadBlank){ diff --git a/Core/Notification/FormNotificationTweet.cs b/Core/Notification/FormNotificationTweet.cs index a8464fe8..d475b9d0 100644 --- a/Core/Notification/FormNotificationTweet.cs +++ b/Core/Notification/FormNotificationTweet.cs @@ -117,7 +117,11 @@ private void LoadNextNotification(){ } protected override void UpdateTitle(){ - Text = tweetQueue.Count > 0 ? Program.BrandName+" ("+tweetQueue.Count+" more left)" : Program.BrandName; + base.UpdateTitle(); + + if (tweetQueue.Count > 0){ + Text = Text+" ("+tweetQueue.Count+" more left)"; + } } protected override void OnNotificationReady(){ diff --git a/Core/Notification/Screenshot/TweetScreenshotManager.cs b/Core/Notification/Screenshot/TweetScreenshotManager.cs index 782f5aa3..ef87de2d 100644 --- a/Core/Notification/Screenshot/TweetScreenshotManager.cs +++ b/Core/Notification/Screenshot/TweetScreenshotManager.cs @@ -44,7 +44,7 @@ public void Trigger(string html, int width, int height){ CanMoveWindow = () => false }; - screenshot.LoadNotificationForScreenshot(new TweetNotification(html, string.Empty, 0), width, height); + screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, string.Empty, 0), width, height); screenshot.Show(); timeout.Start(); } diff --git a/Core/Notification/TweetNotification.cs b/Core/Notification/TweetNotification.cs index 2e018602..21f27aed 100644 --- a/Core/Notification/TweetNotification.cs +++ b/Core/Notification/TweetNotification.cs @@ -35,7 +35,7 @@ public static TweetNotification ExampleTweet{ #endif } - return new TweetNotification(ExampleTweetHTML, "", 95, true); + return new TweetNotification("Home", ExampleTweetHTML, "", 95, true); } } @@ -51,20 +51,28 @@ public enum Position{ TopLeft, TopRight, BottomLeft, BottomRight, Custom } + public string Column{ + get{ + return column; + } + } + public string Url{ get{ return url; } } + private readonly string column; private readonly string html; private readonly string url; private readonly int characters; private readonly bool isExample; - public TweetNotification(string html, string url, int characters) : this(html, url, characters, false){} + public TweetNotification(string column, string html, string url, int characters) : this(column, html, url, characters, false){} - private TweetNotification(string html, string url, int characters, bool isExample){ + private TweetNotification(string column, string html, string url, int characters, bool isExample){ + this.column = column; this.html = html; this.url = url; this.characters = characters; diff --git a/Core/Other/Settings/TabSettingsNotifications.Designer.cs b/Core/Other/Settings/TabSettingsNotifications.Designer.cs index 7fb6ab85..b08373cd 100644 --- a/Core/Other/Settings/TabSettingsNotifications.Designer.cs +++ b/Core/Other/Settings/TabSettingsNotifications.Designer.cs @@ -43,6 +43,7 @@ private void InitializeComponent() { this.labelDurationValue = new System.Windows.Forms.Label(); this.trackBarDuration = new System.Windows.Forms.TrackBar(); this.groupUserInterface = new System.Windows.Forms.GroupBox(); + this.checkColumnName = new System.Windows.Forms.CheckBox(); this.labelIdlePause = new System.Windows.Forms.Label(); this.comboBoxIdlePause = new System.Windows.Forms.ComboBox(); this.checkNonIntrusive = new System.Windows.Forms.CheckBox(); @@ -71,7 +72,7 @@ private void InitializeComponent() { this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance); this.groupNotificationLocation.Location = new System.Drawing.Point(198, 9); this.groupNotificationLocation.Name = "groupNotificationLocation"; - this.groupNotificationLocation.Size = new System.Drawing.Size(183, 256); + this.groupNotificationLocation.Size = new System.Drawing.Size(183, 264); this.groupNotificationLocation.TabIndex = 2; this.groupNotificationLocation.TabStop = false; this.groupNotificationLocation.Text = "Location"; @@ -199,7 +200,7 @@ private void InitializeComponent() { this.groupNotificationDuration.Controls.Add(this.tableLayoutDurationButtons); this.groupNotificationDuration.Controls.Add(this.labelDurationValue); this.groupNotificationDuration.Controls.Add(this.trackBarDuration); - this.groupNotificationDuration.Location = new System.Drawing.Point(9, 160); + this.groupNotificationDuration.Location = new System.Drawing.Point(9, 184); this.groupNotificationDuration.Name = "groupNotificationDuration"; this.groupNotificationDuration.Size = new System.Drawing.Size(183, 89); this.groupNotificationDuration.TabIndex = 1; @@ -297,6 +298,7 @@ private void InitializeComponent() { // // groupUserInterface // + this.groupUserInterface.Controls.Add(this.checkColumnName); this.groupUserInterface.Controls.Add(this.labelIdlePause); this.groupUserInterface.Controls.Add(this.comboBoxIdlePause); this.groupUserInterface.Controls.Add(this.checkNonIntrusive); @@ -304,15 +306,29 @@ private void InitializeComponent() { this.groupUserInterface.Controls.Add(this.checkNotificationTimer); this.groupUserInterface.Location = new System.Drawing.Point(9, 9); this.groupUserInterface.Name = "groupUserInterface"; - this.groupUserInterface.Size = new System.Drawing.Size(183, 145); + this.groupUserInterface.Size = new System.Drawing.Size(183, 169); this.groupUserInterface.TabIndex = 0; this.groupUserInterface.TabStop = false; this.groupUserInterface.Text = "General"; // + // checkColumnName + // + this.checkColumnName.AutoSize = true; + this.checkColumnName.Location = new System.Drawing.Point(9, 21); + this.checkColumnName.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3); + this.checkColumnName.Name = "checkColumnName"; + this.checkColumnName.Size = new System.Drawing.Size(129, 17); + this.checkColumnName.TabIndex = 5; + this.checkColumnName.Text = "Display Column Name"; + this.toolTip.SetToolTip(this.checkColumnName, "Shows column name each notification originated\r\nfrom in the notification window t" + + "itle."); + this.checkColumnName.UseVisualStyleBackColor = true; + // // labelIdlePause // + this.labelIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.labelIdlePause.AutoSize = true; - this.labelIdlePause.Location = new System.Drawing.Point(3, 99); + this.labelIdlePause.Location = new System.Drawing.Point(3, 123); this.labelIdlePause.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelIdlePause.Name = "labelIdlePause"; this.labelIdlePause.Size = new System.Drawing.Size(89, 13); @@ -321,11 +337,11 @@ private void InitializeComponent() { // // comboBoxIdlePause // - this.comboBoxIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.comboBoxIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.comboBoxIdlePause.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxIdlePause.FormattingEnabled = true; - this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 115); + this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 139); this.comboBoxIdlePause.Name = "comboBoxIdlePause"; this.comboBoxIdlePause.Size = new System.Drawing.Size(171, 21); this.comboBoxIdlePause.TabIndex = 4; @@ -334,7 +350,7 @@ private void InitializeComponent() { // checkNonIntrusive // this.checkNonIntrusive.AutoSize = true; - this.checkNonIntrusive.Location = new System.Drawing.Point(9, 67); + this.checkNonIntrusive.Location = new System.Drawing.Point(9, 90); this.checkNonIntrusive.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); this.checkNonIntrusive.Name = "checkNonIntrusive"; this.checkNonIntrusive.Size = new System.Drawing.Size(128, 17); @@ -347,7 +363,7 @@ private void InitializeComponent() { // checkTimerCountDown // this.checkTimerCountDown.AutoSize = true; - this.checkTimerCountDown.Location = new System.Drawing.Point(9, 44); + this.checkTimerCountDown.Location = new System.Drawing.Point(9, 67); this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); this.checkTimerCountDown.Name = "checkTimerCountDown"; this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17); @@ -359,8 +375,8 @@ private void InitializeComponent() { // checkNotificationTimer // this.checkNotificationTimer.AutoSize = true; - this.checkNotificationTimer.Location = new System.Drawing.Point(9, 21); - this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3); + this.checkNotificationTimer.Location = new System.Drawing.Point(9, 44); + this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); this.checkNotificationTimer.Name = "checkNotificationTimer"; this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17); this.checkNotificationTimer.TabIndex = 0; @@ -418,5 +434,6 @@ private void InitializeComponent() { private System.Windows.Forms.CheckBox checkNonIntrusive; private System.Windows.Forms.Label labelIdlePause; private System.Windows.Forms.ComboBox comboBoxIdlePause; + private System.Windows.Forms.CheckBox checkColumnName; } } diff --git a/Core/Other/Settings/TabSettingsNotifications.cs b/Core/Other/Settings/TabSettingsNotifications.cs index de671c2a..2921d1e3 100644 --- a/Core/Other/Settings/TabSettingsNotifications.cs +++ b/Core/Other/Settings/TabSettingsNotifications.cs @@ -54,7 +54,8 @@ public TabSettingsNotifications(FormNotificationMain notification){ } comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay); - + + checkColumnName.Checked = Config.DisplayNotificationColumn; checkNotificationTimer.Checked = Config.DisplayNotificationTimer; checkTimerCountDown.Enabled = checkNotificationTimer.Checked; checkTimerCountDown.Checked = Config.NotificationTimerCountDown; @@ -78,6 +79,7 @@ public override void OnReady(){ btnDurationMedium.Click += btnDurationMedium_Click; btnDurationLong.Click += btnDurationLong_Click; + checkColumnName.CheckedChanged += checkColumnName_CheckedChanged; checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged; checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged; checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged; @@ -138,6 +140,11 @@ private void btnDurationLong_Click(object sender, EventArgs e){ trackBarDuration.Value = 35; } + private void checkColumnName_CheckedChanged(object sender, EventArgs e){ + Config.DisplayNotificationColumn = checkColumnName.Checked; + notification.ShowNotificationForSettings(false); + } + private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){ Config.DisplayNotificationTimer = checkNotificationTimer.Checked; checkTimerCountDown.Enabled = checkNotificationTimer.Checked; diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 6f886141..de04dad2 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -19,6 +19,29 @@ // var app = $(document.body).children(".js-app"); + // + // Constant: Column types mapped to their titles. + // + const columnTypes = { + "col_home": "Home", + "col_timeline" : "Home", + "col_mentions": "Mentions", + "col_me": "Mentions", + "col_inbox": "Messages", + "col_messages": "Messages", + "col_interactions": "Notifications", + "col_followers": "Followers", + "col_activity": "Activity", + "col_favorites": "Likes", + "col_usertweets": "User", + "col_search": "Search", + "col_list": "List", + "col_customtimeline": "Timeline", + "col_dataminr": "Dataminr", + "col_livevideo": "Live video", + "col_scheduled": "Scheduled" + }; + // // Function: Prepends code at the beginning of a function. If the prepended function returns true, execution of the original function is cancelled. // @@ -59,7 +82,7 @@ // var onNewTweet = function(column, tweet){ if (column.model.getHasNotification()){ - var html = $(tweet.render({ + let html = $(tweet.render({ withFooter: false, withTweetActions: false, withMediaPreview: true, @@ -73,9 +96,8 @@ html.find(".js-media").last().remove(); // and quoted tweets still show media previews, nice nice html.find(".js-quote-detail").removeClass("is-actionable"); - var url = html.find("time").first().children("a").first().attr("href") || ""; - - $TD.onTweetPopup(html.html(), url, tweet.text.length); // TODO column + let url = html.find("time").first().children("a").first().attr("href") || ""; + $TD.onTweetPopup(columnTypes[column.getColumnType()] || "", html.html(), url, tweet.text.length); } if (column.model.getHasSound()){