Deduplicated the default text column parameters across platforms.

This commit is contained in:
Pietro Gagliardi 2018-06-24 00:45:54 -04:00
parent 9b340ed40c
commit 4dbf1994a6
5 changed files with 19 additions and 24 deletions

View File

@ -11,6 +11,7 @@ extern uiTableValueType uiprivTableModelColumnType(uiTableModel *m, int column);
extern int uiprivTableModelNumRows(uiTableModel *m); extern int uiprivTableModelNumRows(uiTableModel *m);
extern uiTableValue *uiprivTableModelCellValue(uiTableModel *m, int row, int column); extern uiTableValue *uiprivTableModelCellValue(uiTableModel *m, int row, int column);
extern void uiprivTableModelSetCellValue(uiTableModel *m, int row, int column, const uiTableValue *value); extern void uiprivTableModelSetCellValue(uiTableModel *m, int row, int column, const uiTableValue *value);
extern const uiTableTextColumnOptionalParams uiprivDefaultTextColumnOptionalParams;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -42,3 +42,7 @@ void uiprivTableModelSetCellValue(uiTableModel *m, int row, int column, const ui
mh = uiprivTableModelHandler(m); mh = uiprivTableModelHandler(m);
(*(mh->SetCellValue))(mh, m, row, column, value); (*(mh->SetCellValue))(mh, m, row, column, value);
} }
const uiTableTextColumnOptionalParams uiprivDefaultTextColumnOptionalParams = {
.ColorModelColumn = -1,
};

View File

@ -51,10 +51,6 @@ static BOOL isCellEditable(uiTableModel *m, NSInteger row, int modelColumn)
return editable != 0; return editable != 0;
} }
static uiTableTextColumnOptionalParams defaultTextColumnOptionalParams = {
.ColorModelColumn = -1,
};
struct textColumnCreateParams { struct textColumnCreateParams {
uiTable *t; uiTable *t;
uiTableModel *m; uiTableModel *m;
@ -623,9 +619,10 @@ void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn,
p.makeTextField = YES; p.makeTextField = YES;
p.textModelColumn = textModelColumn; p.textModelColumn = textModelColumn;
p.textEditableColumn = textEditableModelColumn; p.textEditableColumn = textEditableModelColumn;
if (params == NULL) if (params != NULL)
params = &defaultTextColumnOptionalParams;
p.textParams = *params; p.textParams = *params;
else
p.textParams = uiprivDefaultTextColumnOptionalParams;
str = [NSString stringWithUTF8String:name]; str = [NSString stringWithUTF8String:name];
col = [[uiprivTextImageCheckboxTableColumn alloc] initWithIdentifier:str params:&p]; col = [[uiprivTextImageCheckboxTableColumn alloc] initWithIdentifier:str params:&p];
@ -665,9 +662,10 @@ void uiTableAppendImageTextColumn(uiTable *t, const char *name, int imageModelCo
p.makeTextField = YES; p.makeTextField = YES;
p.textModelColumn = textModelColumn; p.textModelColumn = textModelColumn;
p.textEditableColumn = textEditableModelColumn; p.textEditableColumn = textEditableModelColumn;
if (textParams == NULL) if (textParams != NULL)
textParams = &defaultTextColumnOptionalParams;
p.textParams = *textParams; p.textParams = *textParams;
else
p.textParams = uiprivDefaultTextColumnOptionalParams;
p.makeImage = YES; p.makeImage = YES;
p.imageModelColumn = imageModelColumn; p.imageModelColumn = imageModelColumn;
@ -711,9 +709,10 @@ void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxM
p.makeTextField = YES; p.makeTextField = YES;
p.textModelColumn = textModelColumn; p.textModelColumn = textModelColumn;
p.textEditableColumn = textEditableModelColumn; p.textEditableColumn = textEditableModelColumn;
if (textParams == NULL) if (textParams != NULL)
textParams = &defaultTextColumnOptionalParams;
p.textParams = *textParams; p.textParams = *textParams;
else
p.textParams = uiprivDefaultTextColumnOptionalParams;
p.makeCheckbox = YES; p.makeCheckbox = YES;
p.checkboxModelColumn = checkboxModelColumn; p.checkboxModelColumn = checkboxModelColumn;

View File

@ -87,11 +87,6 @@ static void onEdited(uiTableModel *m, int column, const char *pathstr, const uiT
uiprivTableModelSetCellValue(m, row, column, tvalue); uiprivTableModelSetCellValue(m, row, column, tvalue);
} }
// TODO deduplicate this between platforms
static uiTableTextColumnOptionalParams defaultTextColumnOptionalParams = {
.ColorModelColumn = -1,
};
struct textColumnParams { struct textColumnParams {
uiTable *t; uiTable *t;
uiTableModel *m; uiTableModel *m;
@ -282,7 +277,7 @@ static void addTextColumn(uiTable *t, GtkTreeViewColumn *c, int textModelColumn,
if (params != NULL) if (params != NULL)
p->params = *params; p->params = *params;
else else
p->params = defaultTextColumnOptionalParams; p->params = uiprivDefaultTextColumnOptionalParams;
r = gtk_cell_renderer_text_new(); r = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(c, r, TRUE); gtk_tree_view_column_pack_start(c, r, TRUE);

View File

@ -7,10 +7,6 @@
// - implement keyboard accessibility // - implement keyboard accessibility
// - implement accessibility in general (Dynamic Annotations maybe?) // - implement accessibility in general (Dynamic Annotations maybe?)
static uiTableTextColumnOptionalParams defaultTextColumnOptionalParams = {
/*TODO.ColorModelColumn = */-1,
};
uiTableModel *uiNewTableModel(uiTableModelHandler *mh) uiTableModel *uiNewTableModel(uiTableModelHandler *mh)
{ {
uiTableModel *m; uiTableModel *m;
@ -401,7 +397,7 @@ static uiprivTableColumnParams *appendColumn(uiTable *t, const char *name, int c
p = uiprivNew(uiprivTableColumnParams); p = uiprivNew(uiprivTableColumnParams);
p->textModelColumn = -1; p->textModelColumn = -1;
p->textEditableColumn = -1; p->textEditableColumn = -1;
p->textParams = defaultTextColumnOptionalParams; p->textParams = uiprivDefaultTextColumnOptionalParams;
p->imageModelColumn = -1; p->imageModelColumn = -1;
p->checkboxModelColumn = -1; p->checkboxModelColumn = -1;
p->checkboxEditableColumn = -1; p->checkboxEditableColumn = -1;