summaryrefslogtreecommitdiff
path: root/src/main.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
commitb86540b743f1a87a163ffb811c8fe22a01fefa38 (patch)
treeb47cb3bb83c2377234226fb3987ab3320a987dd9 /src/main.vala
parentac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff)
parente905d8e16eec152d19797937f13ba3cf4b8f8aca (diff)
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
Diffstat (limited to 'src/main.vala')
-rw-r--r--src/main.vala171
1 files changed, 125 insertions, 46 deletions
diff --git a/src/main.vala b/src/main.vala
index d0cb246..cdc9b27 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -72,6 +72,10 @@ void library_exec(string[] mounts) {
result.to_string());
break;
}
+
+ // Need to set this before anything else, but _after_ setting the profile
+ var use_dark = Config.Facade.get_instance().get_gtk_theme_variant();
+ Gtk.Settings.get_default().gtk_application_prefer_dark_theme = use_dark;
if (errormsg != null) {
Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.MODAL,
@@ -107,7 +111,7 @@ void library_exec(string[] mounts) {
progress_dialog.update_display_every(100);
progress_dialog.set_minimum_on_screen_time_msec(250);
try {
- progress_dialog.icon = new Gdk.Pixbuf.from_resource("/org/gnome/Shotwell/icons/shotwell.svg");
+ progress_dialog.icon = new Gdk.Pixbuf.from_resource("/org/gnome/Shotwell/icons/hicolor/scalable/org.gnome.Shotwell.svg");
} catch (Error err) {
debug("Warning - could not load application icon for loading window: %s", err.message);
}
@@ -253,13 +257,43 @@ private void report_system_pictures_import(ImportManifest manifest, BatchImportR
ImportUI.report_manifest(manifest, true);
}
+void dump_tags (GExiv2.Metadata metadata, string[] tags) throws Error {
+ foreach (string tag in tags) {
+ try {
+ print("%-64s%s\n",
+ tag,
+ metadata.try_get_tag_interpreted_string (tag));
+ } catch (Error err) {
+ print("Failed to get tag %s: %s\n", tag, err.message);
+ }
+ }
+}
+
+void dump_metadata (string filename) {
+ try {
+ var metadata = new GExiv2.Metadata();
+ var file = File.new_for_commandline_arg(filename);
+ metadata.from_stream (file.read());
+
+ dump_tags(metadata, metadata.get_exif_tags());
+ dump_tags(metadata, metadata.get_iptc_tags());
+ dump_tags(metadata, metadata.get_xmp_tags());
+ } catch (Error err) {
+ stderr.printf("Unable to dump metadata for %s: %s\n", filename, err.message);
+ }
+}
+
void editing_exec(string filename, bool fullscreen) {
File initial_file = File.new_for_commandline_arg(filename);
// preconfigure units
Direct.preconfigure(initial_file);
Db.preconfigure(null);
-
+
+ // Need to set this before anything else, but _after_ setting the profile
+ var use_dark = Config.Facade.get_instance().get_gtk_theme_variant();
+ Gtk.Settings.get_default().gtk_application_prefer_dark_theme = use_dark;
+
// initialize units for direct-edit mode
try {
Direct.app_init();
@@ -278,6 +312,7 @@ void editing_exec(string filename, bool fullscreen) {
DirectWindow direct_window = new DirectWindow(initial_file);
direct_window.show_all();
+ direct_window.maximize();
debug("%lf seconds to Gtk.main()", startup_timer.elapsed());
@@ -299,43 +334,29 @@ void editing_exec(string filename, bool fullscreen) {
namespace CommandlineOptions {
bool no_startup_progress = false;
-string data_dir = null;
+string? data_dir = null;
bool show_version = false;
bool no_runtime_monitoring = false;
bool fullscreen = false;
-
-private OptionEntry[]? entries = null;
-
-public OptionEntry[] get_options() {
- if (entries != null)
- return entries;
-
- OptionEntry datadir = { "datadir", 'd', 0, OptionArg.FILENAME, &data_dir,
- _("Path to Shotwell’s private data"), _("DIRECTORY") };
- entries += datadir;
-
- OptionEntry no_monitoring = { "no-runtime-monitoring", 0, 0, OptionArg.NONE, &no_runtime_monitoring,
- _("Do not monitor library directory at runtime for changes"), null };
- entries += no_monitoring;
-
- OptionEntry no_startup = { "no-startup-progress", 0, 0, OptionArg.NONE, &no_startup_progress,
- _("Don’t display startup progress meter"), null };
- entries += no_startup;
-
- OptionEntry version = { "version", 'V', 0, OptionArg.NONE, &show_version,
- _("Show the application’s version"), null };
- entries += version;
-
- OptionEntry fullscreen = { "fullscreen", 'f', 0, OptionArg.NONE,
- &fullscreen, _("Start the application in fullscreen mode"), null };
- entries += fullscreen;
-
- OptionEntry terminator = { null, 0, 0, 0, null, null, null };
- entries += terminator;
-
- return entries;
-}
-
+bool show_metadata = false;
+string? profile = null;
+bool create_profile = false;
+bool list_profiles = false;
+bool browse_profiles = false;
+
+const OptionEntry[] entries = {
+ { "datadir", 'd', 0, OptionArg.FILENAME, ref data_dir, N_("Path to Shotwell’s private data"), N_("DIRECTORY") },
+ { "no-runtime-monitoring", 0, 0, OptionArg.NONE, ref no_runtime_monitoring, N_("Do not monitor library directory at runtime for changes"), null },
+ { "no-startup-progress", 0, 0, OptionArg.NONE, ref no_startup_progress, N_("Don’t display startup progress meter"), null },
+ { "version", 'V', 0, OptionArg.NONE, ref show_version, N_("Show the application’s version") },
+ { "fullscreen", 'f', 0, OptionArg.NONE, ref fullscreen, N_("Start the application in fullscreen mode"), null },
+ { "show-metadata", 'p', 0, OptionArg.NONE, ref show_metadata, N_("Print the metadata of the image file"), null },
+ { "profile", 'i', 0, OptionArg.STRING, ref profile, N_("Name for a custom profile"), N_("PROFILE") },
+ { "profile-browser", 'b', 0, OptionArg.NONE, ref browse_profiles, N_("Start with a browser of available profiles"), null },
+ { "create", 'c', 0, OptionArg.NONE, ref create_profile, N_("If PROFILE given with --profile does not exist, create it"), null },
+ { "list-profiles", 'l', 0, OptionArg.NONE, ref list_profiles, N_("Show available profiles"), null },
+ { null, 0, 0, 0, null, null, null }
+};
}
void main(string[] args) {
@@ -345,7 +366,7 @@ void main(string[] args) {
// This has to be done before the AppWindow is created in order to ensure the XMP
// parser is initialized in a thread-safe fashion; please see
- // http://redmine.yorba.org/issues/4120 for details.
+ // https://bugzilla.gnome.org/show_bug.cgi?id=717931 for details.
GExiv2.initialize();
GExiv2.log_use_glib_logging();
@@ -353,22 +374,30 @@ void main(string[] args) {
// logging mechanisms
GExiv2.log_set_level(GExiv2.LogLevel.DEBUG);
+ // If set to non-empty, initialize GdkPixbuf with an additional loader path
+ if (Resources.PIXBUF_LOADER_PATH != "") {
+ debug("Trying to set module path to %s", Resources.PIXBUF_LOADER_PATH);
+ try {
+ Gdk.Pixbuf.init_modules(Resources.PIXBUF_LOADER_PATH);
+ } catch (Error err) {
+ message("Failed to set additional pixbuf loader path: %s", err.message);
+ }
+ }
+
// following the GIO programming guidelines at http://developer.gnome.org/gio/2.26/ch03.html,
// set the GSETTINGS_SCHEMA_DIR environment variable to allow us to load GSettings schemas from
// the build directory. this allows us to access local GSettings schemas without having to
// muck with the user's XDG_... directories, which is seriously frowned upon
if (AppDirs.get_install_dir() == null) {
GLib.Environment.set_variable("GSETTINGS_SCHEMA_DIR", AppDirs.get_lib_dir().get_path() +
- "/misc", true);
+ "/data/gsettings", true);
}
-
+
// init GTK (valac has already called g_threads_init())
try {
- Gtk.init_with_args(ref args, _("[FILE]"), CommandlineOptions.get_options(),
+ Gtk.init_with_args(ref args, _("[FILE]"), CommandlineOptions.entries,
Resources.APP_GETTEXT_PACKAGE);
- var use_dark = Config.Facade.get_instance().get_gtk_theme_variant();
- Gtk.Settings.get_default().gtk_application_prefer_dark_theme = use_dark;
} catch (Error e) {
print(e.message + "\n");
print(_("Run “%s --help” to see a full list of available command line options.\n"), args[0]);
@@ -376,6 +405,41 @@ void main(string[] args) {
return;
}
+ if (CommandlineOptions.browse_profiles) {
+ var window = new Gtk.Dialog();
+ window.set_title (_("Choose Shotwell's profile"));
+ var browser = new Shotwell.ProfileBrowser();
+ browser.profile_activated.connect((profile) => {
+ CommandlineOptions.profile = profile;
+ window.response(Gtk.ResponseType.OK);
+ });
+ window.get_content_area().add(browser);
+ window.set_size_request(430, 560);
+ var response = window.run();
+ window.destroy();
+ // Anything else than selecting an entry in the list will stop shotwell from starting
+ if (response != Gtk.ResponseType.OK) {
+ return;
+ }
+ }
+
+ // Setup profile manager
+ if (CommandlineOptions.profile != null) {
+ var manager = Shotwell.ProfileManager.get_instance();
+ if (!manager.has_profile (CommandlineOptions.profile)) {
+ if (!CommandlineOptions.create_profile) {
+ print(_("Profile %s does not exist. Did you mean to pass --create as well?"),
+ CommandlineOptions.profile);
+ AppDirs.terminate();
+ return;
+ }
+ }
+ manager.set_profile(CommandlineOptions.profile);
+ CommandlineOptions.data_dir = manager.derive_data_dir(CommandlineOptions.data_dir);
+ } else {
+ message("Starting session with system profile");
+ }
+
if (CommandlineOptions.show_version) {
if (Resources.GIT_VERSION != "")
print("%s %s (%s)\n", Resources.APP_TITLE, Resources.APP_VERSION, Resources.GIT_VERSION);
@@ -386,7 +450,16 @@ void main(string[] args) {
return;
}
-
+
+ if (CommandlineOptions.list_profiles) {
+ var manager = Shotwell.ProfileManager.get_instance();
+ manager.print_profiles();
+
+ AppDirs.terminate();
+
+ return;
+ }
+
// init debug prior to anything else (except Gtk, which it relies on, and AppDirs, which needs
// to be set ASAP) ... since we need to know what mode we're in, examine the command-line
// first
@@ -397,15 +470,21 @@ void main(string[] args) {
string[] mounts = new string[0];
string filename = null;
- for (int ctr = 1; ctr < args.length; ctr++) {
- string arg = args[ctr];
-
+ foreach (var arg in args[1:args.length]) {
if (LibraryWindow.is_mount_uri_supported(arg)) {
mounts += arg;
} else if (is_string_empty(filename) && !arg.contains("://")) {
filename = arg;
}
}
+
+ if (CommandlineOptions.show_metadata) {
+ dump_metadata (filename);
+
+ AppDirs.terminate();
+
+ return;
+ }
Debug.init(is_string_empty(filename) ? Debug.LIBRARY_PREFIX : Debug.VIEWER_PREFIX);