X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkprintunixdialog.c;h=c4ac91343f38db8e3b35c98d01b76411d8a008f7;hb=ca2368dba958d6fecf2fce417307bb9cbbe6eb6b;hp=d0cdae8c8c5f4e6ee9a43261b60cc7b11843ad1e;hpb=d433a606111d89727530f71d7b956ba40655bcbf;p=~andy%2Fgtk diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index d0cdae8c8..c4ac91343 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -14,20 +14,24 @@ * 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 . */ #include "config.h" + #include #include #include #include #include -#include "gtkintl.h" -#include "gtkprivate.h" +#include "gtkprintunixdialog.h" + +#include "gtkcustompaperunixdialog.h" +#include "gtkprintbackend.h" +#include "gtkprinter-private.h" +#include "gtkprinteroptionwidget.h" +#include "gtkprintutils.h" #include "gtkspinbutton.h" #include "gtkcellrendererpixbuf.h" @@ -42,25 +46,90 @@ #include "gtktogglebutton.h" #include "gtkradiobutton.h" #include "gtkdrawingarea.h" -#include "gtkvbox.h" -#include "gtktable.h" +#include "gtkbox.h" +#include "gtkgrid.h" #include "gtkframe.h" -#include "gtkalignment.h" #include "gtklabel.h" #include "gtkeventbox.h" #include "gtkbuildable.h" - -#include "gtkcustompaperunixdialog.h" -#include "gtkprintbackend.h" -#include "gtkprinter-private.h" -#include "gtkprintunixdialog.h" -#include "gtkprinteroptionwidget.h" -#include "gtkprintutils.h" - #include "gtkmessagedialog.h" #include "gtkbutton.h" +#include "gtkintl.h" +#include "gtkprivate.h" +#include "gtktypebuiltins.h" + + +/** + * SECTION:gtkprintunixdialog + * @Short_description: A print dialog + * @Title: GtkPrintUnixDialog + * @See_also: #GtkPageSetupUnixDialog, #GtkPrinter, #GtkPrintJob + * + * GtkPrintUnixDialog implements a print dialog for platforms + * which don't provide a native print dialog, like Unix. It can + * be used very much like any other GTK+ dialog, at the cost of + * the portability offered by the + * high-level printing API + * + * In order to print something with #GtkPrintUnixDialog, you need + * to use gtk_print_unix_dialog_get_selected_printer() to obtain + * a #GtkPrinter object and use it to construct a #GtkPrintJob using + * gtk_print_job_new(). + * + * #GtkPrintUnixDialog uses the following response values: + * + * %GTK_RESPONSE_OK + * for the "Print" button + * + * %GTK_RESPONSE_APPLY + * for the "Preview" button + * + * %GTK_RESPONSE_CANCEL + * for the "Cancel" button + * + * + * + * + * + * Printing support was added in GTK+ 2.10. + * + * + * GtkPrintUnixDialog as GtkBuildable + * + * The GtkPrintUnixDialog implementation of the GtkBuildable interface exposes its + * @notebook internal children with the name "notebook". + * + * + * A <structname>GtkPrintUnixDialog</structname> UI definition fragment. + * + * + * + * + * + * Content on notebook tab + * + * + * + * + * Tab label + * + * + * False + * False + * + * + * + * + * + * ]]> + * + * + * + */ -#define EXAMPLE_PAGE_AREA_SIZE 140 + +#define EXAMPLE_PAGE_AREA_SIZE 110 #define RULER_DISTANCE 7.5 #define RULER_RADIUS 2 @@ -75,8 +144,7 @@ static void gtk_print_unix_dialog_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gtk_print_unix_dialog_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void gtk_print_unix_dialog_style_updated (GtkWidget *widget); static void populate_dialog (GtkPrintUnixDialog *dialog); static void unschedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog); static void selected_printer_changed (GtkTreeSelection *selection, @@ -248,7 +316,7 @@ struct GtkPrintUnixDialogPrivate GtkPrinter *current_printer; GtkPrinter *request_details_printer; - guint request_details_tag; + gulong request_details_tag; GtkPrinterOptionSet *options; gulong options_changed_handler; gulong mark_conflicts_id; @@ -290,7 +358,7 @@ gtk_print_unix_dialog_class_init (GtkPrintUnixDialogClass *class) object_class->set_property = gtk_print_unix_dialog_set_property; object_class->get_property = gtk_print_unix_dialog_get_property; - widget_class->style_set = gtk_print_unix_dialog_style_set; + widget_class->style_updated = gtk_print_unix_dialog_style_updated; g_object_class_install_property (object_class, PROP_PAGE_SETUP, @@ -352,12 +420,12 @@ gtk_print_unix_dialog_class_init (GtkPrintUnixDialogClass *class) GTK_PARAM_READWRITE)); g_object_class_install_property (object_class, - PROP_EMBED_PAGE_SETUP, - g_param_spec_boolean ("embed-page-setup", - P_("Embed Page Setup"), - P_("TRUE if page setup combos are embedded in GtkPrintUnixDialog"), - FALSE, - GTK_PARAM_READWRITE)); + PROP_EMBED_PAGE_SETUP, + g_param_spec_boolean ("embed-page-setup", + P_("Embed Page Setup"), + P_("TRUE if page setup combos are embedded in GtkPrintUnixDialog"), + FALSE, + GTK_PARAM_READWRITE)); g_type_class_add_private (class, sizeof (GtkPrintUnixDialogPrivate)); } @@ -377,7 +445,7 @@ get_toplevel (GtkWidget *widget) static void set_busy_cursor (GtkPrintUnixDialog *dialog, - gboolean busy) + gboolean busy) { GtkWidget *widget; GtkWindow *toplevel; @@ -397,12 +465,11 @@ set_busy_cursor (GtkPrintUnixDialog *dialog, else cursor = NULL; - gdk_window_set_cursor (gtk_widget_get_window (widget), - cursor); + gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); gdk_display_flush (display); if (cursor) - gdk_cursor_unref (cursor); + g_object_unref (cursor); } static void @@ -452,8 +519,9 @@ error_dialogs (GtkPrintUnixDialog *print_dialog, return TRUE; } - /* Shows overwrite confirmation dialog in the case of printing to file which - * already exists. */ + /* Shows overwrite confirmation dialog in the case of printing + * to file which already exists. + */ if (gtk_printer_is_virtual (printer)) { option = gtk_printer_option_set_lookup (priv->options, @@ -548,20 +616,14 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog) priv->support_selection = FALSE; priv->has_selection = FALSE; - g_signal_connect (dialog, - "destroy", - (GCallback) gtk_print_unix_dialog_destroy, - NULL); + g_signal_connect (dialog, "destroy", + (GCallback) gtk_print_unix_dialog_destroy, NULL); - g_signal_connect (dialog, - "response", - (GCallback) error_dialogs, - NULL); + g_signal_connect (dialog, "response", + (GCallback) error_dialogs, NULL); - g_signal_connect (dialog, - "notify::page-setup", - (GCallback) redraw_page_layout_preview, - NULL); + g_signal_connect (dialog, "notify::page-setup", + (GCallback) redraw_page_layout_preview, NULL); priv->preview_button = gtk_button_new_from_stock (GTK_STOCK_PRINT_PREVIEW); gtk_widget_show (priv->preview_button); @@ -600,7 +662,8 @@ gtk_print_unix_dialog_destroy (GtkPrintUnixDialog *dialog) } static void -disconnect_printer_details_request (GtkPrintUnixDialog *dialog, gboolean details_failed) +disconnect_printer_details_request (GtkPrintUnixDialog *dialog, + gboolean details_failed) { GtkPrintUnixDialogPrivate *priv = dialog->priv; @@ -640,35 +703,11 @@ gtk_print_unix_dialog_finalize (GObject *object) unschedule_idle_mark_conflicts (dialog); disconnect_printer_details_request (dialog, FALSE); - if (priv->current_printer) - { - g_object_unref (priv->current_printer); - priv->current_printer = NULL; - } - - if (priv->printer_list) - { - g_object_unref (priv->printer_list); - priv->printer_list = NULL; - } - - if (priv->custom_paper_list) - { - g_object_unref (priv->custom_paper_list); - priv->custom_paper_list = NULL; - } - - if (priv->printer_list_filter) - { - g_object_unref (priv->printer_list_filter); - priv->printer_list_filter = NULL; - } - - if (priv->options) - { - g_object_unref (priv->options); - priv->options = NULL; - } + g_clear_object (&priv->current_printer); + g_clear_object (&priv->printer_list); + g_clear_object (&priv->custom_paper_list); + g_clear_object (&priv->printer_list_filter); + g_clear_object (&priv->options); if (priv->number_up_layout_2_option) { @@ -682,29 +721,11 @@ gtk_print_unix_dialog_finalize (GObject *object) priv->number_up_layout_2_option = NULL; } - if (priv->number_up_layout_n_option) - { - g_object_unref (priv->number_up_layout_n_option); - priv->number_up_layout_n_option = NULL; - } - - if (priv->page_setup) - { - g_object_unref (priv->page_setup); - priv->page_setup = NULL; - } - - if (priv->initial_settings) - { - g_object_unref (priv->initial_settings); - priv->initial_settings = NULL; - } - - g_free (priv->waiting_for_printer); - priv->waiting_for_printer = NULL; - - g_free (priv->format_for_printer); - priv->format_for_printer = NULL; + g_clear_object (&priv->number_up_layout_n_option); + g_clear_object (&priv->page_setup); + g_clear_object (&priv->initial_settings); + g_clear_pointer (&priv->waiting_for_printer, (GDestroyNotify)g_free); + g_clear_pointer (&priv->format_for_printer, (GDestroyNotify)g_free); for (node = priv->print_backends; node != NULL; node = node->next) { @@ -721,11 +742,7 @@ gtk_print_unix_dialog_finalize (GObject *object) g_list_free (priv->print_backends); priv->print_backends = NULL; - if (priv->page_setup_list) - { - g_object_unref (priv->page_setup_list); - priv->page_setup_list = NULL; - } + g_clear_object (&priv->page_setup_list); G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->finalize (object); } @@ -761,8 +778,9 @@ gtk_print_unix_dialog_buildable_get_internal_child (GtkBuildable *buildable, return parent_buildable_iface->get_internal_child (buildable, builder, childname); } -/* This function controls "sensitive" property of GtkCellRenderer based on pause - * state of printers. */ +/* This function controls "sensitive" property of GtkCellRenderer + * based on pause state of printers. + */ void set_cell_sensitivity_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, @@ -771,16 +789,16 @@ void set_cell_sensitivity_func (GtkTreeViewColumn *tree_column, { GtkPrinter *printer; - gtk_tree_model_get (tree_model, iter, PRINTER_LIST_COL_PRINTER_OBJ, &printer, -1); + gtk_tree_model_get (tree_model, iter, + PRINTER_LIST_COL_PRINTER_OBJ, &printer, + -1); if (printer != NULL && !gtk_printer_is_accepting_jobs (printer)) - g_object_set (cell, - "sensitive", FALSE, - NULL); + g_object_set (cell, "sensitive", FALSE, NULL); else - g_object_set (cell, - "sensitive", TRUE, - NULL); + g_object_set (cell, "sensitive", TRUE, NULL); + + g_object_unref (printer); } static void @@ -802,7 +820,8 @@ printer_status_cb (GtkPrintBackend *backend, -1); /* When the pause state change then we need to update sensitive property - * of GTK_RESPONSE_OK button inside of selected_printer_changed function. */ + * of GTK_RESPONSE_OK button inside of selected_printer_changed function. + */ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview)); selected_printer_changed (selection, dialog); @@ -845,8 +864,7 @@ printer_added_cb (GtkPrintBackend *backend, selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview)); if (priv->waiting_for_printer != NULL && - strcmp (gtk_printer_get_name (printer), - priv->waiting_for_printer) == 0) + strcmp (gtk_printer_get_name (printer), priv->waiting_for_printer) == 0) { priv->internal_printer_change = TRUE; gtk_tree_selection_select_iter (selection, &filter_iter); @@ -878,20 +896,14 @@ printer_list_initialize (GtkPrintUnixDialog *dialog, 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); @@ -1009,10 +1021,8 @@ is_printer_active (GtkTreeModel *model, GtkPrinter *printer; GtkPrintUnixDialogPrivate *priv = dialog->priv; - gtk_tree_model_get (model, - iter, - PRINTER_LIST_COL_PRINTER_OBJ, - &printer, + gtk_tree_model_get (model, iter, + PRINTER_LIST_COL_PRINTER_OBJ, &printer, -1); if (printer == NULL) @@ -1082,8 +1092,10 @@ default_printer_list_sort_func (GtkTreeModel *model, g_free (a_name); g_free (b_name); - g_object_unref (a_printer); - g_object_unref (b_printer); + if (a_printer) + g_object_unref (a_printer); + if (b_printer) + g_object_unref (b_printer); return result; } @@ -1129,29 +1141,28 @@ static GtkWidget * wrap_in_frame (const gchar *label, GtkWidget *child) { - GtkWidget *frame, *alignment, *label_widget; + GtkWidget *frame, *label_widget; gchar *bold_text; label_widget = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); + gtk_widget_set_halign (label_widget, GTK_ALIGN_START); + gtk_widget_set_valign (label_widget, GTK_ALIGN_CENTER); gtk_widget_show (label_widget); bold_text = g_markup_printf_escaped ("%s", label); gtk_label_set_markup (GTK_LABEL (label_widget), bold_text); g_free (bold_text); - frame = gtk_vbox_new (FALSE, 6); + frame = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (frame), label_widget, FALSE, FALSE, 0); - alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), - 0, 0, 12, 0); - gtk_box_pack_start (GTK_BOX (frame), alignment, FALSE, FALSE, 0); + gtk_widget_set_margin_left (child, 12); + gtk_widget_set_halign (child, GTK_ALIGN_FILL); + gtk_widget_set_valign (child, GTK_ALIGN_FILL); - gtk_container_add (GTK_CONTAINER (alignment), child); + gtk_box_pack_start (GTK_BOX (frame), child, FALSE, FALSE, 0); gtk_widget_show (frame); - gtk_widget_show (alignment); return frame; } @@ -1186,56 +1197,85 @@ add_option_to_extension_point (GtkPrinterOption *option, label = gtk_printer_option_widget_get_external_label (GTK_PRINTER_OPTION_WIDGET (widget)); gtk_widget_show (label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - hbox = gtk_hbox_new (FALSE, 12); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (extension_point), hbox, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (extension_point), hbox, TRUE, TRUE, 0); } else - gtk_box_pack_start (GTK_BOX (extension_point), widget, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (extension_point), widget, TRUE, TRUE, 0); +} + +static gint +grid_rows (GtkGrid *table) +{ + gint t0, t1, t, h; + GList *children, *c; + + children = gtk_container_get_children (GTK_CONTAINER (table)); + t0 = t1 = 0; + for (c = children; c; c = c->next) + { + gtk_container_child_get (GTK_CONTAINER (table), c->data, + "top-attach", &t, + "height", &h, + NULL); + if (c == children) + { + t0 = t; + t1 = t + h; + } + else + { + if (t < t0) + t0 = t; + if (t + h > t1) + t1 = t + h; + } + } + g_list_free (children); + + return t1 - t0; } static void add_option_to_table (GtkPrinterOption *option, gpointer user_data) { - GtkTable *table; + GtkGrid *table; GtkWidget *label, *widget; guint row; - table = GTK_TABLE (user_data); + table = GTK_GRID (user_data); if (g_str_has_prefix (option->name, "gtk-")) return; + row = grid_rows (table); + widget = gtk_printer_option_widget_new (option); gtk_widget_show (widget); - gtk_table_get_size (table, &row, NULL); - gtk_table_resize (table, row + 1, 2); - if (gtk_printer_option_widget_has_external_label (GTK_PRINTER_OPTION_WIDGET (widget))) { label = gtk_printer_option_widget_get_external_label (GTK_PRINTER_OPTION_WIDGET (widget)); gtk_widget_show (label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - gtk_table_attach (table, label, - 0, 1, row - 1 , row, GTK_FILL, 0, 0, 0); - - gtk_table_attach (table, widget, - 1, 2, row - 1, row, GTK_FILL, 0, 0, 0); + gtk_grid_attach (table, label, 0, row - 1, 1, 1); + gtk_grid_attach (table, widget, 1, row - 1, 1, 1); } else - gtk_table_attach (table, widget, - 0, 2, row - 1, row, GTK_FILL, 0, 0, 0); + gtk_grid_attach (table, widget, 0, row - 1, 2, 1); } static void @@ -1244,14 +1284,14 @@ setup_page_table (GtkPrinterOptionSet *options, GtkWidget *table, GtkWidget *page) { - guint nrows; + gint nrows; gtk_printer_option_set_foreach_in_group (options, group, add_option_to_table, table); - gtk_table_get_size (GTK_TABLE (table), &nrows, NULL); - if (nrows == 1) + nrows = grid_rows (GTK_GRID (table)); + if (nrows == 0) gtk_widget_hide (page); else gtk_widget_show (page); @@ -1281,7 +1321,9 @@ update_print_at_option (GtkPrintUnixDialog *dialog) option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time-text"); if (option != NULL) { - const char *text = gtk_entry_get_text (GTK_ENTRY (priv->print_at_entry)); + const gchar *text; + + text = gtk_entry_get_text (GTK_ENTRY (priv->print_at_entry)); gtk_printer_option_set (option, text); } } @@ -1345,6 +1387,7 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog) GtkWidget *table, *frame; gboolean has_advanced, has_job; guint nrows; + GList *children; if (priv->current_printer == NULL) { @@ -1398,6 +1441,16 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog) add_option_to_extension_point, priv->extension_point); + /* A bit of a hack, keep the last option flush right. + * This keeps the file format radios from moving as the + * filename changes. + */ + children = gtk_container_get_children (GTK_CONTAINER (priv->extension_point)); + l = g_list_last (children); + if (l && l != children) + gtk_widget_set_halign (GTK_WIDGET (l->data), GTK_ALIGN_END); + g_list_free (children); + /* Put the rest of the groups in the advanced page */ groups = gtk_printer_option_set_get_groups (priv->options); @@ -1415,17 +1468,17 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog) strcmp (group, "GtkPrintDialogExtension") == 0) continue; - table = gtk_table_new (1, 2, 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_printer_option_set_foreach_in_group (priv->options, group, add_option_to_table, table); - gtk_table_get_size (GTK_TABLE (table), &nrows, NULL); - if (nrows == 1) + nrows = grid_rows (GTK_GRID (table)); + if (nrows == 0) gtk_widget_destroy (table); else { @@ -1444,8 +1497,7 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog) else gtk_widget_hide (priv->advanced_page); - g_list_foreach (groups, (GFunc) g_free, NULL); - g_list_free (groups); + g_list_free_full (groups, g_free); } static void @@ -1486,12 +1538,12 @@ update_dialog_from_capabilities (GtkPrintUnixDialog *dialog) } 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) && @@ -1500,17 +1552,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 (GtkPrintUnixDialog *dialog, - GtkPageSetup *page_setup, - gboolean size_only, - gboolean add_item) + GtkPageSetup *page_setup, + gboolean size_only, + gboolean add_item) { GtkPrintUnixDialogPrivate *priv = dialog->priv; GtkTreeModel *model; @@ -1528,42 +1580,43 @@ set_paper_size (GtkPrintUnixDialog *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); - gtk_combo_box_set_active (GTK_COMBO_BOX (priv->orientation_combo), - gtk_page_setup_get_orientation (page_setup)); - 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); + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->orientation_combo), + gtk_page_setup_get_orientation (page_setup)); + 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); gtk_combo_box_set_active (GTK_COMBO_BOX (priv->orientation_combo), - gtk_page_setup_get_orientation (page_setup)); + gtk_page_setup_get_orientation (page_setup)); return TRUE; } @@ -1582,22 +1635,22 @@ fill_custom_paper_sizes (GtkPrintUnixDialog *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, @@ -1624,30 +1677,30 @@ fill_paper_sizes (GtkPrintUnixDialog *dialog, if (printer == NULL || (list = gtk_printer_list_papers (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 { 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); } @@ -1776,20 +1829,13 @@ clear_per_printer_ui (GtkPrintUnixDialog *dialog) GtkPrintUnixDialogPrivate *priv = dialog->priv; gtk_container_foreach (GTK_CONTAINER (priv->finishing_table), - (GtkCallback)gtk_widget_destroy, - NULL); - gtk_table_resize (GTK_TABLE (priv->finishing_table), 1, 2); + (GtkCallback)gtk_widget_destroy, NULL); gtk_container_foreach (GTK_CONTAINER (priv->image_quality_table), - (GtkCallback)gtk_widget_destroy, - NULL); - gtk_table_resize (GTK_TABLE (priv->image_quality_table), 1, 2); + (GtkCallback)gtk_widget_destroy, NULL); gtk_container_foreach (GTK_CONTAINER (priv->color_table), - (GtkCallback)gtk_widget_destroy, - NULL); - gtk_table_resize (GTK_TABLE (priv->color_table), 1, 2); + (GtkCallback)gtk_widget_destroy, NULL); gtk_container_foreach (GTK_CONTAINER (priv->advanced_vbox), - (GtkCallback)gtk_widget_destroy, - NULL); + (GtkCallback)gtk_widget_destroy, NULL); extension_point_clear_children (GTK_CONTAINER (priv->extension_point)); } @@ -1820,7 +1866,8 @@ selected_printer_changed (GtkTreeSelection *selection, GtkTreeIter iter, filter_iter; /* Whenever the user selects a printer we stop looking for - the printer specified in the initial settings */ + * the printer specified in the initial settings + */ if (priv->waiting_for_printer && !priv->internal_printer_change) { @@ -1848,14 +1895,10 @@ selected_printer_changed (GtkTreeSelection *selection, if (printer != NULL) { if (!gtk_printer_is_accepting_jobs (printer)) - { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); - } - else - { - if (priv->current_printer == printer && gtk_printer_has_details (printer)) - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); - } + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); + else if (priv->current_printer == printer && gtk_printer_has_details (printer)) + + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); } if (printer != NULL && !gtk_printer_has_details (printer)) @@ -1870,7 +1913,7 @@ selected_printer_changed (GtkTreeSelection *selection, set_busy_cursor (dialog, TRUE); gtk_list_store_set (GTK_LIST_STORE (priv->printer_list), g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter"), - PRINTER_LIST_COL_STATE, _("Getting printer information..."), + PRINTER_LIST_COL_STATE, _("Getting printer information…"), -1); return; } @@ -1884,20 +1927,14 @@ selected_printer_changed (GtkTreeSelection *selection, if (priv->options) { - g_object_unref (priv->options); - priv->options = NULL; - + g_clear_object (&priv->options); clear_per_printer_ui (dialog); } - if (priv->current_printer) - { - g_object_unref (priv->current_printer); - } - + g_clear_object (&priv->current_printer); priv->printer_capabilities = 0; - if (gtk_printer_is_accepting_jobs (printer)) + if (printer != NULL && gtk_printer_is_accepting_jobs (printer)) gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); priv->current_printer = printer; @@ -1928,6 +1965,7 @@ selected_printer_changed (GtkTreeSelection *selection, priv->options_changed_handler = g_signal_connect_swapped (priv->options, "changed", G_CALLBACK (options_changed_cb), dialog); + schedule_idle_mark_conflicts (dialog); } update_dialog_from_settings (dialog); @@ -1958,9 +1996,10 @@ paint_page (GtkWidget *widget, gchar *text, gint text_x) { - GtkStyle *style; + GtkStyleContext *context; gint x, y, width, height; gint text_y, linewidth; + GdkRGBA color; x = x_offset * scale; y = y_offset * scale; @@ -1970,13 +2009,18 @@ paint_page (GtkWidget *widget, linewidth = 2; text_y = 21; - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW); - gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]); + gtk_style_context_get_background_color (context, 0, &color); + gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, x, y, width, height); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]); + gtk_style_context_get_color (context, 0, &color); + gdk_cairo_set_source_rgba (cr, &color); cairo_set_line_width (cr, linewidth); cairo_rectangle (cr, x + linewidth/2.0, y + linewidth/2.0, width - linewidth, height - linewidth); cairo_stroke (cr); @@ -1987,16 +2031,16 @@ paint_page (GtkWidget *widget, cairo_set_font_size (cr, (gint)(9 * scale)); cairo_move_to (cr, x + (gint)(text_x * scale), y + (gint)(text_y * scale)); cairo_show_text (cr, text); + + gtk_style_context_restore (context); } static gboolean draw_collate_cb (GtkWidget *widget, - GdkEventExpose *event, + cairo_t *cr, GtkPrintUnixDialog *dialog) { - GtkAllocation allocation; GtkSettings *settings; - cairo_t *cr; gint size; gfloat scale; gboolean collate, reverse, rtl; @@ -2017,12 +2061,6 @@ draw_collate_cb (GtkWidget *widget, scale = size / 48.0; text_x = rtl ? 4 : 11; - cr = gdk_cairo_create (gtk_widget_get_window (widget)); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); - gtk_widget_set_allocation (widget, &allocation); - if (copies == 1) { paint_page (widget, cr, scale, rtl ? 40: 15, 5, reverse ? "1" : "2", text_x); @@ -2037,16 +2075,13 @@ draw_collate_cb (GtkWidget *widget, paint_page (widget, cr, scale, rtl ? 15 : 40, 15, collate == reverse ? "2" : "1", text_x); } - cairo_destroy (cr); - return TRUE; } static void -gtk_print_unix_dialog_style_set (GtkWidget *widget, - GtkStyle *previous_style) +gtk_print_unix_dialog_style_updated (GtkWidget *widget) { - GTK_WIDGET_CLASS (gtk_print_unix_dialog_parent_class)->style_set (widget, previous_style); + GTK_WIDGET_CLASS (gtk_print_unix_dialog_parent_class)->style_updated (widget); if (gtk_widget_has_screen (widget)) { @@ -2110,11 +2145,11 @@ create_main_page (GtkPrintUnixDialog *dialog) GtkWidget *custom_input; const gchar *range_tooltip; - main_vbox = gtk_vbox_new (FALSE, 18); + main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_widget_show (main_vbox); - vbox = gtk_vbox_new (FALSE, 6); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); @@ -2180,19 +2215,19 @@ create_main_page (GtkPrintUnixDialog *dialog) gtk_widget_show (treeview); gtk_container_add (GTK_CONTAINER (scrolled), treeview); - custom_input = gtk_hbox_new (FALSE, 18); + custom_input = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 18); gtk_widget_show (custom_input); gtk_box_pack_start (GTK_BOX (vbox), custom_input, FALSE, FALSE, 0); priv->extension_point = custom_input; - hbox = gtk_hbox_new (FALSE, 18); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 18); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); - table = gtk_table_new (4, 2, FALSE); + table = gtk_grid_new (); priv->range_table = table; - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_grid_set_row_spacing (GTK_GRID (table), 6); + gtk_grid_set_column_spacing (GTK_GRID (table), 12); frame = wrap_in_frame (_("Range"), table); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (table); @@ -2200,28 +2235,21 @@ create_main_page (GtkPrintUnixDialog *dialog) radio = gtk_radio_button_new_with_mnemonic (NULL, _("_All Pages")); priv->all_pages_radio = radio; gtk_widget_show (radio); - gtk_table_attach (GTK_TABLE (table), radio, - 0, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 0, 2, 1); radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("C_urrent Page")); if (priv->current_page == -1) gtk_widget_set_sensitive (radio, FALSE); priv->current_page_radio = radio; gtk_widget_show (radio); - gtk_table_attach (GTK_TABLE (table), radio, - 0, 2, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 1, 2, 1); radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Se_lection")); gtk_widget_set_sensitive (radio, priv->has_selection); priv->selection_radio = radio; - gtk_table_attach (GTK_TABLE (table), radio, - 0, 2, 2, 3, GTK_FILL, 0, - 0, 0); - gtk_table_set_row_spacing (GTK_TABLE (table), 2, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 2, 2, 1); radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Pag_es:")); range_tooltip = _("Specify one or more page ranges,\n e.g. 1-3,7,11"); @@ -2229,41 +2257,36 @@ create_main_page (GtkPrintUnixDialog *dialog) priv->page_range_radio = radio; gtk_widget_show (radio); - gtk_table_attach (GTK_TABLE (table), radio, - 0, 1, 3, 4, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 3, 1, 1); entry = gtk_entry_new (); gtk_widget_set_tooltip_text (entry, range_tooltip); + gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); atk_object_set_name (gtk_widget_get_accessible (entry), _("Pages")); atk_object_set_description (gtk_widget_get_accessible (entry), range_tooltip); priv->page_range_entry = entry; gtk_widget_show (entry); - gtk_table_attach (GTK_TABLE (table), entry, - 1, 2, 3, 4, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), entry, 1, 3, 1, 1); g_signal_connect (radio, "toggled", G_CALLBACK (update_entry_sensitivity), entry); update_entry_sensitivity (radio, entry); - table = gtk_table_new (3, 2, 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); frame = wrap_in_frame (_("Copies"), table); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (table); /* FIXME chpe: too much space between Copies and spinbutton, put those 2 in a hbox and make it span 2 columns */ label = gtk_label_new_with_mnemonic (_("Copie_s:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1); spinbutton = gtk_spin_button_new_with_range (1.0, 100.0, 1.0); + gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE); priv->copies_spin = spinbutton; gtk_widget_show (spinbutton); - gtk_table_attach (GTK_TABLE (table), spinbutton, - 1, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), spinbutton, 1, 0, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton); g_signal_connect_swapped (spinbutton, "value-changed", G_CALLBACK (update_dialog_from_capabilities), dialog); @@ -2274,17 +2297,13 @@ create_main_page (GtkPrintUnixDialog *dialog) priv->collate_check = check; g_signal_connect (check, "toggled", G_CALLBACK (update_collate_icon), dialog); gtk_widget_show (check); - gtk_table_attach (GTK_TABLE (table), check, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), check, 0, 1, 1, 1); check = gtk_check_button_new_with_mnemonic (_("_Reverse")); g_signal_connect (check, "toggled", G_CALLBACK (update_collate_icon), dialog); priv->reverse_check = check; gtk_widget_show (check); - gtk_table_attach (GTK_TABLE (table), check, - 0, 1, 2, 3, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), check, 0, 2, 1, 1); image = gtk_drawing_area_new (); gtk_widget_set_has_window (image, FALSE); @@ -2292,10 +2311,8 @@ create_main_page (GtkPrintUnixDialog *dialog) priv->collate_image = image; gtk_widget_show (image); gtk_widget_set_size_request (image, 70, 90); - gtk_table_attach (GTK_TABLE (table), image, - 1, 2, 1, 3, GTK_FILL, 0, - 0, 0); - g_signal_connect (image, "expose-event", + gtk_grid_attach (GTK_GRID (table), image, 1, 1, 1, 2); + g_signal_connect (image, "draw", G_CALLBACK (draw_collate_cb), dialog); label = gtk_label_new (_("General")); @@ -2575,6 +2592,13 @@ dialog_get_number_up_layout (GtkPrintUnixDialog *dialog) if (val == NULL) return layout; + if (val[0] == '\0' && priv->options) + { + GtkPrinterOption *option = gtk_printer_option_set_lookup (priv->options, "gtk-n-up-layout"); + if (option) + val = option->value; + } + enum_class = g_type_class_ref (GTK_TYPE_NUMBER_UP_LAYOUT); enum_value = g_enum_get_value_by_nick (enum_class, val); if (enum_value) @@ -2586,13 +2610,11 @@ dialog_get_number_up_layout (GtkPrintUnixDialog *dialog) static gboolean draw_page_cb (GtkWidget *widget, - GdkEventExpose *event, + cairo_t *cr, GtkPrintUnixDialog *dialog) { GtkPrintUnixDialogPrivate *priv = dialog->priv; - GtkAllocation allocation; - GtkStyle *style; - cairo_t *cr; + GtkStyleContext *context; gdouble ratio; gint w, h, tmp, shadow_offset; gint pages_x, pages_y, i, x, y, layout_w, layout_h; @@ -2602,10 +2624,11 @@ draw_page_cb (GtkWidget *widget, PangoLayout *layout; PangoFontDescription *font; gchar *text; - GdkColor *color; + GdkRGBA color; GtkNumberUpLayout number_up_layout; gint start_x, end_x, start_y, end_y; gint dx, dy; + gint width, height; gboolean horizontal; GtkPageSetup *page_setup; gdouble paper_width, paper_height; @@ -2619,12 +2642,12 @@ draw_page_cb (GtkWidget *widget, (orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE); number_up_layout = dialog_get_number_up_layout (dialog); - - cr = gdk_cairo_create (gtk_widget_get_window (widget)); + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); cairo_save (cr); - page_setup = gtk_print_unix_dialog_get_page_setup (dialog); + page_setup = gtk_print_unix_dialog_get_page_setup (dialog); if (page_setup != NULL) { @@ -2700,33 +2723,37 @@ draw_page_cb (GtkWidget *widget, pages_y = tmp; } - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW); - gtk_widget_get_allocation (widget, &allocation); - pos_x = allocation.x + (allocation.width - w) / 2; - pos_y = allocation.y + (allocation.height - h) / 2 - 10; + pos_x = (width - w) / 2; + pos_y = (height - h) / 2 - 10; cairo_translate (cr, pos_x, pos_y); shadow_offset = 3; - color = &style->text[GTK_STATE_NORMAL]; - cairo_set_source_rgba (cr, color->red / 65535., color->green / 65535., color->blue / 65535, 0.5); + gtk_style_context_get_color (context, 0, &color); + cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5); cairo_rectangle (cr, shadow_offset + 1, shadow_offset + 1, w, h); cairo_fill (cr); - gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]); + gtk_style_context_get_background_color (context, 0, &color); + gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 1, 1, w, h); cairo_fill (cr); cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, 0.5, 0.5, w + 1, h + 1); - gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]); + gtk_style_context_get_color (context, 0, &color); + gdk_cairo_set_source_rgba (cr, &color); cairo_stroke (cr); i = 1; - page_width = (double)w / pages_x; - page_height = (double)h / pages_y; + page_width = (gdouble)w / pages_x; + page_height = (gdouble)h / pages_y; layout = pango_cairo_create_layout (cr); @@ -2914,13 +2941,12 @@ draw_page_cb (GtkWidget *widget, ltr = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR; - gtk_widget_get_allocation (widget, &allocation); if (ltr) cairo_translate (cr, pos_x - layout_w / PANGO_SCALE - 2 * RULER_DISTANCE, - allocation.y + (allocation.height - layout_h / PANGO_SCALE) / 2); + (height - layout_h / PANGO_SCALE) / 2); else cairo_translate (cr, pos_x + w + shadow_offset + 2 * RULER_DISTANCE, - allocation.y + (allocation.height - layout_h / PANGO_SCALE) / 2); + (height - layout_h / PANGO_SCALE) / 2); pango_cairo_show_layout (cr, layout); @@ -2936,7 +2962,7 @@ draw_page_cb (GtkWidget *widget, g_free (text); pango_layout_get_size (layout, &layout_w, &layout_h); - cairo_translate (cr, allocation.x + (allocation.width - layout_w / PANGO_SCALE) / 2, + cairo_translate (cr, (width - layout_w / PANGO_SCALE) / 2, pos_y + h + shadow_offset + 2 * RULER_DISTANCE); pango_cairo_show_layout (cr, layout); @@ -2989,7 +3015,7 @@ draw_page_cb (GtkWidget *widget, cairo_stroke (cr); } - cairo_destroy (cr); + gtk_style_context_restore (context); return TRUE; } @@ -3151,8 +3177,8 @@ update_number_up_layout (GtkPrintUnixDialog *dialog) static void custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog, - gint response_id, - gpointer user_data) + gint response_id, + gpointer user_data) { GtkPrintUnixDialog *print_dialog = GTK_PRINT_UNIX_DIALOG (user_data); GtkPrintUnixDialogPrivate *priv = print_dialog->priv; @@ -3228,7 +3254,8 @@ paper_size_changed (GtkComboBox *combo_box, 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) { @@ -3273,7 +3300,9 @@ paper_size_row_is_separator (GtkTreeModel *model, { gboolean separator; - gtk_tree_model_get (model, iter, PAGE_SETUP_LIST_COL_IS_SEPARATOR, &separator, -1); + gtk_tree_model_get (model, iter, + PAGE_SETUP_LIST_COL_IS_SEPARATOR, &separator, + -1); return separator; } @@ -3288,7 +3317,8 @@ page_name_func (GtkCellLayout *cell_layout, 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); @@ -3296,7 +3326,7 @@ 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 void @@ -3308,101 +3338,86 @@ create_page_setup_page (GtkPrintUnixDialog *dialog) GtkWidget *combo, *spinbutton, *draw; GtkCellRenderer *cell; - main_vbox = gtk_vbox_new (FALSE, 18); + main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_widget_show (main_vbox); - hbox = gtk_hbox_new (FALSE, 18); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 18); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); - table = gtk_table_new (5, 2, 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); frame = wrap_in_frame (_("Layout"), table); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (table); label = gtk_label_new_with_mnemonic (_("T_wo-sided:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->duplex = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 0, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("Pages per _side:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1); widget = gtk_printer_option_widget_new (NULL); g_signal_connect_swapped (widget, "changed", G_CALLBACK (redraw_page_layout_preview), dialog); g_signal_connect_swapped (widget, "changed", G_CALLBACK (update_number_up_layout), dialog); priv->pages_per_sheet = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 1, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("Page or_dering:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 2, 3, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1); widget = gtk_printer_option_widget_new (NULL); g_signal_connect_swapped (widget, "changed", G_CALLBACK (redraw_page_layout_preview), dialog); priv->number_up_layout = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 2, 3, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 2, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("_Only print:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 3, 4, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1); - combo = gtk_combo_box_new_text (); + combo = gtk_combo_box_text_new (); priv->page_set_combo = combo; gtk_widget_show (combo); - gtk_table_attach (GTK_TABLE (table), combo, - 1, 2, 3, 4, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), combo, 1, 3, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); /* In enum order */ - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("All sheets")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Even sheets")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Odd sheets")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("All sheets")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Even sheets")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Odd sheets")); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); label = gtk_label_new_with_mnemonic (_("Sc_ale:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 4, 5, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 4, 1, 1); - hbox2 = gtk_hbox_new (FALSE, 6); + hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_widget_show (hbox2); - gtk_table_attach (GTK_TABLE (table), hbox2, - 1, 2, 4, 5, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), hbox2, 1, 4, 1, 1); spinbutton = gtk_spin_button_new_with_range (1.0, 1000.0, 1.0); priv->scale_spin = spinbutton; @@ -3415,117 +3430,100 @@ create_page_setup_page (GtkPrintUnixDialog *dialog) gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); - table = gtk_table_new (4, 2, 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); frame = wrap_in_frame (_("Paper"), table); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 6); gtk_widget_show (table); label = gtk_label_new_with_mnemonic (_("Paper _type:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->paper_type = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 0, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("Paper _source:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->paper_source = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 1, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("Output t_ray:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 2, 3, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->output_tray = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 2, 3, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 2, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("_Paper size:")); priv->paper_size_combo_label = GTK_WIDGET (label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 3, 4, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->page_setup_list)); priv->paper_size_combo = GTK_WIDGET (combo); - gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo), + 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); - gtk_table_attach (GTK_TABLE (table), combo, - 1, 2, 3, 4, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), combo, 1, 3, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gtk_widget_set_sensitive (combo, FALSE); gtk_widget_show (combo); - label = gtk_label_new_with_mnemonic (_("Or_ientation:")); priv->orientation_combo_label = GTK_WIDGET (label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 4, 5, - GTK_FILL, 0, 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 4, 1, 1); - combo = gtk_combo_box_new_text (); + combo = gtk_combo_box_text_new (); priv->orientation_combo = GTK_WIDGET (combo); - gtk_table_attach (GTK_TABLE (table), combo, - 1, 2, 4, 5, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), combo, 1, 4, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); /* In enum order */ - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Portrait")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Landscape")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Reverse portrait")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Reverse landscape")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Portrait")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Landscape")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Reverse portrait")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Reverse landscape")); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); gtk_widget_set_sensitive (combo, FALSE); gtk_widget_show (combo); - /* Add the page layout preview */ - hbox2 = gtk_hbox_new (FALSE, 0); + hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_show (hbox2); gtk_box_pack_start (GTK_BOX (main_vbox), hbox2, TRUE, TRUE, 0); draw = gtk_drawing_area_new (); gtk_widget_set_has_window (draw, FALSE); priv->page_layout_preview = draw; - gtk_widget_set_size_request (draw, 350, 200); - g_signal_connect (draw, "expose-event", G_CALLBACK (draw_page_cb), dialog); + gtk_widget_set_size_request (draw, 280, 160); + g_signal_connect (draw, "draw", G_CALLBACK (draw_page_cb), dialog); gtk_widget_show (draw); gtk_box_pack_start (GTK_BOX (hbox2), draw, TRUE, FALSE, 0); @@ -3547,57 +3545,47 @@ create_job_page (GtkPrintUnixDialog *dialog) const gchar *at_tooltip; const gchar *on_hold_tooltip; - main_table = gtk_table_new (2, 2, FALSE); + main_table = gtk_grid_new (); gtk_container_set_border_width (GTK_CONTAINER (main_table), 12); - gtk_table_set_row_spacings (GTK_TABLE (main_table), 18); - gtk_table_set_col_spacings (GTK_TABLE (main_table), 18); + gtk_grid_set_row_spacing (GTK_GRID (main_table), 18); + gtk_grid_set_column_spacing (GTK_GRID (main_table), 18); - table = gtk_table_new (2, 2, 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); frame = wrap_in_frame (_("Job Details"), table); - gtk_table_attach (GTK_TABLE (main_table), frame, - 0, 1, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (main_table), frame, 0, 0, 1, 1); gtk_widget_show (table); label = gtk_label_new_with_mnemonic (_("Pri_ority:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->job_prio = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 0, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); label = gtk_label_new_with_mnemonic (_("_Billing info:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->billing_info = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 1, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - table = gtk_table_new (2, 2, 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); frame = wrap_in_frame (_("Print Document"), table); - gtk_table_attach (GTK_TABLE (main_table), frame, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (main_table), frame, 0, 1, 1, 1); gtk_widget_show (table); /* Translators: this is one of the choices for the print at option @@ -3606,9 +3594,7 @@ create_job_page (GtkPrintUnixDialog *dialog) radio = gtk_radio_button_new_with_mnemonic (NULL, _("_Now")); priv->print_now_radio = radio; gtk_widget_show (radio); - gtk_table_attach (GTK_TABLE (table), radio, - 0, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 0, 2, 1); /* Translators: this is one of the choices for the print at option * in the print dialog. It also serves as the label for an entry that * allows the user to enter a time. @@ -3624,9 +3610,7 @@ create_job_page (GtkPrintUnixDialog *dialog) gtk_widget_set_tooltip_text (radio, at_tooltip); priv->print_at_radio = radio; gtk_widget_show (radio); - gtk_table_attach (GTK_TABLE (table), radio, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 1, 1, 1); entry = gtk_entry_new (); gtk_widget_set_tooltip_text (entry, at_tooltip); @@ -3634,9 +3618,7 @@ create_job_page (GtkPrintUnixDialog *dialog) atk_object_set_description (gtk_widget_get_accessible (entry), at_tooltip); priv->print_at_entry = entry; gtk_widget_show (entry); - gtk_table_attach (GTK_TABLE (table), entry, - 1, 2, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), entry, 1, 1, 1, 1); g_signal_connect (radio, "toggled", G_CALLBACK (update_entry_sensitivity), entry); update_entry_sensitivity (radio, entry); @@ -3651,9 +3633,7 @@ create_job_page (GtkPrintUnixDialog *dialog) gtk_widget_set_tooltip_text (radio, on_hold_tooltip); priv->print_hold_radio = radio; gtk_widget_show (radio); - gtk_table_attach (GTK_TABLE (table), radio, - 0, 2, 2, 3, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), radio, 0, 2, 2, 1); g_signal_connect_swapped (priv->print_now_radio, "toggled", G_CALLBACK (update_print_at_option), dialog); @@ -3664,49 +3644,41 @@ create_job_page (GtkPrintUnixDialog *dialog) g_signal_connect_swapped (priv->print_hold_radio, "toggled", G_CALLBACK (update_print_at_option), dialog); - table = gtk_table_new (2, 2, 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); frame = wrap_in_frame (_("Add Cover Page"), table); - gtk_table_attach (GTK_TABLE (main_table), frame, - 1, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (main_table), frame, 1, 0, 1, 1); gtk_widget_show (table); /* Translators, this is the label used for the option in the print * dialog that controls the front cover page. */ label = gtk_label_new_with_mnemonic (_("Be_fore:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->cover_before = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 0, 1, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 0, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); /* Translators, this is the label used for the option in the print * dialog that controls the back cover page. */ label = gtk_label_new_with_mnemonic (_("_After:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_widget_set_valign (label, GTK_ALIGN_CENTER); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1); widget = gtk_printer_option_widget_new (NULL); priv->cover_after = GTK_PRINTER_OPTION_WIDGET (widget); gtk_widget_show (widget); - gtk_table_attach (GTK_TABLE (table), widget, - 1, 2, 1, 2, GTK_FILL, 0, - 0, 0); + gtk_grid_attach (GTK_GRID (table), widget, 1, 1, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); /* Translators: this is the tab label for the notebook tab containing @@ -3734,14 +3706,13 @@ create_optional_page (GtkPrintUnixDialog *dialog, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - table = gtk_table_new (1, 2, 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), 12); gtk_widget_show (table); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled), - table); + gtk_container_add (GTK_CONTAINER (scrolled), table); gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrolled))), GTK_SHADOW_NONE); @@ -3767,12 +3738,11 @@ create_advanced_page (GtkPrintUnixDialog *dialog) GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - main_vbox = gtk_vbox_new (FALSE, 18); + main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); gtk_widget_show (main_vbox); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled), - main_vbox); + gtk_container_add (GTK_CONTAINER (scrolled), main_vbox); gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrolled))), GTK_SHADOW_NONE); @@ -3801,7 +3771,7 @@ populate_dialog (GtkPrintUnixDialog *print_dialog) gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); gtk_box_set_spacing (GTK_BOX (action_area), 6); - vbox = gtk_vbox_new (FALSE, 6); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); @@ -3830,7 +3800,7 @@ populate_dialog (GtkPrintUnixDialog *print_dialog) &priv->finishing_page); create_advanced_page (print_dialog); - priv->conflicts_widget = conflict_hbox = gtk_hbox_new (FALSE, 12); + priv->conflicts_widget = conflict_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_end (GTK_BOX (vbox), conflict_hbox, FALSE, FALSE, 0); image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU); gtk_widget_show (image); @@ -3852,21 +3822,16 @@ populate_dialog (GtkPrintUnixDialog *print_dialog) * Return value: a new #GtkPrintUnixDialog * * Since: 2.10 - **/ + */ GtkWidget * gtk_print_unix_dialog_new (const gchar *title, GtkWindow *parent) { GtkWidget *result; - const gchar *_title = _("Print"); - - if (title) - _title = title; result = g_object_new (GTK_TYPE_PRINT_UNIX_DIALOG, "transient-for", parent, - "title", _title, - "has-separator", FALSE, + "title", title ? title : _("Print"), NULL); return result; @@ -3878,7 +3843,7 @@ gtk_print_unix_dialog_new (const gchar *title, * * Gets the currently selected printer. * - * Returns: the currently selected printer + * Returns: (transfer none): the currently selected printer * * Since: 2.10 */ @@ -3927,7 +3892,7 @@ gtk_print_unix_dialog_set_page_setup (GtkPrintUnixDialog *dialog, * * Gets the page setup that is used by the #GtkPrintUnixDialog. * - * Returns: the page setup of @dialog. + * Returns: (transfer none): the page setup of @dialog. * * Since: 2.10 */ @@ -3992,7 +3957,7 @@ gtk_print_unix_dialog_set_current_page (GtkPrintUnixDialog *dialog, * gtk_print_unix_dialog_get_current_page: * @dialog: a #GtkPrintUnixDialog * - * Gets the current page of the #GtkPrintDialog. + * Gets the current page of the #GtkPrintUnixDialog. * * Returns: the current page of @dialog * @@ -4023,7 +3988,8 @@ set_active_printer (GtkPrintUnixDialog *dialog, do { gtk_tree_model_get (GTK_TREE_MODEL (priv->printer_list), &iter, - PRINTER_LIST_COL_PRINTER_OBJ, &printer, -1); + PRINTER_LIST_COL_PRINTER_OBJ, &printer, + -1); if (printer == NULL) continue; @@ -4173,7 +4139,7 @@ gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog) ranges = dialog_get_page_ranges (dialog, &n_ranges); if (ranges) { - gtk_print_settings_set_page_ranges (settings, ranges, n_ranges); + gtk_print_settings_set_page_ranges (settings, ranges, n_ranges); g_free (ranges); } @@ -4237,9 +4203,7 @@ gtk_print_unix_dialog_set_manual_capabilities (GtkPrintUnixDialog *dialog, GtkTreeSelection *selection; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview)); - - g_object_unref (priv->current_printer); - priv->current_printer = NULL; + g_clear_object (&priv->current_printer); priv->internal_printer_change = TRUE; selected_printer_changed (selection, dialog); priv->internal_printer_change = FALSE; @@ -4253,7 +4217,7 @@ gtk_print_unix_dialog_set_manual_capabilities (GtkPrintUnixDialog *dialog, * gtk_print_unix_dialog_get_manual_capabilities: * @dialog: a #GtkPrintUnixDialog * - * Gets the value of #GtkPrintUnixDialog::manual-capabilities property. + * Gets the value of #GtkPrintUnixDialog:manual-capabilities property. * * Returns: the printing capabilities * @@ -4296,15 +4260,11 @@ gtk_print_unix_dialog_set_support_selection (GtkPrintUnixDialog *dialog, if (support_selection) { gtk_widget_set_sensitive (priv->selection_radio, priv->has_selection); - gtk_table_set_row_spacing (GTK_TABLE (priv->range_table), - 2, - gtk_table_get_default_row_spacing (GTK_TABLE (priv->range_table))); gtk_widget_show (priv->selection_radio); } else { gtk_widget_set_sensitive (priv->selection_radio, FALSE); - gtk_table_set_row_spacing (GTK_TABLE (priv->range_table), 2, 0); gtk_widget_hide (priv->selection_radio); } } @@ -4317,7 +4277,7 @@ gtk_print_unix_dialog_set_support_selection (GtkPrintUnixDialog *dialog, * gtk_print_unix_dialog_get_support_selection: * @dialog: a #GtkPrintUnixDialog * - * Gets the value of #GtkPrintUnixDialog::support-selection property. + * Gets the value of #GtkPrintUnixDialog:support-selection property. * * Returns: whether the application supports print of selection * @@ -4371,7 +4331,7 @@ gtk_print_unix_dialog_set_has_selection (GtkPrintUnixDialog *dialog, * gtk_print_unix_dialog_get_has_selection: * @dialog: a #GtkPrintUnixDialog * - * Gets the value of #GtkPrintUnixDialog::has-selection property. + * Gets the value of #GtkPrintUnixDialog:has-selection property. * * Returns: whether there is a selection * @@ -4439,7 +4399,7 @@ gtk_print_unix_dialog_set_embed_page_setup (GtkPrintUnixDialog *dialog, * gtk_print_unix_dialog_get_embed_page_setup: * @dialog: a #GtkPrintUnixDialog * - * Gets the value of #GtkPrintUnixDialog::embed-page-setup property. + * Gets the value of #GtkPrintUnixDialog:embed-page-setup property. * * Returns: whether there is a selection *