]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkpagesetupunixdialog.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkpagesetupunixdialog.c
index 3036f5ceab98c7d4a2a66e5e0616b0c0f8a668f8..801b2515fa7318e0a7af323026c98827ef532018 100644 (file)
@@ -1,4 +1,4 @@
-/* GtkPageSetupUnixDialog 
+/* GtkPageSetupUnixDialog
  * Copyright (C) 2006 Alexander Larsson <alexl@redhat.com>
  * Copyright © 2006, 2007, 2008 Christian Persch
  *
@@ -9,13 +9,11 @@
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 
 #include "gtktreemodel.h"
 #include "gtkbutton.h"
 #include "gtkscrolledwindow.h"
-#include "gtkvbox.h"
-#include "gtkhbox.h"
-#include "gtkframe.h"
-#include "gtkeventbox.h"
 #include "gtkcombobox.h"
 #include "gtktogglebutton.h"
 #include "gtkradiobutton.h"
 #include "gtklabel.h"
-#include "gtktable.h"
+#include "gtkgrid.h"
 #include "gtkcelllayout.h"
 #include "gtkcellrenderertext.h"
-#include "gtkalignment.h"
-#include "gtkspinbutton.h"
-#include "gtkbbox.h"
-#include "gtkhbbox.h"
 
 #include "gtkpagesetupunixdialog.h"
 #include "gtkcustompaperunixdialog.h"
@@ -75,7 +65,7 @@ struct _GtkPageSetupUnixDialogPrivate
   GtkListStore *printer_list;
   GtkListStore *page_setup_list;
   GtkListStore *custom_paper_list;
-  
+
   GList *print_backends;
 
   GtkWidget *printer_combo;
@@ -89,7 +79,7 @@ struct _GtkPageSetupUnixDialogPrivate
 
   gulong request_details_tag;
   GtkPrinter *request_details_printer;
-  
+
   GtkPrintSettings *print_settings;
 
   /* Save last setup so we can re-set it after selecting manage custom sizes */
@@ -115,16 +105,16 @@ G_DEFINE_TYPE (GtkPageSetupUnixDialog, gtk_page_setup_unix_dialog, GTK_TYPE_DIAL
 static void gtk_page_setup_unix_dialog_finalize  (GObject                *object);
 static void populate_dialog                      (GtkPageSetupUnixDialog *dialog);
 static void fill_paper_sizes_from_printer        (GtkPageSetupUnixDialog *dialog,
-                                                 GtkPrinter             *printer);
+                                                  GtkPrinter             *printer);
 static void printer_added_cb                     (GtkPrintBackend        *backend,
-                                                 GtkPrinter             *printer,
-                                                 GtkPageSetupUnixDialog *dialog);
+                                                  GtkPrinter             *printer,
+                                                  GtkPageSetupUnixDialog *dialog);
 static void printer_removed_cb                   (GtkPrintBackend        *backend,
-                                                 GtkPrinter             *printer,
-                                                 GtkPageSetupUnixDialog *dialog);
+                                                  GtkPrinter             *printer,
+                                                  GtkPageSetupUnixDialog *dialog);
 static void printer_status_cb                    (GtkPrintBackend        *backend,
-                                                 GtkPrinter             *printer,
-                                                 GtkPageSetupUnixDialog *dialog);
+                                                  GtkPrinter             *printer,
+                                                  GtkPageSetupUnixDialog *dialog);
 
 
 
@@ -148,10 +138,8 @@ static void
 gtk_page_setup_unix_dialog_class_init (GtkPageSetupUnixDialogClass *class)
 {
   GObjectClass *object_class;
-  GtkWidgetClass *widget_class;
 
   object_class = (GObjectClass *) class;
-  widget_class = (GtkWidgetClass *) class;
 
   object_class->finalize = gtk_page_setup_unix_dialog_finalize;
 
@@ -172,8 +160,8 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
   priv->print_backends = NULL;
 
   priv->printer_list = gtk_list_store_new (PRINTER_LIST_N_COLS,
-                                                  G_TYPE_STRING,
-                                                  G_TYPE_OBJECT);
+                                                   G_TYPE_STRING,
+                                                   G_TYPE_OBJECT);
 
   gtk_list_store_append (priv->printer_list, &iter);
   tmp = g_strdup_printf ("<b>%s</b>\n%s", _("Any Printer"), _("For portable documents"));
@@ -184,22 +172,22 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
   g_free (tmp);
 
   priv->page_setup_list = gtk_list_store_new (PAGE_SETUP_LIST_N_COLS,
-                                                     G_TYPE_OBJECT,
-                                                     G_TYPE_BOOLEAN);
+                                                      G_TYPE_OBJECT,
+                                                      G_TYPE_BOOLEAN);
 
   priv->custom_paper_list = gtk_list_store_new (1, G_TYPE_OBJECT);
   _gtk_print_load_custom_papers (priv->custom_paper_list);
 
   populate_dialog (dialog);
-  
-  gtk_dialog_add_buttons (GTK_DIALOG (dialog), 
+
+  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                           GTK_STOCK_APPLY, GTK_RESPONSE_OK,
                           NULL);
   gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                          GTK_RESPONSE_OK,
-                                          GTK_RESPONSE_CANCEL,
-                                          -1);
+                                           GTK_RESPONSE_OK,
+                                           GTK_RESPONSE_CANCEL,
+                                           -1);
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 }
@@ -211,16 +199,16 @@ gtk_page_setup_unix_dialog_finalize (GObject *object)
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkPrintBackend *backend;
   GList *node;
-  
+
   if (priv->request_details_tag)
     {
       g_signal_handler_disconnect (priv->request_details_printer,
-                                  priv->request_details_tag);
+                                   priv->request_details_tag);
       g_object_unref (priv->request_details_printer);
       priv->request_details_printer = NULL;
       priv->request_details_tag = 0;
     }
-  
+
   if (priv->printer_list)
     {
       g_object_unref (priv->printer_list);
@@ -259,7 +247,7 @@ gtk_page_setup_unix_dialog_finalize (GObject *object)
       gtk_print_backend_destroy (backend);
       g_object_unref (backend);
     }
-  
+
   g_list_free (priv->print_backends);
   priv->print_backends = NULL;
 
@@ -267,9 +255,9 @@ gtk_page_setup_unix_dialog_finalize (GObject *object)
 }
 
 static void
-printer_added_cb (GtkPrintBackend        *backend, 
-                 GtkPrinter             *printer, 
-                 GtkPageSetupUnixDialog *dialog)
+printer_added_cb (GtkPrintBackend        *backend,
+                  GtkPrinter             *printer,
+                  GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkTreeIter iter;
@@ -283,8 +271,8 @@ printer_added_cb (GtkPrintBackend        *backend,
   if (location == NULL)
     location = "";
   str = g_strdup_printf ("<b>%s</b>\n%s",
-                        gtk_printer_get_name (printer),
-                        location);
+                         gtk_printer_get_name (printer),
+                         location);
 
   gtk_list_store_append (priv->printer_list, &iter);
   gtk_list_store_set (priv->printer_list, &iter,
@@ -293,25 +281,25 @@ printer_added_cb (GtkPrintBackend        *backend,
                       -1);
 
   g_object_set_data_full (G_OBJECT (printer),
-                         "gtk-print-tree-iter",
+                          "gtk-print-tree-iter",
                           gtk_tree_iter_copy (&iter),
                           (GDestroyNotify) gtk_tree_iter_free);
   g_free (str);
 
   if (priv->waiting_for_printer != NULL &&
       strcmp (priv->waiting_for_printer,
-             gtk_printer_get_name (printer)) == 0)
+              gtk_printer_get_name (printer)) == 0)
     {
       gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
-                                    &iter);
+                                     &iter);
       priv->waiting_for_printer = NULL;
     }
 }
 
 static void
-printer_removed_cb (GtkPrintBackend        *backend, 
-                   GtkPrinter             *printer, 
-                   GtkPageSetupUnixDialog *dialog)
+printer_removed_cb (GtkPrintBackend        *backend,
+                    GtkPrinter             *printer,
+                    GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkTreeIter *iter;
@@ -322,23 +310,23 @@ printer_removed_cb (GtkPrintBackend        *backend,
 
 
 static void
-printer_status_cb (GtkPrintBackend        *backend, 
-                   GtkPrinter             *printer, 
-                  GtkPageSetupUnixDialog *dialog)
+printer_status_cb (GtkPrintBackend        *backend,
+                   GtkPrinter             *printer,
+                   GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkTreeIter *iter;
   gchar *str;
   const gchar *location;
-  
+
   iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
 
   location = gtk_printer_get_location (printer);
   if (location == NULL)
     location = "";
   str = g_strdup_printf ("<b>%s</b>\n%s",
-                        gtk_printer_get_name (printer),
-                        location);
+                         gtk_printer_get_name (printer),
+                         location);
   gtk_list_store_set (priv->printer_list, iter,
                       PRINTER_LIST_COL_NAME, str,
                       -1);
@@ -347,26 +335,26 @@ printer_status_cb (GtkPrintBackend        *backend,
 
 static void
 printer_list_initialize (GtkPageSetupUnixDialog *dialog,
-                        GtkPrintBackend        *print_backend)
+                         GtkPrintBackend        *print_backend)
 {
   GList *list, *node;
-  
+
   g_return_if_fail (print_backend != NULL);
 
-  g_signal_connect_object (print_backend, 
-                          "printer-added", 
-                          (GCallback) printer_added_cb, 
-                          G_OBJECT (dialog), 0);
+  g_signal_connect_object (print_backend,
+                           "printer-added",
+                           (GCallback) printer_added_cb,
+                           G_OBJECT (dialog), 0);
 
-  g_signal_connect_object (print_backend, 
-                          "printer-removed", 
-                          (GCallback) printer_removed_cb, 
-                          G_OBJECT (dialog), 0);
+  g_signal_connect_object (print_backend,
+                           "printer-removed",
+                           (GCallback) printer_removed_cb,
+                           G_OBJECT (dialog), 0);
 
-  g_signal_connect_object (print_backend, 
-                          "printer-status-changed", 
-                          (GCallback) printer_status_cb, 
-                          G_OBJECT (dialog), 0);
+  g_signal_connect_object (print_backend,
+                           "printer-status-changed",
+                           (GCallback) printer_status_cb,
+                           G_OBJECT (dialog), 0);
 
   list = gtk_print_backend_get_printer_list (print_backend);
 
@@ -378,7 +366,7 @@ printer_list_initialize (GtkPageSetupUnixDialog *dialog,
     }
 
   g_list_free (list);
-  
+
 }
 
 static void
@@ -396,8 +384,8 @@ load_print_backends (GtkPageSetupUnixDialog *dialog)
 
 static gboolean
 paper_size_row_is_separator (GtkTreeModel *model,
-                            GtkTreeIter  *iter,
-                            gpointer      data)
+                             GtkTreeIter  *iter,
+                             gpointer      data)
 {
   gboolean separator;
 
@@ -414,11 +402,11 @@ get_current_page_setup (GtkPageSetupUnixDialog *dialog)
   GtkTreeIter iter;
 
   current_page_setup = NULL;
-  
+
   combo_box = GTK_COMBO_BOX (priv->paper_size_combo);
   if (gtk_combo_box_get_active_iter (combo_box, &iter))
     gtk_tree_model_get (GTK_TREE_MODEL (priv->page_setup_list), &iter,
-                       PAGE_SETUP_LIST_COL_PAGE_SETUP, &current_page_setup, -1);
+                        PAGE_SETUP_LIST_COL_PAGE_SETUP, &current_page_setup, -1);
 
   if (current_page_setup)
     return current_page_setup;
@@ -426,17 +414,17 @@ get_current_page_setup (GtkPageSetupUnixDialog *dialog)
   /* No selected page size, return the default one.
    * This is used to set the first page setup when the dialog is created
    * as there is no selection on the first printer_changed.
-   */ 
+   */
   return gtk_page_setup_new ();
 }
 
 static gboolean
-page_setup_is_equal (GtkPageSetup *a, 
-                    GtkPageSetup *b)
+page_setup_is_equal (GtkPageSetup *a,
+                     GtkPageSetup *b)
 {
   return
     gtk_paper_size_is_equal (gtk_page_setup_get_paper_size (a),
-                            gtk_page_setup_get_paper_size (b)) &&
+                             gtk_page_setup_get_paper_size (b)) &&
     gtk_page_setup_get_top_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_top_margin (b, GTK_UNIT_MM) &&
     gtk_page_setup_get_bottom_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_bottom_margin (b, GTK_UNIT_MM) &&
     gtk_page_setup_get_left_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_left_margin (b, GTK_UNIT_MM) &&
@@ -445,17 +433,17 @@ page_setup_is_equal (GtkPageSetup *a,
 
 static gboolean
 page_setup_is_same_size (GtkPageSetup *a,
-                        GtkPageSetup *b)
+                         GtkPageSetup *b)
 {
   return gtk_paper_size_is_equal (gtk_page_setup_get_paper_size (a),
-                                 gtk_page_setup_get_paper_size (b));
+                                  gtk_page_setup_get_paper_size (b));
 }
 
 static gboolean
 set_paper_size (GtkPageSetupUnixDialog *dialog,
-               GtkPageSetup           *page_setup,
-               gboolean                size_only,
-               gboolean                add_item)
+                GtkPageSetup           *page_setup,
+                gboolean                size_only,
+                gboolean                add_item)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkTreeModel *model;
@@ -467,38 +455,38 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
   if (gtk_tree_model_get_iter_first (model, &iter))
     {
       do
-       {
-         gtk_tree_model_get (GTK_TREE_MODEL (priv->page_setup_list), &iter,
-                             PAGE_SETUP_LIST_COL_PAGE_SETUP, &list_page_setup, -1);
-         if (list_page_setup == NULL)
-           continue;
-         
-         if ((size_only && page_setup_is_same_size (page_setup, list_page_setup)) ||
-             (!size_only && page_setup_is_equal (page_setup, list_page_setup)))
-           {
-             gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
-                                            &iter);
-             g_object_unref (list_page_setup);
-             return TRUE;
-           }
-             
-         g_object_unref (list_page_setup);
-         
-       } while (gtk_tree_model_iter_next (model, &iter));
+        {
+          gtk_tree_model_get (GTK_TREE_MODEL (priv->page_setup_list), &iter,
+                              PAGE_SETUP_LIST_COL_PAGE_SETUP, &list_page_setup, -1);
+          if (list_page_setup == NULL)
+            continue;
+
+          if ((size_only && page_setup_is_same_size (page_setup, list_page_setup)) ||
+              (!size_only && page_setup_is_equal (page_setup, list_page_setup)))
+            {
+              gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
+                                             &iter);
+              g_object_unref (list_page_setup);
+              return TRUE;
+            }
+
+          g_object_unref (list_page_setup);
+
+        } while (gtk_tree_model_iter_next (model, &iter));
     }
 
   if (add_item)
     {
       gtk_list_store_append (priv->page_setup_list, &iter);
       gtk_list_store_set (priv->page_setup_list, &iter,
-                         PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
-                         -1);
+                          PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
+                          -1);
       gtk_list_store_append (priv->page_setup_list, &iter);
       gtk_list_store_set (priv->page_setup_list, &iter,
-                         PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
-                         -1);
+                          PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
+                          -1);
       gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
-                                    &iter);
+                                     &iter);
       return TRUE;
     }
 
@@ -517,22 +505,22 @@ fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
     {
       gtk_list_store_append (priv->page_setup_list, &paper_iter);
       gtk_list_store_set (priv->page_setup_list, &paper_iter,
-                         PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
-                         -1);
+                          PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
+                          -1);
       do
-       {
-         GtkPageSetup *page_setup;
-         gtk_tree_model_get (model, &iter, 0, &page_setup, -1);
+        {
+          GtkPageSetup *page_setup;
+          gtk_tree_model_get (model, &iter, 0, &page_setup, -1);
 
-         gtk_list_store_append (priv->page_setup_list, &paper_iter);
-         gtk_list_store_set (priv->page_setup_list, &paper_iter,
-                             PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
-                             -1);
+          gtk_list_store_append (priv->page_setup_list, &paper_iter);
+          gtk_list_store_set (priv->page_setup_list, &paper_iter,
+                              PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
+                              -1);
 
-         g_object_unref (page_setup);
-       } while (gtk_tree_model_iter_next (model, &iter));
+          g_object_unref (page_setup);
+        } while (gtk_tree_model_iter_next (model, &iter));
     }
-  
+
   gtk_list_store_append (priv->page_setup_list, &paper_iter);
   gtk_list_store_set (priv->page_setup_list, &paper_iter,
                       PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
@@ -545,7 +533,7 @@ fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
 
 static void
 fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
-                              GtkPrinter             *printer)
+                               GtkPrinter             *printer)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GList *list, *l;
@@ -559,38 +547,38 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
   if (printer == NULL)
     {
       for (i = 0; i < G_N_ELEMENTS (common_paper_sizes); i++)
-       {
-         page_setup = gtk_page_setup_new ();
-         paper_size = gtk_paper_size_new (common_paper_sizes[i]);
-         gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
-         gtk_paper_size_free (paper_size);
-         
-         gtk_list_store_append (priv->page_setup_list, &iter);
-         gtk_list_store_set (priv->page_setup_list, &iter,
-                             PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
-                             -1);
-         g_object_unref (page_setup);
-       }
+        {
+          page_setup = gtk_page_setup_new ();
+          paper_size = gtk_paper_size_new (common_paper_sizes[i]);
+          gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
+          gtk_paper_size_free (paper_size);
+
+          gtk_list_store_append (priv->page_setup_list, &iter);
+          gtk_list_store_set (priv->page_setup_list, &iter,
+                              PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
+                              -1);
+          g_object_unref (page_setup);
+        }
     }
   else
     {
       list = gtk_printer_list_papers (printer);
       /* TODO: We should really sort this list so interesting size
-        are at the top */
+         are at the top */
       for (l = list; l != NULL; l = l->next)
-       {
-         page_setup = l->data;
-         gtk_list_store_append (priv->page_setup_list, &iter);
-         gtk_list_store_set (priv->page_setup_list, &iter,
-                             PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
-                             -1);
-         g_object_unref (page_setup);
-       }
+        {
+          page_setup = l->data;
+          gtk_list_store_append (priv->page_setup_list, &iter);
+          gtk_list_store_set (priv->page_setup_list, &iter,
+                              PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
+                              -1);
+          g_object_unref (page_setup);
+        }
       g_list_free (list);
     }
 
   fill_custom_paper_sizes (dialog);
-  
+
   current_page_setup = NULL;
 
   /* When selecting a different printer, select its default paper size */
@@ -602,24 +590,24 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
 
   if (!set_paper_size (dialog, current_page_setup, FALSE, FALSE))
     set_paper_size (dialog, current_page_setup, TRUE, TRUE);
-  
+
   if (current_page_setup)
     g_object_unref (current_page_setup);
 }
 
 static void
 printer_changed_finished_callback (GtkPrinter             *printer,
-                                  gboolean                success,
-                                  GtkPageSetupUnixDialog *dialog)
+                                   gboolean                success,
+                                   GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
 
   g_signal_handler_disconnect (priv->request_details_printer,
-                              priv->request_details_tag);
+                               priv->request_details_tag);
   g_object_unref (priv->request_details_printer);
   priv->request_details_tag = 0;
   priv->request_details_printer = NULL;
-  
+
   if (success)
     fill_paper_sizes_from_printer (dialog, printer);
 
@@ -627,60 +615,60 @@ printer_changed_finished_callback (GtkPrinter             *printer,
 
 static void
 printer_changed_callback (GtkComboBox            *combo_box,
-                         GtkPageSetupUnixDialog *dialog)
+                          GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkPrinter *printer;
   GtkTreeIter iter;
 
   /* If we're waiting for a specific printer but the user changed
-   * to another printer, cancel that wait. 
+   * to another printer, cancel that wait.
    */
   if (priv->waiting_for_printer)
     {
       g_free (priv->waiting_for_printer);
       priv->waiting_for_printer = NULL;
     }
-  
+
   if (priv->request_details_tag)
     {
       g_signal_handler_disconnect (priv->request_details_printer,
-                                  priv->request_details_tag);
+                                   priv->request_details_tag);
       g_object_unref (priv->request_details_printer);
       priv->request_details_printer = NULL;
       priv->request_details_tag = 0;
     }
-  
+
   if (gtk_combo_box_get_active_iter (combo_box, &iter))
     {
       gtk_tree_model_get (gtk_combo_box_get_model (combo_box), &iter,
-                         PRINTER_LIST_COL_PRINTER, &printer, -1);
+                          PRINTER_LIST_COL_PRINTER, &printer, -1);
 
       if (printer == NULL || gtk_printer_has_details (printer))
-       fill_paper_sizes_from_printer (dialog, printer);
+        fill_paper_sizes_from_printer (dialog, printer);
       else
-       {
-         priv->request_details_printer = g_object_ref (printer);
-         priv->request_details_tag =
-           g_signal_connect (printer, "details-acquired",
-                             G_CALLBACK (printer_changed_finished_callback), dialog);
-         gtk_printer_request_details (printer);
+        {
+          priv->request_details_printer = g_object_ref (printer);
+          priv->request_details_tag =
+            g_signal_connect (printer, "details-acquired",
+                              G_CALLBACK (printer_changed_finished_callback), dialog);
+          gtk_printer_request_details (printer);
 
-       }
+        }
 
       if (printer)
-       g_object_unref (printer);
+        g_object_unref (printer);
 
       if (priv->print_settings)
-       {
-         const char *name = NULL;
-
-         if (printer)
-           name = gtk_printer_get_name (printer);
-         
-         gtk_print_settings_set (priv->print_settings,
-                                 "format-for-printer", name);
-       }
+        {
+          const char *name = NULL;
+
+          if (printer)
+            name = gtk_printer_get_name (printer);
+
+          gtk_print_settings_set (priv->print_settings,
+                                  "format-for-printer", name);
+        }
     }
 }
 
@@ -688,8 +676,8 @@ printer_changed_callback (GtkComboBox            *combo_box,
    after the decimal point, and not to many such digits if they
    are nonzero. I wish printf let you specify max precision for %f... */
 static gchar *
-double_to_string (gdouble d, 
-                 GtkUnit unit)
+double_to_string (gdouble d,
+                  GtkUnit unit)
 {
   gchar *val, *p;
   struct lconv *locale_data;
@@ -699,7 +687,7 @@ double_to_string (gdouble d,
   locale_data = localeconv ();
   decimal_point = locale_data->decimal_point;
   decimal_point_len = strlen (decimal_point);
-  
+
   /* Max two decimal digits for inch, max one for mm */
   if (unit == GTK_UNIT_INCH)
     val = g_strdup_printf ("%.2f", d);
@@ -712,7 +700,7 @@ double_to_string (gdouble d,
       while (*p == '0')
         p--;
       if (p - val + 1 >= decimal_point_len &&
-         strncmp (p - (decimal_point_len - 1), decimal_point, decimal_point_len) == 0)
+          strncmp (p - (decimal_point_len - 1), decimal_point, decimal_point_len) == 0)
         p -= decimal_point_len;
       p[1] = '\0';
     }
@@ -723,8 +711,8 @@ double_to_string (gdouble d,
 
 static void
 custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
-                                gint       response_id,
-                                gpointer   user_data)
+                                 gint       response_id,
+                                 gpointer   user_data)
 {
   GtkPageSetupUnixDialog *page_setup_dialog = GTK_PAGE_SETUP_UNIX_DIALOG (user_data);
   GtkPageSetupUnixDialogPrivate *priv = page_setup_dialog->priv;
@@ -739,7 +727,7 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
 
 static void
 paper_size_changed (GtkComboBox            *combo_box,
-                   GtkPageSetupUnixDialog *dialog)
+                    GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkTreeIter iter;
@@ -751,22 +739,22 @@ paper_size_changed (GtkComboBox            *combo_box,
   const gchar *unit_str;
 
   label = GTK_LABEL (priv->paper_size_label);
-   
+
   if (gtk_combo_box_get_active_iter (combo_box, &iter))
     {
       gtk_tree_model_get (gtk_combo_box_get_model (combo_box),
-                         &iter, PAGE_SETUP_LIST_COL_PAGE_SETUP, &page_setup, -1);
+                          &iter, PAGE_SETUP_LIST_COL_PAGE_SETUP, &page_setup, -1);
 
       if (page_setup == NULL)
-       {
+        {
           GtkWidget *custom_paper_dialog;
 
           /* Change from "manage" menu item to last value */
           if (priv->last_setup)
             last_page_setup = g_object_ref (priv->last_setup);
           else
-           last_page_setup = gtk_page_setup_new (); /* "good" default */
-         set_paper_size (dialog, last_page_setup, FALSE, TRUE);
+            last_page_setup = gtk_page_setup_new (); /* "good" default */
+          set_paper_size (dialog, last_page_setup, FALSE, TRUE);
           g_object_unref (last_page_setup);
 
           /* And show the custom paper dialog */
@@ -775,29 +763,28 @@ paper_size_changed (GtkComboBox            *combo_box,
           gtk_window_present (GTK_WINDOW (custom_paper_dialog));
 
           return;
-       }
+        }
 
       if (priv->last_setup)
-       g_object_unref (priv->last_setup);
+        g_object_unref (priv->last_setup);
 
       priv->last_setup = g_object_ref (page_setup);
-      
+
       unit = _gtk_print_get_default_user_units ();
 
       if (unit == GTK_UNIT_MM)
-       unit_str = _("mm");
+        unit_str = _("mm");
       else
-       unit_str = _("inch");
-       
+        unit_str = _("inch");
 
       w = double_to_string (gtk_page_setup_get_paper_width (page_setup, unit),
-                           unit);
+                            unit);
       h = double_to_string (gtk_page_setup_get_paper_height (page_setup, unit),
-                           unit);
+                            unit);
       str = g_strdup_printf ("%s x %s %s", w, h, unit_str);
       g_free (w);
       g_free (h);
-      
+
       gtk_label_set_text (label, str);
       g_free (str);
 
@@ -807,23 +794,23 @@ paper_size_changed (GtkComboBox            *combo_box,
       right = double_to_string (gtk_page_setup_get_right_margin (page_setup, unit), unit);
 
       str = g_strdup_printf (_("Margins:\n"
-                              " Left: %s %s\n"
-                              " Right: %s %s\n"
-                              " Top: %s %s\n"
-                              " Bottom: %s %s"
-                              ),
-                            left, unit_str,
-                            right, unit_str,
-                            top, unit_str,
-                            bottom, unit_str);
+                               " Left: %s %s\n"
+                               " Right: %s %s\n"
+                               " Top: %s %s\n"
+                               " Bottom: %s %s"
+                               ),
+                             left, unit_str,
+                             right, unit_str,
+                             top, unit_str,
+                             bottom, unit_str);
       g_free (top);
       g_free (bottom);
       g_free (left);
       g_free (right);
-      
+
       gtk_widget_set_tooltip_text (priv->paper_size_label, str);
       g_free (str);
-      
+
       g_object_unref (page_setup);
     }
   else
@@ -831,23 +818,23 @@ paper_size_changed (GtkComboBox            *combo_box,
       gtk_label_set_text (label, "");
       gtk_widget_set_tooltip_text (priv->paper_size_label, NULL);
       if (priv->last_setup)
-       g_object_unref (priv->last_setup);
+        g_object_unref (priv->last_setup);
       priv->last_setup = NULL;
     }
 }
 
 static void
 page_name_func (GtkCellLayout   *cell_layout,
-               GtkCellRenderer *cell,
-               GtkTreeModel    *tree_model,
-               GtkTreeIter     *iter,
-               gpointer         data)
+                GtkCellRenderer *cell,
+                GtkTreeModel    *tree_model,
+                GtkTreeIter     *iter,
+                gpointer         data)
 {
   GtkPageSetup *page_setup;
   GtkPaperSize *paper_size;
-  
+
   gtk_tree_model_get (tree_model, iter,
-                     PAGE_SETUP_LIST_COL_PAGE_SETUP, &page_setup, -1);
+                      PAGE_SETUP_LIST_COL_PAGE_SETUP, &page_setup, -1);
   if (page_setup)
     {
       paper_size = gtk_page_setup_get_paper_size (page_setup);
@@ -855,13 +842,13 @@ page_name_func (GtkCellLayout   *cell_layout,
       g_object_unref (page_setup);
     }
   else
-    g_object_set (cell, "text",  _("Manage Custom Sizes..."), NULL);
-      
+    g_object_set (cell, "text",  _("Manage Custom Sizes"), NULL);
+
 }
 
 static GtkWidget *
 create_radio_button (GSList      *group,
-                    const gchar *stock_id)
+                     const gchar *stock_id)
 {
   GtkWidget *radio_button, *image, *label, *hbox;
   GtkStockItem item;
@@ -870,7 +857,7 @@ create_radio_button (GSList      *group,
   image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_LARGE_TOOLBAR);
   gtk_stock_lookup (stock_id, &item);
   label = gtk_label_new (item.label);
-  hbox = gtk_hbox_new (0, 6);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_container_add (GTK_CONTAINER (radio_button), hbox);
   gtk_container_add (GTK_CONTAINER (hbox), image);
   gtk_container_add (GTK_CONTAINER (hbox), label);
@@ -899,18 +886,17 @@ populate_dialog (GtkPageSetupUnixDialog *ps_dialog)
   gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
   gtk_box_set_spacing (GTK_BOX (action_area), 6);
 
-  table = gtk_table_new (5, 4, FALSE);
-  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+  table = gtk_grid_new ();
+  gtk_grid_set_row_spacing (GTK_GRID (table), 6);
+  gtk_grid_set_column_spacing (GTK_GRID (table), 12);
   gtk_container_set_border_width (GTK_CONTAINER (table), 5);
   gtk_box_pack_start (GTK_BOX (content_area), table, TRUE, TRUE, 0);
   gtk_widget_show (table);
 
   label = gtk_label_new_with_mnemonic (_("_Format for:"));
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label,
-                   0, 1, 0, 1,
-                   GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
   gtk_widget_show (label);
 
   combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->printer_list));
@@ -922,81 +908,75 @@ populate_dialog (GtkPageSetupUnixDialog *ps_dialog)
                                   "markup", PRINTER_LIST_COL_NAME,
                                   NULL);
 
-  gtk_table_attach (GTK_TABLE (table), combo,
-                   1, 4, 0, 1,
-                   GTK_FILL | GTK_EXPAND, 0, 0, 0);
+  gtk_widget_set_halign (combo, GTK_ALIGN_FILL);
+  gtk_widget_set_hexpand (combo, TRUE);
+  gtk_grid_attach (GTK_GRID (table), combo, 1, 0, 3, 1);
   gtk_widget_show (combo);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
 
   label = gtk_label_new_with_mnemonic (_("_Paper size:"));
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label,
-                   0, 1, 1, 2,
-                   GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
   gtk_widget_show (label);
 
   combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->page_setup_list));
   priv->paper_size_combo = combo;
-  gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo), 
-                                       paper_size_row_is_separator, NULL, NULL);
-  
+  gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
+                                        paper_size_row_is_separator, NULL, NULL);
+
   cell = gtk_cell_renderer_text_new ();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
   gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), cell,
-                                     page_name_func, NULL, NULL);
+                                      page_name_func, NULL, NULL);
 
-  gtk_table_attach (GTK_TABLE (table), combo,
-                   1, 4, 1, 2,
-                   GTK_FILL | GTK_EXPAND, 0, 0, 0);
+  gtk_widget_set_halign (combo, GTK_ALIGN_FILL);
+  gtk_widget_set_hexpand (combo, TRUE);
+  gtk_grid_attach (GTK_GRID (table), combo, 1, 1, 3, 1);
   gtk_widget_show (combo);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
 
   label = gtk_label_new (NULL);
   priv->paper_size_label = label;
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label,
-                   1, 4, 2, 3,
-                   GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (table), label, 1, 2, 3, 1);
   gtk_widget_show (label);
 
   label = gtk_label_new_with_mnemonic (_("_Orientation:"));
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label,
-                   0, 1, 3, 4,
-                   GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+  gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
   gtk_widget_show (label);
 
   radio_button = create_radio_button (NULL, GTK_STOCK_ORIENTATION_PORTRAIT);
   priv->portrait_radio = radio_button;
-  gtk_table_attach (GTK_TABLE (table), radio_button,
-                   1, 2, 3, 4,
-                   GTK_EXPAND|GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (combo, GTK_ALIGN_FILL);
+  gtk_widget_set_hexpand (combo, TRUE);
+  gtk_grid_attach (GTK_GRID (table), radio_button, 1, 3, 1, 1);
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), radio_button);
 
   radio_button = create_radio_button (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button)),
-                                     GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT);
+                                      GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT);
   priv->reverse_portrait_radio = radio_button;
-  gtk_table_attach (GTK_TABLE (table), radio_button,
-                   2, 3, 3, 4,
-                   GTK_EXPAND|GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (combo, GTK_ALIGN_FILL);
+  gtk_widget_set_hexpand (combo, TRUE);
+  gtk_grid_attach (GTK_GRID (table), radio_button, 2, 3, 1, 1);
 
   radio_button = create_radio_button (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button)),
-                                     GTK_STOCK_ORIENTATION_LANDSCAPE);
+                                      GTK_STOCK_ORIENTATION_LANDSCAPE);
   priv->landscape_radio = radio_button;
-  gtk_table_attach (GTK_TABLE (table), radio_button,
-                   1, 2, 4, 5,
-                   GTK_EXPAND|GTK_FILL, 0, 0, 0);
+  gtk_widget_set_halign (combo, GTK_ALIGN_FILL);
+  gtk_widget_set_hexpand (combo, TRUE);
+  gtk_grid_attach (GTK_GRID (table), radio_button, 1, 4, 1, 1);
   gtk_widget_show (radio_button);
 
-  gtk_table_set_row_spacing (GTK_TABLE (table), 3, 0);
-  
   radio_button = create_radio_button (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_button)),
-                                     GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE);
+                                      GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE);
   priv->reverse_landscape_radio = radio_button;
-  gtk_table_attach (GTK_TABLE (table), radio_button,
-                   2, 3, 4, 5,
-                   GTK_EXPAND|GTK_FILL, 0, 0, 0);
-
+  gtk_widget_set_halign (combo, GTK_ALIGN_FILL);
+  gtk_widget_set_hexpand (combo, TRUE);
+  gtk_grid_attach (GTK_GRID (table), radio_button, 2, 4, 1, 1);
 
   g_signal_connect (priv->paper_size_combo, "changed", G_CALLBACK (paper_size_changed), ps_dialog);
   g_signal_connect (priv->printer_combo, "changed", G_CALLBACK (printer_changed_callback), ps_dialog);
@@ -1018,13 +998,13 @@ populate_dialog (GtkPageSetupUnixDialog *ps_dialog)
  */
 GtkWidget *
 gtk_page_setup_unix_dialog_new (const gchar *title,
-                               GtkWindow   *parent)
+                                GtkWindow   *parent)
 {
   GtkWidget *result;
 
   if (title == NULL)
     title = _("Page Setup");
-  
+
   result = g_object_new (GTK_TYPE_PAGE_SETUP_UNIX_DIALOG,
                          "title", title,
                          NULL);
@@ -1050,8 +1030,8 @@ get_orientation (GtkPageSetupUnixDialog *dialog)
 }
 
 static void
-set_orientation (GtkPageSetupUnixDialog *dialog, 
-                GtkPageOrientation      orientation)
+set_orientation (GtkPageSetupUnixDialog *dialog,
+                 GtkPageOrientation      orientation)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
 
@@ -1076,7 +1056,7 @@ set_orientation (GtkPageSetupUnixDialog *dialog,
  * gtk_page_setup_unix_dialog_set_page_setup:
  * @dialog: a #GtkPageSetupUnixDialog
  * @page_setup: a #GtkPageSetup
- * 
+ *
  * Sets the #GtkPageSetup from which the page setup
  * dialog takes its values.
  *
@@ -1084,7 +1064,7 @@ set_orientation (GtkPageSetupUnixDialog *dialog,
  **/
 void
 gtk_page_setup_unix_dialog_set_page_setup (GtkPageSetupUnixDialog *dialog,
-                                          GtkPageSetup           *page_setup)
+                                           GtkPageSetup           *page_setup)
 {
   if (page_setup)
     {
@@ -1096,10 +1076,10 @@ gtk_page_setup_unix_dialog_set_page_setup (GtkPageSetupUnixDialog *dialog,
 /**
  * gtk_page_setup_unix_dialog_get_page_setup:
  * @dialog: a #GtkPageSetupUnixDialog
- * 
- * Gets the currently selected page setup from the dialog. 
- * 
- * Returns: the current page setup 
+ *
+ * Gets the currently selected page setup from the dialog.
+ *
+ * Returns: (transfer none): the current page setup
  *
  * Since: 2.10
  **/
@@ -1107,7 +1087,7 @@ GtkPageSetup *
 gtk_page_setup_unix_dialog_get_page_setup (GtkPageSetupUnixDialog *dialog)
 {
   GtkPageSetup *page_setup;
-  
+
   page_setup = get_current_page_setup (dialog);
 
   gtk_page_setup_set_orientation (page_setup, get_orientation (dialog));
@@ -1117,7 +1097,7 @@ gtk_page_setup_unix_dialog_get_page_setup (GtkPageSetupUnixDialog *dialog)
 
 static gboolean
 set_active_printer (GtkPageSetupUnixDialog *dialog,
-                   const gchar            *printer_name)
+                    const gchar            *printer_name)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   GtkTreeModel *model;
@@ -1129,25 +1109,25 @@ set_active_printer (GtkPageSetupUnixDialog *dialog,
   if (gtk_tree_model_get_iter_first (model, &iter))
     {
       do
-       {
-         gtk_tree_model_get (GTK_TREE_MODEL (priv->printer_list), &iter,
-                             PRINTER_LIST_COL_PRINTER, &printer, -1);
-         if (printer == NULL)
-           continue;
-         
-         if (strcmp (gtk_printer_get_name (printer), printer_name) == 0)
-           {
-             gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
-                                            &iter);
-             g_object_unref (printer);
-             return TRUE;
-           }
-             
-         g_object_unref (printer);
-         
-       } while (gtk_tree_model_iter_next (model, &iter));
+        {
+          gtk_tree_model_get (GTK_TREE_MODEL (priv->printer_list), &iter,
+                              PRINTER_LIST_COL_PRINTER, &printer, -1);
+          if (printer == NULL)
+            continue;
+
+          if (strcmp (gtk_printer_get_name (printer), printer_name) == 0)
+            {
+              gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
+                                             &iter);
+              g_object_unref (printer);
+              return TRUE;
+            }
+
+          g_object_unref (printer);
+
+        } while (gtk_tree_model_iter_next (model, &iter));
     }
-  
+
   return FALSE;
 }
 
@@ -1155,15 +1135,15 @@ set_active_printer (GtkPageSetupUnixDialog *dialog,
  * gtk_page_setup_unix_dialog_set_print_settings:
  * @dialog: a #GtkPageSetupUnixDialog
  * @print_settings: a #GtkPrintSettings
- * 
+ *
  * Sets the #GtkPrintSettings from which the page setup dialog
  * takes its values.
- * 
+ *
  * Since: 2.10
  **/
 void
 gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
-                                              GtkPrintSettings       *print_settings)
+                                               GtkPrintSettings       *print_settings)
 {
   GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
   const gchar *format_for_printer;
@@ -1181,22 +1161,22 @@ gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
 
       format_for_printer = gtk_print_settings_get (print_settings, "format-for-printer");
 
-      /* Set printer if in list, otherwise set when 
-       * that printer is added 
+      /* Set printer if in list, otherwise set when
+       * that printer is added
        */
       if (format_for_printer &&
-         !set_active_printer (dialog, format_for_printer))
-       priv->waiting_for_printer = g_strdup (format_for_printer); 
+          !set_active_printer (dialog, format_for_printer))
+        priv->waiting_for_printer = g_strdup (format_for_printer);
     }
 }
 
 /**
  * gtk_page_setup_unix_dialog_get_print_settings:
  * @dialog: a #GtkPageSetupUnixDialog
- * 
+ *
  * Gets the current print settings from the dialog.
- * 
- * Returns: the current print settings
+ *
+ * Returns: (transfer none): the current print settings
  *
  * Since: 2.10
  **/