summaryrefslogtreecommitdiff
path: root/src/camera/Branch.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-05-01 14:34:32 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-05-01 14:34:32 +0200
commit49120f48474fc8fdc2448c75d961bc238213cfac (patch)
tree05bcdb95d65a807cf0f1ffffd066c09074b5cf56 /src/camera/Branch.vala
parent2492891f112caac6076ce49721d9d5d78a152c3a (diff)
New upstream version 0.28.2upstream/0.28.2
Diffstat (limited to 'src/camera/Branch.vala')
-rw-r--r--src/camera/Branch.vala114
1 files changed, 0 insertions, 114 deletions
diff --git a/src/camera/Branch.vala b/src/camera/Branch.vala
deleted file mode 100644
index 9bc551a..0000000
--- a/src/camera/Branch.vala
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Copyright 2016 Software Freedom Conservancy Inc.
- *
- * 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 Camera.Branch : Sidebar.Branch {
- internal static string? cameras_icon = Resources.ICON_CAMERAS;
-
- private Gee.HashMap<DiscoveredCamera, Camera.SidebarEntry> camera_map = new Gee.HashMap<
- DiscoveredCamera, Camera.SidebarEntry>();
-
- public Branch() {
- base (new Camera.Header(),
- Sidebar.Branch.Options.HIDE_IF_EMPTY | Sidebar.Branch.Options.AUTO_OPEN_ON_NEW_CHILD,
- camera_comparator);
-
- foreach (DiscoveredCamera camera in CameraTable.get_instance().get_cameras())
- add_camera(camera);
-
- CameraTable.get_instance().camera_added.connect(on_camera_added);
- CameraTable.get_instance().camera_removed.connect(on_camera_removed);
- }
-
- internal static void init() {
- }
-
- internal static void terminate() {
- }
-
- private static int camera_comparator(Sidebar.Entry a, Sidebar.Entry b) {
- if (a == b)
- return 0;
-
- // Compare based on name.
- int ret = a.get_sidebar_name().collate(b.get_sidebar_name());
- if (ret == 0) {
- // Cameras had same name! Fallback to URI comparison.
- Camera.SidebarEntry? cam_a = a as Camera.SidebarEntry;
- Camera.SidebarEntry? cam_b = b as Camera.SidebarEntry;
- assert (cam_a != null && cam_b != null);
- ret = cam_a.get_uri().collate(cam_b.get_uri());
- }
-
- return ret;
- }
-
- public Camera.SidebarEntry? get_entry_for_camera(DiscoveredCamera camera) {
- return camera_map.get(camera);
- }
-
- private void on_camera_added(DiscoveredCamera camera) {
- add_camera(camera);
- }
-
- private void on_camera_removed(DiscoveredCamera camera) {
- remove_camera(camera);
- }
-
- private void add_camera(DiscoveredCamera camera) {
- assert(!camera_map.has_key(camera));
-
- Camera.SidebarEntry entry = new Camera.SidebarEntry(camera);
- camera_map.set(camera, entry);
-
- // want to show before adding page so the grouping is available to graft onto
- graft(get_root(), entry);
- }
-
- private void remove_camera(DiscoveredCamera camera) {
- assert(camera_map.has_key(camera));
-
- Camera.SidebarEntry? entry = camera_map.get(camera);
- assert(entry != null);
-
- bool removed = camera_map.unset(camera);
- assert(removed);
-
- prune(entry);
- }
-}
-
-public class Camera.Header : Sidebar.Header {
- public Header() {
- base (_("Cameras"));
- }
-}
-
-public class Camera.SidebarEntry : Sidebar.SimplePageEntry {
- private DiscoveredCamera camera;
- private string uri;
-
- public SidebarEntry(DiscoveredCamera camera) {
- this.camera = camera;
- this.uri = camera.uri;
- }
-
- public override string get_sidebar_name() {
- return camera.display_name ?? _("Camera");
- }
-
- public override string? get_sidebar_icon() {
- return camera.icon ?? Camera.Branch.cameras_icon;
- }
-
- protected override Page create_page() {
- return new ImportPage(camera.gcamera, uri, get_sidebar_name(), get_sidebar_icon());
- }
-
- public string get_uri() {
- return uri;
- }
-}
-