forked from AuroraMiddleware/gtk
label: refactor code
Split out function for setting attributes. This will be needed in future patches.
This commit is contained in:
parent
a0bfbc8ae1
commit
219357d69c
@ -3285,47 +3285,17 @@ gtk_label_update_layout_width (GtkLabel *label)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_ensure_layout (GtkLabel *label)
|
||||
gtk_label_update_layout_attributes (GtkLabel *label)
|
||||
{
|
||||
GtkLabelPrivate *priv = label->priv;
|
||||
GtkWidget *widget;
|
||||
gboolean rtl;
|
||||
GtkWidget *widget = GTK_WIDGET (label);
|
||||
GtkStyleContext *context;
|
||||
|
||||
widget = GTK_WIDGET (label);
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
|
||||
rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
||||
|
||||
if (!priv->layout)
|
||||
{
|
||||
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
|
||||
PangoAttrList *attrs;
|
||||
gdouble angle = gtk_label_get_angle (label);
|
||||
|
||||
if (angle != 0.0 && !priv->select_info)
|
||||
{
|
||||
PangoMatrix matrix = PANGO_MATRIX_INIT;
|
||||
if (priv->layout == NULL)
|
||||
return;
|
||||
|
||||
/* We rotate the standard singleton PangoContext for the widget,
|
||||
* depending on the fact that it's meant pretty much exclusively
|
||||
* for our use.
|
||||
*/
|
||||
pango_matrix_rotate (&matrix, angle);
|
||||
|
||||
pango_context_set_matrix (gtk_widget_get_pango_context (widget), &matrix);
|
||||
|
||||
priv->have_transform = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (priv->have_transform)
|
||||
pango_context_set_matrix (gtk_widget_get_pango_context (widget), NULL);
|
||||
|
||||
priv->have_transform = FALSE;
|
||||
}
|
||||
|
||||
priv->layout = gtk_widget_create_pango_layout (widget, priv->text);
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
|
||||
if (priv->select_info && priv->select_info->links)
|
||||
{
|
||||
@ -3382,11 +3352,53 @@ gtk_label_ensure_layout (GtkLabel *label)
|
||||
attrs = pango_attr_list_ref (priv->attrs);
|
||||
}
|
||||
|
||||
if (attrs)
|
||||
{
|
||||
pango_layout_set_attributes (priv->layout, attrs);
|
||||
|
||||
if (attrs)
|
||||
pango_attr_list_unref (attrs);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_ensure_layout (GtkLabel *label)
|
||||
{
|
||||
GtkLabelPrivate *priv = label->priv;
|
||||
GtkWidget *widget;
|
||||
gboolean rtl;
|
||||
|
||||
widget = GTK_WIDGET (label);
|
||||
|
||||
rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
||||
|
||||
if (!priv->layout)
|
||||
{
|
||||
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
|
||||
gdouble angle = gtk_label_get_angle (label);
|
||||
|
||||
if (angle != 0.0 && !priv->select_info)
|
||||
{
|
||||
PangoMatrix matrix = PANGO_MATRIX_INIT;
|
||||
|
||||
/* We rotate the standard singleton PangoContext for the widget,
|
||||
* depending on the fact that it's meant pretty much exclusively
|
||||
* for our use.
|
||||
*/
|
||||
pango_matrix_rotate (&matrix, angle);
|
||||
|
||||
pango_context_set_matrix (gtk_widget_get_pango_context (widget), &matrix);
|
||||
|
||||
priv->have_transform = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (priv->have_transform)
|
||||
pango_context_set_matrix (gtk_widget_get_pango_context (widget), NULL);
|
||||
|
||||
priv->have_transform = FALSE;
|
||||
}
|
||||
|
||||
priv->layout = gtk_widget_create_pango_layout (widget, priv->text);
|
||||
|
||||
gtk_label_update_layout_attributes (label);
|
||||
|
||||
switch (priv->jtype)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user