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

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2013-08-26 22:33:05 +0400
committerLluis Sanchez <lluis@xamarin.com>2013-08-26 22:34:36 +0400
commit8c08093768dae5fd31910e6722cde67414b605ad (patch)
tree8cafadce54357cb741b5acf22cf491046d553a4b /main/src
parentf364a2ba614ef4d3894dc9f7cd7833890eaa9fec (diff)
Sync with GtkWorkarounds in XWT
Diffstat (limited to 'main/src')
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/GtkWorkarounds.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/GtkWorkarounds.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/GtkWorkarounds.cs
index bda3a23761..e171ce405c 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/GtkWorkarounds.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/GtkWorkarounds.cs
@@ -1086,9 +1086,15 @@ namespace Mono.TextEditor
[DllImport (PangoUtil.LIBGTK)]
static extern double gtk_widget_get_scale_factor (IntPtr widget);
+
+ [DllImport (PangoUtil.LIBGDK)]
+ static extern double gdk_screen_get_monitor_scale_factor (IntPtr widget, int monitor);
[DllImport (PangoUtil.LIBGOBJECT)]
static extern IntPtr g_object_get_data (IntPtr source, string name);
+
+ [DllImport (PangoUtil.LIBGTK)]
+ static extern IntPtr gtk_icon_set_render_icon_scaled (IntPtr handle, IntPtr style, int direction, int state, int size, IntPtr widget, IntPtr intPtr, ref double scale);
public static bool SetSourceScale (Gtk.IconSource source, double scale)
{
@@ -1155,6 +1161,41 @@ namespace Mono.TextEditor
supportsHiResIcons = false;
return 1;
}
+
+ public static double GetScaleFactor (this Gdk.Screen screen, int monitor)
+ {
+ if (!supportsHiResIcons)
+ return 1;
+
+ try {
+ return gdk_screen_get_monitor_scale_factor (screen.Handle, monitor);
+ } catch (DllNotFoundException) {
+ } catch (EntryPointNotFoundException) {
+ }
+ supportsHiResIcons = false;
+ return 1;
+ }
+
+ public static Gdk.Pixbuf RenderIcon (this Gtk.IconSet iconset, Gtk.Style style, Gtk.TextDirection direction, Gtk.StateType state, Gtk.IconSize size, Gtk.Widget widget, string detail, double scale)
+ {
+ if (scale == 1d)
+ return iconset.RenderIcon (style, direction, state, size, widget, detail);
+
+ if (!supportsHiResIcons)
+ return null;
+
+ try {
+ IntPtr intPtr = GLib.Marshaller.StringToPtrGStrdup (detail);
+ IntPtr o = gtk_icon_set_render_icon_scaled (iconset.Handle, (style != null) ? style.Handle : IntPtr.Zero, (int)direction, (int)state, (int)size, (widget != null) ? widget.Handle : IntPtr.Zero, intPtr, ref scale);
+ Gdk.Pixbuf result = (Gdk.Pixbuf) GLib.Object.GetObject (o);
+ GLib.Marshaller.Free (intPtr);
+ return result;
+ } catch (DllNotFoundException) {
+ } catch (EntryPointNotFoundException) {
+ }
+ supportsHiResIcons = false;
+ return null;
+ }
}
public struct KeyboardShortcut : IEquatable<KeyboardShortcut>