Merge pull request #86 from gergelypolonkai/bug-85
Fix up display theme CSS generating code
This commit is contained in:
commit
7b54d53ebf
15
TODO.org
15
TODO.org
@ -130,6 +130,21 @@
|
|||||||
more sense. This, however, is not possible with aspects and
|
more sense. This, however, is not possible with aspects and
|
||||||
antiscion axes. SWE-GLib should provide a solution to this.
|
antiscion axes. SWE-GLib should provide a solution to this.
|
||||||
|
|
||||||
|
Planet visibility checklist:
|
||||||
|
- planets are visible by default
|
||||||
|
- is the planet excluded from the theme? If so, add rule
|
||||||
|
.planet-<planetname> { visibility: hidden; }
|
||||||
|
|
||||||
|
Aspect visibility checklist:
|
||||||
|
- aspects are visible by default
|
||||||
|
- is this type of aspect has to be visible? If no, add rule
|
||||||
|
.aspect-<aspecttype> {visibility: hidden; }
|
||||||
|
- is planet1 visible? If no, .aspect-p-<planet1> {visibility: hidden; }
|
||||||
|
- repeat for planet2
|
||||||
|
|
||||||
|
Antiscion visibility checklist:
|
||||||
|
- same as for aspects
|
||||||
|
|
||||||
** Implement the original Astrognome theme
|
** Implement the original Astrognome theme
|
||||||
|
|
||||||
The software created by Jean-André Santoni has its own list of
|
The software created by Jean-André Santoni has its own list of
|
||||||
|
@ -4,41 +4,11 @@
|
|||||||
#include "astrognome.h"
|
#include "astrognome.h"
|
||||||
#include "ag-display-theme.h"
|
#include "ag-display-theme.h"
|
||||||
|
|
||||||
static gchar *planet_all = ".planet {\n" \
|
static gchar *planet_rule = ".planet-%s { visibility: hidden; }\n";
|
||||||
" visibility: visible;\n" \
|
static gchar *aspect_type_rule = ".aspect-%s { visibility: hidden; }\n";
|
||||||
"}\n";
|
static gchar *aspect_planet_rule = ".aspect-p-%s { visibility: hidden; }\n";
|
||||||
|
static gchar *antiscion_type_rule = ".antiscion-%s { visibility: hidden; }\n";
|
||||||
static gchar *planet_none = ".planet {\n" \
|
static gchar *antiscion_planet_rule = ".antiscion-p-%s { visibility: hidden; }\n";
|
||||||
" visibility: hidden;\n" \
|
|
||||||
" }\n";
|
|
||||||
|
|
||||||
static gchar *planet_tmpl = ".planet-%s {\n" \
|
|
||||||
" visibility: %s !important;\n" \
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static gchar *aspect_all = ".aspect {\n" \
|
|
||||||
" visibility: visible;\n" \
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static gchar *aspect_none = ".aspect {\n" \
|
|
||||||
" visibility: hidden;\n" \
|
|
||||||
" }\n";
|
|
||||||
|
|
||||||
static gchar *aspect_tmpl = ".aspect-%s {\n" \
|
|
||||||
" visibility: %s !important;\n" \
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static gchar *antiscion_all = ".antiscion {\n" \
|
|
||||||
" visibility: visible;\n" \
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static gchar *antiscion_none = ".antiscion {\n" \
|
|
||||||
" visibility: hidden;\n" \
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static gchar *antiscion_tmpl = ".antiscion-%s {\n" \
|
|
||||||
" visibility: %s !important;\n" \
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static AgDisplayTheme **builtin_themes = NULL;
|
static AgDisplayTheme **builtin_themes = NULL;
|
||||||
static gchar *builtin_theme_name[AG_DISPLAY_THEME_COUNT] = {
|
static gchar *builtin_theme_name[AG_DISPLAY_THEME_COUNT] = {
|
||||||
@ -50,7 +20,10 @@ static gchar *builtin_theme_name[AG_DISPLAY_THEME_COUNT] = {
|
|||||||
gchar *
|
gchar *
|
||||||
ag_display_theme_to_css(AgDisplayTheme *theme)
|
ag_display_theme_to_css(AgDisplayTheme *theme)
|
||||||
{
|
{
|
||||||
GList *i;
|
gint i;
|
||||||
|
GList *l,
|
||||||
|
*all_aspects,
|
||||||
|
*all_antiscion_axes;
|
||||||
gchar *ret;
|
gchar *ret;
|
||||||
GString *css = NULL;
|
GString *css = NULL;
|
||||||
|
|
||||||
@ -59,68 +32,72 @@ ag_display_theme_to_css(AgDisplayTheme *theme)
|
|||||||
return g_strdup("");
|
return g_strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme->planets_include) {
|
css = g_string_sized_new(300);
|
||||||
css = g_string_new(planet_none);
|
|
||||||
} else {
|
|
||||||
css = g_string_new(planet_all);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = theme->planets; i; i = g_list_next(i)) {
|
// Go through the used_planets array. If any of them is not listed
|
||||||
|
// by @theme, add a rule to hide it, and the respective aspects
|
||||||
|
// and antiscia
|
||||||
|
for (i = 0; i < used_planets_count; i++) {
|
||||||
|
gboolean in_list;
|
||||||
|
|
||||||
|
in_list = (g_list_find(theme->planets, GINT_TO_POINTER(used_planets[i])) != NULL);
|
||||||
|
|
||||||
|
if (theme->planets_include != in_list) {
|
||||||
const gchar *planet_name;
|
const gchar *planet_name;
|
||||||
|
|
||||||
planet_name = ag_planet_id_to_nick(GPOINTER_TO_INT(i->data));
|
planet_name = ag_planet_id_to_nick(used_planets[i]);
|
||||||
|
|
||||||
g_string_append_printf(
|
g_string_append_printf(css, planet_rule, planet_name);
|
||||||
css,
|
g_string_append_printf(css, aspect_planet_rule, planet_name);
|
||||||
planet_tmpl,
|
g_string_append_printf(css, antiscion_planet_rule, planet_name);
|
||||||
planet_name,
|
}
|
||||||
(theme->planets_include) ? "visible" : "hidden"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme->aspects_include) {
|
// Go through gswe_all_aspects(). If any of them is not listed by
|
||||||
g_string_append(css, aspect_none);
|
// @theme, add a rule to hide it
|
||||||
} else {
|
all_aspects = gswe_all_aspects();
|
||||||
g_string_append(css, aspect_all);
|
|
||||||
|
for (l = all_aspects; l; l = g_list_next(l)) {
|
||||||
|
const gchar *aspect_type;
|
||||||
|
gboolean in_list;
|
||||||
|
GsweAspect aspect;
|
||||||
|
GsweAspectInfo *aspect_info = l->data;
|
||||||
|
|
||||||
|
aspect = gswe_aspect_info_get_aspect(aspect_info);
|
||||||
|
in_list = (g_list_find(theme->aspects, GINT_TO_POINTER(aspect)) != NULL);
|
||||||
|
aspect_type = ag_aspect_id_to_nick(aspect);
|
||||||
|
|
||||||
|
if (theme->aspects_include != in_list) {
|
||||||
|
g_string_append_printf(css, aspect_type_rule, aspect_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = theme->aspects; i; i = g_list_next(i)) {
|
g_list_free(all_aspects);
|
||||||
const gchar *aspect_name;
|
|
||||||
|
|
||||||
aspect_name = ag_aspect_id_to_nick(GPOINTER_TO_INT(i->data));
|
// Go through gswe_all_antiscion_axes(). If any of them is not
|
||||||
|
// listed by @theme, add a rule to hide it
|
||||||
|
all_antiscion_axes = gswe_all_antiscion_axes();
|
||||||
|
|
||||||
g_string_append_printf(
|
for (l = all_antiscion_axes; l; l = g_list_next(l)) {
|
||||||
css,
|
const gchar *antiscion_axis_type;
|
||||||
aspect_tmpl,
|
gboolean in_list;
|
||||||
aspect_name,
|
GsweAntiscionAxis antiscion_axis;
|
||||||
(theme->aspects_include) ? "visible" : "hidden"
|
GsweAntiscionAxisInfo *antiscion_axis_info = l->data;
|
||||||
);
|
|
||||||
|
antiscion_axis = gswe_antiscion_axis_info_get_axis(antiscion_axis_info);
|
||||||
|
in_list = (g_list_find(theme->antiscia, GINT_TO_POINTER(antiscion_axis)) != NULL);
|
||||||
|
antiscion_axis_type = ag_antiscion_axis_id_to_nick(antiscion_axis);
|
||||||
|
|
||||||
|
if (theme->antiscia_include != in_list) {
|
||||||
|
g_string_append_printf(css, antiscion_type_rule, antiscion_axis_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme->antiscia_include) {
|
g_list_free(all_antiscion_axes);
|
||||||
g_string_append(css, antiscion_none);
|
|
||||||
} else {
|
|
||||||
g_string_append(css, antiscion_all);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = theme->antiscia; i; i = g_list_next(i)) {
|
|
||||||
const gchar *antiscion_axis_name;
|
|
||||||
|
|
||||||
antiscion_axis_name = ag_antiscion_axis_id_to_nick(
|
|
||||||
GPOINTER_TO_INT(i->data)
|
|
||||||
);
|
|
||||||
|
|
||||||
g_string_append_printf(
|
|
||||||
css,
|
|
||||||
antiscion_tmpl,
|
|
||||||
antiscion_axis_name,
|
|
||||||
(theme->antiscia_include) ? "visible" : "hidden"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = g_string_free(css, FALSE);
|
ret = g_string_free(css, FALSE);
|
||||||
|
|
||||||
g_debug("%s", ret);
|
g_debug("Generated CSS:\n%s\n", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -733,7 +733,7 @@
|
|||||||
|
|
||||||
<line class="aspect">
|
<line class="aspect">
|
||||||
<xsl:attribute name="id">aspect-<xsl:value-of select="$planet1"/>-<xsl:value-of select="$planet2"/></xsl:attribute>
|
<xsl:attribute name="id">aspect-<xsl:value-of select="$planet1"/>-<xsl:value-of select="$planet2"/></xsl:attribute>
|
||||||
<xsl:attribute name="class">aspect aspect-<xsl:value-of select="@type"/> aspect-<xsl:value-of select="$planet1"/> aspect-<xsl:value-of select="$planet2"/></xsl:attribute>
|
<xsl:attribute name="class">aspect aspect-<xsl:value-of select="@type"/> aspect-p-<xsl:value-of select="$planet1"/> aspect-p-<xsl:value-of select="$planet2"/></xsl:attribute>
|
||||||
<xsl:attribute name="x1"><xsl:value-of select="$x1"/></xsl:attribute>
|
<xsl:attribute name="x1"><xsl:value-of select="$x1"/></xsl:attribute>
|
||||||
<xsl:attribute name="y1"><xsl:value-of select="$y1"/></xsl:attribute>
|
<xsl:attribute name="y1"><xsl:value-of select="$y1"/></xsl:attribute>
|
||||||
<xsl:attribute name="x2"><xsl:value-of select="$x2"/></xsl:attribute>
|
<xsl:attribute name="x2"><xsl:value-of select="$x2"/></xsl:attribute>
|
||||||
@ -788,7 +788,7 @@
|
|||||||
|
|
||||||
<line class="antiscion">
|
<line class="antiscion">
|
||||||
<xsl:attribute name="id">antiscion-<xsl:value-of select="$planet1"/>-<xsl:value-of select="$planet2"/></xsl:attribute>
|
<xsl:attribute name="id">antiscion-<xsl:value-of select="$planet1"/>-<xsl:value-of select="$planet2"/></xsl:attribute>
|
||||||
<xsl:attribute name="class">antiscion antiscion-<xsl:value-of select="@axis"/> antiscion-<xsl:value-of select="$planet1"/> antiscion-<xsl:value-of select="$planet2"/></xsl:attribute>
|
<xsl:attribute name="class">antiscion antiscion-<xsl:value-of select="@axis"/> antiscion-p-<xsl:value-of select="$planet1"/> antiscion-p-<xsl:value-of select="$planet2"/></xsl:attribute>
|
||||||
<xsl:attribute name="x1"><xsl:value-of select="$x1"/></xsl:attribute>
|
<xsl:attribute name="x1"><xsl:value-of select="$x1"/></xsl:attribute>
|
||||||
<xsl:attribute name="y1"><xsl:value-of select="$y1"/></xsl:attribute>
|
<xsl:attribute name="y1"><xsl:value-of select="$y1"/></xsl:attribute>
|
||||||
<xsl:attribute name="x2"><xsl:value-of select="$x2"/></xsl:attribute>
|
<xsl:attribute name="x2"><xsl:value-of select="$x2"/></xsl:attribute>
|
||||||
|
Loading…
Reference in New Issue
Block a user