Made listStore filterable
This commit is contained in:
parent
6ee8b284b6
commit
cc56768804
@ -2,18 +2,6 @@
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="entryListStore">
|
||||
<columns>
|
||||
<!-- column-name Title -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Date -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Tags -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Timestamp -->
|
||||
<column type="guint"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkTextBuffer" id="entryTextBuffer">
|
||||
<property name="text" translatable="yes">Test text for debugging.</property>
|
||||
</object>
|
||||
@ -132,7 +120,6 @@
|
||||
<property name="height_request">300</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">entryListStore</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="entryListSelection"/>
|
||||
</child>
|
||||
|
@ -26,11 +26,38 @@ static void mainWindow_list_add_entry(struct mainWindow *mainWindow, struct mdia
|
||||
g_free(date_text);
|
||||
}
|
||||
|
||||
static gboolean mainWindow_list_entry_visible (GtkTreeModel *model, GtkTreeIter *iter, struct mainWindow *mainWindow)
|
||||
{
|
||||
/* gtk_tree_model_get (model, iter, COLUMN_NAME, &target, -1); */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeSortable *sortable;
|
||||
GtkTreeViewColumn *col;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeModelFilter *filtered;
|
||||
GtkTreeModelSort *sorted;
|
||||
|
||||
mainWindow->entryListStore = gtk_list_store_new(COL_COUNT,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_UINT);
|
||||
filtered = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (
|
||||
GTK_TREE_MODEL (mainWindow->entryListStore), NULL));
|
||||
sorted = GTK_TREE_MODEL_SORT (gtk_tree_model_sort_new_with_model (
|
||||
GTK_TREE_MODEL (filtered)));
|
||||
gtk_tree_model_filter_set_visible_func (filtered,
|
||||
(GtkTreeModelFilterVisibleFunc) mainWindow_list_entry_visible,
|
||||
mainWindow, NULL);
|
||||
model = GTK_TREE_MODEL (sorted);
|
||||
gtk_tree_view_set_model(mainWindow->entryListView, model);
|
||||
|
||||
/* TODO: Unref mainWindow->entryListStore and filtered, sorted and model? */
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_insert_column_with_attributes(mainWindow->entryListView, -1, "Title", renderer,
|
||||
@ -113,7 +140,6 @@ struct mainWindow *mainWindow_new()
|
||||
mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate"));
|
||||
mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange"));
|
||||
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
||||
mainWindow->entryListStore = GTK_LIST_STORE(gtk_builder_get_object(builder, "entryListStore"));
|
||||
|
||||
gtk_builder_connect_signals(builder, NULL);
|
||||
|
||||
|
@ -14,8 +14,8 @@ struct mainWindow {
|
||||
GtkWidget *popoverDate;
|
||||
GtkWidget *calendarRange;
|
||||
GtkTreeView *entryListView;
|
||||
GtkListStore *entryListStore;
|
||||
|
||||
GtkListStore *entryListStore;
|
||||
GtkWidget *selectedDateEntry;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user