Example #1
0
static void
gconf_configure (void)
{
  JBVariable *variable;

  jb_require_program("gconftool-2");

  if (! strcmp(jb_variable_get_string("gconf-config-source"), "autodetect"))
    {
      char *config_source;

      if (! jb_exec_expand(&config_source, NULL, "$gconftool-2 --get-default-source", NULL))
	jb_error("unable to detect the GConf configuration source address");

      jb_variable_set_string("gconf-config-source", config_source);
      g_free(config_source);
    }

  /* fix the default schemas dir on Ubuntu */
  variable = jb_variable_get_variable_or_error("gconf-schemas-dir");
  if (! variable->user_set)
    {
      static const char *ubuntu_dir = "$datadir/gconf/schemas";
      char *expanded;

      expanded = jb_variable_expand(ubuntu_dir, NULL);

      if (g_file_test(expanded, G_FILE_TEST_IS_DIR))
	jb_variable_set_string("gconf-schemas-dir", ubuntu_dir);

      g_free(expanded);
    }
}
Example #2
0
/* the program must have been registered with jb_register_program() */
gboolean
jb_check_program (const char *name)
{
  static GHashTable *checked_programs = NULL;
  JBVariable *variable;
  const char *program;
  gboolean result = FALSE;

  g_return_val_if_fail(name != NULL, FALSE);

  /* do not check for the same program twice */
  if (checked_programs != NULL)
    {
      gpointer checked_result;

      if (g_hash_table_lookup_extended(checked_programs, name, NULL, &checked_result))
	return GPOINTER_TO_INT(checked_result);
    }
  else
    checked_programs = g_hash_table_new(g_str_hash, g_str_equal);

  jb_message_checking("for %s", name);

  variable = jb_variable_get_variable_or_error(name);

  program = g_value_get_string(&variable->value);

  if (variable->user_set)
    {
      char *absolute_program;

      absolute_program = g_find_program_in_path(program);
      if (absolute_program != NULL)
	{
	  jb_message_result_string(absolute_program);
	  g_value_take_string(&variable->value, absolute_program);
	  result = TRUE;
	}
      else
	{
	  jb_message_result_string_format("not found (\"%s\" was specified but was not found, is a directory or is not executable)", program);
	  g_value_set_string(&variable->value, NULL);
	}
    }
  else
    {
      if (program != NULL)
	{
	  jb_message_result_string(program);
	  result = TRUE;
	}
      else
	jb_message_result_string("not found");
    }

  g_hash_table_insert(checked_programs, g_strdup(name), GINT_TO_POINTER(result));

  return result;
}
mode_t
jb_variable_get_mode (const char *name)
{
  JBVariable *variable;

  g_return_val_if_fail(name != NULL, FALSE);

  variable = jb_variable_get_variable_or_error(name);
  g_return_val_if_fail(variable->type == jb_variable_type_mode, FALSE);

  return g_value_get_uint(&variable->value);
}
const char *
jb_variable_get_string_or_null (const char *name)
{
  JBVariable *variable;

  g_return_val_if_fail(name != NULL, FALSE);

  variable = jb_variable_get_variable_or_error(name);
  g_return_val_if_fail(variable->type == jb_variable_type_string, FALSE);

  return g_value_get_string(&variable->value);
}
gboolean
jb_variable_get_bool (const char *name)
{
  JBVariable *variable;

  g_return_val_if_fail(name != NULL, FALSE);

  variable = jb_variable_get_variable_or_error(name);
  g_return_val_if_fail(variable->type == jb_variable_type_bool, FALSE);

  return g_value_get_boolean(&variable->value);
}