emblemed-icon: allow passing a NULL emblem to g_emblemed_icon_new()
authorCosimo Cecchi <cosimoc@gnome.org>
Wed, 10 Nov 2010 11:03:11 +0000 (12:03 +0100)
committerCosimo Cecchi <cosimoc@gnome.org>
Wed, 10 Nov 2010 18:08:52 +0000 (19:08 +0100)
So that if we already have a list of emblems we know we want to add to
the icon, we can use e.g. a for loop to add them all, without picking
the first and looping from the second.

https://bugzilla.gnome.org/show_bug.cgi?id=634504

gio/gemblemedicon.c

index af26c83..0364cba 100644 (file)
@@ -95,7 +95,7 @@ g_emblemed_icon_init (GEmblemedIcon *emblemed)
 /**
  * g_emblemed_icon_new:
  * @icon: a #GIcon
- * @emblem: a #GEmblem
+ * @emblem: (allow-none): a #GEmblem, or %NULL
  *
  * Creates a new emblemed icon for @icon with the emblem @emblem.
  *
@@ -111,12 +111,12 @@ g_emblemed_icon_new (GIcon   *icon,
   
   g_return_val_if_fail (G_IS_ICON (icon), NULL);
   g_return_val_if_fail (!G_IS_EMBLEM (icon), NULL);
-  g_return_val_if_fail (G_IS_EMBLEM (emblem), NULL);
 
   emblemed = G_EMBLEMED_ICON (g_object_new (G_TYPE_EMBLEMED_ICON, NULL));
   emblemed->icon = g_object_ref (icon);
-  
-  g_emblemed_icon_add_emblem (emblemed, emblem);
+
+  if (emblem != NULL)
+    g_emblemed_icon_add_emblem (emblemed, emblem);
 
   return G_ICON (emblemed);
 }