Commit c2e10190 authored by Jim Nelson's avatar Jim Nelson

#1560: Switched to using Gtk.Actions entirely in our Page code. I've also...

#1560: Switched to using Gtk.Actions entirely in our Page code.  I've also restructured how Actions are registered with the UI Manager to deal better with multi-tiered class heirarchies (with MediaPage, we now have three-deep Page classes with Actions that must be registered).  I've also made it easier to update the Actions when ViewCollection state changes and pushed more common Action code (i.e. Undo/Redo) into LibraryWindow.
parent 60d524b3
......@@ -453,6 +453,7 @@ public abstract class AppWindow : PageWindow {
assert(command_manager == null);
command_manager = new CommandManager();
command_manager.altered.connect(on_command_manager_altered);
}
private Gtk.ActionEntry[] create_actions() {
......@@ -726,63 +727,97 @@ public abstract class AppWindow : PageWindow {
present();
}
public bool set_common_action_sensitive(string name, bool sensitive) {
public Gtk.Action? get_common_action(string name) {
Page? page = get_current_page();
if (page == null) {
warning("No page to set action %s", name);
return false;
return null;
}
Gtk.Action? action = page.common_action_group.get_action(name);
if (action == null) {
warning("Page %s: No action %s", page.get_page_name(), name);
return page.get_common_action(name);
}
public void set_common_action_sensitive(string name, bool sensitive) {
Page? page = get_current_page();
if (page == null) {
warning("No page to set action %s", name);
return false;
return;
}
action.sensitive = sensitive;
return true;
page.set_common_action_sensitive(name, sensitive);
}
protected override void switched_pages(Page? old_page, Page? new_page) {
if (old_page != null) {
old_page.get_view().contents_altered.disconnect(on_contents_altered);
old_page.get_view().selection_group_altered.disconnect(on_selection_group_altered);
old_page.get_view().items_state_changed.disconnect(on_items_altered);
old_page.get_view().contents_altered.disconnect(on_update_actions);
old_page.get_view().selection_group_altered.disconnect(on_update_actions);
old_page.get_view().items_state_changed.disconnect(on_update_actions);
}
if (new_page != null) {
new_page.get_view().contents_altered.connect(on_contents_altered);
new_page.get_view().selection_group_altered.connect(on_selection_group_altered);
new_page.get_view().items_state_changed.connect(on_items_altered);
new_page.get_view().contents_altered.connect(on_update_actions);
new_page.get_view().selection_group_altered.connect(on_update_actions);
new_page.get_view().items_state_changed.connect(on_update_actions);
set_common_action_sensitive("CommonSelectAll", new_page.get_view().get_count() > 0);
set_common_action_sensitive("CommonJumpToFile",
new_page.get_view().get_selected_count() == 1);
update_actions(new_page.get_view().get_selected_count(), new_page.get_view().get_count());
}
base.switched_pages(old_page, new_page);
}
private void on_contents_altered() {
set_common_action_sensitive("CommonSelectAll", get_current_page().get_view().get_count() > 0);
// This is a counterpart to Page.update_actions(), but for common Gtk.Actions
protected virtual void update_actions(int selected_count, int count) {
set_common_action_sensitive("CommonSelectAll", count > 0);
set_common_action_sensitive("CommonJumpToFile", selected_count == 1);
set_common_action_sensitive("CommonFullscreen", count > 0);
decorate_undo_action();
decorate_redo_action();
}
private void on_selection_group_altered() {
set_common_action_sensitive("CommonSelectAll", get_current_page().get_view().get_count() > 0);
private void on_update_actions() {
Page? page = get_current_page();
if (page != null)
update_actions(page.get_view().get_selected_count(), page.get_view().get_count());
}
private void on_items_altered() {
set_common_action_sensitive("CommonJumpToFile",
get_current_page().get_view().get_selected_count() == 1);
}
public static CommandManager get_command_manager() {
return command_manager;
}
private void on_command_manager_altered() {
decorate_undo_action();
decorate_redo_action();
}
private void decorate_command_manager_action(string name, string prefix,
string default_explanation, CommandDescription? desc) {
Gtk.Action? action = get_common_action(name);
if (action == null)
return;
if (desc != null) {
action.label = "%s %s".printf(prefix, desc.get_name());
action.tooltip = desc.get_explanation();
action.sensitive = true;
} else {
action.label = prefix;
action.tooltip = default_explanation;
action.sensitive = false;
}
}
public void decorate_undo_action() {
decorate_command_manager_action("CommonUndo", Resources.UNDO_MENU, Resources.UNDO_TOOLTIP,
get_command_manager().get_undo_description());
}
public void decorate_redo_action() {
decorate_command_manager_action("CommonRedo", Resources.REDO_MENU, Resources.REDO_TOOLTIP,
get_command_manager().get_redo_description());
}
private void on_undo() {
command_manager.undo();
}
......
This diff is collapsed.
......@@ -144,20 +144,16 @@ public class EventsDirectoryPage : CheckerboardPage {
private const int MIN_PHOTOS_FOR_PROGRESS_WINDOW = 50;
private Gtk.ToolButton merge_button;
protected ViewManager view_manager;
public EventsDirectoryPage(string page_name, ViewManager view_manager,
public EventsDirectoryPage(string page_name, ViewManager view_manager,
Gee.Iterable<Event>? initial_events) {
base(page_name);
base (page_name);
// set comparator before monitoring source collection, to prevent a re-sort
get_view().set_comparator(get_event_comparator(), event_comparator_predicate);
get_view().monitor_source_collection(Event.global, view_manager, null, initial_events);
init_ui_start("events_directory.ui", "EventsDirectoryActionGroup", create_actions());
init_ui_bind("/EventsDirectoryMenuBar");
// Adds one menu entry per alien database driver
AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/EventsDirectoryMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
......@@ -171,21 +167,22 @@ public class EventsDirectoryPage : CheckerboardPage {
Gtk.Toolbar toolbar = get_toolbar();
// merge tool
merge_button = new Gtk.ToolButton.from_stock(Resources.MERGE);
merge_button.set_label(Resources.MERGE_LABEL);
merge_button.set_tooltip_text(Resources.MERGE_TOOLTIP);
merge_button.clicked.connect(on_merge);
merge_button.sensitive = (get_view().get_selected_count() > 1);
merge_button.is_important = true;
Gtk.ToolButton merge_button = new Gtk.ToolButton.from_stock(Resources.MERGE);
merge_button.set_related_action(action_group.get_action("Merge"));
toolbar.insert(merge_button, -1);
get_view().items_state_changed.connect(on_selection_changed);
}
~EventsDirectoryPage() {
get_view().items_state_changed.disconnect(on_selection_changed);
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");
base.init_collect_ui_filenames(ui_filenames);
}
private static int64 event_ascending_comparator(void *a, void *b) {
time_t start_a = ((EventDirectoryItem *) a)->event.get_start_time();
time_t start_b = ((EventDirectoryItem *) b)->event.get_start_time();
......@@ -208,18 +205,14 @@ public class EventsDirectoryPage : CheckerboardPage {
return event_descending_comparator;
}
private void on_selection_changed() {
merge_button.sensitive = (get_view().get_selected_count() > 1);
}
private Gtk.ActionEntry[] create_actions() {
Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
protected override Gtk.ActionEntry[] init_collect_action_entries() {
Gtk.ActionEntry[] actions = base.init_collect_action_entries();
Gtk.ActionEntry file = { "FileMenu", null, TRANSLATABLE, null, null, null };
file.label = _("_File");
actions += file;
Gtk.ActionEntry view = { "ViewMenu", null, TRANSLATABLE, null, null, on_view_menu };
Gtk.ActionEntry view = { "ViewMenu", null, TRANSLATABLE, null, null, null };
view.label = _("_View");
actions += view;
......@@ -227,11 +220,11 @@ public class EventsDirectoryPage : CheckerboardPage {
help.label = _("_Help");
actions += help;
Gtk.ActionEntry edit = { "EditMenu", null, TRANSLATABLE, null, null, on_edit_menu };
Gtk.ActionEntry edit = { "EditMenu", null, TRANSLATABLE, null, null, null };
edit.label = _("_Edit");
actions += edit;
Gtk.ActionEntry event = { "EventsMenu", null, TRANSLATABLE, null, null, on_events_menu };
Gtk.ActionEntry event = { "EventsMenu", null, TRANSLATABLE, null, null, null };
event.label = _("Even_ts");
actions += event;
......@@ -249,21 +242,20 @@ public class EventsDirectoryPage : CheckerboardPage {
return actions;
}
protected override void update_actions(int selected_count, int count) {
set_action_sensitive("Merge", selected_count > 1);
set_action_important("Merge", true);
set_action_sensitive("Rename", selected_count == 1);
base.update_actions(selected_count, count);
}
public override void on_item_activated(CheckerboardItem item, CheckerboardPage.Activator
activator, CheckerboardPage.KeyboardModifiers modifiers) {
EventDirectoryItem event = (EventDirectoryItem) item;
LibraryWindow.get_app().switch_to_event(event.event);
}
protected override bool on_context_invoked() {
set_item_sensitive("/EventsDirectoryContextMenu/ContextRename",
get_view().get_selected_count() == 1);
set_item_sensitive("/EventsDirectoryContextMenu/ContextMerge",
get_view().get_selected_count() > 1);
return base.on_context_invoked();
}
private EventDirectoryItem? get_fullscreen_item() {
// use first selected item, otherwise use first item
if (get_view().get_selected_count() > 0)
......@@ -291,22 +283,6 @@ public class EventsDirectoryPage : CheckerboardPage {
get_view().set_comparator(get_event_comparator(), event_comparator_predicate);
}
private void on_view_menu() {
set_item_sensitive("/EventsDirectoryMenuBar/ViewMenu/Fullscreen", get_view().get_count() > 0);
}
private void on_edit_menu() {
decorate_undo_item("/EventsDirectoryMenuBar/EditMenu/Undo");
decorate_redo_item("/EventsDirectoryMenuBar/EditMenu/Redo");
}
private void on_events_menu() {
set_item_sensitive("/EventsDirectoryMenuBar/EventsMenu/EventMerge",
get_view().get_selected_count() > 1);
set_item_sensitive("/EventsDirectoryMenuBar/EventsMenu/EventRename",
get_view().get_selected_count() == 1);
}
private void on_rename() {
// only rename one at a time
if (get_view().get_selected_count() != 1)
......@@ -422,7 +398,7 @@ public class EventPage : CollectionPage {
public Event page_event;
private EventPage(Event page_event) {
base(page_event.get_name(), "event.ui", create_actions());
base (page_event.get_name());
// Adds one menu entry per alien database driver
AlienDatabaseHandler.get_instance().add_menu_entries(
......@@ -435,8 +411,7 @@ public class EventPage : CollectionPage {
init_page_context_menu("/EventContextMenu");
// hide this command in CollectionPage, as it does not apply here
set_item_hidden("/MediaMenuBar/MenubarExtrasPlaceholder/EventsMenu/JumpToEvent");
set_item_hidden("/CollectionContextMenu/ContextJumpToEvent");
set_action_visible("JumpToEvent", false);
Event.global.items_altered.connect(on_events_altered);
}
......@@ -446,11 +421,17 @@ public class EventPage : CollectionPage {
get_view().halt_mirroring();
}
private static Gtk.ActionEntry[] create_actions() {
Gtk.ActionEntry[] new_actions = new Gtk.ActionEntry[0];
protected override void init_collect_ui_filenames(Gee.List<string> ui_filenames) {
base.init_collect_ui_filenames(ui_filenames);
ui_filenames.add("event.ui");
}
protected override Gtk.ActionEntry[] init_collect_action_entries() {
Gtk.ActionEntry[] new_actions = base.init_collect_action_entries();
Gtk.ActionEntry make_primary = { "MakePrimary", Resources.MAKE_PRIMARY,
TRANSLATABLE, null, null, on_make_primary };
TRANSLATABLE, null, TRANSLATABLE, on_make_primary };
make_primary.label = Resources.MAKE_KEY_PHOTO_MENU;
make_primary.tooltip = Resources.MAKE_KEY_PHOTO_TOOLTIP;
new_actions += make_primary;
......@@ -463,6 +444,12 @@ public class EventPage : CollectionPage {
return new_actions;
}
protected override void update_actions(int selected_count, int count) {
set_action_sensitive("MakePrimary", selected_count == 1);
base.update_actions(selected_count, count);
}
public static Stub create_stub(Event event) {
return new Stub(event);
}
......@@ -480,27 +467,11 @@ public class EventPage : CollectionPage {
set_page_name(page_event.get_name());
}
protected override void on_photos_menu() {
set_item_sensitive("/MediaMenuBar/PhotosMenu/MakePrimary",
get_view().get_selected_count() == 1);
base.on_photos_menu();
}
protected override bool on_context_invoked() {
set_item_sensitive("/CollectionContextMenu/ContextMakePrimary",
get_view().get_selected_count() == 1);
return base.on_context_invoked();
}
private void on_make_primary() {
if (get_view().get_selected_count() == 0)
if (get_view().get_selected_count() != 1)
return;
// use first one
DataView view = get_view().get_selected_at(0);
page_event.set_primary_photo(((Thumbnail) view).get_photo());
page_event.set_primary_photo((LibraryPhoto) get_view().get_selected_at(0).get_source());
}
private void on_rename() {
......
......@@ -390,8 +390,6 @@ public class ImportPage : CheckerboardPage {
private SourceCollection import_sources = null;
private Gtk.Label camera_label = new Gtk.Label(null);
private Gtk.CheckButton hide_imported;
private Gtk.ToolButton import_selected_button;
private Gtk.ToolButton import_all_button;
private Gtk.ProgressBar progress_bar = new Gtk.ProgressBar();
private GPhoto.Camera camera;
private string uri;
......@@ -443,8 +441,6 @@ public class ImportPage : CheckerboardPage {
// monitor Photos for removals, at that will change the result of the ViewFilter
LibraryPhoto.global.contents_altered.connect(on_photos_added_removed);
init_ui("import.ui", "/ImportMenuBar", "ImportActionGroup", create_actions(),
create_toggle_actions());
// Adds one menu entry per alien database driver
AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/ImportMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
......@@ -481,21 +477,13 @@ public class ImportPage : CheckerboardPage {
toolbar.insert(progress_item, -1);
import_selected_button = new Gtk.ToolButton.from_stock(Resources.IMPORT);
import_selected_button.set_label(_("Import Selected"));
import_selected_button.set_tooltip_text(_("Import the selected photos into your library"));
import_selected_button.clicked.connect(on_import_selected);
import_selected_button.is_important = true;
import_selected_button.sensitive = false;
Gtk.ToolButton import_selected_button = new Gtk.ToolButton.from_stock(Resources.IMPORT);
import_selected_button.set_related_action(action_group.get_action("ImportSelected"));
toolbar.insert(import_selected_button, -1);
import_all_button = new Gtk.ToolButton.from_stock(Resources.IMPORT_ALL);
import_all_button.set_label(_("Import All"));
import_all_button.set_tooltip_text(_("Import all the photos on this camera into your library"));
import_all_button.clicked.connect(on_import_all);
import_all_button.sensitive = false;
import_all_button.is_important = true;
Gtk.ToolButton import_all_button = new Gtk.ToolButton.from_stock(Resources.IMPORT_ALL);
import_all_button.set_related_action(action_group.get_action("ImportAll"));
toolbar.insert(import_all_button, -1);
......@@ -538,8 +526,18 @@ public class ImportPage : CheckerboardPage {
return ((CameraImportJob *) a)->get_exposure_time() - ((CameraImportJob *) b)->get_exposure_time();
}
private Gtk.ToggleActionEntry[] create_toggle_actions() {
Gtk.ToggleActionEntry[] toggle_actions = new Gtk.ToggleActionEntry[0];
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);
ui_filenames.add("import.ui");
}
protected override Gtk.ToggleActionEntry[] init_collect_toggle_action_entries() {
Gtk.ToggleActionEntry[] toggle_actions = base.init_collect_toggle_action_entries();
Gtk.ToggleActionEntry titles = { "ViewTitle", null, TRANSLATABLE, "<Ctrl><Shift>T",
TRANSLATABLE, on_display_titles, Config.get_instance().get_display_photo_titles() };
......@@ -550,24 +548,26 @@ public class ImportPage : CheckerboardPage {
return toggle_actions;
}
private Gtk.ActionEntry[] create_actions() {
Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
protected override Gtk.ActionEntry[] init_collect_action_entries() {
Gtk.ActionEntry[] actions = base.init_collect_action_entries();
Gtk.ActionEntry file = { "FileMenu", null, TRANSLATABLE, null, null, on_file_menu };
Gtk.ActionEntry file = { "FileMenu", null, TRANSLATABLE, null, null, null };
file.label = _("_File");
actions += file;
Gtk.ActionEntry import_selected = { "ImportSelected", Resources.IMPORT,
TRANSLATABLE, null, null, on_import_selected };
import_selected.label = _("Import _Selected");
import_selected.tooltip = _("Import the selected photos into your library");
actions += import_selected;
Gtk.ActionEntry import_all = { "ImportAll", Resources.IMPORT_ALL, TRANSLATABLE,
null, null, on_import_all };
import_all.label = _("Import _All");
import_all.tooltip = _("Import all the photos into your library");
actions += import_all;
Gtk.ActionEntry edit = { "EditMenu", null, TRANSLATABLE, null, null, on_edit_menu };
Gtk.ActionEntry edit = { "EditMenu", null, TRANSLATABLE, null, null, null };
edit.label = _("_Edit");
actions += edit;
......@@ -594,6 +594,15 @@ public class ImportPage : CheckerboardPage {
return busy;
}
protected override void init_actions(int selected_count, int count) {
on_view_changed();
set_action_important("ImportSelected", true);
set_action_important("ImportAll", true);
base.init_actions(selected_count, count);
}
public bool is_refreshed() {
return refreshed && !busy;
}
......@@ -611,10 +620,19 @@ public class ImportPage : CheckerboardPage {
return msg;
}
private void update_status(bool busy, bool refreshed) {
this.busy = busy;
this.refreshed = refreshed;
on_view_changed();
}
private void on_view_changed() {
set_action_sensitive("ImportSelected", !busy && refreshed && get_view().get_selected_count() > 0);
set_action_sensitive("ImportAll", !busy && refreshed && get_view().get_count() > 0);
hide_imported.sensitive = !busy && refreshed && (get_view().get_unfiltered_count() > 0);
import_selected_button.sensitive = !busy && refreshed && (get_view().get_selected_count() > 0);
import_all_button.sensitive = !busy && refreshed && (get_view().get_count() > 0);
AppWindow.get_instance().set_common_action_sensitive("CommonSelectAll",
!busy && (get_view().get_count() > 0));
}
private void on_photos_added_removed() {
......@@ -718,8 +736,7 @@ public class ImportPage : CheckerboardPage {
if (busy)
return false;
busy = true;
refreshed = false;
update_status(true, false);
progress_bar.visible = true;
progress_bar.set_fraction(0.0);
progress_bar.set_ellipsize(Pango.EllipsizeMode.NONE);
......@@ -749,7 +766,7 @@ public class ImportPage : CheckerboardPage {
// don't trap this signal, even if it does come in, we've backed off
mount.unmounted.disconnect(on_unmounted);
busy = false;
update_status(false, refreshed);
progress_bar.set_ellipsize(Pango.EllipsizeMode.NONE);
progress_bar.set_text("");
progress_bar.visible = false;
......@@ -759,7 +776,7 @@ public class ImportPage : CheckerboardPage {
private void on_unmounted(Mount mount) {
debug("on_unmounted");
busy = false;
update_status(false, refreshed);
progress_bar.set_ellipsize(Pango.EllipsizeMode.NONE);
progress_bar.set_text("");
progress_bar.visible = false;
......@@ -777,7 +794,7 @@ public class ImportPage : CheckerboardPage {
if (busy)
return RefreshResult.BUSY;
refreshed = false;
update_status(busy, false);
refresh_error = null;
refresh_result = camera.init(spin_idle_context.context);
......@@ -787,7 +804,7 @@ public class ImportPage : CheckerboardPage {
return (refresh_result == GPhoto.Result.IO_LOCK) ? RefreshResult.LOCKED : RefreshResult.LIBRARY_ERROR;
}
busy = true;
update_status(true, refreshed);
on_view_changed();
......@@ -823,12 +840,10 @@ public class ImportPage : CheckerboardPage {
warning("Unable to unlock camera: %s", res.to_full_string());
}
busy = false;
if (refresh_result == GPhoto.Result.OK) {
refreshed = true;
update_status(false, true);
} else {
refreshed = false;
update_status(false, false);
// show 'em all or show none
clear_all_import_sources();
......@@ -1091,12 +1106,6 @@ public class ImportPage : CheckerboardPage {
}
}
private void on_file_menu() {
set_item_sensitive("/ImportMenuBar/FileMenu/ImportSelected",
!busy && (get_view().get_selected_count() > 0));
set_item_sensitive("/ImportMenuBar/FileMenu/ImportAll", !busy && (get_view().get_count() > 0));
}
private bool show_unimported_filter(DataView view) {
return !((ImportPreview) view).is_already_imported();
}
......@@ -1116,11 +1125,6 @@ public class ImportPage : CheckerboardPage {
import(get_view().get_all());
}
private void on_edit_menu() {
AppWindow.get_instance().set_common_action_sensitive("CommonSelectAll",
!busy && (get_view().get_count() > 0));
}
private void import(Gee.Iterable<DataObject> items) {
GPhoto.Result res = camera.init(spin_idle_context.context);
if (res != GPhoto.Result.OK) {
......@@ -1129,7 +1133,7 @@ public class ImportPage : CheckerboardPage {
return;
}
busy = true;
update_status(true, refreshed);
on_view_changed();
progress_bar.visible = false;
......@@ -1245,7 +1249,7 @@ public class ImportPage : CheckerboardPage {
message("Unable to unlock camera: %s", res.to_full_string());
}
busy = false;
update_status(false, refreshed);
on_view_changed();
}
......@@ -1257,21 +1261,11 @@ public class ImportPage : CheckerboardPage {
if (action != null)
action.set_active(display);
}
public override bool on_context_invoked() {
set_item_sensitive("/ImportContextMenu/ContextImportSelected", !busy &&
get_view().get_selected_count() > 0);
set_item_sensitive("/ImportContextMenu/ContextImportAll", !busy &&
get_view().get_count() > 0);
return base.on_context_invoked();
}
}
#endif
public class ImportQueuePage : SinglePhotoPage {
private Gtk.ToolButton stop_button = null;
private Gee.ArrayList<BatchImport> queue = new Gee.ArrayList<BatchImport>();
private Gee.HashSet<BatchImport> cancel_unallowed = new Gee.HashSet<BatchImport>();
private BatchImport current_batch = null;
......@@ -1284,10 +1278,7 @@ public class ImportQueuePage : SinglePhotoPage {
public ImportQueuePage() {
base(_("Importing..."), false);
init_ui("import_queue.ui", "/ImportQueueMenuBar", "ImportQueueActionGroup",
create_actions());
// Adds one menu entry per alien database driver
AlienDatabaseHandler.get_instance().add_menu_entries(
ui, "/ImportQueueMenuBar/FileMenu/ImportFromAlienDbPlaceholder"
......@@ -1297,10 +1288,8 @@ public class ImportQueuePage : SinglePhotoPage {
Gtk.Toolbar toolbar = get_toolbar();
// Stop button
stop_button = new Gtk.ToolButton.from_stock(Gtk.STOCK_STOP);
stop_button.set_tooltip_text(_("Stop importing photos"));
stop_button.clicked.connect(on_stop);
stop_button.sensitive = false;
Gtk.ToolButton stop_button = new Gtk.ToolButton.from_stock(Gtk.STOCK_STOP);
stop_button.set_related_action(action_group.get_action("Stop"));
toolbar.insert(stop_button, -1);
......@@ -1317,11 +1306,21 @@ public class ImportQueuePage : SinglePhotoPage {
toolbar.insert(progress_item, -1);
}
private Gtk.ActionEntry[] create_actions() {
Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
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");
Gtk.ActionEntry file = { "FileMenu", null, TRANSLATABLE, null, null, on_file_menu };
base.init_collect_ui_filenames(ui_filenames);
}
protected override Gtk.ActionEntry[] init_collect_action_entries() {
Gtk.ActionEntry[] actions = base.init_collect_action_entries();
Gtk.ActionEntry file = { "FileMenu", null, TRANSLATABLE, null, null, null };
file.label = _("_File");
actions += file;
......@@ -1361,18 +1360,20 @@ public class ImportQueuePage : SinglePhotoPage {
if (queue.size == 1)
batch_import.schedule();
stop_button.sensitive = true;
update_stop_action();
}
public int get_batch_count() {
return queue.size;
}
private void on_file_menu() {
set_item_sensitive("/ImportQueueMenuBar/FileMenu/Stop", queue.size > 0);
private void update_stop_action() {
set_action_sensitive("Stop", !cancel_unallowed.contains(current_batch) && queue.size > 0);
}
private void on_stop() {
update_stop_action();
if (queue.size == 0)
return;
......@@ -1385,8 +1386,8 @@ public class ImportQueuePage : SinglePhotoPage {
}
private void on_starting(BatchImport batch_import) {
update_stop_action();
current_batch = batch_import;
stop_button.sensitive = !cancel_unallowed.contains(batch_import);
}
private void on_preparing() {
......@@ -1436,11 +1437,9 @@ public class ImportQueuePage : SinglePhotoPage {
// schedule next if available
if (queue.size > 0) {
stop_button.sensitive = true;
queue.get(0).schedule();
} else {
// reset UI
stop_button.sensitive = false;
progress_bar.set_ellipsize(Pango.EllipsizeMode.NONE);
progress_bar.set_text("");
progress_bar.set_fraction(0.0);
......@@ -1455,6 +1454,8 @@ public class ImportQueuePage : SinglePhotoPage {
stopped = false;
}
update_stop_action();
// report the batch has been removed from the queue after everything else is set
batch_removed(batch_import);
}
......
......@@ -116,7 +116,7 @@ public abstract class MediaPage : CheckerboardPage {
}
}
public void set_filter_icon(RatingFilter filter) {
public void set_filter_icon(RatingFilter filter) {
set_icon_widget(get_filter_icon(filter));
set_size_request(get_filter_button_size(filter), -1);
set_tooltip_text(Resources.get_rating_filter_tooltip(filter));
......@@ -169,7 +169,7 @@ public abstract class MediaPage : CheckerboardPage {