tui: tweak NmtEditorGrid column rules
If an NmtEditorGrid row has a widget, but no label, then we make the widget span both the label and widget columns. But previously we weren't doing the same for rows with labels but no widgets. (In fact, we didn't even allow rows with no widgets; label-only rows had to specify dummy widgets.) Fix it so that labels will span into an empty widget column. (This ensures that a long section name won't force the entire grid to have an overwide label column). Also, in both the "no label" and "no widget" cases, still show the "extra" column if it's present.
This commit is contained in:
@@ -101,20 +101,17 @@ nmt_editor_grid_finalize (GObject *object)
|
||||
* nmt_editor_grid_append:
|
||||
* @grid: the #NmtEditorGrid
|
||||
* @label: (allow-none): the label text for @widget, or %NULL
|
||||
* @widget: the (main) widget
|
||||
* @widget: (allow-none): the (main) widget
|
||||
* @extra: (allow-none): optional extra widget
|
||||
*
|
||||
* Adds a row to @grid.
|
||||
*
|
||||
* If @label is non-%NULL, this will add a three-column row,
|
||||
* containing a right-aligned #NmtNewtLabel in the first column,
|
||||
* @widget in the second column, and @extra (if non-%NULL) in
|
||||
* the third column.
|
||||
* If @label and @widget are both non-%NULL, this will add a three-column row,
|
||||
* containing a right-aligned #NmtNewtLabel in the first column, @widget in the
|
||||
* second column, and @extra (if non-%NULL) in the third column.
|
||||
*
|
||||
* If @label is %NULL, then this will add a row with a single
|
||||
* grid-spanning column, containing @widget.
|
||||
*
|
||||
* FIXME: That's sort of weird.
|
||||
* If either @label or @widget is %NULL, then the other column will expand into
|
||||
* it.
|
||||
*
|
||||
* See also nmt_editor_grid_set_row_flags().
|
||||
*/
|
||||
@@ -129,8 +126,15 @@ nmt_editor_grid_append (NmtEditorGrid *grid,
|
||||
NmtNewtContainer *container = NMT_NEWT_CONTAINER (grid);
|
||||
NmtEditorGridRow row;
|
||||
|
||||
g_return_if_fail (label != NULL || widget != NULL);
|
||||
|
||||
memset (&row, 0, sizeof (row));
|
||||
|
||||
if (label && !widget) {
|
||||
widget = nmt_newt_label_new (label);
|
||||
label = NULL;
|
||||
}
|
||||
|
||||
if (label) {
|
||||
row.label = nmt_newt_label_new (label);
|
||||
parent_class->add (container, row.label);
|
||||
@@ -408,6 +412,14 @@ nmt_editor_grid_size_allocate (NmtNewtWidget *widget,
|
||||
y + row,
|
||||
col1_width,
|
||||
priv->row_heights[i]);
|
||||
} else {
|
||||
nmt_newt_widget_size_allocate (rows[i].widget,
|
||||
x,
|
||||
y + row,
|
||||
col0_width + col1_width + 1,
|
||||
priv->row_heights[i]);
|
||||
}
|
||||
|
||||
if (rows[i].extra) {
|
||||
int wwidth, wheight, ex;
|
||||
|
||||
@@ -424,13 +436,6 @@ nmt_editor_grid_size_allocate (NmtNewtWidget *widget,
|
||||
col2_width,
|
||||
priv->row_heights[i]);
|
||||
}
|
||||
} else {
|
||||
nmt_newt_widget_size_allocate (rows[i].widget,
|
||||
x,
|
||||
y + row,
|
||||
col0_width + col1_width + col2_width + 2,
|
||||
priv->row_heights[i]);
|
||||
}
|
||||
|
||||
row += priv->row_heights[i];
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ rebuild_header (NmtEditorSection *section)
|
||||
|
||||
nmt_editor_grid_append (priv->header,
|
||||
priv->title,
|
||||
priv->header_widget ? priv->header_widget : nmt_newt_separator_new (),
|
||||
priv->header_widget,
|
||||
priv->toggle);
|
||||
nmt_editor_grid_set_row_flags (priv->header,
|
||||
priv->toggle,
|
||||
|
Reference in New Issue
Block a user