From 7f6f61c9ff37178209b4c9a433b2421fc0180305 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 24 May 2006 16:15:15 +0000 Subject: [PATCH] Custom tab label --- ChangeLog | 10 ++++++ ChangeLog.pre-2-10 | 10 ++++++ docs/reference/gtk/gtk-sections.txt | 1 + gtk/gtk.symbols | 1 + gtk/gtkprintoperation-private.h | 1 + gtk/gtkprintoperation-unix.c | 30 +++++++++------- gtk/gtkprintoperation.c | 54 ++++++++++++++++++++++++++++- gtk/gtkprintoperation.h | 2 ++ tests/print-editor.c | 1 + 9 files changed, 97 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37b29f6cb8..21ecee29f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-05-24 Matthias Clasen + + * gtk/gtkprintoperation.h: + * gtk/gtkprintoperation-private.h: + * gtk/gtk.symbols: + * gtk/gtkprintoperation.c: Add a custom-tab-label property. + + * gtk/gtkprintoperation-unix.c (get_print_dialog): Use it + here. (#342752, Yevgen Muntyan) + 2006-05-24 Alexander Larsson * gtk/gtk.symbols: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 37b29f6cb8..21ecee29f3 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +2006-05-24 Matthias Clasen + + * gtk/gtkprintoperation.h: + * gtk/gtkprintoperation-private.h: + * gtk/gtk.symbols: + * gtk/gtkprintoperation.c: Add a custom-tab-label property. + + * gtk/gtkprintoperation-unix.c (get_print_dialog): Use it + here. (#342752, Yevgen Muntyan) + 2006-05-24 Alexander Larsson * gtk/gtk.symbols: diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 4c39c82118..fc1a843a10 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -6086,6 +6086,7 @@ gtk_print_operation_set_show_dialog gtk_print_operation_set_pdf_target gtk_print_operation_set_show_progress gtk_print_operation_set_track_print_status +gtk_print_operation_set_custom_tab_label gtk_print_operation_run_async gtk_print_operation_cancel gtk_print_operation_get_status diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index d68fe751cb..088069a8bf 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -2697,6 +2697,7 @@ gtk_print_operation_set_show_dialog gtk_print_operation_set_pdf_target gtk_print_operation_set_track_print_status gtk_print_operation_set_show_progress +gtk_print_operation_set_custom_tab_label gtk_print_operation_run gtk_print_operation_run_async gtk_print_operation_get_status diff --git a/gtk/gtkprintoperation-private.h b/gtk/gtkprintoperation-private.h index 99237d5806..55c7a93d0d 100644 --- a/gtk/gtkprintoperation-private.h +++ b/gtk/gtkprintoperation-private.h @@ -60,6 +60,7 @@ struct _GtkPrintOperationPrivate double manual_scale; GtkPageSet manual_page_set; GtkWidget *custom_widget; + gchar *custom_tab_label; gpointer platform_data; GDestroyNotify free_platform_data; diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c index 77e98c4118..33354df60d 100644 --- a/gtk/gtkprintoperation-unix.c +++ b/gtk/gtkprintoperation-unix.c @@ -179,7 +179,7 @@ get_print_dialog (GtkPrintOperation *op, GtkPrintOperationPrivate *priv = op->priv; GtkWidget *pd, *label; GtkPageSetup *page_setup; - const char *app_name; + const gchar *custom_tab_label; pd = gtk_print_unix_dialog_new (NULL, parent); @@ -203,18 +203,24 @@ get_print_dialog (GtkPrintOperation *op, g_object_unref (page_setup); g_signal_emit_by_name (op, "create-custom-widget", - &op->priv->custom_widget); + &priv->custom_widget); - if (op->priv->custom_widget) { - app_name = g_get_application_name (); - if (app_name == NULL) - app_name = _("Application"); - - label = gtk_label_new (app_name); - - gtk_print_unix_dialog_add_custom_tab (GTK_PRINT_UNIX_DIALOG (pd), - op->priv->custom_widget, label); - } + if (priv->custom_widget) + { + custom_tab_label = priv->custom_tab_label; + + if (custom_tab_label == NULL) + { + custom_tab_label = g_get_application_name (); + if (custom_tab_label == NULL) + custom_tab_label = _("Application"); + } + + label = gtk_label_new (custom_tab_label); + + gtk_print_unix_dialog_add_custom_tab (GTK_PRINT_UNIX_DIALOG (pd), + op->priv->custom_widget, label); + } return pd; } diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 20c8962045..e90b81ae09 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -58,7 +58,8 @@ enum { PROP_SHOW_PROGRESS, PROP_PDF_TARGET, PROP_STATUS, - PROP_STATUS_STRING + PROP_STATUS_STRING, + PROP_CUSTOM_TAB_LABEL }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -105,6 +106,7 @@ gtk_print_operation_finalize (GObject *object) g_free (priv->pdf_target); g_free (priv->job_name); + g_free (priv->custom_tab_label); if (priv->print_pages_idle_id > 0) g_source_remove (priv->print_pages_idle_id); @@ -184,6 +186,9 @@ gtk_print_operation_set_property (GObject *object, case PROP_PDF_TARGET: gtk_print_operation_set_pdf_target (op, g_value_get_string (value)); break; + case PROP_CUSTOM_TAB_LABEL: + gtk_print_operation_set_custom_tab_label (op, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -240,6 +245,9 @@ gtk_print_operation_get_property (GObject *object, case PROP_STATUS_STRING: g_value_set_string (value, priv->status_string); break; + case PROP_CUSTOM_TAB_LABEL: + g_value_set_string (value, priv->custom_tab_label); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -743,6 +751,24 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class) GTK_PARAM_READABLE)); + /** + * GtkPrintOperation:custom-tab-label: + * + * Used as the label of the tab containing custom widgets. + * Note that this property may be ignored on some platforms. + * + * If this is %NULL, GTK+ uses a default label. + * + * Since: 2.10 + */ + g_object_class_install_property (gobject_class, + PROP_CUSTOM_TAB_LABEL, + g_param_spec_string ("custom-tab-label", + P_("Custom tab label"), + P_("Label for the tab containing custom widgets."), + NULL, + GTK_PARAM_READWRITE)); + } /** @@ -1262,6 +1288,32 @@ gtk_print_operation_set_show_progress (GtkPrintOperation *op, } } +/** + * gtk_print_operation_set_custom_tag_label: + * @op: a #GtkPrintOperation + * @label: the label to use, or %NULL to use the default label + * + * Sets the label for the tab holding custom widgets. + * + * Since: 2.10 + */ +void +gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op, + const gchar *label) +{ + GtkPrintOperationPrivate *priv; + + g_return_if_fail (GTK_IS_PRINT_OPERATION (op)); + + priv = op->priv; + + g_free (priv->custom_tab_label); + priv->custom_tab_label = g_strdup (label); + + g_object_notify (G_OBJECT (op), "custom-tab-label"); +} + + /** * gtk_print_operation_set_pdf_target: * @op: a #GtkPrintOperation diff --git a/gtk/gtkprintoperation.h b/gtk/gtkprintoperation.h index f3003e4dc2..8f430850fa 100644 --- a/gtk/gtkprintoperation.h +++ b/gtk/gtkprintoperation.h @@ -138,6 +138,8 @@ void gtk_print_operation_set_track_print_status (GtkPrintOper gboolean track_status); void gtk_print_operation_set_show_progress (GtkPrintOperation *op, gboolean show_progress); +void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op, + const gchar *label); GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op, GtkWindow *parent, GError **error); diff --git a/tests/print-editor.c b/tests/print-editor.c index 8775b1079b..eff83c583b 100644 --- a/tests/print-editor.c +++ b/tests/print-editor.c @@ -399,6 +399,7 @@ create_custom_widget (GtkPrintOperation *operation, { GtkWidget *vbox, *hbox, *font, *label; + gtk_print_operation_set_custom_tab_label (operation, "Other"); vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);