diff options
author | Philip Chimento <philip@endlessm.com> | 2014-01-08 16:51:39 -0500 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2015-03-25 17:42:34 -0700 |
commit | 67c212e47a1db5f3e3dd1abaf552052e46512c93 (patch) | |
tree | 84d7d7906b033e502561c4136efeda68312cc6bc /test/smoke-tests/credits.js | |
parent | 88a142a202a3ae5e82f222cbb5ce75372d66e719 (diff) |
Initial implementation of image credits
This is a rough implementation of an "About"-like dialog for image
attribution in SDK applications. You can press the 'secret' hotkey
Shift+Ctrl+A to get a dialog with thumbnails and attribution information
for the images in the app's GResource. Clicking on the thumbnail opens
the image's original URI in the browser, if known. Clicking on the text
opens the image's license text in the browser, if known.
For this, you need to add a JSON file to the app's GResource and pass its
GResource path to the EosApplication:image-attribution-file property. The
format of this JSON file is described in the documentation for
EosApplication.
The dialog uses GtkTreeView because we didn't have GtkListBox when I
started implementing it over a year ago. This places some limitations on
the UI; the links behave weirdly and the mouse pointer doesn't change to
a hand when hovering over the links.
[endlessm/eos-sdk#2934]
Diffstat (limited to 'test/smoke-tests/credits.js')
-rw-r--r-- | test/smoke-tests/credits.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/smoke-tests/credits.js b/test/smoke-tests/credits.js new file mode 100644 index 0000000..5d4be70 --- /dev/null +++ b/test/smoke-tests/credits.js @@ -0,0 +1,44 @@ +const Endless = imports.gi.Endless; +const GdkPixbuf = imports.gi.GdkPixbuf; +const Gio = imports.gi.Gio; +const Gtk = imports.gi.Gtk; +const Lang = imports.lang; + +const TestApp = new Lang.Class({ + Name: 'TestApp', + Extends: Endless.Application, + + vfunc_startup: function () { + this.parent(); + let win = new TestWindow({ application: this }); + win.show_all(); + } +}); + +const TestWindow = new Lang.Class({ + Name: 'TestWindow', + Extends: Endless.Window, + + _init: function (props) { + this.parent(props); + + let grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL }); + ['test1', 'test2', 'test3', 'Fahrradrheinpromenade'].forEach((key) => { + let pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale('/com/example/attributiontest/' + key + '.jpg', + 200, -1, true); + let image = Gtk.Image.new_from_pixbuf(pixbuf); + grid.add(image); + }); + this.page_manager.add(grid); + } +}); + +let resource = Gio.Resource.load(Endless.getCurrentFileDir() + '/images/credits.gresource'); +resource._register(); + +let credits = Gio.File.new_for_uri('resource:///com/example/attributiontest/attribution.json'); +let app = new TestApp({ + application_id: 'com.example.attribution', + image_attribution_file: credits +}); +app.run(ARGV); |