Added an error message in case some entries can not be read
This commit is contained in:
parent
31eb9fd406
commit
5604ff93d7
@ -722,6 +722,7 @@ static void mainWindow_show_error(struct mainWindow *mainWindow, gchar *text)
|
|||||||
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gboolean gpg_enabled)
|
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gboolean gpg_enabled)
|
||||||
{
|
{
|
||||||
struct mdiary_scanner *mdiary_scanner;
|
struct mdiary_scanner *mdiary_scanner;
|
||||||
|
gchar *temp;
|
||||||
|
|
||||||
g_print("Switching workspace to %s.\n", path);
|
g_print("Switching workspace to %s.\n", path);
|
||||||
gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverWorkspace));
|
gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverWorkspace));
|
||||||
@ -739,6 +740,15 @@ void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gbo
|
|||||||
gtk_widget_set_visible(mainWindow->buttonDecrypt, TRUE);
|
gtk_widget_set_visible(mainWindow->buttonDecrypt, TRUE);
|
||||||
else
|
else
|
||||||
gtk_widget_set_visible(mainWindow->buttonDecrypt, FALSE);
|
gtk_widget_set_visible(mainWindow->buttonDecrypt, FALSE);
|
||||||
|
|
||||||
|
if (mdiary_scanner->entries_failed) {
|
||||||
|
temp = g_strdup_printf("%d entr%s could not be read.\n"
|
||||||
|
"See the console log for more information.",
|
||||||
|
mdiary_scanner->entries_failed,
|
||||||
|
mdiary_scanner->entries_failed > 1 ? "ies" : "y");
|
||||||
|
mainWindow_show_error(mainWindow, temp);
|
||||||
|
g_free(temp);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
gtk_header_bar_set_subtitle(GTK_HEADER_BAR(mainWindow->headerBar), "No workspace opened.");
|
gtk_header_bar_set_subtitle(GTK_HEADER_BAR(mainWindow->headerBar), "No workspace opened.");
|
||||||
mainWindow_show_error(mainWindow, "Could not open workspace or no entries were found in it.");
|
mainWindow_show_error(mainWindow, "Could not open workspace or no entries were found in it.");
|
||||||
|
@ -265,6 +265,7 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
|
|||||||
guint header_state = 0;
|
guint header_state = 0;
|
||||||
|
|
||||||
g_message("Add file: %s\n", filename);
|
g_message("Add file: %s\n", filename);
|
||||||
|
mdiary_scanner->entries_failed++; /* Will be decremented again when entry was successfully added. */
|
||||||
|
|
||||||
if (!content) {
|
if (!content) {
|
||||||
file = g_file_new_for_path(filename);
|
file = g_file_new_for_path(filename);
|
||||||
@ -338,6 +339,7 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
|
|||||||
title = g_strdup("Untitled");
|
title = g_strdup("Untitled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mdiary_scanner->entries_failed--;
|
||||||
mdiary_scanner->entries_added++;
|
mdiary_scanner->entries_added++;
|
||||||
mdiary_add_entry_to_store(entryListStore,
|
mdiary_add_entry_to_store(entryListStore,
|
||||||
autoCompletion,
|
autoCompletion,
|
||||||
@ -378,6 +380,7 @@ static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner,
|
|||||||
g_message("GPG: Decryption OK!\n");
|
g_message("GPG: Decryption OK!\n");
|
||||||
mdiary_add_file_to_store(mdiary_scanner, filename, cmd_stdout, entryListStore, autoCompletion);
|
mdiary_add_file_to_store(mdiary_scanner, filename, cmd_stdout, entryListStore, autoCompletion);
|
||||||
} else {
|
} else {
|
||||||
|
mdiary_scanner->entries_failed++;
|
||||||
g_warning("GPG: Decryption of message failed!\n"
|
g_warning("GPG: Decryption of message failed!\n"
|
||||||
"---------- SNIP ----------\n"
|
"---------- SNIP ----------\n"
|
||||||
"%s"
|
"%s"
|
||||||
@ -450,6 +453,7 @@ struct mdiary_scanner *mdiary_scanner_new(gboolean gpg_enabled)
|
|||||||
mdiary_scanner->time_latest = 0;
|
mdiary_scanner->time_latest = 0;
|
||||||
mdiary_scanner->entries_added = 0;
|
mdiary_scanner->entries_added = 0;
|
||||||
mdiary_scanner->gpg_enabled = gpg_enabled;
|
mdiary_scanner->gpg_enabled = gpg_enabled;
|
||||||
|
mdiary_scanner->entries_failed = 0;
|
||||||
mdiary_scanner->entries_encrypted = 0;
|
mdiary_scanner->entries_encrypted = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ struct mdiary_scanner {
|
|||||||
gint64 time_latest;
|
gint64 time_latest;
|
||||||
gint entries_added;
|
gint entries_added;
|
||||||
gint entries_encrypted;
|
gint entries_encrypted;
|
||||||
|
gint entries_failed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mdiary_scanner *mdiary_scanner_new(gboolean gpg_enabled);
|
struct mdiary_scanner *mdiary_scanner_new(gboolean gpg_enabled);
|
||||||
|
Loading…
Reference in New Issue
Block a user