mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-09-14 01:32:10 +02:00
Compare commits
77 Commits
Author | SHA1 | Date | |
---|---|---|---|
fb13695ca5 | |||
20c76d06f7 | |||
339a11f649 | |||
0989400d87 | |||
52aacf602d | |||
54d70a6a17 | |||
d980e09e0f | |||
2e4cb12817 | |||
7b91cb2e96 | |||
95c04a8abc | |||
25822fefdb | |||
d800ee2d28 | |||
2a51371aca | |||
ee5d1a47dc | |||
b330b74347 | |||
11fa13f0bb | |||
21400d72b3 | |||
a710cb9d4f | |||
3326ad52ce | |||
c9560df851 | |||
74cb45118e | |||
c79bf19e51 | |||
961bec0a2f | |||
89e4977cd1 | |||
bfe16475db | |||
915d36867c | |||
48435af407 | |||
86b6ec5212 | |||
775e70bc45 | |||
9f565447d0 | |||
88d27bc29d | |||
172ae87ac6 | |||
91d572235e | |||
64d32dcb75 | |||
564b4283b6 | |||
ca4d374a81 | |||
a753806d7b | |||
bd1692cea3 | |||
b7ce089f08 | |||
8a6b47c5db | |||
9f1fc4df18 | |||
c018a2a7bc | |||
a1aebab114 | |||
e30702e1d8 | |||
008ff4b055 | |||
d7bba22e19 | |||
2b9a910533 | |||
118ebcc627 | |||
c741767b11 | |||
4a09358e14 | |||
3f4ea1af08 | |||
35bb196832 | |||
cb5b50dd42 | |||
8652272526 | |||
0f32504fde | |||
4735c21fc0 | |||
ecbcbcaed4 | |||
1677b73ff8 | |||
5929067a3d | |||
d06834617b | |||
9d048efe06 | |||
6a379bc2cd | |||
9f415b11b5 | |||
b9b9193222 | |||
867c2d1632 | |||
5447afc3f5 | |||
b5e58db242 | |||
8ab99619d6 | |||
4c7660ee65 | |||
c1b9bde7b0 | |||
0e8c6c066f | |||
9e44a86be0 | |||
b61479f84f | |||
e3c709b005 | |||
b2b3dba504 | |||
4d05441aa8 | |||
419b3ee850 |
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Configuration{
|
||||
namespace TweetDuck.Configuration{
|
||||
static class Arguments{
|
||||
// public args
|
||||
public const string ArgDataFolder = "-datafolder";
|
||||
@@ -12,6 +12,7 @@ namespace TweetDck.Configuration{
|
||||
// internal args
|
||||
public const string ArgRestart = "-restart";
|
||||
public const string ArgImportCookies = "-importcookies";
|
||||
public const string ArgUpdated = "-updated";
|
||||
|
||||
// class data and methods
|
||||
private static readonly CommandLineArgs Current = CommandLineArgs.FromStringArray('-', Environment.GetCommandLineArgs());
|
||||
@@ -28,7 +29,18 @@ namespace TweetDck.Configuration{
|
||||
CommandLineArgs args = Current.Clone();
|
||||
args.RemoveFlag(ArgRestart);
|
||||
args.RemoveFlag(ArgImportCookies);
|
||||
args.RemoveFlag(ArgUpdated);
|
||||
return args;
|
||||
}
|
||||
|
||||
public static CommandLineArgs GetCurrentForInstaller(){
|
||||
CommandLineArgs args = GetCurrentClean();
|
||||
args.AddFlag(ArgUpdated);
|
||||
return args;
|
||||
}
|
||||
|
||||
public static string GetCurrentForInstallerCmd(){
|
||||
return GetCurrentForInstaller().ToString().Replace("\"", "::");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Configuration{
|
||||
namespace TweetDuck.Configuration{
|
||||
sealed class LockManager{
|
||||
public enum Result{
|
||||
Success, HasProcess, Fail
|
||||
|
66
Configuration/SystemConfig.cs
Normal file
66
Configuration/SystemConfig.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TweetDuck.Configuration{
|
||||
sealed class SystemConfig{
|
||||
public static readonly bool IsHardwareAccelerationSupported = File.Exists(Path.Combine(Program.ProgramPath, "libEGL.dll")) &&
|
||||
File.Exists(Path.Combine(Program.ProgramPath, "libGLESv2.dll"));
|
||||
|
||||
public bool HardwareAcceleration{
|
||||
get => hardwareAcceleration && IsHardwareAccelerationSupported;
|
||||
set => hardwareAcceleration = value;
|
||||
}
|
||||
|
||||
private readonly string file;
|
||||
|
||||
private bool hardwareAcceleration;
|
||||
|
||||
private SystemConfig(string file){
|
||||
this.file = file;
|
||||
|
||||
HardwareAcceleration = true;
|
||||
}
|
||||
|
||||
private void WriteToStream(Stream stream){
|
||||
stream.WriteByte((byte)(HardwareAcceleration ? 1 : 0));
|
||||
}
|
||||
|
||||
private void ReadFromStream(Stream stream){
|
||||
HardwareAcceleration = stream.ReadByte() > 0;
|
||||
}
|
||||
|
||||
public bool Save(){
|
||||
try{
|
||||
string directory = Path.GetDirectoryName(file);
|
||||
if (directory == null)return false;
|
||||
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
using(Stream stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None)){
|
||||
WriteToStream(stream);
|
||||
}
|
||||
|
||||
return true;
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not save the system configuration file.", true, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static SystemConfig Load(string file){
|
||||
SystemConfig config = new SystemConfig(file);
|
||||
|
||||
try{
|
||||
using(Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)){
|
||||
config.ReadFromStream(stream);
|
||||
}
|
||||
}catch(FileNotFoundException){
|
||||
}catch(DirectoryNotFoundException){
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not open the system configuration file. If you continue, you will lose system specific configuration such as Hardware Acceleration.", true, e);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,16 +3,22 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using TweetDck.Core;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDuck.Core;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
|
||||
namespace TweetDck.Configuration{
|
||||
namespace TweetDuck.Configuration{
|
||||
[Serializable]
|
||||
sealed class UserConfig{
|
||||
private static readonly IFormatter Formatter = new BinaryFormatter();
|
||||
private static readonly IFormatter Formatter = new BinaryFormatter{ Binder = new LegacyBinder() };
|
||||
|
||||
private class LegacyBinder : SerializationBinder{
|
||||
public override Type BindToType(string assemblyName, string typeName){
|
||||
return Type.GetType(string.Format("{0}, {1}", typeName.Replace("TweetDck", "TweetDuck"), assemblyName.Replace("TweetDck", "TweetDuck")));
|
||||
}
|
||||
}
|
||||
|
||||
private const int CurrentFileVersion = 9;
|
||||
|
||||
@@ -40,7 +46,6 @@ namespace TweetDck.Configuration{
|
||||
public bool EnableUpdateCheck { get; set; }
|
||||
public string DismissedUpdate { get; set; }
|
||||
|
||||
[Obsolete] public PluginConfig Plugins { get; set; } // TODO remove eventually
|
||||
public WindowState PluginsWindow { get; set; }
|
||||
|
||||
public string CustomCefArgs { get; set; }
|
||||
@@ -231,7 +236,7 @@ namespace TweetDck.Configuration{
|
||||
Program.Reporter.Log(e.ToString());
|
||||
}
|
||||
else if (firstException != null){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not open the backup configuration file. If you continue, you may lose your settings and list of enabled plugins.", true, e);
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not open the backup configuration file. If you continue, your program options will be reset.", true, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDuck.Core.Controls;
|
||||
|
||||
namespace TweetDck.Core.Bridge{
|
||||
namespace TweetDuck.Core.Bridge{
|
||||
sealed class CallbackBridge{
|
||||
private readonly Control owner;
|
||||
private readonly Action safeCallback;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDck.Core.Bridge{
|
||||
namespace TweetDuck.Core.Bridge{
|
||||
static class PropertyBridge{
|
||||
[Flags]
|
||||
public enum Properties{
|
||||
|
@@ -1,9 +1,9 @@
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Bridge{
|
||||
namespace TweetDuck.Core.Bridge{
|
||||
sealed class TweetDeckBridge{
|
||||
public static string LastRightClickedLink = string.Empty;
|
||||
public static string LastHighlightedTweet = string.Empty;
|
||||
@@ -104,6 +104,13 @@ namespace TweetDck.Core.Bridge{
|
||||
MessageBox.Show(contents, Program.BrandName+" Browser Message", MessageBoxButtons.OK, icon);
|
||||
}
|
||||
|
||||
public void CrashDebug(string message){
|
||||
#if DEBUG
|
||||
Log(message);
|
||||
System.Diagnostics.Debugger.Break();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Log(string data){
|
||||
System.Diagnostics.Debug.WriteLine(data);
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Controls{
|
||||
namespace TweetDuck.Core.Controls{
|
||||
static class ControlExtensions{
|
||||
public static readonly Point InvisibleLocation = new Point(-32000, -32000);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Controls{
|
||||
namespace TweetDuck.Core.Controls{
|
||||
class FlatButton : Button{
|
||||
protected override bool ShowFocusCues => false;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Controls{
|
||||
namespace TweetDuck.Core.Controls{
|
||||
sealed class FlatProgressBar : ProgressBar{
|
||||
private readonly SolidBrush brush;
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Controls{
|
||||
namespace TweetDuck.Core.Controls{
|
||||
sealed class TabButton : FlatButton{
|
||||
public Action Callback { get; private set; }
|
||||
|
||||
|
2
Core/Controls/TabPanel.Designer.cs
generated
2
Core/Controls/TabPanel.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Controls {
|
||||
namespace TweetDuck.Core.Controls {
|
||||
partial class TabPanel {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -4,7 +4,7 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Controls{
|
||||
namespace TweetDuck.Core.Controls{
|
||||
sealed partial class TabPanel : UserControl{
|
||||
public Panel Content => panelContent;
|
||||
public IEnumerable<TabButton> Buttons => panelButtons.Controls.Cast<TabButton>();
|
||||
|
9
Core/FormBrowser.Designer.cs
generated
9
Core/FormBrowser.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core {
|
||||
namespace TweetDuck.Core {
|
||||
sealed partial class FormBrowser {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -24,7 +24,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.trayIcon = new TweetDck.Core.TrayIcon(this.components);
|
||||
this.trayIcon = new TweetDuck.Core.TrayIcon(this.components);
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -32,15 +32,16 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = TweetDck.Core.Utils.BrowserUtils.BackgroundColor;
|
||||
this.BackColor = TweetDuck.Core.Utils.BrowserUtils.BackgroundColor;
|
||||
this.ClientSize = new System.Drawing.Size(324, 386);
|
||||
this.Icon = Properties.Resources.icon;
|
||||
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.MinimumSize = new System.Drawing.Size(340, 424);
|
||||
this.Name = "FormBrowser";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Activated += new System.EventHandler(this.FormBrowser_Activated);
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormBrowser_FormClosing);
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormBrowser_FormClosed);
|
||||
this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd);
|
||||
this.Resize += new System.EventHandler(this.FormBrowser_Resize);
|
||||
this.ResumeLayout(false);
|
||||
|
@@ -5,23 +5,23 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Handling;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Notification.Screenshot;
|
||||
using TweetDck.Core.Notification.Sound;
|
||||
using TweetDck.Core.Other;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Plugins.Events;
|
||||
using TweetDck.Resources;
|
||||
using TweetDck.Updates;
|
||||
using TweetDck.Updates.Events;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Notification.Screenshot;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Plugins.Events;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Updates;
|
||||
using TweetDuck.Updates.Events;
|
||||
using TweetLib.Audio.Utils;
|
||||
|
||||
namespace TweetDck.Core{
|
||||
namespace TweetDuck.Core{
|
||||
sealed partial class FormBrowser : Form{
|
||||
private static UserConfig Config => Program.UserConfig;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TweetDck.Core{
|
||||
private FormWindowState prevState;
|
||||
|
||||
private TweetScreenshotManager notificationScreenshotManager;
|
||||
private ISoundNotificationPlayer soundNotification;
|
||||
private SoundNotification soundNotification;
|
||||
|
||||
public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){
|
||||
InitializeComponent();
|
||||
@@ -64,7 +64,8 @@ namespace TweetDck.Core{
|
||||
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
|
||||
MenuHandler = new ContextMenuBrowser(this),
|
||||
JsDialogHandler = new JavaScriptDialogHandler(),
|
||||
LifeSpanHandler = new LifeSpanHandler()
|
||||
LifeSpanHandler = new LifeSpanHandler(),
|
||||
RequestHandler = new RequestHandlerBrowser()
|
||||
};
|
||||
|
||||
#if DEBUG
|
||||
@@ -247,6 +248,12 @@ namespace TweetDck.Core{
|
||||
}
|
||||
}
|
||||
|
||||
private void FormBrowser_FormClosed(object sender, FormClosedEventArgs e){
|
||||
if (isLoaded && UpdateInstallerPath == null){
|
||||
updates.CleanupDownload();
|
||||
}
|
||||
}
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
UpdateProperties(PropertyBridge.Properties.MuteNotifications);
|
||||
}
|
||||
@@ -285,23 +292,13 @@ namespace TweetDck.Core{
|
||||
}
|
||||
}
|
||||
|
||||
Hide();
|
||||
updates.BeginUpdateDownload(this, e.UpdateInfo, update => {
|
||||
if (update.DownloadStatus == UpdateDownloadStatus.Done){
|
||||
UpdateInstallerPath = update.InstallerPath;
|
||||
}
|
||||
|
||||
FormUpdateDownload downloadForm = new FormUpdateDownload(e.UpdateInfo);
|
||||
downloadForm.MoveToCenter(this);
|
||||
downloadForm.ShowDialog();
|
||||
downloadForm.Dispose();
|
||||
|
||||
if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Succeeded){
|
||||
UpdateInstallerPath = downloadForm.InstallerPath;
|
||||
ForceClose();
|
||||
}
|
||||
else if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Manual){
|
||||
ForceClose();
|
||||
}
|
||||
else{
|
||||
Show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updates_UpdateDismissed(object sender, UpdateDismissedEventArgs e){
|
||||
@@ -315,12 +312,12 @@ namespace TweetDck.Core{
|
||||
using(FormMessage form = new FormMessage("Notification Sound Error", "Could not play custom notification sound."+Environment.NewLine+e.Message, MessageBoxIcon.Error)){
|
||||
form.CancelButton = form.AddButton("Ignore");
|
||||
|
||||
Button btnOpenSettings = form.AddButton("Open Settings");
|
||||
Button btnOpenSettings = form.AddButton("View Options");
|
||||
btnOpenSettings.Width += 16;
|
||||
btnOpenSettings.Location = new Point(btnOpenSettings.Location.X-16, btnOpenSettings.Location.Y);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnOpenSettings){
|
||||
OpenSettings(FormSettings.TabIndexNotification);
|
||||
OpenSettings(FormSettings.TabIndexSounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,7 +427,7 @@ namespace TweetDck.Core{
|
||||
}
|
||||
|
||||
if (soundNotification == null){
|
||||
soundNotification = SoundNotification.New();
|
||||
soundNotification = new SoundNotification();
|
||||
soundNotification.PlaybackError += soundNotification_PlaybackError;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using CefSharp;
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class BrowserProcessHandler : IBrowserProcessHandler{
|
||||
void IBrowserProcessHandler.OnContextInitialized(){
|
||||
using(IRequestContext ctx = Cef.GetGlobalRequestContext()){
|
||||
|
@@ -3,13 +3,14 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
namespace TweetDuck.Core.Handling{
|
||||
abstract class ContextMenuBase : IContextMenuHandler{
|
||||
private static readonly Regex RegexTwitterAccount = new Regex(@"^https?://twitter\.com/([^/]+)/?$", RegexOptions.Compiled);
|
||||
private static readonly Lazy<Regex> RegexTwitterAccount = new Lazy<Regex>(() => new Regex(@"^https?://twitter\.com/([^/]+)/?$", RegexOptions.Compiled), false);
|
||||
protected static readonly bool HasDevTools = File.Exists(Path.Combine(Program.ProgramPath, "devtools_resources.pak"));
|
||||
|
||||
private const int MenuOpenLinkUrl = 26500;
|
||||
private const int MenuCopyLinkUrl = 26501;
|
||||
@@ -17,15 +18,8 @@ namespace TweetDck.Core.Handling{
|
||||
private const int MenuOpenImage = 26503;
|
||||
private const int MenuSaveImage = 26504;
|
||||
private const int MenuCopyImageUrl = 26505;
|
||||
|
||||
#if DEBUG
|
||||
private const int MenuOpenDevTools = 26599;
|
||||
|
||||
protected void AddDebugMenuItems(IMenuModel model){
|
||||
model.AddItem((CefMenuCommand)MenuOpenDevTools, "Open dev tools");
|
||||
}
|
||||
#endif
|
||||
|
||||
private readonly Form form;
|
||||
|
||||
protected ContextMenuBase(Form form){
|
||||
@@ -34,7 +28,7 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
|
||||
if (RegexTwitterAccount.IsMatch(parameters.UnfilteredLinkUrl)){
|
||||
if (RegexTwitterAccount.Value.IsMatch(parameters.UnfilteredLinkUrl)){
|
||||
model.AddItem((CefMenuCommand)MenuOpenLinkUrl, "Open account in browser");
|
||||
model.AddItem((CefMenuCommand)MenuCopyLinkUrl, "Copy account address");
|
||||
model.AddItem((CefMenuCommand)MenuCopyUsername, "Copy account username");
|
||||
@@ -85,7 +79,7 @@ namespace TweetDck.Core.Handling{
|
||||
}
|
||||
|
||||
if (saveTarget != null){
|
||||
BrowserUtils.DownloadFileAsync(parameters.SourceUrl, saveTarget, ex => {
|
||||
BrowserUtils.DownloadFileAsync(parameters.SourceUrl, saveTarget, null, ex => {
|
||||
MessageBox.Show("An error occurred while downloading the image: "+ex.Message, Program.BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
});
|
||||
}
|
||||
@@ -97,15 +91,13 @@ namespace TweetDck.Core.Handling{
|
||||
break;
|
||||
|
||||
case MenuCopyUsername:
|
||||
Match match = RegexTwitterAccount.Match(parameters.UnfilteredLinkUrl);
|
||||
Match match = RegexTwitterAccount.Value.Match(parameters.UnfilteredLinkUrl);
|
||||
SetClipboardText(match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl);
|
||||
break;
|
||||
|
||||
#if DEBUG
|
||||
case MenuOpenDevTools:
|
||||
browserControl.ShowDevTools();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -121,6 +113,10 @@ namespace TweetDck.Core.Handling{
|
||||
form.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
|
||||
}
|
||||
|
||||
protected void AddDebugMenuItems(IMenuModel model){
|
||||
model.AddItem((CefMenuCommand)MenuOpenDevTools, "Open dev tools");
|
||||
}
|
||||
|
||||
protected static void RemoveSeparatorIfLast(IMenuModel model){
|
||||
if (model.Count > 0 && model.GetTypeAt(model.Count-1) == MenuItemType.Separator){
|
||||
model.RemoveAt(model.Count-1);
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using CefSharp;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class ContextMenuBrowser : ContextMenuBase{
|
||||
private const int MenuGlobal = 26600;
|
||||
private const int MenuMute = 26601;
|
||||
@@ -20,7 +20,7 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
private const string TitleReloadBrowser = "Reload browser";
|
||||
private const string TitleMuteNotifications = "Mute notifications";
|
||||
private const string TitleSettings = "Settings";
|
||||
private const string TitleSettings = "Options";
|
||||
private const string TitlePlugins = "Plugins";
|
||||
private const string TitleAboutProgram = "About "+Program.BrandName;
|
||||
|
||||
@@ -82,10 +82,10 @@ namespace TweetDck.Core.Handling{
|
||||
globalMenu.AddItem((CefMenuCommand)MenuPlugins, TitlePlugins);
|
||||
globalMenu.AddItem((CefMenuCommand)MenuAbout, TitleAboutProgram);
|
||||
|
||||
#if DEBUG
|
||||
globalMenu.AddSeparator();
|
||||
AddDebugMenuItems(globalMenu);
|
||||
#endif
|
||||
if (HasDevTools){
|
||||
globalMenu.AddSeparator();
|
||||
AddDebugMenuItems(globalMenu);
|
||||
}
|
||||
}
|
||||
|
||||
RemoveSeparatorIfLast(model);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using CefSharp;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class ContextMenuNotification : ContextMenuBase{
|
||||
private const int MenuSkipTweet = 26600;
|
||||
private const int MenuFreeze = 26601;
|
||||
@@ -44,9 +44,9 @@ namespace TweetDck.Core.Handling{
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
AddDebugMenuItems(model);
|
||||
#endif
|
||||
if (HasDevTools){
|
||||
AddDebugMenuItems(model);
|
||||
}
|
||||
|
||||
RemoveSeparatorIfLast(model);
|
||||
|
||||
|
@@ -2,10 +2,10 @@
|
||||
using CefSharp.WinForms;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Other;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other;
|
||||
|
||||
namespace TweetDck.Core.Handling {
|
||||
namespace TweetDuck.Core.Handling {
|
||||
class JavaScriptDialogHandler : IJsDialogHandler{
|
||||
bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage){
|
||||
((ChromiumWebBrowser)browserControl).InvokeSafe(() => {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using CefSharp;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class LifeSpanHandler : ILifeSpanHandler{
|
||||
public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser){
|
||||
newBrowser = null;
|
||||
|
68
Core/Handling/RequestHandler.cs
Normal file
68
Core/Handling/RequestHandler.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
abstract class RequestHandler : IRequestHandler{
|
||||
// Browser
|
||||
|
||||
public virtual void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser){}
|
||||
|
||||
public virtual void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){}
|
||||
|
||||
public virtual bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool isRedirect){
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture){
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url){
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resources
|
||||
|
||||
public virtual CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
|
||||
return CefReturnValue.Continue;
|
||||
}
|
||||
|
||||
public virtual void OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl){}
|
||||
|
||||
public virtual bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength){}
|
||||
|
||||
// JavaScript & Plugins
|
||||
|
||||
public virtual bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback){
|
||||
callback.Dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath){}
|
||||
|
||||
// Auth
|
||||
|
||||
public virtual bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback){
|
||||
callback.Dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback){
|
||||
callback.Dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback){
|
||||
callback.Dispose();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
17
Core/Handling/RequestHandlerBrowser.cs
Normal file
17
Core/Handling/RequestHandlerBrowser.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class RequestHandlerBrowser : RequestHandler{
|
||||
public override void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){
|
||||
browser.Reload();
|
||||
}
|
||||
|
||||
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
|
||||
if (request.ResourceType == ResourceType.Script && request.Url.Contains("analytics.")){
|
||||
return CefReturnValue.Cancel;
|
||||
}
|
||||
|
||||
return CefReturnValue.Continue;
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class ResourceHandlerNotification : IResourceHandler{
|
||||
private readonly NameValueCollection headers = new NameValueCollection(0);
|
||||
private MemoryStream dataIn;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Notification {
|
||||
namespace TweetDuck.Core.Notification {
|
||||
partial class FormNotificationBase {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -34,7 +34,7 @@
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(284, 122);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormNotification";
|
||||
|
@@ -3,12 +3,12 @@ using CefSharp.WinForms;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Handling;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
namespace TweetDuck.Core.Notification{
|
||||
partial class FormNotificationBase : Form{
|
||||
protected Point PrimaryLocation{
|
||||
get{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Notification {
|
||||
namespace TweetDuck.Core.Notification {
|
||||
partial class FormNotificationMain {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -26,7 +26,7 @@
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerProgress = new System.Windows.Forms.Timer(this.components);
|
||||
this.progressBarTimer = new TweetDck.Core.Controls.FlatProgressBar();
|
||||
this.progressBarTimer = new TweetDuck.Core.Controls.FlatProgressBar();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// timerDisplayDelay
|
||||
|
@@ -2,14 +2,14 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Resources;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
namespace TweetDuck.Core.Notification{
|
||||
partial class FormNotificationMain : FormNotificationBase{
|
||||
private const string NotificationScriptFile = "notification.js";
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Notification {
|
||||
namespace TweetDuck.Core.Notification {
|
||||
partial class FormNotificationTweet {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDuck.Plugins;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
namespace TweetDuck.Core.Notification{
|
||||
sealed partial class FormNotificationTweet : FormNotificationMain{
|
||||
private const int NonIntrusiveIdleLimit = 30;
|
||||
private const int TrimMinimum = 32;
|
||||
|
@@ -2,11 +2,11 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Resources;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDck.Core.Notification.Screenshot{
|
||||
namespace TweetDuck.Core.Notification.Screenshot{
|
||||
sealed class FormNotificationScreenshotable : FormNotificationBase{
|
||||
public FormNotificationScreenshotable(Action callback, Form owner) : base(owner, false){
|
||||
browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new CallbackBridge(this, callback));
|
||||
|
@@ -3,9 +3,9 @@
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDuck.Core.Controls;
|
||||
|
||||
namespace TweetDck.Core.Notification.Screenshot{
|
||||
namespace TweetDuck.Core.Notification.Screenshot{
|
||||
sealed class TweetScreenshotManager : IDisposable{
|
||||
private readonly Form owner;
|
||||
private readonly Timer timeout;
|
||||
|
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Notification.Sound{
|
||||
interface ISoundNotificationPlayer : IDisposable{
|
||||
string SupportedFormats { get; }
|
||||
|
||||
event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
void Play(string file);
|
||||
void Stop();
|
||||
}
|
||||
}
|
@@ -1,28 +1,29 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using TweetDck.Core.Notification.Sound;
|
||||
using System;
|
||||
using TweetLib.Audio;
|
||||
using TweetLib.Audio.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
static class SoundNotification{
|
||||
private static bool? IsWMPAvailable;
|
||||
namespace TweetDuck.Core.Notification{
|
||||
sealed class SoundNotification : IDisposable{
|
||||
public string SupportedFormats => player.SupportedFormats;
|
||||
public event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
public static ISoundNotificationPlayer New(){
|
||||
if (IsWMPAvailable.HasValue){
|
||||
if (IsWMPAvailable.Value){
|
||||
return new SoundPlayerImplWMP();
|
||||
}
|
||||
else{
|
||||
return new SoundPlayerImplFallback();
|
||||
}
|
||||
}
|
||||
private readonly AudioPlayer player;
|
||||
|
||||
try{
|
||||
SoundPlayerImplWMP implWMP = new SoundPlayerImplWMP();
|
||||
IsWMPAvailable = true;
|
||||
return implWMP;
|
||||
}catch(COMException){
|
||||
IsWMPAvailable = false;
|
||||
return new SoundPlayerImplFallback();
|
||||
}
|
||||
public SoundNotification(){
|
||||
this.player = AudioPlayer.New();
|
||||
this.player.PlaybackError += Player_PlaybackError;
|
||||
}
|
||||
|
||||
public void Play(string file){
|
||||
player.Play(file);
|
||||
}
|
||||
|
||||
private void Player_PlaybackError(object sender, PlaybackErrorEventArgs e){
|
||||
PlaybackError?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public void Dispose(){
|
||||
player.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using TweetDck.Resources;
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
namespace TweetDuck.Core.Notification{
|
||||
sealed class TweetNotification{
|
||||
private static string FontSizeClass { get; set; }
|
||||
private static string HeadTag { get; set; }
|
||||
@@ -51,24 +51,22 @@ namespace TweetDck.Core.Notification{
|
||||
TopLeft, TopRight, BottomLeft, BottomRight, Custom
|
||||
}
|
||||
|
||||
public string Column => column;
|
||||
public string TweetUrl => tweetUrl;
|
||||
public string QuoteUrl => quoteUrl;
|
||||
public string Column { get; }
|
||||
public string TweetUrl { get; }
|
||||
public string QuoteUrl { get; }
|
||||
|
||||
private readonly string column;
|
||||
private readonly string html;
|
||||
private readonly int characters;
|
||||
private readonly string tweetUrl;
|
||||
private readonly string quoteUrl;
|
||||
private readonly bool isExample;
|
||||
|
||||
public TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl) : this(column, html, characters, tweetUrl, quoteUrl, false){}
|
||||
|
||||
private TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){
|
||||
this.column = column;
|
||||
this.Column = column;
|
||||
this.TweetUrl = tweetUrl;
|
||||
this.QuoteUrl = quoteUrl;
|
||||
|
||||
this.html = html;
|
||||
this.tweetUrl = tweetUrl;
|
||||
this.quoteUrl = quoteUrl;
|
||||
this.characters = characters;
|
||||
this.isExample = isExample;
|
||||
}
|
||||
|
2
Core/Other/FormAbout.Designer.cs
generated
2
Core/Other/FormAbout.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other {
|
||||
namespace TweetDuck.Core.Other {
|
||||
sealed partial class FormAbout {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other{
|
||||
namespace TweetDuck.Core.Other{
|
||||
sealed partial class FormAbout : Form{
|
||||
private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki";
|
||||
private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues";
|
||||
|
2
Core/Other/FormMessage.Designer.cs
generated
2
Core/Other/FormMessage.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other {
|
||||
namespace TweetDuck.Core.Other {
|
||||
partial class FormMessage {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Other{
|
||||
namespace TweetDuck.Core.Other{
|
||||
sealed partial class FormMessage : Form{
|
||||
public Button ClickedButton { get; private set; }
|
||||
|
||||
|
8
Core/Other/FormPlugins.Designer.cs
generated
8
Core/Other/FormPlugins.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other {
|
||||
namespace TweetDuck.Core.Other {
|
||||
partial class FormPlugins {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -26,7 +26,7 @@
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.btnReload = new System.Windows.Forms.Button();
|
||||
this.btnOpenFolder = new System.Windows.Forms.Button();
|
||||
this.tabPanelPlugins = new TweetDck.Core.Controls.TabPanel();
|
||||
this.tabPanelPlugins = new TweetDuck.Core.Controls.TabPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
@@ -87,7 +87,7 @@
|
||||
this.Controls.Add(this.btnOpenFolder);
|
||||
this.Controls.Add(this.btnReload);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Icon = global::TweetDck.Properties.Resources.icon;
|
||||
this.Icon = global::TweetDuck.Properties.Resources.icon;
|
||||
this.MinimumSize = new System.Drawing.Size(480, 320);
|
||||
this.Name = "FormPlugins";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
@@ -101,6 +101,6 @@
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.Button btnReload;
|
||||
private System.Windows.Forms.Button btnOpenFolder;
|
||||
private TweetDck.Core.Controls.TabPanel tabPanelPlugins;
|
||||
private TweetDuck.Core.Controls.TabPanel tabPanelPlugins;
|
||||
}
|
||||
}
|
@@ -3,13 +3,13 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Controls;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Plugins.Events;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Controls;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Plugins.Events;
|
||||
|
||||
namespace TweetDck.Core.Other{
|
||||
namespace TweetDuck.Core.Other{
|
||||
sealed partial class FormPlugins : Form{
|
||||
private readonly PluginManager pluginManager;
|
||||
private readonly TabButton tabBtnOfficial, tabBtnCustom;
|
||||
|
6
Core/Other/FormSettings.Designer.cs
generated
6
Core/Other/FormSettings.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other {
|
||||
namespace TweetDuck.Core.Other {
|
||||
sealed partial class FormSettings {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -25,7 +25,7 @@
|
||||
private void InitializeComponent() {
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.labelTip = new System.Windows.Forms.Label();
|
||||
this.tabPanel = new TweetDck.Core.Controls.TabPanel();
|
||||
this.tabPanel = new TweetDuck.Core.Controls.TabPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
@@ -70,7 +70,7 @@
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.tabPanel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = global::TweetDck.Properties.Resources.icon;
|
||||
this.Icon = global::TweetDuck.Properties.Resources.icon;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormSettings";
|
||||
|
@@ -2,13 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Other.Settings;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Updates;
|
||||
using TweetDuck.Core.Other.Settings;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Updates;
|
||||
|
||||
namespace TweetDck.Core.Other{
|
||||
namespace TweetDuck.Core.Other{
|
||||
sealed partial class FormSettings : Form{
|
||||
public const int TabIndexNotification = 1;
|
||||
public const int TabIndexSounds = 2;
|
||||
|
||||
private readonly FormBrowser browser;
|
||||
private readonly Dictionary<Type, BaseTabSettings> tabs = new Dictionary<Type, BaseTabSettings>(4);
|
||||
@@ -16,7 +16,7 @@ namespace TweetDck.Core.Other{
|
||||
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, int startTabIndex = 0){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName+" Settings";
|
||||
Text = Program.BrandName+" Options";
|
||||
|
||||
this.browser = browser;
|
||||
this.browser.PauseNotification();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDuck.Configuration;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
class BaseTabSettings : UserControl{
|
||||
protected static UserConfig Config => Program.UserConfig;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace TweetDck.Core.Other.Settings{
|
||||
public virtual void OnClosing(){}
|
||||
|
||||
protected static void PromptRestart(){
|
||||
if (MessageBox.Show("The application must restart for the setting to take place. Do you want to restart now?", Program.BrandName+" Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes){
|
||||
if (MessageBox.Show("The application must restart for the option to take place. Do you want to restart now?", Program.BrandName+" Options", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes){
|
||||
Program.Restart();
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
partial class DialogSettingsCSS {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
sealed partial class DialogSettingsCSS : Form{
|
||||
public string BrowserCSS => textBoxBrowserCSS.Text;
|
||||
public string NotificationCSS => textBoxNotificationCSS.Text;
|
||||
@@ -13,7 +13,7 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
public DialogSettingsCSS(Action<string> reinjectBrowserCSS){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName+" Settings - CSS";
|
||||
Text = Program.BrandName+" Options - CSS";
|
||||
|
||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
partial class DialogSettingsCefArgs {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
sealed partial class DialogSettingsCefArgs : Form{
|
||||
public string CefArgs => textBoxArgs.Text;
|
||||
|
||||
public DialogSettingsCefArgs(){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName+" Settings - CEF Arguments";
|
||||
Text = Program.BrandName+" Options - CEF Arguments";
|
||||
|
||||
textBoxArgs.EnableMultilineShortcuts();
|
||||
textBoxArgs.Text = Program.UserConfig.CustomCefArgs ?? "";
|
||||
@@ -31,7 +31,7 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
}
|
||||
|
||||
int count = CommandLineArgsParser.ReadCefArguments(CefArgs).Count;
|
||||
string prompt = count == 0 && !string.IsNullOrWhiteSpace(prevArgs) ? "All arguments will be removed from the settings. Continue?" : count+(count == 1 ? " argument" : " arguments")+" will be added to the settings. Continue?";
|
||||
string prompt = count == 0 && !string.IsNullOrWhiteSpace(prevArgs) ? "All current arguments will be removed. Continue?" : count+(count == 1 ? " argument was" : " arguments were")+" detected. Continue?";
|
||||
|
||||
if (MessageBox.Show(prompt, "Confirm CEF Arguments", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK){
|
||||
DialogResult = DialogResult.OK;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
partial class DialogSettingsExport {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -66,9 +66,8 @@
|
||||
this.cbConfig.Name = "cbConfig";
|
||||
this.cbConfig.Size = new System.Drawing.Size(106, 17);
|
||||
this.cbConfig.TabIndex = 0;
|
||||
this.cbConfig.Text = "Program Settings";
|
||||
this.toolTip.SetToolTip(this.cbConfig, "Interface, notification, and update settings.\r\nIncludes a list of disabled plugin" +
|
||||
"s.");
|
||||
this.cbConfig.Text = "Program Options";
|
||||
this.toolTip.SetToolTip(this.cbConfig, "Interface, notification, and update options.");
|
||||
this.cbConfig.UseVisualStyleBackColor = true;
|
||||
this.cbConfig.CheckedChanged += new System.EventHandler(this.cbConfig_CheckedChanged);
|
||||
//
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Other.Settings.Export;
|
||||
using TweetDuck.Core.Other.Settings.Export;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
sealed partial class DialogSettingsExport : Form{
|
||||
public static DialogSettingsExport Import(ExportFileFlags flags){
|
||||
return new DialogSettingsExport(flags);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
partial class DialogSettingsRestart {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -2,10 +2,10 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
sealed partial class DialogSettingsRestart : Form{
|
||||
private const string DefaultLocale = "en-US";
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Export{
|
||||
namespace TweetDuck.Core.Other.Settings.Export{
|
||||
class CombinedFileStream : IDisposable{
|
||||
public const char KeySeparator = '|';
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Export{
|
||||
namespace TweetDuck.Core.Other.Settings.Export{
|
||||
[Flags]
|
||||
enum ExportFileFlags{
|
||||
None = 0,
|
||||
|
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Export{
|
||||
namespace TweetDuck.Core.Other.Settings.Export{
|
||||
sealed class ExportManager{
|
||||
private static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies");
|
||||
private static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp");
|
||||
@@ -27,7 +27,7 @@ namespace TweetDck.Core.Other.Settings.Export{
|
||||
try{
|
||||
using(CombinedFileStream stream = new CombinedFileStream(new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None))){
|
||||
if (flags.HasFlag(ExportFileFlags.Config)){
|
||||
stream.WriteFile("config", Program.ConfigFilePath);
|
||||
stream.WriteFile("config", Program.UserConfigFilePath);
|
||||
}
|
||||
|
||||
if (flags.HasFlag(ExportFileFlags.PluginData)){
|
||||
@@ -101,7 +101,7 @@ namespace TweetDck.Core.Other.Settings.Export{
|
||||
switch(entry.KeyName){
|
||||
case "config":
|
||||
if (flags.HasFlag(ExportFileFlags.Config)){
|
||||
entry.WriteToFile(Program.ConfigFilePath);
|
||||
entry.WriteToFile(Program.UserConfigFilePath);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings {
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
partial class TabSettingsAdvanced {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Other.Settings.Dialogs;
|
||||
using TweetDck.Core.Other.Settings.Export;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other.Settings.Dialogs;
|
||||
using TweetDuck.Core.Other.Settings.Export;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
partial class TabSettingsAdvanced : BaseTabSettings{
|
||||
private readonly Action<string> reinjectBrowserCSS;
|
||||
private readonly PluginManager plugins;
|
||||
@@ -19,7 +19,13 @@ namespace TweetDck.Core.Other.Settings{
|
||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||
this.plugins = plugins;
|
||||
|
||||
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled;
|
||||
if (SystemConfig.IsHardwareAccelerationSupported){
|
||||
checkHardwareAcceleration.Checked = Program.SystemConfig.HardwareAcceleration;
|
||||
}
|
||||
else{
|
||||
checkHardwareAcceleration.Enabled = false;
|
||||
checkHardwareAcceleration.Checked = false;
|
||||
}
|
||||
|
||||
BrowserCache.CalculateCacheSize(bytes => this.InvokeSafe(() => {
|
||||
if (bytes == -1L){
|
||||
@@ -56,52 +62,54 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
private void checkHardwareAcceleration_CheckedChanged(object sender, EventArgs e){
|
||||
bool succeeded = false;
|
||||
|
||||
if (checkHardwareAcceleration.Checked){
|
||||
if (HardwareAcceleration.CanEnable){
|
||||
succeeded = HardwareAcceleration.Enable();
|
||||
}
|
||||
else{
|
||||
MessageBox.Show("Cannot enable hardware acceleration, the libraries libEGL.dll and libGLESv2.dll could not be restored.", Program.BrandName+" Settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else{
|
||||
succeeded = HardwareAcceleration.Disable();
|
||||
}
|
||||
|
||||
if (succeeded){
|
||||
PromptRestart();
|
||||
}
|
||||
else{
|
||||
checkHardwareAcceleration.CheckedChanged -= checkHardwareAcceleration_CheckedChanged;
|
||||
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled;
|
||||
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
|
||||
}
|
||||
Program.SystemConfig.HardwareAcceleration = checkHardwareAcceleration.Checked;
|
||||
Program.SystemConfig.Save();
|
||||
PromptRestart();
|
||||
}
|
||||
|
||||
private void btnEditCefArgs_Click(object sender, EventArgs e){
|
||||
DialogSettingsCefArgs form = new DialogSettingsCefArgs();
|
||||
|
||||
if (form.ShowDialog(ParentForm) == DialogResult.OK){
|
||||
Config.CustomCefArgs = form.CefArgs;
|
||||
form.Dispose();
|
||||
PromptRestart();
|
||||
}
|
||||
else{
|
||||
form.Dispose();
|
||||
}
|
||||
form.VisibleChanged += (sender2, args2) => {
|
||||
form.MoveToCenter(ParentForm);
|
||||
};
|
||||
|
||||
form.FormClosed += (sender2, args2) => {
|
||||
NativeMethods.SetFormDisabled(ParentForm, false);
|
||||
|
||||
if (form.DialogResult == DialogResult.OK){
|
||||
Config.CustomCefArgs = form.CefArgs;
|
||||
PromptRestart();
|
||||
form.Dispose();
|
||||
}
|
||||
else form.Dispose();
|
||||
};
|
||||
|
||||
form.Show(ParentForm);
|
||||
NativeMethods.SetFormDisabled(ParentForm, true);
|
||||
}
|
||||
|
||||
private void btnEditCSS_Click(object sender, EventArgs e){
|
||||
using(DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS)){
|
||||
if (form.ShowDialog(ParentForm) == DialogResult.OK){
|
||||
DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS);
|
||||
|
||||
form.VisibleChanged += (sender2, args2) => {
|
||||
form.MoveToCenter(ParentForm);
|
||||
};
|
||||
|
||||
form.FormClosed += (sender2, args2) => {
|
||||
NativeMethods.SetFormDisabled(ParentForm, false);
|
||||
|
||||
if (form.DialogResult == DialogResult.OK){
|
||||
Config.CustomBrowserCSS = form.BrowserCSS;
|
||||
Config.CustomNotificationCSS = form.NotificationCSS;
|
||||
}
|
||||
|
||||
reinjectBrowserCSS(Config.CustomBrowserCSS); // reinject on cancel too, because the CSS is updated while typing
|
||||
}
|
||||
form.Dispose();
|
||||
};
|
||||
|
||||
form.Show(ParentForm);
|
||||
NativeMethods.SetFormDisabled(ParentForm, true);
|
||||
}
|
||||
|
||||
private void btnExport_Click(object sender, EventArgs e){
|
||||
@@ -123,8 +131,8 @@ namespace TweetDck.Core.Other.Settings{
|
||||
OverwritePrompt = true,
|
||||
DefaultExt = "tdsettings",
|
||||
FileName = Program.BrandName+".tdsettings",
|
||||
Title = "Export "+Program.BrandName+" Settings",
|
||||
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings"
|
||||
Title = "Export "+Program.BrandName+" Profile",
|
||||
Filter = Program.BrandName+" Profile (*.tdsettings)|*.tdsettings"
|
||||
}){
|
||||
if (dialog.ShowDialog() != DialogResult.OK){
|
||||
return;
|
||||
@@ -138,7 +146,7 @@ namespace TweetDck.Core.Other.Settings{
|
||||
ExportManager manager = new ExportManager(file, plugins);
|
||||
|
||||
if (!manager.Export(flags)){
|
||||
Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting "+Program.BrandName+" settings.", true, manager.LastException);
|
||||
Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting "+Program.BrandName+" profile.", true, manager.LastException);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +156,8 @@ namespace TweetDck.Core.Other.Settings{
|
||||
using(OpenFileDialog dialog = new OpenFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
DereferenceLinks = true,
|
||||
Title = "Import "+Program.BrandName+" Settings",
|
||||
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings"
|
||||
Title = "Import "+Program.BrandName+" Profile",
|
||||
Filter = Program.BrandName+" Profile (*.tdsettings)|*.tdsettings"
|
||||
}){
|
||||
if (dialog.ShowDialog() != DialogResult.OK){
|
||||
return;
|
||||
@@ -175,12 +183,12 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
}
|
||||
else{
|
||||
Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing "+Program.BrandName+" settings.", true, manager.LastException);
|
||||
Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing "+Program.BrandName+" profile.", true, manager.LastException);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnReset_Click(object sender, EventArgs e){
|
||||
if (MessageBox.Show("This will reset all of your program settings. Plugins will not be affected. Do you want to proceed?", "Reset "+Program.BrandName+" Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||
if (MessageBox.Show("This will reset all of your program options. Plugins will not be affected. Do you want to proceed?", "Reset "+Program.BrandName+" Options", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||
Program.ResetConfig();
|
||||
((FormSettings)ParentForm).ReloadUI();
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings {
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
partial class TabSettingsGeneral {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Updates;
|
||||
using TweetDck.Updates.Events;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Updates;
|
||||
using TweetDuck.Updates.Events;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
partial class TabSettingsGeneral : BaseTabSettings{
|
||||
private readonly UpdateHandler updates;
|
||||
private int updateCheckEventId = -1;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings {
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
partial class TabSettingsNotifications {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -37,9 +37,9 @@
|
||||
this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar();
|
||||
this.groupNotificationDuration = new System.Windows.Forms.GroupBox();
|
||||
this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.btnDurationMedium = new TweetDck.Core.Controls.FlatButton();
|
||||
this.btnDurationLong = new TweetDck.Core.Controls.FlatButton();
|
||||
this.btnDurationShort = new TweetDck.Core.Controls.FlatButton();
|
||||
this.btnDurationMedium = new TweetDuck.Core.Controls.FlatButton();
|
||||
this.btnDurationLong = new TweetDuck.Core.Controls.FlatButton();
|
||||
this.btnDurationShort = new TweetDuck.Core.Controls.FlatButton();
|
||||
this.labelDurationValue = new System.Windows.Forms.Label();
|
||||
this.trackBarDuration = new System.Windows.Forms.TrackBar();
|
||||
this.groupUserInterface = new System.Windows.Forms.GroupBox();
|
||||
@@ -440,9 +440,9 @@
|
||||
private System.Windows.Forms.Label labelDurationValue;
|
||||
private System.Windows.Forms.TrackBar trackBarDuration;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons;
|
||||
private TweetDck.Core.Controls.FlatButton btnDurationMedium;
|
||||
private TweetDck.Core.Controls.FlatButton btnDurationLong;
|
||||
private TweetDck.Core.Controls.FlatButton btnDurationShort;
|
||||
private TweetDuck.Core.Controls.FlatButton btnDurationMedium;
|
||||
private TweetDuck.Core.Controls.FlatButton btnDurationLong;
|
||||
private TweetDuck.Core.Controls.FlatButton btnDurationShort;
|
||||
private System.Windows.Forms.CheckBox checkNonIntrusive;
|
||||
private System.Windows.Forms.Label labelIdlePause;
|
||||
private System.Windows.Forms.ComboBox comboBoxIdlePause;
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
partial class TabSettingsNotifications : BaseTabSettings{
|
||||
private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 };
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core.Other.Settings {
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
partial class TabSettingsSounds {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -2,17 +2,17 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Notification.Sound;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetLib.Audio.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
partial class TabSettingsSounds : BaseTabSettings{
|
||||
private readonly ISoundNotificationPlayer soundNotification;
|
||||
private readonly SoundNotification soundNotification;
|
||||
|
||||
public TabSettingsSounds(){
|
||||
InitializeComponent();
|
||||
|
||||
soundNotification = SoundNotification.New();
|
||||
soundNotification = new SoundNotification();
|
||||
soundNotification.PlaybackError += sound_PlaybackError;
|
||||
|
||||
tbCustomSound.Text = Config.NotificationSoundPath;
|
||||
|
2
Core/TrayIcon.Designer.cs
generated
2
Core/TrayIcon.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Core {
|
||||
namespace TweetDuck.Core {
|
||||
partial class TrayIcon {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core{
|
||||
namespace TweetDuck.Core{
|
||||
partial class TrayIcon : Component{
|
||||
public enum Behavior{ // keep order
|
||||
Disabled, DisplayOnly, MinimizeToTray, CloseToTray, Combined
|
||||
|
@@ -4,7 +4,7 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class BrowserCache{
|
||||
private static bool ClearOnExit { get; set; }
|
||||
|
||||
|
@@ -8,7 +8,7 @@ using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class BrowserUtils{
|
||||
public static string HeaderAcceptLanguage{
|
||||
get{
|
||||
@@ -69,17 +69,28 @@ namespace TweetDck.Core.Utils{
|
||||
return ConvertPascalCaseToScreamingSnakeCase(Enum.GetName(typeof(CefErrorCode), code) ?? string.Empty);
|
||||
}
|
||||
|
||||
public static void DownloadFileAsync(string url, string target, Action<Exception> onFailure){
|
||||
public static WebClient DownloadFileAsync(string url, string target, Action onSuccess, Action<Exception> onFailure){
|
||||
WebClient client = new WebClient{ Proxy = null };
|
||||
client.Headers[HttpRequestHeader.UserAgent] = HeaderUserAgent;
|
||||
|
||||
client.DownloadFileCompleted += (sender, args) => {
|
||||
if (args.Error != null){
|
||||
onFailure(args.Error);
|
||||
if (args.Cancelled){
|
||||
try{
|
||||
File.Delete(target);
|
||||
}catch{
|
||||
// didn't want it deleted anyways
|
||||
}
|
||||
}
|
||||
else if (args.Error != null){
|
||||
onFailure?.Invoke(args.Error);
|
||||
}
|
||||
else{
|
||||
onSuccess?.Invoke();
|
||||
}
|
||||
};
|
||||
|
||||
client.DownloadFileAsync(new Uri(url), target);
|
||||
return client;
|
||||
}
|
||||
|
||||
public static void SetZoomLevel(IBrowser browser, int percentage){
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
class CommandLineArgs{
|
||||
public static CommandLineArgs FromStringArray(char entryChar, string[] array){
|
||||
CommandLineArgs args = new CommandLineArgs();
|
||||
|
@@ -1,10 +1,9 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class CommandLineArgsParser{
|
||||
private static Regex splitRegex;
|
||||
|
||||
private static Regex SplitRegex => splitRegex ?? (splitRegex = new Regex(@"([^=\s]+(?:=(?:[^ ]*""[^""]*?""[^ ]*|[^ ]*))?)", RegexOptions.Compiled));
|
||||
private static readonly Lazy<Regex> SplitRegex = new Lazy<Regex>(() => new Regex(@"([^=\s]+(?:=(?:[^ ]*""[^""]*?""[^ ]*|[^ ]*))?)", RegexOptions.Compiled), false);
|
||||
|
||||
public static CommandLineArgs ReadCefArguments(string argumentString){
|
||||
CommandLineArgs args = new CommandLineArgs();
|
||||
@@ -13,7 +12,7 @@ namespace TweetDck.Core.Utils{
|
||||
return args;
|
||||
}
|
||||
|
||||
foreach(Match match in SplitRegex.Matches(argumentString)){
|
||||
foreach(Match match in SplitRegex.Value.Matches(argumentString)){
|
||||
string matchValue = match.Value;
|
||||
|
||||
int indexEquals = matchValue.IndexOf('=');
|
||||
|
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
static class HardwareAcceleration{
|
||||
private static readonly string LibEGL = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libEGL.dll");
|
||||
private static readonly string LibGLES = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libGLESv2.dll");
|
||||
|
||||
private static readonly string DisabledLibEGL = LibEGL+".bak";
|
||||
private static readonly string DisabledLibGLES = LibGLES+".bak";
|
||||
|
||||
public static bool IsEnabled => File.Exists(LibEGL) && File.Exists(LibGLES);
|
||||
public static bool CanEnable => File.Exists(DisabledLibEGL) && File.Exists(DisabledLibGLES);
|
||||
|
||||
public static bool Enable(){
|
||||
if (IsEnabled)return false;
|
||||
|
||||
try{
|
||||
File.Move(DisabledLibEGL, LibEGL);
|
||||
File.Move(DisabledLibGLES, LibGLES);
|
||||
return true;
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Disable(){
|
||||
if (!IsEnabled)return false;
|
||||
|
||||
try{
|
||||
if (File.Exists(DisabledLibEGL)){
|
||||
File.Delete(DisabledLibEGL);
|
||||
}
|
||||
|
||||
if (File.Exists(DisabledLibGLES)){
|
||||
File.Delete(DisabledLibGLES);
|
||||
}
|
||||
}catch{
|
||||
// woops
|
||||
}
|
||||
|
||||
try{
|
||||
File.Move(LibEGL, DisabledLibEGL);
|
||||
File.Move(LibGLES, DisabledLibGLES);
|
||||
return true;
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
class InjectedHTML{
|
||||
public enum Position{
|
||||
Before, After
|
||||
|
@@ -4,7 +4,7 @@ using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Local")]
|
||||
static class NativeMethods{
|
||||
@@ -13,6 +13,8 @@ namespace TweetDck.Core.Utils{
|
||||
|
||||
public const int HWND_TOPMOST = -1;
|
||||
public const uint SWP_NOACTIVATE = 0x0010;
|
||||
public const int WS_DISABLED = 0x08000000;
|
||||
public const int GWL_STYLE = -16;
|
||||
|
||||
public const int SB_HORZ = 0;
|
||||
public const int BCM_SETSHIELD = 0x160C;
|
||||
@@ -83,10 +85,25 @@ namespace TweetDck.Core.Utils{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
public static void SetFormPos(Form form, int hWndOrder, uint flags){
|
||||
SetWindowPos(form.Handle.ToInt32(), hWndOrder, form.Left, form.Top, form.Width, form.Height, flags);
|
||||
}
|
||||
|
||||
public static void SetFormDisabled(Form form, bool disabled){
|
||||
if (disabled){
|
||||
SetWindowLong(form.Handle, GWL_STYLE, GetWindowLong(form.Handle, GWL_STYLE) | WS_DISABLED);
|
||||
}
|
||||
else{
|
||||
SetWindowLong(form.Handle, GWL_STYLE, GetWindowLong(form.Handle, GWL_STYLE) & ~WS_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMouseHookData(IntPtr ptr){
|
||||
return Marshal.PtrToStructure<MSLLHOOKSTRUCT>(ptr).mouseData >> 16;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
class TwoKeyDictionary<K1, K2, V>{
|
||||
private readonly Dictionary<K1, Dictionary<K2, V>> dict;
|
||||
private readonly int innerCapacity;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDuck.Core.Controls;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
[Serializable]
|
||||
class WindowState{
|
||||
private Rectangle rect;
|
||||
|
@@ -6,8 +6,11 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class WindowsUtils{
|
||||
private static readonly Lazy<Regex> RegexStripHtmlStyles = new Lazy<Regex>(() => new Regex(@"\s?(?:style|class)="".*?"""), false);
|
||||
private static readonly Lazy<Regex> RegexOffsetClipboardHtml = new Lazy<Regex>(() => new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)"), false);
|
||||
|
||||
public static bool ShouldAvoidToolWindow { get; }
|
||||
|
||||
static WindowsUtils(){
|
||||
@@ -54,6 +57,21 @@ namespace TweetDck.Core.Utils{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void TryDeleteFolderWhenAble(string path, int timeout){
|
||||
new Thread(() => {
|
||||
TrySleepUntil(() => {
|
||||
try{
|
||||
Directory.Delete(path, true);
|
||||
return true;
|
||||
}catch(DirectoryNotFoundException){
|
||||
return true;
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
}, timeout, 500);
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public static void ClipboardStripHtmlStyles(){
|
||||
if (!Clipboard.ContainsText(TextDataFormat.Html)){
|
||||
return;
|
||||
@@ -62,10 +80,10 @@ namespace TweetDck.Core.Utils{
|
||||
string originalText = Clipboard.GetText(TextDataFormat.UnicodeText);
|
||||
string originalHtml = Clipboard.GetText(TextDataFormat.Html);
|
||||
|
||||
string updatedHtml = ClipboardRegexes.RegexStripHtmlStyles.Replace(originalHtml, string.Empty);
|
||||
string updatedHtml = RegexStripHtmlStyles.Value.Replace(originalHtml, string.Empty);
|
||||
|
||||
int removed = originalHtml.Length-updatedHtml.Length;
|
||||
updatedHtml = ClipboardRegexes.RegexOffsetClipboardHtml.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
|
||||
updatedHtml = RegexOffsetClipboardHtml.Value.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
|
||||
|
||||
DataObject obj = new DataObject();
|
||||
obj.SetText(originalText, TextDataFormat.UnicodeText);
|
||||
@@ -90,10 +108,5 @@ namespace TweetDck.Core.Utils{
|
||||
Program.Reporter.HandleException("Clipboard Error", Program.BrandName+" could not access the clipboard as it is currently used by another process.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClipboardRegexes{ // delays construction of regular expressions until needed
|
||||
public static readonly Regex RegexStripHtmlStyles = new Regex(@"\s?(?:style|class)="".*?""");
|
||||
public static readonly Regex RegexOffsetClipboardHtml = new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
Plugins/Controls/PluginControl.Designer.cs
generated
2
Plugins/Controls/PluginControl.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Plugins.Controls {
|
||||
namespace TweetDuck.Plugins.Controls {
|
||||
partial class PluginControl {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@@ -3,9 +3,9 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Plugins.Controls{
|
||||
namespace TweetDuck.Plugins.Controls{
|
||||
partial class PluginControl : UserControl{
|
||||
private readonly PluginManager pluginManager;
|
||||
private readonly Plugin plugin;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Plugins.Controls{
|
||||
namespace TweetDuck.Plugins.Controls{
|
||||
sealed class PluginListFlowLayout : FlowLayoutPanel{
|
||||
public PluginListFlowLayout(){
|
||||
FlowDirection = FlowDirection.TopDown;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TweetDck.Plugins.Enums{
|
||||
namespace TweetDuck.Plugins.Enums{
|
||||
[Flags]
|
||||
enum PluginEnvironment{
|
||||
None = 0,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Plugins.Enums{
|
||||
namespace TweetDuck.Plugins.Enums{
|
||||
enum PluginFolder{
|
||||
Root, Data
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDck.Plugins.Enums{
|
||||
namespace TweetDuck.Plugins.Enums{
|
||||
enum PluginGroup{
|
||||
Official, Custom
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Plugins.Events{
|
||||
namespace TweetDuck.Plugins.Events{
|
||||
class PluginChangedStateEventArgs : EventArgs{
|
||||
public Plugin Plugin { get; }
|
||||
public bool IsEnabled { get; }
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TweetDck.Plugins.Events{
|
||||
namespace TweetDuck.Plugins.Events{
|
||||
class PluginErrorEventArgs : EventArgs{
|
||||
public bool HasErrors => Errors.Count > 0;
|
||||
|
||||
|
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
namespace TweetDuck.Plugins{
|
||||
class Plugin{
|
||||
public string Identifier { get; }
|
||||
public PluginGroup Group { get; }
|
||||
@@ -73,22 +73,6 @@ namespace TweetDck.Plugins{
|
||||
if (configPath.Length > 0 && defaultConfigPath.Length > 0 && !File.Exists(configPath) && File.Exists(defaultConfigPath)){
|
||||
string dataFolder = GetPluginFolder(PluginFolder.Data);
|
||||
|
||||
if (!Directory.Exists(dataFolder)){ // config migration
|
||||
string originalFile = Path.Combine(GetPluginFolder(PluginFolder.Root), ConfigFile);
|
||||
|
||||
if (File.Exists(originalFile)){
|
||||
try{
|
||||
Directory.CreateDirectory(dataFolder);
|
||||
File.Copy(originalFile, configPath, false);
|
||||
File.Delete(originalFile); // will fail without write perms in program folder, ignore if so
|
||||
}catch{
|
||||
// ignore
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
Directory.CreateDirectory(dataFolder);
|
||||
File.Copy(defaultConfigPath, configPath, false);
|
||||
|
@@ -2,11 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Plugins.Events;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Plugins.Events;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
namespace TweetDuck.Plugins{
|
||||
class PluginBridge{
|
||||
private static string SanitizeCacheKey(string key){
|
||||
return key.Replace('\\', '/').Trim();
|
||||
|
@@ -2,12 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using TweetDck.Plugins.Events;
|
||||
using TweetDuck.Plugins.Events;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
[Serializable]
|
||||
namespace TweetDuck.Plugins{
|
||||
sealed class PluginConfig{
|
||||
[field:NonSerialized]
|
||||
public event EventHandler<PluginChangedStateEventArgs> InternalPluginChangedState; // should only be accessed from PluginManager
|
||||
|
||||
public IEnumerable<string> DisabledPlugins => Disabled;
|
||||
@@ -18,14 +16,6 @@ namespace TweetDck.Plugins{
|
||||
"official/reply-account"
|
||||
};
|
||||
|
||||
public void ImportLegacy(PluginConfig config){
|
||||
Disabled.Clear();
|
||||
|
||||
foreach(string plugin in config.Disabled){
|
||||
Disabled.Add(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEnabled(Plugin plugin, bool enabled){
|
||||
if ((enabled && Disabled.Remove(plugin.Identifier)) || (!enabled && Disabled.Add(plugin.Identifier))){
|
||||
InternalPluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled));
|
||||
|
@@ -3,11 +3,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Plugins.Events;
|
||||
using TweetDck.Resources;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Plugins.Events;
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
namespace TweetDuck.Plugins{
|
||||
sealed class PluginManager{
|
||||
public const string PluginBrowserScriptFile = "plugins.browser.js";
|
||||
public const string PluginNotificationScriptFile = "plugins.notification.js";
|
||||
@@ -42,29 +42,14 @@ namespace TweetDck.Plugins{
|
||||
this.Config = new PluginConfig();
|
||||
this.Bridge = new PluginBridge(this);
|
||||
|
||||
LoadConfig();
|
||||
Config.Load(configPath);
|
||||
|
||||
Config.InternalPluginChangedState += Config_InternalPluginChangedState;
|
||||
Program.UserConfigReplaced += Program_UserConfigReplaced;
|
||||
}
|
||||
|
||||
private void LoadConfig(){
|
||||
#pragma warning disable 612
|
||||
if (Program.UserConfig.Plugins != null){
|
||||
Config.ImportLegacy(Program.UserConfig.Plugins);
|
||||
Config.Save(configPath);
|
||||
|
||||
Program.UserConfig.Plugins = null;
|
||||
Program.UserConfig.Save();
|
||||
}
|
||||
#pragma warning restore 612
|
||||
else{
|
||||
Config.Load(configPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void Program_UserConfigReplaced(object sender, EventArgs e){
|
||||
LoadConfig();
|
||||
Config.Load(configPath);
|
||||
Reload();
|
||||
}
|
||||
|
||||
|
@@ -1,29 +1,36 @@
|
||||
using System.Text;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using System.Globalization;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
namespace TweetDuck.Plugins{
|
||||
static class PluginScriptGenerator{
|
||||
public static string GenerateConfig(PluginConfig config){
|
||||
return config.AnyDisabled ? "window.TD_PLUGINS.disabled = [\""+string.Join("\",\"", config.DisabledPlugins)+"\"];" : string.Empty;
|
||||
}
|
||||
|
||||
public static string GeneratePlugin(string pluginIdentifier, string pluginContents, int pluginToken, PluginEnvironment environment){
|
||||
StringBuilder build = new StringBuilder(2*pluginIdentifier.Length+pluginContents.Length+165);
|
||||
|
||||
build.Append("(function(").Append(environment.GetScriptVariables()).Append("){");
|
||||
|
||||
build.Append("let tmp={");
|
||||
build.Append("id:\"").Append(pluginIdentifier).Append("\",");
|
||||
build.Append("obj:new class extends PluginBase{").Append(pluginContents).Append("}");
|
||||
build.Append("};");
|
||||
|
||||
build.Append("tmp.obj.$id=\"").Append(pluginIdentifier).Append("\";");
|
||||
build.Append("tmp.obj.$token=").Append(pluginToken).Append(";");
|
||||
build.Append("window.TD_PLUGINS.install(tmp);");
|
||||
|
||||
build.Append("})(").Append(environment.GetScriptVariables()).Append(");");
|
||||
|
||||
return build.ToString();
|
||||
return PluginGen
|
||||
.Replace("%params", environment.GetScriptVariables())
|
||||
.Replace("%id", pluginIdentifier)
|
||||
.Replace("%token", pluginToken.ToString(CultureInfo.InvariantCulture))
|
||||
.Replace("%contents", pluginContents);
|
||||
}
|
||||
|
||||
private const string PluginGen = "(function(%params,$d){let tmp={id:'%id',obj:new class extends PluginBase{%contents}};$d(tmp.obj,'$id',{value:'%id'});$d(tmp.obj,'$token',{value:%token});window.TD_PLUGINS.install(tmp);})(%params,Object.defineProperty);";
|
||||
|
||||
/* PluginGen
|
||||
|
||||
(function(%params, $i, $d){
|
||||
let tmp = {
|
||||
id: '%id',
|
||||
obj: new class extends PluginBase{%contents}
|
||||
};
|
||||
|
||||
$d(tmp.obj, '$id', { value: '%id' });
|
||||
$d(tmp.obj, '$token', { value: %token });
|
||||
|
||||
window.TD_PLUGINS.install(tmp);
|
||||
})(%params, Object.defineProperty);
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
63
Program.cs
63
Program.cs
@@ -5,23 +5,23 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core;
|
||||
using TweetDck.Core.Handling;
|
||||
using TweetDck.Core.Other;
|
||||
using TweetDck.Core.Other.Settings.Export;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Events;
|
||||
using TweetDck.Updates;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Other.Settings.Export;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Events;
|
||||
using TweetDuck.Updates;
|
||||
|
||||
namespace TweetDck{
|
||||
namespace TweetDuck{
|
||||
static class Program{
|
||||
public const string BrandName = "TweetDuck";
|
||||
public const string Website = "https://tweetduck.chylex.com";
|
||||
|
||||
public const string VersionTag = "1.7.5";
|
||||
public const string VersionFull = "1.7.5.0";
|
||||
public const string VersionTag = "1.8";
|
||||
public const string VersionFull = "1.8.0.0";
|
||||
|
||||
public static readonly Version Version = new Version(VersionTag);
|
||||
public static readonly bool IsPortable = File.Exists("makeportable");
|
||||
@@ -29,21 +29,26 @@ namespace TweetDck{
|
||||
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : GetDataStoragePath();
|
||||
|
||||
public static readonly string ConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
|
||||
public static readonly string PluginDataPath = Path.Combine(StoragePath, "TD_Plugins");
|
||||
public static readonly string PluginConfigFilePath = Path.Combine(StoragePath, "TD_PluginConfig.cfg");
|
||||
private static readonly string ErrorLogFilePath = Path.Combine(StoragePath, "TD_Log.txt");
|
||||
private static readonly string ConsoleLogFilePath = Path.Combine(StoragePath, "TD_Console.txt");
|
||||
|
||||
public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts");
|
||||
public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins");
|
||||
|
||||
public static readonly string UserConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
|
||||
public static readonly string SystemConfigFilePath = Path.Combine(StoragePath, "TD_SystemConfig.cfg");
|
||||
public static readonly string PluginConfigFilePath = Path.Combine(StoragePath, "TD_PluginConfig.cfg");
|
||||
|
||||
public static readonly string PluginDataPath = Path.Combine(StoragePath, "TD_Plugins");
|
||||
private static readonly string InstallerPath = Path.Combine(StoragePath, "TD_Updates");
|
||||
|
||||
private static string ErrorLogFilePath => Path.Combine(StoragePath, "TD_Log.txt");
|
||||
private static string ConsoleLogFilePath => Path.Combine(StoragePath, "TD_Console.txt");
|
||||
|
||||
public static uint WindowRestoreMessage;
|
||||
|
||||
private static readonly LockManager LockManager = new LockManager(Path.Combine(StoragePath, ".lock"));
|
||||
private static bool HasCleanedUp;
|
||||
|
||||
public static UserConfig UserConfig { get; private set; }
|
||||
public static SystemConfig SystemConfig { get; private set; }
|
||||
public static Reporter Reporter { get; private set; }
|
||||
|
||||
public static event EventHandler UserConfigReplaced;
|
||||
@@ -122,28 +127,33 @@ namespace TweetDck{
|
||||
}
|
||||
|
||||
ReloadConfig();
|
||||
SystemConfig = SystemConfig.Load(SystemConfigFilePath);
|
||||
|
||||
if (Arguments.HasFlag(Arguments.ArgImportCookies)){
|
||||
ExportManager.ImportCookies();
|
||||
}
|
||||
|
||||
if (Arguments.HasFlag(Arguments.ArgUpdated)){
|
||||
WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000);
|
||||
}
|
||||
|
||||
CefSharpSettings.WcfEnabled = false;
|
||||
|
||||
CefSettings settings = new CefSettings{
|
||||
AcceptLanguageList = BrowserUtils.HeaderAcceptLanguage,
|
||||
UserAgent = BrowserUtils.HeaderUserAgent,
|
||||
Locale = Arguments.GetValue(Arguments.ArgLocale, string.Empty),
|
||||
BrowserSubprocessPath = BrandName+".Browser.exe",
|
||||
CachePath = StoragePath,
|
||||
LogFile = ConsoleLogFilePath,
|
||||
#if !DEBUG
|
||||
BrowserSubprocessPath = BrandName+".Browser.exe",
|
||||
LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable
|
||||
#endif
|
||||
};
|
||||
|
||||
CommandLineArgsParser.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs);
|
||||
|
||||
if (!HardwareAcceleration.IsEnabled){
|
||||
if (!SystemConfig.HardwareAcceleration){
|
||||
settings.CefCommandLineArgs["disable-gpu"] = "1";
|
||||
settings.CefCommandLineArgs["disable-gpu-vsync"] = "1";
|
||||
}
|
||||
@@ -163,7 +173,8 @@ namespace TweetDck{
|
||||
|
||||
FormBrowser mainForm = new FormBrowser(plugins, new UpdaterSettings{
|
||||
AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates),
|
||||
DismissedUpdate = UserConfig.DismissedUpdate
|
||||
DismissedUpdate = UserConfig.DismissedUpdate,
|
||||
InstallerDownloadFolder = InstallerPath
|
||||
});
|
||||
|
||||
Application.Run(mainForm);
|
||||
@@ -172,7 +183,7 @@ namespace TweetDck{
|
||||
ExitCleanup();
|
||||
|
||||
// ProgramPath has a trailing backslash
|
||||
string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+Arguments.GetCurrentClean().ToString().Replace("\"", "^\"")+"\""+(IsPortable ? " /PORTABLE=1" : "");
|
||||
string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+Arguments.GetCurrentForInstallerCmd()+"\""+(IsPortable ? " /PORTABLE=1" : "");
|
||||
bool runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath);
|
||||
|
||||
WindowsUtils.StartProcess(mainForm.UpdateInstallerPath, updaterArgs, runElevated);
|
||||
@@ -213,16 +224,16 @@ namespace TweetDck{
|
||||
}
|
||||
|
||||
public static void ReloadConfig(){
|
||||
UserConfig = UserConfig.Load(ConfigFilePath);
|
||||
UserConfig = UserConfig.Load(UserConfigFilePath);
|
||||
UserConfigReplaced?.Invoke(UserConfig, new EventArgs());
|
||||
}
|
||||
|
||||
public static void ResetConfig(){
|
||||
try{
|
||||
File.Delete(ConfigFilePath);
|
||||
File.Delete(UserConfig.GetBackupFile(ConfigFilePath));
|
||||
File.Delete(UserConfigFilePath);
|
||||
File.Delete(UserConfig.GetBackupFile(UserConfigFilePath));
|
||||
}catch(Exception e){
|
||||
Reporter.HandleException("Configuration Reset Error", "Could not delete configuration files to reset the settings.", true, e);
|
||||
Reporter.HandleException("Configuration Reset Error", "Could not delete configuration files to reset the options.", true, e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.InteropServices;
|
||||
using TweetDck;
|
||||
using TweetDuck;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@@ -37,9 +37,9 @@ using TweetDck;
|
||||
[assembly: AssemblyVersion(Program.VersionFull)]
|
||||
[assembly: AssemblyFileVersion(Program.VersionFull)]
|
||||
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
[assembly: CLSCompliant(false)]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
#if DEBUG
|
||||
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("UnitTests")]
|
||||
|
5
Properties/Resources.Designer.cs
generated
5
Properties/Resources.Designer.cs
generated
@@ -8,7 +8,8 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TweetDck.Properties {
|
||||
namespace TweetDuck.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -38,7 +39,7 @@ namespace TweetDck.Properties {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TweetDck.Properties.Resources", typeof(Resources).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TweetDuck.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
|
@@ -5,9 +5,9 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Other;
|
||||
using TweetDuck.Core.Other;
|
||||
|
||||
namespace TweetDck{
|
||||
namespace TweetDuck{
|
||||
class Reporter{
|
||||
private readonly string logFile;
|
||||
|
||||
|
@@ -3,7 +3,7 @@ Clear columns
|
||||
|
||||
[description]
|
||||
- Adds buttons and keyboard shortcuts to quickly clear columns
|
||||
- Hold Shift when clicking or using a keyboard shortcut to reset the column instead
|
||||
- Hold Shift when clicking or using a keyboard shortcut to restore the column instead
|
||||
|
||||
[author]
|
||||
chylex
|
||||
|
@@ -38,7 +38,7 @@ enabled(){
|
||||
$(document).off("mousemove", this.eventKeyUp);
|
||||
}
|
||||
|
||||
$("#clear-columns-btn-all").text(pressed ? "Reset all" : "Clear all");
|
||||
$("#clear-columns-btn-all").text(pressed ? "Restore columns" : "Clear columns");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ enabled(){
|
||||
replaceMustache("column/column_header.mustache", "</header>", [
|
||||
'{{^isTemporary}}',
|
||||
'<a class="column-header-link" href="#" data-action="td-clearcolumns-dosingle" style="right:34px">',
|
||||
'<i class="icon icon-clear-timeline"></i>',
|
||||
'<i class="icon icon-clear-timeline js-show-tip" data-placement="bottom" data-original-title="Clear column (hold Shift to restore)"></i>',
|
||||
'</a>',
|
||||
'{{/isTemporary}}',
|
||||
'</header>'
|
||||
@@ -94,7 +94,7 @@ enabled(){
|
||||
'<dd class="keyboard-shortcut-definition" style="white-space:nowrap">',
|
||||
'<span class="text-like-keyboard-key">1</span> … <span class="text-like-keyboard-key">9</span> + <span class="text-like-keyboard-key">Del</span> Clear column 1-9',
|
||||
'</dd><dd class="keyboard-shortcut-definition">',
|
||||
'<span class="text-like-keyboard-key">Alt</span> + <span class="text-like-keyboard-key">Del</span> Clear all',
|
||||
'<span class="text-like-keyboard-key">Alt</span> + <span class="text-like-keyboard-key">Del</span> Clear all columns',
|
||||
'</dd></dl><dl'
|
||||
].join(""));
|
||||
|
||||
@@ -116,11 +116,18 @@ ready(){
|
||||
|
||||
// add clear all button
|
||||
$("nav.app-navigator").first().append([
|
||||
'<a class="link-clean cf app-nav-link padding-h--10" data-title="Clear all" data-action="td-clearcolumns-doall">',
|
||||
'<a id="clear-columns-btn-all-parent" class="js-header-action link-clean cf app-nav-link padding-h--10" data-title="Clear columns (hold Shift to restore)" data-action="td-clearcolumns-doall">',
|
||||
'<div class="obj-left margin-l--2"><i class="icon icon-medium icon-clear-timeline"></i></div>',
|
||||
'<div id="clear-columns-btn-all" class="nbfc padding-ts hide-condensed txt-size--16">Clear all</div>',
|
||||
'<div id="clear-columns-btn-all" class="nbfc padding-ts hide-condensed txt-size--16">Clear columns</div>',
|
||||
'</a></nav>'
|
||||
].join(""));
|
||||
|
||||
// setup tooltip handling
|
||||
var tooltipEvents = $._data($(".js-header-action")[0]).events;
|
||||
|
||||
if (tooltipEvents.mouseover && tooltipEvents.mouseover.length && tooltipEvents.mouseout && tooltipEvents.mouseout.length){
|
||||
$("#clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler);
|
||||
}
|
||||
}
|
||||
|
||||
disabled(){
|
||||
|
@@ -8,7 +8,7 @@ Edit layout & design
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.0
|
||||
1.1
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
@@ -7,6 +7,7 @@ constructor(){
|
||||
enabled(){
|
||||
// elements & data
|
||||
this.css = null;
|
||||
this.icons = null;
|
||||
this.htmlModal = null;
|
||||
this.config = null;
|
||||
|
||||
@@ -18,11 +19,14 @@ enabled(){
|
||||
revertReplies: false,
|
||||
themeColorTweaks: true,
|
||||
roundedScrollBars: false,
|
||||
revertIcons: true,
|
||||
smallComposeTextSize: false,
|
||||
optimizeAnimations: true,
|
||||
avatarRadius: 10
|
||||
};
|
||||
|
||||
this.firstTimeLoad = null;
|
||||
|
||||
// modal dialog loading
|
||||
$TDP.readFileRoot(this.$token, "modal.html").then(contents => {
|
||||
this.htmlModal = contents;
|
||||
@@ -32,30 +36,58 @@ enabled(){
|
||||
|
||||
// configuration
|
||||
const configFile = "config.json";
|
||||
|
||||
this.tmpConfig = null;
|
||||
this.currentStage = 0;
|
||||
|
||||
var loadConfigObject = obj => {
|
||||
this.tmpConfig = obj || {};
|
||||
|
||||
if (TD.ready){
|
||||
this.onAppReady();
|
||||
this.onStageReady = () => {
|
||||
if (this.currentStage === 0){
|
||||
this.currentStage = 1;
|
||||
}
|
||||
|
||||
this.injectDeciderReplyHook(this.tmpConfig.revertReplies);
|
||||
};
|
||||
|
||||
this.onAppReady = () => {
|
||||
if (this.tmpConfig !== null){
|
||||
else if (this.tmpConfig !== null){
|
||||
this.config = $.extend(this.defaultConfig, this.tmpConfig);
|
||||
this.tmpConfig = null;
|
||||
this.reinjectAll();
|
||||
|
||||
if (this.firstTimeLoad){
|
||||
$TDP.writeFile(this.$token, configFile, JSON.stringify(this.config));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var loadConfigObject = obj => {
|
||||
this.tmpConfig = obj || {};
|
||||
this.firstTimeLoad = obj === null;
|
||||
|
||||
this.onStageReady();
|
||||
this.injectDeciderReplyHook(obj && obj.revertReplies);
|
||||
};
|
||||
|
||||
if (this.$$wasLoadedBefore){
|
||||
this.onStageReady();
|
||||
}
|
||||
else{
|
||||
$(document).one("dataSettingsValues", () => {
|
||||
switch(TD.settings.getColumnWidth()){
|
||||
case "wide": this.defaultConfig.columnWidth = "350px"; break;
|
||||
case "narrow": this.defaultConfig.columnWidth = "270px"; break;
|
||||
}
|
||||
|
||||
switch(TD.settings.getFontSize()){
|
||||
case "small": this.defaultConfig.fontSize = "13px"; break;
|
||||
case "medium": this.defaultConfig.fontSize = "14px"; break;
|
||||
case "large": this.defaultConfig.fontSize = "15px"; break;
|
||||
case "largest": this.defaultConfig.fontSize = "16px"; break;
|
||||
}
|
||||
|
||||
this.$$wasLoadedBefore = true;
|
||||
this.onStageReady();
|
||||
});
|
||||
}
|
||||
|
||||
$TDP.checkFileExists(this.$token, configFile).then(exists => {
|
||||
if (!exists){
|
||||
loadConfigObject(null);
|
||||
$TDP.writeFile(this.$token, configFile, JSON.stringify(this.defaultConfig));
|
||||
}
|
||||
else{
|
||||
$TDP.readFile(this.$token, configFile, true).then(contents => {
|
||||
@@ -208,7 +240,7 @@ enabled(){
|
||||
_render: () => $(this.htmlModal),
|
||||
destroy: function(){
|
||||
if (this.reloadPage){
|
||||
location.reload();
|
||||
window.TDPF_requestReload();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -227,7 +259,7 @@ enabled(){
|
||||
};
|
||||
|
||||
TD.decider.updateForGuestId();
|
||||
this.$pluginSettings.requiresPageReload = enable;
|
||||
this.$requiresReload = enable;
|
||||
};
|
||||
|
||||
// animation optimization
|
||||
@@ -282,13 +314,13 @@ enabled(){
|
||||
};
|
||||
|
||||
this.onWindowFocusEvent = () => {
|
||||
if (this.config.optimizeAnimations){
|
||||
if (this.config && this.config.optimizeAnimations){
|
||||
injectOptimizations(true);
|
||||
}
|
||||
};
|
||||
|
||||
this.onWindowBlurEvent = () => {
|
||||
if (this.config.optimizeAnimations){
|
||||
if (this.config && this.config.optimizeAnimations){
|
||||
disableOptimizations();
|
||||
clearOptimizationTimer();
|
||||
}
|
||||
@@ -301,6 +333,11 @@ enabled(){
|
||||
}
|
||||
|
||||
this.css = window.TDPF_createCustomStyle(this);
|
||||
|
||||
if (this.icons){
|
||||
document.head.removeChild(this.icons);
|
||||
this.icons = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.reinjectAll = () => {
|
||||
@@ -338,8 +375,9 @@ enabled(){
|
||||
|
||||
if (this.config.hideTweetActions){
|
||||
this.css.insert(".tweet-action { opacity: 0; }");
|
||||
this.css.insert(".tweet-actions.is-visible .tweet-action { opacity: 0.5; }");
|
||||
this.css.insert(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important }");
|
||||
this.css.insert(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important }");
|
||||
this.css.insert(".tweet:hover .tweet-action, .tweet-action.is-selected, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1 !important; visibility: visible !important }");
|
||||
}
|
||||
|
||||
if (this.config.moveTweetActionsToRight){
|
||||
@@ -367,6 +405,98 @@ enabled(){
|
||||
this.css.insert(".activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }");
|
||||
}
|
||||
|
||||
if (this.config.revertIcons){
|
||||
this.icons = document.createElement("style");
|
||||
this.icons.innerHTML = `
|
||||
@font-face {
|
||||
font-family: 'tweetdeckold';
|
||||
src: url("https://ton.twimg.com/tweetdeck-web/web/assets/fonts/tweetdeck-regular-webfont.5f4ea87976.woff") format("woff");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.icon-twitter-bird:before{content:"\\f000";font-family:tweetdeckold}
|
||||
.icon-mention:before{content:"\\f001";font-family:tweetdeckold}
|
||||
.icon-following:before{content:"\\f002";font-family:tweetdeckold}
|
||||
.icon-message:before{content:"\\f003";font-family:tweetdeckold}
|
||||
.icon-home:before{content:"\\f004";font-family:tweetdeckold}
|
||||
.icon-hashtag:before{content:"\\f005";font-family:tweetdeckold}
|
||||
.icon-reply:before{content:"\\f006";font-family:tweetdeckold}
|
||||
.icon-favorite:before{content:"\\f055";font-family:tweetdeckold}
|
||||
.icon-retweet:before{content:"\\f008";font-family:tweetdeckold}
|
||||
.icon-drafts:before{content:"\\f009";font-family:tweetdeckold}
|
||||
.icon-search:before{content:"\\f00a";font-family:tweetdeckold}
|
||||
.icon-trash:before{content:"\\f00c";font-family:tweetdeckold}
|
||||
.icon-close:before{content:"\\f00d";font-family:tweetdeckold}
|
||||
.icon-arrow-r:before,.Icon--caretRight:before{content:"\\f00e";font-family:tweetdeckold}
|
||||
.icon-arrow-l:before,.Icon--caretLeft:before{content:"\\f00f";font-family:tweetdeckold}
|
||||
.icon-protected:before{content:"\\f013";font-family:tweetdeckold}
|
||||
.icon-list:before{content:"\\f014";font-family:tweetdeckold}
|
||||
.icon-camera:before{content:"\\f015";font-family:tweetdeckold}
|
||||
.icon-more:before{content:"\\f016";font-family:tweetdeckold}
|
||||
.icon-settings:before{content:"\\f018";font-family:tweetdeckold}
|
||||
.icon-notifications:before{content:"\\f019";font-family:tweetdeckold}
|
||||
.icon-user-dd:before{content:"\\f01a";font-family:tweetdeckold}
|
||||
.icon-activity:before{content:"\\f01c";font-family:tweetdeckold}
|
||||
.icon-trending:before{content:"\\f01d";font-family:tweetdeckold}
|
||||
.icon-minus:before{content:"\\f01e";font-family:tweetdeckold}
|
||||
.icon-plus:before{content:"\\f01f";font-family:tweetdeckold}
|
||||
.icon-geo:before{content:"\\f020";font-family:tweetdeckold}
|
||||
.icon-check:before{content:"\\f021";font-family:tweetdeckold}
|
||||
.icon-schedule:before{content:"\\f022";font-family:tweetdeckold}
|
||||
.icon-dot:before{content:"\\f023";font-family:tweetdeckold}
|
||||
.icon-user:before{content:"\\f024";font-family:tweetdeckold}
|
||||
.icon-content:before{content:"\\f025";font-family:tweetdeckold}
|
||||
.icon-arrow-d:before,.Icon--caretDown:before{content:"\\f026";font-family:tweetdeckold}
|
||||
.icon-arrow-u:before{content:"\\f027";font-family:tweetdeckold}
|
||||
.icon-share:before{content:"\\f028";font-family:tweetdeckold}
|
||||
.icon-info:before{content:"\\f029";font-family:tweetdeckold}
|
||||
.icon-verified:before{content:"\\f02a";font-family:tweetdeckold}
|
||||
.icon-translator:before{content:"\\f02b";font-family:tweetdeckold}
|
||||
.icon-blocked:before{content:"\\f02c";font-family:tweetdeckold}
|
||||
.icon-constrain:before{content:"\\f02d";font-family:tweetdeckold}
|
||||
.icon-play-video:before{content:"\\f02e";font-family:tweetdeckold}
|
||||
.icon-empty:before{content:"\\f02f";font-family:tweetdeckold}
|
||||
.icon-clear-input:before{content:"\\f030";font-family:tweetdeckold}
|
||||
.icon-compose:before{content:"\\f031";font-family:tweetdeckold}
|
||||
.icon-mark-read:before{content:"\\f032";font-family:tweetdeckold}
|
||||
.icon-arrow-r-double:before{content:"\\f033";font-family:tweetdeckold}
|
||||
.icon-arrow-l-double:before{content:"\\f034";font-family:tweetdeckold}
|
||||
.icon-follow:before{content:"\\f035";font-family:tweetdeckold}
|
||||
.icon-image:before{content:"\\f036";font-family:tweetdeckold}
|
||||
.icon-popout:before{content:"\\f037";font-family:tweetdeckold}
|
||||
.icon-move:before{content:"\\f039";font-family:tweetdeckold}
|
||||
.icon-compose-grid:before{content:"\\f03a";font-family:tweetdeckold}
|
||||
.icon-compose-minigrid:before{content:"\\f03b";font-family:tweetdeckold}
|
||||
.icon-compose-list:before{content:"\\f03c";font-family:tweetdeckold}
|
||||
.icon-edit:before{content:"\\f040";font-family:tweetdeckold}
|
||||
.icon-clear-timeline:before{content:"\\f041";font-family:tweetdeckold}
|
||||
.icon-sliders:before{content:"\\f042";font-family:tweetdeckold}
|
||||
.icon-custom-timeline:before{content:"\\f043";font-family:tweetdeckold}
|
||||
.icon-compose-dm:before{content:"\\f044";font-family:tweetdeckold}
|
||||
.icon-bg-dot:before{content:"\\f045";font-family:tweetdeckold}
|
||||
.icon-user-team-mgr:before{content:"\\f046";font-family:tweetdeckold}
|
||||
.icon-user-switch:before{content:"\\f047";font-family:tweetdeckold}
|
||||
.icon-conversation:before{content:"\\f048";font-family:tweetdeckold}
|
||||
.icon-dataminr:before{content:"\\f049";font-family:tweetdeckold}
|
||||
.icon-link:before{content:"\\f04a";font-family:tweetdeckold}
|
||||
.icon-flash:before{content:"\\f050";font-family:tweetdeckold}
|
||||
.icon-pointer-u:before{content:"\\f051";font-family:tweetdeckold}
|
||||
.icon-analytics:before{content:"\\f054";font-family:tweetdeckold}
|
||||
.icon-heart:before{content:"\\f055";font-family:tweetdeckold}
|
||||
.icon-calendar:before{content:"\\f056";font-family:tweetdeckold}
|
||||
.icon-attachment:before{content:"\\f057";font-family:tweetdeckold}
|
||||
.icon-play:before{content:"\\f058";font-family:tweetdeckold}
|
||||
.icon-bookmark:before{content:"\\f059";font-family:tweetdeckold}
|
||||
.icon-play-badge:before{content:"\\f060";font-family:tweetdeckold}
|
||||
.icon-gif-badge:before{content:"\\f061";font-family:tweetdeckold}
|
||||
.icon-poll:before{content:"\\f062";font-family:tweetdeckold}
|
||||
|
||||
.column-header .column-type-icon { bottom: 26px !important }`;
|
||||
|
||||
document.head.appendChild(this.icons);
|
||||
}
|
||||
|
||||
if (this.config.columnWidth[0] === '/'){
|
||||
let cols = this.config.columnWidth.slice(1);
|
||||
|
||||
@@ -399,13 +529,25 @@ enabled(){
|
||||
default: TD.settings.setFontSize(parseInt(this.config.fontSize, 10) >= 16 ? "largest" : "smallest"); break;
|
||||
}
|
||||
|
||||
$TDP.injectIntoNotificationsBefore(this.$token, "css", "</head>", [
|
||||
"<style type='text/css'>",
|
||||
".txt-base-smallest:not(.icon), .txt-base-largest:not(.icon) { font-size: "+this.config.fontSize+" !important }",
|
||||
".avatar { border-radius: "+this.config.avatarRadius+"% !important }",
|
||||
(this.config.revertReplies ? ".activity-header + .tweet .tweet-context { margin-left: -35px } .activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }" : ""),
|
||||
"</style>"
|
||||
].join(""));
|
||||
$TDP.injectIntoNotificationsBefore(this.$token, "css", "</head>", `
|
||||
<style type='text/css'>
|
||||
.txt-base-smallest:not(.icon), .txt-base-largest:not(.icon) { font-size: ${this.config.fontSize} !important }
|
||||
.avatar { border-radius: ${this.config.avatarRadius}% !important }
|
||||
|
||||
${this.config.revertReplies ? `
|
||||
.activity-header + .tweet .tweet-context { margin-left: -35px }
|
||||
.activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }
|
||||
` : ``}
|
||||
|
||||
${this.config.revertIcons ? `
|
||||
@font-face { font-family: 'tweetdeckold'; src: url(\"https://ton.twimg.com/tweetdeck-web/web/assets/fonts/tweetdeck-regular-webfont.5f4ea87976.woff\") format(\"woff\"); font-weight: normal; font-style: normal }
|
||||
.icon-reply:before{content:"\\f006";font-family:tweetdeckold}
|
||||
.icon-favorite:before{content:"\\f055";font-family:tweetdeckold}
|
||||
.icon-retweet:before{content:"\\f008";font-family:tweetdeckold}
|
||||
.icon-follow:before{content:"\\f035";font-family:tweetdeckold}
|
||||
.icon-user-dd:before{content:"\\f01a";font-family:tweetdeckold}
|
||||
` : ``}
|
||||
</style>`);
|
||||
};
|
||||
|
||||
this.uiShowActionsMenuEvent = () => {
|
||||
@@ -416,21 +558,6 @@ enabled(){
|
||||
}
|
||||
|
||||
ready(){
|
||||
// configuration
|
||||
switch(TD.settings.getColumnWidth()){
|
||||
case "wide": this.defaultConfig.columnWidth = "350px"; break;
|
||||
case "narrow": this.defaultConfig.columnWidth = "270px"; break;
|
||||
}
|
||||
|
||||
switch(TD.settings.getFontSize()){
|
||||
case "small": this.defaultConfig.fontSize = "13px"; break;
|
||||
case "medium": this.defaultConfig.fontSize = "14px"; break;
|
||||
case "large": this.defaultConfig.fontSize = "15px"; break;
|
||||
case "largest": this.defaultConfig.fontSize = "16px"; break;
|
||||
}
|
||||
|
||||
this.onAppReady();
|
||||
|
||||
// optimization events
|
||||
$(window).on("focus", this.onWindowFocusEvent);
|
||||
$(window).on("blur", this.onWindowBlurEvent);
|
||||
@@ -448,6 +575,10 @@ disabled(){
|
||||
this.css.remove();
|
||||
}
|
||||
|
||||
if (this.icons){
|
||||
document.head.removeChild(this.icons);
|
||||
}
|
||||
|
||||
if (this.optimizations){
|
||||
this.optimizations.remove();
|
||||
}
|
||||
|
@@ -106,6 +106,10 @@
|
||||
<input data-td-key="roundedScrollBars" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Rounded scroll bars
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="revertIcons" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Revert icon design
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="smallComposeTextSize" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Small compose tweet font size
|
||||
|
@@ -9,7 +9,7 @@ Emoji keyboard
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.0
|
||||
1.1
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
@@ -1,5 +1,6 @@
|
||||
enabled(){
|
||||
this.selectedSkinTone = "";
|
||||
this.currentKeywords = [];
|
||||
|
||||
this.skinToneList = [
|
||||
"", "1F3FB", "1F3FC", "1F3FD", "1F3FE", "1F3FF"
|
||||
@@ -20,9 +21,10 @@ enabled(){
|
||||
|
||||
this.emojiURL = "https://ton.twimg.com/tweetdeck-web/web/assets/emoji/";
|
||||
|
||||
this.emojiHTML1 = ""; // no skin tones, prepended
|
||||
this.emojiHTML2 = {}; // contains emojis with skin tones
|
||||
this.emojiHTML3 = ""; // no skin tones, appended
|
||||
this.emojiData1 = []; // no skin tones, prepended
|
||||
this.emojiData2 = {}; // contains emojis with skin tones
|
||||
this.emojiData3 = []; // no skin tones, appended
|
||||
this.emojiNames = [];
|
||||
|
||||
var me = this;
|
||||
|
||||
@@ -33,6 +35,8 @@ enabled(){
|
||||
this.css.insert(".emoji-keyboard-list { height: 10.14em; padding: 0.1em; box-sizing: border-box; overflow-y: auto }");
|
||||
this.css.insert(".emoji-keyboard-list .separator { height: 26px }");
|
||||
this.css.insert(".emoji-keyboard-list img { padding: 0.1em !important; width: 1em; height: 1em; vertical-align: -0.1em; cursor: pointer }");
|
||||
this.css.insert(".emoji-keyboard-search { height: auto; padding: 4px 10px 8px; background-color: #292f33; border-radius: 2px 2px 0 0 }");
|
||||
this.css.insert(".emoji-keyboard-search input { width: 100%; border-radius: 1px; }");
|
||||
this.css.insert(".emoji-keyboard-skintones { height: 1.3em; text-align: center; background-color: #292f33; border-radius: 0 0 2px 2px }");
|
||||
this.css.insert(".emoji-keyboard-skintones div { width: 0.8em; height: 0.8em; margin: 0.25em 0.1em; border-radius: 50%; display: inline-block; box-sizing: border-box; cursor: pointer }");
|
||||
this.css.insert(".emoji-keyboard-skintones .sel { border: 2px solid rgba(0, 0, 0, 0.35); box-shadow: 0 0 2px 0 rgba(255, 255, 255, 0.65), 0 0 1px 0 rgba(255, 255, 255, 0.4) inset }");
|
||||
@@ -54,26 +58,70 @@ enabled(){
|
||||
// keyboard generation
|
||||
|
||||
this.currentKeyboard = null;
|
||||
this.currentSpanner = null;
|
||||
|
||||
var hideKeyboard = () => {
|
||||
$(this.currentKeyboard).remove();
|
||||
this.currentKeyboard = null;
|
||||
|
||||
$(this.currentSpanner).remove();
|
||||
this.currentSpanner = null;
|
||||
|
||||
this.composePanelScroller.trigger("scroll");
|
||||
|
||||
$(".emoji-keyboard-popup-btn").removeClass("is-selected");
|
||||
$(".js-compose-text").first().focus();
|
||||
};
|
||||
|
||||
var generateEmojiHTML = skinTone => {
|
||||
return (this.emojiHTML1+this.emojiHTML2[skinTone]+this.emojiHTML3).replace(/u#/g, this.emojiURL);
|
||||
let index = 0;
|
||||
let html = [ "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that most emoji will not show up properly in the text box above, but they will display in the tweet.</p>" ];
|
||||
|
||||
for(let array of [ this.emojiData1, this.emojiData2[skinTone], this.emojiData3 ]){
|
||||
for(let emoji of array){
|
||||
if (emoji === "___"){
|
||||
html.push("<div class='separator'></div>");
|
||||
}
|
||||
else{
|
||||
html.push(TD.util.cleanWithEmoji(emoji).replace(' class="emoji" draggable="false"', ''));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return html.join("");
|
||||
};
|
||||
|
||||
var updateFilters = () => {
|
||||
let keywords = this.currentKeywords;
|
||||
let container = $(this.currentKeyboard.children[1]);
|
||||
|
||||
let emoji = container.children("img");
|
||||
let info = container.children("p:first");
|
||||
let separators = container.children("div");
|
||||
|
||||
if (keywords.length === 0){
|
||||
info.css("display", "block");
|
||||
separators.css("display", "block");
|
||||
emoji.css("display", "inline");
|
||||
}
|
||||
else{
|
||||
info.css("display", "none");
|
||||
separators.css("display", "none");
|
||||
|
||||
emoji.css("display", "none");
|
||||
emoji.filter(index => keywords.every(kw => me.emojiNames[index].includes(kw))).css("display", "inline");
|
||||
}
|
||||
};
|
||||
|
||||
var selectSkinTone = skinTone => {
|
||||
let selectedEle = this.currentKeyboard.children[1].querySelector("[data-tone='"+this.selectedSkinTone+"']");
|
||||
let selectedEle = this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']");
|
||||
selectedEle && selectedEle.classList.remove("sel");
|
||||
|
||||
this.selectedSkinTone = skinTone;
|
||||
this.currentKeyboard.children[0].innerHTML = generateEmojiHTML(skinTone);
|
||||
this.currentKeyboard.children[1].querySelector("[data-tone='"+this.selectedSkinTone+"']").classList.add("sel");
|
||||
this.currentKeyboard.children[1].innerHTML = generateEmojiHTML(skinTone);
|
||||
this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']").classList.add("sel");
|
||||
updateFilters();
|
||||
};
|
||||
|
||||
this.generateKeyboard = (input, left, top) => {
|
||||
@@ -103,10 +151,19 @@ enabled(){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
var search = document.createElement("div");
|
||||
search.innerHTML = "<input type='text' placeholder='Search...'>";
|
||||
search.classList.add("emoji-keyboard-search");
|
||||
|
||||
var skintones = document.createElement("div");
|
||||
skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join("");
|
||||
skintones.classList.add("emoji-keyboard-skintones");
|
||||
|
||||
outer.appendChild(search);
|
||||
outer.appendChild(keyboard);
|
||||
outer.appendChild(skintones);
|
||||
$(".js-app").append(outer);
|
||||
|
||||
skintones.addEventListener("click", function(e){
|
||||
if (e.target.hasAttribute("data-tone")){
|
||||
selectSkinTone(e.target.getAttribute("data-tone") || "");
|
||||
@@ -115,23 +172,36 @@ enabled(){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
outer.appendChild(keyboard);
|
||||
outer.appendChild(skintones);
|
||||
document.body.appendChild(outer);
|
||||
search.addEventListener("click", function(e){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
var searchInput = search.children[0];
|
||||
searchInput.focus();
|
||||
|
||||
searchInput.addEventListener("input", function(e){
|
||||
me.currentKeywords = e.target.value.split(" ").filter(kw => kw.length > 0).map(kw => kw.toLowerCase());
|
||||
updateFilters();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
searchInput.addEventListener("focus", function(){
|
||||
$(this).select();
|
||||
});
|
||||
|
||||
this.currentKeyboard = outer;
|
||||
selectSkinTone(this.selectedSkinTone);
|
||||
|
||||
this.currentSpanner = document.createElement("div");
|
||||
this.currentSpanner.style.height = ($(this.currentKeyboard).height()-10)+"px";
|
||||
$(".emoji-keyboard-popup-btn").parent().after(this.currentSpanner);
|
||||
|
||||
this.composePanelScroller.trigger("scroll");
|
||||
};
|
||||
|
||||
this.prevTryPasteImage = window.TDGF_tryPasteImage;
|
||||
var prevTryPasteImageF = this.prevTryPasteImage;
|
||||
|
||||
window.TDGF_tryPasteImage = function(){
|
||||
if (me.currentKeyboard){
|
||||
hideKeyboard();
|
||||
}
|
||||
|
||||
return prevTryPasteImageF.apply(this, arguments);
|
||||
var getKeyboardTop = () => {
|
||||
let button = $(".emoji-keyboard-popup-btn");
|
||||
return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8;
|
||||
};
|
||||
|
||||
// event handlers
|
||||
@@ -139,18 +209,22 @@ enabled(){
|
||||
this.emojiKeyboardButtonClickEvent = function(e){
|
||||
if (me.currentKeyboard){
|
||||
hideKeyboard();
|
||||
$(this).blur();
|
||||
}
|
||||
else{
|
||||
var pos = $(this).offset();
|
||||
me.generateKeyboard($(".js-compose-text").first(), pos.left, pos.top+$(this).outerHeight()+8);
|
||||
|
||||
me.generateKeyboard($(".js-compose-text").first(), $(this).offset().left, getKeyboardTop());
|
||||
$(this).addClass("is-selected");
|
||||
}
|
||||
|
||||
$(this).blur();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
this.composerScrollEvent = function(e){
|
||||
if (me.currentKeyboard){
|
||||
me.currentKeyboard.style.marginTop = (-$(this).scrollTop())+"px";
|
||||
}
|
||||
};
|
||||
|
||||
this.documentClickEvent = function(e){
|
||||
if (me.currentKeyboard && !e.target.classList.contains("js-compose-text")){
|
||||
hideKeyboard();
|
||||
@@ -164,18 +238,21 @@ enabled(){
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* ----
|
||||
* add emoji search if I can be bothered
|
||||
* lazy emoji loading
|
||||
*/
|
||||
this.uploadFilesEvent = function(e){
|
||||
if (me.currentKeyboard){
|
||||
me.currentKeyboard.style.top = getKeyboardTop()+"px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ready(){
|
||||
this.composePanelScroller = $(".js-compose-scroller", ".js-docked-compose").first().children().first();
|
||||
this.composePanelScroller.on("scroll", this.composerScrollEvent);
|
||||
|
||||
$(".emoji-keyboard-popup-btn").on("click", this.emojiKeyboardButtonClickEvent);
|
||||
$(document).on("click", this.documentClickEvent);
|
||||
$(document).on("keydown", this.documentKeyEvent);
|
||||
$(document).on("uiComposeImageAdded", this.uploadFilesEvent);
|
||||
|
||||
// HTML generation
|
||||
|
||||
@@ -190,18 +267,14 @@ ready(){
|
||||
};
|
||||
|
||||
$TDP.readFileRoot(this.$token, "emoji-ordering.txt").then(contents => {
|
||||
let generated1 = [];
|
||||
let generated2 = {};
|
||||
let generated3 = [];
|
||||
|
||||
for(let skinTone of this.skinToneList){
|
||||
generated2[skinTone] = [];
|
||||
this.emojiData2[skinTone] = [];
|
||||
}
|
||||
|
||||
// declaration inserters
|
||||
|
||||
let addDeclaration1 = decl => {
|
||||
generated1.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
|
||||
this.emojiData1.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
|
||||
};
|
||||
|
||||
let addDeclaration2 = (tone, decl) => {
|
||||
@@ -209,16 +282,16 @@ ready(){
|
||||
|
||||
if (tone === null){
|
||||
for(let skinTone of this.skinToneList){
|
||||
generated2[skinTone].push(gen);
|
||||
this.emojiData2[skinTone].push(gen);
|
||||
}
|
||||
}
|
||||
else{
|
||||
generated2[tone].push(gen);
|
||||
this.emojiData2[tone].push(gen);
|
||||
}
|
||||
};
|
||||
|
||||
let addDeclaration3 = decl => {
|
||||
generated3.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
|
||||
this.emojiData3.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
|
||||
};
|
||||
|
||||
// line reading
|
||||
@@ -228,9 +301,9 @@ ready(){
|
||||
for(let line of contents.split("\n")){
|
||||
if (line[0] === '@'){
|
||||
switch(skinToneState){
|
||||
case 0: generated1.push("___"); break;
|
||||
case 1: this.skinToneList.forEach(skinTone => generated2[skinTone].push("___")); break;
|
||||
case 2: generated3.push("___"); break;
|
||||
case 0: this.emojiData1.push("___"); break;
|
||||
case 1: this.skinToneList.forEach(skinTone => this.emojiData2[skinTone].push("___")); break;
|
||||
case 2: this.emojiData3.push("___"); break;
|
||||
}
|
||||
|
||||
if (line[1] === '1'){
|
||||
@@ -239,9 +312,15 @@ ready(){
|
||||
else if (line[1] === '2'){
|
||||
skinToneState = 2;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (skinToneState === 1){
|
||||
let decl = line.slice(0, line.indexOf(';'));
|
||||
|
||||
let semicolon = line.indexOf(';');
|
||||
let decl = line.slice(0, semicolon);
|
||||
let desc = line.slice(semicolon+1).toLowerCase();
|
||||
|
||||
if (skinToneState === 1){
|
||||
let skinIndex = decl.indexOf('$');
|
||||
|
||||
if (skinIndex !== -1){
|
||||
@@ -249,35 +328,24 @@ ready(){
|
||||
let declPost = decl.slice(skinIndex+1);
|
||||
|
||||
for(let skinTone of this.skinToneNonDefaultList){
|
||||
generated2[skinTone].pop();
|
||||
this.emojiData2[skinTone].pop();
|
||||
addDeclaration2(skinTone, declPre+skinTone+declPost);
|
||||
}
|
||||
}
|
||||
else{
|
||||
addDeclaration2(null, decl);
|
||||
this.emojiNames.push(desc);
|
||||
}
|
||||
}
|
||||
else if (skinToneState === 2){
|
||||
addDeclaration3(line.slice(0, line.indexOf(';')));
|
||||
addDeclaration3(decl);
|
||||
this.emojiNames.push(desc);
|
||||
}
|
||||
else if (skinToneState === 0){
|
||||
addDeclaration1(line.slice(0, line.indexOf(';')));
|
||||
addDeclaration1(decl);
|
||||
this.emojiNames.push(desc);
|
||||
}
|
||||
}
|
||||
|
||||
// final processing
|
||||
|
||||
let urlRegex = new RegExp(this.emojiURL.replace(/\./g, "\\."), "g");
|
||||
let process = str => TD.util.cleanWithEmoji(str).replace(/ class=\"emoji\" draggable=\"false\"/g, "").replace(urlRegex, "u#").replace(/___/g, "<div class='separator'></div>");
|
||||
|
||||
let start = "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that most emoji will not show up properly in the text box above, but they will display in the tweet.</p>";
|
||||
this.emojiHTML1 = start+process(generated1.join(""));
|
||||
|
||||
for(let skinTone of this.skinToneList){
|
||||
this.emojiHTML2[skinTone] = process(generated2[skinTone].join(""));
|
||||
}
|
||||
|
||||
this.emojiHTML3 = process(generated3.join(""));
|
||||
}).catch(err => {
|
||||
$TD.alert("error", "Problem loading emoji keyboard: "+err.message);
|
||||
});
|
||||
@@ -290,12 +358,17 @@ disabled(){
|
||||
$(this.currentKeyboard).remove();
|
||||
}
|
||||
|
||||
window.TDGF_tryPasteImage = this.prevTryPasteImage;
|
||||
if (this.currentSpanner){
|
||||
$(this.currentSpanner).remove();
|
||||
}
|
||||
|
||||
this.composePanelScroller.off("scroll", this.composerScrollEvent);
|
||||
|
||||
$(".emoji-keyboard-popup-btn").off("click", this.emojiKeyboardButtonClickEvent);
|
||||
$(".emoji-keyboard-popup-btn").remove();
|
||||
|
||||
$(document).off("click", this.documentClickEvent);
|
||||
$(document).off("keydown", this.documentKeyEvent);
|
||||
$(document).off("uiComposeImageAdded", this.uploadFilesEvent);
|
||||
TD.mustaches["compose/docked_compose.mustache"] = this.prevComposeMustache;
|
||||
}
|
||||
|
70
Resources/Plugins/emoji-keyboard/emoji-instructions.txt
Normal file
70
Resources/Plugins/emoji-keyboard/emoji-instructions.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
Emoji list: http://unicode.org/emoji/charts/emoji-ordering.html
|
||||
Emoji order: http://unicode.org/emoji/charts/emoji-ordering.txt
|
||||
|
||||
|
||||
------------------------
|
||||
Remove unnecessary info:
|
||||
|
||||
Search: \s;.+?#.+?\s
|
||||
Replace: ;
|
||||
|
||||
Search: U+
|
||||
Replace:
|
||||
|
||||
|
||||
-----------------------------
|
||||
Replace skin tone variations:
|
||||
|
||||
Example:
|
||||
|
||||
1F9D2;child
|
||||
1F9D2 1F3FB; child: light skin tone
|
||||
1F9D2 1F3FC; child: medium-light skin tone
|
||||
1F9D2 1F3FD; child: medium skin tone
|
||||
1F9D2 1F3FE; child: medium-dark skin tone
|
||||
1F9D2 1F3FF; child: dark skin tone
|
||||
|
||||
1F9D2;child
|
||||
1F9D2 $;child
|
||||
|
||||
TODO: Update this section with exact regexes
|
||||
|
||||
|
||||
----------------
|
||||
Move some emoji:
|
||||
|
||||
1F443 $;nose
|
||||
> 1F91D;handshake
|
||||
1F463;footprints
|
||||
|
||||
1F939 $ 200D 2640 FE0F;woman juggling
|
||||
> 1F6CC;person in bed
|
||||
> 1F6CC $;person in bed
|
||||
> 1F6C0;person taking bath
|
||||
> 1F6C0 $;person taking bath
|
||||
1F46B;man and woman holding hands
|
||||
|
||||
|
||||
------------------
|
||||
Remove some emoji:
|
||||
|
||||
1F469 $ 200D 1F692;woman firefighter
|
||||
> remove all non-gendered duplicates below here
|
||||
|
||||
3030;wavy dash
|
||||
> remove copyright
|
||||
> remove registered trademark
|
||||
> remove trademark
|
||||
0023 FE0F 20E3;keycap
|
||||
|
||||
1F441;eye
|
||||
> remove eye in speech bubble
|
||||
1F445;tongue
|
||||
|
||||
|
||||
-------------------------
|
||||
Add preprocessor symbols:
|
||||
|
||||
@ = group separator
|
||||
@1 = enable skin tones below
|
||||
@2 = disable skin tones below
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user