mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-01 08:34:11 +02:00
Make the TweetDuck entry in TweetDeck Settings show the context menu
This commit is contained in:
parent
0cbcc8c9f3
commit
2de5b5c6e4
@ -53,12 +53,8 @@ public void SetNotificationQuotedTweet(string link){
|
|||||||
notification.InvokeAsyncSafe(() => notification.CurrentQuotedTweetUrl = link);
|
notification.InvokeAsyncSafe(() => notification.CurrentQuotedTweetUrl = link);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenSettingsMenu(){
|
public void OpenContextMenu(){
|
||||||
form.InvokeAsyncSafe(form.OpenSettings);
|
form.InvokeAsyncSafe(form.OpenContextMenu);
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenPluginsMenu(){
|
|
||||||
form.InvokeAsyncSafe(form.OpenPlugins);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){
|
public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){
|
||||||
|
@ -33,6 +33,7 @@ private static UserConfig Config{
|
|||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
private readonly UpdateHandler updates;
|
private readonly UpdateHandler updates;
|
||||||
private readonly FormNotificationTweet notification;
|
private readonly FormNotificationTweet notification;
|
||||||
|
private readonly ContextMenu contextMenu;
|
||||||
|
|
||||||
private FormSettings currentFormSettings;
|
private FormSettings currentFormSettings;
|
||||||
private FormAbout currentFormAbout;
|
private FormAbout currentFormAbout;
|
||||||
@ -53,6 +54,8 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
|
|||||||
this.plugins.Reloaded += plugins_Reloaded;
|
this.plugins.Reloaded += plugins_Reloaded;
|
||||||
this.plugins.PluginChangedState += plugins_PluginChangedState;
|
this.plugins.PluginChangedState += plugins_PluginChangedState;
|
||||||
|
|
||||||
|
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
||||||
|
|
||||||
this.notification = new FormNotificationTweet(this, plugins, NotificationFlags.TopMost){
|
this.notification = new FormNotificationTweet(this, plugins, NotificationFlags.TopMost){
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
CanMoveWindow = () => (ModifierKeys & Keys.Alt) == Keys.Alt
|
CanMoveWindow = () => (ModifierKeys & Keys.Alt) == Keys.Alt
|
||||||
@ -85,6 +88,7 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
|
|||||||
|
|
||||||
Disposed += (sender, args) => {
|
Disposed += (sender, args) => {
|
||||||
browser.Dispose();
|
browser.Dispose();
|
||||||
|
contextMenu.Dispose();
|
||||||
|
|
||||||
if (notificationScreenshotManager != null){
|
if (notificationScreenshotManager != null){
|
||||||
notificationScreenshotManager.Dispose();
|
notificationScreenshotManager.Dispose();
|
||||||
@ -308,8 +312,16 @@ public void UpdateProperties(PropertyBridge.Properties properties = PropertyBrid
|
|||||||
browser.ExecuteScriptAsync(PropertyBridge.GenerateScript(properties));
|
browser.ExecuteScriptAsync(PropertyBridge.GenerateScript(properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReloadToTweetDeck(){
|
||||||
|
browser.ExecuteScriptAsync("window.location.href = 'https://tweetdeck.twitter.com'");
|
||||||
|
}
|
||||||
|
|
||||||
// callback handlers
|
// callback handlers
|
||||||
|
|
||||||
|
public void OpenContextMenu(){
|
||||||
|
contextMenu.Show(this, new Point(Cursor.Position.X, Cursor.Position.Y-22));
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenSettings(){
|
public void OpenSettings(){
|
||||||
OpenSettings(0);
|
OpenSettings(0);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using CefSharp;
|
using System.Windows.Forms;
|
||||||
|
using CefSharp;
|
||||||
using TweetDck.Core.Bridge;
|
using TweetDck.Core.Bridge;
|
||||||
using TweetDck.Core.Controls;
|
using TweetDck.Core.Controls;
|
||||||
using TweetDck.Core.Utils;
|
using TweetDck.Core.Utils;
|
||||||
@ -17,6 +18,12 @@ class ContextMenuBrowser : ContextMenuBase{
|
|||||||
private const int MenuCopyQuotedTweetUrl = 26613;
|
private const int MenuCopyQuotedTweetUrl = 26613;
|
||||||
private const int MenuScreenshotTweet = 26614;
|
private const int MenuScreenshotTweet = 26614;
|
||||||
|
|
||||||
|
private const string TitleReloadBrowser = "Reload browser";
|
||||||
|
private const string TitleMuteNotifications = "Mute notifications";
|
||||||
|
private const string TitleSettings = "Settings";
|
||||||
|
private const string TitlePlugins = "Plugins";
|
||||||
|
private const string TitleAboutProgram = "About "+Program.BrandName;
|
||||||
|
|
||||||
private readonly FormBrowser form;
|
private readonly FormBrowser form;
|
||||||
|
|
||||||
private string lastHighlightedTweet;
|
private string lastHighlightedTweet;
|
||||||
@ -66,14 +73,14 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
|
|||||||
|
|
||||||
IMenuModel globalMenu = model.Count == 0 ? model : model.AddSubMenu((CefMenuCommand)MenuGlobal, Program.BrandName);
|
IMenuModel globalMenu = model.Count == 0 ? model : model.AddSubMenu((CefMenuCommand)MenuGlobal, Program.BrandName);
|
||||||
|
|
||||||
globalMenu.AddItem(CefMenuCommand.Reload, "Reload browser");
|
globalMenu.AddItem(CefMenuCommand.Reload, TitleReloadBrowser);
|
||||||
globalMenu.AddCheckItem((CefMenuCommand)MenuMute, "Mute notifications");
|
globalMenu.AddCheckItem((CefMenuCommand)MenuMute, TitleMuteNotifications);
|
||||||
globalMenu.SetChecked((CefMenuCommand)MenuMute, Program.UserConfig.MuteNotifications);
|
globalMenu.SetChecked((CefMenuCommand)MenuMute, Program.UserConfig.MuteNotifications);
|
||||||
globalMenu.AddSeparator();
|
globalMenu.AddSeparator();
|
||||||
|
|
||||||
globalMenu.AddItem((CefMenuCommand)MenuSettings, "Settings");
|
globalMenu.AddItem((CefMenuCommand)MenuSettings, TitleSettings);
|
||||||
globalMenu.AddItem((CefMenuCommand)MenuPlugins, "Plugins");
|
globalMenu.AddItem((CefMenuCommand)MenuPlugins, TitlePlugins);
|
||||||
globalMenu.AddItem((CefMenuCommand)MenuAbout, "About "+Program.BrandName);
|
globalMenu.AddItem((CefMenuCommand)MenuAbout, TitleAboutProgram);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
globalMenu.AddSeparator();
|
globalMenu.AddSeparator();
|
||||||
@ -107,11 +114,7 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MenuMute:
|
case MenuMute:
|
||||||
form.InvokeAsyncSafe(() => {
|
form.InvokeAsyncSafe(ToggleMuteNotifications);
|
||||||
Program.UserConfig.MuteNotifications = !Program.UserConfig.MuteNotifications;
|
|
||||||
Program.UserConfig.Save();
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MenuOpenTweetUrl:
|
case MenuOpenTweetUrl:
|
||||||
@ -137,5 +140,27 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ContextMenu CreateMenu(FormBrowser form){
|
||||||
|
ContextMenu menu = new ContextMenu();
|
||||||
|
|
||||||
|
menu.MenuItems.Add(TitleReloadBrowser, (sender, args) => form.ReloadToTweetDeck());
|
||||||
|
menu.MenuItems.Add(TitleMuteNotifications, (sender, args) => ToggleMuteNotifications());
|
||||||
|
menu.MenuItems.Add("-");
|
||||||
|
menu.MenuItems.Add(TitleSettings, (sender, args) => form.OpenSettings());
|
||||||
|
menu.MenuItems.Add(TitlePlugins, (sender, args) => form.OpenPlugins());
|
||||||
|
menu.MenuItems.Add(TitleAboutProgram, (sender, args) => form.OpenAbout());
|
||||||
|
|
||||||
|
menu.Popup += (sender, args) => {
|
||||||
|
menu.MenuItems[1].Checked = Program.UserConfig.MuteNotifications;
|
||||||
|
};
|
||||||
|
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ToggleMuteNotifications(){
|
||||||
|
Program.UserConfig.MuteNotifications = !Program.UserConfig.MuteNotifications;
|
||||||
|
Program.UserConfig.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,26 +119,15 @@
|
|||||||
var menu = $(".js-dropdown-content").children("ul").first();
|
var menu = $(".js-dropdown-content").children("ul").first();
|
||||||
if (menu.length === 0)return;
|
if (menu.length === 0)return;
|
||||||
|
|
||||||
menu.children(".drp-h-divider").last().after([
|
menu.children(".drp-h-divider").last().before('<li class="is-selectable" data-std><a href="#" data-action="tweetduck">TweetDuck</a></li>');
|
||||||
'<li class="is-selectable" data-std><a href="#" data-action="td-settings">TweetDuck settings</a></li>',
|
|
||||||
'<li class="is-selectable" data-std><a href="#" data-action="td-plugins">TweetDuck plugins</a></li>',
|
|
||||||
'<li class="drp-h-divider"></li>'
|
|
||||||
].join(""));
|
|
||||||
|
|
||||||
var buttons = menu.children("[data-std]");
|
var button = menu.children("[data-std]");
|
||||||
|
|
||||||
buttons.on("click", "a", function(){
|
button.on("click", "a", function(){
|
||||||
var action = $(this).attr("data-action");
|
$TD.openContextMenu();
|
||||||
|
|
||||||
if (action === "td-settings"){
|
|
||||||
$TD.openSettingsMenu();
|
|
||||||
}
|
|
||||||
else if (action === "td-plugins"){
|
|
||||||
$TD.openPluginsMenu();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
buttons.hover(function(){
|
button.hover(function(){
|
||||||
$(this).addClass("is-selected");
|
$(this).addClass("is-selected");
|
||||||
}, function(){
|
}, function(){
|
||||||
$(this).removeClass("is-selected");
|
$(this).removeClass("is-selected");
|
||||||
|
Loading…
Reference in New Issue
Block a user