Browse Source

Merge pull request #440 from VitalElement/master

Scaling issue for linux + small fix to Folder Browse.
pull/447/head
Steven Kirk 10 years ago
parent
commit
f41f66f29a
  1. 9
      src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs
  2. 32
      src/Gtk/Perspex.Gtk/SystemDialogImpl.cs

9
src/Gtk/Perspex.Cairo/Media/FormattedTextImpl.cs

@ -15,6 +15,11 @@ namespace Perspex.Cairo.Media
private Size _size;
private readonly string _text;
static double CorrectScale(double input)
{
return input * 0.75;
}
public FormattedTextImpl(
Pango.Context context,
string text,
@ -25,14 +30,14 @@ namespace Perspex.Cairo.Media
FontWeight fontWeight)
{
Contract.Requires<ArgumentNullException>(context != null);
Contract.Requires<ArgumentNullException> (text != null);
Contract.Requires<ArgumentNullException>(text != null);
Layout = new Pango.Layout(context);
_text = text;
Layout.SetText(text);
Layout.FontDescription = new Pango.FontDescription
{
Family = fontFamily,
Size = Pango.Units.FromDouble(fontSize),
Size = Pango.Units.FromDouble(CorrectScale(fontSize)),
Style = (Pango.Style)fontStyle,
Weight = fontWeight.ToCairo()
};

32
src/Gtk/Perspex.Gtk/SystemDialogImpl.cs

@ -15,7 +15,7 @@ namespace Perspex.Gtk
public Task<string[]> ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent)
{
var tcs = new TaskCompletionSource<string[]>();
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl) parent),
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent),
dialog is OpenFileDialog
? FileChooserAction.Open
: FileChooserAction.Save,
@ -44,7 +44,7 @@ namespace Perspex.Gtk
dlg.Hide();
dlg.Dispose();
};
dlg.Close += delegate
{
tcs.TrySetResult(null);
@ -56,7 +56,33 @@ namespace Perspex.Gtk
public Task<string> ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent)
{
throw new NotImplementedException();
var tcs = new TaskCompletionSource<string>();
var dlg = new global::Gtk.FileChooserDialog(dialog.Title, ((WindowImpl)parent),
FileChooserAction.SelectFolder,
"Cancel", ResponseType.Cancel,
"Select Folder", ResponseType.Accept)
{
};
dlg.Modal = true;
dlg.Response += (_, args) =>
{
if (args.ResponseId == ResponseType.Accept)
tcs.TrySetResult(dlg.Filename);
dlg.Hide();
dlg.Dispose();
};
dlg.Close += delegate
{
tcs.TrySetResult(null);
dlg.Dispose();
};
dlg.Show();
return tcs.Task;
}
}
}

Loading…
Cancel
Save