]> Pileus Git - ~andy/gtk/commitdiff
Add convenience function for the font description.
authorPaolo Borelli <pborelli@gnome.org>
Sun, 5 Dec 2010 18:40:13 +0000 (19:40 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 13 Dec 2010 21:31:27 +0000 (22:31 +0100)
docs/reference/gtk/gtk3-sections.txt
gtk/gtkstylecontext.c
gtk/gtkstylecontext.h

index 261cf311965d85c98bd772aea3ae944bb2ffad9f..35fbd5e5f42b5a115845160392245850bf12d70c 100644 (file)
@@ -5415,6 +5415,7 @@ gtk_style_context_get_border_color
 gtk_style_context_get_border
 gtk_style_context_get_padding
 gtk_style_context_get_margin
+gtk_style_context_get_font
 gtk_style_context_invalidate
 gtk_style_context_state_is_running
 gtk_style_context_lookup_color
index 2aee8b29925058dab9061b63ed92017d296377ac..be7f78279feb72a82476581a6a327ae200c95143 100644 (file)
@@ -3346,6 +3346,38 @@ gtk_style_context_get_margin (GtkStyleContext *context,
   *margin = *b;
 }
 
+/**
+ * gtk_style_context_get_font:
+ * @context: a #GtkStyleContext
+ * @state: state to retrieve the font for
+ *
+ * Returns the font description for a given state. The returned
+ * object is const and will remain valid until the
+ * #GtkStyleContext::changed signal happens.
+ *
+ * Returns: the #PangoFontDescription for the given state. This
+ *          object is owned by GTK+ and should not be freed.
+ *
+ * Since: 3.0
+ **/
+const PangoFontDescription *
+gtk_style_context_get_font (GtkStyleContext *context,
+                            GtkStateFlags    state)
+{
+  GtkStyleContextPrivate *priv;
+  StyleData *data;
+  const GValue *value;
+
+  g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+
+  priv = context->priv;
+  g_return_val_if_fail (priv->widget_path != NULL, NULL);
+
+  data = style_data_lookup (context);
+  value = _gtk_style_properties_peek_property (data->store, "font", state);
+  return g_value_get_boxed (value);
+}
+
 /* Paint methods */
 
 /**
index a67e523a83010399d3ee309a0d777e16adb6178b..f7d658a5a6948097291de91b4c716b3b5a0d0305 100644 (file)
@@ -439,6 +439,9 @@ void gtk_style_context_get_border_color     (GtkStyleContext *context,
                                              GtkStateFlags    state,
                                              GdkRGBA         *color);
 
+const PangoFontDescription * gtk_style_context_get_font (GtkStyleContext *context,
+                                                    GtkStateFlags    state);
+
 void gtk_style_context_get_border           (GtkStyleContext *context,
                                              GtkStateFlags    state,
                                              GtkBorder       *border);