[shotwell/wip/gtk4: 104/154] Add Camera and SavedSearch tree




commit 521fcb629952fa2bca1fe8de700b13474d753124
Author: Jens Georg <mail jensge org>
Date:   Sun Apr 10 15:19:56 2022 +0200

    Add Camera and SavedSearch tree

 src/camera/Camera.vala           |  4 ++--
 src/library/LibraryWindow.vala   | 16 ++++++----------
 src/meson.build                  |  4 +++-
 src/searches/Searches.vala       |  4 ++--
 src/searches/SearchesBranch.vala | 26 ++++++++------------------
 5 files changed, 21 insertions(+), 33 deletions(-)
---
diff --git a/src/camera/Camera.vala b/src/camera/Camera.vala
index 291daa4a..891507e7 100644
--- a/src/camera/Camera.vala
+++ b/src/camera/Camera.vala
@@ -7,11 +7,11 @@
 namespace Camera {
 
 public void init() throws Error {
-    //Camera.Branch.init();
+    Camera.Branch.init();
 }
 
 public void terminate() {
-    //Camera.Branch.terminate();
+    Camera.Branch.terminate();
 }
 
 }
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 15df5441..ebcd828c 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -109,11 +109,11 @@ public class LibraryWindow : AppWindow {
     private Library.Branch library_branch = new Library.Branch();
     private Tags.Branch tags_branch = new Tags.Branch();
     private Events.Branch events_branch = new Events.Branch();
+    private Camera.Branch camera_branch = new Camera.Branch();
+    private Searches.Branch saved_search_branch = new Searches.Branch();
 #if DOES_NOT_WORK_WITH_GTK4
     private Folders.Branch folders_branch = new Folders.Branch();
     private Faces.Branch faces_branch = new Faces.Branch();
-    private Camera.Branch camera_branch = new Camera.Branch();
-    private Searches.Branch saved_search_branch = new Searches.Branch();
     private ImportRoll.Branch import_roll_branch = new ImportRoll.Branch();
     
 #endif
@@ -169,9 +169,9 @@ public class LibraryWindow : AppWindow {
 #endif
 
         sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
-        #if 0
         sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);
         sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
+        #if 0
         sidebar_tree.graft(import_roll_branch, SidebarRootPosition.IMPORT_ROLL);
         #endif
         
@@ -399,13 +399,11 @@ public class LibraryWindow : AppWindow {
     }
 
     public void rename_search_in_sidebar(SavedSearch search) {
-    #if 0
         Searches.SidebarEntry? entry = saved_search_branch.get_entry_for_saved_search(search);
         if (entry != null)
             sidebar_tree.rename_entry_in_place(entry);
         else
             debug("No search entry found for rename");
-            #endif
     }
     
 #if ENABLE_FACES
@@ -943,9 +941,9 @@ public class LibraryWindow : AppWindow {
     }
     
     public void switch_to_saved_search(SavedSearch search) {
-        //Searches.SidebarEntry? entry = saved_search_branch.get_entry_for_saved_search(search);
-        //if (entry != null)
-        //    switch_to_page(entry.get_page());
+        Searches.SidebarEntry? entry = saved_search_branch.get_entry_for_saved_search(search);
+        if (entry != null)
+            switch_to_page(entry.get_page());
     }
     
     public void switch_to_photo_page(CollectionPage controller, Photo current) {
@@ -968,7 +966,6 @@ public class LibraryWindow : AppWindow {
     }
     
     private void on_camera_added(DiscoveredCamera camera) {
-    #if 0
         Camera.SidebarEntry? entry = camera_branch.get_entry_for_camera(camera);
         if (entry == null)
             return;
@@ -987,7 +984,6 @@ public class LibraryWindow : AppWindow {
         } else {
             switch_to_page(page);
         }
-        #endif
     }
 
     // This should only be called by LibraryWindow and PageStub.
diff --git a/src/meson.build b/src/meson.build
index 47b920b8..0037110e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -139,11 +139,13 @@ executable(
         'tags/HierarchicalTagIndex.vala',
         'tags/HierarchicalTagUtilities.vala',
         'camera/Camera.vala',
+        'camera/CameraBranch.vala',
         'camera/CameraTable.vala',
-            'camera/DiscoveredCamera.vala',
+        'camera/DiscoveredCamera.vala',
         'camera/GPhoto.vala',
         'camera/ImportPage.vala',
         'searches/Searches.vala',
+        'searches/SearchesBranch.vala',
         'searches/SearchBoolean.vala',
         'searches/SavedSearchPage.vala',
         'searches/SavedSearchDialog.vala',
diff --git a/src/searches/Searches.vala b/src/searches/Searches.vala
index f13a987e..20213818 100644
--- a/src/searches/Searches.vala
+++ b/src/searches/Searches.vala
@@ -20,11 +20,11 @@ public void preconfigure() {
 }
 
 public void init() throws Error {
-    //Searches.SidebarEntry.init();
+    Searches.SidebarEntry.init();
 }
 
 public void terminate() {
-    //Searches.SidebarEntry.terminate();
+    Searches.SidebarEntry.terminate();
 }
 
 }
diff --git a/src/searches/SearchesBranch.vala b/src/searches/SearchesBranch.vala
index 22a38e26..5a1a80db 100644
--- a/src/searches/SearchesBranch.vala
+++ b/src/searches/SearchesBranch.vala
@@ -62,27 +62,14 @@ public class Searches.Branch : Sidebar.Branch {
 
 public class Searches.Header : Sidebar.Header, Sidebar.Contextable {
     private Gtk.Builder builder;
-    private Gtk.Menu? context_menu = null;
+    private Gtk.PopoverMenu? context_menu = null;
     
     public Header() {
         base (_("Saved Searches"), _("Organize your saved searches"));
-        setup_context_menu();
+        context_menu = get_popover_menu_from_resource(Resources.get_ui("search_sidebar_context.ui"), 
"popup-menu", null);
     }
 
-    private void setup_context_menu() {
-        this.builder = new Gtk.Builder ();
-        try {
-            this.builder.add_from_resource(Resources.get_ui("search_sidebar_context.ui"));
-            var model = builder.get_object ("popup-menu") as GLib.MenuModel;
-            this.context_menu = new Gtk.Menu.from_model (model);
-        } catch (Error error) {
-            AppWindow.error_message("Error loading UI resource: %s".printf(
-                error.message));
-            Application.get_instance().panic();
-        }
-    }
-
-    public Gtk.Menu? get_sidebar_context_menu(Gdk.EventButton? event) {
+    public Gtk.PopoverMenu? get_sidebar_context_menu() {
         return context_menu;
     }
 }
@@ -131,7 +118,10 @@ public class Searches.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.Renameable
     }
     
     public void destroy_source() {
-        if (Dialogs.confirm_delete_saved_search(search))
-            AppWindow.get_command_manager().execute(new DeleteSavedSearchCommand(search));
+        Dialogs.confirm_delete_saved_search.begin(search, (source, res) => {
+            if (Dialogs.confirm_delete_saved_search.end(res)) {
+                AppWindow.get_command_manager().execute(new DeleteSavedSearchCommand(search));
+            }
+        });
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]