31 #include <string.h> |
31 #include <string.h> |
32 |
32 |
33 #include "../ui/window.h" |
33 #include "../ui/window.h" |
34 #include "../ui/properties.h" |
34 #include "../ui/properties.h" |
35 #include "../common/context.h" |
35 #include "../common/context.h" |
|
36 #include "../common/menu.h" |
|
37 #include "../common/toolbar.h" |
36 |
38 |
37 #include <cx/basic_mempool.h> |
39 #include <cx/mempool.h> |
38 |
40 |
39 #include "menu.h" |
41 #include "menu.h" |
40 #include "toolbar.h" |
42 #include "toolbar.h" |
41 #include "container.h" |
43 #include "container.h" |
42 |
44 |
65 gtk_main_quit(); |
67 gtk_main_quit(); |
66 } |
68 } |
67 #endif |
69 #endif |
68 } |
70 } |
69 |
71 |
70 static UiObject* create_window(char *title, void *window_data, UiBool simple) { |
72 static UiObject* create_window(const char *title, void *window_data, UiBool simple) { |
71 CxMempool *mp = cxBasicMempoolCreate(256); |
73 CxMempool *mp = cxBasicMempoolCreate(256); |
72 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
74 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
73 |
75 |
74 #ifndef UI_GTK2 |
76 #ifndef UI_GTK2 |
75 obj->widget = gtk_application_window_new(ui_get_application()); |
77 obj->widget = gtk_application_window_new(ui_get_application()); |
76 #else |
78 #else |
77 obj->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
79 obj->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
78 #endif |
80 #endif |
79 |
81 |
80 |
82 |
81 obj->ctx = uic_context(obj, mp->allocator); |
83 obj->ctx = uic_context(obj, mp); |
82 obj->window = window_data; |
84 obj->window = window_data; |
83 |
85 |
84 if(title != NULL) { |
86 if(title != NULL) { |
85 gtk_window_set_title(GTK_WINDOW(obj->widget), title); |
87 gtk_window_set_title(GTK_WINDOW(obj->widget), title); |
86 } |
88 } |
108 GtkWidget *vbox = ui_gtk_vbox_new(0); |
110 GtkWidget *vbox = ui_gtk_vbox_new(0); |
109 gtk_container_add(GTK_CONTAINER(obj->widget), vbox); |
111 gtk_container_add(GTK_CONTAINER(obj->widget), vbox); |
110 |
112 |
111 if(!simple) { |
113 if(!simple) { |
112 // menu |
114 // menu |
113 GtkWidget *mb = ui_create_menubar(obj); |
115 if(uic_get_menu_list()) { |
114 if(mb) { |
116 GtkWidget *mb = ui_create_menubar(obj); |
115 gtk_box_pack_start(GTK_BOX(vbox), mb, FALSE, FALSE, 0); |
117 if(mb) { |
|
118 gtk_box_pack_start(GTK_BOX(vbox), mb, FALSE, FALSE, 0); |
|
119 } |
116 } |
120 } |
117 |
121 |
118 // toolbar |
122 // toolbar |
119 GtkWidget *tb = ui_create_toolbar(obj); |
123 if(uic_toolbar_isenabled()) { |
120 if(tb) { |
124 GtkWidget *tb = ui_create_toolbar(obj); |
121 gtk_box_pack_start(GTK_BOX(vbox), tb, FALSE, FALSE, 0); |
125 if(tb) { |
|
126 gtk_box_pack_start(GTK_BOX(vbox), tb, FALSE, FALSE, 0); |
|
127 } |
122 } |
128 } |
123 } |
129 } |
124 |
130 |
125 // window content |
131 // window content |
126 // the content has a (TODO: not yet) configurable frame |
132 // the content has a (TODO: not yet) configurable frame |
136 nwindows++; |
142 nwindows++; |
137 return obj; |
143 return obj; |
138 } |
144 } |
139 |
145 |
140 |
146 |
141 UiObject* ui_window(char *title, void *window_data) { |
147 UiObject* ui_window(const char *title, void *window_data) { |
142 return create_window(title, window_data, FALSE); |
148 return create_window(title, window_data, FALSE); |
143 } |
149 } |
144 |
150 |
145 UiObject* ui_simplewindow(char *title, void *window_data) { |
151 UiObject* ui_simplewindow(const char *title, void *window_data) { |
146 return create_window(title, window_data, TRUE); |
152 return create_window(title, window_data, TRUE); |
147 } |
153 } |
148 |
154 |
149 static char* ui_gtkfilechooser(UiObject *obj, GtkFileChooserAction action) { |
155 static char* ui_gtkfilechooser(UiObject *obj, GtkFileChooserAction action) { |
150 char *button; |
156 char *button; |