From: Christian Dywan Date: Thu, 1 Jul 2010 18:42:42 +0000 (+0200) Subject: Introduce katze_item_get_meta_boolean convenience X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6822969aacd1a65941913764a75366729cb82d95;p=midori Introduce katze_item_get_meta_boolean convenience --- diff --git a/katze/katze-item.c b/katze/katze-item.c index 9ea98bd3..e56bc47b 100644 --- a/katze/katze-item.c +++ b/katze/katze-item.c @@ -595,6 +595,32 @@ katze_item_get_meta_integer (KatzeItem* item, return -1; } +/** + * katze_item_get_meta_boolean: + * @item: a #KatzeItem + * @key: the name of a boolean value + * + * The Value should be set with katze_item_set_meta_integer(). + * If the value is set and not 0, %TRUE will be returned. + * + * Since: 0.2.7 + **/ +gboolean +katze_item_get_meta_boolean (KatzeItem* item, + const gchar* key) +{ + const gchar* value; + + g_return_val_if_fail (KATZE_IS_ITEM (item), FALSE); + g_return_val_if_fail (key != NULL, FALSE); + + value = katze_item_get_meta_string (item, key); + if (value == NULL || value[0] == '0') + return FALSE; + else + return TRUE; +} + /** * katze_item_set_meta_integer: * @item: a #KatzeItem diff --git a/katze/katze-item.h b/katze/katze-item.h index 387a7a23..23b61fd2 100644 --- a/katze/katze-item.h +++ b/katze/katze-item.h @@ -118,6 +118,10 @@ gint64 katze_item_get_meta_integer (KatzeItem* item, const gchar* key); +gboolean +katze_item_get_meta_boolean (KatzeItem* item, + const gchar* key); + void katze_item_set_meta_integer (KatzeItem* item, const gchar* key,