Compare commits
No commits in common. "a9b9232dd5d267d0159c7a43e042a7d082842812" and "6555b8d8e2437cfe947f7005cfedc864e0d2ffbb" have entirely different histories.
a9b9232dd5
...
6555b8d8e2
@ -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"/>
|
||||||
@ -479,19 +479,6 @@
|
|||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -525,21 +512,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>
|
||||||
@ -548,76 +534,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">1</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="GtkBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkStack" id="stackNewDateFormat">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBoxText" id="comboNewDateFormat">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="name">page0</property>
|
|
||||||
<property name="title" translatable="yes">page0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="entryNewDateFormat">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="name">page1</property>
|
|
||||||
<property name="title" translatable="yes">page1</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</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="buttonCustomNewFileDateFormat">
|
|
||||||
<property name="label" translatable="yes">...</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="tooltip_text" translatable="yes">Use custom format</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
236
src/mainwindow.c
236
src/mainwindow.c
@ -1,15 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mdiary.h"
|
#include "mdiary.h"
|
||||||
|
|
||||||
const gchar *default_template[] = {"# Title\n"
|
|
||||||
"Date: ", "\0",
|
|
||||||
"\n"
|
|
||||||
"Summary: \n"
|
|
||||||
"Tags: \n"
|
|
||||||
"\n"
|
|
||||||
"Text",
|
|
||||||
NULL};
|
|
||||||
|
|
||||||
static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
|
static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
struct mainWindow *mainWindow)
|
struct mainWindow *mainWindow)
|
||||||
@ -215,9 +206,9 @@ static void mainWindow_configure_workspaceTreeView(struct mainWindow *mainWindow
|
|||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
mainWindow->workspaceListFiltered = GTK_TREE_MODEL_FILTER(
|
mainWindow->workspaceListFiltered = GTK_TREE_MODEL_FILTER(
|
||||||
gtk_tree_model_filter_new(
|
gtk_tree_model_filter_new(
|
||||||
GTK_TREE_MODEL(mainWindow->workspaceListStore),
|
GTK_TREE_MODEL(mainWindow->workspaceListStore),
|
||||||
NULL));
|
NULL));
|
||||||
|
|
||||||
gtk_tree_model_filter_set_visible_func(mainWindow->workspaceListFiltered,
|
gtk_tree_model_filter_set_visible_func(mainWindow->workspaceListFiltered,
|
||||||
(GtkTreeModelFilterVisibleFunc) mainWindow_workspace_entry_visible,
|
(GtkTreeModelFilterVisibleFunc) mainWindow_workspace_entry_visible,
|
||||||
@ -417,10 +408,6 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
|
|||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_workspace_search_changed,
|
(GCallback) mainWindow_workspace_search_changed,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
g_signal_connect(mainWindow->buttonNew,
|
|
||||||
"clicked",
|
|
||||||
(GCallback) mainWindow_new_entry_clicked,
|
|
||||||
mainWindow);
|
|
||||||
g_signal_connect(mainWindow->buttonDecrypt,
|
g_signal_connect(mainWindow->buttonDecrypt,
|
||||||
"clicked",
|
"clicked",
|
||||||
(GCallback) mainWindow_decrypt_gpg_clicked,
|
(GCallback) mainWindow_decrypt_gpg_clicked,
|
||||||
@ -503,59 +490,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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void mainWindow_settings_buttonCustomNewFileDateFormat_clicked(GtkComboBox *widget, gpointer user_data)
|
|
||||||
{
|
|
||||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
|
||||||
|
|
||||||
if (gtk_stack_get_visible_child(GTK_STACK(mainWindow->settingsDialog.stackNewDateFormat)) == mainWindow->settingsDialog.entryNewDateFormat) {
|
|
||||||
mainWindow_set_new_file_date_format(mainWindow, gtk_entry_get_text(mainWindow->settingsDialog.entryNewDateFormat));
|
|
||||||
gtk_stack_set_visible_child(GTK_STACK(mainWindow->settingsDialog.stackNewDateFormat),
|
|
||||||
mainWindow->settingsDialog.comboNewDateFormat);
|
|
||||||
gtk_button_set_label(GTK_BUTTON(mainWindow->settingsDialog.buttonCustomNewFileDateFormat), "...");
|
|
||||||
} else {
|
|
||||||
gtk_stack_set_visible_child(GTK_STACK(mainWindow->settingsDialog.stackNewDateFormat),
|
|
||||||
mainWindow->settingsDialog.entryNewDateFormat);
|
|
||||||
gtk_button_set_label(GTK_BUTTON(mainWindow->settingsDialog.buttonCustomNewFileDateFormat), "OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
GDateTime *datetime;
|
|
||||||
gchar *text;
|
|
||||||
|
|
||||||
if (!fmt) {
|
|
||||||
fmt = newDateFormats[0];
|
|
||||||
}
|
|
||||||
g_free(mainWindow->newFileDateFormat);
|
|
||||||
mainWindow->newFileDateFormat = g_strdup(fmt);
|
|
||||||
|
|
||||||
gtk_entry_set_text(mainWindow->settingsDialog.entryNewDateFormat, fmt);
|
|
||||||
|
|
||||||
/* Custom format -> Add to list for this session */
|
|
||||||
if (!gtk_combo_box_set_active_id(mainWindow->settingsDialog.comboNewDateFormat, fmt)) {
|
|
||||||
datetime = g_date_time_new_now_local();
|
|
||||||
text = g_date_time_format(datetime, fmt);
|
|
||||||
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(mainWindow->settingsDialog.comboNewDateFormat),
|
|
||||||
fmt, text);
|
|
||||||
g_free(text);
|
|
||||||
g_date_time_unref(datetime);
|
|
||||||
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);
|
||||||
@ -569,10 +503,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),
|
||||||
@ -580,31 +510,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.buttonCustomNewFileDateFormat,
|
|
||||||
"clicked",
|
|
||||||
(GCallback) mainWindow_settings_buttonCustomNewFileDateFormat_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,
|
||||||
@ -641,7 +551,6 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
|
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
|
||||||
mainWindow->headerBar = GTK_WIDGET(gtk_builder_get_object(builder, "headerBar"));
|
mainWindow->headerBar = GTK_WIDGET(gtk_builder_get_object(builder, "headerBar"));
|
||||||
mainWindow->labelDateToDate = GTK_WIDGET(gtk_builder_get_object(builder, "label_date_to_date"));
|
mainWindow->labelDateToDate = GTK_WIDGET(gtk_builder_get_object(builder, "label_date_to_date"));
|
||||||
mainWindow->buttonNew = GTK_WIDGET(gtk_builder_get_object(builder, "buttonNew"));
|
|
||||||
mainWindow->buttonDecrypt = GTK_WIDGET(gtk_builder_get_object(builder, "buttonDecrypt"));
|
mainWindow->buttonDecrypt = GTK_WIDGET(gtk_builder_get_object(builder, "buttonDecrypt"));
|
||||||
mainWindow->stackRenderMode = GTK_WIDGET(gtk_builder_get_object(builder, "stackRenderMode"));
|
mainWindow->stackRenderMode = GTK_WIDGET(gtk_builder_get_object(builder, "stackRenderMode"));
|
||||||
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
||||||
@ -656,14 +565,8 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow->workspaceListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder,
|
mainWindow->workspaceListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder,
|
||||||
"treeWorkspaceSelection"));
|
"treeWorkspaceSelection"));
|
||||||
|
|
||||||
mainWindow->currentWorkspaceUrl = NULL;
|
mainWindow->settingsDialog.settingsDialog = GTK_WIDGET(gtk_builder_get_object(builder, "settingsDialog"));
|
||||||
|
mainWindow->settingsDialog.comboDisplayMode = GTK_WIDGET(gtk_builder_get_object(builder, "comboDisplayMode"));
|
||||||
mainWindow->settingsDialog.settingsDialog = GTK_WIDGET(gtk_builder_get_object(builder, "settingsDialog"));
|
|
||||||
mainWindow->settingsDialog.comboDisplayMode = GTK_WIDGET(gtk_builder_get_object(builder, "comboDisplayMode"));
|
|
||||||
mainWindow->settingsDialog.comboNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "comboNewDateFormat"));
|
|
||||||
mainWindow->settingsDialog.stackNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "stackNewDateFormat"));
|
|
||||||
mainWindow->settingsDialog.entryNewDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "entryNewDateFormat"));
|
|
||||||
mainWindow->settingsDialog.buttonCustomNewFileDateFormat = GTK_WIDGET(gtk_builder_get_object(builder, "buttonCustomNewFileDateFormat"));
|
|
||||||
|
|
||||||
mainWindow->filterSettings.time_start = 0;
|
mainWindow->filterSettings.time_start = 0;
|
||||||
mainWindow->filterSettings.time_end = -1;
|
mainWindow->filterSettings.time_end = -1;
|
||||||
@ -673,8 +576,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));
|
||||||
@ -690,7 +591,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;
|
||||||
@ -804,9 +704,9 @@ static void mainWindow_set_text(struct mainWindow *mainWindow, gchar *text, gcha
|
|||||||
base_url = g_strdup_printf("file://%s", file_url);
|
base_url = g_strdup_printf("file://%s", file_url);
|
||||||
file = g_file_new_for_path(tempfile_path);
|
file = g_file_new_for_path(tempfile_path);
|
||||||
stream = g_file_replace(
|
stream = g_file_replace(
|
||||||
file, NULL, FALSE,
|
file, NULL, FALSE,
|
||||||
G_FILE_CREATE_NONE,
|
G_FILE_CREATE_NONE,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_output_stream_write(G_OUTPUT_STREAM(stream), text, strlen(text), NULL, NULL);
|
g_output_stream_write(G_OUTPUT_STREAM(stream), text, strlen(text), NULL, NULL);
|
||||||
g_output_stream_flush(G_OUTPUT_STREAM(stream), NULL, NULL);
|
g_output_stream_flush(G_OUTPUT_STREAM(stream), NULL, NULL);
|
||||||
|
|
||||||
@ -879,27 +779,6 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief mainWindow_openExternalEditor opens the supplied path with the default system editor
|
|
||||||
* @param mainWindow
|
|
||||||
* @param path is the file to open
|
|
||||||
*/
|
|
||||||
void mainWindow_openExternalEditor(gchar *path)
|
|
||||||
{
|
|
||||||
GFile *file;
|
|
||||||
GAppInfo *info;
|
|
||||||
GList *files = NULL;
|
|
||||||
|
|
||||||
g_info("Opening entry in external editor.");
|
|
||||||
file = g_file_new_for_path(path);
|
|
||||||
info = g_file_query_default_handler(file, NULL, NULL);
|
|
||||||
files = g_list_append(files, (gpointer) file);
|
|
||||||
g_app_info_launch(info, files, NULL, NULL);
|
|
||||||
g_list_free(files); // Content is freed individually
|
|
||||||
g_object_unref(info);
|
|
||||||
g_object_unref(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief mainWindow_entryActivated is the callback when the user doubleclicks or presses enter on an entry
|
* @brief mainWindow_entryActivated is the callback when the user doubleclicks or presses enter on an entry
|
||||||
* @param widget is the entryListView
|
* @param widget is the entryListView
|
||||||
@ -907,7 +786,9 @@ void mainWindow_openExternalEditor(gchar *path)
|
|||||||
*/
|
*/
|
||||||
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
|
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GFile *file;
|
||||||
|
GAppInfo *info;
|
||||||
|
GList *files = NULL;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeView *treeview = (GtkTreeView*) widget;
|
GtkTreeView *treeview = (GtkTreeView*) widget;
|
||||||
@ -916,9 +797,16 @@ void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeView
|
|||||||
model = gtk_tree_view_get_model(treeview);
|
model = gtk_tree_view_get_model(treeview);
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter(model, &iter, path)) {
|
if (gtk_tree_model_get_iter(model, &iter, path)) {
|
||||||
|
g_info("Opening entry in external editor.");
|
||||||
gtk_tree_model_get(model, &iter, COL_URL, &name, -1);
|
gtk_tree_model_get(model, &iter, COL_URL, &name, -1);
|
||||||
mainWindow_openExternalEditor(name);
|
file = g_file_new_for_path(name);
|
||||||
|
info = g_file_query_default_handler(file, NULL, NULL);
|
||||||
|
files = g_list_append(files, (gpointer) file);
|
||||||
|
g_app_info_launch(info, files, NULL, NULL);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
g_list_free(files); // Content is freed individually
|
||||||
|
g_object_unref(info);
|
||||||
|
g_object_unref(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,13 +844,13 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle));
|
||||||
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags));
|
||||||
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchText));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchText));
|
||||||
mainWindow->filterSettings.search_summary = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_summary = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary));
|
||||||
|
|
||||||
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
||||||
}
|
}
|
||||||
@ -1061,10 +949,6 @@ void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gbo
|
|||||||
mdiary_reset_store(mainWindow->entryListStore, mainWindow->completionListStore);
|
mdiary_reset_store(mainWindow->entryListStore, mainWindow->completionListStore);
|
||||||
|
|
||||||
mdiary_scanner = mdiary_scanner_new(gpg_enabled);
|
mdiary_scanner = mdiary_scanner_new(gpg_enabled);
|
||||||
|
|
||||||
g_free(mainWindow->currentWorkspaceUrl);
|
|
||||||
mainWindow->currentWorkspaceUrl = g_strdup(path);
|
|
||||||
|
|
||||||
if (mdiary_scan_to_store(mdiary_scanner, path, mainWindow->entryListStore, mainWindow->completionListStore)) {
|
if (mdiary_scan_to_store(mdiary_scanner, path, mainWindow->entryListStore, mainWindow->completionListStore)) {
|
||||||
mainWindow_set_meta_information(mainWindow,
|
mainWindow_set_meta_information(mainWindow,
|
||||||
mdiary_scanner->time_earliest, mdiary_scanner->time_latest,
|
mdiary_scanner->time_earliest, mdiary_scanner->time_latest,
|
||||||
@ -1144,80 +1028,6 @@ void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data)
|
|||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief mainWindow_otherWorkspaceClicked is called when the user clicks the New Entry button.
|
|
||||||
* @param widget N/A
|
|
||||||
* @param user_data struct mainWindow *
|
|
||||||
*/
|
|
||||||
void mainWindow_new_entry_clicked(GtkWidget *widget, gpointer user_data)
|
|
||||||
{
|
|
||||||
void close_dialog(GtkWidget *widget, gpointer dlg)
|
|
||||||
{
|
|
||||||
gtk_dialog_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
|
||||||
GtkWidget *dialog;
|
|
||||||
GtkWidget *textInput;
|
|
||||||
gchar *path;
|
|
||||||
FILE *fd;
|
|
||||||
gchar *default_path;
|
|
||||||
GDateTime *datetime;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(GTK_WINDOW(mainWindow->mainWindow),
|
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
|
|
||||||
"Please enter the filename of the entry");
|
|
||||||
textInput = gtk_entry_new();
|
|
||||||
datetime = g_date_time_new_now_local();
|
|
||||||
default_path = g_date_time_format(datetime, "%Y/%Y-%m-%d");
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(textInput), default_path);
|
|
||||||
g_free(default_path);
|
|
||||||
gtk_box_pack_end(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), textInput, true, true, 4);
|
|
||||||
g_signal_connect(textInput,
|
|
||||||
"activate",
|
|
||||||
(GCallback) close_dialog,
|
|
||||||
dialog);
|
|
||||||
gtk_widget_show(textInput);
|
|
||||||
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
|
|
||||||
path = (gchar*) gtk_entry_get_text(GTK_ENTRY(textInput));
|
|
||||||
if (strlen(path) > 0) {
|
|
||||||
if (path[0] != '/')
|
|
||||||
path = g_strdup_printf("%s/%s.md", mainWindow->currentWorkspaceUrl, path);
|
|
||||||
else
|
|
||||||
path = g_strdup_printf("%s.md", path);
|
|
||||||
fd = fopen(path, "r");
|
|
||||||
if (fd) {
|
|
||||||
fclose(fd);
|
|
||||||
g_warning("File '%s' already exists.", path);
|
|
||||||
} else {
|
|
||||||
fd = fopen(path, "w");
|
|
||||||
if (fd) {
|
|
||||||
for (i = 0; default_template[i] != NULL; ++i) {
|
|
||||||
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);
|
|
||||||
mainWindow_openExternalEditor(path);
|
|
||||||
} else {
|
|
||||||
g_warning("Could not open file '%s' for writing.", path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_date_time_unref(datetime);
|
|
||||||
|
|
||||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
|
||||||
}
|
|
||||||
|
|
||||||
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data)
|
void mainWindow_decrypt_gpg_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
||||||
|
@ -42,7 +42,6 @@ struct mainWindow {
|
|||||||
GtkWidget *buttonClearSearch;
|
GtkWidget *buttonClearSearch;
|
||||||
GtkWidget *headerBar;
|
GtkWidget *headerBar;
|
||||||
GtkWidget *labelDateToDate;
|
GtkWidget *labelDateToDate;
|
||||||
GtkWidget *buttonNew;
|
|
||||||
GtkWidget *buttonDecrypt;
|
GtkWidget *buttonDecrypt;
|
||||||
GtkWidget *webkitView;
|
GtkWidget *webkitView;
|
||||||
GtkWidget *webkitScrollArea;
|
GtkWidget *webkitScrollArea;
|
||||||
@ -52,8 +51,6 @@ struct mainWindow {
|
|||||||
GtkTextBuffer *textBuffer;
|
GtkTextBuffer *textBuffer;
|
||||||
GtkEntryCompletion *searchEntryCompletion;
|
GtkEntryCompletion *searchEntryCompletion;
|
||||||
|
|
||||||
gchar *currentWorkspaceUrl;
|
|
||||||
|
|
||||||
GtkListStore *completionListStore;
|
GtkListStore *completionListStore;
|
||||||
GtkListStore *entryListStore;
|
GtkListStore *entryListStore;
|
||||||
GtkWidget *selectedDateEntry;
|
GtkWidget *selectedDateEntry;
|
||||||
@ -82,15 +79,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 *stackNewDateFormat;
|
|
||||||
GtkWidget *comboNewDateFormat;
|
|
||||||
GtkWidget *buttonCustomNewFileDateFormat;
|
|
||||||
GtkWidget *entryNewDateFormat;
|
|
||||||
} settingsDialog;
|
} settingsDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,7 +99,6 @@ void mainWindow_workspaceListClicked(GtkWidget *widget,
|
|||||||
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
|
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
|
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_openExternalEditor(gchar *path);
|
|
||||||
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data);
|
void mainWindow_entryActivated(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data);
|
||||||
void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
|
void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_workspace_search_changed(GtkWidget *widget, gpointer user_data);
|
void mainWindow_workspace_search_changed(GtkWidget *widget, gpointer user_data);
|
||||||
@ -116,11 +106,9 @@ void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data);
|
|||||||
void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpointer user_data);
|
void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpointer user_data);
|
||||||
void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path, gboolean append);
|
void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path, gboolean append);
|
||||||
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gboolean gpg_enabled);
|
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gboolean gpg_enabled);
|
||||||
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);
|
||||||
gboolean mainWindow_toggleSummaryWrap(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
gboolean mainWindow_toggleSummaryWrap(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
||||||
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)
|
||||||
@ -78,9 +70,9 @@ gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings)
|
|||||||
|
|
||||||
file = g_file_new_for_path(filename);
|
file = g_file_new_for_path(filename);
|
||||||
stream = g_file_replace(
|
stream = g_file_replace(
|
||||||
file, NULL, FALSE,
|
file, NULL, FALSE,
|
||||||
G_FILE_CREATE_NONE,
|
G_FILE_CREATE_NONE,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
output_buffer = g_strdup_printf("renderer = %d\n", settings->mainWindow->renderer);
|
output_buffer = g_strdup_printf("renderer = %d\n", settings->mainWindow->renderer);
|
||||||
@ -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