55 if(nwindows == 0) { |
55 if(nwindows == 0) { |
56 gtk_main_quit(); |
56 gtk_main_quit(); |
57 } |
57 } |
58 } |
58 } |
59 |
59 |
60 UiObject* ui_window(char *title, void *window_data) { |
60 static UiObject* create_window(char *title, void *window_data, UiBool simple) { |
61 UcxMempool *mp = ucx_mempool_new(256); |
61 UcxMempool *mp = ucx_mempool_new(256); |
62 UiObject *obj = ucx_mempool_calloc(mp, 1, sizeof(UiObject)); |
62 UiObject *obj = ucx_mempool_calloc(mp, 1, sizeof(UiObject)); |
63 obj->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
63 obj->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
64 obj->ctx = uic_context(obj, mp); |
64 obj->ctx = uic_context(obj, mp); |
65 |
65 |
88 window_data); |
88 window_data); |
89 |
89 |
90 GtkWidget *vbox = ui_gtk_vbox_new(); |
90 GtkWidget *vbox = ui_gtk_vbox_new(); |
91 gtk_container_add(GTK_CONTAINER(obj->widget), vbox); |
91 gtk_container_add(GTK_CONTAINER(obj->widget), vbox); |
92 |
92 |
93 // menu |
93 if(!simple) { |
94 GtkWidget *mb = ui_create_menubar(obj); |
94 // menu |
95 if(mb) { |
95 GtkWidget *mb = ui_create_menubar(obj); |
96 gtk_box_pack_start(GTK_BOX(vbox), mb, FALSE, FALSE, 0); |
96 if(mb) { |
97 } |
97 gtk_box_pack_start(GTK_BOX(vbox), mb, FALSE, FALSE, 0); |
98 |
98 } |
99 // toolbar |
99 |
100 GtkWidget *tb = ui_create_toolbar(obj); |
100 // toolbar |
101 if(tb) { |
101 GtkWidget *tb = ui_create_toolbar(obj); |
102 gtk_box_pack_start(GTK_BOX(vbox), tb, FALSE, FALSE, 0); |
102 if(tb) { |
|
103 gtk_box_pack_start(GTK_BOX(vbox), tb, FALSE, FALSE, 0); |
|
104 } |
103 } |
105 } |
104 |
106 |
105 // window content |
107 // window content |
106 // the content has a (TODO: not yet) configurable frame |
108 // the content has a (TODO: not yet) configurable frame |
107 GtkWidget *frame = gtk_alignment_new(0.5, 0.5, 1, 1); |
109 GtkWidget *frame = gtk_alignment_new(0.5, 0.5, 1, 1); |
112 gtk_container_add(GTK_CONTAINER(frame), content_box); |
114 gtk_container_add(GTK_CONTAINER(frame), content_box); |
113 obj->container = ui_box_container(obj, content_box); |
115 obj->container = ui_box_container(obj, content_box); |
114 |
116 |
115 nwindows++; |
117 nwindows++; |
116 return obj; |
118 return obj; |
|
119 } |
|
120 |
|
121 |
|
122 UiObject* ui_window(char *title, void *window_data) { |
|
123 return create_window(title, window_data, FALSE); |
|
124 } |
|
125 |
|
126 UiObject* ui_simplewindow(char *title, void *window_data) { |
|
127 return create_window(title, window_data, TRUE); |
117 } |
128 } |
118 |
129 |
119 static char* ui_gtkfilechooser(UiObject *obj, GtkFileChooserAction action) { |
130 static char* ui_gtkfilechooser(UiObject *obj, GtkFileChooserAction action) { |
120 char *button; |
131 char *button; |
121 char *title; |
132 char *title; |