From bce624e7a766ce312686c10d0d277bd2bda67e9e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 12 May 2015 08:20:35 -0400 Subject: [PATCH] gtk3-demo: Add a page setup example This mainly so I can fix deprecation warnings in the page setup dialog. --- demos/gtk-demo/Makefile.am | 4 ++++ demos/gtk-demo/demo.gresource.xml | 1 + demos/gtk-demo/pagesetup.c | 38 +++++++++++++++++++++++++++++++ demos/gtk-demo/printing.c | 2 +- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 demos/gtk-demo/pagesetup.c diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am index f8b7c9f256..19c3abfdc0 100644 --- a/demos/gtk-demo/Makefile.am +++ b/demos/gtk-demo/Makefile.am @@ -61,6 +61,10 @@ demos = \ transparent.c \ tree_store.c +if OS_UNIX +demos += pagesetup.c +endif + AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_builddir)/gdk \ diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml index 91f50b6e82..c364e42487 100644 --- a/demos/gtk-demo/demo.gresource.xml +++ b/demos/gtk-demo/demo.gresource.xml @@ -147,6 +147,7 @@ offscreen_window.c offscreen_window2.c overlay.c + pagesetup.c panes.c pickers.c pixbufs.c diff --git a/demos/gtk-demo/pagesetup.c b/demos/gtk-demo/pagesetup.c new file mode 100644 index 0000000000..59709ab654 --- /dev/null +++ b/demos/gtk-demo/pagesetup.c @@ -0,0 +1,38 @@ +/* Printing/Page Setup + * + * GtkPageSetupUnixDialog can be used if page setup is needed + * independent of a full printing dialog. + */ + +#include +#include +#include + +static void +done_cb (GtkDialog *dialog, gint response, gpointer data) +{ + gtk_widget_destroy (GTK_WIDGET (dialog)); +} + +GtkWidget * +do_pagesetup (GtkWidget *do_widget) +{ + static GtkWidget *window = NULL; + + if (!window) + { + window = gtk_page_setup_unix_dialog_new ("Page Setup", GTK_WINDOW (do_widget)); + g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); + g_signal_connect (window, "response", G_CALLBACK (done_cb), NULL); + } + + if (!gtk_widget_get_visible (window)) + gtk_widget_show (window); + else + { + gtk_widget_destroy (window); + window = NULL; + } + + return window; +} diff --git a/demos/gtk-demo/printing.c b/demos/gtk-demo/printing.c index cc6473fb0e..4604311494 100644 --- a/demos/gtk-demo/printing.c +++ b/demos/gtk-demo/printing.c @@ -1,4 +1,4 @@ -/* Printing +/* Printing/Printing * * GtkPrintOperation offers a simple API to support printing * in a cross-platform way.