diff -r 9a5f47fbc5c3 -r 458831c574f4 ui/gtk/container.c --- a/ui/gtk/container.c Sat Apr 12 13:44:53 2014 +0200 +++ b/ui/gtk/container.c Sat May 10 15:43:22 2014 +0200 @@ -31,6 +31,8 @@ #include "container.h" #include "../common/context.h" +#include "../common/object.h" + UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) { UiContainer *ct = ucx_mempool_malloc( @@ -44,3 +46,58 @@ void ui_frame_container_add(UiContainer *ct, GtkWidget *widget) { gtk_container_add(GTK_CONTAINER(ct->widget), widget); } + + +UIWIDGET ui_sidebar(UiObject *obj) { +#ifdef UI_GTK3 + GtkWidget *paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); +#else + GtkWidget *paned = gtk_hpaned_new(); +#endif + gtk_paned_set_position(GTK_PANED(paned), 200); + + GtkWidget *sidebar; +#ifdef UI_GTK3 + sidebar = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); +#else + sidebar = gtk_vbox_new(FALSE, 0); +#endif + gtk_paned_pack1(GTK_PANED(paned), sidebar, TRUE, FALSE); + + UiObject *left = uic_object_new(obj, sidebar); + UiContainer *ct1 = ucx_mempool_malloc( + obj->ctx->mempool, + sizeof(UiContainer)); + ct1->widget = sidebar; + ct1->add = ui_box_add; + left->container = ct1; + + UiObject *right = uic_object_new(obj, sidebar); + UiContainer *ct2 = ucx_mempool_malloc( + obj->ctx->mempool, + sizeof(UiContainer)); + ct2->widget = paned; + ct2->add = ui_split_container_add2; + right->container = ct2; + + UiContainer *ct = uic_get_current_container(obj); + ct->add(ct, paned); + + uic_obj_add(obj, right); + uic_obj_add(obj, left); + + return sidebar; +} + +void ui_split_container_add1(UiContainer *ct, GtkWidget *widget) { + gtk_paned_pack1(GTK_PANED(ct->widget), widget, TRUE, FALSE); +} + +void ui_split_container_add2(UiContainer *ct, GtkWidget *widget) { + gtk_paned_pack2(GTK_PANED(ct->widget), widget, TRUE, FALSE); +} + + +void ui_box_add(UiContainer *ct, GtkWidget *widget) { + gtk_box_pack_start(GTK_BOX(ct->widget), widget, TRUE, TRUE, 0); +}