summaryrefslogtreecommitdiff
path: root/src/Resources.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-09-30 14:09:20 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-09-30 14:09:20 +0200
commit5e9f4eea451a77ba3b93db3747841ed2bd969e9f (patch)
tree75046a38ca68975261d853a2e56ff7bf6b3e1daa /src/Resources.vala
parent18b52c2983a1b3409011f72d27f15de576c5eb1c (diff)
New upstream version 0.30.1upstream/0.30.1
Diffstat (limited to 'src/Resources.vala')
-rw-r--r--src/Resources.vala332
1 files changed, 199 insertions, 133 deletions
diff --git a/src/Resources.vala b/src/Resources.vala
index ef86424..8fabbe4 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -66,76 +66,45 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
""";
- public const string CLOCKWISE = "object-rotate-right";
- public const string COUNTERCLOCKWISE = "object-rotate-left";
- public const string HFLIP = "object-flip-horizontal";
- public const string VFLIP = "object-flip-vertical";
- public const string CROP = "shotwell-crop";
- public const string STRAIGHTEN = "shotwell-straighten";
- public const string REDEYE = "shotwell-redeye";
- public const string ADJUST = "image-adjust";
- public const string PIN_TOOLBAR = "shotwell-pin-toolbar";
- public const string MAKE_PRIMARY = "shotwell-make-primary";
- public const string IMPORT = "import";
- public const string IMPORT_ALL = "import-all";
- public const string ENHANCE = "shotwell-auto-enhance";
- public const string CROP_PIVOT_RETICLE = "shotwell-crop-pivot-reticle";
- public const string PUBLISH = "applications-internet";
- public const string MERGE = "shotwell-merge-events";
-
- public const string GO_NEXT = "go-next";
- public const string GO_PREVIOUS = "go-previous";
-
-
- //public const string ICON_ABOUT_LOGO = "shotwell-street.jpg";
- public const string ICON_ABOUT_LOGO = "about-braunschweig.jpg";
- public const string ICON_GENERIC_PLUGIN = "generic-plugin.png";
+ public const string CLOCKWISE = "object-rotate-right-symbolic";
+ public const string COUNTERCLOCKWISE = "object-rotate-left-symbolic";
+ public const string HFLIP = "object-flip-horizontal-symbolic";
+ public const string VFLIP = "object-flip-vertical-symbolic";
+ public const string STRAIGHTEN = "straighten-symbolic";
+ public const string ADJUST = "image-adjust-color-symbolic";
+ public const string IMPORT = "image-x-generic-symbolic";
+ public const string IMPORT_ALL = "filter-photos-symbolic";
+ public const string ENHANCE = "image-auto-adjust-symbolic";
+ public const string PUBLISH = "send-to-symbolic";
+ public const string FACES_TOOL = "avatar-default-symbolic";
+
+ public const string GO_NEXT = "go-next-symbolic";
+ public const string GO_PREVIOUS = "go-previous-symbolic";
+
+ public const string ICON_ABOUT_LOGO = "about-celle.jpg";
+ public const string ICON_GENERIC_PLUGIN = "application-x-addon-symbolic";
public const string ICON_SLIDESHOW_EXTENSION_POINT = "slideshow-extension-point";
- public const string ICON_RATING_REJECTED = "rejected.svg";
- public const string ICON_RATING_ONE = "one-star.svg";
- public const string ICON_RATING_TWO = "two-stars.svg";
- public const string ICON_RATING_THREE = "three-stars.svg";
- public const string ICON_RATING_FOUR = "four-stars.svg";
- public const string ICON_RATING_FIVE = "five-stars.svg";
- public const string ICON_FILTER_REJECTED_OR_BETTER = "all-rejected.png";
public const int ICON_FILTER_REJECTED_OR_BETTER_FIXED_SIZE = 32;
- public const string ICON_FILTER_UNRATED_OR_BETTER = "shotwell-16.png";
public const int ICON_FILTER_UNRATED_OR_BETTER_FIXED_SIZE = 16;
- public const string ICON_FILTER_ONE_OR_BETTER = "one-star-filter-plus.svg";
- public const string ICON_FILTER_TWO_OR_BETTER = "two-star-filter-plus.svg";
- public const string ICON_FILTER_THREE_OR_BETTER = "three-star-filter-plus.svg";
- public const string ICON_FILTER_FOUR_OR_BETTER = "four-star-filter-plus.svg";
- public const string ICON_FILTER_FIVE = "five-star-filter.svg";
- public const string ICON_ZOOM_IN = "zoom-in.png";
- public const string ICON_ZOOM_OUT = "zoom-out.png";
public const int ICON_ZOOM_SCALE = 16;
public const string ICON_CAMERAS = "camera-photo";
- public const string ICON_EVENTS = "multiple-events";
- public const string ICON_ONE_EVENT = "one-event";
- public const string ICON_NO_EVENT = "no-event";
- public const string ICON_ONE_TAG = "one-tag";
- public const string ICON_TAGS = "multiple-tags";
- public const string ICON_FOLDER = "folder";
- public const string ICON_FOLDER_DOCUMENTS = "folder-documents";
- public const string ICON_IMPORTING = "go-down";
- public const string ICON_LAST_IMPORT = "document-open-recent";
- public const string ICON_MISSING_FILES = "process-stop";
- public const string ICON_PHOTOS = "shotwell";
- public const string ICON_SINGLE_PHOTO = "image-x-generic";
- public const string ICON_FILTER_PHOTOS = "filter-photos";
- public const string ICON_FILTER_PHOTOS_DISABLED = "filter-photos-disabled";
- public const string ICON_FILTER_VIDEOS = "filter-videos";
- public const string ICON_FILTER_VIDEOS_DISABLED = "filter-videos-disabled";
- public const string ICON_FILTER_RAW = "filter-raw";
- public const string ICON_FILTER_RAW_DISABLED = "filter-raw-disabled";
- public const string ICON_FILTER_FLAGGED = "filter-flagged";
- public const string ICON_FILTER_FLAGGED_DISABLED = "filter-flagged-disabled";
- public const string ICON_TRASH_EMPTY = "user-trash";
- public const string ICON_TRASH_FULL = "user-trash-full";
- public const string ICON_VIDEOS_PAGE = "videos-page";
- public const string ICON_FLAGGED_PAGE = "flag-page";
- public const string ICON_FLAGGED_TRINKET = "flag-trinket.png";
+ public const string ICON_EVENTS = "multiple-events-symbolic";
+ public const string ICON_ONE_EVENT = "one-event-symbolic";
+ public const string ICON_NO_EVENT = "no-event-symbolic";
+ public const string ICON_ONE_TAG = "one-tag-symbolic";
+ public const string ICON_TAGS = "multiple-tags-symbolic";
+ public const string ICON_FOLDER = "folder-symbolic";
+ public const string ICON_FOLDER_DOCUMENTS = "folder-documents-symbolic";
+ public const string ICON_IMPORTING = "go-down-symbolic";
+ public const string ICON_LAST_IMPORT = "document-open-recent-symbolic";
+ public const string ICON_MISSING_FILES = "process-stop-symbolic";
+ public const string ICON_PHOTOS = "shotwell-symbolic";
+ public const string ICON_SINGLE_PHOTO = "image-x-generic-symbolic";
+ public const string ICON_TRASH_EMPTY = "user-trash-symbolic";
+ public const string ICON_TRASH_FULL = "user-trash-full-symbolic";
+ public const string ICON_ONE_FACE = "avatar-default-symbolic";
+ public const string ICON_FACES = "avatar-default-symbolic";
public const string ROTATE_CW_MENU = _("Rotate _Right");
public const string ROTATE_CW_LABEL = _("Rotate");
@@ -332,6 +301,15 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public const string UNFLAG_MENU = _("Un_flag");
+ public const string FACES_MENU = _("Faces");
+ public const string FACES_LABEL = _("Faces");
+ public const string FACES_TOOLTIP = _("Mark faces of people in the photo");
+ public const string MODIFY_FACES_LABEL = _("Modify Faces");
+ public const string DELETE_FACE_TITLE = _("Delete Face");
+ public const string DELETE_FACE_SIDEBAR_MENU = _("_Delete");
+ public const string RENAME_FACE_SIDEBAR_MENU = _("_Rename…");
+ public const string FACES_MENU_SECTION = "FacesMenuPlaceholder";
+
public string launch_editor_failed(Error err) {
return _("Unable to launch editor: %s").printf(err.message);
}
@@ -423,6 +401,38 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public string delete_search_label(string name) {
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);
+ }
+
+ public string remove_face_from_photos_menu(string name, int count) {
+ return ngettext ("Remove Face “%s” From _Photo",
+ "Remove Face “%s” From _Photos", count).printf(name);
+ }
+
+ public string remove_face_from_photos_label(string name, int count) {
+ return ngettext ("Remove Face “%s” From Photo",
+ "Remove Face “%s” From Photos", count).printf(name);
+ }
+
+ public string rename_face_menu(string name) {
+ return _("Re_name Face “%s”…").printf(name);
+ }
+
+ public string rename_face_label(string old_name, string new_name) {
+ return _("Rename Face “%s” to “%s”").printf(old_name, new_name);
+ }
+
+ public string delete_face_menu(string name) {
+ return _("_Delete Face “%s”").printf(name);
+ }
+
+ public string delete_face_label(string name) {
+ return _("Delete Face “%s”").printf(name);
+ }
+#endif
private unowned string rating_label(Rating rating) {
switch (rating) {
@@ -521,6 +531,8 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
private string get_stars(Rating rating) {
switch (rating) {
+ case Rating.REJECTED:
+ return "\xE2\x9D\x8C";
case Rating.ONE:
return "\xE2\x98\x85";
case Rating.TWO:
@@ -536,26 +548,116 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
}
}
- private Gdk.Pixbuf? get_rating_trinket(Rating rating, int scale) {
- switch (rating) {
- case Rating.REJECTED:
- return Resources.get_icon(Resources.ICON_RATING_REJECTED, scale);
- // case Rating.UNRATED needs no icon
- case Rating.ONE:
- return Resources.get_icon(Resources.ICON_RATING_ONE, scale);
- case Rating.TWO:
- return Resources.get_icon(Resources.ICON_RATING_TWO, scale*2);
- case Rating.THREE:
- return Resources.get_icon(Resources.ICON_RATING_THREE, scale*3);
- case Rating.FOUR:
- return Resources.get_icon(Resources.ICON_RATING_FOUR, scale*4);
- case Rating.FIVE:
- return Resources.get_icon(Resources.ICON_RATING_FIVE, scale*5);
- default:
- return null;
+ private GLib.HashTable<int?, Gdk.Pixbuf> trinket_cache = null;
+ private Gdk.Pixbuf? get_cached_trinket(int key) {
+ if (trinket_cache == null) {
+ trinket_cache = new GLib.HashTable<int?, Gdk.Pixbuf>(int_hash, int_equal);
}
+
+ if (trinket_cache[key] != null) {
+ return trinket_cache[key];
+ }
+
+ return null;
}
-
+
+ public Gdk.Pixbuf? get_video_trinket(int scale) {
+ int cache_key = scale << 18;
+ var cached_pixbuf = get_cached_trinket(cache_key);
+
+ if (cached_pixbuf != null)
+ return cached_pixbuf;
+
+ try {
+ var theme = Gtk.IconTheme.get_default();
+ var info = theme.lookup_icon ("filter-videos-symbolic", (int)(scale * 2), Gtk.IconLookupFlags.GENERIC_FALLBACK);
+ var icon = info.load_symbolic({0.8, 0.8, 0.8, 1.0}, null, null, null);
+ var surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, icon.width, icon.height);
+ var ctx = new Cairo.Context(surface);
+ ctx.set_source_rgba(0.0, 0.0, 0.0, 0.35);
+ ctx.rectangle(0, 0, icon.width, icon.height);
+ ctx.fill();
+ Gdk.cairo_set_source_pixbuf(ctx, icon, 0, 0);
+ ctx.paint();
+
+ trinket_cache[cache_key] = Gdk.pixbuf_get_from_surface(surface, 0, 0, icon.width, icon.height);
+ return trinket_cache[cache_key];
+ } catch (Error err) {
+ critical ("%s", err.message);
+
+ return null;
+ }
+ }
+
+ public Gdk.Pixbuf? get_flagged_trinket(int scale) {
+ int cache_key = scale << 16;
+ var cached_pixbuf = get_cached_trinket(cache_key);
+
+ if (cached_pixbuf != null)
+ return cached_pixbuf;
+
+ try {
+ var theme = Gtk.IconTheme.get_default();
+ var info = theme.lookup_icon ("filter-flagged-symbolic", (int)(scale * 1.33), Gtk.IconLookupFlags.GENERIC_FALLBACK);
+ var icon = info.load_symbolic({0.8, 0.8, 0.8, 1.0}, null, null, null);
+ var surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, icon.width, icon.height);
+ var ctx = new Cairo.Context(surface);
+ ctx.set_source_rgba(0.0, 0.0, 0.0, 0.35);
+ ctx.rectangle(0, 0, icon.width, icon.height);
+ ctx.fill();
+ Gdk.cairo_set_source_pixbuf(ctx, icon, 0, 0);
+ ctx.paint();
+
+ trinket_cache[cache_key] = Gdk.pixbuf_get_from_surface(surface, 0, 0, icon.width, icon.height);
+ return trinket_cache[cache_key];
+ } catch (Error err) {
+ critical ("%s", err.message);
+
+ return null;
+ }
+ }
+
+ private Gdk.Pixbuf? get_rating_trinket(Rating rating, int scale) {
+ if (rating == Rating.UNRATED)
+ return null;
+
+ int rating_key = (rating << 8) + scale;
+
+ var cached_pixbuf = get_cached_trinket(rating_key);
+ if (cached_pixbuf != null)
+ return cached_pixbuf;
+
+ var layout = AppWindow.get_instance().create_pango_layout(get_stars(rating));
+
+ // Adjust style according to scale (depending on whether it is rendered on a Thumbnail or on a full foto)
+ var att = new Pango.AttrList();
+ var a = Pango.attr_scale_new((double)scale/12.0);
+ att.insert(a.copy());
+ layout.set_attributes(att);
+
+ // Render the layout with a slight dark background so it stands out on all kinds of images
+ // FIXME: Cache the result
+ int width, height;
+ layout.get_pixel_size(out width, out height);
+ var surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, width, height);
+ var ctx = new Cairo.Context(surface);
+ ctx.set_source_rgba(0.0, 0.0, 0.0, 0.35);
+ ctx.rectangle(0,0,width,height);
+ ctx.fill();
+ if (rating == Rating.REJECTED)
+ ctx.set_source_rgba(0.8, 0.0, 0.0, 1.0);
+ else
+ ctx.set_source_rgba(0.8, 0.8, 0.8, 1.0);
+
+ ctx.move_to(0, 0);
+ Pango.cairo_show_layout(ctx, layout);
+
+ cached_pixbuf = Gdk.pixbuf_get_from_surface(surface, 0, 0, width, height);
+ trinket_cache[rating_key] = cached_pixbuf;
+
+ return cached_pixbuf;
+ }
+
private void generate_rating_strings() {
string menu_base = "%s";
string label_base = _("Rate %s");
@@ -906,7 +1008,7 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
// fetch from cache and if not present, from disk
Gdk.Pixbuf? pixbuf = icon_cache.get(name);
if (pixbuf == null) {
- pixbuf = load_icon(name, 0);
+ pixbuf = load_icon(name, scale);
if (pixbuf == null)
return null;
@@ -929,6 +1031,14 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public Gdk.Pixbuf? load_icon(string name, int scale = DEFAULT_ICON_SCALE) {
Gdk.Pixbuf pixbuf = null;
try {
+ var theme = Gtk.IconTheme.get_default();
+ var info = theme.lookup_icon(name, scale, Gtk.IconLookupFlags.GENERIC_FALLBACK);
+ pixbuf = info.load_symbolic_for_context(AppWindow.get_instance().get_style_context(), null);
+ } catch (Error err) {
+ debug("Failed to find icon %s in theme, falling back to resources", name);
+ }
+
+ try {
var path = "/org/gnome/Shotwell/icons/%s".printf(name);
pixbuf = new Gdk.Pixbuf.from_resource(path);
} catch (Error err) {
@@ -953,7 +1063,7 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
if (dir.get_path().has_suffix("src")) {
dir = dir.get_parent().get_parent();
}
-
+
File help_dir = dir.get_child("help").get_child("C");
File help_index = help_dir.get_child("index.page");
@@ -975,7 +1085,7 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
return null;
}
- public static void launch_help(Gdk.Screen screen, string? anchor=null) throws Error {
+ public static void launch_help(Gtk.Window window, string? anchor=null) throws Error {
string? help_path = get_help_path();
if(help_path != null) {
@@ -1001,50 +1111,16 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
}
// launch from system-installed help
+ var uri = "help:shotwell";
if (anchor != null) {
- sys_show_uri(screen, "help:shotwell" + anchor);
- } else {
- sys_show_uri(screen, "help:shotwell");
+ uri += anchor;
}
- }
-
- public string to_css_color(Gdk.RGBA color) {
- int r = (int) (color.red * 255);
- int g = (int) (color.green * 255);
- int b = (int) (color.blue * 255);
-
- return "rgb(%d, %d, %d)".printf(r, g, b);
+
+ Gtk.show_uri_on_window(window, uri, Gdk.CURRENT_TIME);
}
public const int ALL_DATA = -1;
- private static Gee.Map<Gtk.Widget, Gtk.CssProvider> providers = null;
-
- public static void style_widget(Gtk.Widget widget, string stylesheet) {
- if (providers == null)
- providers = new Gee.HashMap<Gtk.Widget, Gtk.CssProvider>();
-
- if (providers.has_key(widget))
- widget.get_style_context().remove_provider(providers.get(widget));
-
- Gtk.CssProvider styler = new Gtk.CssProvider();
-
- try {
- styler.load_from_data(stylesheet, ALL_DATA);
- } catch (Error e) {
- warning("couldn't parse widget stylesheet '%s': %s", stylesheet,
- e.message);
- // short-circuit return -- if the stylesheet couldn't be interpreted
- // then we can't do anything more
- return;
- }
-
- widget.get_style_context().add_provider(styler,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- providers.set(widget, styler);
- }
-
public static int use_header_bar() {
if (Environment.get_variable("SHOTWELL_USE_HEADERBARS") != null) {
return 0;
@@ -1056,16 +1132,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
return use_header ? 1 : 0;
}
- public const string CUSTOM_CSS =
- """LibraryWindow .pane-separator {
- background-color: @borders;
- }
- SearchFilterToolbar {
- border-width: 0 0 1px 0;
- border-style: solid;
- border-color: @borders;
- }""";
-
public const string ONIMAGE_FONT_COLOR = "#000000";
public const string ONIMAGE_FONT_BACKGROUND = "rgba(255,255,255,0.5)";
}