Esempio n. 1
0
setting_t *
settings_create_multiopt(prop_t *parent, const char *id, prop_t *title)
{
  setting_t *s = setting_create_leaf(parent, title, "multiopt", "options", 0);
  s->s_id = strdup(id);
  return s;
}
Esempio n. 2
0
setting_t *
settings_create_bool(prop_t *parent, const char *id, prop_t *title,
		     int initial, htsmsg_t *store,
		     prop_callback_int_t *cb, void *opaque,
		     int flags, prop_courier_t *pc,
		     settings_saver_t *saver, void *saver_opaque)
{
  setting_t *s = setting_create_leaf(parent, title, "bool", "value", flags);
  prop_sub_t *sub;

  s->s_id = strdup(id);
  s->s_callback = cb;
  s->s_opaque = opaque;

  if(store != NULL)
    initial = htsmsg_get_u32_or_default(store, id, initial);

  prop_set_int(s->s_val, !!initial);

  if(flags & SETTINGS_INITIAL_UPDATE)
    settings_int_callback(s, !!initial);
  
  sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		       PROP_TAG_CALLBACK_INT, settings_int_callback, s,
		       PROP_TAG_ROOT, s->s_val,
		       PROP_TAG_COURIER, pc,
		       NULL);
  s->s_sub = sub;
  s->s_store = store;
  s->s_saver = saver;
  s->s_saver_opaque = saver_opaque;
  return s;
}
Esempio n. 3
0
setting_t *
settings_create_action(prop_t *parent, prop_t *title,
		       prop_callback_t *cb, void *opaque,
		       prop_courier_t *pc)
{
  setting_t *s = setting_create_leaf(parent, title, "action", "action", 0);
  s->s_sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
			    PROP_TAG_CALLBACK, cb, opaque,
			    PROP_TAG_ROOT, s->s_val,
			    PROP_TAG_COURIER, pc,
			    NULL);
  return s;
}
Esempio n. 4
0
setting_t *
settings_create_multiopt(prop_t *parent, const char *id, const char *title,
			 prop_callback_string_t *cb, void *opaque)
{
  setting_t *s = setting_create_leaf(parent, title, "multiopt", "options");

  s->s_id = strdup(id);
  s->s_callback = cb;
  s->s_opaque = opaque;
  
  s->s_sub = prop_subscribe(0,
			    PROP_TAG_CALLBACK, callback_opt, s, 
			    PROP_TAG_ROOT, s->s_val, 
			    NULL);
  return s;
}
Esempio n. 5
0
setting_t *
settings_create_int(prop_t *parent, const char *id, prop_t *title,
		    int initial, htsmsg_t *store,
		    int min, int max, int step,
		    prop_callback_int_t *cb, void *opaque,
		    int flags, const char *unit,
		    prop_courier_t *pc,
		    settings_saver_t *saver, void *saver_opaque)
{
  setting_t *s = setting_create_leaf(parent, title, "integer", "value", flags);
  prop_sub_t *sub;

  s->s_id = strdup(id);
  s->s_callback = cb;
  s->s_opaque = opaque;


  if(store != NULL)
    initial = htsmsg_get_s32_or_default(store, id, initial);

  prop_set_int_clipping_range(s->s_val, min, max);

  prop_set_int(prop_create(s->s_root, "min"), min);
  prop_set_int(prop_create(s->s_root, "max"), max);
  prop_set_int(prop_create(s->s_root, "step"), step);
  prop_set_string(prop_create(s->s_root, "unit"), unit);

  prop_set_int(s->s_val, initial);

  s->s_min = min;
  s->s_max = max;

  if(flags & SETTINGS_INITIAL_UPDATE)
    settings_int_callback(s, initial);

  sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		       PROP_TAG_CALLBACK_INT, settings_int_callback, s,
		       PROP_TAG_ROOT, s->s_val,
		       PROP_TAG_COURIER, pc,
		       NULL);
  s->s_sub = sub;
  s->s_store = store;
  s->s_saver = saver;
  s->s_saver_opaque = saver_opaque;
  return s;
}
Esempio n. 6
0
setting_t *
settings_create_string(prop_t *parent, const char *id, prop_t *title,
		       const char *initial, htsmsg_t *store,
		       prop_callback_string_t *cb, void *opaque,
		       int flags, prop_courier_t *pc,
		       settings_saver_t *saver, void *saver_opaque)
{
  setting_t *s = setting_create_leaf(parent, title, "string", "value", flags);

  s->s_id = strdup(id);
  s->s_callback = cb;
  s->s_opaque = opaque;

  if(store != NULL)
    initial = htsmsg_get_str(store, id) ?: initial;

  if(initial != NULL)
    prop_set_string(s->s_val, initial);

  if(flags & SETTINGS_PASSWORD)
    prop_set_int(prop_create(s->s_root, "password"), 1);

  if(flags & SETTINGS_INITIAL_UPDATE)
    settings_string_callback(s, initial);

  s->s_sub =
    prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		   PROP_TAG_CALLBACK_STRING, settings_string_callback, s,
		   PROP_TAG_ROOT, s->s_val,
		   PROP_TAG_COURIER, pc,
		   NULL);
  
  s->s_store = store;
  s->s_saver = saver;
  s->s_saver_opaque = saver_opaque;
  return s;
}