forked from AuroraMiddleware/gtk
Allow the custom widget to actualize on a printer change
Passes print settings and page setup to the custom widget through a new "update-custom-widget" signal (#564854).
This commit is contained in:
parent
4059557491
commit
6e121ee85e
@ -88,6 +88,7 @@ VOID:OBJECT,STRING,STRING
|
||||
VOID:OBJECT,UINT
|
||||
VOID:OBJECT,UINT,FLAGS
|
||||
VOID:OBJECT,STRING
|
||||
VOID:OBJECT,OBJECT,OBJECT
|
||||
VOID:POINTER
|
||||
VOID:POINTER,INT
|
||||
VOID:POINTER,BOOLEAN
|
||||
|
@ -363,6 +363,26 @@ job_status_changed_cb (GtkPrintJob *job,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
printer_changed_cb (GtkPrintUnixDialog *print_dialog,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkPageSetup *page_setup;
|
||||
GtkPrintSettings *print_settings;
|
||||
GtkPrintOperation *op = user_data;
|
||||
GtkPrintOperationPrivate *priv = op->priv;
|
||||
|
||||
page_setup = gtk_print_unix_dialog_get_page_setup (print_dialog);
|
||||
print_settings = gtk_print_unix_dialog_get_settings (print_dialog);
|
||||
|
||||
g_signal_emit_by_name (op,
|
||||
"update-custom-widget",
|
||||
priv->custom_widget,
|
||||
page_setup,
|
||||
print_settings);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_print_dialog (GtkPrintOperation *op,
|
||||
GtkWindow *parent)
|
||||
@ -409,6 +429,8 @@ get_print_dialog (GtkPrintOperation *op,
|
||||
|
||||
gtk_print_unix_dialog_add_custom_tab (GTK_PRINT_UNIX_DIALOG (pd),
|
||||
priv->custom_widget, label);
|
||||
|
||||
g_signal_connect (pd, "notify::selected-printer", (GCallback) printer_changed_cb, op);
|
||||
}
|
||||
|
||||
return pd;
|
||||
|
@ -48,6 +48,7 @@ enum
|
||||
CREATE_CUSTOM_WIDGET,
|
||||
CUSTOM_WIDGET_APPLY,
|
||||
PREVIEW,
|
||||
UPDATE_CUSTOM_WIDGET,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@ -819,13 +820,35 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
|
||||
_gtk_marshal_OBJECT__VOID,
|
||||
G_TYPE_OBJECT, 0);
|
||||
|
||||
/**
|
||||
* GtkPrintOperation::update-custom-widget:
|
||||
* @operation: the #GtkPrintOperation on which the signal was emitted
|
||||
* @widget: the custom widget added in create-custom-widget
|
||||
* @setup: actual page setup
|
||||
* @settings: actual print settings
|
||||
*
|
||||
* Emmited after change of selected printer. The actual page setup and
|
||||
* print settings are passed to the custom widget, which can actualize
|
||||
* itself according to this change.
|
||||
*
|
||||
* Since: 2.18
|
||||
*/
|
||||
signals[UPDATE_CUSTOM_WIDGET] =
|
||||
g_signal_new (I_("update-custom-widget"),
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrintOperationClass, update_custom_widget),
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__OBJECT_OBJECT_OBJECT,
|
||||
G_TYPE_NONE, 3, GTK_TYPE_WIDGET, GTK_TYPE_PAGE_SETUP, GTK_TYPE_PRINT_SETTINGS);
|
||||
|
||||
/**
|
||||
* GtkPrintOperation::custom-widget-apply:
|
||||
* @operation: the #GtkPrintOperation on which the signal was emitted
|
||||
* @widget: the custom widget added in create-custom-widget
|
||||
*
|
||||
* Emitted right before #GtkPrintOperation::begin-print if you added
|
||||
* a custom widget in the #GtkPrintOperation:;create-custom-widget handler.
|
||||
* a custom widget in the #GtkPrintOperation::create-custom-widget handler.
|
||||
* When you get this signal you should read the information from the
|
||||
* custom widgets, as the widgets are not guaraneed to be around at a
|
||||
* later time.
|
||||
|
@ -105,13 +105,18 @@ struct _GtkPrintOperationClass
|
||||
|
||||
GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
|
||||
void (*custom_widget_apply) (GtkPrintOperation *operation,
|
||||
GtkWidget *widget);
|
||||
GtkWidget *widget);
|
||||
|
||||
gboolean (*preview) (GtkPrintOperation *operation,
|
||||
GtkPrintOperationPreview *preview,
|
||||
GtkPrintContext *context,
|
||||
GtkWindow *parent);
|
||||
|
||||
void (*update_custom_widget) (GtkPrintOperation *operation,
|
||||
GtkWidget *widget,
|
||||
GtkPageSetup *setup,
|
||||
GtkPrintSettings *settings);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
@ -119,7 +124,6 @@ struct _GtkPrintOperationClass
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
#define GTK_PRINT_ERROR gtk_print_error_quark ()
|
||||
|
@ -1552,6 +1552,8 @@ selected_printer_changed (GtkTreeSelection *selection,
|
||||
|
||||
update_dialog_from_settings (dialog);
|
||||
update_dialog_from_capabilities (dialog);
|
||||
|
||||
g_object_notify ( G_OBJECT(dialog), "selected-printer");
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user