# File icon-artist/icon.rb, line 306
    def self.create(iconname, context, template="default")
      userdir_templates = Icon.get_templatedir
      @template = File.expand_path("#{template}")
      if !File.exist?(@template)
        @template = File.expand_path("#{userdir_templates}/#{template}.svg")
        if !File.exist?(@template)
          @template = "#{ARTIST_SHAREDIR}/templates/#{template}.svg"
          if !File.exist?(@template)
            raise "Could not find either #{template}, #{userdir_templates}/#{template}.svg or #{ARTIST_SHAREDIR}/templates/#{template}.svg"
          end
        end
      end
      
      @iconname=iconname
      @context=context
      @filename=File.expand_path("#{@iconname}.svg")
      
      if File.exist?(@filename)
        raise "Selected icon (#{@filename}) already exists. \nPlease set another icon name."
      end
      
      if !(THEME_CONTEXTS.include?(@context))
        out = "Context must be one of: "
        THEME_CONTEXTS.each {|el| out = out + "#{el}, "}
        out = (out + "\n").gsub(", \n", ".\n")
        raise out
      end
      
      @svg = Document.new(File.new("#{@template}", 'r'))
      
      @svg.root.attributes.delete_all("inkscape:export-filename")
      @svg.root.attributes.delete_all("sodipodi:docname")
    
      element = @svg.root.elements["metadata/rdf:RDF/cc:Work"]

      element.elements.delete_all("dc:title")
      element.elements.delete_all("dc:description")

      title = Element.new "dc:title"
      title.add_text "#{@iconname}"
      element.add_element title

      description = Element.new "dc:description"
      description.add_text "#{@context}"
      element.add_element description

      f = File.open(@filename,"w")
      @svg.write(f, -1, false)
      f.close

      puts "New icon #{@filename} created."
      self.new(@filename, :skip_check => true)
    end