For a project I need to make a popup which should be "re-useable" under Gtk-sharp (2.12). I am developing under Ubuntu (14.04, LTS), Monodevelop (4.0.12)
When calling an update function it should refresh the information and show itself to the user. Refreshing isn't an issue. The issue I am having is when presenting the window to the user.
My idea is to use the window.Present() to show it to the user. When testing this, however, I am finding a strange behavior. Testing code is included at the bottom of this post.
Assume all examples start with a freshly started application
Scenario 1:
- Start program
- Click outside the window
- Wait
- Repeat steps 2 & 3.
Result: the window is shown, steps 2 and 3 can be repeated. No problem.
Scenario 2:
- Start program
- Click the "Hide" button
- Wait
- Window re-appears -> so far, so good
- Click the "Hide" button
- Click outside the window
Result: The icon appears but the window is not presented, sometimes the icon shakes.
Am I missing something here? Are more actions needed inside the body of TestPresent to Reset the Window?
The show is needed, in case the window is hidden.
static Window win;
public static void Main ()
{
Application.Init ();
win = new Window ("Test");
win.DeleteEvent += (o, args) => Application.Quit();
win.Resize (200, 200);
Button btnHide = new Button (new Label ("Hide"));
btnHide.Clicked += (sender, e) => win.Hide ();
win.Add (btnHide);
GLib.Timeout.Add(5000, new GLib.TimeoutHandler(TestPresent));
win.ShowAll ();
Application.Run ();
}
private static bool TestPresent()
{
win.Show ();
win.Present ();
return true;
}