| 1109 "destroy", |
1109 "destroy", |
| 1110 G_CALLBACK(save_pane_pos), |
1110 G_CALLBACK(save_pane_pos), |
| 1111 strdup(args->position_property)); |
1111 strdup(args->position_property)); |
| 1112 } |
1112 } |
| 1113 |
1113 |
| 1114 UiContainerX *container = ui_splitpane_container(obj, pane0, orientation, max, args->initial_position); |
1114 UiSplitPane *splitpane = ui_create_splitpane_data(pane0, orientation, max, args->initial_position); |
| |
1115 UiContainerX *container = ui_splitpane_container(obj, pane0, splitpane); |
| 1115 uic_object_push_container(obj, container); |
1116 uic_object_push_container(obj, container); |
| 1116 |
1117 |
| 1117 g_object_set_data(G_OBJECT(pane0), "ui_splitpane", container); |
1118 g_object_set_data(G_OBJECT(pane0), "ui_splitpane", splitpane); |
| 1118 |
1119 |
| 1119 UiVar *var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER); |
1120 UiVar *var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER); |
| 1120 if(var) { |
1121 if(var) { |
| 1121 UiSplitPaneContainer *s = (UiSplitPaneContainer*)container; |
|
| 1122 UiInteger *i = var->value; |
1122 UiInteger *i = var->value; |
| 1123 s->initial_position = i->value; |
1123 splitpane->initial_position = i->value; |
| 1124 |
1124 |
| 1125 i->obj = s; |
1125 i->obj = splitpane; |
| 1126 i->get = ui_splitpane_get; |
1126 i->get = ui_splitpane_get; |
| 1127 i->set = ui_splitpane_set; |
1127 i->set = ui_splitpane_set; |
| 1128 } |
1128 } |
| 1129 |
1129 |
| 1130 return pane0; |
1130 return pane0; |
| 1136 |
1136 |
| 1137 UIWIDGET ui_vsplitpane_create(UiObject *obj, UiSplitPaneArgs *args) { |
1137 UIWIDGET ui_vsplitpane_create(UiObject *obj, UiSplitPaneArgs *args) { |
| 1138 return splitpane_create(obj, UI_VERTICAL, args); |
1138 return splitpane_create(obj, UI_VERTICAL, args); |
| 1139 } |
1139 } |
| 1140 |
1140 |
| 1141 UiContainerX* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiOrientation orientation, int max, int init) { |
1141 UiSplitPane* ui_create_splitpane_data(GtkWidget *pane, UiOrientation orientation, int max, int init) { |
| 1142 UiSplitPaneContainer *ct = ui_calloc(obj->ctx, 1, sizeof(UiSplitPaneContainer)); |
1142 UiSplitPane *ct = malloc(sizeof(UiSplitPane)); |
| 1143 ct->container.widget = pane; |
|
| 1144 ct->container.add = ui_splitpane_container_add; |
|
| 1145 ct->current_pane = pane; |
1143 ct->current_pane = pane; |
| 1146 ct->orientation = orientation; |
1144 ct->orientation = orientation; |
| 1147 ct->max = max; |
1145 ct->max = max; |
| 1148 ct->initial_position = init; |
1146 ct->initial_position = init; |
| 1149 ct->children = cxArrayListCreateSimple(CX_STORE_POINTERS, 4); |
1147 ct->children = cxArrayListCreateSimple(CX_STORE_POINTERS, 4); |
| |
1148 return ct; |
| |
1149 } |
| |
1150 |
| |
1151 UiContainerX* ui_splitpane_container(UiObject *obj, GtkWidget *pane, UiSplitPane *data) { |
| |
1152 UiSplitPaneContainer *ct = ui_calloc(obj->ctx, 1, sizeof(UiSplitPaneContainer)); |
| |
1153 ct->container.widget = pane; |
| |
1154 ct->container.add = ui_splitpane_container_add; |
| |
1155 ct->splitpane = data; |
| 1150 return (UiContainerX*)ct; |
1156 return (UiContainerX*)ct; |
| 1151 } |
1157 } |
| 1152 |
1158 |
| 1153 void ui_splitpane_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout) { |
1159 void ui_splitpane_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout) { |
| 1154 UiSplitPaneContainer *s = (UiSplitPaneContainer*)ct; |
1160 UiSplitPaneContainer *sct = (UiSplitPaneContainer*)ct; |
| |
1161 UiSplitPane *s = sct->splitpane; |
| 1155 |
1162 |
| 1156 if(s->nchildren >= s->max) { |
1163 if(s->nchildren >= s->max) { |
| 1157 fprintf(stderr, "splitpane: maximum number of children reached\n"); |
1164 fprintf(stderr, "splitpane: maximum number of children reached\n"); |
| 1158 return; |
1165 return; |
| 1159 } |
1166 } |
| 1181 s->nchildren++; |
1188 s->nchildren++; |
| 1182 } |
1189 } |
| 1183 } |
1190 } |
| 1184 |
1191 |
| 1185 int64_t ui_splitpane_get(UiInteger *i) { |
1192 int64_t ui_splitpane_get(UiInteger *i) { |
| 1186 UiSplitPaneContainer *s = i->obj; |
1193 UiSplitPane *s = i->obj; |
| 1187 i->value = gtk_paned_get_position(GTK_PANED(s->container.widget)); |
1194 i->value = gtk_paned_get_position(GTK_PANED(s->current_pane)); |
| 1188 return i->value; |
1195 return i->value; |
| 1189 } |
1196 } |
| 1190 |
1197 |
| 1191 void ui_splitpane_set(UiInteger *i, int64_t value) { |
1198 void ui_splitpane_set(UiInteger *i, int64_t value) { |
| 1192 UiSplitPaneContainer *s = i->obj; |
1199 UiSplitPane *s = i->obj; |
| 1193 i->value = value; |
1200 i->value = value; |
| 1194 gtk_paned_set_position(GTK_PANED(s->container.widget), (int)value); |
1201 gtk_paned_set_position(GTK_PANED(s->current_pane), (int)value); |
| 1195 } |
1202 } |
| 1196 |
1203 |
| 1197 UIEXPORT void ui_splitpane_set_visible(UIWIDGET splitpane, int child_index, UiBool visible) { |
1204 UIEXPORT void ui_splitpane_set_visible(UIWIDGET splitpane, int child_index, UiBool visible) { |
| 1198 UiSplitPaneContainer *ct = g_object_get_data(G_OBJECT(splitpane), "ui_splitpane"); |
1205 UiSplitPane *s = g_object_get_data(G_OBJECT(splitpane), "ui_splitpane"); |
| 1199 if(!ct) { |
1206 if(!s) { |
| 1200 fprintf(stderr, "UI Error: not a splitpane\n"); |
1207 fprintf(stderr, "UI Error: not a splitpane\n"); |
| 1201 return; |
1208 return; |
| 1202 } |
1209 } |
| 1203 |
1210 |
| 1204 GtkWidget *w = cxListAt(ct->children, child_index); |
1211 GtkWidget *w = cxListAt(s->children, child_index); |
| 1205 if(w) { |
1212 if(w) { |
| 1206 gtk_widget_set_visible(w, visible); |
1213 gtk_widget_set_visible(w, visible); |
| 1207 } |
1214 } |
| 1208 } |
1215 } |
| 1209 |
1216 |