示例#1
0
文件: gtkcssmatcher.c 项目: GNOME/gtk
static gboolean
gtk_css_matcher_widget_path_has_name (const GtkCssMatcher     *matcher,
                                      /*interned*/ const char *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))
    {
      const char *path_name = gtk_widget_path_iter_get_object_name (siblings, matcher->path.sibling_index);

      if (path_name == NULL)
        path_name = g_type_name (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index));

      return path_name == name;
    }
  else
    {
      const char *path_name = gtk_widget_path_iter_get_object_name (matcher->path.path, matcher->path.index);

      if (path_name == NULL)
        path_name = g_type_name (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index));

      return path_name == name;
    }
}
示例#2
0
static gboolean
gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher)
{
  const GtkWidgetPath *siblings;
  GSList *regions;
  gboolean result;

  if (matcher->path.decl)
    {
      GList *list = gtk_css_node_declaration_list_regions (matcher->path.decl);
      if (list)
        {
          g_list_free (list);
          return TRUE;
        }
    }

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  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))
    regions = gtk_widget_path_iter_list_regions (siblings, matcher->path.sibling_index);
  else
    regions = gtk_widget_path_iter_list_regions (matcher->path.path, matcher->path.index);
  result = regions != NULL;
  g_slist_free (regions);

  return result;
G_GNUC_END_IGNORE_DEPRECATIONS
}
示例#3
0
static gboolean
gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher,
                                        const char          *region,
                                        GtkRegionFlags       flags)
{
  const GtkWidgetPath *siblings;
  GtkRegionFlags region_flags;
  
  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))
    {
      if (!gtk_widget_path_iter_has_region (siblings, matcher->path.sibling_index, region, &region_flags))
        return FALSE;
    }
  else
    {
      if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, &region_flags))
        return FALSE;
    }

  if ((flags & region_flags) != flags)
    return FALSE;

  return TRUE;
}
示例#4
0
static gboolean
gtk_css_matcher_widget_path_has_type (const GtkCssMatcher *matcher,
                                      GType                type)
{
  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 g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index), type);
  else
    return g_type_is_a (gtk_widget_path_iter_get_object_type (matcher->path.path, matcher->path.index), type);
}
示例#5
0
static gboolean
gtk_css_matcher_widget_path_has_id (const GtkCssMatcher *matcher,
                                    const char          *id)
{
  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_name (siblings, matcher->path.sibling_index, id);
  else
    return gtk_widget_path_iter_has_name (matcher->path.path, matcher->path.index, id);
}
示例#6
0
static gboolean
gtk_css_matcher_widget_path_has_class (const GtkCssMatcher *matcher,
                                       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_qclass (siblings, matcher->path.sibling_index, class_name);
  else
    return gtk_widget_path_iter_has_qclass (matcher->path.path, matcher->path.index, class_name);
}
示例#7
0
static GtkStateFlags
gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
{
  const GtkWidgetPath *siblings;
  
  if (matcher->path.decl)
    return gtk_css_node_declaration_get_state (matcher->path.decl);

  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_get_state (siblings, matcher->path.sibling_index);
  else
    return gtk_widget_path_iter_get_state (matcher->path.path, matcher->path.index);
}
示例#8
0
static gboolean
gtk_css_matcher_widget_path_get_parent (GtkCssMatcher       *matcher,
                                        const GtkCssMatcher *child)
{
  if (child->path.index == 0)
    return FALSE;

  matcher->path.klass = child->path.klass;
  matcher->path.decl = NULL;
  matcher->path.path = child->path.path;
  matcher->path.index = child->path.index - 1;
  matcher->path.sibling_index = gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index);

  return TRUE;
}
示例#9
0
gboolean
_gtk_css_matcher_init (GtkCssMatcher               *matcher,
                       const GtkWidgetPath         *path,
                       const GtkCssNodeDeclaration *decl)
{
  if (gtk_widget_path_length (path) == 0)
    return FALSE;

  matcher->path.klass = &GTK_CSS_MATCHER_WIDGET_PATH;
  matcher->path.decl = decl;
  matcher->path.path = path;
  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;
}
示例#10
0
gboolean
_gtk_css_matcher_init (GtkCssMatcher       *matcher,
                       const GtkWidgetPath *path,
                       GtkStateFlags        state)
{
  if (gtk_widget_path_length (path) == 0)
    return FALSE;

  matcher->path.klass = &GTK_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;
}
示例#11
0
static gboolean
gtk_css_matcher_widget_path_has_regions (const GtkCssMatcher *matcher)
{
  const GtkWidgetPath *siblings;
  GSList *regions;
  gboolean result;
  
  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))
    regions = gtk_widget_path_iter_list_regions (siblings, matcher->path.sibling_index);
  else
    regions = gtk_widget_path_iter_list_regions (matcher->path.path, matcher->path.index);
  result = regions != NULL;
  g_slist_free (regions);

  return result;
}
示例#12
0
static gboolean
gtk_css_matcher_widget_path_has_region (const GtkCssMatcher *matcher,
                                        const char          *region,
                                        GtkRegionFlags       flags)
{
  const GtkWidgetPath *siblings;
  GtkRegionFlags region_flags;
  
  if (matcher->path.decl)
    {
      GQuark q = g_quark_try_string (region);

      if (q && gtk_css_node_declaration_has_region (matcher->path.decl, q, &region_flags))
        goto found;
    }

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  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))
    {
      if (!gtk_widget_path_iter_has_region (siblings, matcher->path.sibling_index, region, &region_flags))
        return FALSE;
    }
  else
    {
      if (!gtk_widget_path_iter_has_region (matcher->path.path, matcher->path.index, region, &region_flags))
        return FALSE;
    }
G_GNUC_END_IGNORE_DEPRECATIONS

found:
  if ((flags & region_flags) != flags)
    return FALSE;

  return TRUE;
}