What I believe to me the most sense-full way is to:
- Check if the application is invisible and show it,
- Otherwise check if the window is inactive and present it,
- Otherwise hide it.
/* Show the window */ if (!(GTK_WIDGET_VISIBLE(window))) { gtk_widget_show(window); } /* Present the window */ else if (!gtk_window_is_active(GTK_WINDOW(window))) { gtk_window_present(GTK_WINDOW(window)); } /* Hide the window */ else { int winx, winy; gtk_window_get_position(GTK_WINDOW(window), &winx, &winy); gtk_widget_hide(window); gtk_window_move(GTK_WINDOW(window), winx, winy); }I have been doing this for quite a long time inside the Xfce Notes plugin, except a little different with multiple windows.
Some remarks, the PendingSealings proposes gtk_widget_get_visible instead of its analogous MACRO. And as you may also notice when the window is hidden it gets moved just after, this is important as otherwise the window would be repositioned by its initial value once shown again (e.g. centre of screen or dynamically by the window manager).
No comments:
Post a Comment