summaryrefslogtreecommitdiff
path: root/navit/navit.c
diff options
context:
space:
mode:
authorWildemann Stefan <stefan.wildemann@corpuls.com>2019-07-24 10:52:44 +0200
committerWildemann Stefan <stefan.wildemann@corpuls.com>2019-07-24 10:56:26 +0200
commit9d230bcc1a259f5d3f8ad099200209c5ce67c503 (patch)
tree91a51633e16fea3b51f262f955f16e652ea55cd6 /navit/navit.c
parent0f08c04dd9816533ffbaa2b684b8b0d57f0da9a5 (diff)
downloadnavit-fix_default_layout_handling.tar.gz
fix:core: Correct default layout handling.fix_default_layout_handling
This commit corrects the default layout handling broken when splitting the layouts to own files. It restores the layout saving of the internal gui. So now it starts again with the last selected layout.
Diffstat (limited to 'navit/navit.c')
-rw-r--r--navit/navit.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/navit/navit.c b/navit/navit.c
index 1d1b8e664..ae39aca59 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -2551,6 +2551,7 @@ static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) {
case attr_layout:
if(!attr->u.layout)
return 0;
+ dbg(lvl_debug,"setting attr_layout to %s", attr->u.layout->name);
if(this_->layout_current!=attr->u.layout) {
navit_update_current_layout(this_, attr->u.layout);
graphics_font_destroy_all(this_->gra);
@@ -2563,6 +2564,7 @@ static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) {
case attr_layout_name:
if(!attr->u.str)
return 0;
+ dbg(lvl_debug,"setting attr_layout_name to %s", attr->u.str);
l=this_->layouts;
while (l) {
lay=l->data;
@@ -3000,9 +3002,27 @@ static int navit_add_log(struct navit *this_, struct log *log) {
static int navit_add_layout(struct navit *this_, struct layout *layout) {
struct attr active;
+ int is_default=0;
+ int is_active=0;
this_->layouts = g_list_append(this_->layouts, layout);
+ /** check if we want to immediately activate this layout.
+ * Unfortunately we have concurring conditions about when to activate
+ * a layout:
+ * - A layout could bear the "active" property
+ * - A layout's name could match this_->default_layout_name
+ * This cannot be fully resolved, as we cannot predict the future, so
+ * lets set the last parsed layout active, which either matches default_layout_name or
+ * bears the "active" tag, or is the first layout ever parsed.
+ */
+ if((layout->name != NULL) && (this_->default_layout_name != NULL)) {
+ if (strcmp(layout->name, this_->default_layout_name) == 0)
+ is_default = 1;
+ }
layout_get_attr(layout, attr_active, &active, NULL);
- if(active.u.num || !this_->layout_current) {
+ if(active.u.num)
+ is_active = 1;
+ dbg(lvl_debug, "add layout '%s' is_default %d, is_active %d", layout->name, is_default, is_active);
+ if(is_default || is_active || !this_->layout_current) {
this_->layout_current=layout;
return 1;
}