29 #include <stdio.h> |
29 #include <stdio.h> |
30 #include <stdlib.h> |
30 #include <stdlib.h> |
31 |
31 |
32 #include "container.h" |
32 #include "container.h" |
33 #include "../common/context.h" |
33 #include "../common/context.h" |
|
34 #include "../common/object.h" |
|
35 |
34 |
36 |
35 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) { |
37 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) { |
36 UiContainer *ct = ucx_mempool_malloc( |
38 UiContainer *ct = ucx_mempool_malloc( |
37 obj->ctx->mempool, |
39 obj->ctx->mempool, |
38 sizeof(UiContainer)); |
40 sizeof(UiContainer)); |
42 } |
44 } |
43 |
45 |
44 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget) { |
46 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget) { |
45 gtk_container_add(GTK_CONTAINER(ct->widget), widget); |
47 gtk_container_add(GTK_CONTAINER(ct->widget), widget); |
46 } |
48 } |
|
49 |
|
50 |
|
51 UIWIDGET ui_sidebar(UiObject *obj) { |
|
52 #ifdef UI_GTK3 |
|
53 GtkWidget *paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); |
|
54 #else |
|
55 GtkWidget *paned = gtk_hpaned_new(); |
|
56 #endif |
|
57 gtk_paned_set_position(GTK_PANED(paned), 200); |
|
58 |
|
59 GtkWidget *sidebar; |
|
60 #ifdef UI_GTK3 |
|
61 sidebar = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); |
|
62 #else |
|
63 sidebar = gtk_vbox_new(FALSE, 0); |
|
64 #endif |
|
65 gtk_paned_pack1(GTK_PANED(paned), sidebar, TRUE, FALSE); |
|
66 |
|
67 UiObject *left = uic_object_new(obj, sidebar); |
|
68 UiContainer *ct1 = ucx_mempool_malloc( |
|
69 obj->ctx->mempool, |
|
70 sizeof(UiContainer)); |
|
71 ct1->widget = sidebar; |
|
72 ct1->add = ui_box_add; |
|
73 left->container = ct1; |
|
74 |
|
75 UiObject *right = uic_object_new(obj, sidebar); |
|
76 UiContainer *ct2 = ucx_mempool_malloc( |
|
77 obj->ctx->mempool, |
|
78 sizeof(UiContainer)); |
|
79 ct2->widget = paned; |
|
80 ct2->add = ui_split_container_add2; |
|
81 right->container = ct2; |
|
82 |
|
83 UiContainer *ct = uic_get_current_container(obj); |
|
84 ct->add(ct, paned); |
|
85 |
|
86 uic_obj_add(obj, right); |
|
87 uic_obj_add(obj, left); |
|
88 |
|
89 return sidebar; |
|
90 } |
|
91 |
|
92 void ui_split_container_add1(UiContainer *ct, GtkWidget *widget) { |
|
93 gtk_paned_pack1(GTK_PANED(ct->widget), widget, TRUE, FALSE); |
|
94 } |
|
95 |
|
96 void ui_split_container_add2(UiContainer *ct, GtkWidget *widget) { |
|
97 gtk_paned_pack2(GTK_PANED(ct->widget), widget, TRUE, FALSE); |
|
98 } |
|
99 |
|
100 |
|
101 void ui_box_add(UiContainer *ct, GtkWidget *widget) { |
|
102 gtk_box_pack_start(GTK_BOX(ct->widget), widget, TRUE, TRUE, 0); |
|
103 } |