Added code to parse the selected entry

This commit is contained in:
Markus Koch 2017-02-02 20:02:33 +01:00
parent 2e1c1512be
commit ac6cec66e9
2 changed files with 26 additions and 0 deletions

View File

@ -184,6 +184,11 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"day-selected", "day-selected",
(GCallback) mainWindow_calendarSelected, (GCallback) mainWindow_calendarSelected,
mainWindow); mainWindow);
g_signal_connect(mainWindow->entryListSelection,
"changed",
(GCallback) mainWindow_entrySelected,
mainWindow);
} }
struct mainWindow *mainWindow_new() struct mainWindow *mainWindow_new()
@ -203,6 +208,7 @@ struct mainWindow *mainWindow_new()
mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate")); mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate"));
mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange")); mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange"));
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView")); mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
gtk_builder_connect_signals(builder, NULL); gtk_builder_connect_signals(builder, NULL);
@ -244,3 +250,21 @@ void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data)
gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverDate)); gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverDate));
} }
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *temp;
selection = gtk_tree_view_get_selection(mainWindow->entryListView);
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
gtk_tree_model_get (model, &iter, COL_TITLE, &temp, -1);
printf ("Selected entry: %s\n", temp);
fflush(stdout);
g_free(temp);
}
}

View File

@ -14,6 +14,7 @@ struct mainWindow {
GtkWidget *popoverDate; GtkWidget *popoverDate;
GtkWidget *calendarRange; GtkWidget *calendarRange;
GtkTreeView *entryListView; GtkTreeView *entryListView;
GtkTreeSelection *entryListSelection;
GtkListStore *entryListStore; GtkListStore *entryListStore;
GtkWidget *selectedDateEntry; GtkWidget *selectedDateEntry;
@ -25,5 +26,6 @@ struct mainWindow *mainWindow_new();
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data); void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data); void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, 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);
#endif /* MAINWINDOW_H */ #endif /* MAINWINDOW_H */