Commit 29f12273 authored by Jim Nelson's avatar Jim Nelson

#1358: Tags menu items reorganized, moving all to Tags menu. ...

#1358: Tags menu items reorganized, moving all to Tags menu.  Internationalizable plural extra credit included.
parent 5b0dbf5b
......@@ -790,8 +790,9 @@ public abstract class CollectionPage : CheckerboardPage {
set_item_sensitive("/CollectionMenuBar/EventsMenu/NewEvent", get_view().get_selected_count() > 0);
}
private void on_tags_menu() {
protected virtual void on_tags_menu() {
set_item_sensitive("/CollectionMenuBar/TagsMenu/NewTag", get_view().get_selected_count() > 0);
set_item_sensitive("/CollectionMenuBar/TagsMenu/SetTags", get_view().get_selected_count() == 1);
}
private void on_select_all() {
......@@ -826,7 +827,6 @@ public abstract class CollectionPage : CheckerboardPage {
}
protected virtual void on_photos_menu() {
bool one_selected = get_view().get_selected_count() == 1;
bool selected = (get_view().get_selected_count() > 0);
bool revert_possible = can_revert_selected();
......@@ -839,7 +839,6 @@ public abstract class CollectionPage : CheckerboardPage {
set_hide_item_sensitive("/CollectionMenuBar/PhotosMenu/HideUnhide", selected);
set_favorite_item_sensitive("/CollectionMenuBar/PhotosMenu/FavoriteUnfavorite", selected);
set_item_sensitive("/CollectionMenuBar/PhotosMenu/AdjustDateTime", selected);
set_item_sensitive("/CollectionMenuBar/PhotosMenu/SetTags", one_selected);
#if WINDOWS
set_item_sensitive("/CollectionMenuBar/PhotosMenu/ContextSetBackground", false);
......
......@@ -1102,10 +1102,12 @@ public class TagUntagPhotosCommand : SimpleProxyableCommand {
private Gee.Collection<LibraryPhoto> photos;
private bool attach;
public TagUntagPhotosCommand(Tag tag, Gee.Collection<LibraryPhoto> photos, bool attach) {
public TagUntagPhotosCommand(Tag tag, Gee.Collection<LibraryPhoto> photos, int count, bool attach) {
base (tag,
(attach ? Resources.TAG_PHOTOS_LABEL : Resources.UNTAG_PHOTOS_LABEL).printf(tag.get_name()),
attach ? Resources.TAG_PHOTOS_TOOLTIP : Resources.UNTAG_PHOTOS_TOOLTIP);
attach ? Resources.tag_photos_label(tag.get_name(), count)
: Resources.untag_photos_label(tag.get_name(), count),
attach ? Resources.tag_photos_tooltip(count)
: Resources.untag_photos_tooltip(count));
this.photos = photos;
this.attach = attach;
......
......@@ -748,7 +748,8 @@ public class LibraryWindow : AppWindow {
success = true;
}
} else if (page is TagPageStub) {
get_command_manager().execute(new TagUntagPhotosCommand(((TagPageStub) page).tag, photos, true));
get_command_manager().execute(new TagUntagPhotosCommand(((TagPageStub) page).tag, photos,
photos.size, true));
success = true;
} else if (path != null && path.compare(tags_marker.get_path()) == 0) {
NewTagDialog dialog = new NewTagDialog();
......
......@@ -221,7 +221,24 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
widget.sensitive = sensitive;
}
public void set_item_display(string path, string? label, string? tooltip, bool sensitive) {
Gtk.Action? action = ui.get_action(path);
if (action == null) {
critical("No action for UI element %s", path);
return;
}
if (label != null)
action.label = label;
if (tooltip != null)
action.tooltip = tooltip;
action.sensitive = sensitive;
}
private void get_modifiers(out bool ctrl, out bool alt, out bool shift) {
int x, y;
Gdk.ModifierType mask;
......
......@@ -158,7 +158,7 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public const string ADJUST_DATE_TIME_LABEL = _("Adjust Date and Time");
public const string ADJUST_DATE_TIME_TOOLTIP = _("Adjust date and time of selected photos");
public const string NEW_TAG_MENU = _("_New Tag...");
public const string NEW_TAG_MENU = _("New _Tag...");
public const string NEW_TAG_LABEL = _("New Tag \"%s\"");
public const string NEW_TAG_TITLE = _("New Tag");
public const string NEW_TAG_TOOLTIP = _("Create a new tag for the selected photos");
......@@ -168,7 +168,7 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public const string DELETE_TAG_TITLE = _("Delete Tag");
public const string DELETE_TAG_TOOLTIP = _("Remove the tag from all photos");
public const string RENAME_TAG_MENU = _("_Rename Tag...");
public const string RENAME_TAG_MENU = _("Re_name Tag...");
public const string RENAME_TAG_LABEL = _("Rename Tag \"%s\" to \"%s\"");
public const string RENAME_TAG_TITLE = _("Rename Tag");
public const string RENAME_TAG_TOOLTIP = _("Rename the tag");
......@@ -177,12 +177,27 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public const string SET_TAGS_LABEL = _("Set Tags");
public const string SET_TAGS_TOOLTIP = _("Tag photo with labels");
public const string TAG_PHOTOS_LABEL = _("Tag Photos as \"%s\"");
public const string TAG_PHOTOS_TOOLTIP = _("Tag the selected photos");
public string tag_photos_label(string name, int count) {
return ngettext("Tag Photo as \"%s\"", "Tag Photos as \"%s\"", count).printf(name);
}
public string tag_photos_tooltip(int count) {
return ngettext("Tag the selected photo", "Tag the selected photos", count);
}
public string untag_photos_menu(int count) {
return ngettext("_Remove Tag from Photo", "_Remove Tag from Photos", count);
}
public string untag_photos_label(string name, int count) {
return ngettext("Remove Tag \"%s\" from Photo", "Remove Tag \"%s\" from Photos", count).printf(
name);
}
public const string UNTAG_PHOTOS_MENU = _("Remove _Tag");
public const string UNTAG_PHOTOS_LABEL = _("Remove Tag \"%s\" from Photos");
public const string UNTAG_PHOTOS_TOOLTIP = _("Remove tag from the selected photos");
public string untag_photos_tooltip(int count) {
return ngettext("Remove tag from the selected photo", "Remove tag from the selected photos",
count);
}
private Gtk.IconFactory factory = null;
private Gee.HashMap<string, Gdk.Pixbuf> icon_cache = null;
......
......@@ -17,10 +17,8 @@ public class TagPage : CollectionPage {
init_page_context_menu("/TagsContextMenu");
ui.add_ui(ui.new_merge_id(), "/CollectionMenuBar/PhotosMenu/RemoveTagPlaceholder",
"RemoveTag", "RemoveTag", Gtk.UIManagerItemType.AUTO, false);
ui.add_ui(ui.new_merge_id(), "/CollectionContextMenu/ContextRemoveTagPlaceholder",
"ContextRemoveTag", "RemoveTag", Gtk.UIManagerItemType.AUTO, false);
ui.add_ui(ui.new_merge_id(), "/CollectionContextMenu/ContextTagsPlaceholder",
"ContextRemoveTagFromPhotos", "RemoveTagFromPhotos", Gtk.UIManagerItemType.AUTO, false);
}
~TagPage() {
......@@ -52,9 +50,9 @@ public class TagPage : CollectionPage {
rename_tag.tooltip = Resources.RENAME_TAG_TOOLTIP;
actions += rename_tag;
Gtk.ActionEntry remove_tag = { "RemoveTag", null, TRANSLATABLE, null, null, on_remove_tag };
remove_tag.label = Resources.UNTAG_PHOTOS_MENU;
remove_tag.tooltip = Resources.UNTAG_PHOTOS_TOOLTIP;
Gtk.ActionEntry remove_tag = { "RemoveTagFromPhotos", null, TRANSLATABLE, null, null,
on_remove_tag_from_photos };
// label and tooltip are assigned when the menu is displayed
actions += remove_tag;
return actions;
......@@ -64,16 +62,24 @@ public class TagPage : CollectionPage {
set_page_name(tag.get_name());
}
protected override void on_photos_menu() {
set_item_sensitive("/CollectionMenuBar/PhotosMenu/RemoveTagPlaceholder/RemoveTag",
get_view().get_selected_count() > 0);
protected override void on_tags_menu() {
int selected_count = get_view().get_selected_count();
base.on_photos_menu();
set_item_display("/CollectionMenuBar/TagsMenu/RemoveTagFromPhotos",
Resources.untag_photos_menu(selected_count),
Resources.untag_photos_tooltip(selected_count),
selected_count > 0);
base.on_tags_menu();
}
protected override bool on_context_invoked() {
set_item_sensitive("/CollectionContextMenu/ContextRemoveTagPlaceholder/ContextRemoveTag",
get_view().get_selected_count() > 0);
int selected_count = get_view().get_selected_count();
set_item_display("/CollectionContextMenu/ContextTagsPlaceholder/ContextRemoveTagFromPhotos",
Resources.untag_photos_menu(selected_count),
Resources.untag_photos_tooltip(selected_count),
selected_count > 0);
return base.on_context_invoked();
}
......@@ -98,10 +104,11 @@ public class TagPage : CollectionPage {
get_command_manager().execute(new DeleteTagCommand(tag));
}
private void on_remove_tag() {
private void on_remove_tag_from_photos() {
if (get_view().get_selected_count() > 0) {
get_command_manager().execute(new TagUntagPhotosCommand(tag,
(Gee.Collection<LibraryPhoto>) get_view().get_selected_sources(), false));
(Gee.Collection<LibraryPhoto>) get_view().get_selected_sources(),
get_view().get_selected_count(), false));
}
}
}
......
......@@ -59,8 +59,6 @@
<menuitem name="Enhance" action="Enhance" />
<menuitem name="Revert" action="Revert" />
<separator />
<menuitem name="SetTags" action="SetTags" />
<placeholder name="RemoveTagPlaceholder" />
<menuitem name="FavoriteUnfavorite" action="FavoriteUnfavorite" />
<menuitem name="HideUnhide" action="HideUnhide" />
<separator />
......@@ -77,6 +75,7 @@
<menu name="TagsMenu" action="TagsMenu">
<menuitem name="NewTag" action="NewTag" />
<menuitem name="SetTags" action="SetTags" />
</menu>
<menu name="HelpMenu" action="HelpMenu">
......@@ -95,7 +94,7 @@
<separator />
<menuitem name="ContextNewTag" action="NewTag" />
<menuitem name="ContextSetTags" action="SetTags" />
<placeholder name="ContextRemoveTagPlaceholder" />
<placeholder name="ContextTagsPlaceholder" />
<separator />
<menuitem name="ContextFavoriteUnfavorite" action="FavoriteUnfavorite" />
<menuitem name="ContextHideUnhide" action="HideUnhide" />
......
......@@ -2,6 +2,8 @@
<menubar name="CollectionMenuBar">
<menu name="TagsMenu" action="TagsMenu">
<menuitem name="RemoveTagFromPhotos" action="RemoveTagFromPhotos" />
<separator />
<menuitem name="RenameTag" action="RenameTag" />
<menuitem name="DeleteTag" action="DeleteTag" />
</menu>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment