Tree storage modified to use combination struct

This commit is contained in:
Mario Hüttel 2019-02-05 19:44:29 +01:00
parent c7ffcf68ed
commit 1d67424bc9
3 changed files with 15 additions and 10 deletions

View File

@ -337,26 +337,23 @@ GtkWindow *create_main_window()
{ {
GtkBuilder *main_builder; GtkBuilder *main_builder;
GtkTreeView *cell_tree; GtkTreeView *cell_tree;
GtkTreeStore *cell_store;
GtkWidget *listbox; GtkWidget *listbox;
GtkWidget *conv_button; GtkWidget *conv_button;
GtkWidget *search_entry; GtkWidget *search_entry;
static GList *gds_libs; static GList *gds_libs;
static struct open_button_data open_data; static struct open_button_data open_data;
static struct convert_button_data conv_data; static struct convert_button_data conv_data;
struct tree_stores *cell_selector_stores;
main_builder = gtk_builder_new_from_resource("/main.glade"); main_builder = gtk_builder_new_from_resource("/main.glade");
gtk_builder_connect_signals(main_builder, NULL); gtk_builder_connect_signals(main_builder, NULL);
cell_tree = GTK_TREE_VIEW(gtk_builder_get_object(main_builder, "cell-tree")); 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")); search_entry = GTK_WIDGET(gtk_builder_get_object(main_builder, "cell-search"));
open_data.search_entry = GTK_SEARCH_ENTRY(search_entry); 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_selector_stores->base_store;
open_data.cell_store = cell_store;
open_data.list_ptr = &gds_libs; open_data.list_ptr = &gds_libs;
open_data.main_window = GTK_WINDOW(gtk_builder_get_object(main_builder, "main-window")); 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")), g_signal_connect(GTK_WIDGET(gtk_builder_get_object(main_builder, "button-load-gds")),

View File

@ -130,10 +130,12 @@ abort_search:
* @brief Setup a GtkTreeView with the necessary columns * @brief Setup a GtkTreeView with the necessary columns
* @param view Tree view to set up * @param view Tree view to set up
* @param search_entry Entry field for search * @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; GtkTreeStore *cell_store;
GtkCellRenderer *render_dates; 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); gtk_tree_view_set_search_entry(view, search_entry);
} }
return cell_store; stores.base_store = cell_store;
return &stores;
} }
/** @} */ /** @} */

View File

@ -43,7 +43,11 @@ enum cell_store_columns {
CELL_SEL_COLUMN_COUNT /**< Not a column. Used to determine count of coumns **/ 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__ */ #endif /* __TREE_STORE_H__ */