From 1d67424bc91ad38bc9d7873be6a4c290fd31c2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 5 Feb 2019 19:44:29 +0100 Subject: [PATCH] Tree storage modified to use combination struct --- main-window.c | 9 +++------ tree-renderer/tree-store.c | 10 +++++++--- tree-renderer/tree-store.h | 6 +++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/main-window.c b/main-window.c index 0133513..89f1aca 100644 --- a/main-window.c +++ b/main-window.c @@ -337,26 +337,23 @@ GtkWindow *create_main_window() { GtkBuilder *main_builder; GtkTreeView *cell_tree; - GtkTreeStore *cell_store; GtkWidget *listbox; GtkWidget *conv_button; GtkWidget *search_entry; static GList *gds_libs; static struct open_button_data open_data; static struct convert_button_data conv_data; + struct tree_stores *cell_selector_stores; main_builder = gtk_builder_new_from_resource("/main.glade"); gtk_builder_connect_signals(main_builder, NULL); - - cell_tree = GTK_TREE_VIEW(gtk_builder_get_object(main_builder, "cell-tree")); search_entry = GTK_WIDGET(gtk_builder_get_object(main_builder, "cell-search")); open_data.search_entry = GTK_SEARCH_ENTRY(search_entry); - cell_store = setup_cell_selector(cell_tree, GTK_ENTRY(search_entry)); + cell_selector_stores = setup_cell_selector(cell_tree, GTK_ENTRY(search_entry)); - - open_data.cell_store = cell_store; + open_data.cell_store = cell_selector_stores->base_store; open_data.list_ptr = &gds_libs; open_data.main_window = GTK_WINDOW(gtk_builder_get_object(main_builder, "main-window")); g_signal_connect(GTK_WIDGET(gtk_builder_get_object(main_builder, "button-load-gds")), diff --git a/tree-renderer/tree-store.c b/tree-renderer/tree-store.c index b7c8414..f19dbe5 100644 --- a/tree-renderer/tree-store.c +++ b/tree-renderer/tree-store.c @@ -130,10 +130,12 @@ abort_search: * @brief Setup a GtkTreeView with the necessary columns * @param view Tree view to set up * @param search_entry Entry field for search - * @return TreeStore for storing data inside the GtkTreeView + * @return Tree stores for storing data inside the GtkTreeView */ -GtkTreeStore *setup_cell_selector(GtkTreeView* view, GtkEntry *search_entry) +struct tree_stores *setup_cell_selector(GtkTreeView* view, GtkEntry *search_entry) { + static struct tree_stores stores; + GtkTreeStore *cell_store; GtkCellRenderer *render_dates; @@ -173,6 +175,8 @@ GtkTreeStore *setup_cell_selector(GtkTreeView* view, GtkEntry *search_entry) gtk_tree_view_set_search_entry(view, search_entry); } - return cell_store; + stores.base_store = cell_store; + + return &stores; } /** @} */ diff --git a/tree-renderer/tree-store.h b/tree-renderer/tree-store.h index 6e8c2f2..1fa3007 100644 --- a/tree-renderer/tree-store.h +++ b/tree-renderer/tree-store.h @@ -43,7 +43,11 @@ enum cell_store_columns { CELL_SEL_COLUMN_COUNT /**< Not a column. Used to determine count of coumns **/ }; -GtkTreeStore *setup_cell_selector(GtkTreeView* view, GtkEntry *search_entry); +struct tree_stores { + GtkTreeStore *base_store; +}; + +struct tree_stores *setup_cell_selector(GtkTreeView* view, GtkEntry *search_entry); #endif /* __TREE_STORE_H__ */