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
=== modified file 'src/CollectionPage.vala'
--- src/CollectionPage.vala 2014-08-25 06:04:50 +0000
+++ src/CollectionPage.vala 2014-08-28 00:04:23 +0000
@@ -249,7 +249,9 @@
249 }249 }
250250
251 populate_contractor_menu (menu, "/CollectionContextMenu/ContractorPlaceholder");251 populate_contractor_menu (menu, "/CollectionContextMenu/ContractorPlaceholder");
252252 populate_rating_widget_menu_item (menu, "/CollectionContextMenu/RatingWidgetPlaceholder");
253 update_rating_sensitivities ();
254 menu.show_all ();
253 return menu;255 return menu;
254 }256 }
255257
@@ -496,7 +498,6 @@
496 case "KP_End":498 case "KP_End":
497 key_press_event (event);499 key_press_event (event);
498 break;500 break;
499
500 case "bracketright":501 case "bracketright":
501 activate_action ("RotateClockwise");502 activate_action ("RotateClockwise");
502 break;503 break;
503504
=== modified file 'src/MediaPage.vala'
--- src/MediaPage.vala 2014-08-25 06:10:33 +0000
+++ src/MediaPage.vala 2014-08-28 00:04:23 +0000
@@ -333,42 +333,6 @@
333 rate_rejected.label = Resources.rating_menu (Rating.REJECTED);333 rate_rejected.label = Resources.rating_menu (Rating.REJECTED);
334 actions += rate_rejected;334 actions += rate_rejected;
335335
336 Gtk.ActionEntry rate_unrated = { "RateUnrated", null, TRANSLATABLE,
337 "0", TRANSLATABLE, on_rate_unrated
338 };
339 rate_unrated.label = Resources.rating_menu (Rating.UNRATED);
340 actions += rate_unrated;
341
342 Gtk.ActionEntry rate_one = { "RateOne", null, TRANSLATABLE,
343 "1", TRANSLATABLE, on_rate_one
344 };
345 rate_one.label = Resources.rating_menu (Rating.ONE);
346 actions += rate_one;
347
348 Gtk.ActionEntry rate_two = { "RateTwo", null, TRANSLATABLE,
349 "2", TRANSLATABLE, on_rate_two
350 };
351 rate_two.label = Resources.rating_menu (Rating.TWO);
352 actions += rate_two;
353
354 Gtk.ActionEntry rate_three = { "RateThree", null, TRANSLATABLE,
355 "3", TRANSLATABLE, on_rate_three
356 };
357 rate_three.label = Resources.rating_menu (Rating.THREE);
358 actions += rate_three;
359
360 Gtk.ActionEntry rate_four = { "RateFour", null, TRANSLATABLE,
361 "4", TRANSLATABLE, on_rate_four
362 };
363 rate_four.label = Resources.rating_menu (Rating.FOUR);
364 actions += rate_four;
365
366 Gtk.ActionEntry rate_five = { "RateFive", null, TRANSLATABLE,
367 "5", TRANSLATABLE, on_rate_five
368 };
369 rate_five.label = Resources.rating_menu (Rating.FIVE);
370 actions += rate_five;
371
372 Gtk.ActionEntry sort_photos = { "SortPhotos", null, TRANSLATABLE, null, null, null };336 Gtk.ActionEntry sort_photos = { "SortPhotos", null, TRANSLATABLE, null, null, null };
373 sort_photos.label = _ ("Sort _Photos");337 sort_photos.label = _ ("Sort _Photos");
374 actions += sort_photos;338 actions += sort_photos;
@@ -523,18 +487,19 @@
523 }487 }
524 }488 }
525489
526 private void update_rating_sensitivities () {490 protected void update_rating_sensitivities () {
527 set_action_sensitive ("RateRejected", can_rate_selected (Rating.REJECTED));491 if (rating_menu_item != null) {
528 set_action_sensitive ("RateUnrated", can_rate_selected (Rating.UNRATED));492 rating_menu_item.sensitive = can_rate_selected ();
529 set_action_sensitive ("RateOne", can_rate_selected (Rating.ONE));493 rating_menu_item.rating_value = Resources.int_to_rating (get_selected_rating ());
530 set_action_sensitive ("RateTwo", can_rate_selected (Rating.TWO));494 }
531 set_action_sensitive ("RateThree", can_rate_selected (Rating.THREE));
532 set_action_sensitive ("RateFour", can_rate_selected (Rating.FOUR));
533 set_action_sensitive ("RateFive", can_rate_selected (Rating.FIVE));
534 set_action_sensitive ("IncreaseRating", can_increase_selected_rating ());495 set_action_sensitive ("IncreaseRating", can_increase_selected_rating ());
535 set_action_sensitive ("DecreaseRating", can_decrease_selected_rating ());496 set_action_sensitive ("DecreaseRating", can_decrease_selected_rating ());
536 }497 }
537498
499 protected override void on_rating_widget_activate () {
500 on_set_rating (Resources.int_to_rating(rating_menu_item.rating_value));
501 }
502
538 private void update_development_menu_item_sensitivity () {503 private void update_development_menu_item_sensitivity () {
539 if (get_view ().get_selected ().size == 0) {504 if (get_view ().get_selected ().size == 0) {
540 set_action_sensitive ("RawDeveloper", false);505 set_action_sensitive ("RawDeveloper", false);
@@ -614,13 +579,22 @@
614 action.set_active (display);579 action.set_active (display);
615 }580 }
616581
617 private bool can_rate_selected (Rating rating) {582 private bool can_rate_selected () {
583 return get_view ().get_selected ().size > 0;
584 }
585
586 private Rating get_selected_rating () {
587 bool init = false;
588 Rating last_rating = Rating.UNRATED;
618 foreach (DataView view in get_view ().get_selected ()) {589 foreach (DataView view in get_view ().get_selected ()) {
619 if (((Thumbnail) view).get_media_source ().get_rating () != rating)590 var rating = ((Thumbnail) view).get_media_source ().get_rating ();
620 return true;591 if (!init)
592 init = true;
593 else if (last_rating != rating)
594 return Rating.UNRATED;
595 last_rating = rating;
621 }596 }
622597 return last_rating;
623 return false;
624 }598 }
625599
626 private bool can_increase_selected_rating () {600 private bool can_increase_selected_rating () {
@@ -702,31 +676,31 @@
702 activate_action ("DecreaseRating");676 activate_action ("DecreaseRating");
703 break;677 break;
704678
705 case "KP_1":679 case "1":
706 activate_action ("RateOne");680 on_set_rating (Rating.ONE);
707 break;681 break;
708682
709 case "KP_2":683 case "2":
710 activate_action ("RateTwo");684 on_set_rating (Rating.TWO);
711 break;685 break;
712686
713 case "KP_3":687 case "3":
714 activate_action ("RateThree");688 on_set_rating (Rating.THREE);
715 break;689 break;
716690
717 case "KP_4":691 case "4":
718 activate_action ("RateFour");692 on_set_rating (Rating.FOUR);
719 break;693 break;
720694
721 case "KP_5":695 case "5":
722 activate_action ("RateFive");696 on_set_rating (Rating.FIVE);
723 break;697 break;
724698
725 case "KP_0":699 case "0":
726 activate_action ("RateUnrated");700 on_set_rating (Rating.UNRATED);
727 break;701 break;
728702
729 case "KP_9":703 case "9":
730 activate_action ("RateRejected");704 activate_action ("RateRejected");
731 break;705 break;
732706
@@ -920,30 +894,6 @@
920 on_set_rating (Rating.REJECTED);894 on_set_rating (Rating.REJECTED);
921 }895 }
922896
923 protected virtual void on_rate_unrated () {
924 on_set_rating (Rating.UNRATED);
925 }
926
927 protected virtual void on_rate_one () {
928 on_set_rating (Rating.ONE);
929 }
930
931 protected virtual void on_rate_two () {
932 on_set_rating (Rating.TWO);
933 }
934
935 protected virtual void on_rate_three () {
936 on_set_rating (Rating.THREE);
937 }
938
939 protected virtual void on_rate_four () {
940 on_set_rating (Rating.FOUR);
941 }
942
943 protected virtual void on_rate_five () {
944 on_set_rating (Rating.FIVE);
945 }
946
947 private void on_remove_from_library () {897 private void on_remove_from_library () {
948 remove_photos_from_library ((Gee.Collection<LibraryPhoto>) get_view ().get_selected_sources ());898 remove_photos_from_library ((Gee.Collection<LibraryPhoto>) get_view ().get_selected_sources ());
949 }899 }
950900
=== modified file 'src/Page.vala'
--- src/Page.vala 2014-08-27 03:08:01 +0000
+++ src/Page.vala 2014-08-28 00:04:23 +0000
@@ -53,6 +53,7 @@
53 protected Gtk.Toolbar toolbar;53 protected Gtk.Toolbar toolbar;
54 protected bool in_view = false;54 protected bool in_view = false;
55 protected Gtk.ToolButton show_sidebar_button;55 protected Gtk.ToolButton show_sidebar_button;
56 protected PhotoRatingMenuItem rating_menu_item;
5657
57 private string page_name;58 private string page_name;
58 private ViewCollection view = null;59 private ViewCollection view = null;
@@ -119,11 +120,13 @@
119 warning (e.message);120 warning (e.message);
120 }121 }
121 // Remove old contracts122 // Remove old contracts
122 contractor_menu_items.foreach ((item) => { if (item != null) item.destroy (); });123 contractor_menu_items.foreach ((item) => {
124 if (item != null) item.destroy ();
125 });
123126
124 //find where is contractor_placeholder in the menu127 //find where is contractor_placeholder in the menu
125 Gtk.Widget holder= ui.get_widget (placeholder_ui);128 Gtk.Widget holder = ui.get_widget (placeholder_ui);
126 int pos=0;129 int pos = 0;
127 foreach (Gtk.Widget w in menu.get_children ()) {130 foreach (Gtk.Widget w in menu.get_children ()) {
128 if (w == holder)131 if (w == holder)
129 break;132 break;
@@ -141,8 +144,30 @@
141 }144 }
142 menu.show_all ();145 menu.show_all ();
143 }146 }
144147
145 // This is called by the page controller when it has removed this page ... pages should override148 protected void populate_rating_widget_menu_item (Gtk.Menu menu, string placeholder_ui) {
149 if (rating_menu_item != null) rating_menu_item.destroy ();
150 rating_menu_item = new PhotoRatingMenuItem ();
151 //find where is rating_placeholder in the menu
152 Gtk.Widget holder = ui.get_widget (placeholder_ui);
153 int pos = 0;
154 foreach (Gtk.Widget w in menu.get_children ()) {
155 if (w == holder)
156 break;
157 pos++;
158 }
159
160 menu.append (rating_menu_item);
161 menu.reorder_child (rating_menu_item, pos);
162 rating_menu_item.activate.connect (on_rating_widget_activate);
163 menu.show_all ();
164 }
165
166 protected virtual void on_rating_widget_activate () {
167 }
168
169 // This is called by the page
170 // controller when it has removed this page ... pages should override
146 // this (or the signal) to clean up171 // this (or the signal) to clean up
147 public override void destroy () {172 public override void destroy () {
148 if (is_destroyed)173 if (is_destroyed)
@@ -370,7 +395,7 @@
370395
371 return null;396 return null;
372 }397 }
373 398
374 public void update_sidebar_action (bool show) {399 public void update_sidebar_action (bool show) {
375 if (show_sidebar_button == null)400 if (show_sidebar_button == null)
376 return;401 return;
377402
=== modified file 'src/PhotoPage.vala'
--- src/PhotoPage.vala 2014-08-27 06:20:32 +0000
+++ src/PhotoPage.vala 2014-08-28 00:04:23 +0000
@@ -2595,42 +2595,6 @@
2595 rate_rejected.label = Resources.rating_menu (Rating.REJECTED);2595 rate_rejected.label = Resources.rating_menu (Rating.REJECTED);
2596 actions += rate_rejected;2596 actions += rate_rejected;
25972597
2598 Gtk.ActionEntry rate_unrated = { "RateUnrated", null, TRANSLATABLE,
2599 "0", TRANSLATABLE, on_rate_unrated
2600 };
2601 rate_unrated.label = Resources.rating_menu (Rating.UNRATED);
2602 actions += rate_unrated;
2603
2604 Gtk.ActionEntry rate_one = { "RateOne", null, TRANSLATABLE,
2605 "1", TRANSLATABLE, on_rate_one
2606 };
2607 rate_one.label = Resources.rating_menu (Rating.ONE);
2608 actions += rate_one;
2609
2610 Gtk.ActionEntry rate_two = { "RateTwo", null, TRANSLATABLE,
2611 "2", TRANSLATABLE, on_rate_two
2612 };
2613 rate_two.label = Resources.rating_menu (Rating.TWO);
2614 actions += rate_two;
2615
2616 Gtk.ActionEntry rate_three = { "RateThree", null, TRANSLATABLE,
2617 "3", TRANSLATABLE, on_rate_three
2618 };
2619 rate_three.label = Resources.rating_menu (Rating.THREE);
2620 actions += rate_three;
2621
2622 Gtk.ActionEntry rate_four = { "RateFour", null, TRANSLATABLE,
2623 "4", TRANSLATABLE, on_rate_four
2624 };
2625 rate_four.label = Resources.rating_menu (Rating.FOUR);
2626 actions += rate_four;
2627
2628 Gtk.ActionEntry rate_five = { "RateFive", null, TRANSLATABLE,
2629 "5", TRANSLATABLE, on_rate_five
2630 };
2631 rate_five.label = Resources.rating_menu (Rating.FIVE);
2632 actions += rate_five;
2633
2634 Gtk.ActionEntry increase_size = { "IncreaseSize", Gtk.Stock.ZOOM_IN, TRANSLATABLE,2598 Gtk.ActionEntry increase_size = { "IncreaseSize", Gtk.Stock.ZOOM_IN, TRANSLATABLE,
2635 "<Ctrl>plus", TRANSLATABLE, on_increase_size2599 "<Ctrl>plus", TRANSLATABLE, on_increase_size
2636 };2600 };
@@ -3004,31 +2968,31 @@
3004 activate_action ("DecreaseRating");2968 activate_action ("DecreaseRating");
3005 break;2969 break;
30062970
3007 case "KP_1":2971 case "1":
3008 activate_action ("RateOne");2972 on_set_rating (Rating.ONE);
3009 break;2973 break;
30102974
3011 case "KP_2":2975 case "2":
3012 activate_action ("RateTwo");2976 on_set_rating (Rating.TWO);
3013 break;2977 break;
30142978
3015 case "KP_3":2979 case "3":
3016 activate_action ("RateThree");2980 on_set_rating (Rating.THREE);
3017 break;2981 break;
30182982
3019 case "KP_4":2983 case "4":
3020 activate_action ("RateFour");2984 on_set_rating (Rating.FOUR);
3021 break;2985 break;
30222986
3023 case "KP_5":2987 case "5":
3024 activate_action ("RateFive");2988 on_set_rating (Rating.FIVE);
3025 break;2989 break;
30262990
3027 case "KP_0":2991 case "0":
3028 activate_action ("RateUnrated");2992 on_set_rating (Rating.UNRATED);
3029 break;2993 break;
30302994
3031 case "KP_9":2995 case "9":
3032 activate_action ("RateRejected");2996 activate_action ("RateRejected");
3033 break;2997 break;
30342998
@@ -3090,6 +3054,9 @@
3090 }3054 }
30913055
3092 populate_contractor_menu (menu, "/PhotoContextMenu/ContractorPlaceholder");3056 populate_contractor_menu (menu, "/PhotoContextMenu/ContractorPlaceholder");
3057 populate_rating_widget_menu_item (menu, "/PhotoContextMenu/RatingWidgetPlaceholder");
3058 update_rating_menu_item_sensitivity ();
3059 menu.show_all ();
3093 return menu;3060 return menu;
3094 }3061 }
30953062
@@ -3320,6 +3287,10 @@
33203287
3321 update_rating_menu_item_sensitivity ();3288 update_rating_menu_item_sensitivity ();
3322 }3289 }
3290
3291 protected virtual void on_rate_rejected () {
3292 on_set_rating (Rating.REJECTED);
3293 }
33233294
3324 private void on_set_rating (Rating rating) {3295 private void on_set_rating (Rating rating) {
3325 if (!has_photo () || get_photo_missing ())3296 if (!has_photo () || get_photo_missing ())
@@ -3331,42 +3302,16 @@
3331 update_rating_menu_item_sensitivity ();3302 update_rating_menu_item_sensitivity ();
3332 }3303 }
33333304
3334 private void on_rate_rejected () {3305 protected override void on_rating_widget_activate () {
3335 on_set_rating (Rating.REJECTED);3306 on_set_rating (Resources.int_to_rating(rating_menu_item.rating_value));
3336 }
3337
3338 private void on_rate_unrated () {
3339 on_set_rating (Rating.UNRATED);
3340 }
3341
3342 private void on_rate_one () {
3343 on_set_rating (Rating.ONE);
3344 }
3345
3346 private void on_rate_two () {
3347 on_set_rating (Rating.TWO);
3348 }
3349
3350 private void on_rate_three () {
3351 on_set_rating (Rating.THREE);
3352 }
3353
3354 private void on_rate_four () {
3355 on_set_rating (Rating.FOUR);
3356 }
3357
3358 private void on_rate_five () {
3359 on_set_rating (Rating.FIVE);
3360 }3307 }
33613308
3362 private void update_rating_menu_item_sensitivity () {3309 private void update_rating_menu_item_sensitivity () {
3363 set_action_sensitive ("RateRejected", get_photo ().get_rating () != Rating.REJECTED);3310 set_action_sensitive ("RateRejected", get_photo ().get_rating () != Rating.REJECTED);
3364 set_action_sensitive ("RateUnrated", get_photo ().get_rating () != Rating.UNRATED);3311 if (rating_menu_item != null) {
3365 set_action_sensitive ("RateOne", get_photo ().get_rating () != Rating.ONE);3312 rating_menu_item.sensitive = (get_photo () != null);
3366 set_action_sensitive ("RateTwo", get_photo ().get_rating () != Rating.TWO);3313 rating_menu_item.rating_value = get_photo ().get_rating ();
3367 set_action_sensitive ("RateThree", get_photo ().get_rating () != Rating.THREE);3314 }
3368 set_action_sensitive ("RateFour", get_photo ().get_rating () != Rating.FOUR);
3369 set_action_sensitive ("RateFive", get_photo ().get_rating () != Rating.FIVE);
3370 set_action_sensitive ("IncreaseRating", get_photo ().get_rating ().can_increase ());3315 set_action_sensitive ("IncreaseRating", get_photo ().get_rating ().can_increase ());
3371 set_action_sensitive ("DecreaseRating", get_photo ().get_rating ().can_decrease ());3316 set_action_sensitive ("DecreaseRating", get_photo ().get_rating ().can_decrease ());
3372 }3317 }
33733318
=== modified file 'ui/collection.ui'
--- ui/collection.ui 2014-08-25 06:04:50 +0000
+++ ui/collection.ui 2014-08-28 00:04:23 +0000
@@ -11,18 +11,8 @@
11 <placeholder name="ContextFacesPlaceholder" />11 <placeholder name="ContextFacesPlaceholder" />
12 <separator />12 <separator />
13 <menuitem name="ContextFlag" action="Flag" />13 <menuitem name="ContextFlag" action="Flag" />
14 <menu name="Rate" action="Rate">14 <menuitem name="RateRejected" action="RateRejected" />
15 <menuitem name="RateFive" action="RateFive" />15 <placeholder name="RatingWidgetPlaceholder" />
16 <menuitem name="RateFour" action="RateFour" />
17 <menuitem name="RateThree" action="RateThree" />
18 <menuitem name="RateTwo" action="RateTwo" />
19 <menuitem name="RateOne" action="RateOne" />
20 <menuitem name="RateUnrated" action="RateUnrated" />
21 <menuitem name="RateRejected" action="RateRejected" />
22 <separator />
23 <menuitem name="IncreaseRating" action="IncreaseRating" />
24 <menuitem name="DecreaseRating" action="DecreaseRating" />
25 </menu>
26 <menu name="RawDeveloper" action="RawDeveloper">16 <menu name="RawDeveloper" action="RawDeveloper">
27 <menuitem name="RawDeveloperShotwell" action="RawDeveloperShotwell" />17 <menuitem name="RawDeveloperShotwell" action="RawDeveloperShotwell" />
28 <menuitem name="RawDeveloperCamera" action="RawDeveloperCamera" />18 <menuitem name="RawDeveloperCamera" action="RawDeveloperCamera" />
2919
=== modified file 'ui/photo_context.ui'
--- ui/photo_context.ui 2014-08-25 06:04:50 +0000
+++ ui/photo_context.ui 2014-08-28 00:04:23 +0000
@@ -9,18 +9,8 @@
9 <menuitem name="ContextPasteColorAdjustments" action="PasteColorAdjustments" />9 <menuitem name="ContextPasteColorAdjustments" action="PasteColorAdjustments" />
10 <separator />10 <separator />
11 <menuitem name="ContextFlag" action="Flag" />11 <menuitem name="ContextFlag" action="Flag" />
12 <menu name="Rate" action="Rate">12 <menuitem name="RateRejected" action="RateRejected" />
13 <menuitem name="RateFive" action="RateFive" />13 <placeholder name="RatingWidgetPlaceholder" />
14 <menuitem name="RateFour" action="RateFour" />
15 <menuitem name="RateThree" action="RateThree" />
16 <menuitem name="RateTwo" action="RateTwo" />
17 <menuitem name="RateOne" action="RateOne" />
18 <menuitem name="RateUnrated" action="RateUnrated" />
19 <menuitem name="RateRejected" action="RateRejected" />
20 <separator />
21 <menuitem name="IncreaseRating" action="IncreaseRating" />
22 <menuitem name="DecreaseRating" action="DecreaseRating" />
23 </menu>
24 <menu name="RawDeveloper" action="RawDeveloper">14 <menu name="RawDeveloper" action="RawDeveloper">
25 <menuitem name="RawDeveloperShotwell" action="RawDeveloperShotwell" />15 <menuitem name="RawDeveloperShotwell" action="RawDeveloperShotwell" />
26 <menuitem name="RawDeveloperCamera" action="RawDeveloperCamera" />16 <menuitem name="RawDeveloperCamera" action="RawDeveloperCamera" />

Subscribers

People subscribed via source and target branches

to all changes: