mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Merge branch 'printer-combo-conversion' into 'master'
Printer combo conversion See merge request GNOME/gtk!2095
This commit is contained in:
commit
ab50d2090d
@ -64,7 +64,6 @@ struct _GtkCustomPaperUnixDialog
|
||||
GtkWidget *right_widget;
|
||||
|
||||
gulong printer_inserted_tag;
|
||||
gulong printer_removed_tag;
|
||||
|
||||
guint request_details_tag;
|
||||
GtkPrinter *request_details_printer;
|
||||
@ -72,11 +71,9 @@ struct _GtkCustomPaperUnixDialog
|
||||
guint non_user_change : 1;
|
||||
|
||||
GListStore *custom_paper_list;
|
||||
GtkListStore *printer_list;
|
||||
GListModel *printer_list;
|
||||
|
||||
GList *print_backends;
|
||||
|
||||
gchar *waiting_for_printer;
|
||||
};
|
||||
|
||||
typedef struct _GtkCustomPaperUnixDialogClass GtkCustomPaperUnixDialogClass;
|
||||
@ -100,15 +97,6 @@ G_DEFINE_TYPE (GtkCustomPaperUnixDialog, gtk_custom_paper_unix_dialog, GTK_TYPE_
|
||||
static void gtk_custom_paper_unix_dialog_constructed (GObject *object);
|
||||
static void gtk_custom_paper_unix_dialog_finalize (GObject *object);
|
||||
static void populate_dialog (GtkCustomPaperUnixDialog *dialog);
|
||||
static void printer_added_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkCustomPaperUnixDialog *dialog);
|
||||
static void printer_removed_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkCustomPaperUnixDialog *dialog);
|
||||
static void printer_status_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkCustomPaperUnixDialog *dialog);
|
||||
|
||||
|
||||
|
||||
@ -303,10 +291,20 @@ custom_paper_dialog_response_cb (GtkDialog *dialog,
|
||||
gtk_print_save_custom_papers (self->custom_paper_list);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
match_func (gpointer item, gpointer user_data)
|
||||
{
|
||||
return !gtk_printer_is_virtual (GTK_PRINTER (item));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkPrinter *printer;
|
||||
GListStore *printer_list;
|
||||
GListStore *printer_list_list;
|
||||
GListModel *full_list;
|
||||
GtkFilter *filter;
|
||||
|
||||
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
|
||||
|
||||
@ -315,11 +313,21 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
|
||||
dialog->request_details_printer = NULL;
|
||||
dialog->request_details_tag = 0;
|
||||
|
||||
dialog->printer_list = gtk_list_store_new (PRINTER_LIST_N_COLS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_OBJECT);
|
||||
printer_list_list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
printer_list = g_list_store_new (GTK_TYPE_PRINTER);
|
||||
printer = gtk_printer_new (_("Margins from Printer…"), NULL, FALSE);
|
||||
g_list_store_append (printer_list, printer);
|
||||
g_object_unref (printer);
|
||||
g_list_store_append (printer_list_list, printer_list);
|
||||
g_object_unref (printer_list);
|
||||
|
||||
gtk_list_store_append (dialog->printer_list, &iter);
|
||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (GTK_TYPE_PRINTER, G_LIST_MODEL (printer_list_list)));
|
||||
g_object_unref (printer_list_list);
|
||||
|
||||
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
|
||||
g_object_unref (full_list);
|
||||
g_object_unref (filter);
|
||||
|
||||
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
|
||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||
@ -350,13 +358,11 @@ static void
|
||||
gtk_custom_paper_unix_dialog_finalize (GObject *object)
|
||||
{
|
||||
GtkCustomPaperUnixDialog *dialog = GTK_CUSTOM_PAPER_UNIX_DIALOG (object);
|
||||
GtkPrintBackend *backend;
|
||||
GList *node;
|
||||
|
||||
if (dialog->printer_list)
|
||||
{
|
||||
g_signal_handler_disconnect (dialog->printer_list, dialog->printer_inserted_tag);
|
||||
g_signal_handler_disconnect (dialog->printer_list, dialog->printer_removed_tag);
|
||||
g_object_unref (dialog->printer_list);
|
||||
dialog->printer_list = NULL;
|
||||
}
|
||||
@ -372,22 +378,9 @@ gtk_custom_paper_unix_dialog_finalize (GObject *object)
|
||||
|
||||
g_clear_object (&dialog->custom_paper_list);
|
||||
|
||||
g_free (dialog->waiting_for_printer);
|
||||
dialog->waiting_for_printer = NULL;
|
||||
|
||||
for (node = dialog->print_backends; node != NULL; node = node->next)
|
||||
{
|
||||
backend = GTK_PRINT_BACKEND (node->data);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (backend, printer_added_cb, dialog);
|
||||
g_signal_handlers_disconnect_by_func (backend, printer_removed_cb, dialog);
|
||||
g_signal_handlers_disconnect_by_func (backend, printer_status_cb, dialog);
|
||||
|
||||
gtk_print_backend_destroy (backend);
|
||||
g_object_unref (backend);
|
||||
}
|
||||
|
||||
g_list_free (dialog->print_backends);
|
||||
for (node = dialog->print_backends; node; node = node->next)
|
||||
gtk_print_backend_destroy (GTK_PRINT_BACKEND (node->data));
|
||||
g_list_free_full (dialog->print_backends, g_object_unref);
|
||||
dialog->print_backends = NULL;
|
||||
|
||||
G_OBJECT_CLASS (gtk_custom_paper_unix_dialog_parent_class)->finalize (object);
|
||||
@ -422,118 +415,24 @@ _gtk_custom_paper_unix_dialog_new (GtkWindow *parent,
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
printer_added_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gchar *str;
|
||||
|
||||
if (gtk_printer_is_virtual (printer))
|
||||
return;
|
||||
|
||||
str = g_strdup_printf ("<b>%s</b>",
|
||||
gtk_printer_get_name (printer));
|
||||
|
||||
gtk_list_store_append (dialog->printer_list, &iter);
|
||||
gtk_list_store_set (dialog->printer_list, &iter,
|
||||
PRINTER_LIST_COL_NAME, str,
|
||||
PRINTER_LIST_COL_PRINTER, printer,
|
||||
-1);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (printer),
|
||||
"gtk-print-tree-iter",
|
||||
gtk_tree_iter_copy (&iter),
|
||||
(GDestroyNotify) gtk_tree_iter_free);
|
||||
|
||||
g_free (str);
|
||||
|
||||
if (dialog->waiting_for_printer != NULL &&
|
||||
strcmp (dialog->waiting_for_printer,
|
||||
gtk_printer_get_name (printer)) == 0)
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->printer_combo),
|
||||
&iter);
|
||||
dialog->waiting_for_printer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printer_removed_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
GtkTreeIter *iter;
|
||||
|
||||
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
|
||||
gtk_list_store_remove (GTK_LIST_STORE (dialog->printer_list), iter);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
printer_status_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
GtkTreeIter *iter;
|
||||
gchar *str;
|
||||
|
||||
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
|
||||
|
||||
str = g_strdup_printf ("<b>%s</b>",
|
||||
gtk_printer_get_name (printer));
|
||||
gtk_list_store_set (dialog->printer_list, iter,
|
||||
PRINTER_LIST_COL_NAME, str,
|
||||
-1);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
static void
|
||||
printer_list_initialize (GtkCustomPaperUnixDialog *dialog,
|
||||
GtkPrintBackend *print_backend)
|
||||
{
|
||||
GList *list, *node;
|
||||
|
||||
g_return_if_fail (print_backend != NULL);
|
||||
|
||||
g_signal_connect_object (print_backend,
|
||||
"printer-added",
|
||||
(GCallback) printer_added_cb,
|
||||
G_OBJECT (dialog), 0);
|
||||
|
||||
g_signal_connect_object (print_backend,
|
||||
"printer-removed",
|
||||
(GCallback) printer_removed_cb,
|
||||
G_OBJECT (dialog), 0);
|
||||
|
||||
g_signal_connect_object (print_backend,
|
||||
"printer-status-changed",
|
||||
(GCallback) printer_status_cb,
|
||||
G_OBJECT (dialog), 0);
|
||||
|
||||
list = gtk_print_backend_get_printer_list (print_backend);
|
||||
|
||||
node = list;
|
||||
while (node != NULL)
|
||||
{
|
||||
printer_added_cb (print_backend, node->data, dialog);
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
static void
|
||||
load_print_backends (GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
GListModel *full_list;
|
||||
GListStore *printer_list_list;
|
||||
GList *node;
|
||||
|
||||
full_list = gtk_filter_list_model_get_model (GTK_FILTER_LIST_MODEL (dialog->printer_list));
|
||||
printer_list_list = G_LIST_STORE (gtk_flatten_list_model_get_model (GTK_FLATTEN_LIST_MODEL (full_list)));
|
||||
|
||||
if (g_module_supported ())
|
||||
dialog->print_backends = gtk_print_backend_load_modules ();
|
||||
|
||||
for (node = dialog->print_backends; node != NULL; node = node->next)
|
||||
printer_list_initialize (dialog, GTK_PRINT_BACKEND (node->data));
|
||||
{
|
||||
GtkPrintBackend *backend = GTK_PRINT_BACKEND (node->data);
|
||||
g_list_store_append (printer_list_list, gtk_print_backend_get_printers (backend));
|
||||
}
|
||||
}
|
||||
|
||||
static void unit_widget_changed (GtkCustomPaperUnixDialog *dialog);
|
||||
@ -600,43 +499,12 @@ unit_widget_set (GtkWidget *unit_widget,
|
||||
_gtk_print_convert_from_mm (value, data->display_unit));
|
||||
}
|
||||
|
||||
static void
|
||||
custom_paper_printer_data_func (GtkCellLayout *cell_layout,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
GtkPrinter *printer;
|
||||
|
||||
gtk_tree_model_get (tree_model, iter,
|
||||
PRINTER_LIST_COL_PRINTER, &printer, -1);
|
||||
|
||||
if (printer)
|
||||
g_object_set (cell, "text", gtk_printer_get_name (printer), NULL);
|
||||
else
|
||||
g_object_set (cell, "text", _("Margins from Printer…"), NULL);
|
||||
|
||||
if (printer)
|
||||
g_object_unref (printer);
|
||||
}
|
||||
|
||||
static void
|
||||
update_combo_sensitivity_from_printers (GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
gboolean sensitive = FALSE;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GListModel *selection;
|
||||
|
||||
sensitive = FALSE;
|
||||
|
||||
model = GTK_TREE_MODEL (dialog->printer_list);
|
||||
selection = gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview));
|
||||
|
||||
if (gtk_tree_model_get_iter_first (model, &iter) &&
|
||||
gtk_tree_model_iter_next (model, &iter) &&
|
||||
gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (selection)))
|
||||
if (g_list_model_get_n_items (dialog->printer_list) > 1)
|
||||
sensitive = TRUE;
|
||||
|
||||
gtk_widget_set_sensitive (dialog->printer_combo, sensitive);
|
||||
@ -824,18 +692,15 @@ get_margins_finished_callback (GtkPrinter *printer,
|
||||
if (success)
|
||||
set_margins_from_printer (dialog, printer);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->printer_combo), 0);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->printer_combo), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
margins_from_printer_changed (GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkComboBox *combo;
|
||||
guint selected;
|
||||
GtkPrinter *printer;
|
||||
|
||||
combo = GTK_COMBO_BOX (dialog->printer_combo);
|
||||
|
||||
if (dialog->request_details_tag)
|
||||
{
|
||||
g_signal_handler_disconnect (dialog->request_details_printer,
|
||||
@ -845,17 +710,20 @@ margins_from_printer_changed (GtkCustomPaperUnixDialog *dialog)
|
||||
dialog->request_details_tag = 0;
|
||||
}
|
||||
|
||||
if (gtk_combo_box_get_active_iter (combo, &iter))
|
||||
selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (dialog->printer_combo));
|
||||
if (selected != 0)
|
||||
{
|
||||
gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
|
||||
PRINTER_LIST_COL_PRINTER, &printer, -1);
|
||||
GListModel *model;
|
||||
|
||||
model = gtk_drop_down_get_model (GTK_DROP_DOWN (dialog->printer_combo));
|
||||
printer = g_list_model_get_item (model, selected);
|
||||
|
||||
if (printer)
|
||||
{
|
||||
if (gtk_printer_has_details (printer))
|
||||
{
|
||||
set_margins_from_printer (dialog, printer);
|
||||
gtk_combo_box_set_active (combo, 0);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (dialog->printer_combo), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -970,6 +838,30 @@ unbind_item (GtkSignalListItemFactory *factory,
|
||||
g_signal_handlers_disconnect_by_func (gtk_widget_get_parent (label), state_changed, label);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_printer_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_printer_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkPrinter *printer;
|
||||
GtkWidget *label;
|
||||
|
||||
printer = gtk_list_item_get_item (item);
|
||||
label = gtk_list_item_get_child (item);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), gtk_printer_get_name (printer));
|
||||
}
|
||||
|
||||
static void
|
||||
populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
||||
{
|
||||
@ -977,7 +869,6 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *grid, *label, *widget, *frame, *combo;
|
||||
GtkWidget *hbox, *vbox, *listview, *scrolled, *toolbar, *button;
|
||||
GtkCellRenderer *cell;
|
||||
GtkUnit user_units;
|
||||
GListModel *model;
|
||||
GtkListItemFactory *factory;
|
||||
@ -1131,28 +1022,26 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
||||
gtk_grid_attach (GTK_GRID (grid), hbox, 0, 4, 2, 1);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (dialog->printer_list));
|
||||
combo = gtk_drop_down_new ();
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (combo), dialog->printer_list);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_printer_item), dialog);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_printer_item), dialog);
|
||||
gtk_drop_down_set_factory (GTK_DROP_DOWN (combo), factory);
|
||||
g_object_unref (factory);
|
||||
|
||||
dialog->printer_combo = combo;
|
||||
|
||||
dialog->printer_inserted_tag =
|
||||
g_signal_connect_swapped (dialog->printer_list, "row-inserted",
|
||||
G_CALLBACK (update_combo_sensitivity_from_printers), dialog);
|
||||
dialog->printer_removed_tag =
|
||||
g_signal_connect_swapped (dialog->printer_list, "row-deleted",
|
||||
g_signal_connect_swapped (dialog->printer_list, "items-changed",
|
||||
G_CALLBACK (update_combo_sensitivity_from_printers), dialog);
|
||||
update_combo_sensitivity_from_printers (dialog);
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
|
||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), cell,
|
||||
custom_paper_printer_data_func,
|
||||
NULL, NULL);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
|
||||
gtk_box_append (GTK_BOX (hbox), combo);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
g_signal_connect_swapped (combo, "changed",
|
||||
g_signal_connect_swapped (combo, "notify::selected",
|
||||
G_CALLBACK (margins_from_printer_changed), dialog);
|
||||
|
||||
frame = wrap_in_frame (_("Paper Margins"), grid);
|
||||
|
@ -47,8 +47,6 @@
|
||||
#include "gtkspinbutton.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktextview.h"
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtktreeview.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtksettings.h"
|
||||
#include "gtkdialog.h"
|
||||
|
@ -59,20 +59,11 @@
|
||||
*/
|
||||
|
||||
typedef struct _GtkPageSetupUnixDialogClass GtkPageSetupUnixDialogClass;
|
||||
typedef struct _GtkPageSetupUnixDialogPrivate GtkPageSetupUnixDialogPrivate;
|
||||
|
||||
struct _GtkPageSetupUnixDialog
|
||||
{
|
||||
GtkDialog parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkPageSetupUnixDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkPageSetupUnixDialogPrivate
|
||||
{
|
||||
GtkListStore *printer_list;
|
||||
GtkListStore *page_setup_list;
|
||||
GtkListStore *custom_paper_list;
|
||||
@ -100,6 +91,11 @@ struct _GtkPageSetupUnixDialogPrivate
|
||||
gchar *waiting_for_printer;
|
||||
};
|
||||
|
||||
struct _GtkPageSetupUnixDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Keep these in line with GtkListStores defined in gtkpagesetupunixprintdialog.ui */
|
||||
enum {
|
||||
@ -114,7 +110,7 @@ enum {
|
||||
PAGE_SETUP_LIST_N_COLS
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkPageSetupUnixDialog, gtk_page_setup_unix_dialog, GTK_TYPE_DIALOG)
|
||||
G_DEFINE_TYPE (GtkPageSetupUnixDialog, gtk_page_setup_unix_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
static void gtk_page_setup_unix_dialog_finalize (GObject *object);
|
||||
static void fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
|
||||
@ -175,17 +171,17 @@ gtk_page_setup_unix_dialog_class_init (GtkPageSetupUnixDialogClass *class)
|
||||
gtk_widget_class_set_template_from_resource (widget_class,
|
||||
"/org/gtk/libgtk/ui/gtkpagesetupunixdialog.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, printer_list);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, page_setup_list);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, custom_paper_list);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, printer_combo);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, paper_size_combo);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, paper_size_label);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, paper_size_cell);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, portrait_radio);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, reverse_portrait_radio);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, landscape_radio);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkPageSetupUnixDialog, reverse_landscape_radio);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, printer_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, page_setup_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, custom_paper_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, printer_combo);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, paper_size_combo);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, paper_size_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, paper_size_cell);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, portrait_radio);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, reverse_portrait_radio);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, landscape_radio);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPageSetupUnixDialog, reverse_landscape_radio);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, printer_changed_callback);
|
||||
gtk_widget_class_bind_template_callback (widget_class, paper_size_changed);
|
||||
@ -194,13 +190,10 @@ gtk_page_setup_unix_dialog_class_init (GtkPageSetupUnixDialogClass *class)
|
||||
static void
|
||||
gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv;
|
||||
GtkTreeIter iter;
|
||||
gchar *tmp;
|
||||
|
||||
priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
|
||||
priv->print_backends = NULL;
|
||||
dialog->print_backends = NULL;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (dialog));
|
||||
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
|
||||
@ -211,26 +204,26 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
|
||||
/* Do this in code, we want the translatable strings without the markup */
|
||||
gtk_list_store_append (priv->printer_list, &iter);
|
||||
gtk_list_store_append (dialog->printer_list, &iter);
|
||||
tmp = g_strdup_printf ("<b>%s</b>\n%s", _("Any Printer"), _("For portable documents"));
|
||||
gtk_list_store_set (priv->printer_list, &iter,
|
||||
gtk_list_store_set (dialog->printer_list, &iter,
|
||||
PRINTER_LIST_COL_NAME, tmp,
|
||||
PRINTER_LIST_COL_PRINTER, NULL,
|
||||
-1);
|
||||
g_free (tmp);
|
||||
|
||||
/* After adding the above row, set it active */
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->printer_combo), 0);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->printer_combo), 0);
|
||||
|
||||
/* Setup cell data func and separator func in code */
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (priv->paper_size_combo),
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (dialog->paper_size_combo),
|
||||
paper_size_row_is_separator, NULL, NULL);
|
||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->paper_size_combo),
|
||||
priv->paper_size_cell,
|
||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (dialog->paper_size_combo),
|
||||
dialog->paper_size_cell,
|
||||
page_name_func, NULL, NULL);
|
||||
|
||||
/* Load data */
|
||||
_gtk_print_load_custom_papers (priv->custom_paper_list);
|
||||
_gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||
load_print_backends (dialog);
|
||||
}
|
||||
|
||||
@ -238,47 +231,46 @@ static void
|
||||
gtk_page_setup_unix_dialog_finalize (GObject *object)
|
||||
{
|
||||
GtkPageSetupUnixDialog *dialog = GTK_PAGE_SETUP_UNIX_DIALOG (object);
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkPrintBackend *backend;
|
||||
GList *node;
|
||||
|
||||
if (priv->request_details_tag)
|
||||
if (dialog->request_details_tag)
|
||||
{
|
||||
g_signal_handler_disconnect (priv->request_details_printer,
|
||||
priv->request_details_tag);
|
||||
g_object_unref (priv->request_details_printer);
|
||||
priv->request_details_printer = NULL;
|
||||
priv->request_details_tag = 0;
|
||||
g_signal_handler_disconnect (dialog->request_details_printer,
|
||||
dialog->request_details_tag);
|
||||
g_object_unref (dialog->request_details_printer);
|
||||
dialog->request_details_printer = NULL;
|
||||
dialog->request_details_tag = 0;
|
||||
}
|
||||
|
||||
if (priv->printer_list)
|
||||
if (dialog->printer_list)
|
||||
{
|
||||
g_object_unref (priv->printer_list);
|
||||
priv->printer_list = NULL;
|
||||
g_object_unref (dialog->printer_list);
|
||||
dialog->printer_list = NULL;
|
||||
}
|
||||
|
||||
if (priv->page_setup_list)
|
||||
if (dialog->page_setup_list)
|
||||
{
|
||||
g_object_unref (priv->page_setup_list);
|
||||
priv->page_setup_list = NULL;
|
||||
g_object_unref (dialog->page_setup_list);
|
||||
dialog->page_setup_list = NULL;
|
||||
}
|
||||
|
||||
if (priv->custom_paper_list)
|
||||
if (dialog->custom_paper_list)
|
||||
{
|
||||
g_object_unref (priv->custom_paper_list);
|
||||
priv->custom_paper_list = NULL;
|
||||
g_object_unref (dialog->custom_paper_list);
|
||||
dialog->custom_paper_list = NULL;
|
||||
}
|
||||
|
||||
if (priv->print_settings)
|
||||
if (dialog->print_settings)
|
||||
{
|
||||
g_object_unref (priv->print_settings);
|
||||
priv->print_settings = NULL;
|
||||
g_object_unref (dialog->print_settings);
|
||||
dialog->print_settings = NULL;
|
||||
}
|
||||
|
||||
g_free (priv->waiting_for_printer);
|
||||
priv->waiting_for_printer = NULL;
|
||||
g_free (dialog->waiting_for_printer);
|
||||
dialog->waiting_for_printer = NULL;
|
||||
|
||||
for (node = priv->print_backends; node != NULL; node = node->next)
|
||||
for (node = dialog->print_backends; node != NULL; node = node->next)
|
||||
{
|
||||
backend = GTK_PRINT_BACKEND (node->data);
|
||||
|
||||
@ -290,8 +282,8 @@ gtk_page_setup_unix_dialog_finalize (GObject *object)
|
||||
g_object_unref (backend);
|
||||
}
|
||||
|
||||
g_list_free (priv->print_backends);
|
||||
priv->print_backends = NULL;
|
||||
g_list_free (dialog->print_backends);
|
||||
dialog->print_backends = NULL;
|
||||
|
||||
G_OBJECT_CLASS (gtk_page_setup_unix_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
@ -301,7 +293,6 @@ printer_added_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeIter iter;
|
||||
gchar *str;
|
||||
const gchar *location;
|
||||
@ -316,8 +307,8 @@ printer_added_cb (GtkPrintBackend *backend,
|
||||
gtk_printer_get_name (printer),
|
||||
location);
|
||||
|
||||
gtk_list_store_append (priv->printer_list, &iter);
|
||||
gtk_list_store_set (priv->printer_list, &iter,
|
||||
gtk_list_store_append (dialog->printer_list, &iter);
|
||||
gtk_list_store_set (dialog->printer_list, &iter,
|
||||
PRINTER_LIST_COL_NAME, str,
|
||||
PRINTER_LIST_COL_PRINTER, printer,
|
||||
-1);
|
||||
@ -328,13 +319,13 @@ printer_added_cb (GtkPrintBackend *backend,
|
||||
(GDestroyNotify) gtk_tree_iter_free);
|
||||
g_free (str);
|
||||
|
||||
if (priv->waiting_for_printer != NULL &&
|
||||
strcmp (priv->waiting_for_printer,
|
||||
if (dialog->waiting_for_printer != NULL &&
|
||||
strcmp (dialog->waiting_for_printer,
|
||||
gtk_printer_get_name (printer)) == 0)
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->printer_combo),
|
||||
&iter);
|
||||
priv->waiting_for_printer = NULL;
|
||||
dialog->waiting_for_printer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,11 +334,10 @@ printer_removed_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeIter *iter;
|
||||
|
||||
iter = g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter");
|
||||
gtk_list_store_remove (GTK_LIST_STORE (priv->printer_list), iter);
|
||||
gtk_list_store_remove (GTK_LIST_STORE (dialog->printer_list), iter);
|
||||
}
|
||||
|
||||
|
||||
@ -356,7 +346,6 @@ printer_status_cb (GtkPrintBackend *backend,
|
||||
GtkPrinter *printer,
|
||||
GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeIter *iter;
|
||||
gchar *str;
|
||||
const gchar *location;
|
||||
@ -369,7 +358,7 @@ printer_status_cb (GtkPrintBackend *backend,
|
||||
str = g_strdup_printf ("<b>%s</b>\n%s",
|
||||
gtk_printer_get_name (printer),
|
||||
location);
|
||||
gtk_list_store_set (priv->printer_list, iter,
|
||||
gtk_list_store_set (dialog->printer_list, iter,
|
||||
PRINTER_LIST_COL_NAME, str,
|
||||
-1);
|
||||
g_free (str);
|
||||
@ -414,13 +403,12 @@ printer_list_initialize (GtkPageSetupUnixDialog *dialog,
|
||||
static void
|
||||
load_print_backends (GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GList *node;
|
||||
|
||||
if (g_module_supported ())
|
||||
priv->print_backends = gtk_print_backend_load_modules ();
|
||||
dialog->print_backends = gtk_print_backend_load_modules ();
|
||||
|
||||
for (node = priv->print_backends; node != NULL; node = node->next)
|
||||
for (node = dialog->print_backends; node != NULL; node = node->next)
|
||||
printer_list_initialize (dialog, GTK_PRINT_BACKEND (node->data));
|
||||
}
|
||||
|
||||
@ -438,16 +426,15 @@ paper_size_row_is_separator (GtkTreeModel *model,
|
||||
static GtkPageSetup *
|
||||
get_current_page_setup (GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkPageSetup *current_page_setup;
|
||||
GtkComboBox *combo_box;
|
||||
GtkTreeIter iter;
|
||||
|
||||
current_page_setup = NULL;
|
||||
|
||||
combo_box = GTK_COMBO_BOX (priv->paper_size_combo);
|
||||
combo_box = GTK_COMBO_BOX (dialog->paper_size_combo);
|
||||
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->page_setup_list), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (dialog->page_setup_list), &iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, ¤t_page_setup, -1);
|
||||
|
||||
if (current_page_setup)
|
||||
@ -487,18 +474,17 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
|
||||
gboolean size_only,
|
||||
gboolean add_item)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkPageSetup *list_page_setup;
|
||||
|
||||
model = GTK_TREE_MODEL (priv->page_setup_list);
|
||||
model = GTK_TREE_MODEL (dialog->page_setup_list);
|
||||
|
||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||
{
|
||||
do
|
||||
{
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->page_setup_list), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (dialog->page_setup_list), &iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, &list_page_setup, -1);
|
||||
if (list_page_setup == NULL)
|
||||
continue;
|
||||
@ -506,7 +492,7 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
|
||||
if ((size_only && page_setup_is_same_size (page_setup, list_page_setup)) ||
|
||||
(!size_only && page_setup_is_equal (page_setup, list_page_setup)))
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->paper_size_combo),
|
||||
&iter);
|
||||
g_object_unref (list_page_setup);
|
||||
return TRUE;
|
||||
@ -519,15 +505,15 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
|
||||
|
||||
if (add_item)
|
||||
{
|
||||
gtk_list_store_append (priv->page_setup_list, &iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &iter,
|
||||
PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
|
||||
-1);
|
||||
gtk_list_store_append (priv->page_setup_list, &iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
|
||||
-1);
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->paper_size_combo),
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->paper_size_combo),
|
||||
&iter);
|
||||
return TRUE;
|
||||
}
|
||||
@ -538,15 +524,14 @@ set_paper_size (GtkPageSetupUnixDialog *dialog,
|
||||
static void
|
||||
fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeIter iter, paper_iter;
|
||||
GtkTreeModel *model;
|
||||
|
||||
model = GTK_TREE_MODEL (priv->custom_paper_list);
|
||||
model = GTK_TREE_MODEL (dialog->custom_paper_list);
|
||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||
{
|
||||
gtk_list_store_append (priv->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &paper_iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &paper_iter,
|
||||
PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
|
||||
-1);
|
||||
do
|
||||
@ -554,8 +539,8 @@ fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
|
||||
GtkPageSetup *page_setup;
|
||||
gtk_tree_model_get (model, &iter, 0, &page_setup, -1);
|
||||
|
||||
gtk_list_store_append (priv->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &paper_iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &paper_iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
|
||||
-1);
|
||||
|
||||
@ -563,12 +548,12 @@ fill_custom_paper_sizes (GtkPageSetupUnixDialog *dialog)
|
||||
} while (gtk_tree_model_iter_next (model, &iter));
|
||||
}
|
||||
|
||||
gtk_list_store_append (priv->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &paper_iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &paper_iter,
|
||||
PAGE_SETUP_LIST_COL_IS_SEPARATOR, TRUE,
|
||||
-1);
|
||||
gtk_list_store_append (priv->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &paper_iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &paper_iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &paper_iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, NULL,
|
||||
-1);
|
||||
}
|
||||
@ -577,14 +562,13 @@ static void
|
||||
fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
|
||||
GtkPrinter *printer)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GList *list, *l;
|
||||
GtkPageSetup *current_page_setup, *page_setup;
|
||||
GtkPaperSize *paper_size;
|
||||
GtkTreeIter iter;
|
||||
gint i;
|
||||
|
||||
gtk_list_store_clear (priv->page_setup_list);
|
||||
gtk_list_store_clear (dialog->page_setup_list);
|
||||
|
||||
if (printer == NULL)
|
||||
{
|
||||
@ -595,8 +579,8 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
|
||||
gtk_page_setup_set_paper_size_and_default_margins (page_setup, paper_size);
|
||||
gtk_paper_size_free (paper_size);
|
||||
|
||||
gtk_list_store_append (priv->page_setup_list, &iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
|
||||
-1);
|
||||
g_object_unref (page_setup);
|
||||
@ -610,8 +594,8 @@ fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog,
|
||||
for (l = list; l != NULL; l = l->next)
|
||||
{
|
||||
page_setup = l->data;
|
||||
gtk_list_store_append (priv->page_setup_list, &iter);
|
||||
gtk_list_store_set (priv->page_setup_list, &iter,
|
||||
gtk_list_store_append (dialog->page_setup_list, &iter);
|
||||
gtk_list_store_set (dialog->page_setup_list, &iter,
|
||||
PAGE_SETUP_LIST_COL_PAGE_SETUP, page_setup,
|
||||
-1);
|
||||
g_object_unref (page_setup);
|
||||
@ -642,13 +626,11 @@ printer_changed_finished_callback (GtkPrinter *printer,
|
||||
gboolean success,
|
||||
GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
|
||||
g_signal_handler_disconnect (priv->request_details_printer,
|
||||
priv->request_details_tag);
|
||||
g_object_unref (priv->request_details_printer);
|
||||
priv->request_details_tag = 0;
|
||||
priv->request_details_printer = NULL;
|
||||
g_signal_handler_disconnect (dialog->request_details_printer,
|
||||
dialog->request_details_tag);
|
||||
g_object_unref (dialog->request_details_printer);
|
||||
dialog->request_details_tag = 0;
|
||||
dialog->request_details_printer = NULL;
|
||||
|
||||
if (success)
|
||||
fill_paper_sizes_from_printer (dialog, printer);
|
||||
@ -659,22 +641,21 @@ static void
|
||||
printer_changed_callback (GtkComboBox *combo_box,
|
||||
GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkPrinter *printer;
|
||||
GtkTreeIter iter;
|
||||
|
||||
/* If we're waiting for a specific printer but the user changed
|
||||
* to another printer, cancel that wait.
|
||||
*/
|
||||
g_clear_pointer (&priv->waiting_for_printer, g_free);
|
||||
g_clear_pointer (&dialog->waiting_for_printer, g_free);
|
||||
|
||||
if (priv->request_details_tag)
|
||||
if (dialog->request_details_tag)
|
||||
{
|
||||
g_signal_handler_disconnect (priv->request_details_printer,
|
||||
priv->request_details_tag);
|
||||
g_object_unref (priv->request_details_printer);
|
||||
priv->request_details_printer = NULL;
|
||||
priv->request_details_tag = 0;
|
||||
g_signal_handler_disconnect (dialog->request_details_printer,
|
||||
dialog->request_details_tag);
|
||||
g_object_unref (dialog->request_details_printer);
|
||||
dialog->request_details_printer = NULL;
|
||||
dialog->request_details_tag = 0;
|
||||
}
|
||||
|
||||
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
||||
@ -686,8 +667,8 @@ printer_changed_callback (GtkComboBox *combo_box,
|
||||
fill_paper_sizes_from_printer (dialog, printer);
|
||||
else
|
||||
{
|
||||
priv->request_details_printer = g_object_ref (printer);
|
||||
priv->request_details_tag =
|
||||
dialog->request_details_printer = g_object_ref (printer);
|
||||
dialog->request_details_tag =
|
||||
g_signal_connect (printer, "details-acquired",
|
||||
G_CALLBACK (printer_changed_finished_callback), dialog);
|
||||
gtk_printer_request_details (printer);
|
||||
@ -697,14 +678,14 @@ printer_changed_callback (GtkComboBox *combo_box,
|
||||
if (printer)
|
||||
g_object_unref (printer);
|
||||
|
||||
if (priv->print_settings)
|
||||
if (dialog->print_settings)
|
||||
{
|
||||
const char *name = NULL;
|
||||
|
||||
if (printer)
|
||||
name = gtk_printer_get_name (printer);
|
||||
|
||||
gtk_print_settings_set (priv->print_settings,
|
||||
gtk_print_settings_set (dialog->print_settings,
|
||||
"format-for-printer", name);
|
||||
}
|
||||
}
|
||||
@ -753,12 +734,11 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkPageSetupUnixDialog *dialog = GTK_PAGE_SETUP_UNIX_DIALOG (user_data);
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
|
||||
_gtk_print_load_custom_papers (priv->custom_paper_list);
|
||||
_gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||
|
||||
/* Update printer page list */
|
||||
printer_changed_callback (GTK_COMBO_BOX (priv->printer_combo), dialog);
|
||||
printer_changed_callback (GTK_COMBO_BOX (dialog->printer_combo), dialog);
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (custom_paper_dialog));
|
||||
}
|
||||
@ -767,7 +747,6 @@ static void
|
||||
paper_size_changed (GtkComboBox *combo_box,
|
||||
GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeIter iter;
|
||||
GtkPageSetup *page_setup, *last_page_setup;
|
||||
GtkUnit unit;
|
||||
@ -776,7 +755,7 @@ paper_size_changed (GtkComboBox *combo_box,
|
||||
GtkLabel *label;
|
||||
const gchar *unit_str;
|
||||
|
||||
label = GTK_LABEL (priv->paper_size_label);
|
||||
label = GTK_LABEL (dialog->paper_size_label);
|
||||
|
||||
if (gtk_combo_box_get_active_iter (combo_box, &iter))
|
||||
{
|
||||
@ -788,8 +767,8 @@ paper_size_changed (GtkComboBox *combo_box,
|
||||
GtkWidget *custom_paper_dialog;
|
||||
|
||||
/* Change from "manage" menu item to last value */
|
||||
if (priv->last_setup)
|
||||
last_page_setup = g_object_ref (priv->last_setup);
|
||||
if (dialog->last_setup)
|
||||
last_page_setup = g_object_ref (dialog->last_setup);
|
||||
else
|
||||
last_page_setup = gtk_page_setup_new (); /* "good" default */
|
||||
set_paper_size (dialog, last_page_setup, FALSE, TRUE);
|
||||
@ -805,10 +784,10 @@ paper_size_changed (GtkComboBox *combo_box,
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->last_setup)
|
||||
g_object_unref (priv->last_setup);
|
||||
if (dialog->last_setup)
|
||||
g_object_unref (dialog->last_setup);
|
||||
|
||||
priv->last_setup = g_object_ref (page_setup);
|
||||
dialog->last_setup = g_object_ref (page_setup);
|
||||
|
||||
unit = _gtk_print_get_default_user_units ();
|
||||
|
||||
@ -848,7 +827,7 @@ paper_size_changed (GtkComboBox *combo_box,
|
||||
g_free (left);
|
||||
g_free (right);
|
||||
|
||||
gtk_widget_set_tooltip_text (priv->paper_size_label, str);
|
||||
gtk_widget_set_tooltip_text (dialog->paper_size_label, str);
|
||||
g_free (str);
|
||||
|
||||
g_object_unref (page_setup);
|
||||
@ -856,10 +835,10 @@ paper_size_changed (GtkComboBox *combo_box,
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (label, "");
|
||||
gtk_widget_set_tooltip_text (priv->paper_size_label, NULL);
|
||||
if (priv->last_setup)
|
||||
g_object_unref (priv->last_setup);
|
||||
priv->last_setup = NULL;
|
||||
gtk_widget_set_tooltip_text (dialog->paper_size_label, NULL);
|
||||
if (dialog->last_setup)
|
||||
g_object_unref (dialog->last_setup);
|
||||
dialog->last_setup = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -917,13 +896,11 @@ gtk_page_setup_unix_dialog_new (const gchar *title,
|
||||
static GtkPageOrientation
|
||||
get_orientation (GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->portrait_radio)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->portrait_radio)))
|
||||
return GTK_PAGE_ORIENTATION_PORTRAIT;
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->landscape_radio)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->landscape_radio)))
|
||||
return GTK_PAGE_ORIENTATION_LANDSCAPE;
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reverse_landscape_radio)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->reverse_landscape_radio)))
|
||||
return GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE;
|
||||
return GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT;
|
||||
}
|
||||
@ -932,21 +909,19 @@ static void
|
||||
set_orientation (GtkPageSetupUnixDialog *dialog,
|
||||
GtkPageOrientation orientation)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
|
||||
switch (orientation)
|
||||
{
|
||||
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reverse_portrait_radio), TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->reverse_portrait_radio), TRUE);
|
||||
break;
|
||||
case GTK_PAGE_ORIENTATION_PORTRAIT:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->portrait_radio), TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->portrait_radio), TRUE);
|
||||
break;
|
||||
case GTK_PAGE_ORIENTATION_LANDSCAPE:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->landscape_radio), TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->landscape_radio), TRUE);
|
||||
break;
|
||||
case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reverse_landscape_radio), TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->reverse_landscape_radio), TRUE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -996,25 +971,24 @@ static gboolean
|
||||
set_active_printer (GtkPageSetupUnixDialog *dialog,
|
||||
const gchar *printer_name)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkPrinter *printer;
|
||||
|
||||
model = GTK_TREE_MODEL (priv->printer_list);
|
||||
model = GTK_TREE_MODEL (dialog->printer_list);
|
||||
|
||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||
{
|
||||
do
|
||||
{
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->printer_list), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (dialog->printer_list), &iter,
|
||||
PRINTER_LIST_COL_PRINTER, &printer, -1);
|
||||
if (printer == NULL)
|
||||
continue;
|
||||
|
||||
if (strcmp (gtk_printer_get_name (printer), printer_name) == 0)
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->printer_combo),
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (dialog->printer_combo),
|
||||
&iter);
|
||||
g_object_unref (printer);
|
||||
return TRUE;
|
||||
@ -1040,15 +1014,14 @@ void
|
||||
gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
|
||||
GtkPrintSettings *print_settings)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
const gchar *format_for_printer;
|
||||
|
||||
if (priv->print_settings == print_settings) return;
|
||||
if (dialog->print_settings == print_settings) return;
|
||||
|
||||
if (priv->print_settings)
|
||||
g_object_unref (priv->print_settings);
|
||||
if (dialog->print_settings)
|
||||
g_object_unref (dialog->print_settings);
|
||||
|
||||
priv->print_settings = print_settings;
|
||||
dialog->print_settings = print_settings;
|
||||
|
||||
if (print_settings)
|
||||
{
|
||||
@ -1061,7 +1034,7 @@ gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
|
||||
*/
|
||||
if (format_for_printer &&
|
||||
!set_active_printer (dialog, format_for_printer))
|
||||
priv->waiting_for_printer = g_strdup (format_for_printer);
|
||||
dialog->waiting_for_printer = g_strdup (format_for_printer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1076,7 +1049,5 @@ gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
|
||||
GtkPrintSettings *
|
||||
gtk_page_setup_unix_dialog_get_print_settings (GtkPageSetupUnixDialog *dialog)
|
||||
{
|
||||
GtkPageSetupUnixDialogPrivate *priv = gtk_page_setup_unix_dialog_get_instance_private (dialog);
|
||||
|
||||
return priv->print_settings;
|
||||
return dialog->print_settings;
|
||||
}
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "gtkimage.h"
|
||||
#include "gtknotebook.h"
|
||||
#include "gtkscrolledwindow.h"
|
||||
#include "gtkcombobox.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtkradiobutton.h"
|
||||
#include "gtkdrawingarea.h"
|
||||
@ -148,10 +147,6 @@ static void update_collate_icon (GtkToggleButton *toggle_b
|
||||
static void error_dialogs (GtkPrintUnixDialog *print_dialog,
|
||||
gint print_dialog_response_id,
|
||||
gpointer data);
|
||||
static void emit_ok_response (GtkTreeView *tree_view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer *user_data);
|
||||
static gboolean page_range_entry_focus_changed (GtkWidget *entry,
|
||||
GParamSpec *pspec,
|
||||
GtkPrintUnixDialog *dialog);
|
||||
@ -258,7 +253,6 @@ struct _GtkPrintUnixDialog
|
||||
GListStore *page_setup_list;
|
||||
GListStore *custom_paper_list;
|
||||
GListStore *manage_papers_list;
|
||||
GListStore *paper_size_list;
|
||||
|
||||
gboolean support_selection;
|
||||
gboolean has_selection;
|
||||
@ -505,7 +499,6 @@ gtk_print_unix_dialog_class_init (GtkPrintUnixDialogClass *class)
|
||||
/* Callbacks handled in the UI */
|
||||
gtk_widget_class_bind_template_callback (widget_class, redraw_page_layout_preview);
|
||||
gtk_widget_class_bind_template_callback (widget_class, error_dialogs);
|
||||
gtk_widget_class_bind_template_callback (widget_class, emit_ok_response);
|
||||
gtk_widget_class_bind_template_callback (widget_class, page_range_entry_focus_changed);
|
||||
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);
|
||||
@ -959,8 +952,6 @@ gtk_print_unix_dialog_finalize (GObject *object)
|
||||
g_list_free (dialog->print_backends);
|
||||
dialog->print_backends = NULL;
|
||||
|
||||
g_clear_object (&dialog->page_setup_list);
|
||||
|
||||
g_clear_object (&dialog->page_setup_list);
|
||||
g_clear_object (&dialog->custom_paper_list);
|
||||
g_clear_object (&dialog->manage_papers_list);
|
||||
@ -2065,19 +2056,6 @@ update_print_at_entry_sensitivity (GtkWidget *button,
|
||||
gtk_widget_grab_focus (dialog->print_at_entry);
|
||||
}
|
||||
|
||||
static void
|
||||
emit_ok_response (GtkTreeView *tree_view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer *user_data)
|
||||
{
|
||||
GtkPrintUnixDialog *print_dialog;
|
||||
|
||||
print_dialog = (GtkPrintUnixDialog *) user_data;
|
||||
|
||||
gtk_dialog_response (GTK_DIALOG (print_dialog), GTK_RESPONSE_OK);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_range_separator (gchar c)
|
||||
{
|
||||
@ -2933,9 +2911,7 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
|
||||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (user_data);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (user_data);
|
||||
|
||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||
|
||||
@ -2945,21 +2921,20 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog,
|
||||
|
||||
if (dialog->page_setup_set)
|
||||
{
|
||||
model = GTK_TREE_MODEL (dialog->custom_paper_list);
|
||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||
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++)
|
||||
{
|
||||
do
|
||||
{
|
||||
GtkPageSetup *page_setup;
|
||||
gtk_tree_model_get (model, &iter, 0, &page_setup, -1);
|
||||
GtkPageSetup *page_setup = g_list_model_get_item (model, i);
|
||||
|
||||
if (page_setup &&
|
||||
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);
|
||||
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);
|
||||
|
||||
g_clear_object (&page_setup);
|
||||
} while (gtk_tree_model_iter_next (model, &iter));
|
||||
g_clear_object (&page_setup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,6 @@
|
||||
#include "gtktexthistoryprivate.h"
|
||||
#include "gtktextutil.h"
|
||||
#include "gtktooltip.h"
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtktreeview.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkwindow.h"
|
||||
|
Loading…
Reference in New Issue
Block a user