| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# |
| 4 |
# Copyright (C) 2009-2024 Jerry Casiano |
| 5 |
# |
| 6 |
# This program is free software: you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation, either version 3 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program. |
| 18 |
# |
| 19 |
# If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>. |
| 20 |
|
| 21 |
import os |
| 22 |
import shutil |
| 23 |
|
| 24 |
RESOURCE_PATH = '/com/github/FontManager/FontManager' |
| 25 |
RESOURCE_ID = 'com.github.FontManager.FontManager' |
| 26 |
SVG_OPTIONS = 'preprocess="xml-stripblanks" compressed="true"' |
| 27 |
|
| 28 |
icon_categories = { |
| 29 |
|
| 30 |
'apps' : [ |
| 31 |
'preferences-desktop-locale-symbolic.svg' |
| 32 |
], |
| 33 |
|
| 34 |
'actions' : [ |
| 35 |
'action-unavailable-symbolic.svg', |
| 36 |
'document-edit-symbolic.svg', |
| 37 |
'edit-clear-symbolic.svg', |
| 38 |
'edit-clear-symbolic-rtl.svg', |
| 39 |
'edit-find-symbolic.svg', |
| 40 |
'edit-select-all-symbolic.svg', |
| 41 |
'edit-undo-symbolic-rtl.svg', |
| 42 |
'edit-undo-symbolic.svg', |
| 43 |
'format-justify-center-symbolic.svg', |
| 44 |
'format-justify-fill-symbolic.svg', |
| 45 |
'format-justify-left-symbolic.svg', |
| 46 |
'format-justify-right-symbolic.svg', |
| 47 |
'go-home-symbolic.svg', |
| 48 |
'go-previous-symbolic.svg', |
| 49 |
'list-add-symbolic.svg', |
| 50 |
'list-drag-handle-symbolic.svg', |
| 51 |
'list-remove-symbolic.svg', |
| 52 |
'open-menu-symbolic.svg', |
| 53 |
'panel-right-symbolic.svg', |
| 54 |
'panel-right-symbolic-rtl.svg', |
| 55 |
'system-run-symbolic.svg', |
| 56 |
'view-grid-symbolic.svg', |
| 57 |
'view-list-symbolic.svg', |
| 58 |
'view-more-symbolic.svg', |
| 59 |
'view-sort-descending-symbolic.svg', |
| 60 |
'view-pin-symbolic.svg', |
| 61 |
'window-close-symbolic.svg', |
| 62 |
'zoom-in-symbolic.svg', |
| 63 |
'zoom-out-symbolic.svg' |
| 64 |
], |
| 65 |
|
| 66 |
'devices' : [ |
| 67 |
'computer-symbolic.svg' |
| 68 |
], |
| 69 |
|
| 70 |
'emblems' : [ |
| 71 |
'emblem-documents-symbolic.svg', |
| 72 |
'emblem-synchronizing-symbolic.svg' |
| 73 |
], |
| 74 |
|
| 75 |
'places' : [ |
| 76 |
'folder-symbolic.svg' |
| 77 |
], |
| 78 |
|
| 79 |
'status' : [ |
| 80 |
'avatar-default-symbolic.svg', |
| 81 |
'computer-fail-symbolic.svg', |
| 82 |
'dialog-question-symbolic.svg', |
| 83 |
'folder-open-symbolic.svg', |
| 84 |
'network-error-symbolic.svg', |
| 85 |
'network-offline-symbolic.svg' |
| 86 |
] |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
os.makedirs('ui/icons', exist_ok=True) |
| 91 |
|
| 92 |
with open('ui/gresources.xml', 'w') as resources: |
| 93 |
resources.write('<?xml version="1.0" encoding="UTF-8"?>\n') |
| 94 |
resources.write('<gresources>\n') |
| 95 |
os.makedirs('ui/icons/symbolic/apps', exist_ok=True) |
| 96 |
shutil.copy('com.github.FontManager.FontManager-symbolic.svg', 'ui/icons/symbolic/apps/') |
| 97 |
resources.write(' <gresource prefix="{}">\n'.format(RESOURCE_PATH)) |
| 98 |
resources.write(' <file {}>icons/symbolic/apps/{}-symbolic.svg</file>\n'.format(SVG_OPTIONS, RESOURCE_ID)) |
| 99 |
for category, icons in icon_categories.items(): |
| 100 |
os.makedirs('ui/icons/scalable/{}'.format(category), exist_ok=True) |
| 101 |
for icon in icons: |
| 102 |
shutil.copy(icon, 'ui/icons/scalable/{}/'.format(category)) |
| 103 |
resources.write(' <file {}>icons/scalable/{}/{}</file>\n'.format(SVG_OPTIONS, category, icon)) |
| 104 |
resources.write(' </gresource>\n') |
| 105 |
resources.write(' <gresource prefix="{}/ui">\n'.format(RESOURCE_PATH)) |
| 106 |
resources.write(' <file compressed="true">FontManager.css</file>\n') |
| 107 |
resources.write(' </gresource>\n') |
| 108 |
resources.write('</gresources>\n') |
| 109 |
|
| 110 |
with open('ui/meson.build', 'w') as meson: |
| 111 |
meson.write('\ngresources_xml_file = files(\'gresources.xml\')\n') |
| 112 |
meson.write('\ngresources = gnome.compile_resources(\'ui-resources\', gresources_xml_file)\n\n') |
| 113 |
|
| 114 |
with open('ui/icons/CREDITS', 'w') as credits: |
| 115 |
credits.write('\nIcons in the scalable directory are sourced from the papirus-icon-theme\n') |
| 116 |
credits.write('\nSee https://github.com/PapirusDevelopmentTeam/papirus-icon-theme for more info') |
| 117 |
|