pango_descr*unset_fields breaks GtkCellRenderer



In pango/fonts.c: 398  

void
pango_font_description_unset_fields (PangoFontDescription *desc,
				     PangoFontMask         to_unset)
{
  g_return_if_fail (desc != NULL);

  /* We reset cleared mask values back to defaults, to avoid
   * having to check the mask for getters.
   */



This code breaks GtkCellRenderer set_style/set_weight and similar....
and makes those propertys unusable....

for example:

  g_object(cell, "style", PANGO_STYLE_ITALIC);
  fileview->column_filename = gtk_tree_view_column_new_with_attributes
("Filename", cell, "foreground", 1, "style_set", 2, "text" , 4, NULL);
  
now if style_set is set to FALSE it will reset style = PANGO_STYLE_NORMAL
and next time when you set it to TRUE it's still default.

One solution is to fix above code in pango:

1. Just unset the fontmask in *_unset_fields() and leave the fields asis 
2.  add pango_font_description_set_fields ()
3. check mask in getters and return default (*_NORMAL) if mask is not
set...
 
Here is a patch fixing the problem ok to submit?

Index: pango/pango/fonts.c
===================================================================
RCS file: /cvs/gnome/pango/pango/fonts.c,v
retrieving revision 1.33
diff -r1.33 fonts.c
171c171
<   return desc->family_name;
---
>   return (desc->mask | PANGO_FONT_MASK_FAMILY) ? desc->family_name :
NULL;
215c215
<   return desc->style;
---
>   return  (desc->mask | PANGO_FONT_MASK_STYLE) ? desc->style :
PANGO_STYLE_NORMAL;
253c253
<   return desc->variant;
---
>   return (desc->mask | PANGO_FONT_MASK_VARIANT) ? desc->variant :
PANGO_VARIANT_NORMAL;
293c293
<   return desc->weight;
---
>   return (desc->mask | PANGO_FONT_MASK_WEIGHT) ? desc->weight :
PANGO_WEIGHT_NORMAL;
331c331
<   return desc->stretch;
---
>   return (desc->mask | PANGO_FONT_MASK_STRETCH) ? desc->stretch :
PANGO_STRETCH_NORMAL;
370c370
<   return desc->size;
---
>   return (desc->mask | PANGO_FONT_MASK_SIZE) ? desc->size : 0;
403,418d402
<   /* We reset cleared mask values back to defaults, to avoid
<    * having to check the mask for getters.
<    */
<   if (to_unset & PANGO_FONT_MASK_FAMILY)
<     pango_font_description_set_family (desc, NULL);
<   if (to_unset & PANGO_FONT_MASK_STYLE)
<     desc->style = PANGO_STYLE_NORMAL;
<   if (to_unset & PANGO_FONT_MASK_VARIANT)
<     desc->variant = PANGO_VARIANT_NORMAL;
<   if (to_unset & PANGO_FONT_MASK_WEIGHT)
<     desc->weight = PANGO_WEIGHT_NORMAL;
<   if (to_unset & PANGO_FONT_MASK_STRETCH)
<     desc->stretch = PANGO_STRETCH_NORMAL;
<   if (to_unset & PANGO_FONT_MASK_SIZE)
<     desc->size = 0;
<     
419a404,419
> }
> 
> /**
>  * pango_font_description_set_fields:
>  * @desc: a #PangoFontDescription
>  * @to_set: bitmask of fields in the @desc to set.
>  * 
>  * Sets some of the fields in a #PangoFontDescription.
>  **/
> void
> pango_font_description_set_fields (PangoFontDescription *desc,
> 				     PangoFontMask         to_set)
> {
>   g_return_if_fail (desc != NULL);
> 
>   desc->mask |= to_set;
Index: pango/pango/pango-font.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-font.h,v
retrieving revision 1.24
diff -r1.24 pango-font.h
133a134,135
> void          pango_font_description_set_fields   (PangoFontDescription  
    *desc,
> 						     PangoFontMask           
   to_set);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]