forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Global.Linux.cs
168 lines (149 loc) · 6.62 KB
/
Global.Linux.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using Eto.Drawing;
using Eto.GtkSharp.Drawing;
using Gtk;
namespace MonoGame.Tools.Pipeline
{
static partial class Global
{
public static Application Application;
private static IconTheme _theme;
private static void PlatformInit()
{
Linux = true;
_theme = IconTheme.Default;
var iconMissing = _theme.LoadIcon("dialog-error", 16, 0);
var file = _theme.LoadIcon("text-x-generic", 16, 0);
var fileMissing = file.Copy();
iconMissing.Composite(fileMissing, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
var folder = _theme.LoadIcon("folder", 16, 0);
var folderMissing = folder.Copy();
iconMissing.Composite(folderMissing, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
_files["."] = ToEtoImage(file);
_fileMissing = ToEtoImage(fileMissing);
_folder = ToEtoImage(folder);
_folderMissing = ToEtoImage(folderMissing);
}
private static Gdk.Pixbuf PlatformGetFileIcon(string path)
{
Gdk.Pixbuf icon = null;
var file = GLib.FileFactory.NewForPath(path);
var info = file.QueryInfo("standard::*", GLib.FileQueryInfoFlags.None, null);
var sicon = info.Icon.ToString().Split(' ');
for (int i = sicon.Length - 1; i >= 1; i--)
{
try
{
icon = _theme.LoadIcon(sicon[i], 16, 0);
if (icon != null)
break;
}
catch { }
}
if (icon == null)
throw new Exception();
return icon;
}
private static Eto.Drawing.Image ToEtoImage(Gdk.Pixbuf icon)
{
return new Bitmap(new BitmapHandler(icon));
}
private static Gdk.Pixbuf PlatformGetIcon(string resource)
{
IconInfo iconInfo = null;
Gdk.Pixbuf icon = null;
try
{
switch (resource)
{
case "Commands.New.png":
iconInfo = _theme.LookupIcon("document-new", 16, 0);
break;
case "Commands.Open.png":
iconInfo = _theme.LookupIcon("document-open", 16, 0);
break;
case "Commands.Close.png":
iconInfo = _theme.LookupIcon("window-close", 16, 0);
break;
case "Commands.Save.png":
iconInfo = _theme.LookupIcon("document-save", 16, 0);
break;
case "Commands.SaveAs.png":
iconInfo = _theme.LookupIcon("document-save-as", 16, 0);
break;
case "Commands.Undo.png":
iconInfo = _theme.LookupIcon("edit-undo", 16, 0);
break;
case "Commands.Redo.png":
iconInfo = _theme.LookupIcon("edit-redo", 16, 0);
break;
case "Commands.Delete.png":
iconInfo = _theme.LookupIcon("edit-delete", 16, 0);
break;
case "Commands.NewItem.png":
iconInfo = _theme.LookupIcon("document-new", 16, 0);
break;
case "Commands.NewFolder.png":
iconInfo = _theme.LookupIcon("folder-new", 16, 0);
break;
case "Commands.ExistingItem.png":
iconInfo = _theme.LookupIcon("document", 16, 0);
break;
case "Commands.ExistingFolder.png":
iconInfo = _theme.LookupIcon("folder", 16, 0);
break;
case "Commands.Build.png":
iconInfo = _theme.LookupIcon("applications-system", 16, 0);
break;
case "Commands.Rebuild.png":
iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Commands.Clean.png":
iconInfo = _theme.LookupIcon("edit-clear-all", 16, 0);
if (iconInfo == null)
iconInfo = _theme.LookupIcon("edit-clear", 16, 0);
break;
case "Commands.CancelBuild.png":
iconInfo = _theme.LookupIcon("process-stop", 16, 0);
break;
case "Commands.Help.png":
iconInfo = _theme.LookupIcon("system-help", 16, 0);
break;
case "Build.Information.png":
iconInfo = _theme.LookupIcon("dialog-information", 16, 0);
break;
case "Build.Fail.png":
iconInfo = _theme.LookupIcon("dialog-error", 16, 0);
break;
case "Build.Processing.png":
iconInfo = _theme.LookupIcon("preferences-system-time", 16, 0);
break;
case "Build.Skip.png":
iconInfo = _theme.LookupIcon("emblem-default", 16, 0);
break;
case "Build.Start.png":
iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Build.EndSucceed.png":
iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Build.EndFailed.png":
iconInfo = _theme.LookupIcon("system-run", 16, 0);
break;
case "Build.Succeed.png":
iconInfo = _theme.LookupIcon("emblem-default", 16, 0);
break;
}
if (iconInfo != null)
icon = iconInfo.LoadIcon();
if (resource == "Commands.Rename.png" || resource == "Commands.OpenItem.png")
icon = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 1, 1, 1);
}
catch { }
return icon;
}
}
}