def _GetViewSpecs(view_args, width_per_col, grid_width, col_width=None):
  """Convert a single view into its JSON specifications.

  Args:
    view_args: A tuple of (title, widgets[, properties]).
    width_per_col: The width for each column.
    grid_width: The width of the canvas (in CSS style).
    col_width: The pre-determined width of the view
        (in units defined by layout._DESIRED_VIEW_COLS).

  Returns:
    A dict with parameters describing the view.
  """

  if len(view_args) == 2:
    title, widgets = view_args
    properties = {}
  else:
    assert len(view_args) == 3
    title, widgets, properties = view_args
  view = {
      'name': title,
      'cols': 1,  # By default, each view occupies one column.
      'indicators': []
  }
  view.update(properties)
  if col_width:
    view['cols'] = col_width
  view['grid_width'] = view['cols'] * width_per_col

  for widget in widgets:
    # Note that each grid cell is logically split into a finer grid.
    # Let each widget span horizontally across the entire view.
    widget.SetCols(grid_width)
    view['indicators'] += widget.Indicators()
  return view