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>
|
2007-12-31 00:04:32 +00:00
|
|
|
|
* Copyright © 2006, 2007 Christian Persch
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2007-05-23 15:06:03 +00:00
|
|
|
|
#include <ctype.h>
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtkprintunixdialog.h"
|
|
|
|
|
|
|
|
|
|
#include "gtkcustompaperunixdialog.h"
|
2019-05-26 21:57:23 +00:00
|
|
|
|
#include "gtkprintbackendprivate.h"
|
2019-05-26 20:29:57 +00:00
|
|
|
|
#include "gtkprinterprivate.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtkprinteroptionwidget.h"
|
|
|
|
|
#include "gtkprintutils.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkspinbutton.h"
|
|
|
|
|
#include "gtkimage.h"
|
|
|
|
|
#include "gtknotebook.h"
|
|
|
|
|
#include "gtkscrolledwindow.h"
|
|
|
|
|
#include "gtktogglebutton.h"
|
|
|
|
|
#include "gtkdrawingarea.h"
|
2011-08-28 05:34:17 +00:00
|
|
|
|
#include "gtkbox.h"
|
|
|
|
|
#include "gtkgrid.h"
|
2006-04-21 15:09:32 +00:00
|
|
|
|
#include "gtkframe.h"
|
|
|
|
|
#include "gtklabel.h"
|
2007-09-07 20:03:22 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
2008-03-12 18:02:29 +00:00
|
|
|
|
#include "gtkmessagedialog.h"
|
|
|
|
|
#include "gtkbutton.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
#include "gtktypebuiltins.h"
|
2013-12-08 14:38:43 +00:00
|
|
|
|
#include "gtkdialogprivate.h"
|
2015-11-07 05:57:03 +00:00
|
|
|
|
#include "gtkstylecontextprivate.h"
|
2015-11-10 12:45:56 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2008-03-12 18:02:29 +00:00
|
|
|
|
|
2011-04-17 23:07:41 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* GtkPrintUnixDialog:
|
2011-04-17 23:07:41 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* `GtkPrintUnixDialog` implements a print dialog for platforms
|
|
|
|
|
* which don’t provide a native print dialog, like Unix.
|
2011-04-17 23:07:41 +00:00
|
|
|
|
*
|
2021-02-27 23:22:52 +00:00
|
|
|
|
* ![An example GtkPrintUnixDialog](printdialog.png)
|
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* It can be used very much like any other GTK dialog, at the cost of
|
|
|
|
|
* the portability offered by the high-level printing API with
|
|
|
|
|
* [class@Gtk.PrintOperation].
|
|
|
|
|
*
|
|
|
|
|
* In order to print something with `GtkPrintUnixDialog`, you need to
|
|
|
|
|
* use [method@Gtk.PrintUnixDialog.get_selected_printer] to obtain a
|
|
|
|
|
* [class@Gtk.Printer] object and use it to construct a [class@Gtk.PrintJob]
|
|
|
|
|
* using [ctor@Gtk.PrintJob.new].
|
|
|
|
|
*
|
|
|
|
|
* `GtkPrintUnixDialog` uses the following response values:
|
2011-04-17 23:07:41 +00:00
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* - %GTK_RESPONSE_OK: for the “Print” button
|
|
|
|
|
* - %GTK_RESPONSE_APPLY: for the “Preview” button
|
|
|
|
|
* - %GTK_RESPONSE_CANCEL: for the “Cancel” button
|
2011-04-17 23:07:41 +00:00
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # GtkPrintUnixDialog as GtkBuildable
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* The `GtkPrintUnixDialog` implementation of the `GtkBuildable` interface
|
|
|
|
|
* exposes its @notebook internal children with the name “notebook”.
|
2011-04-17 23:07:41 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* An example of a `GtkPrintUnixDialog` UI definition fragment:
|
|
|
|
|
*
|
|
|
|
|
* ```xml
|
2011-04-17 23:07:41 +00:00
|
|
|
|
* <object class="GtkPrintUnixDialog" id="dialog1">
|
|
|
|
|
* <child internal-child="notebook">
|
|
|
|
|
* <object class="GtkNotebook" id="notebook">
|
|
|
|
|
* <child>
|
2019-04-05 18:38:00 +00:00
|
|
|
|
* <object type="GtkNotebookPage">
|
2011-04-17 23:07:41 +00:00
|
|
|
|
* <property name="tab_expand">False</property>
|
|
|
|
|
* <property name="tab_fill">False</property>
|
2019-04-05 18:38:00 +00:00
|
|
|
|
* <property name="tab">
|
|
|
|
|
* <object class="GtkLabel" id="tablabel">
|
|
|
|
|
* <property name="label">Tab label</property>
|
|
|
|
|
* </object>
|
|
|
|
|
* </property>
|
|
|
|
|
* <property name="child">
|
|
|
|
|
* <object class="GtkLabel" id="tabcontent">
|
|
|
|
|
* <property name="label">Content on notebook tab</property>
|
|
|
|
|
* </object>
|
|
|
|
|
* </property>
|
|
|
|
|
* </object>
|
2011-04-17 23:07:41 +00:00
|
|
|
|
* </child>
|
|
|
|
|
* </object>
|
|
|
|
|
* </child>
|
|
|
|
|
* </object>
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* ```
|
2016-01-14 04:37:08 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* `GtkPrintUnixDialog` has a single CSS node with name window. The style classes
|
2020-06-06 06:13:00 +00:00
|
|
|
|
* dialog and print are added.
|
2011-04-17 23:07:41 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2011-01-03 17:51:22 +00:00
|
|
|
|
#define EXAMPLE_PAGE_AREA_SIZE 110
|
2009-07-10 09:28:31 +00:00
|
|
|
|
#define RULER_DISTANCE 7.5
|
|
|
|
|
#define RULER_RADIUS 2
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_print_unix_dialog_constructed (GObject *object);
|
2020-05-05 20:51:33 +00:00
|
|
|
|
static void gtk_print_unix_dialog_dispose (GObject *object);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void gtk_print_unix_dialog_finalize (GObject *object);
|
|
|
|
|
static void gtk_print_unix_dialog_set_property (GObject *object,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void gtk_print_unix_dialog_get_property (GObject *object,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void unschedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static void selected_printer_changed (GtkPrintUnixDialog *dialog);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void clear_per_printer_ui (GtkPrintUnixDialog *dialog);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static void printer_added_cb (GListModel *model,
|
|
|
|
|
guint position,
|
|
|
|
|
guint removed,
|
|
|
|
|
guint added,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void printer_status_cb (GtkPrintBackend *backend,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrinter *printer,
|
|
|
|
|
GtkPrintUnixDialog *dialog);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void update_collate_icon (GtkToggleButton *toggle_button,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog);
|
2020-04-30 17:45:01 +00:00
|
|
|
|
static void error_dialogs (GtkPrintUnixDialog *print_dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int print_dialog_response_id,
|
2013-03-28 06:06:05 +00:00
|
|
|
|
gpointer data);
|
2019-06-13 21:11:56 +00:00
|
|
|
|
static gboolean page_range_entry_focus_changed (GtkWidget *entry,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GtkPrintUnixDialog *dialog);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
static void update_page_range_entry_sensitivity(GtkWidget *button,
|
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
|
static void update_print_at_entry_sensitivity (GtkWidget *button,
|
|
|
|
|
GtkPrintUnixDialog *dialog);
|
|
|
|
|
static void update_print_at_option (GtkPrintUnixDialog *dialog);
|
|
|
|
|
static void update_dialog_from_capabilities (GtkPrintUnixDialog *dialog);
|
2016-11-18 05:32:27 +00:00
|
|
|
|
static void draw_collate (GtkDrawingArea *da,
|
2013-03-28 06:06:05 +00:00
|
|
|
|
cairo_t *cr,
|
2016-11-18 05:32:27 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static gboolean is_printer_active (gpointer item,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static int default_printer_list_sort_func (gconstpointer a,
|
|
|
|
|
gconstpointer b,
|
2013-03-28 06:06:05 +00:00
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void update_number_up_layout (GtkPrintUnixDialog *dialog);
|
2016-11-18 05:32:27 +00:00
|
|
|
|
static void draw_page (GtkDrawingArea *da,
|
2013-03-28 06:06:05 +00:00
|
|
|
|
cairo_t *cr,
|
2016-11-18 05:32:27 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static gboolean dialog_get_collate (GtkPrintUnixDialog *dialog);
|
|
|
|
|
static gboolean dialog_get_reverse (GtkPrintUnixDialog *dialog);
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int dialog_get_n_copies (GtkPrintUnixDialog *dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2008-09-17 22:07:10 +00:00
|
|
|
|
static gboolean set_active_printer (GtkPrintUnixDialog *dialog,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *printer_name);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
static void redraw_page_layout_preview (GtkPrintUnixDialog *dialog);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static GListModel *load_print_backends (GtkPrintUnixDialog *dialog);
|
2008-07-15 17:34:34 +00:00
|
|
|
|
|
2007-09-07 20:03:22 +00:00
|
|
|
|
/* GtkBuildable */
|
|
|
|
|
static void gtk_print_unix_dialog_buildable_init (GtkBuildableIface *iface);
|
|
|
|
|
static GObject *gtk_print_unix_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *childname);
|
2007-09-07 20:03:22 +00:00
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static const char common_paper_sizes[][16] = {
|
2009-07-10 09:28:31 +00:00
|
|
|
|
"na_letter",
|
|
|
|
|
"na_legal",
|
|
|
|
|
"iso_a4",
|
|
|
|
|
"iso_a5",
|
|
|
|
|
"roc_16k",
|
|
|
|
|
"iso_b5",
|
|
|
|
|
"jis_b5",
|
|
|
|
|
"na_number-10",
|
|
|
|
|
"iso_dl",
|
|
|
|
|
"jpn_chou3",
|
|
|
|
|
"na_ledger",
|
|
|
|
|
"iso_a3",
|
|
|
|
|
};
|
|
|
|
|
|
2013-03-28 06:06:05 +00:00
|
|
|
|
/* Keep in line with liststore defined in gtkprintunixdialog.ui */
|
2009-07-10 09:28:31 +00:00
|
|
|
|
enum {
|
|
|
|
|
PAGE_SETUP_LIST_COL_PAGE_SETUP,
|
|
|
|
|
PAGE_SETUP_LIST_COL_IS_SEPARATOR,
|
|
|
|
|
PAGE_SETUP_LIST_N_COLS
|
|
|
|
|
};
|
|
|
|
|
|
2013-03-28 06:06:05 +00:00
|
|
|
|
/* Keep in line with liststore defined in gtkprintunixdialog.ui */
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_PAGE_SETUP,
|
|
|
|
|
PROP_CURRENT_PAGE,
|
|
|
|
|
PROP_PRINT_SETTINGS,
|
2009-06-08 13:37:32 +00:00
|
|
|
|
PROP_SELECTED_PRINTER,
|
|
|
|
|
PROP_MANUAL_CAPABILITIES,
|
|
|
|
|
PROP_SUPPORT_SELECTION,
|
2009-07-10 09:28:31 +00:00
|
|
|
|
PROP_HAS_SELECTION,
|
|
|
|
|
PROP_EMBED_PAGE_SETUP
|
2006-04-21 15:09:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-05-26 19:55:04 +00:00
|
|
|
|
typedef struct _GtkPrintUnixDialogClass GtkPrintUnixDialogClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkPrintUnixDialog
|
|
|
|
|
{
|
|
|
|
|
GtkDialog parent_instance;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *notebook;
|
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GtkWidget *printer_list;
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
|
|
|
|
GtkPrintCapabilities manual_capabilities;
|
|
|
|
|
GtkPrintCapabilities printer_capabilities;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageSetup *page_setup;
|
2008-05-21 02:17:30 +00:00
|
|
|
|
gboolean page_setup_set;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
gboolean embed_page_setup;
|
2020-06-12 12:28:59 +00:00
|
|
|
|
GListStore *page_setup_list;
|
|
|
|
|
GListStore *custom_paper_list;
|
|
|
|
|
GListStore *manage_papers_list;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2009-06-08 13:37:32 +00:00
|
|
|
|
gboolean support_selection;
|
|
|
|
|
gboolean has_selection;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *all_pages_radio;
|
|
|
|
|
GtkWidget *current_page_radio;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
GtkWidget *selection_radio;
|
|
|
|
|
GtkWidget *range_table;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *page_range_radio;
|
|
|
|
|
GtkWidget *page_range_entry;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
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;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
GtkWidget *paper_size_combo;
|
|
|
|
|
GtkWidget *orientation_combo;
|
|
|
|
|
gboolean internal_page_setup_change;
|
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;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
GtkPrinterOptionWidget *number_up_layout;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2009-06-28 20:13:33 +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-06-12 04:39:55 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintSettings *initial_settings;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
|
|
|
|
GtkPrinterOption *number_up_layout_n_option;
|
|
|
|
|
GtkPrinterOption *number_up_layout_2_option;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
|
|
|
|
/* 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
|
2006-04-21 15:09:32 +00:00
|
|
|
|
* 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;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GList *print_backends;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinter *current_printer;
|
2008-05-27 04:48:31 +00:00
|
|
|
|
GtkPrinter *request_details_printer;
|
2010-10-08 00:37:23 +00:00
|
|
|
|
gulong request_details_tag;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinterOptionSet *options;
|
|
|
|
|
gulong options_changed_handler;
|
|
|
|
|
gulong mark_conflicts_id;
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *format_for_printer;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int current_page;
|
2020-05-07 07:01:50 +00:00
|
|
|
|
GtkCssNode *collate_paper_node;
|
|
|
|
|
GtkCssNode *page_layout_paper_node;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
struct _GtkPrintUnixDialogClass
|
|
|
|
|
{
|
|
|
|
|
GtkDialogClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2007-09-07 20:03:22 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkPrintUnixDialog, gtk_print_unix_dialog, GTK_TYPE_DIALOG,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_print_unix_dialog_buildable_init))
|
|
|
|
|
|
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
is_default_printer (GtkPrintUnixDialog *dialog,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrinter *printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->format_for_printer)
|
|
|
|
|
return strcmp (dialog->format_for_printer,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
gtk_printer_get_name (printer)) == 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
object_class->constructed = gtk_print_unix_dialog_constructed;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
object_class->finalize = gtk_print_unix_dialog_finalize;
|
2020-05-05 20:51:33 +00:00
|
|
|
|
object_class->dispose = gtk_print_unix_dialog_dispose;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
object_class->set_property = gtk_print_unix_dialog_set_property;
|
|
|
|
|
object_class->get_property = gtk_print_unix_dialog_get_property;
|
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:page-setup: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_page_setup org.gtk.Property.set=gtk_print_unix_dialog_set_page_setup)
|
|
|
|
|
*
|
|
|
|
|
* The `GtkPageSetup` object to use.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
PROP_PAGE_SETUP,
|
|
|
|
|
g_param_spec_object ("page-setup",
|
|
|
|
|
P_("Page Setup"),
|
|
|
|
|
P_("The GtkPageSetup to use"),
|
|
|
|
|
GTK_TYPE_PAGE_SETUP,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:current-page: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_current_page org.gtk.Property.set=gtk_print_unix_dialog_set_current_page)
|
|
|
|
|
*
|
|
|
|
|
* The current page in the document.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
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));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:print-settings: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_settings org.gtk.Property.set=gtk_print_unix_dialog_set_settings)
|
|
|
|
|
*
|
|
|
|
|
* The `GtkPrintSettings` object used for this dialog.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
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));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:selected-printer: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_selected_printer)
|
|
|
|
|
*
|
|
|
|
|
* The `GtkPrinter` which is selected.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
PROP_SELECTED_PRINTER,
|
|
|
|
|
g_param_spec_object ("selected-printer",
|
|
|
|
|
P_("Selected Printer"),
|
|
|
|
|
P_("The GtkPrinter which is selected"),
|
|
|
|
|
GTK_TYPE_PRINTER,
|
|
|
|
|
GTK_PARAM_READABLE));
|
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:manual-capabilities: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_manual_capabilities org.gtk.Property.set=gtk_print_unix_dialog_set_manual_capabilities)
|
|
|
|
|
*
|
|
|
|
|
* Capabilities the application can handle.
|
|
|
|
|
*/
|
2009-06-08 13:37:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
PROP_MANUAL_CAPABILITIES,
|
|
|
|
|
g_param_spec_flags ("manual-capabilities",
|
2010-08-10 08:23:49 +00:00
|
|
|
|
P_("Manual Capabilities"),
|
2009-06-28 20:13:33 +00:00
|
|
|
|
P_("Capabilities the application can handle"),
|
|
|
|
|
GTK_TYPE_PRINT_CAPABILITIES,
|
|
|
|
|
0,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
2009-06-08 13:37:32 +00:00
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:support-selection: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_support_selection org.gtk.Property.set=gtk_print_unix_dialog_set_support_selection)
|
|
|
|
|
*
|
|
|
|
|
* Whether the dialog supports selection.
|
|
|
|
|
*/
|
2009-06-08 13:37:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
PROP_SUPPORT_SELECTION,
|
|
|
|
|
g_param_spec_boolean ("support-selection",
|
|
|
|
|
P_("Support Selection"),
|
|
|
|
|
P_("Whether the dialog supports selection"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
2009-06-08 13:37:32 +00:00
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:has-selection: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_has_selection org.gtk.Property.set=gtk_print_unix_dialog_set_has_selection)
|
|
|
|
|
*
|
|
|
|
|
* Whether the application has a selection.
|
|
|
|
|
*/
|
2009-06-08 13:37:32 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
PROP_HAS_SELECTION,
|
|
|
|
|
g_param_spec_boolean ("has-selection",
|
|
|
|
|
P_("Has Selection"),
|
|
|
|
|
P_("Whether the application has a selection"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
2021-02-27 15:55:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkPrintUnixDialog:embed-page-setup: (attributes org.gtk.Property.get=gtk_print_unix_dialog_get_embed_page_setup org.gtk.Property.set=gtk_print_unix_dialog_set_embed_page_setup)
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if the page setup controls are embedded.
|
|
|
|
|
*/
|
2009-07-10 09:28:31 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
2012-06-23 17:08:03 +00:00
|
|
|
|
PROP_EMBED_PAGE_SETUP,
|
|
|
|
|
g_param_spec_boolean ("embed-page-setup",
|
|
|
|
|
P_("Embed Page Setup"),
|
|
|
|
|
P_("TRUE if page setup combos are embedded in GtkPrintUnixDialog"),
|
|
|
|
|
FALSE,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2013-03-28 06:06:05 +00:00
|
|
|
|
/* Bind class to template
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class,
|
2014-01-23 23:59:20 +00:00
|
|
|
|
"/org/gtk/libgtk/ui/gtkprintunixdialog.ui");
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* GtkTreeView / GtkTreeModel */
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, printer_list);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* General Widgetry */
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, notebook);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, all_pages_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, all_pages_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, current_page_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, selection_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, range_table);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, page_range_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, page_range_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, copies_spin);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, collate_check);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, reverse_check);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, collate_image);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, page_layout_preview);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, scale_spin);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, page_set_combo);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, print_now_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, print_at_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, print_at_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, print_hold_radio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, paper_size_combo);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, orientation_combo);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, conflicts_widget);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, job_page);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, finishing_table);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, finishing_page);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, image_quality_table);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, image_quality_page);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, color_table);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, color_page);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, advanced_vbox);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, advanced_page);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, extension_point);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* GtkPrinterOptionWidgets... */
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, pages_per_sheet);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, duplex);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, paper_type);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, paper_source);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, output_tray);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, job_prio);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, billing_info);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, cover_before);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, cover_after);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkPrintUnixDialog, number_up_layout);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* Callbacks handled in the UI */
|
2013-07-26 17:49:49 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, error_dialogs);
|
2019-06-13 21:11:56 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, page_range_entry_focus_changed);
|
2013-07-26 17:49:49 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, update_page_range_entry_sensitivity);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, update_print_at_entry_sensitivity);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, update_print_at_option);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, update_dialog_from_capabilities);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, update_collate_icon);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, update_number_up_layout);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-12 18:02:29 +00:00
|
|
|
|
/* Returns a toplevel GtkWindow, or NULL if none */
|
|
|
|
|
static GtkWindow *
|
|
|
|
|
get_toplevel (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *toplevel = NULL;
|
|
|
|
|
|
2019-05-20 04:47:50 +00:00
|
|
|
|
toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
|
2019-05-20 03:31:03 +00:00
|
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
2008-03-12 18:02:29 +00:00
|
|
|
|
return GTK_WINDOW (toplevel);
|
2019-05-20 03:31:03 +00:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2008-03-12 18:02:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 07:11:31 +00:00
|
|
|
|
static void
|
|
|
|
|
set_busy_cursor (GtkPrintUnixDialog *dialog,
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gboolean busy)
|
2009-08-06 07:11:31 +00:00
|
|
|
|
{
|
2010-08-15 15:28:38 +00:00
|
|
|
|
GtkWidget *widget;
|
2009-08-06 07:11:31 +00:00
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
|
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (dialog));
|
2010-08-15 15:28:38 +00:00
|
|
|
|
widget = GTK_WIDGET (toplevel);
|
|
|
|
|
|
|
|
|
|
if (!toplevel || !gtk_widget_get_realized (widget))
|
2009-08-06 07:11:31 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (busy)
|
2017-11-04 00:37:03 +00:00
|
|
|
|
gtk_widget_set_cursor_from_name (widget, "progress");
|
2009-08-06 07:11:31 +00:00
|
|
|
|
else
|
2017-11-04 00:37:03 +00:00
|
|
|
|
gtk_widget_set_cursor (widget, NULL);
|
2009-08-06 07:11:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 17:45:01 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
GMainLoop *loop;
|
|
|
|
|
int response;
|
|
|
|
|
} ConfirmationData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_confirmation_dialog_response (GtkWidget *dialog,
|
|
|
|
|
int response,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
ConfirmationData *data = user_data;
|
|
|
|
|
|
|
|
|
|
data->response = response;
|
|
|
|
|
|
|
|
|
|
g_main_loop_quit (data->loop);
|
|
|
|
|
|
|
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
/* This function handles error messages before printing.
|
2008-03-12 18:02:29 +00:00
|
|
|
|
*/
|
2020-04-30 17:45:01 +00:00
|
|
|
|
static void
|
2020-03-28 20:04:30 +00:00
|
|
|
|
error_dialogs (GtkPrintUnixDialog *dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int dialog_response_id,
|
2008-07-15 17:34:34 +00:00
|
|
|
|
gpointer data)
|
2008-03-12 18:02:29 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog != NULL && dialog_response_id == GTK_RESPONSE_OK)
|
2008-03-12 18:02:29 +00:00
|
|
|
|
{
|
2020-04-30 17:45:01 +00:00
|
|
|
|
GtkPrinter *printer = gtk_print_unix_dialog_get_selected_printer (dialog);
|
2008-03-12 18:02:29 +00:00
|
|
|
|
|
2009-08-06 07:11:31 +00:00
|
|
|
|
if (printer != NULL)
|
2008-03-12 18:02:29 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->request_details_tag || !gtk_printer_is_accepting_jobs (printer))
|
2009-08-06 07:11:31 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_signal_stop_emission_by_name (dialog, "response");
|
2020-04-30 17:45:01 +00:00
|
|
|
|
return;
|
2009-08-06 07:11:31 +00:00
|
|
|
|
}
|
2008-03-12 18:02:29 +00:00
|
|
|
|
|
2012-06-23 17:08:03 +00:00
|
|
|
|
/* Shows overwrite confirmation dialog in the case of printing
|
|
|
|
|
* to file which already exists.
|
|
|
|
|
*/
|
2009-08-06 07:11:31 +00:00
|
|
|
|
if (gtk_printer_is_virtual (printer))
|
2008-03-12 18:02:29 +00:00
|
|
|
|
{
|
2020-04-30 17:45:01 +00:00
|
|
|
|
GtkPrinterOption *option =
|
|
|
|
|
gtk_printer_option_set_lookup (dialog->options,
|
|
|
|
|
"gtk-main-page-custom-input");
|
2008-03-12 18:02:29 +00:00
|
|
|
|
|
2009-08-06 07:11:31 +00:00
|
|
|
|
if (option != NULL &&
|
|
|
|
|
option->type == GTK_PRINTER_OPTION_TYPE_FILESAVE)
|
2008-03-12 18:02:29 +00:00
|
|
|
|
{
|
2020-04-30 17:45:01 +00:00
|
|
|
|
GFile *file = g_file_new_for_uri (option->value);
|
2008-09-30 08:45:01 +00:00
|
|
|
|
|
2013-11-26 15:06:48 +00:00
|
|
|
|
if (g_file_query_exists (file, NULL))
|
2008-03-12 18:02:29 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
GtkWidget *message_dialog;
|
2020-04-30 17:45:01 +00:00
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
|
char *basename;
|
|
|
|
|
char *dirname;
|
|
|
|
|
GFile *parent;
|
2014-02-19 05:31:40 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
toplevel = get_toplevel (GTK_WIDGET (dialog));
|
2009-08-06 07:11:31 +00:00
|
|
|
|
|
|
|
|
|
basename = g_file_get_basename (file);
|
2014-02-19 05:31:40 +00:00
|
|
|
|
parent = g_file_get_parent (file);
|
|
|
|
|
dirname = g_file_get_parse_name (parent);
|
|
|
|
|
g_object_unref (parent);
|
2009-08-06 07:11:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
message_dialog = gtk_message_dialog_new (toplevel,
|
|
|
|
|
GTK_DIALOG_MODAL |
|
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
|
GTK_BUTTONS_NONE,
|
|
|
|
|
_("A file named “%s” already exists. Do you want to replace it?"),
|
|
|
|
|
basename);
|
2009-08-06 07:11:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
|
2013-07-18 02:37:50 +00:00
|
|
|
|
_("The file already exists in “%s”. Replacing it will "
|
2009-08-06 07:11:31 +00:00
|
|
|
|
"overwrite its contents."),
|
|
|
|
|
dirname);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_dialog_add_button (GTK_DIALOG (message_dialog),
|
2014-01-20 14:38:42 +00:00
|
|
|
|
_("_Cancel"),
|
|
|
|
|
GTK_RESPONSE_CANCEL);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_dialog_add_button (GTK_DIALOG (message_dialog),
|
2014-01-20 14:38:42 +00:00
|
|
|
|
_("_Replace"),
|
|
|
|
|
GTK_RESPONSE_ACCEPT);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (message_dialog),
|
2009-08-06 07:11:31 +00:00
|
|
|
|
GTK_RESPONSE_ACCEPT);
|
|
|
|
|
|
2010-08-24 14:10:38 +00:00
|
|
|
|
if (gtk_window_has_group (toplevel))
|
|
|
|
|
gtk_window_group_add_window (gtk_window_get_group (toplevel),
|
2020-03-28 20:04:30 +00:00
|
|
|
|
GTK_WINDOW (message_dialog));
|
2009-08-06 07:11:31 +00:00
|
|
|
|
|
2020-04-30 17:45:01 +00:00
|
|
|
|
gtk_window_present (GTK_WINDOW (message_dialog));
|
|
|
|
|
|
|
|
|
|
/* Block on the confirmation dialog until we have a response,
|
|
|
|
|
* so that we can stop the "response" signal emission on the
|
|
|
|
|
* print dialog
|
|
|
|
|
*/
|
|
|
|
|
ConfirmationData cdata;
|
|
|
|
|
|
|
|
|
|
cdata.loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
cdata.response = 0;
|
|
|
|
|
|
|
|
|
|
g_signal_connect (message_dialog, "response",
|
|
|
|
|
G_CALLBACK (on_confirmation_dialog_response),
|
|
|
|
|
&cdata);
|
2009-08-06 07:11:31 +00:00
|
|
|
|
|
2020-04-30 17:45:01 +00:00
|
|
|
|
g_main_loop_run (cdata.loop);
|
|
|
|
|
g_main_loop_unref (cdata.loop);
|
2009-08-06 07:11:31 +00:00
|
|
|
|
|
|
|
|
|
g_free (dirname);
|
|
|
|
|
g_free (basename);
|
|
|
|
|
|
2020-04-30 17:45:01 +00:00
|
|
|
|
if (cdata.response != GTK_RESPONSE_ACCEPT)
|
|
|
|
|
g_signal_stop_emission_by_name (dialog, "response");
|
2008-03-12 18:02:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 07:11:31 +00:00
|
|
|
|
g_object_unref (file);
|
|
|
|
|
}
|
2008-03-12 18:02:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static char *
|
|
|
|
|
get_printer_key (GtkPrinter *printer)
|
|
|
|
|
{
|
|
|
|
|
return g_strconcat ("", gtk_printer_get_name (printer), " ", gtk_printer_get_location (printer), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
static void
|
|
|
|
|
setup_paper_size_item (GtkSignalListItemFactory *factory,
|
|
|
|
|
GtkListItem *item)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
|
|
label = gtk_label_new ("");
|
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
|
gtk_list_item_set_child (item, label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bind_paper_size_list_item (GtkSignalListItemFactory *factory,
|
|
|
|
|
GtkListItem *item,
|
|
|
|
|
GtkPrintUnixDialog *self)
|
|
|
|
|
{
|
|
|
|
|
GtkPageSetup *page_setup;
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
guint pos;
|
|
|
|
|
GListModel *papers;
|
|
|
|
|
GListModel *model;
|
|
|
|
|
gpointer first;
|
|
|
|
|
|
|
|
|
|
page_setup = gtk_list_item_get_item (item);
|
|
|
|
|
label = gtk_list_item_get_child (item);
|
|
|
|
|
|
|
|
|
|
pos = gtk_list_item_get_position (item);
|
|
|
|
|
papers = gtk_drop_down_get_model (GTK_DROP_DOWN (self->paper_size_combo));
|
|
|
|
|
model = gtk_flatten_list_model_get_model_for_item (GTK_FLATTEN_LIST_MODEL (papers), pos);
|
|
|
|
|
if (model != G_LIST_MODEL (self->manage_papers_list))
|
|
|
|
|
{
|
|
|
|
|
GtkPaperSize *paper_size = gtk_page_setup_get_paper_size (page_setup);
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), gtk_paper_size_get_display_name (paper_size));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), _("Manage Custom Sizes…"));
|
|
|
|
|
|
|
|
|
|
first = g_list_model_get_item (model, 0);
|
|
|
|
|
g_object_unref (first);
|
|
|
|
|
if (pos != 0 &&
|
|
|
|
|
page_setup == GTK_PAGE_SETUP (first))
|
|
|
|
|
gtk_widget_add_css_class (gtk_widget_get_parent (label), "separator");
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_remove_css_class (gtk_widget_get_parent (label), "separator");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bind_paper_size_item (GtkSignalListItemFactory *factory,
|
|
|
|
|
GtkListItem *item,
|
|
|
|
|
GtkPrintUnixDialog *self)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
|
|
bind_paper_size_list_item (factory, item, self);
|
|
|
|
|
|
|
|
|
|
label = gtk_list_item_get_child (item);
|
|
|
|
|
gtk_widget_remove_css_class (label, "separator-before");
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2014-02-21 14:39:05 +00:00
|
|
|
|
GtkWidget *widget;
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GListModel *model;
|
|
|
|
|
GListModel *sorted;
|
|
|
|
|
GListModel *filtered;
|
|
|
|
|
GListModel *selection;
|
|
|
|
|
GtkSorter *sorter;
|
|
|
|
|
GtkFilter *filter;
|
2020-08-03 19:04:33 +00:00
|
|
|
|
GtkStringFilter *filter1;
|
|
|
|
|
GtkCustomFilter *filter2;
|
2020-06-12 12:28:59 +00:00
|
|
|
|
GtkListItemFactory *factory;
|
|
|
|
|
GListStore *store;
|
|
|
|
|
GListModel *paper_size_list;
|
|
|
|
|
GtkPageSetup *page_setup;
|
2010-07-14 00:11:00 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->print_backends = NULL;
|
|
|
|
|
dialog->current_page = -1;
|
|
|
|
|
dialog->number_up_layout_n_option = NULL;
|
|
|
|
|
dialog->number_up_layout_2_option = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->page_setup = gtk_page_setup_new ();
|
|
|
|
|
dialog->page_setup_set = FALSE;
|
|
|
|
|
dialog->embed_page_setup = FALSE;
|
|
|
|
|
dialog->internal_page_setup_change = FALSE;
|
2020-06-12 12:28:59 +00:00
|
|
|
|
dialog->page_setup_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
|
|
|
|
|
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
|
|
|
|
|
dialog->manage_papers_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
|
|
|
|
|
page_setup = gtk_page_setup_new ();
|
|
|
|
|
g_list_store_append (dialog->manage_papers_list, page_setup);
|
|
|
|
|
g_object_unref (page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->support_selection = FALSE;
|
|
|
|
|
dialog->has_selection = FALSE;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
|
2015-03-05 01:35:09 +00:00
|
|
|
|
g_type_ensure (GTK_TYPE_PRINTER);
|
|
|
|
|
g_type_ensure (GTK_TYPE_PRINTER_OPTION);
|
|
|
|
|
g_type_ensure (GTK_TYPE_PRINTER_OPTION_SET);
|
|
|
|
|
g_type_ensure (GTK_TYPE_PRINTER_OPTION_WIDGET);
|
|
|
|
|
|
2013-03-28 06:06:05 +00:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (dialog));
|
2020-06-06 06:13:00 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (dialog), "print");
|
|
|
|
|
|
2013-12-08 14:38:43 +00:00
|
|
|
|
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
|
|
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
|
|
|
|
_("Pre_view"), GTK_RESPONSE_APPLY,
|
|
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
|
_("_Print"), GTK_RESPONSE_OK,
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
2014-02-21 14:39:05 +00:00
|
|
|
|
widget = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
|
|
|
|
gtk_widget_set_sensitive (widget, FALSE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_visible (dialog->selection_radio, FALSE);
|
|
|
|
|
gtk_widget_set_visible (dialog->conflicts_widget, FALSE);
|
2017-10-07 02:33:24 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
factory = gtk_signal_list_item_factory_new ();
|
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_paper_size_item), dialog);
|
|
|
|
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_paper_size_item), dialog);
|
|
|
|
|
gtk_drop_down_set_factory (GTK_DROP_DOWN (dialog->paper_size_combo), factory);
|
|
|
|
|
g_object_unref (factory);
|
|
|
|
|
|
|
|
|
|
factory = gtk_signal_list_item_factory_new ();
|
|
|
|
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_paper_size_item), dialog);
|
|
|
|
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_paper_size_list_item), dialog);
|
|
|
|
|
gtk_drop_down_set_list_factory (GTK_DROP_DOWN (dialog->paper_size_combo), factory);
|
|
|
|
|
g_object_unref (factory);
|
|
|
|
|
|
|
|
|
|
store = g_list_store_new (G_TYPE_LIST_MODEL);
|
|
|
|
|
g_list_store_append (store, dialog->page_setup_list);
|
|
|
|
|
g_list_store_append (store, dialog->custom_paper_list);
|
|
|
|
|
g_list_store_append (store, dialog->manage_papers_list);
|
2020-07-04 19:47:48 +00:00
|
|
|
|
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
2020-06-12 12:28:59 +00:00
|
|
|
|
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
|
|
|
|
|
g_object_unref (paper_size_list);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* Load backends */
|
2019-12-22 23:09:54 +00:00
|
|
|
|
model = load_print_backends (dialog);
|
2020-08-03 19:54:42 +00:00
|
|
|
|
sorter = GTK_SORTER (gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL));
|
2019-12-22 23:09:54 +00:00
|
|
|
|
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
|
|
|
|
|
|
2020-08-03 19:04:33 +00:00
|
|
|
|
filter = GTK_FILTER (gtk_every_filter_new ());
|
2019-12-22 23:09:54 +00:00
|
|
|
|
|
2020-07-12 05:02:04 +00:00
|
|
|
|
filter1 = gtk_string_filter_new (
|
|
|
|
|
gtk_cclosure_expression_new (G_TYPE_STRING,
|
|
|
|
|
NULL, 0, NULL,
|
|
|
|
|
G_CALLBACK (get_printer_key),
|
|
|
|
|
NULL, NULL));
|
2020-08-03 19:04:33 +00:00
|
|
|
|
gtk_string_filter_set_match_mode (filter1, GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
|
|
|
|
|
gtk_string_filter_set_ignore_case (filter1, TRUE);
|
|
|
|
|
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), GTK_FILTER (filter1));
|
2019-12-22 23:09:54 +00:00
|
|
|
|
|
2020-08-03 19:04:33 +00:00
|
|
|
|
filter2 = gtk_custom_filter_new (is_printer_active, dialog, NULL);
|
|
|
|
|
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), GTK_FILTER (filter2));
|
2019-12-22 23:09:54 +00:00
|
|
|
|
|
|
|
|
|
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
|
|
|
|
|
|
|
|
|
|
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
|
|
|
|
|
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
|
|
|
|
|
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (selection), GTK_INVALID_LIST_POSITION);
|
2020-08-31 21:06:48 +00:00
|
|
|
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (dialog->printer_list), GTK_SELECTION_MODEL (selection));
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), dialog);
|
|
|
|
|
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
|
|
|
|
|
g_object_unref (selection);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
2015-11-10 12:45:56 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (dialog->collate_image),
|
2016-11-18 05:32:27 +00:00
|
|
|
|
draw_collate,
|
|
|
|
|
dialog, NULL);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (dialog->page_layout_preview),
|
2016-11-18 05:32:27 +00:00
|
|
|
|
draw_page,
|
|
|
|
|
dialog, NULL);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_css_node_set_name (gtk_widget_get_css_node (dialog->collate_image), g_quark_from_static_string ("drawing"));
|
|
|
|
|
gtk_css_node_set_name (gtk_widget_get_css_node (dialog->page_layout_preview), g_quark_from_static_string ("drawing"));
|
2020-05-07 07:01:50 +00:00
|
|
|
|
|
|
|
|
|
dialog->collate_paper_node = gtk_css_node_new();
|
|
|
|
|
gtk_css_node_set_name (dialog->collate_paper_node, g_quark_from_static_string ("paper"));
|
|
|
|
|
gtk_css_node_set_parent (dialog->collate_paper_node,
|
|
|
|
|
gtk_widget_get_css_node (dialog->collate_image));
|
|
|
|
|
g_object_unref (dialog->collate_paper_node);
|
|
|
|
|
|
|
|
|
|
dialog->page_layout_paper_node = gtk_css_node_new();
|
|
|
|
|
gtk_css_node_set_name (dialog->page_layout_paper_node, g_quark_from_static_string ("paper"));
|
|
|
|
|
gtk_css_node_set_parent (dialog->page_layout_paper_node,
|
|
|
|
|
gtk_widget_get_css_node (dialog->page_layout_preview));
|
|
|
|
|
g_object_unref (dialog->page_layout_paper_node);
|
2006-05-12 09:47:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_print_unix_dialog_constructed (GObject *object)
|
2013-12-08 14:38:43 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean use_header;
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->constructed (object);
|
2013-12-08 14:38:43 +00:00
|
|
|
|
|
|
|
|
|
g_object_get (object, "use-header-bar", &use_header, NULL);
|
|
|
|
|
if (use_header)
|
|
|
|
|
{
|
|
|
|
|
/* Reorder the preview button */
|
|
|
|
|
GtkWidget *button, *parent;
|
|
|
|
|
button = gtk_dialog_get_widget_for_response (GTK_DIALOG (object), GTK_RESPONSE_APPLY);
|
|
|
|
|
g_object_ref (button);
|
2019-11-01 16:51:42 +00:00
|
|
|
|
parent = gtk_widget_get_ancestor (button, GTK_TYPE_HEADER_BAR);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_remove (GTK_BOX (gtk_widget_get_parent (button)), button);
|
2013-12-08 14:38:43 +00:00
|
|
|
|
gtk_header_bar_pack_end (GTK_HEADER_BAR (parent), button);
|
|
|
|
|
g_object_unref (button);
|
|
|
|
|
}
|
2016-07-02 22:08:38 +00:00
|
|
|
|
|
|
|
|
|
update_dialog_from_capabilities (GTK_PRINT_UNIX_DIALOG (object));
|
2013-12-08 14:38:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
2020-05-05 20:51:33 +00:00
|
|
|
|
gtk_print_unix_dialog_dispose (GObject *object)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-05-05 20:51:33 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
|
2014-02-18 02:40:36 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
/* Make sure we don't destroy custom widgets owned by the backends */
|
2009-06-28 20:13:33 +00:00
|
|
|
|
clear_per_printer_ui (dialog);
|
2014-02-18 02:40:36 +00:00
|
|
|
|
|
2020-05-05 20:51:33 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->dispose (object);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-27 04:48:31 +00:00
|
|
|
|
static void
|
2012-06-23 17:08:03 +00:00
|
|
|
|
disconnect_printer_details_request (GtkPrintUnixDialog *dialog,
|
|
|
|
|
gboolean details_failed)
|
2008-05-27 04:48:31 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->request_details_tag)
|
2008-05-27 04:48:31 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_signal_handler_disconnect (dialog->request_details_printer,
|
|
|
|
|
dialog->request_details_tag);
|
|
|
|
|
dialog->request_details_tag = 0;
|
2009-08-06 07:11:31 +00:00
|
|
|
|
set_busy_cursor (dialog, FALSE);
|
2009-09-23 12:35:26 +00:00
|
|
|
|
if (details_failed)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
gtk_printer_set_state_message (dialog->request_details_printer, _("Getting printer information failed"));
|
|
|
|
|
g_clear_object (&dialog->request_details_printer);
|
2008-05-27 04:48:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_print_unix_dialog_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
|
|
|
|
|
|
|
|
|
|
unschedule_idle_mark_conflicts (dialog);
|
2009-09-23 12:35:26 +00:00
|
|
|
|
disconnect_printer_details_request (dialog, FALSE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->current_printer);
|
|
|
|
|
g_clear_object (&dialog->options);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->number_up_layout_2_option)
|
2008-08-21 10:25:27 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->number_up_layout_2_option->choices[0] = NULL;
|
|
|
|
|
dialog->number_up_layout_2_option->choices[1] = NULL;
|
|
|
|
|
g_free (dialog->number_up_layout_2_option->choices_display[0]);
|
|
|
|
|
g_free (dialog->number_up_layout_2_option->choices_display[1]);
|
|
|
|
|
dialog->number_up_layout_2_option->choices_display[0] = NULL;
|
|
|
|
|
dialog->number_up_layout_2_option->choices_display[1] = NULL;
|
|
|
|
|
g_object_unref (dialog->number_up_layout_2_option);
|
|
|
|
|
dialog->number_up_layout_2_option = NULL;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->number_up_layout_n_option);
|
|
|
|
|
g_clear_object (&dialog->page_setup);
|
|
|
|
|
g_clear_object (&dialog->initial_settings);
|
|
|
|
|
g_clear_pointer (&dialog->waiting_for_printer, (GDestroyNotify)g_free);
|
|
|
|
|
g_clear_pointer (&dialog->format_for_printer, (GDestroyNotify)g_free);
|
2006-05-02 12:48:52 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_list_free (dialog->print_backends);
|
|
|
|
|
dialog->print_backends = NULL;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_clear_object (&dialog->page_setup_list);
|
|
|
|
|
g_clear_object (&dialog->custom_paper_list);
|
|
|
|
|
g_clear_object (&dialog->manage_papers_list);
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2007-09-07 20:03:22 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_print_unix_dialog_buildable_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
|
|
iface->get_internal_child = gtk_print_unix_dialog_buildable_get_internal_child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
|
gtk_print_unix_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *childname)
|
2007-09-07 20:03:22 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (buildable);
|
2019-05-26 20:08:01 +00:00
|
|
|
|
|
2007-09-07 20:03:22 +00:00
|
|
|
|
if (strcmp (childname, "notebook") == 0)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return G_OBJECT (dialog->notebook);
|
2007-09-07 20:03:22 +00:00
|
|
|
|
|
|
|
|
|
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
printer_status_cb (GtkPrintBackend *backend,
|
|
|
|
|
GtkPrinter *printer,
|
|
|
|
|
GtkPrintUnixDialog *dialog)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GListModel *model;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2008-07-15 17:34:34 +00:00
|
|
|
|
/* When the pause state change then we need to update sensitive property
|
2012-06-23 17:08:03 +00:00
|
|
|
|
* of GTK_RESPONSE_OK button inside of selected_printer_changed function.
|
|
|
|
|
*/
|
2019-12-22 23:09:54 +00:00
|
|
|
|
selected_printer_changed (dialog);
|
|
|
|
|
|
2020-08-31 21:06:48 +00:00
|
|
|
|
model = G_LIST_MODEL (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
|
2008-09-17 22:07:10 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_print_backend_printer_list_is_done (backend) &&
|
|
|
|
|
gtk_printer_is_default (printer) &&
|
2019-12-22 23:09:54 +00:00
|
|
|
|
gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (model)) == GTK_INVALID_LIST_POSITION)
|
2008-09-17 22:07:10 +00:00
|
|
|
|
set_active_printer (dialog, gtk_printer_get_name (printer));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-22 23:09:54 +00:00
|
|
|
|
printer_added_cb (GListModel *model,
|
|
|
|
|
guint position,
|
|
|
|
|
guint removed,
|
|
|
|
|
guint added,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
guint i;
|
2007-03-16 05:13:10 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
for (i = position; i < position + added; i++)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GtkPrinter *printer = g_list_model_get_item (model, i);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
if (dialog->waiting_for_printer != NULL &&
|
|
|
|
|
strcmp (gtk_printer_get_name (printer), dialog->waiting_for_printer) == 0)
|
|
|
|
|
{
|
|
|
|
|
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (model), i);
|
|
|
|
|
g_free (dialog->waiting_for_printer);
|
|
|
|
|
dialog->waiting_for_printer = NULL;
|
|
|
|
|
g_object_unref (printer);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (is_default_printer (dialog, printer) &&
|
|
|
|
|
gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (model)) == GTK_INVALID_LIST_POSITION)
|
|
|
|
|
{
|
|
|
|
|
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (model), i);
|
|
|
|
|
g_object_unref (printer);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_object_unref (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static GListModel *
|
2006-04-21 15:09:32 +00:00
|
|
|
|
load_print_backends (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GList *node;
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GListStore *lists;
|
|
|
|
|
|
|
|
|
|
lists = g_list_store_new (G_TYPE_LIST_MODEL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (g_module_supported ())
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->print_backends = gtk_print_backend_load_modules ();
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
for (node = dialog->print_backends; node != NULL; node = node->next)
|
2009-04-21 12:24:32 +00:00
|
|
|
|
{
|
|
|
|
|
GtkPrintBackend *backend = node->data;
|
2019-12-22 23:09:54 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect_object (backend, "printer-status-changed",
|
|
|
|
|
G_CALLBACK (printer_status_cb), G_OBJECT (dialog), 0);
|
|
|
|
|
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
|
2009-04-21 12:24:32 +00:00
|
|
|
|
}
|
2019-12-22 23:09:54 +00:00
|
|
|
|
|
2020-07-26 14:53:55 +00:00
|
|
|
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_unix_dialog_set_property (GObject *object,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
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;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
case PROP_MANUAL_CAPABILITIES:
|
|
|
|
|
gtk_print_unix_dialog_set_manual_capabilities (dialog, g_value_get_flags (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_SUPPORT_SELECTION:
|
|
|
|
|
gtk_print_unix_dialog_set_support_selection (dialog, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_HAS_SELECTION:
|
|
|
|
|
gtk_print_unix_dialog_set_has_selection (dialog, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
case PROP_EMBED_PAGE_SETUP:
|
|
|
|
|
gtk_print_unix_dialog_set_embed_page_setup (dialog, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_print_unix_dialog_get_property (GObject *object,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_PAGE_SETUP:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_object (value, dialog->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_CURRENT_PAGE:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_int (value, dialog->current_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_PRINT_SETTINGS:
|
2007-12-31 00:04:32 +00:00
|
|
|
|
g_value_take_object (value, gtk_print_unix_dialog_get_settings (dialog));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_SELECTED_PRINTER:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_object (value, dialog->current_printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
break;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
case PROP_MANUAL_CAPABILITIES:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_flags (value, dialog->manual_capabilities);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_SUPPORT_SELECTION:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_boolean (value, dialog->support_selection);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_HAS_SELECTION:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_boolean (value, dialog->has_selection);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
break;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
case PROP_EMBED_PAGE_SETUP:
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_value_set_boolean (value, dialog->embed_page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2019-12-22 23:09:54 +00:00
|
|
|
|
is_printer_active (gpointer item, gpointer data)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GtkPrinter *printer = item;
|
|
|
|
|
GtkPrintUnixDialog *dialog = data;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
|
|
result = gtk_printer_is_active (printer);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
|
|
|
|
if (result &&
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->manual_capabilities & (GTK_PRINT_CAPABILITY_GENERATE_PDF |
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GTK_PRINT_CAPABILITY_GENERATE_PS))
|
2006-06-12 16:47:41 +00:00
|
|
|
|
{
|
2009-06-28 20:13:33 +00:00
|
|
|
|
/* Check that the printer can handle at least one of the data
|
|
|
|
|
* formats that the application supports.
|
2006-06-19 04:21:22 +00:00
|
|
|
|
*/
|
2020-03-28 20:04:30 +00:00
|
|
|
|
result = ((dialog->manual_capabilities & GTK_PRINT_CAPABILITY_GENERATE_PDF) &&
|
2009-06-28 20:13:33 +00:00
|
|
|
|
gtk_printer_accepts_pdf (printer)) ||
|
2020-03-28 20:04:30 +00:00
|
|
|
|
((dialog->manual_capabilities & GTK_PRINT_CAPABILITY_GENERATE_PS) &&
|
2009-06-28 20:13:33 +00:00
|
|
|
|
gtk_printer_accepts_ps (printer));
|
2006-06-12 16:47:41 +00:00
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
static int
|
|
|
|
|
default_printer_list_sort_func (gconstpointer a,
|
|
|
|
|
gconstpointer b,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GtkPrinter *a_printer = (gpointer)a;
|
|
|
|
|
GtkPrinter *b_printer = (gpointer)b;
|
|
|
|
|
const char *a_name;
|
|
|
|
|
const char *b_name;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (a_printer == NULL && b_printer == NULL)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (a_printer == NULL)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (b_printer == NULL)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (gtk_printer_is_virtual (a_printer) && gtk_printer_is_virtual (b_printer))
|
|
|
|
|
return 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (gtk_printer_is_virtual (a_printer) && !gtk_printer_is_virtual (b_printer))
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return -1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (!gtk_printer_is_virtual (a_printer) && gtk_printer_is_virtual (b_printer))
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
a_name = gtk_printer_get_name (a_printer);
|
|
|
|
|
b_name = gtk_printer_get_name (b_printer);
|
|
|
|
|
|
|
|
|
|
if (a_name == NULL && b_name == NULL)
|
|
|
|
|
return 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (a_name == NULL && b_name != NULL)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (a_name != NULL && b_name == NULL)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return -1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return g_ascii_strcasecmp (a_name, b_name);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
2020-07-24 18:40:36 +00:00
|
|
|
|
wrap_in_frame (const char *label,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
2020-05-10 17:18:22 +00:00
|
|
|
|
GtkWidget *box, *label_widget;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *bold_text;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2007-12-31 00:04:32 +00:00
|
|
|
|
label_widget = gtk_label_new (NULL);
|
2011-06-07 02:36:39 +00:00
|
|
|
|
gtk_widget_set_halign (label_widget, GTK_ALIGN_START);
|
|
|
|
|
gtk_widget_set_valign (label_widget, GTK_ALIGN_CENTER);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_widget_show (label_widget);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
bold_text = g_markup_printf_escaped ("<b>%s</b>", label);
|
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label_widget), bold_text);
|
|
|
|
|
g_free (bold_text);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-05-10 17:18:22 +00:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (box), label_widget);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2013-12-01 21:54:20 +00:00
|
|
|
|
gtk_widget_set_margin_start (child, 12);
|
2011-06-07 02:36:39 +00:00
|
|
|
|
gtk_widget_set_halign (child, GTK_ALIGN_FILL);
|
|
|
|
|
gtk_widget_set_valign (child, GTK_ALIGN_FILL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (box), child);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-05-10 17:18:22 +00:00
|
|
|
|
return box;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
setup_option (GtkPrintUnixDialog *dialog,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *option_name,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrinterOptionWidget *widget)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
GtkPrinterOption *option;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = gtk_printer_option_set_lookup (dialog->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,
|
2009-06-28 20:13:33 +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);
|
2009-06-28 20:13:33 +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;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2016-02-21 05:09:32 +00:00
|
|
|
|
gtk_widget_set_valign (widget, GTK_ALIGN_BASELINE);
|
|
|
|
|
|
2006-06-17 05:15:49 +00:00
|
|
|
|
label = gtk_printer_option_widget_get_external_label (GTK_PRINTER_OPTION_WIDGET (widget));
|
|
|
|
|
gtk_widget_show (label);
|
2011-06-09 02:12:17 +00:00
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
2016-02-21 05:09:32 +00:00
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
2006-06-17 05:15:49 +00:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2016-02-21 05:09:32 +00:00
|
|
|
|
gtk_widget_set_valign (hbox, GTK_ALIGN_BASELINE);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (hbox), label);
|
|
|
|
|
gtk_box_append (GTK_BOX (hbox), widget);
|
2006-06-17 05:15:49 +00:00
|
|
|
|
gtk_widget_show (hbox);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (extension_point), hbox);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (extension_point), widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2011-08-28 05:34:17 +00:00
|
|
|
|
grid_rows (GtkGrid *table)
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int t0, t1, l, t, w, h;
|
2020-05-07 18:23:36 +00:00
|
|
|
|
GtkWidget *c;
|
|
|
|
|
gboolean first;
|
2011-08-28 05:34:17 +00:00
|
|
|
|
|
|
|
|
|
t0 = t1 = 0;
|
2020-05-07 18:23:36 +00:00
|
|
|
|
for (c = gtk_widget_get_first_child (GTK_WIDGET (table)), first = TRUE;
|
|
|
|
|
c != NULL;
|
|
|
|
|
c = gtk_widget_get_next_sibling (GTK_WIDGET (c)), first = FALSE)
|
2011-08-28 05:34:17 +00:00
|
|
|
|
{
|
2020-05-07 18:23:36 +00:00
|
|
|
|
gtk_grid_query_child (table, c, &l, &t, &w, &h);
|
|
|
|
|
if (first)
|
2011-08-28 05:34:17 +00:00
|
|
|
|
{
|
|
|
|
|
t0 = t;
|
|
|
|
|
t1 = t + h;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (t < t0)
|
|
|
|
|
t0 = t;
|
|
|
|
|
if (t + h > t1)
|
|
|
|
|
t1 = t + h;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return t1 - t0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
add_option_to_table (GtkPrinterOption *option,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
gpointer user_data)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2011-08-28 05:34:17 +00:00
|
|
|
|
GtkGrid *table;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *label, *widget;
|
2010-07-13 02:09:38 +00:00
|
|
|
|
guint row;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2011-08-28 05:34:17 +00:00
|
|
|
|
table = GTK_GRID (user_data);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (g_str_has_prefix (option->name, "gtk-"))
|
|
|
|
|
return;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2011-08-28 05:34:17 +00:00
|
|
|
|
row = grid_rows (table);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
widget = gtk_printer_option_widget_new (option);
|
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2011-06-09 02:12:17 +00:00
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
2006-04-30 05:31:14 +00:00
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
|
|
|
|
|
2011-08-28 05:34:17 +00:00
|
|
|
|
gtk_grid_attach (table, label, 0, row - 1, 1, 1);
|
|
|
|
|
gtk_grid_attach (table, widget, 1, row - 1, 1, 1);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2011-08-28 05:34:17 +00:00
|
|
|
|
gtk_grid_attach (table, widget, 0, row - 1, 2, 1);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
setup_page_table (GtkPrinterOptionSet *options,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *group,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkWidget *table,
|
|
|
|
|
GtkWidget *page)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int nrows;
|
2010-07-13 02:09:38 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_option_set_foreach_in_group (options, group,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
add_option_to_table,
|
|
|
|
|
table);
|
2010-07-13 02:09:38 +00:00
|
|
|
|
|
2011-10-24 20:31:50 +00:00
|
|
|
|
nrows = grid_rows (GTK_GRID (table));
|
2012-01-05 12:17:46 +00:00
|
|
|
|
if (nrows == 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_widget_hide (page);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_show (page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_print_at_option (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrinterOption *option;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = gtk_printer_option_set_lookup (dialog->options, "gtk-print-time");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (option == NULL)
|
|
|
|
|
return;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->updating_print_at)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return;
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2020-08-30 20:58:17 +00:00
|
|
|
|
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->print_at_radio)))
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_printer_option_set (option, "at");
|
2020-08-30 20:58:17 +00:00
|
|
|
|
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->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");
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = gtk_printer_option_set_lookup (dialog->options, "gtk-print-time-text");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (option != NULL)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text;
|
2012-06-23 17:08:03 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (dialog->print_at_entry));
|
2009-04-08 04:12:54 +00:00
|
|
|
|
gtk_printer_option_set (option, text);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
setup_print_at (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrinterOption *option;
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = gtk_printer_option_set_lookup (dialog->options, "gtk-print-time");
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (option == NULL)
|
|
|
|
|
{
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->print_now_radio), TRUE);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->print_at_radio, FALSE);
|
|
|
|
|
gtk_widget_set_sensitive (dialog->print_at_entry, FALSE);
|
|
|
|
|
gtk_widget_set_sensitive (dialog->print_hold_radio, FALSE);
|
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (dialog->print_at_entry), "");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->updating_print_at = TRUE;
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->print_at_entry, FALSE);
|
|
|
|
|
gtk_widget_set_sensitive (dialog->print_at_radio,
|
2009-04-08 04:12:54 +00:00
|
|
|
|
gtk_printer_option_has_choice (option, "at"));
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->print_hold_radio,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
gtk_printer_option_has_choice (option, "on-hold"));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
update_print_at_option (dialog);
|
|
|
|
|
|
|
|
|
|
if (strcmp (option->value, "at") == 0)
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->print_at_radio), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (strcmp (option->value, "on-hold") == 0)
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->print_hold_radio), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->print_now_radio), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = gtk_printer_option_set_lookup (dialog->options, "gtk-print-time-text");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (option != NULL)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (dialog->print_at_entry), option->value);
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->updating_print_at = FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2009-04-08 04:12:54 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
update_dialog_from_settings (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GList *groups, *l;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *group;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *table, *frame;
|
|
|
|
|
gboolean has_advanced, has_job;
|
2010-07-13 02:09:38 +00:00
|
|
|
|
guint nrows;
|
2020-05-09 12:26:52 +00:00
|
|
|
|
GtkWidget *child;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->current_printer == NULL)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
clear_per_printer_ui (dialog);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_hide (dialog->job_page);
|
|
|
|
|
gtk_widget_hide (dialog->advanced_page);
|
|
|
|
|
gtk_widget_hide (dialog->image_quality_page);
|
|
|
|
|
gtk_widget_hide (dialog->finishing_page);
|
|
|
|
|
gtk_widget_hide (dialog->color_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
setup_option (dialog, "gtk-n-up", dialog->pages_per_sheet);
|
|
|
|
|
setup_option (dialog, "gtk-n-up-layout", dialog->number_up_layout);
|
|
|
|
|
setup_option (dialog, "gtk-duplex", dialog->duplex);
|
|
|
|
|
setup_option (dialog, "gtk-paper-type", dialog->paper_type);
|
|
|
|
|
setup_option (dialog, "gtk-paper-source", dialog->paper_source);
|
|
|
|
|
setup_option (dialog, "gtk-output-tray", dialog->output_tray);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
has_job = FALSE;
|
2020-03-28 20:04:30 +00:00
|
|
|
|
has_job |= setup_option (dialog, "gtk-job-prio", dialog->job_prio);
|
|
|
|
|
has_job |= setup_option (dialog, "gtk-billing-info", dialog->billing_info);
|
|
|
|
|
has_job |= setup_option (dialog, "gtk-cover-before", dialog->cover_before);
|
|
|
|
|
has_job |= setup_option (dialog, "gtk-cover-after", dialog->cover_after);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
has_job |= setup_print_at (dialog);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (has_job)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_show (dialog->job_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_hide (dialog->job_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
setup_page_table (dialog->options,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
"ImageQualityPage",
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->image_quality_table,
|
|
|
|
|
dialog->image_quality_page);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
setup_page_table (dialog->options,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
"FinishingPage",
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->finishing_table,
|
|
|
|
|
dialog->finishing_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
setup_page_table (dialog->options,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
"ColorPage",
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->color_table,
|
|
|
|
|
dialog->color_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_printer_option_set_foreach_in_group (dialog->options,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
"GtkPrintDialogExtension",
|
|
|
|
|
add_option_to_extension_point,
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->extension_point);
|
2006-06-17 05:15:49 +00:00
|
|
|
|
|
2012-09-01 02:45:18 +00:00
|
|
|
|
/* A bit of a hack, keep the last option flush right.
|
|
|
|
|
* This keeps the file format radios from moving as the
|
|
|
|
|
* filename changes.
|
|
|
|
|
*/
|
2020-05-09 12:26:52 +00:00
|
|
|
|
child = gtk_widget_get_last_child (dialog->extension_point);
|
|
|
|
|
if (child && child != gtk_widget_get_first_child (dialog->extension_point))
|
|
|
|
|
gtk_widget_set_halign (child, GTK_ALIGN_END);
|
2012-09-01 02:45:18 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
/* Put the rest of the groups in the advanced page */
|
2020-03-28 20:04:30 +00:00
|
|
|
|
groups = gtk_printer_option_set_get_groups (dialog->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)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (strcmp (group, "ImageQualityPage") == 0 ||
|
2009-06-28 20:13:33 +00:00
|
|
|
|
strcmp (group, "ColorPage") == 0 ||
|
|
|
|
|
strcmp (group, "FinishingPage") == 0 ||
|
|
|
|
|
strcmp (group, "GtkPrintDialogExtension") == 0)
|
|
|
|
|
continue;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2011-08-28 05:34:17 +00:00
|
|
|
|
table = gtk_grid_new ();
|
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (table), 6);
|
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (table), 12);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_printer_option_set_foreach_in_group (dialog->options,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
group,
|
|
|
|
|
add_option_to_table,
|
|
|
|
|
table);
|
2010-07-13 02:09:38 +00:00
|
|
|
|
|
2011-08-28 05:34:17 +00:00
|
|
|
|
nrows = grid_rows (GTK_GRID (table));
|
2012-01-05 12:17:46 +00:00
|
|
|
|
if (nrows == 0)
|
2020-05-09 14:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
g_object_unref (g_object_ref_sink (table));
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2009-06-28 20:13:33 +00:00
|
|
|
|
{
|
|
|
|
|
has_advanced = TRUE;
|
|
|
|
|
frame = wrap_in_frame (group, table);
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_append (GTK_BOX (dialog->advanced_vbox), frame);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (has_advanced)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_show (dialog->advanced_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_hide (dialog->advanced_page);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2012-01-02 03:20:59 +00:00
|
|
|
|
g_list_free_full (groups, g_free);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
|
static void
|
|
|
|
|
update_dialog_from_capabilities (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintCapabilities caps;
|
2006-05-24 19:03:52 +00:00
|
|
|
|
gboolean can_collate;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *copies;
|
2013-12-08 14:38:43 +00:00
|
|
|
|
GtkWidget *button;
|
2006-05-24 19:03:52 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
copies = gtk_editable_get_text (GTK_EDITABLE (dialog->copies_spin));
|
2006-12-06 15:17:40 +00:00
|
|
|
|
can_collate = (*copies != '\0' && atoi (copies) > 1);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
caps = dialog->manual_capabilities | dialog->printer_capabilities;
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->page_set_combo,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
caps & GTK_PRINT_CAPABILITY_PAGE_SET);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->copies_spin,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
caps & GTK_PRINT_CAPABILITY_COPIES);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->collate_check,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
can_collate &&
|
|
|
|
|
(caps & GTK_PRINT_CAPABILITY_COLLATE));
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->reverse_check,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
caps & GTK_PRINT_CAPABILITY_REVERSE);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->scale_spin,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
caps & GTK_PRINT_CAPABILITY_SCALE);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (dialog->pages_per_sheet),
|
2009-06-28 20:13:33 +00:00
|
|
|
|
caps & GTK_PRINT_CAPABILITY_NUMBER_UP);
|
2006-05-24 10:50:57 +00:00
|
|
|
|
|
2013-12-08 14:38:43 +00:00
|
|
|
|
button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY);
|
|
|
|
|
gtk_widget_set_visible (button, (caps & GTK_PRINT_CAPABILITY_PREVIEW) != 0);
|
2006-06-30 10:32:56 +00:00
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
|
update_collate_icon (NULL, dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
static gboolean
|
2012-06-23 17:08:03 +00:00
|
|
|
|
page_setup_is_equal (GtkPageSetup *a,
|
|
|
|
|
GtkPageSetup *b)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
gtk_paper_size_is_equal (gtk_page_setup_get_paper_size (a),
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gtk_page_setup_get_paper_size (b)) &&
|
2009-07-10 09:28:31 +00:00
|
|
|
|
gtk_page_setup_get_top_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_top_margin (b, GTK_UNIT_MM) &&
|
|
|
|
|
gtk_page_setup_get_bottom_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_bottom_margin (b, GTK_UNIT_MM) &&
|
|
|
|
|
gtk_page_setup_get_left_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_left_margin (b, GTK_UNIT_MM) &&
|
|
|
|
|
gtk_page_setup_get_right_margin (a, GTK_UNIT_MM) == gtk_page_setup_get_right_margin (b, GTK_UNIT_MM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
page_setup_is_same_size (GtkPageSetup *a,
|
2012-06-23 17:08:03 +00:00
|
|
|
|
GtkPageSetup *b)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
|
|
|
|
return gtk_paper_size_is_equal (gtk_page_setup_get_paper_size (a),
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gtk_page_setup_get_paper_size (b));
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
set_paper_size (GtkPrintUnixDialog *dialog,
|
2012-06-23 17:08:03 +00:00
|
|
|
|
GtkPageSetup *page_setup,
|
|
|
|
|
gboolean size_only,
|
|
|
|
|
gboolean add_item)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-06-12 12:28:59 +00:00
|
|
|
|
GListModel *model;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
GtkPageSetup *list_page_setup;
|
2020-06-12 12:28:59 +00:00
|
|
|
|
guint i;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (!dialog->internal_page_setup_change)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (page_setup == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2020-08-29 20:00:01 +00:00
|
|
|
|
model = gtk_drop_down_get_model (GTK_DROP_DOWN (dialog->paper_size_combo));
|
2020-06-12 12:28:59 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-06-12 12:28:59 +00:00
|
|
|
|
list_page_setup = g_list_model_get_item (model, i);
|
|
|
|
|
if (list_page_setup == NULL)
|
|
|
|
|
continue;
|
2012-06-23 17:08:03 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
if ((size_only && page_setup_is_same_size (page_setup, list_page_setup)) ||
|
|
|
|
|
(!size_only && page_setup_is_equal (page_setup, list_page_setup)))
|
|
|
|
|
{
|
|
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->paper_size_combo), i);
|
|
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->orientation_combo),
|
|
|
|
|
gtk_page_setup_get_orientation (page_setup));
|
2012-06-23 17:08:03 +00:00
|
|
|
|
g_object_unref (list_page_setup);
|
2020-06-12 12:28:59 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2012-06-23 17:08:03 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_object_unref (list_page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (add_item)
|
|
|
|
|
{
|
2020-06-12 12:28:59 +00:00
|
|
|
|
i = g_list_model_get_n_items (model);
|
|
|
|
|
g_list_store_append (dialog->page_setup_list, page_setup);
|
|
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->paper_size_combo), i);
|
2020-06-11 22:10:42 +00:00
|
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->orientation_combo),
|
|
|
|
|
gtk_page_setup_get_orientation (page_setup));
|
2009-07-10 09:28:31 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fill_custom_paper_sizes (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_list_store_remove_all (dialog->custom_paper_list);
|
|
|
|
|
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fill_paper_sizes (GtkPrintUnixDialog *dialog,
|
|
|
|
|
GtkPrinter *printer)
|
|
|
|
|
{
|
|
|
|
|
GList *list, *l;
|
|
|
|
|
GtkPageSetup *page_setup;
|
|
|
|
|
GtkPaperSize *paper_size;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_list_store_remove_all (dialog->page_setup_list);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
|
|
|
|
if (printer == NULL || (list = gtk_printer_list_papers (printer)) == NULL)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (common_paper_sizes); i++)
|
2012-06-23 17:08:03 +00:00
|
|
|
|
{
|
|
|
|
|
page_setup = gtk_page_setup_new ();
|
|
|
|
|
paper_size = gtk_paper_size_new (common_paper_sizes[i]);
|
|
|
|
|
gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
|
|
|
|
|
gtk_paper_size_free (paper_size);
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_list_store_append (dialog->page_setup_list, page_setup);
|
2012-06-23 17:08:03 +00:00
|
|
|
|
g_object_unref (page_setup);
|
|
|
|
|
}
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (l = list; l != NULL; l = l->next)
|
2012-06-23 17:08:03 +00:00
|
|
|
|
{
|
|
|
|
|
page_setup = l->data;
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_list_store_append (dialog->page_setup_list, page_setup);
|
2012-06-23 17:08:03 +00:00
|
|
|
|
g_object_unref (page_setup);
|
|
|
|
|
}
|
2009-07-10 09:28:31 +00:00
|
|
|
|
g_list_free (list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_paper_sizes (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPageSetup *current_page_setup = NULL;
|
|
|
|
|
GtkPrinter *printer;
|
|
|
|
|
|
|
|
|
|
printer = gtk_print_unix_dialog_get_selected_printer (dialog);
|
|
|
|
|
|
|
|
|
|
fill_paper_sizes (dialog, printer);
|
2020-06-12 12:28:59 +00:00
|
|
|
|
fill_custom_paper_sizes (dialog);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
|
|
|
|
current_page_setup = gtk_page_setup_copy (gtk_print_unix_dialog_get_page_setup (dialog));
|
|
|
|
|
|
|
|
|
|
if (current_page_setup)
|
|
|
|
|
{
|
|
|
|
|
if (!set_paper_size (dialog, current_page_setup, FALSE, FALSE))
|
|
|
|
|
set_paper_size (dialog, current_page_setup, TRUE, TRUE);
|
|
|
|
|
|
|
|
|
|
g_object_unref (current_page_setup);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
mark_conflicts (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrinter *printer;
|
|
|
|
|
gboolean have_conflict;
|
|
|
|
|
|
|
|
|
|
have_conflict = FALSE;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
printer = dialog->current_printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (printer)
|
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_signal_handler_block (dialog->options, dialog->options_changed_handler);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_printer_option_set_clear_conflicts (dialog->options);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
have_conflict = _gtk_printer_mark_conflicts (printer, dialog->options);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_signal_handler_unblock (dialog->options, dialog->options_changed_handler);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (have_conflict)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_show (dialog->conflicts_widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_hide (dialog->conflicts_widget);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
mark_conflicts_callback (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintUnixDialog *dialog = data;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->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)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->mark_conflicts_id != 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_source_remove (dialog->mark_conflicts_id);
|
|
|
|
|
dialog->mark_conflicts_id = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
schedule_idle_mark_conflicts (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->mark_conflicts_id != 0)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->mark_conflicts_id = g_idle_add (mark_conflicts_callback, dialog);
|
2021-07-26 21:03:15 +00:00
|
|
|
|
gdk_source_set_static_name_by_id (dialog->mark_conflicts_id, "[gtk] mark_conflicts_callback");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
options_changed_cb (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
schedule_idle_mark_conflicts (dialog);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_free (dialog->waiting_for_printer);
|
|
|
|
|
dialog->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
clear_per_printer_ui (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-05-09 14:33:02 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->finishing_table == NULL)
|
2014-02-18 02:40:36 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-09 14:33:02 +00:00
|
|
|
|
while ((child = gtk_widget_get_first_child (dialog->finishing_table)))
|
2020-05-07 18:23:36 +00:00
|
|
|
|
gtk_grid_remove (GTK_GRID (dialog->finishing_table), child);
|
2020-05-09 14:33:02 +00:00
|
|
|
|
while ((child = gtk_widget_get_first_child (dialog->image_quality_table)))
|
2020-05-07 18:23:36 +00:00
|
|
|
|
gtk_grid_remove (GTK_GRID (dialog->image_quality_table), child);
|
2020-05-09 14:33:02 +00:00
|
|
|
|
while ((child = gtk_widget_get_first_child (dialog->color_table)))
|
2020-05-07 18:23:36 +00:00
|
|
|
|
gtk_grid_remove (GTK_GRID (dialog->color_table), child);
|
2020-05-09 14:33:02 +00:00
|
|
|
|
while ((child = gtk_widget_get_first_child (dialog->advanced_vbox)))
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_remove (GTK_BOX (dialog->advanced_vbox), child);
|
2020-05-09 14:33:02 +00:00
|
|
|
|
while ((child = gtk_widget_get_first_child (dialog->extension_point)))
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_box_remove (GTK_BOX (dialog->extension_point), child);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
printer_details_acquired (GtkPrinter *printer,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
gboolean success,
|
|
|
|
|
GtkPrintUnixDialog *dialog)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2009-09-23 12:35:26 +00:00
|
|
|
|
disconnect_printer_details_request (dialog, !success);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (success)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
selected_printer_changed (dialog);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-22 23:09:54 +00:00
|
|
|
|
selected_printer_changed (GtkPrintUnixDialog *dialog)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-08-31 21:06:48 +00:00
|
|
|
|
GListModel *model = G_LIST_MODEL (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinter *printer;
|
|
|
|
|
|
|
|
|
|
/* Whenever the user selects a printer we stop looking for
|
2012-06-23 17:08:03 +00:00
|
|
|
|
* the printer specified in the initial settings
|
|
|
|
|
*/
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->waiting_for_printer &&
|
|
|
|
|
!dialog->internal_printer_change)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_free (dialog->waiting_for_printer);
|
|
|
|
|
dialog->waiting_for_printer = NULL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2008-05-27 04:48:31 +00:00
|
|
|
|
|
2009-09-23 12:35:26 +00:00
|
|
|
|
disconnect_printer_details_request (dialog, FALSE);
|
2008-05-27 04:48:31 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
printer = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (model));
|
2008-07-15 17:34:34 +00:00
|
|
|
|
|
2009-06-28 20:13:33 +00:00
|
|
|
|
/* sets GTK_RESPONSE_OK button sensitivity depending on whether the printer
|
|
|
|
|
* accepts/rejects jobs
|
|
|
|
|
*/
|
2008-07-15 17:34:34 +00:00
|
|
|
|
if (printer != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!gtk_printer_is_accepting_jobs (printer))
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
else if (dialog->current_printer == printer && gtk_printer_has_details (printer))
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
|
2008-07-15 17:34:34 +00:00
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2007-04-29 04:42:13 +00:00
|
|
|
|
if (printer != NULL && !gtk_printer_has_details (printer))
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
dialog->request_details_tag = g_signal_connect (printer, "details-acquired",
|
|
|
|
|
G_CALLBACK (printer_details_acquired), dialog);
|
|
|
|
|
|
|
|
|
|
dialog->request_details_printer = g_object_ref (printer);
|
2009-08-06 07:11:31 +00:00
|
|
|
|
set_busy_cursor (dialog, TRUE);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
gtk_printer_set_state_message (printer, _("Getting printer information…"));
|
2014-03-14 14:36:10 +00:00
|
|
|
|
gtk_printer_request_details (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (printer == dialog->current_printer)
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->options)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->options);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
clear_per_printer_ui (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->current_printer);
|
|
|
|
|
dialog->printer_capabilities = 0;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2011-04-09 00:46:57 +00:00
|
|
|
|
if (printer != NULL && gtk_printer_is_accepting_jobs (printer))
|
2008-07-15 17:34:34 +00:00
|
|
|
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
dialog->current_printer = g_object_ref (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (printer != NULL)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (!dialog->page_setup_set)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
{
|
|
|
|
|
/* if no explicit page setup has been set, use the printer default */
|
|
|
|
|
GtkPageSetup *page_setup;
|
2008-05-21 02:17:30 +00:00
|
|
|
|
|
2009-06-28 20:13:33 +00:00
|
|
|
|
page_setup = gtk_printer_get_default_page_size (printer);
|
2008-05-21 02:17:30 +00:00
|
|
|
|
|
2009-06-28 20:13:33 +00:00
|
|
|
|
if (!page_setup)
|
|
|
|
|
page_setup = gtk_page_setup_new ();
|
2008-05-21 02:17:30 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (page_setup && dialog->page_setup)
|
|
|
|
|
gtk_page_setup_set_orientation (page_setup, gtk_page_setup_get_orientation (dialog->page_setup));
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->page_setup);
|
|
|
|
|
dialog->page_setup = page_setup; /* transfer ownership */
|
2009-06-28 20:13:33 +00:00
|
|
|
|
}
|
2008-05-21 02:17:30 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->printer_capabilities = gtk_printer_get_capabilities (printer);
|
|
|
|
|
dialog->options = _gtk_printer_get_options (printer,
|
|
|
|
|
dialog->initial_settings,
|
|
|
|
|
dialog->page_setup,
|
|
|
|
|
dialog->manual_capabilities);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->options_changed_handler =
|
|
|
|
|
g_signal_connect_swapped (dialog->options, "changed", G_CALLBACK (options_changed_cb), dialog);
|
2010-12-07 17:25:37 +00:00
|
|
|
|
schedule_idle_mark_conflicts (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);
|
2009-04-21 11:06:49 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->internal_page_setup_change = TRUE;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
update_paper_sizes (dialog);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->internal_page_setup_change = FALSE;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_object_notify (G_OBJECT (dialog), "selected-printer");
|
2013-12-19 13:52:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static void
|
|
|
|
|
update_collate_icon (GtkToggleButton *toggle_button,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_queue_draw (dialog->collate_image);
|
2006-05-03 20:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-07 07:01:50 +00:00
|
|
|
|
paint_page (GtkPrintUnixDialog *dialog,
|
|
|
|
|
GtkWidget *widget,
|
2016-10-15 20:32:51 +00:00
|
|
|
|
cairo_t *cr,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int x,
|
|
|
|
|
int y,
|
2016-10-15 20:32:51 +00:00
|
|
|
|
const char *text,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int text_x)
|
2006-05-03 20:18:38 +00:00
|
|
|
|
{
|
2011-01-10 01:42:05 +00:00
|
|
|
|
GtkStyleContext *context;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width, height;
|
|
|
|
|
int text_y;
|
2019-12-24 17:28:00 +00:00
|
|
|
|
GdkRGBA color;
|
2006-05-03 20:18:38 +00:00
|
|
|
|
|
2014-10-04 15:00:10 +00:00
|
|
|
|
width = 20;
|
|
|
|
|
height = 26;
|
2006-05-05 19:49:13 +00:00
|
|
|
|
text_y = 21;
|
|
|
|
|
|
2011-01-10 01:42:05 +00:00
|
|
|
|
context = gtk_widget_get_style_context (widget);
|
2020-05-07 07:01:50 +00:00
|
|
|
|
gtk_style_context_save_to_node (context, dialog->collate_paper_node);
|
2010-08-15 15:28:38 +00:00
|
|
|
|
|
2014-10-03 03:46:49 +00:00
|
|
|
|
gtk_render_background (context, cr, x, y, width, height);
|
|
|
|
|
gtk_render_frame (context, cr, x, y, width, height);
|
2006-05-03 20:18:38 +00:00
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
gtk_style_context_get_color (context, &color);
|
|
|
|
|
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
|
|
|
|
|
|
2009-06-28 20:13:33 +00:00
|
|
|
|
cairo_select_font_face (cr, "Sans",
|
|
|
|
|
CAIRO_FONT_SLANT_NORMAL,
|
|
|
|
|
CAIRO_FONT_WEIGHT_NORMAL);
|
2014-10-04 15:00:10 +00:00
|
|
|
|
cairo_set_font_size (cr, 9);
|
|
|
|
|
cairo_move_to (cr, x + text_x, y + text_y);
|
2006-05-03 20:18:38 +00:00
|
|
|
|
cairo_show_text (cr, text);
|
2017-10-07 02:50:03 +00:00
|
|
|
|
|
|
|
|
|
gtk_style_context_restore (context);
|
2006-05-03 20:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-18 05:32:27 +00:00
|
|
|
|
static void
|
|
|
|
|
draw_collate (GtkDrawingArea *da,
|
|
|
|
|
cairo_t *cr,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (data);
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (da);
|
2006-05-05 19:49:13 +00:00
|
|
|
|
gboolean collate, reverse, rtl;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int copies;
|
|
|
|
|
int text_x;
|
|
|
|
|
int x, y, x1, x2, p1, p2;
|
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);
|
|
|
|
|
|
2016-11-18 05:32:27 +00:00
|
|
|
|
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2016-11-18 05:32:27 +00:00
|
|
|
|
x = (width - 30) / 2;
|
|
|
|
|
y = (height - 36) / 2;
|
2014-10-04 14:38:59 +00:00
|
|
|
|
if (rtl)
|
2006-12-20 04:39:52 +00:00
|
|
|
|
{
|
2014-10-04 15:56:44 +00:00
|
|
|
|
x1 = x;
|
|
|
|
|
x2 = x - 36;
|
2014-10-04 14:38:59 +00:00
|
|
|
|
p1 = 0;
|
|
|
|
|
p2 = 10;
|
|
|
|
|
text_x = 4;
|
2006-12-20 04:39:52 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-04 14:53:57 +00:00
|
|
|
|
x1 = x;
|
|
|
|
|
x2 = x + 36;
|
2014-10-04 14:38:59 +00:00
|
|
|
|
p1 = 10;
|
|
|
|
|
p2 = 0;
|
|
|
|
|
text_x = 11;
|
|
|
|
|
}
|
2006-12-20 04:39:52 +00:00
|
|
|
|
|
2014-10-04 14:38:59 +00:00
|
|
|
|
if (copies == 1)
|
|
|
|
|
{
|
2020-05-07 07:01:50 +00:00
|
|
|
|
paint_page (dialog, widget, cr, x1 + p1, y, reverse ? "1" : "2", text_x);
|
|
|
|
|
paint_page (dialog, widget, cr, x1 + p2, y + 10, reverse ? "2" : "1", text_x);
|
2006-12-20 04:39:52 +00:00
|
|
|
|
}
|
2014-10-04 14:38:59 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2020-05-07 07:01:50 +00:00
|
|
|
|
paint_page (dialog, widget, cr, x1 + p1, y, collate == reverse ? "1" : "2", text_x);
|
|
|
|
|
paint_page (dialog, widget, cr, x1 + p2, y + 10, reverse ? "2" : "1", text_x);
|
2014-10-04 14:38:59 +00:00
|
|
|
|
|
2020-05-07 07:01:50 +00:00
|
|
|
|
paint_page (dialog, widget, cr, x2 + p1, y, reverse ? "1" : "2", text_x);
|
|
|
|
|
paint_page (dialog, widget, cr, x2 + p2, y + 10, collate == reverse ? "2" : "1", text_x);
|
2015-11-10 12:45:56 +00:00
|
|
|
|
}
|
2006-05-03 20:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 21:11:56 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
page_range_entry_focus_changed (GtkWidget *entry,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
if (gtk_widget_has_focus (entry))
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->page_range_radio), TRUE);
|
2019-06-13 21:11:56 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-24 18:21:12 +00:00
|
|
|
|
static void
|
2013-03-28 06:06:05 +00:00
|
|
|
|
update_page_range_entry_sensitivity (GtkWidget *button,
|
|
|
|
|
GtkPrintUnixDialog *dialog)
|
2006-05-24 18:21:12 +00:00
|
|
|
|
{
|
2006-05-24 19:03:52 +00:00
|
|
|
|
gboolean active;
|
|
|
|
|
|
2020-08-30 20:58:17 +00:00
|
|
|
|
active = gtk_check_button_get_active (GTK_CHECK_BUTTON (button));
|
2006-05-24 19:03:52 +00:00
|
|
|
|
|
2009-04-08 03:51:52 +00:00
|
|
|
|
if (active)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_grab_focus (dialog->page_range_entry);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_print_at_entry_sensitivity (GtkWidget *button,
|
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
gboolean active;
|
|
|
|
|
|
2020-08-30 20:58:17 +00:00
|
|
|
|
active = gtk_check_button_get_active (GTK_CHECK_BUTTON (button));
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->print_at_entry, active);
|
2013-03-28 06:06:05 +00:00
|
|
|
|
|
|
|
|
|
if (active)
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_grab_focus (dialog->print_at_entry);
|
2006-05-24 18:21:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
static gboolean
|
2020-07-24 18:40:36 +00:00
|
|
|
|
is_range_separator (char c)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
return (c == ',' || c == ';' || c == ':');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkPageRange *
|
|
|
|
|
dialog_get_page_ranges (GtkPrintUnixDialog *dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *n_ranges_out)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i, n_ranges;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text, *p;
|
|
|
|
|
char *next;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageRange *ranges;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start, end;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (dialog->page_range_entry));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
if (*text == 0)
|
|
|
|
|
{
|
|
|
|
|
*n_ranges_out = 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
n_ranges = 1;
|
|
|
|
|
p = text;
|
|
|
|
|
while (*p)
|
|
|
|
|
{
|
|
|
|
|
if (is_range_separator (*p))
|
2009-06-28 20:13:33 +00:00
|
|
|
|
n_ranges++;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ranges = g_new0 (GtkPageRange, n_ranges);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
i = 0;
|
|
|
|
|
p = text;
|
|
|
|
|
while (*p)
|
|
|
|
|
{
|
2007-04-24 20:16:35 +00:00
|
|
|
|
while (isspace (*p)) p++;
|
|
|
|
|
|
|
|
|
|
if (*p == '-')
|
|
|
|
|
{
|
|
|
|
|
/* a half-open range like -2 */
|
|
|
|
|
start = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
start = (int)strtol (p, &next, 10);
|
|
|
|
|
if (start < 1)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
start = 1;
|
2007-04-24 20:16:35 +00:00
|
|
|
|
p = next;
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
end = start;
|
|
|
|
|
|
2007-04-24 20:16:35 +00:00
|
|
|
|
while (isspace (*p)) p++;
|
|
|
|
|
|
|
|
|
|
if (*p == '-')
|
2009-06-28 20:13:33 +00:00
|
|
|
|
{
|
|
|
|
|
p++;
|
|
|
|
|
end = (int)strtol (p, &next, 10);
|
2007-04-24 20:16:35 +00:00
|
|
|
|
if (next == p) /* a half-open range like 2- */
|
|
|
|
|
end = 0;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
else if (end < start)
|
|
|
|
|
end = start;
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
ranges[i].start = start - 1;
|
|
|
|
|
ranges[i].end = end - 1;
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Skip until end or separator */
|
|
|
|
|
while (*p && !is_range_separator (*p))
|
2009-06-28 20:13:33 +00:00
|
|
|
|
p++;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
/* if not at end, skip separator */
|
|
|
|
|
if (*p)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
p++;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*n_ranges_out = i;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return ranges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dialog_set_page_ranges (GtkPrintUnixDialog *dialog,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPageRange *ranges,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_ranges)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i;
|
2007-12-31 00:04:32 +00:00
|
|
|
|
GString *s = g_string_new (NULL);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_ranges; i++)
|
|
|
|
|
{
|
|
|
|
|
g_string_append_printf (s, "%d", ranges[i].start + 1);
|
|
|
|
|
if (ranges[i].end > ranges[i].start)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
g_string_append_printf (s, "-%d", ranges[i].end + 1);
|
2007-04-24 20:16:35 +00:00
|
|
|
|
else if (ranges[i].end == -1)
|
|
|
|
|
g_string_append (s, "-");
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (i != n_ranges - 1)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
g_string_append (s, ",");
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (dialog->page_range_entry), s->str);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_string_free (s, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkPrintPages
|
|
|
|
|
dialog_get_print_pages (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-08-30 20:58:17 +00:00
|
|
|
|
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->all_pages_radio)))
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return GTK_PRINT_PAGES_ALL;
|
2020-08-30 20:58:17 +00:00
|
|
|
|
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->current_page_radio)))
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return GTK_PRINT_PAGES_CURRENT;
|
2020-08-30 20:58:17 +00:00
|
|
|
|
else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->selection_radio)))
|
2009-06-08 13:37:32 +00:00
|
|
|
|
return GTK_PRINT_PAGES_SELECTION;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
|
|
|
|
return GTK_PRINT_PAGES_RANGES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_print_pages (GtkPrintUnixDialog *dialog,
|
|
|
|
|
GtkPrintPages pages)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (pages == GTK_PRINT_PAGES_RANGES)
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->page_range_radio), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else if (pages == GTK_PRINT_PAGES_CURRENT)
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->current_page_radio), TRUE);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
else if (pages == GTK_PRINT_PAGES_SELECTION)
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->selection_radio), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->all_pages_radio), TRUE);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
|
static double
|
2006-04-21 15:09:32 +00:00
|
|
|
|
dialog_get_scale (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (gtk_widget_is_sensitive (dialog->scale_spin))
|
|
|
|
|
return gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->scale_spin));
|
2006-05-24 10:50:57 +00:00
|
|
|
|
else
|
|
|
|
|
return 100.0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_scale (GtkPrintUnixDialog *dialog,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double val)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->scale_spin), val);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkPageSet
|
|
|
|
|
dialog_get_page_set (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (gtk_widget_is_sensitive (dialog->page_set_combo))
|
2020-06-11 22:10:42 +00:00
|
|
|
|
return (GtkPageSet)gtk_drop_down_get_selected (GTK_DROP_DOWN (dialog->page_set_combo));
|
2006-05-24 10:50:57 +00:00
|
|
|
|
else
|
|
|
|
|
return GTK_PAGE_SET_ALL;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_page_set (GtkPrintUnixDialog *dialog,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageSet val)
|
|
|
|
|
{
|
2020-06-11 22:10:42 +00:00
|
|
|
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->page_set_combo), (guint)val);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
dialog_get_n_copies (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2017-05-18 14:11:56 +00:00
|
|
|
|
GtkAdjustment *adjustment;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text;
|
|
|
|
|
char *endptr = NULL;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_copies;
|
2017-05-18 14:11:56 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (dialog->copies_spin));
|
2017-05-18 14:11:56 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (dialog->copies_spin));
|
2017-05-18 14:11:56 +00:00
|
|
|
|
n_copies = g_ascii_strtoull (text, &endptr, 0);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (gtk_widget_is_sensitive (dialog->copies_spin))
|
2017-05-18 14:11:56 +00:00
|
|
|
|
{
|
|
|
|
|
if (n_copies != 0 && endptr != text && (endptr != NULL && endptr[0] == '\0') &&
|
|
|
|
|
n_copies >= gtk_adjustment_get_lower (adjustment) &&
|
|
|
|
|
n_copies <= gtk_adjustment_get_upper (adjustment))
|
|
|
|
|
{
|
|
|
|
|
return n_copies;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->copies_spin));
|
2017-05-18 14:11:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
|
return 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_n_copies (GtkPrintUnixDialog *dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n_copies)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->copies_spin), n_copies);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
dialog_get_collate (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (gtk_widget_is_sensitive (dialog->collate_check))
|
2020-08-30 20:58:17 +00:00
|
|
|
|
return gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->collate_check));
|
2006-05-24 10:50:57 +00:00
|
|
|
|
return FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_collate (GtkPrintUnixDialog *dialog,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean collate)
|
|
|
|
|
{
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->collate_check), collate);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
dialog_get_reverse (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (gtk_widget_is_sensitive (dialog->reverse_check))
|
2020-08-30 20:58:17 +00:00
|
|
|
|
return gtk_check_button_get_active (GTK_CHECK_BUTTON (dialog->reverse_check));
|
2006-05-24 10:50:57 +00:00
|
|
|
|
return FALSE;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_reverse (GtkPrintUnixDialog *dialog,
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gboolean reverse)
|
|
|
|
|
{
|
2020-08-30 20:58:17 +00:00
|
|
|
|
gtk_check_button_set_active (GTK_CHECK_BUTTON (dialog->reverse_check), reverse);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
dialog_get_pages_per_sheet (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
val = gtk_printer_option_widget_get_value (dialog->pages_per_sheet);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
num = 1;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (val)
|
|
|
|
|
{
|
|
|
|
|
num = atoi(val);
|
|
|
|
|
if (num < 1)
|
2009-06-28 20:13:33 +00:00
|
|
|
|
num = 1;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
static GtkNumberUpLayout
|
|
|
|
|
dialog_get_number_up_layout (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintCapabilities caps;
|
|
|
|
|
GtkNumberUpLayout layout;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *val;
|
2008-09-04 14:14:11 +00:00
|
|
|
|
GEnumClass *enum_class;
|
|
|
|
|
GEnumValue *enum_value;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
val = gtk_printer_option_widget_get_value (dialog->number_up_layout);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
caps = dialog->manual_capabilities | dialog->printer_capabilities;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
if ((caps & GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT) == 0)
|
|
|
|
|
return GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR)
|
2008-08-21 10:25:27 +00:00
|
|
|
|
layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
|
2008-09-04 14:14:11 +00:00
|
|
|
|
else
|
|
|
|
|
layout = GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
|
|
|
|
if (val == NULL)
|
|
|
|
|
return layout;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (val[0] == '\0' && dialog->options)
|
2010-10-15 10:08:12 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
GtkPrinterOption *option = gtk_printer_option_set_lookup (dialog->options, "gtk-n-up-layout");
|
2010-10-15 10:08:12 +00:00
|
|
|
|
if (option)
|
|
|
|
|
val = option->value;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
enum_class = g_type_class_ref (GTK_TYPE_NUMBER_UP_LAYOUT);
|
|
|
|
|
enum_value = g_enum_get_value_by_nick (enum_class, val);
|
|
|
|
|
if (enum_value)
|
|
|
|
|
layout = enum_value->value;
|
|
|
|
|
g_type_class_unref (enum_class);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
|
|
|
|
return layout;
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2016-11-18 05:32:27 +00:00
|
|
|
|
static void
|
|
|
|
|
draw_page (GtkDrawingArea *da,
|
|
|
|
|
cairo_t *cr,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *widget = GTK_WIDGET (da);
|
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (data);
|
2011-01-10 01:42:05 +00:00
|
|
|
|
GtkStyleContext *context;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double ratio;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int w, h, tmp;
|
|
|
|
|
int pages_x, pages_y, i, x, y, layout_w, layout_h;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double page_width, page_height;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageOrientation orientation;
|
|
|
|
|
gboolean landscape;
|
|
|
|
|
PangoLayout *layout;
|
|
|
|
|
PangoFontDescription *font;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *text;
|
2011-01-10 01:42:05 +00:00
|
|
|
|
GdkRGBA color;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
GtkNumberUpLayout number_up_layout;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int start_x, end_x, start_y, end_y;
|
|
|
|
|
int dx, dy;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
gboolean horizontal;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
GtkPageSetup *page_setup;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double paper_width, paper_height;
|
|
|
|
|
double pos_x, pos_y;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int pages_per_sheet;
|
2009-07-17 14:33:16 +00:00
|
|
|
|
gboolean ltr = TRUE;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
orientation = gtk_page_setup_get_orientation (dialog->page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
landscape =
|
|
|
|
|
(orientation == GTK_PAGE_ORIENTATION_LANDSCAPE) ||
|
|
|
|
|
(orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
|
|
|
|
number_up_layout = dialog_get_number_up_layout (dialog);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
2012-06-23 17:08:03 +00:00
|
|
|
|
page_setup = gtk_print_unix_dialog_get_page_setup (dialog);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
|
|
|
|
if (page_setup != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!landscape)
|
|
|
|
|
{
|
|
|
|
|
paper_width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_MM);
|
|
|
|
|
paper_height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_MM);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
paper_width = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_MM);
|
|
|
|
|
paper_height = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_MM);
|
|
|
|
|
}
|
2008-05-25 12:53:59 +00:00
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
if (paper_width < paper_height)
|
|
|
|
|
{
|
|
|
|
|
h = EXAMPLE_PAGE_AREA_SIZE - 3;
|
|
|
|
|
w = (paper_height != 0) ? h * paper_width / paper_height : 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
w = EXAMPLE_PAGE_AREA_SIZE - 3;
|
|
|
|
|
h = (paper_width != 0) ? w * paper_height / paper_width : 0;
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
if (paper_width == 0)
|
|
|
|
|
w = 0;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
if (paper_height == 0)
|
|
|
|
|
h = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ratio = G_SQRT2;
|
|
|
|
|
w = (EXAMPLE_PAGE_AREA_SIZE - 3) / ratio;
|
|
|
|
|
h = EXAMPLE_PAGE_AREA_SIZE - 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pages_per_sheet = dialog_get_pages_per_sheet (dialog);
|
|
|
|
|
switch (pages_per_sheet)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2011-01-10 01:42:05 +00:00
|
|
|
|
context = gtk_widget_get_style_context (widget);
|
2020-05-07 07:01:50 +00:00
|
|
|
|
gtk_style_context_save_to_node (context, dialog->page_layout_paper_node);
|
2016-10-08 03:07:23 +00:00
|
|
|
|
gtk_style_context_get_color (context, &color);
|
2010-08-15 15:28:38 +00:00
|
|
|
|
|
2010-09-08 19:35:03 +00:00
|
|
|
|
pos_x = (width - w) / 2;
|
|
|
|
|
pos_y = (height - h) / 2 - 10;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
cairo_translate (cr, pos_x, pos_y);
|
|
|
|
|
|
2014-10-03 03:46:49 +00:00
|
|
|
|
gtk_render_background (context, cr, 1, 1, w, h);
|
2019-12-24 17:28:00 +00:00
|
|
|
|
gtk_render_frame (context, cr, 1, 1, w, h);
|
2014-10-03 03:46:49 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
|
page_width = (double)w / pages_x;
|
|
|
|
|
page_height = (double)h / pages_y;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
layout = pango_cairo_create_layout (cr);
|
|
|
|
|
|
|
|
|
|
font = pango_font_description_new ();
|
|
|
|
|
pango_font_description_set_family (font, "sans");
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
|
|
|
|
if (page_height > 0)
|
|
|
|
|
pango_font_description_set_absolute_size (font, page_height * 0.4 * PANGO_SCALE);
|
|
|
|
|
else
|
|
|
|
|
pango_font_description_set_absolute_size (font, 1);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
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);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
switch (number_up_layout)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2008-08-21 10:25:27 +00:00
|
|
|
|
default:
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM:
|
|
|
|
|
start_x = 0;
|
|
|
|
|
end_x = pages_x - 1;
|
|
|
|
|
start_y = 0;
|
|
|
|
|
end_y = pages_y - 1;
|
|
|
|
|
dx = 1;
|
|
|
|
|
dy = 1;
|
|
|
|
|
horizontal = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP:
|
|
|
|
|
start_x = 0;
|
|
|
|
|
end_x = pages_x - 1;
|
|
|
|
|
start_y = pages_y - 1;
|
|
|
|
|
end_y = 0;
|
|
|
|
|
dx = 1;
|
|
|
|
|
dy = - 1;
|
|
|
|
|
horizontal = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM:
|
|
|
|
|
start_x = pages_x - 1;
|
|
|
|
|
end_x = 0;
|
|
|
|
|
start_y = 0;
|
|
|
|
|
end_y = pages_y - 1;
|
|
|
|
|
dx = - 1;
|
|
|
|
|
dy = 1;
|
|
|
|
|
horizontal = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP:
|
|
|
|
|
start_x = pages_x - 1;
|
|
|
|
|
end_x = 0;
|
|
|
|
|
start_y = pages_y - 1;
|
|
|
|
|
end_y = 0;
|
|
|
|
|
dx = - 1;
|
|
|
|
|
dy = - 1;
|
|
|
|
|
horizontal = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT:
|
|
|
|
|
start_x = 0;
|
|
|
|
|
end_x = pages_x - 1;
|
|
|
|
|
start_y = 0;
|
|
|
|
|
end_y = pages_y - 1;
|
|
|
|
|
dx = 1;
|
|
|
|
|
dy = 1;
|
|
|
|
|
horizontal = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT:
|
|
|
|
|
start_x = pages_x - 1;
|
|
|
|
|
end_x = 0;
|
|
|
|
|
start_y = 0;
|
|
|
|
|
end_y = pages_y - 1;
|
|
|
|
|
dx = - 1;
|
|
|
|
|
dy = 1;
|
|
|
|
|
horizontal = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT:
|
|
|
|
|
start_x = 0;
|
|
|
|
|
end_x = pages_x - 1;
|
|
|
|
|
start_y = pages_y - 1;
|
|
|
|
|
end_y = 0;
|
|
|
|
|
dx = 1;
|
|
|
|
|
dy = - 1;
|
|
|
|
|
horizontal = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT:
|
|
|
|
|
start_x = pages_x - 1;
|
|
|
|
|
end_x = 0;
|
|
|
|
|
start_y = pages_y - 1;
|
|
|
|
|
end_y = 0;
|
|
|
|
|
dx = - 1;
|
|
|
|
|
dy = - 1;
|
|
|
|
|
horizontal = FALSE;
|
|
|
|
|
break;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2008-01-28 16:06:16 +00:00
|
|
|
|
|
2020-05-07 07:01:50 +00:00
|
|
|
|
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
if (horizontal)
|
|
|
|
|
for (y = start_y; y != end_y + dy; y += dy)
|
|
|
|
|
{
|
|
|
|
|
for (x = start_x; x != end_x + dx; x += dx)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
for (x = start_x; x != end_x + dx; x += dx)
|
|
|
|
|
{
|
|
|
|
|
for (y = start_y; y != end_y + dy; y += dy)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2008-01-28 16:06:16 +00:00
|
|
|
|
g_object_unref (layout);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
gtk_style_context_restore (context);
|
|
|
|
|
|
|
|
|
|
gtk_style_context_get_color (context, &color);
|
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
if (page_setup != NULL)
|
|
|
|
|
{
|
2013-10-06 03:02:54 +00:00
|
|
|
|
PangoContext *pango_c = NULL;
|
|
|
|
|
PangoFontDescription *pango_f = NULL;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int font_size = 12 * PANGO_SCALE;
|
2013-10-06 03:02:54 +00:00
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
pos_x += 1;
|
|
|
|
|
pos_y += 1;
|
|
|
|
|
|
|
|
|
|
if (pages_per_sheet == 2 || pages_per_sheet == 6)
|
|
|
|
|
{
|
|
|
|
|
paper_width = gtk_page_setup_get_paper_height (page_setup, _gtk_print_get_default_user_units ());
|
|
|
|
|
paper_height = gtk_page_setup_get_paper_width (page_setup, _gtk_print_get_default_user_units ());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
paper_width = gtk_page_setup_get_paper_width (page_setup, _gtk_print_get_default_user_units ());
|
|
|
|
|
paper_height = gtk_page_setup_get_paper_height (page_setup, _gtk_print_get_default_user_units ());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
2013-10-06 03:02:54 +00:00
|
|
|
|
layout = pango_cairo_create_layout (cr);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
|
|
|
|
font = pango_font_description_new ();
|
|
|
|
|
pango_font_description_set_family (font, "sans");
|
|
|
|
|
|
|
|
|
|
pango_c = gtk_widget_get_pango_context (widget);
|
|
|
|
|
if (pango_c != NULL)
|
|
|
|
|
{
|
|
|
|
|
pango_f = pango_context_get_font_description (pango_c);
|
|
|
|
|
if (pango_f != NULL)
|
|
|
|
|
font_size = pango_font_description_get_size (pango_f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pango_font_description_set_size (font, font_size);
|
|
|
|
|
pango_layout_set_font_description (layout, font);
|
|
|
|
|
pango_font_description_free (font);
|
|
|
|
|
|
|
|
|
|
pango_layout_set_width (layout, -1);
|
|
|
|
|
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
|
|
|
|
|
|
|
|
|
if (_gtk_print_get_default_user_units () == GTK_UNIT_MM)
|
|
|
|
|
text = g_strdup_printf ("%.1f mm", paper_height);
|
|
|
|
|
else
|
|
|
|
|
text = g_strdup_printf ("%.2f inch", paper_height);
|
|
|
|
|
|
|
|
|
|
pango_layout_set_text (layout, text, -1);
|
|
|
|
|
g_free (text);
|
|
|
|
|
pango_layout_get_size (layout, &layout_w, &layout_h);
|
|
|
|
|
|
2009-07-17 14:33:16 +00:00
|
|
|
|
ltr = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR;
|
|
|
|
|
|
|
|
|
|
if (ltr)
|
|
|
|
|
cairo_translate (cr, pos_x - layout_w / PANGO_SCALE - 2 * RULER_DISTANCE,
|
2010-09-08 19:35:03 +00:00
|
|
|
|
(height - layout_h / PANGO_SCALE) / 2);
|
2009-07-17 14:33:16 +00:00
|
|
|
|
else
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_translate (cr, pos_x + w + 2 * RULER_DISTANCE,
|
2010-09-08 19:35:03 +00:00
|
|
|
|
(height - layout_h / PANGO_SCALE) / 2);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2013-10-06 03:02:54 +00:00
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
|
|
|
|
if (_gtk_print_get_default_user_units () == GTK_UNIT_MM)
|
|
|
|
|
text = g_strdup_printf ("%.1f mm", paper_width);
|
|
|
|
|
else
|
|
|
|
|
text = g_strdup_printf ("%.2f inch", paper_width);
|
|
|
|
|
|
|
|
|
|
pango_layout_set_text (layout, text, -1);
|
|
|
|
|
g_free (text);
|
|
|
|
|
pango_layout_get_size (layout, &layout_w, &layout_h);
|
|
|
|
|
|
2010-09-08 19:35:03 +00:00
|
|
|
|
cairo_translate (cr, (width - layout_w / PANGO_SCALE) / 2,
|
2019-12-24 17:28:00 +00:00
|
|
|
|
pos_y + h + 2 * RULER_DISTANCE);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2013-10-06 03:02:54 +00:00
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
|
|
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, 1);
|
|
|
|
|
|
2013-10-06 03:02:54 +00:00
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
|
|
|
|
|
2009-07-17 14:33:16 +00:00
|
|
|
|
if (ltr)
|
|
|
|
|
{
|
|
|
|
|
cairo_move_to (cr, pos_x - RULER_DISTANCE, pos_y);
|
|
|
|
|
cairo_line_to (cr, pos_x - RULER_DISTANCE, pos_y + h);
|
|
|
|
|
cairo_stroke (cr);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2009-07-17 14:33:16 +00:00
|
|
|
|
cairo_move_to (cr, pos_x - RULER_DISTANCE - RULER_RADIUS, pos_y - 0.5);
|
|
|
|
|
cairo_line_to (cr, pos_x - RULER_DISTANCE + RULER_RADIUS, pos_y - 0.5);
|
|
|
|
|
cairo_stroke (cr);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2009-07-17 14:33:16 +00:00
|
|
|
|
cairo_move_to (cr, pos_x - RULER_DISTANCE - RULER_RADIUS, pos_y + h + 0.5);
|
|
|
|
|
cairo_line_to (cr, pos_x - RULER_DISTANCE + RULER_RADIUS, pos_y + h + 0.5);
|
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_move_to (cr, pos_x + w + RULER_DISTANCE, pos_y);
|
|
|
|
|
cairo_line_to (cr, pos_x + w + RULER_DISTANCE, pos_y + h);
|
2009-07-17 14:33:16 +00:00
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_move_to (cr, pos_x + w + RULER_DISTANCE - RULER_RADIUS, pos_y - 0.5);
|
|
|
|
|
cairo_line_to (cr, pos_x + w + RULER_DISTANCE + RULER_RADIUS, pos_y - 0.5);
|
2009-07-17 14:33:16 +00:00
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_move_to (cr, pos_x + w + RULER_DISTANCE - RULER_RADIUS, pos_y + h + 0.5);
|
|
|
|
|
cairo_line_to (cr, pos_x + w + RULER_DISTANCE + RULER_RADIUS, pos_y + h + 0.5);
|
2009-07-17 14:33:16 +00:00
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
}
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_move_to (cr, pos_x, pos_y + h + RULER_DISTANCE);
|
|
|
|
|
cairo_line_to (cr, pos_x + w, pos_y + h + RULER_DISTANCE);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_move_to (cr, pos_x - 0.5, pos_y + h + RULER_DISTANCE - RULER_RADIUS);
|
|
|
|
|
cairo_line_to (cr, pos_x - 0.5, pos_y + h + RULER_DISTANCE + RULER_RADIUS);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
2019-12-24 17:28:00 +00:00
|
|
|
|
cairo_move_to (cr, pos_x + w + 0.5, pos_y + h + RULER_DISTANCE - RULER_RADIUS);
|
|
|
|
|
cairo_line_to (cr, pos_x + w + 0.5, pos_y + h + RULER_DISTANCE + RULER_RADIUS);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
redraw_page_layout_preview (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->page_layout_preview)
|
|
|
|
|
gtk_widget_queue_draw (dialog->page_layout_preview);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
static void
|
|
|
|
|
update_number_up_layout (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintCapabilities caps;
|
|
|
|
|
GtkPrinterOptionSet *set;
|
|
|
|
|
GtkNumberUpLayout layout;
|
|
|
|
|
GtkPrinterOption *option;
|
|
|
|
|
GtkPrinterOption *old_option;
|
2009-05-13 16:28:42 +00:00
|
|
|
|
GtkPageOrientation page_orientation;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
set = dialog->options;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
caps = dialog->manual_capabilities | dialog->printer_capabilities;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
|
|
|
|
if (caps & GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->number_up_layout_n_option == NULL)
|
2008-08-21 10:25:27 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->number_up_layout_n_option = gtk_printer_option_set_lookup (set, "gtk-n-up-layout");
|
|
|
|
|
if (dialog->number_up_layout_n_option == NULL)
|
2009-05-13 16:28:42 +00:00
|
|
|
|
{
|
2016-10-15 20:32:51 +00:00
|
|
|
|
const char *n_up_layout[] = { "lrtb", "lrbt", "rltb", "rlbt", "tblr", "tbrl", "btlr", "btrl" };
|
2009-05-13 16:28:42 +00:00
|
|
|
|
/* Translators: These strings name the possible arrangements of
|
|
|
|
|
* multiple pages on a sheet when printing (same as in gtkprintbackendcups.c)
|
|
|
|
|
*/
|
2016-10-15 20:32:51 +00:00
|
|
|
|
const char *n_up_layout_display[] = { N_("Left to right, top to bottom"), N_("Left to right, bottom to top"),
|
|
|
|
|
N_("Right to left, top to bottom"), N_("Right to left, bottom to top"),
|
|
|
|
|
N_("Top to bottom, left to right"), N_("Top to bottom, right to left"),
|
|
|
|
|
N_("Bottom to top, left to right"), N_("Bottom to top, right to left") };
|
2009-05-13 16:28:42 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->number_up_layout_n_option = gtk_printer_option_new ("gtk-n-up-layout",
|
2009-05-13 16:28:42 +00:00
|
|
|
|
_("Page Ordering"),
|
|
|
|
|
GTK_PRINTER_OPTION_TYPE_PICKONE);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_printer_option_allocate_choices (dialog->number_up_layout_n_option, 8);
|
2009-05-13 16:28:42 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (n_up_layout_display); i++)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->number_up_layout_n_option->choices[i] = g_strdup (n_up_layout[i]);
|
|
|
|
|
dialog->number_up_layout_n_option->choices_display[i] = g_strdup (_(n_up_layout_display[i]));
|
2009-05-13 16:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_object_ref (dialog->number_up_layout_n_option);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->number_up_layout_2_option = gtk_printer_option_new ("gtk-n-up-layout",
|
2008-08-21 10:25:27 +00:00
|
|
|
|
_("Page Ordering"),
|
|
|
|
|
GTK_PRINTER_OPTION_TYPE_PICKONE);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_printer_option_allocate_choices (dialog->number_up_layout_2_option, 2);
|
2009-05-13 16:28:42 +00:00
|
|
|
|
}
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
page_orientation = gtk_page_setup_get_orientation (dialog->page_setup);
|
2009-05-13 16:28:42 +00:00
|
|
|
|
if (page_orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
|
|
|
|
|
page_orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (! (dialog->number_up_layout_2_option->choices[0] == dialog->number_up_layout_n_option->choices[0] &&
|
|
|
|
|
dialog->number_up_layout_2_option->choices[1] == dialog->number_up_layout_n_option->choices[2]))
|
2009-05-13 16:28:42 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_free (dialog->number_up_layout_2_option->choices_display[0]);
|
|
|
|
|
g_free (dialog->number_up_layout_2_option->choices_display[1]);
|
|
|
|
|
dialog->number_up_layout_2_option->choices[0] = dialog->number_up_layout_n_option->choices[0];
|
|
|
|
|
dialog->number_up_layout_2_option->choices[1] = dialog->number_up_layout_n_option->choices[2];
|
|
|
|
|
dialog->number_up_layout_2_option->choices_display[0] = g_strdup ( _("Left to right"));
|
|
|
|
|
dialog->number_up_layout_2_option->choices_display[1] = g_strdup ( _("Right to left"));
|
2009-05-13 16:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (! (dialog->number_up_layout_2_option->choices[0] == dialog->number_up_layout_n_option->choices[0] &&
|
|
|
|
|
dialog->number_up_layout_2_option->choices[1] == dialog->number_up_layout_n_option->choices[1]))
|
2009-05-13 16:28:42 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_free (dialog->number_up_layout_2_option->choices_display[0]);
|
|
|
|
|
g_free (dialog->number_up_layout_2_option->choices_display[1]);
|
|
|
|
|
dialog->number_up_layout_2_option->choices[0] = dialog->number_up_layout_n_option->choices[0];
|
|
|
|
|
dialog->number_up_layout_2_option->choices[1] = dialog->number_up_layout_n_option->choices[1];
|
|
|
|
|
dialog->number_up_layout_2_option->choices_display[0] = g_strdup ( _("Top to bottom"));
|
|
|
|
|
dialog->number_up_layout_2_option->choices_display[1] = g_strdup ( _("Bottom to top"));
|
2009-05-13 16:28:42 +00:00
|
|
|
|
}
|
2008-08-21 10:25:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layout = dialog_get_number_up_layout (dialog);
|
|
|
|
|
|
|
|
|
|
old_option = gtk_printer_option_set_lookup (set, "gtk-n-up-layout");
|
|
|
|
|
if (old_option != NULL)
|
|
|
|
|
gtk_printer_option_set_remove (set, old_option);
|
|
|
|
|
|
|
|
|
|
if (dialog_get_pages_per_sheet (dialog) != 1)
|
|
|
|
|
{
|
2008-09-04 14:14:11 +00:00
|
|
|
|
GEnumClass *enum_class;
|
|
|
|
|
GEnumValue *enum_value;
|
|
|
|
|
enum_class = g_type_class_ref (GTK_TYPE_NUMBER_UP_LAYOUT);
|
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
if (dialog_get_pages_per_sheet (dialog) == 2)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = dialog->number_up_layout_2_option;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2009-10-21 00:55:46 +00:00
|
|
|
|
switch (layout)
|
|
|
|
|
{
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM:
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT:
|
|
|
|
|
enum_value = g_enum_get_value (enum_class, GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP:
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT:
|
|
|
|
|
enum_value = g_enum_get_value (enum_class, GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM:
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT:
|
|
|
|
|
enum_value = g_enum_get_value (enum_class, GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP:
|
|
|
|
|
case GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT:
|
|
|
|
|
enum_value = g_enum_get_value (enum_class, GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached();
|
|
|
|
|
enum_value = NULL;
|
|
|
|
|
}
|
2008-08-21 10:25:27 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
option = dialog->number_up_layout_n_option;
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
enum_value = g_enum_get_value (enum_class, layout);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-04 14:14:11 +00:00
|
|
|
|
g_assert (enum_value != NULL);
|
|
|
|
|
gtk_printer_option_set (option, enum_value->value_nick);
|
|
|
|
|
g_type_class_unref (enum_class);
|
|
|
|
|
|
2008-08-21 10:25:27 +00:00
|
|
|
|
gtk_printer_option_set_add (set, option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
setup_option (dialog, "gtk-n-up-layout", dialog->number_up_layout);
|
2008-08-21 10:25:27 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->number_up_layout != NULL)
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (dialog->number_up_layout),
|
2008-08-21 10:25:27 +00:00
|
|
|
|
(caps & GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT) &&
|
|
|
|
|
(dialog_get_pages_per_sheet (dialog) > 1));
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
static void
|
|
|
|
|
custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int response_id,
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gpointer user_data)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-06-15 21:54:49 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (user_data);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->internal_page_setup_change = TRUE;
|
2020-08-29 20:00:01 +00:00
|
|
|
|
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
update_paper_sizes (dialog);
|
|
|
|
|
dialog->internal_page_setup_change = FALSE;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->page_setup_set)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-06-15 21:54:49 +00:00
|
|
|
|
GListModel *model;
|
|
|
|
|
guint n, i;
|
|
|
|
|
|
|
|
|
|
model = G_LIST_MODEL (dialog->custom_paper_list);
|
|
|
|
|
n = g_list_model_get_n_items (model);
|
|
|
|
|
for (i = 0; i < n; i++)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-06-15 21:54:49 +00:00
|
|
|
|
GtkPageSetup *page_setup = g_list_model_get_item (model, i);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-06-15 21:54:49 +00:00
|
|
|
|
if (g_strcmp0 (gtk_paper_size_get_display_name (gtk_page_setup_get_paper_size (page_setup)),
|
|
|
|
|
gtk_paper_size_get_display_name (gtk_page_setup_get_paper_size (dialog->page_setup))) == 0)
|
|
|
|
|
gtk_print_unix_dialog_set_page_setup (dialog, page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-06-15 21:54:49 +00:00
|
|
|
|
g_clear_object (&page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 14:26:22 +00:00
|
|
|
|
gtk_window_destroy (GTK_WINDOW (custom_paper_dialog));
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-06-11 22:10:42 +00:00
|
|
|
|
orientation_changed (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
2009-07-10 09:28:31 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
2020-06-11 22:10:42 +00:00
|
|
|
|
GtkPageOrientation orientation;
|
|
|
|
|
GtkPageSetup *page_setup;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->internal_page_setup_change)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-06-11 22:10:42 +00:00
|
|
|
|
orientation = (GtkPageOrientation) gtk_drop_down_get_selected (GTK_DROP_DOWN (dialog->orientation_combo));
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->page_setup)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
page_setup = gtk_page_setup_copy (dialog->page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
if (page_setup)
|
|
|
|
|
gtk_page_setup_set_orientation (page_setup, orientation);
|
|
|
|
|
|
|
|
|
|
gtk_print_unix_dialog_set_page_setup (dialog, page_setup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
redraw_page_layout_preview (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-06-12 12:28:59 +00:00
|
|
|
|
paper_size_changed (GtkDropDown *combo_box,
|
|
|
|
|
GParamSpec *pspec,
|
2009-07-10 09:28:31 +00:00
|
|
|
|
GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPageSetup *page_setup, *last_page_setup;
|
|
|
|
|
GtkPageOrientation orientation;
|
2020-06-12 12:28:59 +00:00
|
|
|
|
guint selected;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->internal_page_setup_change)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (combo_box));
|
|
|
|
|
if (selected != GTK_INVALID_LIST_POSITION)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-06-12 12:28:59 +00:00
|
|
|
|
GListModel *papers, *model;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-06-12 12:28:59 +00:00
|
|
|
|
papers = gtk_drop_down_get_model (GTK_DROP_DOWN (dialog->paper_size_combo));
|
|
|
|
|
page_setup = g_list_model_get_item (papers, selected);
|
|
|
|
|
model = gtk_flatten_list_model_get_model_for_item (GTK_FLATTEN_LIST_MODEL (papers), selected);
|
|
|
|
|
|
|
|
|
|
if (model == G_LIST_MODEL (dialog->manage_papers_list))
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *custom_paper_dialog;
|
|
|
|
|
|
|
|
|
|
/* Change from "manage" menu item to last value */
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->page_setup)
|
|
|
|
|
last_page_setup = g_object_ref (dialog->page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
else
|
|
|
|
|
last_page_setup = gtk_page_setup_new (); /* "good" default */
|
|
|
|
|
|
|
|
|
|
if (!set_paper_size (dialog, last_page_setup, FALSE, FALSE))
|
|
|
|
|
set_paper_size (dialog, last_page_setup, TRUE, TRUE);
|
|
|
|
|
g_object_unref (last_page_setup);
|
|
|
|
|
|
|
|
|
|
/* And show the custom paper dialog */
|
|
|
|
|
custom_paper_dialog = _gtk_custom_paper_unix_dialog_new (GTK_WINDOW (dialog), _("Manage Custom Sizes"));
|
|
|
|
|
g_signal_connect (custom_paper_dialog, "response", G_CALLBACK (custom_paper_dialog_response_cb), dialog);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (custom_paper_dialog));
|
|
|
|
|
|
2020-07-16 12:48:09 +00:00
|
|
|
|
g_object_unref (page_setup);
|
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->page_setup)
|
|
|
|
|
orientation = gtk_page_setup_get_orientation (dialog->page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
else
|
|
|
|
|
orientation = GTK_PAGE_ORIENTATION_PORTRAIT;
|
|
|
|
|
|
|
|
|
|
gtk_page_setup_set_orientation (page_setup, orientation);
|
|
|
|
|
gtk_print_unix_dialog_set_page_setup (dialog, page_setup);
|
|
|
|
|
|
|
|
|
|
g_object_unref (page_setup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
redraw_page_layout_preview (dialog);
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_unix_dialog_new:
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @title: (nullable): Title of the dialog
|
|
|
|
|
* @parent: (nullable): Transient parent of the dialog
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Creates a new `GtkPrintUnixDialog`.
|
2006-04-21 15:09:32 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Returns: a new `GtkPrintUnixDialog`
|
2012-06-23 17:08:03 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkWidget *
|
2020-07-24 18:40:36 +00:00
|
|
|
|
gtk_print_unix_dialog_new (const char *title,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkWindow *parent)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *result;
|
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,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
"transient-for", parent,
|
2012-06-23 17:08:03 +00:00
|
|
|
|
"title", title ? title : _("Print"),
|
2006-04-21 15:09:32 +00:00
|
|
|
|
NULL);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_selected_printer: (attributes org.gtk.Method.get_property=selected-printer)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2006-04-24 17:51:51 +00:00
|
|
|
|
* Gets the currently selected printer.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2011-01-18 09:01:17 +00:00
|
|
|
|
* Returns: (transfer none): the currently selected printer
|
2006-04-24 17:51:51 +00:00
|
|
|
|
*/
|
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);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->current_printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_page_setup: (attributes org.gtk.Method.set_property=page-setup)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
|
|
|
|
* @page_setup: a `GtkPageSetup`
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Sets the page setup of the `GtkPrintUnixDialog`.
|
2006-04-24 17:51:51 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_set_page_setup (GtkPrintUnixDialog *dialog,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPageSetup *page_setup)
|
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));
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->page_setup != page_setup)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->page_setup);
|
|
|
|
|
dialog->page_setup = g_object_ref (page_setup);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->page_setup_set = TRUE;
|
2008-05-21 02:17:30 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_object_notify (G_OBJECT (dialog), "page-setup");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_page_setup: (attributes org.gtk.Method.get_property=page-setup)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets the page setup that is used by the `GtkPrintUnixDialog`.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2011-01-18 09:01:17 +00:00
|
|
|
|
* Returns: (transfer none): the page setup of @dialog.
|
2006-04-24 17:51:51 +00:00
|
|
|
|
*/
|
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);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->page_setup;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_unix_dialog_get_page_setup_set:
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-07-10 09:28:31 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets whether a page setup was set by the user.
|
2009-07-10 09:28:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: whether a page setup was set by user.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_unix_dialog_get_page_setup_set (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->page_setup_set;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_current_page: (attributes org.gtk.Method.set_property=current-page)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2006-04-24 17:51:51 +00:00
|
|
|
|
* @current_page: the current page number.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Sets the current page number.
|
|
|
|
|
*
|
|
|
|
|
* If @current_page is not -1, this enables the current page choice
|
|
|
|
|
* for the range of pages to print.
|
2006-04-24 17:51:51 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_set_current_page (GtkPrintUnixDialog *dialog,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int current_page)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->current_page != current_page)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->current_page = current_page;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->current_page_radio)
|
|
|
|
|
gtk_widget_set_sensitive (dialog->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
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_current_page: (attributes org.gtk.Method.get_property=current-page)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets the current page of the `GtkPrintUnixDialog`.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2006-04-24 17:51:51 +00:00
|
|
|
|
* Returns: the current page of @dialog
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_unix_dialog_get_current_page (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), -1);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->current_page;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
set_active_printer (GtkPrintUnixDialog *dialog,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *printer_name)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
GListModel *model;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrinter *printer;
|
2019-12-22 23:09:54 +00:00
|
|
|
|
guint i;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-08-31 21:06:48 +00:00
|
|
|
|
model = G_LIST_MODEL (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2019-12-22 23:09:54 +00:00
|
|
|
|
printer = g_list_model_get_item (model, i);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
if (strcmp (gtk_printer_get_name (printer), printer_name) == 0)
|
|
|
|
|
{
|
|
|
|
|
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (model), i);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_free (dialog->waiting_for_printer);
|
|
|
|
|
dialog->waiting_for_printer = NULL;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (printer);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2019-12-22 23:09:54 +00:00
|
|
|
|
g_object_unref (printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-24 17:51:51 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_settings: (attributes org.gtk.Method.set_property=print-settings)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @settings: (nullable): a `GtkPrintSettings`
|
2021-02-27 15:55:12 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the `GtkPrintSettings` for the `GtkPrintUnixDialog`.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Typically, this is used to restore saved print settings
|
|
|
|
|
* from a previous print operation before the print dialog
|
|
|
|
|
* is shown.
|
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrintSettings *settings)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *printer;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPageRange *ranges;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int num_ranges;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_set_page_ranges (dialog, ranges, num_ranges);
|
2006-06-30 10:42:31 +00:00
|
|
|
|
g_free (ranges);
|
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->format_for_printer =
|
2009-06-28 20:13:33 +00:00
|
|
|
|
g_strdup (gtk_print_settings_get (settings, "format-for-printer"));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->initial_settings)
|
|
|
|
|
g_object_unref (dialog->initial_settings);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->initial_settings = settings;
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_free (dialog->waiting_for_printer);
|
|
|
|
|
dialog->waiting_for_printer = NULL;
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (settings)
|
|
|
|
|
{
|
|
|
|
|
g_object_ref (settings);
|
|
|
|
|
|
|
|
|
|
printer = gtk_print_settings_get_printer (settings);
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
if (printer && !set_active_printer (dialog, printer))
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->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
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_settings: (attributes org.gtk.Method.set_property=print-settings)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
|
|
|
|
*
|
|
|
|
|
* Gets a new `GtkPrintSettings` object that represents the
|
|
|
|
|
* current values in the print dialog.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Note that this creates a new object, and you need to unref
|
|
|
|
|
* it if don’t want to keep it.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Returns: (transfer full): a new `GtkPrintSettings` object with the values from @dialog
|
2006-04-24 17:51:51 +00:00
|
|
|
|
*/
|
2006-04-21 15:09:32 +00:00
|
|
|
|
GtkPrintSettings *
|
|
|
|
|
gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
GtkPrintSettings *settings;
|
|
|
|
|
GtkPrintPages print_pages;
|
|
|
|
|
GtkPageRange *ranges;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int 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
|
|
|
|
|
|
|
|
|
settings = gtk_print_settings_new ();
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->current_printer)
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_set_printer (settings,
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_printer_get_name (dialog->current_printer));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
else
|
|
|
|
|
gtk_print_settings_set_printer (settings, "default");
|
2009-06-28 20:13:33 +00:00
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_set (settings, "format-for-printer",
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->format_for_printer);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
gtk_print_settings_set_collate (settings,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_get_collate (dialog));
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_set_reverse (settings,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_get_reverse (dialog));
|
|
|
|
|
|
2006-05-12 09:47:58 +00:00
|
|
|
|
gtk_print_settings_set_n_copies (settings,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_get_n_copies (dialog));
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
|
|
|
|
gtk_print_settings_set_scale (settings,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_get_scale (dialog));
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
gtk_print_settings_set_page_set (settings,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
dialog_get_page_set (dialog));
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2012-06-23 17:08:03 +00:00
|
|
|
|
gtk_print_settings_set_page_ranges (settings, ranges, n_ranges);
|
2006-04-21 15:09:32 +00:00
|
|
|
|
g_free (ranges);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* TODO: print when. How to handle? */
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->current_printer)
|
|
|
|
|
_gtk_printer_get_settings_from_options (dialog->current_printer,
|
|
|
|
|
dialog->options,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
settings);
|
|
|
|
|
|
2006-04-21 15:09:32 +00:00
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-29 09:18:07 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_print_unix_dialog_add_custom_tab:
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2006-06-29 09:18:07 +00:00
|
|
|
|
* @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.
|
|
|
|
|
*/
|
2006-05-23 08:09:08 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_add_custom_tab (GtkPrintUnixDialog *dialog,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkWidget *child,
|
|
|
|
|
GtkWidget *tab_label)
|
2006-05-23 08:09:08 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_notebook_insert_page (GTK_NOTEBOOK (dialog->notebook),
|
2009-06-28 20:13:33 +00:00
|
|
|
|
child, tab_label, 2);
|
2006-05-23 08:09:08 +00:00
|
|
|
|
gtk_widget_show (child);
|
|
|
|
|
gtk_widget_show (tab_label);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-24 10:50:57 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_manual_capabilities: (attributes org.gtk.Method.set_property=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
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* 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.
|
2006-05-24 10:50:57 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2006-06-12 16:47:41 +00:00
|
|
|
|
gtk_print_unix_dialog_set_manual_capabilities (GtkPrintUnixDialog *dialog,
|
2009-06-28 20:13:33 +00:00
|
|
|
|
GtkPrintCapabilities capabilities)
|
2006-05-24 10:50:57 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->manual_capabilities != capabilities)
|
2009-06-08 13:37:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->manual_capabilities = capabilities;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
update_dialog_from_capabilities (dialog);
|
2006-08-17 04:48:39 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->current_printer)
|
2009-06-08 13:37:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
g_clear_object (&dialog->current_printer);
|
2019-12-22 23:09:54 +00:00
|
|
|
|
selected_printer_changed (dialog);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (dialog), "manual-capabilities");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_manual_capabilities: (attributes org.gtk.Method.get_property=manual-capabilities)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-08 13:37:32 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets the capabilities that have been set on this `GtkPrintUnixDialog`.
|
2009-06-08 13:37:32 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the printing capabilities
|
|
|
|
|
*/
|
|
|
|
|
GtkPrintCapabilities
|
|
|
|
|
gtk_print_unix_dialog_get_manual_capabilities (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->manual_capabilities;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_support_selection: (attributes org.gtk.Method.set_property=support-selection)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-08 13:37:32 +00:00
|
|
|
|
* @support_selection: %TRUE to allow print selection
|
|
|
|
|
*
|
|
|
|
|
* Sets whether the print dialog allows user to print a selection.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_set_support_selection (GtkPrintUnixDialog *dialog,
|
|
|
|
|
gboolean support_selection)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
|
|
|
|
|
|
support_selection = support_selection != FALSE;
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->support_selection != support_selection)
|
2006-08-17 04:48:39 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->support_selection = support_selection;
|
2006-08-17 04:48:39 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->selection_radio)
|
2009-06-08 13:37:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (support_selection)
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->selection_radio, dialog->has_selection);
|
|
|
|
|
gtk_widget_show (dialog->selection_radio);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->selection_radio, FALSE);
|
|
|
|
|
gtk_widget_hide (dialog->selection_radio);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-08-17 04:48:39 +00:00
|
|
|
|
|
2009-06-08 13:37:32 +00:00
|
|
|
|
g_object_notify (G_OBJECT (dialog), "support-selection");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_support_selection: (attributes org.gtk.Method.get_property=support-selection)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-08 13:37:32 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets whether the print dialog allows user to print a selection.
|
2009-06-08 13:37:32 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: whether the application supports print of selection
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_unix_dialog_get_support_selection (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->support_selection;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_has_selection: (attributes org.gtk.Method.set_property=has-selection)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-08 13:37:32 +00:00
|
|
|
|
* @has_selection: %TRUE indicates that a selection exists
|
|
|
|
|
*
|
|
|
|
|
* Sets whether a selection exists.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_set_has_selection (GtkPrintUnixDialog *dialog,
|
|
|
|
|
gboolean has_selection)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
|
|
|
|
|
|
has_selection = has_selection != FALSE;
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->has_selection != has_selection)
|
2009-06-08 13:37:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->has_selection = has_selection;
|
2009-06-08 13:37:32 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->selection_radio)
|
2009-06-08 13:37:32 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->support_selection)
|
|
|
|
|
gtk_widget_set_sensitive (dialog->selection_radio, has_selection);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
else
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->selection_radio, FALSE);
|
2009-06-08 13:37:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (dialog), "has-selection");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_has_selection: (attributes org.gtk.Method.get_property=has-selection)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-06-08 13:37:32 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets whether there is a selection.
|
2009-06-28 20:13:33 +00:00
|
|
|
|
*
|
2009-06-08 13:37:32 +00:00
|
|
|
|
* Returns: whether there is a selection
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_unix_dialog_get_has_selection (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->has_selection;
|
2006-05-24 10:50:57 +00:00
|
|
|
|
}
|
2006-04-21 15:09:32 +00:00
|
|
|
|
|
2009-07-10 09:28:31 +00:00
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_set_embed_page_setup: (attributes org.gtk.Method.set_property=embed-page-setup)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-07-10 09:28:31 +00:00
|
|
|
|
* @embed: embed page setup selection
|
|
|
|
|
*
|
|
|
|
|
* Embed page size combo box and orientation combo box into page setup page.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_print_unix_dialog_set_embed_page_setup (GtkPrintUnixDialog *dialog,
|
|
|
|
|
gboolean embed)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog));
|
|
|
|
|
|
|
|
|
|
embed = embed != FALSE;
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->embed_page_setup != embed)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->embed_page_setup = embed;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
gtk_widget_set_sensitive (dialog->paper_size_combo, dialog->embed_page_setup);
|
|
|
|
|
gtk_widget_set_sensitive (dialog->orientation_combo, dialog->embed_page_setup);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->embed_page_setup)
|
2009-07-10 09:28:31 +00:00
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->paper_size_combo != NULL)
|
2020-06-12 12:28:59 +00:00
|
|
|
|
g_signal_connect (dialog->paper_size_combo, "notify::selected", G_CALLBACK (paper_size_changed), dialog);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->orientation_combo)
|
2020-06-11 22:10:42 +00:00
|
|
|
|
g_signal_connect (dialog->orientation_combo, "notify::selected", G_CALLBACK (orientation_changed), dialog);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->paper_size_combo != NULL)
|
|
|
|
|
g_signal_handlers_disconnect_by_func (dialog->paper_size_combo, G_CALLBACK (paper_size_changed), dialog);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
if (dialog->orientation_combo)
|
|
|
|
|
g_signal_handlers_disconnect_by_func (dialog->orientation_combo, G_CALLBACK (orientation_changed), dialog);
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->internal_page_setup_change = TRUE;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
update_paper_sizes (dialog);
|
2020-03-28 20:04:30 +00:00
|
|
|
|
dialog->internal_page_setup_change = FALSE;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* gtk_print_unix_dialog_get_embed_page_setup: (attributes org.gtk.Method.get_property=embed-page-setup)
|
|
|
|
|
* @dialog: a `GtkPrintUnixDialog`
|
2009-07-10 09:28:31 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Gets whether to embed the page setup.
|
2009-07-10 09:28:31 +00:00
|
|
|
|
*
|
2021-02-27 15:55:12 +00:00
|
|
|
|
* Returns: whether to embed the page setup
|
2009-07-10 09:28:31 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_print_unix_dialog_get_embed_page_setup (GtkPrintUnixDialog *dialog)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_PRINT_UNIX_DIALOG (dialog), FALSE);
|
|
|
|
|
|
2020-03-28 20:04:30 +00:00
|
|
|
|
return dialog->embed_page_setup;
|
2009-07-10 09:28:31 +00:00
|
|
|
|
}
|