diff options
author | Ryan Lortie <desrt@moonpix.lan> | 2013-02-15 11:12:47 -0500 |
---|---|---|
committer | Ryan Lortie <desrt@moonpix.lan> | 2013-02-15 11:12:47 -0500 |
commit | c447062e42944470d0b34d581368fcaad58118b1 (patch) | |
tree | 0d9f3c333bfdf345f5e87aeb4ea9cf61ab4d04a0 /gio/gmenu.c | |
parent | 23d6d1769bc95eba6029dae4593755154c320cf4 (diff) | |
download | glib-wip/gicon.tar.gz |
GIcon serialize wipwip/gicon
Diffstat (limited to 'gio/gmenu.c')
-rw-r--r-- | gio/gmenu.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gio/gmenu.c b/gio/gmenu.c index d0b41303e..0dafb3558 100644 --- a/gio/gmenu.c +++ b/gio/gmenu.c @@ -25,6 +25,8 @@ #include <string.h> +#include "gicon.h" + /** * SECTION:gmenu * @title: GMenu @@ -1334,3 +1336,37 @@ g_menu_item_new_from_model (GMenuModel *model, return menu_item; } + +/** + * g_menu_item_set_icon: + * @menu_item: a #GMenuItem + * @icon: a #GIcon, or %NULL + * + * Sets (or unsets) the icon on @menu_item. + * + * This call is the same as calling g_icon_serialize() and using the + * result as the value to g_menu_item_set_attribute_value() for the + * "icon" attribute. + * + * If @icon is %NULL then the icon is unset. + * + * Since: 2.36 + **/ +void +g_menu_item_set_icon (GMenuItem *menu_item, + GIcon *icon) +{ + GVariant *value; + + g_return_if_fail (G_IS_MENU_ITEM (menu_item)); + g_return_if_fail (G_IS_ICON (icon)); + + if (icon != NULL) + value = g_icon_serialize (icon); + else + value = NULL; + + g_menu_item_set_attribute_value (menu_item, "icon", value); + if (value) + g_variant_unref (value); +} |