Skip to content

Commit

Permalink
Merge pull request #1740 from cwensley/gtk-fixes
Browse files Browse the repository at this point in the history
Gtk fixes
  • Loading branch information
cwensley authored Jun 28, 2020
2 parents a43f79b + b275507 commit c30c6ce
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Eto.Gtk/Forms/Controls/ButtonHandler.gtk2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public override string Text
get { return label.Text.ToEtoMnemonic(); }
set
{
label.Text = value;
label.TextWithMnemonic = value.ToPlatformMnemonic();
SetImagePosition();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Gtk/Forms/Controls/ButtonHandler.gtk3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override string Text
get { return label.Text.ToEtoMnemonic(); }
set
{
label.Text = value.ToPlatformMnemonic();
label.TextWithMnemonic = value.ToPlatformMnemonic();
SetImagePosition();
}
}
Expand Down
22 changes: 19 additions & 3 deletions src/Eto.Gtk/Forms/Controls/DocumentControlHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public DocumentControlHandler()
Control.Scrollable = true;
}

static readonly object HideTabsWithSinglePage_Key = new object();

public bool HideTabsWithSinglePage
{
get => Widget.Properties.Get<bool>(HideTabsWithSinglePage_Key);
set => Widget.Properties.Set(HideTabsWithSinglePage_Key, value);
}

protected override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -120,7 +128,7 @@ public void InsertPage(int index, DocumentPage page)


Control.SetTabReorderable(pageHandler.ContainerControl, allowReorder && Enabled);
Control.ShowTabs = Control.NPages > 1;
SetShowTabs();
}

public override bool Enabled
Expand All @@ -136,10 +144,18 @@ public override bool Enabled
}
}

void SetShowTabs()
{
if (HideTabsWithSinglePage)
{
Control.ShowTabs = Control.NPages > 1;
}
}

internal void ClosePage(Gtk.Widget control, DocumentPage page)
{
Control.RemovePage(Control.PageNum(control));
Control.ShowTabs = Control.NPages > 1;
SetShowTabs();

if (Widget.Loaded)
Callback.OnPageClosed(Widget, new DocumentPageEventArgs(page));
Expand All @@ -153,7 +169,7 @@ public void RemovePage(int index)
if (Widget.Loaded && Control.NPages == 0)
Callback.OnSelectedIndexChanged(Widget, EventArgs.Empty);

Control.ShowTabs = Control.NPages > 1;
SetShowTabs();
}

public DocumentPage GetPage(int index)
Expand Down
4 changes: 3 additions & 1 deletion src/Eto.Gtk/Forms/Controls/WebKit2WebViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ public string ExecuteScript(string script)
jsrunning = true;
jsreturn = "";

NativeMethods.webkit_web_view_run_javascript(Control.Handle, "function EtOrEtFuN() {" + script + " } EtOrEtFuN();", IntPtr.Zero, (Action<IntPtr, IntPtr, IntPtr>)FinishScriptExecution, IntPtr.Zero);
NativeMethods.webkit_web_view_run_javascript(Control.Handle, "function EtOrEtFuN() {" + script + " } EtOrEtFuN();", IntPtr.Zero, (FinishScriptExecutionDelegate)FinishScriptExecution, IntPtr.Zero);

while (jsrunning)
Gtk.Application.RunIteration();

return jsreturn;
}

delegate void FinishScriptExecutionDelegate(IntPtr webview, IntPtr result, IntPtr error);

private void FinishScriptExecution(IntPtr webview, IntPtr result, IntPtr error)
{
var jsresult = NativeMethods.webkit_web_view_run_javascript_finish(Control.Handle, result, IntPtr.Zero);
Expand Down

0 comments on commit c30c6ce

Please sign in to comment.