[gtk+] GtkStyleProvider: Pass a GParamSpec in get_style_property().



commit c9dc09e980d26844d72bf740ddffc1a5530f2627
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Nov 17 02:42:27 2010 +0100

    GtkStyleProvider: Pass a GParamSpec in get_style_property().
    
    This is so we can know the owner type of the property, and matching
    with the stored strings in GtkCssProvider is direct.

 gtk/gtkcssprovider.c   |    9 +++------
 gtk/gtkstylecontext.c  |    5 +++--
 gtk/gtkstyleprovider.c |   11 ++++++-----
 gtk/gtkstyleprovider.h |    4 ++--
 4 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 8f703f4..73ad759 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1031,20 +1031,17 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
 static gboolean
 gtk_css_provider_get_style_property (GtkStyleProvider *provider,
                                      GtkWidgetPath    *path,
-                                     const gchar      *property_name,
+                                     GParamSpec       *pspec,
                                      GValue           *value)
 {
   GArray *priority_info;
   gboolean found = FALSE;
   gchar *prop_name;
-  GType path_type;
   gint i;
 
-  path_type = gtk_widget_path_get_widget_type (path);
-
   prop_name = g_strdup_printf ("-%s-%s",
-                               g_type_name (path_type),
-                               property_name);
+                               g_type_name (pspec->owner_type),
+                               pspec->name);
 
   priority_info = css_provider_get_selectors (GTK_CSS_PROVIDER (provider), path);
 
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 58faf5d..09970bb 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2040,8 +2040,9 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
           else
             global = global->prev;
 
-          if (gtk_style_provider_get_style_property (provider_data->provider, priv->widget_path,
-                                                     pspec->name, &pcache->value))
+          if (gtk_style_provider_get_style_property (provider_data->provider,
+                                                     priv->widget_path, pspec,
+                                                     &pcache->value))
             {
               /* Resolve symbolic colors to GdkColor/GdkRGBA */
               if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR)
diff --git a/gtk/gtkstyleprovider.c b/gtk/gtkstyleprovider.c
index 0f1312f..5033410 100644
--- a/gtk/gtkstyleprovider.c
+++ b/gtk/gtkstyleprovider.c
@@ -86,25 +86,26 @@ gtk_style_provider_get_style (GtkStyleProvider *provider,
  * gtk_style_provider_get_style_property:
  * @provider: a #GtkStyleProvider
  * @path: #GtkWidgetPath to query
- * @property_name: the property name
+ * @pspec: The #GParamSpec to query
  * @value: (out): return location for the property value
  *
  * Looks up a widget style property as defined by @provider for
- * the widget represented by @widget_path.
+ * the widget represented by @path.
  *
  * Returns: %TRUE if the property was found and has a value, %FALSE otherwise
  **/
 gboolean
 gtk_style_provider_get_style_property (GtkStyleProvider *provider,
                                        GtkWidgetPath    *path,
-                                       const gchar      *property_name,
+                                       GParamSpec       *pspec,
                                        GValue           *value)
 {
   GtkStyleProviderIface *iface;
 
   g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), FALSE);
+  g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
   g_return_val_if_fail (path != NULL, FALSE);
-  g_return_val_if_fail (property_name != NULL, FALSE);
+  g_return_val_if_fail (g_type_is_a (gtk_widget_path_get_widget_type (path), pspec->owner_type), FALSE);
   g_return_val_if_fail (value != NULL, FALSE);
 
   iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
@@ -112,7 +113,7 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider,
   if (!iface->get_style_property)
     return FALSE;
 
-  return iface->get_style_property (provider, path, property_name, value);
+  return iface->get_style_property (provider, path, pspec, value);
 }
 
 /**
diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h
index 9e67a32..e901a20 100644
--- a/gtk/gtkstyleprovider.h
+++ b/gtk/gtkstyleprovider.h
@@ -57,7 +57,7 @@ struct _GtkStyleProviderIface
 
   gboolean (* get_style_property) (GtkStyleProvider *provider,
                                    GtkWidgetPath    *path,
-                                   const gchar      *property_name,
+                                   GParamSpec       *pspec,
                                    GValue           *value);
 
   GtkIconFactory * (* get_icon_factory) (GtkStyleProvider *provider,
@@ -71,7 +71,7 @@ GtkStyleProperties *gtk_style_provider_get_style (GtkStyleProvider *provider,
 
 gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider,
                                                 GtkWidgetPath    *path,
-                                                const gchar      *property_name,
+                                                GParamSpec       *pspec,
                                                 GValue           *value);
 
 GtkIconFactory * gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,



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