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/"
27#define BASE_THUMBNAILER_URI "image://thumbnailer/"
29QString gIconToDeclarativeImageProviderString(QString const &giconString)
31 if (giconString.isEmpty()) return giconString;
33 if (giconString.startsWith('/') || giconString.startsWith(QLatin1String("http")) ||
34 giconString.startsWith(QLatin1String("file:")) || giconString.startsWith(QLatin1String("image:"))) {
38 if (!giconString.startsWith(QLatin1String(". "))) {
39 // must be a themed icon
40 QString themedIcon(BASE_THEME_ICON_URI);
41 themedIcon.append(giconString);
45 // special case annotated icon
46 if (giconString.startsWith(QLatin1String(". UnityProtocolAnnotatedIcon "))) {
47 QString annotatedIcon;
48 QString serializedData(QUrl::fromPercentEncoding(giconString.mid(29).toUtf8()));
49 GVariant *variant = g_variant_parse(G_VARIANT_TYPE_VARDICT, serializedData.toUtf8().constData(), NULL, NULL, NULL);
51 if (variant != NULL && g_variant_lookup(variant, "base-icon", "&s", &baseUri)) {
52 annotatedIcon = gIconToDeclarativeImageProviderString(QString(baseUri));
53 // FIXME: enclose in image://annotated/... once unity supports that
55 if (variant != NULL) g_variant_unref(variant);
60 // handle real gicon strings
63 GIcon *icon = g_icon_new_for_string(giconString.toLocal8Bit().constData(), &error);
64 if (error != NULL || icon == NULL) {
65 qWarning("Unable to deserialize icon: %s", giconString.toLocal8Bit().constData());
66 g_clear_error(&error);
70 if (G_IS_THEMED_ICON(icon)) {
71 QString themedIcon(BASE_THEME_ICON_URI);
73 const char* const *iconNames = g_themed_icon_get_names(G_THEMED_ICON(icon));
74 if (iconNames != NULL) {
75 for (const char * const *iter = iconNames; *iter != NULL; ++iter) {
76 list << QLatin1String(*iter);
79 themedIcon.append(list.join(QString(",")));
81 } else if (G_IS_FILE_ICON(icon)) {
82 GFile *file = g_file_icon_get_file(G_FILE_ICON(icon));
83 gchar *uri = g_file_get_uri(file);
94QString uriToThumbnailerProviderString(QString const &uri)
96 if (uri.startsWith(QLatin1String("file:///"))) {
97 QString thumbnailerUri(BASE_THUMBNAILER_URI);
98 thumbnailerUri.append(uri.midRef(7));
99 return thumbnailerUri;
102 return QString::null;
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