gtkcssmatcherprivate.h 6.05 KB
Newer Older
Benjamin Otte's avatar
Benjamin Otte committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* GTK - The GIMP Toolkit
 * Copyright (C) 2012 Benjamin Otte <otte@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __GTK_CSS_MATCHER_PRIVATE_H__
#define __GTK_CSS_MATCHER_PRIVATE_H__

#include <gtk/gtkenums.h>
#include <gtk/gtktypes.h>
23
#include "gtk/gtkcsstypesprivate.h"
Benjamin Otte's avatar
Benjamin Otte committed
24 25 26

G_BEGIN_DECLS

27
typedef struct _GtkCssMatcherNode GtkCssMatcherNode;
28
typedef struct _GtkCssMatcherSuperset GtkCssMatcherSuperset;
29
typedef struct _GtkCssMatcherWidgetPath GtkCssMatcherWidgetPath;
Benjamin Otte's avatar
Benjamin Otte committed
30
typedef struct _GtkCssMatcherClass GtkCssMatcherClass;
Benjamin Otte's avatar
Benjamin Otte committed
31

Benjamin Otte's avatar
Benjamin Otte committed
32 33
struct _GtkCssMatcherClass {
  gboolean        (* get_parent)                  (GtkCssMatcher          *matcher,
Benjamin Otte's avatar
Benjamin Otte committed
34
                                                   const GtkCssMatcher    *child);
Benjamin Otte's avatar
Benjamin Otte committed
35
  gboolean        (* get_previous)                (GtkCssMatcher          *matcher,
Benjamin Otte's avatar
Benjamin Otte committed
36 37
                                                   const GtkCssMatcher    *next);

Benjamin Otte's avatar
Benjamin Otte committed
38
  GtkStateFlags   (* get_state)                   (const GtkCssMatcher   *matcher);
39 40
  gboolean        (* has_type)                    (const GtkCssMatcher   *matcher,
                                                   GType                  type);
Benjamin Otte's avatar
Benjamin Otte committed
41
  gboolean        (* has_class)                   (const GtkCssMatcher   *matcher,
42
                                                   GQuark                 class_name);
Benjamin Otte's avatar
Benjamin Otte committed
43
  gboolean        (* has_id)                      (const GtkCssMatcher   *matcher,
Benjamin Otte's avatar
Benjamin Otte committed
44
                                                   const char            *id);
Benjamin Otte's avatar
Benjamin Otte committed
45 46
  gboolean        (* has_regions)                 (const GtkCssMatcher   *matcher);
  gboolean        (* has_region)                  (const GtkCssMatcher   *matcher,
Benjamin Otte's avatar
Benjamin Otte committed
47 48
                                                   const char            *region,
                                                   GtkRegionFlags         flags);
49 50 51 52
  gboolean        (* has_position)                (const GtkCssMatcher   *matcher,
                                                   gboolean               forward,
                                                   int                    a,
                                                   int                    b);
53
  gboolean is_any;
Benjamin Otte's avatar
Benjamin Otte committed
54 55
};

56
struct _GtkCssMatcherWidgetPath {
Benjamin Otte's avatar
Benjamin Otte committed
57
  const GtkCssMatcherClass *klass;
58
  const GtkCssNodeDeclaration *decl;
Benjamin Otte's avatar
Benjamin Otte committed
59 60 61 62 63
  const GtkWidgetPath      *path;
  guint                     index;
  guint                     sibling_index;
};

64 65 66 67 68
struct _GtkCssMatcherNode {
  const GtkCssMatcherClass *klass;
  GtkCssNode               *node;
};

69 70 71 72 73 74
struct _GtkCssMatcherSuperset {
  const GtkCssMatcherClass *klass;
  const GtkCssMatcher      *subset;
  GtkCssChange              relevant;
};

75 76 77
union _GtkCssMatcher {
  const GtkCssMatcherClass *klass;
  GtkCssMatcherWidgetPath   path;
78
  GtkCssMatcherNode         node;
79
  GtkCssMatcherSuperset     superset;
80 81
};

82
gboolean          _gtk_css_matcher_init           (GtkCssMatcher          *matcher,
83 84
                                                   const GtkWidgetPath    *path,
                                                   const GtkCssNodeDeclaration *decl) G_GNUC_WARN_UNUSED_RESULT;
85 86
void              _gtk_css_matcher_node_init      (GtkCssMatcher          *matcher,
                                                   GtkCssNode             *node);
87
void              _gtk_css_matcher_any_init       (GtkCssMatcher          *matcher);
88 89 90 91
void              _gtk_css_matcher_superset_init  (GtkCssMatcher          *matcher,
                                                   const GtkCssMatcher    *subset,
                                                   GtkCssChange            relevant);

Benjamin Otte's avatar
Benjamin Otte committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

static inline gboolean
_gtk_css_matcher_get_parent (GtkCssMatcher       *matcher,
                             const GtkCssMatcher *child)
{
  return child->klass->get_parent (matcher, child);
}

static inline gboolean
_gtk_css_matcher_get_previous (GtkCssMatcher       *matcher,
                               const GtkCssMatcher *next)
{
  return next->klass->get_previous (matcher, next);
}

static inline GtkStateFlags
_gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
{
  return matcher->klass->get_state (matcher);
}

static inline gboolean
114 115
_gtk_css_matcher_has_type (const GtkCssMatcher *matcher,
                           GType type)
Benjamin Otte's avatar
Benjamin Otte committed
116
{
117
  return matcher->klass->has_type (matcher, type);
Benjamin Otte's avatar
Benjamin Otte committed
118 119 120 121
}

static inline gboolean
_gtk_css_matcher_has_class (const GtkCssMatcher *matcher,
122
                            GQuark               class_name)
Benjamin Otte's avatar
Benjamin Otte committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
{
  return matcher->klass->has_class (matcher, class_name);
}

static inline gboolean
_gtk_css_matcher_has_id (const GtkCssMatcher *matcher,
                         const char          *id)
{
  return matcher->klass->has_id (matcher, id);
}


static inline gboolean
_gtk_css_matcher_has_regions (const GtkCssMatcher *matcher)
{
  return matcher->klass->has_regions (matcher);
}

static inline gboolean
_gtk_css_matcher_has_region (const GtkCssMatcher *matcher,
                             const char          *region,
                             GtkRegionFlags       flags)
{
  return matcher->klass->has_region (matcher, region, flags);
}

static inline guint
150 151 152 153
_gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
                               gboolean             forward,
                               int                  a,
                               int                  b)
Benjamin Otte's avatar
Benjamin Otte committed
154
{
155
  return matcher->klass->has_position (matcher, forward, a, b);
Benjamin Otte's avatar
Benjamin Otte committed
156 157
}

158 159 160 161 162 163
static inline gboolean
_gtk_css_matcher_matches_any (const GtkCssMatcher *matcher)
{
  return matcher->klass->is_any;
}

Benjamin Otte's avatar
Benjamin Otte committed
164 165 166 167

G_END_DECLS

#endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */