472 event.obj = view->obj; |
472 event.obj = view->obj; |
473 event.document = event.obj->ctx->document; |
473 event.document = event.obj->ctx->document; |
474 event.window = event.obj->window; |
474 event.window = event.obj->window; |
475 event.intval = view->selection.count; |
475 event.intval = view->selection.count; |
476 event.eventdata = &view->selection; |
476 event.eventdata = &view->selection; |
|
477 event.set = ui_get_setop(); |
477 if(cb) { |
478 if(cb) { |
478 cb(&event, cbdata); |
479 cb(&event, cbdata); |
479 } |
480 } |
480 } |
481 } |
481 |
482 |
514 event.obj = view->obj; |
515 event.obj = view->obj; |
515 event.document = event.obj->ctx->document; |
516 event.document = event.obj->ctx->document; |
516 event.window = event.obj->window; |
517 event.window = event.obj->window; |
517 event.intval = index; |
518 event.intval = index; |
518 event.eventdata = eventdata->data; |
519 event.eventdata = eventdata->data; |
|
520 event.set = ui_get_setop(); |
519 view->onactivate(&event, view->onactivatedata); |
521 view->onactivate(&event, view->onactivatedata); |
520 } |
522 } |
521 } |
523 } |
522 |
524 |
523 |
525 |
550 event.obj = view->obj; |
552 event.obj = view->obj; |
551 event.document = event.obj->ctx->document; |
553 event.document = event.obj->ctx->document; |
552 event.window = event.obj->window; |
554 event.window = event.obj->window; |
553 event.intval = view->selection.count; |
555 event.intval = view->selection.count; |
554 event.eventdata = &view->selection; |
556 event.eventdata = &view->selection; |
|
557 event.set = ui_get_setop(); |
555 view->onactivate(&event, view->onactivatedata); |
558 view->onactivate(&event, view->onactivatedata); |
556 } |
559 } |
557 } |
560 } |
558 |
561 |
559 void ui_update_liststore(GListStore *liststore, UiList *list) { |
562 void ui_update_liststore(GListStore *liststore, UiList *list) { |
587 memcpy(selection.rows, view->selection.rows, selection.count*sizeof(int)); |
590 memcpy(selection.rows, view->selection.rows, selection.count*sizeof(int)); |
588 return selection; |
591 return selection; |
589 } |
592 } |
590 |
593 |
591 void ui_listview_setselection2(UiList *list, UiListSelection selection) { |
594 void ui_listview_setselection2(UiList *list, UiListSelection selection) { |
|
595 ui_setop_enable(TRUE); |
592 UiListView *view = list->obj; |
596 UiListView *view = list->obj; |
593 UiListSelection newselection; |
597 UiListSelection newselection; |
594 newselection.count = view->selection.count; |
598 newselection.count = view->selection.count; |
595 if(selection.count > 0) { |
599 if(selection.count > 0) { |
596 newselection.rows = calloc(newselection.count, sizeof(int)); |
600 newselection.rows = calloc(newselection.count, sizeof(int)); |
605 if(selection.count > 0) { |
609 if(selection.count > 0) { |
606 for(int i=0;i<selection.count;i++) { |
610 for(int i=0;i<selection.count;i++) { |
607 gtk_selection_model_select_item(view->selectionmodel, selection.rows[i], FALSE); |
611 gtk_selection_model_select_item(view->selectionmodel, selection.rows[i], FALSE); |
608 } |
612 } |
609 } |
613 } |
|
614 ui_setop_enable(FALSE); |
610 } |
615 } |
611 |
616 |
612 UiListSelection ui_combobox_getselection(UiList *list) { |
617 UiListSelection ui_combobox_getselection(UiList *list) { |
613 UiListView *view = list->obj; |
618 UiListView *view = list->obj; |
614 guint selection = gtk_drop_down_get_selected(GTK_DROP_DOWN(view->widget)); |
619 guint selection = gtk_drop_down_get_selected(GTK_DROP_DOWN(view->widget)); |
620 } |
625 } |
621 return sel; |
626 return sel; |
622 } |
627 } |
623 |
628 |
624 void ui_combobox_setselection(UiList *list, UiListSelection selection) { |
629 void ui_combobox_setselection(UiList *list, UiListSelection selection) { |
|
630 ui_setop_enable(TRUE); |
625 UiListView *view = list->obj; |
631 UiListView *view = list->obj; |
626 if(selection.count > 0) { |
632 if(selection.count > 0) { |
627 gtk_drop_down_set_selected(GTK_DROP_DOWN(view->widget), selection.rows[0]); |
633 gtk_drop_down_set_selected(GTK_DROP_DOWN(view->widget), selection.rows[0]); |
628 } else { |
634 } else { |
629 gtk_drop_down_set_selected(GTK_DROP_DOWN(view->widget), GTK_INVALID_LIST_POSITION); |
635 gtk_drop_down_set_selected(GTK_DROP_DOWN(view->widget), GTK_INVALID_LIST_POSITION); |
630 } |
636 } |
|
637 ui_setop_enable(FALSE); |
631 } |
638 } |
632 |
639 |
633 #else |
640 #else |
634 |
641 |
635 static GtkListStore* create_list_store(UiList *list, UiModel *model) { |
642 static GtkListStore* create_list_store(UiList *list, UiModel *model) { |
1044 NULL); |
1051 NULL); |
1045 return selection; |
1052 return selection; |
1046 } |
1053 } |
1047 |
1054 |
1048 void ui_listview_setselection(UiList *list, UiListSelection selection) { |
1055 void ui_listview_setselection(UiList *list, UiListSelection selection) { |
|
1056 ui_setop_enable(TRUE); |
1049 UiListView *view = list->obj; |
1057 UiListView *view = list->obj; |
1050 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view->widget)); |
1058 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view->widget)); |
1051 GtkTreePath *path = gtk_tree_path_new_from_indicesv(selection.rows, selection.count); |
1059 GtkTreePath *path = gtk_tree_path_new_from_indicesv(selection.rows, selection.count); |
1052 gtk_tree_selection_select_path(sel, path); |
1060 gtk_tree_selection_select_path(sel, path); |
1053 //g_object_unref(path); |
1061 //g_object_unref(path); |
|
1062 ui_setop_enable(FALSE); |
1054 } |
1063 } |
1055 |
1064 |
1056 |
1065 |
1057 |
1066 |
1058 /* --------------------------- ComboBox --------------------------- */ |
1067 /* --------------------------- ComboBox --------------------------- */ |
1163 event.obj = e->obj; |
1173 event.obj = e->obj; |
1164 event.window = event.obj->window; |
1174 event.window = event.obj->window; |
1165 event.document = event.obj->ctx->document; |
1175 event.document = event.obj->ctx->document; |
1166 event.eventdata = eventdata; |
1176 event.eventdata = eventdata; |
1167 event.intval = index; |
1177 event.intval = index; |
|
1178 event.set = ui_get_setop(); |
1168 e->callback(&event, e->userdata); |
1179 e->callback(&event, e->userdata); |
1169 } |
1180 } |
1170 |
1181 |
1171 void ui_combobox_modelupdate(UiList *list, int i) { |
1182 void ui_combobox_modelupdate(UiList *list, int i) { |
1172 UiListView *view = list->obj; |
1183 UiListView *view = list->obj; |
1183 ret.rows[0] = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox->widget)); |
1194 ret.rows[0] = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox->widget)); |
1184 return ret; |
1195 return ret; |
1185 } |
1196 } |
1186 |
1197 |
1187 void ui_combobox_setselection(UiList *list, UiListSelection selection) { |
1198 void ui_combobox_setselection(UiList *list, UiListSelection selection) { |
|
1199 ui_setop_enable(TRUE); |
1188 UiListView *combobox = list->obj; |
1200 UiListView *combobox = list->obj; |
1189 if(selection.count > 0) { |
1201 if(selection.count > 0) { |
1190 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox->widget), selection.rows[0]); |
1202 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox->widget), selection.rows[0]); |
1191 } |
1203 } |
|
1204 ui_setop_enable(FALSE); |
1192 } |
1205 } |
1193 |
1206 |
1194 |
1207 |
1195 |
1208 |
1196 |
1209 |
1208 e.obj = event->obj; |
1221 e.obj = event->obj; |
1209 e.window = event->obj->window; |
1222 e.window = event->obj->window; |
1210 e.document = event->obj->ctx->document; |
1223 e.document = event->obj->ctx->document; |
1211 e.eventdata = &selection; |
1224 e.eventdata = &selection; |
1212 e.intval = selection.count > 0 ? selection.rows[0] : -1; |
1225 e.intval = selection.count > 0 ? selection.rows[0] : -1; |
|
1226 e.set = ui_get_setop(); |
1213 event->activate(&e, event->activatedata); |
1227 event->activate(&e, event->activatedata); |
1214 |
1228 |
1215 if(selection.count > 0) { |
1229 if(selection.count > 0) { |
1216 free(selection.rows); |
1230 free(selection.rows); |
1217 } |
1231 } |
1227 e.obj = event->obj; |
1241 e.obj = event->obj; |
1228 e.window = event->obj->window; |
1242 e.window = event->obj->window; |
1229 e.document = event->obj->ctx->document; |
1243 e.document = event->obj->ctx->document; |
1230 e.eventdata = &selection; |
1244 e.eventdata = &selection; |
1231 e.intval = selection.count > 0 ? selection.rows[0] : -1; |
1245 e.intval = selection.count > 0 ? selection.rows[0] : -1; |
|
1246 e.set = ui_get_setop(); |
1232 event->selection(&e, event->selectiondata); |
1247 event->selection(&e, event->selectiondata); |
1233 |
1248 |
1234 if(selection.count > 0) { |
1249 if(selection.count > 0) { |
1235 free(selection.rows); |
1250 free(selection.rows); |
1236 } |
1251 } |
1285 event.obj = listview->obj; |
1300 event.obj = listview->obj; |
1286 event.window = event.obj->window; |
1301 event.window = event.obj->window; |
1287 event.document = event.obj->ctx->document; |
1302 event.document = event.obj->ctx->document; |
1288 event.eventdata = dnd; |
1303 event.eventdata = dnd; |
1289 event.intval = 0; |
1304 event.intval = 0; |
|
1305 event.set = ui_get_setop(); |
1290 listview->ondragstart(&event, listview->ondragstartdata); |
1306 listview->ondragstart(&event, listview->ondragstartdata); |
1291 } |
1307 } |
1292 |
1308 |
1293 size_t numproviders = cxListSize(dnd->providers); |
1309 size_t numproviders = cxListSize(dnd->providers); |
1294 if(numproviders > 0) { |
1310 if(numproviders > 0) { |
1320 event.obj = listview->obj; |
1336 event.obj = listview->obj; |
1321 event.window = event.obj->window; |
1337 event.window = event.obj->window; |
1322 event.document = event.obj->ctx->document; |
1338 event.document = event.obj->ctx->document; |
1323 event.eventdata = &dnd; |
1339 event.eventdata = &dnd; |
1324 event.intval = 0; |
1340 event.intval = 0; |
|
1341 event.set = ui_get_setop(); |
1325 listview->ondragcomplete(&event, listview->ondragcompletedata); |
1342 listview->ondragcomplete(&event, listview->ondragcompletedata); |
1326 } |
1343 } |
1327 } |
1344 } |
1328 |
1345 |
1329 static gboolean ui_listview_drop( |
1346 static gboolean ui_listview_drop( |
1348 event.obj = listview->obj; |
1365 event.obj = listview->obj; |
1349 event.window = event.obj->window; |
1366 event.window = event.obj->window; |
1350 event.document = event.obj->ctx->document; |
1367 event.document = event.obj->ctx->document; |
1351 event.eventdata = &dnd; |
1368 event.eventdata = &dnd; |
1352 event.intval = 0; |
1369 event.intval = 0; |
|
1370 event.set = ui_get_setop(); |
1353 listview->ondrop(&event, listview->ondropdata); |
1371 listview->ondrop(&event, listview->ondropdata); |
1354 } |
1372 } |
1355 |
1373 |
1356 return dnd.accept; |
1374 return dnd.accept; |
1357 } |
1375 } |
1410 event.obj = listview->obj; |
1428 event.obj = listview->obj; |
1411 event.window = event.obj->window; |
1429 event.window = event.obj->window; |
1412 event.document = event.obj->ctx->document; |
1430 event.document = event.obj->ctx->document; |
1413 event.eventdata = &dnd; |
1431 event.eventdata = &dnd; |
1414 event.intval = 0; |
1432 event.intval = 0; |
|
1433 event.set = ui_get_setop(); |
1415 listview->ondragstart(&event, listview->ondragstartdata); |
1434 listview->ondragstart(&event, listview->ondragstartdata); |
1416 } |
1435 } |
1417 } |
1436 } |
1418 |
1437 |
1419 static void ui_listview_drag_end( |
1438 static void ui_listview_drag_end( |
1434 event.obj = listview->obj; |
1453 event.obj = listview->obj; |
1435 event.window = event.obj->window; |
1454 event.window = event.obj->window; |
1436 event.document = event.obj->ctx->document; |
1455 event.document = event.obj->ctx->document; |
1437 event.eventdata = &dnd; |
1456 event.eventdata = &dnd; |
1438 event.intval = 0; |
1457 event.intval = 0; |
|
1458 event.set = ui_get_setop(); |
1439 listview->ondragcomplete(&event, listview->ondragcompletedata); |
1459 listview->ondragcomplete(&event, listview->ondragcompletedata); |
1440 } |
1460 } |
1441 } |
1461 } |
1442 |
1462 |
1443 void ui_listview_add_dnd(UiListView *listview, UiListArgs *args) { |
1463 void ui_listview_add_dnd(UiListView *listview, UiListArgs *args) { |
1479 event.obj = listview->obj; |
1499 event.obj = listview->obj; |
1480 event.window = event.obj->window; |
1500 event.window = event.obj->window; |
1481 event.document = event.obj->ctx->document; |
1501 event.document = event.obj->ctx->document; |
1482 event.eventdata = &dnd; |
1502 event.eventdata = &dnd; |
1483 event.intval = 0; |
1503 event.intval = 0; |
|
1504 event.set = ui_get_setop(); |
1484 listview->ondrop(&event, listview->ondropdata); |
1505 listview->ondrop(&event, listview->ondropdata); |
1485 } |
1506 } |
1486 } |
1507 } |
1487 |
1508 |
1488 void ui_listview_enable_drop(UiListView *listview, UiListArgs *args) { |
1509 void ui_listview_enable_drop(UiListView *listview, UiListArgs *args) { |
1951 event.obj = data->obj; |
1972 event.obj = data->obj; |
1952 event.window = event.obj->window; |
1973 event.window = event.obj->window; |
1953 event.document = event.obj->ctx->document; |
1974 event.document = event.obj->ctx->document; |
1954 event.eventdata = &eventdata; |
1975 event.eventdata = &eventdata; |
1955 event.intval = data->value0; |
1976 event.intval = data->value0; |
|
1977 event.set = ui_get_setop(); |
1956 |
1978 |
1957 if(data->callback) { |
1979 if(data->callback) { |
1958 data->callback(&event, data->userdata); |
1980 data->callback(&event, data->userdata); |
1959 } |
1981 } |
1960 } |
1982 } |