Compare commits
No commits in common. "c4809f29b24e8e9adc86eb17ca33cf03fdb45f04" and "247ea6977f80411be5a5913d72c3568cfdbaea3c" have entirely different histories.
c4809f29b2
...
247ea6977f
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.20.4 -->
|
<!-- Generated with glade 3.20.0 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.20"/>
|
||||||
<object class="GtkTextBuffer" id="entryTextBuffer"/>
|
<object class="GtkTextBuffer" id="entryTextBuffer"/>
|
||||||
@ -520,21 +520,20 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="row_spacing">4</property>
|
<property name="spacing">4</property>
|
||||||
<property name="column_spacing">4</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Entry display mode:</property>
|
<property name="label" translatable="yes">Entry display mode:</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="expand">False</property>
|
||||||
<property name="top_attach">0</property>
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -543,30 +542,9 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="expand">False</property>
|
||||||
<property name="top_attach">0</property>
|
<property name="fill">True</property>
|
||||||
</packing>
|
<property name="position">2</property>
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">New entry date format:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBoxText" id="comboNewDateFormat">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mdiary.h"
|
#include "mdiary.h"
|
||||||
|
|
||||||
const gchar *default_template[] = {"# Title\n"
|
const gchar *default_template = "\
|
||||||
"Date: ", "\0",
|
# Title\n\
|
||||||
"\n"
|
Date: 01.01.2000 00:00\n\
|
||||||
"Summary: \n"
|
Summary: \n\
|
||||||
"Tags: \n"
|
Tags: \n\
|
||||||
"\n"
|
\n\
|
||||||
"Text",
|
Text";
|
||||||
NULL};
|
|
||||||
|
|
||||||
static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
|
static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
@ -498,28 +497,6 @@ static void mainWindow_settings_combo_changed(GtkComboBox *widget, gpointer user
|
|||||||
mainWindow_entrySelected(NULL, user_data);
|
mainWindow_entrySelected(NULL, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mainWindow_settings_comboNewDateFormat_changed(GtkComboBox *widget, gpointer user_data)
|
|
||||||
{
|
|
||||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
|
||||||
|
|
||||||
mainWindow_set_new_file_date_format(mainWindow, gtk_combo_box_get_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboNewDateFormat)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *newDateFormats[] = {"%d.%m.%Y %H:%M",
|
|
||||||
"%Y-%m-%d %H:%M",
|
|
||||||
NULL};
|
|
||||||
|
|
||||||
void mainWindow_set_new_file_date_format(struct mainWindow *mainWindow, gchar *fmt)
|
|
||||||
{
|
|
||||||
if (!fmt) {
|
|
||||||
fmt = newDateFormats[0];
|
|
||||||
}
|
|
||||||
g_free(mainWindow->newFileDateFormat);
|
|
||||||
mainWindow->newFileDateFormat = g_strdup(fmt);
|
|
||||||
|
|
||||||
gtk_combo_box_set_active_id(mainWindow->settingsDialog.comboNewDateFormat, fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean mainWindow_settings_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
static gboolean mainWindow_settings_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
||||||
{
|
{
|
||||||
gtk_widget_hide(widget);
|
gtk_widget_hide(widget);
|
||||||
@ -533,10 +510,6 @@ void mainWindow_settings_show(struct mainWindow *mainWindow)
|
|||||||
|
|
||||||
static void mainWindow_configure_settings_dialog(struct mainWindow *mainWindow)
|
static void mainWindow_configure_settings_dialog(struct mainWindow *mainWindow)
|
||||||
{
|
{
|
||||||
GDateTime *datetime;
|
|
||||||
int i;
|
|
||||||
gchar *text;
|
|
||||||
|
|
||||||
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboDisplayMode),
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboDisplayMode),
|
||||||
"text", "Text only");
|
"text", "Text only");
|
||||||
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboDisplayMode),
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboDisplayMode),
|
||||||
@ -544,26 +517,11 @@ static void mainWindow_configure_settings_dialog(struct mainWindow *mainWindow)
|
|||||||
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboDisplayMode),
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboDisplayMode),
|
||||||
"html", "Full HTML with images");
|
"html", "Full HTML with images");
|
||||||
|
|
||||||
datetime = g_date_time_new_now_local();
|
|
||||||
for (i= 0; newDateFormats[i]; ++i) {
|
|
||||||
text = g_date_time_format(datetime, newDateFormats[i]);
|
|
||||||
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboNewDateFormat),
|
|
||||||
newDateFormats[i], text);
|
|
||||||
g_free(text);
|
|
||||||
}
|
|
||||||
g_date_time_unref(datetime);
|
|
||||||
|
|
||||||
|
|
||||||
g_signal_connect(mainWindow->settingsDialog.comboDisplayMode,
|
g_signal_connect(mainWindow->settingsDialog.comboDisplayMode,
|
||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_settings_combo_changed,
|
(GCallback) mainWindow_settings_combo_changed,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
|
|
||||||
g_signal_connect(mainWindow->settingsDialog.comboNewDateFormat,
|
|
||||||
"changed",
|
|
||||||
(GCallback) mainWindow_settings_comboNewDateFormat_changed,
|
|
||||||
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,
|
||||||
@ -616,9 +574,8 @@ struct mainWindow *mainWindow_new()
|
|||||||
|
|
||||||
mainWindow->currentWorkspaceUrl = NULL;
|
mainWindow->currentWorkspaceUrl = NULL;
|
||||||
|
|
||||||
mainWindow->settingsDialog.settingsDialog = GTK_WIDGET(gtk_builder_get_object(builder, "settingsDialog"));
|
mainWindow->settingsDialog.settingsDialog = GTK_WIDGET(gtk_builder_get_object(builder, "settingsDialog"));
|
||||||
mainWindow->settingsDialog.comboDisplayMode = GTK_WIDGET(gtk_builder_get_object(builder, "comboDisplayMode"));
|
mainWindow->settingsDialog.comboDisplayMode = GTK_WIDGET(gtk_builder_get_object(builder, "comboDisplayMode"));
|
||||||
mainWindow->settingsDialog.comboNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "comboNewDateFormat"));
|
|
||||||
|
|
||||||
mainWindow->filterSettings.time_start = 0;
|
mainWindow->filterSettings.time_start = 0;
|
||||||
mainWindow->filterSettings.time_end = -1;
|
mainWindow->filterSettings.time_end = -1;
|
||||||
@ -628,8 +585,6 @@ struct mainWindow *mainWindow_new()
|
|||||||
|
|
||||||
mainWindow->renderer = RENDERER_NONE;
|
mainWindow->renderer = RENDERER_NONE;
|
||||||
|
|
||||||
mainWindow->newFileDateFormat = NULL;
|
|
||||||
|
|
||||||
gtk_builder_connect_signals(builder, NULL);
|
gtk_builder_connect_signals(builder, NULL);
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(builder));
|
g_object_unref(G_OBJECT(builder));
|
||||||
@ -645,7 +600,6 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow_configure_entry_completion(mainWindow);
|
mainWindow_configure_entry_completion(mainWindow);
|
||||||
mainWindow_set_meta_information(mainWindow, 0, 0, TRUE);
|
mainWindow_set_meta_information(mainWindow, 0, 0, TRUE);
|
||||||
|
|
||||||
mainWindow_set_new_file_date_format(mainWindow, NULL);
|
|
||||||
mainWindow_renderer_set(mainWindow, RENDERER_TEXT);
|
mainWindow_renderer_set(mainWindow, RENDERER_TEXT);
|
||||||
|
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
@ -1118,7 +1072,6 @@ void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data)
|
|||||||
FILE *fd;
|
FILE *fd;
|
||||||
gchar *default_path;
|
gchar *default_path;
|
||||||
GDateTime *datetime;
|
GDateTime *datetime;
|
||||||
int i;
|
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(GTK_WINDOW(mainWindow->mainWindow),
|
dialog = gtk_message_dialog_new(GTK_WINDOW(mainWindow->mainWindow),
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
@ -1129,6 +1082,7 @@ void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data)
|
|||||||
default_path = g_date_time_format(datetime, "%Y/%Y-%m-%d");
|
default_path = g_date_time_format(datetime, "%Y/%Y-%m-%d");
|
||||||
gtk_entry_set_text(GTK_ENTRY(textInput), default_path);
|
gtk_entry_set_text(GTK_ENTRY(textInput), default_path);
|
||||||
g_free(default_path);
|
g_free(default_path);
|
||||||
|
g_date_time_unref(datetime);
|
||||||
gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), textInput, true, true, 4);
|
gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), textInput, true, true, 4);
|
||||||
g_signal_connect(textInput,
|
g_signal_connect(textInput,
|
||||||
"activate",
|
"activate",
|
||||||
@ -1150,15 +1104,7 @@ void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data)
|
|||||||
} else {
|
} else {
|
||||||
fd = fopen(path, "w");
|
fd = fopen(path, "w");
|
||||||
if (fd) {
|
if (fd) {
|
||||||
for (i = 0; default_template[i] != NULL; ++i) {
|
fwrite(default_template, sizeof(char), strlen(default_template), fd);
|
||||||
if (default_template[i][0] == '\0') {
|
|
||||||
default_path = g_date_time_format(datetime, mainWindow->newFileDateFormat);
|
|
||||||
fwrite(default_path, sizeof(char), strlen(default_path), fd);
|
|
||||||
g_free(default_path);
|
|
||||||
} else {
|
|
||||||
fwrite(default_template[i], sizeof(char), strlen(default_template[i]), fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
mainWindow_openExternalEditor(path);
|
mainWindow_openExternalEditor(path);
|
||||||
} else {
|
} else {
|
||||||
@ -1168,9 +1114,11 @@ void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_date_time_unref(datetime);
|
|
||||||
|
|
||||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||||
|
// Get ws path
|
||||||
|
// Ask user for filename
|
||||||
|
// Create file and paste template
|
||||||
|
// Launch editor on file
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data)
|
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
|
@ -81,12 +81,9 @@ struct mainWindow {
|
|||||||
GtkListStore *workspaceListStore;
|
GtkListStore *workspaceListStore;
|
||||||
GtkTreeModelFilter *workspaceListFiltered;
|
GtkTreeModelFilter *workspaceListFiltered;
|
||||||
|
|
||||||
gchar *newFileDateFormat;
|
|
||||||
|
|
||||||
struct settingsDialog {
|
struct settingsDialog {
|
||||||
GtkWidget *settingsDialog;
|
GtkWidget *settingsDialog;
|
||||||
GtkWidget *comboDisplayMode;
|
GtkWidget *comboDisplayMode;
|
||||||
GtkWidget *comboNewDateFormat;
|
|
||||||
} settingsDialog;
|
} settingsDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,6 +113,5 @@ void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data);
|
|||||||
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data);
|
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_renderer_set(struct mainWindow *mainWindow, enum renderer_mode state);
|
void mainWindow_renderer_set(struct mainWindow *mainWindow, enum renderer_mode state);
|
||||||
void mainWindow_settings_show(struct mainWindow *mainWindow);
|
void mainWindow_settings_show(struct mainWindow *mainWindow);
|
||||||
void mainWindow_set_new_file_date_format(struct mainWindow *mainWindow, gchar *fmt);
|
|
||||||
|
|
||||||
#endif /* MAINWINDOW_H */
|
#endif /* MAINWINDOW_H */
|
||||||
|
@ -20,14 +20,6 @@ static void mdiary_settings_parse_line(gchar *line, struct mdiary_settings *sett
|
|||||||
mainWindow_renderer_set(settings->mainWindow, atoi(g_match_info_fetch(match_info, 1)));
|
mainWindow_renderer_set(settings->mainWindow, atoi(g_match_info_fetch(match_info, 1)));
|
||||||
}
|
}
|
||||||
g_regex_unref(regex);
|
g_regex_unref(regex);
|
||||||
|
|
||||||
regex = g_regex_new("^newfileformat = (.*)", G_REGEX_RAW, 0, NULL);
|
|
||||||
if (g_regex_match(regex, line, 0, &match_info) &&
|
|
||||||
g_regex_get_capture_count(regex) > 0 &&
|
|
||||||
g_match_info_matches(match_info)) {
|
|
||||||
mainWindow_set_new_file_date_format(settings->mainWindow, g_match_info_fetch(match_info, 1));
|
|
||||||
}
|
|
||||||
g_regex_unref(regex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings)
|
gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings)
|
||||||
@ -88,11 +80,6 @@ gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings)
|
|||||||
output_buffer, strlen(output_buffer), NULL, NULL);
|
output_buffer, strlen(output_buffer), NULL, NULL);
|
||||||
g_free(output_buffer);
|
g_free(output_buffer);
|
||||||
|
|
||||||
output_buffer = g_strdup_printf("newfileformat = %s\n", settings->mainWindow->newFileDateFormat);
|
|
||||||
g_output_stream_write(G_OUTPUT_STREAM(stream),
|
|
||||||
output_buffer, strlen(output_buffer), NULL, NULL);
|
|
||||||
g_free(output_buffer);
|
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter)) {
|
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter)) {
|
||||||
do {
|
do {
|
||||||
gtk_tree_model_get(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter,
|
gtk_tree_model_get(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter,
|
||||||
|
Loading…
Reference in New Issue
Block a user