Configured entryListView
This commit is contained in:
parent
8b75d7f037
commit
02ac6dc595
@ -4,15 +4,13 @@
|
|||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.20"/>
|
||||||
<object class="GtkListStore" id="entryListStore">
|
<object class="GtkListStore" id="entryListStore">
|
||||||
<columns>
|
<columns>
|
||||||
<!-- column-name test1 -->
|
<!-- column-name Title -->
|
||||||
<column type="test"/>
|
<column type="gchararray"/>
|
||||||
<!-- column-name vfg1 -->
|
<!-- column-name Date -->
|
||||||
<column type="vfg"/>
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name Tags -->
|
||||||
|
<column type="gchararray"/>
|
||||||
</columns>
|
</columns>
|
||||||
<data>
|
|
||||||
<row/>
|
|
||||||
<row/>
|
|
||||||
</data>
|
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkTextBuffer" id="entryTextBuffer">
|
<object class="GtkTextBuffer" id="entryTextBuffer">
|
||||||
<property name="text" translatable="yes">Test text for debugging.</property>
|
<property name="text" translatable="yes">Test text for debugging.</property>
|
||||||
@ -122,23 +120,32 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="wide_handle">True</property>
|
<property name="wide_handle">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeView" id="entryListView">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="model">entryListStore</property>
|
<property name="shadow_type">in</property>
|
||||||
<child internal-child="selection">
|
<property name="propagate_natural_height">True</property>
|
||||||
<object class="GtkTreeSelection" id="entryListSelection"/>
|
<child>
|
||||||
|
<object class="GtkTreeView" id="entryListView">
|
||||||
|
<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>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="resize">False</property>
|
<property name="resize">True</property>
|
||||||
<property name="shrink">True</property>
|
<property name="shrink">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTextView" id="entryText">
|
<object class="GtkTextView" id="entryText">
|
||||||
<property name="width_request">640</property>
|
<property name="width_request">640</property>
|
||||||
<property name="height_request">480</property>
|
<property name="height_request">320</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="editable">False</property>
|
<property name="editable">False</property>
|
||||||
|
@ -1,5 +1,69 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
COL_TITLE = 0,
|
||||||
|
COL_DATE,
|
||||||
|
COL_TAGS,
|
||||||
|
COL_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
static void mainWindow_test_treeView(struct mainWindow *mainWindow)
|
||||||
|
{
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeSortable *sortable;
|
||||||
|
GtkTreeViewColumn *col;
|
||||||
|
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_insert_column_with_attributes(mainWindow->entryListView, -1, "Title", renderer,
|
||||||
|
"text", COL_TITLE, NULL);
|
||||||
|
col = gtk_tree_view_get_column(mainWindow->entryListView, COL_TITLE);
|
||||||
|
gtk_tree_view_column_set_resizable(col, 1);
|
||||||
|
gtk_tree_view_column_set_sort_column_id(col, COL_TITLE);
|
||||||
|
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_insert_column_with_attributes(mainWindow->entryListView, -1, "Date", renderer,
|
||||||
|
"text", COL_DATE, NULL);
|
||||||
|
col = gtk_tree_view_get_column(mainWindow->entryListView, COL_DATE);
|
||||||
|
gtk_tree_view_column_set_resizable(col, 1);
|
||||||
|
gtk_tree_view_column_set_sort_column_id(col, COL_DATE);
|
||||||
|
|
||||||
|
renderer = gtk_cell_renderer_text_new();
|
||||||
|
gtk_tree_view_insert_column_with_attributes(mainWindow->entryListView, -1, "Tags", renderer,
|
||||||
|
"text", COL_TAGS, NULL);
|
||||||
|
col = gtk_tree_view_get_column(mainWindow->entryListView, COL_TAGS);
|
||||||
|
gtk_tree_view_column_set_resizable(col, 1);
|
||||||
|
gtk_tree_view_column_set_sort_column_id(col, COL_TAGS);
|
||||||
|
|
||||||
|
/*gtk_tree_sortable_set_sort_func(sortable, COL_DATE, mainWindow_sort_date_compare_func,
|
||||||
|
GINT_TO_POINTER(COL_DATE), NULL);*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Code just for debugging - some test values
|
||||||
|
*/
|
||||||
|
gtk_list_store_append(mainWindow->entryListStore, &iter);
|
||||||
|
gtk_list_store_set (mainWindow->entryListStore, &iter,
|
||||||
|
COL_TITLE, "ZA Test entry longer title",
|
||||||
|
COL_DATE, "2016-05-12",
|
||||||
|
COL_TAGS, "X",
|
||||||
|
-1);
|
||||||
|
gtk_list_store_append(mainWindow->entryListStore, &iter);
|
||||||
|
gtk_list_store_set (mainWindow->entryListStore, &iter,
|
||||||
|
COL_TITLE, "baz",
|
||||||
|
COL_DATE, "2016-11-22",
|
||||||
|
COL_TAGS, "A",
|
||||||
|
-1);
|
||||||
|
gtk_list_store_append(mainWindow->entryListStore, &iter);
|
||||||
|
gtk_list_store_set (mainWindow->entryListStore, &iter,
|
||||||
|
COL_TITLE, "Foo",
|
||||||
|
COL_DATE, "1998-12-03",
|
||||||
|
COL_TAGS, "F",
|
||||||
|
-1);
|
||||||
|
|
||||||
|
sortable = GTK_TREE_SORTABLE(mainWindow->entryListStore);
|
||||||
|
gtk_tree_sortable_set_sort_column_id(sortable, COL_DATE, GTK_SORT_DESCENDING);
|
||||||
|
}
|
||||||
|
|
||||||
struct mainWindow *mainWindow_new()
|
struct mainWindow *mainWindow_new()
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
@ -14,10 +78,14 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow->dateStart = GTK_WIDGET(gtk_builder_get_object(builder, "dateStart"));
|
mainWindow->dateStart = GTK_WIDGET(gtk_builder_get_object(builder, "dateStart"));
|
||||||
mainWindow->dateEnd = GTK_WIDGET(gtk_builder_get_object(builder, "dateEnd"));
|
mainWindow->dateEnd = GTK_WIDGET(gtk_builder_get_object(builder, "dateEnd"));
|
||||||
mainWindow->entryText = GTK_WIDGET(gtk_builder_get_object(builder, "entryText"));
|
mainWindow->entryText = GTK_WIDGET(gtk_builder_get_object(builder, "entryText"));
|
||||||
|
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);
|
gtk_builder_connect_signals(builder, NULL);
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(builder));
|
g_object_unref(G_OBJECT(builder));
|
||||||
|
|
||||||
|
mainWindow_test_treeView(mainWindow);
|
||||||
|
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ struct mainWindow {
|
|||||||
GtkWidget *dateStart;
|
GtkWidget *dateStart;
|
||||||
GtkWidget *dateEnd;
|
GtkWidget *dateEnd;
|
||||||
GtkWidget *entryText;
|
GtkWidget *entryText;
|
||||||
|
GtkTreeView *entryListView;
|
||||||
|
GtkListStore *entryListStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mainWindow *mainWindow_new();
|
struct mainWindow *mainWindow_new();
|
||||||
|
Loading…
Reference in New Issue
Block a user