diff options
author | Marek Kasik <mkasik@redhat.com> | 2009-04-21 13:06:49 +0200 |
---|---|---|
committer | Marek Kasik <mkasik@redhat.com> | 2009-04-21 13:06:49 +0200 |
commit | 6e121ee85e7c796b33d2f6635744ab3f0d0f65e2 (patch) | |
tree | 465e3d7a9e02f5350131294bf6162c0f9008cb68 /gtk | |
parent | 405955749103dcfdf582b6ae4f053c66837a6281 (diff) | |
download | gtk+-6e121ee85e7c796b33d2f6635744ab3f0d0f65e2.tar.gz |
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).
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkmarshalers.list | 1 | ||||
-rw-r--r-- | gtk/gtkprintoperation-unix.c | 22 | ||||
-rw-r--r-- | gtk/gtkprintoperation.c | 25 | ||||
-rw-r--r-- | gtk/gtkprintoperation.h | 8 | ||||
-rw-r--r-- | gtk/gtkprintunixdialog.c | 2 |
5 files changed, 55 insertions, 3 deletions
diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list index c932f1d555..3e19a21551 100644 --- a/gtk/gtkmarshalers.list +++ b/gtk/gtkmarshalers.list @@ -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 diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c index 6ec4ebdd8c..bec565c01f 100644 --- a/gtk/gtkprintoperation-unix.c +++ b/gtk/gtkprintoperation-unix.c @@ -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; diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 05b8b9e4a7..424054601f 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -48,6 +48,7 @@ enum CREATE_CUSTOM_WIDGET, CUSTOM_WIDGET_APPLY, PREVIEW, + UPDATE_CUSTOM_WIDGET, LAST_SIGNAL }; @@ -820,12 +821,34 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class) 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. diff --git a/gtk/gtkprintoperation.h b/gtk/gtkprintoperation.h index a3f0410943..af46332fcf 100644 --- a/gtk/gtkprintoperation.h +++ b/gtk/gtkprintoperation.h @@ -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 () diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index 72520f82a7..9f4cd6123a 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -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 |