Commit 30102cc2 authored by Jim Nelson's avatar Jim Nelson

#3148: Moved AlienDb/F-Spot import menu actions into LibraryWindow as a common action.

parent 40dde946
......@@ -702,7 +702,7 @@ public abstract class AppWindow : PageWindow {
sys_show_uri(window.get_screen(), url);
}
public virtual void add_common_actions(Gtk.ActionGroup action_group) {
public virtual void add_common_actions(Page page, Gtk.ActionGroup action_group) {
action_group.add_actions(create_actions(), this);
}
......
......@@ -91,7 +91,7 @@ public abstract class CollectionPage : MediaPage {
}
private static InjectionGroup create_file_menu_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/FileMenu/FileExtrasPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/FileMenu/FileExtrasPlaceholder");
group.add_menu_item("Print");
group.add_separator();
......@@ -103,7 +103,7 @@ public abstract class CollectionPage : MediaPage {
}
private static InjectionGroup create_edit_menu_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/EditMenu/EditExtrasPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/EditMenu/EditExtrasPlaceholder");
group.add_menu_item("Duplicate");
......@@ -111,7 +111,7 @@ public abstract class CollectionPage : MediaPage {
}
private static InjectionGroup create_view_menu_fullscreen_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/ViewMenu/ViewExtrasFullscreenSlideshowPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/ViewMenu/ViewExtrasFullscreenSlideshowPlaceholder");
group.add_menu_item("Fullscreen", "CommonFullscreen");
group.add_separator();
......@@ -121,7 +121,7 @@ public abstract class CollectionPage : MediaPage {
}
private static InjectionGroup create_photos_menu_edits_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/PhotosMenu/PhotosExtrasEditsPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/PhotosMenu/PhotosExtrasEditsPlaceholder");
group.add_menu_item("RotateClockwise");
group.add_menu_item("RotateCounterclockwise");
......@@ -135,7 +135,7 @@ public abstract class CollectionPage : MediaPage {
}
private static InjectionGroup create_photos_menu_date_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/PhotosMenu/PhotosExtrasDateTimePlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/PhotosMenu/PhotosExtrasDateTimePlaceholder");
group.add_menu_item("AdjustDateTime");
......@@ -143,7 +143,7 @@ public abstract class CollectionPage : MediaPage {
}
private static InjectionGroup create_photos_menu_externals_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/PhotosMenu/PhotosExtrasExternalsPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/PhotosMenu/PhotosExtrasExternalsPlaceholder");
group.add_menu_item("ExternalEdit");
group.add_menu_item("ExternalEditRAW");
......
......@@ -163,11 +163,6 @@ public class EventsDirectoryPage : CheckerboardPage {
get_view().set_comparator(get_event_comparator(), event_comparator_predicate);
get_view().monitor_source_collection(Event.global, view_manager, null, initial_events);
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/EventsDirectoryMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
init_item_context_menu("/EventsDirectoryContextMenu");
this.view_manager = view_manager;
......@@ -182,10 +177,6 @@ public class EventsDirectoryPage : CheckerboardPage {
toolbar.insert(merge_button, -1);
}
protected override string? get_menubar_path() {
return "/EventsDirectoryMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
ui_filenames.add("events_directory.ui");
......@@ -368,11 +359,6 @@ public class NoEventPage : CollectionPage {
private NoEventPage() {
base(NO_EVENT_PAGE_NAME);
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/EventsDirectoryMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
ViewManager filter = new NoEventViewManager(this);
get_view().monitor_source_collection(LibraryPhoto.global, filter, no_event_page_alteration);
get_view().monitor_source_collection(Video.global, filter, no_event_page_alteration);
......@@ -422,11 +408,6 @@ public class EventPage : CollectionPage {
private EventPage(Event page_event) {
base (page_event.get_name());
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/EventsDirectoryMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
this.page_event = page_event;
page_event.mirror_photos(get_view(), create_thumbnail);
......
......@@ -507,10 +507,6 @@ public class ImportPage : CheckerboardPage {
LibraryPhoto.global.contents_altered.connect(on_media_added_removed);
Video.global.contents_altered.connect(on_media_added_removed);
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/ImportMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
init_item_context_menu("/ImportContextMenu");
init_page_context_menu("/ImportContextMenu");
......@@ -582,10 +578,6 @@ public class ImportPage : CheckerboardPage {
return ((CameraImportJob *) a)->get_exposure_time() - ((CameraImportJob *) b)->get_exposure_time();
}
protected override string? get_menubar_path() {
return "/ImportMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
......@@ -1352,11 +1344,6 @@ public class ImportQueuePage : SinglePhotoPage {
public ImportQueuePage() {
base(_("Importing..."), false);
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/ImportQueueMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
// Set up toolbar
Gtk.Toolbar toolbar = get_toolbar();
......@@ -1380,10 +1367,6 @@ public class ImportQueuePage : SinglePhotoPage {
toolbar.insert(progress_item, -1);
}
protected override string? get_menubar_path() {
return "/ImportQueueMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
ui_filenames.add("import_queue.ui");
......
......@@ -491,13 +491,18 @@ public class LibraryWindow : AppWindow {
return false;
}
public override void add_common_actions(Gtk.ActionGroup action_group) {
base.add_common_actions(action_group);
public override void add_common_actions(Page page, Gtk.ActionGroup action_group) {
base.add_common_actions(page, action_group);
action_group.add_actions(create_actions(), this);
action_group.add_toggle_actions(create_toggle_actions(), this);
action_group.add_radio_actions(create_order_actions(),
SORT_EVENTS_ORDER_ASCENDING, on_events_sort_changed);
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
page.ui, "/MenuBar/FileMenu/CommonImportFromAlienDbPlaceholder"
);
}
public override string get_app_role() {
......
......@@ -531,11 +531,6 @@ public abstract class MediaPage : CheckerboardPage {
public MediaPage(string page_name) {
base (page_name);
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/MediaMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
get_view().set_comparator(get_sort_comparator(), get_sort_comparator_predicate());
get_view().items_altered.connect(on_media_altered);
......@@ -573,10 +568,6 @@ public abstract class MediaPage : CheckerboardPage {
return new_scale.clamp(Thumbnail.MIN_SCALE, Thumbnail.MAX_SCALE);
}
protected override string? get_menubar_path() {
return "/MediaMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
......@@ -1063,7 +1054,7 @@ public abstract class MediaPage : CheckerboardPage {
protected RatingFilter get_filter_criteria() {
// any member of the group knows the current value
Gtk.RadioAction action = (Gtk.RadioAction) ui.get_action(
"/MediaMenuBar/ViewMenu/FilterPhotos/DisplayRejectedOrHigher");
"/MenuBar/ViewMenu/FilterPhotos/DisplayRejectedOrHigher");
assert(action != null);
RatingFilter filter = (RatingFilter) action.get_current_value();
......@@ -1471,7 +1462,7 @@ public abstract class MediaPage : CheckerboardPage {
protected int get_sort_criteria() {
// any member of the group knows the current value
Gtk.RadioAction action = (Gtk.RadioAction) ui.get_action(
"/MediaMenuBar/ViewMenu/SortPhotos/SortByTitle");
"/MenuBar/ViewMenu/SortPhotos/SortByTitle");
assert(action != null);
int value = action.get_current_value();
......@@ -1482,7 +1473,7 @@ public abstract class MediaPage : CheckerboardPage {
protected int get_sort_order() {
// any member of the group knows the current value
Gtk.RadioAction action = (Gtk.RadioAction) ui.get_action(
"/MediaMenuBar/ViewMenu/SortPhotos/SortAscending");
"/MenuBar/ViewMenu/SortPhotos/SortAscending");
assert(action != null);
int value = action.get_current_value();
......@@ -1538,13 +1529,13 @@ public abstract class MediaPage : CheckerboardPage {
protected string get_sortby_path(int sort_by) {
switch(sort_by) {
case SortBy.TITLE:
return "/MediaMenuBar/ViewMenu/SortPhotos/SortByTitle";
return "/MenuBar/ViewMenu/SortPhotos/SortByTitle";
case SortBy.EXPOSURE_DATE:
return "/MediaMenuBar/ViewMenu/SortPhotos/SortByExposureDate";
return "/MenuBar/ViewMenu/SortPhotos/SortByExposureDate";
case SortBy.RATING:
return "/MediaMenuBar/ViewMenu/SortPhotos/SortByRating";
return "/MenuBar/ViewMenu/SortPhotos/SortByRating";
default:
error("Unknown sort criteria: %d", sort_by);
......@@ -1567,7 +1558,7 @@ public abstract class MediaPage : CheckerboardPage {
}
Gtk.RadioAction ascending_action =
(Gtk.RadioAction) ui.get_action("/MediaMenuBar/ViewMenu/SortPhotos/SortAscending");
(Gtk.RadioAction) ui.get_action("/MenuBar/ViewMenu/SortPhotos/SortAscending");
int sort_order_int = sort_order ? SORT_ORDER_ASCENDING : SORT_ORDER_DESCENDING;
if (ascending_action != null && ascending_action.get_current_value() != sort_order_int) {
......
......@@ -34,11 +34,6 @@ public class OfflinePage : CheckerboardPage {
base (name);
init_item_context_menu("/OfflineContextMenu");
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/OfflineMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
Gtk.Toolbar toolbar = get_toolbar();
......@@ -61,10 +56,6 @@ public class OfflinePage : CheckerboardPage {
Video.global.offline_contents_altered.disconnect(on_offline_contents_altered);
}
protected override string? get_menubar_path() {
return "/OfflineMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
......
......@@ -327,9 +327,10 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
}
public virtual Gtk.MenuBar get_menubar() {
assert(get_menubar_path() != null);
Gtk.MenuBar? menubar = ui.get_widget("/MenuBar") as Gtk.MenuBar;
assert(menubar != null);
return (Gtk.MenuBar) ui.get_widget(get_menubar_path());
return menubar;
}
public virtual Gtk.Toolbar get_toolbar() {
......@@ -536,7 +537,7 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
common_action_group = new Gtk.ActionGroup("CommonActionGroup");
// Add common actions to the Page's common ActionGroup
AppWindow.get_instance().add_common_actions(common_action_group);
AppWindow.get_instance().add_common_actions(this, common_action_group);
// Add both ActionGroups to the UIManager
ui.insert_action_group(action_group, 0);
......@@ -592,11 +593,6 @@ public abstract class Page : Gtk.ScrolledWindow, SidebarPage {
protected virtual void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
}
// This is called during construction for the menubar path to use for the menubar widget
protected virtual string? get_menubar_path() {
return null;
}
// This is called during init_ui() to collect all Gtk.ActionEntries for the page.
protected virtual Gtk.ActionEntry[] init_collect_action_entries() {
return new Gtk.ActionEntry[0];
......
......@@ -2133,11 +2133,6 @@ public class LibraryPhotoPage : EditingHostPage {
public LibraryPhotoPage() {
base(LibraryPhoto.global, "Photo");
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/PhotoMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
context_menu = (Gtk.Menu) ui.get_widget("/PhotoContextMenu");
// monitor view to update UI elements
......@@ -2174,10 +2169,6 @@ public class LibraryPhotoPage : EditingHostPage {
filter.refresh();
}
protected override string? get_menubar_path() {
return "/PhotoMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
......@@ -2476,17 +2467,17 @@ public class LibraryPhotoPage : EditingHostPage {
protected override InjectionGroup[] init_collect_injection_groups() {
InjectionGroup[] groups = base.init_collect_injection_groups();
InjectionGroup print_group = new InjectionGroup("/PhotoMenuBar/FileMenu/PrintPlaceholder");
InjectionGroup print_group = new InjectionGroup("/MenuBar/FileMenu/PrintPlaceholder");
print_group.add_menu_item("Print");
groups += print_group;
InjectionGroup publish_group = new InjectionGroup("/PhotoMenuBar/FileMenu/PublishPlaceholder");
InjectionGroup publish_group = new InjectionGroup("/MenuBar/FileMenu/PublishPlaceholder");
publish_group.add_menu_item("Publish");
groups += publish_group;
InjectionGroup bg_group = new InjectionGroup("/PhotoMenuBar/FileMenu/SetBackgroundPlaceholder");
InjectionGroup bg_group = new InjectionGroup("/MenuBar/FileMenu/SetBackgroundPlaceholder");
bg_group.add_menu_item("SetBackground");
groups += bg_group;
......@@ -3286,10 +3277,6 @@ public class DirectPhotoPage : EditingHostPage {
DirectPhoto.global.items_altered.disconnect(on_photos_altered);
}
protected override string? get_menubar_path() {
return "/DirectMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
......@@ -3461,12 +3448,12 @@ public class DirectPhotoPage : EditingHostPage {
protected override InjectionGroup[] init_collect_injection_groups() {
InjectionGroup[] groups = base.init_collect_injection_groups();
InjectionGroup print_group = new InjectionGroup("/DirectMenuBar/FileMenu/PrintPlaceholder");
InjectionGroup print_group = new InjectionGroup("/MenuBar/FileMenu/PrintPlaceholder");
print_group.add_menu_item("Print");
groups += print_group;
InjectionGroup bg_group = new InjectionGroup("/DirectMenuBar/FileMenu/SetBackgroundPlaceholder");
InjectionGroup bg_group = new InjectionGroup("/MenuBar/FileMenu/SetBackgroundPlaceholder");
bg_group.add_menu_item("SetBackground");
groups += bg_group;
......
......@@ -42,11 +42,6 @@ public class TrashPage : CheckerboardPage {
init_item_context_menu("/TrashContextMenu");
init_page_context_menu("/TrashPageMenu");
// Adds one menu entry per alien database driver
AlienDb.AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/TrashMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
);
Gtk.Toolbar toolbar = get_toolbar();
// delete button
......@@ -74,10 +69,6 @@ public class TrashPage : CheckerboardPage {
on_trashcan_contents_altered(Video.global.get_trashcan_contents(), null);
}
protected override string? get_menubar_path() {
return "/TrashMenuBar";
}
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
......
......@@ -95,7 +95,7 @@ public class VideosPage : MediaPage {
}
private static InjectionGroup create_file_menu_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/FileMenu/FileExtrasPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/FileMenu/FileExtrasPlaceholder");
group.add_separator();
group.add_menu_item("Publish");
......@@ -105,7 +105,7 @@ public class VideosPage : MediaPage {
}
private static InjectionGroup create_videos_menu_injectables() {
InjectionGroup group = new InjectionGroup("/MediaMenuBar/PhotosMenu/PhotosExtrasExternalsPlaceholder");
InjectionGroup group = new InjectionGroup("/MenuBar/PhotosMenu/PhotosExtrasExternalsPlaceholder");
group.add_menu_item("PlayVideo");
......
<ui>
<menubar name="DirectMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Save" action="Save" />
<menuitem name="SaveAs" action="SaveAs" />
......
<ui>
<menubar name="MediaMenuBar">
<menubar name="MenuBar">
<menu name="PhotosMenu" action="PhotosMenu">
<separator />
<menuitem name="MakePrimary" action="MakePrimary" />
......
<ui>
<menubar name="EventsDirectoryMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Import" action="CommonFileImport" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<separator />
<menuitem name="EmptyTrash" action="CommonEmptyTrash" />
<separator />
......
<ui>
<menubar name="ImportMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Import" action="CommonFileImport" />
<menuitem name="ImportSelected" action="ImportSelected" />
<menuitem name="ImportAll" action="ImportAll" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<separator />
<menuitem name="EmptyTrash" action="CommonEmptyTrash" />
<separator />
......
<ui>
<menubar name="ImportQueueMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Stop" action="Stop" />
<separator />
<menuitem name="Import" action="CommonFileImport" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<separator />
<menuitem name="EmptyTrash" action="CommonEmptyTrash" />
<separator />
......
<ui>
<menubar name="MediaMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Import" action="CommonFileImport" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<menuitem name="Export" action="Export" />
<separator />
<placeholder name="FileExtrasPlaceholder" />
......
<ui>
<menubar name="OfflineMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Import" action="CommonFileImport" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<separator />
<menuitem name="EmptyTrash" action="CommonEmptyTrash" />
<separator />
......
<ui>
<menubar name="PhotoMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Import" action="CommonFileImport" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<menuitem name="Export" action="Export" />
<separator />
<placeholder name="PrintPlaceholder" />
......
<ui>
<menubar name="MediaMenuBar">
<menubar name="MenuBar">
<menu name="TagsMenu" action="TagsMenu">
<menuitem name="RemoveTagFromPhotos" action="RemoveTagFromPhotos" />
<separator />
......
<ui>
<menubar name="TrashMenuBar">
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Import" action="CommonFileImport" />
<placeholder name="ImportFromAlienDbPlaceholder" />
<placeholder name="CommonImportFromAlienDbPlaceholder" />
<separator />
<menuitem name="JumpToFile" action="CommonJumpToFile" />
<menuitem name="EmptyTrash" action="CommonEmptyTrash" />
......
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