[shotwell] Prevent accidental profile creation
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Prevent accidental profile creation
- Date: Sat, 26 Jun 2021 10:57:47 +0000 (UTC)
commit 5fb2f1621252ebf206aceabf86d1f8324738d37e
Author: Jens Georg <mail jensge org>
Date: Sat Jun 26 12:57:34 2021 +0200
Prevent accidental profile creation
src/Profiles.vala | 9 +++++++--
src/main.vala | 10 ++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/Profiles.vala b/src/Profiles.vala
index 3fb7ebf0..52b2e3b4 100644
--- a/src/Profiles.vala
+++ b/src/Profiles.vala
@@ -44,12 +44,17 @@ namespace Shotwell {
}
}
+ public bool has_profile (string profile, out string group_name = null) {
+ group_name = Base64.encode (profile.data);
+ return profiles.has_group(group_name);
+ }
+
public void set_profile(string profile) {
assert(this.profile == null);
this.profile = profile;
- group_name = Base64.encode(profile.data);
- if (profiles.has_group(group_name))
+
+ if (has_profile (this.profile, out this.group_name))
return;
try {
diff --git a/src/main.vala b/src/main.vala
index f1a80966..f5365211 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -341,6 +341,7 @@ bool no_runtime_monitoring = false;
bool fullscreen = false;
bool show_metadata = false;
string? profile = null;
+bool create_profile = false;
bool list_profiles = false;
const OptionEntry[] entries = {
@@ -351,6 +352,7 @@ const OptionEntry[] entries = {
{ "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") },
+ { "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 }
};
@@ -395,6 +397,14 @@ void main(string[] args) {
// 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]