diff --git a/particles/list.c b/particles/list.c index 0f14297..e92a9b6 100644 --- a/particles/list.c +++ b/particles/list.c @@ -5,13 +5,13 @@ #define LOG_ENABLE_DBG 1 #include "../log.h" -struct particle_private { +struct private { struct particle **particles; size_t count; int left_spacing, right_spacing; }; -struct exposable_private { +struct eprivate { struct exposable **exposables; int *widths; size_t count; @@ -22,7 +22,7 @@ struct exposable_private { static void exposable_destroy(struct exposable *exposable) { - struct exposable_private *e = exposable->private; + struct eprivate *e = exposable->private; for (size_t i = 0; i < e->count; i++) e->exposables[i]->destroy(e->exposables[i]); @@ -35,7 +35,7 @@ exposable_destroy(struct exposable *exposable) static int begin_expose(struct exposable *exposable, cairo_t *cr) { - const struct exposable_private *e = exposable->private; + const struct eprivate *e = exposable->private; exposable->width = exposable->particle->left_margin; @@ -54,7 +54,7 @@ begin_expose(struct exposable *exposable, cairo_t *cr) static void expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height) { - const struct exposable_private *e = exposable->private; + const struct eprivate *e = exposable->private; const struct deco *deco = exposable->particle->deco; if (deco != NULL) @@ -77,7 +77,7 @@ on_mouse(struct exposable *exposable, struct bar *bar, enum mouse_event event, int x, int y) { const struct particle *p = exposable->particle; - const struct exposable_private *e = exposable->private; + const struct eprivate *e = exposable->private; if (exposable->on_click != NULL) { /* We have our own handler */ @@ -105,9 +105,9 @@ on_mouse(struct exposable *exposable, struct bar *bar, static struct exposable * instantiate(const struct particle *particle, const struct tag_set *tags) { - const struct particle_private *p = particle->private; + const struct private *p = particle->private; - struct exposable_private *e = malloc(sizeof(*e)); + struct eprivate *e = malloc(sizeof(*e)); e->exposables = malloc(p->count * sizeof(*e->exposables)); e->widths = malloc(p->count * sizeof(*e->widths)); e->count = p->count; @@ -135,7 +135,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags) static void particle_destroy(struct particle *particle) { - struct particle_private *p = particle->private; + struct private *p = particle->private; for (size_t i = 0; i < p->count; i++) p->particles[i]->destroy(p->particles[i]); free(p->particles); @@ -149,7 +149,7 @@ particle_list_new( int left_spacing, int right_spacing, int left_margin, int right_margin, const char *on_click_template) { - struct particle_private *p = malloc(sizeof(*p)); + struct private *p = malloc(sizeof(*p)); p->particles = malloc(count * sizeof(p->particles[0])); p->count = count; p->left_spacing = left_spacing; diff --git a/particles/map.c b/particles/map.c index 2000c72..5735e9f 100644 --- a/particles/map.c +++ b/particles/map.c @@ -4,7 +4,7 @@ #include #include -struct map { +struct private { char *tag; struct particle *default_particle; struct particle_map *map; @@ -14,17 +14,17 @@ struct map { static struct exposable * instantiate(const struct particle *particle, const struct tag_set *tags) { - const struct map *map = particle->private; - const struct tag *tag = tag_for_name(tags, map->tag); - assert(tag != NULL || map->default_particle != NULL); + const struct private *p = particle->private; + const struct tag *tag = tag_for_name(tags, p->tag); + assert(tag != NULL || p->default_particle != NULL); if (tag == NULL) - return map->default_particle->instantiate(map->default_particle, tags); + return p->default_particle->instantiate(p->default_particle, tags); const char *tag_value = tag->as_string(tag); - for (size_t i = 0; i < map->count; i++) { - const struct particle_map *e = &map->map[i]; + for (size_t i = 0; i < p->count; i++) { + const struct particle_map *e = &p->map[i]; if (strcmp(e->tag_value, tag_value) != 0) continue; @@ -32,27 +32,27 @@ instantiate(const struct particle *particle, const struct tag_set *tags) return e->particle->instantiate(e->particle, tags); } - assert(map->default_particle != NULL); - return map->default_particle->instantiate(map->default_particle, tags); + assert(p->default_particle != NULL); + return p->default_particle->instantiate(p->default_particle, tags); } static void particle_destroy(struct particle *particle) { - struct map *map = particle->private; + struct private *p = particle->private; - if (map->default_particle != NULL) - map->default_particle->destroy(map->default_particle); + if (p->default_particle != NULL) + p->default_particle->destroy(p->default_particle); - for (size_t i = 0; i < map->count; i++) { - struct particle *p = map->map[i].particle; - p->destroy(p); - free((char *)map->map[i].tag_value); + for (size_t i = 0; i < p->count; i++) { + struct particle *pp = p->map[i].particle; + pp->destroy(pp); + free((char *)p->map[i].tag_value); } - free(map->map); - free(map->tag); - free(map); + free(p->map); + free(p->tag); + free(p); particle_default_destroy(particle); } @@ -69,17 +69,17 @@ particle_map_new(const char *tag, const struct particle_map *particle_map, particle->destroy = &particle_destroy; particle->instantiate = &instantiate; - struct map *map = malloc(sizeof(*map)); - map->tag = strdup(tag); - map->default_particle = default_particle; - map->count = count; - map->map = malloc(count * sizeof(map->map[0])); + struct private *priv = malloc(sizeof(*priv)); + priv->tag = strdup(tag); + priv->default_particle = default_particle; + priv->count = count; + priv->map = malloc(count * sizeof(priv->map[0])); for (size_t i = 0; i < count; i++) { - map->map[i].tag_value = strdup(particle_map[i].tag_value); - map->map[i].particle = particle_map[i].particle; + priv->map[i].tag_value = strdup(particle_map[i].tag_value); + priv->map[i].particle = particle_map[i].particle; } - particle->private = map; + particle->private = priv; return particle; } diff --git a/particles/progress_bar.c b/particles/progress_bar.c index 717b21e..21b4a8a 100644 --- a/particles/progress_bar.c +++ b/particles/progress_bar.c @@ -19,7 +19,7 @@ struct private { struct particle *indicator; }; -struct exposable_private { +struct eprivate { size_t count; struct exposable **exposables; }; @@ -43,7 +43,7 @@ particle_destroy(struct particle *particle) static void exposable_destroy(struct exposable *exposable) { - struct exposable_private *e = exposable->private; + struct eprivate *e = exposable->private; for (size_t i = 0; i < e->count; i++) e->exposables[i]->destroy(e->exposables[i]); free(e->exposables); @@ -54,7 +54,7 @@ exposable_destroy(struct exposable *exposable) static int begin_expose(struct exposable *exposable, cairo_t *cr) { - struct exposable_private *e = exposable->private; + struct eprivate *e = exposable->private; /* Margins */ exposable->width = exposable->particle->left_margin + @@ -70,7 +70,7 @@ begin_expose(struct exposable *exposable, cairo_t *cr) static void expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height) { - const struct exposable_private *e = exposable->private; + const struct eprivate *e = exposable->private; const struct deco *deco = exposable->particle->deco; if (deco != NULL) @@ -144,7 +144,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags) long fill_count = max == min ? 0 : p->width * value / (max - min); long empty_count = p->width - fill_count; - struct exposable_private *epriv = malloc(sizeof(*epriv)); + struct eprivate *epriv = malloc(sizeof(*epriv)); epriv->count = ( 1 + /* Start marker */ fill_count + /* Before current position */ diff --git a/particles/ramp.c b/particles/ramp.c index 3c57695..bb1ef51 100644 --- a/particles/ramp.c +++ b/particles/ramp.c @@ -6,7 +6,7 @@ #include -struct ramp { +struct private { char *tag; struct particle **particles; size_t count; @@ -15,25 +15,25 @@ struct ramp { static void particle_destroy(struct particle *particle) { - struct ramp *ramp = particle->private; + struct private *p = particle->private; - for (size_t i = 0; i < ramp->count; i++) - ramp->particles[i]->destroy(ramp->particles[i]); + for (size_t i = 0; i < p->count; i++) + p->particles[i]->destroy(p->particles[i]); - free(ramp->tag); - free(ramp->particles); - free(ramp); + free(p->tag); + free(p->particles); + free(p); particle_default_destroy(particle); } static struct exposable * instantiate(const struct particle *particle, const struct tag_set *tags) { - const struct ramp *ramp = particle->private; - const struct tag *tag = tag_for_name(tags, ramp->tag); + const struct private *p = particle->private; + const struct tag *tag = tag_for_name(tags, p->tag); assert(tag != NULL); - assert(ramp->count > 0); + assert(p->count > 0); long value = tag->as_int(tag); long min = tag->min(tag); @@ -44,18 +44,18 @@ instantiate(const struct particle *particle, const struct tag_set *tags) size_t idx = 0; if (max - min > 0) - idx = ramp->count * value / (max - min); + idx = p->count * value / (max - min); - if (idx == ramp->count) + if (idx == p->count) idx--; /* * printf("ramp: value: %lu, min: %lu, max: %lu, progress: %f, idx: %zu\n", * value, min, max, progress, idx); */ - assert(idx >= 0 && idx < ramp->count); + assert(idx >= 0 && idx < p->count); - struct particle *p = ramp->particles[idx]; - return p->instantiate(p, tags); + struct particle *pp = p->particles[idx]; + return pp->instantiate(pp, tags); } struct particle * @@ -70,14 +70,14 @@ particle_ramp_new(const char *tag, struct particle *particles[], size_t count, particle->destroy = &particle_destroy; particle->instantiate = &instantiate; - struct ramp *ramp = malloc(sizeof(*ramp)); - ramp->tag = strdup(tag); - ramp->particles = calloc(count, sizeof(ramp->particles[0])); - ramp->count = count; + struct private *priv = malloc(sizeof(*priv)); + priv->tag = strdup(tag); + priv->particles = calloc(count, sizeof(priv->particles[0])); + priv->count = count; for (size_t i = 0; i < count; i++) - ramp->particles[i] = particles[i]; + priv->particles[i] = particles[i]; - particle->private = ramp; + particle->private = priv; return particle; }