X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkcssmatcher.c;h=ccdf5479cf853575e5e1fd3615a05c09f9a8b0e9;hb=45ad8a06ad511ad95a74172172b9fe459bc666ad;hp=7c09d0ca51f4fb8cc40559bcab0380b4e90ebd96;hpb=102d10016f5546126f809659bcc006edfb0f706f;p=~andy%2Fgtk diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c index 7c09d0ca5..ccdf5479c 100644 --- a/gtk/gtkcssmatcher.c +++ b/gtk/gtkcssmatcher.c @@ -62,13 +62,11 @@ gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher) } static gboolean -gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher, - const char *name) +gtk_css_matcher_widget_path_has_type (const GtkCssMatcher *matcher, + GType type) { const GtkWidgetPath *siblings; - GType type; - - type = g_type_from_name (name); + siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) return g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index), type); @@ -78,15 +76,15 @@ gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher, static gboolean gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher, - const char *class_name) + GQuark class_name) { const GtkWidgetPath *siblings; siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index); if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index)) - return gtk_widget_path_iter_has_class (siblings, matcher->path.sibling_index, class_name); + return gtk_widget_path_iter_has_qclass (siblings, matcher->path.sibling_index, class_name); else - return gtk_widget_path_iter_has_class (matcher->path.path, matcher->path.index, class_name); + return gtk_widget_path_iter_has_qclass (matcher->path.path, matcher->path.index, class_name); } static gboolean @@ -179,24 +177,30 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = { gtk_css_matcher_widget_path_get_parent, gtk_css_matcher_widget_path_get_previous, gtk_css_matcher_widget_path_get_state, - gtk_css_matcher_widget_path_has_name, + gtk_css_matcher_widget_path_has_type, gtk_css_matcher_widget_path_has_class, gtk_css_matcher_widget_path_has_id, gtk_css_matcher_widget_path_has_regions, gtk_css_matcher_widget_path_has_region, gtk_css_matcher_widget_path_has_position, + FALSE }; -void +gboolean _gtk_css_matcher_init (GtkCssMatcher *matcher, const GtkWidgetPath *path, GtkStateFlags state) { + if (gtk_widget_path_length (path) == 0) + return FALSE; + matcher->path.klass = >K_CSS_MATCHER_WIDGET_PATH; matcher->path.path = path; matcher->path.state_flags = state; matcher->path.index = gtk_widget_path_length (path) - 1; matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (path, matcher->path.index); + + return TRUE; } /* GTK_CSS_MATCHER_WIDGET_ANY */ @@ -230,15 +234,15 @@ gtk_css_matcher_any_get_state (const GtkCssMatcher *matcher) } static gboolean -gtk_css_matcher_any_has_name (const GtkCssMatcher *matcher, - const char *name) +gtk_css_matcher_any_has_type (const GtkCssMatcher *matcher, + GType type) { return TRUE; } static gboolean gtk_css_matcher_any_has_class (const GtkCssMatcher *matcher, - const char *class_name) + GQuark class_name) { return TRUE; } @@ -277,12 +281,13 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = { gtk_css_matcher_any_get_parent, gtk_css_matcher_any_get_previous, gtk_css_matcher_any_get_state, - gtk_css_matcher_any_has_name, + gtk_css_matcher_any_has_type, gtk_css_matcher_any_has_class, gtk_css_matcher_any_has_id, gtk_css_matcher_any_has_regions, gtk_css_matcher_any_has_region, gtk_css_matcher_any_has_position, + TRUE }; void @@ -325,18 +330,18 @@ gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher) } static gboolean -gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher, - const char *name) +gtk_css_matcher_superset_has_type (const GtkCssMatcher *matcher, + GType type) { if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME) - return _gtk_css_matcher_has_name (matcher->superset.subset, name); + return _gtk_css_matcher_has_type (matcher->superset.subset, type); else return TRUE; } static gboolean gtk_css_matcher_superset_has_class (const GtkCssMatcher *matcher, - const char *class_name) + GQuark class_name) { if (matcher->superset.relevant & GTK_CSS_CHANGE_CLASS) return _gtk_css_matcher_has_class (matcher->superset.subset, class_name); @@ -395,12 +400,13 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = { gtk_css_matcher_superset_get_parent, gtk_css_matcher_superset_get_previous, gtk_css_matcher_superset_get_state, - gtk_css_matcher_superset_has_name, + gtk_css_matcher_superset_has_type, gtk_css_matcher_superset_has_class, gtk_css_matcher_superset_has_id, gtk_css_matcher_superset_has_regions, gtk_css_matcher_superset_has_region, gtk_css_matcher_superset_has_position, + FALSE }; void