GNOME Bugzilla – Bug 417777
convenience API for creation of PangoAttrList
Last modified: 2018-05-22 12:26:48 UTC
libgimpwidgets includes an API for conveniently applying a PangoAttrList to a GtkLabel and I would like to propose it for inclusion in GTK+. It would make sense though to have most of this code in Pango, so I am filing this bug report asking for an API addition to Pango. The implementation of gimp_label_set_attributes can be reviewed in http://svn.gnome.org/viewcvs/gimp/trunk/libgimpwidgets/gimpwidgets.c?view=markup I propose adding pango_attr_list_new_full(...). Perhaps also add pango_attr_new(type, ...).
Got a patch?
Created attachment 95586 [details] [review] patch to add pango_attr_list_new_full
Ok, almost ready to commit this. There are two problems with it though, none are solvable but still: - PangoColor attr is passed as PangoColor* which is different from r,g,b that is passed to normal constructors. - User-defined attribute types don't work. One way this one can be fixed is to add pango_attr_type_register_full() that takes either a "gpointer data" or a variadic constructor for the attribute type. variadic will be more flexible but more work to implement for user. "gpointer data" version limits user attributes to taking a pointer when parsed by pango_attr_list_new_full() which is not very limiting IMO. YMMV. If we go with the latter, pango_attr_new() can take a pointer instead of being variadic too. Comments?
I don't have very strong opinions on this except that I would really like to see this API being added to Pango so that it can be wrapped into a GtkLabel convenience API in GTK+ so that people finally stop to use PangoMarkup for simple things like bold labels.
Created attachment 105511 [details] [review] patch with improved documentation This updated patch tries to solve the remaining issues by improving the documentation.
Of course for use from GTK+ we would have to add a variant that takes a va_list argument. I can provide a patch that does this if you are otherwise happy with the new API.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/70.