Custom tab label

This commit is contained in:
Matthias Clasen 2006-05-24 16:15:15 +00:00
parent 70376f280a
commit 7f6f61c9ff
9 changed files with 97 additions and 13 deletions

View File

@ -1,3 +1,13 @@
2006-05-24 Matthias Clasen <mclasen@redhat.com>
* 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 <alexl@redhat.com> 2006-05-24 Alexander Larsson <alexl@redhat.com>
* gtk/gtk.symbols: * gtk/gtk.symbols:

View File

@ -1,3 +1,13 @@
2006-05-24 Matthias Clasen <mclasen@redhat.com>
* 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 <alexl@redhat.com> 2006-05-24 Alexander Larsson <alexl@redhat.com>
* gtk/gtk.symbols: * gtk/gtk.symbols:

View File

@ -6086,6 +6086,7 @@ gtk_print_operation_set_show_dialog
gtk_print_operation_set_pdf_target gtk_print_operation_set_pdf_target
gtk_print_operation_set_show_progress gtk_print_operation_set_show_progress
gtk_print_operation_set_track_print_status gtk_print_operation_set_track_print_status
gtk_print_operation_set_custom_tab_label
gtk_print_operation_run_async gtk_print_operation_run_async
gtk_print_operation_cancel gtk_print_operation_cancel
gtk_print_operation_get_status gtk_print_operation_get_status

View File

@ -2697,6 +2697,7 @@ gtk_print_operation_set_show_dialog
gtk_print_operation_set_pdf_target gtk_print_operation_set_pdf_target
gtk_print_operation_set_track_print_status gtk_print_operation_set_track_print_status
gtk_print_operation_set_show_progress gtk_print_operation_set_show_progress
gtk_print_operation_set_custom_tab_label
gtk_print_operation_run gtk_print_operation_run
gtk_print_operation_run_async gtk_print_operation_run_async
gtk_print_operation_get_status gtk_print_operation_get_status

View File

@ -60,6 +60,7 @@ struct _GtkPrintOperationPrivate
double manual_scale; double manual_scale;
GtkPageSet manual_page_set; GtkPageSet manual_page_set;
GtkWidget *custom_widget; GtkWidget *custom_widget;
gchar *custom_tab_label;
gpointer platform_data; gpointer platform_data;
GDestroyNotify free_platform_data; GDestroyNotify free_platform_data;

View File

@ -179,7 +179,7 @@ get_print_dialog (GtkPrintOperation *op,
GtkPrintOperationPrivate *priv = op->priv; GtkPrintOperationPrivate *priv = op->priv;
GtkWidget *pd, *label; GtkWidget *pd, *label;
GtkPageSetup *page_setup; GtkPageSetup *page_setup;
const char *app_name; const gchar *custom_tab_label;
pd = gtk_print_unix_dialog_new (NULL, parent); pd = gtk_print_unix_dialog_new (NULL, parent);
@ -203,18 +203,24 @@ get_print_dialog (GtkPrintOperation *op,
g_object_unref (page_setup); g_object_unref (page_setup);
g_signal_emit_by_name (op, "create-custom-widget", g_signal_emit_by_name (op, "create-custom-widget",
&op->priv->custom_widget); &priv->custom_widget);
if (op->priv->custom_widget) { if (priv->custom_widget)
app_name = g_get_application_name (); {
if (app_name == NULL) custom_tab_label = priv->custom_tab_label;
app_name = _("Application");
if (custom_tab_label == NULL)
label = gtk_label_new (app_name); {
custom_tab_label = g_get_application_name ();
gtk_print_unix_dialog_add_custom_tab (GTK_PRINT_UNIX_DIALOG (pd), if (custom_tab_label == NULL)
op->priv->custom_widget, label); 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; return pd;
} }

View File

@ -58,7 +58,8 @@ enum {
PROP_SHOW_PROGRESS, PROP_SHOW_PROGRESS,
PROP_PDF_TARGET, PROP_PDF_TARGET,
PROP_STATUS, PROP_STATUS,
PROP_STATUS_STRING PROP_STATUS_STRING,
PROP_CUSTOM_TAB_LABEL
}; };
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
@ -105,6 +106,7 @@ gtk_print_operation_finalize (GObject *object)
g_free (priv->pdf_target); g_free (priv->pdf_target);
g_free (priv->job_name); g_free (priv->job_name);
g_free (priv->custom_tab_label);
if (priv->print_pages_idle_id > 0) if (priv->print_pages_idle_id > 0)
g_source_remove (priv->print_pages_idle_id); g_source_remove (priv->print_pages_idle_id);
@ -184,6 +186,9 @@ gtk_print_operation_set_property (GObject *object,
case PROP_PDF_TARGET: case PROP_PDF_TARGET:
gtk_print_operation_set_pdf_target (op, g_value_get_string (value)); gtk_print_operation_set_pdf_target (op, g_value_get_string (value));
break; break;
case PROP_CUSTOM_TAB_LABEL:
gtk_print_operation_set_custom_tab_label (op, g_value_get_string (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -240,6 +245,9 @@ gtk_print_operation_get_property (GObject *object,
case PROP_STATUS_STRING: case PROP_STATUS_STRING:
g_value_set_string (value, priv->status_string); g_value_set_string (value, priv->status_string);
break; break;
case PROP_CUSTOM_TAB_LABEL:
g_value_set_string (value, priv->custom_tab_label);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -743,6 +751,24 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
GTK_PARAM_READABLE)); 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: * gtk_print_operation_set_pdf_target:
* @op: a #GtkPrintOperation * @op: a #GtkPrintOperation

View File

@ -138,6 +138,8 @@ void gtk_print_operation_set_track_print_status (GtkPrintOper
gboolean track_status); gboolean track_status);
void gtk_print_operation_set_show_progress (GtkPrintOperation *op, void gtk_print_operation_set_show_progress (GtkPrintOperation *op,
gboolean show_progress); gboolean show_progress);
void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op,
const gchar *label);
GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op, GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
GtkWindow *parent, GtkWindow *parent,
GError **error); GError **error);

View File

@ -399,6 +399,7 @@ create_custom_widget (GtkPrintOperation *operation,
{ {
GtkWidget *vbox, *hbox, *font, *label; GtkWidget *vbox, *hbox, *font, *label;
gtk_print_operation_set_custom_tab_label (operation, "Other");
vbox = gtk_vbox_new (FALSE, 0); vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);