A viewer for a file based diary with entries written in markdown.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.1 KiB

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include "mdiary.h"
#include "md_pango.h"
#include "hoedown/src/document.h"
#include "hoedown/src/html.h"
#define FILE_LIST_MAX_LEN 5
enum {
WSCOL_LABEL = 0,
WSCOL_PATH,
WSCOL_COUNT
};
enum renderer_mode {
RENDERER_NONE = -1,
RENDERER_TEXT = 0,
RENDERER_BASIC,
RENDERER_HTML
};
struct mainWindow {
GtkWidget *mainWindow;
GtkWidget *mainPane;
GtkWidget *searchEntry;
GtkWidget *dateStart;
GtkWidget *dateEnd;
GtkWidget *entryText;
GtkWidget *entryTextScrollArea;
GtkWidget *popoverDate;
GtkWidget *calendarRange;
GtkWidget *checkSearchTitle;
GtkWidget *checkSearchSummary;
GtkWidget *checkSearchTags;
GtkWidget *checkSearchText;
GtkWidget *summaryEventBox;
GtkWidget *labelSummary;
GtkWidget *buttonClearSearch;
GtkWidget *headerBar;
GtkWidget *labelDateToDate;
GtkWidget *buttonNew;
GtkWidget *buttonDecrypt;
GtkWidget *webkitView;
GtkWidget *webkitScrollArea;
GtkWidget *stackRenderMode;
GtkTreeView *entryListView;
GtkTreeSelection *entryListSelection;
GtkTextBuffer *textBuffer;
GtkEntryCompletion *searchEntryCompletion;
gchar *currentWorkspaceUrl;
GtkListStore *completionListStore;
GtkListStore *entryListStore;
GtkWidget *selectedDateEntry;
GtkTreeModelFilter *entryListFiltered;
enum renderer_mode renderer;
gint64 time_earliest;
gint64 time_latest;
struct filterSettings {
gint64 time_start;
gint64 time_end;
gboolean search_title;
gboolean search_tags;
gboolean search_summary;
gboolean search_text;
gboolean hide_all;
} filterSettings;
GtkWidget *buttonOtherWorkspace;
GtkWidget *workspaceSearch;
GtkWidget *popoverWorkspace;
GtkTreeView *workspaceListView;
GtkTreeSelection *workspaceListSelection;
GtkListStore *workspaceListStore;
GtkTreeModelFilter *workspaceListFiltered;
gchar *newFileDateFormat;
struct settingsDialog {
GtkWidget *settingsDialog;
GtkWidget *comboDisplayMode;
GtkWidget *stackNewDateFormat;
GtkWidget *comboNewDateFormat;
GtkWidget *buttonCustomNewFileDateFormat;
GtkWidget *buttonOpenWorkspaceFolder;
GtkWidget *entryNewDateFormat;
} settingsDialog;
};
struct mainWindow *mainWindow_new();
void mainWindow_set_meta_information(struct mainWindow *mainWindow,
guint time_earliest,
guint time_latest,
gboolean hide_all);
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data);
void mainWindow_workspaceListClicked(GtkWidget *widget,
GtkTreePath *tree_path,
GtkTreeViewColumn *column,
gpointer user_data);
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data);
void mainWindow_calendarSelected(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_filterChanged(GtkWidget *widget, gpointer user_data);
void mainWindow_workspace_search_changed(GtkWidget *widget, gpointer user_data);
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_add_recent_workspace(struct mainWindow *mainWindow, gchar *path, gboolean append);
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_renderer_set(struct mainWindow *mainWindow, enum renderer_mode state);
void mainWindow_settings_show(struct mainWindow *mainWindow);
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 */