Add UI elements for new-entry button

This commit is contained in:
Markus Koch 2017-07-09 16:56:45 +02:00
parent 2b2d7d08e3
commit 99e3de70b9
3 changed files with 42 additions and 1 deletions

View File

@ -460,6 +460,19 @@
<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>
@ -531,7 +544,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@ -408,6 +408,10 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"changed",
(GCallback) mainWindow_workspace_search_changed,
mainWindow);
g_signal_connect(mainWindow->buttonNew,
"clicked",
(GCallback) mainWindow_new_entry_clicked,
mainWindow);
g_signal_connect(mainWindow->buttonDecrypt,
"clicked",
(GCallback) mainWindow_decrypt_gpg_clicked,
@ -545,6 +549,7 @@ struct mainWindow *mainWindow_new()
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
mainWindow->headerBar = GTK_WIDGET(gtk_builder_get_object(builder, "headerBar"));
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->stackRenderMode = GTK_WIDGET(gtk_builder_get_object(builder, "stackRenderMode"));
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
@ -559,6 +564,8 @@ struct mainWindow *mainWindow_new()
mainWindow->workspaceListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder,
"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"));
@ -945,6 +952,8 @@ void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path, gbo
mdiary_scanner->time_earliest, mdiary_scanner->time_latest,
FALSE);
mainWindow_add_recent_workspace(mainWindow, path, FALSE);
g_free(mainWindow->currentWorkspaceUrl);
mainWindow->currentWorkspaceUrl = g_strdup(path);
gtk_header_bar_set_subtitle(GTK_HEADER_BAR(mainWindow->headerBar), path);
if (mdiary_scanner->entries_encrypted > 0 && !gpg_enabled)
gtk_widget_set_visible(mainWindow->buttonDecrypt, TRUE);
@ -1019,6 +1028,21 @@ void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data)
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)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
// 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)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;

View File

@ -41,6 +41,7 @@ struct mainWindow {
GtkWidget *buttonClearSearch;
GtkWidget *headerBar;
GtkWidget *labelDateToDate;
GtkWidget *buttonNew;
GtkWidget *buttonDecrypt;
GtkWidget *webkitView;
GtkWidget *webkitScrollArea;
@ -50,6 +51,8 @@ struct mainWindow {
GtkTextBuffer *textBuffer;
GtkEntryCompletion *searchEntryCompletion;
gchar *currentWorkspaceUrl;
GtkListStore *completionListStore;
GtkListStore *entryListStore;
GtkWidget *selectedDateEntry;
@ -105,6 +108,7 @@ 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);