gtk3-demo: Add a page setup example

This mainly so I can fix deprecation warnings in the
page setup dialog.
This commit is contained in:
Matthias Clasen 2015-05-12 08:20:35 -04:00
parent 2bb1ed69f0
commit bce624e7a7
4 changed files with 44 additions and 1 deletions

View File

@ -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 \

View File

@ -147,6 +147,7 @@
<file>offscreen_window.c</file>
<file>offscreen_window2.c</file>
<file>overlay.c</file>
<file>pagesetup.c</file>
<file>panes.c</file>
<file>pickers.c</file>
<file>pixbufs.c</file>

View File

@ -0,0 +1,38 @@
/* Printing/Page Setup
*
* GtkPageSetupUnixDialog can be used if page setup is needed
* independent of a full printing dialog.
*/
#include <math.h>
#include <gtk/gtk.h>
#include <gtk/gtkunixprint.h>
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;
}

View File

@ -1,4 +1,4 @@
/* Printing
/* Printing/Printing
*
* GtkPrintOperation offers a simple API to support printing
* in a cross-platform way.