summaryrefslogtreecommitdiff
path: root/clients/tui
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-09-24 17:00:50 -0400
committerDan Winship <danw@redhat.com>2014-11-21 09:01:01 -0500
commit04ef74b16f75d285940463919ff6bd65fb170fba (patch)
tree08e57a2810d465c93826a9255adb99d266de4f0d /clients/tui
parent5f6b0be525d2d61fae207a4d5be79c44d396b412 (diff)
downloadNetworkManager-04ef74b16f75d285940463919ff6bd65fb170fba.tar.gz
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.
Diffstat (limited to 'clients/tui')
-rw-r--r--clients/tui/nmt-editor-grid.c57
-rw-r--r--clients/tui/nmt-editor-section.c2
2 files changed, 32 insertions, 27 deletions
diff --git a/clients/tui/nmt-editor-grid.c b/clients/tui/nmt-editor-grid.c
index 7fb2f6bf1d..118bf01d3a 100644
--- a/clients/tui/nmt-editor-grid.c
+++ b/clients/tui/nmt-editor-grid.c
@@ -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,27 +412,28 @@ nmt_editor_grid_size_allocate (NmtNewtWidget *widget,
y + row,
col1_width,
priv->row_heights[i]);
- if (rows[i].extra) {
- int wwidth, wheight, ex;
-
- if (rows[i].flags & NMT_EDITOR_GRID_ROW_EXTRA_ALIGN_RIGHT)
- ex = x + col0_width + col1_width + 2;
- else {
- nmt_newt_widget_size_request (rows[i].widget, &wwidth, &wheight);
- ex = x + col0_width + wwidth + 2;
- }
-
- nmt_newt_widget_size_allocate (rows[i].extra,
- ex,
- y + row,
- 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,
+ col0_width + col1_width + 1,
+ priv->row_heights[i]);
+ }
+
+ if (rows[i].extra) {
+ int wwidth, wheight, ex;
+
+ if (rows[i].flags & NMT_EDITOR_GRID_ROW_EXTRA_ALIGN_RIGHT)
+ ex = x + col0_width + col1_width + 2;
+ else {
+ nmt_newt_widget_size_request (rows[i].widget, &wwidth, &wheight);
+ ex = x + col0_width + wwidth + 2;
+ }
+
+ nmt_newt_widget_size_allocate (rows[i].extra,
+ ex,
+ y + row,
+ col2_width,
priv->row_heights[i]);
}
diff --git a/clients/tui/nmt-editor-section.c b/clients/tui/nmt-editor-section.c
index 9d892cc521..ad970a90d7 100644
--- a/clients/tui/nmt-editor-section.c
+++ b/clients/tui/nmt-editor-section.c
@@ -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,