Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Duplicati/GUI/Duplicati.GUI.TrayIcon')
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs45
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj24
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs133
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_open.svg13
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_pause.svg14
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_quit.svg13
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_resume.svg13
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_open.svg13
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_pause.svg14
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_quit.svg13
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_resume.svg13
11 files changed, 238 insertions, 70 deletions
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs
index ecacbbd8d..407db2157 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs
@@ -54,32 +54,29 @@ namespace Duplicati.GUI.TrayIcon
{
set
{
+ m_appIndicator.IconName = GetTrayIconFilename(value);
+
switch(value)
{
- case TrayIcons.Paused:
- m_appIndicator.IconName = "normal-pause";
- m_appIndicator.IconDesc = "Paused";
- break;
- case TrayIcons.Running:
- m_appIndicator.IconName = "normal-running";
- m_appIndicator.IconDesc = "Running";
- break;
- case TrayIcons.IdleError:
- m_appIndicator.IconName = "normal-error";
- m_appIndicator.IconDesc = "Error";
- break;
- case TrayIcons.RunningError:
- m_appIndicator.IconName = "normal-running";
- break;
- case TrayIcons.PausedError:
- m_appIndicator.IconName = "normal-pause";
- m_appIndicator.IconDesc = "Paused";
- break;
- case TrayIcons.Idle:
- default:
- m_appIndicator.IconName = "normal";
- m_appIndicator.IconDesc = "Ready";
- break;
+ case TrayIcons.Paused:
+ m_appIndicator.IconDesc = "Paused";
+ break;
+ case TrayIcons.Running:
+ m_appIndicator.IconDesc = "Running";
+ break;
+ case TrayIcons.IdleError:
+ m_appIndicator.IconDesc = "Error";
+ break;
+ case TrayIcons.RunningError:
+ m_appIndicator.IconDesc = "Running";
+ break;
+ case TrayIcons.PausedError:
+ m_appIndicator.IconDesc = "Paused";
+ break;
+ case TrayIcons.Idle:
+ default:
+ m_appIndicator.IconDesc = "Ready";
+ break;
}
}
}
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
index 9429b8ac5..4556e4aa9 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj
@@ -372,5 +372,29 @@
<Link>OSXTrayHost\rumps.py</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="SVGIcons\dark\context_menu_open.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\dark\context_menu_pause.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\dark\context_menu_quit.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\dark\context_menu_resume.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\light\context_menu_open.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\light\context_menu_pause.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\light\context_menu_quit.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="SVGIcons\light\context_menu_resume.svg">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs
index caaa16377..5237edb81 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs
@@ -24,11 +24,16 @@ namespace Duplicati.GUI.TrayIcon
{
public class GtkRunner : TrayIconBase
{
+ private static string m_svgfolder;
+
/// <summary>
/// Static constructor that ensures the Gtk environment is initialized
/// </summary>
static GtkRunner()
{
+ m_svgfolder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SVGIcons");
+ m_svgfolder = System.IO.Path.Combine(m_svgfolder, "dark");
+
Gtk.Application.Init();
}
@@ -45,34 +50,36 @@ namespace Duplicati.GUI.TrayIcon
private static Dictionary<MenuIcons, Gtk.Image> _icons = new Dictionary<MenuIcons, Gtk.Image>();
public MenuItem MenuItem { get { return m_item; } }
-
- private Gtk.Image GetIcon(MenuIcons icon)
- {
- if (Duplicati.Library.Utility.Utility.IsClientOSX)
- return null;
- if (!_icons.ContainsKey(icon))
+ private string GetFilenameForIcon(MenuIcons icon)
+ {
+ switch (icon)
{
- switch(icon)
- {
- case MenuIcons.None:
- _icons[icon] = null;
- break;
case MenuIcons.Pause:
- _icons[icon] = ImageToGtk(ImageLoader.Pause);
- break;
+ return "context_menu_pause";
case MenuIcons.Quit:
- _icons[icon] = ImageToGtk(ImageLoader.CloseMenuIcon);
- break;
+ return "context_menu_quit";
case MenuIcons.Resume:
- _icons[icon] = ImageToGtk(ImageLoader.Play);
- break;
+ return "context_menu_resume";
case MenuIcons.Status:
- _icons[icon] = ImageToGtk(ImageLoader.StatusMenuIcon);
- break;
+ return "context_menu_open";
default:
- _icons[icon] = null;
- break;
+ return null;
+ }
+ }
+
+ private Gtk.Image GetIcon(MenuIcons icon)
+ {
+ if (!_icons.ContainsKey(icon))
+ {
+ _icons[icon] = null;
+
+ var filename = GetFilenameForIcon(icon);
+ if (filename != null)
+ {
+ filename = System.IO.Path.Combine(m_svgfolder, System.IO.Path.ChangeExtension(filename, ".svg"));
+ if (System.IO.File.Exists(filename))
+ _icons[icon] = new Gtk.Image(filename);
}
}
@@ -89,9 +96,9 @@ namespace Duplicati.GUI.TrayIcon
if (!Duplicati.Library.Utility.Utility.IsClientOSX)
if (icon != MenuIcons.None) {
((ImageMenuItem)m_item).Image = GetIcon(icon);
-
- //TODO: Not sure we should do this, it overrides policy?
- m_item.ExposeEvent += DrawImageMenuItemImage;
+
+ // On some (older versions) of GDK, this hack is required
+ //m_item.ExposeEvent += DrawImageMenuItemImage;
}
if (subitems != null && subitems.Count > 0)
@@ -116,6 +123,7 @@ namespace Duplicati.GUI.TrayIcon
m_callback();
}
+ /*
/// <summary> Draw the image to the image menu item. Taken from: http://mono.1490590.n4.nabble.com/ImageMenuItem-does-not-display-the-image-Linux-platform-tp3510861p3511376.html </summary>
/// The event source. <see cref="System.Object"/>
/// The event args. <see cref="Gtk.ExposeEventArgs"/>
@@ -133,7 +141,8 @@ namespace Duplicati.GUI.TrayIcon
args.Event.Window.DrawPixbuf(mainGC, image.Pixbuf, 0, 0, r.Left + 2,
r.Top + (r.Height - image.Pixbuf.Height) / 2, -1, -1, Gdk.RgbDither.None, 0, 0);
- }
+ }
+ */
public string Text
{
@@ -176,7 +185,9 @@ namespace Duplicati.GUI.TrayIcon
protected virtual void CreateTrayInstance()
{
- m_trayIcon = new StatusIcon();
+ // Sometimes the tray icon will not display
+ // if it is not created with an icon
+ m_trayIcon = StatusIcon.NewFromStock(Stock.About);
}
protected override void Run (string[] args)
@@ -231,33 +242,63 @@ namespace Duplicati.GUI.TrayIcon
Gtk.Image img = new Gtk.Image(stream);
return img;
}
- }
+ }
+
+ protected static string GetTrayIconFilename(TrayIcons icon)
+ {
+ switch (icon)
+ {
+ case TrayIcons.Paused:
+ return "normal-pause";
+ case TrayIcons.Running:
+ return "normal-running";
+ case TrayIcons.IdleError:
+ return "normal-error";
+ case TrayIcons.RunningError:
+ return "normal-running";
+ case TrayIcons.PausedError:
+ return "normal-pause";
+ case TrayIcons.Idle:
+ default:
+ return "normal";
+ }
+ }
protected static Pixbuf GetIcon(TrayIcons icon)
{
if (!_images.ContainsKey(icon))
{
- switch(icon)
+ if (Duplicati.Library.Utility.Utility.IsClientOSX)
{
- case TrayIcons.Paused:
- _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.PauseIcon).ToBitmap());
- break;
- case TrayIcons.Running:
- _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.WorkingIcon).ToBitmap());
- break;
- case TrayIcons.IdleError:
- _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.ErrorIcon).ToBitmap());
- break;
- case TrayIcons.RunningError:
- _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.WorkingIcon).ToBitmap());
- break;
- case TrayIcons.PausedError:
+ switch (icon)
+ {
+ case TrayIcons.Paused:
_images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.PauseIcon).ToBitmap());
- break;
- case TrayIcons.Idle:
- default:
- _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.NormalIcon).ToBitmap());
- break;
+ break;
+ case TrayIcons.Running:
+ _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.WorkingIcon).ToBitmap());
+ break;
+ case TrayIcons.IdleError:
+ _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.ErrorIcon).ToBitmap());
+ break;
+ case TrayIcons.RunningError:
+ _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.WorkingIcon).ToBitmap());
+ break;
+ case TrayIcons.PausedError:
+ _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.PauseIcon).ToBitmap());
+ break;
+ case TrayIcons.Idle:
+ default:
+ _images[icon] = ImageToPixbuf(ImageLoader.LoadIcon(ImageLoader.NormalIcon).ToBitmap());
+ break;
+ }
+ }
+ else
+ {
+ _images[icon] = null;
+ var filename = System.IO.Path.Combine(m_svgfolder, System.IO.Path.ChangeExtension(GetTrayIconFilename(icon), ".svg"));
+ if (System.IO.File.Exists(filename))
+ _images[icon] = new Pixbuf(filename);
}
}
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_open.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_open.svg
new file mode 100644
index 000000000..8dfe03665
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_open.svg
@@ -0,0 +1,13 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="show_Kopie" data-name="show Kopie">
+ <polygon class="cls-1" points="8 4.001 2 10.301 3.5 11.876 8 7.072 12.5 11.876 14 10.301 8 4.001"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_pause.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_pause.svg
new file mode 100644
index 000000000..8f646c100
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_pause.svg
@@ -0,0 +1,14 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="pause_Kopie" data-name="pause Kopie">
+ <rect class="cls-1" x="4" y="2" width="3" height="12"/>
+ <rect class="cls-1" x="9" y="2" width="3" height="12"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_quit.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_quit.svg
new file mode 100644
index 000000000..bc3cfae06
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_quit.svg
@@ -0,0 +1,13 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="15.997" height="16" viewBox="0 0 15.997 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="stop_Kopie" data-name="stop Kopie">
+ <polygon id="stop" class="cls-1" points="13.998 3.95 12.048 2 7.998 6.05 3.948 2 1.998 3.95 6.049 8 1.998 12.05 3.948 14 7.998 9.95 12.048 14 13.998 12.05 9.949 8 13.998 3.95"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_resume.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_resume.svg
new file mode 100644
index 000000000..b1c4ed79d
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/dark/context_menu_resume.svg
@@ -0,0 +1,13 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="resume_Kopie" data-name="resume Kopie">
+ <polygon class="cls-1" points="5 14 13 8 5 2 5 14"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_open.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_open.svg
new file mode 100644
index 000000000..8dfe03665
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_open.svg
@@ -0,0 +1,13 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="show_Kopie" data-name="show Kopie">
+ <polygon class="cls-1" points="8 4.001 2 10.301 3.5 11.876 8 7.072 12.5 11.876 14 10.301 8 4.001"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_pause.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_pause.svg
new file mode 100644
index 000000000..8f646c100
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_pause.svg
@@ -0,0 +1,14 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="pause_Kopie" data-name="pause Kopie">
+ <rect class="cls-1" x="4" y="2" width="3" height="12"/>
+ <rect class="cls-1" x="9" y="2" width="3" height="12"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_quit.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_quit.svg
new file mode 100644
index 000000000..bc3cfae06
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_quit.svg
@@ -0,0 +1,13 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="15.997" height="16" viewBox="0 0 15.997 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="stop_Kopie" data-name="stop Kopie">
+ <polygon id="stop" class="cls-1" points="13.998 3.95 12.048 2 7.998 6.05 3.948 2 1.998 3.95 6.049 8 1.998 12.05 3.948 14 7.998 9.95 12.048 14 13.998 12.05 9.949 8 13.998 3.95"/>
+ </g>
+</svg>
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_resume.svg b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_resume.svg
new file mode 100644
index 000000000..b1c4ed79d
--- /dev/null
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/light/context_menu_resume.svg
@@ -0,0 +1,13 @@
+<svg id="tray_menu_icons" data-name="tray menu icons" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #65b1dd;
+ }
+ </style>
+ </defs>
+ <title>tray context menu icons</title>
+ <g id="resume_Kopie" data-name="resume Kopie">
+ <polygon class="cls-1" points="5 14 13 8 5 2 5 14"/>
+ </g>
+</svg>