31#include <glib/gi18n.h>
32#include <glib/gstdio.h>
44 char lck_pathname[1024];
45 snprintf(lck_pathname,
sizeof(lck_pathname),
"%s.lock", err.
dbfilename);
46 char *lck_dirname = g_strdup(lck_pathname);
47 char *slash_pos = g_strrstr(lck_dirname,
"/");
50 char *label_text = g_markup_printf_escaped(
52 " Sorry, Ansel could not be started because the database is locked.\n"
54 " How to solve this problem?\n"
56 " 1 - If another Ansel instance is already running, \n"
57 " click \"Quit\" and either use that instance or close it before trying to start Ansel again. \n"
58 " (process ID <i><b>%d</b></i> created the database lock files)\n"
60 " 2 - If you cannot find any running instance of Ansel, try restarting your session or your computer. \n"
61 " This will close all running programs and should release any database locks. \n"
63 " 3 - If you have already tried the above steps, or you are certain that no other instances of Ansel are running, \n"
64 " this likely means the previous instance ended unexpectedly. \n"
65 " Click the \"Delete database lock files\" button to remove <i>data.db.lock</i> and <i>library.db.lock</i>. \n"
66 " Ansel will then attempt to load the database again. \n"
68 " <i><u>Caution!</u> Do not delete these files without first undertaking the above checks, \n"
69 " otherwise you risk generating serious inconsistencies in your database.</i>\n"),
74 _(
"Quit"), _(
"Retry"), _(
"Delete database lock files and try again"));
85 gboolean really_delete_lockfiles =
88 _(
"\n<u>Caution!</u> Are you sure you want to delete the database lock files?\n"
89 "This action should only be performed if you are certain no other Ansel instances are running.\n"), _(
"Quit"), _(
"Yes"));
90 if(really_delete_lockfiles)
98 _(
"\nThe database lock files have been deleted successfully.\n"),
106 gchar *err_text = g_markup_printf_escaped(
107 _(
"\nAt least one lock file could not be removed.\n"
108 "You may try to manually delete the files <i>data.db.lock</i> and <i>library.db.lock</i>\n"
109 "in folder <a href=\"file:///%s\">%s</a>.\n"), lck_dirname, lck_dirname);
128 char *label_text = g_markup_printf_escaped(_(
"the database schema has to be upgraded for\n"
130 "<span style='italic'>%s</span>\n"
131 "\nthis might take a long time in case of a large database\n\n"
132 "do you want to proceed or quit now to do a backup\n"),
135 const gboolean proceed =
137 _(
"close Ansel"), _(
"upgrade database"));
148 const char *later_info =
"";
150 later_info = _(
"click later to be asked on next startup");
152 later_info = _(
"click later to be asked when closing Ansel");
154 later_info = _(
"click later to be asked next time when closing Ansel");
157 char *label_text = g_markup_printf_escaped(_(
"the database could use some maintenance\n"
159 "there's <span style='italic'>%s</span> to be freed"
161 "do you want to proceed now?\n\n"
163 "you can always change maintenance preferences in core options"),
164 size_info, later_info);
166 const gboolean proceed =
168 _(
"later"), _(
"yes"));
183 const char *
const dbfilename = context->
dbfilename;
184 const char *
const quick_check = context->
quick_check;
190 const GtkDialogFlags dflags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
192 char *label_text = NULL;
196 dialog = gtk_dialog_new_with_buttons(_(
"Ansel - Database is read-only"), NULL, dflags,
197 _(
"Close Ansel"), GTK_RESPONSE_CLOSE, NULL);
198 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
199 label_text = g_markup_printf_escaped(_(
"<span weight='bold'>Ansel library database is read-only</span>\n\n"
200 "This happens if you don't have permissions to write on the filesystem\n"
201 "or if you have restored a write-protected backup snapshot.\n\n"
202 "Please change the filesystem access permissions for:\n\n"
203 "\t<span style='italic'>%s</span>"),
208 const char *label_options;
209 if(snapshot_available)
211 dialog = gtk_dialog_new_with_buttons(_(
"ansel - error opening database"), NULL, dflags,
212 _(
"close Ansel"), GTK_RESPONSE_CLOSE,
213 _(
"attempt restore"), GTK_RESPONSE_ACCEPT,
214 _(
"delete database"), GTK_RESPONSE_REJECT, NULL);
215 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
216 label_options = _(
"do you want to close Ansel now to manually restore\n"
217 "the database from a backup, attempt an automatic restore\n"
218 "from the most recent snapshot or delete the corrupted database\n"
219 "and start with a new one?");
223 dialog = gtk_dialog_new_with_buttons(_(
"ansel - error opening database"), NULL, dflags,
224 _(
"close Ansel"), GTK_RESPONSE_CLOSE,
225 _(
"delete database"), GTK_RESPONSE_REJECT, NULL);
226 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
227 label_options = _(
"do you want to close Ansel now to manually restore\n"
228 "the database from a backup or delete the corrupted database\n"
229 "and start with a new one?");
234 label_text = g_markup_printf_escaped(_(
"an error has occurred while trying to open the database from\n"
236 "<span style='italic'>%s</span>\n"
238 "it seems that the database is corrupted.\n"
240 dbfilename,
IS_NULL_PTR(quick_check) ?
"" : quick_check, label_options);
243 GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
245 gtk_label_set_markup(GTK_LABEL(label), label_text);
247 gtk_container_add(GTK_CONTAINER(content_area), label);
248 gtk_widget_show_all(content_area);
250 const int resp = gtk_dialog_run(GTK_DIALOG(dialog));
251 gtk_widget_destroy(dialog);
255 case GTK_RESPONSE_ACCEPT:
257 case GTK_RESPONSE_REJECT:
static void error(char *msg)
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
void dt_database_take_error(dt_database_error_t *error)
void dt_database_error_free(dt_database_error_t *error)
void dt_database_set_prompt_handler(dt_database_prompt_handler_t handler)
int dt_database_delete_lock_files(const char *dbfilename)
@ DT_DATABASE_RESPONSE_CLOSE
@ DT_DATABASE_RESPONSE_PROCEED
@ DT_DATABASE_RESPONSE_RESTORE
@ DT_DATABASE_RESPONSE_DELETE
@ DT_DATABASE_PROMPT_UPGRADE
@ DT_DATABASE_PROMPT_MAINTENANCE
@ DT_DATABASE_PROMPT_READONLY
static dt_database_response_t _prompt_upgrade(const dt_database_prompt_context_t *context)
void dt_database_gui_register_handlers(void)
gboolean dt_database_show_error(void)
static dt_database_response_t _database_prompt(const dt_database_prompt_context_t *context)
static dt_database_response_t _prompt_maintenance(const dt_database_prompt_context_t *context)
int dt_gui_show_standalone_three_choice_dialog(const char *title, const char *markup, const char *first_text, const char *second_text, const char *third_text)
gboolean dt_gui_show_standalone_yes_no_dialog(const char *title, const char *markup, const char *no_text, const char *yes_text)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
dt_imageio_retval_t status
dt_database_prompt_t prompt
guint64 reclaimable_bytes
gboolean snapshot_available