[shotwell] faces: Always enable face tagging
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] faces: Always enable face tagging
- Date: Sat, 8 Oct 2022 06:47:41 +0000 (UTC)
commit 9637f3b074304b1b06becc19e0b8cfc3d13bd258
Author: Jens Georg <mail jensge org>
Date: Sat May 7 09:03:34 2022 +0200
faces: Always enable face tagging
There was absolutely no reason to not enable that always. Also fixes an
issue with shotwell aborting on unexpected OpenCV log output.
The face-detection build option will now just building the disable the
helper process so the OpenCV dependency is still opt-in.
meson.build | 2 +-
src/AppDirs.vala | 4 ----
src/Commands.vala | 3 ---
src/Dialogs.vala | 4 ----
src/Photo.vala | 2 --
src/PhotoPage.vala | 8 --------
src/Resources.vala | 2 --
src/SearchFilter.vala | 5 +----
src/db/FaceLocationTable.vala | 1 -
src/faces/Face.vala | 7 ++-----
src/faces/FaceDetect.vala | 2 ++
src/faces/FaceLocation.vala | 2 --
src/faces/FacePage.vala | 4 ----
src/faces/FaceShape.vala | 4 ----
src/faces/Faces.vala | 20 --------------------
src/faces/FacesBranch.vala | 4 ----
src/faces/FacesTool.vala | 5 ++---
src/library/LibraryWindow.vala | 9 ---------
src/main.vala | 6 ------
src/meson.build | 7 +------
src/searches/SavedSearchDialog.vala | 2 --
src/searches/SearchBoolean.vala | 18 ++++++------------
src/util/ui.vala | 2 --
23 files changed, 15 insertions(+), 108 deletions(-)
---
diff --git a/meson.build b/meson.build
index 7629861d..e1865c32 100644
--- a/meson.build
+++ b/meson.build
@@ -98,7 +98,7 @@ if get_option('udev') and gudev.found()
endif
if get_option('face_detection')
- add_global_arguments(['--define=ENABLE_FACES'], language : 'vala')
+ add_global_arguments(['--define=ENABLE_FACE_DETECTION'], language : 'vala')
if get_option('face_detection_helper_bus') == 'private'
add_global_arguments(['--define=FACEDETECT_BUS_PRIVATE'], language : 'vala')
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index f82fe4f4..b303958d 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -258,14 +258,12 @@ class AppDirs {
return subdir;
}
-#if ENABLE_FACES
public static File get_resources_dir() {
File? install_dir = get_install_dir();
return (install_dir != null) ? install_dir.get_child("share").get_child("shotwell")
: get_lib_dir();
}
-#endif
public static File get_lib_dir() {
File? install_dir = get_install_dir();
@@ -366,7 +364,6 @@ class AppDirs {
return f;
}
-#if ENABLE_FACES
public static File get_facedetect_bin() {
const string filename = "shotwell-facedetect";
File f =
AppDirs.get_libexec_dir().get_parent().get_child("subprojects").get_child(filename).get_child (filename);
@@ -392,7 +389,6 @@ class AppDirs {
return get_data_subdir("data"); //get_child("openface.nn4.small2.v1.t7");
}
-#endif
}
diff --git a/src/Commands.vala b/src/Commands.vala
index 9825b6de..f832b85d 100644
--- a/src/Commands.vala
+++ b/src/Commands.vala
@@ -2507,7 +2507,6 @@ public class FlagUnflagCommand : MultipleDataSourceAtOnceCommand {
}
}
-#if ENABLE_FACES
public class RemoveFacesFromPhotosCommand : SimpleProxyableCommand {
private Gee.Map<MediaSource, string> map_source_geometry = new Gee.HashMap<MediaSource, string>();
@@ -2743,5 +2742,3 @@ public class ModifyFacesCommand : SingleDataSourceCommand {
get_command_manager().reset();
}
}
-
-#endif
diff --git a/src/Dialogs.vala b/src/Dialogs.vala
index d123ca37..e0c42f35 100644
--- a/src/Dialogs.vala
+++ b/src/Dialogs.vala
@@ -46,8 +46,6 @@ public bool confirm_warn_developer_changed(int number) {
return response == Gtk.ResponseType.YES;
}
-#if ENABLE_FACES
-
public bool confirm_delete_face(Face face) {
int count = face.get_sources_count();
string msg = ngettext(
@@ -59,8 +57,6 @@ public bool confirm_delete_face(Face face) {
Resources.DELETE_FACE_TITLE);
}
-#endif
-
}
namespace ExportUI {
diff --git a/src/Photo.vala b/src/Photo.vala
index 04eb504b..db811588 100644
--- a/src/Photo.vala
+++ b/src/Photo.vala
@@ -5256,7 +5256,6 @@ public class LibraryPhoto : Photo, Flaggable, Monitorable {
}
}
-#if ENABLE_FACES
// Attach faces.
Gee.Collection<Face>? faces = Face.global.fetch_for_source(this);
if (faces != null) {
@@ -5270,7 +5269,6 @@ public class LibraryPhoto : Photo, Flaggable, Monitorable {
}
}
}
-#endif
return dupe;
}
diff --git a/src/PhotoPage.vala b/src/PhotoPage.vala
index 4d21647d..b63d726f 100644
--- a/src/PhotoPage.vala
+++ b/src/PhotoPage.vala
@@ -396,9 +396,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
private Gtk.ToggleToolButton redeye_button = null;
private Gtk.ToggleToolButton adjust_button = null;
private Gtk.ToggleToolButton straighten_button = null;
-#if ENABLE_FACES
private Gtk.ToggleToolButton faces_button = null;
-#endif
private Gtk.ToolButton enhance_button = null;
private Gtk.Scale zoom_slider = null;
private Gtk.ToolButton prev_button = new Gtk.ToolButton(null, Resources.PREVIOUS_LABEL);
@@ -491,12 +489,10 @@ public abstract class EditingHostPage : SinglePhotoPage {
enhance_button.is_important = true;
toolbar.insert(enhance_button, -1);
-#if ENABLE_FACES
// faces tool
insert_faces_button(toolbar);
faces_button = new Gtk.ToggleToolButton();
//face_button
-#endif
// separator to force next/prev buttons to right side of toolbar
Gtk.SeparatorToolItem separator = new Gtk.SeparatorToolItem();
@@ -2357,9 +2353,7 @@ public class LibraryPhotoPage : EditingHostPage {
}
}
-#if ENABLE_FACES
private Gtk.ToggleToolButton faces_button = null;
-#endif
private CollectionPage? return_page = null;
private bool return_to_collection_on_release = false;
private LibraryPhotoPageViewFilter filter = new LibraryPhotoPageViewFilter();
@@ -3169,7 +3163,6 @@ public class LibraryPhotoPage : EditingHostPage {
get_command_manager().execute(new ModifyTagsCommand(photo, new_tags));
}
-#if ENABLE_FACES
private void on_faces_toggled() {
on_tool_button_toggled(faces_button, FacesTool.factory);
}
@@ -3187,6 +3180,5 @@ public class LibraryPhotoPage : EditingHostPage {
faces_button.is_important = true;
toolbar.insert(faces_button, -1);
}
-#endif
}
diff --git a/src/Resources.vala b/src/Resources.vala
index 58283618..d1657bbc 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -398,7 +398,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
return _("Delete Search “%s”").printf(name);
}
-#if ENABLE_FACES
public static string rename_face_exists_message(string name) {
return _("Unable to rename face to “%s” because the face already exists.").printf(name);
}
@@ -442,7 +441,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public string delete_face_label(string name) {
return _("Delete Face “%s”").printf(name);
}
-#endif
private unowned string rating_label(Rating rating) {
switch (rating) {
diff --git a/src/SearchFilter.vala b/src/SearchFilter.vala
index 9a88cf2e..969591f3 100644
--- a/src/SearchFilter.vala
+++ b/src/SearchFilter.vala
@@ -223,9 +223,7 @@ public abstract class DefaultSearchViewFilter : SearchViewFilter {
Gee.List<Tag>? tags = Tag.global.fetch_for_source(source);
int tags_size = (tags != null) ? tags.size : 0;
-#if ENABLE_FACES
Gee.List<Face>? faces = Face.global.fetch_for_source(source);
-#endif
foreach (unowned string word in get_search_filter_words()) {
if (media_keywords != null && media_keywords.contains(word))
@@ -249,7 +247,6 @@ public abstract class DefaultSearchViewFilter : SearchViewFilter {
continue;
}
-#if ENABLE_FACES
if (faces != null) {
bool found = false;
foreach (Face f in faces) {
@@ -264,7 +261,7 @@ public abstract class DefaultSearchViewFilter : SearchViewFilter {
if (found)
continue;
}
-#endif
+
// failed all tests (this even works if none of the Indexables have strings,
// as they fail the implicit AND test)
return false;
diff --git a/src/db/FaceLocationTable.vala b/src/db/FaceLocationTable.vala
index 989c2941..f4c88d76 100644
--- a/src/db/FaceLocationTable.vala
+++ b/src/db/FaceLocationTable.vala
@@ -222,7 +222,6 @@ public class FaceLocationTable : DatabaseTable {
if (res != Sqlite.DONE)
throw_error("FaceLocationTable.update_face_location_serialized_geometry", res);
}
-
public Gee.List<FaceLocationRow?> get_face_ref_vecs(Gee.List<FaceRow?> face_rows)
throws DatabaseError {
Sqlite.Statement stmt;
diff --git a/src/faces/Face.vala b/src/faces/Face.vala
index b2249076..83e0840a 100644
--- a/src/faces/Face.vala
+++ b/src/faces/Face.vala
@@ -346,20 +346,18 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
global.add_many(faces);
global.init_add_many_unlinked(unlinked);
-#if ENABLE_FACES
+#if ENABLE_FACE_DETECTION
// Start the face detection background process
// FaceTool talks to it over DBus
start_facedetect_process();
#endif
}
-#if ENABLE_FACES
public static void terminate() {
try {
FaceDetect.interface.terminate();
} catch(Error e) {}
}
-#endif
public static int compare_names(void *a, void *b) {
Face *aface = (Face *) a;
@@ -377,7 +375,7 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
return String.collated_equals(a, b);
}
-#if ENABLE_FACES
+#if ENABLE_FACE_DETECTION
private static void start_facedetect_process() {
message("Launching facedetect process: %s", AppDirs.get_facedetect_bin().get_path());
// Start the watcher, process started via DBus service
@@ -705,4 +703,3 @@ public class Face : DataSource, ContainerSource, Proxyable, Indexable {
base.destroy();
}
}
-
diff --git a/src/faces/FaceDetect.vala b/src/faces/FaceDetect.vala
index 4bf6e6af..ab1cc299 100644
--- a/src/faces/FaceDetect.vala
+++ b/src/faces/FaceDetect.vala
@@ -69,6 +69,7 @@ public class FaceDetect {
connected = false;
}
+#if FACEDETECT_BUS_PRIVATE
private static bool on_new_connection(DBusServer server, DBusConnection connection) {
try {
interface = connection.get_proxy_sync(null, DBUS_PATH,
@@ -97,6 +98,7 @@ public class FaceDetect {
return false;
}
}
+#endif
public static void init(string net_file) {
FaceDetect.net_file = net_file;
diff --git a/src/faces/FaceLocation.vala b/src/faces/FaceLocation.vala
index f222cae2..0f4e383e 100644
--- a/src/faces/FaceLocation.vala
+++ b/src/faces/FaceLocation.vala
@@ -9,7 +9,6 @@ public struct FaceLocationData {
public string geometry;
public string vec;
}
-
public class FaceLocation : Object {
private static Gee.Map<FaceID?, Gee.Map<PhotoID?, FaceLocation>> face_photos_map;
@@ -221,4 +220,3 @@ public class FaceLocation : Object {
this.face_data = face_data;
}
}
-
diff --git a/src/faces/FacePage.vala b/src/faces/FacePage.vala
index d238a5ae..1766b918 100644
--- a/src/faces/FacePage.vala
+++ b/src/faces/FacePage.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public class FacePage : CollectionPage {
private Face face;
@@ -137,5 +135,3 @@ public class FacePage : CollectionPage {
}
}
}
-
-#endif
diff --git a/src/faces/FaceShape.vala b/src/faces/FaceShape.vala
index b65a2398..e2d2fe76 100644
--- a/src/faces/FaceShape.vala
+++ b/src/faces/FaceShape.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public abstract class FaceShape : Object {
public const string SHAPE_TYPE = null;
@@ -823,5 +821,3 @@ public class FaceRectangle : FaceShape {
return Math.sqrt((center_x - x) * (center_x - x) + (center_y - y) * (center_y - y));
}
}
-
-#endif
diff --git a/src/faces/Faces.vala b/src/faces/Faces.vala
index 3f0623a7..595c3b6c 100644
--- a/src/faces/Faces.vala
+++ b/src/faces/Faces.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
namespace Faces {
public void init() throws Error {
@@ -17,21 +15,3 @@ public void terminate() {
}
}
-
-#else
-
-namespace Faces {
-
-public void init() throws Error {
- // do nothing; this method is here only
- // to make the unitizing mechanism happy
-}
-
-public void terminate() {
- // do nothing; this method is here only
- // to make the unitizing mechanism happy
-}
-
-}
-
-#endif
diff --git a/src/faces/FacesBranch.vala b/src/faces/FacesBranch.vala
index 1eb25cf4..42fd9213 100644
--- a/src/faces/FacesBranch.vala
+++ b/src/faces/FacesBranch.vala
@@ -4,8 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
-
public class Faces.Branch : Sidebar.Branch {
private Gee.HashMap<Face, Faces.SidebarEntry> entry_map = new Gee.HashMap<Face, Faces.SidebarEntry>();
@@ -142,5 +140,3 @@ public class Faces.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEnt
AppWindow.get_command_manager().execute(new DeleteFaceCommand(face));
}
}
-
-#endif
diff --git a/src/faces/FacesTool.vala b/src/faces/FacesTool.vala
index b15390a4..fa1eb9d2 100644
--- a/src/faces/FacesTool.vala
+++ b/src/faces/FacesTool.vala
@@ -4,7 +4,6 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-#if ENABLE_FACES
public errordomain FaceShapeError {
CANT_CREATE
}
@@ -155,7 +154,9 @@ public class FacesTool : EditingTools.EditingTool {
help_layout.pack_start(help_text, true);
response_layout = new Gtk.Box(Gtk.Orientation.HORIZONTAL, CONTROL_SPACING);
+ #if ENABLE_FACE_DETECTION
response_layout.add(detection_button);
+ #endif
response_layout.add(cancel_button);
response_layout.add(ok_button);
@@ -967,5 +968,3 @@ public class FacesTool : EditingTools.EditingTool {
face_detection.cancel();
}
}
-
-#endif
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 4eac314f..849ae2ed 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -40,9 +40,7 @@ public class LibraryWindow : AppWindow {
EVENTS,
IMPORT_ROLL,
FOLDERS,
-#if ENABLE_FACES
FACES,
-#endif
TAGS
}
@@ -107,9 +105,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();
-#if ENABLE_FACES
private Faces.Branch faces_branch = new Faces.Branch();
-#endif
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();
@@ -161,10 +157,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);
-#if ENABLE_FACES
sidebar_tree.graft(faces_branch, SidebarRootPosition.FACES);
-#endif
-
sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);
sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
@@ -398,7 +391,6 @@ public class LibraryWindow : AppWindow {
debug("No search entry found for rename");
}
-#if ENABLE_FACES
public void rename_face_in_sidebar(Face face) {
Faces.SidebarEntry? entry = faces_branch.get_entry_for_face(face);
if (entry != null)
@@ -406,7 +398,6 @@ public class LibraryWindow : AppWindow {
else
assert_not_reached();
}
-#endif
protected override void on_quit() {
Config.Facade.get_instance().set_library_window_state(maximized, dimensions);
diff --git a/src/main.vala b/src/main.vala
index 4afaf295..63cd8191 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -103,10 +103,8 @@ void library_exec(string[] mounts) {
+ EventTable.get_instance().get_row_count()
+ TagTable.get_instance().get_row_count()
+ VideoTable.get_instance().get_row_count()
-#if ENABLE_FACES
+ FaceTable.get_instance().get_row_count()
+ FaceLocationTable.get_instance().get_row_count()
-#endif
+ Upgrades.get_instance().get_step_count();
if (grand_total > 5000) {
progress_dialog = new ProgressDialog(null, _("Loading Shotwell"));
@@ -150,14 +148,12 @@ void library_exec(string[] mounts) {
if (aggregate_monitor != null)
aggregate_monitor.next_step("Tag.init");
Tag.init(monitor);
-#if ENABLE_FACES
if (aggregate_monitor != null)
aggregate_monitor.next_step("FaceLocation.init");
FaceLocation.init(monitor);
if (aggregate_monitor != null)
aggregate_monitor.next_step("Face.init");
Face.init(monitor);
-#endif
MetadataWriter.init();
DesktopIntegration.init();
@@ -223,10 +219,8 @@ void library_exec(string[] mounts) {
Tombstone.terminate();
ThumbnailCache.terminate();
Video.terminate();
-#if ENABLE_FACES
Face.terminate();
FaceLocation.terminate();
-#endif
Library.app_terminate();
}
diff --git a/src/meson.build b/src/meson.build
index e043db3c..bbd28317 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -23,17 +23,12 @@ shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
shotwell_libs = [sw_graphics_processor]
-face_sources = []
-face_obj = ''
-
-if get_option('face_detection')
- face_sources = (['faces/FacesBranch.vala',
+face_sources = (['faces/FacesBranch.vala',
'faces/FacePage.vala',
'faces/FaceShape.vala',
'faces/FaceDetect.vala',
'faces/Faces.vala',
'faces/FacesTool.vala'])
-endif
shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
gstreamer_pbu, gio_unix, gudev, gexiv2, gmodule, unity,
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala
index 0ba5426b..b08c8a8d 100644
--- a/src/searches/SavedSearchDialog.vala
+++ b/src/searches/SavedSearchDialog.vala
@@ -79,9 +79,7 @@ public class SavedSearchDialog : Gtk.Dialog {
case SearchCondition.SearchType.ANY_TEXT:
case SearchCondition.SearchType.EVENT_NAME:
case SearchCondition.SearchType.FILE_NAME:
-#if ENABLE_FACES
case SearchCondition.SearchType.FACE:
-#endif
case SearchCondition.SearchType.TAG:
case SearchCondition.SearchType.COMMENT:
case SearchCondition.SearchType.TITLE:
diff --git a/src/searches/SearchBoolean.vala b/src/searches/SearchBoolean.vala
index 2be83020..5e69e57b 100644
--- a/src/searches/SearchBoolean.vala
+++ b/src/searches/SearchBoolean.vala
@@ -52,9 +52,7 @@ public abstract class SearchCondition {
TAG,
EVENT_NAME,
FILE_NAME,
-#if ENABLE_FACES
FACE,
-#endif
MEDIA_TYPE,
FLAG_STATE,
MODIFIED_STATE,
@@ -65,9 +63,7 @@ public abstract class SearchCondition {
public static SearchType[] as_array() {
return { ANY_TEXT, TITLE, TAG, COMMENT, EVENT_NAME, FILE_NAME,
-#if ENABLE_FACES
FACE,
-#endif
MEDIA_TYPE, FLAG_STATE, MODIFIED_STATE, RATING, DATE };
}
@@ -98,10 +94,10 @@ public abstract class SearchCondition {
case SearchType.FILE_NAME:
return "FILE_NAME";
-#if ENABLE_FACES
+
case SearchType.FACE:
return "FACE";
-#endif
+
case SearchType.MEDIA_TYPE:
return "MEDIA_TYPE";
@@ -140,10 +136,10 @@ public abstract class SearchCondition {
else if (str == "FILE_NAME")
return SearchType.FILE_NAME;
-#if ENABLE_FACES
+
else if (str == "FACE")
return SearchType.FACE;
-#endif
+
else if (str == "MEDIA_TYPE")
return SearchType.MEDIA_TYPE;
@@ -182,10 +178,10 @@ public abstract class SearchCondition {
case SearchType.FILE_NAME:
return _("File name");
-#if ENABLE_FACES
+
case SearchType.FACE:
return _("Face");
-#endif
+
case SearchType.MEDIA_TYPE:
return _("Media type");
@@ -361,7 +357,6 @@ public class SearchConditionText : SearchCondition {
ret |= string_match(text, String.remove_diacritics(source.get_basename().down()));
}
-#if ENABLE_FACES
if (SearchType.ANY_TEXT == search_type || SearchType.FACE == search_type) {
Gee.List<Face>? face_list = Face.global.fetch_for_source(source);
if (null != face_list) {
@@ -372,7 +367,6 @@ public class SearchConditionText : SearchCondition {
ret |= string_match(text, null); // for IS_NOT_SET
}
}
-#endif
return (context == Context.DOES_NOT_CONTAIN) ? !ret : ret;
}
diff --git a/src/util/ui.vala b/src/util/ui.vala
index c8638ca6..bdc7157d 100644
--- a/src/util/ui.vala
+++ b/src/util/ui.vala
@@ -86,7 +86,6 @@ public bool has_only_key_modifier(Gdk.ModifierType field, Gdk.ModifierType mask)
| Gdk.ModifierType.META_MASK)) == mask;
}
-#if ENABLE_FACES
bool is_pointer_over(Gdk.Window window) {
var seat = window.get_display().get_default_seat();
if (seat == null) {
@@ -100,5 +99,4 @@ bool is_pointer_over(Gdk.Window window) {
return x >= 0 && y >= 0 && x < window.get_width() && y < window.get_height();
}
-#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]