| 2299 ui_listbox_update_sublist(listbox, sublist, pos); |
2299 ui_listbox_update_sublist(listbox, sublist, pos); |
| 2300 pos += sublist->numitems; |
2300 pos += sublist->numitems; |
| 2301 } |
2301 } |
| 2302 } |
2302 } |
| 2303 |
2303 |
| 2304 static void listbox_button_clicked(GtkWidget *widget, UiEventDataExt *data) { |
2304 static void listbox_button_clicked(GtkWidget *button, UiEventDataExt *data) { |
| 2305 UiListBoxSubList *sublist = data->customdata0; |
2305 UiListBoxSubList *sublist = data->customdata0; |
| 2306 |
2306 |
| 2307 UiSubListEventData eventdata; |
2307 UiSubListEventData eventdata; |
| 2308 eventdata.list = sublist->var->value; |
2308 eventdata.list = sublist->var->value; |
| 2309 eventdata.sublist_index = sublist->index; |
2309 eventdata.sublist_index = sublist->index; |
| 2322 event.set = ui_get_setop(); |
2322 event.set = ui_get_setop(); |
| 2323 |
2323 |
| 2324 if(data->callback2) { |
2324 if(data->callback2) { |
| 2325 data->callback2(&event, data->userdata2); |
2325 data->callback2(&event, data->userdata2); |
| 2326 } |
2326 } |
| 2327 } |
2327 |
| |
2328 if(data->customdata3) { |
| |
2329 UIMENU menu = data->customdata3; |
| |
2330 g_object_set_data(G_OBJECT(button), "ui-button-popup", menu); |
| |
2331 gtk_popover_popup(GTK_POPOVER(menu)); |
| |
2332 } |
| |
2333 } |
| |
2334 |
| |
2335 #if GTK_CHECK_VERSION(3, 0, 0) |
| |
2336 static void button_popover_closed(GtkPopover *popover, GtkWidget *button) { |
| |
2337 g_object_set_data(G_OBJECT(button), "ui-button-popup", NULL); |
| |
2338 if(g_object_get_data(G_OBJECT(button), "ui-button-invisible")) { |
| |
2339 g_object_set_data(G_OBJECT(button), "ui-button-invisible", NULL); |
| |
2340 gtk_widget_set_visible(button, FALSE); |
| |
2341 } |
| |
2342 } |
| |
2343 #endif |
| 2328 |
2344 |
| 2329 static void listbox_fill_row(UiListBox *listbox, GtkWidget *row, UiListBoxSubList *sublist, UiSubListItem *item, int index) { |
2345 static void listbox_fill_row(UiListBox *listbox, GtkWidget *row, UiListBoxSubList *sublist, UiSubListItem *item, int index) { |
| 2330 UiBool is_header = index < 0; |
2346 UiBool is_header = index < 0; |
| 2331 |
2347 |
| 2332 GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); |
2348 GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); |
| 2396 event |
2412 event |
| 2397 ); |
2413 ); |
| 2398 gtk_widget_set_visible(button, FALSE); |
2414 gtk_widget_set_visible(button, FALSE); |
| 2399 |
2415 |
| 2400 g_object_set_data(G_OBJECT(row), "ui-listbox-row-button", button); |
2416 g_object_set_data(G_OBJECT(row), "ui-listbox-row-button", button); |
| |
2417 |
| |
2418 // menu |
| |
2419 if(item->button_menu) { |
| |
2420 UIMENU menu = ui_contextmenu_create(item->button_menu, listbox->obj, button); |
| |
2421 event->customdata3 = menu; |
| |
2422 g_signal_connect(menu, "closed", G_CALLBACK(button_popover_closed), button); |
| |
2423 } |
| 2401 } |
2424 } |
| 2402 } |
2425 } |
| 2403 |
2426 |
| 2404 static void update_sublist_item(UiListBox *listbox, UiListBoxSubList *sublist, int index) { |
2427 static void update_sublist_item(UiListBox *listbox, UiListBoxSubList *sublist, int index) { |
| 2405 int header_row = listbox->header_is_item && sublist->header ? 1 : 0; |
2428 int header_row = listbox->header_is_item && sublist->header ? 1 : 0; |
| 2439 } |
2462 } |
| 2440 } |
2463 } |
| 2441 |
2464 |
| 2442 static void listbox_row_on_leave(GtkWidget *row) { |
2465 static void listbox_row_on_leave(GtkWidget *row) { |
| 2443 GtkWidget *button = g_object_get_data(G_OBJECT(row), "ui-listbox-row-button"); |
2466 GtkWidget *button = g_object_get_data(G_OBJECT(row), "ui-listbox-row-button"); |
| 2444 if(button) { |
2467 if(button) { |
| 2445 gtk_widget_set_visible(button, FALSE); |
2468 if(!g_object_get_data(G_OBJECT(button), "ui-button-popup")) { |
| |
2469 gtk_widget_set_visible(button, FALSE); |
| |
2470 } else { |
| |
2471 g_object_set_data(G_OBJECT(button), "ui-button-invisible", (void*)1); |
| |
2472 } |
| 2446 } |
2473 } |
| 2447 } |
2474 } |
| 2448 |
2475 |
| 2449 #if GTK_CHECK_VERSION(4, 0, 0) |
2476 #if GTK_CHECK_VERSION(4, 0, 0) |
| 2450 static void listbox_row_enter( |
2477 static void listbox_row_enter( |