tMake GtkListStore derive from GObject - vaccinewars - be a doctor and try to v… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7be3bfd72043b8786fddbac23f5b4ab3e988b455 | |
parent 2cef1a49dd2aca421d8fd1a93135e726db0f24c2 | |
Author: Ben Webb <[email protected]> | |
Date: Sat, 28 Nov 2020 19:03:05 -0800 | |
Make GtkListStore derive from GObject | |
This allows us to cast GtkListStore* to GObject*, | |
and to use GObject behavior such as g_object_set_data(). | |
Diffstat: | |
M src/gtkport/gtkport.c | 2 +- | |
M src/gtkport/gtkport.h | 1 + | |
M src/gtkport/treeview.c | 6 +++++- | |
M src/gtkport/treeview.h | 1 + | |
4 files changed, 8 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/src/gtkport/gtkport.c b/src/gtkport/gtkport.c | |
t@@ -258,7 +258,7 @@ static GtkSignalType GtkObjectSignals[] = { | |
{"", NULL, NULL} | |
}; | |
-static GtkClass GtkObjectClass = { | |
+GtkClass GtkObjectClass = { | |
"object", NULL, sizeof(GObject), GtkObjectSignals, NULL | |
}; | |
diff --git a/src/gtkport/gtkport.h b/src/gtkport/gtkport.h | |
t@@ -293,6 +293,7 @@ struct _GtkTableRowCol { | |
}; | |
extern GtkClass GtkContainerClass; | |
+extern GtkClass GtkObjectClass; | |
extern HFONT defFont; | |
extern HINSTANCE hInst; | |
diff --git a/src/gtkport/treeview.c b/src/gtkport/treeview.c | |
t@@ -80,6 +80,10 @@ static GtkClass GtkTreeViewClass = { | |
gtk_tree_view_wndproc | |
}; | |
+static GtkClass GtkListStoreClass = { | |
+ "list_store", &GtkObjectClass, sizeof(GtkListStore), NULL, NULL | |
+}; | |
+ | |
static void SetTreeViewHeaderSize(GtkTreeView *clist) | |
{ | |
RECT rc; | |
t@@ -917,7 +921,7 @@ GtkListStore *gtk_list_store_new(gint n_columns, ...) | |
va_list ap; | |
va_start(ap, n_columns); | |
- store = g_new0(GtkListStore, 1); | |
+ store = GTK_LIST_STORE(GtkNewObject(&GtkListStoreClass)); | |
store->view = NULL; | |
store->ncols = n_columns; | |
store->coltype = g_new(int, n_columns); | |
diff --git a/src/gtkport/treeview.h b/src/gtkport/treeview.h | |
t@@ -86,6 +86,7 @@ struct _GtkListStoreRow { | |
}; | |
struct _GtkListStore { | |
+ GObject object; | |
int ncols; /* Number of columns */ | |
int *coltype; /* Type of each column (e.g. G_TYPE_STRING) */ | |
GArray *rows; /* All rows in the list as GtkListStoreRow */ |