diff options
author | tinloaf <tinloaf@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-04-04 18:40:53 +0000 |
---|---|---|
committer | tinloaf <tinloaf@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-04-04 18:40:53 +0000 |
commit | 54cdc84bf6bcd9e1c24c9d29c95f4a1792c8c1dd (patch) | |
tree | cd59457eaf5581695949ebb3f8158a6456c1dbbb /navit/osd.c | |
parent | 028c8ac1f00240e2ee080936ab881454ed75c92c (diff) | |
download | navit-54cdc84bf6bcd9e1c24c9d29c95f4a1792c8c1dd.tar.gz |
Add:Core:Adding support for "saved" commands
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2184 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/osd.c')
-rw-r--r-- | navit/osd.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/navit/osd.c b/navit/osd.c index 4df2126df..5e87fbb54 100644 --- a/navit/osd.c +++ b/navit/osd.c @@ -116,6 +116,16 @@ osd_std_calculate_sizes(struct osd_item *item, struct osd_priv *priv, int w, int } } +static void +osd_std_reconfigure(struct osd_item *item, struct command_saved *cs) +{ + if (!command_saved_error(cs)) { + graphics_overlay_disable(item->gr, !command_saved_get_int(cs)); + } else { + dbg(0, "Error in saved command: %i\n", command_saved_error(cs)); + } +} + void osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags) { @@ -148,8 +158,9 @@ osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags) item->osd_configuration = attr->u.num; attr=attr_search(attrs, NULL, attr_enable_expression); - if (attr) - item->enable_expression = g_strdup(attr->u.str); + if (attr) { + item->enable_cs = command_saved_new(attr->u.str, item->navit, NULL); + } attr = attr_search(attrs, NULL, attr_w); if (attr) { @@ -214,16 +225,15 @@ osd_std_config(struct osd_item *item, struct navit *navit) { struct attr attr; dbg(1,"enter\n"); - if (item->enable_expression) { - int error,configured; - attr.type=attr_navit; - attr.u.navit=navit; - configured=command_evaluate_to_int(&navit, item->enable_expression, &error); - if (error) { - dbg(0,"evaluating %s resulted in error %d\n", item->enable_expression, error); - configured=0; + if (item->enable_cs) { + item->reconfig_cb = callback_new_1(callback_cast(osd_std_reconfigure), item); + command_saved_set_cb(item->enable_cs, item->reconfig_cb); + + if (!command_saved_error(item->enable_cs)) { + item->configured = !! command_saved_get_int(item->enable_cs); + } else { + dbg(0, "Error in saved command: %i.\n", command_saved_error(item->enable_cs)); } - item->configured = !!configured; } else { if (!navit_get_attr(navit, attr_osd_configuration, &attr, NULL)) attr.u.num=-1; |