Merge lp:~meese/pantheon-photos/fix-1272573 into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by meese
Status: Merged
Approved by: Cody Garver
Approved revision: 2601
Merged at revision: 2604
Proposed branch: lp:~meese/pantheon-photos/fix-1272573
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 508 lines (+124/-223)
6 files modified
src/CollectionPage.vala (+3/-2)
src/MediaPage.vala (+48/-98)
src/Page.vala (+31/-6)
src/PhotoPage.vala (+38/-93)
ui/collection.ui (+2/-12)
ui/photo_context.ui (+2/-12)
To merge this branch: bzr merge lp:~meese/pantheon-photos/fix-1272573
Reviewer Review Type Date Requested Status
Danielle Foré ux Approve
Photos Devs code Pending
Review via email: mp+232492@code.launchpad.net

Commit message

changes context menu rating stuff to a rating widget

Description of the change

changes context menu rating stuff to a rating widget

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

I can confirm that it does what it's supposed to do :)

review: Approve (ux)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CollectionPage.vala'
2--- src/CollectionPage.vala 2014-08-25 06:04:50 +0000
3+++ src/CollectionPage.vala 2014-08-28 00:04:23 +0000
4@@ -249,7 +249,9 @@
5 }
6
7 populate_contractor_menu (menu, "/CollectionContextMenu/ContractorPlaceholder");
8-
9+ populate_rating_widget_menu_item (menu, "/CollectionContextMenu/RatingWidgetPlaceholder");
10+ update_rating_sensitivities ();
11+ menu.show_all ();
12 return menu;
13 }
14
15@@ -496,7 +498,6 @@
16 case "KP_End":
17 key_press_event (event);
18 break;
19-
20 case "bracketright":
21 activate_action ("RotateClockwise");
22 break;
23
24=== modified file 'src/MediaPage.vala'
25--- src/MediaPage.vala 2014-08-25 06:10:33 +0000
26+++ src/MediaPage.vala 2014-08-28 00:04:23 +0000
27@@ -333,42 +333,6 @@
28 rate_rejected.label = Resources.rating_menu (Rating.REJECTED);
29 actions += rate_rejected;
30
31- Gtk.ActionEntry rate_unrated = { "RateUnrated", null, TRANSLATABLE,
32- "0", TRANSLATABLE, on_rate_unrated
33- };
34- rate_unrated.label = Resources.rating_menu (Rating.UNRATED);
35- actions += rate_unrated;
36-
37- Gtk.ActionEntry rate_one = { "RateOne", null, TRANSLATABLE,
38- "1", TRANSLATABLE, on_rate_one
39- };
40- rate_one.label = Resources.rating_menu (Rating.ONE);
41- actions += rate_one;
42-
43- Gtk.ActionEntry rate_two = { "RateTwo", null, TRANSLATABLE,
44- "2", TRANSLATABLE, on_rate_two
45- };
46- rate_two.label = Resources.rating_menu (Rating.TWO);
47- actions += rate_two;
48-
49- Gtk.ActionEntry rate_three = { "RateThree", null, TRANSLATABLE,
50- "3", TRANSLATABLE, on_rate_three
51- };
52- rate_three.label = Resources.rating_menu (Rating.THREE);
53- actions += rate_three;
54-
55- Gtk.ActionEntry rate_four = { "RateFour", null, TRANSLATABLE,
56- "4", TRANSLATABLE, on_rate_four
57- };
58- rate_four.label = Resources.rating_menu (Rating.FOUR);
59- actions += rate_four;
60-
61- Gtk.ActionEntry rate_five = { "RateFive", null, TRANSLATABLE,
62- "5", TRANSLATABLE, on_rate_five
63- };
64- rate_five.label = Resources.rating_menu (Rating.FIVE);
65- actions += rate_five;
66-
67 Gtk.ActionEntry sort_photos = { "SortPhotos", null, TRANSLATABLE, null, null, null };
68 sort_photos.label = _ ("Sort _Photos");
69 actions += sort_photos;
70@@ -523,18 +487,19 @@
71 }
72 }
73
74- private void update_rating_sensitivities () {
75- set_action_sensitive ("RateRejected", can_rate_selected (Rating.REJECTED));
76- set_action_sensitive ("RateUnrated", can_rate_selected (Rating.UNRATED));
77- set_action_sensitive ("RateOne", can_rate_selected (Rating.ONE));
78- set_action_sensitive ("RateTwo", can_rate_selected (Rating.TWO));
79- set_action_sensitive ("RateThree", can_rate_selected (Rating.THREE));
80- set_action_sensitive ("RateFour", can_rate_selected (Rating.FOUR));
81- set_action_sensitive ("RateFive", can_rate_selected (Rating.FIVE));
82+ protected void update_rating_sensitivities () {
83+ if (rating_menu_item != null) {
84+ rating_menu_item.sensitive = can_rate_selected ();
85+ rating_menu_item.rating_value = Resources.int_to_rating (get_selected_rating ());
86+ }
87 set_action_sensitive ("IncreaseRating", can_increase_selected_rating ());
88 set_action_sensitive ("DecreaseRating", can_decrease_selected_rating ());
89 }
90
91+ protected override void on_rating_widget_activate () {
92+ on_set_rating (Resources.int_to_rating(rating_menu_item.rating_value));
93+ }
94+
95 private void update_development_menu_item_sensitivity () {
96 if (get_view ().get_selected ().size == 0) {
97 set_action_sensitive ("RawDeveloper", false);
98@@ -614,13 +579,22 @@
99 action.set_active (display);
100 }
101
102- private bool can_rate_selected (Rating rating) {
103+ private bool can_rate_selected () {
104+ return get_view ().get_selected ().size > 0;
105+ }
106+
107+ private Rating get_selected_rating () {
108+ bool init = false;
109+ Rating last_rating = Rating.UNRATED;
110 foreach (DataView view in get_view ().get_selected ()) {
111- if (((Thumbnail) view).get_media_source ().get_rating () != rating)
112- return true;
113+ var rating = ((Thumbnail) view).get_media_source ().get_rating ();
114+ if (!init)
115+ init = true;
116+ else if (last_rating != rating)
117+ return Rating.UNRATED;
118+ last_rating = rating;
119 }
120-
121- return false;
122+ return last_rating;
123 }
124
125 private bool can_increase_selected_rating () {
126@@ -702,31 +676,31 @@
127 activate_action ("DecreaseRating");
128 break;
129
130- case "KP_1":
131- activate_action ("RateOne");
132- break;
133-
134- case "KP_2":
135- activate_action ("RateTwo");
136- break;
137-
138- case "KP_3":
139- activate_action ("RateThree");
140- break;
141-
142- case "KP_4":
143- activate_action ("RateFour");
144- break;
145-
146- case "KP_5":
147- activate_action ("RateFive");
148- break;
149-
150- case "KP_0":
151- activate_action ("RateUnrated");
152- break;
153-
154- case "KP_9":
155+ case "1":
156+ on_set_rating (Rating.ONE);
157+ break;
158+
159+ case "2":
160+ on_set_rating (Rating.TWO);
161+ break;
162+
163+ case "3":
164+ on_set_rating (Rating.THREE);
165+ break;
166+
167+ case "4":
168+ on_set_rating (Rating.FOUR);
169+ break;
170+
171+ case "5":
172+ on_set_rating (Rating.FIVE);
173+ break;
174+
175+ case "0":
176+ on_set_rating (Rating.UNRATED);
177+ break;
178+
179+ case "9":
180 activate_action ("RateRejected");
181 break;
182
183@@ -920,30 +894,6 @@
184 on_set_rating (Rating.REJECTED);
185 }
186
187- protected virtual void on_rate_unrated () {
188- on_set_rating (Rating.UNRATED);
189- }
190-
191- protected virtual void on_rate_one () {
192- on_set_rating (Rating.ONE);
193- }
194-
195- protected virtual void on_rate_two () {
196- on_set_rating (Rating.TWO);
197- }
198-
199- protected virtual void on_rate_three () {
200- on_set_rating (Rating.THREE);
201- }
202-
203- protected virtual void on_rate_four () {
204- on_set_rating (Rating.FOUR);
205- }
206-
207- protected virtual void on_rate_five () {
208- on_set_rating (Rating.FIVE);
209- }
210-
211 private void on_remove_from_library () {
212 remove_photos_from_library ((Gee.Collection<LibraryPhoto>) get_view ().get_selected_sources ());
213 }
214
215=== modified file 'src/Page.vala'
216--- src/Page.vala 2014-08-27 03:08:01 +0000
217+++ src/Page.vala 2014-08-28 00:04:23 +0000
218@@ -53,6 +53,7 @@
219 protected Gtk.Toolbar toolbar;
220 protected bool in_view = false;
221 protected Gtk.ToolButton show_sidebar_button;
222+ protected PhotoRatingMenuItem rating_menu_item;
223
224 private string page_name;
225 private ViewCollection view = null;
226@@ -119,11 +120,13 @@
227 warning (e.message);
228 }
229 // Remove old contracts
230- contractor_menu_items.foreach ((item) => { if (item != null) item.destroy (); });
231+ contractor_menu_items.foreach ((item) => {
232+ if (item != null) item.destroy ();
233+ });
234
235 //find where is contractor_placeholder in the menu
236- Gtk.Widget holder= ui.get_widget (placeholder_ui);
237- int pos=0;
238+ Gtk.Widget holder = ui.get_widget (placeholder_ui);
239+ int pos = 0;
240 foreach (Gtk.Widget w in menu.get_children ()) {
241 if (w == holder)
242 break;
243@@ -141,8 +144,30 @@
244 }
245 menu.show_all ();
246 }
247-
248- // This is called by the page controller when it has removed this page ... pages should override
249+
250+ protected void populate_rating_widget_menu_item (Gtk.Menu menu, string placeholder_ui) {
251+ if (rating_menu_item != null) rating_menu_item.destroy ();
252+ rating_menu_item = new PhotoRatingMenuItem ();
253+ //find where is rating_placeholder in the menu
254+ Gtk.Widget holder = ui.get_widget (placeholder_ui);
255+ int pos = 0;
256+ foreach (Gtk.Widget w in menu.get_children ()) {
257+ if (w == holder)
258+ break;
259+ pos++;
260+ }
261+
262+ menu.append (rating_menu_item);
263+ menu.reorder_child (rating_menu_item, pos);
264+ rating_menu_item.activate.connect (on_rating_widget_activate);
265+ menu.show_all ();
266+ }
267+
268+ protected virtual void on_rating_widget_activate () {
269+ }
270+
271+ // This is called by the page
272+ // controller when it has removed this page ... pages should override
273 // this (or the signal) to clean up
274 public override void destroy () {
275 if (is_destroyed)
276@@ -370,7 +395,7 @@
277
278 return null;
279 }
280-
281+
282 public void update_sidebar_action (bool show) {
283 if (show_sidebar_button == null)
284 return;
285
286=== modified file 'src/PhotoPage.vala'
287--- src/PhotoPage.vala 2014-08-27 06:20:32 +0000
288+++ src/PhotoPage.vala 2014-08-28 00:04:23 +0000
289@@ -2595,42 +2595,6 @@
290 rate_rejected.label = Resources.rating_menu (Rating.REJECTED);
291 actions += rate_rejected;
292
293- Gtk.ActionEntry rate_unrated = { "RateUnrated", null, TRANSLATABLE,
294- "0", TRANSLATABLE, on_rate_unrated
295- };
296- rate_unrated.label = Resources.rating_menu (Rating.UNRATED);
297- actions += rate_unrated;
298-
299- Gtk.ActionEntry rate_one = { "RateOne", null, TRANSLATABLE,
300- "1", TRANSLATABLE, on_rate_one
301- };
302- rate_one.label = Resources.rating_menu (Rating.ONE);
303- actions += rate_one;
304-
305- Gtk.ActionEntry rate_two = { "RateTwo", null, TRANSLATABLE,
306- "2", TRANSLATABLE, on_rate_two
307- };
308- rate_two.label = Resources.rating_menu (Rating.TWO);
309- actions += rate_two;
310-
311- Gtk.ActionEntry rate_three = { "RateThree", null, TRANSLATABLE,
312- "3", TRANSLATABLE, on_rate_three
313- };
314- rate_three.label = Resources.rating_menu (Rating.THREE);
315- actions += rate_three;
316-
317- Gtk.ActionEntry rate_four = { "RateFour", null, TRANSLATABLE,
318- "4", TRANSLATABLE, on_rate_four
319- };
320- rate_four.label = Resources.rating_menu (Rating.FOUR);
321- actions += rate_four;
322-
323- Gtk.ActionEntry rate_five = { "RateFive", null, TRANSLATABLE,
324- "5", TRANSLATABLE, on_rate_five
325- };
326- rate_five.label = Resources.rating_menu (Rating.FIVE);
327- actions += rate_five;
328-
329 Gtk.ActionEntry increase_size = { "IncreaseSize", Gtk.Stock.ZOOM_IN, TRANSLATABLE,
330 "<Ctrl>plus", TRANSLATABLE, on_increase_size
331 };
332@@ -3004,31 +2968,31 @@
333 activate_action ("DecreaseRating");
334 break;
335
336- case "KP_1":
337- activate_action ("RateOne");
338- break;
339-
340- case "KP_2":
341- activate_action ("RateTwo");
342- break;
343-
344- case "KP_3":
345- activate_action ("RateThree");
346- break;
347-
348- case "KP_4":
349- activate_action ("RateFour");
350- break;
351-
352- case "KP_5":
353- activate_action ("RateFive");
354- break;
355-
356- case "KP_0":
357- activate_action ("RateUnrated");
358- break;
359-
360- case "KP_9":
361+ case "1":
362+ on_set_rating (Rating.ONE);
363+ break;
364+
365+ case "2":
366+ on_set_rating (Rating.TWO);
367+ break;
368+
369+ case "3":
370+ on_set_rating (Rating.THREE);
371+ break;
372+
373+ case "4":
374+ on_set_rating (Rating.FOUR);
375+ break;
376+
377+ case "5":
378+ on_set_rating (Rating.FIVE);
379+ break;
380+
381+ case "0":
382+ on_set_rating (Rating.UNRATED);
383+ break;
384+
385+ case "9":
386 activate_action ("RateRejected");
387 break;
388
389@@ -3090,6 +3054,9 @@
390 }
391
392 populate_contractor_menu (menu, "/PhotoContextMenu/ContractorPlaceholder");
393+ populate_rating_widget_menu_item (menu, "/PhotoContextMenu/RatingWidgetPlaceholder");
394+ update_rating_menu_item_sensitivity ();
395+ menu.show_all ();
396 return menu;
397 }
398
399@@ -3320,6 +3287,10 @@
400
401 update_rating_menu_item_sensitivity ();
402 }
403+
404+ protected virtual void on_rate_rejected () {
405+ on_set_rating (Rating.REJECTED);
406+ }
407
408 private void on_set_rating (Rating rating) {
409 if (!has_photo () || get_photo_missing ())
410@@ -3331,42 +3302,16 @@
411 update_rating_menu_item_sensitivity ();
412 }
413
414- private void on_rate_rejected () {
415- on_set_rating (Rating.REJECTED);
416- }
417-
418- private void on_rate_unrated () {
419- on_set_rating (Rating.UNRATED);
420- }
421-
422- private void on_rate_one () {
423- on_set_rating (Rating.ONE);
424- }
425-
426- private void on_rate_two () {
427- on_set_rating (Rating.TWO);
428- }
429-
430- private void on_rate_three () {
431- on_set_rating (Rating.THREE);
432- }
433-
434- private void on_rate_four () {
435- on_set_rating (Rating.FOUR);
436- }
437-
438- private void on_rate_five () {
439- on_set_rating (Rating.FIVE);
440+ protected override void on_rating_widget_activate () {
441+ on_set_rating (Resources.int_to_rating(rating_menu_item.rating_value));
442 }
443
444 private void update_rating_menu_item_sensitivity () {
445 set_action_sensitive ("RateRejected", get_photo ().get_rating () != Rating.REJECTED);
446- set_action_sensitive ("RateUnrated", get_photo ().get_rating () != Rating.UNRATED);
447- set_action_sensitive ("RateOne", get_photo ().get_rating () != Rating.ONE);
448- set_action_sensitive ("RateTwo", get_photo ().get_rating () != Rating.TWO);
449- set_action_sensitive ("RateThree", get_photo ().get_rating () != Rating.THREE);
450- set_action_sensitive ("RateFour", get_photo ().get_rating () != Rating.FOUR);
451- set_action_sensitive ("RateFive", get_photo ().get_rating () != Rating.FIVE);
452+ if (rating_menu_item != null) {
453+ rating_menu_item.sensitive = (get_photo () != null);
454+ rating_menu_item.rating_value = get_photo ().get_rating ();
455+ }
456 set_action_sensitive ("IncreaseRating", get_photo ().get_rating ().can_increase ());
457 set_action_sensitive ("DecreaseRating", get_photo ().get_rating ().can_decrease ());
458 }
459
460=== modified file 'ui/collection.ui'
461--- ui/collection.ui 2014-08-25 06:04:50 +0000
462+++ ui/collection.ui 2014-08-28 00:04:23 +0000
463@@ -11,18 +11,8 @@
464 <placeholder name="ContextFacesPlaceholder" />
465 <separator />
466 <menuitem name="ContextFlag" action="Flag" />
467- <menu name="Rate" action="Rate">
468- <menuitem name="RateFive" action="RateFive" />
469- <menuitem name="RateFour" action="RateFour" />
470- <menuitem name="RateThree" action="RateThree" />
471- <menuitem name="RateTwo" action="RateTwo" />
472- <menuitem name="RateOne" action="RateOne" />
473- <menuitem name="RateUnrated" action="RateUnrated" />
474- <menuitem name="RateRejected" action="RateRejected" />
475- <separator />
476- <menuitem name="IncreaseRating" action="IncreaseRating" />
477- <menuitem name="DecreaseRating" action="DecreaseRating" />
478- </menu>
479+ <menuitem name="RateRejected" action="RateRejected" />
480+ <placeholder name="RatingWidgetPlaceholder" />
481 <menu name="RawDeveloper" action="RawDeveloper">
482 <menuitem name="RawDeveloperShotwell" action="RawDeveloperShotwell" />
483 <menuitem name="RawDeveloperCamera" action="RawDeveloperCamera" />
484
485=== modified file 'ui/photo_context.ui'
486--- ui/photo_context.ui 2014-08-25 06:04:50 +0000
487+++ ui/photo_context.ui 2014-08-28 00:04:23 +0000
488@@ -9,18 +9,8 @@
489 <menuitem name="ContextPasteColorAdjustments" action="PasteColorAdjustments" />
490 <separator />
491 <menuitem name="ContextFlag" action="Flag" />
492- <menu name="Rate" action="Rate">
493- <menuitem name="RateFive" action="RateFive" />
494- <menuitem name="RateFour" action="RateFour" />
495- <menuitem name="RateThree" action="RateThree" />
496- <menuitem name="RateTwo" action="RateTwo" />
497- <menuitem name="RateOne" action="RateOne" />
498- <menuitem name="RateUnrated" action="RateUnrated" />
499- <menuitem name="RateRejected" action="RateRejected" />
500- <separator />
501- <menuitem name="IncreaseRating" action="IncreaseRating" />
502- <menuitem name="DecreaseRating" action="DecreaseRating" />
503- </menu>
504+ <menuitem name="RateRejected" action="RateRejected" />
505+ <placeholder name="RatingWidgetPlaceholder" />
506 <menu name="RawDeveloper" action="RawDeveloper">
507 <menuitem name="RawDeveloperShotwell" action="RawDeveloperShotwell" />
508 <menuitem name="RawDeveloperCamera" action="RawDeveloperCamera" />

Subscribers

People subscribed via source and target branches

to all changes: