Пример #1
0
/**
 * e_categories_exist:
 * @category: category to be searched.
 *
 * Checks whether the given category is available in the configuration.
 *
 * Return value: %TRUE if the category is available, %FALSE otherwise.
 */
gboolean
e_categories_exist (const char *category)
{
	g_return_val_if_fail (category != NULL, FALSE);

	if (!initialized)
		initialize_categories ();

	return (g_hash_table_lookup (categories_table, category) != NULL);
}
Пример #2
0
/**
 * e_categories_remove:
 * @category: category to be removed.
 *
 * Removes the given category from the configuration.
 */
void
e_categories_remove (const char *category)
{
	g_return_if_fail (category != NULL);

	if (!initialized)
		initialize_categories ();

	if (g_hash_table_remove (categories_table, category))
		save_categories ();
}
Пример #3
0
/**
 * e_categories_get_list:
 *
 * Returns a sorted list of all the category names currently configured.
 *
 * Return value: a sorted GList containing the names of the categories. The
 * list should be freed using g_list_free, but the names of the categories
 * should not be touched at all, they are internal strings.
 */
GList *
e_categories_get_list (void)
{
	GList *list = NULL;

	if (!initialized)
		initialize_categories ();

	g_hash_table_foreach (categories_table, add_hash_to_list, &list);

	return g_list_sort (list, (GCompareFunc) g_utf8_collate);
}
Пример #4
0
SingleAvroFile::SingleAvroFile(std::string &path, bool create):
  AvroKeysAndCategories("buffer"),
  dirty_(false), text_(false),
  buffer_(&path),
  write_to_buffer_(true) {
  if (!create) {
    reload();
  } else {
    initialize_frames();
    initialize_categories();
    initialize_node_keys();
    all_.file.version=1;
  }
  null_static_frame_data_.frame = ALL_FRAMES;
}
Пример #5
0
SingleAvroFile::SingleAvroFile(std::string path, bool create,
                               bool /*read_only*/): AvroKeysAndCategories(path),
                                                    dirty_(false),
                                                    text_(get_is_text(path)),
                                                buffer_(NULL),
                                                write_to_buffer_(false) {
  if (!create) {
    reload();
  } else {
    initialize_frames();
    initialize_categories();
    initialize_node_keys();
    all_.file.version=1;
  }
  null_static_frame_data_.frame = ALL_FRAMES;
}
Пример #6
0
/**
 * e_categories_is_searchable:
 * @category: category name.
 *
 * Gets whether the given calendar is to be used for searches in the GUI.
 *
 * Return value; %TRUE% if the category is searchable, %FALSE% if not.
 */
gboolean
e_categories_is_searchable (const char *category)
{
	CategoryInfo *cat_info;

	g_return_val_if_fail (category != NULL, FALSE);

	if (!initialized)
		initialize_categories ();

	cat_info = g_hash_table_lookup (categories_table, category);
	if (cat_info == NULL)
		return FALSE;

	return cat_info->searchable;
}
Пример #7
0
/**
 * e_categories_get_icon_file_for:
 * @category: category to retrieve the icon file for.
 *
 * Gets the icon file associated with the given category.
 *
 * Return value: icon file name.
 */
const char *
e_categories_get_icon_file_for (const char *category)
{
	CategoryInfo *cat_info;

	g_return_val_if_fail (category != NULL, NULL);

	if (!initialized)
		initialize_categories ();

	cat_info = g_hash_table_lookup (categories_table, category);
	if (cat_info == NULL)
		return NULL;

	return cat_info->icon_file;
}
Пример #8
0
/**
 * e_categories_set_icon_file_for:
 * @category: category to set the icon file for.
 * @icon_file: icon file.
 *
 * Sets the icon file associated with the given category.
 */
void
e_categories_set_icon_file_for (const char *category, const char *icon_file)
{
	CategoryInfo *cat_info;

	g_return_if_fail (category != NULL);

	if (!initialized)
		initialize_categories ();

	cat_info = g_hash_table_lookup (categories_table, category);
	g_return_if_fail (cat_info != NULL);

	g_free (cat_info->icon_file);
	cat_info->icon_file = g_strdup (icon_file);
	save_categories ();
}
Пример #9
0
void SingleAvroFile::reload() {
  if (!write_to_buffer_ && !text_) {
    bool success;
    try {
      rmf_avro::DataFileReader<RMF_avro_backend::All>
      rd(get_file_path().c_str(), get_All_schema());
      success = rd.read(all_);
    } catch (std::exception &e) {
      RMF_THROW(Message(e.what()) << File(get_file_path()),
                IOException);
    }
    if (!success) {
      RMF_THROW(Message("Can't read input file on reload"), IOException);
    }
  } else if (!write_to_buffer_ && text_) {
    boost::shared_ptr<rmf_avro::Decoder> decoder
      = rmf_avro::jsonDecoder(get_All_schema());
    std::auto_ptr<rmf_avro::InputStream> stream
      = rmf_avro::fileInputStream(get_file_path().c_str());
    decoder->init(*stream);
    bool success=false;
    try {
      rmf_avro::decode(*decoder, all_);
      success = true;
    } catch (std::exception &e) {
      RMF_THROW(Message(e.what()) << File(get_file_path()),
                IOException);
    }
    if (!success) {
      RMF_THROW(Message("Can't read input file on reload"), IOException);
    }
  } else {
    std::istringstream iss(*buffer_, std::ios_base::binary);
    boost::scoped_ptr<rmf_avro::InputStream>
      is(rmf_avro::istreamInputStream(iss).release());
    boost::shared_ptr<rmf_avro::Decoder> decoder = rmf_avro::binaryDecoder();
    decoder->init(*is);
    rmf_avro::decode(*decoder, all_);
  }
  initialize_categories();
  initialize_node_keys();
  dirty_ = false;
}
Пример #10
0
/**
 * e_categories_add:
 * @category: name of category to add.
 * @unused: DEPRECATED! associated color. DEPRECATED!
 * @icon_file: full path of the icon associated to the category.
 * @searchable: whether the category can be used for searching in the GUI.
 *
 * Adds a new category, with its corresponding icon, to the
 * configuration database.
 */
void
e_categories_add (const char *category, const char *unused, const char *icon_file, gboolean searchable)
{
	CategoryInfo *cat_info;

	g_return_if_fail (category != NULL);

	if (!initialized)
		initialize_categories ();

	/* add the new category */
	cat_info = g_new0 (CategoryInfo, 1);
	cat_info->category = g_strdup (category);
#ifndef EDS_DISABLE_DEPRECATED
	cat_info->color = g_strdup (unused);
#endif
	cat_info->icon_file = g_strdup (icon_file);
	cat_info->searchable = searchable;

	g_hash_table_insert (categories_table, g_strdup (category), cat_info);

	save_categories ();
}