diff --git a/404.html b/404.html index 7a87e1e..181d9c6 100644 --- a/404.html +++ b/404.html @@ -476,11 +476,11 @@

标签
-
18
+
19
分类
-
39
+
40
文章
@@ -533,11 +533,11 @@

404
Page Not Found

- 共撰写了 39 篇文章 + 共撰写了 40 篇文章 - 共 47.2k 字 + 共 50.6k 字

diff --git a/Centos8-install/index.html b/Centos8-install/index.html index 6d4f292..d0af70f 100644 --- a/Centos8-install/index.html +++ b/Centos8-install/index.html @@ -480,11 +480,11 @@

标签
-
18
+
19
分类
-
39
+
40
文章
@@ -817,11 +817,11 @@

- 共撰写了 39 篇文章 + 共撰写了 40 篇文章 - 共 47.2k 字 + 共 50.6k 字

diff --git a/GObject-tutorial-beginner-01/index.html b/GObject-tutorial-beginner-01/index.html index a009fb7..e7ba7e6 100644 --- a/GObject-tutorial-beginner-01/index.html +++ b/GObject-tutorial-beginner-01/index.html @@ -26,7 +26,7 @@ - + @@ -480,11 +480,11 @@

标签
-
18
+
19
分类
-
39
+
40
文章
@@ -538,8 +538,8 @@

  - 2024-11-11 13:52:26 - 2024-11-11 13:52:26 + 2024-11-14 10:38:55 + 2024-11-14 10:38:55 更新 @@ -640,7 +640,7 @@

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
//file: gobject.h
typedef struct _GObjectClass GObjectClass;
struct _GObjectClass
{
GTypeClass g_type_class;

/*< private >*/
GSList *construct_properties;

/*< public >*/
/* seldom overridden */
GObject* (*constructor) (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties);
/* overridable methods */
void (*set_property) (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
void (*get_property) (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
void (*dispose) (GObject *object);
void (*finalize) (GObject *object);
/* seldom overridden */
void (*dispatch_properties_changed) (GObject *object,
guint n_pspecs,
GParamSpec **pspecs);
/* signals */
void (*notify) (GObject *object,
GParamSpec *pspec);

/* called when done constructing */
void (*constructed) (GObject *object);

/*< private >*/
gsize flags;

gsize n_construct_properties;

gpointer pspecs;
gsize n_pspecs;

/* padding */
gpointer pdummy[3];
};

下面使用一个简单示例,来演示GObject的类和实例的使用

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//file: example01.c
#include <glib-object.h>

int main (int argc, char **argv)
{

GObject *instance1, *instance2; //指向实例的指针
GObjectClass *class1, *class2; //指向类的指针

instance1 = g_object_new (G_TYPE_OBJECT, NULL);
instance2 = g_object_new (G_TYPE_OBJECT, NULL);
g_print ("The address of instance1 is %p\n", instance1);
g_print ("The address of instance2 is %p\n", instance2);

class1 = G_OBJECT_GET_CLASS (instance1);
class2 = G_OBJECT_GET_CLASS (instance2);
g_print ("The address of the class of instance1 is %p\n", class1);
g_print ("The address of the class of instance2 is %p\n", class2);

g_object_unref (instance1);
g_object_unref (instance2);

return 0;
}
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//file: example01.c
#include <glib-object.h>

int main (int argc, char **argv)
{

GObject* instance1,* instance2; //指向实例的指针
GObjectClass* class1,* class2; //指向类的指针

instance1 = g_object_new (G_TYPE_OBJECT, NULL);
instance2 = g_object_new (G_TYPE_OBJECT, NULL);
g_print ("The address of instance1 is %p\n", instance1);
g_print ("The address of instance2 is %p\n", instance2);

class1 = G_OBJECT_GET_CLASS (instance1);
class2 = G_OBJECT_GET_CLASS (instance2);
g_print ("The address of the class of instance1 is %p\n", class1);
g_print ("The address of the class of instance2 is %p\n", class2);

g_object_unref (instance1);
g_object_unref (instance2);

return 0;
}

其中: