Use a priv variable when accessing priv multiple times in the same

2006-05-02  Christian Persch  <chpe@cvs.gnome.org>

	* gtk/gtkpagesetupunixdialog.c:
	* gtk/gtkprintcontext.c:
	* gtk/gtkprinter.c:
	* gtk/gtkprinteroptionwidget.c:
	* gtk/gtkprintjob.c:
	* gtk/gtkprintoperation-unix.c:
	* gtk/gtkprintoperation.c:
	* gtk/gtkprintunixdialog.c: Use a priv variable when accessing priv
	  multiple times in the same function. Bug #340288.
This commit is contained in:
Christian Persch 2006-05-02 12:48:52 +00:00 committed by Christian Persch
parent 5d6f77b4ed
commit 061f252873
10 changed files with 924 additions and 719 deletions

View File

@ -1,3 +1,15 @@
2006-05-02 Christian Persch <chpe@cvs.gnome.org>
* gtk/gtkpagesetupunixdialog.c:
* gtk/gtkprintcontext.c:
* gtk/gtkprinter.c:
* gtk/gtkprinteroptionwidget.c:
* gtk/gtkprintjob.c:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.c:
* gtk/gtkprintunixdialog.c: Use a priv variable when accessing priv
multiple times in the same function. Bug #340288.
2006-05-02 Michael Natterer <mitch@imendio.com>
* gtk/gtklabel.c (gtk_label_set_line_wrap): added note about the

View File

@ -1,3 +1,15 @@
2006-05-02 Christian Persch <chpe@cvs.gnome.org>
* gtk/gtkpagesetupunixdialog.c:
* gtk/gtkprintcontext.c:
* gtk/gtkprinter.c:
* gtk/gtkprinteroptionwidget.c:
* gtk/gtkprintjob.c:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.c:
* gtk/gtkprintunixdialog.c: Use a priv variable when accessing priv
multiple times in the same function. Bug #340288.
2006-05-02 Michael Natterer <mitch@imendio.com>
* gtk/gtklabel.c (gtk_label_set_line_wrap): added note about the

View File

@ -332,29 +332,31 @@ gtk_page_setup_unix_dialog_class_init (GtkPageSetupUnixDialogClass *class)
static void
gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv;
GtkTreeIter iter;
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
dialog->priv = GTK_PAGE_SETUP_UNIX_DIALOG_GET_PRIVATE (dialog);
dialog->priv->print_backends = NULL;
priv = dialog->priv = GTK_PAGE_SETUP_UNIX_DIALOG_GET_PRIVATE (dialog);
dialog->priv->printer_list = gtk_list_store_new (PRINTER_LIST_N_COLS,
priv->print_backends = NULL;
priv->printer_list = gtk_list_store_new (PRINTER_LIST_N_COLS,
G_TYPE_STRING,
G_TYPE_OBJECT);
gtk_list_store_append (dialog->priv->printer_list, &iter);
gtk_list_store_set (dialog->priv->printer_list, &iter,
gtk_list_store_append (priv->printer_list, &iter);
gtk_list_store_set (priv->printer_list, &iter,
PRINTER_LIST_COL_NAME, _("<b>Any Printer</b>\nFor portable documents"),
PRINTER_LIST_COL_PRINTER, NULL,
-1);
dialog->priv->page_setup_list = gtk_list_store_new (PAGE_SETUP_LIST_N_COLS,
priv->page_setup_list = gtk_list_store_new (PAGE_SETUP_LIST_N_COLS,
G_TYPE_OBJECT,
G_TYPE_BOOLEAN);
dialog->priv->custom_paper_list = gtk_list_store_new (1, G_TYPE_OBJECT);
load_custom_papers (dialog->priv->custom_paper_list);
priv->custom_paper_list = gtk_list_store_new (1, G_TYPE_OBJECT);
load_custom_papers (priv->custom_paper_list);
populate_dialog (dialog);
@ -370,38 +372,36 @@ static void
gtk_page_setup_unix_dialog_finalize (GObject *object)
{
GtkPageSetupUnixDialog *dialog = GTK_PAGE_SETUP_UNIX_DIALOG (object);
g_return_if_fail (object != NULL);
if (dialog->priv->request_details_tag)
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
if (priv->request_details_tag)
{
g_source_remove (dialog->priv->request_details_tag);
dialog->priv->request_details_tag = 0;
g_source_remove (priv->request_details_tag);
priv->request_details_tag = 0;
}
if (dialog->priv->printer_list)
if (priv->printer_list)
{
g_object_unref (dialog->priv->printer_list);
dialog->priv->printer_list = NULL;
g_object_unref (priv->printer_list);
priv->printer_list = NULL;
}
if (dialog->priv->page_setup_list)
if (priv->page_setup_list)
{
g_object_unref (dialog->priv->page_setup_list);
dialog->priv->page_setup_list = NULL;
g_object_unref (priv->page_setup_list);
priv->page_setup_list = NULL;
}
if (dialog->priv->print_settings)
if (priv->print_settings)
{
g_object_unref (dialog->priv->print_settings);
dialog->priv->print_settings = NULL;
g_object_unref (priv->print_settings);
priv->print_settings = NULL;
}
g_free (dialog->priv->waiting_for_printer);
dialog->priv->waiting_for_printer = NULL;
if (G_OBJECT_CLASS (gtk_page_setup_unix_dialog_parent_class)->finalize)
G_OBJECT_CLASS (gtk_page_setup_unix_dialog_parent_class)->finalize (object);
g_free (priv->waiting_for_printer);
priv->waiting_for_printer = NULL;
G_OBJECT_CLASS (gtk_page_setup_unix_dialog_parent_class)->finalize (object);
}
static void
@ -433,6 +433,7 @@ printer_added_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter iter;
char *str;
const char *location;;
@ -447,8 +448,8 @@ printer_added_cb (GtkPrintBackend *backend,
gtk_printer_get_name (printer),
location);
gtk_list_store_append (dialog->priv->printer_list, &iter);
gtk_list_store_set (dialog->priv->printer_list, &iter,
gtk_list_store_append (priv->printer_list, &iter);
gtk_list_store_set (priv->printer_list, &iter,
PRINTER_LIST_COL_NAME, str,
PRINTER_LIST_COL_PRINTER, printer,
-1);
@ -460,13 +461,13 @@ printer_added_cb (GtkPrintBackend *backend,
g_free (str);
if (dialog->priv->waiting_for_printer != NULL &&
strcmp (dialog->priv->waiting_for_printer,
if (priv->waiting_for_printer != NULL &&
strcmp (priv->waiting_for_printer,
gtk_printer_get_name (printer)) == 0)
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->priv->printer_combo),
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
&iter);
dialog->priv->waiting_for_printer = NULL;
priv->waiting_for_printer = NULL;
}
}
@ -475,9 +476,11 @@ printer_removed_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter *iter;
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
gtk_list_store_remove (GTK_LIST_STORE (dialog->priv->printer_list), iter);
gtk_list_store_remove (GTK_LIST_STORE (priv->printer_list), iter);
}
@ -486,6 +489,7 @@ printer_status_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter *iter;
char *str;
const char *location;;
@ -498,7 +502,7 @@ printer_status_cb (GtkPrintBackend *backend,
str = g_strdup_printf ("<b>%s</b>\n%s",
gtk_printer_get_name (printer),
location);
gtk_list_store_set (dialog->priv->printer_list, iter,
gtk_list_store_set (priv->printer_list, iter,
PRINTER_LIST_COL_NAME, str,
-1);
}
@ -542,12 +546,13 @@ printer_list_initialize (GtkPageSetupUnixDialog *dialog,
static void
load_print_backends (GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GList *node;
if (g_module_supported ())
dialog->priv->print_backends = gtk_print_backend_load_modules ();
priv->print_backends = gtk_print_backend_load_modules ();
for (node = dialog->priv->print_backends; node != NULL; node = node->next)
for (node = priv->print_backends; node != NULL; node = node->next)
printer_list_initialize (dialog, GTK_PRINT_BACKEND (node->data));
}
@ -565,15 +570,16 @@ paper_size_row_is_separator (GtkTreeModel *model,
static GtkPageSetup *
get_current_page_setup (GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkPageSetup *current_page_setup;
GtkComboBox *combo_box;
GtkTreeIter iter;
current_page_setup = NULL;
combo_box = GTK_COMBO_BOX (dialog->priv->paper_size_combo);
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 (dialog->priv->page_setup_list), &iter,
gtk_tree_model_get (GTK_TREE_MODEL (priv->page_setup_list), &iter,
PAGE_SETUP_LIST_COL_PAGE_SETUP, &current_page_setup, -1);
if (current_page_setup)
@ -611,17 +617,18 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
gboolean size_only,
gboolean add_item)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeModel *model;
GtkTreeIter iter;
GtkPageSetup *list_page_setup;
model = GTK_TREE_MODEL (dialog->priv->page_setup_list);
model = GTK_TREE_MODEL (priv->page_setup_list);
if (gtk_tree_model_get_iter_first (model, &iter))
{
do
{
gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->page_setup_list), &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;
@ -629,7 +636,7 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
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 (dialog->priv->paper_size_combo),
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
&iter);
g_object_unref (list_page_setup);
return TRUE;
@ -642,15 +649,15 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
if (add_item)
{
gtk_list_store_append (dialog->priv->page_setup_list, &iter);
gtk_list_store_set (dialog->priv->page_setup_list, &iter,
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);
gtk_list_store_append (dialog->priv->page_setup_list, &iter);
gtk_list_store_set (dialog->priv->page_setup_list, &iter,
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);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->priv->paper_size_combo),
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
&iter);
return TRUE;
}
@ -661,14 +668,15 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
static void
fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter iter, paper_iter;
GtkTreeModel *model;
model = GTK_TREE_MODEL (dialog->priv->custom_paper_list);
model = GTK_TREE_MODEL (priv->custom_paper_list);
if (gtk_tree_model_get_iter_first (model, &iter))
{
gtk_list_store_append (dialog->priv->page_setup_list, &paper_iter);
gtk_list_store_set (dialog->priv->page_setup_list, &paper_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,
-1);
do
@ -676,8 +684,8 @@ fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
GtkPageSetup *page_setup;
gtk_tree_model_get (model, &iter, 0, &page_setup, -1);
gtk_list_store_append (dialog->priv->page_setup_list, &paper_iter);
gtk_list_store_set (dialog->priv->page_setup_list, &paper_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_PAGE_SETUP, page_setup,
-1);
@ -685,12 +693,12 @@ fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
} while (gtk_tree_model_iter_next (model, &iter));
}
gtk_list_store_append (dialog->priv->page_setup_list, &paper_iter);
gtk_list_store_set (dialog->priv->page_setup_list, &paper_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,
-1);
gtk_list_store_append (dialog->priv->page_setup_list, &paper_iter);
gtk_list_store_set (dialog->priv->page_setup_list, &paper_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_PAGE_SETUP, NULL,
-1);
}
@ -699,6 +707,7 @@ static void
fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
GtkPrinter *printer)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GList *list, *l;
GtkPageSetup *current_page_setup, *page_setup;
GtkPaperSize *paper_size;
@ -707,7 +716,7 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
current_page_setup = get_current_page_setup (dialog);
gtk_list_store_clear (dialog->priv->page_setup_list);
gtk_list_store_clear (priv->page_setup_list);
if (printer == NULL)
{
@ -718,8 +727,8 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
gtk_paper_size_free (paper_size);
gtk_list_store_append (dialog->priv->page_setup_list, &iter);
gtk_list_store_set (dialog->priv->page_setup_list, &iter,
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);
@ -733,8 +742,8 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
for (l = list; l != NULL; l = l->next)
{
page_setup = l->data;
gtk_list_store_append (dialog->priv->page_setup_list, &iter);
gtk_list_store_set (dialog->priv->page_setup_list, &iter,
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);
@ -756,7 +765,9 @@ printer_changed_finished_callback (GtkPrinter *printer,
gboolean success,
GtkPageSetupUnixDialog *dialog)
{
dialog->priv->request_details_tag = 0;
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
priv->request_details_tag = 0;
if (success)
fill_paper_sizes_from_printer (dialog, printer);
@ -767,21 +778,22 @@ static void
printer_changed_callback (GtkComboBox *combo_box,
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. */
if (dialog->priv->waiting_for_printer)
if (priv->waiting_for_printer)
{
g_free (dialog->priv->waiting_for_printer);
dialog->priv->waiting_for_printer = NULL;
g_free (priv->waiting_for_printer);
priv->waiting_for_printer = NULL;
}
if (dialog->priv->request_details_tag)
if (priv->request_details_tag)
{
g_source_remove (dialog->priv->request_details_tag);
dialog->priv->request_details_tag = 0;
g_source_remove (priv->request_details_tag);
priv->request_details_tag = 0;
}
if (gtk_combo_box_get_active_iter (combo_box, &iter))
@ -793,7 +805,7 @@ printer_changed_callback (GtkComboBox *combo_box,
fill_paper_sizes_from_printer (dialog, printer);
else
{
dialog->priv->request_details_tag =
priv->request_details_tag =
g_signal_connect (printer, "details-acquired",
G_CALLBACK (printer_changed_finished_callback), dialog);
_gtk_printer_request_details (printer);
@ -803,14 +815,14 @@ printer_changed_callback (GtkComboBox *combo_box,
if (printer)
g_object_unref (printer);
if (dialog->priv->print_settings)
if (priv->print_settings)
{
const char *name = NULL;
if (printer)
name = gtk_printer_get_name (printer);
gtk_print_settings_set (dialog->priv->print_settings,
gtk_print_settings_set (priv->print_settings,
"format-for-printer", name);
}
}
@ -852,8 +864,10 @@ double_to_string (double d, GtkUnit unit)
}
static void
paper_size_changed (GtkComboBox *combo_box, GtkPageSetupUnixDialog *dialog)
paper_size_changed (GtkComboBox *combo_box,
GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter iter;
GtkPageSetup *page_setup, *last_page_setup;
GtkUnit unit;
@ -862,7 +876,7 @@ paper_size_changed (GtkComboBox *combo_box, GtkPageSetupUnixDialog *dialog)
GtkLabel *label;
const char *unit_str;
label = GTK_LABEL (dialog->priv->paper_size_label);
label = GTK_LABEL (priv->paper_size_label);
if (gtk_combo_box_get_active_iter (combo_box, &iter))
{
@ -875,11 +889,11 @@ paper_size_changed (GtkComboBox *combo_box, GtkPageSetupUnixDialog *dialog)
/* Save current last_setup as it is changed by updating the list */
last_page_setup = NULL;
if (dialog->priv->last_setup)
last_page_setup = g_object_ref (dialog->priv->last_setup);
if (priv->last_setup)
last_page_setup = g_object_ref (priv->last_setup);
/* Update printer page list */
printer_changed_callback (GTK_COMBO_BOX (dialog->priv->printer_combo), dialog);
printer_changed_callback (GTK_COMBO_BOX (priv->printer_combo), dialog);
/* Change from "manage" menu item to last value */
if (last_page_setup == NULL)
@ -890,10 +904,10 @@ paper_size_changed (GtkComboBox *combo_box, GtkPageSetupUnixDialog *dialog)
return;
}
if (dialog->priv->last_setup)
g_object_unref (dialog->priv->last_setup);
if (priv->last_setup)
g_object_unref (priv->last_setup);
dialog->priv->last_setup = g_object_ref (page_setup);
priv->last_setup = g_object_ref (page_setup);
unit = get_default_user_units ();
@ -934,8 +948,8 @@ paper_size_changed (GtkComboBox *combo_box, GtkPageSetupUnixDialog *dialog)
g_free (left);
g_free (right);
gtk_tooltips_set_tip (GTK_TOOLTIPS (dialog->priv->tooltips),
dialog->priv->paper_size_eventbox, str, NULL);
gtk_tooltips_set_tip (GTK_TOOLTIPS (priv->tooltips),
priv->paper_size_eventbox, str, NULL);
g_free (str);
g_object_unref (page_setup);
@ -943,11 +957,11 @@ paper_size_changed (GtkComboBox *combo_box, GtkPageSetupUnixDialog *dialog)
else
{
gtk_label_set_text (label, "");
gtk_tooltips_set_tip (GTK_TOOLTIPS (dialog->priv->tooltips),
dialog->priv->paper_size_eventbox, NULL, NULL);
if (dialog->priv->last_setup)
g_object_unref (dialog->priv->last_setup);
dialog->priv->last_setup = NULL;
gtk_tooltips_set_tip (GTK_TOOLTIPS (priv->tooltips),
priv->paper_size_eventbox, NULL, NULL);
if (priv->last_setup)
g_object_unref (priv->last_setup);
priv->last_setup = NULL;
}
}
@ -974,17 +988,12 @@ page_name_func (GtkCellLayout *cell_layout,
}
static void
populate_dialog (GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv;
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkWidget *table, *label, *combo, *radio_button, *ebox, *image;
GtkCellRenderer *cell;
g_return_if_fail (GTK_IS_PAGE_SETUP_UNIX_DIALOG (dialog));
priv = dialog->priv;
table = gtk_table_new (4, 4, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 12);
@ -999,8 +1008,8 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
GTK_FILL, 0, 0, 0);
gtk_widget_show (label);
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (dialog->priv->printer_list));
dialog->priv->printer_combo = combo;
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->printer_list));
priv->printer_combo = combo;
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
@ -1019,8 +1028,8 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
GTK_FILL, 0, 0, 0);
gtk_widget_show (label);
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (dialog->priv->page_setup_list));
dialog->priv->paper_size_combo = combo;
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);
@ -1037,7 +1046,7 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 0);
ebox = gtk_event_box_new ();
dialog->priv->paper_size_eventbox = ebox;
priv->paper_size_eventbox = ebox;
gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
gtk_table_attach (GTK_TABLE (table), ebox,
1, 4, 2, 3,
@ -1045,7 +1054,7 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
gtk_widget_show (ebox);
label = gtk_label_new_with_mnemonic ("");
dialog->priv->paper_size_label = label;
priv->paper_size_label = label;
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (label), 12, 4);
gtk_container_add (GTK_CONTAINER (ebox), label);
@ -1062,7 +1071,7 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (radio_button), image);
dialog->priv->portrait_radio = radio_button;
priv->portrait_radio = radio_button;
gtk_table_attach (GTK_TABLE (table), radio_button,
1, 2, 3, 4,
0, 0, 0, 0);
@ -1073,7 +1082,7 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (radio_button), image);
dialog->priv->landscape_radio = radio_button;
priv->landscape_radio = radio_button;
gtk_table_attach (GTK_TABLE (table), radio_button,
2, 3, 3, 4,
0, 0, 0, 0);
@ -1086,17 +1095,17 @@ populate_dialog (GtkPageSetupUnixDialog *dialog)
GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (radio_button), image);
dialog->priv->reverse_landscape_radio = radio_button;
priv->reverse_landscape_radio = radio_button;
gtk_table_attach (GTK_TABLE (table), radio_button,
3, 4, 3, 4,
0, 0, 0, 0);
gtk_widget_show (radio_button);
dialog->priv->tooltips = gtk_tooltips_new ();
priv->tooltips = gtk_tooltips_new ();
g_signal_connect (dialog->priv->paper_size_combo, "changed", G_CALLBACK (paper_size_changed), dialog);
g_signal_connect (dialog->priv->printer_combo, "changed", G_CALLBACK (printer_changed_callback), dialog);
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->printer_combo), 0);
g_signal_connect (priv->paper_size_combo, "changed", G_CALLBACK (paper_size_changed), dialog);
g_signal_connect (priv->printer_combo, "changed", G_CALLBACK (printer_changed_callback), dialog);
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->printer_combo), 0);
load_print_backends (dialog);
}
@ -1123,11 +1132,13 @@ gtk_page_setup_unix_dialog_new (const gchar *title,
static GtkPageOrientation
get_orientation (GtkPageSetupUnixDialog *dialog)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->portrait_radio)))
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->portrait_radio)))
return GTK_PAGE_ORIENTATION_PORTRAIT;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->landscape_radio)))
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->landscape_radio)))
return GTK_PAGE_ORIENTATION_LANDSCAPE;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->reverse_landscape_radio)))
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reverse_landscape_radio)))
return GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE;
return GTK_PAGE_ORIENTATION_PORTRAIT;
}
@ -1135,17 +1146,19 @@ get_orientation (GtkPageSetupUnixDialog *dialog)
static void
set_orientation (GtkPageSetupUnixDialog *dialog, GtkPageOrientation orientation)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
switch (orientation)
{
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
case GTK_PAGE_ORIENTATION_PORTRAIT:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->portrait_radio), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->portrait_radio), TRUE);
break;
case GTK_PAGE_ORIENTATION_LANDSCAPE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->landscape_radio), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->landscape_radio), TRUE);
break;
case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->reverse_landscape_radio), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reverse_landscape_radio), TRUE);
break;
}
}
@ -1178,24 +1191,25 @@ static gboolean
set_active_printer (GtkPageSetupUnixDialog *dialog,
const char *printer_name)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkTreeModel *model;
GtkTreeIter iter;
GtkPrinter *printer;
model = GTK_TREE_MODEL (dialog->priv->printer_list);
model = GTK_TREE_MODEL (priv->printer_list);
if (gtk_tree_model_get_iter_first (model, &iter))
{
do
{
gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->printer_list), &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 (dialog->priv->printer_combo),
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
&iter);
g_object_unref (printer);
return TRUE;
@ -1213,12 +1227,13 @@ void
gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
GtkPrintSettings *print_settings)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
const char *format_for_printer;
if (dialog->priv->print_settings)
g_object_unref (dialog->priv->print_settings);
if (priv->print_settings)
g_object_unref (priv->print_settings);
dialog->priv->print_settings = print_settings;
priv->print_settings = print_settings;
if (print_settings)
{
@ -1230,14 +1245,16 @@ gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
is added */
if (format_for_printer &&
!set_active_printer (dialog, format_for_printer))
dialog->priv->waiting_for_printer = g_strdup (format_for_printer);
priv->waiting_for_printer = g_strdup (format_for_printer);
}
}
GtkPrintSettings *
gtk_page_setup_unix_dialog_get_print_settings (GtkPageSetupUnixDialog *dialog)
{
return dialog->priv->print_settings;
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
return priv->print_settings;
}
static GtkWidget *
@ -1734,6 +1751,7 @@ set_dialog_hig_spacing (GtkWidget *widget,
static void
run_custom_paper_dialog (GtkPageSetupUnixDialog *dialog)
{
GtkPageSetupUnixDialogPrivate *priv = dialog->priv;
GtkWidget *custom_dialog, *image, *table, *label, *widget, *frame, *combo;
GtkWidget *hbox, *vbox, *treeview, *scrolled, *button_box, *button;
GtkCellRenderer *cell;
@ -1773,7 +1791,7 @@ run_custom_paper_dialog (GtkPageSetupUnixDialog *dialog)
gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
gtk_widget_show (scrolled);
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->priv->custom_paper_list));
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->custom_paper_list));
data->treeview = treeview;
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
gtk_widget_set_size_request (treeview, 140, -1);
@ -1918,14 +1936,14 @@ run_custom_paper_dialog (GtkPageSetupUnixDialog *dialog)
gtk_widget_show (hbox);
gtk_table_set_row_spacing (GTK_TABLE (table), 3, 8);
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (dialog->priv->printer_list));
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->printer_list));
data->printer_combo = combo;
printer_tag1 =
g_signal_connect_swapped (dialog->priv->printer_list, "row_inserted",
g_signal_connect_swapped (priv->printer_list, "row_inserted",
G_CALLBACK (update_combo_sensitivity_from_printers), data);
printer_tag2 =
g_signal_connect_swapped (dialog->priv->printer_list, "row_deleted",
g_signal_connect_swapped (priv->printer_list, "row_deleted",
G_CALLBACK (update_combo_sensitivity_from_printers), data);
update_combo_sensitivity_from_printers (data);
@ -1950,7 +1968,7 @@ run_custom_paper_dialog (GtkPageSetupUnixDialog *dialog)
update_custom_widgets_from_list (data);
/* If no custom sizes, add one */
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->priv->custom_paper_list),
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->custom_paper_list),
&iter))
{
/* Need to realize treeview so we can start the rename */
@ -1961,10 +1979,10 @@ run_custom_paper_dialog (GtkPageSetupUnixDialog *dialog)
gtk_dialog_run (GTK_DIALOG (custom_dialog));
gtk_widget_destroy (custom_dialog);
save_custom_papers (dialog->priv->custom_paper_list);
save_custom_papers (priv->custom_paper_list);
g_signal_handler_disconnect (dialog->priv->printer_list, printer_tag1);
g_signal_handler_disconnect (dialog->priv->printer_list, printer_tag2);
g_signal_handler_disconnect (priv->printer_list, printer_tag1);
g_signal_handler_disconnect (priv->printer_list, printer_tag2);
}

View File

@ -83,14 +83,15 @@ gtk_print_context_class_init (GtkPrintContextClass *class)
GtkPrintContext *
_gtk_print_context_new (GtkPrintOperation *op)
{
GtkPrintOperationPrivate *priv = op->priv;
GtkPrintContext *context;
context = g_object_new (GTK_TYPE_PRINT_CONTEXT, NULL);
context->op = op;
context->cr = cairo_create (op->priv->surface);
context->cr = cairo_create (priv->surface);
switch (op->priv->unit)
switch (priv->unit)
{
default:
case GTK_UNIT_PIXEL:
@ -99,16 +100,16 @@ _gtk_print_context_new (GtkPrintOperation *op)
context->pixels_per_unit_y = 1.0;
break;
case GTK_UNIT_POINTS:
context->pixels_per_unit_x = op->priv->dpi_x / POINTS_PER_INCH;
context->pixels_per_unit_y = op->priv->dpi_y / POINTS_PER_INCH;
context->pixels_per_unit_x = priv->dpi_x / POINTS_PER_INCH;
context->pixels_per_unit_y = priv->dpi_y / POINTS_PER_INCH;
break;
case GTK_UNIT_INCH:
context->pixels_per_unit_x = op->priv->dpi_x;
context->pixels_per_unit_y = op->priv->dpi_y;
context->pixels_per_unit_x = priv->dpi_x;
context->pixels_per_unit_y = priv->dpi_y;
break;
case GTK_UNIT_MM:
context->pixels_per_unit_x = op->priv->dpi_x / MM_PER_INCH;
context->pixels_per_unit_y = op->priv->dpi_y / MM_PER_INCH;
context->pixels_per_unit_x = priv->dpi_x / MM_PER_INCH;
context->pixels_per_unit_y = priv->dpi_y / MM_PER_INCH;
break;
}
cairo_scale (context->cr,
@ -118,7 +119,7 @@ _gtk_print_context_new (GtkPrintOperation *op)
context->fontmap = pango_cairo_font_map_new ();
/* We use the unit-scaled resolution, as we still want fonts given in points to work */
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (context->fontmap),
op->priv->dpi_y / context->pixels_per_unit_y);
priv->dpi_y / context->pixels_per_unit_y);
return context;
}
@ -126,6 +127,7 @@ _gtk_print_context_new (GtkPrintOperation *op)
void
_gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
{
GtkPrintOperationPrivate *priv = context->op->priv;
cairo_t *cr = context->cr;
cairo_matrix_t matrix;
GtkPaperSize *paper_size;
@ -134,9 +136,9 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
paper_size = gtk_page_setup_get_paper_size (context->page_setup);
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH);
width = width * context->op->priv->dpi_x / context->pixels_per_unit_x;
width = width * priv->dpi_x / context->pixels_per_unit_x;
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH);
height = height * context->op->priv->dpi_y / context->pixels_per_unit_y;
height = height * priv->dpi_y / context->pixels_per_unit_y;
switch (gtk_page_setup_get_orientation (context->page_setup))
{
@ -173,18 +175,21 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
void
_gtk_print_context_translate_into_margin (GtkPrintContext *context)
{
GtkPrintOperationPrivate *priv;
gdouble left, top;
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
priv = context->op->priv;
/* We do it this way to also handle GTK_UNIT_PIXELS */
left = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
cairo_translate (context->cr,
left * context->op->priv->dpi_x / context->pixels_per_unit_x,
top * context->op->priv->dpi_y / context->pixels_per_unit_y);
left * priv->dpi_x / context->pixels_per_unit_x,
top * priv->dpi_y / context->pixels_per_unit_y);
}
void
@ -254,17 +259,20 @@ gtk_print_context_get_page_setup (GtkPrintContext *context)
gdouble
gtk_print_context_get_width (GtkPrintContext *context)
{
GtkPrintOperationPrivate *priv;
gdouble width;
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
if (context->op->priv->use_full_page)
priv = context->op->priv;
if (priv->use_full_page)
width = gtk_page_setup_get_paper_width (context->page_setup, GTK_UNIT_INCH);
else
width = gtk_page_setup_get_page_width (context->page_setup, GTK_UNIT_INCH);
/* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
return width * context->op->priv->dpi_x / context->pixels_per_unit_x;
return width * priv->dpi_x / context->pixels_per_unit_x;
}
/**
@ -280,17 +288,20 @@ gtk_print_context_get_width (GtkPrintContext *context)
gdouble
gtk_print_context_get_height (GtkPrintContext *context)
{
GtkPrintOperationPrivate *priv;
gdouble height;
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
if (context->op->priv->use_full_page)
priv = context->op->priv;
if (priv->use_full_page)
height = gtk_page_setup_get_paper_height (context->page_setup, GTK_UNIT_INCH);
else
height = gtk_page_setup_get_page_height (context->page_setup, GTK_UNIT_INCH);
/* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
return height * context->op->priv->dpi_y / context->pixels_per_unit_y;
return height * priv->dpi_y / context->pixels_per_unit_y;
}
/**

View File

@ -186,36 +186,36 @@ gtk_printer_class_init (GtkPrinterClass *class)
static void
gtk_printer_init (GtkPrinter *printer)
{
printer->priv = GTK_PRINTER_GET_PRIVATE (printer);
GtkPrinterPrivate *priv;
printer->priv->name = NULL;
printer->priv->location = NULL;
printer->priv->description = NULL;
printer->priv->icon_name = NULL;
priv = printer->priv = GTK_PRINTER_GET_PRIVATE (printer);
printer->priv->is_active = TRUE;
printer->priv->is_new = TRUE;
printer->priv->has_details = FALSE;
priv->name = NULL;
priv->location = NULL;
priv->description = NULL;
priv->icon_name = NULL;
printer->priv->state_message = NULL;
printer->priv->job_count = 0;
priv->is_active = TRUE;
priv->is_new = TRUE;
priv->has_details = FALSE;
priv->state_message = NULL;
priv->job_count = 0;
}
static void
gtk_printer_finalize (GObject *object)
{
g_return_if_fail (object != NULL);
GtkPrinter *printer = GTK_PRINTER (object);
GtkPrinterPrivate *priv = printer->priv;
g_free (printer->priv->name);
g_free (printer->priv->location);
g_free (printer->priv->description);
g_free (printer->priv->state_message);
g_free (printer->priv->icon_name);
g_free (priv->name);
g_free (priv->location);
g_free (priv->description);
g_free (priv->state_message);
g_free (priv->icon_name);
if (G_OBJECT_CLASS (gtk_printer_parent_class)->finalize)
G_OBJECT_CLASS (gtk_printer_parent_class)->finalize (object);
G_OBJECT_CLASS (gtk_printer_parent_class)->finalize (object);
}
static void
@ -225,19 +225,20 @@ gtk_printer_set_property (GObject *object,
GParamSpec *pspec)
{
GtkPrinter *printer = GTK_PRINTER (object);
GtkPrinterPrivate *priv = printer->priv;
switch (prop_id)
{
case PROP_NAME:
printer->priv->name = g_value_dup_string (value);
priv->name = g_value_dup_string (value);
break;
case PROP_BACKEND:
printer->priv->backend = GTK_PRINT_BACKEND (g_value_get_object (value));
priv->backend = GTK_PRINT_BACKEND (g_value_get_object (value));
break;
case PROP_IS_VIRTUAL:
printer->priv->is_virtual = g_value_get_boolean (value);
priv->is_virtual = g_value_get_boolean (value);
break;
default:
@ -253,38 +254,39 @@ gtk_printer_get_property (GObject *object,
GParamSpec *pspec)
{
GtkPrinter *printer = GTK_PRINTER (object);
GtkPrinterPrivate *priv = printer->priv;
switch (prop_id)
{
case PROP_NAME:
if (printer->priv->name)
g_value_set_string (value, printer->priv->name);
if (priv->name)
g_value_set_string (value, priv->name);
else
g_value_set_string (value, "");
break;
case PROP_BACKEND:
g_value_set_object (value, printer->priv->backend);
g_value_set_object (value, priv->backend);
break;
case PROP_STATE_MESSAGE:
if (printer->priv->state_message)
g_value_set_string (value, printer->priv->state_message);
if (priv->state_message)
g_value_set_string (value, priv->state_message);
else
g_value_set_string (value, "");
break;
case PROP_LOCATION:
if (printer->priv->location)
g_value_set_string (value, printer->priv->location);
if (priv->location)
g_value_set_string (value, priv->location);
else
g_value_set_string (value, "");
break;
case PROP_ICON_NAME:
if (printer->priv->icon_name)
g_value_set_string (value, printer->priv->icon_name);
if (priv->icon_name)
g_value_set_string (value, priv->icon_name);
else
g_value_set_string (value, "");
break;
case PROP_JOB_COUNT:
g_value_set_int (value, printer->priv->job_count);
g_value_set_int (value, priv->job_count);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -388,13 +390,17 @@ gboolean
gtk_printer_set_description (GtkPrinter *printer,
const gchar *description)
{
GtkPrinterPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
if (safe_strcmp (printer->priv->description, description) == 0)
priv = printer->priv;
if (safe_strcmp (priv->description, description) == 0)
return FALSE;
g_free (printer->priv->description);
printer->priv->description = g_strdup (description);
g_free (priv->description);
priv->description = g_strdup (description);
return TRUE;
}
@ -422,13 +428,17 @@ gboolean
gtk_printer_set_state_message (GtkPrinter *printer,
const gchar *message)
{
GtkPrinterPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
if (safe_strcmp (printer->priv->state_message, message) == 0)
priv = printer->priv;
if (safe_strcmp (priv->state_message, message) == 0)
return FALSE;
g_free (printer->priv->state_message);
printer->priv->state_message = g_strdup (message);
g_free (priv->state_message);
priv->state_message = g_strdup (message);
g_object_notify (G_OBJECT (printer), "state-message");
return TRUE;
@ -456,13 +466,17 @@ gboolean
gtk_printer_set_location (GtkPrinter *printer,
const gchar *location)
{
GtkPrinterPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
if (safe_strcmp (printer->priv->location, location) == 0)
priv = printer->priv;
if (safe_strcmp (priv->location, location) == 0)
return FALSE;
g_free (printer->priv->location);
printer->priv->location = g_strdup (location);
g_free (priv->location);
priv->location = g_strdup (location);
g_object_notify (G_OBJECT (printer), "location");
return TRUE;
@ -490,10 +504,14 @@ void
gtk_printer_set_icon_name (GtkPrinter *printer,
const gchar *icon)
{
GtkPrinterPrivate *priv;
g_return_if_fail (GTK_IS_PRINTER (printer));
g_free (printer->priv->icon_name);
printer->priv->icon_name = g_strdup (icon);
priv = printer->priv;
g_free (priv->icon_name);
priv->icon_name = g_strdup (icon);
g_object_notify (G_OBJECT (printer), "icon-name");
}
@ -519,12 +537,16 @@ gboolean
gtk_printer_set_job_count (GtkPrinter *printer,
gint count)
{
GtkPrinterPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
if (printer->priv->job_count == count)
priv = printer->priv;
if (priv->job_count == count)
return FALSE;
printer->priv->job_count = count;
priv->job_count = count;
g_object_notify (G_OBJECT (printer), "job-count");

View File

@ -134,18 +134,16 @@ gtk_printer_option_widget_init (GtkPrinterOptionWidget *widget)
static void
gtk_printer_option_widget_finalize (GObject *object)
{
GtkPrinterOptionWidget *widget;
GtkPrinterOptionWidget *widget = GTK_PRINTER_OPTION_WIDGET (object);
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
widget = GTK_PRINTER_OPTION_WIDGET (object);
if (widget->priv->source)
if (priv->source)
{
g_object_unref (widget->priv->source);
widget->priv->source = NULL;
g_object_unref (priv->source);
priv->source = NULL;
}
if (G_OBJECT_CLASS (gtk_printer_option_widget_parent_class)->finalize)
G_OBJECT_CLASS (gtk_printer_option_widget_parent_class)->finalize (object);
G_OBJECT_CLASS (gtk_printer_option_widget_parent_class)->finalize (object);
}
static void
@ -175,14 +173,13 @@ gtk_printer_option_widget_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GtkPrinterOptionWidget *widget;
widget = GTK_PRINTER_OPTION_WIDGET (object);
GtkPrinterOptionWidget *widget = GTK_PRINTER_OPTION_WIDGET (object);
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
switch (prop_id)
{
case PROP_SOURCE:
g_value_set_object (value, widget->priv->source);
g_value_set_object (value, priv->source);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -231,20 +228,22 @@ void
gtk_printer_option_widget_set_source (GtkPrinterOptionWidget *widget,
GtkPrinterOption *source)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
if (source)
g_object_ref (source);
if (widget->priv->source)
if (priv->source)
{
g_signal_handler_disconnect (widget->priv->source,
widget->priv->source_changed_handler);
g_object_unref (widget->priv->source);
g_signal_handler_disconnect (priv->source,
priv->source_changed_handler);
g_object_unref (priv->source);
}
widget->priv->source = source;
priv->source = source;
if (source)
widget->priv->source_changed_handler =
priv->source_changed_handler =
g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), widget);
construct_widgets (widget);
@ -351,42 +350,44 @@ combo_box_get (GtkWidget *combo)
static void
deconstruct_widgets (GtkPrinterOptionWidget *widget)
{
if (widget->priv->check)
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
if (priv->check)
{
gtk_widget_destroy (widget->priv->check);
widget->priv->check = NULL;
gtk_widget_destroy (priv->check);
priv->check = NULL;
}
if (widget->priv->combo)
if (priv->combo)
{
gtk_widget_destroy (widget->priv->combo);
widget->priv->combo = NULL;
gtk_widget_destroy (priv->combo);
priv->combo = NULL;
}
if (widget->priv->entry)
if (priv->entry)
{
gtk_widget_destroy (widget->priv->entry);
widget->priv->entry = NULL;
gtk_widget_destroy (priv->entry);
priv->entry = NULL;
}
/* make sure entry and combo are destroyed first */
/* as we use the two of them to create the filechooser */
if (widget->priv->filechooser)
if (priv->filechooser)
{
gtk_widget_destroy (widget->priv->filechooser);
widget->priv->filechooser = NULL;
gtk_widget_destroy (priv->filechooser);
priv->filechooser = NULL;
}
if (widget->priv->image)
if (priv->image)
{
gtk_widget_destroy (widget->priv->image);
widget->priv->image = NULL;
gtk_widget_destroy (priv->image);
priv->image = NULL;
}
if (widget->priv->label)
if (priv->label)
{
gtk_widget_destroy (widget->priv->label);
widget->priv->label = NULL;
gtk_widget_destroy (priv->label);
priv->label = NULL;
}
}
@ -394,10 +395,12 @@ static void
check_toggled_cb (GtkToggleButton *toggle_button,
GtkPrinterOptionWidget *widget)
{
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
gtk_printer_option_set_boolean (widget->priv->source,
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
g_signal_handler_block (priv->source, priv->source_changed_handler);
gtk_printer_option_set_boolean (priv->source,
gtk_toggle_button_get_active (toggle_button));
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
emit_changed (widget);
}
@ -405,26 +408,27 @@ static void
filesave_changed_cb (GtkWidget *w,
GtkPrinterOptionWidget *widget)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
char *value;
char *directory;
const char *file;
/* combine the value of the chooser with the value of the entry */
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
g_signal_handler_block (priv->source, priv->source_changed_handler);
/* TODO: how do we support nonlocal file systems? */
directory = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget->priv->combo));
file = gtk_entry_get_text (GTK_ENTRY (widget->priv->entry));
directory = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (priv->combo));
file = gtk_entry_get_text (GTK_ENTRY (priv->entry));
value = g_build_filename (directory, file, NULL);
if (value)
gtk_printer_option_set (widget->priv->source, value);
gtk_printer_option_set (priv->source, value);
g_free (directory);
g_free (value);
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
emit_changed (widget);
}
@ -432,14 +436,15 @@ static void
combo_changed_cb (GtkWidget *combo,
GtkPrinterOptionWidget *widget)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
char *value;
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
g_signal_handler_block (priv->source, priv->source_changed_handler);
value = combo_box_get (combo);
if (value)
gtk_printer_option_set (widget->priv->source, value);
gtk_printer_option_set (priv->source, value);
g_free (value);
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
emit_changed (widget);
}
@ -447,13 +452,14 @@ static void
entry_changed_cb (GtkWidget *entry,
GtkPrinterOptionWidget *widget)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
const char *value;
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
g_signal_handler_block (priv->source, priv->source_changed_handler);
value = gtk_entry_get_text (GTK_ENTRY (entry));
if (value)
gtk_printer_option_set (widget->priv->source, value);
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
gtk_printer_option_set (priv->source, value);
g_signal_handler_unblock (priv->source, priv->source_changed_handler);
emit_changed (widget);
}
@ -461,56 +467,57 @@ entry_changed_cb (GtkWidget *entry,
static void
construct_widgets (GtkPrinterOptionWidget *widget)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
GtkPrinterOption *source;
char *text;
int i;
source = widget->priv->source;
source = priv->source;
deconstruct_widgets (widget);
if (source == NULL)
{
widget->priv->combo = combo_box_new ();
combo_box_append (widget->priv->combo,_("Not available"), "None");
gtk_combo_box_set_active (GTK_COMBO_BOX (widget->priv->combo), 0);
gtk_widget_set_sensitive (widget->priv->combo, FALSE);
gtk_widget_show (widget->priv->combo);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->combo, TRUE, TRUE, 0);
priv->combo = combo_box_new ();
combo_box_append (priv->combo,_("Not available"), "None");
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combo), 0);
gtk_widget_set_sensitive (priv->combo, FALSE);
gtk_widget_show (priv->combo);
gtk_box_pack_start (GTK_BOX (widget), priv->combo, TRUE, TRUE, 0);
}
else switch (source->type)
{
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
widget->priv->check = gtk_check_button_new_with_mnemonic (source->display_text);
g_signal_connect (widget->priv->check, "toggled", G_CALLBACK (check_toggled_cb), widget);
gtk_widget_show (widget->priv->check);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->check, TRUE, TRUE, 0);
priv->check = gtk_check_button_new_with_mnemonic (source->display_text);
g_signal_connect (priv->check, "toggled", G_CALLBACK (check_toggled_cb), widget);
gtk_widget_show (priv->check);
gtk_box_pack_start (GTK_BOX (widget), priv->check, TRUE, TRUE, 0);
break;
case GTK_PRINTER_OPTION_TYPE_PICKONE:
widget->priv->combo = combo_box_new ();
priv->combo = combo_box_new ();
for (i = 0; i < source->num_choices; i++)
combo_box_append (widget->priv->combo,
combo_box_append (priv->combo,
source->choices_display[i],
source->choices[i]);
gtk_widget_show (widget->priv->combo);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->combo, TRUE, TRUE, 0);
g_signal_connect (widget->priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
gtk_widget_show (priv->combo);
gtk_box_pack_start (GTK_BOX (widget), priv->combo, TRUE, TRUE, 0);
g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
text = g_strdup_printf ("%s:", source->display_text);
widget->priv->label = gtk_label_new_with_mnemonic (text);
priv->label = gtk_label_new_with_mnemonic (text);
g_free (text);
gtk_widget_show (widget->priv->label);
gtk_widget_show (priv->label);
break;
case GTK_PRINTER_OPTION_TYPE_STRING:
widget->priv->entry = gtk_entry_new ();
gtk_widget_show (widget->priv->entry);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->entry, TRUE, TRUE, 0);
g_signal_connect (widget->priv->entry, "changed", G_CALLBACK (entry_changed_cb), widget);
priv->entry = gtk_entry_new ();
gtk_widget_show (priv->entry);
gtk_box_pack_start (GTK_BOX (widget), priv->entry, TRUE, TRUE, 0);
g_signal_connect (priv->entry, "changed", G_CALLBACK (entry_changed_cb), widget);
text = g_strdup_printf ("%s:", source->display_text);
widget->priv->label = gtk_label_new_with_mnemonic (text);
priv->label = gtk_label_new_with_mnemonic (text);
g_free (text);
gtk_widget_show (widget->priv->label);
gtk_widget_show (priv->label);
break;
@ -518,65 +525,66 @@ construct_widgets (GtkPrinterOptionWidget *widget)
{
GtkWidget *label;
widget->priv->filechooser = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (widget->priv->filechooser), 6);
gtk_table_set_col_spacings (GTK_TABLE (widget->priv->filechooser), 12);
priv->filechooser = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (priv->filechooser), 6);
gtk_table_set_col_spacings (GTK_TABLE (priv->filechooser), 12);
/* TODO: make this a gtkfilechooserentry once we move to GTK */
widget->priv->entry = gtk_entry_new ();
widget->priv->combo = gtk_file_chooser_button_new (_("Print to PDF"),
priv->entry = gtk_entry_new ();
priv->combo = gtk_file_chooser_button_new (_("Print to PDF"),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
label = gtk_label_new_with_mnemonic (_("_Name:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget->priv->entry);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->entry);
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), label,
gtk_table_attach (GTK_TABLE (priv->filechooser), label,
0, 1, 0, 1, GTK_FILL, 0,
0, 0);
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), widget->priv->entry,
gtk_table_attach (GTK_TABLE (priv->filechooser), priv->entry,
1, 2, 0, 1, GTK_FILL, 0,
0, 0);
label = gtk_label_new_with_mnemonic (_("_Save in folder:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget->priv->combo);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->combo);
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), label,
gtk_table_attach (GTK_TABLE (priv->filechooser), label,
0, 1, 1, 2, GTK_FILL, 0,
0, 0);
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), widget->priv->combo,
gtk_table_attach (GTK_TABLE (priv->filechooser), priv->combo,
1, 2, 1, 2, GTK_FILL, 0,
0, 0);
gtk_widget_show_all (widget->priv->filechooser);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->filechooser, TRUE, TRUE, 0);
gtk_widget_show_all (priv->filechooser);
gtk_box_pack_start (GTK_BOX (widget), priv->filechooser, TRUE, TRUE, 0);
g_signal_connect (widget->priv->entry, "changed", G_CALLBACK (filesave_changed_cb), widget);
g_signal_connect (priv->entry, "changed", G_CALLBACK (filesave_changed_cb), widget);
g_signal_connect (widget->priv->combo, "current-folder-changed", G_CALLBACK (filesave_changed_cb), widget);
g_signal_connect (priv->combo, "current-folder-changed", G_CALLBACK (filesave_changed_cb), widget);
}
break;
default:
break;
}
widget->priv->image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (widget), widget->priv->image, FALSE, FALSE, 0);
priv->image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (widget), priv->image, FALSE, FALSE, 0);
}
static void
update_widgets (GtkPrinterOptionWidget *widget)
{
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
GtkPrinterOption *source;
source = widget->priv->source;
source = priv->source;
if (source == NULL)
{
gtk_widget_hide (widget->priv->image);
gtk_widget_hide (priv->image);
return;
}
@ -584,23 +592,23 @@ update_widgets (GtkPrinterOptionWidget *widget)
{
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
if (strcmp (source->value, "True") == 0)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->priv->check), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check), TRUE);
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->priv->check), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check), FALSE);
break;
case GTK_PRINTER_OPTION_TYPE_PICKONE:
combo_box_set (widget->priv->combo, source->value);
combo_box_set (priv->combo, source->value);
break;
case GTK_PRINTER_OPTION_TYPE_STRING:
gtk_entry_set_text (GTK_ENTRY (widget->priv->entry), source->value);
gtk_entry_set_text (GTK_ENTRY (priv->entry), source->value);
break;
case GTK_PRINTER_OPTION_TYPE_FILESAVE:
{
char *basename = g_path_get_basename (source->value);
char *dirname = g_path_get_dirname (source->value);
gtk_entry_set_text (GTK_ENTRY (widget->priv->entry), basename);
gtk_entry_set_text (GTK_ENTRY (priv->entry), basename);
if (g_path_is_absolute (dirname))
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget->priv->combo),
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (priv->combo),
dirname);
g_free (basename);
g_free (dirname);
@ -611,9 +619,9 @@ update_widgets (GtkPrinterOptionWidget *widget)
}
if (source->has_conflict)
gtk_widget_show (widget->priv->image);
gtk_widget_show (priv->image);
else
gtk_widget_hide (widget->priv->image);
gtk_widget_hide (priv->image);
}
gboolean
@ -631,8 +639,10 @@ gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *widget)
const char *
gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *widget)
{
if (widget->priv->source)
return widget->priv->source->value;
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
if (priv->source)
return priv->source->value;
return "";
}

View File

@ -165,18 +165,21 @@ gtk_print_job_class_init (GtkPrintJobClass *class)
static void
gtk_print_job_init (GtkPrintJob *job)
{
job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
job->priv->spool_file_fd = -1;
GtkPrintJobPrivate *priv;
job->priv->title = g_strdup ("");
job->priv->surface = NULL;
job->priv->backend = NULL;
job->priv->printer = NULL;
priv = job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
job->priv->printer_set = FALSE;
job->priv->settings_set = FALSE;
job->priv->page_setup_set = FALSE;
job->priv->status = GTK_PRINT_STATUS_INITIAL;
priv->spool_file_fd = -1;
priv->title = g_strdup ("");
priv->surface = NULL;
priv->backend = NULL;
priv->printer = NULL;
priv->printer_set = FALSE;
priv->settings_set = FALSE;
priv->page_setup_set = FALSE;
priv->status = GTK_PRINT_STATUS_INITIAL;
job->print_pages = GTK_PRINT_PAGES_ALL;
job->page_ranges = NULL;
@ -196,6 +199,7 @@ gtk_print_job_constructor (GType type,
GObjectConstructParam *construct_params)
{
GtkPrintJob *job;
GtkPrintJobPrivate *priv;
GObject *object;
object =
@ -204,15 +208,16 @@ gtk_print_job_constructor (GType type,
construct_params);
job = GTK_PRINT_JOB (object);
priv = job->priv;
g_assert (priv->printer_set &&
priv->settings_set &&
priv->page_setup_set);
g_assert (job->priv->printer_set &&
job->priv->settings_set &&
job->priv->page_setup_set);
_gtk_printer_prepare_for_print (job->priv->printer,
_gtk_printer_prepare_for_print (priv->printer,
job,
job->priv->settings,
job->priv->page_setup);
priv->settings,
priv->page_setup);
return object;
}
@ -221,41 +226,37 @@ gtk_print_job_constructor (GType type,
static void
gtk_print_job_finalize (GObject *object)
{
GtkPrintJob *job;
g_return_if_fail (object != NULL);
GtkPrintJob *job = GTK_PRINT_JOB (object);
GtkPrintJobPrivate *priv = job->priv;
job = GTK_PRINT_JOB (object);
if (job->priv->spool_file_fd > 0)
if (priv->spool_file_fd >= 0)
{
close (job->priv->spool_file_fd);
job->priv->spool_file_fd = -1;
close (priv->spool_file_fd);
priv->spool_file_fd = -1;
}
if (job->priv->backend)
g_object_unref (G_OBJECT (job->priv->backend));
if (priv->backend)
g_object_unref (priv->backend);
if (job->priv->printer)
g_object_unref (G_OBJECT (job->priv->printer));
if (priv->printer)
g_object_unref (priv->printer);
if (job->priv->surface)
cairo_surface_destroy (job->priv->surface);
if (priv->surface)
cairo_surface_destroy (priv->surface);
if (job->priv->settings)
g_object_unref (job->priv->settings);
if (priv->settings)
g_object_unref (priv->settings);
if (job->priv->page_setup)
g_object_unref (job->priv->page_setup);
if (priv->page_setup)
g_object_unref (priv->page_setup);
g_free (job->page_ranges);
job->page_ranges = NULL;
g_free (job->priv->title);
job->priv->title = NULL;
if (G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize)
G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
g_free (priv->title);
priv->title = NULL;
G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
}
/**
@ -363,12 +364,16 @@ void
gtk_print_job_set_status (GtkPrintJob *job,
GtkPrintStatus status)
{
GtkPrintJobPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_JOB (job));
if (job->priv->status == status)
priv = job->priv;
if (priv->status == status)
return;
job->priv->status = status;
priv->status = status;
g_signal_emit (job, signals[STATUS_CHANGED], 0);
}
@ -392,10 +397,14 @@ gtk_print_job_set_source_file (GtkPrintJob *job,
const gchar *filename,
GError **error)
{
GtkPrintJobPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
job->priv->spool_file_fd = g_open (filename, O_RDONLY|O_BINARY);
if (job->priv->spool_file_fd < 0)
priv = job->priv;
priv->spool_file_fd = g_open (filename, O_RDONLY|O_BINARY);
if (priv->spool_file_fd < 0)
{
gchar *display_filename = g_filename_display_name (filename);
int save_errno = errno;
@ -430,33 +439,38 @@ cairo_surface_t *
gtk_print_job_get_surface (GtkPrintJob *job,
GError **error)
{
GtkPrintJobPrivate *priv;
gchar *filename;
gdouble width, height;
GtkPaperSize *paper_size;
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
if (job->priv->surface)
return job->priv->surface;
job->priv->spool_file_fd = g_file_open_tmp ("gtkprint_XXXXXX",
priv = job->priv;
if (priv->surface)
return priv->surface;
g_return_val_if_fail (priv->spool_file_fd == -1, NULL);
priv->spool_file_fd = g_file_open_tmp ("gtkprint_XXXXXX",
&filename,
error);
if (job->priv->spool_file_fd == -1)
if (priv->spool_file_fd == -1)
return NULL;
fchmod (job->priv->spool_file_fd, S_IRUSR | S_IWUSR);
fchmod (priv->spool_file_fd, S_IRUSR | S_IWUSR);
unlink (filename);
paper_size = gtk_page_setup_get_paper_size (job->priv->page_setup);
paper_size = gtk_page_setup_get_paper_size (priv->page_setup);
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
job->priv->surface = _gtk_printer_create_cairo_surface (job->priv->printer,
priv->surface = _gtk_printer_create_cairo_surface (priv->printer,
width, height,
job->priv->spool_file_fd);
priv->spool_file_fd);
return job->priv->surface;
return priv->surface;
}
static void
@ -467,31 +481,32 @@ gtk_print_job_set_property (GObject *object,
{
GtkPrintJob *job = GTK_PRINT_JOB (object);
GtkPrintJobPrivate *priv = job->priv;
GtkPrintSettings *settings;
switch (prop_id)
{
case GTK_PRINT_JOB_PROP_TITLE:
job->priv->title = g_value_dup_string (value);
priv->title = g_value_dup_string (value);
break;
case GTK_PRINT_JOB_PROP_PRINTER:
job->priv->printer = GTK_PRINTER (g_value_dup_object (value));
job->priv->printer_set = TRUE;
job->priv->backend = g_object_ref (gtk_printer_get_backend (job->priv->printer));
priv->printer = GTK_PRINTER (g_value_dup_object (value));
priv->printer_set = TRUE;
priv->backend = g_object_ref (gtk_printer_get_backend (priv->printer));
break;
case GTK_PRINT_JOB_PROP_PAGE_SETUP:
job->priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
job->priv->page_setup_set = TRUE;
priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
priv->page_setup_set = TRUE;
break;
case GTK_PRINT_JOB_PROP_SETTINGS:
/* We save a copy of the settings since we modify
* if when preparing the printer job. */
settings = GTK_PRINT_SETTINGS (g_value_get_object (value));
job->priv->settings = gtk_print_settings_copy (settings);
job->priv->settings_set = TRUE;
priv->settings = gtk_print_settings_copy (settings);
priv->settings_set = TRUE;
break;
default:
@ -507,20 +522,21 @@ gtk_print_job_get_property (GObject *object,
GParamSpec *pspec)
{
GtkPrintJob *job = GTK_PRINT_JOB (object);
GtkPrintJobPrivate *priv = job->priv;
switch (prop_id)
{
case GTK_PRINT_JOB_PROP_TITLE:
g_value_set_string (value, job->priv->title);
g_value_set_string (value, priv->title);
break;
case GTK_PRINT_JOB_PROP_PRINTER:
g_value_set_object (value, job->priv->printer);
g_value_set_object (value, priv->printer);
break;
case GTK_PRINT_JOB_PROP_SETTINGS:
g_value_set_object (value, job->priv->settings);
g_value_set_object (value, priv->settings);
break;
case GTK_PRINT_JOB_PROP_PAGE_SETUP:
g_value_set_object (value, job->priv->page_setup);
g_value_set_object (value, priv->page_setup);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -549,14 +565,18 @@ gtk_print_job_send (GtkPrintJob *job,
GDestroyNotify dnotify,
GError **error)
{
GtkPrintJobPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
g_return_val_if_fail (job->priv->spool_file_fd > 0, FALSE);
priv = job->priv;
g_return_val_if_fail (priv->spool_file_fd > 0, FALSE);
gtk_print_job_set_status (job, GTK_PRINT_STATUS_SENDING_DATA);
lseek (job->priv->spool_file_fd, 0, SEEK_SET);
gtk_print_backend_print_stream (job->priv->backend,
lseek (priv->spool_file_fd, 0, SEEK_SET);
gtk_print_backend_print_stream (priv->backend,
job,
job->priv->spool_file_fd,
priv->spool_file_fd,
callback,
user_data,
dnotify);

View File

@ -80,16 +80,13 @@ unix_finish_send (GtkPrintJob *job,
GError *error)
{
GtkPrintOperationUnix *op_unix;
GtkWindow *parent;
op_unix = (GtkPrintOperationUnix *) user_data;
parent = op_unix->parent;
if (error != NULL)
{
GtkWidget *edialog;
edialog = gtk_message_dialog_new (parent,
edialog = gtk_message_dialog_new (op_unix->parent,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
@ -125,16 +122,17 @@ static GtkWidget *
get_print_dialog (GtkPrintOperation *op,
GtkWindow *parent)
{
GtkPrintOperationPrivate *priv = op->priv;
GtkWidget *pd;
GtkPageSetup *page_setup;
pd = gtk_print_unix_dialog_new (NULL, parent);
if (op->priv->print_settings)
if (priv->print_settings)
gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG (pd),
op->priv->print_settings);
if (op->priv->default_page_setup)
page_setup = gtk_page_setup_copy (op->priv->default_page_setup);
priv->print_settings);
if (priv->default_page_setup)
page_setup = gtk_page_setup_copy (priv->default_page_setup);
else
page_setup = gtk_page_setup_new ();
@ -171,6 +169,7 @@ handle_print_response (GtkWidget *dialog,
GtkPrintUnixDialog *pd = GTK_PRINT_UNIX_DIALOG (dialog);
PrintResponseData *rdata = data;
GtkPrintOperation *op = rdata->op;
GtkPrintOperationPrivate *priv = op->priv;
if (response == GTK_RESPONSE_OK)
{
@ -193,7 +192,7 @@ handle_print_response (GtkWidget *dialog,
gtk_print_operation_set_print_settings (op, settings);
op_unix = g_new0 (GtkPrintOperationUnix, 1);
op_unix->job = gtk_print_job_new (op->priv->job_name,
op_unix->job = gtk_print_job_new (priv->job_name,
printer,
settings,
page_setup);
@ -215,27 +214,27 @@ handle_print_response (GtkWidget *dialog,
op_unix->parent = gtk_window_get_transient_for (GTK_WINDOW (pd));
op->priv->dpi_x = 72;
op->priv->dpi_y = 72;
priv->dpi_x = 72;
priv->dpi_y = 72;
op->priv->platform_data = op_unix;
op->priv->free_platform_data = (GDestroyNotify) op_unix_free;
priv->platform_data = op_unix;
priv->free_platform_data = (GDestroyNotify) op_unix_free;
op->priv->print_pages = op_unix->job->print_pages;
op->priv->page_ranges = op_unix->job->page_ranges;
op->priv->num_page_ranges = op_unix->job->num_page_ranges;
priv->print_pages = op_unix->job->print_pages;
priv->page_ranges = op_unix->job->page_ranges;
priv->num_page_ranges = op_unix->job->num_page_ranges;
op->priv->manual_num_copies = op_unix->job->num_copies;
op->priv->manual_collation = op_unix->job->collate;
op->priv->manual_reverse = op_unix->job->reverse;
op->priv->manual_page_set = op_unix->job->page_set;
op->priv->manual_scale = op_unix->job->scale;
op->priv->manual_orientation = op_unix->job->rotate_to_orientation;
priv->manual_num_copies = op_unix->job->num_copies;
priv->manual_collation = op_unix->job->collate;
priv->manual_reverse = op_unix->job->reverse;
priv->manual_page_set = op_unix->job->page_set;
priv->manual_scale = op_unix->job->scale;
priv->manual_orientation = op_unix->job->rotate_to_orientation;
}
op->priv->start_page = unix_start_page;
op->priv->end_page = unix_end_page;
op->priv->end_run = unix_end_run;
priv->start_page = unix_start_page;
priv->end_page = unix_end_page;
priv->end_run = unix_end_run;
out:
gtk_widget_destroy (GTK_WIDGET (pd));

View File

@ -80,22 +80,23 @@ static void
gtk_print_operation_finalize (GObject *object)
{
GtkPrintOperation *print_operation = GTK_PRINT_OPERATION (object);
GtkPrintOperationPrivate *priv = print_operation->priv;
if (print_operation->priv->free_platform_data &&
print_operation->priv->platform_data)
if (priv->free_platform_data &&
priv->platform_data)
{
print_operation->priv->free_platform_data (print_operation->priv->platform_data);
print_operation->priv->free_platform_data = NULL;
priv->free_platform_data (priv->platform_data);
priv->free_platform_data = NULL;
}
if (print_operation->priv->default_page_setup)
g_object_unref (print_operation->priv->default_page_setup);
if (priv->default_page_setup)
g_object_unref (priv->default_page_setup);
if (print_operation->priv->print_settings)
g_object_unref (print_operation->priv->print_settings);
if (priv->print_settings)
g_object_unref (priv->print_settings);
g_free (print_operation->priv->pdf_target);
g_free (print_operation->priv->job_name);
g_free (priv->pdf_target);
g_free (priv->job_name);
G_OBJECT_CLASS (gtk_print_operation_parent_class)->finalize (object);
}
@ -103,25 +104,25 @@ gtk_print_operation_finalize (GObject *object)
static void
gtk_print_operation_init (GtkPrintOperation *operation)
{
GtkPrintOperationPrivate *priv;
const char *appname;
operation->priv = GTK_PRINT_OPERATION_GET_PRIVATE (operation);
priv = operation->priv = GTK_PRINT_OPERATION_GET_PRIVATE (operation);
operation->priv->status = GTK_PRINT_STATUS_INITIAL;
operation->priv->status_string = g_strdup ("");
operation->priv->default_page_setup = NULL;
operation->priv->print_settings = NULL;
operation->priv->nr_of_pages = -1;
operation->priv->current_page = -1;
operation->priv->use_full_page = FALSE;
operation->priv->show_dialog = TRUE;
operation->priv->pdf_target = NULL;
priv->status = GTK_PRINT_STATUS_INITIAL;
priv->status_string = g_strdup ("");
priv->default_page_setup = NULL;
priv->print_settings = NULL;
priv->nr_of_pages = -1;
priv->current_page = -1;
priv->use_full_page = FALSE;
priv->show_dialog = TRUE;
priv->pdf_target = NULL;
operation->priv->unit = GTK_UNIT_PIXEL;
priv->unit = GTK_UNIT_PIXEL;
appname = g_get_application_name ();
operation->priv->job_name = g_strdup_printf ("%s job #%d",
appname, ++job_nr);
priv->job_name = g_strdup_printf ("%s job #%d", appname, ++job_nr);
}
static void
@ -174,41 +175,42 @@ gtk_print_operation_get_property (GObject *object,
GParamSpec *pspec)
{
GtkPrintOperation *op = GTK_PRINT_OPERATION (object);
GtkPrintOperationPrivate *priv = op->priv;
switch (prop_id)
{
case PROP_DEFAULT_PAGE_SETUP:
g_value_set_object (value, op->priv->default_page_setup);
g_value_set_object (value, priv->default_page_setup);
break;
case PROP_PRINT_SETTINGS:
g_value_set_object (value, op->priv->print_settings);
g_value_set_object (value, priv->print_settings);
break;
case PROP_JOB_NAME:
g_value_set_string (value, op->priv->job_name);
g_value_set_string (value, priv->job_name);
break;
case PROP_NR_OF_PAGES:
g_value_set_int (value, op->priv->nr_of_pages);
g_value_set_int (value, priv->nr_of_pages);
break;
case PROP_CURRENT_PAGE:
g_value_set_int (value, op->priv->current_page);
g_value_set_int (value, priv->current_page);
break;
case PROP_USE_FULL_PAGE:
g_value_set_boolean (value, op->priv->use_full_page);
g_value_set_boolean (value, priv->use_full_page);
break;
case PROP_UNIT:
g_value_set_enum (value, op->priv->unit);
g_value_set_enum (value, priv->unit);
break;
case PROP_SHOW_DIALOG:
g_value_set_boolean (value, op->priv->show_dialog);
g_value_set_boolean (value, priv->show_dialog);
break;
case PROP_PDF_TARGET:
g_value_set_string (value, op->priv->pdf_target);
g_value_set_string (value, priv->pdf_target);
break;
case PROP_STATUS:
g_value_set_enum (value, op->priv->status);
g_value_set_enum (value, priv->status);
break;
case PROP_STATUS_STRING:
g_value_set_string (value, op->priv->status_string);
g_value_set_string (value, priv->status_string);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -600,19 +602,23 @@ void
gtk_print_operation_set_default_page_setup (GtkPrintOperation *op,
GtkPageSetup *default_page_setup)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_return_if_fail (default_page_setup == NULL ||
GTK_IS_PAGE_SETUP (default_page_setup));
if (default_page_setup != op->priv->default_page_setup)
priv = op->priv;
if (default_page_setup != priv->default_page_setup)
{
if (default_page_setup)
g_object_ref (default_page_setup);
if (op->priv->default_page_setup)
g_object_unref (op->priv->default_page_setup);
if (priv->default_page_setup)
g_object_unref (priv->default_page_setup);
op->priv->default_page_setup = default_page_setup;
priv->default_page_setup = default_page_setup;
g_object_notify (G_OBJECT (op), "default-page-setup");
}
@ -653,19 +659,23 @@ void
gtk_print_operation_set_print_settings (GtkPrintOperation *op,
GtkPrintSettings *print_settings)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_return_if_fail (print_settings == NULL ||
GTK_IS_PRINT_SETTINGS (print_settings));
if (print_settings != op->priv->print_settings)
priv = op->priv;
if (print_settings != priv->print_settings)
{
if (print_settings)
g_object_ref (print_settings);
if (op->priv->print_settings)
g_object_unref (op->priv->print_settings);
if (priv->print_settings)
g_object_unref (priv->print_settings);
op->priv->print_settings = print_settings;
priv->print_settings = print_settings;
g_object_notify (G_OBJECT (op), "print-settings");
}
@ -710,11 +720,15 @@ void
gtk_print_operation_set_job_name (GtkPrintOperation *op,
const gchar *job_name)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_return_if_fail (g_utf8_validate (job_name, -1, NULL));
g_free (op->priv->job_name);
op->priv->job_name = g_strdup (job_name);
priv = op->priv;
g_free (priv->job_name);
priv->job_name = g_strdup (job_name);
g_object_notify (G_OBJECT (op), "job-name");
}
@ -741,14 +755,18 @@ void
gtk_print_operation_set_nr_of_pages (GtkPrintOperation *op,
gint n_pages)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_return_if_fail (n_pages > 0);
g_return_if_fail (op->priv->current_page == -1 ||
op->priv->current_page < n_pages);
if (op->priv->nr_of_pages != n_pages)
priv = op->priv;
g_return_if_fail (priv->current_page == -1 ||
priv->current_page < n_pages);
if (priv->nr_of_pages != n_pages)
{
op->priv->nr_of_pages = n_pages;
priv->nr_of_pages = n_pages;
g_object_notify (G_OBJECT (op), "number-of-pages");
}
@ -772,14 +790,18 @@ void
gtk_print_operation_set_current_page (GtkPrintOperation *op,
gint current_page)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_return_if_fail (current_page >= 0);
g_return_if_fail (op->priv->nr_of_pages == -1 ||
current_page < op->priv->nr_of_pages);
if (op->priv->current_page != current_page)
priv = op->priv;
g_return_if_fail (priv->nr_of_pages == -1 ||
current_page < priv->nr_of_pages);
if (priv->current_page != current_page)
{
op->priv->current_page = current_page;
priv->current_page = current_page;
g_object_notify (G_OBJECT (op), "current-page");
}
@ -803,13 +825,17 @@ void
gtk_print_operation_set_use_full_page (GtkPrintOperation *op,
gboolean full_page)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
full_page = full_page != FALSE;
if (op->priv->use_full_page != full_page)
priv = op->priv;
if (priv->use_full_page != full_page)
{
op->priv->use_full_page = full_page;
priv->use_full_page = full_page;
g_object_notify (G_OBJECT (op), "use-full-page");
}
@ -830,11 +856,15 @@ void
gtk_print_operation_set_unit (GtkPrintOperation *op,
GtkUnit unit)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
if (op->priv->unit != unit)
priv = op->priv;
if (priv->unit != unit)
{
op->priv->unit = unit;
priv->unit = unit;
g_object_notify (G_OBJECT (op), "unit");
}
@ -845,7 +875,8 @@ _gtk_print_operation_set_status (GtkPrintOperation *op,
GtkPrintStatus status,
const gchar *string)
{
const gchar *status_strs[] = {
GtkPrintOperationPrivate *priv = op->priv;
static const gchar *status_strs[] = {
/* translators, strip the prefix up to and including the first | */
N_("print operation status|Initial state"),
/* translators, strip the prefix up to and including the first | */
@ -873,13 +904,13 @@ _gtk_print_operation_set_status (GtkPrintOperation *op,
string = g_strip_context (status_strs[status],
gettext (status_strs[status]));
if (op->priv->status == status &&
strcmp (string, op->priv->status_string) == 0)
if (priv->status == status &&
strcmp (string, priv->status_string) == 0)
return;
g_free (op->priv->status_string);
op->priv->status_string = g_strdup (string);
op->priv->status = status;
g_free (priv->status_string);
priv->status_string = g_strdup (string);
priv->status = status;
g_object_notify (G_OBJECT (op), "status");
g_object_notify (G_OBJECT (op), "status-string");
@ -947,11 +978,14 @@ gtk_print_operation_get_status_string (GtkPrintOperation *op)
gboolean
gtk_print_operation_is_finished (GtkPrintOperation *op)
{
GtkPrintOperationPrivate *priv;
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), TRUE);
priv = op->priv;
return
op->priv->status == GTK_PRINT_STATUS_FINISHED_ABORTED ||
op->priv->status == GTK_PRINT_STATUS_FINISHED;
priv->status == GTK_PRINT_STATUS_FINISHED_ABORTED ||
priv->status == GTK_PRINT_STATUS_FINISHED;
}
@ -969,13 +1003,17 @@ void
gtk_print_operation_set_show_dialog (GtkPrintOperation *op,
gboolean show_dialog)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
priv = op->priv;
show_dialog = show_dialog != FALSE;
if (op->priv->show_dialog != show_dialog)
if (priv->show_dialog != show_dialog)
{
op->priv->show_dialog = show_dialog;
priv->show_dialog = show_dialog;
g_object_notify (G_OBJECT (op), "show-dialog");
}
@ -1000,10 +1038,14 @@ void
gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
const gchar *filename)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_free (op->priv->pdf_target);
op->priv->pdf_target = g_strdup (filename);
priv = op->priv;
g_free (priv->pdf_target);
priv->pdf_target = g_strdup (filename);
g_object_notify (G_OBJECT (op), "pdf-target");
}
@ -1022,15 +1064,16 @@ gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
static GtkPageSetup *
create_page_setup (GtkPrintOperation *op)
{
GtkPrintOperationPrivate *priv = op->priv;
GtkPageSetup *page_setup;
GtkPrintSettings *settings;
if (op->priv->default_page_setup)
page_setup = gtk_page_setup_copy (op->priv->default_page_setup);
if (priv->default_page_setup)
page_setup = gtk_page_setup_copy (priv->default_page_setup);
else
page_setup = gtk_page_setup_new ();
settings = op->priv->print_settings;
settings = priv->print_settings;
if (settings)
{
GtkPaperSize *paper_size;
@ -1074,8 +1117,10 @@ pdf_end_page (GtkPrintOperation *op,
static void
pdf_end_run (GtkPrintOperation *op)
{
cairo_surface_destroy (op->priv->surface);
op->priv->surface = NULL;
GtkPrintOperationPrivate *priv = op->priv;
cairo_surface_destroy (priv->surface);
priv->surface = NULL;
}
static GtkPrintOperationResult
@ -1084,6 +1129,7 @@ run_pdf (GtkPrintOperation *op,
gboolean *do_print,
GError **error)
{
GtkPrintOperationPrivate *priv = op->priv;
GtkPageSetup *page_setup;
double width, height;
/* This will be overwritten later by the non-default size, but
@ -1094,22 +1140,22 @@ run_pdf (GtkPrintOperation *op,
height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
g_object_unref (page_setup);
op->priv->surface = cairo_pdf_surface_create (op->priv->pdf_target,
width, height);
priv->surface = cairo_pdf_surface_create (priv->pdf_target,
width, height);
/* TODO: DPI from settings object? */
cairo_pdf_surface_set_dpi (op->priv->surface, 300, 300);
cairo_pdf_surface_set_dpi (priv->surface, 300, 300);
op->priv->dpi_x = 72;
op->priv->dpi_y = 72;
priv->dpi_x = 72;
priv->dpi_y = 72;
op->priv->manual_num_copies = 1;
op->priv->manual_collation = FALSE;
priv->manual_num_copies = 1;
priv->manual_collation = FALSE;
*do_print = TRUE;
op->priv->start_page = pdf_start_page;
op->priv->end_page = pdf_end_page;
op->priv->end_run = pdf_end_run;
priv->start_page = pdf_start_page;
priv->end_page = pdf_end_page;
priv->end_run = pdf_end_run;
return GTK_PRINT_OPERATION_RESULT_APPLY;
}
@ -1117,6 +1163,7 @@ run_pdf (GtkPrintOperation *op,
static void
print_pages (GtkPrintOperation *op)
{
GtkPrintOperationPrivate *priv = op->priv;
int page, range;
GtkPageSetup *initial_page_setup, *page_setup;
GtkPrintContext *print_context;
@ -1127,15 +1174,15 @@ print_pages (GtkPrintOperation *op)
GtkPageRange one_range;
int num_ranges;
if (op->priv->manual_collation)
if (priv->manual_collation)
{
uncollated_copies = op->priv->manual_num_copies;
uncollated_copies = priv->manual_num_copies;
collated_copies = 1;
}
else
{
uncollated_copies = 1;
collated_copies = op->priv->manual_num_copies;
collated_copies = priv->manual_num_copies;
}
print_context = _gtk_print_context_new (op);
@ -1146,27 +1193,27 @@ print_pages (GtkPrintOperation *op)
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_PREPARING, NULL);
g_signal_emit (op, signals[BEGIN_PRINT], 0, print_context);
g_return_if_fail (op->priv->nr_of_pages > 0);
g_return_if_fail (priv->nr_of_pages > 0);
if (op->priv->print_pages == GTK_PRINT_PAGES_RANGES)
if (priv->print_pages == GTK_PRINT_PAGES_RANGES)
{
ranges = op->priv->page_ranges;
num_ranges = op->priv->num_page_ranges;
ranges = priv->page_ranges;
num_ranges = priv->num_page_ranges;
}
else if (op->priv->print_pages == GTK_PRINT_PAGES_CURRENT &&
op->priv->current_page != -1)
else if (priv->print_pages == GTK_PRINT_PAGES_CURRENT &&
priv->current_page != -1)
{
ranges = &one_range;
num_ranges = 1;
ranges[0].start = op->priv->current_page;
ranges[0].end = op->priv->current_page;
ranges[0].start = priv->current_page;
ranges[0].end = priv->current_page;
}
else
{
ranges = &one_range;
num_ranges = 1;
ranges[0].start = 0;
ranges[0].end = op->priv->nr_of_pages - 1;
ranges[0].end = priv->nr_of_pages - 1;
}
_gtk_print_operation_set_status (op, GTK_PRINT_STATUS_GENERATING_DATA, NULL);
@ -1179,7 +1226,7 @@ print_pages (GtkPrintOperation *op)
int low = ranges[range].start;
int high = ranges[range].end;
if (op->priv->manual_reverse)
if (priv->manual_reverse)
{
start = high;
end = low - 1;
@ -1193,8 +1240,8 @@ print_pages (GtkPrintOperation *op)
}
for (page = start; page != end; page += inc)
{
if ((op->priv->manual_page_set == GTK_PAGE_SET_EVEN && page % 2 == 0) ||
(op->priv->manual_page_set == GTK_PAGE_SET_ODD && page % 2 == 1))
if ((priv->manual_page_set == GTK_PAGE_SET_EVEN && page % 2 == 0) ||
(priv->manual_page_set == GTK_PAGE_SET_ODD && page % 2 == 1))
continue;
for (j = 0; j < collated_copies; j++)
@ -1203,26 +1250,26 @@ print_pages (GtkPrintOperation *op)
g_signal_emit (op, signals[REQUEST_PAGE_SETUP], 0, print_context, page, page_setup);
_gtk_print_context_set_page_setup (print_context, page_setup);
op->priv->start_page (op, print_context, page_setup);
priv->start_page (op, print_context, page_setup);
cr = gtk_print_context_get_cairo (print_context);
cairo_save (cr);
if (op->priv->manual_scale != 100.0)
if (priv->manual_scale != 100.0)
cairo_scale (cr,
op->priv->manual_scale,
op->priv->manual_scale);
priv->manual_scale,
priv->manual_scale);
if (op->priv->manual_orientation)
if (priv->manual_orientation)
_gtk_print_context_rotate_according_to_orientation (print_context);
if (!op->priv->use_full_page)
if (!priv->use_full_page)
_gtk_print_context_translate_into_margin (print_context);
g_signal_emit (op, signals[DRAW_PAGE], 0,
print_context, page);
op->priv->end_page (op, print_context);
priv->end_page (op, print_context);
cairo_restore (cr);
@ -1241,8 +1288,8 @@ print_pages (GtkPrintOperation *op)
g_object_unref (print_context);
g_object_unref (initial_page_setup);
cairo_surface_finish (op->priv->surface);
op->priv->end_run (op);
cairo_surface_finish (priv->surface);
priv->end_run (op);
}
@ -1279,13 +1326,16 @@ gtk_print_operation_run (GtkPrintOperation *op,
GtkWindow *parent,
GError **error)
{
GtkPrintOperationPrivate *priv;
GtkPrintOperationResult result;
gboolean do_print;
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op),
GTK_PRINT_OPERATION_RESULT_ERROR);
if (op->priv->pdf_target != NULL)
priv = op->priv;
if (priv->pdf_target != NULL)
result = run_pdf (op, parent, &do_print, error);
else
result = _gtk_print_operation_platform_backend_run_dialog (op,
@ -1323,11 +1373,14 @@ void
gtk_print_operation_run_async (GtkPrintOperation *op,
GtkWindow *parent)
{
GtkPrintOperationPrivate *priv;
gboolean do_print;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
if (op->priv->pdf_target != NULL)
priv = op->priv;
if (priv->pdf_target != NULL)
{
run_pdf (op, parent, &do_print, NULL);
if (do_print)

File diff suppressed because it is too large Load Diff