2
* Copyright (C) 2013-2015 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
function printSize(i18n, size) {
20
if (size >= 1073741824)
21
// TRANSLATORS: %1 is the size of a file, expressed in GB
22
return i18n.tr("%1 GB").arg((size / 1073741824).toFixed(2));
25
// TRANSLATORS: %1 is the size of a file, expressed in MB
26
return i18n.tr("%1 MB").arg((size / 1048576).toFixed(2));
29
// TRANSLATORS: %1 is the size of a file, expressed in kB
30
return i18n.tr("%1 kB").arg(parseInt(size / 1024));
32
// TRANSLATORS: %1 is the size of a file, expressed in byte
33
return i18n.tr("%1 byte").arg(size);
36
function getIconNameFromMimetype(mimetype) {
37
if (mimetype.substring(0, 5) === "text/")
38
return "text-x-generic-symbolic"
40
if (mimetype.substring(0, 5) === "image")
41
return "image-x-generic-symbolic"
43
if (mimetype === "application/pdf")
44
return "application-pdf-symbolic"
46
if (mimetype === "application/vnd.oasis.opendocument.text"
47
|| mimetype === "application/msword"
48
|| mimetype === "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
49
return "x-office-document-symbolic"
51
if (mimetype === "application/vnd.oasis.opendocument.spreadsheet"
52
|| mimetype === "application/vnd.ms-excel"
53
|| mimetype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
54
return "x-office-spreadsheet-symbolic"
56
if (mimetype === "application/vnd.oasis.opendocument.presentation"
57
|| mimetype === "application/vnd.ms-powerpoint"
58
|| mimetype === "application/vnd.openxmlformats-officedocument.presentationml.presentation")
59
return "x-office-presentation-symbolic"
61
return "package-x-generic-symbolic"