Compare commits

..

No commits in common. "master" and "mdrework" have entirely different histories.

5 changed files with 116 additions and 174 deletions

View File

@ -10,7 +10,7 @@ url='https://git.notsyncing.net:8080/markus/mdiary'
license=('GPL') license=('GPL')
depends=('gtk3' 'glib2' 'webkit2gtk') depends=('gtk3' 'glib2' 'webkit2gtk')
makedepends=('cmake') makedepends=('cmake')
source=("$pkgname"::"git+https://git.notsyncing.net/markus/mdiary.git") source=("$pkgname"::"git+https://notsyncing.net:8080/markus/mdiary.git")
sha1sums=('SKIP') sha1sums=('SKIP')
pkgver () { pkgver () {

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 --> <!-- Generated with glade 3.20.4 -->
<interface> <interface>
<requires lib="gtk+" version="3.20"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkTextBuffer" id="entryTextBuffer"/> <object class="GtkTextBuffer" id="entryTextBuffer"/>
@ -78,93 +78,6 @@
<property name="width_request">720</property> <property name="width_request">720</property>
<property name="height_request">405</property> <property name="height_request">405</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">MDiary</property>
<property name="subtitle">No workspace opened.</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popover">popoverWorkspace</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Choose Workspace</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">pan-down-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonNew">
<property name="label" translatable="yes">New Entry</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonDecrypt">
<property name="label" translatable="yes">Decrypt GPG</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">imageDecrypt</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child> <child>
<object class="GtkPaned" id="mainPane"> <object class="GtkPaned" id="mainPane">
<property name="visible">True</property> <property name="visible">True</property>
@ -496,6 +409,93 @@
</child> </child>
</object> </object>
</child> </child>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">MDiary</property>
<property name="subtitle">No workspace opened.</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popover">popoverWorkspace</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Choose Workspace</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">pan-down-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonDecrypt">
<property name="label" translatable="yes">Decrypt GPG</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">imageDecrypt</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttonNew">
<property name="label" translatable="yes">New Entry</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object> </object>
<object class="GtkPopover" id="popoverDate"> <object class="GtkPopover" id="popoverDate">
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -514,19 +514,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="window_position">center</property> <property name="window_position">center</property>
<property name="destroy_with_parent">True</property> <property name="destroy_with_parent">True</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Preferences</property>
<property name="has_subtitle">False</property>
<property name="show_close_button">True</property>
<property name="decoration_layout">close:</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
@ -640,18 +627,18 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title">Preferences</property>
<property name="has_subtitle">False</property>
<property name="show_close_button">True</property>
<property name="decoration_layout">close:</property>
<child> <child>
<object class="GtkButton" id="buttonOpenWorkspaceFolder"> <placeholder/>
<property name="label" translatable="yes">Open Workspace in File Browser</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
</child> </child>

View File

@ -2,10 +2,10 @@
#include "mdiary.h" #include "mdiary.h"
const gchar *default_template[] = {"# Title\n" const gchar *default_template[] = {"# Title\n"
" Date: ", "\0", "Date: ", "\0",
"\n" "\n"
" Summary: \n" "Summary: \n"
" Tags: \n" "Tags: \n"
"\n" "\n"
"Text", "Text",
NULL}; NULL};
@ -527,13 +527,6 @@ static void mainWindow_settings_buttonCustomNewFileDateFormat_clicked(GtkComboBo
} }
} }
static void mainWindow_settings_buttonOpenWorkspaceFolder_clicked(GtkComboBox *widget, gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
mainWindow_openExternalEditor(mainWindow->currentWorkspaceUrl);
}
const gchar *newDateFormats[] = {"%d.%m.%Y %H:%M", const gchar *newDateFormats[] = {"%d.%m.%Y %H:%M",
"%Y-%m-%d %H:%M", "%Y-%m-%d %H:%M",
NULL}; NULL};
@ -612,11 +605,6 @@ static void mainWindow_configure_settings_dialog(struct mainWindow *mainWindow)
(GCallback) mainWindow_settings_buttonCustomNewFileDateFormat_clicked, (GCallback) mainWindow_settings_buttonCustomNewFileDateFormat_clicked,
mainWindow); mainWindow);
g_signal_connect(mainWindow->settingsDialog.buttonOpenWorkspaceFolder,
"clicked",
(GCallback) mainWindow_settings_buttonOpenWorkspaceFolder_clicked,
mainWindow);
g_signal_connect(mainWindow->settingsDialog.settingsDialog, g_signal_connect(mainWindow->settingsDialog.settingsDialog,
"delete-event", "delete-event",
(GCallback) mainWindow_settings_delete_event, (GCallback) mainWindow_settings_delete_event,
@ -676,7 +664,6 @@ struct mainWindow *mainWindow_new()
mainWindow->settingsDialog.stackNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "stackNewDateFormat")); mainWindow->settingsDialog.stackNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "stackNewDateFormat"));
mainWindow->settingsDialog.entryNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "entryNewDateFormat")); mainWindow->settingsDialog.entryNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "entryNewDateFormat"));
mainWindow->settingsDialog.buttonCustomNewFileDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "buttonCustomNewFileDateFormat")); mainWindow->settingsDialog.buttonCustomNewFileDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "buttonCustomNewFileDateFormat"));
mainWindow->settingsDialog.buttonOpenWorkspaceFolder = GTK_WIDGET(gtk_builder_get_object(builder, "buttonOpenWorkspaceFolder"));
mainWindow->filterSettings.time_start = 0; mainWindow->filterSettings.time_start = 0;
mainWindow->filterSettings.time_end = -1; mainWindow->filterSettings.time_end = -1;
@ -724,8 +711,6 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow,
mainWindow->time_latest = time_latest; mainWindow->time_latest = time_latest;
mainWindow->filterSettings.hide_all = hide_all; mainWindow->filterSettings.hide_all = hide_all;
gtk_widget_set_sensitive(mainWindow->mainPane, !hide_all); gtk_widget_set_sensitive(mainWindow->mainPane, !hide_all);
gtk_widget_set_sensitive(mainWindow->settingsDialog.buttonOpenWorkspaceFolder,
!hide_all);
mainWindow_clearSearch(NULL, mainWindow); mainWindow_clearSearch(NULL, mainWindow);
} }

View File

@ -93,7 +93,6 @@ struct mainWindow {
GtkWidget *stackNewDateFormat; GtkWidget *stackNewDateFormat;
GtkWidget *comboNewDateFormat; GtkWidget *comboNewDateFormat;
GtkWidget *buttonCustomNewFileDateFormat; GtkWidget *buttonCustomNewFileDateFormat;
GtkWidget *buttonOpenWorkspaceFolder;
GtkWidget *entryNewDateFormat; GtkWidget *entryNewDateFormat;
} settingsDialog; } settingsDialog;
}; };

View File

@ -246,7 +246,7 @@ static gchar *mdiary_get_line_from_string(gchar **str_ptr)
* @param autoCompletion * @param autoCompletion
*/ */
static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner, static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
gchar *filename, gchar *content, GList *autotags, gchar *filename, gchar *content,
GtkListStore *entryListStore, GtkListStore *autoCompletion) GtkListStore *entryListStore, GtkListStore *autoCompletion)
{ {
GFile *file = NULL; GFile *file = NULL;
@ -263,8 +263,6 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
GString *text = NULL; GString *text = NULL;
guint header_state = 0; guint header_state = 0;
GList *l;
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. */ mdiary_scanner->entries_failed++; /* Will be decremented again when entry was successfully added. */
@ -325,7 +323,7 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
} }
if (!tagList) { if (!tagList) {
g_warning("PARSER: Could not detect tags in file!\n"); g_warning("PARSER: Could not detect tags in file!\n");
tagList = g_list_append(tagList, g_strdup("untagged")); tagList = g_list_append(tagList, "untagged");
} }
if (!text) { if (!text) {
g_warning("PARSER: Could not find any text in file!\n"); g_warning("PARSER: Could not find any text in file!\n");
@ -340,11 +338,6 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
title = g_strdup("Untitled"); title = g_strdup("Untitled");
} }
for (l = autotags; l != NULL; l = l->next)
{
tagList = g_list_append(tagList, g_strdup(l->data));
}
mdiary_scanner->entries_failed--; mdiary_scanner->entries_failed--;
mdiary_scanner->entries_added++; mdiary_scanner->entries_added++;
mdiary_add_entry_to_store(entryListStore, mdiary_add_entry_to_store(entryListStore,
@ -366,8 +359,6 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
g_input_stream_close(G_INPUT_STREAM(stream), NULL, NULL); g_input_stream_close(G_INPUT_STREAM(stream), NULL, NULL);
g_object_unref(file); g_object_unref(file);
} }
g_list_free_full(tagList, *g_free);
g_string_free(text, 0); g_string_free(text, 0);
g_free(summary); g_free(summary);
g_free(title); g_free(title);
@ -375,7 +366,7 @@ static void mdiary_add_file_to_store(struct mdiary_scanner *mdiary_scanner,
} }
static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner, static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner,
gchar *filename, GList **autotags, gchar *filename,
GtkListStore *entryListStore, GtkListStore *autoCompletion) GtkListStore *entryListStore, GtkListStore *autoCompletion)
{ {
gchar *cmd = NULL; gchar *cmd = NULL;
@ -383,34 +374,19 @@ static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner,
gchar *cmd_stderr = NULL; gchar *cmd_stderr = NULL;
gint exit_status = 0; gint exit_status = 0;
g_message("Decrypt file: %s", filename); cmd = g_strdup_printf("gpg --decrypt %s", filename);
if (mdiary_scanner->gpg_enabled == 2) { /* GPG operation was manually cancelled */
g_warning("GPG: Skipping file.");
mdiary_scanner->entries_failed++; /* Simply count files that won't be decoded. */
return;
}
cmd = g_strdup_printf("gpg --decrypt \"%s\"", filename);
if (g_spawn_command_line_sync(cmd, &cmd_stdout, &cmd_stderr, &exit_status, NULL) && exit_status == 0) { if (g_spawn_command_line_sync(cmd, &cmd_stdout, &cmd_stderr, &exit_status, NULL) && exit_status == 0) {
g_message("GPG: Decryption OK!\n"); g_message("GPG: Decryption OK!\n");
*autotags = g_list_append(*autotags, "encrypted"); mdiary_add_file_to_store(mdiary_scanner, filename, cmd_stdout, entryListStore, autoCompletion);
mdiary_add_file_to_store(mdiary_scanner, filename, cmd_stdout, *autotags, entryListStore, autoCompletion);
*autotags = g_list_remove(*autotags, g_list_last(*autotags)->data);
} else { } else {
mdiary_scanner->entries_failed++; mdiary_scanner->entries_failed++;
mdiary_scanner->error_code |= MDS_ERROR_GPG; mdiary_scanner->error_code |= MDS_ERROR_GPG;
g_warning("GPG: Decryption of message failed with error code %d!\n" g_warning("GPG: Decryption of message failed!\n"
"---------- SNIP ----------\n" "---------- SNIP ----------\n"
"%s" "%s"
"---------- SNIP ----------\n", "---------- SNIP ----------\n",
exit_status, cmd_stderr ? cmd_stderr : "Unknown error.");
cmd_stderr ? cmd_stderr : "Unknown error.\n");
if (cmd_stderr && strstr(cmd_stderr, "Operation cancelled")) {
g_warning("GPG: Aborting import of further GPG messages.");
mdiary_scanner->gpg_enabled = 2;
}
} }
g_free(cmd); g_free(cmd);
@ -420,7 +396,6 @@ static void mdiary_add_gpg_to_store(struct mdiary_scanner *mdiary_scanner,
static void mdiary_recurse_and_collect(struct mdiary_scanner *mdiary_scanner, static void mdiary_recurse_and_collect(struct mdiary_scanner *mdiary_scanner,
gchar *base_dir, gchar *base_dir,
GList **autotags,
GtkListStore *entryListStore, GtkListStore *entryListStore,
GtkListStore *autoCompletion, GtkListStore *autoCompletion,
guint max_level) guint max_level)
@ -442,28 +417,27 @@ static void mdiary_recurse_and_collect(struct mdiary_scanner *mdiary_scanner,
if (g_regex_match(regex, fullPath, 0, &match_info) && if (g_regex_match(regex, fullPath, 0, &match_info) &&
g_match_info_matches(match_info)) g_match_info_matches(match_info))
mdiary_add_file_to_store(mdiary_scanner, mdiary_add_file_to_store(mdiary_scanner,
fullPath, NULL, *autotags, fullPath, NULL,
entryListStore, autoCompletion); entryListStore, autoCompletion);
g_regex_unref(regex); g_regex_unref(regex);
regex = g_regex_new("\\.md.gpg$", G_REGEX_CASELESS, 0, NULL); regex = g_regex_new("\\.md.gpg$", G_REGEX_CASELESS, 0, NULL);
if (g_regex_match(regex, fullPath, 0, &match_info) && if (g_regex_match(regex, fullPath, 0, &match_info) &&
g_match_info_matches(match_info)) { g_match_info_matches(match_info)) {
mdiary_scanner->entries_encrypted++; mdiary_scanner->entries_encrypted++;
if (mdiary_scanner->gpg_enabled) if (mdiary_scanner->gpg_enabled)
mdiary_add_gpg_to_store(mdiary_scanner, mdiary_add_gpg_to_store(mdiary_scanner,
fullPath, autotags, fullPath,
entryListStore, autoCompletion); entryListStore, autoCompletion);
} }
g_regex_unref(regex); g_regex_unref(regex);
} else if (g_file_test(fullPath, G_FILE_TEST_IS_DIR) && max_level) { } else if (g_file_test(fullPath, G_FILE_TEST_IS_DIR) && max_level) {
*autotags = g_list_append(*autotags, dirname);
mdiary_recurse_and_collect(mdiary_scanner, mdiary_recurse_and_collect(mdiary_scanner,
fullPath, autotags, fullPath,
entryListStore, autoCompletion, entryListStore, autoCompletion,
max_level - 1); max_level--);
*autotags = g_list_remove(*autotags, g_list_last(*autotags)->data);
} }
g_free(fullPath); g_free(fullPath);
} }
@ -504,11 +478,8 @@ gint mdiary_scan_to_store(struct mdiary_scanner *mdiary_scanner,
gchar *base_dir, gchar *base_dir,
GtkListStore *entryListStore, GtkListStore *autoCompletion) GtkListStore *entryListStore, GtkListStore *autoCompletion)
{ {
GList *autotags = NULL;
mdiary_recurse_and_collect(mdiary_scanner, base_dir, &autotags, entryListStore, autoCompletion, 5); mdiary_recurse_and_collect(mdiary_scanner, base_dir, entryListStore, autoCompletion, 5);
g_list_free(autotags);
return mdiary_scanner->entries_added; return mdiary_scanner->entries_added;
} }