mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
609e04ddcf
Clean up the code of many examples in minor ways, fix some memory leaks, and avoid the use of dialogs where a regular toplevel works just as well.
39 lines
955 B
C
39 lines
955 B
C
/* Stack
|
|
*
|
|
* GtkStack is a container that shows a single child at a time,
|
|
* with nice transitions when the visible child changes.
|
|
*
|
|
* GtkStackSwitcher adds buttons to control which child is visible.
|
|
*/
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
GtkWidget *
|
|
do_stack (GtkWidget *do_widget)
|
|
{
|
|
static GtkWidget *window = NULL;
|
|
|
|
if (!window)
|
|
{
|
|
GtkBuilder *builder;
|
|
|
|
builder = gtk_builder_new_from_resource ("/stack/stack.ui");
|
|
gtk_builder_connect_signals (builder, NULL);
|
|
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
|
gtk_window_set_screen (GTK_WINDOW (window),
|
|
gtk_widget_get_screen (do_widget));
|
|
g_signal_connect (window, "destroy",
|
|
G_CALLBACK (gtk_widget_destroyed), &window);
|
|
|
|
g_object_unref (builder);
|
|
}
|
|
|
|
if (!gtk_widget_get_visible (window))
|
|
gtk_widget_show_all (window);
|
|
else
|
|
gtk_widget_destroy (window);
|
|
|
|
|
|
return window;
|
|
}
|