Merge lp:~elementary-apps/pantheon-photos/video-thumbnail into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Felipe Escoto
Approved revision: 3071
Merged at revision: 3081
Proposed branch: lp:~elementary-apps/pantheon-photos/video-thumbnail
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 192 lines (+45/-87)
5 files modified
data/icons/noninterpretable-video.svg (+43/-0)
src/MediaPage.vala (+1/-79)
src/Resources.vala (+1/-1)
src/Thumbnail.vala (+0/-3)
src/camera/ImportPage.vala (+0/-4)
To merge this branch: bzr merge lp:~elementary-apps/pantheon-photos/video-thumbnail
Reviewer Review Type Date Requested Status
Photos Devs Pending
Review via email: mp+311653@code.launchpad.net

Commit message

Remove the "sprocket" from video thumbnails and replace the thumbnail image

Description of the change

Gets rid of the dumb sprocket and replaces the placeholder thumbnail with something a little simpler.

It's still not ideal, we're presenting a pixbuf instead of a gtk.image and ideally I think I'd like to do this with native widgets and icons and not have an image at all here. But It's way less code than the old thing

To test this you'll need to make install and to clear your video thumbnails in .cache/pantheon-photos

To post a comment you must log in.
3071. By Danielle Foré

kill sprockets

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'data/icons/noninterpretable-video.png'
2Binary files data/icons/noninterpretable-video.png 2010-12-03 00:51:38 +0000 and data/icons/noninterpretable-video.png 1970-01-01 00:00:00 +0000 differ
3=== added file 'data/icons/noninterpretable-video.svg'
4--- data/icons/noninterpretable-video.svg 1970-01-01 00:00:00 +0000
5+++ data/icons/noninterpretable-video.svg 2016-12-08 22:24:42 +0000
6@@ -0,0 +1,43 @@
7+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
8+<svg
9+ xmlns:dc="http://purl.org/dc/elements/1.1/"
10+ xmlns:cc="http://creativecommons.org/ns#"
11+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
12+ xmlns:svg="http://www.w3.org/2000/svg"
13+ xmlns="http://www.w3.org/2000/svg"
14+ height="300"
15+ id="svg7384"
16+ version="1.1"
17+ width="400">
18+ <title
19+ id="title9167">elementary Symbolic Icon Theme</title>
20+ <defs
21+ id="defs7386" />
22+ <rect
23+ width="400"
24+ height="300"
25+ rx="0"
26+ ry="0"
27+ x="0"
28+ y="0"
29+ id="rect5505-21-3-8-5-2"
30+ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#2c2f32;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999994;marker:none;enable-background:accumulate" />
31+ <g
32+ id="layer1-1-4-3"
33+ transform="matrix(4,0,0,4,168,122)"
34+ style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate;opacity:0.05">
35+ <path
36+ style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate"
37+ id="rect3032-8-6"
38+ d="M 1.75,0 C 1.3345,0 1,0.3345 1,0.75 l 0,13.5 C 1,14.6655 1.3345,15 1.75,15 l 12.5,0 C 14.6655,15 15,14.6655 15,14.25 L 15,0.75 C 15,0.3345 14.6655,0 14.25,0 L 1.75,0 Z M 2,1 3,1 3,2 2,2 2,1 Z m 2.5,0 7,0 C 11.777,1 12,1.223 12,1.5 l 0,5 C 12,6.777 11.777,7 11.5,7 l -7,0 C 4.223,7 4,6.777 4,6.5 l 0,-5 C 4,1.223 4.223,1 4.5,1 Z m 8.5,0 1,0 0,1 -1,0 0,-1 z M 2,3 3,3 3,4 2,4 2,3 Z m 11,0 1,0 0,1 -1,0 0,-1 z M 2,5 3,5 3,6 2,6 2,5 Z m 11,0 1,0 0,1 -1,0 0,-1 z M 2,7 3,7 3,8 2,8 2,7 Z m 11,0 1,0 0,1 -1,0 0,-1 z m -8.5,1 7,0 C 11.777,8 12,8.223 12,8.5 l 0,5 c 0,0.277 -0.223,0.5 -0.5,0.5 l -7,0 C 4.223,14 4,13.777 4,13.5 l 0,-5 C 4,8.223 4.223,8 4.5,8 Z M 2,9 3,9 3,10 2,10 2,9 Z m 11,0 1,0 0,1 -1,0 0,-1 z m -11,2 1,0 0,1 -1,0 0,-1 z m 11,0 1,0 0,1 -1,0 0,-1 z m -11,2 1,0 0,1 -1,0 0,-1 z m 11,0 1,0 0,1 -1,0 0,-1 z" />
39+ </g>
40+ <g
41+ id="layer1-1-4"
42+ transform="matrix(4,0,0,4,168,120)"
43+ style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#050b0b;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate;opacity:1">
44+ <path
45+ style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#050b0b;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;enable-background:accumulate"
46+ id="rect3032-8"
47+ d="M 1.75,0 C 1.3345,0 1,0.3345 1,0.75 l 0,13.5 C 1,14.6655 1.3345,15 1.75,15 l 12.5,0 C 14.6655,15 15,14.6655 15,14.25 L 15,0.75 C 15,0.3345 14.6655,0 14.25,0 L 1.75,0 Z M 2,1 3,1 3,2 2,2 2,1 Z m 2.5,0 7,0 C 11.777,1 12,1.223 12,1.5 l 0,5 C 12,6.777 11.777,7 11.5,7 l -7,0 C 4.223,7 4,6.777 4,6.5 l 0,-5 C 4,1.223 4.223,1 4.5,1 Z m 8.5,0 1,0 0,1 -1,0 0,-1 z M 2,3 3,3 3,4 2,4 2,3 Z m 11,0 1,0 0,1 -1,0 0,-1 z M 2,5 3,5 3,6 2,6 2,5 Z m 11,0 1,0 0,1 -1,0 0,-1 z M 2,7 3,7 3,8 2,8 2,7 Z m 11,0 1,0 0,1 -1,0 0,-1 z m -8.5,1 7,0 C 11.777,8 12,8.223 12,8.5 l 0,5 c 0,0.277 -0.223,0.5 -0.5,0.5 l -7,0 C 4.223,14 4,13.777 4,13.5 l 0,-5 C 4,8.223 4.223,8 4.5,8 Z M 2,9 3,9 3,10 2,10 2,9 Z m 11,0 1,0 0,1 -1,0 0,-1 z m -11,2 1,0 0,1 -1,0 0,-1 z m 11,0 1,0 0,1 -1,0 0,-1 z m -11,2 1,0 0,1 -1,0 0,-1 z m 11,0 1,0 0,1 -1,0 0,-1 z" />
48+ </g>
49+</svg>
50
51=== removed file 'data/icons/sprocket.png'
52Binary files data/icons/sprocket.png 2010-12-07 23:13:21 +0000 and data/icons/sprocket.png 1970-01-01 00:00:00 +0000 differ
53=== modified file 'src/MediaPage.vala'
54--- src/MediaPage.vala 2016-11-21 04:25:34 +0000
55+++ src/MediaPage.vala 2016-12-08 22:24:42 +0000
56@@ -5,93 +5,15 @@
57 */
58
59 public class MediaSourceItem : CheckerboardItem {
60- private static Gdk.Pixbuf basis_sprocket_pixbuf = null;
61- private static Gdk.Pixbuf current_sprocket_pixbuf = null;
62-
63- private bool enable_sprockets = false;
64-
65 // preserve the same constructor arguments and semantics as CheckerboardItem so that we're
66 // a drop-in replacement
67 public MediaSourceItem (ThumbnailSource source, Dimensions initial_pixbuf_dim, string title,
68 string? comment, bool marked_up = false, Pango.Alignment alignment = Pango.Alignment.LEFT) {
69 base (source, initial_pixbuf_dim, title, comment, marked_up, alignment);
70- if (basis_sprocket_pixbuf == null)
71- basis_sprocket_pixbuf = Resources.load_icon ("sprocket.png", 0);
72 }
73
74- protected override void paint_image (Cairo.Context ctx, Gdk.Pixbuf pixbuf,
75- Gdk.Point origin) {
76- Dimensions pixbuf_dim = Dimensions.for_pixbuf (pixbuf);
77- // sprocket geometry calculation (and possible adjustment) has to occur before we call
78- // base.paint_image( ) because the base-class method needs the correct trinket horizontal
79- // offsets
80-
81- if (!enable_sprockets) {
82- set_horizontal_trinket_offset (0);
83- } else {
84- double reduction_factor = ((double) pixbuf_dim.major_axis ()) /
85- ((double) ThumbnailCache.Size.LARGEST);
86- int reduced_size = (int) (reduction_factor * basis_sprocket_pixbuf.width);
87-
88- if (current_sprocket_pixbuf == null || reduced_size != current_sprocket_pixbuf.width) {
89- current_sprocket_pixbuf = basis_sprocket_pixbuf.scale_simple (reduced_size,
90- reduced_size, Gdk.InterpType.HYPER);
91- }
92-
93- set_horizontal_trinket_offset (current_sprocket_pixbuf.width);
94- }
95-
96+ protected override void paint_image (Cairo.Context ctx, Gdk.Pixbuf pixbuf, Gdk.Point origin) {
97 base.paint_image (ctx, pixbuf, origin);
98-
99- if (enable_sprockets) {
100- paint_sprockets (ctx, origin, pixbuf_dim);
101- }
102- }
103-
104- protected void paint_one_sprocket (Cairo.Context ctx, Gdk.Point origin) {
105- ctx.save ();
106- Gdk.cairo_set_source_pixbuf (ctx, current_sprocket_pixbuf, origin.x, origin.y);
107- ctx.paint ();
108- ctx.restore ();
109- }
110-
111- protected void paint_sprockets (Cairo.Context ctx, Gdk.Point item_origin,
112- Dimensions item_dimensions) {
113- int num_sprockets = item_dimensions.height / current_sprocket_pixbuf.height;
114-
115- Gdk.Point left_paint_location = item_origin;
116- Gdk.Point right_paint_location = item_origin;
117- right_paint_location.x += (item_dimensions.width - current_sprocket_pixbuf.width);
118- for (int i = 0; i < num_sprockets; i++) {
119- paint_one_sprocket (ctx, left_paint_location);
120- paint_one_sprocket (ctx, right_paint_location);
121-
122- left_paint_location.y += current_sprocket_pixbuf.height;
123- right_paint_location.y += current_sprocket_pixbuf.height;
124- }
125-
126- int straggler_pixels = item_dimensions.height % current_sprocket_pixbuf.height;
127- if (straggler_pixels > 0) {
128- ctx.save ();
129-
130- Gdk.cairo_set_source_pixbuf (ctx, current_sprocket_pixbuf, left_paint_location.x,
131- left_paint_location.y);
132- ctx.rectangle (left_paint_location.x, left_paint_location.y,
133- current_sprocket_pixbuf.get_width (), straggler_pixels);
134- ctx.fill ();
135-
136- Gdk.cairo_set_source_pixbuf (ctx, current_sprocket_pixbuf, right_paint_location.x,
137- right_paint_location.y);
138- ctx.rectangle (right_paint_location.x, right_paint_location.y,
139- current_sprocket_pixbuf.get_width (), straggler_pixels);
140- ctx.fill ();
141-
142- ctx.restore ();
143- }
144- }
145-
146- public void set_enable_sprockets (bool enable_sprockets) {
147- this.enable_sprockets = enable_sprockets;
148 }
149 }
150
151
152=== modified file 'src/Resources.vala'
153--- src/Resources.vala 2016-11-21 23:16:12 +0000
154+++ src/Resources.vala 2016-12-08 22:24:42 +0000
155@@ -532,7 +532,7 @@
156 return AppDirs.get_resources_dir ().get_child ("ui").get_child (filename);
157 }
158
159-private const string NONINTERPRETABLE_BADGE_FILE = "noninterpretable-video.png";
160+private const string NONINTERPRETABLE_BADGE_FILE = "noninterpretable-video.svg";
161 private Gdk.Pixbuf? noninterpretable_badge_pixbuf = null;
162
163 public Gdk.Pixbuf? get_noninterpretable_badge_pixbuf () {
164
165=== modified file 'src/Thumbnail.vala'
166--- src/Thumbnail.vala 2016-09-20 00:44:41 +0000
167+++ src/Thumbnail.vala 2016-12-08 22:24:42 +0000
168@@ -54,9 +54,6 @@
169 Tag.global.container_contents_altered.connect (on_tag_contents_altered);
170 Tag.global.items_altered.connect (on_tags_altered);
171
172- assert ((media is LibraryPhoto) || (media is Video));
173- set_enable_sprockets (media is Video);
174-
175 original_dim = media.get_dimensions ();
176 dim = original_dim.get_scaled (scale, true);
177
178
179=== modified file 'src/camera/ImportPage.vala'
180--- src/camera/ImportPage.vala 2016-11-21 04:25:34 +0000
181+++ src/camera/ImportPage.vala 2016-12-08 22:24:42 +0000
182@@ -273,10 +273,6 @@
183
184 this.duplicated_file = null;
185
186- // draw sprocket holes as visual indications on video previews
187- if (source is VideoImportSource)
188- set_enable_sprockets (true);
189-
190 // scale down pixbuf if necessary
191 Gdk.Pixbuf pixbuf = null;
192 try {

Subscribers

People subscribed via source and target branches