Sun, 27 Oct 2024 10:22:19 +0100
add support for groups/states to text, list widgets (GTK)
ui/gtk/entry.c | file | annotate | diff | comparison | revisions | |
ui/gtk/list.c | file | annotate | diff | comparison | revisions | |
ui/gtk/text.c | file | annotate | diff | comparison | revisions | |
ui/ui/text.h | file | annotate | diff | comparison | revisions | |
ui/ui/tree.h | file | annotate | diff | comparison | revisions |
--- a/ui/gtk/entry.c Sun Oct 27 09:38:21 2024 +0100 +++ b/ui/gtk/entry.c Sun Oct 27 10:22:19 2024 +0100 @@ -71,6 +71,7 @@ #endif GtkWidget *spin = gtk_spin_button_new_with_range(min, max, args.step); ui_set_name_and_style(spin, args.name, args.style_class); + ui_set_widget_groups(obj->ctx, spin, args.groups); gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), args.digits); UiObserver **obs = NULL; if(var) {
--- a/ui/gtk/list.c Sun Oct 27 09:38:21 2024 +0100 +++ b/ui/gtk/list.c Sun Oct 27 10:22:19 2024 +0100 @@ -162,6 +162,8 @@ // create treeview GtkWidget *view = gtk_tree_view_new(); + ui_set_name_and_style(view, args.name, args.style_class); + ui_set_widget_groups(obj->ctx, view, args.groups); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(NULL, renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); @@ -589,6 +591,8 @@ UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); GtkWidget *combobox = ui_create_combobox(obj, model, var, args.onactivate, args.onactivatedata); + ui_set_name_and_style(combobox, args.name, args.style_class); + ui_set_widget_groups(obj->ctx, combobox, args.groups); UI_APPLY_LAYOUT1(current, args); current->container->add(current->container, combobox, FALSE); current->container->current = combobox; @@ -597,7 +601,7 @@ GtkWidget* ui_create_combobox(UiObject *obj, UiModel *model, UiVar *var, ui_callback f, void *udata) { GtkWidget *combobox = gtk_combo_box_new(); - + UiListView *uicbox = malloc(sizeof(UiListView)); uicbox->obj = obj; uicbox->widget = combobox;
--- a/ui/gtk/text.c Sun Oct 27 09:38:21 2024 +0100 +++ b/ui/gtk/text.c Sun Oct 27 10:22:19 2024 +0100 @@ -68,6 +68,7 @@ GtkWidget *text_area = gtk_text_view_new(); ui_set_name_and_style(text_area, args.name, args.style_class); + ui_set_widget_groups(obj->ctx, text_area, args.groups); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_area), GTK_WRAP_WORD_CHAR); g_signal_connect( @@ -529,6 +530,7 @@ static UIWIDGET create_textfield(UiObject *obj, UiBool frameless, UiBool password, UiTextFieldArgs args) { GtkWidget *textfield = gtk_entry_new(); ui_set_name_and_style(textfield, args.name, args.style_class); + ui_set_widget_groups(obj->ctx, textfield, args.groups); UiObject* current = uic_current_obj(obj); UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING);
--- a/ui/ui/text.h Sun Oct 27 09:38:21 2024 +0100 +++ b/ui/ui/text.h Sun Oct 27 10:22:19 2024 +0100 @@ -49,6 +49,8 @@ const char *varname; ui_callback onchange; void *onchangedata; + + const int *groups; } UiTextAreaArgs; typedef struct UiTextFieldArgs { @@ -65,6 +67,8 @@ const char *varname; ui_callback onchange; void *onchangedata; + + const int *groups; } UiTextFieldArgs; typedef struct UiPathElmRet {
--- a/ui/ui/tree.h Sun Oct 27 09:38:21 2024 +0100 +++ b/ui/ui/tree.h Sun Oct 27 10:22:19 2024 +0100 @@ -105,6 +105,8 @@ UiBool vexpand; int colspan; int rowspan; + const char *name; + const char *style_class; UiList* list; const char* varname; @@ -121,6 +123,8 @@ ui_callback ondrop; void* ondropsdata; UiBool multiselection; + + const int *groups; }; UIEXPORT UiModel* ui_model(UiContext *ctx, ...);