2 * Copyright (C) 2013 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/>.
17 * Michal Hruby <michal.hruby@canonical.com>
26#define BASE_THEME_ICON_URI "image://theme/"
28QString gIconToDeclarativeImageProviderString(QString const &giconString)
30 if (giconString.isEmpty()) return giconString;
32 if (giconString.startsWith('/') || giconString.startsWith(QLatin1String("http")) ||
33 giconString.startsWith(QLatin1String("file:")) || giconString.startsWith(QLatin1String("image:"))) {
37 if (!giconString.startsWith(QLatin1String(". "))) {
38 // must be a themed icon
39 QString themedIcon(BASE_THEME_ICON_URI);
40 themedIcon.append(giconString);
44 // special case annotated icon
45 if (giconString.startsWith(QLatin1String(". UnityProtocolAnnotatedIcon "))) {
46 QString annotatedIcon;
47 QString serializedData(QUrl::fromPercentEncoding(giconString.mid(29).toUtf8()));
48 GVariant *variant = g_variant_parse(G_VARIANT_TYPE_VARDICT, serializedData.toUtf8().constData(), NULL, NULL, NULL);
50 if (variant != NULL && g_variant_lookup(variant, "base-icon", "&s", &baseUri)) {
51 annotatedIcon = gIconToDeclarativeImageProviderString(QString(baseUri));
52 // FIXME: enclose in image://annotated/... once unity supports that
54 if (variant != NULL) g_variant_unref(variant);
59 // handle real gicon strings
62 GIcon *icon = g_icon_new_for_string(giconString.toLocal8Bit().constData(), &error);
63 if (error != NULL || icon == NULL) {
64 qWarning("Unable to deserialize icon: %s", giconString.toLocal8Bit().constData());
65 g_clear_error(&error);
69 if (G_IS_THEMED_ICON(icon)) {
70 QString themedIcon(BASE_THEME_ICON_URI);
72 const char* const *iconNames = g_themed_icon_get_names(G_THEMED_ICON(icon));
73 if (iconNames != NULL) {
74 for (const char * const *iter = iconNames; *iter != NULL; ++iter) {
75 list << QLatin1String(*iter);
78 themedIcon.append(list.join(QString(",")));
80 } else if (G_IS_FILE_ICON(icon)) {
81 GFile *file = g_file_icon_get_file(G_FILE_ICON(icon));
82 gchar *uri = g_file_get_uri(file);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list