diff options
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/Branch.vala | 115 | ||||
| -rw-r--r-- | src/library/FlaggedPage.vala | 2 | ||||
| -rw-r--r-- | src/library/FlaggedSidebarEntry.vala (renamed from src/library/FlaggedBranch.vala) | 49 | ||||
| -rw-r--r-- | src/library/ImportQueuePage.vala | 7 | ||||
| -rw-r--r-- | src/library/ImportQueueSidebarEntry.vala (renamed from src/library/ImportQueueBranch.vala) | 58 | ||||
| -rw-r--r-- | src/library/LastImportPage.vala | 2 | ||||
| -rw-r--r-- | src/library/LastImportSidebarEntry.vala (renamed from src/library/LastImportBranch.vala) | 33 | ||||
| -rw-r--r-- | src/library/Library.vala | 2 | ||||
| -rw-r--r-- | src/library/LibraryWindow.vala | 82 | ||||
| -rw-r--r-- | src/library/OfflinePage.vala | 4 | ||||
| -rw-r--r-- | src/library/OfflineSidebarEntry.vala (renamed from src/library/OfflineBranch.vala) | 24 | ||||
| -rw-r--r-- | src/library/TrashPage.vala | 6 | ||||
| -rw-r--r-- | src/library/TrashSidebarEntry.vala (renamed from src/library/TrashBranch.vala) | 22 | ||||
| -rw-r--r-- | src/library/mk/library.mk | 10 | 
14 files changed, 213 insertions, 203 deletions
diff --git a/src/library/Branch.vala b/src/library/Branch.vala index dc05d60..0e875d2 100644 --- a/src/library/Branch.vala +++ b/src/library/Branch.vala @@ -1,31 +1,104 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution.   */ -public class Library.Branch : Sidebar.RootOnlyBranch { +public class Library.Branch : Sidebar.Branch { +    private const string POSITION_DATA = "x-photos-entry-position"; + +    public Library.PhotosEntry photos_entry { get; private set; } +    public Library.FlaggedSidebarEntry flagged_entry { get; private set; } +    public Library.LastImportSidebarEntry last_imported_entry { get; private set; } +    public Library.ImportQueueSidebarEntry import_queue_entry { get; private set; } +    public Library.OfflineSidebarEntry offline_entry { get; private set; } +    public Library.TrashSidebarEntry trash_entry { get; private set; } +     +    // This lists the order of the library items in the sidebar. To re-order, simply move +    // the item in this list to a new position. These numbers should *not* persist anywhere +    // outside the app. +    private enum EntryPosition { +        PHOTOS, +        FLAGGED, +        LAST_IMPORTED, +        IMPORT_QUEUE, +        OFFLINE, +        TRASH +    } +          public Branch() { -        base (new Library.SidebarEntry()); +        base(new Sidebar.Header(_("Library")), +            Sidebar.Branch.Options.STARTUP_OPEN_GROUPING, comparator); + +        photos_entry = new Library.PhotosEntry(); +        trash_entry = new Library.TrashSidebarEntry(); +        last_imported_entry = new Library.LastImportSidebarEntry(); +        flagged_entry = new Library.FlaggedSidebarEntry(); +        offline_entry = new Library.OfflineSidebarEntry(); +        import_queue_entry = new Library.ImportQueueSidebarEntry(); + +        insert(photos_entry, EntryPosition.PHOTOS); +        insert(trash_entry, EntryPosition.TRASH); + +        flagged_entry.visibility_changed.connect(on_flagged_visibility_changed); +        on_flagged_visibility_changed(); + +        last_imported_entry.visibility_changed.connect(on_last_imported_visibility_changed); +        on_last_imported_visibility_changed(); + +        import_queue_entry.visibility_changed.connect(on_import_queue_visibility_changed); +        on_import_queue_visibility_changed(); + +        offline_entry.visibility_changed.connect(on_offline_visibility_changed); +        on_offline_visibility_changed();      } -    public Library.MainPage get_main_page() { -        return (Library.MainPage) ((Library.SidebarEntry) get_root()).get_page(); +    private void insert(Sidebar.Entry entry, int position) { +        entry.set_data<int>(POSITION_DATA, position); +        graft(get_root(), entry); +    } + +    private void on_flagged_visibility_changed() { +        update_entry_visibility(flagged_entry, EntryPosition.FLAGGED); +    } + +    private void on_last_imported_visibility_changed() { +        update_entry_visibility(last_imported_entry, EntryPosition.LAST_IMPORTED); +    } + +    private void on_import_queue_visibility_changed() { +        update_entry_visibility(import_queue_entry, EntryPosition.IMPORT_QUEUE); +    } + +    private void on_offline_visibility_changed() { +        update_entry_visibility(offline_entry, EntryPosition.OFFLINE); +    } + +    private void update_entry_visibility(Library.HideablePageEntry entry, int position) { +        if (entry.visible) { +            if (!has_entry(entry)) +                insert(entry, position); +        } else if (has_entry(entry)) { +            prune(entry); +        } +    } + +    private static int comparator(Sidebar.Entry a, Sidebar.Entry b) { +        return a.get_data<int>(POSITION_DATA) - b.get_data<int>(POSITION_DATA);      }  } -public class Library.SidebarEntry : Sidebar.SimplePageEntry { -    private Icon icon = new ThemedIcon(Resources.ICON_PHOTOS); +public class Library.PhotosEntry : Sidebar.SimplePageEntry { -    public SidebarEntry() { +    public PhotosEntry() {      }      public override string get_sidebar_name() { -        return Library.MainPage.NAME; +        return _("Photos");      } -    public override Icon? get_sidebar_icon() { -        return icon; +    public override string? get_sidebar_icon() { +        return Resources.ICON_PHOTOS;      }      protected override Page create_page() { @@ -33,6 +106,26 @@ public class Library.SidebarEntry : Sidebar.SimplePageEntry {      }  } +public abstract class Library.HideablePageEntry : Sidebar.SimplePageEntry { +    // container branch should listen to this signal +    public signal void visibility_changed(bool visible); + +    private bool show_entry = false; +    public bool visible { +        get { return show_entry; } +        set { +            if (value == show_entry) +                return; + +            show_entry = value; +            visibility_changed(value); +        } +    } + +    public HideablePageEntry() { +    } +} +  public class Library.MainPage : CollectionPage {      public const string NAME = _("Library"); diff --git a/src/library/FlaggedPage.vala b/src/library/FlaggedPage.vala index 28bc57b..b45cc54 100644 --- a/src/library/FlaggedPage.vala +++ b/src/library/FlaggedPage.vala @@ -1,4 +1,4 @@ -/* Copyright 2010-2014 Yorba Foundation +/* Copyright 2010-2015 Yorba Foundation   *   * This software is licensed under the GNU LGPL (version 2.1 or later).   * See the COPYING file in this distribution. diff --git a/src/library/FlaggedBranch.vala b/src/library/FlaggedSidebarEntry.vala index 472d999..240aaf3 100644 --- a/src/library/FlaggedBranch.vala +++ b/src/library/FlaggedSidebarEntry.vala @@ -1,47 +1,28 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution.   */ -public class Library.FlaggedBranch : Sidebar.RootOnlyBranch { -    public FlaggedBranch() { -        base (new Library.FlaggedSidebarEntry()); -         +public class Library.FlaggedSidebarEntry : Library.HideablePageEntry, Sidebar.InternalDropTargetEntry { +    public FlaggedSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())              media_sources.flagged_contents_altered.connect(on_flagged_contents_altered); -        set_show_branch(get_total_flagged() != 0); +        visible = (get_total_flagged() != 0);      } -    ~FlaggedBranch() { +    ~FlaggedSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())              media_sources.flagged_contents_altered.disconnect(on_flagged_contents_altered); -    } -     -    private void on_flagged_contents_altered() { -        set_show_branch(get_total_flagged() != 0); -    } -     -    private int get_total_flagged() { -        int total = 0; -        foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) -            total += media_sources.get_flagged().size; -         -        return total; -    } -} - -public class Library.FlaggedSidebarEntry : Sidebar.SimplePageEntry, Sidebar.InternalDropTargetEntry { -    public FlaggedSidebarEntry() { -    } -     +    }  +             public override string get_sidebar_name() {          return FlaggedPage.NAME;      } -    public override Icon? get_sidebar_icon() { -        return new ThemedIcon(Resources.ICON_FLAGGED_PAGE); +    public override string? get_sidebar_icon() { +        return Resources.ICON_FLAGGED_PAGE;      }      protected override Page create_page() { @@ -57,5 +38,17 @@ public class Library.FlaggedSidebarEntry : Sidebar.SimplePageEntry, Sidebar.Inte      public bool internal_drop_received_arbitrary(Gtk.SelectionData data) {          return false;      } + +    private void on_flagged_contents_altered() { +        visible = (get_total_flagged() != 0); +    } +     +    private int get_total_flagged() { +        int total = 0; +        foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) +            total += media_sources.get_flagged().size; +         +        return total; +    }  } diff --git a/src/library/ImportQueuePage.vala b/src/library/ImportQueuePage.vala index 5ace1d8..9886f5a 100644 --- a/src/library/ImportQueuePage.vala +++ b/src/library/ImportQueuePage.vala @@ -1,4 +1,4 @@ -/* Copyright 2009-2014 Yorba Foundation +/* Copyright 2009-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution. @@ -28,7 +28,8 @@ public class ImportQueuePage : SinglePhotoPage {          Gtk.Toolbar toolbar = get_toolbar();          // Stop button -        Gtk.ToolButton stop_button = new Gtk.ToolButton.from_stock(Gtk.Stock.STOP); +        Gtk.ToolButton stop_button = new Gtk.ToolButton(null, null); +        stop_button.set_icon_name("stop");          stop_button.set_related_action(get_action("Stop"));          toolbar.insert(stop_button, -1); @@ -61,7 +62,7 @@ public class ImportQueuePage : SinglePhotoPage {      protected override Gtk.ActionEntry[] init_collect_action_entries() {          Gtk.ActionEntry[] actions = base.init_collect_action_entries(); -        Gtk.ActionEntry stop = { "Stop", Gtk.Stock.STOP, TRANSLATABLE, null, TRANSLATABLE, +        Gtk.ActionEntry stop = { "Stop", Resources.STOP_LABEL, TRANSLATABLE, null, TRANSLATABLE,              on_stop };          stop.label = _("_Stop Import");          stop.tooltip = _("Stop importing photos"); diff --git a/src/library/ImportQueueBranch.vala b/src/library/ImportQueueSidebarEntry.vala index 32a3e0d..5d34ce2 100644 --- a/src/library/ImportQueueBranch.vala +++ b/src/library/ImportQueueSidebarEntry.vala @@ -1,38 +1,37 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution.   */ -public class Library.ImportQueueBranch : Sidebar.RootOnlyBranch { -    private Library.ImportQueueSidebarEntry entry; -     -    public ImportQueueBranch() { -        // can't pass to base() an object that was allocated in declaration; see -        // https://bugzilla.gnome.org/show_bug.cgi?id=646286 -        base (new Library.ImportQueueSidebarEntry()); -         -        entry = (Library.ImportQueueSidebarEntry) get_root(); -         +public class Library.ImportQueueSidebarEntry : Library.HideablePageEntry { +    public ImportQueueSidebarEntry() {          // only attach signals to the page when it's created -        entry.page_created.connect(on_page_created); -        entry.destroying_page.connect(on_destroying_page); +        page_created.connect(on_page_created); +        destroying_page.connect(on_destroying_page);          // don't use entry.get_page() or get_queue_page() because (a) we don't want to          // create the page during initialization, and (b) we know there's no import activity          // at this moment -        set_show_branch(false); +        visible = false;      } -    ~ImportQueueBranch() { -        entry.page_created.disconnect(on_page_created); -        entry.destroying_page.disconnect(on_destroying_page); +    public override string get_sidebar_name() { +        return ImportQueuePage.NAME;      } -    public ImportQueuePage get_queue_page() { -        return (ImportQueuePage) entry.get_page(); +    public override string? get_sidebar_icon() { +        return Resources.ICON_IMPORTING;      } +    protected override Page create_page() { +        return new ImportQueuePage(); +    } + +    private ImportQueuePage get_queue_page() { +        return get_page() as ImportQueuePage; +    } +      private void on_page_created() {          get_queue_page().batch_added.connect(on_batch_added_or_removed);          get_queue_page().batch_removed.connect(on_batch_added_or_removed); @@ -44,31 +43,14 @@ public class Library.ImportQueueBranch : Sidebar.RootOnlyBranch {      }      private void on_batch_added_or_removed() { -        set_show_branch(get_queue_page().get_batch_count() > 0); +        visible = (get_queue_page().get_batch_count() > 0);      }      public void enqueue_and_schedule(BatchImport batch_import, bool allow_user_cancel) {          // want to display the branch before passing to the page because this might result in the          // page being created, and want it all hooked up in the tree prior to creating the page -        set_show_branch(true); +        visible = true;          get_queue_page().enqueue_and_schedule(batch_import, allow_user_cancel);      }  } -public class Library.ImportQueueSidebarEntry : Sidebar.SimplePageEntry { -    public ImportQueueSidebarEntry() { -    } -     -    public override string get_sidebar_name() { -        return ImportQueuePage.NAME; -    } -     -    public override Icon? get_sidebar_icon() { -        return new ThemedIcon(Resources.ICON_IMPORTING); -    } -     -    protected override Page create_page() { -        return new ImportQueuePage(); -    } -} - diff --git a/src/library/LastImportPage.vala b/src/library/LastImportPage.vala index 877faa5..ea9045c 100644 --- a/src/library/LastImportPage.vala +++ b/src/library/LastImportPage.vala @@ -1,4 +1,4 @@ -/* Copyright 2010-2014 Yorba Foundation +/* Copyright 2010-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution. diff --git a/src/library/LastImportBranch.vala b/src/library/LastImportSidebarEntry.vala index bc03ee5..3414130 100644 --- a/src/library/LastImportBranch.vala +++ b/src/library/LastImportSidebarEntry.vala @@ -1,47 +1,36 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution.   */ -public class Library.LastImportBranch : Sidebar.RootOnlyBranch { -    public LastImportBranch() { -        base (new Library.LastImportSidebarEntry()); -         +public class Library.LastImportSidebarEntry : Library.HideablePageEntry { +    public LastImportSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())              media_sources.import_roll_altered.connect(on_import_rolls_altered); -        set_show_branch(MediaCollectionRegistry.get_instance().get_last_import_id() != null); +        visible = (MediaCollectionRegistry.get_instance().get_last_import_id() != null);      } -    ~LastImportBranch() { +    ~LastImportSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())              media_sources.import_roll_altered.disconnect(on_import_rolls_altered);      } -    public Library.LastImportSidebarEntry get_main_entry() { -        return (Library.LastImportSidebarEntry) get_root(); -    } -     -    private void on_import_rolls_altered() { -        set_show_branch(MediaCollectionRegistry.get_instance().get_last_import_id() != null); -    } -} - -public class Library.LastImportSidebarEntry : Sidebar.SimplePageEntry { -    public LastImportSidebarEntry() { -    } -          public override string get_sidebar_name() {          return LastImportPage.NAME;      } -    public override Icon? get_sidebar_icon() { -        return new ThemedIcon(Resources.ICON_LAST_IMPORT); +    public override string? get_sidebar_icon() { +        return Resources.ICON_LAST_IMPORT;      }      protected override Page create_page() {          return new LastImportPage();      } + +    private void on_import_rolls_altered() { +        visible = (MediaCollectionRegistry.get_instance().get_last_import_id() != null); +    }  } diff --git a/src/library/Library.vala b/src/library/Library.vala index 79a4880..272f3d2 100644 --- a/src/library/Library.vala +++ b/src/library/Library.vala @@ -1,4 +1,4 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution. diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala index dab1f6f..a756436 100644 --- a/src/library/LibraryWindow.vala +++ b/src/library/LibraryWindow.vala @@ -1,4 +1,4 @@ -/* Copyright 2009-2014 Yorba Foundation +/* Copyright 2009-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution. @@ -42,16 +42,11 @@ public class LibraryWindow : AppWindow {      // outside the app.      private enum SidebarRootPosition {          LIBRARY, -        FLAGGED, -        LAST_IMPORTED,          CAMERAS, -        IMPORT_QUEUE,          SAVED_SEARCH,          EVENTS,          FOLDERS, -        TAGS, -        TRASH, -        OFFLINE +        TAGS      }      public enum TargetType { @@ -114,12 +109,7 @@ public class LibraryWindow : AppWindow {      private Library.Branch library_branch = new Library.Branch();      private Tags.Branch tags_branch = new Tags.Branch();      private Folders.Branch folders_branch = new Folders.Branch(); -    private Library.TrashBranch trash_branch = new Library.TrashBranch();      private Events.Branch events_branch = new Events.Branch(); -    private Library.OfflineBranch offline_branch = new Library.OfflineBranch(); -    private Library.FlaggedBranch flagged_branch = new Library.FlaggedBranch(); -    private Library.LastImportBranch last_import_branch = new Library.LastImportBranch(); -    private Library.ImportQueueBranch import_queue_branch = new Library.ImportQueueBranch();      private Camera.Branch camera_branch = new Camera.Branch();      private Searches.Branch saved_search_branch = new Searches.Branch();      private bool page_switching_enabled = true; @@ -172,12 +162,7 @@ public class LibraryWindow : AppWindow {          sidebar_tree.graft(library_branch, SidebarRootPosition.LIBRARY);          sidebar_tree.graft(tags_branch, SidebarRootPosition.TAGS);          sidebar_tree.graft(folders_branch, SidebarRootPosition.FOLDERS); -        sidebar_tree.graft(trash_branch, SidebarRootPosition.TRASH);          sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS); -        sidebar_tree.graft(offline_branch, SidebarRootPosition.OFFLINE); -        sidebar_tree.graft(flagged_branch, SidebarRootPosition.FLAGGED); -        sidebar_tree.graft(last_import_branch, SidebarRootPosition.LAST_IMPORTED); -        sidebar_tree.graft(import_queue_branch, SidebarRootPosition.IMPORT_QUEUE);          sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);          sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH); @@ -207,7 +192,7 @@ public class LibraryWindow : AppWindow {          menubar.no_show_all = true;          // create the main layout & start at the Library page -        create_layout(library_branch.get_main_page()); +        create_layout(library_branch.photos_entry.get_page());          // settings that should persist between sessions          load_configuration(); @@ -313,12 +298,12 @@ public class LibraryWindow : AppWindow {          sort.label = _("Sort _Events");          actions += sort; -        Gtk.ActionEntry preferences = { "CommonPreferences", Gtk.Stock.PREFERENCES, TRANSLATABLE, +        Gtk.ActionEntry preferences = { "CommonPreferences", Resources.PREFERENCES_LABEL, TRANSLATABLE,              null, TRANSLATABLE, on_preferences };          preferences.label = Resources.PREFERENCES_MENU;          actions += preferences; -        Gtk.ActionEntry empty = { "CommonEmptyTrash", Gtk.Stock.CLEAR, TRANSLATABLE, null, null, +        Gtk.ActionEntry empty = { "CommonEmptyTrash", null, TRANSLATABLE, null, null,              on_empty_trash };          empty.label = _("Empty T_rash");          empty.tooltip = _("Delete all photos in the trash"); @@ -329,8 +314,7 @@ public class LibraryWindow : AppWindow {          jump_to_event.label = _("View Eve_nt for Photo");          actions += jump_to_event; -        Gtk.ActionEntry find = { "CommonFind", Gtk.Stock.FIND, TRANSLATABLE, null, null, -            on_find }; +        Gtk.ActionEntry find = { "CommonFind", null, TRANSLATABLE, null, null, on_find };          find.label = _("_Find");          find.tooltip = _("Find photos and videos by search criteria");          actions += find; @@ -398,7 +382,7 @@ public class LibraryWindow : AppWindow {          extended_props.tooltip = _("Display extended information for the selection");          actions += extended_props; -        Gtk.ToggleActionEntry searchbar = { "CommonDisplaySearchbar", Gtk.Stock.FIND, TRANSLATABLE, +        Gtk.ToggleActionEntry searchbar = { "CommonDisplaySearchbar", "edit-find", TRANSLATABLE,              "F8", TRANSLATABLE, on_display_searchbar, is_search_toolbar_visible };          searchbar.label = _("_Search Bar");          searchbar.tooltip = _("Display the search bar"); @@ -417,14 +401,14 @@ public class LibraryWindow : AppWindow {          Gtk.RadioActionEntry[] actions = new Gtk.RadioActionEntry[0];          Gtk.RadioActionEntry ascending = { "CommonSortEventsAscending", -            Gtk.Stock.SORT_ASCENDING, TRANSLATABLE, null, TRANSLATABLE, +            Resources.SORT_ASCENDING_LABEL, TRANSLATABLE, null, TRANSLATABLE,              SORT_EVENTS_ORDER_ASCENDING };          ascending.label = _("_Ascending");          ascending.tooltip = _("Sort photos in an ascending order");          actions += ascending;          Gtk.RadioActionEntry descending = { "CommonSortEventsDescending", -            Gtk.Stock.SORT_DESCENDING, TRANSLATABLE, null, TRANSLATABLE, +            Resources.SORT_DESCENDING_LABEL, TRANSLATABLE, null, TRANSLATABLE,              SORT_EVENTS_ORDER_DESCENDING };          descending.label = _("D_escending");          descending.tooltip = _("Sort photos in a descending order"); @@ -666,8 +650,8 @@ public class LibraryWindow : AppWindow {      private void on_file_import() {          Gtk.FileChooserDialog import_dialog = new Gtk.FileChooserDialog(_("Import From Folder"), null, -            Gtk.FileChooserAction.SELECT_FOLDER, Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,  -            Gtk.Stock.OK, Gtk.ResponseType.OK); +            Gtk.FileChooserAction.SELECT_FOLDER, Resources.CANCEL_LABEL, Gtk.ResponseType.CANCEL,  +            Resources.OK_LABEL, Gtk.ResponseType.OK);          import_dialog.set_local_only(false);          import_dialog.set_select_multiple(true);          import_dialog.set_current_folder(import_dir); @@ -883,7 +867,7 @@ public class LibraryWindow : AppWindow {      }      public void enqueue_batch_import(BatchImport batch_import, bool allow_user_cancel) { -        import_queue_branch.enqueue_and_schedule(batch_import, allow_user_cancel); +        library_branch.import_queue_entry.enqueue_and_schedule(batch_import, allow_user_cancel);      }      private void import_reporter(ImportManifest manifest) { @@ -1029,7 +1013,7 @@ public class LibraryWindow : AppWindow {      }      public void switch_to_library_page() { -        switch_to_page(library_branch.get_main_page()); +        switch_to_page(library_branch.photos_entry.get_page());      }      public void switch_to_event(Event event) { @@ -1066,7 +1050,7 @@ public class LibraryWindow : AppWindow {      }      public void switch_to_import_queue_page() { -        switch_to_page(import_queue_branch.get_queue_page()); +        switch_to_page(library_branch.import_queue_entry.get_page());      }      private void on_camera_added(DiscoveredCamera camera) { @@ -1285,52 +1269,36 @@ public class LibraryWindow : AppWindow {          Gtk.ScrolledWindow scrolled_sidebar = new Gtk.ScrolledWindow(null, null);          scrolled_sidebar.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);          scrolled_sidebar.add(sidebar_tree); -        scrolled_sidebar.get_style_context().add_class(Gtk.STYLE_CLASS_SIDEBAR); -        scrolled_sidebar.set_shadow_type(Gtk.ShadowType.IN); -        get_style_context().add_class("sidebar-pane-separator"); -         -        // divy the sidebar up into selection tree list, background progress bar, and properties -        Gtk.Frame top_frame = new Gtk.Frame(null); -        top_frame.add(scrolled_sidebar); -        top_frame.set_shadow_type(Gtk.ShadowType.IN); +        background_progress_frame.set_border_width(2);          background_progress_frame.add(background_progress_bar); -        background_progress_frame.set_shadow_type(Gtk.ShadowType.IN); +        background_progress_frame.get_style_context().remove_class("frame");          // pad the bottom frame (properties)          Gtk.Alignment bottom_alignment = new Gtk.Alignment(0, 0.5f, 1, 0); - -        Resources.style_widget(scrolled_sidebar, Resources.SCROLL_FRAME_STYLESHEET); -        Resources.style_widget(bottom_frame, Resources.INSET_FRAME_STYLESHEET);          bottom_alignment.set_padding(10, 10, 6, 0);          bottom_alignment.add(basic_properties);          bottom_frame.add(bottom_alignment); -        bottom_frame.set_shadow_type(Gtk.ShadowType.IN); +        bottom_frame.get_style_context().remove_class("frame");          // "attach" the progress bar to the sidebar tree, so the movable ridge is to resize the          // top two and the basic information pane -        top_section.pack_start(top_frame, true, true, 0); +        top_section.pack_start(scrolled_sidebar, true, true, 0);          sidebar_paned.pack1(top_section, true, false);          sidebar_paned.pack2(bottom_frame, false, false);          sidebar_paned.set_position(1000); - -        // layout the selection tree to the left of the collection/toolbar box with an adjustable -        // gutter between them, framed for presentation -        Gtk.Frame right_frame = new Gtk.Frame(null); -        right_frame.set_shadow_type(Gtk.ShadowType.IN);          right_vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); -        right_frame.add(right_vbox);          right_vbox.pack_start(search_toolbar, false, false, 0);          right_vbox.pack_start(notebook, true, true, 0);          client_paned = new Gtk.Paned(Gtk.Orientation.HORIZONTAL);          client_paned.pack1(sidebar_paned, false, false);          sidebar_tree.set_size_request(SIDEBAR_MIN_WIDTH, -1); -        client_paned.pack2(right_frame, true, false); +        client_paned.pack2(right_vbox, true, false);          client_paned.set_position(Config.Facade.get_instance().get_sidebar_position());          // TODO: Calc according to layout's size, to give sidebar a maximum width          notebook.set_size_request(PAGE_MIN_WIDTH, -1); @@ -1436,7 +1404,7 @@ public class LibraryWindow : AppWindow {      // Turns the search bar on or off.  Note that if show is true, page must not be null.      private void toggle_search_bar(bool show, CheckerboardPage? page = null) { -        search_toolbar.visible = show; +        search_toolbar.set_reveal_child(show);          if (show) {              assert(null != page);              search_toolbar.set_view_filter(page.get_search_view_filter()); @@ -1457,7 +1425,7 @@ public class LibraryWindow : AppWindow {      private void on_destroying_page(Sidebar.PageRepresentative entry, Page page) {          // if page is the current page, switch to fallback before destroying          if (page == get_current_page()) -            switch_to_page(library_branch.get_main_page()); +            switch_to_page(library_branch.photos_entry.get_page());          remove_from_notebook(page); @@ -1475,9 +1443,11 @@ public class LibraryWindow : AppWindow {          // if the currently selected item is removed, want to jump to fallback page (which          // depends on the item that was selected) +        Library.LastImportSidebarEntry last_import_entry = library_branch.last_imported_entry; +                  // Importing... -> Last Import (if available) -        if (selectable is Library.ImportQueueSidebarEntry && last_import_branch.get_show_branch()) { -            switch_to_page(last_import_branch.get_main_entry().get_page()); +        if (selectable is Library.ImportQueueSidebarEntry && last_import_entry.visible) { +            switch_to_page(last_import_entry.get_page());              return;          } @@ -1497,7 +1467,7 @@ public class LibraryWindow : AppWindow {          }          // basic all-around default: jump to the Library page -        switch_to_page(library_branch.get_main_page()); +        switch_to_page(library_branch.photos_entry.get_page());      }      private void subscribe_for_basic_information(Page page) { diff --git a/src/library/OfflinePage.vala b/src/library/OfflinePage.vala index cb6af2d..eecd71b 100644 --- a/src/library/OfflinePage.vala +++ b/src/library/OfflinePage.vala @@ -1,4 +1,4 @@ -/* Copyright 2010-2014 Yorba Foundation +/* Copyright 2010-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution. @@ -55,7 +55,7 @@ public class OfflinePage : CheckerboardPage {      protected override Gtk.ActionEntry[] init_collect_action_entries() {          Gtk.ActionEntry[] actions = base.init_collect_action_entries(); -        Gtk.ActionEntry remove = { "RemoveFromLibrary", Gtk.Stock.REMOVE, TRANSLATABLE, "Delete", +        Gtk.ActionEntry remove = { "RemoveFromLibrary", Resources.REMOVE_LABEL, TRANSLATABLE, "Delete",              TRANSLATABLE, on_remove_from_library };          remove.label = Resources.REMOVE_FROM_LIBRARY_MENU;          remove.tooltip = Resources.DELETE_FROM_LIBRARY_TOOLTIP; diff --git a/src/library/OfflineBranch.vala b/src/library/OfflineSidebarEntry.vala index 4ed2e49..34c09a0 100644 --- a/src/library/OfflineBranch.vala +++ b/src/library/OfflineSidebarEntry.vala @@ -1,26 +1,25 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution.   */ -public class Library.OfflineBranch : Sidebar.RootOnlyBranch { -    public OfflineBranch() { -        base (new Library.OfflineSidebarEntry()); +public class Library.OfflineSidebarEntry : Library.HideablePageEntry { +    public OfflineSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())              media_sources.offline_contents_altered.connect(on_offline_contents_altered); -        set_show_branch(get_total_offline() != 0); +        visible = (get_total_offline() != 0);      } -     -    ~OfflineBranch() { + +    ~OfflineSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())              media_sources.trashcan_contents_altered.disconnect(on_offline_contents_altered);      }      private void on_offline_contents_altered() { -        set_show_branch(get_total_offline() != 0); +        visible = (get_total_offline() != 0);      }      private int get_total_offline() { @@ -30,18 +29,13 @@ public class Library.OfflineBranch : Sidebar.RootOnlyBranch {          return total;      } -} - -public class Library.OfflineSidebarEntry : Sidebar.SimplePageEntry { -    public OfflineSidebarEntry() { -    }      public override string get_sidebar_name() {          return OfflinePage.NAME;      } -    public override Icon? get_sidebar_icon() { -        return new ThemedIcon(Resources.ICON_MISSING_FILES); +    public override string? get_sidebar_icon() { +        return Resources.ICON_MISSING_FILES;      }      protected override Page create_page() { diff --git a/src/library/TrashPage.vala b/src/library/TrashPage.vala index 2991727..ae80a7b 100644 --- a/src/library/TrashPage.vala +++ b/src/library/TrashPage.vala @@ -1,4 +1,4 @@ -/* Copyright 2010-2014 Yorba Foundation +/* Copyright 2010-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution. @@ -50,13 +50,13 @@ public class TrashPage : CheckerboardPage {      protected override Gtk.ActionEntry[] init_collect_action_entries() {          Gtk.ActionEntry[] actions = base.init_collect_action_entries(); -        Gtk.ActionEntry delete_action = { "Delete", Gtk.Stock.DELETE, TRANSLATABLE, "Delete", +        Gtk.ActionEntry delete_action = { "Delete", Resources.DELETE_LABEL, TRANSLATABLE, "Delete",              TRANSLATABLE, on_delete };          delete_action.label = Resources.DELETE_PHOTOS_MENU;          delete_action.tooltip = Resources.DELETE_FROM_TRASH_TOOLTIP;          actions += delete_action; -        Gtk.ActionEntry restore = { "Restore", Gtk.Stock.UNDELETE, TRANSLATABLE, null, TRANSLATABLE, +        Gtk.ActionEntry restore = { "Restore", Resources.UNDELETE_LABEL, TRANSLATABLE, null, TRANSLATABLE,              on_restore };          restore.label = Resources.RESTORE_PHOTOS_MENU;          restore.tooltip = Resources.RESTORE_PHOTOS_TOOLTIP; diff --git a/src/library/TrashBranch.vala b/src/library/TrashSidebarEntry.vala index 5ef8b3c..69412b7 100644 --- a/src/library/TrashBranch.vala +++ b/src/library/TrashSidebarEntry.vala @@ -1,18 +1,10 @@ -/* Copyright 2011-2014 Yorba Foundation +/* Copyright 2011-2015 Yorba Foundation   *   * This software is licensed under the GNU Lesser General Public License   * (version 2.1 or later).  See the COPYING file in this distribution.   */ -public class Library.TrashBranch : Sidebar.RootOnlyBranch { -    public TrashBranch() { -        base (new Library.TrashSidebarEntry()); -    } -} -  public class Library.TrashSidebarEntry : Sidebar.SimplePageEntry, Sidebar.InternalDropTargetEntry { -    private static Icon? full_icon = null; -    private static Icon? empty_icon = null;      public TrashSidebarEntry() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) @@ -25,30 +17,26 @@ public class Library.TrashSidebarEntry : Sidebar.SimplePageEntry, Sidebar.Intern      }      internal static void init() { -        full_icon = new ThemedIcon(Resources.ICON_TRASH_FULL); -        empty_icon = new ThemedIcon(Resources.ICON_TRASH_EMPTY);      }      internal static void terminate() { -        full_icon = null; -        empty_icon = null;      }      public override string get_sidebar_name() {          return TrashPage.NAME;      } -    public override Icon? get_sidebar_icon() { +    public override string? get_sidebar_icon() {          return get_current_icon();      } -    private static Icon get_current_icon() { +    private static string get_current_icon() {          foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) {              if (media_sources.get_trashcan_count() > 0) -                return full_icon; +                return Resources.ICON_TRASH_FULL;          } -        return empty_icon; +        return Resources.ICON_TRASH_EMPTY;      }      public bool internal_drop_received(Gee.List<MediaSource> media) { diff --git a/src/library/mk/library.mk b/src/library/mk/library.mk index b4ab790..dc6201f 100644 --- a/src/library/mk/library.mk +++ b/src/library/mk/library.mk @@ -13,11 +13,11 @@ UNIT_DIR := library  UNIT_FILES := \  	LibraryWindow.vala \  	Branch.vala \ -	TrashBranch.vala \ -	OfflineBranch.vala \ -	FlaggedBranch.vala \ -	LastImportBranch.vala \ -	ImportQueueBranch.vala \ +        TrashSidebarEntry.vala \ +        OfflineSidebarEntry.vala \ +        FlaggedSidebarEntry.vala \ +        LastImportSidebarEntry.vala \ +        ImportQueueSidebarEntry.vala \  	FlaggedPage.vala \  	ImportQueuePage.vala \  	LastImportPage.vala \  | 
