2006-04-21 15:09:32 +00:00
|
|
|
/* GtkPrintUnixDialog
|
|
|
|
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
|
|
|
* Copyright (C) 2006 Alexander Larsson <alexl@redhat.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
|
|
|
#include "gtkspinbutton.h"
|
|
|
|
#include "gtkcellrendererpixbuf.h"
|
|
|
|
#include "gtkcellrenderertext.h"
|
|
|
|
#include "gtkstock.h"
|
2006-05-03 20:18:38 +00:00
|
|
|
#include "gtkiconfactory.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
#include "gtkimage.h"
|
|
|
|
#include "gtktreeselection.h"
|
|
|
|
#include "gtknotebook.h"
|
|
|
|
#include "gtkscrolledwindow.h"
|
|
|
|
#include "gtkcombobox.h"
|
|
|
|
#include "gtktogglebutton.h"
|
|
|
|
#include "gtkradiobutton.h"
|
|
|
|
#include "gtkdrawingarea.h"
|
|
|
|
#include "gtkvbox.h"
|
|
|
|
#include "gtktable.h"
|
|
|
|
#include "gtkframe.h"
|
|
|
|
#include "gtkalignment.h"
|
|
|
|
#include "gtklabel.h"
|
2006-12-20 04:39:52 +00:00
|
|
|
#include "gtktooltips.h"
|
|
|
|
#include "gtkeventbox.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
#include "gtkprintbackend.h"
|
2006-06-08 17:01:28 +00:00
|
|
|
#include "gtkprinter-private.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
#include "gtkprintunixdialog.h"
|
|
|
|
#include "gtkprinteroptionwidget.h"
|
|
|
|
#include "gtkalias.h"
|
|
|
|
|
|
|
|
#define EXAMPLE_PAGE_AREA_SIZE 140
|
|
|
|
|
|
|
|
#define GTK_PRINT_UNIX_DIALOG_GET_PRIVATE(o) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_UNIX_DIALOG, GtkPrintUnixDialogPrivate))
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
static void gtk_print_unix_dialog_destroy (GtkPrintUnixDialog *dialog);
|
|
|
|
static void gtk_print_unix_dialog_finalize (GObject *object);
|
|
|
|
static void gtk_print_unix_dialog_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_print_unix_dialog_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_print_unix_dialog_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *previous_style);
|
|
|
|
static void populate_dialog (GtkPrintUnixDialog *dialog);
|
|
|
|
static void unschedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog);
|
|
|
|
static void selected_printer_changed (GtkTreeSelection *selection,
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
static void clear_per_printer_ui (GtkPrintUnixDialog *dialog);
|
|
|
|
static void printer_added_cb (GtkPrintBackend *backend,
|
|
|
|
GtkPrinter *printer,
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
static void printer_removed_cb (GtkPrintBackend *backend,
|
|
|
|
GtkPrinter *printer,
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
static void printer_status_cb (GtkPrintBackend *backend,
|
|
|
|
GtkPrinter *printer,
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
static void update_collate_icon (GtkToggleButton *toggle_button,
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
static gboolean dialog_get_collate (GtkPrintUnixDialog *dialog);
|
|
|
|
static gboolean dialog_get_reverse (GtkPrintUnixDialog *dialog);
|
2006-12-20 04:39:52 +00:00
|
|
|
static gint dialog_get_n_copies (GtkPrintUnixDialog *dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_PAGE_SETUP,
|
|
|
|
PROP_CURRENT_PAGE,
|
|
|
|
PROP_PRINT_SETTINGS,
|
|
|
|
PROP_SELECTED_PRINTER
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PRINTER_LIST_COL_ICON,
|
|
|
|
PRINTER_LIST_COL_NAME,
|
|
|
|
PRINTER_LIST_COL_STATE,
|
|
|
|
PRINTER_LIST_COL_JOBS,
|
|
|
|
PRINTER_LIST_COL_LOCATION,
|
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ,
|
|
|
|
PRINTER_LIST_N_COLS
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GtkPrintUnixDialogPrivate
|
|
|
|
{
|
|
|
|
GtkWidget *notebook;
|
|
|
|
|
|
|
|
GtkWidget *printer_treeview;
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
|
|
GtkPrintCapabilities manual_capabilities;
|
|
|
|
GtkPrintCapabilities printer_capabilities;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
GtkTreeModel *printer_list;
|
|
|
|
GtkTreeModelFilter *printer_list_filter;
|
|
|
|
|
|
|
|
GtkPageSetup *page_setup;
|
|
|
|
|
2006-12-20 04:39:52 +00:00
|
|
|
GtkTooltips *tooltips;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *all_pages_radio;
|
|
|
|
GtkWidget *current_page_radio;
|
|
|
|
GtkWidget *page_range_radio;
|
|
|
|
GtkWidget *page_range_entry;
|
|
|
|
|
|
|
|
GtkWidget *copies_spin;
|
|
|
|
GtkWidget *collate_check;
|
|
|
|
GtkWidget *reverse_check;
|
|
|
|
GtkWidget *collate_image;
|
|
|
|
GtkWidget *page_layout_preview;
|
|
|
|
GtkWidget *scale_spin;
|
|
|
|
GtkWidget *page_set_combo;
|
|
|
|
GtkWidget *print_now_radio;
|
|
|
|
GtkWidget *print_at_radio;
|
|
|
|
GtkWidget *print_at_entry;
|
|
|
|
GtkWidget *print_hold_radio;
|
2006-06-30 10:32:56 +00:00
|
|
|
GtkWidget *preview_button;
|
2006-04-21 15:09:32 +00:00
|
|
|
gboolean updating_print_at;
|
|
|
|
GtkPrinterOptionWidget *pages_per_sheet;
|
|
|
|
GtkPrinterOptionWidget *duplex;
|
|
|
|
GtkPrinterOptionWidget *paper_type;
|
|
|
|
GtkPrinterOptionWidget *paper_source;
|
|
|
|
GtkPrinterOptionWidget *output_tray;
|
|
|
|
GtkPrinterOptionWidget *job_prio;
|
|
|
|
GtkPrinterOptionWidget *billing_info;
|
|
|
|
GtkPrinterOptionWidget *cover_before;
|
|
|
|
GtkPrinterOptionWidget *cover_after;
|
|
|
|
|
|
|
|
GtkWidget *conflicts_widget;
|
|
|
|
|
|
|
|
GtkWidget *job_page;
|
|
|
|
GtkWidget *finishing_table;
|
|
|
|
GtkWidget *finishing_page;
|
|
|
|
GtkWidget *image_quality_table;
|
|
|
|
GtkWidget *image_quality_page;
|
|
|
|
GtkWidget *color_table;
|
|
|
|
GtkWidget *color_page;
|
|
|
|
|
|
|
|
GtkWidget *advanced_vbox;
|
|
|
|
GtkWidget *advanced_page;
|
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
GtkWidget *extension_point;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
/* These are set initially on selected printer (either default printer,
|
|
|
|
* printer taken from set settings, or user-selected), but when any setting
|
|
|
|
* is changed by the user it is cleared.
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrintSettings *initial_settings;
|
|
|
|
|
|
|
|
/* This is the initial printer set by set_settings. We look for it in the
|
|
|
|
* added printers. We clear this whenever the user manually changes
|
|
|
|
* to another printer, when the user changes a setting or when we find
|
2006-06-12 04:39:55 +00:00
|
|
|
* this printer.
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
char *waiting_for_printer;
|
|
|
|
gboolean internal_printer_change;
|
|
|
|
|
|
|
|
GList *print_backends;
|
|
|
|
|
|
|
|
GtkPrinter *current_printer;
|
|
|
|
guint request_details_tag;
|
|
|
|
GtkPrinterOptionSet *options;
|
|
|
|
gulong options_changed_handler;
|
|
|
|
gulong mark_conflicts_id;
|
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
gchar *format_for_printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
gint current_page;
|
|
|
|
};
|
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkPrintUnixDialog, gtk_print_unix_dialog, GTK_TYPE_DIALOG)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_default_printer (GtkPrintUnixDialog *dialog,
|
2006-06-12 04:39:55 +00:00
|
|
|
GtkPrinter *printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
if (priv->format_for_printer)
|
|
|
|
return strcmp (priv->format_for_printer,
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_get_name (printer)) == 0;
|
|
|
|
else
|
|
|
|
return gtk_printer_is_default (printer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_class_init (GtkPrintUnixDialogClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
object_class = (GObjectClass *) class;
|
|
|
|
widget_class = (GtkWidgetClass *) class;
|
|
|
|
|
|
|
|
object_class->finalize = gtk_print_unix_dialog_finalize;
|
|
|
|
object_class->set_property = gtk_print_unix_dialog_set_property;
|
|
|
|
object_class->get_property = gtk_print_unix_dialog_get_property;
|
|
|
|
|
2006-05-03 20:18:38 +00:00
|
|
|
widget_class->style_set = gtk_print_unix_dialog_style_set;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_PAGE_SETUP,
|
|
|
|
g_param_spec_object ("page-setup",
|
|
|
|
P_("Page Setup"),
|
|
|
|
P_("The GtkPageSetup to use"),
|
|
|
|
GTK_TYPE_PAGE_SETUP,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_CURRENT_PAGE,
|
|
|
|
g_param_spec_int ("current-page",
|
|
|
|
P_("Current Page"),
|
|
|
|
P_("The current page in the document"),
|
|
|
|
-1,
|
|
|
|
G_MAXINT,
|
|
|
|
-1,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_PRINT_SETTINGS,
|
|
|
|
g_param_spec_object ("print-settings",
|
|
|
|
P_("Print Settings"),
|
|
|
|
P_("The GtkPrintSettings used for initializing the dialog"),
|
|
|
|
GTK_TYPE_PRINT_SETTINGS,
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_SELECTED_PRINTER,
|
|
|
|
g_param_spec_object ("selected-printer",
|
|
|
|
P_("Selected Printer"),
|
2006-05-08 00:08:39 +00:00
|
|
|
P_("The GtkPrinter which is selected"),
|
2006-04-21 15:09:32 +00:00
|
|
|
GTK_TYPE_PRINTER,
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
2006-05-12 09:47:58 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
g_type_class_add_private (class, sizeof (GtkPrintUnixDialogPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = dialog->priv = GTK_PRINT_UNIX_DIALOG_GET_PRIVATE (dialog);
|
|
|
|
priv->print_backends = NULL;
|
|
|
|
priv->current_page = -1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-12-20 04:39:52 +00:00
|
|
|
priv->tooltips = gtk_tooltips_new ();
|
|
|
|
g_object_ref_sink (priv->tooltips);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->page_setup = gtk_page_setup_new ();
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_signal_connect (dialog,
|
|
|
|
"destroy",
|
|
|
|
(GCallback) gtk_print_unix_dialog_destroy,
|
|
|
|
NULL);
|
|
|
|
|
2006-06-30 10:32:56 +00:00
|
|
|
priv->preview_button = gtk_button_new_from_stock (GTK_STOCK_PRINT_PREVIEW);
|
|
|
|
gtk_widget_show (priv->preview_button);
|
|
|
|
|
|
|
|
gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
|
|
|
|
priv->preview_button,
|
|
|
|
GTK_RESPONSE_APPLY);
|
2006-06-02 15:16:13 +00:00
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
2006-04-21 15:09:32 +00:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_PRINT, GTK_RESPONSE_OK,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
|
2006-05-12 09:47:58 +00:00
|
|
|
|
2006-05-12 16:06:53 +00:00
|
|
|
populate_dialog (dialog);
|
2006-05-12 09:47:58 +00:00
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_destroy (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
/* Make sure we don't destroy custom widgets owned by the backends */
|
|
|
|
clear_per_printer_ui (dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-05-04 13:43:32 +00:00
|
|
|
GtkPrintBackend *backend;
|
|
|
|
GList *node;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
unschedule_idle_mark_conflicts (dialog);
|
|
|
|
|
2006-12-20 04:39:52 +00:00
|
|
|
if (priv->tooltips)
|
|
|
|
{
|
|
|
|
g_object_unref (priv->tooltips);
|
|
|
|
priv->tooltips = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->request_details_tag)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_source_remove (priv->request_details_tag);
|
|
|
|
priv->request_details_tag = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->current_printer);
|
|
|
|
priv->current_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->printer_list)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->printer_list);
|
|
|
|
priv->printer_list = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->printer_list_filter)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->printer_list_filter);
|
|
|
|
priv->printer_list_filter = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->options)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->options);
|
|
|
|
priv->options = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
if (priv->page_setup)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->page_setup);
|
|
|
|
priv->page_setup = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->initial_settings)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->initial_settings);
|
|
|
|
priv->initial_settings = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_free (priv->waiting_for_printer);
|
|
|
|
priv->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_free (priv->format_for_printer);
|
|
|
|
priv->format_for_printer = NULL;
|
|
|
|
|
2006-05-04 13:43:32 +00:00
|
|
|
for (node = priv->print_backends; node != NULL; node = node->next)
|
|
|
|
{
|
|
|
|
backend = GTK_PRINT_BACKEND (node->data);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (backend, printer_added_cb, dialog);
|
|
|
|
g_signal_handlers_disconnect_by_func (backend, printer_removed_cb, dialog);
|
|
|
|
g_signal_handlers_disconnect_by_func (backend, printer_status_cb, dialog);
|
|
|
|
|
|
|
|
gtk_print_backend_destroy (backend);
|
|
|
|
g_object_unref (backend);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (priv->print_backends);
|
|
|
|
priv->print_backends = NULL;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->finalize (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_removed_cb (GtkPrintBackend *backend,
|
|
|
|
GtkPrinter *printer,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkTreeIter *iter;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_list_store_remove (GTK_LIST_STORE (priv->printer_list), iter);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_status_cb (GtkPrintBackend *backend,
|
|
|
|
GtkPrinter *printer,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkTreeIter *iter;
|
2006-05-02 12:48:52 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->printer_list), iter,
|
2006-04-21 15:09:32 +00:00
|
|
|
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),
|
|
|
|
PRINTER_LIST_COL_LOCATION, gtk_printer_get_location (printer),
|
|
|
|
-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_added_cb (GtkPrintBackend *backend,
|
|
|
|
GtkPrinter *printer,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkTreeIter iter, filter_iter;
|
|
|
|
GtkTreeSelection *selection;
|
2007-03-16 05:13:10 +00:00
|
|
|
GtkTreePath *path;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (priv->printer_list), &iter);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (printer),
|
|
|
|
"gtk-print-tree-iter",
|
|
|
|
gtk_tree_iter_copy (&iter),
|
|
|
|
(GDestroyNotify) gtk_tree_iter_free);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (priv->printer_list), &iter,
|
2006-04-21 15:09:32 +00:00
|
|
|
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),
|
|
|
|
PRINTER_LIST_COL_JOBS, gtk_printer_get_job_count (printer),
|
|
|
|
PRINTER_LIST_COL_LOCATION, gtk_printer_get_location (printer),
|
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ, printer,
|
|
|
|
-1);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_tree_model_filter_convert_child_iter_to_iter (priv->printer_list_filter,
|
2006-04-21 15:09:32 +00:00
|
|
|
&filter_iter, &iter);
|
2007-03-16 05:13:10 +00:00
|
|
|
path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->printer_list_filter), &filter_iter);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->waiting_for_printer != NULL &&
|
2006-04-21 15:09:32 +00:00
|
|
|
strcmp (gtk_printer_get_name (printer),
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->waiting_for_printer) == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->internal_printer_change = TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_tree_selection_select_iter (selection, &filter_iter);
|
2007-03-16 05:13:10 +00:00
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->printer_treeview),
|
|
|
|
path, NULL, TRUE, 0.5, 0.0);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->internal_printer_change = FALSE;
|
|
|
|
g_free (priv->waiting_for_printer);
|
|
|
|
priv->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
else if (is_default_printer (dialog, printer) &&
|
|
|
|
gtk_tree_selection_count_selected_rows (selection) == 0)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->internal_printer_change = TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_tree_selection_select_iter (selection, &filter_iter);
|
2007-03-16 05:13:10 +00:00
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->printer_treeview),
|
|
|
|
path, NULL, TRUE, 0.5, 0.0);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->internal_printer_change = FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
2007-03-16 05:13:10 +00:00
|
|
|
|
|
|
|
gtk_tree_path_free (path);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_list_initialize (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPrintBackend *print_backend)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
GList *node;
|
|
|
|
|
|
|
|
g_return_if_fail (print_backend != NULL);
|
|
|
|
|
|
|
|
g_signal_connect_object (print_backend,
|
|
|
|
"printer-added",
|
|
|
|
(GCallback) printer_added_cb,
|
|
|
|
G_OBJECT (dialog), 0);
|
|
|
|
|
|
|
|
g_signal_connect_object (print_backend,
|
|
|
|
"printer-removed",
|
|
|
|
(GCallback) printer_removed_cb,
|
|
|
|
G_OBJECT (dialog), 0);
|
|
|
|
|
|
|
|
g_signal_connect_object (print_backend,
|
|
|
|
"printer-status-changed",
|
|
|
|
(GCallback) printer_status_cb,
|
|
|
|
G_OBJECT (dialog), 0);
|
|
|
|
|
|
|
|
list = gtk_print_backend_get_printer_list (print_backend);
|
|
|
|
|
|
|
|
node = list;
|
|
|
|
while (node != NULL)
|
|
|
|
{
|
|
|
|
printer_added_cb (print_backend, node->data, dialog);
|
|
|
|
node = node->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_print_backends (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GList *node;
|
|
|
|
|
|
|
|
if (g_module_supported ())
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->print_backends = gtk_print_backend_load_modules ();
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
for (node = priv->print_backends; node != NULL; node = node->next)
|
2006-04-21 15:09:32 +00:00
|
|
|
printer_list_initialize (dialog, GTK_PRINT_BACKEND (node->data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
|
|
|
{
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PAGE_SETUP:
|
|
|
|
gtk_print_unix_dialog_set_page_setup (dialog, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
case PROP_CURRENT_PAGE:
|
|
|
|
gtk_print_unix_dialog_set_current_page (dialog, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
case PROP_PRINT_SETTINGS:
|
|
|
|
gtk_print_unix_dialog_set_settings (dialog, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PAGE_SETUP:
|
2006-05-02 12:48:52 +00:00
|
|
|
g_value_set_object (value, priv->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
|
|
|
case PROP_CURRENT_PAGE:
|
2006-05-02 12:48:52 +00:00
|
|
|
g_value_set_int (value, priv->current_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
|
|
|
case PROP_PRINT_SETTINGS:
|
|
|
|
g_value_set_object (value, gtk_print_unix_dialog_get_settings (dialog));
|
|
|
|
break;
|
|
|
|
case PROP_SELECTED_PRINTER:
|
2006-05-02 12:48:52 +00:00
|
|
|
g_value_set_object (value, priv->current_printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_printer_active (GtkTreeModel *model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
gboolean result;
|
|
|
|
GtkPrinter *printer;
|
2006-06-12 16:47:41 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
gtk_tree_model_get (model,
|
|
|
|
iter,
|
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ,
|
|
|
|
&printer,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (printer == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
result = gtk_printer_is_active (printer);
|
2006-06-12 16:47:41 +00:00
|
|
|
|
2006-06-19 04:21:22 +00:00
|
|
|
if (result &&
|
|
|
|
priv->manual_capabilities & (GTK_PRINT_CAPABILITY_GENERATE_PDF |
|
|
|
|
GTK_PRINT_CAPABILITY_GENERATE_PS))
|
2006-06-12 16:47:41 +00:00
|
|
|
{
|
2006-06-19 04:21:22 +00:00
|
|
|
/* Check that the printer can handle at least one of the data
|
|
|
|
* formats that the application supports.
|
|
|
|
*/
|
|
|
|
result = ((priv->manual_capabilities & GTK_PRINT_CAPABILITY_GENERATE_PDF) &&
|
|
|
|
gtk_printer_accepts_pdf (printer)) ||
|
|
|
|
((priv->manual_capabilities & GTK_PRINT_CAPABILITY_GENERATE_PS) &&
|
|
|
|
gtk_printer_accepts_ps (printer));
|
2006-06-12 16:47:41 +00:00
|
|
|
}
|
2006-06-12 17:45:49 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
g_object_unref (printer);
|
2006-06-12 17:45:49 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
default_printer_list_sort_func (GtkTreeModel *model,
|
|
|
|
GtkTreeIter *a,
|
|
|
|
GtkTreeIter *b,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gchar *a_name;
|
|
|
|
gchar *b_name;
|
|
|
|
GtkPrinter *a_printer;
|
|
|
|
GtkPrinter *b_printer;
|
|
|
|
gint result;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, a,
|
|
|
|
PRINTER_LIST_COL_NAME, &a_name,
|
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ, &a_printer,
|
|
|
|
-1);
|
|
|
|
gtk_tree_model_get (model, b,
|
|
|
|
PRINTER_LIST_COL_NAME, &b_name,
|
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ, &b_printer,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (a_printer == NULL && b_printer == NULL)
|
|
|
|
result = 0;
|
|
|
|
else if (a_printer == NULL)
|
|
|
|
result = G_MAXINT;
|
|
|
|
else if (b_printer == NULL)
|
|
|
|
result = G_MININT;
|
|
|
|
else if (gtk_printer_is_virtual (a_printer) && gtk_printer_is_virtual (b_printer))
|
|
|
|
result = 0;
|
|
|
|
else if (gtk_printer_is_virtual (a_printer) && !gtk_printer_is_virtual (b_printer))
|
|
|
|
result = G_MININT;
|
|
|
|
else if (!gtk_printer_is_virtual (a_printer) && gtk_printer_is_virtual (b_printer))
|
|
|
|
result = G_MAXINT;
|
|
|
|
else if (a_name == NULL && b_name == NULL)
|
|
|
|
result = 0;
|
|
|
|
else if (a_name == NULL && b_name != NULL)
|
|
|
|
result = 1;
|
|
|
|
else if (a_name != NULL && b_name == NULL)
|
|
|
|
result = -1;
|
|
|
|
else
|
|
|
|
result = g_ascii_strcasecmp (a_name, b_name);
|
|
|
|
|
|
|
|
g_free (a_name);
|
|
|
|
g_free (b_name);
|
|
|
|
g_object_unref (a_printer);
|
|
|
|
g_object_unref (b_printer);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_printer_list_model (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkListStore *model;
|
|
|
|
GtkTreeSortable *sort;
|
|
|
|
|
|
|
|
model = gtk_list_store_new (PRINTER_LIST_N_COLS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_OBJECT);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->printer_list = (GtkTreeModel *)model;
|
|
|
|
priv->printer_list_filter = (GtkTreeModelFilter *) gtk_tree_model_filter_new ((GtkTreeModel *)model,
|
2006-04-21 15:09:32 +00:00
|
|
|
NULL);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_tree_model_filter_set_visible_func (priv->printer_list_filter,
|
2006-04-21 15:09:32 +00:00
|
|
|
(GtkTreeModelFilterVisibleFunc) is_printer_active,
|
|
|
|
dialog,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
sort = GTK_TREE_SORTABLE (model);
|
|
|
|
gtk_tree_sortable_set_default_sort_func (sort,
|
|
|
|
default_printer_list_sort_func,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_column_id (sort,
|
|
|
|
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
|
|
|
|
GTK_SORT_ASCENDING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
wrap_in_frame (const gchar *label,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GtkWidget *frame, *alignment, *label_widget;
|
2006-06-12 04:39:55 +00:00
|
|
|
gchar *bold_text;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
label_widget = gtk_label_new ("");
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (label_widget);
|
|
|
|
|
|
|
|
bold_text = g_markup_printf_escaped ("<b>%s</b>", label);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label_widget), bold_text);
|
|
|
|
g_free (bold_text);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
frame = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (frame), label_widget, FALSE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
|
2006-04-30 05:31:14 +00:00
|
|
|
0, 0, 12, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (frame), alignment, FALSE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), child);
|
|
|
|
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
gtk_widget_show (alignment);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
setup_option (GtkPrintUnixDialog *dialog,
|
|
|
|
const gchar *option_name,
|
|
|
|
GtkPrinterOptionWidget *widget)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOption *option;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
option = gtk_printer_option_set_lookup (priv->options, option_name);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_option_widget_set_source (widget, option);
|
|
|
|
|
|
|
|
return option != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-30 05:31:14 +00:00
|
|
|
add_option_to_extension_point (GtkPrinterOption *option,
|
2006-06-17 05:15:49 +00:00
|
|
|
gpointer data)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-06-17 05:15:49 +00:00
|
|
|
GtkWidget *extension_point = data;
|
|
|
|
GtkWidget *widget;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
widget = gtk_printer_option_widget_new (option);
|
|
|
|
gtk_widget_show (widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
if (gtk_printer_option_widget_has_external_label (GTK_PRINTER_OPTION_WIDGET (widget)))
|
|
|
|
{
|
|
|
|
GtkWidget *label, *hbox;
|
|
|
|
|
|
|
|
label = gtk_printer_option_widget_get_external_label (GTK_PRINTER_OPTION_WIDGET (widget));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (extension_point), hbox, FALSE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
else
|
2006-06-17 05:15:49 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (extension_point), widget, FALSE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_option_to_table (GtkPrinterOption *option,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkTable *table;
|
|
|
|
GtkWidget *label, *widget;
|
2006-06-12 04:39:55 +00:00
|
|
|
gint row;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
table = GTK_TABLE (user_data);
|
|
|
|
|
|
|
|
if (g_str_has_prefix (option->name, "gtk-"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (option);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
row = table->nrows;
|
2006-06-16 18:33:29 +00:00
|
|
|
gtk_table_resize (table, table->nrows + 1, 2);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (gtk_printer_option_widget_has_external_label (GTK_PRINTER_OPTION_WIDGET (widget)))
|
|
|
|
{
|
|
|
|
label = gtk_printer_option_widget_get_external_label (GTK_PRINTER_OPTION_WIDGET (widget));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_table_attach (table, label,
|
|
|
|
0, 1, row - 1 , row, GTK_FILL, 0, 0, 0);
|
|
|
|
|
|
|
|
gtk_table_attach (table, widget,
|
|
|
|
1, 2, row - 1, row, GTK_FILL, 0, 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_table_attach (table, widget,
|
|
|
|
0, 2, row - 1, row, GTK_FILL, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_page_table (GtkPrinterOptionSet *options,
|
|
|
|
const gchar *group,
|
|
|
|
GtkWidget *table,
|
|
|
|
GtkWidget *page)
|
|
|
|
{
|
|
|
|
gtk_printer_option_set_foreach_in_group (options, group,
|
|
|
|
add_option_to_table,
|
|
|
|
table);
|
|
|
|
if (GTK_TABLE (table)->nrows == 1)
|
|
|
|
gtk_widget_hide (page);
|
|
|
|
else
|
|
|
|
gtk_widget_show (page);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_print_at_option (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOption *option;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (option == NULL)
|
|
|
|
return;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->updating_print_at)
|
2006-04-21 15:09:32 +00:00
|
|
|
return;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->print_at_radio)))
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_option_set (option, "at");
|
2006-05-02 12:48:52 +00:00
|
|
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->print_hold_radio)))
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_option_set (option, "on-hold");
|
|
|
|
else
|
|
|
|
gtk_printer_option_set (option, "now");
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time-text");
|
2006-04-21 15:09:32 +00:00
|
|
|
if (option != NULL)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
const char *text = gtk_entry_get_text (GTK_ENTRY (priv->print_at_entry));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_option_set (option,text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
setup_print_at (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinterOption *option;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (option == NULL)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_now_radio),
|
2006-04-21 15:09:32 +00:00
|
|
|
TRUE);
|
2006-05-02 12:48:52 +00:00
|
|
|
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), "");
|
2006-04-21 15:09:32 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->updating_print_at = TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (gtk_printer_option_has_choice (option, "at"))
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_set_sensitive (priv->print_at_radio, TRUE);
|
|
|
|
gtk_widget_set_sensitive (priv->print_at_entry, TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_set_sensitive (priv->print_at_radio, FALSE);
|
|
|
|
gtk_widget_set_sensitive (priv->print_at_entry, FALSE);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_set_sensitive (priv->print_hold_radio,
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_printer_option_has_choice (option, "on-hold"));
|
|
|
|
|
|
|
|
update_print_at_option (dialog);
|
|
|
|
|
|
|
|
if (strcmp (option->value, "at") == 0)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_at_radio),
|
2006-04-21 15:09:32 +00:00
|
|
|
TRUE);
|
|
|
|
else if (strcmp (option->value, "on-hold") == 0)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_hold_radio),
|
2006-04-21 15:09:32 +00:00
|
|
|
TRUE);
|
|
|
|
else
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->print_now_radio),
|
2006-04-21 15:09:32 +00:00
|
|
|
TRUE);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
option = gtk_printer_option_set_lookup (priv->options, "gtk-print-time-text");
|
2006-04-21 15:09:32 +00:00
|
|
|
if (option != NULL)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->print_at_entry),
|
2006-04-21 15:09:32 +00:00
|
|
|
option->value);
|
|
|
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->updating_print_at = FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_dialog_from_settings (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GList *groups, *l;
|
2006-06-12 04:39:55 +00:00
|
|
|
gchar *group;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *table, *frame;
|
|
|
|
gboolean has_advanced, has_job;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_printer == NULL)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
clear_per_printer_ui (dialog);
|
2006-05-02 12:48:52 +00:00
|
|
|
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);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
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);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
has_job = FALSE;
|
2006-05-02 12:48:52 +00:00
|
|
|
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);
|
2006-04-21 15:09:32 +00:00
|
|
|
has_job |= setup_print_at (dialog);
|
|
|
|
|
|
|
|
if (has_job)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->job_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
else
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_hide (priv->job_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
setup_page_table (priv->options,
|
2006-04-21 15:09:32 +00:00
|
|
|
"ImageQualityPage",
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->image_quality_table,
|
|
|
|
priv->image_quality_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
setup_page_table (priv->options,
|
2006-04-21 15:09:32 +00:00
|
|
|
"FinishingPage",
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->finishing_table,
|
|
|
|
priv->finishing_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
setup_page_table (priv->options,
|
2006-04-21 15:09:32 +00:00
|
|
|
"ColorPage",
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->color_table,
|
|
|
|
priv->color_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
gtk_printer_option_set_foreach_in_group (priv->options,
|
|
|
|
"GtkPrintDialogExtension",
|
|
|
|
add_option_to_extension_point,
|
|
|
|
priv->extension_point);
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
/* Put the rest of the groups in the advanced page */
|
2006-05-02 12:48:52 +00:00
|
|
|
groups = gtk_printer_option_set_get_groups (priv->options);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
has_advanced = FALSE;
|
|
|
|
for (l = groups; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
group = l->data;
|
|
|
|
|
|
|
|
if (group == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp (group, "ImageQualityPage") == 0 ||
|
|
|
|
strcmp (group, "ColorPage") == 0 ||
|
2006-06-17 05:15:49 +00:00
|
|
|
strcmp (group, "FinishingPage") == 0 ||
|
|
|
|
strcmp (group, "GtkPrintDialogExtension") == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_printer_option_set_foreach_in_group (priv->options,
|
2006-04-21 15:09:32 +00:00
|
|
|
group,
|
|
|
|
add_option_to_table,
|
|
|
|
table);
|
|
|
|
if (GTK_TABLE (table)->nrows == 1)
|
|
|
|
gtk_widget_destroy (table);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
has_advanced = TRUE;
|
|
|
|
frame = wrap_in_frame (group, table);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (priv->advanced_vbox),
|
2006-04-21 15:09:32 +00:00
|
|
|
frame, FALSE, FALSE, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_advanced)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->advanced_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
else
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_hide (priv->advanced_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
g_list_foreach (groups, (GFunc) g_free, NULL);
|
|
|
|
g_list_free (groups);
|
|
|
|
}
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
static void
|
|
|
|
update_dialog_from_capabilities (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
GtkPrintCapabilities caps;
|
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-05-24 19:03:52 +00:00
|
|
|
gboolean can_collate;
|
2006-12-06 15:17:40 +00:00
|
|
|
const gchar *copies;
|
2006-05-24 19:03:52 +00:00
|
|
|
|
2006-12-06 15:17:40 +00:00
|
|
|
copies = gtk_entry_get_text (GTK_ENTRY (priv->copies_spin));
|
|
|
|
can_collate = (*copies != '\0' && atoi (copies) > 1);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
|
|
caps = priv->manual_capabilities | priv->printer_capabilities;
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (priv->page_set_combo,
|
|
|
|
caps & GTK_PRINT_CAPABILITY_PAGE_SET);
|
|
|
|
gtk_widget_set_sensitive (priv->copies_spin,
|
|
|
|
caps & GTK_PRINT_CAPABILITY_COPIES);
|
|
|
|
gtk_widget_set_sensitive (priv->collate_check,
|
2006-05-24 19:03:52 +00:00
|
|
|
can_collate &&
|
|
|
|
(caps & GTK_PRINT_CAPABILITY_COLLATE));
|
2006-05-24 10:50:57 +00:00
|
|
|
gtk_widget_set_sensitive (priv->reverse_check,
|
|
|
|
caps & GTK_PRINT_CAPABILITY_REVERSE);
|
|
|
|
gtk_widget_set_sensitive (priv->scale_spin,
|
2006-10-08 19:39:15 +00:00
|
|
|
caps & GTK_PRINT_CAPABILITY_SCALE);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
2006-06-30 10:32:56 +00:00
|
|
|
if (caps & GTK_PRINT_CAPABILITY_PREVIEW)
|
|
|
|
gtk_widget_show (priv->preview_button);
|
|
|
|
else
|
|
|
|
gtk_widget_hide (priv->preview_button);
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
update_collate_icon (NULL, dialog);
|
2006-06-12 16:47:41 +00:00
|
|
|
|
|
|
|
gtk_tree_model_filter_refilter (priv->printer_list_filter);
|
2006-05-24 10:50:57 +00:00
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
mark_conflicts (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinter *printer;
|
|
|
|
gboolean have_conflict;
|
|
|
|
|
|
|
|
have_conflict = FALSE;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
printer = priv->current_printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (printer)
|
|
|
|
{
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_block (priv->options,
|
|
|
|
priv->options_changed_handler);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_printer_option_set_clear_conflicts (priv->options);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
have_conflict = _gtk_printer_mark_conflicts (printer,
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->options);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_signal_handler_unblock (priv->options,
|
|
|
|
priv->options_changed_handler);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (have_conflict)
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_show (priv->conflicts_widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
else
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_widget_hide (priv->conflicts_widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
mark_conflicts_callback (gpointer data)
|
|
|
|
{
|
|
|
|
GtkPrintUnixDialog *dialog = data;
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->mark_conflicts_id = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
mark_conflicts (dialog);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unschedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
if (priv->mark_conflicts_id != 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_source_remove (priv->mark_conflicts_id);
|
|
|
|
priv->mark_conflicts_id = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
schedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
if (priv->mark_conflicts_id != 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
return;
|
|
|
|
|
2006-12-22 19:10:43 +00:00
|
|
|
priv->mark_conflicts_id = gdk_threads_add_idle (mark_conflicts_callback,
|
2006-06-12 04:39:55 +00:00
|
|
|
dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
options_changed_cb (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
schedule_idle_mark_conflicts (dialog);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->initial_settings)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->initial_settings);
|
|
|
|
priv->initial_settings = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_free (priv->waiting_for_printer);
|
|
|
|
priv->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remove_custom_widget (GtkWidget *widget,
|
|
|
|
GtkContainer *container)
|
|
|
|
{
|
|
|
|
gtk_container_remove (container, widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-17 05:15:49 +00:00
|
|
|
extension_point_clear_children (GtkContainer *container)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
gtk_container_foreach (container,
|
|
|
|
(GtkCallback)remove_custom_widget,
|
|
|
|
container);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clear_per_printer_ui (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (priv->finishing_table),
|
2006-04-21 15:09:32 +00:00
|
|
|
(GtkCallback)gtk_widget_destroy,
|
|
|
|
NULL);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_table_resize (GTK_TABLE (priv->finishing_table), 1, 2);
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (priv->image_quality_table),
|
2006-04-21 15:09:32 +00:00
|
|
|
(GtkCallback)gtk_widget_destroy,
|
|
|
|
NULL);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_table_resize (GTK_TABLE (priv->image_quality_table), 1, 2);
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (priv->color_table),
|
2006-04-21 15:09:32 +00:00
|
|
|
(GtkCallback)gtk_widget_destroy,
|
|
|
|
NULL);
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_table_resize (GTK_TABLE (priv->color_table), 1, 2);
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (priv->advanced_vbox),
|
2006-04-21 15:09:32 +00:00
|
|
|
(GtkCallback)gtk_widget_destroy,
|
|
|
|
NULL);
|
2006-06-19 04:21:22 +00:00
|
|
|
extension_point_clear_children (GTK_CONTAINER (priv->extension_point));
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printer_details_acquired (GtkPrinter *printer,
|
|
|
|
gboolean success,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
priv->request_details_tag = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
GtkTreeSelection *selection;
|
2006-05-02 12:48:52 +00:00
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
selected_printer_changed (selection, dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
selected_printer_changed (GtkTreeSelection *selection,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinter *printer;
|
|
|
|
GtkTreeIter iter, filter_iter;
|
|
|
|
|
|
|
|
/* Whenever the user selects a printer we stop looking for
|
|
|
|
the printer specified in the initial settings */
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->waiting_for_printer &&
|
|
|
|
!priv->internal_printer_change)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_free (priv->waiting_for_printer);
|
|
|
|
priv->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->request_details_tag)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_source_remove (priv->request_details_tag);
|
|
|
|
priv->request_details_tag = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printer = NULL;
|
|
|
|
if (gtk_tree_selection_get_selected (selection, NULL, &filter_iter))
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_tree_model_filter_convert_iter_to_child_iter (priv->printer_list_filter,
|
2006-04-21 15:09:32 +00:00
|
|
|
&iter,
|
|
|
|
&filter_iter);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_tree_model_get (priv->printer_list, &iter,
|
2006-04-21 15:09:32 +00:00
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ, &printer,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (printer != NULL && !_gtk_printer_has_details (printer))
|
|
|
|
{
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->request_details_tag =
|
2006-04-21 15:09:32 +00:00
|
|
|
g_signal_connect (printer, "details-acquired",
|
|
|
|
G_CALLBACK (printer_details_acquired), dialog);
|
|
|
|
_gtk_printer_request_details (printer);
|
2006-05-04 13:43:32 +00:00
|
|
|
g_object_unref (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (printer == priv->current_printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
if (printer)
|
|
|
|
g_object_unref (printer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->options)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->options);
|
|
|
|
priv->options = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
clear_per_printer_ui (dialog);
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->current_printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
priv->printer_capabilities = 0;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->current_printer = printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (printer != NULL)
|
|
|
|
{
|
2006-05-24 10:50:57 +00:00
|
|
|
priv->printer_capabilities = _gtk_printer_get_capabilities (printer);
|
2006-06-19 11:42:28 +00:00
|
|
|
priv->options = _gtk_printer_get_options (printer,
|
|
|
|
priv->initial_settings,
|
|
|
|
priv->page_setup,
|
|
|
|
priv->manual_capabilities);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->options_changed_handler =
|
|
|
|
g_signal_connect_swapped (priv->options, "changed", G_CALLBACK (options_changed_cb), dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
update_dialog_from_settings (dialog);
|
2006-05-24 10:50:57 +00:00
|
|
|
update_dialog_from_capabilities (dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
2006-05-24 10:50:57 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
update_collate_icon (GtkToggleButton *toggle_button,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-05-03 20:18:38 +00:00
|
|
|
|
|
|
|
gtk_widget_queue_draw (priv->collate_image);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_page (GtkWidget *widget,
|
|
|
|
cairo_t *cr,
|
|
|
|
gfloat scale,
|
|
|
|
gint x_offset,
|
|
|
|
gint y_offset,
|
2006-05-05 19:49:13 +00:00
|
|
|
gchar *text,
|
|
|
|
gint text_x)
|
2006-05-03 20:18:38 +00:00
|
|
|
{
|
|
|
|
gint x, y, width, height;
|
2006-05-05 19:49:13 +00:00
|
|
|
gint text_y, linewidth;
|
2006-05-03 20:18:38 +00:00
|
|
|
|
|
|
|
x = x_offset * scale;
|
|
|
|
y = y_offset * scale;
|
|
|
|
width = 20 * scale;
|
|
|
|
height = 26 * scale;
|
|
|
|
|
2006-05-05 19:49:13 +00:00
|
|
|
linewidth = 2;
|
|
|
|
text_y = 21;
|
|
|
|
|
2006-05-03 20:18:38 +00:00
|
|
|
gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]);
|
|
|
|
cairo_rectangle (cr, x, y, width, height);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_NORMAL]);
|
|
|
|
cairo_set_line_width (cr, linewidth);
|
|
|
|
cairo_rectangle (cr, x + linewidth/2.0, y + linewidth/2.0, width - linewidth, height - linewidth);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
cairo_select_font_face (cr, "Sans",
|
|
|
|
CAIRO_FONT_SLANT_NORMAL,
|
|
|
|
CAIRO_FONT_WEIGHT_NORMAL);
|
|
|
|
cairo_set_font_size (cr, (gint)(9 * scale));
|
2006-05-05 19:49:13 +00:00
|
|
|
cairo_move_to (cr, x + (gint)(text_x * scale), y + (gint)(text_y * scale));
|
2006-05-03 20:18:38 +00:00
|
|
|
cairo_show_text (cr, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
draw_collate_cb (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
cairo_t *cr;
|
|
|
|
gint size;
|
|
|
|
gfloat scale;
|
2006-05-05 19:49:13 +00:00
|
|
|
gboolean collate, reverse, rtl;
|
2006-12-20 04:39:52 +00:00
|
|
|
gint copies;
|
2006-05-05 19:49:13 +00:00
|
|
|
gint text_x;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
collate = dialog_get_collate (dialog);
|
|
|
|
reverse = dialog_get_reverse (dialog);
|
2006-12-20 04:39:52 +00:00
|
|
|
copies = dialog_get_n_copies (dialog);
|
|
|
|
|
2006-05-05 19:49:13 +00:00
|
|
|
rtl = (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-03 20:18:38 +00:00
|
|
|
settings = gtk_widget_get_settings (widget);
|
|
|
|
gtk_icon_size_lookup_for_settings (settings,
|
|
|
|
GTK_ICON_SIZE_DIALOG,
|
|
|
|
&size,
|
|
|
|
NULL);
|
|
|
|
scale = size / 48.0;
|
2006-05-05 19:49:13 +00:00
|
|
|
text_x = rtl ? 4 : 11;
|
2006-05-03 20:18:38 +00:00
|
|
|
|
|
|
|
cr = gdk_cairo_create (widget->window);
|
|
|
|
|
2006-12-20 04:39:52 +00:00
|
|
|
if (copies == 1)
|
|
|
|
{
|
|
|
|
paint_page (widget, cr, scale, rtl ? 40: 15, 5, reverse ? "1" : "2", text_x);
|
|
|
|
paint_page (widget, cr, scale, rtl ? 50: 5, 15, reverse ? "2" : "1", text_x);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
paint_page (widget, cr, scale, rtl ? 40: 15, 5, collate == reverse ? "1" : "2", text_x);
|
|
|
|
paint_page (widget, cr, scale, rtl ? 50: 5, 15, reverse ? "2" : "1", text_x);
|
|
|
|
|
|
|
|
paint_page (widget, cr, scale, rtl ? 5 : 50, 5, reverse ? "1" : "2", text_x);
|
|
|
|
paint_page (widget, cr, scale, rtl ? 15 : 40, 15, collate == reverse ? "2" : "1", text_x);
|
|
|
|
}
|
2006-05-03 20:18:38 +00:00
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_print_unix_dialog_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *previous_style)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_CLASS (gtk_print_unix_dialog_parent_class)->style_set)
|
|
|
|
GTK_WIDGET_CLASS (gtk_print_unix_dialog_parent_class)->style_set (widget, previous_style);
|
|
|
|
|
|
|
|
if (gtk_widget_has_screen (widget))
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-03 20:18:38 +00:00
|
|
|
GtkPrintUnixDialog *dialog = (GtkPrintUnixDialog *)widget;
|
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
GtkSettings *settings;
|
|
|
|
gint size;
|
|
|
|
gfloat scale;
|
|
|
|
|
|
|
|
settings = gtk_widget_get_settings (widget);
|
|
|
|
gtk_icon_size_lookup_for_settings (settings,
|
|
|
|
GTK_ICON_SIZE_DIALOG,
|
|
|
|
&size,
|
|
|
|
NULL);
|
|
|
|
scale = size / 48.0;
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (priv->collate_image,
|
|
|
|
(50 + 20) * scale,
|
|
|
|
(15 + 26) * scale);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-24 18:21:12 +00:00
|
|
|
static void
|
|
|
|
update_range_sensitivity (GtkWidget *button,
|
|
|
|
GtkWidget *range)
|
|
|
|
{
|
2006-05-24 19:03:52 +00:00
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (range, active);
|
2006-05-24 18:21:12 +00:00
|
|
|
}
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
static void
|
|
|
|
create_main_page (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-04-30 05:31:14 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
GtkWidget *main_vbox, *label, *vbox, *hbox;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *scrolled, *treeview, *frame, *table;
|
2006-12-20 04:39:52 +00:00
|
|
|
GtkWidget *entry, *spinbutton, *event_box;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *radio, *check, *image;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkWidget *custom_input;
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 18);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
vbox = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_SHADOW_IN);
|
|
|
|
gtk_widget_show (scrolled);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
treeview = gtk_tree_view_new_with_model ((GtkTreeModel *) priv->printer_list_filter);
|
|
|
|
priv->printer_treeview = treeview;
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
|
|
|
|
gtk_tree_view_set_search_column (GTK_TREE_VIEW (treeview), PRINTER_LIST_COL_NAME);
|
|
|
|
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), TRUE);
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
|
|
|
|
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
|
|
|
|
g_signal_connect (selection, "changed", G_CALLBACK (selected_printer_changed), dialog);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes ("",
|
|
|
|
renderer,
|
|
|
|
"icon-name",
|
|
|
|
PRINTER_LIST_COL_ICON,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (_("Printer"),
|
|
|
|
renderer,
|
|
|
|
"text",
|
|
|
|
PRINTER_LIST_COL_NAME,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (_("Location"),
|
|
|
|
renderer,
|
|
|
|
"text",
|
|
|
|
PRINTER_LIST_COL_LOCATION,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (_("Status"),
|
|
|
|
renderer,
|
|
|
|
"text",
|
|
|
|
PRINTER_LIST_COL_STATE,
|
|
|
|
NULL);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
|
|
|
|
|
|
|
gtk_widget_show (treeview);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled), treeview);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
custom_input = gtk_hbox_new (FALSE, 18);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (custom_input);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), custom_input, FALSE, FALSE, 0);
|
2006-06-17 05:15:49 +00:00
|
|
|
priv->extension_point = custom_input;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 18);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Print Pages"), table);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (NULL, _("_All"));
|
2006-04-21 15:09:32 +00:00
|
|
|
priv->all_pages_radio = radio;
|
|
|
|
gtk_widget_show (radio);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio,
|
2006-04-30 05:31:14 +00:00
|
|
|
0, 2, 0, 1, GTK_FILL, 0,
|
2006-04-21 15:09:32 +00:00
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)),
|
|
|
|
_("C_urrent"));
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_page == -1)
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_set_sensitive (radio, FALSE);
|
|
|
|
priv->current_page_radio = radio;
|
|
|
|
gtk_widget_show (radio);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio,
|
2006-04-30 05:31:14 +00:00
|
|
|
0, 2, 1, 2, GTK_FILL, 0,
|
2006-04-21 15:09:32 +00:00
|
|
|
0, 0);
|
2006-12-20 04:39:52 +00:00
|
|
|
|
|
|
|
radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Ra_nge"));
|
|
|
|
gtk_tooltips_set_tip (priv->tooltips, radio, _("Specify one or more page ranges,\n e.g. 1-3,7,11"), NULL);
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
priv->page_range_radio = radio;
|
|
|
|
gtk_widget_show (radio);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio,
|
|
|
|
0, 1, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
entry = gtk_entry_new ();
|
|
|
|
priv->page_range_entry = entry;
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), entry,
|
|
|
|
1, 2, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-05-24 18:21:12 +00:00
|
|
|
g_signal_connect (radio, "toggled", G_CALLBACK (update_range_sensitivity), entry);
|
|
|
|
update_range_sensitivity (radio, entry);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Copies"), table);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-05-24 19:03:52 +00:00
|
|
|
/* FIXME chpe: too much space between Copies and spinbutton, put those 2 in a hbox and make it span 2 columns */
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Copie_s:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
spinbutton = gtk_spin_button_new_with_range (1.0, 100.0, 1.0);
|
|
|
|
priv->copies_spin = spinbutton;
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), spinbutton,
|
|
|
|
1, 2, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
|
2006-05-24 19:03:52 +00:00
|
|
|
g_signal_connect_swapped (spinbutton, "value-changed",
|
|
|
|
G_CALLBACK (update_dialog_from_capabilities), dialog);
|
2006-12-06 15:17:40 +00:00
|
|
|
g_signal_connect_swapped (spinbutton, "changed",
|
|
|
|
G_CALLBACK (update_dialog_from_capabilities), dialog);
|
2006-05-24 19:03:52 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
check = gtk_check_button_new_with_mnemonic (_("C_ollate"));
|
2006-04-21 15:09:32 +00:00
|
|
|
priv->collate_check = check;
|
|
|
|
g_signal_connect (check, "toggled", G_CALLBACK (update_collate_icon), dialog);
|
|
|
|
gtk_widget_show (check);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), check,
|
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-05-24 19:03:52 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
check = gtk_check_button_new_with_mnemonic (_("_Reverse"));
|
|
|
|
g_signal_connect (check, "toggled", G_CALLBACK (update_collate_icon), dialog);
|
|
|
|
priv->reverse_check = check;
|
|
|
|
gtk_widget_show (check);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), check,
|
|
|
|
0, 1, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
2006-05-03 20:18:38 +00:00
|
|
|
image = gtk_drawing_area_new ();
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->collate_image = image;
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (image);
|
2006-05-03 20:18:38 +00:00
|
|
|
gtk_widget_set_size_request (image, 70, 90);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_table_attach (GTK_TABLE (table), image,
|
|
|
|
1, 2, 1, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-06-01 04:58:18 +00:00
|
|
|
g_signal_connect (image, "expose-event", G_CALLBACK (draw_collate_cb), dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (_("General"));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), main_vbox, label);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_range_separator (gchar c)
|
|
|
|
{
|
|
|
|
return (c == ',' || c == ';' || c == ':');
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkPageRange *
|
|
|
|
dialog_get_page_ranges (GtkPrintUnixDialog *dialog,
|
|
|
|
gint *n_ranges_out)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-06-12 04:39:55 +00:00
|
|
|
gint i, n_ranges;
|
|
|
|
const gchar *text, *p;
|
|
|
|
gchar *next;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPageRange *ranges;
|
2006-06-12 04:39:55 +00:00
|
|
|
gint start, end;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (priv->page_range_entry));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (*text == 0)
|
|
|
|
{
|
|
|
|
*n_ranges_out = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
n_ranges = 1;
|
|
|
|
p = text;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (is_range_separator (*p))
|
|
|
|
n_ranges++;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ranges = g_new0 (GtkPageRange, n_ranges);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
p = text;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
start = (int)strtol (p, &next, 10);
|
|
|
|
if (start < 1)
|
|
|
|
start = 1;
|
|
|
|
end = start;
|
|
|
|
|
|
|
|
if (next != p)
|
|
|
|
{
|
|
|
|
p = next;
|
|
|
|
|
|
|
|
if (*p == '-')
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
end = (int)strtol (p, NULL, 10);
|
|
|
|
if (end < start)
|
|
|
|
end = start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ranges[i].start = start - 1;
|
|
|
|
ranges[i].end = end - 1;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* Skip until end or separator */
|
|
|
|
while (*p && !is_range_separator (*p))
|
|
|
|
p++;
|
|
|
|
|
|
|
|
/* if not at end, skip separator */
|
|
|
|
if (*p)
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*n_ranges_out = i;
|
|
|
|
|
|
|
|
return ranges;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_set_page_ranges (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPageRange *ranges,
|
|
|
|
gint n_ranges)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-06-12 04:39:55 +00:00
|
|
|
gint i;
|
2006-04-21 15:09:32 +00:00
|
|
|
GString *s = g_string_new ("");
|
|
|
|
|
|
|
|
for (i = 0; i < n_ranges; i++)
|
|
|
|
{
|
|
|
|
g_string_append_printf (s, "%d", ranges[i].start + 1);
|
|
|
|
if (ranges[i].end > ranges[i].start)
|
|
|
|
g_string_append_printf (s, "-%d", ranges[i].end + 1);
|
|
|
|
|
|
|
|
if (i != n_ranges - 1)
|
|
|
|
g_string_append (s, ",");
|
|
|
|
}
|
|
|
|
|
2006-06-12 04:39:55 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (priv->page_range_entry), s->str);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GtkPrintPages
|
|
|
|
dialog_get_print_pages (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->all_pages_radio)))
|
|
|
|
return GTK_PRINT_PAGES_ALL;
|
|
|
|
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->current_page_radio)))
|
|
|
|
return GTK_PRINT_PAGES_CURRENT;
|
|
|
|
else
|
|
|
|
return GTK_PRINT_PAGES_RANGES;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-12 04:39:55 +00:00
|
|
|
dialog_set_print_pages (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPrintPages pages)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
if (pages == GTK_PRINT_PAGES_RANGES)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->page_range_radio), TRUE);
|
|
|
|
else if (pages == GTK_PRINT_PAGES_CURRENT)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->current_page_radio), TRUE);
|
|
|
|
else
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_pages_radio), TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
|
|
|
dialog_get_scale (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-24 10:50:57 +00:00
|
|
|
if (GTK_WIDGET_IS_SENSITIVE (dialog->priv->scale_spin))
|
|
|
|
return gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->priv->scale_spin));
|
|
|
|
else
|
|
|
|
return 100.0;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_set_scale (GtkPrintUnixDialog *dialog,
|
|
|
|
gdouble val)
|
|
|
|
{
|
2006-05-22 12:55:02 +00:00
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->scale_spin), val);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkPageSet
|
|
|
|
dialog_get_page_set (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-24 10:50:57 +00:00
|
|
|
if (GTK_WIDGET_IS_SENSITIVE (dialog->priv->page_set_combo))
|
|
|
|
return (GtkPageSet)gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->page_set_combo));
|
|
|
|
else
|
|
|
|
return GTK_PAGE_SET_ALL;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_set_page_set (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPageSet val)
|
|
|
|
{
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->page_set_combo),
|
|
|
|
(int)val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
dialog_get_n_copies (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-24 10:50:57 +00:00
|
|
|
if (GTK_WIDGET_IS_SENSITIVE (dialog->priv->copies_spin))
|
|
|
|
return gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->priv->copies_spin));
|
|
|
|
return 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_set_n_copies (GtkPrintUnixDialog *dialog,
|
|
|
|
gint n_copies)
|
|
|
|
{
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->copies_spin),
|
|
|
|
n_copies);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
dialog_get_collate (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-24 10:50:57 +00:00
|
|
|
if (GTK_WIDGET_IS_SENSITIVE (dialog->priv->collate_check))
|
|
|
|
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->collate_check));
|
|
|
|
return FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_set_collate (GtkPrintUnixDialog *dialog,
|
|
|
|
gboolean collate)
|
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->collate_check),
|
|
|
|
collate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
dialog_get_reverse (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-24 10:50:57 +00:00
|
|
|
if (GTK_WIDGET_IS_SENSITIVE (dialog->priv->reverse_check))
|
|
|
|
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->reverse_check));
|
|
|
|
return FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_set_reverse (GtkPrintUnixDialog *dialog,
|
|
|
|
gboolean reverse)
|
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->reverse_check),
|
|
|
|
reverse);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
dialog_get_pages_per_sheet (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-06-12 04:39:55 +00:00
|
|
|
const gchar *val;
|
|
|
|
gint num;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
val = gtk_printer_option_widget_get_value (priv->pages_per_sheet);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
num = 1;
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
num = atoi(val);
|
|
|
|
if (num < 1)
|
|
|
|
num = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
draw_page_cb (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
cairo_t *cr;
|
2006-06-12 04:39:55 +00:00
|
|
|
gdouble ratio;
|
|
|
|
gint w, h, tmp, shadow_offset;
|
|
|
|
gint pages_x, pages_y, i, x, y, layout_w, layout_h;
|
|
|
|
gdouble page_width, page_height;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPageOrientation orientation;
|
|
|
|
gboolean landscape;
|
|
|
|
PangoLayout *layout;
|
|
|
|
PangoFontDescription *font;
|
2006-06-12 04:39:55 +00:00
|
|
|
gchar *text;
|
2006-05-05 19:49:13 +00:00
|
|
|
GdkColor *color;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
orientation = gtk_page_setup_get_orientation (priv->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
landscape =
|
|
|
|
(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE) ||
|
|
|
|
(orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE);
|
|
|
|
|
|
|
|
cr = gdk_cairo_create (widget->window);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
ratio = G_SQRT2;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
w = (EXAMPLE_PAGE_AREA_SIZE - 3) / ratio;
|
|
|
|
h = w * ratio;
|
|
|
|
|
|
|
|
switch (dialog_get_pages_per_sheet (dialog))
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 1:
|
|
|
|
pages_x = 1; pages_y = 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
landscape = !landscape;
|
|
|
|
pages_x = 1; pages_y = 2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
pages_x = 2; pages_y = 2;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
landscape = !landscape;
|
|
|
|
pages_x = 2; pages_y = 3;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
pages_x = 3; pages_y = 3;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
pages_x = 4; pages_y = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (landscape)
|
|
|
|
{
|
|
|
|
tmp = w;
|
|
|
|
w = h;
|
|
|
|
h = tmp;
|
|
|
|
|
|
|
|
tmp = pages_x;
|
|
|
|
pages_x = pages_y;
|
|
|
|
pages_y = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
shadow_offset = 3;
|
|
|
|
|
2006-05-05 19:49:13 +00:00
|
|
|
color = &widget->style->text[GTK_STATE_NORMAL];
|
|
|
|
cairo_set_source_rgba (cr, color->red / 65535., color->green / 65535., color->blue / 65535, 0.5);
|
2006-04-21 15:09:32 +00:00
|
|
|
cairo_rectangle (cr, shadow_offset + 1, shadow_offset + 1, w, h);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
2006-05-05 19:49:13 +00:00
|
|
|
gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_NORMAL]);
|
2006-04-21 15:09:32 +00:00
|
|
|
cairo_rectangle (cr, 1, 1, w, h);
|
|
|
|
cairo_fill (cr);
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
cairo_rectangle (cr, 0.5, 0.5, w+1, h+1);
|
|
|
|
|
2006-05-05 19:49:13 +00:00
|
|
|
gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_NORMAL]);
|
2006-04-21 15:09:32 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
|
|
|
|
page_width = (double)w / pages_x;
|
|
|
|
page_height = (double)h / pages_y;
|
|
|
|
|
|
|
|
layout = pango_cairo_create_layout (cr);
|
|
|
|
|
|
|
|
font = pango_font_description_new ();
|
|
|
|
pango_font_description_set_family (font, "sans");
|
|
|
|
pango_font_description_set_absolute_size (font, page_height * 0.4 * PANGO_SCALE);
|
|
|
|
pango_layout_set_font_description (layout, font);
|
|
|
|
pango_font_description_free (font);
|
|
|
|
|
|
|
|
pango_layout_set_width (layout, page_width * PANGO_SCALE);
|
|
|
|
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
|
|
|
|
|
|
|
for (y = 0; y < pages_y; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < pages_x; x++)
|
|
|
|
{
|
|
|
|
text = g_strdup_printf ("%d", i++);
|
|
|
|
pango_layout_set_text (layout, text, -1);
|
|
|
|
g_free (text);
|
|
|
|
pango_layout_get_size (layout, &layout_w, &layout_h);
|
|
|
|
cairo_save (cr);
|
|
|
|
cairo_translate (cr,
|
|
|
|
x * page_width,
|
|
|
|
y * page_height + (page_height - layout_h / 1024.0) / 2
|
|
|
|
);
|
|
|
|
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-03 17:52:41 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
redraw_page_layout_preview (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
if (priv->page_layout_preview)
|
|
|
|
gtk_widget_queue_draw (priv->page_layout_preview);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_page_setup_page (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-04-30 05:31:14 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *main_vbox, *label, *hbox, *hbox2;
|
|
|
|
GtkWidget *frame, *table, *widget;
|
|
|
|
GtkWidget *combo, *spinbutton, *draw;
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 18);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
hbox = gtk_hbox_new (FALSE, 18);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (hbox);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
table = gtk_table_new (5, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Layout"), table);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2007-02-26 19:12:22 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Pages per _side:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
g_signal_connect_swapped (widget, "changed", G_CALLBACK (redraw_page_layout_preview), dialog);
|
|
|
|
priv->pages_per_sheet = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("T_wo-sided:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->duplex = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-13 03:05:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Only print:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
combo = gtk_combo_box_new_text ();
|
|
|
|
priv->page_set_combo = combo;
|
|
|
|
gtk_widget_show (combo);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), combo,
|
|
|
|
1, 2, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
2006-04-21 15:09:32 +00:00
|
|
|
/* In enum order */
|
2006-04-24 15:52:28 +00:00
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("All sheets"));
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Even sheets"));
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Odd sheets"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Sc_ale:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 3, 4, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
hbox2 = gtk_hbox_new (FALSE, 6);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (hbox2);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), hbox2,
|
|
|
|
1, 2, 3, 4, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
spinbutton = gtk_spin_button_new_with_range (1.0, 1000.0, 1.0);
|
|
|
|
priv->scale_spin = spinbutton;
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), 1);
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), 100.0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
label = gtk_label_new ("%"); /* FIXMEchpe does there exist any language where % needs to be translated? */
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
table = gtk_table_new (4, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Paper"), table);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 6);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-05-13 03:05:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Paper _type:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->paper_type = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-13 03:05:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Paper _source:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->paper_source = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-13 03:05:16 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Output t_ray:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->output_tray = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
/* Add the page layout preview */
|
2006-04-21 15:09:32 +00:00
|
|
|
hbox2 = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_widget_show (hbox2);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox2, TRUE, TRUE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
draw = gtk_drawing_area_new ();
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->page_layout_preview = draw;
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_set_size_request (draw, 200, 200);
|
2006-06-01 04:58:18 +00:00
|
|
|
g_signal_connect (draw, "expose-event", G_CALLBACK (draw_page_cb), dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (draw);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), draw, TRUE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (_("Page Setup"));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
|
|
|
|
main_vbox, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_job_page (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-04-30 05:31:14 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *main_table, *label;
|
|
|
|
GtkWidget *frame, *table, *radio;
|
|
|
|
GtkWidget *entry, *widget;
|
|
|
|
|
|
|
|
main_table = gtk_table_new (2, 2, FALSE);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_table), 12);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (main_table), 18);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (main_table), 18);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Job Details"), table);
|
|
|
|
gtk_table_attach (GTK_TABLE (main_table), frame,
|
2006-04-30 05:31:14 +00:00
|
|
|
0, 1, 0, 1, GTK_FILL, 0,
|
2006-04-21 15:09:32 +00:00
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Pri_ority:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->job_prio = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Billing info:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->billing_info = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Print Document"), table);
|
|
|
|
gtk_table_attach (GTK_TABLE (main_table), frame,
|
2006-04-30 05:31:14 +00:00
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
2006-04-21 15:09:32 +00:00
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (NULL, _("_Now"));
|
2006-04-21 15:09:32 +00:00
|
|
|
priv->print_now_radio = radio;
|
|
|
|
gtk_widget_show (radio);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio,
|
2006-04-30 05:31:14 +00:00
|
|
|
0, 2, 0, 1, GTK_FILL, 0,
|
2006-04-21 15:09:32 +00:00
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)),
|
|
|
|
_("A_t:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
priv->print_at_radio = radio;
|
|
|
|
gtk_widget_show (radio);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio,
|
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
entry = gtk_entry_new ();
|
|
|
|
priv->print_at_entry = entry;
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), entry,
|
|
|
|
1, 2, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
radio = gtk_radio_button_new_with_mnemonic (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)),
|
2006-05-13 03:05:16 +00:00
|
|
|
_("On _hold"));
|
2006-04-30 05:31:14 +00:00
|
|
|
priv->print_hold_radio = radio;
|
|
|
|
gtk_widget_show (radio);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio,
|
|
|
|
0, 2, 2, 3, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
g_signal_connect_swapped (priv->print_now_radio, "toggled",
|
|
|
|
G_CALLBACK (update_print_at_option), dialog);
|
|
|
|
g_signal_connect_swapped (priv->print_at_radio, "toggled",
|
|
|
|
G_CALLBACK (update_print_at_option), dialog);
|
|
|
|
g_signal_connect_swapped (priv->print_at_entry, "changed",
|
|
|
|
G_CALLBACK (update_print_at_option), dialog);
|
|
|
|
g_signal_connect_swapped (priv->print_hold_radio, "toggled",
|
|
|
|
G_CALLBACK (update_print_at_option), dialog);
|
|
|
|
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
|
|
|
frame = wrap_in_frame (_("Add Cover Page"), table);
|
|
|
|
gtk_table_attach (GTK_TABLE (main_table), frame,
|
2006-04-30 05:31:14 +00:00
|
|
|
1, 2, 0, 1, GTK_FILL, 0,
|
2006-04-21 15:09:32 +00:00
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("Be_fore:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->cover_before = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 0, 1, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_After:"));
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
0, 1, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
widget = gtk_printer_option_widget_new (NULL);
|
|
|
|
priv->cover_after = GTK_PRINTER_OPTION_WIDGET (widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget,
|
|
|
|
1, 2, 1, 2, GTK_FILL, 0,
|
|
|
|
0, 0);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (_("Job"));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
priv->job_page = main_table;
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
|
|
|
|
main_table, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_optional_page (GtkPrintUnixDialog *dialog,
|
|
|
|
const gchar *text,
|
|
|
|
GtkWidget **table_out,
|
|
|
|
GtkWidget **page_out)
|
|
|
|
{
|
2006-04-30 05:31:14 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *table, *label, *scrolled;
|
|
|
|
|
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
table);
|
|
|
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN(scrolled)->child),
|
|
|
|
GTK_SHADOW_NONE);
|
|
|
|
|
|
|
|
label = gtk_label_new (text);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
|
|
|
|
scrolled, label);
|
|
|
|
|
|
|
|
*table_out = table;
|
|
|
|
*page_out = scrolled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_advanced_page (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-04-30 05:31:14 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkWidget *main_vbox, *label, *scrolled;
|
|
|
|
|
|
|
|
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
priv->advanced_page = scrolled;
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 18);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
|
|
|
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
|
|
|
|
main_vbox);
|
|
|
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN(scrolled)->child),
|
|
|
|
GTK_SHADOW_NONE);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->advanced_vbox = main_vbox;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (_("Advanced"));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
|
|
|
|
scrolled, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-04-30 05:31:14 +00:00
|
|
|
populate_dialog (GtkPrintUnixDialog *print_dialog)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-04-30 05:31:14 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = print_dialog->priv;
|
|
|
|
GtkDialog *dialog = GTK_DIALOG (print_dialog);
|
2006-06-16 17:38:00 +00:00
|
|
|
GtkWidget *vbox, *conflict_hbox, *image, *label;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
gtk_dialog_set_has_separator (dialog, FALSE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-06-16 17:38:00 +00:00
|
|
|
vbox = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
priv->notebook = gtk_notebook_new ();
|
2006-06-16 17:38:00 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (priv->notebook);
|
2006-04-30 05:31:14 +00:00
|
|
|
|
|
|
|
create_printer_list_model (print_dialog);
|
|
|
|
|
|
|
|
create_main_page (print_dialog);
|
|
|
|
create_page_setup_page (print_dialog);
|
|
|
|
create_job_page (print_dialog);
|
|
|
|
create_optional_page (print_dialog, _("Image Quality"),
|
|
|
|
&priv->image_quality_table,
|
|
|
|
&priv->image_quality_page);
|
|
|
|
create_optional_page (print_dialog, _("Color"),
|
|
|
|
&priv->color_table,
|
|
|
|
&priv->color_page);
|
|
|
|
create_optional_page (print_dialog, _("Finishing"),
|
|
|
|
&priv->finishing_table,
|
|
|
|
&priv->finishing_page);
|
|
|
|
create_advanced_page (print_dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-06-16 17:38:00 +00:00
|
|
|
priv->conflicts_widget = conflict_hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), conflict_hbox, FALSE, FALSE, 0);
|
2006-04-21 15:09:32 +00:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
gtk_box_pack_start (GTK_BOX (conflict_hbox), image, FALSE, TRUE, 0);
|
|
|
|
label = gtk_label_new (_("Some of the settings in the dialog conflict"));
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_box_pack_start (GTK_BOX (conflict_hbox), label, FALSE, TRUE, 0);
|
|
|
|
|
2006-04-30 05:31:14 +00:00
|
|
|
load_print_backends (print_dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_new:
|
|
|
|
* @title: Title of the dialog, or %NULL
|
|
|
|
* @parent: Transient parent of the dialog, or %NULL
|
|
|
|
*
|
|
|
|
* Creates a new #GtkPrintUnixDialog.
|
|
|
|
*
|
|
|
|
* Return value: a new #GtkPrintUnixDialog
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gtk_print_unix_dialog_new (const gchar *title,
|
|
|
|
GtkWindow *parent)
|
|
|
|
{
|
|
|
|
GtkWidget *result;
|
|
|
|
const gchar *_title = _("Print");
|
|
|
|
|
|
|
|
if (title)
|
|
|
|
_title = title;
|
2006-05-12 09:47:58 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
result = g_object_new (GTK_TYPE_PRINT_UNIX_DIALOG,
|
2006-05-12 09:47:58 +00:00
|
|
|
"transient-for", parent,
|
2006-04-21 15:09:32 +00:00
|
|
|
"title", _title,
|
|
|
|
"has-separator", FALSE,
|
|
|
|
NULL);
|
2006-05-12 09:47:58 +00:00
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_get_selected_printer:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
*
|
|
|
|
* Gets the currently selected printer.
|
|
|
|
*
|
|
|
|
* Returns: the currently selected printer
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrinter *
|
|
|
|
gtk_print_unix_dialog_get_selected_printer (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), NULL);
|
|
|
|
|
|
|
|
return dialog->priv->current_printer;
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_set_page_setup:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
* @page_setup: a #GtkPageSetup
|
|
|
|
*
|
|
|
|
* Sets the page setup of the #GtkPrintUnixDialog.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
void
|
|
|
|
gtk_print_unix_dialog_set_page_setup (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPageSetup *page_setup)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = dialog->priv;
|
|
|
|
|
|
|
|
if (priv->page_setup != page_setup)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
g_object_unref (priv->page_setup);
|
|
|
|
priv->page_setup = g_object_ref (page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (dialog), "page-setup");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_get_page_setup:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
*
|
|
|
|
* Gets the page setup that is used by the #GtkPrintUnixDialog.
|
|
|
|
*
|
|
|
|
* Returns: the page setup of @dialog.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPageSetup *
|
|
|
|
gtk_print_unix_dialog_get_page_setup (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), NULL);
|
|
|
|
|
|
|
|
return dialog->priv->page_setup;
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_set_current_page:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
* @current_page: the current page number.
|
|
|
|
*
|
|
|
|
* Sets the current page number. If @current_page is not -1, this enables
|
|
|
|
* the current page choice for the range of pages to print.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
void
|
|
|
|
gtk_print_unix_dialog_set_current_page (GtkPrintUnixDialog *dialog,
|
|
|
|
gint current_page)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = dialog->priv;
|
|
|
|
|
|
|
|
if (priv->current_page != current_page)
|
2006-04-21 15:09:32 +00:00
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->current_page = current_page;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_page_radio)
|
|
|
|
gtk_widget_set_sensitive (priv->current_page_radio, current_page != -1);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (dialog), "current-page");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_get_current_page:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
*
|
|
|
|
* Gets the current page of the #GtkPrintDialog.
|
|
|
|
*
|
|
|
|
* Returns: the current page of @dialog
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
gint
|
|
|
|
gtk_print_unix_dialog_get_current_page (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), -1);
|
|
|
|
|
|
|
|
return dialog->priv->current_page;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
set_active_printer (GtkPrintUnixDialog *dialog,
|
|
|
|
const gchar *printer_name)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter, filter_iter;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkPrinter *printer;
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
model = GTK_TREE_MODEL (priv->printer_list);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_first (model, &iter))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (priv->printer_list), &iter,
|
2006-04-21 15:09:32 +00:00
|
|
|
PRINTER_LIST_COL_PRINTER_OBJ, &printer, -1);
|
|
|
|
if (printer == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strcmp (gtk_printer_get_name (printer), printer_name) == 0)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_tree_model_filter_convert_child_iter_to_iter (priv->printer_list_filter,
|
2006-04-21 15:09:32 +00:00
|
|
|
&filter_iter, &iter);
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
|
|
|
|
priv->internal_printer_change = TRUE;
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_tree_selection_select_iter (selection, &filter_iter);
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->internal_printer_change = FALSE;
|
|
|
|
g_free (priv->waiting_for_printer);
|
|
|
|
priv->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_object_unref (printer);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (printer);
|
|
|
|
|
|
|
|
} while (gtk_tree_model_iter_next (model, &iter));
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_set_settings:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
* @settings: a #GtkPrintSettings, or %NULL
|
|
|
|
*
|
|
|
|
* Sets the #GtkPrintSettings for the #GtkPrintUnixDialog. Typically,
|
|
|
|
* this is used to restore saved print settings from a previous print
|
|
|
|
* operation before the print dialog is shown.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
2006-04-21 15:09:32 +00:00
|
|
|
void
|
|
|
|
gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPrintSettings *settings)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv;
|
2006-06-12 04:39:55 +00:00
|
|
|
const gchar *printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPageRange *ranges;
|
2006-06-12 04:39:55 +00:00
|
|
|
gint num_ranges;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
g_return_if_fail (settings == NULL || GTK_IS_PRINT_SETTINGS (settings));
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = dialog->priv;
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
if (settings != NULL)
|
|
|
|
{
|
|
|
|
dialog_set_collate (dialog, gtk_print_settings_get_collate (settings));
|
|
|
|
dialog_set_reverse (dialog, gtk_print_settings_get_reverse (settings));
|
2006-05-12 09:47:58 +00:00
|
|
|
dialog_set_n_copies (dialog, gtk_print_settings_get_n_copies (settings));
|
2006-04-21 15:09:32 +00:00
|
|
|
dialog_set_scale (dialog, gtk_print_settings_get_scale (settings));
|
|
|
|
dialog_set_page_set (dialog, gtk_print_settings_get_page_set (settings));
|
|
|
|
dialog_set_print_pages (dialog, gtk_print_settings_get_print_pages (settings));
|
|
|
|
ranges = gtk_print_settings_get_page_ranges (settings, &num_ranges);
|
|
|
|
if (ranges)
|
2006-06-30 10:42:31 +00:00
|
|
|
{
|
|
|
|
dialog_set_page_ranges (dialog, ranges, num_ranges);
|
|
|
|
g_free (ranges);
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->format_for_printer =
|
2006-04-21 15:09:32 +00:00
|
|
|
g_strdup (gtk_print_settings_get (settings, "format-for-printer"));
|
|
|
|
}
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->initial_settings)
|
|
|
|
g_object_unref (priv->initial_settings);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->initial_settings = settings;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
g_free (priv->waiting_for_printer);
|
|
|
|
priv->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
if (settings)
|
|
|
|
{
|
|
|
|
g_object_ref (settings);
|
|
|
|
|
|
|
|
printer = gtk_print_settings_get_printer (settings);
|
|
|
|
|
|
|
|
if (printer && !set_active_printer (dialog, printer))
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->waiting_for_printer = g_strdup (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (dialog), "print-settings");
|
|
|
|
}
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_get_settings:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
*
|
|
|
|
* Gets a new #GtkPrintSettings object that represents the
|
|
|
|
* current values in the print dialog. Note that this creates a
|
|
|
|
* <emphasis>new object</emphasis>, and you need to unref it
|
|
|
|
* if don't want to keep it.
|
|
|
|
*
|
|
|
|
* Returns: a new #GtkPrintSettings object with the values from @dialog
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrintSettings *
|
|
|
|
gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog)
|
|
|
|
{
|
2006-05-02 12:48:52 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
GtkPrintSettings *settings;
|
|
|
|
GtkPrintPages print_pages;
|
|
|
|
GtkPageRange *ranges;
|
2006-06-12 04:39:55 +00:00
|
|
|
gint n_ranges;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-04-24 09:27:40 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), NULL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
priv = dialog->priv;
|
2006-04-21 15:09:32 +00:00
|
|
|
settings = gtk_print_settings_new ();
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
gtk_print_settings_set_printer (settings,
|
2006-05-02 12:48:52 +00:00
|
|
|
gtk_printer_get_name (priv->current_printer));
|
2006-04-21 15:09:32 +00:00
|
|
|
else
|
|
|
|
gtk_print_settings_set_printer (settings, "default");
|
|
|
|
|
|
|
|
gtk_print_settings_set (settings, "format-for-printer",
|
2006-05-02 12:48:52 +00:00
|
|
|
priv->format_for_printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
gtk_print_settings_set_collate (settings,
|
|
|
|
dialog_get_collate (dialog));
|
|
|
|
|
|
|
|
gtk_print_settings_set_reverse (settings,
|
|
|
|
dialog_get_reverse (dialog));
|
|
|
|
|
2006-05-12 09:47:58 +00:00
|
|
|
gtk_print_settings_set_n_copies (settings,
|
|
|
|
dialog_get_n_copies (dialog));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
gtk_print_settings_set_scale (settings,
|
|
|
|
dialog_get_scale (dialog));
|
|
|
|
|
|
|
|
gtk_print_settings_set_page_set (settings,
|
|
|
|
dialog_get_page_set (dialog));
|
|
|
|
|
|
|
|
print_pages = dialog_get_print_pages (dialog);
|
|
|
|
gtk_print_settings_set_print_pages (settings, print_pages);
|
|
|
|
|
|
|
|
ranges = dialog_get_page_ranges (dialog, &n_ranges);
|
|
|
|
if (ranges)
|
|
|
|
{
|
|
|
|
gtk_print_settings_set_page_ranges (settings, ranges, n_ranges);
|
|
|
|
g_free (ranges);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: print when. How to handle? */
|
|
|
|
|
2006-05-02 12:48:52 +00:00
|
|
|
if (priv->current_printer)
|
|
|
|
_gtk_printer_get_settings_from_options (priv->current_printer,
|
|
|
|
priv->options,
|
2006-04-21 15:09:32 +00:00
|
|
|
settings);
|
|
|
|
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
2006-06-29 09:18:07 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_add_custom_tab:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
|
|
|
* @child: the widget to put in the custom tab
|
|
|
|
* @tab_label: the widget to use as tab label
|
|
|
|
*
|
|
|
|
* Adds a custom tab to the print dialog.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
2006-05-23 08:09:08 +00:00
|
|
|
void
|
|
|
|
gtk_print_unix_dialog_add_custom_tab (GtkPrintUnixDialog *dialog,
|
2006-06-12 04:39:55 +00:00
|
|
|
GtkWidget *child,
|
|
|
|
GtkWidget *tab_label)
|
2006-05-23 08:09:08 +00:00
|
|
|
{
|
|
|
|
gtk_notebook_insert_page (GTK_NOTEBOOK (dialog->priv->notebook),
|
|
|
|
child, tab_label, 2);
|
|
|
|
gtk_widget_show (child);
|
|
|
|
gtk_widget_show (tab_label);
|
|
|
|
}
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
/**
|
|
|
|
* gtk_print_unix_dialog_set_manual_capabilities:
|
|
|
|
* @dialog: a #GtkPrintUnixDialog
|
2006-06-29 09:18:07 +00:00
|
|
|
* @capabilities: the printing capabilities of your application
|
2006-05-24 10:50:57 +00:00
|
|
|
*
|
|
|
|
* This lets you specify the printing capabilities your application
|
|
|
|
* supports. For instance, if you can handle scaling the output then
|
|
|
|
* you pass #GTK_PRINT_CAPABILITY_SCALE. If you don't pass that, then
|
|
|
|
* the dialog will only let you select the scale if the printing
|
|
|
|
* system automatically handles scaling.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
void
|
2006-06-12 16:47:41 +00:00
|
|
|
gtk_print_unix_dialog_set_manual_capabilities (GtkPrintUnixDialog *dialog,
|
|
|
|
GtkPrintCapabilities capabilities)
|
2006-05-24 10:50:57 +00:00
|
|
|
{
|
2006-08-17 04:48:39 +00:00
|
|
|
GtkPrintUnixDialogPrivate *priv = dialog->priv;
|
|
|
|
|
|
|
|
priv->manual_capabilities = capabilities;
|
2006-05-24 10:50:57 +00:00
|
|
|
update_dialog_from_capabilities (dialog);
|
2006-08-17 04:48:39 +00:00
|
|
|
|
|
|
|
if (priv->current_printer)
|
|
|
|
{
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->printer_treeview));
|
|
|
|
|
|
|
|
g_object_unref (priv->current_printer);
|
|
|
|
priv->current_printer = NULL;
|
|
|
|
priv->internal_printer_change = TRUE;
|
|
|
|
selected_printer_changed (selection, dialog);
|
|
|
|
priv->internal_printer_change = FALSE;
|
|
|
|
}
|
2006-05-24 10:50:57 +00:00
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
#define __GTK_PRINT_UNIX_DIALOG_C__
|
|
|
|
#include "gtkaliasdef.c"
|
2006-06-12 17:45:49 +00:00
|
|
|
|