summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-05-02 12:48:52 +0000
committerChristian Persch <chpe@src.gnome.org>2006-05-02 12:48:52 +0000
commit061f252873596d738452923ea99e1e8419347da4 (patch)
tree9e2ffb1e5c589c9791939bad7098047fdcc6f333
parent5d6f77b4ed3cd6bf2ead8a5b0430bc1fc2f8c186 (diff)
downloadgdk-pixbuf-061f252873596d738452923ea99e1e8419347da4.tar.gz
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.
-rw-r--r--ChangeLog12
-rw-r--r--ChangeLog.pre-2-1012
-rw-r--r--gtk/gtkpagesetupunixdialog.c274
-rw-r--r--gtk/gtkprintcontext.c47
-rw-r--r--gtk/gtkprinter.c114
-rw-r--r--gtk/gtkprinteroptionwidget.c216
-rw-r--r--gtk/gtkprintjob.c162
-rw-r--r--gtk/gtkprintoperation-unix.c49
-rw-r--r--gtk/gtkprintoperation.c279
-rw-r--r--gtk/gtkprintunixdialog.c476
10 files changed, 923 insertions, 718 deletions
diff --git a/ChangeLog b/ChangeLog
index e230ff920..bb8dd03d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index e230ff920..bb8dd03d2 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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
diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c
index 2eb2a32bd..8def617c3 100644
--- a/gtk/gtkpagesetupunixdialog.c
+++ b/gtk/gtkpagesetupunixdialog.c
@@ -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);
+
+ priv->print_backends = NULL;
- dialog->priv->printer_list = gtk_list_store_new (PRINTER_LIST_N_COLS,
+ 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);
}
diff --git a/gtk/gtkprintcontext.c b/gtk/gtkprintcontext.c
index 8525ec8f2..7464933ed 100644
--- a/gtk/gtkprintcontext.c
+++ b/gtk/gtkprintcontext.c
@@ -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;
}
/**
diff --git a/gtk/gtkprinter.c b/gtk/gtkprinter.c
index dde0c5265..b78f0b1ee 100644
--- a/gtk/gtkprinter.c
+++ b/gtk/gtkprinter.c
@@ -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");
diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c
index 688f5c90f..afa1ea29b 100644
--- a/gtk/gtkprinteroptionwidget.c
+++ b/gtk/gtkprinteroptionwidget.c
@@ -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 "";
}
diff --git a/gtk/gtkprintjob.c b/gtk/gtkprintjob.c
index 0989fdaa1..6761b2d67 100644
--- a/gtk/gtkprintjob.c
+++ b/gtk/gtkprintjob.c
@@ -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);
-
- job = GTK_PRINT_JOB (object);
+ GtkPrintJob *job = GTK_PRINT_JOB (object);
+ GtkPrintJobPrivate *priv = job->priv;
- 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);
diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c
index ffecd75fc..c1d14e98f 100644
--- a/gtk/gtkprintoperation-unix.c
+++ b/gtk/gtkprintoperation-unix.c
@@ -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));
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c
index a6100cd3d..cd52b8eb1 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -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)
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 49a2fe118..b390035fd 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -356,8 +356,10 @@ static gboolean
is_default_printer (GtkPrintUnixDialog *dialog,
GtkPrinter *printer)
{
- if (dialog->priv->format_for_printer)
- return strcmp (dialog->priv->format_for_printer,
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
+ if (priv->format_for_printer)
+ return strcmp (priv->format_for_printer,
gtk_printer_get_name (printer)) == 0;
else
return gtk_printer_is_default (printer);
@@ -416,14 +418,16 @@ gtk_print_unix_dialog_class_init (GtkPrintUnixDialogClass *class)
static void
gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
{
- dialog->priv = GTK_PRINT_UNIX_DIALOG_GET_PRIVATE (dialog);
- dialog->priv->print_backends = NULL;
- dialog->priv->current_page = -1;
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
- dialog->priv->extension_points = g_hash_table_new (g_str_hash,
- g_str_equal);
+ priv = dialog->priv = GTK_PRINT_UNIX_DIALOG_GET_PRIVATE (dialog);
+ priv->print_backends = NULL;
+ priv->current_page = -1;
- dialog->priv->page_setup = gtk_page_setup_new ();
+ priv->extension_points = g_hash_table_new (g_str_hash,
+ g_str_equal);
+
+ priv->page_setup = gtk_page_setup_new ();
populate_dialog (dialog);
@@ -452,68 +456,66 @@ static void
gtk_print_unix_dialog_finalize (GObject *object)
{
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
-
- g_return_if_fail (object != NULL);
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
unschedule_idle_mark_conflicts (dialog);
- 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 (dialog->priv->current_printer)
+ if (priv->current_printer)
{
- g_object_unref (dialog->priv->current_printer);
- dialog->priv->current_printer = NULL;
+ g_object_unref (priv->current_printer);
+ priv->current_printer = NULL;
}
- 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->printer_list_filter)
+ if (priv->printer_list_filter)
{
- g_object_unref (dialog->priv->printer_list_filter);
- dialog->priv->printer_list_filter = NULL;
+ g_object_unref (priv->printer_list_filter);
+ priv->printer_list_filter = NULL;
}
- if (dialog->priv->options)
+ if (priv->options)
{
- g_object_unref (dialog->priv->options);
- dialog->priv->options = NULL;
+ g_object_unref (priv->options);
+ priv->options = NULL;
}
- if (dialog->priv->extension_points)
+ if (priv->extension_points)
{
- g_hash_table_unref (dialog->priv->extension_points);
- dialog->priv->extension_points = NULL;
+ g_hash_table_unref (priv->extension_points);
+ priv->extension_points = NULL;
}
- if (dialog->priv->page_setup)
+ if (priv->page_setup)
{
- g_object_unref (dialog->priv->page_setup);
- dialog->priv->page_setup = NULL;
+ g_object_unref (priv->page_setup);
+ priv->page_setup = NULL;
}
- if (dialog->priv->initial_settings)
+ if (priv->initial_settings)
{
- g_object_unref (dialog->priv->initial_settings);
- dialog->priv->initial_settings = NULL;
+ g_object_unref (priv->initial_settings);
+ priv->initial_settings = NULL;
}
- g_free (dialog->priv->waiting_for_printer);
- dialog->priv->waiting_for_printer = NULL;
+ g_free (priv->waiting_for_printer);
+ priv->waiting_for_printer = NULL;
- g_free (dialog->priv->format_for_printer);
- dialog->priv->format_for_printer = NULL;
-
- if (G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->finalize)
- G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->finalize (object);
+ g_free (priv->format_for_printer);
+ priv->format_for_printer = NULL;
+
+ G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->finalize (object);
}
static void
@@ -521,9 +523,11 @@ printer_removed_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *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);
}
static void
@@ -531,10 +535,12 @@ printer_status_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter *iter;
+
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
- gtk_list_store_set (GTK_LIST_STORE (dialog->priv->printer_list), iter,
+ gtk_list_store_set (GTK_LIST_STORE (priv->printer_list), iter,
PRINTER_LIST_COL_ICON, gtk_printer_get_icon_name (printer),
PRINTER_LIST_COL_STATE, gtk_printer_get_state_message (printer),
PRINTER_LIST_COL_JOBS, gtk_printer_get_job_count (printer),
@@ -548,17 +554,18 @@ printer_added_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkTreeIter iter, filter_iter;
GtkTreeSelection *selection;
- gtk_list_store_append (GTK_LIST_STORE (dialog->priv->printer_list), &iter);
+ gtk_list_store_append (GTK_LIST_STORE (priv->printer_list), &iter);
g_object_set_data_full (G_OBJECT (printer),
"gtk-print-tree-iter",
gtk_tree_iter_copy (&iter),
(GDestroyNotify) gtk_tree_iter_free);
- gtk_list_store_set (GTK_LIST_STORE (dialog->priv->printer_list), &iter,
+ gtk_list_store_set (GTK_LIST_STORE (priv->printer_list), &iter,
PRINTER_LIST_COL_ICON, gtk_printer_get_icon_name (printer),
PRINTER_LIST_COL_NAME, gtk_printer_get_name (printer),
PRINTER_LIST_COL_STATE, gtk_printer_get_state_message (printer),
@@ -567,27 +574,27 @@ printer_added_cb (GtkPrintBackend *backend,
PRINTER_LIST_COL_PRINTER_OBJ, printer,
-1);
- gtk_tree_model_filter_convert_child_iter_to_iter (dialog->priv->printer_list_filter,
+ gtk_tree_model_filter_convert_child_iter_to_iter (priv->printer_list_filter,
&filter_iter, &iter);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->printer_treeview));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
- if (dialog->priv->waiting_for_printer != NULL &&
+ if (priv->waiting_for_printer != NULL &&
strcmp (gtk_printer_get_name (printer),
- dialog->priv->waiting_for_printer) == 0)
+ priv->waiting_for_printer) == 0)
{
- dialog->priv->internal_printer_change = TRUE;
+ priv->internal_printer_change = TRUE;
gtk_tree_selection_select_iter (selection, &filter_iter);
- dialog->priv->internal_printer_change = FALSE;
- g_free (dialog->priv->waiting_for_printer);
- dialog->priv->waiting_for_printer = NULL;
+ priv->internal_printer_change = FALSE;
+ g_free (priv->waiting_for_printer);
+ priv->waiting_for_printer = NULL;
}
else if (is_default_printer (dialog, printer) &&
gtk_tree_selection_count_selected_rows (selection) == 0)
{
- dialog->priv->internal_printer_change = TRUE;
+ priv->internal_printer_change = TRUE;
gtk_tree_selection_select_iter (selection, &filter_iter);
- dialog->priv->internal_printer_change = FALSE;
+ priv->internal_printer_change = FALSE;
}
}
@@ -630,12 +637,13 @@ printer_list_initialize (GtkPrintUnixDialog *dialog,
static void
load_print_backends (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *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));
}
@@ -672,20 +680,21 @@ gtk_print_unix_dialog_get_property (GObject *object,
GParamSpec *pspec)
{
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
switch (prop_id)
{
case PROP_PAGE_SETUP:
- g_value_set_object (value, dialog->priv->page_setup);
+ g_value_set_object (value, priv->page_setup);
break;
case PROP_CURRENT_PAGE:
- g_value_set_int (value, dialog->priv->current_page);
+ g_value_set_int (value, priv->current_page);
break;
case PROP_PRINT_SETTINGS:
g_value_set_object (value, gtk_print_unix_dialog_get_settings (dialog));
break;
case PROP_SELECTED_PRINTER:
- g_value_set_object (value, dialog->priv->current_printer);
+ g_value_set_object (value, priv->current_printer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -771,6 +780,7 @@ default_printer_list_sort_func (GtkTreeModel *model,
static void
create_printer_list_model (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkListStore *model;
GtkTreeSortable *sort;
@@ -782,11 +792,11 @@ create_printer_list_model (GtkPrintUnixDialog *dialog)
G_TYPE_STRING,
G_TYPE_OBJECT);
- dialog->priv->printer_list = (GtkTreeModel *)model;
- dialog->priv->printer_list_filter = (GtkTreeModelFilter *) gtk_tree_model_filter_new ((GtkTreeModel *)model,
+ priv->printer_list = (GtkTreeModel *)model;
+ priv->printer_list_filter = (GtkTreeModelFilter *) gtk_tree_model_filter_new ((GtkTreeModel *)model,
NULL);
- gtk_tree_model_filter_set_visible_func (dialog->priv->printer_list_filter,
+ gtk_tree_model_filter_set_visible_func (priv->printer_list_filter,
(GtkTreeModelFilterVisibleFunc) is_printer_active,
dialog,
NULL);
@@ -840,9 +850,10 @@ setup_option (GtkPrintUnixDialog *dialog,
const gchar *option_name,
GtkPrinterOptionWidget *widget)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkPrinterOption *option;
- option = gtk_printer_option_set_lookup (dialog->priv->options, option_name);
+ option = gtk_printer_option_set_lookup (priv->options, option_name);
gtk_printer_option_widget_set_source (widget, option);
return option != NULL;
@@ -943,27 +954,28 @@ setup_page_table (GtkPrinterOptionSet *options,
static void
update_print_at_option (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkPrinterOption *option;
- option = gtk_printer_option_set_lookup (dialog->priv->options, "gtk-print-time");
+ option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time");
if (option == NULL)
return;
- if (dialog->priv->updating_print_at)
+ if (priv->updating_print_at)
return;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->print_at_radio)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->print_at_radio)))
gtk_printer_option_set (option, "at");
- else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->print_hold_radio)))
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->print_hold_radio)))
gtk_printer_option_set (option, "on-hold");
else
gtk_printer_option_set (option, "now");
- option = gtk_printer_option_set_lookup (dialog->priv->options, "gtk-print-time-text");
+ option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time-text");
if (option != NULL)
{
- const char *text = gtk_entry_get_text (GTK_ENTRY (dialog->priv->print_at_entry));
+ const char *text = gtk_entry_get_text (GTK_ENTRY (priv->print_at_entry));
gtk_printer_option_set (option,text);
}
}
@@ -972,56 +984,57 @@ update_print_at_option (GtkPrintUnixDialog *dialog)
static gboolean
setup_print_at (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkPrinterOption *option;
- option = gtk_printer_option_set_lookup (dialog->priv->options, "gtk-print-time");
+ option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time");
if (option == NULL)
{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->print_now_radio),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_now_radio),
TRUE);
- gtk_widget_set_sensitive (dialog->priv->print_at_radio, FALSE);
- gtk_widget_set_sensitive (dialog->priv->print_at_entry, FALSE);
- gtk_widget_set_sensitive (dialog->priv->print_hold_radio, FALSE);
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->print_at_entry), "");
+ gtk_widget_set_sensitive (priv->print_at_radio, FALSE);
+ gtk_widget_set_sensitive (priv->print_at_entry, FALSE);
+ gtk_widget_set_sensitive (priv->print_hold_radio, FALSE);
+ gtk_entry_set_text (GTK_ENTRY (priv->print_at_entry), "");
return FALSE;
}
- dialog->priv->updating_print_at = TRUE;
+ priv->updating_print_at = TRUE;
if (gtk_printer_option_has_choice (option, "at"))
{
- gtk_widget_set_sensitive (dialog->priv->print_at_radio, TRUE);
- gtk_widget_set_sensitive (dialog->priv->print_at_entry, TRUE);
+ gtk_widget_set_sensitive (priv->print_at_radio, TRUE);
+ gtk_widget_set_sensitive (priv->print_at_entry, TRUE);
}
else
{
- gtk_widget_set_sensitive (dialog->priv->print_at_radio, FALSE);
- gtk_widget_set_sensitive (dialog->priv->print_at_entry, FALSE);
+ gtk_widget_set_sensitive (priv->print_at_radio, FALSE);
+ gtk_widget_set_sensitive (priv->print_at_entry, FALSE);
}
- gtk_widget_set_sensitive (dialog->priv->print_hold_radio,
+ gtk_widget_set_sensitive (priv->print_hold_radio,
gtk_printer_option_has_choice (option, "on-hold"));
update_print_at_option (dialog);
if (strcmp (option->value, "at") == 0)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->print_at_radio),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_at_radio),
TRUE);
else if (strcmp (option->value, "on-hold") == 0)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->print_hold_radio),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_hold_radio),
TRUE);
else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->print_now_radio),
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_now_radio),
TRUE);
- option = gtk_printer_option_set_lookup (dialog->priv->options, "gtk-print-time-text");
+ option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time-text");
if (option != NULL)
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->print_at_entry),
+ gtk_entry_set_text (GTK_ENTRY (priv->print_at_entry),
option->value);
- dialog->priv->updating_print_at = FALSE;
+ priv->updating_print_at = FALSE;
return TRUE;
}
@@ -1029,60 +1042,61 @@ setup_print_at (GtkPrintUnixDialog *dialog)
static void
update_dialog_from_settings (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GList *groups, *l;
char *group;
GtkWidget *table, *frame;
gboolean has_advanced, has_job;
- if (dialog->priv->current_printer == NULL)
+ if (priv->current_printer == NULL)
{
clear_per_printer_ui (dialog);
- gtk_widget_hide (dialog->priv->job_page);
- gtk_widget_hide (dialog->priv->advanced_page);
- gtk_widget_hide (dialog->priv->image_quality_page);
- gtk_widget_hide (dialog->priv->finishing_page);
- gtk_widget_hide (dialog->priv->color_page);
+ gtk_widget_hide (priv->job_page);
+ gtk_widget_hide (priv->advanced_page);
+ gtk_widget_hide (priv->image_quality_page);
+ gtk_widget_hide (priv->finishing_page);
+ gtk_widget_hide (priv->color_page);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
return;
}
- setup_option (dialog, "gtk-n-up", dialog->priv->pages_per_sheet);
- setup_option (dialog, "gtk-duplex", dialog->priv->duplex);
- setup_option (dialog, "gtk-paper-type", dialog->priv->paper_type);
- setup_option (dialog, "gtk-paper-source", dialog->priv->paper_source);
- setup_option (dialog, "gtk-output-tray", dialog->priv->output_tray);
+ setup_option (dialog, "gtk-n-up", priv->pages_per_sheet);
+ setup_option (dialog, "gtk-duplex", priv->duplex);
+ setup_option (dialog, "gtk-paper-type", priv->paper_type);
+ setup_option (dialog, "gtk-paper-source", priv->paper_source);
+ setup_option (dialog, "gtk-output-tray", priv->output_tray);
has_job = FALSE;
- has_job |= setup_option (dialog, "gtk-job-prio", dialog->priv->job_prio);
- has_job |= setup_option (dialog, "gtk-billing-info", dialog->priv->billing_info);
- has_job |= setup_option (dialog, "gtk-cover-before", dialog->priv->cover_before);
- has_job |= setup_option (dialog, "gtk-cover-after", dialog->priv->cover_after);
+ has_job |= setup_option (dialog, "gtk-job-prio", priv->job_prio);
+ has_job |= setup_option (dialog, "gtk-billing-info", priv->billing_info);
+ has_job |= setup_option (dialog, "gtk-cover-before", priv->cover_before);
+ has_job |= setup_option (dialog, "gtk-cover-after", priv->cover_after);
has_job |= setup_print_at (dialog);
if (has_job)
- gtk_widget_show (dialog->priv->job_page);
+ gtk_widget_show (priv->job_page);
else
- gtk_widget_hide (dialog->priv->job_page);
+ gtk_widget_hide (priv->job_page);
- setup_page_table (dialog->priv->options,
+ setup_page_table (priv->options,
"ImageQualityPage",
- dialog->priv->image_quality_table,
- dialog->priv->image_quality_page);
+ priv->image_quality_table,
+ priv->image_quality_page);
- setup_page_table (dialog->priv->options,
+ setup_page_table (priv->options,
"FinishingPage",
- dialog->priv->finishing_table,
- dialog->priv->finishing_page);
+ priv->finishing_table,
+ priv->finishing_page);
- setup_page_table (dialog->priv->options,
+ setup_page_table (priv->options,
"ColorPage",
- dialog->priv->color_table,
- dialog->priv->color_page);
+ priv->color_table,
+ priv->color_page);
/* Put the rest of the groups in the advanced page */
- groups = gtk_printer_option_set_get_groups (dialog->priv->options);
+ groups = gtk_printer_option_set_get_groups (priv->options);
has_advanced = FALSE;
for (l = groups; l != NULL; l = l->next)
@@ -1099,10 +1113,10 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
if (strcmp (group, "GtkPrintDialogExtention") == 0)
{
- gtk_printer_option_set_foreach_in_group (dialog->priv->options,
+ gtk_printer_option_set_foreach_in_group (priv->options,
group,
add_option_to_extension_point,
- dialog->priv->extension_points);
+ priv->extension_points);
continue;
}
@@ -1110,7 +1124,7 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_printer_option_set_foreach_in_group (dialog->priv->options,
+ gtk_printer_option_set_foreach_in_group (priv->options,
group,
add_option_to_table,
table);
@@ -1123,15 +1137,15 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
gtk_widget_show (table);
gtk_widget_show (frame);
- gtk_box_pack_start (GTK_BOX (dialog->priv->advanced_vbox),
+ gtk_box_pack_start (GTK_BOX (priv->advanced_vbox),
frame, FALSE, FALSE, 0);
}
}
if (has_advanced)
- gtk_widget_show (dialog->priv->advanced_page);
+ gtk_widget_show (priv->advanced_page);
else
- gtk_widget_hide (dialog->priv->advanced_page);
+ gtk_widget_hide (priv->advanced_page);
g_list_foreach (groups, (GFunc) g_free, NULL);
@@ -1141,40 +1155,42 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
static void
mark_conflicts (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkPrinter *printer;
gboolean have_conflict;
have_conflict = FALSE;
- printer = dialog->priv->current_printer;
+ printer = priv->current_printer;
if (printer)
{
- g_signal_handler_block (dialog->priv->options,
- dialog->priv->options_changed_handler);
+ g_signal_handler_block (priv->options,
+ priv->options_changed_handler);
- gtk_printer_option_set_clear_conflicts (dialog->priv->options);
+ gtk_printer_option_set_clear_conflicts (priv->options);
have_conflict = _gtk_printer_mark_conflicts (printer,
- dialog->priv->options);
+ priv->options);
- g_signal_handler_unblock (dialog->priv->options,
- dialog->priv->options_changed_handler);
+ g_signal_handler_unblock (priv->options,
+ priv->options_changed_handler);
}
if (have_conflict)
- gtk_widget_show (dialog->priv->conflicts_widget);
+ gtk_widget_show (priv->conflicts_widget);
else
- gtk_widget_hide (dialog->priv->conflicts_widget);
+ gtk_widget_hide (priv->conflicts_widget);
}
static gboolean
mark_conflicts_callback (gpointer data)
{
GtkPrintUnixDialog *dialog = data;
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
- dialog->priv->mark_conflicts_id = 0;
+ priv->mark_conflicts_id = 0;
mark_conflicts (dialog);
@@ -1184,36 +1200,42 @@ mark_conflicts_callback (gpointer data)
static void
unschedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog)
{
- if (dialog->priv->mark_conflicts_id != 0)
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
+ if (priv->mark_conflicts_id != 0)
{
- g_source_remove (dialog->priv->mark_conflicts_id);
- dialog->priv->mark_conflicts_id = 0;
+ g_source_remove (priv->mark_conflicts_id);
+ priv->mark_conflicts_id = 0;
}
}
static void
schedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog)
{
- if (dialog->priv->mark_conflicts_id != 0)
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
+ if (priv->mark_conflicts_id != 0)
return;
- dialog->priv->mark_conflicts_id = g_idle_add (mark_conflicts_callback,
+ priv->mark_conflicts_id = g_idle_add (mark_conflicts_callback,
dialog);
}
static void
options_changed_cb (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
schedule_idle_mark_conflicts (dialog);
- if (dialog->priv->initial_settings)
+ if (priv->initial_settings)
{
- g_object_unref (dialog->priv->initial_settings);
- dialog->priv->initial_settings = NULL;
+ g_object_unref (priv->initial_settings);
+ priv->initial_settings = NULL;
}
- g_free (dialog->priv->waiting_for_printer);
- dialog->priv->waiting_for_printer = NULL;
+ g_free (priv->waiting_for_printer);
+ priv->waiting_for_printer = NULL;
}
static void
@@ -1236,22 +1258,24 @@ extension_point_clear_children (const gchar *key,
static void
clear_per_printer_ui (GtkPrintUnixDialog *dialog)
{
- gtk_container_foreach (GTK_CONTAINER (dialog->priv->finishing_table),
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
+ gtk_container_foreach (GTK_CONTAINER (priv->finishing_table),
(GtkCallback)gtk_widget_destroy,
NULL);
- gtk_table_resize (GTK_TABLE (dialog->priv->finishing_table), 1, 2);
- gtk_container_foreach (GTK_CONTAINER (dialog->priv->image_quality_table),
+ gtk_table_resize (GTK_TABLE (priv->finishing_table), 1, 2);
+ gtk_container_foreach (GTK_CONTAINER (priv->image_quality_table),
(GtkCallback)gtk_widget_destroy,
NULL);
- gtk_table_resize (GTK_TABLE (dialog->priv->image_quality_table), 1, 2);
- gtk_container_foreach (GTK_CONTAINER (dialog->priv->color_table),
+ gtk_table_resize (GTK_TABLE (priv->image_quality_table), 1, 2);
+ gtk_container_foreach (GTK_CONTAINER (priv->color_table),
(GtkCallback)gtk_widget_destroy,
NULL);
- gtk_table_resize (GTK_TABLE (dialog->priv->color_table), 1, 2);
- gtk_container_foreach (GTK_CONTAINER (dialog->priv->advanced_vbox),
+ gtk_table_resize (GTK_TABLE (priv->color_table), 1, 2);
+ gtk_container_foreach (GTK_CONTAINER (priv->advanced_vbox),
(GtkCallback)gtk_widget_destroy,
NULL);
- g_hash_table_foreach (dialog->priv->extension_points,
+ g_hash_table_foreach (priv->extension_points,
(GHFunc) extension_point_clear_children,
NULL);
}
@@ -1261,12 +1285,14 @@ printer_details_acquired (GtkPrinter *printer,
gboolean success,
GtkPrintUnixDialog *dialog)
{
- dialog->priv->request_details_tag = 0;
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
+ priv->request_details_tag = 0;
if (success)
{
GtkTreeSelection *selection;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->printer_treeview));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
selected_printer_changed (selection, dialog);
}
@@ -1276,32 +1302,33 @@ static void
selected_printer_changed (GtkTreeSelection *selection,
GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkPrinter *printer;
GtkTreeIter iter, filter_iter;
/* Whenever the user selects a printer we stop looking for
the printer specified in the initial settings */
- if (dialog->priv->waiting_for_printer &&
- !dialog->priv->internal_printer_change)
+ if (priv->waiting_for_printer &&
+ !priv->internal_printer_change)
{
- 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;
}
printer = NULL;
if (gtk_tree_selection_get_selected (selection, NULL, &filter_iter))
{
- gtk_tree_model_filter_convert_iter_to_child_iter (dialog->priv->printer_list_filter,
+ gtk_tree_model_filter_convert_iter_to_child_iter (priv->printer_list_filter,
&iter,
&filter_iter);
- gtk_tree_model_get (dialog->priv->printer_list, &iter,
+ gtk_tree_model_get (priv->printer_list, &iter,
PRINTER_LIST_COL_PRINTER_OBJ, &printer,
-1);
}
@@ -1309,43 +1336,43 @@ selected_printer_changed (GtkTreeSelection *selection,
if (printer != NULL && !_gtk_printer_has_details (printer))
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
- dialog->priv->request_details_tag =
+ priv->request_details_tag =
g_signal_connect (printer, "details-acquired",
G_CALLBACK (printer_details_acquired), dialog);
_gtk_printer_request_details (printer);
return;
}
- if (printer == dialog->priv->current_printer)
+ if (printer == priv->current_printer)
{
if (printer)
g_object_unref (printer);
return;
}
- if (dialog->priv->options)
+ if (priv->options)
{
- g_object_unref (dialog->priv->options);
- dialog->priv->options = NULL;
+ g_object_unref (priv->options);
+ priv->options = NULL;
clear_per_printer_ui (dialog);
}
- if (dialog->priv->current_printer)
+ if (priv->current_printer)
{
- g_object_unref (dialog->priv->current_printer);
+ g_object_unref (priv->current_printer);
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
- dialog->priv->current_printer = printer;
+ priv->current_printer = printer;
if (printer != NULL)
{
- dialog->priv->options = _gtk_printer_get_options (printer, dialog->priv->initial_settings,
- dialog->priv->page_setup);
+ priv->options = _gtk_printer_get_options (printer, priv->initial_settings,
+ priv->page_setup);
- dialog->priv->options_changed_handler =
- g_signal_connect_swapped (dialog->priv->options, "changed", G_CALLBACK (options_changed_cb), dialog);
+ priv->options_changed_handler =
+ g_signal_connect_swapped (priv->options, "changed", G_CALLBACK (options_changed_cb), dialog);
}
update_dialog_from_settings (dialog);
@@ -1355,12 +1382,13 @@ static void
update_collate_icon (GtkToggleButton *toggle_button,
GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GdkPixbuf *pixbuf;
gboolean collate, reverse;
const char **xpm;
- collate = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->collate_check));
- reverse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->reverse_check));
+ collate = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->collate_check));
+ reverse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reverse_check));
if (collate)
{
@@ -1378,7 +1406,7 @@ update_collate_icon (GtkToggleButton *toggle_button,
}
pixbuf = gdk_pixbuf_new_from_xpm_data (xpm);
- gtk_image_set_from_pixbuf (GTK_IMAGE (dialog->priv->collate_image), pixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->collate_image), pixbuf);
g_object_unref (pixbuf);
}
@@ -1460,7 +1488,7 @@ create_main_page (GtkPrintUnixDialog *dialog)
custom_input = gtk_hbox_new (FALSE, 18);
gtk_widget_show (custom_input);
gtk_box_pack_start (GTK_BOX (vbox), custom_input, FALSE, FALSE, 0);
- g_hash_table_insert (dialog->priv->extension_points,
+ g_hash_table_insert (priv->extension_points,
_EXTENTION_POINT_MAIN_PAGE_CUSTOM_INPUT,
custom_input);
@@ -1483,7 +1511,7 @@ create_main_page (GtkPrintUnixDialog *dialog)
0, 0);
radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)),
_("C_urrent"));
- if (dialog->priv->current_page == -1)
+ if (priv->current_page == -1)
gtk_widget_set_sensitive (radio, FALSE);
priv->current_page_radio = radio;
gtk_widget_show (radio);
@@ -1542,7 +1570,7 @@ create_main_page (GtkPrintUnixDialog *dialog)
0, 0);
image = gtk_image_new ();
- dialog->priv->collate_image = image;
+ priv->collate_image = image;
gtk_widget_show (image);
gtk_table_attach (GTK_TABLE (table), image,
1, 2, 1, 3, GTK_FILL, 0,
@@ -1567,13 +1595,14 @@ static GtkPageRange *
dialog_get_page_ranges (GtkPrintUnixDialog *dialog,
gint *n_ranges_out)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
int i, n_ranges;
const char *text, *p;
char *next;
GtkPageRange *ranges;
int start, end;
- text = gtk_entry_get_text (GTK_ENTRY (dialog->priv->page_range_entry));
+ text = gtk_entry_get_text (GTK_ENTRY (priv->page_range_entry));
if (*text == 0)
{
@@ -1637,6 +1666,7 @@ dialog_set_page_ranges (GtkPrintUnixDialog *dialog,
GtkPageRange *ranges,
gint n_ranges)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
int i;
GString *s = g_string_new ("");
@@ -1650,7 +1680,7 @@ dialog_set_page_ranges (GtkPrintUnixDialog *dialog,
g_string_append (s, ",");
}
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->page_range_entry),
+ gtk_entry_set_text (GTK_ENTRY (priv->page_range_entry),
s->str);
g_string_free (s, TRUE);
@@ -1756,10 +1786,11 @@ dialog_set_reverse (GtkPrintUnixDialog *dialog,
static gint
dialog_get_pages_per_sheet (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
const char *val;
int num;
- val = gtk_printer_option_widget_get_value (dialog->priv->pages_per_sheet);
+ val = gtk_printer_option_widget_get_value (priv->pages_per_sheet);
num = 1;
@@ -1779,6 +1810,7 @@ draw_page_cb (GtkWidget *widget,
GdkEventExpose *event,
GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
cairo_t *cr;
double ratio;
int w, h, tmp, shadow_offset;
@@ -1790,7 +1822,7 @@ draw_page_cb (GtkWidget *widget,
PangoFontDescription *font;
char *text;
- orientation = gtk_page_setup_get_orientation (dialog->priv->page_setup);
+ orientation = gtk_page_setup_get_orientation (priv->page_setup);
landscape =
(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE) ||
(orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE);
@@ -1894,8 +1926,10 @@ draw_page_cb (GtkWidget *widget,
static void
redraw_page_layout_preview (GtkPrintUnixDialog *dialog)
{
- if (dialog->priv->page_layout_preview)
- gtk_widget_queue_draw (dialog->priv->page_layout_preview);
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+
+ if (priv->page_layout_preview)
+ gtk_widget_queue_draw (priv->page_layout_preview);
}
static void
@@ -2054,7 +2088,7 @@ create_page_setup_page (GtkPrintUnixDialog *dialog)
gtk_box_pack_start (GTK_BOX (main_vbox), hbox2, TRUE, TRUE, 0);
draw = gtk_drawing_area_new ();
- dialog->priv->page_layout_preview = draw;
+ priv->page_layout_preview = draw;
gtk_widget_set_size_request (draw, 200, 200);
g_signal_connect (draw, "expose_event", G_CALLBACK (draw_page_cb), dialog);
gtk_widget_show (draw);
@@ -2270,7 +2304,7 @@ create_advanced_page (GtkPrintUnixDialog *dialog)
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN(scrolled)->child),
GTK_SHADOW_NONE);
- dialog->priv->advanced_vbox = main_vbox;
+ priv->advanced_vbox = main_vbox;
label = gtk_label_new (_("Advanced"));
gtk_widget_show (label);
@@ -2408,13 +2442,17 @@ void
gtk_print_unix_dialog_set_page_setup (GtkPrintUnixDialog *dialog,
GtkPageSetup *page_setup)
{
+ GtkPrintUnixDialogPrivate *priv;
+
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
- if (dialog->priv->page_setup != page_setup)
+ priv = dialog->priv;
+
+ if (priv->page_setup != page_setup)
{
- g_object_unref (dialog->priv->page_setup);
- dialog->priv->page_setup = g_object_ref (page_setup);
+ g_object_unref (priv->page_setup);
+ priv->page_setup = g_object_ref (page_setup);
g_object_notify (G_OBJECT (dialog), "page-setup");
}
@@ -2452,14 +2490,18 @@ void
gtk_print_unix_dialog_set_current_page (GtkPrintUnixDialog *dialog,
gint current_page)
{
+ GtkPrintUnixDialogPrivate *priv;
+
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
- if (dialog->priv->current_page != current_page)
+ priv = dialog->priv;
+
+ if (priv->current_page != current_page)
{
- dialog->priv->current_page = current_page;
+ priv->current_page = current_page;
- if (dialog->priv->current_page_radio)
- gtk_widget_set_sensitive (dialog->priv->current_page_radio, current_page != -1);
+ if (priv->current_page_radio)
+ gtk_widget_set_sensitive (priv->current_page_radio, current_page != -1);
g_object_notify (G_OBJECT (dialog), "current-page");
}
@@ -2487,33 +2529,34 @@ static gboolean
set_active_printer (GtkPrintUnixDialog *dialog,
const gchar *printer_name)
{
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
GtkTreeModel *model;
GtkTreeIter iter, filter_iter;
GtkTreeSelection *selection;
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_OBJ, &printer, -1);
if (printer == NULL)
continue;
if (strcmp (gtk_printer_get_name (printer), printer_name) == 0)
{
- gtk_tree_model_filter_convert_child_iter_to_iter (dialog->priv->printer_list_filter,
+ gtk_tree_model_filter_convert_child_iter_to_iter (priv->printer_list_filter,
&filter_iter, &iter);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->printer_treeview));
- dialog->priv->internal_printer_change = TRUE;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
+ priv->internal_printer_change = TRUE;
gtk_tree_selection_select_iter (selection, &filter_iter);
- dialog->priv->internal_printer_change = FALSE;
- g_free (dialog->priv->waiting_for_printer);
- dialog->priv->waiting_for_printer = NULL;
+ priv->internal_printer_change = FALSE;
+ g_free (priv->waiting_for_printer);
+ priv->waiting_for_printer = NULL;
g_object_unref (printer);
return TRUE;
@@ -2542,6 +2585,7 @@ void
gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
GtkPrintSettings *settings)
{
+ GtkPrintUnixDialogPrivate *priv;
const char *printer;
GtkPageRange *ranges;
int num_ranges;
@@ -2549,6 +2593,8 @@ gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
g_return_if_fail (settings == NULL || GTK_IS_PRINT_SETTINGS (settings));
+ priv = dialog->priv;
+
if (settings != NULL)
{
dialog_set_collate (dialog, gtk_print_settings_get_collate (settings));
@@ -2561,17 +2607,17 @@ gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
if (ranges)
dialog_set_page_ranges (dialog, ranges, num_ranges);
- dialog->priv->format_for_printer =
+ priv->format_for_printer =
g_strdup (gtk_print_settings_get (settings, "format-for-printer"));
}
- if (dialog->priv->initial_settings)
- g_object_unref (dialog->priv->initial_settings);
+ if (priv->initial_settings)
+ g_object_unref (priv->initial_settings);
- dialog->priv->initial_settings = settings;
+ priv->initial_settings = settings;
- 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 (settings)
{
@@ -2580,7 +2626,7 @@ gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
printer = gtk_print_settings_get_printer (settings);
if (printer && !set_active_printer (dialog, printer))
- dialog->priv->waiting_for_printer = g_strdup (printer);
+ priv->waiting_for_printer = g_strdup (printer);
}
g_object_notify (G_OBJECT (dialog), "print-settings");
@@ -2602,6 +2648,7 @@ gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
GtkPrintSettings *
gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog)
{
+ GtkPrintUnixDialogPrivate *priv;
GtkPrintSettings *settings;
GtkPrintPages print_pages;
GtkPageRange *ranges;
@@ -2609,16 +2656,17 @@ gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog)
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), NULL);
+ priv = dialog->priv;
settings = gtk_print_settings_new ();
- if (dialog->priv->current_printer)
+ if (priv->current_printer)
gtk_print_settings_set_printer (settings,
- gtk_printer_get_name (dialog->priv->current_printer));
+ gtk_printer_get_name (priv->current_printer));
else
gtk_print_settings_set_printer (settings, "default");
gtk_print_settings_set (settings, "format-for-printer",
- dialog->priv->format_for_printer);
+ priv->format_for_printer);
gtk_print_settings_set_collate (settings,
@@ -2648,9 +2696,9 @@ gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog)
/* TODO: print when. How to handle? */
- if (dialog->priv->current_printer)
- _gtk_printer_get_settings_from_options (dialog->priv->current_printer,
- dialog->priv->options,
+ if (priv->current_printer)
+ _gtk_printer_get_settings_from_options (priv->current_printer,
+ priv->options,
settings);
return settings;