ui/gtk/list.c

changeset 118
6d0da97105d8
parent 117
b174e721663e
equal deleted inserted replaced
117:b174e721663e 118:6d0da97105d8
1019 for(int i=0;i<model->columns;i++,c++) { 1019 for(int i=0;i<model->columns;i++,c++) {
1020 UiBool freevalue = FALSE; 1020 UiBool freevalue = FALSE;
1021 void *data = listview->getvalue(list, elm, row, c, listview->getvaluedata, &freevalue); 1021 void *data = listview->getvalue(list, elm, row, c, listview->getvaluedata, &freevalue);
1022 1022
1023 UiModelType type = model->types[i]; 1023 UiModelType type = model->types[i];
1024 1024 UiTextStyle cstyle = { 0, 0 };
1025 if(getstyle) { 1025 if(getstyle) {
1026 // in case the column is icon+text, only get a style for the text column 1026 // in case the column is icon+text, only get a style for the text column
1027 int style_col = c; 1027 int style_col = c;
1028 if(type == UI_ICON_TEXT || type == UI_ICON_TEXT_FREE) { 1028 if(type == UI_ICON_TEXT || type == UI_ICON_TEXT_FREE) {
1029 style_col++; 1029 style_col++;
1030 } 1030 }
1031 1031
1032 // Get the individual column style 1032 // Get the individual column style
1033 // The column style overrides the row style, however if no column style 1033 // The column style overrides the row style, however if no column style
1034 // is provided, we stick with the row style 1034 // is provided, we stick with the row style
1035 if(getstyle(list, elm, row, style_col, listview->getstyledata, &style)) { 1035 if(getstyle(list, elm, row, style_col, listview->getstyledata, &cstyle)) {
1036 style_set = TRUE; 1036 style_set = TRUE;
1037 cstyle.text_style |= style.text_style;
1038 if(!cstyle.fg_set) {
1039 cstyle.fg_set = style.fg_set;
1040 cstyle.fg = style.fg;
1041 }
1042 } else {
1043 cstyle = style;
1037 } 1044 }
1038 } 1045 }
1039 1046
1040 GValue value = G_VALUE_INIT; 1047 GValue value = G_VALUE_INIT;
1041 switch(type) { 1048 switch(type) {
1137 g_value_set_boolean(&style_set_value, TRUE); 1144 g_value_set_boolean(&style_set_value, TRUE);
1138 gtk_list_store_set_value(store, iter, soff, &style_set_value); 1145 gtk_list_store_set_value(store, iter, soff, &style_set_value);
1139 1146
1140 GValue style_weight_value = G_VALUE_INIT; 1147 GValue style_weight_value = G_VALUE_INIT;
1141 g_value_init(&style_weight_value, G_TYPE_INT); 1148 g_value_init(&style_weight_value, G_TYPE_INT);
1142 if(style.text_style & UI_TEXT_STYLE_BOLD) { 1149 if(cstyle.text_style & UI_TEXT_STYLE_BOLD) {
1143 g_value_set_int(&style_weight_value, 600); 1150 g_value_set_int(&style_weight_value, 600);
1144 } else { 1151 } else {
1145 g_value_set_int(&style_weight_value, 400); 1152 g_value_set_int(&style_weight_value, 400);
1146 } 1153 }
1147 gtk_list_store_set_value(store, iter, soff + 1, &style_weight_value); 1154 gtk_list_store_set_value(store, iter, soff + 1, &style_weight_value);
1148 1155
1149 GValue style_underline_value = G_VALUE_INIT; 1156 GValue style_underline_value = G_VALUE_INIT;
1150 g_value_init(&style_underline_value, G_TYPE_INT); 1157 g_value_init(&style_underline_value, G_TYPE_INT);
1151 if(style.text_style & UI_TEXT_STYLE_UNDERLINE) { 1158 if(cstyle.text_style & UI_TEXT_STYLE_UNDERLINE) {
1152 g_value_set_int(&style_underline_value, PANGO_UNDERLINE_SINGLE); 1159 g_value_set_int(&style_underline_value, PANGO_UNDERLINE_SINGLE);
1153 } else { 1160 } else {
1154 g_value_set_int(&style_underline_value, PANGO_UNDERLINE_NONE); 1161 g_value_set_int(&style_underline_value, PANGO_UNDERLINE_NONE);
1155 } 1162 }
1156 gtk_list_store_set_value(store, iter, soff + 2, &style_underline_value); 1163 gtk_list_store_set_value(store, iter, soff + 2, &style_underline_value);
1157 1164
1158 GValue style_italic_value = G_VALUE_INIT; 1165 GValue style_italic_value = G_VALUE_INIT;
1159 g_value_init(&style_italic_value, G_TYPE_INT); 1166 g_value_init(&style_italic_value, G_TYPE_INT);
1160 if(style.text_style & UI_TEXT_STYLE_ITALIC) { 1167 if(cstyle.text_style & UI_TEXT_STYLE_ITALIC) {
1161 g_value_set_int(&style_italic_value, PANGO_STYLE_ITALIC); 1168 g_value_set_int(&style_italic_value, PANGO_STYLE_ITALIC);
1162 } else { 1169 } else {
1163 g_value_set_int(&style_italic_value, PANGO_STYLE_NORMAL); 1170 g_value_set_int(&style_italic_value, PANGO_STYLE_NORMAL);
1164 } 1171 }
1165 gtk_list_store_set_value(store, iter, soff + 3, &style_italic_value); 1172 gtk_list_store_set_value(store, iter, soff + 3, &style_italic_value);
1166 1173
1167 GValue style_fgset_value = G_VALUE_INIT; 1174 GValue style_fgset_value = G_VALUE_INIT;
1168 g_value_init(&style_fgset_value, G_TYPE_BOOLEAN); 1175 g_value_init(&style_fgset_value, G_TYPE_BOOLEAN);
1169 g_value_set_boolean(&style_fgset_value, style.fg_set); 1176 g_value_set_boolean(&style_fgset_value, cstyle.fg_set);
1170 gtk_list_store_set_value(store, iter, soff + 4, &style_fgset_value); 1177 gtk_list_store_set_value(store, iter, soff + 4, &style_fgset_value);
1171 1178
1172 if(style.fg_set) { 1179 if(cstyle.fg_set) {
1173 char buf[8]; 1180 char buf[8];
1174 snprintf(buf, 8, "#%02X%02X%02X", (int)style.fg.red, (int)style.fg.green, (int)style.fg.blue); 1181 snprintf(buf, 8, "#%02X%02X%02X", (int)cstyle.fg.red, (int)cstyle.fg.green, (int)cstyle.fg.blue);
1175 1182
1176 GValue style_fg_value = G_VALUE_INIT; 1183 GValue style_fg_value = G_VALUE_INIT;
1177 g_value_init(&style_fg_value, G_TYPE_STRING); 1184 g_value_init(&style_fg_value, G_TYPE_STRING);
1178 g_value_set_string(&style_fg_value, buf); 1185 g_value_set_string(&style_fg_value, buf);
1179 gtk_list_store_set_value(store, iter, soff + 5, &style_fg_value); 1186 gtk_list_store_set_value(store, iter, soff + 5, &style_fg_value);
2487 if(data->customdata3) { 2494 if(data->customdata3) {
2488 uic_set_tmp_eventdata(eventdata, UI_EVENT_DATA_SUBLIST); 2495 uic_set_tmp_eventdata(eventdata, UI_EVENT_DATA_SUBLIST);
2489 2496
2490 UIMENU menu = data->customdata3; 2497 UIMENU menu = data->customdata3;
2491 g_object_set_data(G_OBJECT(button), "ui-button-popup", menu); 2498 g_object_set_data(G_OBJECT(button), "ui-button-popup", menu);
2499 #if GTK_CHECK_VERSION(4, 0, 0)
2492 gtk_popover_popup(GTK_POPOVER(menu)); 2500 gtk_popover_popup(GTK_POPOVER(menu));
2501 #else
2502 ui_contextmenu_popup(menu, button, 0, 0);
2503 #endif
2493 } 2504 }
2494 } 2505 }
2495 2506
2496 #if GTK_CHECK_VERSION(4, 0, 0) 2507 #if GTK_CHECK_VERSION(4, 0, 0)
2497 static void button_popover_closed(GtkPopover *popover, GtkWidget *button) { 2508 static void button_popover_closed(GtkPopover *popover, GtkWidget *button) {
2579 "clicked", 2590 "clicked",
2580 G_CALLBACK(listbox_button_clicked), 2591 G_CALLBACK(listbox_button_clicked),
2581 event 2592 event
2582 ); 2593 );
2583 gtk_widget_set_visible(button, FALSE); 2594 gtk_widget_set_visible(button, FALSE);
2595 WIDGET_NO_SHOW_ALL(button);
2584 2596
2585 g_object_set_data(G_OBJECT(row), "ui-listbox-row-button", button); 2597 g_object_set_data(G_OBJECT(row), "ui-listbox-row-button", button);
2586 2598
2587 // menu 2599 // menu
2588 if(item->button_menu) { 2600 if(item->button_menu) {
2618 } 2630 }
2619 2631
2620 LISTBOX_ROW_REMOVE_CHILD(row); 2632 LISTBOX_ROW_REMOVE_CHILD(row);
2621 2633
2622 listbox_fill_row(listbox, GTK_WIDGET(row), sublist, &item, index); 2634 listbox_fill_row(listbox, GTK_WIDGET(row), sublist, &item, index);
2635 LISTBOX_ROW_SHOW(row);
2623 2636
2624 // cleanup 2637 // cleanup
2625 free(item.label); 2638 free(item.label);
2626 free(item.icon); 2639 free(item.icon);
2627 free(item.button_label); 2640 free(item.button_label);
2754 g_signal_connect(row, "enter-notify-event", G_CALLBACK(listbox_row_enter), NULL); 2767 g_signal_connect(row, "enter-notify-event", G_CALLBACK(listbox_row_enter), NULL);
2755 g_signal_connect(row, "leave-notify-event", G_CALLBACK(listbox_row_leave), NULL); 2768 g_signal_connect(row, "leave-notify-event", G_CALLBACK(listbox_row_leave), NULL);
2756 #endif 2769 #endif
2757 2770
2758 listbox_fill_row(listbox, row, sublist, &item, index); 2771 listbox_fill_row(listbox, row, sublist, &item, index);
2772 LISTBOX_ROW_SHOW(row);
2759 if(index == first_index) { 2773 if(index == first_index) {
2760 // first row in the sublist, set ui_listbox data to the row 2774 // first row in the sublist, set ui_listbox data to the row
2761 // which is then used by the headerfunc 2775 // which is then used by the headerfunc
2762 g_object_set_data(G_OBJECT(row), "ui_listbox", listbox); 2776 g_object_set_data(G_OBJECT(row), "ui_listbox", listbox);
2763 g_object_set_data(G_OBJECT(row), "ui_listbox_sublist", sublist); 2777 g_object_set_data(G_OBJECT(row), "ui_listbox_sublist", sublist);

mercurial