 
         @listenTo @model, 'change', @onAppChanged
         @onAppChanged @model
-
         @icon = @$ '.icon'
+
+        @setIcon()
+
+
+    # Build icon from model information (depending of icon format and model
+    # name).
+    setIcon: ->
         if @model.isIconSvg()
-            @setBackgroundColor()
             extension = 'svg'
             @icon.addClass 'svg'
         else


        @icon.attr 'src', "api/applications/#{@model.get 'slug'}.#{extension}"

        @setBackgroundColor()


    setBackgroundColor: ->
        slug = @model.get 'slug'
        color = @model.get 'color'
        unless color?
            color = hashColor = ColorHash.getColor slug, 'cozy'
            # By default, look for the color in the market.
            #color = @inMarket?.get('color') or hashColor
        @color = color
        @icon.css 'background-color', color


        @id = "app-btn-#{options.model.id}"
        super


    initialize: ->
        # only re-render when 'version' changes, because it's the only displayed
        # field that can change during the update
        @listenTo @model, 'change:version', @render


    afterRender: =>
        @updateButton = new ColorButton @$ ".update-app"
