-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexampleapp.c
109 lines (91 loc) · 2.37 KB
/
exampleapp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gprintf.h>
#include "exampleapp.h"
#include "lazytreeview.h"
#include "lazystore.h"
struct _ExampleApp
{
GtkApplication parent;
};
struct _ExampleAppClass
{
GtkApplicationClass parent_class;
};
G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
const int nr_of_columns = 20000;
const int nr_of_rows = 15;
static GtkTreeModel *
create_model (void)
{
gint i = 0;
GtkListStore *store;
GtkTreeIter iter;
GType typearray[nr_of_columns];
gchar string[100];
for(i=0;i<nr_of_columns;i++)
{
typearray[i]=G_TYPE_STRING;
}
/* create list store */
store = gtk_list_store_newv (nr_of_columns,
typearray);
/* add data to the list store */
for (i = 0; i < nr_of_rows; i++)
{
gtk_list_store_append (store, &iter);
for(int c = 0;c < nr_of_columns;c++)
{
GValue value = G_VALUE_INIT;
g_value_init(&value, G_TYPE_STRING);
g_sprintf(string,"Row: %d, Column: %d",i,c);
g_value_set_string (&value, string);
gtk_list_store_set_value(store, &iter, c, &value);
}
}
return GTK_TREE_MODEL (store);
}
static void
example_app_init (ExampleApp *app)
{
}
static void
example_app_activate (GApplication *app)
{
GtkWidget *window;
GtkWidget *label;
GtkWidget *sw;
GtkWidget *treeview;
GtkTreeModel *model;
GtkAdjustment *adj;
GtkTreeSelection *selection;
printf("%s\n",__FUNCTION__);
window = gtk_application_window_new (GTK_APPLICATION (app));
gtk_window_set_default_size ( GTK_WINDOW (window), 800, 480);
/* Choose beetween the gkt list store via create_model
or the lazystore*/
#if 0
model = create_model();
#else
model = GTK_TREE_MODEL (lazy_store_new());
#endif
treeview = lazy_tree_view_new();
lazy_tree_view_set_model ( LAZY_TREE_VIEW (treeview), model);
sw = gtk_scrolled_window_new(NULL,NULL);
gtk_container_add (GTK_CONTAINER (sw), treeview);
gtk_container_add (GTK_CONTAINER (window), sw);
gtk_widget_show_all (window);
gtk_window_present (GTK_WINDOW (window));
}
static void
example_app_class_init (ExampleAppClass *class)
{
G_APPLICATION_CLASS (class)->activate = example_app_activate;
}
ExampleApp *
example_app_new (void)
{
return g_object_new (EXAMPLE_APP_TYPE,
"application-id", "org.gtk.exampleapp",
NULL);
}