| 2800 } |
2800 } |
| 2801 |
2801 |
| 2802 static void listbox_row_on_enter(GtkWidget *row) { |
2802 static void listbox_row_on_enter(GtkWidget *row) { |
| 2803 GtkWidget *button = g_object_get_data(G_OBJECT(row), "ui-listbox-row-button"); |
2803 GtkWidget *button = g_object_get_data(G_OBJECT(row), "ui-listbox-row-button"); |
| 2804 if(button) { |
2804 if(button) { |
| |
2805 //gtk_widget_set_opacity(button, 1.0); |
| 2805 gtk_widget_set_visible(button, TRUE); |
2806 gtk_widget_set_visible(button, TRUE); |
| 2806 } |
2807 } |
| 2807 } |
2808 } |
| 2808 |
2809 |
| 2809 static void listbox_row_on_leave(GtkWidget *row) { |
2810 static void listbox_row_on_leave(GtkWidget *row) { |
| 2810 GtkWidget *button = g_object_get_data(G_OBJECT(row), "ui-listbox-row-button"); |
2811 GtkWidget *button = g_object_get_data(G_OBJECT(row), "ui-listbox-row-button"); |
| 2811 if(button) { |
2812 if(button) { |
| 2812 if(!g_object_get_data(G_OBJECT(button), "ui-button-popup")) { |
2813 if(!g_object_get_data(G_OBJECT(button), "ui-button-popup")) { |
| |
2814 //gtk_widget_set_opacity(button, 0.0); |
| 2813 gtk_widget_set_visible(button, FALSE); |
2815 gtk_widget_set_visible(button, FALSE); |
| 2814 } else { |
2816 } else { |
| 2815 g_object_set_data(G_OBJECT(button), "ui-button-invisible", (void*)1); |
2817 g_object_set_data(G_OBJECT(button), "ui-button-invisible", (void*)1); |
| 2816 } |
2818 } |
| 2817 } |
2819 } |
| 2834 listbox_row_on_leave(row); |
2836 listbox_row_on_leave(row); |
| 2835 } |
2837 } |
| 2836 #else |
2838 #else |
| 2837 static gboolean listbox_row_enter( |
2839 static gboolean listbox_row_enter( |
| 2838 GtkWidget *row, |
2840 GtkWidget *row, |
| 2839 GdkEventCrossing event, |
2841 GdkEventCrossing *event, |
| 2840 gpointer user_data) |
2842 gpointer user_data) |
| 2841 { |
2843 { |
| |
2844 if(event->detail == GDK_NOTIFY_INFERIOR) { |
| |
2845 return FALSE; |
| |
2846 } |
| 2842 listbox_row_on_enter(row); |
2847 listbox_row_on_enter(row); |
| 2843 return FALSE; |
2848 return FALSE; |
| 2844 } |
2849 } |
| 2845 |
2850 |
| 2846 |
2851 |
| 2847 static gboolean listbox_row_leave( |
2852 static gboolean listbox_row_leave( |
| 2848 GtkWidget *row, |
2853 GtkWidget *row, |
| 2849 GdkEventCrossing *event, |
2854 GdkEventCrossing *event, |
| 2850 gpointer user_data) |
2855 gpointer user_data) |
| 2851 { |
2856 { |
| |
2857 if(event->detail == GDK_NOTIFY_INFERIOR) { |
| |
2858 return FALSE; |
| |
2859 } |
| 2852 listbox_row_on_leave(row); |
2860 listbox_row_on_leave(row); |
| 2853 return FALSE; |
2861 return FALSE; |
| 2854 } |
2862 } |
| 2855 |
2863 |
| 2856 #endif |
2864 #endif |
| 2912 item.label = strdup(sublist->header); |
2920 item.label = strdup(sublist->header); |
| 2913 } |
2921 } |
| 2914 |
2922 |
| 2915 // create listbox item |
2923 // create listbox item |
| 2916 GtkWidget *row = gtk_list_box_row_new(); |
2924 GtkWidget *row = gtk_list_box_row_new(); |
| |
2925 GtkWidget *row0 = row; |
| 2917 #if GTK_CHECK_VERSION(4, 0, 0) |
2926 #if GTK_CHECK_VERSION(4, 0, 0) |
| 2918 GtkEventController *motion_controller = gtk_event_controller_motion_new(); |
2927 GtkEventController *motion_controller = gtk_event_controller_motion_new(); |
| 2919 gtk_widget_add_controller(GTK_WIDGET(row), motion_controller); |
2928 gtk_widget_add_controller(GTK_WIDGET(row), motion_controller); |
| 2920 g_signal_connect(motion_controller, "enter", G_CALLBACK(listbox_row_enter), row); |
2929 g_signal_connect(motion_controller, "enter", G_CALLBACK(listbox_row_enter), row); |
| 2921 g_signal_connect(motion_controller, "leave", G_CALLBACK(listbox_row_leave), row); |
2930 g_signal_connect(motion_controller, "leave", G_CALLBACK(listbox_row_leave), row); |
| 2922 #else |
2931 #else |
| 2923 gtk_widget_set_events(GTK_WIDGET(row), GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
2932 row0 = gtk_event_box_new(); |
| 2924 g_signal_connect(row, "enter-notify-event", G_CALLBACK(listbox_row_enter), NULL); |
2933 LISTBOX_ROW_SET_CHILD(row, row0); |
| 2925 g_signal_connect(row, "leave-notify-event", G_CALLBACK(listbox_row_leave), NULL); |
2934 gtk_widget_set_events(GTK_WIDGET(row0), GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
| |
2935 g_signal_connect(row0, "enter-notify-event", G_CALLBACK(listbox_row_enter), NULL); |
| |
2936 g_signal_connect(row0, "leave-notify-event", G_CALLBACK(listbox_row_leave), NULL); |
| 2926 #endif |
2937 #endif |
| 2927 |
2938 |
| 2928 listbox_fill_row(listbox, row, sublist, &item, index); |
2939 listbox_fill_row(listbox, row0, sublist, &item, index); |
| 2929 LISTBOX_ROW_SHOW(row); |
2940 LISTBOX_ROW_SHOW(row); |
| 2930 if(index == first_index) { |
2941 if(index == first_index) { |
| 2931 // first row in the sublist, set ui_listbox data to the row |
2942 // first row in the sublist, set ui_listbox data to the row |
| 2932 // which is then used by the headerfunc |
2943 // which is then used by the headerfunc |
| 2933 g_object_set_data(G_OBJECT(row), "ui_listbox", listbox); |
2944 g_object_set_data(G_OBJECT(row), "ui_listbox", listbox); |
| 3303 if(listbox->getvalue) { |
3314 if(listbox->getvalue) { |
| 3304 listbox->getvalue(list, elm, index, &item, listbox->getvaluedata); |
3315 listbox->getvalue(list, elm, index, &item, listbox->getvaluedata); |
| 3305 } |
3316 } |
| 3306 |
3317 |
| 3307 GtkWidget *row = gtk_list_box_row_new(); |
3318 GtkWidget *row = gtk_list_box_row_new(); |
| |
3319 GtkWidget *row0 = row; |
| 3308 #if GTK_CHECK_VERSION(4, 0, 0) |
3320 #if GTK_CHECK_VERSION(4, 0, 0) |
| 3309 GtkEventController *motion_controller = gtk_event_controller_motion_new(); |
3321 GtkEventController *motion_controller = gtk_event_controller_motion_new(); |
| 3310 gtk_widget_add_controller(GTK_WIDGET(row), motion_controller); |
3322 gtk_widget_add_controller(GTK_WIDGET(row), motion_controller); |
| 3311 g_signal_connect(motion_controller, "enter", G_CALLBACK(listbox_row_enter), row); |
3323 g_signal_connect(motion_controller, "enter", G_CALLBACK(listbox_row_enter), row); |
| 3312 g_signal_connect(motion_controller, "leave", G_CALLBACK(listbox_row_leave), row); |
3324 g_signal_connect(motion_controller, "leave", G_CALLBACK(listbox_row_leave), row); |
| 3313 #else |
3325 #else |
| 3314 gtk_widget_set_events(GTK_WIDGET(row), GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
3326 row0 = gtk_event_box_new(); |
| 3315 g_signal_connect(row, "enter-notify-event", G_CALLBACK(listbox_row_enter), NULL); |
3327 LISTBOX_ROW_SET_CHILD(row, row0); |
| 3316 g_signal_connect(row, "leave-notify-event", G_CALLBACK(listbox_row_leave), NULL); |
3328 gtk_widget_set_events(row0, GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
| |
3329 g_signal_connect(row0, "enter-notify-event", G_CALLBACK(listbox_row_enter), NULL); |
| |
3330 g_signal_connect(row0, "leave-notify-event", G_CALLBACK(listbox_row_leave), NULL); |
| 3317 #endif |
3331 #endif |
| 3318 |
3332 |
| 3319 gtk_list_box_insert(listbox->listbox, row, -1); |
3333 gtk_list_box_insert(listbox->listbox, row, -1); |
| 3320 UiListBox2Row row_data = {0}; |
3334 UiListBox2Row row_data = {0}; |
| 3321 row_data.listbox = listbox; |
3335 row_data.listbox = listbox; |
| 3322 row_data.row = row; |
3336 row_data.row = row; |
| 3323 row_data.index = index; |
3337 row_data.index = index; |
| 3324 row_data.depth = item.depth; |
3338 row_data.depth = item.depth; |
| 3325 cxListAdd(listbox->rows, &row_data); |
3339 cxListAdd(listbox->rows, &row_data); |
| 3326 UiListBox2Row *row_data_ptr = cxListLast(listbox->rows); |
3340 UiListBox2Row *row_data_ptr = cxListLast(listbox->rows); |
| 3327 listbox2_update_item(row_data_ptr, row, &item, item.depth - (item.depth > 0 ? heading : 0)); |
3341 listbox2_update_item(row_data_ptr, row0, &item, item.depth - (item.depth > 0 ? heading : 0)); |
| 3328 |
3342 |
| 3329 if(item.depth >= stack_size) { |
3343 if(item.depth >= stack_size) { |
| 3330 stack_size += 8; |
3344 stack_size += 8; |
| 3331 stack = realloc(stack, stack_size * sizeof(UiListBox2Row*)); |
3345 stack = realloc(stack, stack_size * sizeof(UiListBox2Row*)); |
| 3332 } |
3346 } |