~stolowski/+junk/phablet-new-libunity

« back to all changes in this revision

Viewing changes to Dash/GenericLensView.qml

  • Committer: Pawel Stolowski
  • Date: 2013-06-03 14:05:42 UTC
  • Revision ID: pawel.stolowski@canonical.com-20130603140542-km6nhszcqek56ocx
Implemented a quick hack to get some gicons working, and fallback to base icons for annotated ones. Proper global solution needs to be implemented.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
LensView {
23
23
    id: lensView
24
24
 
 
25
    //FIXME: a quick hack to get icons out of gicons and fallback to
 
26
    //base icon for annotated icons. Doesn't correctly handle all icons.
 
27
    //Proper global solution needed.
 
28
    function from_gicon(name) {
 
29
        var icon_name = name;
 
30
        var annotated_re = /^. UnityProtocolAnnotatedIcon/;
 
31
        if (annotated_re.test(name)) {
 
32
            var base_icon_re = /'base-icon':.+?'(.+?)'/;
 
33
            var base_icon = name.toString().match(base_icon_re);
 
34
            icon_name = base_icon[1];
 
35
        }
 
36
        else {
 
37
            var themed_re = /^. GThemedIcon\s*([^\s]+)\s*/;
 
38
            var themed = name.match(themed_re);
 
39
            if (themed) {
 
40
                return "image://gicon/" + themed[1];
 
41
            }
 
42
        }
 
43
        var remote_re = /^http/;
 
44
        if (remote_re.test(icon_name)) {
 
45
            return icon_name;
 
46
        }
 
47
        return "image://gicon/" + icon_name;
 
48
    }
 
49
 
25
50
    onIsCurrentChanged: {
26
51
        pageHeader.resetSearch();
27
52
    }
74
99
                    text: column_5 ? column_5 : "" // FIXME: this shouldn't be necessary
75
100
                    imageWidth: units.gu(11)
76
101
                    imageHeight: units.gu(16)
77
 
                    source: column_1 ? column_1 : "" // FIXME: ditto
 
102
                    source: column_1 ? from_gicon(column_1) : "" // FIXME: ditto
78
103
                }
79
104
            }
80
105
        }