Commit 65e0197e authored by Ricardo Fantin da Costa's avatar Ricardo Fantin da Costa Committed by Jens Georg

Faces code clean up

Change the meson option from face to face-detection.
To compile with face support use -Dface-detection=true.
Many files used old Yorba Copyright notice, they were updated.
A class from file src/editing_tools/EditingTools.vala was moved to it own file
src/faces/FacesTools.vala .
A bug made the menu label to be always in plural "Remove .. photos" instead of
"Remove ... photo". Now it is corrected.
The deprecateds Gtk.HBox and Gtk.Button.from_stock() where changed to they
correct class.
parent 2848610f
/* Copyright 2016 Software Freedom Conservancy Inc.
*
* Copyright 2011 Valentín Barros Puertas <valentin(at)sanva(dot)net>
* Copyright 2018 Ricardo Fantin da Costa <ricardofantin(at)gmail(dot)com>
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
......
......@@ -82,7 +82,7 @@ if not get_option('dupe-detection')
add_global_arguments(['--define=NO_DUPE_DETECTION'], language : vala)
endif
if get_option('face')
if get_option('face-detection')
add_global_arguments(['--define=ENABLE_FACES'], language : 'vala')
subdir('facedetect')
endif
......
......@@ -5,4 +5,4 @@ option('trace', type: 'string', value : '', description: 'Enable various trace
option('measure', type: 'string', value : '', description : 'Enable various timing measurements(available : enhance, import, pipeline, view-filtering, thumbnail-cache)')
option('dupe-detection', type: 'boolean', value : 'true', description: 'Disable duplicate checks')
option('install-apport-hook', type : 'boolean', value : 'true', description: 'Enable Ubuntu apport hook')
option('face', type:'boolean', value:false)
option('face-detection', type:'boolean', value:false)
......@@ -494,8 +494,8 @@ public abstract class EditingHostPage : SinglePhotoPage {
#if ENABLE_FACES
// faces tool
insert_faces_button(toolbar);
faces_button = new Gtk.ToggleToolButton();
//face_button
faces_button = new Gtk.ToggleToolButton();
//face_button
#endif
// separator to force next/prev buttons to right side of toolbar
......@@ -3170,7 +3170,7 @@ public class LibraryPhotoPage : EditingHostPage {
#if ENABLE_FACES
private void on_faces_toggled() {
on_tool_button_toggled(faces_button, EditingTools.FacesTool.factory);
on_tool_button_toggled(faces_button, FacesTool.factory);
}
protected void toggle_faces() {
......@@ -3179,7 +3179,7 @@ public class LibraryPhotoPage : EditingHostPage {
protected override void insert_faces_button(Gtk.Toolbar toolbar) {
faces_button = new Gtk.ToggleToolButton.from_stock(Resources.FACES_TOOL);
faces_button.set_icon_name(Resources.ICON_FACES);
faces_button.set_icon_name(Resources.ICON_FACES);
faces_button.set_label(Resources.FACES_LABEL);
faces_button.set_tooltip_text(Resources.FACES_TOOLTIP);
faces_button.toggled.connect(on_faces_toggled);
......
......@@ -108,7 +108,7 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public const string ICON_TRASH_FULL = "user-trash-full-symbolic";
#if ENABLE_FACES
public const string ICON_ONE_FACE = "one-face";
public const string ICON_FACES = "faces-tool";
public const string ICON_FACES = "faces-tool";
#endif
public const string ROTATE_CW_MENU = _("Rotate _Right");
......
/* Copyright 2011-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
public struct FaceLocationID {
......@@ -86,7 +86,7 @@ public class FaceLocationTable : DatabaseTable {
return row;
}
public Gee.List<FaceLocationRow?> get_all_rows() throws DatabaseError {
Sqlite.Statement stmt;
int res = db.prepare_v2(
......
/* Copyright 2011-2012 Yorba Foundation
/* Copyright 2018 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
public struct FaceID {
public const int64 INVALID = -1;
......@@ -165,3 +166,4 @@ public class FaceTable : DatabaseTable {
update_text_by_id_2(face_id.id, "name", new_name);
}
}
#endif
This diff is collapsed.
/* Copyright 2010-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
public class FaceSourceCollection : ContainerSourceCollection {
private Gee.HashMap<string, Face> name_map = new Gee.HashMap<string, Face>
......@@ -140,7 +141,6 @@ public class FaceSourceCollection : ContainerSourceCollection {
protected override void notify_container_contents_added(ContainerSource container,
Gee.Collection<DataObject> added, bool relinking) {
// Gee.Collection<DataSource> added, bool relinking) {
Face face = (Face) container;
Gee.Collection<MediaSource> sources = (Gee.Collection<MediaSource>) added;
......@@ -160,7 +160,6 @@ public class FaceSourceCollection : ContainerSourceCollection {
protected override void notify_container_contents_removed(ContainerSource container,
Gee.Collection<DataObject> removed, bool unlinking) {
// Gee.Collection<DataSource> removed, bool unlinking) {
Face face = (Face) container;
Gee.Collection<MediaSource> sources = (Gee.Collection<MediaSource>) removed;
......
/* Copyright 2010-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
......
/* Copyright 2010-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
public class FacePage : CollectionPage {
......@@ -13,18 +13,12 @@ public class FacePage : CollectionPage {
base (face.get_name());
this.face = face;
//this.row.name
Face.global.items_altered.connect(on_faces_altered);
face.mirror_sources(get_view(), create_thumbnail);
init_page_context_menu("FacesContextMenu");
// init_item_context_menu("CollectionFacesPlaceholder");
/* GLib.MenuModel menu = get_menubar();
GLib.MenuModel? section = null;
section = find_extension_point (menu, Resources.FACES_MENU_SECTION);*/
}
}
~FacePage() {
get_view().halt_mirroring();
......@@ -50,8 +44,8 @@ public class FacePage : CollectionPage {
private const GLib.ActionEntry[] entries = {
{ "DeleteFace", on_delete_face },
{ "RenameFace", on_rename_face },
{ "RemoveFaceFromPhotos", on_remove_face_from_photos },
{ "RenameFace", on_rename_face },
{ "RemoveFaceFromPhotos", on_remove_face_from_photos },
{ "DeleteFaceSidebar", on_delete_face },
{ "RenameFaceSidebar", on_rename_face }
};
......@@ -73,23 +67,17 @@ public class FacePage : CollectionPage {
protected override InjectionGroup[] init_collect_injection_groups() {
InjectionGroup[] groups = base.init_collect_injection_groups();
//groups.add_menu_item(_("Face Location"), "FaceLocation");
//groups += create_photos_faces_injectables();
groups += create_faces_menu_injectables();
groups += create_faces_menu_injectables();
return groups;
}
private InjectionGroup create_faces_menu_injectables(){
InjectionGroup menuFaces = new InjectionGroup("FacesMenuPlaceholder");
//menuFaces.add_menu("Faces");
menuFaces.add_menu_item("Remove Face \"" + this.face.get_name() + "\" From Photos", "RemoveFaceFromPhotos", "<Primary>r");
menuFaces.add_menu_item("Rename Face \"" + this.face.get_name() + "\"…", "RenameFace", "<Primary>e");
menuFaces.add_menu_item("Dele_teFace", "DeleteFace", "<Primary>t");
menuFaces.add_menu_item(Resources.remove_face_from_photos_menu(this.face.get_name(), get_view().get_count()), "RemoveFaceFromPhotos", "<Primary>r");
menuFaces.add_menu_item(Resources.rename_face_menu(this.face.get_name()), "RenameFace", "<Primary>e");
menuFaces.add_menu_item(Resources.delete_face_menu(this.face.get_name()), "DeleteFace", "<Primary>t");
return menuFaces;
}
......@@ -112,7 +100,7 @@ public class FacePage : CollectionPage {
true);
set_action_details("RemoveFaceFromPhotos",
Resources.remove_face_from_photos_menu(face.get_name(), selected_count),
Resources.remove_face_from_photos_menu(face.get_name(), get_view().get_count()),
null,
selected_count > 0);
......
/* Copyright 2010-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
#if ENABLE_FACES
public abstract class FaceShape : Object {
public const string SHAPE_TYPE = null;
......@@ -16,7 +16,7 @@ public abstract class FaceShape : Object {
public signal void add_me_requested(FaceShape face_shape);
public signal void delete_me_requested();
protected EditingTools.FacesTool.EditingFaceToolWindow face_window;
protected FacesTool.EditingFaceToolWindow face_window;
protected Gdk.CursorType current_cursor_type = Gdk.CursorType.BOTTOM_RIGHT_CORNER;
protected EditingTools.PhotoCanvas canvas;
protected string serialized = null;
......@@ -25,7 +25,7 @@ public abstract class FaceShape : Object {
private bool visible = true;
private bool known = true;
private weak EditingTools.FacesTool.FaceWidget face_widget = null;
private weak FacesTool.FaceWidget face_widget = null;
public FaceShape(EditingTools.PhotoCanvas canvas) {
this.canvas = canvas;
......@@ -33,7 +33,7 @@ public abstract class FaceShape : Object {
prepare_ctx(this.canvas.get_default_ctx(), this.canvas.get_surface_dim());
face_window = new EditingTools.FacesTool.EditingFaceToolWindow(this.canvas.get_container());
face_window = new FacesTool.EditingFaceToolWindow(this.canvas.get_container());
face_window.key_pressed.connect(key_press_event);
face_window.show_all();
......@@ -55,7 +55,7 @@ public abstract class FaceShape : Object {
}
public static FaceShape from_serialized(EditingTools.PhotoCanvas canvas, string serialized)
throws EditingTools.FaceShapeError {
throws FaceShapeError {
FaceShape face_shape;
string[] args = serialized.split(";");
......@@ -91,11 +91,11 @@ public abstract class FaceShape : Object {
return known;
}
public void set_widget(EditingTools.FacesTool.FaceWidget face_widget) {
public void set_widget(FacesTool.FaceWidget face_widget) {
this.face_widget = face_widget;
}
public EditingTools.FacesTool.FaceWidget get_widget() {
public FacesTool.FaceWidget get_widget() {
assert(face_widget != null);
return face_widget;
......@@ -223,7 +223,7 @@ public class FaceRectangle : FaceShape {
}
public static new FaceRectangle from_serialized(EditingTools.PhotoCanvas canvas, string[] args)
throws EditingTools.FaceShapeError {
throws FaceShapeError {
assert(args[0] == SHAPE_TYPE);
Photo photo = canvas.get_photo();
......@@ -266,7 +266,7 @@ public class FaceRectangle : FaceShape {
half_height = box.get_height() / 2;
if (half_width < FACE_MIN_SIZE || half_height < FACE_MIN_SIZE)
throw new EditingTools.FaceShapeError.CANT_CREATE("FaceShape is out of cropped photo area");
throw new FaceShapeError.CANT_CREATE("FaceShape is out of cropped photo area");
return new FaceRectangle(canvas, box.left + half_width, box.top + half_height,
half_width, half_height);
......
/* Copyright 2011-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
......@@ -9,11 +9,11 @@
namespace Faces {
public void init() throws Error {
Faces.SidebarEntry.init();
Faces.SidebarEntry.init();
}
public void terminate() {
Faces.SidebarEntry.terminate();
Faces.SidebarEntry.terminate();
}
}
......@@ -23,13 +23,13 @@ public void terminate() {
namespace Faces {
public void init() throws Error {
// do nothing; this method is here only
// to make the unitizing mechanism happy
// 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
// do nothing; this method is here only
// to make the unitizing mechanism happy
}
}
......
/* Copyright 2011-2012 Yorba Foundation
/* 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.
* (version 2.1 or later). See the COPYING file in this distribution.
*/
#if ENABLE_FACES
......
This diff is collapsed.
......@@ -282,148 +282,6 @@ public class LibraryWindow : AppWindow {
monitor.auto_import_progress.disconnect(on_library_monitor_auto_import_progress);
}
/*<<<<<<< HEAD
Gtk.ActionEntry preferences = { "CommonPreferences", Resources.PREFERENCES_LABEL, TRANSLATABLE,
null, TRANSLATABLE, on_preferences };
preferences.label = Resources.PREFERENCES_MENU;
actions += preferences;
Gtk.ActionEntry empty = { "CommonEmptyTrash", null, TRANSLATABLE, null, null,
on_empty_trash };
empty.label = _("Empty T_rash");
empty.tooltip = _("Delete all photos in the trash");
actions += empty;
Gtk.ActionEntry jump_to_event = { "CommonJumpToEvent", null, TRANSLATABLE, null,
TRANSLATABLE, on_jump_to_event };
jump_to_event.label = _("View Eve_nt for Photo");
actions += jump_to_event;
Gtk.ActionEntry find = { "CommonFind", null, TRANSLATABLE, null, null, on_find };
find.label = _("_Find");
find.tooltip = _("Find photos and videos by search criteria");
actions += find;
// add the common action for the FilterPhotos submenu (the submenu contains items from
// SearchFilterActions)
Gtk.ActionEntry filter_photos = { "CommonFilterPhotos", null, TRANSLATABLE, null, null, null };
filter_photos.label = Resources.FILTER_PHOTOS_MENU;
actions += filter_photos;
Gtk.ActionEntry new_search = { "CommonNewSearch", null, TRANSLATABLE, "<Ctrl>S", null,
on_new_search };
new_search.label = _("Ne_w Saved Search...");
actions += new_search;
// top-level menus
Gtk.ActionEntry file = { "FileMenu", null, TRANSLATABLE, null, null, null };
file.label = _("_File");
actions += file;
Gtk.ActionEntry edit = { "EditMenu", null, TRANSLATABLE, null, null, null };
edit.label = _("_Edit");
actions += edit;
Gtk.ActionEntry view = { "ViewMenu", null, TRANSLATABLE, null, null, null };
view.label = _("_View");
actions += view;
Gtk.ActionEntry photo = { "PhotoMenu", null, TRANSLATABLE, null, null, null };
photo.label = _("_Photo");
actions += photo;
Gtk.ActionEntry photos = { "PhotosMenu", null, TRANSLATABLE, null, null, null };
photos.label = _("_Photos");
actions += photos;
Gtk.ActionEntry event = { "EventsMenu", null, TRANSLATABLE, null, null, null };
event.label = _("Even_ts");
actions += event;
Gtk.ActionEntry tags = { "TagsMenu", null, TRANSLATABLE, null, null, null };
tags.label = _("Ta_gs");
actions += tags;
Gtk.ActionEntry help = { "HelpMenu", null, TRANSLATABLE, null, null, null };
help.label = _("_Help");
actions += help;
return actions;
}
private Gtk.ToggleActionEntry[] create_common_toggle_actions() {
Gtk.ToggleActionEntry[] actions = new Gtk.ToggleActionEntry[0];
Gtk.ToggleActionEntry basic_props = { "CommonDisplayBasicProperties", null,
TRANSLATABLE, "<Ctrl><Shift>I", TRANSLATABLE, on_display_basic_properties, false };
basic_props.label = _("_Basic Information");
basic_props.tooltip = _("Display basic information for the selection");
actions += basic_props;
Gtk.ToggleActionEntry extended_props = { "CommonDisplayExtendedProperties", null,
TRANSLATABLE, "<Ctrl><Shift>X", TRANSLATABLE, on_display_extended_properties, false };
extended_props.label = _("E_xtended Information");
extended_props.tooltip = _("Display extended information for the selection");
actions += extended_props;
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");
actions += searchbar;
Gtk.ToggleActionEntry sidebar = { "CommonDisplaySidebar", null, TRANSLATABLE,
"F9", TRANSLATABLE, on_display_sidebar, is_sidebar_visible() };
sidebar.label = _("S_idebar");
sidebar.tooltip = _("Display the sidebar");
actions += sidebar;
return actions;
}
private void add_common_radio_actions(Gtk.ActionGroup group) {
Gtk.RadioActionEntry[] actions = new Gtk.RadioActionEntry[0];
Gtk.RadioActionEntry ascending = { "CommonSortEventsAscending",
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",
Resources.SORT_DESCENDING_LABEL, TRANSLATABLE, null, TRANSLATABLE,
SORT_EVENTS_ORDER_DESCENDING };
descending.label = _("D_escending");
descending.tooltip = _("Sort photos in a descending order");
actions += descending;
group.add_radio_actions(actions, SORT_EVENTS_ORDER_ASCENDING, on_events_sort_changed);
}
protected override Gtk.ActionGroup[] create_common_action_groups() {
Gtk.ActionGroup[] groups = base.create_common_action_groups();
common_action_group.add_actions(create_common_actions(), this);
common_action_group.add_toggle_actions(create_common_toggle_actions(), this);
add_common_radio_actions(common_action_group);
Gtk.Action? action = common_action_group.get_action("CommonDisplaySearchbar");
if (action != null) {
action.short_label = Resources.FIND_LABEL;
action.is_important = true;
}
groups += common_action_group;
groups += search_actions.get_action_group();
return groups;
}
public override void replace_common_placeholders(Gtk.UIManager ui) {
base.replace_common_placeholders(ui);
=======*/
private const GLib.ActionEntry[] common_actions = {
// Normal actions
{ "CommonFileImport", on_file_import },
......
......@@ -17,16 +17,17 @@ processor = executable('shotwell-graphics-processor',
dependencies: [gio, gdk, gee],
link_with: sw_graphics_processor)
face_resources = []
if get_option('face')
face_resources = (['faces/FacesBranch.vala',
face_sources = []
if get_option('face-detection')
face_sources = (['faces/FacesBranch.vala',
'faces/FaceLocation.vala',
'faces/FacePage.vala',
'faces/FaceShape.vala',
'faces/Faces.vala',
'faces/Face.vala',
'db/FaceLocationTable.vala',
'db/FaceTable.vala'])
'db/FaceTable.vala',
'faces/FacesTool.vala'])
endif
shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
......@@ -237,7 +238,7 @@ executable('shotwell',
'.unitize/_DataImportsInternals.vala',
'.unitize/_FoldersInternals.vala',
'.unitize/_Library_unitize_entry.vala',
'.unitize/_Direct_unitize_entry.vala'] + shotwell_resources + face_resources,
'.unitize/_Direct_unitize_entry.vala'] + shotwell_resources + face_sources,
include_directories : vapi_incdir,
dependencies : shotwell_deps,
vala_args : ['--pkg', 'libgphoto2',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment