summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-06-10 07:17:05 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-06-10 10:30:35 -0400
commitc0044c98d8374f5078b5b5e07674df01f36c9f69 (patch)
treea5594e688ada4574a804551ca67b3128870abea1
parent0e5f9ff5fede7cb51463d65ac158516da188f9b2 (diff)
downloadpango-c0044c98d8374f5078b5b5e07674df01f36c9f69.tar.gz
Add listmodel properties to PangoFontFamily
Add :item-type and :n-items properties, which make the list model implementation more useful.
-rw-r--r--pango/fonts.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 004089fc..e7bd4780 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -2385,13 +2385,68 @@ pango_font_family_default_list_faces (PangoFontFamily *family,
*n_faces = 0;
}
+enum {
+ PROP_ITEM_TYPE = 1,
+ PROP_N_ITEMS,
+ N_PROPERTIES
+};
+
+static GParamSpec *font_family_properties[N_PROPERTIES] = { NULL };
+
static void
-pango_font_family_class_init (PangoFontFamilyClass *class G_GNUC_UNUSED)
+pango_font_family_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ switch (property_id)
+ {
+ case PROP_ITEM_TYPE:
+ g_value_set_gtype (value, PANGO_TYPE_FONT);
+ break;
+
+ case PROP_N_ITEMS:
+ g_value_set_uint (value, pango_font_family_get_n_items (G_LIST_MODEL (object)));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+pango_font_family_class_init (PangoFontFamilyClass *class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+ gobject_class->get_property = pango_font_family_get_property;
+
class->is_monospace = pango_font_family_default_is_monospace;
class->is_variable = pango_font_family_default_is_variable;
class->get_face = pango_font_family_real_get_face;
class->list_faces = pango_font_family_default_list_faces;
+
+ /**
+ * PangoFontFamily:item-type:
+ *
+ * The type of items contained in this list.
+ */
+ font_family_properties[PROP_ITEM_TYPE] =
+ g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * PangoFontFamily:n-items:
+ *
+ * The number of items contained in this list.
+ */
+ font_family_properties[PROP_N_ITEMS] =
+ g_param_spec_uint ("n-items", "", "", 0, G_MAXUINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (gobject_class,
+ N_PROPERTIES,
+ font_family_properties);
}
static void